Allow LOCK TABLE to be run in a procedure / function

pull/5899/head
gledis69 2022-04-19 16:59:38 +03:00
parent 3debcd4f38
commit 1f926db4fa
3 changed files with 5 additions and 5 deletions

View File

@ -472,9 +472,9 @@ ProcessUtilityInternal(PlannedStmt *pstmt,
{
LockStmt *stmt = (LockStmt *) parsetree;
ereport(NOTICE, errmsg("Processing LOCK command."));
bool isTopLevel = context == PROCESS_UTILITY_TOPLEVEL;
ErrorIfUnsupportedLockStmt(stmt, isTopLevel);
ErrorIfUnsupportedLockStmt(stmt);
uint32 nowaitFlag = stmt->nowait ? DIST_LOCK_NOWAIT : 0;
AcquireDistributedLockOnRelations(stmt->relations, stmt->mode,
DIST_LOCK_VIEWS_RECUR | nowaitFlag);

View File

@ -1253,9 +1253,9 @@ AcquireDistributedLockOnRelations(List *relationList, LOCKMODE lockMode, uint32
* - Locking shard, but citus.enable_manual_changes_to_shards is false
*/
void
ErrorIfUnsupportedLockStmt(LockStmt *stmt)
ErrorIfUnsupportedLockStmt(LockStmt *stmt, bool isTopLevel)
{
RequireTransactionBlock(true, "LOCK TABLE");
RequireTransactionBlock(isTopLevel, "LOCK TABLE");
RangeVar *rangeVar = NULL;
foreach_ptr(rangeVar, stmt->relations)

View File

@ -163,5 +163,5 @@ extern LOCKMODE LockModeCStringToLockMode(const char *lockModeName);
extern const char * LockModeToLockModeCString(LOCKMODE lockMode);
extern void AcquireDistributedLockOnRelations(List *relationList, LOCKMODE lockMode,
uint32 configs);
extern void ErrorIfUnsupportedLockStmt(LockStmt *stmt);
extern void ErrorIfUnsupportedLockStmt(LockStmt *stmt, bool isTopLevel);
#endif /* RESOURCE_LOCK_H */