PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
lockcmds.h File Reference
#include "nodes/parsenodes.h"
Include dependency graph for lockcmds.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void LockTableCommand (LockStmt *lockstmt)
 

Function Documentation

void LockTableCommand ( LockStmt lockstmt)

Definition at line 36 of file lockcmds.c.

References RangeVar::inh, lfirst, LockTableRecurse(), LockStmt::mode, LockStmt::nowait, PreventCommandDuringRecovery(), RangeVarCallbackForLockTable(), RangeVarGetRelidExtended(), LockStmt::relations, and RowExclusiveLock.

Referenced by standard_ProcessUtility().

37 {
38  ListCell *p;
39 
40  /*---------
41  * During recovery we only accept these variations:
42  * LOCK TABLE foo IN ACCESS SHARE MODE
43  * LOCK TABLE foo IN ROW SHARE MODE
44  * LOCK TABLE foo IN ROW EXCLUSIVE MODE
45  * This test must match the restrictions defined in LockAcquireExtended()
46  *---------
47  */
48  if (lockstmt->mode > RowExclusiveLock)
49  PreventCommandDuringRecovery("LOCK TABLE");
50 
51  /*
52  * Iterate over the list and process the named relations one at a time
53  */
54  foreach(p, lockstmt->relations)
55  {
56  RangeVar *rv = (RangeVar *) lfirst(p);
57  bool recurse = rv->inh;
58  Oid reloid;
59 
60  reloid = RangeVarGetRelidExtended(rv, lockstmt->mode, false,
61  lockstmt->nowait,
63  (void *) &lockstmt->mode);
64 
65  if (recurse)
66  LockTableRecurse(reloid, lockstmt->mode, lockstmt->nowait);
67  }
68 }
bool nowait
Definition: parsenodes.h:3160
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok, bool nowait, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:218
unsigned int Oid
Definition: postgres_ext.h:31
void PreventCommandDuringRecovery(const char *cmdname)
Definition: utility.c:273
#define RowExclusiveLock
Definition: lockdefs.h:38
bool inh
Definition: primnodes.h:69
static void LockTableRecurse(Oid reloid, LOCKMODE lockmode, bool nowait)
Definition: lockcmds.c:110
List * relations
Definition: parsenodes.h:3158
#define lfirst(lc)
Definition: pg_list.h:106
static void RangeVarCallbackForLockTable(const RangeVar *rv, Oid relid, Oid oldrelid, void *arg)
Definition: lockcmds.c:75