Subject: | quote() method returns NULL on all but first call when arg is a function call |
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.