Re: ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)
Date: 2011-03-25 14:29:37
Message-ID: 3313.1301063377@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Marc Mamin" <M(dot)Mamin(at)intershop(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2011-03-25 14:48:22 Re: ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)
Previous Message Marco 2011-03-25 14:10:26 Re: Need help for constructing query