Re: unlogged sequences - Mailing list pgsql-hackers

From Robert Haas
Subject Re: unlogged sequences
Date
Msg-id CA+Tgmoaw0+S1HcUHu=OoRChXZT0HbJFBeR0Ty=ET+za3zLNAaQ@mail.gmail.com
Whole thread Raw
In response to Re: unlogged sequences  (Tomas Vondra <tomas.vondra@enterprisedb.com>)
Responses Re: unlogged sequences
Re: unlogged sequences
List pgsql-hackers
On Thu, Mar 31, 2022 at 10:14 AM Tomas Vondra
<tomas.vondra@enterprisedb.com> wrote:
> * When linking a sequence to a table (ALTER SEQUENCE ... OWNED BY),
> there's an ereport(ERROR) if the relpersistence values do not match.
>
> * Disallow changing persistence for owned sequences directly.

Wait, what? I don't understand why we would want to do either of these things.

It seems to me that it's totally fine to use a logged table with an
unlogged sequence, or an unlogged table with a logged sequence, or any
of the other combinations. You get what you ask for, so make sure to
ask for what you want. And that's it.

If you say something like CREATE [UNLOGGED] TABLE foo (a serial) it's
fine for serial to attribute the same persistence level to the
sequence as it does to the table. But when that's dumped, it's going
to be dumped as a CREATE TABLE command and a CREATE SEQUENCE command,
each of which has a separate persistence level. So you can recreate
whatever state you have.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: [WIP] ALTER COLUMN IF EXISTS
Next
From: Tom Lane
Date:
Subject: Re: [WIP] ALTER COLUMN IF EXISTS