problem with serial - Mailing list pgsql-general

From Yvon Thoraval
Subject problem with serial
Date
Msg-id CAG6bkBysE_cFdfpWAg0=OWoV3U=rYnhF55gnYwbZFVQHQVL1iA@mail.gmail.com
Whole thread Raw
Responses Re: problem with serial  (Adrian Klaver <adrian.klaver@gmail.com>)
Re: problem with serial  (Alban Hertroys <haramrae@gmail.com>)
Re: problem with serial  (Chris Angelico <rosuav@gmail.com>)
List pgsql-general
i do have a serial named 'rowid' it is of "SERIAL PRIMARY KEY" in a table 'items'.

if i delete some of the rows i can't anymore insert afterwards.

even if i rearrange de sequence by :

"SELECT MAX(rowid) FROM items;";
"SELECT last_value FROM items_rowid_seq;";
then if last_value is lower than MAX(rowid) i set it to MAX(rowid) :
"SELECT setval('items_rowid_seq', max(rowid)) FROM items;";

and even after that i get an error when inserting by :
"INSERT ... RETURNING rowid;"

here I'm not only unable to read back the rowid but also inserion failed.

why ?
--
Yvon


pgsql-general by date:

Previous
From: Chris
Date:
Subject: Re: Performance degrades until dump/restore
Next
From: Adrian Klaver
Date:
Subject: Re: problem with serial