Fix annoying warnings on innocent looking MSSQL code
authorPeter Rabbitson <ribasushi@cpan.org>
Fri, 1 Apr 2016 10:19:51 +0000 (12:19 +0200)
committerPeter Rabbitson <ribasushi@cpan.org>
Fri, 1 Apr 2016 11:23:00 +0000 (13:23 +0200)
commitd3a2e424976a449718ad750b72d4bf3acf689caf
treee42b5a3fd13b00cd2f63f2fa65c5aaa04f8b1bf9
parent23b72652ee1dc2896630cd16a3ead96de1bc8772
Fix annoying warnings on innocent looking MSSQL code

After several rounds of improvements in the retry logic (84efb6d7, 729656c5)
MSSQL code non-fatally aborting due to clashing multiple active resultsets
would emit an annoying warning. Such warnings are especially baffling when
encountered in innocent-looking code like:

   my $first_bar_of_first_foo = $schema->resultset('Foo')
                                        ->search({ foo => 'fa' })
                                         ->next
                                          ->related_resultset("bar")
                                           ->next;

Since no object destruction takes place until the = operator is executed, the
cursor returning "first foo matching fa" is still active when we run a second
search for the "bars". With default MSSQL settings (i.e. without an enabled
MARS[1] implementation) this leads to an exception on the second ->next().
The failed next() is properly retried, since we are not in transaction or some
similar complicating factor, and the entire thing executes correctly, except
the force-disconnect-before-reconnect-after-failed-ping warns about the first
cursor being still alive.

Add extra stack marker for this particular case, and teach the MSSQL driver to
hide the (at this stage spurious) warning

[1] http://p3rl.org/DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server#MULTIPLE-ACTIVE-STATEMENTS
Changes
lib/DBIx/Class/Storage/BlockRunner.pm
lib/DBIx/Class/Storage/DBI/MSSQL.pm
t/746mssql.t