diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result index d6c68fdd917..b57c898c384 100644 --- a/mysql-test/main/create.result +++ b/mysql-test/main/create.result @@ -1083,12 +1083,13 @@ t1 CREATE TABLE `t1` ( `STAGE` tinyint(2) NOT NULL, `MAX_STAGE` tinyint(2) NOT NULL, `PROGRESS` decimal(7,3) NOT NULL, - `MEMORY_USED` bigint(7) NOT NULL, - `MAX_MEMORY_USED` bigint(7) NOT NULL, - `EXAMINED_ROWS` int(7) NOT NULL, - `QUERY_ID` bigint(4) NOT NULL, + `MEMORY_USED` bigint(10) NOT NULL, + `MAX_MEMORY_USED` bigint(10) NOT NULL, + `EXAMINED_ROWS` bigint(10) NOT NULL, + `SENT_ROWS` bigint(10) NOT NULL, + `QUERY_ID` bigint(10) NOT NULL, `INFO_BINARY` blob, - `TID` bigint(4) NOT NULL + `TID` bigint(10) NOT NULL ) DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci drop table t1; create temporary table t1 like information_schema.processlist; @@ -1107,12 +1108,13 @@ t1 CREATE TEMPORARY TABLE `t1` ( `STAGE` tinyint(2) NOT NULL, `MAX_STAGE` tinyint(2) NOT NULL, `PROGRESS` decimal(7,3) NOT NULL, - `MEMORY_USED` bigint(7) NOT NULL, - `MAX_MEMORY_USED` bigint(7) NOT NULL, - `EXAMINED_ROWS` int(7) NOT NULL, - `QUERY_ID` bigint(4) NOT NULL, + `MEMORY_USED` bigint(10) NOT NULL, + `MAX_MEMORY_USED` bigint(10) NOT NULL, + `EXAMINED_ROWS` bigint(10) NOT NULL, + `SENT_ROWS` bigint(10) NOT NULL, + `QUERY_ID` bigint(10) NOT NULL, `INFO_BINARY` blob, - `TID` bigint(4) NOT NULL + `TID` bigint(10) NOT NULL ) DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci drop table t1; create table t1 like information_schema.character_sets; diff --git a/mysql-test/main/delete_returning.result b/mysql-test/main/delete_returning.result index 3a95de0cdca..ab795149de7 100644 --- a/mysql-test/main/delete_returning.result +++ b/mysql-test/main/delete_returning.result @@ -211,3 +211,19 @@ id 3 set sql_mode=@sql_mode_save; DROP TABLE t1; +# +# MDEV-3953 Add columns for ROWS_EXAMINED, ROWS_SENT, and ROWS_READ to I_S and +# processlist +# +create table t1 (a int primary key, b int); +insert into t1 select seq,seq+1 from seq_1_to_10; +flush status; +delete from t1 where a between 1 and 3 returning a,b; +a b +1 2 +2 3 +3 4 +show status like "Rows_sent"; +Variable_name Value +Rows_sent 3 +drop table t1; diff --git a/mysql-test/main/delete_returning.test b/mysql-test/main/delete_returning.test index 4448a6bcccd..cdfb48e843f 100644 --- a/mysql-test/main/delete_returning.test +++ b/mysql-test/main/delete_returning.test @@ -1,3 +1,4 @@ +--source include/have_sequence.inc # # Tests for DELETE FROM ... RETURNING ,... # @@ -170,3 +171,15 @@ DELETE FROM t1 WHERE id > 2 RETURNING *; set sql_mode=@sql_mode_save; DROP TABLE t1; + +--echo # +--echo # MDEV-3953 Add columns for ROWS_EXAMINED, ROWS_SENT, and ROWS_READ to I_S and +--echo # processlist +--echo # + +create table t1 (a int primary key, b int); +insert into t1 select seq,seq+1 from seq_1_to_10; +flush status; +delete from t1 where a between 1 and 3 returning a,b; +show status like "Rows_sent"; +drop table t1; diff --git a/mysql-test/main/insert_returning.result b/mysql-test/main/insert_returning.result index b2ed9c90e51..c58e1c66378 100644 --- a/mysql-test/main/insert_returning.result +++ b/mysql-test/main/insert_returning.result @@ -683,3 +683,23 @@ INSERT t WITH cte AS (SELECT 1) SELECT * FROM cte RETURNING *; a 1 DROP TABLE t; +# +# MDEV-3953 Add columns for ROWS_EXAMINED, ROWS_SENT, and ROWS_READ to I_S and +# processlist +# +create table t1 (a int primary key, b int); +flush status; +insert into t1 values (1,2),(2,4) returning a,b; +a b +1 2 +2 4 +insert into t1 select seq,seq from seq_10_to_13 returning a,b; +a b +10 10 +11 11 +12 12 +13 13 +show status like "Rows_sent"; +Variable_name Value +Rows_sent 6 +drop table t1; diff --git a/mysql-test/main/insert_returning.test b/mysql-test/main/insert_returning.test index 837d61d2c16..250ca55024f 100644 --- a/mysql-test/main/insert_returning.test +++ b/mysql-test/main/insert_returning.test @@ -1,3 +1,5 @@ +--source include/have_sequence.inc + --echo # Test for INSERT...RETURNING CREATE TABLE t1(id1 INT PRIMARY KEY AUTO_INCREMENT, val1 VARCHAR(1)); @@ -396,3 +398,15 @@ CREATE TABLE t (a INT); INSERT t WITH cte AS (SELECT 1) SELECT * FROM cte RETURNING *; DROP TABLE t; + +--echo # +--echo # MDEV-3953 Add columns for ROWS_EXAMINED, ROWS_SENT, and ROWS_READ to I_S and +--echo # processlist +--echo # + +create table t1 (a int primary key, b int); +flush status; +insert into t1 values (1,2),(2,4) returning a,b; +insert into t1 select seq,seq from seq_10_to_13 returning a,b; +show status like "Rows_sent"; +drop table t1; diff --git a/mysql-test/main/status2.result b/mysql-test/main/status2.result index 60309e14fe3..78d658a7605 100644 --- a/mysql-test/main/status2.result +++ b/mysql-test/main/status2.result @@ -83,3 +83,121 @@ variable_value < 1024*1024*1024 # # End of 10.2 tests # +# +# MDEV-32441 SENT_ROWS shows random wrong values when stored function +# is selected +# +create table t1 (a int) engine=aria; +insert into t1 values (1),(2),(3),(4),(5),(6),(7); +flush status; +create function if not exists f() returns int return +( +select sum(a) > 0 from t1 +); +select f() from seq_1_to_10 where seq%5 = 0; +f() +1 +1 +show status like "rows_sent"; +Variable_name Value +Rows_sent 2 +# Test simple query +set debug_sync='RESET'; +connect con1,localhost,root,,; +set debug_sync='end_of_statement SIGNAL parked WAIT_FOR go'; +select f() from seq_1_to_10 where seq%5 = 0; +connection default; +set debug_sync='now WAIT_FOR parked'; +# Result should be 2, 10+7*2=24 +select sent_rows, examined_rows from information_schema.processlist where id=#; +sent_rows examined_rows +2 24 +set debug_sync='now signal go'; +connection con1; +f() +1 +1 +# Test union +set debug_sync='end_of_statement SIGNAL parked WAIT_FOR go'; +select a from t1 where a not in (1,2,3,4) union select a from t1 where a not in (4,5,6,7); +connection default; +set debug_sync='now WAIT_FOR parked'; +# Result should be 6, 7+7+6=20 (2 scans of 7 rows + 6 rows in union) +select sent_rows, examined_rows from information_schema.processlist where id=#; +sent_rows examined_rows +6 20 +set debug_sync='now signal go'; +connection con1; +a +5 +6 +7 +1 +2 +3 +# Test handler calls +handler t1 open; +set debug_sync='end_of_statement SIGNAL parked WAIT_FOR go'; +handler t1 read NEXT LIMIT 2,4; +connection default; +set debug_sync='now WAIT_FOR parked'; +# Result should be 2, 10+7*2=24 +select sent_rows, examined_rows from information_schema.processlist where id=#; +sent_rows examined_rows +4 6 +set debug_sync='now signal go'; +connection con1; +a +3 +4 +5 +6 +handler t1 close; +connection default; +drop function f; +drop table t1; +# Test Stored procedures +create or replace table t (a int primary key); +insert into t select seq from seq_1_to_100; +create procedure pr() +begin +select * from t where a between 1 and 2 ; +select * from t where a between 4 and 6 ; +end $ +connection con1; +flush status; +set debug_sync='end_of_statement SIGNAL parked WAIT_FOR go EXECUTE 2'; +call pr(); +connection default; +set debug_sync='now WAIT_FOR parked'; +select examined_rows, sent_rows, info from information_schema.processlist where id=#; +examined_rows sent_rows info +2 2 select * from t where a between 1 and 2 +set debug_sync='now signal go'; +select examined_rows, sent_rows, info from information_schema.processlist where id=#; +examined_rows sent_rows info +3 3 select * from t where a between 4 and 6 +set debug_sync='now signal go'; +connection con1; +a +1 +2 +a +4 +5 +6 +show status like '%rows%'; +Variable_name Value +Not_flushed_delayed_rows 0 +Rows_read 8 +Rows_sent 5 +Rows_tmp_read 0 +Sort_rows 0 +connection default; +drop table t; +drop procedure pr; +disconnect con1; +set debug_sync= RESET; +# +# End of 11.3 tests +# diff --git a/mysql-test/main/status2.test b/mysql-test/main/status2.test index 339e853f2fc..1cc53b2bc13 100644 --- a/mysql-test/main/status2.test +++ b/mysql-test/main/status2.test @@ -1,4 +1,7 @@ --source include/not_embedded.inc +--source include/have_sequence.inc +--source include/have_debug_sync.inc +--source include/have_sequence.inc --echo # --echo # Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines @@ -77,3 +80,112 @@ select variable_value < 1024*1024*1024 from information_schema.global_status whe --echo # End of 10.2 tests --echo # +--echo # +--echo # MDEV-32441 SENT_ROWS shows random wrong values when stored function +--echo # is selected +--echo # + +create table t1 (a int) engine=aria; +insert into t1 values (1),(2),(3),(4),(5),(6),(7); +flush status; +create function if not exists f() returns int return +( + select sum(a) > 0 from t1 +); + +--disable_ps_protocol +select f() from seq_1_to_10 where seq%5 = 0; +show status like "rows_sent"; +--enable_ps_protocol + +--echo # Test simple query + +set debug_sync='RESET'; +--connect(con1,localhost,root,,) +--let $conid= `select connection_id()` +--let $replace_conid=id=$conid +set debug_sync='end_of_statement SIGNAL parked WAIT_FOR go'; +--send select f() from seq_1_to_10 where seq%5 = 0 + +--connection default +set debug_sync='now WAIT_FOR parked'; +--echo # Result should be 2, 10+7*2=24 +--replace_result $replace_conid id=# +eval select sent_rows, examined_rows from information_schema.processlist where id=$conid; +set debug_sync='now signal go'; +--connection con1 +--reap + +--echo # Test union + +set debug_sync='end_of_statement SIGNAL parked WAIT_FOR go'; +--send select a from t1 where a not in (1,2,3,4) union select a from t1 where a not in (4,5,6,7) +--connection default +set debug_sync='now WAIT_FOR parked'; +--echo # Result should be 6, 7+7+6=20 (2 scans of 7 rows + 6 rows in union) +--replace_result $replace_conid id=# +eval select sent_rows, examined_rows from information_schema.processlist where id=$conid; +set debug_sync='now signal go'; +--connection con1 +--reap + +--echo # Test handler calls +handler t1 open; +set debug_sync='end_of_statement SIGNAL parked WAIT_FOR go'; +--send handler t1 read NEXT LIMIT 2,4 +--connection default +set debug_sync='now WAIT_FOR parked'; +--echo # Result should be 2, 10+7*2=24 +--replace_result $replace_conid id=# +eval select sent_rows, examined_rows from information_schema.processlist where id=$conid; +set debug_sync='now signal go'; +--connection con1 +--reap +handler t1 close; + +--connection default +drop function f; +drop table t1; + +--echo # Test Stored procedures + +create or replace table t (a int primary key); +insert into t select seq from seq_1_to_100; +--delimiter $ +create procedure pr() +begin + select * from t where a between 1 and 2 ; + select * from t where a between 4 and 6 ; +end $ +--delimiter ; + +--connection con1 +flush status; +set debug_sync='end_of_statement SIGNAL parked WAIT_FOR go EXECUTE 2'; + +--send call pr() + +--connection default +set debug_sync='now WAIT_FOR parked'; +--replace_result $replace_conid id=# +eval select examined_rows, sent_rows, info from information_schema.processlist where id=$conid; +set debug_sync='now signal go'; +--replace_result $replace_conid id=# +eval select examined_rows, sent_rows, info from information_schema.processlist where id=$conid; +set debug_sync='now signal go'; + +--connection con1 +--reap +show status like '%rows%'; + +connection default; +# Cleanup +drop table t; +drop procedure pr; + +--disconnect con1 +set debug_sync= RESET; + +--echo # +--echo # End of 11.3 tests +--echo # diff --git a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc index 90bc19f2784..298a026ed77 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc @@ -161,7 +161,7 @@ eval SHOW CREATE TABLE $table; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS eval SHOW $table; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID eval SELECT * FROM $table $select_where ORDER BY id; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID eval SELECT $columns FROM $table $select_where ORDER BY id; @@ -182,7 +182,7 @@ eval SHOW CREATE TABLE $table; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS eval SHOW $table; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID eval SELECT * FROM $table $select_where ORDER BY id; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID eval SELECT $columns FROM $table $select_where ORDER BY id; @@ -209,7 +209,7 @@ SHOW GRANTS; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -222,7 +222,7 @@ SHOW GRANTS; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -246,7 +246,7 @@ SHOW GRANTS; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -269,7 +269,7 @@ SHOW GRANTS; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -296,7 +296,7 @@ if ($fixed_bug_30395) --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; } ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -318,7 +318,7 @@ SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -341,7 +341,7 @@ SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -389,7 +389,7 @@ SHOW GRANTS FOR 'ddicttestuser2'@'localhost'; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -411,7 +411,7 @@ SHOW GRANTS; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -435,7 +435,7 @@ GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 @@ -460,7 +460,7 @@ SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; --replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; ---replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID +--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 E_ROWS 16 S_ROWS 17 QUERY_ID 19 TID SELECT * FROM information_schema.processlist; --real_sleep 0.3 diff --git a/mysql-test/suite/funcs_1/datadict/processlist_val.inc b/mysql-test/suite/funcs_1/datadict/processlist_val.inc index fa6ed4049d6..ab2482393d5 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_val.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_val.inc @@ -92,7 +92,7 @@ echo # - INFO must contain the corresponding SHOW/SELECT PROCESSLIST # # 1. Just dump what we get ---replace_column 1 3 6