creating the same table in 2 different sessions

Started by Jeroen van Iddekingealmost 21 years ago1 messages
#1Jeroen van Iddekinge
iddekingej@lycos.com

Hi,

Maybe I found the following bug or 'not ideal behaviour' of
postgres(version 7.4.7 and 8.0 /linux):

first start asession 1

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"
So i think postgres first inserts into pg_class, but blocks in session 2
because of the unique the unique index on (relname,relnamespace). I just
wonder if it's safer to check if the table is being created in an other
session, 'block' until the session is commited block before starting any
insert or other action? Or when the error 'duplicate key violates unique
constraint "pg_class_relname_nsp_index"' hapens during creating of a
table ,raise the error 'duplicate key violates unique constraint
"pg_class_relname_nsp_index", maybe table allready exists' ?

Regards,

Jeroen