Skip Menu |
 

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 4996
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: vivek [...] khera.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.31
Fixed in: 1.22



Subject: quote() method returns NULL on all but first call when arg is a function call
Download (untitled) / with headers
text/plain 1.3k
DBD::Pg 1.31 (with the patch from ticket 4432 applied) returns NULL on every subsequent call to quote() if the argument is a function, as follows: $dbh->quote(substr($str,0,3000)) Here's a script the demonstrates this: #! /usr/local/bin/perl -wT use strict; use DBD::Pg; print "DBD::Pg Version: $DBD::Pg::VERSION\n"; my $dbh = DBI->connect('dbi:Pg:dbname=template1','www','www',{PrintError=>0}) or die "dbi connect failure: ".$DBI::errstr; sub checkquote { my $str = shift; print "quoting $str\n"; print "substr is ".substr($str,0,3000)."\n"; my $q = $dbh->quote(substr($str,0,3000)); print "got $q\n"; } checkquote("This has an exclamation!"); checkquote("abcdefg <some funny & stuff>"); checkquote("But not this"); checkquote("owner_id=4 AND user_status='active'"); When I run this, I get this output: DBD::Pg Version: 1.31 quoting This has an exclamation! substr is This has an exclamation! got 'This has an exclamation!' quoting abcdefg <some funny & stuff> substr is abcdefg <some funny & stuff> got NULL quoting But not this substr is But not this got NULL quoting owner_id=4 AND user_status='active' substr is owner_id=4 AND user_status='active' got NULL reordering the calls to checkquote() confirms that the first call works while the subsequent ones do not. Dropping back to DBD::Pg 1.22 works as expected: you get quoted output for every one of the above.
Download (untitled) / with headers
text/plain 575b
I just ran the script that Vivek pasted against the latest from CVS, and it does indeed fail. The output is: DBD::Pg Version: 1.33 quoting This has an exclamation! substr is This has an exclamation! got 'This has an exclamation!' quoting abcdefg <some funny & stuff> substr is abcdefg <some funny & stuff> got NULL quoting But not this substr is But not this got NULL quoting owner_id=4 AND user_status='active' substr is owner_id=4 AND user_status='active' The upshot is that those NULLs should not be there. Something nasty is happening in the wooodsh...er, quote method.
Download (untitled) / with headers
text/plain 120b
I've replicated this issue in some new tests, which I'll commit as soon as the OSCON network lets me without timing out!
Download (untitled) / with headers
text/plain 129b
[DWHEELER - Mon Jul 26 16:32:52 2004]: I cannot reproduce the failure. Can you tell what versions of everything you are using?
Download (untitled) / with headers
text/plain 188b
Um, did you run the tests of the version in CVS?I committed them last week. They do fail. I'm using PostgreSQL 7.4.3 and Perl 5.8.5. You need to set up DBI_DSN, DBI_USER, and DBI_PASS.
Download (untitled) / with headers
text/plain 105b
This has been fixed (thanks to the tests I added!). The fix will be in the next release (soon, I hope!).


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.