Skip to content

Commit 2706559

Browse files
committed
disallow concurrent index creation insise tx
1 parent 08762fd commit 2706559

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

contrib/mmts/multimaster.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,21 +2442,17 @@ static void MtmProcessUtility(Node *parsetree, const char *queryString,
24422442
case T_IndexStmt:
24432443
{
24442444
Oid relid;
2445-
LOCKMODE lockmode;
24462445
Relation rel;
2447-
24482446
IndexStmt *stmt = (IndexStmt *) parsetree;
2449-
lockmode = stmt->concurrent ? ShareUpdateExclusiveLock
2450-
: ShareLock;
2451-
relid = RangeVarGetRelidExtended(stmt->relation, lockmode,
2452-
false, false,
2453-
NULL, // ???
2454-
NULL);
2447+
bool isTopLevel = (context == PROCESS_UTILITY_TOPLEVEL);
24552448

2456-
rel = heap_open(relid, lockmode);
2449+
if (stmt->concurrent)
2450+
PreventTransactionChain(isTopLevel,
2451+
"CREATE INDEX CONCURRENTLY");
24572452

2453+
relid = RelnameGetRelid(stmt->relation->relname);
2454+
rel = heap_open(relid, ShareLock);
24582455
skipCommand = rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP;
2459-
24602456
heap_close(rel, NoLock);
24612457
}
24622458
break;

0 commit comments

Comments
 (0)