CC: | ribasushi [...] cpan.org |
Subject: | Filtering in DBI::Profile easily causes warnings |
Date: | Wed, 23 Mar 2016 16:29:23 -0700 |
To: | bug-DBI [...] rt.cpan.org |
From: | fREW Schmidt <frioux [...] gmail.com> |
The following script with latest DBI (1.634) and latest SQLite (1.50)
warns with
Use of uninitialized value in subroutine entry at test.t line 17.
Script:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use DBI::Profile;
$DBI::Profile::ON_DESTROY_DUMP = sub{};
my $dbi_profile = DBI::Profile->new(
Path => [sub { $_[1] eq 'execute' ? ($_) : (undef) }]
);
$DBI::shared_profile = $dbi_profile;
my $dbh = DBI->connect('dbi:SQLite::memory:');
my $sth = $dbh->prepare('SELECT 1');
$sth->execute;
use Devel::Dwarn;
DwarnL $dbi_profile->as_node_path_list;
So the interesting thing is that if the value returned is undef we get
a warning, if it's 0 we get no warning, and both of them cause the
sample to be filtered. The docs say:
Show quoted text
> The sub can 'veto' (reject) a profile sample by including a
> reference to undef in the returned list.
I suspect that at the very least it would be helpful if it said:
Show quoted text> The sub can 'veto' (reject) a profile sample by including a
> reference to undef (C<\undef>) in the returned list.
as this is a very subtle detail. The fact that profiles are filtered
on undef and 0 may be a bug, but that's obv up to you guys.
Thanks!
--
fREW Schmidt
https://blog.afoolishmanifesto.com