aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/async.c5
-rw-r--r--src/backend/commands/copy.c6
-rw-r--r--src/backend/commands/lockcmds.c4
-rw-r--r--src/backend/commands/sequence.c16
4 files changed, 17 insertions, 14 deletions
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 8a31182c997..c7b60de32a9 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.153 2010/02/17 16:54:06 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.154 2010/02/20 21:24:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -534,6 +534,9 @@ pg_notify(PG_FUNCTION_ARGS)
else
payload = text_to_cstring(PG_GETARG_TEXT_PP(1));
+ /* For NOTIFY as a statement, this is checked in ProcessUtility */
+ PreventCommandDuringRecovery("NOTIFY");
+
Async_Notify(channel, payload);
PG_RETURN_VOID();
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 1ed287306a9..fbcc4afb968 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.324 2010/02/08 04:33:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.325 2010/02/20 21:24:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1023,9 +1023,7 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
/* check read-only transaction */
if (XactReadOnly && is_from && !cstate->rel->rd_islocaltemp)
- ereport(ERROR,
- (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION),
- errmsg("transaction is read-only")));
+ PreventCommandIfReadOnly("COPY FROM");
/* Don't allow COPY w/ OIDs to or from a table without them */
if (cstate->oids && !cstate->rel->rd_rel->relhasoids)
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index f40365ac8fc..31096e0beb6 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.27 2010/01/02 16:57:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.28 2010/02/20 21:24:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -55,7 +55,7 @@ LockTableCommand(LockStmt *lockstmt)
* This test must match the restrictions defined in LockAcquire()
*/
if (lockstmt->mode > RowExclusiveLock)
- PreventCommandDuringRecovery();
+ PreventCommandDuringRecovery("LOCK TABLE");
LockTableRecurse(reloid, relation,
lockstmt->mode, lockstmt->nowait, recurse);
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);