BUG #12991: RESTART IDENTITY is not doing anything

From: antoine(at)goutenoir(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #12991: RESTART IDENTITY is not doing anything
Date: 2015-04-07 04:07:56
Message-ID: 20150407040756.2552.47640@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 12991
Logged by: Goutte
Email address: antoine(at)goutenoir(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2015-04-07 06:18:31 Re: PQexec() hangs on OOM
Previous Message Peter Eisentraut 2015-04-06 19:59:49 Re: src/port/getopt_long.c lossy with arguments having no option characters