Commit 91ee98a8 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-7807 information_schema.processlist truncates queries with binary strings

Adding a new column INFORMATION_SCHEMA.PROCESSLIST.INFO_BINARY.
parent 0fcc350f
...@@ -1925,7 +1925,8 @@ t1 CREATE TABLE `t1` ( ...@@ -1925,7 +1925,8 @@ t1 CREATE TABLE `t1` (
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000', `PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000',
`MEMORY_USED` int(7) NOT NULL DEFAULT '0', `MEMORY_USED` int(7) NOT NULL DEFAULT '0',
`EXAMINED_ROWS` int(7) NOT NULL DEFAULT '0', `EXAMINED_ROWS` int(7) NOT NULL DEFAULT '0',
`QUERY_ID` bigint(4) NOT NULL DEFAULT '0' `QUERY_ID` bigint(4) NOT NULL DEFAULT '0',
`INFO_BINARY` blob
) DEFAULT CHARSET=utf8 ) DEFAULT CHARSET=utf8
drop table t1; drop table t1;
create temporary table t1 like information_schema.processlist; create temporary table t1 like information_schema.processlist;
...@@ -1946,7 +1947,8 @@ t1 CREATE TEMPORARY TABLE `t1` ( ...@@ -1946,7 +1947,8 @@ t1 CREATE TEMPORARY TABLE `t1` (
`PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000', `PROGRESS` decimal(7,3) NOT NULL DEFAULT '0.000',
`MEMORY_USED` int(7) NOT NULL DEFAULT '0', `MEMORY_USED` int(7) NOT NULL DEFAULT '0',
`EXAMINED_ROWS` int(7) NOT NULL DEFAULT '0', `EXAMINED_ROWS` int(7) NOT NULL DEFAULT '0',
`QUERY_ID` bigint(4) NOT NULL DEFAULT '0' `QUERY_ID` bigint(4) NOT NULL DEFAULT '0',
`INFO_BINARY` blob
) DEFAULT CHARSET=utf8 ) DEFAULT CHARSET=utf8
drop table t1; drop table t1;
create table t1 like information_schema.character_sets; create table t1 like information_schema.character_sets;
......
...@@ -17,3 +17,21 @@ select command, time < 5 from information_schema.processlist where id != connect ...@@ -17,3 +17,21 @@ select command, time < 5 from information_schema.processlist where id != connect
command time < 5 command time < 5
Sleep 1 Sleep 1
set debug_sync='reset'; set debug_sync='reset';
#
# 10.1 tests
#
#
# MDEV-7807 information_schema.processlist truncates queries with binary strings
#
SET NAMES utf8;
SELECT INFO, INFO_BINARY, 'xxx😎yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%';
INFO SELECT INFO, INFO_BINARY, 'xxx????yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%'
INFO_BINARY SELECT INFO, INFO_BINARY, 'xxx😎yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%'
utf8mb4_string xxx😎yyy
Warnings:
Level Warning
Code 1366
Message Incorrect string value: '\xF0\x9F\x98\x8Eyy...' for column 'INFO' at row 1
#
# End of 10.1 tests
#
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
let $table= processlist; let $table= processlist;
# #
# columns of the information_schema table e.g. to use in a select. # columns of the information_schema table e.g. to use in a select.
let $columns= ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS, QUERY_ID; let $columns= ID, USER, HOST, DB, COMMAND, TIME, STATE, INFO, TIME_MS, STAGE, MAX_STAGE, PROGRESS, MEMORY_USED, EXAMINED_ROWS, QUERY_ID, INFO_BINARY;
# #
# Where clause for an update. # Where clause for an update.
let $update_where= WHERE id=1 ; let $update_where= WHERE id=1 ;
......
...@@ -258,6 +258,7 @@ def information_schema PROCESSLIST EXAMINED_ROWS 14 0 NO int NULL NULL 10 0 NULL ...@@ -258,6 +258,7 @@ def information_schema PROCESSLIST EXAMINED_ROWS 14 0 NO int NULL NULL 10 0 NULL
def information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select def information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select
def information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select def information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4) select
def information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select def information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext select
def information_schema PROCESSLIST INFO_BINARY 16 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob select
def information_schema PROCESSLIST MAX_STAGE 11 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(2) select def information_schema PROCESSLIST MAX_STAGE 11 0 NO tinyint NULL NULL 3 0 NULL NULL NULL tinyint(2) select
def information_schema PROCESSLIST MEMORY_USED 13 0 NO int NULL NULL 10 0 NULL NULL NULL int(7) select def information_schema PROCESSLIST MEMORY_USED 13 0 NO int NULL NULL 10 0 NULL NULL NULL int(7) select
def information_schema PROCESSLIST PROGRESS 12 0.000 NO decimal NULL NULL 7 3 NULL NULL NULL decimal(7,3) select def information_schema PROCESSLIST PROGRESS 12 0.000 NO decimal NULL NULL 7 3 NULL NULL NULL decimal(7,3) select
...@@ -480,6 +481,7 @@ AND table_name <> 'profiling' AND table_name not like 'innodb_%' ...@@ -480,6 +481,7 @@ AND table_name <> 'profiling' AND table_name not like 'innodb_%'
AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH = 1 AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH = 1
ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML; ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
1.0000 blob NULL NULL
1.0000 longtext utf8 utf8_general_ci 1.0000 longtext utf8 utf8_general_ci
SELECT DISTINCT SELECT DISTINCT
CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML, CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
...@@ -792,6 +794,7 @@ NULL information_schema PROCESSLIST PROGRESS decimal NULL NULL NULL NULL decimal ...@@ -792,6 +794,7 @@ NULL information_schema PROCESSLIST PROGRESS decimal NULL NULL NULL NULL decimal
NULL information_schema PROCESSLIST MEMORY_USED int NULL NULL NULL NULL int(7) NULL information_schema PROCESSLIST MEMORY_USED int NULL NULL NULL NULL int(7)
NULL information_schema PROCESSLIST EXAMINED_ROWS int NULL NULL NULL NULL int(7) NULL information_schema PROCESSLIST EXAMINED_ROWS int NULL NULL NULL NULL int(7)
NULL information_schema PROCESSLIST QUERY_ID bigint NULL NULL NULL NULL bigint(4) NULL information_schema PROCESSLIST QUERY_ID bigint NULL NULL NULL NULL bigint(4)
1.0000 information_schema PROCESSLIST INFO_BINARY blob 65535 65535 NULL NULL blob
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
......
...@@ -50,3 +50,23 @@ select command, time < 5 from information_schema.processlist where id != connect ...@@ -50,3 +50,23 @@ select command, time < 5 from information_schema.processlist where id != connect
disconnect con1; disconnect con1;
set debug_sync='reset'; set debug_sync='reset';
connection default;
--echo #
--echo # 10.1 tests
--echo #
--echo #
--echo # MDEV-7807 information_schema.processlist truncates queries with binary strings
--echo #
SET NAMES utf8;
--vertical_results
SELECT INFO, INFO_BINARY, 'xxx😎yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%';
--horizontal_results
--echo #
--echo # End of 10.1 tests
--echo #
...@@ -2833,6 +2833,15 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) ...@@ -2833,6 +2833,15 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
/* QUERY_ID */ /* QUERY_ID */
table->field[14]->store(tmp->query_id, TRUE); table->field[14]->store(tmp->query_id, TRUE);
/* INFO_BINARY */
if (tmp->query())
{
table->field[15]->store(tmp->query(),
MY_MIN(PROCESS_LIST_INFO_WIDTH,
tmp->query_length()), &my_charset_bin);
table->field[15]->set_notnull();
}
if (schema_table_store_record(thd, table)) if (schema_table_store_record(thd, table))
{ {
mysql_mutex_unlock(&LOCK_thread_count); mysql_mutex_unlock(&LOCK_thread_count);
...@@ -8620,6 +8629,8 @@ ST_FIELD_INFO processlist_fields_info[]= ...@@ -8620,6 +8629,8 @@ ST_FIELD_INFO processlist_fields_info[]=
{"MEMORY_USED", 7, MYSQL_TYPE_LONG, 0, 0, "Memory_used", SKIP_OPEN_TABLE}, {"MEMORY_USED", 7, MYSQL_TYPE_LONG, 0, 0, "Memory_used", SKIP_OPEN_TABLE},
{"EXAMINED_ROWS", 7, MYSQL_TYPE_LONG, 0, 0, "Examined_rows", SKIP_OPEN_TABLE}, {"EXAMINED_ROWS", 7, MYSQL_TYPE_LONG, 0, 0, "Examined_rows", SKIP_OPEN_TABLE},
{"QUERY_ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, {"QUERY_ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE},
{"INFO_BINARY", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_BLOB, 0, 1,
"Info_binary", SKIP_OPEN_TABLE},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment