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