perl5-dbi/dbi

dbh->commit return value lost when run in perl debugger

jkahrman opened this issue · 0 comments

When in the debugger and DBD::mysql and DBD::MariaDB connections, calls to dbh->commit return undef even when the commit succeeds.

This behavior started occurring with our update to DBI v1.642. Prior to that, when using v1.633, we experienced the bug described in https://rt.cpan.org/Public/Bug/Display.html?id=102791 instead whenever the code was run in the debugger.

Based on my reading of the XS code, this XS doc, and my experiments, I think that while 71802a1 got rid of the memory access error, the return value still isn't always being maintained properly. Localizing the stack pointer (using the dSP macro) before manipulating the call stack and calling STORE to reset AutoCommit appears to resolve the issue.

dbi/DBI.xs

Lines 3925 to 3931 in ea91ab4

/* and may mess up the error handling below for the commit/rollback */
PUSHMARK(SP);
XPUSHs(h);
XPUSHs(sv_2mortal(newSVpv("AutoCommit",0)));
XPUSHs(&PL_sv_yes);
PUTBACK;
call_method("STORE", G_VOID);

However, I've not well versed in XS. I'm not confident that this is a proper/complete fix.