Re: ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists) - Mailing list pgsql-general

From Tom Lane
Subject Re: ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)
Date
Msg-id 3313.1301063377@sss.pgh.pa.us
Whole thread Raw
In response to ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)  ("Marc Mamin" <M.Mamin@intershop.de>)
Responses Re: ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)  (Peter Geoghegan <peter@2ndquadrant.com>)
List pgsql-general
"Marc Mamin" <M.Mamin@intershop.de> writes:
> By trying to create a sequence that already exists, I'd expect an error
> like
> relation "foo_20110307_id_seq" already exists,
> and not
> type "foo_20110307_id_seq" already

My recollection is that it's possible to get the latter if multiple
sessions try to create the same relation name concurrently.  The initial
check for "does the relation already exist" fails for both sessions,
so they plow ahead, and then you're at the mercy of timing as to whether
you get a unique-index violation on pg_class or pg_type.  It may well
also vary as to which PG version you're using.

            regards, tom lane

pgsql-general by date:

Previous
From: Luca Santaniello
Date:
Subject: Re: cursor with dinamic string
Next
From: Peter Geoghegan
Date:
Subject: Re: ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)