SubTransactionId mySubid,
SubTransactionId parentSubid);
static void CleanupTransaction(void);
-static void CheckTransactionChain(bool isTopLevel, bool throwError,
+static void CheckTransactionBlock(bool isTopLevel, bool throwError,
const char *stmtType);
static void CommitTransaction(void);
static TransactionId RecordTransactionAbort(bool isSubXact);
}
/*
- * PreventTransactionChain
+ * PreventInTransactionBlock
*
* This routine is to be called by statements that must not run inside
* a transaction block, typically because they have non-rollback-able
* stmtType: statement type name, for error messages.
*/
void
-PreventTransactionChain(bool isTopLevel, const char *stmtType)
+PreventInTransactionBlock(bool isTopLevel, const char *stmtType)
{
/*
* xact block already started?
}
/*
- * WarnNoTranactionChain
- * RequireTransactionChain
+ * WarnNoTranactionBlock
+ * RequireTransactionBlock
*
* These two functions allow for warnings or errors if a command is executed
* outside of a transaction block. This is useful for commands that have no
* If we appear to be running inside a user-defined function, we do not
* issue anything, since the function could issue more commands that make
* use of the current statement's results. Likewise subtransactions.
- * Thus these are inverses for PreventTransactionChain.
+ * Thus these are inverses for PreventInTransactionBlock.
*
* isTopLevel: passed down from ProcessUtility to determine whether we are
* inside a function.
* stmtType: statement type name, for warning or error messages.
*/
void
-WarnNoTransactionChain(bool isTopLevel, const char *stmtType)
+WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
{
- CheckTransactionChain(isTopLevel, false, stmtType);
+ CheckTransactionBlock(isTopLevel, false, stmtType);
}
void
-RequireTransactionChain(bool isTopLevel, const char *stmtType)
+RequireTransactionBlock(bool isTopLevel, const char *stmtType)
{
- CheckTransactionChain(isTopLevel, true, stmtType);
+ CheckTransactionBlock(isTopLevel, true, stmtType);
}
/*
* This is the implementation of the above two.
*/
static void
-CheckTransactionChain(bool isTopLevel, bool throwError, const char *stmtType)
+CheckTransactionBlock(bool isTopLevel, bool throwError, const char *stmtType)
{
/*
* xact block already started?
}
/*
- * IsInTransactionChain
+ * IsInTransactionBlock
*
* This routine is for statements that need to behave differently inside
* a transaction block than when running as single commands. ANALYZE is
* inside a function.
*/
bool
-IsInTransactionChain(bool isTopLevel)
+IsInTransactionBlock(bool isTopLevel)
{
/*
- * Return true on same conditions that would make PreventTransactionChain
+ * Return true on same conditions that would make PreventInTransactionBlock
* error out
*/
if (IsTransactionBlock())
* We cannot run this form of CLUSTER inside a user transaction block;
* we'd be holding locks way too long.
*/
- PreventTransactionChain(isTopLevel, "CLUSTER");
+ PreventInTransactionBlock(isTopLevel, "CLUSTER");
/*
* Create special memory context for cross-transaction storage.
dtablespace->defname),
parser_errposition(pstate, dtablespace->location)));
/* this case isn't allowed within a transaction block */
- PreventTransactionChain(isTopLevel, "ALTER DATABASE SET TABLESPACE");
+ PreventInTransactionBlock(isTopLevel, "ALTER DATABASE SET TABLESPACE");
movedb(stmt->dbname, defGetString(dtablespace));
return InvalidOid;
}
* DISCARD ALL inside a transaction block would leave the transaction
* still uncommitted.
*/
- PreventTransactionChain(isTopLevel, "DISCARD ALL");
+ PreventInTransactionBlock(isTopLevel, "DISCARD ALL");
/* Closing portals might run user-defined code, so do that first. */
PortalHashTableDeleteAll();
* user-visible effect).
*/
if (!(cstmt->options & CURSOR_OPT_HOLD))
- RequireTransactionChain(isTopLevel, "DECLARE CURSOR");
+ RequireTransactionBlock(isTopLevel, "DECLARE CURSOR");
/*
* Parse analysis was done already, but we still have to run the rule
* replication slot.
*/
if (create_slot)
- PreventTransactionChain(isTopLevel, "CREATE SUBSCRIPTION ... WITH (create_slot = true)");
+ PreventInTransactionBlock(isTopLevel, "CREATE SUBSCRIPTION ... WITH (create_slot = true)");
if (!superuser())
ereport(ERROR,
* don't have the proper facilities for that.
*/
if (slotname)
- PreventTransactionChain(isTopLevel, "DROP SUBSCRIPTION");
+ PreventInTransactionBlock(isTopLevel, "DROP SUBSCRIPTION");
ObjectAddressSet(myself, SubscriptionRelationId, subid);
!(tup->t_data->t_infomask & HEAP_UPDATED))
/* safe to do inside transaction block */ ;
else
- PreventTransactionChain(isTopLevel, "ALTER TYPE ... ADD");
+ PreventInTransactionBlock(isTopLevel, "ALTER TYPE ... ADD");
AddEnumLabel(enum_type_oid, stmt->newVal,
stmt->newValNeighbor, stmt->newValIsAfter,
*/
if (options & VACOPT_VACUUM)
{
- PreventTransactionChain(isTopLevel, stmttype);
+ PreventInTransactionBlock(isTopLevel, stmttype);
in_outer_xact = false;
}
else
- in_outer_xact = IsInTransactionChain(isTopLevel);
+ in_outer_xact = IsInTransactionBlock(isTopLevel);
/*
* Due to static variables vac_context, anl_context and vac_strategy,
break;
case T_BaseBackupCmd:
- PreventTransactionChain(true, "BASE_BACKUP");
+ PreventInTransactionBlock(true, "BASE_BACKUP");
SendBaseBackup((BaseBackupCmd *) cmd_node);
break;
{
StartReplicationCmd *cmd = (StartReplicationCmd *) cmd_node;
- PreventTransactionChain(true, "START_REPLICATION");
+ PreventInTransactionBlock(true, "START_REPLICATION");
if (cmd->kind == REPLICATION_KIND_PHYSICAL)
StartReplication(cmd);
}
case T_TimeLineHistoryCmd:
- PreventTransactionChain(true, "TIMELINE_HISTORY");
+ PreventInTransactionBlock(true, "TIMELINE_HISTORY");
SendTimeLineHistory((TimeLineHistoryCmd *) cmd_node);
break;
break;
case TRANS_STMT_COMMIT_PREPARED:
- PreventTransactionChain(isTopLevel, "COMMIT PREPARED");
+ PreventInTransactionBlock(isTopLevel, "COMMIT PREPARED");
PreventCommandDuringRecovery("COMMIT PREPARED");
FinishPreparedTransaction(stmt->gid, true);
break;
case TRANS_STMT_ROLLBACK_PREPARED:
- PreventTransactionChain(isTopLevel, "ROLLBACK PREPARED");
+ PreventInTransactionBlock(isTopLevel, "ROLLBACK PREPARED");
PreventCommandDuringRecovery("ROLLBACK PREPARED");
FinishPreparedTransaction(stmt->gid, false);
break;
ListCell *cell;
char *name = NULL;
- RequireTransactionChain(isTopLevel, "SAVEPOINT");
+ RequireTransactionBlock(isTopLevel, "SAVEPOINT");
foreach(cell, stmt->options)
{
break;
case TRANS_STMT_RELEASE:
- RequireTransactionChain(isTopLevel, "RELEASE SAVEPOINT");
+ RequireTransactionBlock(isTopLevel, "RELEASE SAVEPOINT");
ReleaseSavepoint(stmt->options);
break;
case TRANS_STMT_ROLLBACK_TO:
- RequireTransactionChain(isTopLevel, "ROLLBACK TO SAVEPOINT");
+ RequireTransactionBlock(isTopLevel, "ROLLBACK TO SAVEPOINT");
RollbackToSavepoint(stmt->options);
/*
case T_CreateTableSpaceStmt:
/* no event triggers for global objects */
- PreventTransactionChain(isTopLevel, "CREATE TABLESPACE");
+ PreventInTransactionBlock(isTopLevel, "CREATE TABLESPACE");
CreateTableSpace((CreateTableSpaceStmt *) parsetree);
break;
case T_DropTableSpaceStmt:
/* no event triggers for global objects */
- PreventTransactionChain(isTopLevel, "DROP TABLESPACE");
+ PreventInTransactionBlock(isTopLevel, "DROP TABLESPACE");
DropTableSpace((DropTableSpaceStmt *) parsetree);
break;
case T_CreatedbStmt:
/* no event triggers for global objects */
- PreventTransactionChain(isTopLevel, "CREATE DATABASE");
+ PreventInTransactionBlock(isTopLevel, "CREATE DATABASE");
createdb(pstate, (CreatedbStmt *) parsetree);
break;
DropdbStmt *stmt = (DropdbStmt *) parsetree;
/* no event triggers for global objects */
- PreventTransactionChain(isTopLevel, "DROP DATABASE");
+ PreventInTransactionBlock(isTopLevel, "DROP DATABASE");
dropdb(stmt->dbname, stmt->missing_ok);
}
break;
break;
case T_AlterSystemStmt:
- PreventTransactionChain(isTopLevel, "ALTER SYSTEM");
+ PreventInTransactionBlock(isTopLevel, "ALTER SYSTEM");
AlterSystemSetConfigFile((AlterSystemStmt *) parsetree);
break;
* Since the lock would just get dropped immediately, LOCK TABLE
* outside a transaction block is presumed to be user error.
*/
- RequireTransactionChain(isTopLevel, "LOCK TABLE");
+ RequireTransactionBlock(isTopLevel, "LOCK TABLE");
/* forbidden in parallel mode due to CommandIsReadOnly */
LockTableCommand((LockStmt *) parsetree);
break;
case T_ConstraintsSetStmt:
- WarnNoTransactionChain(isTopLevel, "SET CONSTRAINTS");
+ WarnNoTransactionBlock(isTopLevel, "SET CONSTRAINTS");
AfterTriggerSetState((ConstraintsSetStmt *) parsetree);
break;
* start-transaction-command calls would not have the
* intended effect!
*/
- PreventTransactionChain(isTopLevel,
+ PreventInTransactionBlock(isTopLevel,
(stmt->kind == REINDEX_OBJECT_SCHEMA) ? "REINDEX SCHEMA" :
(stmt->kind == REINDEX_OBJECT_SYSTEM) ? "REINDEX SYSTEM" :
"REINDEX DATABASE");
List *inheritors = NIL;
if (stmt->concurrent)
- PreventTransactionChain(isTopLevel,
+ PreventInTransactionBlock(isTopLevel,
"CREATE INDEX CONCURRENTLY");
/*
{
case OBJECT_INDEX:
if (stmt->concurrent)
- PreventTransactionChain(isTopLevel,
+ PreventInTransactionBlock(isTopLevel,
"DROP INDEX CONCURRENTLY");
/* fall through */
case VAR_SET_VALUE:
case VAR_SET_CURRENT:
if (stmt->is_local)
- WarnNoTransactionChain(isTopLevel, "SET LOCAL");
+ WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
(void) set_config_option(stmt->name,
ExtractSetVariableArgs(stmt),
(superuser() ? PGC_SUSET : PGC_USERSET),
{
ListCell *head;
- WarnNoTransactionChain(isTopLevel, "SET TRANSACTION");
+ WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
foreach(head, stmt->args)
{
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
- WarnNoTransactionChain(isTopLevel, "SET TRANSACTION");
+ WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
Assert(nodeTag(&con->val) == T_String);
ImportSnapshot(strVal(&con->val));
}
break;
case VAR_SET_DEFAULT:
if (stmt->is_local)
- WarnNoTransactionChain(isTopLevel, "SET LOCAL");
+ WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
/* fall through */
case VAR_RESET:
if (strcmp(stmt->name, "transaction_isolation") == 0)
- WarnNoTransactionChain(isTopLevel, "RESET TRANSACTION");
+ WarnNoTransactionBlock(isTopLevel, "RESET TRANSACTION");
(void) set_config_option(stmt->name,
NULL,
char pathtmp[MAXPGPATH];
/*
- * It's tempting to call RequireTransactionChain here, since it's not very
+ * It's tempting to call RequireTransactionBlock here, since it's not very
* useful to export a snapshot that will disappear immediately afterwards.
* However, we haven't got enough information to do that, since we don't
* know if we're at top level or not. For example, we could be inside a
/*
* Commands not allowed within transactions. The statements checked for
- * here should be exactly those that call PreventTransactionChain() in the
+ * here should be exactly those that call PreventInTransactionBlock() in the
* backend.
*/
if (wordlen == 6 && pg_strncasecmp(query, "vacuum", 6) == 0)
extern bool IsTransactionOrTransactionBlock(void);
extern char TransactionBlockStatusCode(void);
extern void AbortOutOfAnyTransaction(void);
-extern void PreventTransactionChain(bool isTopLevel, const char *stmtType);
-extern void RequireTransactionChain(bool isTopLevel, const char *stmtType);
-extern void WarnNoTransactionChain(bool isTopLevel, const char *stmtType);
-extern bool IsInTransactionChain(bool isTopLevel);
+extern void PreventInTransactionBlock(bool isTopLevel, const char *stmtType);
+extern void RequireTransactionBlock(bool isTopLevel, const char *stmtType);
+extern void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType);
+extern bool IsInTransactionBlock(bool isTopLevel);
extern void RegisterXactCallback(XactCallback callback, void *arg);
extern void UnregisterXactCallback(XactCallback callback, void *arg);
extern void RegisterSubXactCallback(SubXactCallback callback, void *arg);