Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: TEEJAY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.40
Fixed in: 2.0.0



Subject: ?# in prepared statement wrongly causes error
I'm doing some fairly simple geometric queries and so have clauses like this : ( point(0.149191714087837,0.828304174175642) @ edge OR '((0.149191714087837,0.828304174175642), (0.153897315676687,0.830640006491228 ))' ?# edge which won't work with DBD::Pg because it mistakes ?# for a placeholder, giving different errors depending on if I use ? style of $1 style placeholders. with ? style placeholders I get : DBD::Pg::st execute failed: called with 2 bind variables when 3 are needed with $1 style placeholders I get : Cannot mix placeholder styles "?" and "$1" at /path/to/DBD/Pg.pm line 190. The problem appears to be (MST found this for me) : /* We might slurp in a placeholder, so mark the character before the current one */ /* In other words, inside of "ABC?", set sectionstop to point to "C" */ sectionstop=currpos-1; /* Figure out if we have a placeholder */ placeholder_type = 0; /* Normal question mark style */ if ('?' == ch) { placeholder_type = 1; } in dbdimp.c where it doesn't cope with ?# or similar operators. I would suggest adding tests for geometric operators like this in your placeholder tests, as it would appear this one isn't being tested so you have both a bug in the code and a gap in the tests that need fixing. I'm going to have to provide functions to wrap the ?# operator until this is fixed, which is annoying but at least I've only lost a couple of hours tracking down the problem.
Thanks for the report. Rather than making special cases for the geometric classes and risk breaking existing apps, I added a new attribute called pg_placeholder_dollaronly that can be set at the database handle or as part of the prepare call. Setting it to true will cause any non-dollarsign placeholders to be treated literally, so all the geometric operators should now work. Committed in r9266.