Re: Placeholders for profiling?

[email protected] (Chris Nehren)
Newsgroups perl.dbi.users
Message-ID <[email protected]>
On Wed, Feb 10, 2010 at 10:40:21 +0000 , Tim Bunce wrote:
> On Tue, Feb 09, 2010 at 01:57:40PM -0500, Chris Nehren wrote:
> > Hey, all.
> >
> > We've got a situation where we need to get the placeholders used for
> > statements when doing profiling. I've RTFM'd and RTFS'd and not
> > found
> > any leads. What do I need to poke to get this information?
>
> "get the placeholders"? Do you mean _include_ the current placeholder
> _values_ in the profile 'Path'?

Yes.

> As Greg said, the placeholder values are in $h->{ParamValues}
> (if your driver supports that attribute).
>
> The magic ingredient you need for DBI::Profile is the knowledge that
> the
> Path can contain code refs:
> http://search.cpan.org/~timb/DBI-1.609/lib/DBI/Profile.pm#Code_Reference
>
> So you might, for example, use a Path like this (untested):
>
>     $h->{Profile}{Path} = [
>         '!Statement',
>         sub { my $p = shift->{ParamValues}||{}; return %$p }
>     ];
>
> Other variations on that sub might include:
>
>     sub { my $p = shift->{ParamValues}||{}; return join ",", %$p }
>     sub { my $p = shift->{ParamValues}||{}; return values %$p }
>     sub { my $p = shift->{ParamValues}||{}; my @n=keys %$p; return
>     @{$p}{sort @n} }
>     sub { my $p = shift->{ParamValues}||{}; sort map { "$_=$p->{$_}"}
>     keys %p }
>
> Experiment. Let us know how it works out.

Will do. Thanks for providing a starting point. I'm sure it'll save me a
good deal of time.

> p.s. The slides for DBI::Profile in the Advanced DBI Tutorial (2004)
> on CPAN
> are out of date
> http://cpansearch.perl.org/src/TIMB/DBI_AdvancedTalk_2004/sld022.htm
> I gave a talk at the Italian Perl Workshop on DBI::Profile.
> I've uploaded the screencast to http://blip.tv/file/3199117

Noted, will take a look at the screencast too.

-- 
Thanks and best regards,
Chris Nehren
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.