On Sat, 1 Sep 2001, Alex Krohn wrote:
> > my $dbh = DBI->connect("DBI:Pg:dbname=test", "postgres", "");
> > my $val = $dbh->quote(q!\'?:!);
> > print "val: $val\n";
> > my $sth = $dbh->prepare("INSERT INTO foo (a) values ($val)");
> Placeholders isn't really an option in my case.
>
> I realize quote should not quote the ? character, but the driver should
> understand that question marks inside of quotes is not to be used as
> placeholders, but is rather a question mark. i.e. the following works
> of course:
>
> my $sth = $dbh->prepare ('INSERT INTO foo (a) VALUES ("hello?")');
>
> as the driver realizes that ? is not a placeholder. It's the strange
> mix above that causes a problem (oddly, if I remove the :, it works
> fine).
Driver _does_ realise that question mark is not a placeholder within
quotes.
However, quote behaviour in case of your string is funky. It gets quoted
as '\\''?:' (note the double backslash and double quote), and something
gets very confused in parser for execute() that it doesn't realize that ?
is still within quotes.
I'll come back with a patch tomorrow. ;)
> Does anyone more familiar with the DBD::Pg internals know what the
> sequens is to look for that will catch this? If I remove the : or the \
> from the insert above, it works fine.