Re: pgsql-server: Clean up generation of default names

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql-server: Clean up generation of default names
Date: 2004-06-11 01:34:14
Message-ID: 17633.1086917654@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> writes:
>> Clean up generation of default names for constraints, indexes, and serial
>> sequences, as per recent discussion.

> Do you do any sort of 'locking of potential names' to ensure that
> another process adding a sequence at the same time or something won't
> get the same name first, causing yours to still fail or break uniqueness?

It's not 100% bulletproof, but I'd say that in practice I don't expect
any problems. For instance, since all the generated names start with
the base relation name, in the absence of truncation there can't be any
such conflict --- ALTER TABLE will be holding an exclusive lock on the
base relation, and in the CREATE TABLE case you're going to die on the
base relation name conflict anyway.

If you use sufficiently long table/field names then different tables
could truncate to the same generated names, and in that case there's
some risk of concurrently choosing the same "unique" name. But I don't
recall anyone having complained of that since we started using this
technique for choosing index names, so I'm not very worried. Basically
what this commit did was propagate the index naming technique to
constraints and sequences.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2004-06-11 01:49:25 Re: [COMMITTERS] pgsql-server: Clean up generation of default names
Previous Message Tom Lane 2004-06-11 01:27:39 Re: pgsql-server: Fix oversight in recent ALTER TABLE

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2004-06-11 01:49:25 Re: [COMMITTERS] pgsql-server: Clean up generation of default names
Previous Message Tom Lane 2004-06-11 01:19:39 Re: Delaying the planning of unnamed statements until Bind