Re: BUG #12991: RESTART IDENTITY is not doing anything - Mailing list pgsql-bugs

From Antoine Goutenoir
Subject Re: BUG #12991: RESTART IDENTITY is not doing anything
Date
Msg-id CAHgP0U0dPPgkUFvY7XZnFKxkFtgkyiX+RZZiG4OfA0Nnwwr4tw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #12991: RESTART IDENTITY is not doing anything  (Andres Freund <andres@anarazel.de>)
Responses Re: BUG #12991: RESTART IDENTITY is not doing anything  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
On Tue, Apr 7, 2015 at 5:02 PM, Andres Freund <andres@anarazel.de> wrote:

> On 2015-04-07 04:07:56 +0000, antoine@goutenoir.com wrote:
> > Example, say Article has `id` as primary key :
>
> How is that table defined? Restart identity will only work if the
> sequence is 'owned' by the id column. That happens if you either create
> it by specifying 'serial' as the column type, or if you explicitly use
> ALTER SEQUENCE ... OWNED BY table.col;
>

Oh, I created (actually, Doctrine created) those with :

CREATE TABLE Article (id INT NOT NULL, name VARCHAR(16) NOT NULL, PRIMARY
KEY(id));
CREATE SEQUENCE Article_id_seq INCREMENT BY 1 MINVALUE 1 START 1;

Instead of :

CREATE SEQUENCE Article_id_seq INCREMENT BY 1 MINVALUE 1 START 1 OWNED BY
Article.id;

---

I did not knew about "ownership" of sequences, because the id incremented
so I thought the system knew what field to alter through the sequence name.

Thanks for the tip, I'll fork Doctrine to add it if there's no BC break
ripple effect resulting from the change.

Sorry about the bother,

Antoine

pgsql-bugs by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: BUG #12992: Failure to start: too many private dirs demanded
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #12991: RESTART IDENTITY is not doing anything