Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

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 37 of file lockcmds.c.

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

Referenced by standard_ProcessUtility().

{
    ListCell   *p;

    /*---------
     * During recovery we only accept these variations:
     * LOCK TABLE foo IN ACCESS SHARE MODE
     * LOCK TABLE foo IN ROW SHARE MODE
     * LOCK TABLE foo IN ROW EXCLUSIVE MODE
     * This test must match the restrictions defined in LockAcquireExtended()
     *---------
     */
    if (lockstmt->mode > RowExclusiveLock)
        PreventCommandDuringRecovery("LOCK TABLE");

    /*
     * Iterate over the list and process the named relations one at a time
     */
    foreach(p, lockstmt->relations)
    {
        RangeVar   *rv = (RangeVar *) lfirst(p);
        bool        recurse = interpretInhOption(rv->inhOpt);
        Oid         reloid;

        reloid = RangeVarGetRelidExtended(rv, lockstmt->mode, false,
                                          lockstmt->nowait,
                                          RangeVarCallbackForLockTable,
                                          (void *) &lockstmt->mode);

        if (recurse)
            LockTableRecurse(reloid, lockstmt->mode, lockstmt->nowait);
    }
}