DBIO-PostgreSQL-EV
view release on metacpan or search on metacpan
lib/DBIO/PostgreSQL/EV/TransactionContext.pm view on Meta::CPAN
# CRUD inside a transaction MUST run on the pinned connection that
# BEGIN/COMMIT ran on, not a fresh pooled one. Each method routes
# through the storage's shared CRUD builder with the pinned connection,
# so SQL generation (insert RETURNING, select_single first-row) is not
# duplicated. Forwarding to $storage->select_async etc. would acquire a
# separate pool connection and run the query OUTSIDE the transaction.
sub select_async { my $self = shift; $self->{storage}->_run_crud_pinned('select', $self->{pg}, @_) }
sub select_single_async { my $self = shift; $self->{storage}->_run_crud_pinned('select_single', $self->{pg}, @_) }
sub insert_async { my $self = shift; $self->{storage}->_run_crud_pinned('insert', $self->{pg}, @_) }
sub update_async { my $self = shift; $self->{storage}->_run_crud_pinned('update', $self->{pg}, @_) }
sub delete_async { my $self = shift; $self->{storage}->_run_crud_pinned('delete', $self->{pg}, @_) }
sub select { my $self = shift; $self->select_async(@_)->get }
sub select_single { my $self = shift; $self->select_single_async(@_)->get }
sub insert { my $self = shift; $self->insert_async(@_)->get }
sub update { my $self = shift; $self->update_async(@_)->get }
sub delete { my $self = shift; $self->delete_async(@_)->get }
# Delegations -- mirror the generic DBIO::Storage::Async::TransactionContext
# contract so a txn coderef can reach the storage's sql_maker/debug and open a
# pipeline or nested transaction from inside the pinned context.
sub sql_maker { my $self = shift; $self->{storage}->sql_maker(@_) }
sub debug { my $self = shift; $self->{storage}->debug(@_) }
sub pipeline { my $self = shift; $self->{storage}->pipeline(@_) }
sub txn_do_async { my $self = shift; $self->{storage}->txn_do_async(@_) }
( run in 1.142 second using v1.01-cache-2.11-cpan-364913b4093 )