PREPARE(d) statements and modifying columns

From: Kris Jurka <books(at)ejurka(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: PREPARE(d) statements and modifying columns
Date: 2004-06-27 23:07:43
Message-ID: Pine.BSO.4.56.0406271751370.18065@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


There are problems when a prepared statement's underlying table's column's
type is modified. With 7.5 and using the new ALTER TYPE it causes a
backend crash. Using the old ADD/UPDATE/DROP/RENAME method causes
incorrect data to be returned.

CREATE TABLE mytab (a int);
INSERT INTO mytab VALUES (1);
PREPARE mystat AS SELECT a FROM mytab;

and then:

ALTER TABLE mytab ALTER COLUMN a TYPE bigint USING (a+1);
EXECUTE mystat;

or:

ALTER TABLE mytab ADD COLUMN b bigint;
UPDATE mytab SET b = a+1;
ALTER TABLE mytab DROP COLUMN a;
ALTER TABLE mytab RENAME COLUMN b TO a;
EXECUTE mystat;

Kris Jurka

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Meskes 2004-06-28 12:08:32 Re: Embedded SQL library bug
Previous Message Tom Lane 2004-06-27 22:07:44 Re: BUG #1184: listeners not cleaned on crash