BUG #2079: strage PREPARE/EXECUTE behavior - Mailing list pgsql-bugs

From Yuriy Vostrikoff
Subject BUG #2079: strage PREPARE/EXECUTE behavior
Date
Msg-id 20051130093801.7111CF0B09@svr2.postgresql.org
Whole thread Raw
Responses Re: BUG #2079: strage PREPARE/EXECUTE behavior  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2079
Logged by:          Yuriy Vostrikoff
Email address:      mon@lcpi.ru
PostgreSQL version: 8.1.0
Operating system:   Debian sarge
Description:        strage PREPARE/EXECUTE behavior
Details:

EXECUTE return wrong result after ALTER TABLE ALTER COLUMN TYPE. Is this
expected behavior?

mon=> select version();
                                          version

----------------------------------------------------------------------------
---------------
 PostgreSQL 8.1.0 on i386-pc-linux-gnu, compiled by GCC cc (GCC) 3.3.5
(Debian 1:3.3.5-13)
(1 row)

mon=> \d
No relations found.
mon=> create table test (col timestamp);
CREATE TABLE
mon=> insert into test values(current_timestamp);
INSERT 0 1
mon=> insert into test values(current_timestamp);
INSERT 0 1
mon=> prepare q as select * from test;
PREPARE
mon=> EXECUTE q;
            col
----------------------------
 2005-11-30 12:27:49.569859
 2005-11-30 12:27:51.463482
(2 rows)

mon=> alter table test alter col type text;
ALTER TABLE
mon=> execute q;
             col
------------------------------
 123450-10-10 15:43:18.790174
 123450-10-10 15:43:18.790174
(2 rows)

mon=> select * from test;
            col
----------------------------
 2005-11-30 12:27:49.569859
 2005-11-30 12:27:51.463482
(2 rows)


'123450-10-10 15:43:18.790174' is certainly not '2005-11-30
12:27:49.569859'.

Same problem with other datatypes.
And a second question: why  PQprepare() from libpq returns empty PQresult?
It's useful to know field number, field types before PQexecutePrepared.

pgsql-bugs by date:

Previous
From: "Martin Pelikan"
Date:
Subject: BUG #2077: Hiding databases which I am not owner
Next
From: "Pierre Beyssac"
Date:
Subject: BUG #2078: lock freeing problem in transaction (?)