Skip Menu |

This queue is for tickets about the DBIx-Log4perl CPAN distribution.

Report information
The Basics
Id: 50134
Status: resolved
Priority: 0/
Queue: DBIx-Log4perl

People
Owner: Nobody in particular
Requestors: DavidG [...] airg.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.16



Subject: identifier quote wrong
Date: Wed, 30 Sep 2009 15:15:18 -0700
To: "bug-DBIx-Log4perl [...] rt.cpan.org" <bug-DBIx-Log4perl [...] rt.cpan.org>
From: David Gasson <DavidG [...] airg.com>
Hi folks, I'm keen to use DBIx::Log4perl--it's exactly what I'm looking for. But I noticed a problem. Below is a script that demonstrates it: use strict; use warnings; my $dsn = 'DBI:mysql:database=mydb;host=localhost'; my $user = 'myuser'; my $pass = 'mypass'; sub show_quotes { my ($dbh, $type) = @_; print "Table name w/ quotes ($type): ", $dbh->quote_identifier('Account'), "\n"; } { use DBI; my $dbh = DBI->connect($dsn, $user, $pass) or die DBI->errstr; show_quotes($dbh, 'DBI'); $dbh->disconnect; } { use Log::Log4perl qw/:easy/; Log::Log4perl->easy_init($DEBUG); use DBIx::Log4perl; my $dbh = DBIx::Log4perl->connect($dsn, $user, $pass) or die DBI->errstr; show_quotes($dbh, 'DBIx::Log4perl'); $dbh->disconnect; } In the first case, all is well and the following is outputted: Table name w/ quotes (DBI): `Account` But in the second case (with DBIx::Log4perl): Table name w/quotes (DBIx::Log4perl): "Account" Which is wrong in MySQL. The fix seems really straightforward, though. In DBIx/Log4perl/db.pm simply change: sub get_info { my ($dbh, @args) = @_; my $h = $dbh->{private_DBIx_Log4perl}; my $value = $dbh->SUPER::get_info(@args); $dbh->_dbix_l4p_debug($h, 2, "get_info($h->{dbh_no})", @args, $value) if ($h->{logmask} & DBIX_L4P_LOG_INPUT); } To: sub get_info { my ($dbh, @args) = @_; my $h = $dbh->{private_DBIx_Log4perl}; my $value = $dbh->SUPER::get_info(@args); $dbh->_dbix_l4p_debug($h, 2, "get_info($h->{dbh_no})", @args, $value) if ($h->{logmask} & DBIX_L4P_LOG_INPUT); return $value; } The only difference between the two is the addition of the "return $value" line. Is that the right solution? Things seem to work flawlessly after that change is made. FYI, here are the various versions of things I'm using in case it's relevant: MySQL: 5.0.22 DBI: 1.609 DBD::mysql: 4.013 Log::Log4perl: 1.25 DBIx::Log4perl: 0.15 perl: 5.8.8 Oh, and this is on Linux. If you need any more information, please don't hesitate to ask! Totally digging DBIx::Log4perl otherwise... Cheers, David David Gasson Programmer airG Suite 706, 1155 Robson Street Vancouver, B.C. Canada V6E 1B5 T: +1.604.408.2228  F: +1.866.874.8136 E: davidg@airg.com W: www.airg.com
From: bohica [...] ntlworld.com
On Wed Sep 30 18:15:49 2009, DavidG@airg.com wrote: Show quoted text
> Hi folks, > > I'm keen to use DBIx::Log4perl--it's exactly what I'm looking for. > But I noticed a problem. Below is a script that demonstrates it: > > use strict; > use warnings; > > my $dsn = 'DBI:mysql:database=mydb;host=localhost'; > my $user = 'myuser'; > my $pass = 'mypass'; > > sub show_quotes { > my ($dbh, $type) = @_; > print "Table name w/ quotes ($type): ", $dbh-
> >quote_identifier('Account'), "\n";
> } > > { > use DBI; > > my $dbh = DBI->connect($dsn, $user, $pass) or die DBI->errstr; > show_quotes($dbh, 'DBI'); > $dbh->disconnect; > } > > { > use Log::Log4perl qw/:easy/; > Log::Log4perl->easy_init($DEBUG); > use DBIx::Log4perl; > > my $dbh = DBIx::Log4perl->connect($dsn, $user, $pass) or die DBI-
> >errstr;
> show_quotes($dbh, 'DBIx::Log4perl'); > $dbh->disconnect; > } > > In the first case, all is well and the following is outputted: > > Table name w/ quotes (DBI): `Account` > > But in the second case (with DBIx::Log4perl): > > Table name w/quotes (DBIx::Log4perl): "Account" > > Which is wrong in MySQL. The fix seems really straightforward, > though. In DBIx/Log4perl/db.pm simply change: > > sub get_info > { > my ($dbh, @args) = @_; > > my $h = $dbh->{private_DBIx_Log4perl}; > my $value = $dbh->SUPER::get_info(@args); > > $dbh->_dbix_l4p_debug($h, 2, "get_info($h->{dbh_no})", @args, > $value) > if ($h->{logmask} & DBIX_L4P_LOG_INPUT); > } > > To: > > sub get_info > { > my ($dbh, @args) = @_; > > my $h = $dbh->{private_DBIx_Log4perl}; > my $value = $dbh->SUPER::get_info(@args); > > $dbh->_dbix_l4p_debug($h, 2, "get_info($h->{dbh_no})", @args, > $value) > if ($h->{logmask} & DBIX_L4P_LOG_INPUT); > > return $value; > } > > The only difference between the two is the addition of the "return > $value" line. Is that the right solution? Things seem to work > flawlessly after that change is made. FYI, here are the various > versions of things I'm using in case it's relevant: > > MySQL: 5.0.22 > DBI: 1.609 > DBD::mysql: 4.013 > Log::Log4perl: 1.25 > DBIx::Log4perl: 0.15 > perl: 5.8.8 > > Oh, and this is on Linux. If you need any more information, please > don't hesitate to ask! Totally digging DBIx::Log4perl otherwise... > > Cheers, > David > > David Gasson > Programmer > airG > Suite 706, 1155 Robson Street > Vancouver, B.C. > Canada V6E 1B5 > T: +1.604.408.2228  > F: +1.866.874.8136 > E: davidg@airg.com > W: www.airg.com > >
Looks like a good call - will look at it properly tomorrow as it is 11:27pm here now. Thanks Martin
Problem fixed and 0.16 uploaded to CPAN. You can either wait for it to get around the mirrors or simply change the copy you already have and install it. Thanks for the bug report and for identifying the fix. Martin -- Martin J. Evans Wetherby, UK
Subject: RE: [rt.cpan.org #50134] identifier quote wrong
Date: Thu, 1 Oct 2009 09:03:42 -0700
To: "bug-DBIx-Log4perl [...] rt.cpan.org" <bug-DBIx-Log4perl [...] rt.cpan.org>
From: David Gasson <DavidG [...] airg.com>
Hi Martin, Just noticed DBIx::Log4perl 0.16 :-). Thanks much for fixing that so fast--it's really appreciated! Now we can integrate it into our project (yay!)... Cheers, David
On Thu Oct 01 12:04:04 2009, DavidG@airg.com wrote: Show quoted text
> Hi Martin, > > Just noticed DBIx::Log4perl 0.16 :-). Thanks much for > fixing that so fast--it's really appreciated! Now we can integrate it > into our project (yay!)... > > Cheers, > David
No problem. It was really easy for me when you identified the problem, produced an example and gave me the fix. If you use it then please consider doing a CPAN rating for it. Martin -- Martin J. Evans Wetherby, UK