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

From antoine@goutenoir.com
Subject BUG #12991: RESTART IDENTITY is not doing anything
Date
Msg-id 20150407040756.2552.47640@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #12991: RESTART IDENTITY is not doing anything  (Andres Freund <andres@anarazel.de>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      12991
Logged by:          Goutte
Email address:      antoine@goutenoir.com
PostgreSQL version: 9.3.6
Operating system:   Linux 3.13.0-45-generic x86_64 GNU/Linux
Description:

The bug is pretty straightforward, the doc is crystal clear about the role
of RESTART IDENTITY, and this is not listed is the known bugs.

For my test suite, I have to restart the identity sequences while
truncating.

I need the TRUNCATE to CASCADE too, but I don't know if it is meaningful.

Example, say Article has `id` as primary key :

TRUNCATE TABLE Article RESTART IDENTITY CASCADE;


On the next insertion, the sequence will continue from where it was before
instead of being resetted. The table is successfully truncated, though.

I solve it by doing, right after :
ALTER SEQUENCE Article_id_seq RESTART WITH 1;

This works and restarts the sequence.

---

I observe this behavior (or non-behavior in this case) on the cli using the
`psql` binary, and programmatically in PHP, so I'm sure this is not my
connector acting up.

---

Please note that I'm a pgSQL absolute noob (first day), and I'm using it
because of the awesome `earthdistances` extension.

Maybe I missed something obvious !

Good day to you,

Antoine

pgsql-bugs by date:

Previous
From: kingter wang
Date:
Subject: Re: pg_rewind test could not run in 'remote' mode
Next
From: Kingter Wang
Date:
Subject: pg_rewind TAP tests won't run in 'remote' mode