Rechercher dans le manuel MySQL

27.4.5.17 The ps_thread_trx_info() Function

Returns a JSON object containing information about a given thread. The information includes the current transaction, and the statements it has already executed, derived from the Performance Schema events_transactions_current and events_statements_history tables. (The consumers for those tables must be enabled to obtain full data in the JSON object.)

If the output exceeds the truncation length (65535 by default), a JSON error object is returned, such as:

{ "error": "Trx info truncated: Row 6 was cut by GROUP_CONCAT()" }

Similar error objects are returned for other warnings and exceptions raised during function execution.

Parameters
  • in_thread_id BIGINT UNSIGNED: The thread ID for which to return transaction information. The value should match the THREAD_ID column from some Performance Schema threads table row.

Contents Haut

Configuration Options

ps_thread_trx_info() operation can be modified using the following configuration options or their corresponding user-defined variables (see Section 27.4.2.1, “The sys_config Table”):

  • ps_thread_trx_info.max_length, @sys.ps_thread_trx_info.max_length

    The maximum length of the output. The default is 65535.

Contents Haut

Return Value

A LONGTEXT value.

Contents Haut

Example
  1. mysql> SELECT sys.ps_thread_trx_info(48)\G
  2. *************************** 1. row ***************************
  3. sys.ps_thread_trx_info(48): [
  4.   {
  5.     "time": "790.70 us",
  6.     "state": "COMMITTED",
  7.     "mode": "READ WRITE",
  8.     "autocommitted": "NO",
  9.     "gtid": "AUTOMATIC",
  10.     "isolation": "REPEATABLE READ",
  11.     "statements_executed": [
  12.       {
  13.         "sql_text": "INSERT INTO info VALUES (1, \'foo\')",
  14.         "time": "471.02 us",
  15.         "schema": "trx",
  16.         "rows_examined": 0,
  17.         "rows_affected": 1,
  18.         "rows_sent": 0,
  19.         "tmp_tables": 0,
  20.         "tmp_disk_tables": 0,
  21.         "sort_rows": 0,
  22.         "sort_merge_passes": 0
  23.       },
  24.       {
  25.         "sql_text": "COMMIT",
  26.         "time": "254.42 us",
  27.         "schema": "trx",
  28.         "rows_examined": 0,
  29.         "rows_affected": 0,
  30.         "rows_sent": 0,
  31.         "tmp_tables": 0,
  32.         "tmp_disk_tables": 0,
  33.         "sort_rows": 0,
  34.         "sort_merge_passes": 0
  35.       }
  36.     ]
  37.   },
  38.   {
  39.     "time": "426.20 us",
  40.     "state": "COMMITTED",
  41.     "mode": "READ WRITE",
  42.     "autocommitted": "NO",
  43.     "gtid": "AUTOMATIC",
  44.     "isolation": "REPEATABLE READ",
  45.     "statements_executed": [
  46.       {
  47.         "sql_text": "INSERT INTO info VALUES (2, \'bar\')",
  48.         "time": "107.33 us",
  49.         "schema": "trx",
  50.         "rows_examined": 0,
  51.         "rows_affected": 1,
  52.         "rows_sent": 0,
  53.         "tmp_tables": 0,
  54.         "tmp_disk_tables": 0,
  55.         "sort_rows": 0,
  56.         "sort_merge_passes": 0
  57.       },
  58.       {
  59.         "sql_text": "COMMIT",
  60.         "time": "213.23 us",
  61.         "schema": "trx",
  62.         "rows_examined": 0,
  63.         "rows_affected": 0,
  64.         "rows_sent": 0,
  65.         "tmp_tables": 0,
  66.         "tmp_disk_tables": 0,
  67.         "sort_rows": 0,
  68.         "sort_merge_passes": 0
  69.       }
  70.     ]
  71.   }
  72. ]

Find a PHP function

Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-sys-ps-thread-trx-info.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:en Manuel MySQL : https://dev.mysql.com/

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut