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.