diff options
Diffstat (limited to 'src/backend/tcop/utility.c')
-rw-r--r-- | src/backend/tcop/utility.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 704bbe9cedf..de16a61454b 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -699,12 +699,23 @@ standard_ProcessUtility(Node *parsetree, case T_AlterTableStmt: { + AlterTableStmt *atstmt = (AlterTableStmt *) parsetree; + Oid relid; List *stmts; ListCell *l; + LOCKMODE lockmode; + + /* + * Figure out lock mode, and acquire lock. This also does + * basic permissions checks, so that we won't wait for a lock + * on (for example) a relation on which we have no + * permissions. + */ + lockmode = AlterTableGetLockLevel(atstmt->cmds); + relid = AlterTableLookupRelation(atstmt, lockmode); /* Run parse analysis ... */ - stmts = transformAlterTableStmt((AlterTableStmt *) parsetree, - queryString); + stmts = transformAlterTableStmt(atstmt, queryString); /* ... and do it */ foreach(l, stmts) @@ -714,7 +725,7 @@ standard_ProcessUtility(Node *parsetree, if (IsA(stmt, AlterTableStmt)) { /* Do the table alteration proper */ - AlterTable((AlterTableStmt *) stmt); + AlterTable(relid, lockmode, (AlterTableStmt *) stmt); } else { |