Hi group,

I just noticed getting the next number of a sequence doesn't respect a transaction.
Here is an example:
=======================================================
erwin=# SELECT nextval('tblofferlabel_offerlabelid_seq'::regclass) as nextofferlabelid;
nextofferlabelid
------------------
              87
(1 row)

erwin=# start transaction;
START TRANSACTION
erwin=# SELECT nextval('tblofferlabel_offerlabelid_seq'::regclass) as nextofferlabelid;
nextofferlabelid
------------------
              88
(1 row)

erwin=# SELECT nextval('tblofferlabel_offerlabelid_seq'::regclass) as nextofferlabelid;
 nextofferlabelid
------------------
              89
(1 row)

# rollback;
ROLLBACK

erwin=# SELECT nextval('tblofferlabel_offerlabelid_seq'::regclass) as nextofferlabelid;
nextofferlabelid
------------------
              90
=======================================================
As you can see the sequence just counts on outside the transaction.

I thought a transaction that is rolled back, rolls back *everything* done in that transaction.
Appearantly sequences are not included.

It is no big deal, since I can easily code this differently, but I was unpleasantly surprised. :-/
Can anybody comment on this behaviour? Am I missing something?

Thanks!

Regards,
Erwin Moller

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to