Brent Verner <brent@rcfile.org> writes:
> ISTM it would make sense to expose the sequence naming logic via
> a builtin function, such as pg_serialseq(table,column)?
That might seem cleaner, but I think there's a hidden gotcha: it nails
down a presumption that the sequence name is a function of the table
name, column name, and nothing else. So I think it'd actually make it
harder rather than easier for us to make the sorts of changes we might
want to make in future. (F'r instance, we might add an OID into the
name to prevent collisions.)
I believe that the surprising-name problem will largely go away anyway
as soon as we get around to increasing the default NAMEDATALEN. With
a decent name length no one would ever see truncation in practice.
Also, of course, what we really want is for SERIAL sequences to get
dropped by themselves when the parent table is dropped, and then users
don't need to know what the generated sequence name is ...
regards, tom lane