Re: [HACKERS] Unused(?) field Form_pg_sequence.sequence_name, not updated by seq rename

2015-12-14 Thread Simon Riggs
On 15 December 2015 at 04:40, Craig Ringer  wrote:


> It gets written as part of the Form_pg_sequence each time we write a
> sequence advance to WAL, but just seems to be a waste of space.
>

Agreed


> Am I missing something obvious or should it just be removed? Or perhaps
> replaced with the sequence's Oid in pg_class, since that'd be quite handy
> for logical decoding of sequences.
>

If the name is wrong then probably other fields are wrong also when we do
ALTER SEQUENCE?

We should add the fields you need, but don't alter anything in
Form_pg_sequence.

-- 
Simon Riggshttp://www.2ndQuadrant.com/

PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


[HACKERS] Unused(?) field Form_pg_sequence.sequence_name, not updated by seq rename

2015-12-14 Thread Craig Ringer
Hi all

Does anyone know why Form_pg_sequence has a field sequence_name that
duplicates the sequence's name from pg_class ?

It's assigned when the sequence is created by copying it from pg_class. It
isn't subsequently referenced anywhere as far as I can see. It isn't
updated by ALTER SEQUENCE ... RENAME TO, so it isn't necessarily actually
the correct sequence name either.

It gets written as part of the Form_pg_sequence each time we write a
sequence advance to WAL, but just seems to be a waste of space.

Am I missing something obvious or should it just be removed? Or perhaps
replaced with the sequence's Oid in pg_class, since that'd be quite handy
for logical decoding of sequences.

If we need to keep it for some reason then it should probably be updated by
ALTER SEQUENCE.

(Arose out of
http://www.postgresql.org/message-id/CAMsr+YHSxwZA-xHsgNLpA_DbTywVQYDX8CUjBZ9Sbr=d7xc...@mail.gmail.com
)

-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Re: [HACKERS] Unused(?) field Form_pg_sequence.sequence_name, not updated by seq rename

2015-12-14 Thread Tom Lane
Craig Ringer  writes:
> Does anyone know why Form_pg_sequence has a field sequence_name that
> duplicates the sequence's name from pg_class ?

It's historical, for sure.  We won't be removing it in the foreseeable
future because of on-disk-compatibility issues.  But you might want to
read the pghackers archives, five or ten years back, where we speculated
about redoing sequences to combine them all into one system catalog
(ie, store one row per sequence not one relation per).  Aside from
application compatibility issues, the stumbling block seemed to be how to
separate transactional from nontransactional updates.  That particular
problem is also why ALTER SEQUENCE RENAME can't update the sequence's copy
of the relation name: the wrong things happen if you roll back.

regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Unused(?) field Form_pg_sequence.sequence_name, not updated by seq rename

2015-12-14 Thread Michael Paquier
On Tue, Dec 15, 2015 at 2:05 PM, Tom Lane  wrote:
> Craig Ringer  writes:
>> Does anyone know why Form_pg_sequence has a field sequence_name that
>> duplicates the sequence's name from pg_class ?
>
> It's historical, for sure.  We won't be removing it in the foreseeable
> future because of on-disk-compatibility issues.  But you might want to
> read the pghackers archives, five or ten years back, where we speculated
> about redoing sequences to combine them all into one system catalog
> (ie, store one row per sequence not one relation per).  Aside from
> application compatibility issues, the stumbling block seemed to be how to
> separate transactional from nontransactional updates.  That particular
> problem is also why ALTER SEQUENCE RENAME can't update the sequence's copy
> of the relation name: the wrong things happen if you roll back.

That's a little bit older than 5/10 years visibly, see commit 7415105.
But yes as the sequence data is stored as a single always-visible
tuple on its relfilenode, there is no way to remove it without
breaking on-disk compatibility, but moving back in time, it would have
been surely possible to rely on the sequence OID instead.
-- 
Michael


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers