]> granicus.if.org Git - postgresql/commitdiff
Rename TransactionChain functions
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 17 Feb 2018 01:44:15 +0000 (20:44 -0500)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 16 Mar 2018 17:18:06 +0000 (13:18 -0400)
We call this thing a "transaction block" everywhere except in a few
functions, where it is mysteriously called a "transaction chain".  In
the SQL standard, a transaction chain is something different.  So rename
these functions to match the common terminology.

Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
14 files changed:
src/backend/access/transam/xact.c
src/backend/commands/cluster.c
src/backend/commands/dbcommands.c
src/backend/commands/discard.c
src/backend/commands/portalcmds.c
src/backend/commands/subscriptioncmds.c
src/backend/commands/typecmds.c
src/backend/commands/vacuum.c
src/backend/replication/walsender.c
src/backend/tcop/utility.c
src/backend/utils/misc/guc.c
src/backend/utils/time/snapmgr.c
src/bin/psql/common.c
src/include/access/xact.h

index df7c8ebea1efdbd046579aa6a87008426748ec41..49d4decc71083bab42e7559c0f7e0e0a8cf3c715 100644 (file)
@@ -310,7 +310,7 @@ static void CallSubXactCallbacks(SubXactEvent event,
                                         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);
@@ -3134,7 +3134,7 @@ AbortCurrentTransaction(void)
 }
 
 /*
- *     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
@@ -3151,7 +3151,7 @@ AbortCurrentTransaction(void)
  *     stmtType: statement type name, for error messages.
  */
 void
-PreventTransactionChain(bool isTopLevel, const char *stmtType)
+PreventInTransactionBlock(bool isTopLevel, const char *stmtType)
 {
        /*
         * xact block already started?
@@ -3190,8 +3190,8 @@ PreventTransactionChain(bool isTopLevel, const char *stmtType)
 }
 
 /*
- *     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
@@ -3204,29 +3204,29 @@ PreventTransactionChain(bool isTopLevel, const char *stmtType)
  *     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?
@@ -3255,7 +3255,7 @@ CheckTransactionChain(bool isTopLevel, bool throwError, const char *stmtType)
 }
 
 /*
- *     IsInTransactionChain
+ *     IsInTransactionBlock
  *
  *     This routine is for statements that need to behave differently inside
  *     a transaction block than when running as single commands.  ANALYZE is
@@ -3265,10 +3265,10 @@ CheckTransactionChain(bool isTopLevel, bool throwError, const char *stmtType)
  *     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())
index 5d481dd50de4bf665ca56aaa947bfc785afe733b..96a51bb7603cb546e798a6dabbba4734b7aa5908 100644 (file)
@@ -202,7 +202,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
                 * 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.
index d1718f04eeccf0717db18fcec1bcd5e272c457f8..5342f217c028da722d3918022d629fae5e793b6c 100644 (file)
@@ -1476,7 +1476,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
                                                        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;
        }
index 353ec990af3905ce3f7c5c72db5e5ed7dcf00791..01a999c2ac7d72279ff72a72b9a7ac235ec79766 100644 (file)
@@ -63,7 +63,7 @@ DiscardAll(bool isTopLevel)
         * 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();
index 6ecaea14433ceeafbacd3905f8c0c064e975dbca..73821502ba689ffe7eb051e1ebeeaf5a2434faa6 100644 (file)
@@ -63,7 +63,7 @@ PerformCursorOpen(DeclareCursorStmt *cstmt, ParamListInfo params,
         * 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
index 9de5969302200106c11d2b86234c0f3ee7de45d8..2694e1b2d746ff714b25fdcbd8bc38fd3717b31c 100644 (file)
@@ -339,7 +339,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
         * 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,
@@ -897,7 +897,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
         * don't have the proper facilities for that.
         */
        if (slotname)
-               PreventTransactionChain(isTopLevel, "DROP SUBSCRIPTION");
+               PreventInTransactionBlock(isTopLevel, "DROP SUBSCRIPTION");
 
 
        ObjectAddressSet(myself, SubscriptionRelationId, subid);
index bf3cd3a4546c84d676cd53e4884aedc61e540a1c..e375af4cd012b704e9f468168bd8de0e2f1bb63a 100644 (file)
@@ -1321,7 +1321,7 @@ AlterEnum(AlterEnumStmt *stmt, bool isTopLevel)
                        !(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,
index 18b3966a1f7d4a024d9966705b412d79ab5f9b92..3985c4dd0e50b6c66c61a7016191b22c3b8a2fec 100644 (file)
@@ -186,11 +186,11 @@ vacuum(int options, List *relations, VacuumParams *params,
         */
        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,
index d46374ddce9c70bb9f99d962a4b10d9017a4a90a..5f52e3320799b3e198a713753ec968bfd5127cf9 100644 (file)
@@ -1516,7 +1516,7 @@ exec_replication_command(const char *cmd_string)
                        break;
 
                case T_BaseBackupCmd:
-                       PreventTransactionChain(true, "BASE_BACKUP");
+                       PreventInTransactionBlock(true, "BASE_BACKUP");
                        SendBaseBackup((BaseBackupCmd *) cmd_node);
                        break;
 
@@ -1532,7 +1532,7 @@ exec_replication_command(const char *cmd_string)
                        {
                                StartReplicationCmd *cmd = (StartReplicationCmd *) cmd_node;
 
-                               PreventTransactionChain(true, "START_REPLICATION");
+                               PreventInTransactionBlock(true, "START_REPLICATION");
 
                                if (cmd->kind == REPLICATION_KIND_PHYSICAL)
                                        StartReplication(cmd);
@@ -1542,7 +1542,7 @@ exec_replication_command(const char *cmd_string)
                        }
 
                case T_TimeLineHistoryCmd:
-                       PreventTransactionChain(true, "TIMELINE_HISTORY");
+                       PreventInTransactionBlock(true, "TIMELINE_HISTORY");
                        SendTimeLineHistory((TimeLineHistoryCmd *) cmd_node);
                        break;
 
index 6effe031f858ceec459e1965e1395f41e82fc3de..81881be1d515822f3742cf8386e7697aeba79b33 100644 (file)
@@ -453,13 +453,13 @@ standard_ProcessUtility(PlannedStmt *pstmt,
                                                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;
@@ -473,7 +473,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
                                                        ListCell   *cell;
                                                        char       *name = NULL;
 
-                                                       RequireTransactionChain(isTopLevel, "SAVEPOINT");
+                                                       RequireTransactionBlock(isTopLevel, "SAVEPOINT");
 
                                                        foreach(cell, stmt->options)
                                                        {
@@ -490,12 +490,12 @@ standard_ProcessUtility(PlannedStmt *pstmt,
                                                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);
 
                                                /*
@@ -536,13 +536,13 @@ standard_ProcessUtility(PlannedStmt *pstmt,
 
                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;
 
@@ -592,7 +592,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
 
                case T_CreatedbStmt:
                        /* no event triggers for global objects */
-                       PreventTransactionChain(isTopLevel, "CREATE DATABASE");
+                       PreventInTransactionBlock(isTopLevel, "CREATE DATABASE");
                        createdb(pstate, (CreatedbStmt *) parsetree);
                        break;
 
@@ -611,7 +611,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
                                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;
@@ -690,7 +690,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
                        break;
 
                case T_AlterSystemStmt:
-                       PreventTransactionChain(isTopLevel, "ALTER SYSTEM");
+                       PreventInTransactionBlock(isTopLevel, "ALTER SYSTEM");
                        AlterSystemSetConfigFile((AlterSystemStmt *) parsetree);
                        break;
 
@@ -756,13 +756,13 @@ standard_ProcessUtility(PlannedStmt *pstmt,
                         * 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;
 
@@ -808,7 +808,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
                                                 * 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");
@@ -1307,7 +1307,7 @@ ProcessUtilitySlow(ParseState *pstate,
                                        List       *inheritors = NIL;
 
                                        if (stmt->concurrent)
-                                               PreventTransactionChain(isTopLevel,
+                                               PreventInTransactionBlock(isTopLevel,
                                                                                                "CREATE INDEX CONCURRENTLY");
 
                                        /*
@@ -1715,7 +1715,7 @@ ExecDropStmt(DropStmt *stmt, bool isTopLevel)
        {
                case OBJECT_INDEX:
                        if (stmt->concurrent)
-                               PreventTransactionChain(isTopLevel,
+                               PreventInTransactionBlock(isTopLevel,
                                                                                "DROP INDEX CONCURRENTLY");
                        /* fall through */
 
index 4116c2d66ac4309dc11c3e1eefd8820ec7f53308..4685cef51227300fe0a32774d87b56d4be365c22 100644 (file)
@@ -7348,7 +7348,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
                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),
@@ -7368,7 +7368,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
                        {
                                ListCell   *head;
 
-                               WarnNoTransactionChain(isTopLevel, "SET TRANSACTION");
+                               WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
 
                                foreach(head, stmt->args)
                                {
@@ -7419,7 +7419,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
                                                        (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));
                        }
@@ -7429,11 +7429,11 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
                        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,
index e58c69dbd73410f6f7268d73145414a1f9f9bf9a..4b45d3cccd29af65c3af9da974d34c9cedbdf855 100644 (file)
@@ -1171,7 +1171,7 @@ ExportSnapshot(Snapshot snapshot)
        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
index 1c82180efb3eb261b24cb6d6c5215f88abbd9f13..2b1c4dacedacf635175ac4f6d79d5d7dd789486a 100644 (file)
@@ -2047,7 +2047,7 @@ command_no_begin(const char *query)
 
        /*
         * 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)
index 6445bbc46f3e062f558b5dfe9723a886a97a80cb..4a1307a4f01d748cb926154d60f554205c24f3ec 100644 (file)
@@ -369,10 +369,10 @@ extern bool IsTransactionBlock(void);
 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);