Subject: | Question mark strings is wrongly treated as placeholder |
Platforms that are affected by this bug:
* Slackware 9.1 (kernel 2.4.24), Perl 5.8.0 built for i486-linux, DBI 1.43,
DBD::Pg 1.41_1, PostgreSQL 7.4.2
* Debian 3.1 (kernel 2.4.27), Perl v5.8.4 built for i386-linux-thread-
multi, DBI 1.46, DBD::Pg 1.41, PostgreSQL 7.4.7
Description of the problem: If I execute the following code in one of the above environments, then I get the error message "DBD::Pg::db do failed: execute called with an unbound placeholder at test.pl line 10.". Note that lines 8 and 9 cause no trouble.
use DBI;
$dbh = DBI->connect(undef, undef, undef,
{RaiseError => 1, AutoCommit => 1, PrintError => 0}) or
die "Cannot connect to database: $DBI::errstr";
$dbh->do("SET client_encoding TO 'Latin1'");
eval { $dbh->do("DROP TABLE ptest"); };
$dbh->do("CREATE TABLE ptest(txt varchar(8))");
$dbh->do("INSERT INTO ptest VALUES('?')");
$dbh->do("INSERT INTO ptest VALUES('\\'')");
$dbh->do("INSERT INTO ptest VALUES('\\'?')"); # Line 10
$dbh->do("INSERT INTO ptest VALUES(?)", undef, "'?"); # Workaround
$dbh->disconnect;
Workaround: See line 11.