Re: :PgSQL: More Queestions

From: Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com>
To: Rudy Lippan <rlippan(at)remotelinux(dot)com>
Cc: Adam Witney <awitney(at)sghms(dot)ac(dot)uk>, 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:52:19
Message-ID: 20021121195219.GQ17107@dansat.data-plan.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Or ignore colons that have a digit as the previous character
as that would never be a placeholder.

Tim.

On Thu, Nov 21, 2002 at 02:20:52PM -0500, Rudy Lippan wrote:
> 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
>

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Rudy Lippan 2002-11-21 20:54:56 Re: :PgSQL: More Queestions
Previous Message Rudy Lippan 2002-11-21 19:20:52 Re: :PgSQL: More Queestions