| From: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> | 
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> | 
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org | 
| Subject: | Re: Identity columns should own only one sequence | 
| Date: | 2019-04-26 10:47:17 | 
| Message-ID: | 3916586ef7f33948235fe60f54a3750046f5d940.camel@cybertec.at | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On Thu, 2019-04-25 at 09:55 +0900, Michael Paquier wrote:
> 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?
You are right!  Dropping the dependency with the DEFAULT is the
cleanest approach.
I have left the checks to prevent double sequence ownership from
happening.
I added regression tests covering all added code.
Yours,
Laurenz Albe
| Attachment | Content-Type | Size | 
|---|---|---|
| 0001-Fix-interaction-of-owned-sequences-and-identity-colu.patch | text/x-patch | 9.8 KB | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2019-04-26 12:32:15 | Re: "Routine Reindexing" docs should be updated to reference REINDEX CONCURRENTLY | 
| Previous Message | Rajkumar Raghuwanshi | 2019-04-26 10:29:31 | Re: [HACKERS] advanced partition matching algorithm for partition-wise join |