diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-10 21:08:46 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-10 21:08:46 +0300 |
commit | eae968f62d285de97ed607c87bc131cd863d5d03 (patch) | |
tree | b86dacfaf9e1340161d3675204544a4db937eb05 | |
parent | 101ddc5e2708e4e32f1aaa7a02fe85f0da95b73a (diff) | |
parent | bafc5c1321a7dff5f2da292111bf98fed9d1658d (diff) | |
download | mariadb-git-eae968f62d285de97ed607c87bc131cd863d5d03.tar.gz |
Merge 10.3 into 10.4
43 files changed, 702 insertions, 294 deletions
diff --git a/include/violite.h b/include/violite.h index 27ad58ba1a9..f0fc53e4d6e 100644 --- a/include/violite.h +++ b/include/violite.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2012, 2017, MariaDB Corporation. + Copyright (c) 2012, 2020, MariaDB Corporation. 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 @@ -273,6 +273,7 @@ struct st_vio #ifdef _WIN32 HANDLE hPipe; OVERLAPPED overlapped; + int shutdown_flag; #endif }; #endif /* vio_violite_h_ */ diff --git a/mysql-test/main/ctype_filename.result b/mysql-test/main/ctype_filename.result index c6d7d1e39b9..7536ea97fb1 100644 --- a/mysql-test/main/ctype_filename.result +++ b/mysql-test/main/ctype_filename.result @@ -21,3 +21,10 @@ SET NAMES utf8; SELECT @a:=CONVERT('aя' USING filename) AS `@a`, BINARY @a, REVERSE(@a), HEX(@a), HEX(REVERSE(@a)); @a BINARY @a REVERSE(@a) HEX(@a) HEX(REVERSE(@a)) aя a@r1 яa 61407231 40723161 +# +# MDEV-22022 Various mangled SQL statements will crash 10.3 to 10.5 debug builds +# +SET CHARACTER_SET_CLIENT=17; +SELECT doc.`Children`.0 FROM t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?Children??0?FROM?t1' at line 1 +SET NAMES latin1; diff --git a/mysql-test/main/ctype_filename.test b/mysql-test/main/ctype_filename.test index 7ec07293a2b..6f77a6c5a3a 100644 --- a/mysql-test/main/ctype_filename.test +++ b/mysql-test/main/ctype_filename.test @@ -27,3 +27,13 @@ select convert(convert(',' using filename) using binary); --echo # SET NAMES utf8; SELECT @a:=CONVERT('aя' USING filename) AS `@a`, BINARY @a, REVERSE(@a), HEX(@a), HEX(REVERSE(@a)); + + +--echo # +--echo # MDEV-22022 Various mangled SQL statements will crash 10.3 to 10.5 debug builds +--echo # + +SET CHARACTER_SET_CLIENT=17; +--error ER_PARSE_ERROR +SELECT doc.`Children`.0 FROM t1; +SET NAMES latin1; diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result index 456bc251e78..8cb2ebd551f 100644 --- a/mysql-test/main/grant.result +++ b/mysql-test/main/grant.result @@ -2766,6 +2766,24 @@ root@localhost DROP TABLE t1; DROP USER dummy@localhost; # +# MDEV-23082: ER_TABLEACCESS_DENIED_ERROR error message is truncated, and +# inaccurately +# +CREATE USER foo; +CREATE DATABASE db; +CREATE TABLE db.t (a INT); +connect con1,localhost,foo,,; +GRANT ALL ON db.t TO foo; +ERROR 42000: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, GRANT, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW ... command denied to user 'foo'@'localhost' for table 't' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, GRANT OPTION, REFERENCES, +INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON db.t TO foo; +ERROR 42000: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, GRANT, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW ... command denied to user 'foo'@'localhost' for table 't' +connection default; +disconnect con1; +DROP USER foo; +DROP TABLE db.t; +DROP DATABASE db; +# # End of 10.2 tests # # diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index 147fc42311c..38baf673825 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -2260,6 +2260,31 @@ DROP TABLE t1; DROP USER dummy@localhost; --echo # +--echo # MDEV-23082: ER_TABLEACCESS_DENIED_ERROR error message is truncated, and +--echo # inaccurately +--echo # + +CREATE USER foo; +CREATE DATABASE db; +CREATE TABLE db.t (a INT); + +--connect (con1,localhost,foo,,) + +--error ER_TABLEACCESS_DENIED_ERROR +GRANT ALL ON db.t TO foo; + +--error ER_TABLEACCESS_DENIED_ERROR +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, GRANT OPTION, REFERENCES, +INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON db.t TO foo; + +--connection default +--disconnect con1 + +DROP USER foo; +DROP TABLE db.t; +DROP DATABASE db; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result index 2fd7f98c3a5..b1eff9eb237 100644 --- a/mysql-test/main/information_schema.result +++ b/mysql-test/main/information_schema.result @@ -2219,6 +2219,21 @@ SCHEMA_NAME # End of 10.1 tests # # +# Start of 10.2 Test +# +# MDEV-14836: Assertion `m_status == DA_ERROR' failed in +# Diagnostics_area::sql_errno upon query from I_S with LIMIT ROWS EXAMINED +# +SELECT * FROM INFORMATION_SCHEMA.`COLUMNS` LIMIT ROWS EXAMINED 10; +ERROR HY000: Unknown error +SHOW WARNINGS; +Level Code Message +Error 1105 Unknown error +Warning 1931 Query execution was interrupted. The query examined at least 11 rows, which exceeds LIMIT ROWS EXAMINED (10). The query result may be incomplete +# +# End of 10.2 Test +# +# # MDEV-21201:No records produced in information_schema query, # depending on projection # diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test index 634493832f7..12b940c66b0 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -1924,6 +1924,20 @@ SELECT SCHEMA_NAME from information_schema.schemata where schema_name=REPEAT('a' --echo # End of 10.1 tests --echo # +--echo # +--echo # Start of 10.2 Test +--echo # +--echo # MDEV-14836: Assertion `m_status == DA_ERROR' failed in +--echo # Diagnostics_area::sql_errno upon query from I_S with LIMIT ROWS EXAMINED +--echo # + +--error ER_UNKNOWN_ERROR +SELECT * FROM INFORMATION_SCHEMA.`COLUMNS` LIMIT ROWS EXAMINED 10; +SHOW WARNINGS; + +--echo # +--echo # End of 10.2 Test +--echo # --echo # --echo # MDEV-21201:No records produced in information_schema query, diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff index 77f6f76858f..1bdbc0fc287 100644 --- a/mysql-test/main/mysqld--help,win.rdiff +++ b/mysql-test/main/mysqld--help,win.rdiff @@ -82,20 +82,6 @@ sort-buffer-size 2097152 sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION sql-safe-updates FALSE -@@ -1741,10 +1752,10 @@ - sync-relay-log-info 10000 - sysdate-is-now FALSE - system-versioning-alter-history ERROR --table-cache 421 -+table-cache 2000 - table-definition-cache 400 --table-open-cache 421 --table-open-cache-instances 1 -+table-open-cache 2000 -+table-open-cache-instances 8 - tc-heuristic-recover OFF - tcp-keepalive-interval 0 - tcp-keepalive-probes 0 @@ -1753,6 +1764,8 @@ thread-cache-size 151 thread-pool-idle-timeout 60 diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 059818b2170..45b1e4afe05 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -1550,7 +1550,6 @@ max-binlog-cache-size 18446744073709547520 max-binlog-size 1073741824 max-binlog-stmt-cache-size 18446744073709547520 max-connect-errors 100 -max-connections 151 max-delayed-threads 20 max-digest-length 1024 max-error-count 64 @@ -1741,10 +1740,7 @@ sync-relay-log 10000 sync-relay-log-info 10000 sysdate-is-now FALSE system-versioning-alter-history ERROR -table-cache 421 table-definition-cache 400 -table-open-cache 421 -table-open-cache-instances 1 tc-heuristic-recover OFF tcp-keepalive-interval 0 tcp-keepalive-probes 0 diff --git a/mysql-test/main/mysqld--help.test b/mysql-test/main/mysqld--help.test index 23bf7601e06..6efd088cbdd 100644 --- a/mysql-test/main/mysqld--help.test +++ b/mysql-test/main/mysqld--help.test @@ -23,7 +23,9 @@ perl; log-slow-queries pid-file slow-query-log-file log-basename datadir slave-load-tmpdir tmpdir socket thread-pool-size large-files-support lower-case-file-system system-time-zone - collation-server character-set-server log-tc-size tls-version version.*/; + collation-server character-set-server log-tc-size table-cache + table-open-cache table-open-cache-instances max-connections + tls-version version.*/; # Plugins which may or may not be there: @plugins=qw/innodb archive blackhole federated partition diff --git a/mysql-test/main/named_pipe.test b/mysql-test/main/named_pipe.test index 8503907b808..2fe6f1cc5c0 100644 --- a/mysql-test/main/named_pipe.test +++ b/mysql-test/main/named_pipe.test @@ -30,3 +30,4 @@ let $MYSQLD_DATADIR= `select @@datadir`; let SEARCH_FILE=$MYSQLD_DATADIR/second-mysqld.err; let SEARCH_PATTERN=\[ERROR\] Create named pipe failed; source include/search_pattern_in_file.inc; +remove_file $SEARCH_FILE; diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 37f510c8ce3..78156c842ea 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1764,6 +1764,13 @@ SELECT @@GLOBAL.password; ERROR HY000: Unknown system variable 'password' SELECT @@GLOBAL.role; ERROR HY000: Unknown system variable 'role' +# +# MDEV-22022 Various mangled SQL statements will crash 10.3 to 10.5 debug builds +# +EXECUTE IMMEDIATE 'if(`systeminfo /FO LIST'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`systeminfo /FO LIST' at line 1 +EXECUTE IMMEDIATE 'if(`systeminfo'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`systeminfo' at line 1 End of 10.3 tests # # MDEV-19540: 10.4 allow lock options with SELECT in brackets diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index b8ea7bd22e4..608f76557e5 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1541,6 +1541,15 @@ SELECT @@GLOBAL.password; --error ER_UNKNOWN_SYSTEM_VARIABLE SELECT @@GLOBAL.role; +--echo # +--echo # MDEV-22022 Various mangled SQL statements will crash 10.3 to 10.5 debug builds +--echo # + +--error ER_PARSE_ERROR +EXECUTE IMMEDIATE 'if(`systeminfo /FO LIST'; +--error ER_PARSE_ERROR +EXECUTE IMMEDIATE 'if(`systeminfo'; + --echo End of 10.3 tests --echo # diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index 8c8471512cf..62309d1d232 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -2609,6 +2609,47 @@ Central America and the Caribbean 442 66422 SET @@optimizer_switch= @save_optimizer_switch; DROP TABLE t1; # +# MDEV-9513: Assertion `join->group_list || !join->is_in_subquery()' failed in create_sort_index +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (2),(3); +EXPLAIN +SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 2 Using where +3 DEPENDENT UNION B ALL NULL NULL NULL NULL 2 Using where +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL +SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1); +a +1 +2 +EXPLAIN +SELECT t1.a FROM t1 WHERE EXISTS (SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 SUBQUERY A ALL NULL NULL NULL NULL 2 +3 UNION B ALL NULL NULL NULL NULL 2 +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL +SELECT t1.a FROM t1 WHERE EXISTS (SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1); +a +1 +2 +EXPLAIN +SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION ALL SELECT B.a FROM t2 B ORDER BY 1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY A ALL NULL NULL NULL NULL 2 Using where +3 DEPENDENT UNION B ALL NULL NULL NULL NULL 2 Using where +SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION ALL SELECT B.a FROM t2 B ORDER BY 1); +a +1 +2 +DROP TABLE t1,t2; +# end of 10.1 tests +# # MDEV-22852: SIGSEGV in sortlength (optimized builds) # SET @save_optimizer_switch=@@optimizer_switch; @@ -2620,6 +2661,31 @@ SELECT (SELECT DISTINCT t1i.b FROM t1 t1i GROUP BY t1i.a ORDER BY MAX(t1o.b)) FR 0 SET @@optimizer_switch= @save_optimizer_switch; DROP TABLE t1; +# +# MDEV-17066: Bytes lost or Assertion `status_var.local_memory_used == 0 after DELETE +# with subquery with ROLLUP +# +CREATE TABLE t1 (i INT DEFAULT 0, c VARCHAR(2048)); +INSERT INTO t1 SELECT 0, seq FROM seq_1_to_6000; +CREATE TABLE t2 (f VARCHAR(2048) DEFAULT ''); +INSERT INTO t2 VALUES ('1'),('bar'); +EXPLAIN +SELECT * FROM t2 WHERE f IN ( SELECT MAX(c) FROM t1 GROUP BY c WITH ROLLUP); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6000 Using filesort +SELECT * FROM t2 WHERE f IN ( SELECT MAX(c) FROM t1 GROUP BY c WITH ROLLUP); +f +1 +SELECT * FROM t2; +f +1 +bar +DELETE FROM t2 WHERE f IN ( SELECT MAX(c) FROM t1 GROUP BY c WITH ROLLUP ); +SELECT * FROM t2; +f +bar +DROP TABLE t1, t2; # End of 10.2 tests # # MDEV-19134: EXISTS() slower if ORDER BY is defined diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test index 1ed79de4598..8d2ddaab09b 100644 --- a/mysql-test/main/subselect4.test +++ b/mysql-test/main/subselect4.test @@ -7,6 +7,8 @@ drop table if exists t0,t1,t2,t3,t4,t5,t6; drop view if exists v1, v2; --enable_warnings +--source include/have_sequence.inc + set @subselect4_tmp= @@optimizer_switch; set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; set optimizer_switch='semijoin_with_cache=on'; @@ -2142,6 +2144,31 @@ SET @@optimizer_switch= @save_optimizer_switch; DROP TABLE t1; --echo # +--echo # MDEV-9513: Assertion `join->group_list || !join->is_in_subquery()' failed in create_sort_index +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES (2),(3); +EXPLAIN +SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1); +SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1); + +EXPLAIN +SELECT t1.a FROM t1 WHERE EXISTS (SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1); +SELECT t1.a FROM t1 WHERE EXISTS (SELECT A.a FROM t1 A UNION SELECT B.a FROM t2 B ORDER BY 1); + +EXPLAIN +SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION ALL SELECT B.a FROM t2 B ORDER BY 1); +SELECT t1.a FROM t1 WHERE t1.a IN ( SELECT A.a FROM t1 A UNION ALL SELECT B.a FROM t2 B ORDER BY 1); + +DROP TABLE t1,t2; + +--echo # end of 10.1 tests + +--echo # --echo # MDEV-22852: SIGSEGV in sortlength (optimized builds) --echo # @@ -2153,6 +2180,27 @@ SELECT (SELECT DISTINCT t1i.b FROM t1 t1i GROUP BY t1i.a ORDER BY MAX(t1o.b)) FR SET @@optimizer_switch= @save_optimizer_switch; DROP TABLE t1; +--echo # +--echo # MDEV-17066: Bytes lost or Assertion `status_var.local_memory_used == 0 after DELETE +--echo # with subquery with ROLLUP +--echo # + +CREATE TABLE t1 (i INT DEFAULT 0, c VARCHAR(2048)); +INSERT INTO t1 SELECT 0, seq FROM seq_1_to_6000; + +CREATE TABLE t2 (f VARCHAR(2048) DEFAULT ''); +INSERT INTO t2 VALUES ('1'),('bar'); + +EXPLAIN +SELECT * FROM t2 WHERE f IN ( SELECT MAX(c) FROM t1 GROUP BY c WITH ROLLUP); +SELECT * FROM t2 WHERE f IN ( SELECT MAX(c) FROM t1 GROUP BY c WITH ROLLUP); + +SELECT * FROM t2; +DELETE FROM t2 WHERE f IN ( SELECT MAX(c) FROM t1 GROUP BY c WITH ROLLUP ); +SELECT * FROM t2; + +DROP TABLE t1, t2; + --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/type_newdecimal.result b/mysql-test/main/type_newdecimal.result index cbe7b84277d..eac263296e2 100644 --- a/mysql-test/main/type_newdecimal.result +++ b/mysql-test/main/type_newdecimal.result @@ -2340,6 +2340,53 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; # +# MDEV-23105 Cast number string with many leading zeros to decimal gives unexpected result +# +SELECT CAST(0000000000000000000000000000000000000000000000000000000000000000000000000000000020.01 AS DECIMAL(15,2)) as val; +val +20.01 +SET sql_mode=''; +CREATE TABLE t1 (a TEXT); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1)); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.0')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.9')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.99')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.994')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.995')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.999')); +CREATE TABLE t2 (a TEXT, d DECIMAL(15,2)); +INSERT IGNORE INTO t2 (a,d) SELECT a, a FROM t1; +Warnings: +Note 1265 Data truncated for column 'd' at row 5 +Note 1265 Data truncated for column 'd' at row 6 +Note 1265 Data truncated for column 'd' at row 7 +INSERT IGNORE INTO t2 (a,d) SELECT CONCAT('-',a), CONCAT('-',a) FROM t1; +Warnings: +Note 1265 Data truncated for column 'd' at row 5 +Note 1265 Data truncated for column 'd' at row 6 +Note 1265 Data truncated for column 'd' at row 7 +SELECT d, a FROM t2 ORDER BY d,a; +d a +-2.00 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.995 +-2.00 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.999 +-1.99 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.99 +-1.99 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.994 +-1.90 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.9 +-1.00 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 +-1.00 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.0 +1.00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 +1.00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.0 +1.90 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.9 +1.99 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.99 +1.99 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.994 +2.00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.995 +2.00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001.999 +DROP TABLE t1, t2; +SET sql_mode=DEFAULT; +# +# End of 10.1 tests +# +# # Bug#18408499 UNSIGNED BIGINT HIGH VALUES # WRONG NUMERICAL COMPARISON RESULTS # diff --git a/mysql-test/main/type_newdecimal.test b/mysql-test/main/type_newdecimal.test index c2b3dc44b37..5b7ecf89a07 100644 --- a/mysql-test/main/type_newdecimal.test +++ b/mysql-test/main/type_newdecimal.test @@ -1825,6 +1825,32 @@ SHOW CREATE TABLE t1; DROP TABLE t1; --echo # +--echo # MDEV-23105 Cast number string with many leading zeros to decimal gives unexpected result +--echo # + +SELECT CAST(0000000000000000000000000000000000000000000000000000000000000000000000000000000020.01 AS DECIMAL(15,2)) as val; + +SET sql_mode=''; +CREATE TABLE t1 (a TEXT); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1)); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.0')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.9')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.99')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.994')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.995')); +INSERT INTO t1 VALUES (CONCAT(REPEAT('0',100),1,'.999')); +CREATE TABLE t2 (a TEXT, d DECIMAL(15,2)); +INSERT IGNORE INTO t2 (a,d) SELECT a, a FROM t1; +INSERT IGNORE INTO t2 (a,d) SELECT CONCAT('-',a), CONCAT('-',a) FROM t1; +SELECT d, a FROM t2 ORDER BY d,a; +DROP TABLE t1, t2; +SET sql_mode=DEFAULT; + +--echo # +--echo # End of 10.1 tests +--echo # + +--echo # --echo # Bug#18408499 UNSIGNED BIGINT HIGH VALUES --echo # WRONG NUMERICAL COMPARISON RESULTS --echo # diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 782abbf7947..ed10568703c 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -3850,6 +3850,22 @@ ERROR 42000: Too big scale 56 specified for 'rank() over w1'. Maximum is 38 SELECT cast((rank() over w1) as decimal (53,30)); ERROR HY000: Window specification with name 'w1' is not defined # +# MDEV-15180: server crashed with NTH_VALUE() +# +CREATE TABLE t1 (i1 int, a int); +INSERT INTO t1 VALUES (1, 1), (2, 2),(3, 3); +CREATE TABLE t2 (i2 int); +INSERT INTO t2 VALUES (1),(2),(5),(1),(7),(4),(3); +CREATE VIEW v1 AS (SELECT * FROM t1,t2 WHERE t1.i1=t2.i2) ; +SELECT NTH_VALUE(i1, i1) OVER (PARTITION BY i1) FROM v1; +NTH_VALUE(i1, i1) OVER (PARTITION BY i1) +1 +1 +NULL +NULL +DROP VIEW v1; +DROP TABLE t1,t2; +# # End of 10.2 tests # # diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test index 427a765355b..f5ad5e8b778 100644 --- a/mysql-test/main/win.test +++ b/mysql-test/main/win.test @@ -2507,6 +2507,22 @@ SELECT cast((rank() over w1) as decimal (53,56)); SELECT cast((rank() over w1) as decimal (53,30)); --echo # +--echo # MDEV-15180: server crashed with NTH_VALUE() +--echo # + +CREATE TABLE t1 (i1 int, a int); +INSERT INTO t1 VALUES (1, 1), (2, 2),(3, 3); + +CREATE TABLE t2 (i2 int); +INSERT INTO t2 VALUES (1),(2),(5),(1),(7),(4),(3); + +CREATE VIEW v1 AS (SELECT * FROM t1,t2 WHERE t1.i1=t2.i2) ; +SELECT NTH_VALUE(i1, i1) OVER (PARTITION BY i1) FROM v1; + +DROP VIEW v1; +DROP TABLE t1,t2; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 8550b2bd180..1e993bca1e9 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -15,6 +15,7 @@ GCF-939 : MDEV-21520 galera.GCF-939 MDEV-16509 : MDEV-21523 galera.MDEV-16509 MDEV-20225 : MDEV-20886 galera.MDEV-20225 MW-286 : MDEV-18464 Killing thread can cause mutex deadlock if done concurrently with Galera/replication victim kill +MW-328A : MDEV-22666 galera.MW-328A MTR failed: "Semaphore wait has lasted > 600 seconds" and do not release port 16002 MW-329 : MDEV-19962 Galera test failure on MW-329 galera.galera_defaults : MDEV-21494 Galera test sporadic failure on galera.galera_defaults galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid_log_event::do_apply_event() diff --git a/mysql-test/suite/galera/r/galera_bf_lock_wait.result b/mysql-test/suite/galera/r/galera_bf_lock_wait.result index 723f3e37282..757fbf50cad 100644 --- a/mysql-test/suite/galera/r/galera_bf_lock_wait.result +++ b/mysql-test/suite/galera/r/galera_bf_lock_wait.result @@ -6,24 +6,41 @@ connection node_1; call mtr.add_suppression("WSREP: Trying to continue unpaused monitor"); CREATE TABLE t1 ENGINE=InnoDB select 1 as a, 1 as b union select 2, 2; ALTER TABLE t1 add primary key(a); -CREATE PROCEDURE p1() +CREATE PROCEDURE p1(repeat_count INT) BEGIN +DECLARE current_num int; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION rollback; -WHILE 1 DO +SET current_num = 0; +WHILE current_num < repeat_count DO start transaction; update t1 set b=connection_id() where a=1; commit; +SET current_num = current_num + 1; END WHILE; END| +connection node_2; connect node_1_p1, 127.0.0.1, root, , test, $NODE_MYPORT_1; -call p1; +SET SESSION wsrep_sync_wait=0; +call p1(1000); connect node_1_p2, 127.0.0.1, root, , test, $NODE_MYPORT_1; -call p1; +SET SESSION wsrep_sync_wait=0; +call p1(1000); connect node_2_p1, 127.0.0.1, root, , test, $NODE_MYPORT_2; -call p1; +SET SESSION wsrep_sync_wait=0; +call p1(1000); connect node_2_p2, 127.0.0.1, root, , test, $NODE_MYPORT_2; -call p1; +SET SESSION wsrep_sync_wait=0; +call p1(1000); connection node_1; checking error log for 'BF lock wait long' message for 10 times every 10 seconds ... +connection node_1_p1; +connection node_1_p2; +connection node_2_p1; +connection node_2_p2; +connection node_1; drop table t1; drop procedure p1; +disconnect node_1_p1; +disconnect node_1_p2; +disconnect node_2_p1; +disconnect node_2_p2; diff --git a/mysql-test/suite/galera/t/galera_bf_lock_wait.test b/mysql-test/suite/galera/t/galera_bf_lock_wait.test index a78a94eb1db..0562b4361ff 100644 --- a/mysql-test/suite/galera/t/galera_bf_lock_wait.test +++ b/mysql-test/suite/galera/t/galera_bf_lock_wait.test @@ -13,27 +13,39 @@ ALTER TABLE t1 add primary key(a); DELIMITER |; -CREATE PROCEDURE p1() +CREATE PROCEDURE p1(repeat_count INT) BEGIN + DECLARE current_num int; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION rollback; - WHILE 1 DO + SET current_num = 0; + + WHILE current_num < repeat_count DO start transaction; update t1 set b=connection_id() where a=1; commit; + SET current_num = current_num + 1; END WHILE; END| DELIMITER ;| - + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME = 'p1' +--source include/wait_condition.inc + --connect node_1_p1, 127.0.0.1, root, , test, $NODE_MYPORT_1 -send call p1; +SET SESSION wsrep_sync_wait=0; +send call p1(1000); --connect node_1_p2, 127.0.0.1, root, , test, $NODE_MYPORT_1 -send call p1; +SET SESSION wsrep_sync_wait=0; +send call p1(1000); --connect node_2_p1, 127.0.0.1, root, , test, $NODE_MYPORT_2 -send call p1; +SET SESSION wsrep_sync_wait=0; +send call p1(1000); --connect node_2_p2, 127.0.0.1, root, , test, $NODE_MYPORT_2 -send call p1; +SET SESSION wsrep_sync_wait=0; +send call p1(1000); connection node_1; let $counter=10; @@ -53,7 +65,26 @@ while($counter > 0) exec grep 'BF lock wait long' $MYSQLTEST_VARDIR/log/mysqld.*.err; dec $counter; } - + +--connection node_1_p1 +--error 0,1213 +--reap +--connection node_1_p2 +--error 0,1213 +--reap +--connection node_2_p1 +--error 0,1213 +--reap +--connection node_2_p2 +--error 0,1213 +--reap + +--connection node_1 drop table t1; drop procedure p1; +--disconnect node_1_p1 +--disconnect node_1_p2 +--disconnect node_2_p1 +--disconnect node_2_p2 + diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result index ffd6c3cab1f..f219625b490 100644 --- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result @@ -85,6 +85,15 @@ END IF| # # Testing with explicit timezonefile # +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on' and variable_value='ON') = 1 THEN +ALTER TABLE time_zone ENGINE=InnoDB; +ALTER TABLE time_zone_name ENGINE=InnoDB; +ALTER TABLE time_zone_transition ENGINE=InnoDB; +ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +END IF| +\d ; INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); SET @time_zone_id= LAST_INSERT_ID(); INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); @@ -106,6 +115,15 @@ END IF| \d | IF (select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON') = 1 THEN +ALTER TABLE time_zone ENGINE=InnoDB; +ALTER TABLE time_zone_name ENGINE=InnoDB; +ALTER TABLE time_zone_transition ENGINE=InnoDB; +ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +END IF| +\d ; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on' and variable_value='ON') = 1 THEN ALTER TABLE time_zone_leap_second ENGINE=InnoDB; END IF| \d ; diff --git a/sql/item_subselect.h b/sql/item_subselect.h index a3105bd99e0..7fc953d5532 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -149,6 +149,10 @@ public: Item_subselect(THD *thd); virtual subs_type substype() { return UNKNOWN_SUBS; } + bool is_exists_predicate() + { + return substype() == Item_subselect::EXISTS_SUBS; + } bool is_in_predicate() { return (substype() == Item_subselect::IN_SUBS || diff --git a/sql/records.cc b/sql/records.cc index 3d709182a4e..817caada8e2 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -316,12 +316,9 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, void end_read_record(READ_RECORD *info) -{ /* free cache if used */ - if (info->cache) - { - my_free_lock(info->cache); - info->cache=0; - } +{ + /* free cache if used */ + free_cache(info); if (info->table) { if (info->table->is_created()) @@ -332,6 +329,17 @@ void end_read_record(READ_RECORD *info) } } + +void free_cache(READ_RECORD *info) +{ + if (info->cache) + { + my_free_lock(info->cache); + info->cache=0; + } +} + + static int rr_handle_error(READ_RECORD *info, int error) { if (info->thd->killed) diff --git a/sql/records.h b/sql/records.h index faf0d13c9a9..74f64cd286f 100644 --- a/sql/records.h +++ b/sql/records.h @@ -31,6 +31,7 @@ class SORT_INFO; struct READ_RECORD; void end_read_record(READ_RECORD *info); +void free_cache(READ_RECORD *info); /** A context for reading through a single table using a chosen access method: diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 050ce325fe3..ddc52702e42 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -3244,25 +3244,25 @@ ER_NONEXISTING_GRANT 42000 swe "Det finns inget privilegium definierat för användare '%-.48s' på '%-.64s'" ukr "Повноважень не визначено для користувача '%-.48s' з хосту '%-.64s'" ER_TABLEACCESS_DENIED_ERROR 42000 - cze "%-.32s příkaz nepřístupný pro uživatele: '%s'@'%s' pro tabulku '%-.192s'" - dan "%-.32s-kommandoen er ikke tilladt for brugeren '%s'@'%s' for tabellen '%-.192s'" - nla "%-.32s commando geweigerd voor gebruiker: '%s'@'%s' voor tabel '%-.192s'" - eng "%-.32s command denied to user '%s'@'%s' for table '%-.192s'" - jps "コマンド %-.32s は ユーザー '%s'@'%s' ,テーブル '%-.192s' に対して許可されていません", - est "%-.32s käsk ei ole lubatud kasutajale '%s'@'%s' tabelis '%-.192s'" - fre "La commande '%-.32s' est interdite à l'utilisateur: '%s'@'%s' sur la table '%-.192s'" - ger "%-.32s Befehl nicht erlaubt für Benutzer '%s'@'%s' auf Tabelle '%-.192s'" - hun "%-.32s parancs a '%s'@'%s' felhasznalo szamara nem engedelyezett a '%-.192s' tablaban" - ita "Comando %-.32s negato per l'utente: '%s'@'%s' sulla tabella '%-.192s'" - jpn "コマンド %-.32s は ユーザー '%s'@'%s' ,テーブル '%-.192s' に対して許可されていません" - kor "'%-.32s' 명령은 다음 사용자에게 거부되었습니다. : '%s'@'%s' for 테이블 '%-.192s'" - por "Comando '%-.32s' negado para o usuário '%s'@'%s' na tabela '%-.192s'" - rum "Comanda %-.32s interzisa utilizatorului: '%s'@'%s' pentru tabela '%-.192s'" - rus "Команда %-.32s запрещена пользователю '%s'@'%s' для таблицы '%-.192s'" - serbian "%-.32s komanda zabranjena za korisnika '%s'@'%s' za tabelu '%-.192s'" - spa "%-.32s comando negado para usuario: '%s'@'%s' para tabla '%-.192s'" - swe "%-.32s ej tillåtet för '%s'@'%s' för tabell '%-.192s'" - ukr "%-.32s команда заборонена користувачу: '%s'@'%s' у таблиці '%-.192s'" + cze "%-.100T příkaz nepřístupný pro uživatele: '%s'@'%s' pro tabulku '%-.192s'" + dan "%-.100T-kommandoen er ikke tilladt for brugeren '%s'@'%s' for tabellen '%-.192s'" + nla "%-.100T commando geweigerd voor gebruiker: '%s'@'%s' voor tabel '%-.192s'" + eng "%-.100T command denied to user '%s'@'%s' for table '%-.192s'" + jps "コマンド %-.100T は ユーザー '%s'@'%s' ,テーブル '%-.192s' に対して許可されていません", + est "%-.100T käsk ei ole lubatud kasutajale '%s'@'%s' tabelis '%-.192s'" + fre "La commande '%-.100T' est interdite à l'utilisateur: '%s'@'%s' sur la table '%-.192s'" + ger "%-.100T Befehl nicht erlaubt für Benutzer '%s'@'%s' auf Tabelle '%-.192s'" + hun "%-.100T parancs a '%s'@'%s' felhasznalo szamara nem engedelyezett a '%-.192s' tablaban" + ita "Comando %-.100T negato per l'utente: '%s'@'%s' sulla tabella '%-.192s'" + jpn "コマンド %-.100T は ユーザー '%s'@'%s' ,テーブル '%-.192s' に対して許可されていません" + kor "'%-.100T' 명령은 다음 사용자에게 거부되었습니다. : '%s'@'%s' for 테이블 '%-.192s'" + por "Comando '%-.100T' negado para o usuário '%s'@'%s' na tabela '%-.192s'" + rum "Comanda %-.100T interzisa utilizatorului: '%s'@'%s' pentru tabela '%-.192s'" + rus "Команда %-.100T запрещена пользователю '%s'@'%s' для таблицы '%-.192s'" + serbian "%-.100T komanda zabranjena za korisnika '%s'@'%s' za tabelu '%-.192s'" + spa "%-.100T comando negado para usuario: '%s'@'%s' para tabla '%-.192s'" + swe "%-.100T ej tillåtet för '%s'@'%s' för tabell '%-.192s'" + ukr "%-.100T команда заборонена користувачу: '%s'@'%s' у таблиці '%-.192s'" ER_COLUMNACCESS_DENIED_ERROR 42000 cze "%-.32s příkaz nepřístupný pro uživatele: '%s'@'%s' pro sloupec '%-.192s' v tabulce '%-.192s'" dan "%-.32s-kommandoen er ikke tilladt for brugeren '%s'@'%s' for kolonne '%-.192s' in tabellen '%-.192s'" diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 821755d94eb..bb75ebd12a1 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2280,8 +2280,17 @@ int Lex_input_stream::scan_ident_delimited(THD *thd, uchar c; DBUG_ASSERT(m_ptr == m_tok_start + 1); - while ((c= yyGet())) + for ( ; ; ) { + if (!(c= yyGet())) + { + /* + End-of-query or straight 0x00 inside a delimited identifier. + Return the quote character, to have the parser fail on syntax error. + */ + m_ptr= (char *) m_tok_start + 1; + return quote_char; + } int var_length= my_charlen(cs, get_ptr() - 1, get_end_of_query()); if (var_length == 1) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 5d255831055..19e36632f0c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13831,24 +13831,7 @@ void JOIN::cleanup(bool full) for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITH_CONST_TABLES); tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS)) { - if (!tab->table) - continue; - DBUG_PRINT("info", ("close index: %s.%s alias: %s", - tab->table->s->db.str, - tab->table->s->table_name.str, - tab->table->alias.c_ptr())); - if (tab->table->is_created()) - { - tab->table->file->ha_index_or_rnd_end(); - if (tab->aggr) - { - int tmp= 0; - if ((tmp= tab->table->file->extra(HA_EXTRA_NO_CACHE))) - tab->table->file->print_error(tmp, MYF(0)); - } - } - delete tab->filesort_result; - tab->filesort_result= NULL; + tab->partial_cleanup(); } } } @@ -28848,6 +28831,40 @@ void JOIN::handle_implicit_grouping_with_window_funcs() } + +/* + @brief + Perform a partial cleanup for the JOIN_TAB structure + + @note + this is used to cleanup resources for the re-execution of correlated + subqueries. +*/ +void JOIN_TAB::partial_cleanup() +{ + if (!table) + return; + + if (table->is_created()) + { + table->file->ha_index_or_rnd_end(); + DBUG_PRINT("info", ("close index: %s.%s alias: %s", + table->s->db.str, + table->s->table_name.str, + table->alias.c_ptr())); + if (aggr) + { + int tmp= 0; + if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE))) + table->file->print_error(tmp, MYF(0)); + } + } + delete filesort_result; + filesort_result= NULL; + free_cache(&read_record); +} + + /** @brief Look for provision of the select_handler interface by a foreign engine diff --git a/sql/sql_select.h b/sql/sql_select.h index d4f2bbd737d..3ac8c152ffc 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -671,6 +671,8 @@ typedef struct st_join_table { bool use_order() const; ///< Use ordering provided by chosen index? bool sort_table(); bool remove_duplicates(); + + void partial_cleanup(); void add_keyuses_for_splitting(); SplM_plan_info *choose_best_splitting(double record_count, table_map remaining_tables); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index fd19b6064b5..2f8de331d30 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4681,7 +4681,7 @@ fill_schema_table_by_open(THD *thd, MEM_ROOT *mem_root, Again we don't do this for SHOW COLUMNS/KEYS because of backward compatibility. */ - if (!is_show_fields_or_keys && result && + if (!is_show_fields_or_keys && result && thd->is_error() && (thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE || thd->get_stmt_da()->sql_errno() == ER_WRONG_OBJECT || thd->get_stmt_da()->sql_errno() == ER_NOT_SEQUENCE)) @@ -5973,15 +5973,21 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, I.e. we are in SELECT FROM INFORMATION_SCHEMA.COLUMS rather than in SHOW COLUMNS */ - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, - thd->get_stmt_da()->sql_errno(), - thd->get_stmt_da()->message()); - thd->clear_error(); + if (thd->is_error()) + { + /* + The the query was aborted because examined rows exceeded limit. + Don't send the warning here. It is done later, in handle_select(). + */ + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, + thd->get_stmt_da()->sql_errno(), + thd->get_stmt_da()->message()); + thd->clear_error(); + } res= 0; } DBUG_RETURN(res); } - show_table= tables->table; count= 0; ptr= show_table->field; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 26f08a165b3..e8b66bb8bd7 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2010, 2017, Corporation + Copyright (c) 2010, 2020, MariaDB Corporation. 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 @@ -906,6 +906,25 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, found_rows_for_union= first_sl->options & OPTION_FOUND_ROWS; is_union_select= is_unit_op() || fake_select_lex || single_tvc; + /* + If we are reading UNION output and the UNION is in the + IN/ANY/ALL/EXISTS subquery, then ORDER BY is redundant and hence should + be removed. + Example: + select ... col IN (select col2 FROM t1 union select col3 from t2 ORDER BY 1) + + (as for ORDER BY ... LIMIT, it currently not supported inside + IN/ALL/ANY subqueries) + (For non-UNION this removal of ORDER BY clause is done in + check_and_do_in_subquery_rewrites()) + */ + if (item && is_unit_op() && + (item->is_in_predicate() || item->is_exists_predicate())) + { + global_parameters()->order_list.first= NULL; + global_parameters()->order_list.elements= 0; + } + for (SELECT_LEX *s= first_sl; s; s= s->next_select()) { switch (s->linkage) @@ -920,6 +939,7 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, break; } } + /* Global option */ if (is_union_select || is_recursive) diff --git a/sql/table.h b/sql/table.h index 287f43b8a9a..15ab3590b5d 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1366,9 +1366,16 @@ public: /* number of select if it is derived table */ uint derived_select_number; /* - 0 or JOIN_TYPE_{LEFT|RIGHT}. Currently this is only compared to 0. - If maybe_null !=0, this table is inner w.r.t. some outer join operation, - and null_row may be true. + Possible values: + - 0 by default + - JOIN_TYPE_{LEFT|RIGHT} if the table is inner w.r.t an outer join + operation + - 1 if the SELECT has mixed_implicit_grouping=1. example: + select max(col1), col2 from t1. In this case, the query produces + one row with all columns having NULL values. + + Interpetation: If maybe_null!=0, all fields of the table are considered + NULLable (and have NULL values when null_row=true) */ uint maybe_null; int current_lock; /* Type of lock on table */ diff --git a/sql/tztime.cc b/sql/tztime.cc index 664dae7f4c6..9465a51f3fe 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2705,6 +2705,7 @@ main(int argc, char **argv) } if (opt_skip_write_binlog) + { /* If skip_write_binlog is set and wsrep is compiled in we disable sql_log_bin and wsrep_on to avoid Galera replicating below truncate table clauses. This will allow user to set different @@ -2712,15 +2713,9 @@ main(int argc, char **argv) printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n" "prepare set_wsrep_write_binlog from @prep1;\n" "set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n"); - - if (argc == 1 && !opt_leap) + } + else { - /* Argument is timezonedir */ - - root_name_end= strmake_buf(fullname, argv[0]); - - if(!opt_skip_write_binlog) - { // Alter time zone tables to InnoDB if wsrep_on is enabled // to allow changes to them to replicate with Galera printf("\\d |\n" @@ -2732,7 +2727,13 @@ main(int argc, char **argv) "ALTER TABLE time_zone_transition_type ENGINE=InnoDB;\n" "END IF|\n" "\\d ;\n"); - } + } + + if (argc == 1 && !opt_leap) + { + /* Argument is timezonedir */ + + root_name_end= strmake_buf(fullname, argv[0]); printf("TRUNCATE TABLE time_zone;\n"); printf("TRUNCATE TABLE time_zone_name;\n"); diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 7c342ca0637..7c4046871cc 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -41,9 +41,6 @@ Modified Jan Lindström jan.lindstrom@mariadb.com #include "fil0pagecompress.h" #include <my_crypt.h> -/** Mutex for keys */ -static ib_mutex_t fil_crypt_key_mutex; - static bool fil_crypt_threads_inited = false; /** Is encryption enabled/disabled */ @@ -113,8 +110,6 @@ UNIV_INTERN void fil_space_crypt_init() { - mutex_create(LATCH_ID_FIL_CRYPT_MUTEX, &fil_crypt_key_mutex); - fil_crypt_throttle_sleep_event = os_event_create(0); mutex_create(LATCH_ID_FIL_CRYPT_STAT_MUTEX, &crypt_stat_mutex); @@ -128,7 +123,6 @@ void fil_space_crypt_cleanup() { os_event_destroy(fil_crypt_throttle_sleep_event); - mutex_free(&fil_crypt_key_mutex); mutex_free(&crypt_stat_mutex); } @@ -1582,6 +1576,94 @@ fil_crypt_return_iops( fil_crypt_update_total_stat(state); } +/** Return the next tablespace from rotation_list. +@param space previous tablespace (NULL to start from the start) +@param recheck whether the removal condition needs to be rechecked after +the encryption parameters were changed +@param encrypt expected state of innodb_encrypt_tables +@return the next tablespace to process (n_pending_ops incremented) +@retval NULL if this was the last */ +inline fil_space_t *fil_system_t::keyrotate_next(fil_space_t *space, + bool recheck, bool encrypt) +{ + ut_ad(mutex_own(&mutex)); + + sized_ilist<fil_space_t, rotation_list_tag_t>::iterator it= + space ? space : rotation_list.begin(); + const sized_ilist<fil_space_t, rotation_list_tag_t>::iterator end= + rotation_list.end(); + + if (space) + { + while (++it != end && (!UT_LIST_GET_LEN(it->chain) || it->is_stopping())); + + /* If one of the encryption threads already started the encryption + of the table then don't remove the unencrypted spaces from rotation list + + If there is a change in innodb_encrypt_tables variables value then + don't remove the last processed tablespace from the rotation list. */ + space->release(); + + if (!space->referenced() && + (!recheck || space->crypt_data) && !encrypt == !srv_encrypt_tables && + space->is_in_rotation_list) + { + ut_a(!rotation_list.empty()); + rotation_list.remove(*space); + space->is_in_rotation_list= false; + } + } + + if (it == end) + return NULL; + + space= &*it; + space->acquire(); + return space; +} + +/** Return the next tablespace. +@param space previous tablespace (NULL to start from the beginning) +@param recheck whether the removal condition needs to be rechecked after +the encryption parameters were changed +@param encrypt expected state of innodb_encrypt_tables +@return pointer to the next tablespace (with n_pending_ops incremented) +@retval NULL if this was the last */ +static fil_space_t *fil_space_next(fil_space_t *space, bool recheck, + bool encrypt) +{ + mutex_enter(&fil_system.mutex); + + if (!srv_fil_crypt_rotate_key_age) + space= fil_system.keyrotate_next(space, recheck, encrypt); + else if (!space) + { + space= UT_LIST_GET_FIRST(fil_system.space_list); + /* We can trust that space is not NULL because at least the + system tablespace is always present and loaded first. */ + space->acquire(); + } + else + { + /* Move on to the next fil_space_t */ + space->release(); + space= UT_LIST_GET_NEXT(space_list, space); + + /* Skip abnormal tablespaces or those that are being created by + fil_ibd_create(), or being dropped. */ + while (space && + (UT_LIST_GET_LEN(space->chain) == 0 || + space->is_stopping() || space->purpose != FIL_TYPE_TABLESPACE)) + space= UT_LIST_GET_NEXT(space_list, space); + + if (space) + space->acquire(); + } + + mutex_exit(&fil_system.mutex); + return space; +} + /** Search for a space needing rotation @param[in,out] key_state Key state @param[in,out] state Rotation state @@ -1614,13 +1696,8 @@ static bool fil_crypt_find_space_to_rotate( state->space = NULL; } - /* If key rotation is enabled (default) we iterate all tablespaces. - If key rotation is not enabled we iterate only the tablespaces - added to keyrotation list. */ - state->space = srv_fil_crypt_rotate_key_age - ? fil_space_next(state->space) - : fil_system.keyrotate_next(state->space, *recheck, - key_state->key_version); + state->space = fil_space_next(state->space, *recheck, + key_state->key_version != 0); while (!state->should_shutdown() && state->space) { /* If there is no crypt data and we have not yet read @@ -1638,13 +1715,16 @@ static bool fil_crypt_find_space_to_rotate( return true; } - state->space = srv_fil_crypt_rotate_key_age - ? fil_space_next(state->space) - : fil_system.keyrotate_next(state->space, *recheck, - key_state->key_version); + state->space = fil_space_next(state->space, *recheck, + key_state->key_version != 0); + } + + if (state->space) { + state->space->release(); + state->space = NULL; } - /* if we didn't find any space return iops */ + /* no work to do; release our allocation of I/O capacity */ fil_crypt_return_iops(state); return false; @@ -2455,13 +2535,11 @@ static void fil_crypt_rotation_list_fill() if (!space->size) { /* Protect the tablespace while we may release fil_system.mutex. */ - space->n_pending_ops++; -#ifndef DBUG_OFF + ut_d(space->acquire()); ut_d(const fil_space_t* s=) fil_system.read_page0(space->id); ut_ad(!s || s == space); -#endif - space->n_pending_ops--; + ut_d(space->release()); if (!space->size) { /* Page 0 was not loaded. Skip this tablespace. */ diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 57303a25300..d47e9f3f5bf 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -4914,120 +4914,6 @@ test_make_filepath() #endif /* UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH */ /* @} */ -/** Return the next fil_space_t. -Once started, the caller must keep calling this until it returns NULL. -fil_space_t::acquire() and fil_space_t::release() are invoked here which -blocks a concurrent operation from dropping the tablespace. -@param[in] prev_space Pointer to the previous fil_space_t. -If NULL, use the first fil_space_t on fil_system.space_list. -@return pointer to the next fil_space_t. -@retval NULL if this was the last*/ -fil_space_t* -fil_space_next(fil_space_t* prev_space) -{ - fil_space_t* space=prev_space; - - mutex_enter(&fil_system.mutex); - - if (!space) { - space = UT_LIST_GET_FIRST(fil_system.space_list); - } else { - ut_a(space->referenced()); - - /* Move on to the next fil_space_t */ - space->release(); - space = UT_LIST_GET_NEXT(space_list, space); - } - - /* Skip spaces that are being created by - fil_ibd_create(), or dropped, or !tablespace. */ - while (space != NULL - && (UT_LIST_GET_LEN(space->chain) == 0 - || space->is_stopping() - || space->purpose != FIL_TYPE_TABLESPACE)) { - space = UT_LIST_GET_NEXT(space_list, space); - } - - if (space != NULL) { - space->acquire(); - } - - mutex_exit(&fil_system.mutex); - - return(space); -} - -/** -Remove space from key rotation list if there are no more -pending operations. -@param[in,out] space Tablespace */ -static -void -fil_space_remove_from_keyrotation(fil_space_t* space) -{ - ut_ad(mutex_own(&fil_system.mutex)); - ut_ad(space); - - if (!space->referenced() && space->is_in_rotation_list) { - space->is_in_rotation_list = false; - ut_a(!fil_system.rotation_list.empty()); - fil_system.rotation_list.remove(*space); - } -} - - -/** Return the next fil_space_t from key rotation list. -Once started, the caller must keep calling this until it returns NULL. -fil_space_t::acquire() and fil_space_t::release() are invoked here which -blocks a concurrent operation from dropping the tablespace. -@param[in] prev_space Pointer to the previous fil_space_t. -If NULL, use the first fil_space_t on fil_system.space_list. -@param[in] recheck recheck of the tablespace is needed or - still encryption thread does write page0 for it -@param[in] key_version key version of the key state thread -@return pointer to the next fil_space_t. -@retval NULL if this was the last */ -fil_space_t *fil_system_t::keyrotate_next(fil_space_t *prev_space, - bool recheck, uint key_version) -{ - mutex_enter(&fil_system.mutex); - - /* If one of the encryption threads already started the encryption - of the table then don't remove the unencrypted spaces from rotation list - - If there is a change in innodb_encrypt_tables variables value then - don't remove the last processed tablespace from the rotation list. */ - const bool remove= (!recheck || prev_space->crypt_data) && - !key_version == !srv_encrypt_tables; - sized_ilist<fil_space_t, rotation_list_tag_t>::iterator it= - prev_space ? prev_space : fil_system.rotation_list.end(); - - if (it == fil_system.rotation_list.end()) - it= fil_system.rotation_list.begin(); - else - { - /* Move on to the next fil_space_t */ - prev_space->release(); - - ++it; - - while (it != fil_system.rotation_list.end() && - (UT_LIST_GET_LEN(it->chain) == 0 || it->is_stopping())) - ++it; - - if (remove) - fil_space_remove_from_keyrotation(prev_space); - } - - fil_space_t *space= it == fil_system.rotation_list.end() ? NULL : &*it; - - if (space) - space->acquire(); - - mutex_exit(&fil_system.mutex); - return space; -} - /** Determine the block size of the data file. @param[in] space tablespace @param[in] offset page number diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 64a6676e396..2cbf233a4cb 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -980,24 +980,15 @@ public: @retval NULL if the tablespace does not exist or cannot be read */ fil_space_t* read_page0(ulint id); - /** Return the next fil_space_t from key rotation list. - Once started, the caller must keep calling this until it returns NULL. - fil_space_acquire() and fil_space_t::release() are invoked here, which - blocks a concurrent operation from dropping the tablespace. - @param[in] prev_space Previous tablespace or NULL to start - from beginning of fil_system->rotation - list - @param[in] recheck recheck of the tablespace is needed or - still encryption thread does write page0 - for it - @param[in] key_version key version of the key state thread - If NULL, use the first fil_space_t on fil_system->space_list. - @return pointer to the next fil_space_t. - @retval NULL if this was the last */ - fil_space_t* keyrotate_next( - fil_space_t* prev_space, - bool remove, - uint key_version); + /** Return the next tablespace from rotation_list. + @param space previous tablespace (NULL to start from the start) + @param recheck whether the removal condition needs to be rechecked after + the encryption parameters were changed + @param encrypt expected state of innodb_encrypt_tables + @return the next tablespace to process (n_pending_ops incremented) + @retval NULL if this was the last */ + inline fil_space_t* keyrotate_next(fil_space_t *space, bool recheck, + bool encrypt); }; /** The tablespace memory cache. */ @@ -1152,33 +1143,6 @@ when it could be dropped concurrently. fil_space_t* fil_space_acquire_for_io(ulint id); -/** Return the next fil_space_t. -Once started, the caller must keep calling this until it returns NULL. -fil_space_acquire() and fil_space_t::release() are invoked here which -blocks a concurrent operation from dropping the tablespace. -@param[in,out] prev_space Pointer to the previous fil_space_t. -If NULL, use the first fil_space_t on fil_system.space_list. -@return pointer to the next fil_space_t. -@retval NULL if this was the last */ -fil_space_t* -fil_space_next( - fil_space_t* prev_space) - MY_ATTRIBUTE((warn_unused_result)); - -/** Return the next fil_space_t from key rotation list. -Once started, the caller must keep calling this until it returns NULL. -fil_space_acquire() and fil_space_t::release() are invoked here which -blocks a concurrent operation from dropping the tablespace. -@param[in,out] prev_space Pointer to the previous fil_space_t. -If NULL, use the first fil_space_t on fil_system.space_list. -@param[in] remove Whether to remove the previous tablespace from - the rotation list -@return pointer to the next fil_space_t. -@retval NULL if this was the last*/ -fil_space_t* -fil_space_keyrotate_next(fil_space_t* prev_space, bool remove) - MY_ATTRIBUTE((warn_unused_result)); - /** Replay a file rename operation if possible. @param[in] space_id tablespace identifier @param[in] first_page_no first page number in the file diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h index 32fdc89d6e4..339154a9615 100644 --- a/storage/innobase/include/sync0types.h +++ b/storage/innobase/include/sync0types.h @@ -360,7 +360,6 @@ enum latch_id_t { LATCH_ID_SCRUB_STAT_MUTEX, LATCH_ID_DEFRAGMENT_MUTEX, LATCH_ID_BTR_DEFRAGMENT_MUTEX, - LATCH_ID_FIL_CRYPT_MUTEX, LATCH_ID_FIL_CRYPT_STAT_MUTEX, LATCH_ID_FIL_CRYPT_DATA_MUTEX, LATCH_ID_FIL_CRYPT_THREADS_MUTEX, diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 86708818b36..c6de0e606b9 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -746,7 +746,7 @@ lock_rec_has_to_wait( /* if BF thread is locking and has conflict with another BF thread, we need to look at trx ordering and lock types */ if (wsrep_thd_is_BF(trx->mysql_thd, FALSE) - && wsrep_thd_is_BF(lock2->trx->mysql_thd, TRUE)) { + && wsrep_thd_is_BF(lock2->trx->mysql_thd, FALSE)) { mtr_t mtr; if (UNIV_UNLIKELY(wsrep_debug)) { @@ -1094,7 +1094,7 @@ wsrep_kill_victim( return; } - my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE); + my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, FALSE); mtr_t mtr; if ((!bf_other) || @@ -1418,7 +1418,7 @@ lock_rec_create_low( lock_t *hash = (lock_t *)c_lock->hash; lock_t *prev = NULL; - while (hash && wsrep_thd_is_BF(hash->trx->mysql_thd, TRUE) + while (hash && wsrep_thd_is_BF(hash->trx->mysql_thd, FALSE) && wsrep_thd_order_before(hash->trx->mysql_thd, trx->mysql_thd)) { prev = hash; @@ -1817,11 +1817,9 @@ lock_rec_add_to_queue( = lock_rec_other_has_expl_req( mode, block, false, heap_no, trx); #ifdef WITH_WSREP - //ut_a(!other_lock || (wsrep_thd_is_BF(trx->mysql_thd, FALSE) && - // wsrep_thd_is_BF(other_lock->trx->mysql_thd, TRUE))); if (other_lock && trx->is_wsrep() && !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && - !wsrep_thd_is_BF(other_lock->trx->mysql_thd, TRUE)) { + !wsrep_thd_is_BF(other_lock->trx->mysql_thd, FALSE)) { ib::info() << "WSREP BF lock conflict for my lock:\n BF:" << ((wsrep_thd_is_BF(trx->mysql_thd, FALSE)) ? "BF" : "normal") << " exec: " << @@ -2030,6 +2028,7 @@ lock_rec_has_to_wait_in_queue( ulint bit_offset; hash_table_t* hash; + ut_ad(wait_lock); ut_ad(lock_mutex_own()); ut_ad(lock_get_wait(wait_lock)); ut_ad(lock_get_type_low(wait_lock) == LOCK_REC); @@ -2044,9 +2043,11 @@ lock_rec_has_to_wait_in_queue( hash = lock_hash_get(wait_lock->type_mode); for (lock = lock_rec_get_first_on_page_addr(hash, space, page_no); +#ifdef WITH_WSREP + lock && +#endif lock != wait_lock; lock = lock_rec_get_next_on_page_const(lock)) { - const byte* p = (const byte*) &lock[1]; if (heap_no < lock_rec_get_n_bits(lock) @@ -2054,7 +2055,8 @@ lock_rec_has_to_wait_in_queue( && lock_has_to_wait(wait_lock, lock)) { #ifdef WITH_WSREP if (wsrep_thd_is_BF(wait_lock->trx->mysql_thd, FALSE) && - wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE)) { + wsrep_thd_is_BF(lock->trx->mysql_thd, FALSE)) { + if (UNIV_UNLIKELY(wsrep_debug)) { mtr_t mtr; ib::info() << "WSREP: waiting BF trx: " << ib::hex(wait_lock->trx->id) @@ -6705,7 +6707,7 @@ DeadlockChecker::select_victim() const /* The joining transaction is 'smaller', choose it as the victim and roll it back. */ #ifdef WITH_WSREP - if (wsrep_thd_is_BF(m_start->mysql_thd, TRUE)) { + if (wsrep_thd_is_BF(m_start->mysql_thd, FALSE)) { return(m_wait_lock->trx); } #endif /* WITH_WSREP */ @@ -6713,7 +6715,7 @@ DeadlockChecker::select_victim() const } #ifdef WITH_WSREP - if (wsrep_thd_is_BF(m_wait_lock->trx->mysql_thd, TRUE)) { + if (wsrep_thd_is_BF(m_wait_lock->trx->mysql_thd, FALSE)) { return(m_start); } #endif /* WITH_WSREP */ diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc index 485e867dfe6..5efb447e548 100644 --- a/storage/innobase/sync/sync0debug.cc +++ b/storage/innobase/sync/sync0debug.cc @@ -1485,8 +1485,6 @@ sync_latch_meta_init() PFS_NOT_INSTRUMENTED); LATCH_ADD_MUTEX(BTR_DEFRAGMENT_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED); - LATCH_ADD_MUTEX(FIL_CRYPT_MUTEX, SYNC_NO_ORDER_CHECK, - PFS_NOT_INSTRUMENTED); LATCH_ADD_MUTEX(FIL_CRYPT_STAT_MUTEX, SYNC_NO_ORDER_CHECK, PFS_NOT_INSTRUMENTED); LATCH_ADD_MUTEX(FIL_CRYPT_DATA_MUTEX, SYNC_NO_ORDER_CHECK, diff --git a/strings/decimal.c b/strings/decimal.c index 59e60e0a328..9dae3d987f2 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -812,6 +812,24 @@ internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed) while (s < end_of_string && my_isdigit(&my_charset_latin1, *s)) s++; intg= (int) (s-s1); + /* + If the integer part is long enough and it has multiple leading zeros, + let's trim them, so this expression can return 1 without overflowing: + CAST(CONCAT(REPEAT('0',90),'1') AS DECIMAL(10)) + */ + if (intg > DIG_PER_DEC1 && s1[0] == '0' && s1[1] == '0') + { + /* + Keep at least one digit, to avoid an empty string. + So we trim '0000' to '0' rather than to ''. + Otherwise the below code (converting digits to to->buf) + would fail on a fatal error. + */ + const char *iend= s - 1; + for ( ; s1 < iend && *s1 == '0'; s1++) + { } + intg= (int) (s-s1); + } if (s < end_of_string && *s=='.') { endp= s+1; diff --git a/vio/vio.c b/vio/vio.c index 3f92c1e6853..21c475f5972 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -56,6 +56,7 @@ static my_bool has_no_data(Vio *vio __attribute__((unused))) #ifdef _WIN32 int vio_pipe_shutdown(Vio *vio, int how) { + vio->shutdown_flag= how; return CancelIoEx(vio->hPipe, NULL); } #endif diff --git a/vio/viopipe.c b/vio/viopipe.c index 567884807fe..aeaad311b7e 100644 --- a/vio/viopipe.c +++ b/vio/viopipe.c @@ -75,6 +75,9 @@ size_t vio_read_pipe(Vio *vio, uchar *buf, size_t count) size_t ret= (size_t) -1; DBUG_ENTER("vio_read_pipe"); + if (vio->shutdown_flag) + return ret; + disable_iocp_notification(&vio->overlapped); /* Attempt to read from the pipe (overlapped I/O). */ @@ -85,8 +88,11 @@ size_t vio_read_pipe(Vio *vio, uchar *buf, size_t count) } /* Read operation is pending completion asynchronously? */ else if (GetLastError() == ERROR_IO_PENDING) + { + if (vio->shutdown_flag) + CancelIo(vio->hPipe); ret= wait_overlapped_result(vio, vio->read_timeout); - + } enable_iocp_notification(&vio->overlapped); DBUG_RETURN(ret); @@ -99,6 +105,8 @@ size_t vio_write_pipe(Vio *vio, const uchar *buf, size_t count) size_t ret= (size_t) -1; DBUG_ENTER("vio_write_pipe"); + if (vio->shutdown_flag == SHUT_RDWR) + return ret; disable_iocp_notification(&vio->overlapped); /* Attempt to write to the pipe (overlapped I/O). */ if (WriteFile(vio->hPipe, buf, (DWORD)count, &transferred, &vio->overlapped)) @@ -108,8 +116,11 @@ size_t vio_write_pipe(Vio *vio, const uchar *buf, size_t count) } /* Write operation is pending completion asynchronously? */ else if (GetLastError() == ERROR_IO_PENDING) + { + if (vio->shutdown_flag == SHUT_RDWR) + CancelIo(vio->hPipe); ret= wait_overlapped_result(vio, vio->write_timeout); - + } enable_iocp_notification(&vio->overlapped); DBUG_RETURN(ret); } @@ -129,7 +140,6 @@ int vio_close_pipe(Vio *vio) BOOL ret; DBUG_ENTER("vio_close_pipe"); - CancelIo(vio->hPipe); CloseHandle(vio->overlapped.hEvent); ret= CloseHandle(vio->hPipe); |