Discussion:
execute called with an unbound placeholder: Bug?
Felix E. Klee
20 years ago
Permalink
With DBD::Pg 1.32, DBI 1.43 the code below works flawlessly, i.e. the
field "ngdesc" where ng = 'x.a' is updated to read "'?".

However, with DBD::Pg 1.41, DBI 1.46, I get the error message
"DBD::Pg::db do failed: execute called with an unbound placeholder at
./qqq line 7.". Am I doing something wrong or is this a bug?

#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect("dbi:Pg:dbname=sandpit", '', '',
{RaiseError => 1, AutoCommit => 1, PrintError => 0}) or
die "Cannot connect to database: $DBI::errstr";
$dbh->do("UPDATE qqqmlnggates SET ngdesc = '\\'?' WHERE ng = 'x.a'");
--
Felix E. Klee
Greg Sabino Mullane
20 years ago
Permalink
Post by Felix E. Klee
However, with DBD::Pg 1.41, DBI 1.46, I get the error message
"DBD::Pg::db do failed: execute called with an unbound placeholder at
./qqq line 7.". Am I doing something wrong or is this a bug?
The question mark is getting treated as a placeholder. You can wrap it
in double quotes, or do this:

$dbh->{pg_direct} = 0;

before sending the query, which will prevent DBD::Pg from trying to
parse the statement for placeholders at all. You can also use the
normal "prepare-execute with args" paradigm as well, of course.

- --
Greg Sabino Mullane greg-738XdyZ4GzZWk0Htik3J/***@public.gmane.org
PGP Key: 0x14964AC8 200505090638
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
Felix E. Klee
20 years ago
Permalink
At Mon, 9 May 2005 22:41:12 -0000,
Post by Greg Sabino Mullane
Post by Felix E. Klee
However, with DBD::Pg 1.41, DBI 1.46, I get the error message
"DBD::Pg::db do failed: execute called with an unbound placeholder
at ./qqq line 7.". Am I doing something wrong or is this a bug?
The question mark is getting treated as a placeholder.
I know. But the funny thing is that the code used to work with an older
version. Also, when I substitute the sample replacement string '\\'?'
with the string '?' or with '\\'', then the error isn't triggered.
Post by Greg Sabino Mullane
You can wrap it in double quotes,
You mean `ngdesc = '\\'"?"'` instead of `ngdesc = '\\'?'`? I'll try that
tomorrow.
Post by Greg Sabino Mullane
$dbh->{pg_direct} = 0;
This looks reasonable, thanks for the hint!
--
Felix E. Klee
Felix E. Klee
20 years ago
Permalink
At Tue, 10 May 2005 02:00:44 +0200,
Post by Felix E. Klee
Post by Greg Sabino Mullane
You can wrap it in double quotes,
You mean `ngdesc = '\\'"?"'` instead of `ngdesc = '\\'?'`? I'll try that
tomorrow.
Not surprisingly, this did not work.
Post by Felix E. Klee
Post by Greg Sabino Mullane
$dbh->{pg_direct} = 0;
Neither did this work.

Although I don't have experience with placeholders, I believe that this
is a clear bug: A question mark should never be interpreted as
placeholder if it is part of an SQL string.

Bug report 12870 (Question mark in strings is wrongly treated as
placeholder) that I just filed provides more information, and an obvious
workaround.
--
Felix E. Klee
Rudy Lippan
20 years ago
Permalink
...
It is a bug. Try DBD::Pg 1.32.

Rudy
Felix E. Klee
20 years ago
Permalink
At Wed, 18 May 2005 08:18:45 -0400 (EDT),
Post by Rudy Lippan
It is a bug. Try DBD::Pg 1.32.
Thanks for the hint, but I already knew that things work fine with
version 1.32 (forgot to mention this fact in the bug report). However,
on one of the systems in question, policy is to always use the latest
Debian packages (surely, I could use 1.32 nevertheless, but I don't want
that). So, I guess I'll simply use the work-around which I mentioned in
the bug report.
--
Felix E. Klee
Greg Sabino Mullane
20 years ago
Permalink
Post by Felix E. Klee
Bug report 12870 (Question mark in strings is wrongly treated as
placeholder) that I just filed provides more information, and an obvious
workaround.
This has been fixed (I think) in cvs, and is part of the 1.41_2 tarball:

http://search.cpan.org/~dbdpg/DBD-Pg-1.41/

(see the "Latest Dev. Release" section)

Please try it out and verify that the bug has been fixed for you.

Thanks,
- --
Greg Sabino Mullane greg-738XdyZ4GzZWk0Htik3J/***@public.gmane.org
PGP Key: 0x14964AC8 200505192149
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
Felix E. Klee
20 years ago
Permalink
At Fri, 20 May 2005 01:51:15 -0000,
Post by Greg Sabino Mullane
http://search.cpan.org/~dbdpg/DBD-Pg-1.41/
(see the "Latest Dev. Release" section)
Please try it out and verify that the bug has been fixed for you.
I already tried it out shortly after the release of the new snapshot.
See my second reply to the bug report.
--
Felix E. Klee
Loading...