Re: pgsql-server: Clean up generation of default names - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql-server: Clean up generation of default names
Date
Msg-id 17633.1086917654@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql-server: Clean up generation of default names  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
List pgsql-committers
Christopher Kings-Lynne <chriskl@familyhealth.com.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

pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgsql-server: Fix oversight in recent ALTER TABLE
Next
From: momjian@svr1.postgresql.org (Bruce Momjian)
Date:
Subject: pgsql-server: This patch updates pgpipe() on win32 to log exactly which