Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit04700b6

Browse files
committed
Rename TransactionChain functions
We call this thing a "transaction block" everywhere except in a fewfunctions, where it is mysteriously called a "transaction chain". Inthe SQL standard, a transaction chain is something different. So renamethese functions to match the common terminology.Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
1 parent8d47a90 commit04700b6

File tree

14 files changed

+52
-52
lines changed

14 files changed

+52
-52
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static void CallSubXactCallbacks(SubXactEvent event,
310310
SubTransactionIdmySubid,
311311
SubTransactionIdparentSubid);
312312
staticvoidCleanupTransaction(void);
313-
staticvoidCheckTransactionChain(boolisTopLevel,boolthrowError,
313+
staticvoidCheckTransactionBlock(boolisTopLevel,boolthrowError,
314314
constchar*stmtType);
315315
staticvoidCommitTransaction(void);
316316
staticTransactionIdRecordTransactionAbort(boolisSubXact);
@@ -3134,7 +3134,7 @@ AbortCurrentTransaction(void)
31343134
}
31353135

31363136
/*
3137-
*PreventTransactionChain
3137+
*PreventInTransactionBlock
31383138
*
31393139
*This routine is to be called by statements that must not run inside
31403140
*a transaction block, typically because they have non-rollback-able
@@ -3151,7 +3151,7 @@ AbortCurrentTransaction(void)
31513151
*stmtType: statement type name, for error messages.
31523152
*/
31533153
void
3154-
PreventTransactionChain(boolisTopLevel,constchar*stmtType)
3154+
PreventInTransactionBlock(boolisTopLevel,constchar*stmtType)
31553155
{
31563156
/*
31573157
* xact block already started?
@@ -3190,8 +3190,8 @@ PreventTransactionChain(bool isTopLevel, const char *stmtType)
31903190
}
31913191

31923192
/*
3193-
*WarnNoTranactionChain
3194-
*RequireTransactionChain
3193+
*WarnNoTranactionBlock
3194+
*RequireTransactionBlock
31953195
*
31963196
*These two functions allow for warnings or errors if a command is executed
31973197
*outside of a transaction block. This is useful for commands that have no
@@ -3204,29 +3204,29 @@ PreventTransactionChain(bool isTopLevel, const char *stmtType)
32043204
*If we appear to be running inside a user-defined function, we do not
32053205
*issue anything, since the function could issue more commands that make
32063206
*use of the current statement's results. Likewise subtransactions.
3207-
*Thus these are inverses forPreventTransactionChain.
3207+
*Thus these are inverses forPreventInTransactionBlock.
32083208
*
32093209
*isTopLevel: passed down from ProcessUtility to determine whether we are
32103210
*inside a function.
32113211
*stmtType: statement type name, for warning or error messages.
32123212
*/
32133213
void
3214-
WarnNoTransactionChain(boolisTopLevel,constchar*stmtType)
3214+
WarnNoTransactionBlock(boolisTopLevel,constchar*stmtType)
32153215
{
3216-
CheckTransactionChain(isTopLevel, false,stmtType);
3216+
CheckTransactionBlock(isTopLevel, false,stmtType);
32173217
}
32183218

32193219
void
3220-
RequireTransactionChain(boolisTopLevel,constchar*stmtType)
3220+
RequireTransactionBlock(boolisTopLevel,constchar*stmtType)
32213221
{
3222-
CheckTransactionChain(isTopLevel, true,stmtType);
3222+
CheckTransactionBlock(isTopLevel, true,stmtType);
32233223
}
32243224

32253225
/*
32263226
* This is the implementation of the above two.
32273227
*/
32283228
staticvoid
3229-
CheckTransactionChain(boolisTopLevel,boolthrowError,constchar*stmtType)
3229+
CheckTransactionBlock(boolisTopLevel,boolthrowError,constchar*stmtType)
32303230
{
32313231
/*
32323232
* xact block already started?
@@ -3255,7 +3255,7 @@ CheckTransactionChain(bool isTopLevel, bool throwError, const char *stmtType)
32553255
}
32563256

32573257
/*
3258-
*IsInTransactionChain
3258+
*IsInTransactionBlock
32593259
*
32603260
*This routine is for statements that need to behave differently inside
32613261
*a transaction block than when running as single commands. ANALYZE is
@@ -3265,10 +3265,10 @@ CheckTransactionChain(bool isTopLevel, bool throwError, const char *stmtType)
32653265
*inside a function.
32663266
*/
32673267
bool
3268-
IsInTransactionChain(boolisTopLevel)
3268+
IsInTransactionBlock(boolisTopLevel)
32693269
{
32703270
/*
3271-
* Return true on same conditions that would makePreventTransactionChain
3271+
* Return true on same conditions that would makePreventInTransactionBlock
32723272
* error out
32733273
*/
32743274
if (IsTransactionBlock())

‎src/backend/commands/cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
202202
* We cannot run this form of CLUSTER inside a user transaction block;
203203
* we'd be holding locks way too long.
204204
*/
205-
PreventTransactionChain(isTopLevel,"CLUSTER");
205+
PreventInTransactionBlock(isTopLevel,"CLUSTER");
206206

207207
/*
208208
* Create special memory context for cross-transaction storage.

‎src/backend/commands/dbcommands.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
14761476
dtablespace->defname),
14771477
parser_errposition(pstate,dtablespace->location)));
14781478
/* this case isn't allowed within a transaction block */
1479-
PreventTransactionChain(isTopLevel,"ALTER DATABASE SET TABLESPACE");
1479+
PreventInTransactionBlock(isTopLevel,"ALTER DATABASE SET TABLESPACE");
14801480
movedb(stmt->dbname,defGetString(dtablespace));
14811481
returnInvalidOid;
14821482
}

‎src/backend/commands/discard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ DiscardAll(bool isTopLevel)
6363
* DISCARD ALL inside a transaction block would leave the transaction
6464
* still uncommitted.
6565
*/
66-
PreventTransactionChain(isTopLevel,"DISCARD ALL");
66+
PreventInTransactionBlock(isTopLevel,"DISCARD ALL");
6767

6868
/* Closing portals might run user-defined code, so do that first. */
6969
PortalHashTableDeleteAll();

‎src/backend/commands/portalcmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PerformCursorOpen(DeclareCursorStmt *cstmt, ParamListInfo params,
6363
* user-visible effect).
6464
*/
6565
if (!(cstmt->options&CURSOR_OPT_HOLD))
66-
RequireTransactionChain(isTopLevel,"DECLARE CURSOR");
66+
RequireTransactionBlock(isTopLevel,"DECLARE CURSOR");
6767

6868
/*
6969
* Parse analysis was done already, but we still have to run the rule

‎src/backend/commands/subscriptioncmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
339339
* replication slot.
340340
*/
341341
if (create_slot)
342-
PreventTransactionChain(isTopLevel,"CREATE SUBSCRIPTION ... WITH (create_slot = true)");
342+
PreventInTransactionBlock(isTopLevel,"CREATE SUBSCRIPTION ... WITH (create_slot = true)");
343343

344344
if (!superuser())
345345
ereport(ERROR,
@@ -897,7 +897,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
897897
* don't have the proper facilities for that.
898898
*/
899899
if (slotname)
900-
PreventTransactionChain(isTopLevel,"DROP SUBSCRIPTION");
900+
PreventInTransactionBlock(isTopLevel,"DROP SUBSCRIPTION");
901901

902902

903903
ObjectAddressSet(myself,SubscriptionRelationId,subid);

‎src/backend/commands/typecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ AlterEnum(AlterEnumStmt *stmt, bool isTopLevel)
13211321
!(tup->t_data->t_infomask&HEAP_UPDATED))
13221322
/* safe to do inside transaction block */ ;
13231323
else
1324-
PreventTransactionChain(isTopLevel,"ALTER TYPE ... ADD");
1324+
PreventInTransactionBlock(isTopLevel,"ALTER TYPE ... ADD");
13251325

13261326
AddEnumLabel(enum_type_oid,stmt->newVal,
13271327
stmt->newValNeighbor,stmt->newValIsAfter,

‎src/backend/commands/vacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ vacuum(int options, List *relations, VacuumParams *params,
186186
*/
187187
if (options&VACOPT_VACUUM)
188188
{
189-
PreventTransactionChain(isTopLevel,stmttype);
189+
PreventInTransactionBlock(isTopLevel,stmttype);
190190
in_outer_xact= false;
191191
}
192192
else
193-
in_outer_xact=IsInTransactionChain(isTopLevel);
193+
in_outer_xact=IsInTransactionBlock(isTopLevel);
194194

195195
/*
196196
* Due to static variables vac_context, anl_context and vac_strategy,

‎src/backend/replication/walsender.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ exec_replication_command(const char *cmd_string)
15161516
break;
15171517

15181518
caseT_BaseBackupCmd:
1519-
PreventTransactionChain(true,"BASE_BACKUP");
1519+
PreventInTransactionBlock(true,"BASE_BACKUP");
15201520
SendBaseBackup((BaseBackupCmd*)cmd_node);
15211521
break;
15221522

@@ -1532,7 +1532,7 @@ exec_replication_command(const char *cmd_string)
15321532
{
15331533
StartReplicationCmd*cmd= (StartReplicationCmd*)cmd_node;
15341534

1535-
PreventTransactionChain(true,"START_REPLICATION");
1535+
PreventInTransactionBlock(true,"START_REPLICATION");
15361536

15371537
if (cmd->kind==REPLICATION_KIND_PHYSICAL)
15381538
StartReplication(cmd);
@@ -1542,7 +1542,7 @@ exec_replication_command(const char *cmd_string)
15421542
}
15431543

15441544
caseT_TimeLineHistoryCmd:
1545-
PreventTransactionChain(true,"TIMELINE_HISTORY");
1545+
PreventInTransactionBlock(true,"TIMELINE_HISTORY");
15461546
SendTimeLineHistory((TimeLineHistoryCmd*)cmd_node);
15471547
break;
15481548

‎src/backend/tcop/utility.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,13 @@ standard_ProcessUtility(PlannedStmt *pstmt,
453453
break;
454454

455455
caseTRANS_STMT_COMMIT_PREPARED:
456-
PreventTransactionChain(isTopLevel,"COMMIT PREPARED");
456+
PreventInTransactionBlock(isTopLevel,"COMMIT PREPARED");
457457
PreventCommandDuringRecovery("COMMIT PREPARED");
458458
FinishPreparedTransaction(stmt->gid, true);
459459
break;
460460

461461
caseTRANS_STMT_ROLLBACK_PREPARED:
462-
PreventTransactionChain(isTopLevel,"ROLLBACK PREPARED");
462+
PreventInTransactionBlock(isTopLevel,"ROLLBACK PREPARED");
463463
PreventCommandDuringRecovery("ROLLBACK PREPARED");
464464
FinishPreparedTransaction(stmt->gid, false);
465465
break;
@@ -473,7 +473,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
473473
ListCell*cell;
474474
char*name=NULL;
475475

476-
RequireTransactionChain(isTopLevel,"SAVEPOINT");
476+
RequireTransactionBlock(isTopLevel,"SAVEPOINT");
477477

478478
foreach(cell,stmt->options)
479479
{
@@ -490,12 +490,12 @@ standard_ProcessUtility(PlannedStmt *pstmt,
490490
break;
491491

492492
caseTRANS_STMT_RELEASE:
493-
RequireTransactionChain(isTopLevel,"RELEASE SAVEPOINT");
493+
RequireTransactionBlock(isTopLevel,"RELEASE SAVEPOINT");
494494
ReleaseSavepoint(stmt->options);
495495
break;
496496

497497
caseTRANS_STMT_ROLLBACK_TO:
498-
RequireTransactionChain(isTopLevel,"ROLLBACK TO SAVEPOINT");
498+
RequireTransactionBlock(isTopLevel,"ROLLBACK TO SAVEPOINT");
499499
RollbackToSavepoint(stmt->options);
500500

501501
/*
@@ -536,13 +536,13 @@ standard_ProcessUtility(PlannedStmt *pstmt,
536536

537537
caseT_CreateTableSpaceStmt:
538538
/* no event triggers for global objects */
539-
PreventTransactionChain(isTopLevel,"CREATE TABLESPACE");
539+
PreventInTransactionBlock(isTopLevel,"CREATE TABLESPACE");
540540
CreateTableSpace((CreateTableSpaceStmt*)parsetree);
541541
break;
542542

543543
caseT_DropTableSpaceStmt:
544544
/* no event triggers for global objects */
545-
PreventTransactionChain(isTopLevel,"DROP TABLESPACE");
545+
PreventInTransactionBlock(isTopLevel,"DROP TABLESPACE");
546546
DropTableSpace((DropTableSpaceStmt*)parsetree);
547547
break;
548548

@@ -592,7 +592,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
592592

593593
caseT_CreatedbStmt:
594594
/* no event triggers for global objects */
595-
PreventTransactionChain(isTopLevel,"CREATE DATABASE");
595+
PreventInTransactionBlock(isTopLevel,"CREATE DATABASE");
596596
createdb(pstate, (CreatedbStmt*)parsetree);
597597
break;
598598

@@ -611,7 +611,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
611611
DropdbStmt*stmt= (DropdbStmt*)parsetree;
612612

613613
/* no event triggers for global objects */
614-
PreventTransactionChain(isTopLevel,"DROP DATABASE");
614+
PreventInTransactionBlock(isTopLevel,"DROP DATABASE");
615615
dropdb(stmt->dbname,stmt->missing_ok);
616616
}
617617
break;
@@ -690,7 +690,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
690690
break;
691691

692692
caseT_AlterSystemStmt:
693-
PreventTransactionChain(isTopLevel,"ALTER SYSTEM");
693+
PreventInTransactionBlock(isTopLevel,"ALTER SYSTEM");
694694
AlterSystemSetConfigFile((AlterSystemStmt*)parsetree);
695695
break;
696696

@@ -756,13 +756,13 @@ standard_ProcessUtility(PlannedStmt *pstmt,
756756
* Since the lock would just get dropped immediately, LOCK TABLE
757757
* outside a transaction block is presumed to be user error.
758758
*/
759-
RequireTransactionChain(isTopLevel,"LOCK TABLE");
759+
RequireTransactionBlock(isTopLevel,"LOCK TABLE");
760760
/* forbidden in parallel mode due to CommandIsReadOnly */
761761
LockTableCommand((LockStmt*)parsetree);
762762
break;
763763

764764
caseT_ConstraintsSetStmt:
765-
WarnNoTransactionChain(isTopLevel,"SET CONSTRAINTS");
765+
WarnNoTransactionBlock(isTopLevel,"SET CONSTRAINTS");
766766
AfterTriggerSetState((ConstraintsSetStmt*)parsetree);
767767
break;
768768

@@ -808,7 +808,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
808808
* start-transaction-command calls would not have the
809809
* intended effect!
810810
*/
811-
PreventTransactionChain(isTopLevel,
811+
PreventInTransactionBlock(isTopLevel,
812812
(stmt->kind==REINDEX_OBJECT_SCHEMA) ?"REINDEX SCHEMA" :
813813
(stmt->kind==REINDEX_OBJECT_SYSTEM) ?"REINDEX SYSTEM" :
814814
"REINDEX DATABASE");
@@ -1307,7 +1307,7 @@ ProcessUtilitySlow(ParseState *pstate,
13071307
List*inheritors=NIL;
13081308

13091309
if (stmt->concurrent)
1310-
PreventTransactionChain(isTopLevel,
1310+
PreventInTransactionBlock(isTopLevel,
13111311
"CREATE INDEX CONCURRENTLY");
13121312

13131313
/*
@@ -1715,7 +1715,7 @@ ExecDropStmt(DropStmt *stmt, bool isTopLevel)
17151715
{
17161716
caseOBJECT_INDEX:
17171717
if (stmt->concurrent)
1718-
PreventTransactionChain(isTopLevel,
1718+
PreventInTransactionBlock(isTopLevel,
17191719
"DROP INDEX CONCURRENTLY");
17201720
/* fall through */
17211721

‎src/backend/utils/misc/guc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7348,7 +7348,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
73487348
caseVAR_SET_VALUE:
73497349
caseVAR_SET_CURRENT:
73507350
if (stmt->is_local)
7351-
WarnNoTransactionChain(isTopLevel,"SET LOCAL");
7351+
WarnNoTransactionBlock(isTopLevel,"SET LOCAL");
73527352
(void)set_config_option(stmt->name,
73537353
ExtractSetVariableArgs(stmt),
73547354
(superuser() ?PGC_SUSET :PGC_USERSET),
@@ -7368,7 +7368,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
73687368
{
73697369
ListCell*head;
73707370

7371-
WarnNoTransactionChain(isTopLevel,"SET TRANSACTION");
7371+
WarnNoTransactionBlock(isTopLevel,"SET TRANSACTION");
73727372

73737373
foreach(head,stmt->args)
73747374
{
@@ -7419,7 +7419,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
74197419
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
74207420
errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
74217421

7422-
WarnNoTransactionChain(isTopLevel,"SET TRANSACTION");
7422+
WarnNoTransactionBlock(isTopLevel,"SET TRANSACTION");
74237423
Assert(nodeTag(&con->val)==T_String);
74247424
ImportSnapshot(strVal(&con->val));
74257425
}
@@ -7429,11 +7429,11 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
74297429
break;
74307430
caseVAR_SET_DEFAULT:
74317431
if (stmt->is_local)
7432-
WarnNoTransactionChain(isTopLevel,"SET LOCAL");
7432+
WarnNoTransactionBlock(isTopLevel,"SET LOCAL");
74337433
/* fall through */
74347434
caseVAR_RESET:
74357435
if (strcmp(stmt->name,"transaction_isolation")==0)
7436-
WarnNoTransactionChain(isTopLevel,"RESET TRANSACTION");
7436+
WarnNoTransactionBlock(isTopLevel,"RESET TRANSACTION");
74377437

74387438
(void)set_config_option(stmt->name,
74397439
NULL,

‎src/backend/utils/time/snapmgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ ExportSnapshot(Snapshot snapshot)
11711171
charpathtmp[MAXPGPATH];
11721172

11731173
/*
1174-
* It's tempting to callRequireTransactionChain here, since it's not very
1174+
* It's tempting to callRequireTransactionBlock here, since it's not very
11751175
* useful to export a snapshot that will disappear immediately afterwards.
11761176
* However, we haven't got enough information to do that, since we don't
11771177
* know if we're at top level or not. For example, we could be inside a

‎src/bin/psql/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ command_no_begin(const char *query)
20472047

20482048
/*
20492049
* Commands not allowed within transactions. The statements checked for
2050-
* here should be exactly those that callPreventTransactionChain() in the
2050+
* here should be exactly those that callPreventInTransactionBlock() in the
20512051
* backend.
20522052
*/
20532053
if (wordlen==6&&pg_strncasecmp(query,"vacuum",6)==0)

‎src/include/access/xact.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ extern bool IsTransactionBlock(void);
369369
externboolIsTransactionOrTransactionBlock(void);
370370
externcharTransactionBlockStatusCode(void);
371371
externvoidAbortOutOfAnyTransaction(void);
372-
externvoidPreventTransactionChain(boolisTopLevel,constchar*stmtType);
373-
externvoidRequireTransactionChain(boolisTopLevel,constchar*stmtType);
374-
externvoidWarnNoTransactionChain(boolisTopLevel,constchar*stmtType);
375-
externboolIsInTransactionChain(boolisTopLevel);
372+
externvoidPreventInTransactionBlock(boolisTopLevel,constchar*stmtType);
373+
externvoidRequireTransactionBlock(boolisTopLevel,constchar*stmtType);
374+
externvoidWarnNoTransactionBlock(boolisTopLevel,constchar*stmtType);
375+
externboolIsInTransactionBlock(boolisTopLevel);
376376
externvoidRegisterXactCallback(XactCallbackcallback,void*arg);
377377
externvoidUnregisterXactCallback(XactCallbackcallback,void*arg);
378378
externvoidRegisterSubXactCallback(SubXactCallbackcallback,void*arg);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp