Re: creating the same table in 2 different sessions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: creating the same table in 2 different sessions
Дата
Msg-id 27894.1108290267@sss.pgh.pa.us
обсуждение исходный текст
Ответ на creating the same table in 2 different sessions  (Jeroen van Iddekinge <iddekingej@lycos.com>)
Список pgsql-hackers
Jeroen van Iddekinge <iddekingej@lycos.com> writes:
> begin;
> create table a0(a bigint);

> than login for a second session
> begin
> create table a0(a bigint)

> postgres block nows in session 2

> when session 1  is commited the following error appears in session 2

> duplicate key violates unique constraint "pg_class_relname_nsp_index"

It's always worked like that; certainly as far back as 7.0, which is the
oldest version I have alive to test.  The friendly "a0 already exists"
test falls through because a0 doesn't exist (at least it's not committed
at the time).  The unique index mechanism is the last-ditch fallback
that prevents the race condition from actually creating a problem.

So: no bug, it's operating as designed.  I agree that the error message
isn't as pretty as one might wish, but I don't think it's worth the
effort it would take to produce something else.  (The solution you
suggest doesn't fix it, it only makes the window narrower.)
        regards, tom lane


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

Предыдущее
От: Jeroen van Iddekinge
Дата:
Сообщение: creating the same table in 2 different sessions
Следующее
От: Jeroen van Iddekinge
Дата:
Сообщение: strerror_r int and char* return type mixup on FC2