Skip site navigation (1) Skip section navigation (2)

BUG #3692: Conflicting create table statements throw unexpected error

From: "Bill Moran" <wmoran(at)collaborativefusion(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3692: Conflicting create table statements throw unexpected error
Date: 2007-10-22 20:37:12
Message-ID: 200710222037.l9MKbCJZ098744@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      3692
Logged by:          Bill Moran
Email address:      wmoran(at)collaborativefusion(dot)com
PostgreSQL version: 8.2.5
Operating system:   FreeBSD
Description:        Conflicting create table statements throw unexpected
error
Details: 

(also occurs on 8.1.10)

Issuing a statement like:
CREATE TABLE table2 AS SELECT * FROM table1;

simultaneously in two separate sessions should result in an error like
"ERROR:  relation "table2" already exists" (in one or the other of the
sessions, depending on the exact timing of things).

However, if table1 has enough rows that the command takes a while to execute
(a few seconds seems to be all it takes) the error is far more cryptic:
ERROR: duplicate key violates unique constraint "pg_type_typname_nsp_index"

It seems to me that there's some sort of race condition that if the second
command starts before the first has completed, the backend doesn't really
understand what went wrong.

For a front end, this is tough to parse.  A "relation exists" error on a
table should probably be 42P07, but the duplicate key violation results in
23505, which means a front end will likely behave incorrectly.

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2007-10-22 21:44:59
Subject: Re: BUG #3692: Conflicting create table statements throw unexpected error
Previous:From: Tom LaneDate: 2007-10-22 17:05:47
Subject: Re: Cursor on an INTERSECT query assertion fails

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group