简体   繁体   中英

sequence nextval in read-only transactions- postgresql 9

i recently upgraded to postgresql9 from postgresql8. i have a method marked as @Transactional(readonly=true) and call nextval on the sequence. it worked fine in Postgres8 but it fails in Postgres9. I looked around but nothing concrete. did anyone encounter this problem. i could write a interceptor to change the transaction to write, but was wondering whether this is now a new restriction and can it be changed through some configuration setting on postgresq9

On 05/11/2011 02:29 PM, Dae-man Yang wrote:

I upgrade postgresql from 8.4.2 to 9.0.4. But I have one problem. The Error message 'cannot execute nextval() in a read-only transaction'

Please help me.

nextval() modifies a sequence, so you shouldn't be doing it in a read-only transaction. Pg 9.0.4 enforces this, but it was still a bug in whatever was trying to use nextval() in a read-only transaction before 9.0, Pg just didn't notice and warn you.

-- Craig Ringer

http://archives.postgresql.org/pgsql-general/2011-05/msg00373.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM