Transactional-DDL DROP/CREATE TABLE

Поиск
Список
Период
Сортировка
От Geoff Winkless
Тема Transactional-DDL DROP/CREATE TABLE
Дата
Msg-id CAEzk6ffty6zFKnu7FA9uZOW1B91kEDT_6zfxyK5EVQuSBwvGgA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Transactional-DDL DROP/CREATE TABLE  (Francisco Olarte <folarte@peoplecall.com>)
Re: Transactional-DDL DROP/CREATE TABLE  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: Transactional-DDL DROP/CREATE TABLE  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
Hi

I have code that does (inside a single transaction)

DROP TABLE IF EXISTS mytable; CREATE TABLE mytable ....

Occasionally this produces

ERROR: duplicate key value violates unique constraint
"pg_type_typname_nsp_index" DETAIL: Key (typname,
typnamespace)=(mytable, 2200) already exists.

I can get away from this by using CREATE TABLE IF NOT EXISTS in the
same code, but there's the potential that the wrong data will end up
in the table if that happens, and it also seems a little.... odd.

Would you not expect this transaction to be atomic? ie at commit time,
the transaction should drop any table with the same name that has been
created by another transaction.

Geoff


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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: ZSON, PostgreSQL extension for compressing JSONB
Следующее
От: Aleksander Alekseev
Дата:
Сообщение: Re: ZSON, PostgreSQL extension for compressing JSONB