From 931549ff6685f370f6b2fc356769dcab97f0c6e4 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 22 Nov 2022 14:03:23 +0400 Subject: [PATCH 01/21] MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit Also fixes: MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit The "strnncollsp_nchars" virtual function pointer for tis620_thai_nopad_ci was incorrectly initialized to a generic function my_strnncollsp_nchars_generic_8bit(), which crashed on assert. Implementing a tis620 specific function version. --- mysql-test/main/ctype_tis620.result | 25 +++++++ mysql-test/main/ctype_tis620.test | 31 +++++++++ .../suite/innodb/r/innodb_ctype_tis620.result | 66 +++++++++++++++++++ .../suite/innodb/t/innodb_ctype_tis620.test | 62 +++++++++++++++++ .../suite/parts/r/part_ctype_tis620.result | 47 +++++++++++++ .../suite/parts/t/part_ctype_tis620.test | 52 +++++++++++++++ strings/ctype-tis620.c | 16 ++++- unittest/strings/strings-t.c | 1 + 8 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/parts/r/part_ctype_tis620.result create mode 100644 mysql-test/suite/parts/t/part_ctype_tis620.test diff --git a/mysql-test/main/ctype_tis620.result b/mysql-test/main/ctype_tis620.result index cb27b857f43..5655eb124b2 100644 --- a/mysql-test/main/ctype_tis620.result +++ b/mysql-test/main/ctype_tis620.result @@ -4432,3 +4432,28 @@ HEX(WEIGHT_STRING(_tis620 'a\0b' COLLATE tis620_thai_nopad_ci)) # # End of 10.2 tests # +# +# Start of 10.4 tests +# +# +# MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +# +CREATE OR REPLACE TABLE t1 +( +a VARCHAR(250) COLLATE tis620_thai_nopad_ci, +UNIQUE KEY(a(100)) USING HASH +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('a'),('A'); +ERROR 23000: Duplicate entry 'A' for key 'a' +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 +( +a CHAR(250) COLLATE tis620_thai_nopad_ci, +UNIQUE KEY(a(100)) USING HASH +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('a'),('A'); +ERROR 23000: Duplicate entry 'A' for key 'a' +DROP TABLE t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/ctype_tis620.test b/mysql-test/main/ctype_tis620.test index f432b23d71c..39908b995b2 100644 --- a/mysql-test/main/ctype_tis620.test +++ b/mysql-test/main/ctype_tis620.test @@ -223,3 +223,34 @@ SELECT HEX(WEIGHT_STRING(_tis620 'a\0b' COLLATE tis620_thai_nopad_ci)); --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +--echo # + +CREATE OR REPLACE TABLE t1 +( + a VARCHAR(250) COLLATE tis620_thai_nopad_ci, + UNIQUE KEY(a(100)) USING HASH +) ENGINE=MyISAM; +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES ('a'),('A'); +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 + +( + a CHAR(250) COLLATE tis620_thai_nopad_ci, + UNIQUE KEY(a(100)) USING HASH +) ENGINE=MyISAM; +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES ('a'),('A'); +DROP TABLE t1; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/suite/innodb/r/innodb_ctype_tis620.result b/mysql-test/suite/innodb/r/innodb_ctype_tis620.result index 07de1892a19..b58c7952331 100644 --- a/mysql-test/suite/innodb/r/innodb_ctype_tis620.result +++ b/mysql-test/suite/innodb/r/innodb_ctype_tis620.result @@ -26,3 +26,69 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# Start of 10.4 tests +# +# +# MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +# +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(8), KEY(a)) ENGINE=InnoDB COLLATE tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +DROP TABLE t1; +# +# MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +# +CREATE TABLE t1 (a INT KEY,b INT,c CHAR,KEY(b),KEY(c)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,4,4); +DROP TABLE t1; +CREATE TABLE t1 (C1 CHAR KEY,B1 BIT,B2 BIT,C2 CHAR DEFAULT'') ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +SELECT HEX(c1),HEX (c2) FROM t1 WHERE c1>=''AND c1<''AND c2=''LIMIT 2; +HEX(c1) HEX (c2) +DROP TABLE t1; +SET sql_mode=''; +CREATE TABLE t1 (a INT UNSIGNED,b INT,c CHAR(1),d BINARY (1),e VARCHAR(1),f VARBINARY(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (4386060749083099108,157,0,0,0,0,0,0,12); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (104,15158706241929488558,0,0,0,0,0,0,13); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +SELECT GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) FROM t1; +GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) +4294967295157,1042147483647 +DROP TABLE t1; +SET sql_mode=DEFAULT; +CREATE TABLE t1 (a CHAR(9),b CHAR(7)) COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0); +ALTER TABLE t1 ADD INDEX kb (b),ADD INDEX kab (a,b),ALGORITHM=INPLACE; +DROP TABLE t1; +SET sql_mode=''; +CREATE TABLE t1 (a INT UNSIGNED,b INT UNSIGNED,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (15842995496588415350,5339224446865937973,0,0,0,0,0,0,4); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +INSERT INTO t1 VALUES (8118894032862615316,5299008984764990929,0,0,0,0,0,0,1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +SELECT GROUP_CONCAT(DISTINCT a,c ORDER BY a) FROM t1; +GROUP_CONCAT(DISTINCT a,c ORDER BY a) +42949672950 +DROP TABLE t1; +SET sql_mode=DEFAULT; +CREATE TABLE t1 (a CHAR,b CHAR,KEY(a,b)) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (0,0); +DROP TABLE t1; +CREATE TABLE t1 (a CHAR,b CHAR) COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0,0); +SELECT a,SUM(DISTINCT a),MIN(b) FROM t1 GROUP BY a; +a SUM(DISTINCT a) MIN(b) +0 0 0 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR,KEY(a)) ENGINE=InnoDB COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0); +DROP TABLE t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/suite/innodb/t/innodb_ctype_tis620.test b/mysql-test/suite/innodb/t/innodb_ctype_tis620.test index fee1b283ac3..c5fc8238e10 100644 --- a/mysql-test/suite/innodb/t/innodb_ctype_tis620.test +++ b/mysql-test/suite/innodb/t/innodb_ctype_tis620.test @@ -27,3 +27,65 @@ DROP TABLE t1; --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +--echo # + +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(8), KEY(a)) ENGINE=InnoDB COLLATE tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +DROP TABLE t1; + +--echo # +--echo # MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +--echo # + +CREATE TABLE t1 (a INT KEY,b INT,c CHAR,KEY(b),KEY(c)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,4,4); +DROP TABLE t1; + +CREATE TABLE t1 (C1 CHAR KEY,B1 BIT,B2 BIT,C2 CHAR DEFAULT'') ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +SELECT HEX(c1),HEX (c2) FROM t1 WHERE c1>=''AND c1<''AND c2=''LIMIT 2; +DROP TABLE t1; + +SET sql_mode=''; +CREATE TABLE t1 (a INT UNSIGNED,b INT,c CHAR(1),d BINARY (1),e VARCHAR(1),f VARBINARY(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (4386060749083099108,157,0,0,0,0,0,0,12); +INSERT INTO t1 VALUES (104,15158706241929488558,0,0,0,0,0,0,13); +SELECT GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) FROM t1; +DROP TABLE t1; +SET sql_mode=DEFAULT; + +CREATE TABLE t1 (a CHAR(9),b CHAR(7)) COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0); +ALTER TABLE t1 ADD INDEX kb (b),ADD INDEX kab (a,b),ALGORITHM=INPLACE; +DROP TABLE t1; + +SET sql_mode=''; +CREATE TABLE t1 (a INT UNSIGNED,b INT UNSIGNED,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (15842995496588415350,5339224446865937973,0,0,0,0,0,0,4); +INSERT INTO t1 VALUES (8118894032862615316,5299008984764990929,0,0,0,0,0,0,1); +SELECT GROUP_CONCAT(DISTINCT a,c ORDER BY a) FROM t1; +DROP TABLE t1; +SET sql_mode=DEFAULT; + +CREATE TABLE t1 (a CHAR,b CHAR,KEY(a,b)) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (0,0); +DROP TABLE t1; + +CREATE TABLE t1 (a CHAR,b CHAR) COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0,0); +SELECT a,SUM(DISTINCT a),MIN(b) FROM t1 GROUP BY a; +DROP TABLE t1; + +CREATE TABLE t1 (a CHAR,KEY(a)) ENGINE=InnoDB COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0); +DROP TABLE t1; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/suite/parts/r/part_ctype_tis620.result b/mysql-test/suite/parts/r/part_ctype_tis620.result new file mode 100644 index 00000000000..48a8a95f40e --- /dev/null +++ b/mysql-test/suite/parts/r/part_ctype_tis620.result @@ -0,0 +1,47 @@ +# +# MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +# +CREATE TABLE t1 ( +a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN (''), +PARTITION p VALUES LESS THAN ('') +); +ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +CREATE TABLE t1 ( +a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN (''), +PARTITION p VALUES LESS THAN (' ') +); +ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +CREATE TABLE t1 ( +a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN (' '), +PARTITION p VALUES LESS THAN ('') +); +ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +CREATE TABLE t1 +( +id INT NOT NULL, +data VARCHAR(2), +KEY data_id (data(1),id) +) COLLATE tis620_thai_nopad_ci ENGINE=MyISAM +PARTITION BY RANGE (id) +( +PARTITION p10 VALUES LESS THAN (10), +PARTITION p20 VALUES LESS THAN (20) +); +INSERT INTO t1 VALUES (4, 'ab'), (14, 'ab'), (19,''),(9,'') ; +SELECT id FROM t1 WHERE data='' ORDER BY id; +id +9 +19 +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/part_ctype_tis620.test b/mysql-test/suite/parts/t/part_ctype_tis620.test new file mode 100644 index 00000000000..2e5bcd651b1 --- /dev/null +++ b/mysql-test/suite/parts/t/part_ctype_tis620.test @@ -0,0 +1,52 @@ +--source include/have_partition.inc +--source include/have_tis620.inc + +--echo # +--echo # MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +--echo # + +--error ER_RANGE_NOT_INCREASING_ERROR +CREATE TABLE t1 ( + a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( + PARTITION p0 VALUES LESS THAN (''), + PARTITION p VALUES LESS THAN ('') +); + +--error ER_RANGE_NOT_INCREASING_ERROR +CREATE TABLE t1 ( + a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( + PARTITION p0 VALUES LESS THAN (''), + PARTITION p VALUES LESS THAN (' ') +); + +--error ER_RANGE_NOT_INCREASING_ERROR +CREATE TABLE t1 ( + a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( + PARTITION p0 VALUES LESS THAN (' '), + PARTITION p VALUES LESS THAN ('') +); + + +CREATE TABLE t1 +( + id INT NOT NULL, + data VARCHAR(2), + KEY data_id (data(1),id) +) COLLATE tis620_thai_nopad_ci ENGINE=MyISAM +PARTITION BY RANGE (id) +( + PARTITION p10 VALUES LESS THAN (10), + PARTITION p20 VALUES LESS THAN (20) +); +INSERT INTO t1 VALUES (4, 'ab'), (14, 'ab'), (19,''),(9,'') ; +SELECT id FROM t1 WHERE data='' ORDER BY id; +DROP TABLE t1; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index d5367393c86..b19832cc792 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -585,6 +585,18 @@ ret: } +static int +my_strnncollsp_nchars_tis620(CHARSET_INFO * cs, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, + size_t nchars) +{ + set_if_smaller(a_length, nchars); + set_if_smaller(b_length, nchars); + return my_strnncollsp_tis620(cs, a, a_length, b, b_length); +} + + static int my_strnncollsp_tis620_nopad(CHARSET_INFO * cs __attribute__((unused)), const uchar *a0, size_t a_length, @@ -852,7 +864,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = NULL, /* init */ my_strnncoll_tis620, my_strnncollsp_tis620, - my_strnncollsp_nchars_generic_8bit, + my_strnncollsp_nchars_tis620, my_strnxfrm_tis620, my_strnxfrmlen_simple, my_like_range_simple, @@ -868,7 +880,7 @@ static MY_COLLATION_HANDLER my_collation_nopad_ci_handler = NULL, /* init */ my_strnncoll_tis620, my_strnncollsp_tis620_nopad, - my_strnncollsp_nchars_generic_8bit, + my_strnncollsp_nchars_tis620, my_strnxfrm_tis620_nopad, my_strnxfrmlen_simple, my_like_range_simple, diff --git a/unittest/strings/strings-t.c b/unittest/strings/strings-t.c index 97b9eb1a95e..338d2f53b05 100644 --- a/unittest/strings/strings-t.c +++ b/unittest/strings/strings-t.c @@ -1214,6 +1214,7 @@ test_strnncollsp_char() #ifdef HAVE_CHARSET_tis620 failed+= strnncollsp_char_mbminlen1("tis620_thai_ci", NULL); + failed+= strnncollsp_char_mbminlen1("tis620_thai_nopad_ci", NULL); #endif #ifdef HAVE_CHARSET_big5 From 1ebf0b737202ecb8c0e83e2813cb0038a872d196 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 19 Oct 2022 02:51:01 +0200 Subject: [PATCH 02/21] MDEV-29817: Issues with handling options for SSL CRLs (and some others) This patch adds the correct setting of the "--tls-version" and "--ssl-verify-server-cert" options in the client-side utilities such as mysqltest, mysqlcheck and mysqlslap, as well as the correct setting of the "--ssl-crl" option when executing queries on the slave side, and also the correct option codes in the "sslopts-logopts.h" file (in the latter case, incorrect values are not a problem right now, but may cause subtle test failures in the future, if the option handling code changes). --- client/mysqlcheck.c | 3 +++ client/mysqlslap.c | 3 +++ client/mysqltest.cc | 1 + include/sslopt-longopts.h | 4 ++-- sql/slave.cc | 6 +++--- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1b15da4921a..3e341f13e5a 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1105,7 +1105,10 @@ static int dbConnect(char *host, char *user, char *passwd) opt_ssl_capath, opt_ssl_cipher); mysql_options(&mysql_connection, MYSQL_OPT_SSL_CRL, opt_ssl_crl); mysql_options(&mysql_connection, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); + mysql_options(&mysql_connection, MARIADB_OPT_TLS_VERSION, opt_tls_version); } + mysql_options(&mysql_connection, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqlslap.c b/client/mysqlslap.c index f491bea6c79..8c65dccbb43 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -303,7 +303,10 @@ void set_mysql_connect_options(MYSQL *mysql) opt_ssl_capath, opt_ssl_cipher); mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl); mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); + mysql_options(mysql, MARIADB_OPT_TLS_VERSION, opt_tls_version); } + mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 270b2681095..abaf3ebb416 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -9713,6 +9713,7 @@ int main(int argc, char **argv) opt_ssl_capath, opt_ssl_cipher); mysql_options(con->mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl); mysql_options(con->mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); + mysql_options(con->mysql, MARIADB_OPT_TLS_VERSION, opt_tls_version); #if MYSQL_VERSION_ID >= 50000 /* Turn on ssl_verify_server_cert only if host is "localhost" */ opt_ssl_verify_server_cert= opt_host && !strcmp(opt_host, "localhost"); diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index d0278a1645d..ee90d17fb64 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -39,10 +39,10 @@ {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).", &opt_ssl_key, &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"ssl-crl", OPT_SSL_KEY, "Certificate revocation list (implies --ssl).", + {"ssl-crl", OPT_SSL_CRL, "Certificate revocation list (implies --ssl).", &opt_ssl_crl, &opt_ssl_crl, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"ssl-crlpath", OPT_SSL_KEY, + {"ssl-crlpath", OPT_SSL_CRLPATH, "Certificate revocation list path (implies --ssl).", &opt_ssl_crlpath, &opt_ssl_crlpath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/sql/slave.cc b/sql/slave.cc index c9d5c9ca3be..300e53bee1b 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -7256,9 +7256,9 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, mi->ssl_ca[0]?mi->ssl_ca:0, mi->ssl_capath[0]?mi->ssl_capath:0, mi->ssl_cipher[0]?mi->ssl_cipher:0); - mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, - &mi->ssl_verify_server_cert); - mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, + mysql_options(mysql, MYSQL_OPT_SSL_CRL, + mi->ssl_crl[0] ? mi->ssl_crl : 0); + mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, mi->ssl_crlpath[0] ? mi->ssl_crlpath : 0); mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &mi->ssl_verify_server_cert); From da03d8d99f7ff441cc1079dc074fde204751ef63 Mon Sep 17 00:00:00 2001 From: lrf141 Date: Wed, 9 Mar 2022 02:09:36 +0900 Subject: [PATCH 03/21] MDEV-19190 Assertion `...auto_inc_initialized` failed in get_auto_increment This is a DELETE only case. Normally this statement doesn't make inserts, but DELETE ... FOR PORTION changes it. UPDATE and INSERT initializes autoinc by calling handler::info(HA_STATUS_AUTO). Also myisam and innodb can lazily initialize it in their update_create_info overrides. The solution is to initialize autoinc during delete preparation, if period (DELETE FOR PORTION) is specified. The initial work has been done by Kento Takeuchi by his PR #2048, however this commit also holds a few technical modifications by Nikita Malyavin --- mysql-test/suite/period/r/delete.result | 24 ++++++++++++++++++++ mysql-test/suite/period/t/delete.test | 29 +++++++++++++++++++++++++ sql/handler.cc | 2 +- sql/sql_delete.cc | 4 ++++ sql/table.cc | 1 + 5 files changed, 59 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/period/r/delete.result b/mysql-test/suite/period/r/delete.result index a58f57761b6..f005619974f 100644 --- a/mysql-test/suite/period/r/delete.result +++ b/mysql-test/suite/period/r/delete.result @@ -388,3 +388,27 @@ ERROR 22003: Out of range value for column 'f' at row ROW delete ignore from t for portion of app from '2015-07-07 00:00:00' to '2020-03-11 08:48:52'; drop table t; +# +# MDEV-19190 Assertion `part_share->auto_inc_initialized` failed in +# ha_partition::get_auto_increment +# +create table t1 (id int, s date, e date, period for app(s,e)) +partition by key(id); +insert into t1 (s,e) values ('2023-07-21','2024-06-07'); +alter table t1 modify id int auto_increment key; +delete from t1 for portion of app from '2023-07-20' to '2024-05-23'; +select * from t1; +id s e +2 2024-05-23 2024-06-07 +drop table t1; +create table t1 (id int, s date, e date, period for app(s,e)) +partition by key(id); +insert into t1 (s,e) values ('2023-07-21','2024-06-07'); +alter table t1 modify id int auto_increment key; +delete from t1 for portion of app from '2023-07-20' to '2024-05-23'; +select * from t1; +id s e +2 2024-05-23 2024-06-07 +drop table t1; +drop table log_tbl; +drop procedure log; diff --git a/mysql-test/suite/period/t/delete.test b/mysql-test/suite/period/t/delete.test index 2a5f65d80ba..431c38c74f3 100644 --- a/mysql-test/suite/period/t/delete.test +++ b/mysql-test/suite/period/t/delete.test @@ -1,5 +1,6 @@ source suite/period/engines.inc; source include/have_log_bin.inc; +source include/have_partition.inc; create table t (id int, s date, e date, period for apptime(s,e)); @@ -225,3 +226,31 @@ delete ignore from t --enable_warnings drop table t; + +--echo # +--echo # MDEV-19190 Assertion `part_share->auto_inc_initialized` failed in +--echo # ha_partition::get_auto_increment +--echo # +create table t1 (id int, s date, e date, period for app(s,e)) + partition by key(id); +insert into t1 (s,e) values ('2023-07-21','2024-06-07'); +alter table t1 modify id int auto_increment key; +delete from t1 for portion of app from '2023-07-20' to '2024-05-23'; +select * from t1; +drop table t1; + +create table t1 (id int, s date, e date, period for app(s,e)) + partition by key(id); +insert into t1 (s,e) values ('2023-07-21','2024-06-07'); +alter table t1 modify id int auto_increment key; +--let $trig_table=t1 +--let $trig_cols=id, s, e +--disable_query_log +--source suite/period/create_triggers.inc +--enable_query_log + +delete from t1 for portion of app from '2023-07-20' to '2024-05-23'; +select * from t1; +drop table t1; +drop table log_tbl; +drop procedure log; diff --git a/sql/handler.cc b/sql/handler.cc index 5e9c9dc3a71..aebfeb17b2c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4003,7 +4003,7 @@ void handler::print_error(int error, myf errflag) break; case HA_ERR_AUTOINC_ERANGE: textno= error; - my_error(textno, errflag, table->next_number_field->field_name.str, + my_error(textno, errflag, table->found_next_number_field->field_name.str, table->in_use->get_stmt_da()->current_row_for_warning()); DBUG_VOID_RETURN; break; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 82d4dc48440..1b3fa3087e7 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -707,6 +707,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { table->use_all_columns(); table->rpl_write_set= table->write_set; + // Initialize autoinc. + // We don't set next_number_field here, as it is handled manually. + if (table->found_next_number_field) + table->file->info(HA_STATUS_AUTO); } else { diff --git a/sql/table.cc b/sql/table.cc index b9260853381..e41ed2f00ab 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8733,6 +8733,7 @@ int TABLE::update_generated_fields() res= found_next_number_field->set_default(); if (likely(!res)) res= file->update_auto_increment(); + next_number_field= NULL; } if (likely(!res) && vfield) From bbabdaef31cc9286a35ae5b0aa9e53fe6d262cb7 Mon Sep 17 00:00:00 2001 From: Weijun-H Date: Wed, 23 Nov 2022 09:36:28 +0000 Subject: [PATCH 04/21] increase max field name Signed-off-by: Weijun-H --- mysql-test/main/period_name.result | 9 +++++++++ mysql-test/main/period_name.test | 11 +++++++++++ mysql-test/suite/period/r/create.result | 8 ++++++++ mysql-test/suite/period/t/create.test | 11 +++++++++++ sql/sql_const.h | 2 +- 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 mysql-test/main/period_name.result create mode 100644 mysql-test/main/period_name.test diff --git a/mysql-test/main/period_name.result b/mysql-test/main/period_name.result new file mode 100644 index 00000000000..85004469cd1 --- /dev/null +++ b/mysql-test/main/period_name.result @@ -0,0 +1,9 @@ +# +# MDEV-29387: Period name with more than 32 symbols crashes the server +# +# test 34 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); +drop table t2; +# test 64 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); +drop table t2; diff --git a/mysql-test/main/period_name.test b/mysql-test/main/period_name.test new file mode 100644 index 00000000000..bc9178350be --- /dev/null +++ b/mysql-test/main/period_name.test @@ -0,0 +1,11 @@ +--echo # +--echo # MDEV-29387: Period name with more than 32 symbols crashes the server +--echo # + +--echo # test 34 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); +drop table t2; + +--echo # test 64 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); +drop table t2; diff --git a/mysql-test/suite/period/r/create.result b/mysql-test/suite/period/r/create.result index 58e0b82d085..eb4e110b1b2 100644 --- a/mysql-test/suite/period/r/create.result +++ b/mysql-test/suite/period/r/create.result @@ -100,3 +100,11 @@ show status like "Feature_application_time_periods"; Variable_name Value Feature_application_time_periods 6 drop table t; +# MDEV-29387: Period name with more than 32 symbols crashes the server +# +# test 34 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); +drop table t2; +# test 64 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); +drop table t2; diff --git a/mysql-test/suite/period/t/create.test b/mysql-test/suite/period/t/create.test index 49dcc6ad3c7..081c37d2e9f 100644 --- a/mysql-test/suite/period/t/create.test +++ b/mysql-test/suite/period/t/create.test @@ -85,3 +85,14 @@ insert t values (2, '2001-01-01', '2001-01-01'); show status like "Feature_application_time_periods"; drop table t; + +--echo # MDEV-29387: Period name with more than 32 symbols crashes the server +--echo # + +--echo # test 34 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); +drop table t2; + +--echo # test 64 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); +drop table t2; \ No newline at end of file diff --git a/sql/sql_const.h b/sql/sql_const.h index f7c820c727b..acbddcbf76e 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -29,7 +29,7 @@ /* extra 4+4 bytes for slave tmp tables */ #define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4) #define MAX_ALIAS_NAME 256 -#define MAX_FIELD_NAME 34 /* Max colum name length +2 */ +#define MAX_FIELD_NAME (NAME_LEN+1) /* Max colum name length +2 */ #define MAX_SYS_VAR_LENGTH 32 #define MAX_KEY MAX_INDEXES /* Max used keys */ #define MAX_REF_PARTS 32 /* Max parts used as ref */ From 640d299546239ff9ae045c8e422bbc7848a3a69d Mon Sep 17 00:00:00 2001 From: Weijun-H Date: Thu, 24 Nov 2022 22:48:13 +0000 Subject: [PATCH 05/21] remove redundant test file --- mysql-test/main/period_name.result | 9 --------- mysql-test/main/period_name.test | 11 ----------- 2 files changed, 20 deletions(-) delete mode 100644 mysql-test/main/period_name.result delete mode 100644 mysql-test/main/period_name.test diff --git a/mysql-test/main/period_name.result b/mysql-test/main/period_name.result deleted file mode 100644 index 85004469cd1..00000000000 --- a/mysql-test/main/period_name.result +++ /dev/null @@ -1,9 +0,0 @@ -# -# MDEV-29387: Period name with more than 32 symbols crashes the server -# -# test 34 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); -drop table t2; -# test 64 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); -drop table t2; diff --git a/mysql-test/main/period_name.test b/mysql-test/main/period_name.test deleted file mode 100644 index bc9178350be..00000000000 --- a/mysql-test/main/period_name.test +++ /dev/null @@ -1,11 +0,0 @@ ---echo # ---echo # MDEV-29387: Period name with more than 32 symbols crashes the server ---echo # - ---echo # test 34 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); -drop table t2; - ---echo # test 64 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); -drop table t2; From 196a54052a090cfdaf21f23e510a6790ac79ae19 Mon Sep 17 00:00:00 2001 From: Weijun-H Date: Wed, 23 Nov 2022 09:36:28 +0000 Subject: [PATCH 06/21] increase max field name Signed-off-by: Weijun-H --- mysql-test/main/period_name.result | 9 +++++++++ mysql-test/main/period_name.test | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 mysql-test/main/period_name.result create mode 100644 mysql-test/main/period_name.test diff --git a/mysql-test/main/period_name.result b/mysql-test/main/period_name.result new file mode 100644 index 00000000000..85004469cd1 --- /dev/null +++ b/mysql-test/main/period_name.result @@ -0,0 +1,9 @@ +# +# MDEV-29387: Period name with more than 32 symbols crashes the server +# +# test 34 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); +drop table t2; +# test 64 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); +drop table t2; diff --git a/mysql-test/main/period_name.test b/mysql-test/main/period_name.test new file mode 100644 index 00000000000..bc9178350be --- /dev/null +++ b/mysql-test/main/period_name.test @@ -0,0 +1,11 @@ +--echo # +--echo # MDEV-29387: Period name with more than 32 symbols crashes the server +--echo # + +--echo # test 34 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); +drop table t2; + +--echo # test 64 symbols +create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); +drop table t2; From 8fc23c4a75737db3e73c1ca11a87109a4e252468 Mon Sep 17 00:00:00 2001 From: Weijun-H Date: Thu, 24 Nov 2022 22:48:13 +0000 Subject: [PATCH 07/21] remove redundant test file --- mysql-test/main/period_name.result | 9 --------- mysql-test/main/period_name.test | 11 ----------- 2 files changed, 20 deletions(-) delete mode 100644 mysql-test/main/period_name.result delete mode 100644 mysql-test/main/period_name.test diff --git a/mysql-test/main/period_name.result b/mysql-test/main/period_name.result deleted file mode 100644 index 85004469cd1..00000000000 --- a/mysql-test/main/period_name.result +++ /dev/null @@ -1,9 +0,0 @@ -# -# MDEV-29387: Period name with more than 32 symbols crashes the server -# -# test 34 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); -drop table t2; -# test 64 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); -drop table t2; diff --git a/mysql-test/main/period_name.test b/mysql-test/main/period_name.test deleted file mode 100644 index bc9178350be..00000000000 --- a/mysql-test/main/period_name.test +++ /dev/null @@ -1,11 +0,0 @@ ---echo # ---echo # MDEV-29387: Period name with more than 32 symbols crashes the server ---echo # - ---echo # test 34 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); -drop table t2; - ---echo # test 64 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); -drop table t2; From 0204cf182aeebf6ff8b993a9941a2ebd0fa14ecb Mon Sep 17 00:00:00 2001 From: Weijun-H Date: Fri, 25 Nov 2022 13:33:16 +0000 Subject: [PATCH 08/21] update anotation --- sql/sql_const.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_const.h b/sql/sql_const.h index acbddcbf76e..ef61a592e81 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -29,7 +29,7 @@ /* extra 4+4 bytes for slave tmp tables */ #define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4) #define MAX_ALIAS_NAME 256 -#define MAX_FIELD_NAME (NAME_LEN+1) /* Max colum name length +2 */ +#define MAX_FIELD_NAME (NAME_LEN+1) /* Max colum name length +1 */ #define MAX_SYS_VAR_LENGTH 32 #define MAX_KEY MAX_INDEXES /* Max used keys */ #define MAX_REF_PARTS 32 /* Max parts used as ref */ From 8535189f32b8265bb0fa655cb3bf8ef2f40c582e Mon Sep 17 00:00:00 2001 From: Weijun-H Date: Fri, 25 Nov 2022 19:50:40 +0000 Subject: [PATCH 09/21] reformat the test --- mysql-test/suite/period/r/create.result | 7 +++++-- mysql-test/suite/period/t/create.test | 9 ++++++--- sql/sql_const.h | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/period/r/create.result b/mysql-test/suite/period/r/create.result index eb4e110b1b2..5296aad430f 100644 --- a/mysql-test/suite/period/r/create.result +++ b/mysql-test/suite/period/r/create.result @@ -103,8 +103,11 @@ drop table t; # MDEV-29387: Period name with more than 32 symbols crashes the server # # test 34 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); +create table t2 (s date, e date, +period for `abcd123456789012345678901234567890` (s,e)); drop table t2; # test 64 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); +create table t2 (s date, e date, period for +`abcd123456789012345678901234567890123456789012345678901234567890` + (s,e)); drop table t2; diff --git a/mysql-test/suite/period/t/create.test b/mysql-test/suite/period/t/create.test index 081c37d2e9f..0bca5b6df56 100644 --- a/mysql-test/suite/period/t/create.test +++ b/mysql-test/suite/period/t/create.test @@ -90,9 +90,12 @@ drop table t; --echo # --echo # test 34 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890` (s,e)); +create table t2 (s date, e date, + period for `abcd123456789012345678901234567890` (s,e)); drop table t2; --echo # test 64 symbols -create table t2 (s date, e date, period for `abcd123456789012345678901234567890123456789012345678901234567890` (s,e)); -drop table t2; \ No newline at end of file +create table t2 (s date, e date, period for + `abcd123456789012345678901234567890123456789012345678901234567890` + (s,e)); +drop table t2; diff --git a/sql/sql_const.h b/sql/sql_const.h index ef61a592e81..18e3605d56c 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -29,7 +29,7 @@ /* extra 4+4 bytes for slave tmp tables */ #define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4) #define MAX_ALIAS_NAME 256 -#define MAX_FIELD_NAME (NAME_LEN+1) /* Max colum name length +1 */ +#define MAX_FIELD_NAME (NAME_LEN+1) /* Max colum name length +1 */ #define MAX_SYS_VAR_LENGTH 32 #define MAX_KEY MAX_INDEXES /* Max used keys */ #define MAX_REF_PARTS 32 /* Max parts used as ref */ From c77459f89c6acfd0eabe02f0e3853d071a4346d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 29 Nov 2022 06:49:17 +0200 Subject: [PATCH 10/21] Update wsrep-lib submodule --- wsrep-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wsrep-lib b/wsrep-lib index 8bfce041896..f8ff2cfdd4c 160000 --- a/wsrep-lib +++ b/wsrep-lib @@ -1 +1 @@ -Subproject commit 8bfce04189671eb1f06e0fa83dff8c880f31088f +Subproject commit f8ff2cfdd4c6424ffd96fc53bcc0f2e1d9ffe137 From c2fc5266adad1c97e828ad86f834d1f7d99e88d9 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Mon, 14 Nov 2022 11:31:14 +0100 Subject: [PATCH 11/21] MDEV-29880 Galera test failure on GCF-336 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix `wsrep_table_accessible_when_detached()` so that commands that access no tables are rejected while a node is disconnected from a cluster. Reviewed-by: Jan Lindström --- .../suite/galera/r/galera_var_dirty_reads.result | 6 +++--- mysql-test/suite/galera/t/galera_var_dirty_reads.test | 6 +++--- mysql-test/suite/galera_3nodes_sr/disabled.def | 1 - mysql-test/suite/galera_3nodes_sr/r/GCF-336.result | 11 +++++++++++ sql/sql_parse.cc | 4 +++- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_var_dirty_reads.result b/mysql-test/suite/galera/r/galera_var_dirty_reads.result index 240f1802385..2b164fecee6 100644 --- a/mysql-test/suite/galera/r/galera_var_dirty_reads.result +++ b/mysql-test/suite/galera/r/galera_var_dirty_reads.result @@ -19,9 +19,9 @@ SHOW STATUS LIKE 'wsrep_cluster_status'; Variable_name Value wsrep_cluster_status Disconnected SELECT * FROM t1; -Got one of the listed errors +ERROR 08S01: WSREP has not yet prepared node for application use SELECT 1 FROM t1; -Got one of the listed errors +ERROR 08S01: WSREP has not yet prepared node for application use SET @@session.wsrep_dirty_reads=ON; SELECT * FROM t1; i @@ -34,7 +34,7 @@ i variable_name variable_value 1 WSREP_DIRTY_READS ON SET @@session.wsrep_dirty_reads=OFF; SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; -Got one of the listed errors +ERROR 08S01: WSREP has not yet prepared node for application use SELECT 1; 1 1 diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index 85f72e633dc..e0c5b666c32 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -31,10 +31,10 @@ SHOW STATUS LIKE 'wsrep_ready'; # Must return 'Disconnected' SHOW STATUS LIKE 'wsrep_cluster_status'; ---error ER_UNKNOWN_COM_ERROR,1047 +--error ER_UNKNOWN_COM_ERROR SELECT * FROM t1; ---error ER_UNKNOWN_COM_ERROR,1047 +--error ER_UNKNOWN_COM_ERROR SELECT 1 FROM t1; SET @@session.wsrep_dirty_reads=ON; @@ -46,7 +46,7 @@ SELECT i, variable_name, variable_value FROM t1, information_schema.session_vari SET @@session.wsrep_dirty_reads=OFF; ---error ER_UNKNOWN_COM_ERROR,1047 +--error ER_UNKNOWN_COM_ERROR SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; diff --git a/mysql-test/suite/galera_3nodes_sr/disabled.def b/mysql-test/suite/galera_3nodes_sr/disabled.def index 900b27860a5..f1ec92eee79 100644 --- a/mysql-test/suite/galera_3nodes_sr/disabled.def +++ b/mysql-test/suite/galera_3nodes_sr/disabled.def @@ -1,4 +1,3 @@ -GCF-336 : GCF-582 : GCF-810A : GCF-810B : diff --git a/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result b/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result index bb6c11edf36..eeccfa3b5a3 100644 --- a/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result +++ b/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result @@ -1,11 +1,17 @@ +connection node_2; +connection node_1; +connection node_2; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; SET SESSION wsrep_trx_fragment_size = 1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES (1); +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2a; SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log; COUNT(*) > 0 1 +connection node_1; SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log; COUNT(*) > 0 1 @@ -13,14 +19,19 @@ SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT COUNT(*) > 0 FROM t1; COUNT(*) > 0 1 +connection node_2a; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET SESSION wsrep_sync_wait=0; +connection node_2; INSERT INTO t1 VALUES (2); ERROR 40001: Deadlock found when trying to get lock; try restarting transaction COMMIT; ERROR 08S01: WSREP has not yet prepared node for application use +connection node_2a; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; DROP TABLE t1; CALL mtr.add_suppression("replication aborted"); CALL mtr.add_suppression("WSREP: fragment replication failed: 3"); CALL mtr.add_suppression("WSREP: failed to send SR rollback for "); +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; +connection node_3; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0261e7480f1..9d148895abe 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1162,7 +1162,7 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables) if (get_table_category(&db, &tn) < TABLE_CATEGORY_INFORMATION) return false; } - return true; + return tables != NULL; } static bool wsrep_command_no_result(char command) @@ -3716,6 +3716,8 @@ mysql_execute_command(THD *thd) (sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) && !wsrep_tables_accessible_when_detached(all_tables) && lex->sql_command != SQLCOM_SET_OPTION && + lex->sql_command != SQLCOM_CHANGE_DB && + !(lex->sql_command == SQLCOM_SELECT && !all_tables) && !wsrep_is_show_query(lex->sql_command)) { my_message(ER_UNKNOWN_COM_ERROR, From 97d9bf98b2d25bad36586e2458cae5f387470eb1 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 17 Nov 2022 16:02:04 +0100 Subject: [PATCH 12/21] Restore auto increment offset in test galera_join_with_cc_A MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jan Lindström --- .../suite/galera_3nodes/r/galera_join_with_cc_A.result | 3 +++ .../suite/galera_3nodes/t/galera_join_with_cc_A.test | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_A.result b/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_A.result index a60e2bbb6cc..1813607517a 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_A.result +++ b/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_A.result @@ -1,6 +1,9 @@ connection node_2; connection node_1; connection node_1; +connection node_2; +connection node_3; +connection node_1; CREATE TABLE t1 (pk INT PRIMARY KEY, node INT) ENGINE=innodb; INSERT INTO t1 VALUES (1, 1); connection node_2; diff --git a/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_A.test b/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_A.test index 2248ff5014a..aa264eb8047 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_A.test +++ b/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_A.test @@ -15,6 +15,11 @@ --let $galera_server_number = 3 --source include/galera_connect.inc +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--source ../galera/include/auto_increment_offset_save.inc + --connection node_1 --let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --source include/wait_condition.inc @@ -260,3 +265,5 @@ call mtr.add_suppression("WSREP: Rejecting JOIN message from \(.*\): new State T --connection node_3 call mtr.add_suppression("WSREP: Rejecting JOIN message from \(.*\): new State Transfer required."); + +--source ../galera/include/auto_increment_offset_restore.inc From 283efe2680b8a4158c40573cac9cefe8732e5144 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Fri, 11 Nov 2022 13:08:20 +0100 Subject: [PATCH 13/21] MDEV-29878 Galera test failure on MDEV-26575 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test MDEV-26575 fails when it runs after MDEV-25389. This is because the latter simulates a failure while an applier thread is created in `start_wsrep_THD()`. The failure was not handled correctly and would not cleanup the created THD from the global `server_threads`. A subsequent shutdown would hang and eventually fail trying to close this THD. Reviewed-by: Jan Lindström --- mysql-test/suite/galera/r/MDEV-25389.result | 2 ++ mysql-test/suite/galera/t/MDEV-25389.test | 11 ++++++++++ sql/wsrep_mysqld.cc | 23 ++++++++++++--------- sql/wsrep_thd.cc | 3 +-- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/galera/r/MDEV-25389.result b/mysql-test/suite/galera/r/MDEV-25389.result index 9a142676d92..f1da3f055c0 100644 --- a/mysql-test/suite/galera/r/MDEV-25389.result +++ b/mysql-test/suite/galera/r/MDEV-25389.result @@ -1,5 +1,7 @@ connection node_2; connection node_1; +connection node_1; +connection node_2; connection node_2; call mtr.add_suppression("WSREP: Failed to create/initialize system thread"); SET GLOBAL debug_dbug='+d,simulate_failed_connection_1'; diff --git a/mysql-test/suite/galera/t/MDEV-25389.test b/mysql-test/suite/galera/t/MDEV-25389.test index dcb21ee6136..5c78c6d9b56 100644 --- a/mysql-test/suite/galera/t/MDEV-25389.test +++ b/mysql-test/suite/galera/t/MDEV-25389.test @@ -2,6 +2,10 @@ --source include/have_debug.inc --source include/have_debug_sync.inc +--let $node_1=node_1 +--let $node_2=node_2 +--source ../galera/include/auto_increment_offset_save.inc + --connection node_2 call mtr.add_suppression("WSREP: Failed to create/initialize system thread"); SET GLOBAL debug_dbug='+d,simulate_failed_connection_1'; @@ -11,3 +15,10 @@ SELECT @@wsrep_slave_threads; SET GLOBAL debug_dbug=''; SET GLOBAL wsrep_slave_threads=1; SELECT @@wsrep_slave_threads; + +# MDEV-29878: this test caused a subsequent test to fail +# during shutdown. Do a restart here, to make sure the +# issue is fixed. +--source include/restart_mysqld.inc + +--source ../galera/include/auto_increment_offset_restore.inc diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 1dee4a6d3cd..53212e2433c 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -2901,7 +2901,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len) void* start_wsrep_THD(void *arg) { - THD *thd; + THD *thd= NULL; Wsrep_thd_args* thd_args= (Wsrep_thd_args*) arg; @@ -2939,10 +2939,6 @@ void* start_wsrep_THD(void *arg) thd->thr_create_utime= microsecond_interval_timer(); if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0)) { - close_connection(thd, ER_OUT_OF_RESOURCES); - statistic_increment(aborted_connects,&LOCK_status); - // This will signal error to wsrep_slave_threads_update - wsrep_thread_create_failed.store(true, std::memory_order_relaxed); WSREP_DEBUG("start_wsrep_THD: init_new_connection_thread failed"); goto error; } @@ -2964,11 +2960,6 @@ void* start_wsrep_THD(void *arg) wsrep_assign_from_threadvars(thd); if (wsrep_store_threadvars(thd)) { - close_connection(thd, ER_OUT_OF_RESOURCES); - statistic_increment(aborted_connects,&LOCK_status); - MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0)); - delete thd; - delete thd_args; goto error; } @@ -3061,6 +3052,18 @@ void* start_wsrep_THD(void *arg) error: WSREP_ERROR("Failed to create/initialize system thread"); + if (thd) + { + close_connection(thd, ER_OUT_OF_RESOURCES); + statistic_increment(aborted_connects, &LOCK_status); + server_threads.erase(thd); + delete thd; + my_thread_end(); + } + delete thd_args; + // This will signal error to wsrep_slave_threads_update + wsrep_thread_create_failed.store(true, std::memory_order_relaxed); + /* Abort if its the first applier/rollbacker thread. */ if (!mysqld_server_initialized) unireg_abort(1); diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 5922b39e718..6900efa8bc9 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -23,8 +23,7 @@ #include "rpl_rli.h" #include "log_event.h" #include "sql_parse.h" -#include "mysqld.h" // start_wsrep_THD(); -#include "wsrep_applier.h" // start_wsrep_THD(); +#include "wsrep_mysqld.h" // start_wsrep_THD(); #include "mysql/service_wsrep.h" #include "debug_sync.h" #include "slave.h" From 07a06022c4e63adc360b42775934f35fa1df5a79 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Tue, 8 Nov 2022 16:36:34 +0200 Subject: [PATCH 14/21] MDEV-29512 deadlock between commit monitor and THD::LOCK_thd_data mutex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit contains only a mtr test for reproducing the issue in MDEV-29512 The actual fix will be pushed in wsrep-lib repository The hanging in MDEV-29512 happens when binlog purging is attempted, and there is one local BF aborted transaction waiting for commit monitor. The test will launch two node cluster and enable binlogging with expire log days, to force binlog purging to happen. A local transaction is executed so that will become BF abort victim, and has advanced to replication stage waiting for commit monitor for final cleanup (to mark position in innodb) after that, applier is released to complete the BF abort and due to binlog configuration, starting the binlog purging. This is where the hanging would occur, if code is buggy Reviewed-by: Jan Lindström --- mysql-test/suite/galera/r/MDEV-29512.result | 40 +++++++++ mysql-test/suite/galera/t/MDEV-29512.cnf | 15 ++++ mysql-test/suite/galera/t/MDEV-29512.test | 91 +++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 mysql-test/suite/galera/r/MDEV-29512.result create mode 100644 mysql-test/suite/galera/t/MDEV-29512.cnf create mode 100644 mysql-test/suite/galera/t/MDEV-29512.test diff --git a/mysql-test/suite/galera/r/MDEV-29512.result b/mysql-test/suite/galera/r/MDEV-29512.result new file mode 100644 index 00000000000..aaf24df920e --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-29512.result @@ -0,0 +1,40 @@ +connection node_2; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 int, f3 varchar(2000)); +INSERT INTO t1 VALUES (1, 0, REPEAT('1234567890', 200)); +INSERT INTO t1 VALUES (3, 3, REPEAT('1234567890', 200)); +SET SESSION wsrep_sync_wait=0; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; +SET SESSION wsrep_sync_wait=0; +connection node_1; +begin; +select f1,f2 from t1; +f1 f2 +1 0 +3 3 +connection node_2; +UPDATE t1 SET f2=2 WHERE f1=3; +connection node_1a; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; +connection node_1; +UPDATE t1 SET f2=1 WHERE f1=3; +SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_master_enter_sync'; +COMMIT; +connection node_1a; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_master_enter_sync'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +SET GLOBAL debug_dbug = NULL; +SET debug_sync='RESET'; +connection node_1; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +select f1,f2 from t1; +f1 f2 +1 0 +3 2 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MDEV-29512.cnf b/mysql-test/suite/galera/t/MDEV-29512.cnf new file mode 100644 index 00000000000..bf8e0c37984 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-29512.cnf @@ -0,0 +1,15 @@ +!include ../galera_2nodes.cnf + +[mysqld] +log-bin +log-slave-updates + +[mysqld.1] +log_bin +log_slave_updates +max-binlog-size=4096 +expire-logs-days=1 + + +[mysqld.2] + diff --git a/mysql-test/suite/galera/t/MDEV-29512.test b/mysql-test/suite/galera/t/MDEV-29512.test new file mode 100644 index 00000000000..ffcef792f85 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-29512.test @@ -0,0 +1,91 @@ +# +# This test is for reproducing the issue in: +# https://jira.mariadb.org/browse/MDEV-29512 +# +# The hanging in MDEV-29512 happens when binlog purging is attempted, and there is +# one local BF aborted transaction waiting for commit monitor. +# +# The test will launch two node cluster and enable binlogging with expire log days, +# to force binlog purging to happen. +# A local transaction is executed so that will become BF abort victim, and has advanced +# to replication stage waiting for commit monitor for final cleanup (to mark position in innodb) +# after that, applier is released to complete the BF abort and due to binlog configuration, +# starting the binlog purging. This is where the hanging would occur, if code is buggy +# +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/galera_have_debug_sync.inc + +# +# binlog size is limited to 4096 bytes, we will create enough events to +# cause binlog rotation +# +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 int, f3 varchar(2000)); +INSERT INTO t1 VALUES (1, 0, REPEAT('1234567890', 200)); +INSERT INTO t1 VALUES (3, 3, REPEAT('1234567890', 200)); + +SET SESSION wsrep_sync_wait=0; + +# set sync point for replication applier +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; + +# Control connection to manage sync points for appliers +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait=0; + +# starting local transaction, only select so far, +# write will happen later and this will be ordered after the transaction in node_2 +--connection node_1 +begin; +select f1,f2 from t1; + +# send from node 2 an UPDATE transaction, which will BF abort the transaction in node_1 +--connection node_2 +--let $wait_condition=select count(*)=2 from t1 +--source include/wait_condition.inc + +UPDATE t1 SET f2=2 WHERE f1=3; + +--connection node_1a +# wait to see the UPDATE from node_2 in apply_cb sync point +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; + +--connection node_1 +# now issuing conflicting update +UPDATE t1 SET f2=1 WHERE f1=3; + +# Block the local commit, send final COMMIT and wait until it gets blocked +--let $galera_sync_point = commit_monitor_master_enter_sync +--source include/galera_set_sync_point.inc +--send COMMIT + +--connection node_1a +# wait for the local commit to enter in commit monitor wait state +--let $galera_sync_point = commit_monitor_master_enter_sync +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc + +# release the local transaction to continue with commit +--let $galera_sync_point = commit_monitor_master_enter_sync +--source include/galera_signal_sync_point.inc + +# and now release the applier, it should force local trx to abort +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +SET GLOBAL debug_dbug = NULL; +SET debug_sync='RESET'; + +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +# wait until applying is complete +--let $wait_condition = SELECT COUNT(*)=1 FROM t1 WHERE f2=2 +--source include/wait_condition.inc + +# final read to verify what we got +select f1,f2 from t1; + +DROP TABLE t1; From 4eb8e51c269eb9447d3765a6e4deba0dc68dfa37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 30 Nov 2022 13:10:52 +0200 Subject: [PATCH 15/21] Merge 10.4 into 10.5 --- client/mysqlcheck.c | 3 + client/mysqlslap.c | 3 + client/mysqltest.cc | 1 + include/sslopt-longopts.h | 4 +- mysql-test/main/ctype_tis620.result | 25 +++++ mysql-test/main/ctype_tis620.test | 31 +++++++ mysql-test/suite/galera/r/MDEV-25389.result | 17 ++++ mysql-test/suite/galera/r/MDEV-29512.result | 40 ++++++++ .../galera/r/galera_var_dirty_reads.result | 6 +- mysql-test/suite/galera/t/MDEV-25389.test | 24 +++++ mysql-test/suite/galera/t/MDEV-29512.cnf | 15 +++ mysql-test/suite/galera/t/MDEV-29512.test | 91 +++++++++++++++++++ .../galera/t/galera_var_dirty_reads.test | 6 +- .../r/galera_join_with_cc_A.result | 3 + .../t/galera_join_with_cc_A.test | 7 ++ .../suite/galera_3nodes_sr/disabled.def | 1 - .../suite/galera_3nodes_sr/r/GCF-336.result | 11 +++ .../suite/innodb/r/innodb_ctype_tis620.result | 66 ++++++++++++++ .../suite/innodb/t/innodb_ctype_tis620.test | 62 +++++++++++++ .../suite/parts/r/part_ctype_tis620.result | 47 ++++++++++ .../suite/parts/t/part_ctype_tis620.test | 52 +++++++++++ mysql-test/suite/period/r/create.result | 11 +++ mysql-test/suite/period/r/delete.result | 24 +++++ mysql-test/suite/period/t/create.test | 14 +++ mysql-test/suite/period/t/delete.test | 28 ++++++ sql/handler.cc | 2 +- sql/slave.cc | 6 +- sql/sql_const.h | 2 +- sql/sql_delete.cc | 4 + sql/sql_parse.cc | 4 +- sql/table.cc | 1 + sql/wsrep_mysqld.cc | 16 +++- sql/wsrep_mysqld.h | 1 + sql/wsrep_thd.cc | 3 +- sql/wsrep_var.cc | 9 +- strings/ctype-tis620.c | 16 +++- unittest/strings/strings-t.c | 1 + wsrep-lib | 2 +- 38 files changed, 637 insertions(+), 22 deletions(-) create mode 100644 mysql-test/suite/galera/r/MDEV-25389.result create mode 100644 mysql-test/suite/galera/r/MDEV-29512.result create mode 100644 mysql-test/suite/galera/t/MDEV-25389.test create mode 100644 mysql-test/suite/galera/t/MDEV-29512.cnf create mode 100644 mysql-test/suite/galera/t/MDEV-29512.test create mode 100644 mysql-test/suite/parts/r/part_ctype_tis620.result create mode 100644 mysql-test/suite/parts/t/part_ctype_tis620.test diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index bf70a097c09..147ebb81231 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1110,7 +1110,10 @@ static int dbConnect(char *host, char *user, char *passwd) opt_ssl_capath, opt_ssl_cipher); mysql_options(&mysql_connection, MYSQL_OPT_SSL_CRL, opt_ssl_crl); mysql_options(&mysql_connection, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); + mysql_options(&mysql_connection, MARIADB_OPT_TLS_VERSION, opt_tls_version); } + mysql_options(&mysql_connection, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 08569f2e1a4..f5253533921 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -303,7 +303,10 @@ void set_mysql_connect_options(MYSQL *mysql) opt_ssl_capath, opt_ssl_cipher); mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl); mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); + mysql_options(mysql, MARIADB_OPT_TLS_VERSION, opt_tls_version); } + mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + (char*)&opt_ssl_verify_server_cert); #endif if (opt_protocol) mysql_options(mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index c7ddc0d0d6a..636ab06d745 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -9768,6 +9768,7 @@ int main(int argc, char **argv) opt_ssl_capath, opt_ssl_cipher); mysql_options(con->mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl); mysql_options(con->mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath); + mysql_options(con->mysql, MARIADB_OPT_TLS_VERSION, opt_tls_version); #if MYSQL_VERSION_ID >= 50000 /* Turn on ssl_verify_server_cert only if host is "localhost" */ opt_ssl_verify_server_cert= opt_host && !strcmp(opt_host, "localhost"); diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index d0278a1645d..ee90d17fb64 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -39,10 +39,10 @@ {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).", &opt_ssl_key, &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"ssl-crl", OPT_SSL_KEY, "Certificate revocation list (implies --ssl).", + {"ssl-crl", OPT_SSL_CRL, "Certificate revocation list (implies --ssl).", &opt_ssl_crl, &opt_ssl_crl, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"ssl-crlpath", OPT_SSL_KEY, + {"ssl-crlpath", OPT_SSL_CRLPATH, "Certificate revocation list path (implies --ssl).", &opt_ssl_crlpath, &opt_ssl_crlpath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/mysql-test/main/ctype_tis620.result b/mysql-test/main/ctype_tis620.result index f1d0f5bc20a..4530b3ca4a2 100644 --- a/mysql-test/main/ctype_tis620.result +++ b/mysql-test/main/ctype_tis620.result @@ -4432,3 +4432,28 @@ HEX(WEIGHT_STRING(_tis620 'a\0b' COLLATE tis620_thai_nopad_ci)) # # End of 10.2 tests # +# +# Start of 10.4 tests +# +# +# MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +# +CREATE OR REPLACE TABLE t1 +( +a VARCHAR(250) COLLATE tis620_thai_nopad_ci, +UNIQUE KEY(a(100)) USING HASH +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('a'),('A'); +ERROR 23000: Duplicate entry 'A' for key 'a' +DROP TABLE t1; +CREATE OR REPLACE TABLE t1 +( +a CHAR(250) COLLATE tis620_thai_nopad_ci, +UNIQUE KEY(a(100)) USING HASH +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('a'),('A'); +ERROR 23000: Duplicate entry 'A' for key 'a' +DROP TABLE t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/ctype_tis620.test b/mysql-test/main/ctype_tis620.test index f432b23d71c..39908b995b2 100644 --- a/mysql-test/main/ctype_tis620.test +++ b/mysql-test/main/ctype_tis620.test @@ -223,3 +223,34 @@ SELECT HEX(WEIGHT_STRING(_tis620 'a\0b' COLLATE tis620_thai_nopad_ci)); --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +--echo # + +CREATE OR REPLACE TABLE t1 +( + a VARCHAR(250) COLLATE tis620_thai_nopad_ci, + UNIQUE KEY(a(100)) USING HASH +) ENGINE=MyISAM; +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES ('a'),('A'); +DROP TABLE t1; + +CREATE OR REPLACE TABLE t1 + +( + a CHAR(250) COLLATE tis620_thai_nopad_ci, + UNIQUE KEY(a(100)) USING HASH +) ENGINE=MyISAM; +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES ('a'),('A'); +DROP TABLE t1; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/suite/galera/r/MDEV-25389.result b/mysql-test/suite/galera/r/MDEV-25389.result new file mode 100644 index 00000000000..f369fe4dbae --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-25389.result @@ -0,0 +1,17 @@ +connection node_2; +connection node_1; +connection node_1; +connection node_2; +connection node_2; +call mtr.add_suppression("WSREP: Failed to create/initialize system thread"); +SET GLOBAL debug_dbug='+d,wsrep_simulate_failed_connection_1'; +SET GLOBAL wsrep_slave_threads=2; +ERROR HY000: Incorrect arguments to SET +SELECT @@wsrep_slave_threads; +@@wsrep_slave_threads +1 +SET GLOBAL debug_dbug=''; +SET GLOBAL wsrep_slave_threads=1; +SELECT @@wsrep_slave_threads; +@@wsrep_slave_threads +1 diff --git a/mysql-test/suite/galera/r/MDEV-29512.result b/mysql-test/suite/galera/r/MDEV-29512.result new file mode 100644 index 00000000000..aaf24df920e --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-29512.result @@ -0,0 +1,40 @@ +connection node_2; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 int, f3 varchar(2000)); +INSERT INTO t1 VALUES (1, 0, REPEAT('1234567890', 200)); +INSERT INTO t1 VALUES (3, 3, REPEAT('1234567890', 200)); +SET SESSION wsrep_sync_wait=0; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1a; +SET SESSION wsrep_sync_wait=0; +connection node_1; +begin; +select f1,f2 from t1; +f1 f2 +1 0 +3 3 +connection node_2; +UPDATE t1 SET f2=2 WHERE f1=3; +connection node_1a; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; +connection node_1; +UPDATE t1 SET f2=1 WHERE f1=3; +SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_master_enter_sync'; +COMMIT; +connection node_1a; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_master_enter_sync'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +SET GLOBAL debug_dbug = NULL; +SET debug_sync='RESET'; +connection node_1; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +select f1,f2 from t1; +f1 f2 +1 0 +3 2 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_var_dirty_reads.result b/mysql-test/suite/galera/r/galera_var_dirty_reads.result index 240f1802385..2b164fecee6 100644 --- a/mysql-test/suite/galera/r/galera_var_dirty_reads.result +++ b/mysql-test/suite/galera/r/galera_var_dirty_reads.result @@ -19,9 +19,9 @@ SHOW STATUS LIKE 'wsrep_cluster_status'; Variable_name Value wsrep_cluster_status Disconnected SELECT * FROM t1; -Got one of the listed errors +ERROR 08S01: WSREP has not yet prepared node for application use SELECT 1 FROM t1; -Got one of the listed errors +ERROR 08S01: WSREP has not yet prepared node for application use SET @@session.wsrep_dirty_reads=ON; SELECT * FROM t1; i @@ -34,7 +34,7 @@ i variable_name variable_value 1 WSREP_DIRTY_READS ON SET @@session.wsrep_dirty_reads=OFF; SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; -Got one of the listed errors +ERROR 08S01: WSREP has not yet prepared node for application use SELECT 1; 1 1 diff --git a/mysql-test/suite/galera/t/MDEV-25389.test b/mysql-test/suite/galera/t/MDEV-25389.test new file mode 100644 index 00000000000..fc523371918 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-25389.test @@ -0,0 +1,24 @@ +--source include/galera_cluster.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source ../galera/include/auto_increment_offset_save.inc + +--connection node_2 +call mtr.add_suppression("WSREP: Failed to create/initialize system thread"); +SET GLOBAL debug_dbug='+d,wsrep_simulate_failed_connection_1'; +--error ER_WRONG_ARGUMENTS +SET GLOBAL wsrep_slave_threads=2; +SELECT @@wsrep_slave_threads; +SET GLOBAL debug_dbug=''; +SET GLOBAL wsrep_slave_threads=1; +SELECT @@wsrep_slave_threads; + +# MDEV-29878: this test caused a subsequent test to fail +# during shutdown. Do a restart here, to make sure the +# issue is fixed. +--source include/restart_mysqld.inc + +--source ../galera/include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/MDEV-29512.cnf b/mysql-test/suite/galera/t/MDEV-29512.cnf new file mode 100644 index 00000000000..bf8e0c37984 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-29512.cnf @@ -0,0 +1,15 @@ +!include ../galera_2nodes.cnf + +[mysqld] +log-bin +log-slave-updates + +[mysqld.1] +log_bin +log_slave_updates +max-binlog-size=4096 +expire-logs-days=1 + + +[mysqld.2] + diff --git a/mysql-test/suite/galera/t/MDEV-29512.test b/mysql-test/suite/galera/t/MDEV-29512.test new file mode 100644 index 00000000000..ffcef792f85 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-29512.test @@ -0,0 +1,91 @@ +# +# This test is for reproducing the issue in: +# https://jira.mariadb.org/browse/MDEV-29512 +# +# The hanging in MDEV-29512 happens when binlog purging is attempted, and there is +# one local BF aborted transaction waiting for commit monitor. +# +# The test will launch two node cluster and enable binlogging with expire log days, +# to force binlog purging to happen. +# A local transaction is executed so that will become BF abort victim, and has advanced +# to replication stage waiting for commit monitor for final cleanup (to mark position in innodb) +# after that, applier is released to complete the BF abort and due to binlog configuration, +# starting the binlog purging. This is where the hanging would occur, if code is buggy +# +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/galera_have_debug_sync.inc + +# +# binlog size is limited to 4096 bytes, we will create enough events to +# cause binlog rotation +# +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 int, f3 varchar(2000)); +INSERT INTO t1 VALUES (1, 0, REPEAT('1234567890', 200)); +INSERT INTO t1 VALUES (3, 3, REPEAT('1234567890', 200)); + +SET SESSION wsrep_sync_wait=0; + +# set sync point for replication applier +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; + +# Control connection to manage sync points for appliers +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait=0; + +# starting local transaction, only select so far, +# write will happen later and this will be ordered after the transaction in node_2 +--connection node_1 +begin; +select f1,f2 from t1; + +# send from node 2 an UPDATE transaction, which will BF abort the transaction in node_1 +--connection node_2 +--let $wait_condition=select count(*)=2 from t1 +--source include/wait_condition.inc + +UPDATE t1 SET f2=2 WHERE f1=3; + +--connection node_1a +# wait to see the UPDATE from node_2 in apply_cb sync point +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; + +--connection node_1 +# now issuing conflicting update +UPDATE t1 SET f2=1 WHERE f1=3; + +# Block the local commit, send final COMMIT and wait until it gets blocked +--let $galera_sync_point = commit_monitor_master_enter_sync +--source include/galera_set_sync_point.inc +--send COMMIT + +--connection node_1a +# wait for the local commit to enter in commit monitor wait state +--let $galera_sync_point = commit_monitor_master_enter_sync +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc + +# release the local transaction to continue with commit +--let $galera_sync_point = commit_monitor_master_enter_sync +--source include/galera_signal_sync_point.inc + +# and now release the applier, it should force local trx to abort +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +SET GLOBAL debug_dbug = NULL; +SET debug_sync='RESET'; + +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +# wait until applying is complete +--let $wait_condition = SELECT COUNT(*)=1 FROM t1 WHERE f2=2 +--source include/wait_condition.inc + +# final read to verify what we got +select f1,f2 from t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_dirty_reads.test b/mysql-test/suite/galera/t/galera_var_dirty_reads.test index 85f72e633dc..e0c5b666c32 100644 --- a/mysql-test/suite/galera/t/galera_var_dirty_reads.test +++ b/mysql-test/suite/galera/t/galera_var_dirty_reads.test @@ -31,10 +31,10 @@ SHOW STATUS LIKE 'wsrep_ready'; # Must return 'Disconnected' SHOW STATUS LIKE 'wsrep_cluster_status'; ---error ER_UNKNOWN_COM_ERROR,1047 +--error ER_UNKNOWN_COM_ERROR SELECT * FROM t1; ---error ER_UNKNOWN_COM_ERROR,1047 +--error ER_UNKNOWN_COM_ERROR SELECT 1 FROM t1; SET @@session.wsrep_dirty_reads=ON; @@ -46,7 +46,7 @@ SELECT i, variable_name, variable_value FROM t1, information_schema.session_vari SET @@session.wsrep_dirty_reads=OFF; ---error ER_UNKNOWN_COM_ERROR,1047 +--error ER_UNKNOWN_COM_ERROR SELECT i, variable_name, variable_value FROM t1, information_schema.session_variables WHERE variable_name LIKE "wsrep_dirty_reads" AND i = 1; diff --git a/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_A.result b/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_A.result index a60e2bbb6cc..1813607517a 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_A.result +++ b/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_A.result @@ -1,6 +1,9 @@ connection node_2; connection node_1; connection node_1; +connection node_2; +connection node_3; +connection node_1; CREATE TABLE t1 (pk INT PRIMARY KEY, node INT) ENGINE=innodb; INSERT INTO t1 VALUES (1, 1); connection node_2; diff --git a/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_A.test b/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_A.test index 2248ff5014a..aa264eb8047 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_A.test +++ b/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_A.test @@ -15,6 +15,11 @@ --let $galera_server_number = 3 --source include/galera_connect.inc +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--source ../galera/include/auto_increment_offset_save.inc + --connection node_1 --let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --source include/wait_condition.inc @@ -260,3 +265,5 @@ call mtr.add_suppression("WSREP: Rejecting JOIN message from \(.*\): new State T --connection node_3 call mtr.add_suppression("WSREP: Rejecting JOIN message from \(.*\): new State Transfer required."); + +--source ../galera/include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera_3nodes_sr/disabled.def b/mysql-test/suite/galera_3nodes_sr/disabled.def index 900b27860a5..f1ec92eee79 100644 --- a/mysql-test/suite/galera_3nodes_sr/disabled.def +++ b/mysql-test/suite/galera_3nodes_sr/disabled.def @@ -1,4 +1,3 @@ -GCF-336 : GCF-582 : GCF-810A : GCF-810B : diff --git a/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result b/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result index bb6c11edf36..eeccfa3b5a3 100644 --- a/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result +++ b/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result @@ -1,11 +1,17 @@ +connection node_2; +connection node_1; +connection node_2; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; SET SESSION wsrep_trx_fragment_size = 1; SET AUTOCOMMIT=OFF; START TRANSACTION; INSERT INTO t1 VALUES (1); +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2a; SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log; COUNT(*) > 0 1 +connection node_1; SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log; COUNT(*) > 0 1 @@ -13,14 +19,19 @@ SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT COUNT(*) > 0 FROM t1; COUNT(*) > 0 1 +connection node_2a; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; SET SESSION wsrep_sync_wait=0; +connection node_2; INSERT INTO t1 VALUES (2); ERROR 40001: Deadlock found when trying to get lock; try restarting transaction COMMIT; ERROR 08S01: WSREP has not yet prepared node for application use +connection node_2a; SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; DROP TABLE t1; CALL mtr.add_suppression("replication aborted"); CALL mtr.add_suppression("WSREP: fragment replication failed: 3"); CALL mtr.add_suppression("WSREP: failed to send SR rollback for "); +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; +connection node_3; diff --git a/mysql-test/suite/innodb/r/innodb_ctype_tis620.result b/mysql-test/suite/innodb/r/innodb_ctype_tis620.result index bea188af08f..cf15d1232aa 100644 --- a/mysql-test/suite/innodb/r/innodb_ctype_tis620.result +++ b/mysql-test/suite/innodb/r/innodb_ctype_tis620.result @@ -26,3 +26,69 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# Start of 10.4 tests +# +# +# MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +# +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(8), KEY(a)) ENGINE=InnoDB COLLATE tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +DROP TABLE t1; +# +# MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +# +CREATE TABLE t1 (a INT KEY,b INT,c CHAR,KEY(b),KEY(c)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,4,4); +DROP TABLE t1; +CREATE TABLE t1 (C1 CHAR KEY,B1 BIT,B2 BIT,C2 CHAR DEFAULT'') ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +SELECT HEX(c1),HEX (c2) FROM t1 WHERE c1>=''AND c1<''AND c2=''LIMIT 2; +HEX(c1) HEX (c2) +DROP TABLE t1; +SET sql_mode=''; +CREATE TABLE t1 (a INT UNSIGNED,b INT,c CHAR(1),d BINARY (1),e VARCHAR(1),f VARBINARY(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (4386060749083099108,157,0,0,0,0,0,0,12); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES (104,15158706241929488558,0,0,0,0,0,0,13); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 +SELECT GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) FROM t1; +GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) +4294967295157,1042147483647 +DROP TABLE t1; +SET sql_mode=DEFAULT; +CREATE TABLE t1 (a CHAR(9),b CHAR(7)) COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0); +ALTER TABLE t1 ADD INDEX kb (b),ADD INDEX kab (a,b),ALGORITHM=INPLACE; +DROP TABLE t1; +SET sql_mode=''; +CREATE TABLE t1 (a INT UNSIGNED,b INT UNSIGNED,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (15842995496588415350,5339224446865937973,0,0,0,0,0,0,4); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +INSERT INTO t1 VALUES (8118894032862615316,5299008984764990929,0,0,0,0,0,0,1); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'b' at row 1 +SELECT GROUP_CONCAT(DISTINCT a,c ORDER BY a) FROM t1; +GROUP_CONCAT(DISTINCT a,c ORDER BY a) +42949672950 +DROP TABLE t1; +SET sql_mode=DEFAULT; +CREATE TABLE t1 (a CHAR,b CHAR,KEY(a,b)) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (0,0); +DROP TABLE t1; +CREATE TABLE t1 (a CHAR,b CHAR) COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0,0); +SELECT a,SUM(DISTINCT a),MIN(b) FROM t1 GROUP BY a; +a SUM(DISTINCT a) MIN(b) +0 0 0 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR,KEY(a)) ENGINE=InnoDB COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0); +DROP TABLE t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/suite/innodb/t/innodb_ctype_tis620.test b/mysql-test/suite/innodb/t/innodb_ctype_tis620.test index 4bab0fe9561..b0e9f42cc5a 100644 --- a/mysql-test/suite/innodb/t/innodb_ctype_tis620.test +++ b/mysql-test/suite/innodb/t/innodb_ctype_tis620.test @@ -27,3 +27,65 @@ DROP TABLE t1; --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-27670 Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +--echo # + +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(8), KEY(a)) ENGINE=InnoDB COLLATE tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +DROP TABLE t1; + +--echo # +--echo # MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +--echo # + +CREATE TABLE t1 (a INT KEY,b INT,c CHAR,KEY(b),KEY(c)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,4,4); +DROP TABLE t1; + +CREATE TABLE t1 (C1 CHAR KEY,B1 BIT,B2 BIT,C2 CHAR DEFAULT'') ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +SELECT HEX(c1),HEX (c2) FROM t1 WHERE c1>=''AND c1<''AND c2=''LIMIT 2; +DROP TABLE t1; + +SET sql_mode=''; +CREATE TABLE t1 (a INT UNSIGNED,b INT,c CHAR(1),d BINARY (1),e VARCHAR(1),f VARBINARY(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (4386060749083099108,157,0,0,0,0,0,0,12); +INSERT INTO t1 VALUES (104,15158706241929488558,0,0,0,0,0,0,13); +SELECT GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) FROM t1; +DROP TABLE t1; +SET sql_mode=DEFAULT; + +CREATE TABLE t1 (a CHAR(9),b CHAR(7)) COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0); +ALTER TABLE t1 ADD INDEX kb (b),ADD INDEX kab (a,b),ALGORITHM=INPLACE; +DROP TABLE t1; + +SET sql_mode=''; +CREATE TABLE t1 (a INT UNSIGNED,b INT UNSIGNED,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (15842995496588415350,5339224446865937973,0,0,0,0,0,0,4); +INSERT INTO t1 VALUES (8118894032862615316,5299008984764990929,0,0,0,0,0,0,1); +SELECT GROUP_CONCAT(DISTINCT a,c ORDER BY a) FROM t1; +DROP TABLE t1; +SET sql_mode=DEFAULT; + +CREATE TABLE t1 (a CHAR,b CHAR,KEY(a,b)) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB; +INSERT INTO t1 VALUES (0,0); +DROP TABLE t1; + +CREATE TABLE t1 (a CHAR,b CHAR) COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0,0); +SELECT a,SUM(DISTINCT a),MIN(b) FROM t1 GROUP BY a; +DROP TABLE t1; + +CREATE TABLE t1 (a CHAR,KEY(a)) ENGINE=InnoDB COLLATE=tis620_thai_nopad_ci; +INSERT INTO t1 VALUES (0); +DROP TABLE t1; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/suite/parts/r/part_ctype_tis620.result b/mysql-test/suite/parts/r/part_ctype_tis620.result new file mode 100644 index 00000000000..48a8a95f40e --- /dev/null +++ b/mysql-test/suite/parts/r/part_ctype_tis620.result @@ -0,0 +1,47 @@ +# +# MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +# +CREATE TABLE t1 ( +a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN (''), +PARTITION p VALUES LESS THAN ('') +); +ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +CREATE TABLE t1 ( +a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN (''), +PARTITION p VALUES LESS THAN (' ') +); +ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +CREATE TABLE t1 ( +a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( +PARTITION p0 VALUES LESS THAN (' '), +PARTITION p VALUES LESS THAN ('') +); +ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition +CREATE TABLE t1 +( +id INT NOT NULL, +data VARCHAR(2), +KEY data_id (data(1),id) +) COLLATE tis620_thai_nopad_ci ENGINE=MyISAM +PARTITION BY RANGE (id) +( +PARTITION p10 VALUES LESS THAN (10), +PARTITION p20 VALUES LESS THAN (20) +); +INSERT INTO t1 VALUES (4, 'ab'), (14, 'ab'), (19,''),(9,'') ; +SELECT id FROM t1 WHERE data='' ORDER BY id; +id +9 +19 +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/part_ctype_tis620.test b/mysql-test/suite/parts/t/part_ctype_tis620.test new file mode 100644 index 00000000000..2e5bcd651b1 --- /dev/null +++ b/mysql-test/suite/parts/t/part_ctype_tis620.test @@ -0,0 +1,52 @@ +--source include/have_partition.inc +--source include/have_tis620.inc + +--echo # +--echo # MDEV-27768 MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit +--echo # + +--error ER_RANGE_NOT_INCREASING_ERROR +CREATE TABLE t1 ( + a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( + PARTITION p0 VALUES LESS THAN (''), + PARTITION p VALUES LESS THAN ('') +); + +--error ER_RANGE_NOT_INCREASING_ERROR +CREATE TABLE t1 ( + a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( + PARTITION p0 VALUES LESS THAN (''), + PARTITION p VALUES LESS THAN (' ') +); + +--error ER_RANGE_NOT_INCREASING_ERROR +CREATE TABLE t1 ( + a CHAR +) COLLATE=tis620_thai_nopad_ci +PARTITION BY RANGE COLUMNS (a) +( + PARTITION p0 VALUES LESS THAN (' '), + PARTITION p VALUES LESS THAN ('') +); + + +CREATE TABLE t1 +( + id INT NOT NULL, + data VARCHAR(2), + KEY data_id (data(1),id) +) COLLATE tis620_thai_nopad_ci ENGINE=MyISAM +PARTITION BY RANGE (id) +( + PARTITION p10 VALUES LESS THAN (10), + PARTITION p20 VALUES LESS THAN (20) +); +INSERT INTO t1 VALUES (4, 'ab'), (14, 'ab'), (19,''),(9,'') ; +SELECT id FROM t1 WHERE data='' ORDER BY id; +DROP TABLE t1; diff --git a/mysql-test/suite/period/r/create.result b/mysql-test/suite/period/r/create.result index dcae15c0772..e5fa2d1797d 100644 --- a/mysql-test/suite/period/r/create.result +++ b/mysql-test/suite/period/r/create.result @@ -100,3 +100,14 @@ show status like "Feature_application_time_periods"; Variable_name Value Feature_application_time_periods 6 drop table t; +# MDEV-29387: Period name with more than 32 symbols crashes the server +# +# test 34 symbols +create table t2 (s date, e date, +period for `abcd123456789012345678901234567890` (s,e)); +drop table t2; +# test 64 symbols +create table t2 (s date, e date, period for +`abcd123456789012345678901234567890123456789012345678901234567890` + (s,e)); +drop table t2; diff --git a/mysql-test/suite/period/r/delete.result b/mysql-test/suite/period/r/delete.result index 1954c0fdf81..55ddfac13fb 100644 --- a/mysql-test/suite/period/r/delete.result +++ b/mysql-test/suite/period/r/delete.result @@ -393,3 +393,27 @@ insert into t1 values (1,'2020-01-01','2020-02-20'); delete from t1 for portion of se from '2020-01-30' to '2020-01-31'; drop table t1; # End of 10.5 tests +# +# MDEV-19190 Assertion `part_share->auto_inc_initialized` failed in +# ha_partition::get_auto_increment +# +create table t1 (id int, s date, e date, period for app(s,e)) +partition by key(id); +insert into t1 (s,e) values ('2023-07-21','2024-06-07'); +alter table t1 modify id int auto_increment key; +delete from t1 for portion of app from '2023-07-20' to '2024-05-23'; +select * from t1; +id s e +2 2024-05-23 2024-06-07 +drop table t1; +create table t1 (id int, s date, e date, period for app(s,e)) +partition by key(id); +insert into t1 (s,e) values ('2023-07-21','2024-06-07'); +alter table t1 modify id int auto_increment key; +delete from t1 for portion of app from '2023-07-20' to '2024-05-23'; +select * from t1; +id s e +2 2024-05-23 2024-06-07 +drop table t1; +drop table log_tbl; +drop procedure log; diff --git a/mysql-test/suite/period/t/create.test b/mysql-test/suite/period/t/create.test index 49dcc6ad3c7..0bca5b6df56 100644 --- a/mysql-test/suite/period/t/create.test +++ b/mysql-test/suite/period/t/create.test @@ -85,3 +85,17 @@ insert t values (2, '2001-01-01', '2001-01-01'); show status like "Feature_application_time_periods"; drop table t; + +--echo # MDEV-29387: Period name with more than 32 symbols crashes the server +--echo # + +--echo # test 34 symbols +create table t2 (s date, e date, + period for `abcd123456789012345678901234567890` (s,e)); +drop table t2; + +--echo # test 64 symbols +create table t2 (s date, e date, period for + `abcd123456789012345678901234567890123456789012345678901234567890` + (s,e)); +drop table t2; diff --git a/mysql-test/suite/period/t/delete.test b/mysql-test/suite/period/t/delete.test index 91670469bab..6739487d9a4 100644 --- a/mysql-test/suite/period/t/delete.test +++ b/mysql-test/suite/period/t/delete.test @@ -1,5 +1,6 @@ source suite/period/engines.inc; source include/have_log_bin.inc; +source include/have_partition.inc; create table t (id int, s date, e date, period for apptime(s,e)); @@ -235,3 +236,30 @@ delete from t1 for portion of se from '2020-01-30' to '2020-01-31'; drop table t1; --echo # End of 10.5 tests +--echo # +--echo # MDEV-19190 Assertion `part_share->auto_inc_initialized` failed in +--echo # ha_partition::get_auto_increment +--echo # +create table t1 (id int, s date, e date, period for app(s,e)) + partition by key(id); +insert into t1 (s,e) values ('2023-07-21','2024-06-07'); +alter table t1 modify id int auto_increment key; +delete from t1 for portion of app from '2023-07-20' to '2024-05-23'; +select * from t1; +drop table t1; + +create table t1 (id int, s date, e date, period for app(s,e)) + partition by key(id); +insert into t1 (s,e) values ('2023-07-21','2024-06-07'); +alter table t1 modify id int auto_increment key; +--let $trig_table=t1 +--let $trig_cols=id, s, e +--disable_query_log +--source suite/period/create_triggers.inc +--enable_query_log + +delete from t1 for portion of app from '2023-07-20' to '2024-05-23'; +select * from t1; +drop table t1; +drop table log_tbl; +drop procedure log; diff --git a/sql/handler.cc b/sql/handler.cc index 5942eca6698..49f49002eff 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4211,7 +4211,7 @@ void handler::print_error(int error, myf errflag) break; case HA_ERR_AUTOINC_ERANGE: textno= error; - my_error(textno, errflag, table->next_number_field->field_name.str, + my_error(textno, errflag, table->found_next_number_field->field_name.str, table->in_use->get_stmt_da()->current_row_for_warning()); DBUG_VOID_RETURN; break; diff --git a/sql/slave.cc b/sql/slave.cc index 33a382edc47..715fa8cd69e 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -7281,9 +7281,9 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, mi->ssl_ca[0]?mi->ssl_ca:0, mi->ssl_capath[0]?mi->ssl_capath:0, mi->ssl_cipher[0]?mi->ssl_cipher:0); - mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, - &mi->ssl_verify_server_cert); - mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, + mysql_options(mysql, MYSQL_OPT_SSL_CRL, + mi->ssl_crl[0] ? mi->ssl_crl : 0); + mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, mi->ssl_crlpath[0] ? mi->ssl_crlpath : 0); mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &mi->ssl_verify_server_cert); diff --git a/sql/sql_const.h b/sql/sql_const.h index 3f053a1606d..b2548b4ef8c 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -29,7 +29,7 @@ /* extra 4+4 bytes for slave tmp tables */ #define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4) #define MAX_ALIAS_NAME 256 -#define MAX_FIELD_NAME 34 /* Max colum name length +2 */ +#define MAX_FIELD_NAME (NAME_LEN+1) /* Max colum name length +1 */ #define MAX_SYS_VAR_LENGTH 32 #define MAX_KEY MAX_INDEXES /* Max used keys */ #define MAX_REF_PARTS 32 /* Max parts used as ref */ diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 4c359955dbe..e628ce60d2d 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -693,6 +693,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { table->use_all_columns(); table->rpl_write_set= table->write_set; + // Initialize autoinc. + // We don't set next_number_field here, as it is handled manually. + if (table->found_next_number_field) + table->file->info(HA_STATUS_AUTO); } else { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index faaab33a589..64be8f937e5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1158,7 +1158,7 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables) if (get_table_category(&db, &tn) < TABLE_CATEGORY_INFORMATION) return false; } - return true; + return tables != NULL; } static bool wsrep_command_no_result(char command) @@ -3758,6 +3758,8 @@ mysql_execute_command(THD *thd) (sql_command_flags[lex->sql_command] & CF_CHANGES_DATA) == 0) && !wsrep_tables_accessible_when_detached(all_tables) && lex->sql_command != SQLCOM_SET_OPTION && + lex->sql_command != SQLCOM_CHANGE_DB && + !(lex->sql_command == SQLCOM_SELECT && !all_tables) && !wsrep_is_show_query(lex->sql_command)) { my_message(ER_UNKNOWN_COM_ERROR, diff --git a/sql/table.cc b/sql/table.cc index c99608c6cde..7da22a058ab 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8913,6 +8913,7 @@ int TABLE::update_generated_fields() res= found_next_number_field->set_default(); if (likely(!res)) res= file->update_auto_increment(); + next_number_field= NULL; } if (likely(!res) && vfield) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 3e3b7ec5150..3205b2dfa21 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -127,6 +127,7 @@ ulong wsrep_trx_fragment_unit= WSREP_FRAG_BYTES; ulong wsrep_SR_store_type= WSREP_SR_STORE_TABLE; uint wsrep_ignore_apply_errors= 0; +std::atomic wsrep_thread_create_failed; /* * End configuration options @@ -3143,7 +3144,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len) void* start_wsrep_THD(void *arg) { - THD *thd; + THD *thd= NULL; Wsrep_thd_args* thd_args= (Wsrep_thd_args*) arg; @@ -3174,6 +3175,7 @@ void* start_wsrep_THD(void *arg) mysql_thread_set_psi_id(thd->thread_id); thd->thr_create_utime= microsecond_interval_timer(); + DBUG_EXECUTE_IF("wsrep_simulate_failed_connection_1", goto error; ); // /* handle_one_connection() is normally the only way a thread would @@ -3280,6 +3282,18 @@ void* start_wsrep_THD(void *arg) error: WSREP_ERROR("Failed to create/initialize system thread"); + if (thd) + { + close_connection(thd, ER_OUT_OF_RESOURCES); + statistic_increment(aborted_connects, &LOCK_status); + server_threads.erase(thd); + delete thd; + my_thread_end(); + } + delete thd_args; + // This will signal error to wsrep_slave_threads_update + wsrep_thread_create_failed.store(true, std::memory_order_relaxed); + /* Abort if its the first applier/rollbacker thread. */ if (!mysqld_server_initialized) unireg_abort(1); diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 2437a823df4..2061802afbd 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -90,6 +90,7 @@ extern bool wsrep_new_cluster; extern bool wsrep_gtid_mode; extern my_bool wsrep_strict_ddl; extern uint32 wsrep_gtid_domain_id; +extern std::atomic wsrep_thread_create_failed; enum enum_wsrep_reject_types { WSREP_REJECT_NONE, /* nothing rejected */ diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 915c7bbb5a5..fbca4a76b66 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -23,8 +23,7 @@ #include "rpl_rli.h" #include "log_event.h" #include "sql_parse.h" -#include "mysqld.h" // start_wsrep_THD(); -#include "wsrep_applier.h" // start_wsrep_THD(); +#include "wsrep_mysqld.h" // start_wsrep_THD(); #include "mysql/service_wsrep.h" #include "debug_sync.h" #include "slave.h" diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index ff687975d0a..f6a7e25b945 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -801,18 +801,25 @@ bool wsrep_slave_threads_update (sys_var *self, THD* thd, enum_var_type type) if (wsrep_slave_count_change > 0) { WSREP_DEBUG("Creating %d applier threads, total %ld", wsrep_slave_count_change, wsrep_slave_threads); + wsrep_thread_create_failed.store(false, std::memory_order_relaxed); res= wsrep_create_appliers(wsrep_slave_count_change, true); mysql_mutex_unlock(&LOCK_global_system_variables); mysql_mutex_unlock(&LOCK_wsrep_slave_threads); // Thread creation and execution is asyncronous, therefore we need // wait them to be started or error produced - while (wsrep_running_applier_threads != (ulong)wsrep_slave_threads) + while (wsrep_running_applier_threads != (ulong)wsrep_slave_threads && + !wsrep_thread_create_failed.load(std::memory_order_relaxed)) { my_sleep(1000); } mysql_mutex_lock(&LOCK_global_system_variables); + if (wsrep_thread_create_failed.load(std::memory_order_relaxed)) { + wsrep_slave_threads= wsrep_running_applier_threads; + return true; + } + WSREP_DEBUG("Running %lu applier threads", wsrep_running_applier_threads); wsrep_slave_count_change = 0; } diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index b6ac880dc9f..e6f6ad24eec 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -587,6 +587,18 @@ ret: } +static int +my_strnncollsp_nchars_tis620(CHARSET_INFO * cs, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, + size_t nchars) +{ + set_if_smaller(a_length, nchars); + set_if_smaller(b_length, nchars); + return my_strnncollsp_tis620(cs, a, a_length, b, b_length); +} + + static int my_strnncollsp_tis620_nopad(CHARSET_INFO * cs __attribute__((unused)), const uchar *a0, size_t a_length, @@ -854,7 +866,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = NULL, /* init */ my_strnncoll_tis620, my_strnncollsp_tis620, - my_strnncollsp_nchars_generic_8bit, + my_strnncollsp_nchars_tis620, my_strnxfrm_tis620, my_strnxfrmlen_simple, my_like_range_simple, @@ -870,7 +882,7 @@ static MY_COLLATION_HANDLER my_collation_nopad_ci_handler = NULL, /* init */ my_strnncoll_tis620, my_strnncollsp_tis620_nopad, - my_strnncollsp_nchars_generic_8bit, + my_strnncollsp_nchars_tis620, my_strnxfrm_tis620_nopad, my_strnxfrmlen_simple, my_like_range_simple, diff --git a/unittest/strings/strings-t.c b/unittest/strings/strings-t.c index 773e90bee78..e28e498b6bb 100644 --- a/unittest/strings/strings-t.c +++ b/unittest/strings/strings-t.c @@ -1215,6 +1215,7 @@ test_strnncollsp_char() #ifdef HAVE_CHARSET_tis620 failed+= strnncollsp_char_mbminlen1("tis620_thai_ci", NULL); + failed+= strnncollsp_char_mbminlen1("tis620_thai_nopad_ci", NULL); #endif #ifdef HAVE_CHARSET_big5 diff --git a/wsrep-lib b/wsrep-lib index 8bfce041896..f8ff2cfdd4c 160000 --- a/wsrep-lib +++ b/wsrep-lib @@ -1 +1 @@ -Subproject commit 8bfce04189671eb1f06e0fa83dff8c880f31088f +Subproject commit f8ff2cfdd4c6424ffd96fc53bcc0f2e1d9ffe137 From 072b3668ca6ef3c32817536e3f9f922f8cda6175 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 29 Nov 2022 15:19:37 +1100 Subject: [PATCH 16/21] MDEV-28206: SIGSEGV in Item_field::fix_fields when using LEAD...OVER thd->lex->in_sum_func->max_arg_level cannot be set to a bigger value of select->nest_level if select is null. --- mysql-test/main/win.result | 24 ++++++++++++++++ mysql-test/main/win.test | 28 +++++++++++++++++++ .../encryption/r/tempfiles_encrypted.result | 24 ++++++++++++++++ sql/item.cc | 1 + 4 files changed, 77 insertions(+) diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 0874e5b9a24..3e130c9653e 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -4352,3 +4352,27 @@ row_number() OVER (order by a) 2 3 drop table t1; +# +# MDEV-28206 SIGSEGV in Item_field::fix_fields when using LEAD...OVER +# +CREATE TABLE t(c1 INT); +CREATE FUNCTION f() RETURNS INT READS SQL DATA BEGIN +DECLARE v INT; +SELECT 1 INTO v FROM (SELECT c1,COALESCE(LEAD(a2.c1) OVER (PARTITION BY a2.c1 ORDER BY a2.c1),a2.c1) AS a1 FROM (t a2 JOIN t a3 USING (c1))) a4; +RETURN 1; +END// +SELECT f(),f(); +f() f() +1 1 +EXECUTE IMMEDIATE "SELECT LEAD(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;"; +LEAD(c1) OVER (ORDER BY c1) +EXECUTE IMMEDIATE "SELECT SUM(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;"; +SUM(c1) OVER (ORDER BY c1) +EXECUTE IMMEDIATE "SELECT LEAD(c) OVER (ORDER BY c) FROM (SELECT 1 AS c) AS a NATURAL JOIN (SELECT 1 AS c) AS b;"; +LEAD(c) OVER (ORDER BY c) +NULL +DROP FUNCTION f; +DROP TABLE t; +# +# End of 10.6 tests +# diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test index 5a216123369..d7f52ec32e9 100644 --- a/mysql-test/main/win.test +++ b/mysql-test/main/win.test @@ -2829,3 +2829,31 @@ create table t1 (a int); insert into t1 values (1),(2),(3); SELECT row_number() OVER (order by a) FROM t1 order by NAME_CONST('myname',NULL); drop table t1; + +--echo # +--echo # MDEV-28206 SIGSEGV in Item_field::fix_fields when using LEAD...OVER +--echo # + +CREATE TABLE t(c1 INT); + +DELIMITER //; +CREATE FUNCTION f() RETURNS INT READS SQL DATA BEGIN + DECLARE v INT; + SELECT 1 INTO v FROM (SELECT c1,COALESCE(LEAD(a2.c1) OVER (PARTITION BY a2.c1 ORDER BY a2.c1),a2.c1) AS a1 FROM (t a2 JOIN t a3 USING (c1))) a4; + RETURN 1; +END// +DELIMITER ;// + +SELECT f(),f(); + +EXECUTE IMMEDIATE "SELECT LEAD(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;"; +EXECUTE IMMEDIATE "SELECT SUM(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;"; + +EXECUTE IMMEDIATE "SELECT LEAD(c) OVER (ORDER BY c) FROM (SELECT 1 AS c) AS a NATURAL JOIN (SELECT 1 AS c) AS b;"; + +DROP FUNCTION f; +DROP TABLE t; + +--echo # +--echo # End of 10.6 tests +--echo # diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index fb4738a1fed..2b91cd638e2 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -4359,6 +4359,30 @@ row_number() OVER (order by a) 3 drop table t1; # +# MDEV-28206 SIGSEGV in Item_field::fix_fields when using LEAD...OVER +# +CREATE TABLE t(c1 INT); +CREATE FUNCTION f() RETURNS INT READS SQL DATA BEGIN +DECLARE v INT; +SELECT 1 INTO v FROM (SELECT c1,COALESCE(LEAD(a2.c1) OVER (PARTITION BY a2.c1 ORDER BY a2.c1),a2.c1) AS a1 FROM (t a2 JOIN t a3 USING (c1))) a4; +RETURN 1; +END// +SELECT f(),f(); +f() f() +1 1 +EXECUTE IMMEDIATE "SELECT LEAD(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;"; +LEAD(c1) OVER (ORDER BY c1) +EXECUTE IMMEDIATE "SELECT SUM(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;"; +SUM(c1) OVER (ORDER BY c1) +EXECUTE IMMEDIATE "SELECT LEAD(c) OVER (ORDER BY c) FROM (SELECT 1 AS c) AS a NATURAL JOIN (SELECT 1 AS c) AS b;"; +LEAD(c) OVER (ORDER BY c) +NULL +DROP FUNCTION f; +DROP TABLE t; +# +# End of 10.6 tests +# +# # MDEV-23867: select crash in compute_window_func # set @save_sort_buffer_size=@@sort_buffer_size; diff --git a/sql/item.cc b/sql/item.cc index 91bc175ca13..a63ac1f1119 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6114,6 +6114,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) if (!thd->lex->current_select->no_wrap_view_item && thd->lex->in_sum_func && + select && thd->lex == select->parent_lex && thd->lex->in_sum_func->nest_level == select->nest_level) From dd20a43c6cb59a2ba69124cf51e22e08ca16f858 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 2 Dec 2022 11:54:35 +0530 Subject: [PATCH 17/21] MDEV-30114 Incremental prepare fails when innodb_undo_tablespaces > 0 - Mariabackup fails to open the undo tablespaces while applying delta files to the corresponding data file. Mariabackup opens the undo tablespaces first time in srv_undo_tablespaces_init() and does tries to open the undo tablespaces in xtrabackup_apply_deltas() with conflicting mode and leads to the failure. - Mariabackup should close the undo tablespaces before applying the incremental delta files. --- extra/mariabackup/xtrabackup.cc | 20 +++++++++++++++++++ .../mariabackup/apply-log-only-incr.test | 1 + .../suite/mariabackup/incremental_backup.test | 1 + .../mariabackup/incremental_compressed.test | 1 + .../incremental_ddl_before_backup.test | 1 + .../incremental_ddl_during_backup.test | 1 + .../mariabackup/incremental_encrypted.test | 1 + .../incremental_newdb_while_backup.test | 1 + .../mariabackup/log_page_corruption.test | 1 + .../suite/mariabackup/unsupported_redo.test | 1 + .../suite/mariabackup/xb_partition.test | 1 + 11 files changed, 30 insertions(+) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 3f7dec5ceda..d41321e9bb9 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3799,6 +3799,21 @@ func_exit: return error; } +/** Close all undo tablespaces while applying incremental delta */ +static void xb_close_undo_tablespaces() +{ + if (srv_undo_space_id_start == 0) + return; + for (ulint space_id= srv_undo_space_id_start; + space_id < srv_undo_space_id_start + srv_undo_tablespaces_open; + space_id++) + { + fil_space_t *space= fil_space_get(space_id); + ut_ad(space); + space->close(); + } +} + /**************************************************************************** Populates the tablespace memory cache by scanning for and opening data files. @returns DB_SUCCESS or error code.*/ @@ -3861,6 +3876,11 @@ xb_load_tablespaces() if (err != DB_SUCCESS) { return(err); } + + if (srv_operation == SRV_OPERATION_RESTORE_DELTA) { + xb_close_undo_tablespaces(); + } + DBUG_MARIABACKUP_EVENT("after_load_tablespaces", 0); return(DB_SUCCESS); } diff --git a/mysql-test/suite/mariabackup/apply-log-only-incr.test b/mysql-test/suite/mariabackup/apply-log-only-incr.test index c2d23c88a3e..b110d12540e 100644 --- a/mysql-test/suite/mariabackup/apply-log-only-incr.test +++ b/mysql-test/suite/mariabackup/apply-log-only-incr.test @@ -1,4 +1,5 @@ --source include/have_innodb.inc +--source include/innodb_undo_tablespaces.inc call mtr.add_suppression("InnoDB: New log files created"); diff --git a/mysql-test/suite/mariabackup/incremental_backup.test b/mysql-test/suite/mariabackup/incremental_backup.test index ddcdae4637a..7f4bdc8bff0 100644 --- a/mysql-test/suite/mariabackup/incremental_backup.test +++ b/mysql-test/suite/mariabackup/incremental_backup.test @@ -1,5 +1,6 @@ --source include/have_aria.inc --source include/innodb_page_size.inc +--source include/innodb_undo_tablespaces.inc # see suite.pm "check for exact values, in case the default changes to be small everywhere" if (`select @@max_binlog_stmt_cache_size = 4294963200 and @@innodb_page_size = 65536`) { diff --git a/mysql-test/suite/mariabackup/incremental_compressed.test b/mysql-test/suite/mariabackup/incremental_compressed.test index 32607d57174..15aff909a43 100644 --- a/mysql-test/suite/mariabackup/incremental_compressed.test +++ b/mysql-test/suite/mariabackup/incremental_compressed.test @@ -1,5 +1,6 @@ --source include/have_innodb.inc --source include/have_partition.inc +--source include/innodb_undo_tablespaces.inc let $basedir=$MYSQLTEST_VARDIR/tmp/backup; let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; diff --git a/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test index f243ac1acd9..6d34166d7b5 100644 --- a/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test +++ b/mysql-test/suite/mariabackup/incremental_ddl_before_backup.test @@ -1,4 +1,5 @@ --source include/have_debug.inc +--source include/innodb_undo_tablespaces.inc call mtr.add_suppression("InnoDB: New log files created"); diff --git a/mysql-test/suite/mariabackup/incremental_ddl_during_backup.test b/mysql-test/suite/mariabackup/incremental_ddl_during_backup.test index ebdb2137523..d90ee1566a8 100644 --- a/mysql-test/suite/mariabackup/incremental_ddl_during_backup.test +++ b/mysql-test/suite/mariabackup/incremental_ddl_during_backup.test @@ -1,4 +1,5 @@ --source include/have_debug.inc +--source include/innodb_undo_tablespaces.inc call mtr.add_suppression("InnoDB: New log files created"); diff --git a/mysql-test/suite/mariabackup/incremental_encrypted.test b/mysql-test/suite/mariabackup/incremental_encrypted.test index e618ac4f79e..d5570f20006 100644 --- a/mysql-test/suite/mariabackup/incremental_encrypted.test +++ b/mysql-test/suite/mariabackup/incremental_encrypted.test @@ -1,4 +1,5 @@ --source include/innodb_page_size.inc +--source include/innodb_undo_tablespaces.inc if (!$EXAMPLE_KEY_MANAGEMENT_SO) { diff --git a/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test index c4695edb845..6bd69712ed7 100644 --- a/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test +++ b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test @@ -1,5 +1,6 @@ --source include/have_innodb.inc --source include/have_debug.inc +--source include/innodb_undo_tablespaces.inc call mtr.add_suppression("InnoDB: New log files created"); diff --git a/mysql-test/suite/mariabackup/log_page_corruption.test b/mysql-test/suite/mariabackup/log_page_corruption.test index e14735fd024..0bffb406b7e 100644 --- a/mysql-test/suite/mariabackup/log_page_corruption.test +++ b/mysql-test/suite/mariabackup/log_page_corruption.test @@ -1,5 +1,6 @@ --source include/have_debug.inc --source include/no_valgrind_without_big.inc +--source include/innodb_undo_tablespaces.inc --echo ######## --echo # Test for generating "innodb_corrupted_pages" file during full and diff --git a/mysql-test/suite/mariabackup/unsupported_redo.test b/mysql-test/suite/mariabackup/unsupported_redo.test index b9456751b9c..3dd5fd0db47 100644 --- a/mysql-test/suite/mariabackup/unsupported_redo.test +++ b/mysql-test/suite/mariabackup/unsupported_redo.test @@ -1,4 +1,5 @@ --source include/have_innodb.inc +--source include/innodb_undo_tablespaces.inc call mtr.add_suppression("InnoDB: New log files created"); call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation"); call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified"); diff --git a/mysql-test/suite/mariabackup/xb_partition.test b/mysql-test/suite/mariabackup/xb_partition.test index 3d027b67fc1..1c8eeaa19e6 100644 --- a/mysql-test/suite/mariabackup/xb_partition.test +++ b/mysql-test/suite/mariabackup/xb_partition.test @@ -1,5 +1,6 @@ #--source include/innodb_page_size.inc --source include/have_partition.inc +--source include/innodb_undo_tablespaces.inc CREATE TABLE t1(a INT) ENGINE=InnoDB; INSERT INTO t1 VALUES (1), (2), (3); From e0dbec1ce38688e25cab3720044d6e7e676381f6 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 2 Dec 2022 18:21:52 +0300 Subject: [PATCH 18/21] MDEV-29129: Performance regression starting in 10.6: select order by limit ... The cause of regression was handling for ROWNUM() function. For queries like SELECT ROWNUM() FROM ... ORDER BY ... ROWNUM() should be computed before the ORDER BY. The computation was moved to be before the ORDER BY for any entries in the select list that had RAND_TABLE_BIT set. This had a negative impact on queries in form: SELECT sp_func() FROM t1 ORDER BY ... LIMIT n where sp_func() is NOT declared as DETERMINISTIC (and so has RAND_TABLE_BIT set). The fix is to require evaluation for sorting only for the ROWNUM() function. Functions that just have RAND_TABLE_BIT() can be computed after ORDER BY ... LIMIT is applied. (think about a possible index that satisfies the ORDER BY clause. In that case, the the rows would be read in the needed order and we would stop after reading LIMIT rows, achieving the same effect). --- mysql-test/main/derived_view.result | 2 +- mysql-test/main/having.result | 6 ++--- mysql-test/main/show_explain.result | 6 ++--- mysql-test/main/sp.result | 40 +++++++++++++++++++++++++++++ mysql-test/main/sp.test | 37 ++++++++++++++++++++++++++ mysql-test/main/user_var.result | 4 +-- sql/sql_base.cc | 2 ++ sql/sql_lex.cc | 2 ++ sql/sql_lex.h | 3 +++ sql/sql_select.cc | 4 +-- sql/sql_select.h | 5 ---- 11 files changed, 94 insertions(+), 17 deletions(-) diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index 50f6d381dd6..15a7784c890 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -2696,7 +2696,7 @@ ON p.id = g.p_random ORDER BY gallery_name ASC ; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY ALL NULL NULL NULL NULL 10 Using temporary; Using filesort +1 PRIMARY ALL NULL NULL NULL NULL 10 Using filesort 1 PRIMARY p eq_ref PRIMARY PRIMARY 4 g.p_random 1 Using where 2 DERIVED gal ALL NULL NULL NULL NULL 10 3 DEPENDENT SUBQUERY pi ref gallery_id gallery_id 4 test.gal.id 4 Using temporary; Using filesort diff --git a/mysql-test/main/having.result b/mysql-test/main/having.result index ac26d69543d..d7cbadd5e75 100644 --- a/mysql-test/main/having.result +++ b/mysql-test/main/having.result @@ -834,13 +834,13 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK explain SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t) GROUP BY t HAVING r = 1 ORDER BY t1.u; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort +1 SIMPLE t1 index NULL t 5 NULL 8 Using temporary; Using filesort SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t) GROUP BY t HAVING r = 1 ORDER BY t1.u; t r 10 1 12 1 -14 1 -16 1 +15 1 +17 1 DROP TABLE t1; DROP FUNCTION next_seq_value; DROP TABLE series; diff --git a/mysql-test/main/show_explain.result b/mysql-test/main/show_explain.result index 317a12ef311..6ad93930448 100644 --- a/mysql-test/main/show_explain.result +++ b/mysql-test/main/show_explain.result @@ -1007,7 +1007,7 @@ SELECT a+SLEEP(0.01) FROM t1 WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129 ORDER BY b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 8 Using sort_union(a,b); Using where; Using temporary; Using filesort +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 8 Using sort_union(a,b); Using where; Using filesort set @show_explain_probe_select_id=1; SET debug_dbug='+d,show_explain_probe_join_exec_start'; SELECT a+SLEEP(0.01) FROM t1 @@ -1016,7 +1016,7 @@ ORDER BY b; connection default; show explain for $thr2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 8 Using sort_union(a,b); Using where; Using temporary; Using filesort +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 8 Using sort_union(a,b); Using where; Using filesort Warnings: Note 1003 SELECT a+SLEEP(0.01) FROM t1 WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129 @@ -1039,7 +1039,7 @@ ORDER BY b; connection default; show explain for $thr2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 8 Using sort_union(a,b); Using where; Using temporary; Using filesort +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 8 Using sort_union(a,b); Using where; Using filesort Warnings: Note 1003 SELECT a+SLEEP(0.01) FROM t1 WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129 diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index b14551d35c7..88df800b0e0 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -8932,3 +8932,43 @@ ERROR 42000: PROCEDURE does not support subqueries or stored functions DROP TABLE t1; # End of 10.4 tests # +# +# MDEV-29129: Performance regression starting in 10.6: unlimited "select order by limit" +# +CREATE TABLE t1 ( +lookupId int primary key, +value varchar(255) +); +insert into t1 select seq, seq from seq_1_to_100; +# Note: the function is intentionally NOT declared as DETERMINISTIC +CREATE FUNCTION f1(LOOKUPID_IN INT) RETURNS varchar(255) CHARSET utf8 +BEGIN +DECLARE LOOKUP_VALUE VARCHAR(255); +SET LOOKUP_VALUE = (SELECT value FROM t1 WHERE lookupId = LOOKUPID_IN); +set @counter=@counter+1; +RETURN LOOKUP_VALUE; +END; +// +create table t2 ( +col1 int, +col2 int +); +insert into t2 select mod(seq,100), seq from seq_1_to_1000; +explain +select f1(col1) from t2 order by col2 desc limit 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1000 Using filesort +set @counter=0; +select f1(col1) from t2 order by col2 desc limit 5; +f1(col1) +NULL +99 +98 +97 +96 +# Must show 5, not 1000: +select @counter; +@counter +5 +drop function f1; +drop table t1,t2; diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index b71cfe11d58..baf89eeaba5 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -10519,3 +10519,40 @@ DROP TABLE t1; --echo # End of 10.4 tests --echo # + +--echo # +--echo # MDEV-29129: Performance regression starting in 10.6: unlimited "select order by limit" +--echo # + +CREATE TABLE t1 ( + lookupId int primary key, + value varchar(255) +); +insert into t1 select seq, seq from seq_1_to_100; + +-- echo # Note: the function is intentionally NOT declared as DETERMINISTIC +delimiter //; +CREATE FUNCTION f1(LOOKUPID_IN INT) RETURNS varchar(255) CHARSET utf8 +BEGIN + DECLARE LOOKUP_VALUE VARCHAR(255); + SET LOOKUP_VALUE = (SELECT value FROM t1 WHERE lookupId = LOOKUPID_IN); + set @counter=@counter+1; + RETURN LOOKUP_VALUE; +END; +// +delimiter ;// + +create table t2 ( + col1 int, + col2 int +); +insert into t2 select mod(seq,100), seq from seq_1_to_1000; + +explain +select f1(col1) from t2 order by col2 desc limit 5; +set @counter=0; +select f1(col1) from t2 order by col2 desc limit 5; +--echo # Must show 5, not 1000: +select @counter; +drop function f1; +drop table t1,t2; diff --git a/mysql-test/main/user_var.result b/mysql-test/main/user_var.result index 924c252b951..a5837996c19 100644 --- a/mysql-test/main/user_var.result +++ b/mysql-test/main/user_var.result @@ -372,14 +372,14 @@ insert into t1 (b) values (10), (30), (10), (10); set @var := 0; explain select if(b=@var, 999, b) , @var := b from t1 order by b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort +1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort set @var := 0; select if(b=@var, 999, b) , @var := b from t1 order by b; if(b=@var, 999, b) @var := b 10 10 -10 10 30 30 999 10 +999 10 drop table t1; create temporary table t1 (id int); insert into t1 values (2), (3), (3), (4); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index dfca2500d6d..5de9782fd09 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7738,6 +7738,8 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, thd->lex->current_select->select_list_tables|= item->used_tables(); thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->cur_pos_in_select_list++; + + thd->lex->current_select->rownum_in_field_list |= item->with_rownum_func(); } thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 520982f93b6..b743141598f 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3002,6 +3002,8 @@ void st_select_lex::init_query() prep_leaf_list_state= UNINIT; bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used)); select_list_tables= 0; + rownum_in_field_list= 0; + window_specs.empty(); window_funcs.empty(); tvc= 0; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index e4fe1465c57..82453ad8259 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1344,6 +1344,9 @@ public: */ table_map select_list_tables; + /* Set to 1 if any field in field list has ROWNUM() */ + bool rownum_in_field_list; + /* namp of nesting SELECT visibility (for aggregate functions check) */ nesting_map name_visibility_map; table_map with_dep; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 60b2641e670..446f6e83b0d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -434,7 +434,6 @@ void JOIN::init(THD *thd_arg, List &fields_arg, no_order= 0; simple_order= 0; simple_group= 0; - rand_table_in_field_list= 0; ordered_index_usage= ordered_index_void; need_distinct= 0; skip_sort_order= 0; @@ -1434,7 +1433,6 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num, &all_fields, &select_lex->pre_fix, 1)) DBUG_RETURN(-1); thd->lex->current_select->context_analysis_place= save_place; - rand_table_in_field_list= select_lex->select_list_tables & RAND_TABLE_BIT; if (setup_without_group(thd, ref_ptrs, tables_list, select_lex->leaf_tables, fields_list, @@ -14807,7 +14805,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, and some wrong results so better to leave the code as it was related to ROLLUP. */ - *simple_order= !join->rand_table_in_field_list; + *simple_order= !join->select_lex->rownum_in_field_list; if (join->only_const_tables()) return change_list ? 0 : first_order; // No need to sort diff --git a/sql/sql_select.h b/sql/sql_select.h index c9e0fa25421..3332bc78b6c 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1420,11 +1420,6 @@ public: GROUP/ORDER BY. */ bool simple_order, simple_group; - /* - Set to 1 if any field in field list has RAND_TABLE set. For example if - if one uses RAND() or ROWNUM() in field list - */ - bool rand_table_in_field_list; /* ordered_index_usage is set if an ordered index access From 95d71272eff7d7f0faf64e7afe2cef5b8578b562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Fri, 11 Nov 2022 14:21:56 -0800 Subject: [PATCH 19/21] Gitlab-CI: Upgrade Fedora build always use latest (now 37) version The version was fixed to be Fedora 36 due to previous issues on Gitlab-CI, but those seem to be solved now. Use 'mariadb' name in scripts and server binary as Fedora switched name in https://src.fedoraproject.org/rpms/mariadb/c/df76620f9e8a9b3f14da8a615050feeac2c62e26 Switch to using the `default:` section supported by newer Gitlab-CI, see https://docs.gitlab.com/ee/ci/yaml/#default. Also define an explicit timeout of 3 hours to ensure builds don't time out if the default timeout is too short. NOTE TO MERGERS: These changes are version independent and should be merged up on all MariaDB branches 10.6 -> 10.11. --- .gitlab-ci.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 06a6feef8c3..56f11c2917d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,9 +28,12 @@ stages: - test - Salsa-CI -# Base image for builds and tests unless otherwise defined -# @TODO: Fedora 34 is latest, but fails to start on Gitlab.com with error "shell not found" -image: fedora:33 +default: + # Base image for builds and tests unless otherwise defined + image: fedora:latest + # Extend build jobs to have longer timeout as the default GitLab + # timeout (1h) is often not enough + timeout: 3h # Define common CMAKE_FLAGS for all builds. Skim down build by omitting all # submodules (a commit in this repo does not affect their builds anyway) and @@ -427,14 +430,14 @@ fedora upgrade: dependencies: - fedora script: - - yum install -y mariadb-server + - dnf install -y mariadb-server # Fedora does not support running services in Docker (like Debian packages do) so start it manually - - /usr/libexec/mysql-check-socket - - /usr/libexec/mysql-prepare-db-dir - - sudo -u mysql /usr/libexec/mysqld --basedir=/usr & sleep 10 + - /usr/libexec/mariadb-check-socket + - /usr/libexec/mariadb-prepare-db-dir + - sudo -u mysql /usr/libexec/mariadbd --basedir=/usr & sleep 10 # Dump database contents in installed state - mariadb-dump --all-databases --all-tablespaces --triggers --routines --events --skip-extended-insert > old-installed-database.sql - - /usr/libexec/mysql-check-upgrade + - /usr/libexec/mariadb-check-upgrade # Dump database contents in upgraded state - mariadb-dump --all-databases --all-tablespaces --triggers --routines --events --skip-extended-insert > old-upgraded-database.sql - mariadb --skip-column-names -e "SELECT @@version, @@version_comment" # Show version From 0a7d85c97f6dd68f78ecb3e7074043ff2d4c24fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 5 Dec 2022 18:00:22 +0200 Subject: [PATCH 20/21] MDEV-30148 Race condition between non-persistent statistics and purge btr_cur_t::open_random_leaf(): Replaces btr_cur_open_at_rnd_pos(). Acquire a shared latch on each page, and finally release all latches except the one on the leaf page. This fixes a race condition between the purge of history and btr_estimate_number_of_different_key_vals(), which turned out to only hold a buffer-fix on the randomly chosen leaf page. Typically, an assertion would fail in page_rec_is_supremum(). ibuf_contract(): Start from the beginning of the change buffer, to simplify the logic. Starting with commit b42294bc6409794bdbd2051b32fa079d81cea61d it does not matter much where the change buffer merge is being initiated. The race condition may have been introduced as early as mysql/mysql-server@ac74632293bea967b352d1b472abedeeaa921b98 from where it was copied to commit 2e814d4702d71a04388386a9f591d14a35980bfe. Reviewed by: Vladislav Lesin Tested by: Matthias Leich --- storage/innobase/btr/btr0cur.cc | 282 ---------------------------- storage/innobase/dict/dict0stats.cc | 69 ++++++- storage/innobase/ibuf/ibuf0ibuf.cc | 24 +-- storage/innobase/include/btr0cur.h | 19 +- 4 files changed, 76 insertions(+), 318 deletions(-) diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index c6f11aa518f..ac06d9b1568 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -2629,288 +2629,6 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index, return err; } -/**********************************************************************//** -Positions a cursor at a randomly chosen position within a B-tree. -@return true if the index is available and we have put the cursor, false -if the index is unavailable */ -bool -btr_cur_open_at_rnd_pos( - dict_index_t* index, /*!< in: index */ - btr_latch_mode latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ - btr_cur_t* cursor, /*!< in/out: B-tree cursor */ - mtr_t* mtr) /*!< in: mtr */ -{ - page_cur_t* page_cursor; - ulint node_ptr_max_size = srv_page_size / 2; - ulint height; - rec_t* node_ptr; - btr_intention_t lock_intention; - buf_block_t* tree_blocks[BTR_MAX_LEVELS]; - ulint tree_savepoints[BTR_MAX_LEVELS]; - ulint n_blocks = 0; - ulint n_releases = 0; - mem_heap_t* heap = NULL; - rec_offs offsets_[REC_OFFS_NORMAL_SIZE]; - rec_offs* offsets = offsets_; - rec_offs_init(offsets_); - - ut_ad(!index->is_spatial()); - - lock_intention = btr_cur_get_and_clear_intention(&latch_mode); - - ulint savepoint = mtr_set_savepoint(mtr); - - rw_lock_type_t upper_rw_latch; - - switch (latch_mode) { - case BTR_MODIFY_TREE: - /* Most of delete-intended operations are purging. - Free blocks and read IO bandwidth should be prior - for them, when the history list is glowing huge. */ - if (lock_intention == BTR_INTENTION_DELETE - && buf_pool.n_pend_reads - && trx_sys.history_size_approx() - > BTR_CUR_FINE_HISTORY_LENGTH) { - mtr_x_lock_index(index, mtr); - } else { - mtr_sx_lock_index(index, mtr); - } - upper_rw_latch = RW_X_LATCH; - break; - case BTR_SEARCH_PREV: - case BTR_MODIFY_PREV: - /* This function doesn't support left uncle - page lock for left leaf page lock, when - needed. */ - case BTR_SEARCH_TREE: - case BTR_CONT_MODIFY_TREE: - case BTR_CONT_SEARCH_TREE: - ut_ad(0); - /* fall through */ - default: - if (!srv_read_only_mode) { - mtr_s_lock_index(index, mtr); - upper_rw_latch = RW_S_LATCH; - } else { - upper_rw_latch = RW_NO_LATCH; - } - } - - DBUG_EXECUTE_IF("test_index_is_unavailable", - return(false);); - - if (index->page == FIL_NULL) { - /* Since we don't hold index lock until just now, the index - could be modified by others, for example, if this is a - statistics updater for referenced table, it could be marked - as unavailable by 'DROP TABLE' in the mean time, since - we don't hold lock for statistics updater */ - return(false); - } - - const rw_lock_type_t root_leaf_rw_latch = btr_cur_latch_for_root_leaf( - latch_mode); - - page_cursor = btr_cur_get_page_cur(cursor); - page_cursor->index = index; - - page_id_t page_id(index->table->space_id, index->page); - const ulint zip_size = index->table->space->zip_size(); - dberr_t err; - - if (root_leaf_rw_latch == RW_X_LATCH) { - node_ptr_max_size = btr_node_ptr_max_size(index); - } - - height = ULINT_UNDEFINED; - - for (;;) { - page_t* page; - - ut_ad(n_blocks < BTR_MAX_LEVELS); - tree_savepoints[n_blocks] = mtr_set_savepoint(mtr); - - const rw_lock_type_t rw_latch = height - && latch_mode != BTR_MODIFY_TREE - ? upper_rw_latch : RW_NO_LATCH; - buf_block_t* block = buf_page_get_gen(page_id, zip_size, - rw_latch, NULL, BUF_GET, - mtr, &err, - height == 0 - && !index->is_clust()); - tree_blocks[n_blocks] = block; - - ut_ad((block != NULL) == (err == DB_SUCCESS)); - - if (!block) { - if (err == DB_DECRYPTION_FAILED) { - btr_decryption_failed(*index); - } - - break; - } - - page = buf_block_get_frame(block); - - if (height == ULINT_UNDEFINED - && page_is_leaf(page) - && rw_latch != RW_NO_LATCH - && rw_latch != root_leaf_rw_latch) { - /* We should retry to get the page, because the root page - is latched with different level as a leaf page. */ - ut_ad(root_leaf_rw_latch != RW_NO_LATCH); - ut_ad(rw_latch == RW_S_LATCH); - - ut_ad(n_blocks == 0); - mtr_release_block_at_savepoint( - mtr, tree_savepoints[n_blocks], - tree_blocks[n_blocks]); - - upper_rw_latch = root_leaf_rw_latch; - continue; - } - - ut_ad(fil_page_index_page_check(page)); - ut_ad(index->id == btr_page_get_index_id(page)); - - if (height == ULINT_UNDEFINED) { - /* We are in the root node */ - - height = btr_page_get_level(page); - } - - if (height == 0) { - if (rw_latch == RW_NO_LATCH - || srv_read_only_mode) { - btr_cur_latch_leaves(block, latch_mode, cursor, - mtr); - } - - /* btr_cur_t::open_leaf() and - btr_cur_search_to_nth_level() release - tree s-latch here.*/ - switch (latch_mode) { - case BTR_MODIFY_TREE: - case BTR_CONT_MODIFY_TREE: - case BTR_CONT_SEARCH_TREE: - break; - default: - /* Release the tree s-latch */ - if (!srv_read_only_mode) { - mtr_release_s_latch_at_savepoint( - mtr, savepoint, - &index->lock); - } - - /* release upper blocks */ - for (; n_releases < n_blocks; n_releases++) { - mtr_release_block_at_savepoint( - mtr, - tree_savepoints[n_releases], - tree_blocks[n_releases]); - } - } - } - - page_cursor->block = block; - page_cur_open_on_rnd_user_rec(page_cursor); - - if (height == 0) { - - break; - } - - ut_ad(height > 0); - - height--; - - node_ptr = page_cur_get_rec(page_cursor); - offsets = rec_get_offsets(node_ptr, page_cursor->index, - offsets, 0, ULINT_UNDEFINED, &heap); - - /* If the rec is the first or last in the page for - pessimistic delete intention, it might cause node_ptr insert - for the upper level. We should change the intention and retry. - */ - if (latch_mode == BTR_MODIFY_TREE - && btr_cur_need_opposite_intention( - page, lock_intention, node_ptr)) { - - ut_ad(upper_rw_latch == RW_X_LATCH); - /* release all blocks */ - for (; n_releases <= n_blocks; n_releases++) { - mtr_release_block_at_savepoint( - mtr, tree_savepoints[n_releases], - tree_blocks[n_releases]); - } - - lock_intention = BTR_INTENTION_BOTH; - - page_id.set_page_no(dict_index_get_page(index)); - - height = ULINT_UNDEFINED; - - n_blocks = 0; - n_releases = 0; - - continue; - } - - if (latch_mode == BTR_MODIFY_TREE - && !btr_cur_will_modify_tree( - page_cursor->index, page, lock_intention, - node_ptr, node_ptr_max_size, zip_size, mtr)) { - ut_ad(upper_rw_latch == RW_X_LATCH); - ut_ad(n_releases <= n_blocks); - - /* we can release upper blocks */ - for (; n_releases < n_blocks; n_releases++) { - if (n_releases == 0) { - /* we should not release root page - to pin to same block. */ - continue; - } - - /* release unused blocks to unpin */ - mtr_release_block_at_savepoint( - mtr, tree_savepoints[n_releases], - tree_blocks[n_releases]); - } - } - - if (height == 0 - && latch_mode == BTR_MODIFY_TREE) { - ut_ad(upper_rw_latch == RW_X_LATCH); - /* we should sx-latch root page, if released already. - It contains seg_header. */ - if (n_releases > 0) { - mtr->sx_latch_at_savepoint( - tree_savepoints[0], - tree_blocks[0]); - } - - /* x-latch the branch blocks not released yet. */ - for (ulint i = n_releases; i <= n_blocks; i++) { - mtr->x_latch_at_savepoint( - tree_savepoints[i], - tree_blocks[i]); - } - } - - /* Go to the child node */ - page_id.set_page_no( - btr_node_ptr_get_child_page_no(node_ptr, offsets)); - - n_blocks++; - } - - if (UNIV_LIKELY_NULL(heap)) { - mem_heap_free(heap); - } - - return err == DB_SUCCESS; -} - /*==================== B-TREE INSERT =========================*/ /*************************************************************//** diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index dcd604cfb74..afc38654f55 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1079,6 +1079,60 @@ btr_record_not_null_field_in_rec( } } +inline dberr_t +btr_cur_t::open_random_leaf(rec_offs *&offsets, mem_heap_t *&heap, mtr_t &mtr) +{ + ut_ad(!index()->is_spatial()); + ut_ad(!mtr.get_savepoint()); + + mtr_s_lock_index(index(), &mtr); + + if (index()->page == FIL_NULL) + return DB_CORRUPTION; + + dberr_t err; + auto offset= index()->page; + bool merge= false; + ulint height= ULINT_UNDEFINED; + + while (buf_block_t *block= + btr_block_get(*index(), offset, RW_S_LATCH, merge, &mtr, &err)) + { + page_cur.block= block; + + if (height == ULINT_UNDEFINED) + { + height= btr_page_get_level(block->page.frame); + if (height > BTR_MAX_LEVELS) + return DB_CORRUPTION; + + if (height == 0) + goto got_leaf; + } + + if (height == 0) + { + mtr.rollback_to_savepoint(0, mtr.get_savepoint() - 1); + got_leaf: + page_cur.rec= page_get_infimum_rec(block->page.frame); + return DB_SUCCESS; + } + + if (!--height) + merge= !index()->is_clust(); + + page_cur_open_on_rnd_user_rec(&page_cur); + + offsets= rec_get_offsets(page_cur.rec, page_cur.index, offsets, 0, + ULINT_UNDEFINED, &heap); + + /* Go to the child node */ + offset= btr_node_ptr_get_child_page_no(page_cur.rec, offsets); + } + + return err; +} + /** Estimated table level stats from sampled value. @param value sampled stats @param index index being sampled @@ -1107,7 +1161,6 @@ std::vector btr_estimate_number_of_different_key_vals(dict_index_t* index, trx_id_t bulk_trx_id) { - btr_cur_t cursor; page_t* page; rec_t* rec; ulint n_cols; @@ -1222,14 +1275,15 @@ btr_estimate_number_of_different_key_vals(dict_index_t* index, ut_ad(n_sample_pages > 0 && n_sample_pages <= (index->stat_index_size <= 1 ? 1 : index->stat_index_size)); /* We sample some pages in the index to get an estimate */ + btr_cur_t cursor; + cursor.page_cur.index = index; for (ulint i = 0; i < n_sample_pages; i++) { mtr.start(); - if (!btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, - &cursor, &mtr) - || index->table->bulk_trx_id != bulk_trx_id - || !index->is_readable()) { + if (cursor.open_random_leaf(offsets_rec, heap, mtr) != + DB_SUCCESS + || index->table->bulk_trx_id != bulk_trx_id) { mtr.commit(); goto exit_loop; } @@ -1242,9 +1296,8 @@ btr_estimate_number_of_different_key_vals(dict_index_t* index, page = btr_cur_get_page(&cursor); - rec = page_rec_get_next(page_get_infimum_rec(page)); - const ulint n_core = page_is_leaf(page) - ? index->n_core_fields : 0; + rec = page_rec_get_next(cursor.page_cur.rec); + const ulint n_core = index->n_core_fields; if (rec && !page_rec_is_supremum(rec)) { not_empty_flag = 1; diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 6c15571a305..5a97ea4ebe0 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2416,36 +2416,26 @@ will be merged from ibuf trees to the pages read ulint ibuf_contract() { mtr_t mtr; - btr_pcur_t pcur; + btr_cur_t cur; ulint sum_sizes; uint32_t page_nos[IBUF_MAX_N_PAGES_MERGED]; uint32_t space_ids[IBUF_MAX_N_PAGES_MERGED]; ibuf_mtr_start(&mtr); - /* Open a cursor to a randomly chosen leaf of the tree, at a random - position within the leaf */ - pcur.pos_state = BTR_PCUR_IS_POSITIONED; - pcur.old_rec = nullptr; - pcur.trx_if_known = nullptr; - pcur.search_mode = PAGE_CUR_G; - pcur.latch_mode = BTR_SEARCH_LEAF; - - btr_pcur_init(&pcur); - - if (!btr_cur_open_at_rnd_pos(ibuf.index, BTR_SEARCH_LEAF, - btr_pcur_get_btr_cur(&pcur), &mtr)) { + if (cur.open_leaf(true, ibuf.index, BTR_SEARCH_LEAF, &mtr) != + DB_SUCCESS) { return 0; } - ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf.index)); + ut_ad(page_validate(btr_cur_get_page(&cur), ibuf.index)); - if (page_is_empty(btr_pcur_get_page(&pcur))) { + if (page_is_empty(btr_cur_get_page(&cur))) { /* If a B-tree page is empty, it must be the root page and the whole B-tree must be empty. InnoDB does not allow empty B-tree pages other than the root. */ ut_ad(ibuf.empty); - ut_ad(btr_pcur_get_block(&pcur)->page.id() + ut_ad(btr_cur_get_block(&cur)->page.id() == page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO)); ibuf_mtr_commit(&mtr); @@ -2455,7 +2445,7 @@ ulint ibuf_contract() ulint n_pages = 0; sum_sizes = ibuf_get_merge_page_nos(TRUE, - btr_pcur_get_rec(&pcur), &mtr, + btr_cur_get_rec(&cur), &mtr, space_ids, page_nos, &n_pages); ibuf_mtr_commit(&mtr); diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index aa890be9936..49bc8a4ff1b 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -172,17 +172,6 @@ dberr_t btr_cur_search_to_nth_level(ulint level, btr_cur_t *cursor, mtr_t *mtr, ib_uint64_t autoinc= 0); -/**********************************************************************//** -Positions a cursor at a randomly chosen position within a B-tree. -@return true if the index is available and we have put the cursor, false -if the index is unavailable */ -bool -btr_cur_open_at_rnd_pos( - dict_index_t* index, /*!< in: index */ - btr_latch_mode latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ - btr_cur_t* cursor, /*!< in/out: B-tree cursor */ - mtr_t* mtr) /*!< in: mtr */ - MY_ATTRIBUTE((nonnull,warn_unused_result)); /*************************************************************//** Tries to perform an insert to a page in an index tree, next to cursor. It is assumed that mtr holds an x-latch on the page. The operation does @@ -813,6 +802,14 @@ struct btr_cur_t { @return error code */ dberr_t open_leaf(bool first, dict_index_t *index, btr_latch_mode latch_mode, mtr_t *mtr); + + /** Open the cursor at a random leaf page record. + @param offsets temporary memory for rec_get_offsets() + @param heap memory heap for rec_get_offsets() + @param mtr mini-transaction + @return error code */ + inline dberr_t open_random_leaf(rec_offs *&offsets, mem_heap_t *& heap, + mtr_t &mtr); }; /** Modify the delete-mark flag of a record. From 9044e016c54762300beb2cd609b41c285bbf8794 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 6 Dec 2022 13:31:11 +0100 Subject: [PATCH 21/21] MDEV-29822 - disable a test that fails sporadically --- mysql-test/suite/sysschema/disabled.def | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 mysql-test/suite/sysschema/disabled.def diff --git a/mysql-test/suite/sysschema/disabled.def b/mysql-test/suite/sysschema/disabled.def new file mode 100644 index 00000000000..62df96a4663 --- /dev/null +++ b/mysql-test/suite/sysschema/disabled.def @@ -0,0 +1,12 @@ +############################################################################## +# +# List the test cases that are to be disabled temporarily. +# +# Separate the test case name and the comment with ':'. +# +# : BUG# +# +# Do not use any TAB characters for whitespace. +# +############################################################################## +pr_statement_performance_analyzer : MDEV-29822 perfschema specific and Windows specific problems.