Re: creating the same table in 2 different sessions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: creating the same table in 2 different sessions
Date
Msg-id 27894.1108290267@sss.pgh.pa.us
Whole thread Raw
In response to creating the same table in 2 different sessions  (Jeroen van Iddekinge <iddekingej@lycos.com>)
List 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 by date:

Previous
From: Jeroen van Iddekinge
Date:
Subject: creating the same table in 2 different sessions
Next
From: Jeroen van Iddekinge
Date:
Subject: strerror_r int and char* return type mixup on FC2