Re: unlogged sequences

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: unlogged sequences
Date: 2022-04-01 00:44:08
Message-ID: CAKFQuwa8qnzNQ_pzk19kvf3983j0N1r=OL2S2NzbuvjwHFXgjg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 31, 2022 at 5:25 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Thu, Mar 31, 2022 at 10:14 AM Tomas Vondra
> <tomas(dot)vondra(at)enterprisedb(dot)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.
>

It seems reasonable to extend the definition of "ownership of a sequence"
in this way. We always let you create unowned sequences with whatever
persistence you like if you need flexibility.

The "give the user power" argument is also valid. But since they already
have power through unowned sequences, having the owned sequences more
narrowly defined doesn't detract from usability, and in many ways enhances
it by further reinforcing the fact that the sequence internally used when
you say "GENERATED ALWAYS AS IDENTITY" is an implementation detail - one
that has the same persistence as the table.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-04-01 00:52:27 Re: [WIP] ALTER COLUMN IF EXISTS
Previous Message Tomas Vondra 2022-04-01 00:42:29 Re: unlogged sequences