# IS\_USED\_LOCK

## Syntax

```sql
IS_USED_LOCK(str)
```

## Description

Checks whether the lock named `str` is in use (that is, locked). If so, it returns the connection identifier of the client that holds the lock. Otherwise, it returns `NULL`. `str` is case insensitive.

If the [metadata\_lock\_info](https://mariadb.com/docs/server/reference/plugins/other-plugins/metadata-lock-info-plugin) plugin is installed, the [Information Schema](https://mariadb.com/docs/server/reference/system-tables/information-schema) [metadata\_lock\_info](https://mariadb.com/docs/server/reference/system-tables/information-schema/information-schema-tables/information-schema-metadata_lock_info-table) table contains information about locks of this kind (as well as [metadata locks](https://mariadb.com/docs/server/reference/sql-statements/transactions/metadata-locking)).

Statements using the `IS_USED_LOCK` function are [not safe for statement-based replication](https://mariadb.com/docs/server/ha-and-performance/standard-replication/unsafe-statements-for-statement-based-replication).

## See Also

* [GET\_LOCK](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/get_lock)
* [RELEASE\_LOCK](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_lock)
* [IS\_FREE\_LOCK](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_free_lock)
* [RELEASE\_ALL\_LOCKS](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_all_locks)

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/is_used_lock.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
