Re: determine sequence name for a serial - Mailing list pgsql-general

From Greg Stark
Subject Re: determine sequence name for a serial
Date
Msg-id 87u0seqtx4.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: determine sequence name for a serial  ("Ed L." <pgsql@bluepolka.net>)
Responses Re: determine sequence name for a serial  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
List pgsql-general
"Ed L." <pgsql@bluepolka.net> writes:

> In PostgreSQL, at least for the past 5 years if not longer, if you create a
> SERIAL column for (schemaname, tablename, columnname), then your sequence
> will *always* be "schemaname.tablename_columnname_seq". If that naming
> convention changes, there will be a whole lotta breakage world-wide.

I hope you're wrong about people expecting that to be true because it isn't.
The resulting sequence name is limited to 63 characters and gets truncated if
it goes over. (63!? was it intended to be 64?) I believe the limit used to be
32 characters too.

In any case it's just plain good design to avoid unnecessary
interrelationships between different parts of the code. Practically speaking
it makes renaming something not involve an error-prone search and replace.
More importantly it makes it easier to verify that a piece of code is correct
without having to hunt down all the related bits to be sure the relationships
are correct. It also makes it possible to reuse or refactor the code.

--
greg

pgsql-general by date:

Previous
From: "Ed L."
Date:
Subject: Re: determine sequence name for a serial
Next
From: Jerry LeVan
Date:
Subject: Upgrading from beta3 to beta4