MySQL 9.0 发行说明
返回一个包含有关给定线程信息的 JSON 对象。信息包括当前事务,以及它已经执行的语句,这些信息来自 Performance Schema 的 events_transactions_current
和 events_statements_history
表。 (这些表的消费者必须启用才能在 JSON 对象中获取完整数据。)
如果输出超过截断长度 (默认情况下为 65535),则返回一个 JSON 错误对象,例如
{ "error": "Trx info truncated: Row 6 was cut by GROUP_CONCAT()" }
函数执行过程中出现的其他警告和异常也会返回类似的错误对象。
in_thread_id BIGINT UNSIGNED
: 要返回事务信息的线程 ID。此值应与某些 Performance Schemathreads
表行的THREAD_ID
列匹配。
ps_thread_trx_info()
操作可以使用以下配置选项或其对应的用户定义变量进行修改 (参见 Section 30.4.2.1, “sys_config 表”)
ps_thread_trx_info.max_length
,@sys.ps_thread_trx_info.max_length
输出的最大长度。默认值为 65535。
mysql> SELECT sys.ps_thread_trx_info(48)\G
*************************** 1. row ***************************
sys.ps_thread_trx_info(48): [
{
"time": "790.70 us",
"state": "COMMITTED",
"mode": "READ WRITE",
"autocommitted": "NO",
"gtid": "AUTOMATIC",
"isolation": "REPEATABLE READ",
"statements_executed": [
{
"sql_text": "INSERT INTO info VALUES (1, \'foo\')",
"time": "471.02 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 1,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
},
{
"sql_text": "COMMIT",
"time": "254.42 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 0,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
}
]
},
{
"time": "426.20 us",
"state": "COMMITTED",
"mode": "READ WRITE",
"autocommitted": "NO",
"gtid": "AUTOMATIC",
"isolation": "REPEATABLE READ",
"statements_executed": [
{
"sql_text": "INSERT INTO info VALUES (2, \'bar\')",
"time": "107.33 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 1,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
},
{
"sql_text": "COMMIT",
"time": "213.23 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 0,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
}
]
}
]