Re: Time to Document Callbacks

"David E. Wheeler" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
On Oct 24, 2009, at 2:50 PM, Tim Bunce wrote:

> Callbacks are handled by the method dispatcher so all method names are
> valid (so don't bother trying to list them in the docs :)
>
> Plus the two special cases for connect_cached: 'connect_cached.new'  
> and
> 'connect_cached.reused'. (There's also '*' but that's not really  
> recommended.)
>
> Thanks!
>
> Tim.
>
> p.s. Might be worth skimming through the archives
> http://tinyurl.com/yl582mt

Thanks. Following up on [this post](http://markmail.org/message/fus3dfauxs6yz6sv 
), I wrote this code:

     my $dbh = DBI->connect('dbi:Pg:dbname=bric', '', '', {
         Callbacks => {
             execute => sub { print "Set in DBH\n"; return; }
         }
     });

     my $sth = $dbh->prepare('SELECT id FROM pref WHERE name = ?');
#    $sth->{Callbacks}{execute} = sub { print "Set in STH\n"; return; };
     $sth->execute('Time Zone');

It output nothing. When I uncommented that second-to-last line, it  
output "Set in STH". So it seems that a callback added to the dbh for  
a statement method name does not end up getting passed on to the  
statement handle. So I guess the Callbacks attribute is not passed on  
to statement handles created for the database handle? Seems a shame…

Best,

David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.