From: | Rudy Lippan <rlippan(at)remotelinux(dot)com> |
---|---|
To: | Adam Witney <awitney(at)sghms(dot)ac(dot)uk> |
Cc: | David Wheeler <david(at)wheeler(dot)net>, <dbi-dev(at)perl(dot)org>, pgsql-interfaces <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | Re: :PgSQL: More Queestions |
Date: | 2002-11-21 19:20:52 |
Message-ID: | Pine.LNX.4.44.0211211357560.21197-100000@elfride.ineffable.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
On Thu, 21 Nov 2002, Adam Witney wrote:
> One thing you may want to keep in mind is the situation concerning array
> slices
>
> If you send a statement like this
>
> my $sth = $dbh->prepare("select cube[1:2][1][1] from test4");
>
> Then the :2 gets treated as a placeholder and gets substituted. From the
> trace
Ugg.
Maybe as a possible idea, what do you think?
--- dbdimp.orig Thu Nov 21 15:51:06 2002
+++ dbdimp.c Thu Nov 21 15:56:24 2002
@@ -692,6 +692,8 @@
if (*src != ':' && *src != '?') {
if (*src == '\'' || *src == '"') {
in_literal = *src;
+ } else if ('[' == *src) {
+ in_literal = ']';
}
*dest++ = *src++;
continue;
@@ -1139,6 +1141,8 @@
if (*src != ':' && *src != '?') {
if (*src == '\'' || *src == '"') {
in_literal = *src;
+ } else if ('[' == *src) {
+ in_literal = ']';
}
*dest++ = *src++;
continue;
Untested, but compiles. :) (well I did do a quick test on your above stmt
and it works for that one, but may break other things. YMMV)
>
> dbd_st_execute: statement = >select cube[1NULL][1][1] from test4<
> ERROR: parser: parse error at or near "NULL" at character 14 error 7
> recorded: ERROR: parser: parse error at or near "
> NULL" at character 14
>
> As no parameters have been bound to the placeholder then a NULL is
> substituted and so it fails.
>
> Or maybe I was doing it wrong and there is a way to get around this already?
>
As a quick workaround $dbh->prepare("cube[1:?][1][1]"); make '2' your
first param to execute()
-r
From | Date | Subject | |
---|---|---|---|
Next Message | Tim Bunce | 2002-11-21 19:52:19 | Re: :PgSQL: More Queestions |
Previous Message | William Brennan | 2002-11-21 18:37:07 | Handling SQL errors using libpq |