You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[`CURRENT_RESOURCE_GROUP()`](#current_resource_group)| Returns the resource group name that the current session is bound to. See also: [Use Resource Control to Achieve Resource Isolation](/tidb-resource-control.md). |
15
-
|[`TIDB_BOUNDED_STALENESS()`](#tidb_bounded_staleness)| Instructs TiDB to read the data as new as possible within the time range. See also: [Read Historical Data Using the `AS OF TIMESTAMP`Clause](/as-of-timestamp.md). |
16
-
|[`TIDB_CURRENT_TSO()`](#tidb_current_tso)| Returns the current [TSO](/tso.md). |
14
+
|[`CURRENT_RESOURCE_GROUP()`](#current_resource_group)| Returns the name of the resource group that the current session is bound to. See [using resource control to achieve resource isolation](/tidb-resource-control.md). |
15
+
|[`TIDB_BOUNDED_STALENESS()`](#tidb_bounded_staleness)| Instructs TiDB to read the most recent data within a specified time range. See [reading historical data using the `AS OF TIMESTAMP`clause](/as-of-timestamp.md). |
16
+
|[`TIDB_CURRENT_TSO()`](#tidb_current_tso)| Returns the current [TimeStamp Oracle (TSO) in TiDB](/tso.md). |
|[`TIDB_DECODE_KEY()`](#tidb_decode_key)| Decodes a TiDB-encoded key entry into a JSON structure containing `_tidb_rowid` and `table_id`. These encoded keys can be found in some system tables and logging outputs. |
19
19
|[`TIDB_DECODE_PLAN()`](#tidb_decode_plan)| Decodes a TiDB execution plan. |
20
-
|[`TIDB_DECODE_SQL_DIGESTS()`](#tidb_decode_sql_digests)| Queries the normalized SQL statements (a form without formats and arguments) corresponding to the set of SQL digests in the cluster. |
20
+
|[`TIDB_DECODE_SQL_DIGESTS()`](#tidb_decode_sql_digests)| Queries the normalized SQL statements (a form without formats and arguments) corresponding to a set of SQL digests in the cluster. |
21
21
|[`TIDB_ENCODE_SQL_DIGEST()`](#tidb_encode_sql_digest)| Gets a digest for a query string. |
22
-
|[`TIDB_IS_DDL_OWNER()`](#tidb_is_ddl_owner)| Checks whether or not the TiDB instance you are connected to is the one that is the DDL Owner. The DDL Owner is the TiDB instance that is tasked with executing DDL statements on behalf of all other nodes in the cluster. |
22
+
|[`TIDB_IS_DDL_OWNER()`](#tidb_is_ddl_owner)| Checks whether or not the TiDB instance you are connected to is the DDL Owner. The DDL Owner is the TiDB instance that is tasked with executing DDL statements on behalf of all other nodes in the cluster. |
23
23
|[`TIDB_PARSE_TSO()`](#tidb_parse_tso)| Extracts the physical timestamp from a TiDB TSO timestamp. See also: [`tidb_current_ts`](/system-variables.md#tidb_current_ts). |
24
24
|[`TIDB_PARSE_TSO_LOGICAL()`](#tidb_parse_tso_logical)| Extracts the logical timestamp from a TiDB TSO timestamp. |
25
25
|[`TIDB_ROW_CHECKSUM()`](#tidb_row_checksum)| Queries the checksum value of a row. This function can only be used in `SELECT` statements within the FastPlan process. That is, you can query through statements like `SELECT TIDB_ROW_CHECKSUM() FROM t WHERE id = ?` or `SELECT TIDB_ROW_CHECKSUM() FROM t WHERE id IN (?, ?, ...)`. See also: [Data integrity validation for single-row data](/ticdc/ticdc-integrity-check.md). |
26
26
|[`TIDB_SHARD()`](#tidb_shard)| Creates a shard index to scatter the index hotspot. A shard index is an expression index with a `TIDB_SHARD` function as the prefix.|
27
27
|[`TIDB_VERSION()`](#tidb_version)| Returns the TiDB version with additional build information. |
28
-
|[`VITESS_HASH()`](#vitess_hash)| Returns the hash of a number that is compatible with Vitess'`HASH` function. This is intended to help the data migration from Vitess. |
28
+
|[`VITESS_HASH()`](#vitess_hash)| Returns the hash of a number. This function is compatible with the`HASH` function of Vitess, and is intended to help the data migration from Vitess. |
|[`CURRENT_RESOURCE_GROUP()`](#current_resource_group)| Returns the resource group name that the current session is bound to. See also: [Use Resource Control to Achieve Resource Isolation](/tidb-resource-control.md). |
37
-
|[`TIDB_BOUNDED_STALENESS()`](#tidb_bounded_staleness)| Instructs TiDB to read the data as new as possible within the time range. See also: [Read Historical Data Using the `AS OF TIMESTAMP`Clause](/as-of-timestamp.md). |
38
-
|[`TIDB_CURRENT_TSO()`](#tidb_current_tso)| Returns the current [TSO](/tso.md). |
36
+
|[`CURRENT_RESOURCE_GROUP()`](#current_resource_group)| Returns the resource group name that the current session is bound to. See [using resource control to achieve resource isolation](/tidb-resource-control.md). |
37
+
|[`TIDB_BOUNDED_STALENESS()`](#tidb_bounded_staleness)| Instructs TiDB to read most recent data within a specified time range. See [reading historical data using the `AS OF TIMESTAMP`clause](/as-of-timestamp.md). |
38
+
|[`TIDB_CURRENT_TSO()`](#tidb_current_tso)| Returns the current [TimeStamp Oracle (TSO) in TiDB](/tso.md). |
|[`TIDB_DECODE_KEY()`](#tidb_decode_key)| Decodes a TiDB-encoded key entry into a JSON structure containing `_tidb_rowid` and `table_id`. These encoded keys can be found in some system tables and in logging outputs. |
40
+
|[`TIDB_DECODE_KEY()`](#tidb_decode_key)| Decodes a TiDB-encoded key entry into a JSON structure containing `_tidb_rowid` and `table_id`. These encoded keys can be found in some system tables and logging outputs. |
41
41
|[`TIDB_DECODE_PLAN()`](#tidb_decode_plan)| Decodes a TiDB execution plan. |
42
-
|[`TIDB_DECODE_SQL_DIGESTS()`](#tidb_decode_sql_digests)| Queries the normalized SQL statements (a form without formats and arguments) corresponding to the set of SQL digests in the cluster. |
42
+
|[`TIDB_DECODE_SQL_DIGESTS()`](#tidb_decode_sql_digests)| Queries the normalized SQL statements (a form without formats and arguments) corresponding to a set of SQL digests in the cluster. |
43
43
|[`TIDB_ENCODE_SQL_DIGEST()`](#tidb_encode_sql_digest)| Gets a digest for a query string. |
44
-
|[`TIDB_IS_DDL_OWNER()`](#tidb_is_ddl_owner)| Checks whether or not the TiDB instance you are connected to is the one that is the DDL Owner. The DDL Owner is the TiDB instance that is tasked with executing DDL statements on behalf of all other nodes in the cluster. |
44
+
|[`TIDB_IS_DDL_OWNER()`](#tidb_is_ddl_owner)| Checks whether or not the TiDB instance you are connected to is the DDL Owner. The DDL Owner is the TiDB instance that is tasked with executing DDL statements on behalf of all other nodes in the cluster. |
45
45
|[`TIDB_PARSE_TSO()`](#tidb_parse_tso)| Extracts the physical timestamp from a TiDB TSO timestamp. See also: [`tidb_current_ts`](/system-variables.md#tidb_current_ts). |
46
46
|[`TIDB_PARSE_TSO_LOGICAL()`](#tidb_parse_tso_logical)| Extracts the logical timestamp from a TiDB TSO timestamp. |
47
47
|[`TIDB_ROW_CHECKSUM()`](#tidb_row_checksum)| Queries the checksum value of a row. This function can only be used in `SELECT` statements within the FastPlan process. That is, you can query through statements like `SELECT TIDB_ROW_CHECKSUM() FROM t WHERE id = ?` or `SELECT TIDB_ROW_CHECKSUM() FROM t WHERE id IN (?, ?, ...)`. See also: [Data integrity validation for single-row data](https://docs.pingcap.com/tidb/stable/ticdc-integrity-check). |
48
48
|[`TIDB_SHARD()`](#tidb_shard)| Creates a shard index to scatter the index hotspot. A shard index is an expression index with a `TIDB_SHARD` function as the prefix.|
49
49
|[`TIDB_VERSION()`](#tidb_version)| Returns the TiDB version with additional build information. |
50
-
|[`VITESS_HASH()`](#vitess_hash)| Returns the hash of a number that is compatible with Vitess'`HASH` function. This is intended to help the data migration from Vitess. |
50
+
|[`VITESS_HASH()`](#vitess_hash)| Returns the hash of a number. This function is compatible with the`HASH` function of Vitess, and is intended to help the data migration from Vitess. |
51
51
52
52
</CustomContent>
53
53
54
54
## CURRENT_RESOURCE_GROUP
55
55
56
-
The `CURRENT_RESOURCE_GROUP` function is used to show the resource group name that the current session is bound to. When the [Resource control](/tidb-resource-control.md) feature is enabled, the available resources that can be used by SQL statements are restricted by the resource quota of the bound resource group.
56
+
The `CURRENT_RESOURCE_GROUP()` function is used to show the resource group name that the current session is bound to. When the [Resource control](/tidb-resource-control.md) feature is enabled, the available resources that can be used by SQL statements are restricted by the resource quota of the bound resource group.
57
57
58
58
When a session is established, TiDB binds the session to the resource group that the login user is bound to by default. If the user is not bound to any resource groups, the session is bound to the `default` resource group. Once the session is established, the bound resource group will not change by default, even if the bound resource group of the user is changed via [modifying the resource group bound to the user](/sql-statements/sql-statement-alter-user.md#modify-basic-user-information). To change the bound resource group of the current session, you can use [`SET RESOURCE GROUP`](/sql-statements/sql-statement-set-resource-group.md).
59
59
@@ -63,8 +63,8 @@ Create a user `user1`, create two resource groups `rg1` and `rg2`, and bind the
63
63
64
64
```sql
65
65
CREATEUSER 'user1';
66
-
CREATE RESOURCE GROUP 'rg1' RU_PER_SEC =1000;
67
-
CREATE RESOURCE GROUP 'rg2' RU_PER_SEC =2000;
66
+
CREATE RESOURCE GROUP rg1 RU_PER_SEC =1000;
67
+
CREATE RESOURCE GROUP rg2 RU_PER_SEC =2000;
68
68
ALTERUSER'user1' RESOURCE GROUP `rg1`;
69
69
```
70
70
@@ -105,7 +105,7 @@ The `TIDB_BOUNDED_STALENESS()` function is used as part of [`AS OF TIMESTAMP`](/
105
105
106
106
## TIDB_CURRENT_TSO
107
107
108
-
The `TIDB_CURRENT_TSO()` function returns the [TSO](/tso.md) for the current transaction. This is similar to the [`tidb_current_ts`](/system-variables.md#tidb_current_ts) variable.
108
+
The `TIDB_CURRENT_TSO()` function returns the [TSO](/tso.md) for the current transaction. This is similar to the [`tidb_current_ts`](/system-variables.md#tidb_current_ts)system variable.
109
109
110
110
```sql
111
111
BEGIN;
@@ -303,14 +303,14 @@ This function returns a string, which is in the format of a JSON string array. T
303
303
> * This function has a high overhead because every time it is called, it internally queries the `STATEMENTS_SUMMARY`, `STATEMENTS_SUMMARY_HISTORY`, `CLUSTER_STATEMENTS_SUMMARY`, and `CLUSTER_STATEMENTS_SUMMARY_HISTORY` tables, and the query involves the `UNION` operation. This function currently does not support vectorization, that is, when calling this function for multiple rows of data, the above query is performed separately for each row.
304
304
305
305
```sql
306
-
set @digests = '["e6f07d43b5c21db0fbb9a31feac2dc599787763393dd5acbfad80e247eb02ad5","38b03afa5debbdf0326a014dbe5012a62c51957f1982b3093e748460f8b00821","e5796985ccafe2f71126ed6c0ac939ffa015a8c0744a24b7aee6d587103fd2f7"]';
306
+
SET @digests = '["e6f07d43b5c21db0fbb9a31feac2dc599787763393dd5acbfad80e247eb02ad5","38b03afa5debbdf0326a014dbe5012a62c51957f1982b3093e748460f8b00821","e5796985ccafe2f71126ed6c0ac939ffa015a8c0744a24b7aee6d587103fd2f7"]';
In the above example, the parameter is a JSON array containing 3 SQL digests, and the corresponding SQL statements are the three items in the query results. But the SQL statement corresponding to the second SQL digest cannot be found from the cluster, so the second item in the result is `null`.
321
321
322
322
```sql
323
-
select tidb_decode_sql_digests(@digests, 10);
323
+
SELECT TIDB_DECODE_SQL_DIGESTS(@digests, 10);
324
324
```
325
325
326
326
```sql
327
327
+---------------------------------------+
328
-
| tidb_decode_sql_digests(@digests, 10) |
328
+
| TIDB_DECODE_SQL_DIGESTS(@digests, 10) |
329
329
+---------------------------------------+
330
330
| ["begin",null,"select * f..."] |
331
331
+---------------------------------------+
@@ -336,7 +336,7 @@ The above call specifies the second parameter (that is, the truncation length) a
0 commit comments