Re: Identity columns should own only one sequence

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Identity columns should own only one sequence
Date: 2019-04-25 00:55:44
Message-ID: 20190425005544.GE8552@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Apr 14, 2019 at 05:51:47PM +0200, Laurenz Albe wrote:
> test=> INSERT INTO ser (id) VALUES (DEFAULT);
> ERROR: more than one owned sequence found

Yes this should never be user-triggerable, so it seems that we need to
fix and back-patch something if possible.

> I propose that we check if there already is a dependent sequence
> before adding an identity column.

That looks awkward. Souldn't we make sure that when dropping the
default associated with a serial column then the dependency between
the column and the sequence is removed instead? This implies more
complication in ATExecColumnDefault().

> The attached patch does that, and also forbids setting the ownership
> of a sequence to an identity column.
>
> I think this should be backpatched.

Could you add some test cases with what you think is adapted?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2019-04-25 01:11:04 Re: set relispartition when attaching child index
Previous Message Tom Lane 2019-04-25 00:55:01 Re: Calling PrepareTempTablespaces in BufFileCreateTemp