creating the same table in 2 different sessions

From: Jeroen van Iddekinge <iddekingej(at)lycos(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: creating the same table in 2 different sessions
Date: 2005-02-13 10:57:56
Message-ID: 420F32B4.1060400@lycos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeroen van Iddekinge 2005-02-13 13:56:21 strerror_r int and char* return type mixup on FC2
Previous Message Tom Lane 2005-02-13 10:24:27 Re: creating the same table in 2 different sessions