pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adam Witney <awitney@sghms.ac.uk>
To: David Wheeler <david@wheeler.net>
Cc: dbi-dev@perl.org, pgsql-interfaces <pgsql-interfaces@postgresql.org>
Subject: Re: :PgSQL: More Queestions
Date: Thu, 21 Nov 2002 10:53:32 +0000
Message-ID: <BA026BAC.BF01%a.witney@sghms.ac.uk> (raw)
In-Reply-To: <289E1136-FC56-11D6-8F04-0003931A964A@wheeler.net>

> I understand that the goal is to convert the placeholders from '?' or
> ':nn' to the PostgreSQL internal version (':pn'). What I'm referring to
> specifically, however, is this snippet from DBD::Pg:
> 
>        if (in_literal) {
>            /* Check if literal ends but keep quotes in literal */
>            if (*src == in_literal) {
>                int bs = 0;
>                char *str;
>                str = src-1; /* Back a character. */
>                while (*(str - bs) == '\\')
>                    bs++;
>                if (!(bs & 1))
>                    /* bs is an even number? */
>                    in_literal = 0;
>            }
>            *dest++ = *src++;
>            continue;
>        }
> 
> in_literal is set when the last character wasn't a placeholder
> character ('?' or ':') and is either a single or a double quotation
> mark. So while I understand that one might want to ignore placeholder
> characters, I don't really understand what the above code is doing.
> Probably'll be easier for me after I've been looking a C for a while...

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

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?

Thanks

adam


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




view thread (22+ messages)  latest in thread

Message-ID: <BA026BAC.BF01%a.witney@sghms.ac.uk>
Permalink:  ../BA026BAC.BF01%25a.witney@sghms.ac.uk/
Also on:    postgresql.org/message-id/BA026BAC.BF01%a.witney@sghms.ac.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: awitney@sghms.ac.uk, david@wheeler.net
  Subject: Re: :PgSQL: More Queestions
  In-Reply-To: <BA026BAC.BF01%a.witney@sghms.ac.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox