Re: debugging and stepping into ->do

[email protected] ("Martin J. Evans" via dbi-users) Wed, 25 Apr 2018 16:17:02 +0100
Newsgroups perl.dbi.users
Message-ID <[email protected]>
On 25/04/18 16:13, Jeff Macdonald wrote:
> Hi,
>
> When using DBD::mysql, I can step into the prepare and execute methods of DBD, but I can't step into do (execution is the next code line after the do statement). 'do' is defined in DBI.pm this way:
>
>      sub do {
> 	my($dbh, $statement, $attr, @params) = @_;
> 	my $sth = $dbh->prepare($statement, $attr) or return undef;
> 	$sth->execute(@params) or return undef;
> 	my $rows = $sth->rows;
> 	($rows == 0) ? "0E0" : $rows;
>      }
>
> Based on this, if I were to put a breakpoint on execute, I should be able to see 'do' statements via execute, but I don't. For example:
>
> $dbh->do('insert into foo (a, b) values (1,2)')
>
> should cause the execute method to be called, but that does not seem to be the case. Is 'do' in DBI/DBD calling some magic method?
> -- 
> Jeff Macdonald
> Ayer, MA

do may be implemented by the driver in XS (c code) in which case you would not be able to step into it. Drivers can override the DBI methods.

Martin