DBIO-MySQL-EV
view release on metacpan or search on metacpan
t/transaction-context.t view on Meta::CPAN
# Records the op and the connection it was pinned to.
sub _run_crud_pinned {
my ($self, $op, $mdb, @args) = @_;
push @{ $self->{_crud} //= [] }, { op => $op, mdb => $mdb };
return Future->done([]);
}
# These should NOT be reached by the context anymore â if they are, the
# query is escaping the transaction onto a fresh pool connection.
sub select_async { die 'select_async on storage MUST NOT be called from txn context' }
sub select_single_async { die 'select_single_async on storage MUST NOT be called from txn context' }
sub update_async { die 'update_async on storage MUST NOT be called from txn context' }
sub delete_async { die 'delete_async on storage MUST NOT be called from txn context' }
sub insert_async { die 'insert_async on storage MUST NOT be called from txn context' }
# core karr k213: the context's pipeline runs the scaffold on the PINNED txn
# connection via _pipeline_on_conn, with NO release coderef (the connection
# belongs to the transaction boundary). Record exactly what it is handed:
# every argument after the coderef, the first of which is the release slot.
# Since core karr k232 the context fills that slot with an explicit undef and
# passes a $retire coderef after it; before k232 it passed nothing there.
# core karr k218: the context asks _pipeline_refusal BEFORE touching the txn
# connection. This mock plays a transport that CAN pipeline (undef = no
t/transaction-context.t view on Meta::CPAN
return Future->done('PIPELINE_RESULT');
}
# Neither may be reached from the context any more (core karr k213): the
# storage's pipeline acquires a SECOND pool connection (batch outside the
# txn), and the storage's txn_do_async opens an INDEPENDENT transaction.
sub pipeline { push @{$_[0]->{_queries} //= []}, 'pipeline'; Future->done([]) }
sub txn_do_async { push @{$_[0]->{_queries} //= []}, 'txn_do_async'; Future->done([]) }
sub select { push @{$_[0]->{_queries} //= []}, 'select'; 'SELECT_RESULT' }
sub select_single { push @{$_[0]->{_queries} //= []}, 'select_single'; 'SELECT_SINGLE_RESULT' }
sub insert { push @{$_[0]->{_queries} //= []}, 'insert'; 'INSERT_RESULT' }
sub update { push @{$_[0]->{_queries} //= []}, 'update'; 'UPDATE_RESULT' }
sub delete { push @{$_[0]->{_queries} //= []}, 'delete'; 'DELETE_RESULT' }
}
{
package MockPoolMySQL;
sub new { bless {}, $_[0] }
sub acquire { push @{ $_[0]->{_calls} //= [] }, 'acquire'; Future->done(MockConnMySQL->new) }
sub release { push @{ $_[0]->{_calls} //= [] }, 'release'; }
}
{
# The owning sync storage core's _assert_context_active consults. Ownership
( run in 2.028 seconds using v1.01-cache-2.11-cpan-145b269f2f3 )