HomeMogDBMogDB StackUqbar
v2.1

Documentation:v2.1

Supported Versions:

Other Versions:

Advisory Lock Functions

Advisory lock functions manage advisory locks.

  • pg_advisory_lock(key bigint)

    Description: Obtains an exclusive session-level advisory lock.

    Return type: void

    Note:pg_advisory_lock locks resources defined by an application. The resources can be identified using a 64-bit or two nonoverlapped 32-bit key values. If another session locks the resources, the function blocks the resources until they can be used. The lock is exclusive. Multiple locking requests are pushed into the stack. Therefore, if the same resource is locked three times, it must be unlocked three times so that it is released to another session.

  • pg_advisory_lock(key1 int, key2 int)

    Description: Obtains an exclusive session-level advisory lock.

    Return type: void

    Note: Only users with the sysadmin permission can add session-level exclusive advisory locks to the key-value pair (65535, 65535).

  • pg_advisory_lock(int4, int4, Name)

    Description: Obtains the exclusive advisory lock of a specified database.

    Return type: void

  • pg_advisory_lock_shared(key bigint)

    Description: Obtains a shared session-level advisory lock.

    Return type: void

  • pg_advisory_lock_shared(key1 int, key2 int)

    Description: Obtains a shared session-level advisory lock.

    Return type: void

    Note:pg_advisory_lock_shared works in the same way as pg_advisory_lock, except the lock can be shared with other sessions requesting shared locks. Only would-be exclusive lockers are locked out.

  • pg_advisory_unlock(key bigint)

    Description: Releases an exclusive session-level advisory lock.

    Return type: Boolean

  • pg_advisory_unlock(key1 int, key2 int)

    Description: Releases an exclusive session-level advisory lock.

    Return type: Boolean

    Note:pg_advisory_unlock releases the obtained exclusive advisory lock. If the release is successful, the function returns true. If the lock was not held, it will return false. In addition, a SQL warning will be reported by the server.

  • pg_advisory_unlock(int4, int4, Name)

    Description: Releases the exclusive advisory lock of a specified database.

    Return type: Boolean

    Note: If the release is successful, true is returned. If no lock is held, false is returned.

  • pg_advisory_unlock_shared(key bigint)

    Description: Releases a shared session-level advisory lock.

    Return type: Boolean

  • pg_advisory_unlock_shared(key1 int, key2 int)

    Description: Releases a shared session-level advisory lock.

    Return type: Boolean

    Note:pg_advisory_unlock_shared works in the same way as pg_advisory_unlock, except it releases a shared session-level advisory lock.

  • pg_advisory_unlock_all()

    Description: Releases all advisory locks owned by the current session.

    Return type: void

    Note:pg_advisory_unlock_all releases all advisory locks owned by the current session. The function is implicitly invoked when the session ends even if the client is abnormally disconnected.

  • pg_advisory_xact_lock(key bigint)

    Description: Obtains an exclusive transaction-level advisory lock.

    Return type: void

  • pg_advisory_xact_lock(key1 int, key2 int)

    Description: Obtains an exclusive transaction-level advisory lock.

    Return type: void

    Note:pg_advisory_xact_lock works in the same way as pg_advisory_lock, except the lock is automatically released at the end of the current transaction and cannot be released explicitly. Only users with the sysadmin permission can add transaction-level exclusive advisory locks to the key-value pair (65535, 65535).

  • pg_advisory_xact_lock_shared(key bigint)

    Description: Obtains a shared transaction-level advisory lock.

    Return type: void

  • pg_advisory_xact_lock_shared(key1 int, key2 int)

    Description: Obtains a shared transaction-level advisory lock.

    Return type: void

    Note:pg_advisory_xact_lock_shared works in the same way as pg_advisory_lock_shared, except the lock is automatically released at the end of the current transaction and cannot be released explicitly.

  • pg_try_advisory_lock(key bigint)

    Description: Obtains an exclusive session-level advisory lock if available.

    Return type: Boolean

    Note:pg_try_advisory_lock is similar to pg_advisory_lock, except pg_try_advisory_lock does not block the resource until the resource is released. pg_try_advisory_lock either immediately obtains the lock and returns true or returns false, which indicates the lock cannot be performed currently.

  • pg_try_advisory_lock(key1 int, key2 int)

    Description: Obtains an exclusive session-level advisory lock if available.

    Return type: Boolean

    Note: Only users with the sysadmin permission can add session-level exclusive advisory locks to the key-value pair (65535, 65535).

  • pg_try_advisory_lock_shared(key bigint)

    Description: Obtains a shared session-level advisory lock if available.

    Return type: Boolean

  • pg_try_advisory_lock_shared(key1 int, key2 int)

    Description: Obtains a shared session-level advisory lock if available.

    Return type: Boolean

    Note:pg_try_advisory_lock_shared is similar to pg_try_advisory_lock, except pg_try_advisory_lock_shared attempts to obtain a shared lock instead of an exclusive lock.

  • pg_try_advisory_xact_lock(key bigint)

    Description: Obtains an exclusive transaction-level advisory lock if available.

    Return type: Boolean

  • pg_try_advisory_xact_lock(key1 int, key2 int)

    Description: Obtains an exclusive transaction-level advisory lock if available.

    Return type: Boolean

    Note:pg_try_advisory_xact_lock works in the same way as pg_try_advisory_lock, except the lock, if acquired, is automatically released at the end of the current transaction and cannot be released explicitly. Note: Only users with the sysadmin permission can add transaction-level exclusive advisory locks to the key-value pair (65535, 65535).

  • pg_try_advisory_xact_lock_shared(key bigint)

    Description: Obtains a shared transaction-level advisory lock if available.

    Return type: Boolean

  • pg_try_advisory_xact_lock_shared(key1 int, key2 int)

    Description: Obtains a shared transaction-level advisory lock if available.

    Return type: Boolean

    Note:pg_try_advisory_xact_lock_shared works in the same way as pg_try_advisory_lock_shared, except the lock, if acquired, is automatically released at the end of the current transaction and cannot be released explicitly.

  • lock_cluster_ddl()

    Description: Attempts to obtain a session-level exclusive advisory lock for all active primary database nodes in MogDB.

    Return type: Boolean

    Note: Only users with the sysadmin permission can call this function.

  • unlock_cluster_ddl()

    Description: Attempts to add a session-level exclusive advisory lock on the primary database node.

    Return type: Boolean

Copyright © 2011-2024 www.enmotech.com All rights reserved.