aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/sequence.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/sequence.c')
-rw-r--r--src/backend/commands/sequence.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index ffb7fcaba9d..fc2446997a7 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.167 2010/02/19 06:29:19 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.168 2010/02/20 21:24:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -459,9 +459,6 @@ nextval_internal(Oid relid)
rescnt = 0;
bool logit = false;
- /* nextval() writes to database and must be prevented during recovery */
- PreventCommandDuringRecovery();
-
/* open and AccessShareLock sequence */
init_sequence(relid, &elm, &seqrel);
@@ -472,6 +469,10 @@ nextval_internal(Oid relid)
errmsg("permission denied for sequence %s",
RelationGetRelationName(seqrel))));
+ /* read-only transactions may only modify temp sequences */
+ if (!seqrel->rd_islocaltemp)
+ PreventCommandIfReadOnly("nextval()");
+
if (elm->last != elm->cached) /* some numbers were cached */
{
Assert(elm->last_valid);
@@ -736,9 +737,6 @@ do_setval(Oid relid, int64 next, bool iscalled)
Buffer buf;
Form_pg_sequence seq;
- /* setval() writes to database and must be prevented during recovery */
- PreventCommandDuringRecovery();
-
/* open and AccessShareLock sequence */
init_sequence(relid, &elm, &seqrel);
@@ -748,6 +746,10 @@ do_setval(Oid relid, int64 next, bool iscalled)
errmsg("permission denied for sequence %s",
RelationGetRelationName(seqrel))));
+ /* read-only transactions may only modify temp sequences */
+ if (!seqrel->rd_islocaltemp)
+ PreventCommandIfReadOnly("setval()");
+
/* lock page' buffer and read tuple */
seq = read_info(elm, seqrel, &buf);