When a sequence is created in 7.3.2, it appears you get a new table for each 
sequence object.  Is it ever possible for the sequence_name in a sequence 
relation not to match the name of the relation itself?

For example, suppose I create a table:  

	CREATE TABLE t1(id serial);

A new relation called 't1_id_seq' is created where 

	t1_id_seq.sequence_name = 't1_id_seq'

Is that always true?

Ed


Fri, 4 Apr 2003 09:52:13 -0700
"Ed L." <pgsql@bluepolka.net>
<sequence_name>.sequence_name != <sequence_name>?
"Ed L." <pgsql@bluepolka.net> writes:
> When a sequence is created in 7.3.2, it appears you get a new table for each 
> sequence object.  Is it ever possible for the sequence_name in a sequence 
> relation not to match the name of the relation itself?

ALTER TABLE RENAME on a sequence doesn't update the sequence_name.

I think someone looked at doing that update, but we concluded it was too
messy (mainly because ALTER RENAME is transactional but updates to a
sequence tuple aren't).

In general I'd counsel that you should ignore the sequence_name field
anyway.  It's vestigial.

			regards, tom lane


Fri, 04 Apr 2003 12:24:12 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: <sequence_name>.sequence_name != <sequence_name>? 
On Friday April 4 2003 10:24, Tom Lane wrote:
> "Ed L." <pgsql@bluepolka.net> writes:
> > When a sequence is created in 7.3.2, it appears you get a new table for
> > each sequence object.  Is it ever possible for the sequence_name in a
> > sequence relation not to match the name of the relation itself?
>
> In general I'd counsel that you should ignore the sequence_name field
> anyway.  It's vestigial.

A related question:  Is there a single generalized SQL query which can yield 
the set of (sequence_name, last_value) pairs for all sequence objects?  The 
fact that each sequence is its own relation seems to block that, and the 
query constructed from grabbing sequence names from pg_class gets quite 
long for more than just a few sequence objects...

Ed


Fri, 4 Apr 2003 11:27:36 -0700
"Ed L." <pgsql@bluepolka.net>
Re: <sequence_name>.sequence_name != <sequence_name>?