Re: ALTER TABLE ... REPLACE WITH

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: ALTER TABLE ... REPLACE WITH
Дата
Msg-id 21252.1295558658@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: ALTER TABLE ... REPLACE WITH  (Noah Misch <noah@leadboat.com>)
Ответы Re: ALTER TABLE ... REPLACE WITH  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Noah Misch <noah@leadboat.com> writes:
> Heikki's suggestion seemed straightforward, so much so that I couldn't figure
> why nobody had done it.  That would usually mean I'm missing something.

If you're willing to substitute an incompatible table, it's not clear
why you don't just do
    begin;    drop table t;    alter table t_new rename to t;    commit;

There are some implementation issues with this: concurrent accesses are
likely to end up failing with "relation with OID nnn doesn't exist",
because backends translate the table's name to OID before acquiring
lock.  But you'd have to solve those issues anyway to make an ALTER
REPLACE WITH work as transparently as you seem to hope it would.
Unless the idea here is to also have t_new acquire t's OID, and that
is an absolute complete won't-happen if you're not enforcing a pretty
thorough level of compatibility between the two tables.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Orphaned statements issue
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: estimating # of distinct values