dbTalk Databases Forums  

[BUGS] PREPARE(d) statements and modifying columns

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] PREPARE(d) statements and modifying columns in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kris Jurka
 
Posts: n/a

Default [BUGS] PREPARE(d) statements and modifying columns - 06-27-2004 , 06:27 PM







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


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply With Quote
  #2  
Old   
Kris Jurka
 
Posts: n/a

Default Re: [BUGS] PREPARE(d) statements and modifying columns - 10-28-2004 , 01:34 AM







I'd like to re-raise this bug I reported some time ago and got no response
on. Generally any plain sql commands shouldn't crash the backend and I
don't like a query reporting incorrect results.

On Sun, 27 Jun 2004, Kris Jurka wrote:

Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.