Table definition changes when a row is dropped and recreated - Mailing list pgsql-general

From deep ...
Subject Table definition changes when a row is dropped and recreated
Date
Msg-id 331363f40612042242v6e8adcf4r4cdab8d96d220497@mail.gmail.com
Whole thread Raw
Responses Re: Table definition changes when a row is dropped and  (Scott Marlowe <smarlowe@g2switchworks.com>)
List pgsql-general
Hi everyone,

I have a java app using pgsql 7.3 on unix platform where the latest
version of the app updates the width of a row in a table as a part of
upgrade. Since there is no straightforward 'modify' clause in
Postgresql 7.3, we're using

alter table ...  add new_column type (width);
update ... set new_column=old_column;
alter table... drop old_column;

After running this sql as a part of upgrade script, the table
definition changes in database, in that the widened column gets pushed
to the end of the definition (as can be seen through \d table_name
command). This is making the insert queries fail which were designed
with the original table definition in mind.

Assuming there is no way to know whether the insert command is running
before or after upgrade (from within the database handler part of the
app, I mean), how do we solve this problem? Backup data, Drop the
table and create it again? In that case, what happens to the indexes
and constraints?

Thanks in advance,
Walter

pgsql-general by date:

Previous
From: "Marina Olhovsky"
Date:
Subject: Ident authentication failed for user - URGENT
Next
From: "shakahshakah@gmail.com"
Date:
Subject: Re: Row-based authorization