Re: :PgSQL: More Queestions

From: Rudy Lippan <rlippan(at)remotelinux(dot)com>
To: David Wheeler <david(at)wheeler(dot)net>
Cc: Jeff Urlwin <jurlwin(at)bellatlantic(dot)net>, <dbi-dev(at)perl(dot)org>, <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: :PgSQL: More Queestions
Date: 2002-11-21 10:52:26
Message-ID: Pine.LNX.4.44.0211210535440.28232-100000@elfride.ineffable.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Wed, 20 Nov 2002, David Wheeler wrote:

>
> >> Maybe it's just too complex, because, looking at DBD::ODBC's
> >> dbd_preparse(), the handling of literals in the query seems a good
> >> deal
> >> more straight-forward (though it doesn't appear to handle '\'' or "\""
> >> -- am I reading that right?
> >
> > Nope, it handles " or '.
> >
> > if (*src == '"' || *src == '\'') {
> > etc...
> > }
>
> It doesn't appear to handle "...""...", though, right? Or am I missing
> it?
>

So you have a "". On the first " of the medial "" cluster, the code will
set in_literal to 0, but the very next character is a " so it will set
in_literal right back to '"'. Now, if there were something between the "s
it would not be in_literal, see? || am I just serving to confuse?

> PostgreSQL folks, can the same statement return a different number of
> fields on different executes? I'm guessing yes for something like this,
> though:
>
> CREATE TABLE foo ( bar int, bat, text);
>
> SELECT * FROM foo; -- Returns two fields.
>
> ALTER TABLE foo ADD COLUMN fat int;
>
> SELECT * FROM foo; -- Returns three fields.
>

But using prepared statements:

test=# create table foo (foo integer);
CREATE TABLE
test=# prepare cached (varchar) AS select * from foo where foo= $1;
PREPARE
test=# insert into foo values (1);
INSERT 16982 1
test=# execute cached (1);
foo
-----
1
(1 row)

test=# alter table foo add column bar varchar;
ALTER TABLE
test=# execute cached (1);
foo
-----
1
(1 row)

test=# select * from bar;
ERROR: Relation "bar" does not exist
test=# select * from foo;
foo | bar
-----+-----
1 |
(1 row)

-r

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Adam Witney 2002-11-21 10:53:32 Re: :PgSQL: More Queestions
Previous Message Tim Bunce 2002-11-21 09:47:09 Re: DBD::PgSQL: More Queestions