Table definition changes when a row is dropped and recreated

Поиск
Список
Период
Сортировка
От deep ...
Тема Table definition changes when a row is dropped and recreated
Дата
Msg-id 331363f40612042242v6e8adcf4r4cdab8d96d220497@mail.gmail.com
обсуждение исходный текст
Ответы Re: Table definition changes when a row is dropped and  (Scott Marlowe <smarlowe@g2switchworks.com>)
Список 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 по дате отправления:

Предыдущее
От: "Marina Olhovsky"
Дата:
Сообщение: Ident authentication failed for user - URGENT
Следующее
От: "shakahshakah@gmail.com"
Дата:
Сообщение: Re: Row-based authorization