Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How to report call stack for DBI queries

by perlplexer (Hermit)
on Apr 17, 2003 at 18:36 UTC ( [id://251286]=note: print w/replies, xml ) Need Help??


in reply to How to report call stack for DBI queries

The proxy approach should work. Try creating a class using DBI as the base class. Then re-define the methods that you're interested in; e.g.,
------- MyDBI.pm ------- package MyDBI; use DBI; @ISA = qw(DBI); sub execute{ print "DBI::execute() called with ".join(',', @_)."\n"; $_[0]->SUPER::execute(@_); } # other methods here ------- MyDBI.pm -------
The only "problem" with this is that the code that you're trying to debug needs to "use MyDBI;" and not "use DBI;".
There's also a problem with things like "my $dbh = DBI->new(foo);" since they need to be changed to "my $dbh = MyDBI->new(foo);". There may be a workaround for this but I'm not that good with Perl OOP.

--perlplexer

Replies are listed 'Best First'.
•Re: Re: How to report call stack for DBI queries
by merlyn (Sage) on Apr 17, 2003 at 20:23 UTC
    Proxying doesn't exactly work like that, because DBI creates objects of other classes, and your execute is defined in the wrong class.

    There's a section on "subclassing the DBI" on the DBI manpage that lists in careful detail what you have to do. Basically, you'll have to create three classes named similarly to the DBI triad, and then add your execute override to the statement-handle derived class.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Thanks for pointing that out. I was looking at, apparently, an older version of DBI docs which doesn't have any info on subclassing DBI.

      --perlplexer

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://251286]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-03-28 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found