Search Postgresql Archives

Sequences change in a rolled-back transactions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux