-- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; version 2 of the License. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Returns a JSON object with info on the given threads current transaction, and the statements it has already executed, derived from the
performance_schema.events_transactions_current and
performance_schema.events_statements_history tables (so the consumers for these also have to be enabled within Performance Schemato get full
data in the object).
When the output exceeds the default truncation length (65535), 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 when calling the function.
The max length of the output of this function can be controlled with the
ps_thread_trx_info.max_length variable set via sys_config, or the
@sys.ps_thread_trx_info.max_length user variable, as appropriate.
Parameters -----------
in_thread_id (BIGINTUNSIGNED):
The id of the thread toreturn the transaction info for.
SQL SECURITY INVOKER NOTDETERMINISTIC READSSQL DATA
BEGIN DECLARE v_output LONGTEXTDEFAULT'{}'; DECLARE v_msg_text TEXT DEFAULT''; DECLARE v_signal_msg TEXT DEFAULT''; DECLARE v_mysql_errno INT; DECLARE v_max_output_len BIGINT; -- Capture warnings/errors such as group_concat truncation -- and report as JSON error objects DECLAREEXIT HANDLER FORSQLWARNING, SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION1
v_msg_text = MESSAGE_TEXT,
v_mysql_errno = MYSQL_ERRNO;
IF v_mysql_errno = 1260THEN SET v_signal_msg = CONCAT('{ "error": "Trx info truncated: ', v_msg_text, '" }'); ELSE SET v_signal_msg = CONCAT('{ "error": "', v_msg_text, '" }');
END IF;
RETURN v_signal_msg;
END;
-- Set configuration options IF (@sys.ps_thread_trx_info.max_length ISNULL) THEN SET @sys.ps_thread_trx_info.max_length = sys.sys_get_config('ps_thread_trx_info.max_length', 65535);
END IF;
IF (@sys.ps_thread_trx_info.max_length != @@session.group_concat_max_len) THEN SET @old_group_concat_max_len = @@session.group_concat_max_len; -- Convert to int value for the SET, and give some surrounding space SET v_max_output_len = (@sys.ps_thread_trx_info.max_length - 5); SET SESSION group_concat_max_len = v_max_output_len;
END IF;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.