Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 5132
Status: resolved
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: mjhbugs-cpanrt [...] liminalflux.net
Cc:
AdminCc:

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



Subject: DBI:quote returns NULL for tied hash variables.
perl: v5.8.0 DBI.pm: v 11.42 Problem: dbi->quote(%hash->{'value'}) returns NULL if "%hash" is tied but valid. Example: use strict; use DBI; use Apache::Session::MySQL; use Data::Dumper; my $dbh = DBI->connect( "dbi:mysql:database=$db", $user, $pass); my $sessionId = '0167d73142462923e29ef694839a26c2'; my %session; tie %session, 'Apache::Session::MySQL', $sessionId, { 'Handle' => $dbh, 'LockHandle' => $dbh, }; my $session = \%session; my $username = $session->{'username'}; $Data::Dumper::Indent= 1; print Dumper($session) . "\n"; print $username . "\n"; print $session->{'username'} . "\n"; print $$session{'username'} . "\n\n"; print $dbh->quote( $session->{'username'} ) . "\n"; print $dbh->quote( ${ \$session->{'username'} } ) . "\n"; print $dbh->quote( $session{username} ) . "\n\n"; print $dbh->quote( $$session{username} ) . "\n"; print $dbh->quote($username) . "\n"; print $dbh->quote( "$session->{'username'}"); Produces: $VAR1 = { 'name' => undef, 'logged in' => 'y', 'cookie' => '0167d73142462923e29ef694839a26c2', 'username' => 'tESTING', '_session_id' => '0167d73142462923e29ef694839a26c2', 'last used' => 1075436736 }; tESTING tESTING tESTING NULL NULL NULL NULL 'tESTING' 'tESTING' As you can see, anything that forces the tied value into a scalar context works, anything that does not results in a NULL.
Please post an example using only standard modules. Use Tie::StdHash and DBD::ExampleP, for example. And include a trace (level 2) that shows that values are being passed into quote(). (But not that there's a chance that tracing will hide the bug, but that in itself would help identify the cause.) Thanks.
From: MJH <mjhbugs-cpanrt [...] liminalflux.net>
[TIMB - Fri Jan 30 12:24:45 2004]: Show quoted text
> Please post an example using only standard modules. > Use Tie::StdHash and DBD::ExampleP, for example.
I haven't quite got that worked out yet (being new to using Tie and DBD and not having had much time to look into this). However: Show quoted text
> (But not that there's a chance that tracing will hide the bug, > but that in itself would help identify the cause.)
Tracing does hide the bug. Show quoted text
> And include a trace (level 2) that shows that values > are being passed into quote().
Unhelpfully with the mysql DBD it just gives: -> quote for DBD::mysql::db (DBI::db=HASH(0x823ec08)~0x823f284 'tESTING' (magic-sgr:p)) thr#804b618 <- quote= ''tESTING'' at ./test.pl line 41 Does that help at all?
RT-Send-CC: rlippan [...] remotelinux.com
This is a bug in DBD::mysql so I've closed this ticket. DBD::mysql needs to do: if (GMAGICAL(sv)) mg_get(sv);