diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index eb969679bf7..55e960a3c15 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -163,6 +163,7 @@ SET(INSTALL_UNIX_ADDRDIR_RPM "${INSTALL_MYSQLDATADIR_RPM}/mysql.sock" SET(INSTALL_SYSTEMD_UNITDIR_RPM "/usr/lib/systemd/system") SET(INSTALL_SYSTEMD_SYSUSERSDIR_RPM "/usr/lib/sysusers.d") SET(INSTALL_SYSTEMD_TMPFILESDIR_RPM "/usr/lib/tmpfiles.d") +SET(INSTALL_RUNDATADIR_RPM "/run/mariadb") SET(INSTALL_PAMDIR_RPM "/${INSTALL_LIBDIR_RPM}/security") SET(INSTALL_PAMDATADIR_RPM "/etc/security") @@ -193,7 +194,8 @@ SET(INSTALL_SUPPORTFILESDIR_DEB "share/mariadb") # SET(INSTALL_MYSQLDATADIR_DEB "/var/lib/mysql") -SET(INSTALL_UNIX_ADDRDIR_DEB "/run/mysqld/mysqld.sock") +SET(INSTALL_RUNDATADIR_DEB "/run/mysqld") +SET(INSTALL_UNIX_ADDRDIR_DEB "${INSTALL_RUNDATADIR_DEB}/mysqld.sock") SET(INSTALL_SYSTEMD_UNITDIR_DEB "/lib/systemd/system") SET(INSTALL_SYSTEMD_SYSUSERSDIR_DEB "/usr/lib/sysusers.d") SET(INSTALL_SYSTEMD_TMPFILESDIR_DEB "/usr/lib/tmpfiles.d") @@ -257,3 +259,7 @@ IF(NOT MYSQL_UNIX_ADDR) SET(MYSQL_UNIX_ADDR ${INSTALL_UNIX_ADDRDIR}) ENDIF() +IF(NOT INSTALL_RUNDATADIR) + get_filename_component(MYSQL_UNIX_DIR ${MYSQL_UNIX_ADDR} DIRECTORY) + SET(INSTALL_RUNDATADIR "${MYSQL_UNIX_DIR}" CACHE FILEPATH "Rundata installation directory" ${FORCE}) +ENDIF() diff --git a/cmake/systemd.cmake b/cmake/systemd.cmake index 6788cf0d295..a825cd0cb68 100644 --- a/cmake/systemd.cmake +++ b/cmake/systemd.cmake @@ -50,8 +50,7 @@ MACRO(CHECK_SYSTEMD) SET(SYSTEMD_SCRIPTS ${SYSTEMD_SCRIPTS} galera_recovery) ENDIF() IF(DEB) - SET(SYSTEMD_EXECSTARTPRE "ExecStartPre=+/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld") - SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=+/etc/mysql/debian-start") + SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=!/etc/mysql/debian-start") ENDIF() IF(URING_FOUND) SET(SYSTEMD_LIMIT "# For liburing and io_uring_setup() diff --git a/debian/control b/debian/control index 35c3e00d4a6..9643a66f540 100644 --- a/debian/control +++ b/debian/control @@ -980,8 +980,7 @@ Description: Connect storage engine JDBC interface for MariaDB server. Package: mariadb-plugin-s3 Architecture: any -Depends: libcurl4, - mariadb-server (= ${server:Version}), +Depends: mariadb-server (= ${server:Version}), ${misc:Depends}, ${shlibs:Depends} Description: Amazon S3 archival storage engine for MariaDB @@ -1010,8 +1009,7 @@ Description: RocksDB storage engine for MariaDB server Package: mariadb-plugin-oqgraph Architecture: any -Depends: libjudydebian1, - mariadb-server (= ${server:Version}), +Depends: mariadb-server (= ${server:Version}), ${misc:Depends}, ${shlibs:Depends} Breaks: mariadb-oqgraph-engine-10.0, @@ -1076,8 +1074,7 @@ Description: Spider storage engine for MariaDB server Package: mariadb-plugin-gssapi-server Architecture: any -Depends: libgssapi-krb5-2, - mariadb-server, +Depends: mariadb-server (= ${server:Version}), ${misc:Depends}, ${shlibs:Depends} Breaks: mariadb-gssapi-server-10.1, @@ -1100,8 +1097,7 @@ Description: GSSAPI authentication plugin for MariaDB server Package: mariadb-plugin-gssapi-client Architecture: any -Depends: libgssapi-krb5-2, - mariadb-client (= ${binary:Version}), +Depends: mariadb-client (= ${binary:Version}), ${misc:Depends}, ${shlibs:Depends} Breaks: mariadb-gssapi-client-10.1, @@ -1120,8 +1116,7 @@ Description: GSSAPI authentication plugin for MariaDB client Package: mariadb-plugin-cracklib-password-check Architecture: any -Depends: libcrack2 (>= 2.9.0), - mariadb-server, +Depends: mariadb-server, ${misc:Depends}, ${shlibs:Depends} Description: CrackLib Password Validation Plugin for MariaDB server @@ -1134,8 +1129,7 @@ Description: CrackLib Password Validation Plugin for MariaDB server Package: mariadb-plugin-hashicorp-key-management Architecture: any -Depends: libcurl4, - mariadb-server, +Depends: mariadb-server, ${misc:Depends}, ${shlibs:Depends} Description: Hashicorp Key Management plugin for MariaDB diff --git a/debian/mariadb-server.install b/debian/mariadb-server.install index c125d171661..de484115db3 100644 --- a/debian/mariadb-server.install +++ b/debian/mariadb-server.install @@ -15,6 +15,7 @@ lib/systemd/system/mariadb@.socket lib/systemd/system/mysql.service lib/systemd/system/mysqld.service support-files/rpm/enable_encryption.preset etc/mysql/mariadb.conf.d/99-enable-encryption.cnf.preset +usr/lib/tmpfiles.d/mariadb.conf usr/bin/aria_chk usr/bin/aria_dump_log usr/bin/aria_ftdump diff --git a/debian/not-installed b/debian/not-installed index 16cd355f559..8936d8e7d76 100644 --- a/debian/not-installed +++ b/debian/not-installed @@ -22,7 +22,6 @@ usr/lib/*/pkgconfig/mariadb.pc usr/bin/uca-dump usr/bin/wsrep_sst_backup usr/lib/sysusers.d/mariadb.conf # Not used (yet) in Debian systemd -usr/lib/tmpfiles.d/mariadb.conf # Not used (yet) in Debian systemd usr/sbin/rcmysql usr/share/doc/mariadb-server/COPYING (related file: "debian/tmp/usr/share/mariadb/mroonga/COPYING") usr/share/doc/mariadb-server/CREDITS diff --git a/include/typelib.h b/include/typelib.h index 054370b5f3a..091e58d04c8 100644 --- a/include/typelib.h +++ b/include/typelib.h @@ -25,6 +25,12 @@ typedef struct st_typelib { /* Different types saved here */ const char *name; /* Name of typelib */ const char **type_names; unsigned int *type_lengths; + /* + An array of indexes of enum values that are no longer supported and so are + hidden. One cannot specify hidden values, an attempt to do so will produce + a warning (while an attempt to use a name that was never part of this set + will produce an error). + */ const int *hidden_values; } TYPELIB; diff --git a/mysql-test/main/alter_table_lock.result b/mysql-test/main/alter_table_lock.result index 170a7c47e6b..b98f8d50c80 100644 --- a/mysql-test/main/alter_table_lock.result +++ b/mysql-test/main/alter_table_lock.result @@ -1,23 +1,4 @@ # -# MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in -# Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK) -# -SET @max_session_mem_used_save= @@max_session_mem_used; -CREATE TABLE t1 (a INT); -SELECT * FROM t1; -a -ALTER TABLE x MODIFY xx INT; -ERROR 42S02: Table 'test.x' doesn't exist -SET SESSION max_session_mem_used= 8192; -LOCK TABLE t1 WRITE; -ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT; -SET SESSION max_session_mem_used = @max_session_mem_used_save; -UNLOCK TABLES; -DROP TABLE t1; -# -# End of 10.5 tests -# -# # MDEV-28943 Online alter fails under LOCK TABLE with ER_ALTER_OPERATION_NOT_SUPPORTED_REASON # create table t1 (f int) engine=innodb; @@ -58,9 +39,6 @@ alter online table t1 add column s blob not null, algorithm=inplace; ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED drop table t1; # -# End of 10.11 tests -# -# # MDEV-35611 Assertion failure in Diagnostics_area::sql_errno upon interrupted ALTER # CREATE TABLE t (a INT) ENGINE=MyISAM; @@ -76,6 +54,4 @@ disconnect con1; connection default; UNLOCK TABLES; DROP TABLE t; -# # End of 11.4 tests -# diff --git a/mysql-test/main/alter_table_lock.test b/mysql-test/main/alter_table_lock.test index a01bd721e04..aaf40243a1b 100644 --- a/mysql-test/main/alter_table_lock.test +++ b/mysql-test/main/alter_table_lock.test @@ -1,36 +1,6 @@ --source include/not_embedded.inc --source include/have_innodb.inc ---echo # ---echo # MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in ---echo # Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK) ---echo # - -SET @max_session_mem_used_save= @@max_session_mem_used; - -CREATE TABLE t1 (a INT); -SELECT * FROM t1; - ---error ER_NO_SUCH_TABLE -ALTER TABLE x MODIFY xx INT; - -SET SESSION max_session_mem_used= 8192; ---error 0,ER_OPTION_PREVENTS_STATEMENT -LOCK TABLE t1 WRITE; - ---disable_warnings ---error 0,ER_OPTION_PREVENTS_STATEMENT -ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT; ---enable_warnings - -SET SESSION max_session_mem_used = @max_session_mem_used_save; -UNLOCK TABLES; -DROP TABLE t1; - ---echo # ---echo # End of 10.5 tests ---echo # - --echo # --echo # MDEV-28943 Online alter fails under LOCK TABLE with ER_ALTER_OPERATION_NOT_SUPPORTED_REASON --echo # @@ -75,10 +45,6 @@ lock table t1 write; alter online table t1 add column s blob not null, algorithm=inplace; drop table t1; ---echo # ---echo # End of 10.11 tests ---echo # - --echo # --echo # MDEV-35611 Assertion failure in Diagnostics_area::sql_errno upon interrupted ALTER --echo # @@ -97,6 +63,4 @@ ALTER TABLE IF EXISTS t FORCE; UNLOCK TABLES; DROP TABLE t; ---echo # --echo # End of 11.4 tests ---echo # diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index faf83e490df..c419dcf26da 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -1036,6 +1036,71 @@ set statement optimizer_switch='split_materialized=off' for $query; a b name total_amt 1 NULL A 10 DROP TABLE t1,t2; +# +# MDEV-37407 Wrong result with ORDER BY LIMIT +# Both, with and without split_materialized should +# produce the same results +# +SET @save_optimizer_switch= @@optimizer_switch; +CREATE TABLE t1 +(a varchar(35), b varchar(4), KEY (a)) +ENGINE=InnoDB; +INSERT INTO t1 VALUES +('Albania','AXA'), ('Australia','AUS'), ('Myanmar','MMR'), +('Bahamas','BS'), ('Brazil','BRA'), ('Barbados','BRB'); +CREATE TABLE t2 +(a varchar(4), b varchar(50), PRIMARY KEY (b,a), KEY (a)) +ENGINE=InnoDB; +INSERT INTO t2 VALUES +('AUS','Anglican'), ('MMR','Baptist'), ('BS','Anglican'), +('BS','Baptist'), ('BS','Methodist'), ('BRB','Methodist'), +('BRA','Baptist'), ('USA','Baptist'); +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +ANALYZE TABLE t2 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +set optimizer_switch='split_materialized=off'; +SELECT t1.a +FROM (SELECT a FROM t2 GROUP BY a ORDER BY a, COUNT(DISTINCT b) LIMIT 1) dt +JOIN t1 ON +dt.a=t1.b +WHERE t1.a LIKE 'B%'; +a +set optimizer_switch='split_materialized=on'; +SELECT t1.a +FROM (SELECT a FROM t2 GROUP BY a ORDER BY a, COUNT(DISTINCT b) LIMIT 1) dt +JOIN t1 ON +dt.a=t1.b +WHERE t1.a LIKE 'B%'; +a +DROP TABLE t1,t2; +SET optimizer_switch= @save_optimizer_switch; +# +# MDEV-29638 Crash when considering Split-Materialized plan +# +set @save_optimizer_switch= @@optimizer_switch; +set optimizer_switch='condition_pushdown_for_derived=off,split_materialized=on'; +CREATE TABLE t1 (id int PRIMARY KEY)engine=innodb; +CREATE TABLE t2 (id int PRIMARY KEY, c int) engine=innodb; +CREATE TABLE t3 (id int PRIMARY KEY, a int , b int, KEY (a))engine=innodb; +SELECT * FROM +( +SELECT DISTINCT t1.id +FROM t1 JOIN +( +SELECT t2.id FROM t2 JOIN t3 +ON t3.id = t2.c +WHERE (t3.a > 2 AND t3.b = 2) +GROUP BY t2.id +) m2 ON m2.id = t1.id +) dt; +id +drop table t1, t2, t3; +SET optimizer_switch= @save_optimizer_switch; # End of 10.11 tests # # MDEV-37057 Wrong result with LATERAL DERIVED diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index d6a8e14416b..207d5e084d4 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -632,6 +632,77 @@ evalp set statement optimizer_switch='split_materialized=off' for $query; DROP TABLE t1,t2; +--echo # +--echo # MDEV-37407 Wrong result with ORDER BY LIMIT +--echo # Both, with and without split_materialized should +--echo # produce the same results +--echo # + +SET @save_optimizer_switch= @@optimizer_switch; + +CREATE TABLE t1 + (a varchar(35), b varchar(4), KEY (a)) +ENGINE=InnoDB; + +INSERT INTO t1 VALUES +('Albania','AXA'), ('Australia','AUS'), ('Myanmar','MMR'), +('Bahamas','BS'), ('Brazil','BRA'), ('Barbados','BRB'); + +CREATE TABLE t2 + (a varchar(4), b varchar(50), PRIMARY KEY (b,a), KEY (a)) +ENGINE=InnoDB; + +INSERT INTO t2 VALUES +('AUS','Anglican'), ('MMR','Baptist'), ('BS','Anglican'), +('BS','Baptist'), ('BS','Methodist'), ('BRB','Methodist'), +('BRA','Baptist'), ('USA','Baptist'); + +ANALYZE TABLE t1 PERSISTENT FOR ALL; +ANALYZE TABLE t2 PERSISTENT FOR ALL; + +let $q= +SELECT t1.a +FROM (SELECT a FROM t2 GROUP BY a ORDER BY a, COUNT(DISTINCT b) LIMIT 1) dt + JOIN t1 ON + dt.a=t1.b +WHERE t1.a LIKE 'B%'; + +set optimizer_switch='split_materialized=off'; +eval $q; + +set optimizer_switch='split_materialized=on'; +eval $q; + +DROP TABLE t1,t2; + +SET optimizer_switch= @save_optimizer_switch; + +--echo # +--echo # MDEV-29638 Crash when considering Split-Materialized plan +--echo # + +set @save_optimizer_switch= @@optimizer_switch; +set optimizer_switch='condition_pushdown_for_derived=off,split_materialized=on'; + +CREATE TABLE t1 (id int PRIMARY KEY)engine=innodb; +CREATE TABLE t2 (id int PRIMARY KEY, c int) engine=innodb; +CREATE TABLE t3 (id int PRIMARY KEY, a int , b int, KEY (a))engine=innodb; + +SELECT * FROM +( + SELECT DISTINCT t1.id + FROM t1 JOIN + ( + SELECT t2.id FROM t2 JOIN t3 + ON t3.id = t2.c + WHERE (t3.a > 2 AND t3.b = 2) + GROUP BY t2.id + ) m2 ON m2.id = t1.id +) dt; + +drop table t1, t2, t3; +SET optimizer_switch= @save_optimizer_switch; + --echo # End of 10.11 tests --echo # diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result index c3f4fae80e6..38371c34a35 100644 --- a/mysql-test/main/distinct.result +++ b/mysql-test/main/distinct.result @@ -212,7 +212,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 1 Using index explain SELECT distinct a from t3 order by a desc limit 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index NULL a 5 NULL 40 Using index +1 SIMPLE t3 range a a 5 NULL 10 Using index for group-by; Using temporary; Using filesort explain SELECT distinct a,b from t3 order by a+1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort diff --git a/mysql-test/main/error_simulation.result b/mysql-test/main/error_simulation.result index ba4c8bcf477..009f5323b37 100644 --- a/mysql-test/main/error_simulation.result +++ b/mysql-test/main/error_simulation.result @@ -125,13 +125,4 @@ SELECT f1(1); Got one of the listed errors DROP FUNCTION f1; SET debug_dbug= @saved_dbug; -# -# MDEV-27978 wrong option name in error when exceeding max_session_mem_used -# -SET SESSION max_session_mem_used = 8192; -SELECT * FROM information_schema.processlist; -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET SESSION max_session_mem_used = DEFAULT; -# # End of 10.2 tests -# diff --git a/mysql-test/main/error_simulation.test b/mysql-test/main/error_simulation.test index fc5d9c537c7..3beeefce39f 100644 --- a/mysql-test/main/error_simulation.test +++ b/mysql-test/main/error_simulation.test @@ -144,8 +144,6 @@ SELECT a FROM t1 ORDER BY rand(1); --echo #cleanup DROP TABLE t1, pid_table; - - --echo # --echo # MDEV-12416 OOM in create_virtual_tmp_table() makes the server crash --echo # @@ -158,15 +156,4 @@ SELECT f1(1); DROP FUNCTION f1; SET debug_dbug= @saved_dbug; ---echo # ---echo # MDEV-27978 wrong option name in error when exceeding max_session_mem_used ---echo # -SET SESSION max_session_mem_used = 8192; ---error ER_OPTION_PREVENTS_STATEMENT -SELECT * FROM information_schema.processlist; -SET SESSION max_session_mem_used = DEFAULT; - - ---echo # --echo # End of 10.2 tests ---echo # diff --git a/mysql-test/main/errors.result b/mysql-test/main/errors.result index e0568676952..e4ccc8a7319 100644 --- a/mysql-test/main/errors.result +++ b/mysql-test/main/errors.result @@ -1,4 +1,3 @@ -drop table if exists t1; insert into t1 values(1); ERROR 42S02: Table 'test.t1' doesn't exist delete from t1; @@ -170,12 +169,6 @@ UPDATE t1 SET a = 'new' WHERE COLUMN_CREATE( 1, 'v', 1, 'w' ) IS NULL; ERROR 22007: Illegal value used as argument of dynamic column function drop table t1; -set @max_session_mem_used_save= @@max_session_mem_used; -set max_session_mem_used = 50000; -select * from seq_1_to_1000; -set max_session_mem_used = 8192; -select * from seq_1_to_1000; -set max_session_mem_used = @max_session_mem_used_save; # # MDEV-20604: Duplicate key value is silently truncated to 64 # characters in print_keydup_error @@ -231,16 +224,3 @@ Error 1327 Undeclared variable: foo Error 1305 PROCEDURE P1 does not exist drop procedure P1; # End of 10.4 tests -# -# MDEV-35828: Assertion fails in alloc_root() when memory causes it to call itself -# -CREATE TEMPORARY TABLE t1 (a INT,b INT); -INSERT INTO t1 VALUES (1,1),(2,2); -SET -@tmp=@@max_session_mem_used, -max_session_mem_used=8192; -SELECT * FROM (t1 AS t2 LEFT JOIN t1 AS t3 USING (a)),t1; -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -DROP TABLE t1; -SET max_session_mem_used=@tmp; -# End of 10.6 tests diff --git a/mysql-test/main/errors.test b/mysql-test/main/errors.test index 87d6d2fdec9..e748b3bef2d 100644 --- a/mysql-test/main/errors.test +++ b/mysql-test/main/errors.test @@ -3,31 +3,28 @@ # --source include/have_sequence.inc ---disable_warnings -drop table if exists t1; ---enable_warnings ---error 1146 +--error ER_NO_SUCH_TABLE insert into t1 values(1); ---error 1146 +--error ER_NO_SUCH_TABLE delete from t1; ---error 1146 +--error ER_NO_SUCH_TABLE update t1 set a=1; create table t1 (a int); ---error 1054 +--error ER_BAD_FIELD_ERROR select count(test.t1.b) from t1; ---error 1054 +--error ER_BAD_FIELD_ERROR select count(not_existing_database.t1) from t1; ---error 1054 +--error ER_BAD_FIELD_ERROR select count(not_existing_database.t1.a) from t1; ---error 1044,1146 +--error ER_DBACCESS_DENIED_ERROR,ER_NO_SUCH_TABLE select count(not_existing_database.t1.a) from not_existing_database.t1; ---error 1054 +--error ER_BAD_FIELD_ERROR select 1 from t1 order by 2; ---error 1054 +--error ER_BAD_FIELD_ERROR select 1 from t1 group by 2; ---error 1054 +--error ER_BAD_FIELD_ERROR select 1 from t1 order by t1.b; ---error 1054 +--error ER_BAD_FIELD_ERROR select count(*),b from t1; drop table t1; @@ -36,10 +33,10 @@ drop table t1; # # Bug #6080: Error message for a field with a display width that is too long # ---error 1439 +--error ER_TOO_BIG_DISPLAYWIDTH create table t1 (a int(256)); set sql_mode='traditional'; ---error 1074 +--error ER_TOO_BIG_FIELDLENGTH create table t1 (a varchar(66000)); set sql_mode=default; @@ -95,7 +92,7 @@ delimiter ;| flush status; --disable_ps2_protocol ---error 1062 +--error ER_DUP_ENTRY select f1(), f2(); --enable_ps2_protocol show status like 'Com_insert'; @@ -202,24 +199,6 @@ UPDATE t1 SET a = 'new' WHERE COLUMN_CREATE( 1, 'v', 1, 'w' ) IS NULL; drop table t1; -# -# errors caused by max_session_mem_used -# -set @max_session_mem_used_save= @@max_session_mem_used; - ---disable_result_log -set max_session_mem_used = 50000; ---error 0,ER_OPTION_PREVENTS_STATEMENT -select * from seq_1_to_1000; -set max_session_mem_used = 8192; ---error 0,ER_OPTION_PREVENTS_STATEMENT -select * from seq_1_to_1000; ---enable_result_log -# We may not be able to execute any more queries with this connection -# because of too little memory# - -set max_session_mem_used = @max_session_mem_used_save; - --echo # --echo # MDEV-20604: Duplicate key value is silently truncated to 64 --echo # characters in print_keydup_error @@ -283,24 +262,4 @@ show warnings; drop procedure P1; --- echo # End of 10.4 tests - - ---echo # ---echo # MDEV-35828: Assertion fails in alloc_root() when memory causes it to call itself ---echo # -CREATE TEMPORARY TABLE t1 (a INT,b INT); -INSERT INTO t1 VALUES (1,1),(2,2); - -SET - @tmp=@@max_session_mem_used, - max_session_mem_used=8192; - ---error ER_OPTION_PREVENTS_STATEMENT -SELECT * FROM (t1 AS t2 LEFT JOIN t1 AS t3 USING (a)),t1; - -DROP TABLE t1; -SET max_session_mem_used=@tmp; - - ---echo # End of 10.6 tests +--echo # End of 10.4 tests diff --git a/mysql-test/main/fetch_first.result b/mysql-test/main/fetch_first.result index 775595783b9..861273030e8 100644 --- a/mysql-test/main/fetch_first.result +++ b/mysql-test/main/fetch_first.result @@ -846,7 +846,7 @@ group by first_name, last_name order by first_name fetch first 2 rows with ties; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range t1_name t1_name 206 NULL 3 Using where; Using index for group-by +1 SIMPLE t1 range t1_name t1_name 206 NULL 3 Using where; Using index for group-by; Using temporary; Using filesort select first_name, last_name from t1 where first_name != 'John' @@ -871,7 +871,7 @@ select * from temp_table order by first_name, last_name; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 2 Using filesort -2 DERIVED t1 range t1_name t1_name 206 NULL 3 Using where; Using index for group-by +2 DERIVED t1 range t1_name t1_name 206 NULL 3 Using where; Using index for group-by; Using temporary; Using filesort with temp_table as ( select first_name, last_name from t1 @@ -1462,3 +1462,88 @@ a b 3 bar 3 zzz DROP TABLE t1; +# +# MDEV-37901: Wrong result with Loose Scan on QUICK_GROUP_MIN_MAX_SELECT WITH TIES +# +create table t1 ( +country varchar(100), +city varchar(100), +user_score int, +index (country, city, user_score) +); +insert into t1 +select 'China', 'Shenzhen', seq from seq_10_to_100; +insert into t1 +select 'India', 'New Delhi', seq from seq_10_to_100; +insert into t1 +select 'Sri Lanka', 'Colombo', seq from seq_10_to_100; +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +insert into t1 +select 'Finland', 'Espoo', seq from seq_10_to_200; +insert into t1 +select 'Greece', 'Chania', seq from seq_10_to_20; +insert into t1 +select 'Estonia', 'Narva', seq from seq_10_to_20; +insert into t1 +select 'Russia', 'St Petersburg', seq from seq_10_to_20; +# Must use "Using index for group-by": +explain +select country, city, min(user_score) +from t1 +where user_score between 9 and 199 +group by country, city +order by country +fetch first 5 rows with ties; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL country 811 NULL 4 Using where; Using index for group-by; Using temporary; Using filesort +# Must not use "Using index for group-by": +explain +select country, city, sum(user_score) +from t1 +where user_score between 9 and 199 +group by country, concat(city,'AA') +order by country +fetch first 5 rows with ties; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL country 811 NULL 273 Using where; Using index; Using temporary; Using filesort +select country, city, sum(user_score) +from t1 +where user_score between 9 and 199 +group by country, concat(city,'AA') +order by country +fetch first 5 rows with ties; +country city sum(user_score) +China Shenzhen 5005 +Estonia Narva 165 +Finland Espoo 19855 +Greece Chania 165 +India New Delhi 5005 +# both using index and index with group by should produce same result +select country, city, min(user_score) +from t1 +where user_score between 9 and 199 +group by country, city +order by country +fetch first 5 rows with ties; +country city min(user_score) +China Shenzhen 10 +Estonia Narva 10 +Finland Espoo 10 +Greece Chania 10 +India New Delhi 10 +select country, city, min(user_score) +from t1 use index() +where user_score between 9 and 199 +group by country, city +order by country +fetch first 5 rows with ties; +country city min(user_score) +China Shenzhen 10 +Estonia Narva 10 +Finland Espoo 10 +Greece Chania 10 +India New Delhi 10 +drop table t1; diff --git a/mysql-test/main/fetch_first.test b/mysql-test/main/fetch_first.test index 71e45f5c288..d4cb8edaa0d 100644 --- a/mysql-test/main/fetch_first.test +++ b/mysql-test/main/fetch_first.test @@ -1095,3 +1095,77 @@ SELECT DISTINCT a, b FROM t1 ORDER BY a FETCH FIRST 3 ROWS WITH TIES; # Cleanup DROP TABLE t1; + + +--echo # +--echo # MDEV-37901: Wrong result with Loose Scan on QUICK_GROUP_MIN_MAX_SELECT WITH TIES +--echo # + +--source include/have_sequence.inc + +create table t1 ( + country varchar(100), + city varchar(100), + user_score int, + index (country, city, user_score) +); + +insert into t1 +select 'China', 'Shenzhen', seq from seq_10_to_100; +insert into t1 +select 'India', 'New Delhi', seq from seq_10_to_100; +insert into t1 +select 'Sri Lanka', 'Colombo', seq from seq_10_to_100; +analyze table t1 persistent for all; + +insert into t1 +select 'Finland', 'Espoo', seq from seq_10_to_200; +insert into t1 +select 'Greece', 'Chania', seq from seq_10_to_20; +insert into t1 +select 'Estonia', 'Narva', seq from seq_10_to_20; +insert into t1 +select 'Russia', 'St Petersburg', seq from seq_10_to_20; + +--echo # Must use "Using index for group-by": +explain +select country, city, min(user_score) +from t1 +where user_score between 9 and 199 +group by country, city +order by country +fetch first 5 rows with ties; + +--echo # Must not use "Using index for group-by": +explain +select country, city, sum(user_score) +from t1 +where user_score between 9 and 199 +group by country, concat(city,'AA') +order by country +fetch first 5 rows with ties; + +select country, city, sum(user_score) +from t1 +where user_score between 9 and 199 +group by country, concat(city,'AA') +order by country +fetch first 5 rows with ties; + +--echo # both using index and index with group by should produce same result + +select country, city, min(user_score) +from t1 +where user_score between 9 and 199 +group by country, city +order by country +fetch first 5 rows with ties; + +select country, city, min(user_score) +from t1 use index() +where user_score between 9 and 199 +group by country, city +order by country +fetch first 5 rows with ties; + +drop table t1; diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 0226de09f0c..bd50bc1d6ef 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -2713,6 +2713,77 @@ json_detailed('[[123],456]') SELECT JSON_VALUE(JSON_OBJECT("a", ""), '$.a') = "" AS not_null; not_null 1 +# +# MDEV-36319: Wrong result json_table +# +SET @JSON=' +{ + "SZ": [ + { + "NAME": "S0", + "OFFERS": [ + { + "NAME": "S0A0" + } + ] + }, + { + "NAME": "S1", + "OFFERS": [ + { + "NAME": "S1A0" + }, + { + "NAME": "S1A1" + } + ] + }, + { + "NAME": "S2", + "OFFERS": [ + { + "NAME": "S2A0" + } + ] + }, + { + "NAME": "S3", + "OFFERS": [ + { + "NAME": "S3A0" + } + ] + }, + { + "NAME": "S4", + "OFFERS": [ + { + "NAME": "S4A0" + } + ] + }, + { + "NAME": "S5", + "OFFERS": [ + { + "NAME": "S5A0" + } + ] + } + ] +} + +' +; +# Should return EMPTY result +SELECT * FROM json_table(@JSON, '$.SZ[0].OFFERS[1]' +COLUMNS(NAME VARCHAR(30) PATH '$.NAME')) AS t_sz; +NAME +# Should return S1A1 +SELECT * FROM json_table(@JSON, '$.SZ[1].OFFERS[1]' +COLUMNS(NAME VARCHAR(30) PATH '$.NAME')) AS t_sz; +NAME +S1A1 # End of 10.11 Test # # MDEV-32007: JSON_VALUE and JSON_EXTRACT doesn't handle dash (-) diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 529ce92d840..625b832f852 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1965,6 +1965,78 @@ select json_detailed('[[123],456]'); SELECT JSON_VALUE(JSON_OBJECT("a", ""), '$.a') = "" AS not_null; +--echo # +--echo # MDEV-36319: Wrong result json_table +--echo # + +SET @JSON=' +{ + "SZ": [ + { + "NAME": "S0", + "OFFERS": [ + { + "NAME": "S0A0" + } + ] + }, + { + "NAME": "S1", + "OFFERS": [ + { + "NAME": "S1A0" + }, + { + "NAME": "S1A1" + } + ] + }, + { + "NAME": "S2", + "OFFERS": [ + { + "NAME": "S2A0" + } + ] + }, + { + "NAME": "S3", + "OFFERS": [ + { + "NAME": "S3A0" + } + ] + }, + { + "NAME": "S4", + "OFFERS": [ + { + "NAME": "S4A0" + } + ] + }, + { + "NAME": "S5", + "OFFERS": [ + { + "NAME": "S5A0" + } + ] + } + ] +} + +' +; + +--echo # Should return EMPTY result +SELECT * FROM json_table(@JSON, '$.SZ[0].OFFERS[1]' +COLUMNS(NAME VARCHAR(30) PATH '$.NAME')) AS t_sz; + +--echo # Should return S1A1 +SELECT * FROM json_table(@JSON, '$.SZ[1].OFFERS[1]' +COLUMNS(NAME VARCHAR(30) PATH '$.NAME')) AS t_sz; + --echo # End of 10.11 Test --echo # diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index f046b2c80c1..eacc9b1c4df 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -5415,8 +5415,14 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; # -# End of 10.6 tests +# MDEV-37947 Item_func_hex doesn't check for max_allowed_packet # +select hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex('\\'))))))))))))))))))))))))))))))))))))))))))))) as x; +x +NULL +Warnings: +Warning 1301 Result of hex() was larger than max_allowed_packet (16777216) - truncated +# End of 10.6 tests # # MDEV-25704 Function random_bytes # diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index e11bdac9acd..03c9e0d6dd0 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -2451,8 +2451,11 @@ SHOW CREATE TABLE t1; DROP TABLE t1; --echo # ---echo # End of 10.6 tests +--echo # MDEV-37947 Item_func_hex doesn't check for max_allowed_packet --echo # +select hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex(hex('\\'))))))))))))))))))))))))))))))))))))))))))))) as x; + +--echo # End of 10.6 tests --echo # --echo # MDEV-25704 Function random_bytes diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index 6859cce1b5c..b7b75fa0ce1 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -2465,7 +2465,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index -2 SUBQUERY t1 index NULL a 10 NULL 15 Using index +2 SUBQUERY t1 range a a 5 NULL 6 Using index for group-by EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/max_session_mem_used.result b/mysql-test/main/max_session_mem_used.result new file mode 100644 index 00000000000..20a88d7d811 --- /dev/null +++ b/mysql-test/main/max_session_mem_used.result @@ -0,0 +1,130 @@ +# +# MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in +# Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK) +# +CREATE TABLE t1 (a INT); +SELECT * FROM t1; +a +ALTER TABLE x MODIFY xx INT; +ERROR 42S02: Table 'test.x' doesn't exist +SET SESSION max_session_mem_used= 8192; +LOCK TABLE t1 WRITE; +ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT; +SET SESSION max_session_mem_used = DEFAULT; +UNLOCK TABLES; +DROP TABLE t1; +# +# MDEV-27978 wrong option name in error when exceeding max_session_mem_used +# +SET SESSION max_session_mem_used = 8192; +SELECT * FROM information_schema.processlist; +ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement +SET SESSION max_session_mem_used = DEFAULT; +set max_session_mem_used = 50000; +select * from seq_1_to_1000; +set max_session_mem_used = 8192; +select * from seq_1_to_1000; +set max_session_mem_used = DEFAULT; +# +# MDEV-35828: Assertion fails in alloc_root() when memory causes it to call itself +# +CREATE TEMPORARY TABLE t1 (a INT,b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +SET max_session_mem_used=8192; +SELECT * FROM (t1 AS t2 LEFT JOIN t1 AS t3 USING (a)),t1; +ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement +SET max_session_mem_used=DEFAULT; +DROP TABLE t1; +# +# MDEV-23824 SIGSEGV in end_io_cache on REPAIR LOCAL TABLE for Aria table +# +CREATE TABLE t1 (i INT) ENGINE=Aria; +INSERT INTO t1 VALUES (1); +SET max_session_mem_used=50000; +REPAIR LOCAL TABLE t1 USE_FRM; +REPAIR LOCAL TABLE t1; +DROP TABLE t1; +SET max_session_mem_used=default; +# End of 10.6 tests +# +# MDEV-37489: SIGSEGV in get_param_default_value | store_schema_params +# +CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) +BEGIN +SELECT x; +END; +// +SET SESSION max_session_mem_used=8192; +CALL p0(); +ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement +SET @@max_session_mem_used=DEFAULT; +CALL p0(); +ERROR 42000: FUNCTION test.func does not exist +SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; +SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE +def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE +# with func() defined +CREATE FUNCTION func(x INT DEFAULT 10) RETURNS INT +BEGIN +RETURN x; +END; +// +CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) +BEGIN +SELECT x; +END; +// +SET SESSION max_session_mem_used=8192; +CALL p0(); +ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement +SET @@max_session_mem_used=DEFAULT; +CALL p0(); +x +10 +SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; +SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE +def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE +# with multiple functions +CREATE FUNCTION func2(x INT DEFAULT 10) RETURNS INT +BEGIN +RETURN x; +END; +// +CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2()) +BEGIN +SELECT x, y; +END; +// +SET SESSION max_session_mem_used=8192; +CALL p0(); +ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement +SET @@max_session_mem_used=DEFAULT; +CALL p0(); +x y +10 10 +SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; +SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE +def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE +def test p0 2 IN y int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE +# with function and constant default param +CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2(), z INT DEFAULT 10) +BEGIN +SELECT x, y, z; +END; +// +SET SESSION max_session_mem_used=8192; +CALL p0(); +ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement +SET @@max_session_mem_used=DEFAULT; +CALL p0(); +x y z +10 10 10 +SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; +SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE +def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE +def test p0 2 IN y int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE +def test p0 3 IN z int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE +DROP PROCEDURE p0; +DROP FUNCTION func; +DROP FUNCTION func2; +# End of 11.8 tests diff --git a/mysql-test/main/max_session_mem_used.test b/mysql-test/main/max_session_mem_used.test new file mode 100644 index 00000000000..ba270470c3b --- /dev/null +++ b/mysql-test/main/max_session_mem_used.test @@ -0,0 +1,179 @@ +# memory usage is sensitive to valgrind/ps-protocol/embedded +source include/not_msan.inc; +source include/not_valgrind.inc; +source include/no_protocol.inc; +source include/not_embedded.inc; +source include/have_64bit.inc; +source include/have_sequence.inc; + +--echo # +--echo # MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in +--echo # Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK) +--echo # + +CREATE TABLE t1 (a INT); +SELECT * FROM t1; + +--error ER_NO_SUCH_TABLE +ALTER TABLE x MODIFY xx INT; + +SET SESSION max_session_mem_used= 8192; +--error 0,ER_OPTION_PREVENTS_STATEMENT +LOCK TABLE t1 WRITE; + +--disable_warnings +--error 0,ER_OPTION_PREVENTS_STATEMENT +ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT; +--enable_warnings + +SET SESSION max_session_mem_used = DEFAULT; +UNLOCK TABLES; +DROP TABLE t1; + +--echo # +--echo # MDEV-27978 wrong option name in error when exceeding max_session_mem_used +--echo # +SET SESSION max_session_mem_used = 8192; +--error ER_OPTION_PREVENTS_STATEMENT +SELECT * FROM information_schema.processlist; +SET SESSION max_session_mem_used = DEFAULT; + +# +# errors caused by max_session_mem_used +# +--disable_result_log +set max_session_mem_used = 50000; +--error 0,ER_OPTION_PREVENTS_STATEMENT +select * from seq_1_to_1000; +set max_session_mem_used = 8192; +--error 0,ER_OPTION_PREVENTS_STATEMENT +select * from seq_1_to_1000; +--enable_result_log +# We may not be able to execute any more queries with this connection +# because of too little memory + +set max_session_mem_used = DEFAULT; + +--echo # +--echo # MDEV-35828: Assertion fails in alloc_root() when memory causes it to call itself +--echo # +CREATE TEMPORARY TABLE t1 (a INT,b INT); +INSERT INTO t1 VALUES (1,1),(2,2); + +SET max_session_mem_used=8192; + +--error ER_OPTION_PREVENTS_STATEMENT +SELECT * FROM (t1 AS t2 LEFT JOIN t1 AS t3 USING (a)),t1; + +SET max_session_mem_used=DEFAULT; +DROP TABLE t1; + +--echo # +--echo # MDEV-23824 SIGSEGV in end_io_cache on REPAIR LOCAL TABLE for Aria table +--echo # + +CREATE TABLE t1 (i INT) ENGINE=Aria; +INSERT INTO t1 VALUES (1); +SET max_session_mem_used=50000; +--disable_result_log +REPAIR LOCAL TABLE t1 USE_FRM; +REPAIR LOCAL TABLE t1; +--enable_result_log +DROP TABLE t1; +SET max_session_mem_used=default; + +--echo # End of 10.6 tests + +--echo # +--echo # MDEV-37489: SIGSEGV in get_param_default_value | store_schema_params +--echo # + +--DELIMITER // +CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) +BEGIN + SELECT x; +END; +// +--DELIMITER ; + +SET SESSION max_session_mem_used=8192; +--ERROR ER_OPTION_PREVENTS_STATEMENT +CALL p0(); + +SET @@max_session_mem_used=DEFAULT; +--ERROR ER_SP_DOES_NOT_EXIST +CALL p0(); + +SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; + +--echo # with func() defined +--DELIMITER // +CREATE FUNCTION func(x INT DEFAULT 10) RETURNS INT +BEGIN + RETURN x; +END; +// + +CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) +BEGIN + SELECT x; +END; +// +--DELIMITER ; + +SET SESSION max_session_mem_used=8192; +--ERROR ER_OPTION_PREVENTS_STATEMENT +CALL p0(); + +SET @@max_session_mem_used=DEFAULT; +CALL p0(); + +SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; + +--echo # with multiple functions +--DELIMITER // +CREATE FUNCTION func2(x INT DEFAULT 10) RETURNS INT +BEGIN + RETURN x; +END; +// + +CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2()) +BEGIN + SELECT x, y; +END; +// +--DELIMITER ; + +SET SESSION max_session_mem_used=8192; +--ERROR ER_OPTION_PREVENTS_STATEMENT +CALL p0(); + +SET @@max_session_mem_used=DEFAULT; +CALL p0(); + +SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; + +--echo # with function and constant default param +--DELIMITER // +CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2(), z INT DEFAULT 10) +BEGIN + SELECT x, y, z; +END; +// +--DELIMITER ; + +SET SESSION max_session_mem_used=8192; +--ERROR ER_OPTION_PREVENTS_STATEMENT +CALL p0(); + +SET @@max_session_mem_used=DEFAULT; +CALL p0(); + +SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; + +DROP PROCEDURE p0; +DROP FUNCTION func; +DROP FUNCTION func2; + +--echo # End of 11.8 tests diff --git a/mysql-test/main/merge_alter-master.opt b/mysql-test/main/merge_alter-master.opt new file mode 100644 index 00000000000..4d69f3359db --- /dev/null +++ b/mysql-test/main/merge_alter-master.opt @@ -0,0 +1 @@ +--timezone=GMT-3 diff --git a/mysql-test/main/merge_alter.result b/mysql-test/main/merge_alter.result new file mode 100644 index 00000000000..823931d2ccd --- /dev/null +++ b/mysql-test/main/merge_alter.result @@ -0,0 +1,77 @@ +SET timestamp=1000000000; +RESET MASTER; +CREATE TABLE t (i1 int, i2 int, pk int) ; +CREATE TABLE t3 LIKE t ; +ALTER TABLE t3 ENGINE = MERGE UNION (t1,t2); +insert into t values(1,1,1); +flush logs; +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; +/*!40019 SET @@session.max_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup +ROLLBACK/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Gtid list [] +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Binlog checkpoint master-bin.000001 +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-1 ddl thread_id=# +/*M!100101 SET @@session.skip_parallel_replication=0*//*!*/; +/*M!100001 SET @@session.gtid_domain_id=0*//*!*/; +/*M!100001 SET @@session.server_id=1*//*!*/; +/*M!100001 SET @@session.gtid_seq_no=1*//*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid= +use `test`/*!*/; +SET TIMESTAMP=1000000000/*!*/; +SET @@session.pseudo_thread_id=#/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/; +SET @@session.sql_mode=1411383296/*!*/; +SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; +/*!\C latin1 *//*!*/; +SET @@session.character_set_client=X,@@session.collation_connection=X,@@session.collation_server=X/*!*/; +SET @@session.lc_time_names=0/*!*/; +SET @@session.collation_database=DEFAULT/*!*/; +CREATE TABLE t (i1 int, i2 int, pk int) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-2 ddl thread_id=# +/*M!100001 SET @@session.gtid_seq_no=2*//*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid= +SET TIMESTAMP=1000000000/*!*/; +CREATE TABLE t3 LIKE t +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-3 ddl thread_id=# +/*M!100001 SET @@session.gtid_seq_no=3*//*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid= +SET TIMESTAMP=1000000000/*!*/; +ALTER TABLE t3 ENGINE = MERGE UNION (t1,t2) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-4 thread_id=# +/*M!100001 SET @@session.gtid_seq_no=4*//*!*/; +START TRANSACTION +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid= +SET TIMESTAMP=1000000000/*!*/; +insert into t values(1,1,1) +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid= +SET TIMESTAMP=1000000000/*!*/; +COMMIT +/*!*/; +# at # +#010909 4:46:40 server id # end_log_pos # CRC32 XXX Rotate to master-bin.000002 pos: 4 +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; +drop table t,t3; diff --git a/mysql-test/main/merge_alter.test b/mysql-test/main/merge_alter.test new file mode 100644 index 00000000000..8094fd4e9f9 --- /dev/null +++ b/mysql-test/main/merge_alter.test @@ -0,0 +1,20 @@ +--source include/have_binlog_format_mixed.inc + +# MDEV-37903 ALTER TABLE ... ENGINE=MRG_MyISAM is not binlogged as DDL + +# Fix timestamp to avoid varying results. +SET timestamp=1000000000; + +RESET MASTER; + +CREATE TABLE t (i1 int, i2 int, pk int) ; +CREATE TABLE t3 LIKE t ; +ALTER TABLE t3 ENGINE = MERGE UNION (t1,t2); +insert into t values(1,1,1); + +flush logs; +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /CRC32 0x[0-9a-f]*/CRC32 XXX/ /collation_server=[0-9]+/collation_server=X/ /character_set_client=[a-zA-Z0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/ /xid=\d*/xid=/ +--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001 + +drop table t,t3; diff --git a/mysql-test/main/mysqld--help.test b/mysql-test/main/mysqld--help.test index 1125edeff58..f5ae013294b 100644 --- a/mysql-test/main/mysqld--help.test +++ b/mysql-test/main/mysqld--help.test @@ -2,8 +2,6 @@ # mysqld --help # --source include/not_embedded.inc ---source include/not_asan.inc ---source include/not_ubsan.inc --source include/have_perfschema.inc --source include/have_profiling.inc --source include/platform.inc diff --git a/mysql-test/main/null_aware_cardinality.result b/mysql-test/main/null_aware_cardinality.result new file mode 100644 index 00000000000..97f9cee9080 --- /dev/null +++ b/mysql-test/main/null_aware_cardinality.result @@ -0,0 +1,162 @@ +SET @session_start_value = @@new_mode; +# Small driving table +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1, 1), (2, 2000),(3,300); +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +# Table that will be accessed by an index lookup (`ref` access) +CREATE TABLE t2 (a INT, b INT, KEY key_b(b)); +# All t11.b values are NULL +INSERT INTO t2 SELECT seq/100, NULL FROM seq_1_to_1000; +ANALYZE TABLE t2 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS"; +Warnings: +Warning 4200 The setting 'new_mode=FIX_INDEX_STATS_FOR_ALL_NULLS' is ignored. It only exists for compatibility with old installations and will be removed in a future release +# NULL-rejecting equality t1.b = t2.b will not return any matches +# because all values of t2.b are NULL. So "rows" = 1 for t2 where 1 is +# a special value meaning "very few" rows +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 ref key_b key_b 5 test.t1.b 1 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` +# However, rows estimation for not NULL-rejecting conditions +# must not be affected ("rows" > 1 is expected) +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b <=> t2.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +1 SIMPLE t2 ref key_b key_b 5 test.t1.b 11 100.00 Using index condition; Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`b` <=> `test`.`t2`.`b` +# Insert some non-NULL values and re-collect the stats +INSERT INTO t2 SELECT 1, 1 FROM seq_1_to_100; +ANALYZE TABLE t2 PERSISTENT FOR COLUMNS (b) INDEXES (key_b); +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 ref key_b key_b 5 test.t1.b 100 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` +# Test composite index for two columns. Key prefix is used for access +CREATE TABLE t3 (a INT, b INT, KEY key_ab(a,b)); +# All t3.b values are NULL +INSERT INTO t3 SELECT seq/100, NULL FROM seq_1_to_1000; +ANALYZE TABLE t3 PERSISTENT FOR COLUMNS(b) INDEXES(key_ab); +Table Op Msg_type Msg_text +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status Table is already up to date +# NULL-rejecting equality t1.b = t3.b, same as above. +# "rows" must be estimated to 1 +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t3 ref key_ab key_ab 10 test.t1.a,test.t1.b 1 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t3`.`b` = `test`.`t1`.`b` +# Rows estimation for not NULL-rejecting conditions are not affected +# ("rows" > 1 is expected) +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t3 ref key_ab key_ab 5 test.t1.a 90 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`a` +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b <=> t3.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t3 ref key_ab key_ab 10 test.t1.a,test.t1.b 11 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t1`.`b` <=> `test`.`t3`.`b` +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t3.b is NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t3 ref key_ab key_ab 10 test.t1.a,const 11 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t3`.`b` is null +# In the old mode (null-aware estimation is not enabled), "rows" > 1 +SET @@new_mode = ""; +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t2 ref key_b key_b 5 test.t1.b 100 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` +# Insert some non-NULL values and re-collect the stats +INSERT INTO t3 SELECT 1, 1 FROM seq_1_to_100; +ANALYZE TABLE t3 PERSISTENT FOR COLUMNS (b) INDEXES (key_ab); +Table Op Msg_type Msg_text +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status OK +SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS"; +Warnings: +Warning 4200 The setting 'new_mode=FIX_INDEX_STATS_FOR_ALL_NULLS' is ignored. It only exists for compatibility with old installations and will be removed in a future release +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t3 ref key_ab key_ab 10 test.t1.a,test.t1.b 100 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t3`.`b` = `test`.`t1`.`b` +# Test composite index for 3 columns. Key prefix is used for access +CREATE TABLE t4 (a INT, b INT, c INT, KEY key_abc(a,b,c)); +# All t3.b values are NULL +INSERT INTO t4 SELECT seq/10, NULL, seq/10 FROM seq_1_to_1000; +ANALYZE TABLE t4 PERSISTENT FOR COLUMNS(b) INDEXES(key_abc); +Table Op Msg_type Msg_text +test.t4 analyze status Engine-independent statistics collected +test.t4 analyze status Table is already up to date +# NULL-rejecting equality t1.b = t3.b, same as above. +# "rows" must be estimated to 1 +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t4 ON t1.a = t4.a AND t1.b = t4.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t4 ref key_abc key_abc 10 test.t1.a,test.t1.b 1 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c` from `test`.`t1` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t1`.`a` and `test`.`t4`.`b` = `test`.`t1`.`b` +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t4 ON t1.a = t4.a AND t1.b = t4.b and t1.b = t4.c; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t4 ref key_abc key_abc 15 test.t1.a,test.t1.b,test.t1.b 1 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c` from `test`.`t1` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t1`.`a` and `test`.`t4`.`b` = `test`.`t1`.`b` and `test`.`t4`.`c` = `test`.`t1`.`b` +# "rows" expected to be > 1 +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t4 ON t1.a = t4.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t4 ref key_abc key_abc 5 test.t1.a 9 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c` from `test`.`t1` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t1`.`a` +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t4 ON t1.a = t4.a AND t1.b <=> t4.c; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t4 ref key_abc key_abc 5 test.t1.a 9 100.00 Using where; Using index +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t4`.`c` AS `c` from `test`.`t1` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t1`.`a` and `test`.`t1`.`b` <=> `test`.`t4`.`c` +DROP TABLE t1, t2, t3, t4; +# Test for partially covered column +CREATE TABLE t1 (a VARCHAR(10)); +INSERT INTO t1 SELECT seq FROM seq_1_to_10; +CREATE TABLE t2 ( +a VARCHAR(10), +b VARCHAR(10), +INDEX i1(a, b(5)) +); +INSERT INTO t2 SELECT seq, NULL FROM seq_1_to_1000; +ANALYZE TABLE t2 PERSISTENT FOR COLUMNS (b) INDEXES (i1); +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +EXPLAIN SELECT * FROM t1, t2 WHERE t2.a=t1.a AND t2.b=t1.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where +1 SIMPLE t2 ref i1 i1 66 test.t1.a,test.t1.a 1 Using where +SET @@new_mode = @session_start_value; +DROP TABLE t1, t2; diff --git a/mysql-test/main/null_aware_cardinality.test b/mysql-test/main/null_aware_cardinality.test new file mode 100644 index 00000000000..eead918367a --- /dev/null +++ b/mysql-test/main/null_aware_cardinality.test @@ -0,0 +1,103 @@ +--source include/have_sequence.inc + +SET @session_start_value = @@new_mode; + +--echo # Small driving table +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1, 1), (2, 2000),(3,300); + +ANALYZE TABLE t1 PERSISTENT FOR ALL; + +--echo # Table that will be accessed by an index lookup (`ref` access) +CREATE TABLE t2 (a INT, b INT, KEY key_b(b)); +--echo # All t11.b values are NULL +INSERT INTO t2 SELECT seq/100, NULL FROM seq_1_to_1000; + +ANALYZE TABLE t2 PERSISTENT FOR ALL; + +SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS"; + +--echo # NULL-rejecting equality t1.b = t2.b will not return any matches +--echo # because all values of t2.b are NULL. So "rows" = 1 for t2 where 1 is +--echo # a special value meaning "very few" rows +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b; + +--echo # However, rows estimation for not NULL-rejecting conditions +--echo # must not be affected ("rows" > 1 is expected) +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b <=> t2.b; + +--echo # Insert some non-NULL values and re-collect the stats +INSERT INTO t2 SELECT 1, 1 FROM seq_1_to_100; + +ANALYZE TABLE t2 PERSISTENT FOR COLUMNS (b) INDEXES (key_b); + +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b; + +--echo # Test composite index for two columns. Key prefix is used for access +CREATE TABLE t3 (a INT, b INT, KEY key_ab(a,b)); +--echo # All t3.b values are NULL +INSERT INTO t3 SELECT seq/100, NULL FROM seq_1_to_1000; + +ANALYZE TABLE t3 PERSISTENT FOR COLUMNS(b) INDEXES(key_ab); + +--echo # NULL-rejecting equality t1.b = t3.b, same as above. +--echo # "rows" must be estimated to 1 +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b; + +--echo # Rows estimation for not NULL-rejecting conditions are not affected +--echo # ("rows" > 1 is expected) +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a; + +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b <=> t3.b; + +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t3.b is NULL; + +--echo # In the old mode (null-aware estimation is not enabled), "rows" > 1 +SET @@new_mode = ""; +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t2 ON t1.a = t2.a AND t1.b = t2.b; + +--echo # Insert some non-NULL values and re-collect the stats +INSERT INTO t3 SELECT 1, 1 FROM seq_1_to_100; + +ANALYZE TABLE t3 PERSISTENT FOR COLUMNS (b) INDEXES (key_ab); + +SET @@new_mode = "FIX_INDEX_STATS_FOR_ALL_NULLS"; +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t3 ON t1.a = t3.a AND t1.b = t3.b; + +--echo # Test composite index for 3 columns. Key prefix is used for access +CREATE TABLE t4 (a INT, b INT, c INT, KEY key_abc(a,b,c)); + +--echo # All t3.b values are NULL +INSERT INTO t4 SELECT seq/10, NULL, seq/10 FROM seq_1_to_1000; + +ANALYZE TABLE t4 PERSISTENT FOR COLUMNS(b) INDEXES(key_abc); + +--echo # NULL-rejecting equality t1.b = t3.b, same as above. +--echo # "rows" must be estimated to 1 +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t4 ON t1.a = t4.a AND t1.b = t4.b; + +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t4 ON t1.a = t4.a AND t1.b = t4.b and t1.b = t4.c; + +--echo # "rows" expected to be > 1 +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t4 ON t1.a = t4.a; + +EXPLAIN EXTENDED SELECT * FROM t1 JOIN t4 ON t1.a = t4.a AND t1.b <=> t4.c; + +DROP TABLE t1, t2, t3, t4; + +--echo # Test for partially covered column +CREATE TABLE t1 (a VARCHAR(10)); +INSERT INTO t1 SELECT seq FROM seq_1_to_10; + +CREATE TABLE t2 ( + a VARCHAR(10), + b VARCHAR(10), + INDEX i1(a, b(5)) +); +INSERT INTO t2 SELECT seq, NULL FROM seq_1_to_1000; +ANALYZE TABLE t2 PERSISTENT FOR COLUMNS (b) INDEXES (i1); + +EXPLAIN SELECT * FROM t1, t2 WHERE t2.a=t1.a AND t2.b=t1.a; + +SET @@new_mode = @session_start_value; +DROP TABLE t1, t2; \ No newline at end of file diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index 70480222a6f..56560180c80 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -3794,6 +3794,27 @@ DROP TABLE t1; # # End of 10.5 tests # +# +# MDEV-37913: disable_index_merge_plans causes SELECT data loss when more than 100 ORs +# +CREATE TABLE t1 ( +id int primary key, +key1 int, +index(key1) +); +INSERT INTO t1 VALUES +(1, 1), +(2, 1), +(3, 2); +$query; +id key1 +1 1 +2 1 +3 2 +drop table t1; +# +# End of 10.11 tests +# set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/range.test b/mysql-test/main/range.test index 9bff8b5d683..ae3bc84aed0 100644 --- a/mysql-test/main/range.test +++ b/mysql-test/main/range.test @@ -2558,6 +2558,32 @@ DROP TABLE t1; --echo # End of 10.5 tests --echo # +--echo # +--echo # MDEV-37913: disable_index_merge_plans causes SELECT data loss when more than 100 ORs +--echo # +CREATE TABLE t1 ( + id int primary key, + key1 int, + index(key1) +); + +INSERT INTO t1 VALUES +(1, 1), +(2, 1), +(3, 2); + +let $query=` + select concat('select * from t1 where (key1 = 2 AND id = 3) ', + REPEAT(' OR (key1 = 1)', 100)) +`; + +evalp $query; + +drop table t1; + +--echo # +--echo # End of 10.11 tests +--echo # set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index accf79d9c49..3e7048e1e46 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -3792,6 +3792,27 @@ DROP TABLE t1; # # End of 10.5 tests # +# +# MDEV-37913: disable_index_merge_plans causes SELECT data loss when more than 100 ORs +# +CREATE TABLE t1 ( +id int primary key, +key1 int, +index(key1) +); +INSERT INTO t1 VALUES +(1, 1), +(2, 1), +(3, 2); +$query; +id key1 +1 1 +2 1 +3 2 +drop table t1; +# +# End of 10.11 tests +# set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent_sample_pages= @innodb_stats_persistent_sample_pages_save; diff --git a/mysql-test/main/sp-bugs2.result b/mysql-test/main/sp-bugs2.result index 71879aeb815..2a5ebf71e30 100644 --- a/mysql-test/main/sp-bugs2.result +++ b/mysql-test/main/sp-bugs2.result @@ -1,3 +1,6 @@ +# +# MDEV-6610 Assertion `thd->is_error() || thd->killed' failed in mysql_execute_command on executing an SP with repeated CREATE TABLE .. SELECT +# CREATE TABLE t1 (i INT); SET @a = 2; CREATE TABLE IF NOT EXISTS t2 (i INT) ENGINE = MyISAM @@ -94,6 +97,34 @@ CALL p1(); # Clean up DROP FUNCTION cnt; DROP PROCEDURE p1; +# +# MDEV-37710 ASAN errors in find_type2 upon executing a procedure from sys schema +# +set names utf8mb3 collate utf8mb3_general_ci; +create procedure p1() +begin +declare found int; +repeat +set found = exists (select * from information_schema.routines where routine_name='f'); +if (sys.ps_is_consumer_enabled('events_waits_history_long') = 'yes') then +select * from mysql.user; +end if; +select release_all_locks(); +until found end repeat; +end$$ +select get_lock('p1', 300); +get_lock('p1', 300) +1 +call p1(); +connect con1,localhost,root,,; +select get_lock('p1', 300); +get_lock('p1', 300) +1 +create function f() returns int return 1; +connection default; +drop function f; +drop procedure p1; +set names utf8mb3; # End of 10.11 tests # # MDEV-26115: Crash when calling stored function in FOR loop argument diff --git a/mysql-test/main/sp-bugs2.test b/mysql-test/main/sp-bugs2.test index 268a6bd858a..2f0c933e7be 100644 --- a/mysql-test/main/sp-bugs2.test +++ b/mysql-test/main/sp-bugs2.test @@ -1,6 +1,6 @@ -# -# MDEV-6610 Assertion `thd->is_error() || thd->killed' failed in mysql_execute_command on executing an SP with repeated CREATE TABLE .. SELECT -# +--echo # +--echo # MDEV-6610 Assertion `thd->is_error() || thd->killed' failed in mysql_execute_command on executing an SP with repeated CREATE TABLE .. SELECT +--echo # CREATE TABLE t1 (i INT); SET @a = 2; @@ -97,6 +97,35 @@ CALL p1(); DROP FUNCTION cnt; DROP PROCEDURE p1; +--echo # +--echo # MDEV-37710 ASAN errors in find_type2 upon executing a procedure from sys schema +--echo # +set names utf8mb3 collate utf8mb3_general_ci; +delimiter $$; +create procedure p1() +begin + declare found int; + repeat + set found = exists (select * from information_schema.routines where routine_name='f'); + if (sys.ps_is_consumer_enabled('events_waits_history_long') = 'yes') then + select * from mysql.user; + end if; + select release_all_locks(); + until found end repeat; +end$$ +delimiter ;$$ +select get_lock('p1', 300); +--send call p1() +--connect con1,localhost,root,, +select get_lock('p1', 300); +create function f() returns int return 1; +--connection default +--disable_result_log +--reap +--enable_result_log +drop function f; +drop procedure p1; +set names utf8mb3; --echo # End of 10.11 tests diff --git a/mysql-test/main/sp-default-param.result b/mysql-test/main/sp-default-param.result index 9a6867a467d..7cef0fe9916 100644 --- a/mysql-test/main/sp-default-param.result +++ b/mysql-test/main/sp-default-param.result @@ -130,85 +130,4 @@ SET p2 = p2 + 1; END; DELIMITER ;$$ ERROR 42000: This version of MariaDB doesn't yet support 'IN sparam1 DEFAULT , OUT spparam2 ' -# -# MDEV-37489: SIGSEGV in get_param_default_value | store_schema_params -# -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) -BEGIN -SELECT x; -END; -// -SET SESSION max_session_mem_used=8192; -CALL p0(); -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET @@max_session_mem_used=DEFAULT; -CALL p0(); -ERROR 42000: FUNCTION test.func does not exist -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; -SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE -def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -# with func() defined -CREATE FUNCTION func(x INT DEFAULT 10) RETURNS INT -BEGIN -RETURN x; -END; -// -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) -BEGIN -SELECT x; -END; -// -SET SESSION max_session_mem_used=8192; -CALL p0(); -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET @@max_session_mem_used=DEFAULT; -CALL p0(); -x -10 -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; -SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE -def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -# with multiple functions -CREATE FUNCTION func2(x INT DEFAULT 10) RETURNS INT -BEGIN -RETURN x; -END; -// -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2()) -BEGIN -SELECT x, y; -END; -// -SET SESSION max_session_mem_used=8192; -CALL p0(); -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET @@max_session_mem_used=DEFAULT; -CALL p0(); -x y -10 10 -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; -SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE -def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -def test p0 2 IN y int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -# with function and constant default param -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2(), z INT DEFAULT 10) -BEGIN -SELECT x, y, z; -END; -// -SET SESSION max_session_mem_used=8192; -CALL p0(); -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET @@max_session_mem_used=DEFAULT; -CALL p0(); -x y z -10 10 10 -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; -SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE -def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -def test p0 2 IN y int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -def test p0 3 IN z int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -DROP PROCEDURE p0; -DROP FUNCTION func; -DROP FUNCTION func2; # End of 11.8 tests diff --git a/mysql-test/main/sp-default-param.test b/mysql-test/main/sp-default-param.test index f615ee793e6..cc30b6d78f6 100644 --- a/mysql-test/main/sp-default-param.test +++ b/mysql-test/main/sp-default-param.test @@ -139,96 +139,4 @@ BEGIN END; DELIMITER ;$$ ---echo # ---echo # MDEV-37489: SIGSEGV in get_param_default_value | store_schema_params ---echo # - ---DELIMITER // -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) -BEGIN - SELECT x; -END; -// ---DELIMITER ; - -SET SESSION max_session_mem_used=8192; ---ERROR ER_OPTION_PREVENTS_STATEMENT -CALL p0(); - -SET @@max_session_mem_used=DEFAULT; ---ERROR ER_SP_DOES_NOT_EXIST -CALL p0(); - -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; - ---echo # with func() defined ---DELIMITER // -CREATE FUNCTION func(x INT DEFAULT 10) RETURNS INT -BEGIN - RETURN x; -END; -// - -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) -BEGIN - SELECT x; -END; -// ---DELIMITER ; - -SET SESSION max_session_mem_used=8192; ---ERROR ER_OPTION_PREVENTS_STATEMENT -CALL p0(); - -SET @@max_session_mem_used=DEFAULT; -CALL p0(); - -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; - ---echo # with multiple functions ---DELIMITER // -CREATE FUNCTION func2(x INT DEFAULT 10) RETURNS INT -BEGIN - RETURN x; -END; -// - -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2()) -BEGIN - SELECT x, y; -END; -// ---DELIMITER ; - -SET SESSION max_session_mem_used=8192; ---ERROR ER_OPTION_PREVENTS_STATEMENT -CALL p0(); - -SET @@max_session_mem_used=DEFAULT; -CALL p0(); - -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; - ---echo # with function and constant default param ---DELIMITER // -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2(), z INT DEFAULT 10) -BEGIN - SELECT x, y, z; -END; -// ---DELIMITER ; - -SET SESSION max_session_mem_used=8192; ---ERROR ER_OPTION_PREVENTS_STATEMENT -CALL p0(); - -SET @@max_session_mem_used=DEFAULT; -CALL p0(); - -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; - -DROP PROCEDURE p0; -DROP FUNCTION func; -DROP FUNCTION func2; - --echo # End of 11.8 tests diff --git a/mysql-test/suite/compat/oracle/r/sp-default-param.result b/mysql-test/suite/compat/oracle/r/sp-default-param.result index 7cbe7b18612..dc3374c9274 100644 --- a/mysql-test/suite/compat/oracle/r/sp-default-param.result +++ b/mysql-test/suite/compat/oracle/r/sp-default-param.result @@ -222,91 +222,4 @@ SET p2 = p2 + 1; END; DELIMITER ;$$ ERROR 42000: This version of MariaDB doesn't yet support 'sparam1 IN DEFAULT , spparam2 OUT ' -# -# MDEV-37489: SIGSEGV in get_param_default_value | store_schema_params -# -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) -AS -BEGIN -SELECT x; -END; -// -SET SESSION max_session_mem_used=8192; -CALL p0(); -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET @@max_session_mem_used=DEFAULT; -CALL p0(); -ERROR 42000: FUNCTION test.func does not exist -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; -SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE -def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -# with func() defined -CREATE FUNCTION func(x INT DEFAULT 10) RETURN INT -AS -BEGIN -RETURN x; -END; -// -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) -AS -BEGIN -SELECT x; -END; -// -SET SESSION max_session_mem_used=8192; -CALL p0(); -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET @@max_session_mem_used=DEFAULT; -CALL p0(); -x -10 -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; -SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE -def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -# with multiple functions -CREATE FUNCTION func2(x INT DEFAULT 10) RETURN INT -AS -BEGIN -RETURN x; -END; -// -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2()) -AS -BEGIN -SELECT x, y; -END; -// -SET SESSION max_session_mem_used=8192; -CALL p0(); -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET @@max_session_mem_used=DEFAULT; -CALL p0(); -x y -10 10 -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; -SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE -def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -def test p0 2 IN y int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -# with function and constant default param -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2(), z INT DEFAULT 10) -AS -BEGIN -SELECT x, y, z; -END; -// -SET SESSION max_session_mem_used=8192; -CALL p0(); -ERROR HY000: The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement -SET @@max_session_mem_used=DEFAULT; -CALL p0(); -x y z -10 10 10 -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; -SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE -def test p0 1 IN x int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -def test p0 2 IN y int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -def test p0 3 IN z int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE -DROP PROCEDURE p0; -DROP FUNCTION func; -DROP FUNCTION func2; # End of 11.8 tests diff --git a/mysql-test/suite/compat/oracle/t/sp-default-param.test b/mysql-test/suite/compat/oracle/t/sp-default-param.test index 45d02b9cdc9..a57828d7164 100644 --- a/mysql-test/suite/compat/oracle/t/sp-default-param.test +++ b/mysql-test/suite/compat/oracle/t/sp-default-param.test @@ -244,102 +244,4 @@ BEGIN END; DELIMITER ;$$ ---echo # ---echo # MDEV-37489: SIGSEGV in get_param_default_value | store_schema_params ---echo # - ---DELIMITER // -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) -AS -BEGIN - SELECT x; -END; -// ---DELIMITER ; - -SET SESSION max_session_mem_used=8192; ---ERROR ER_OPTION_PREVENTS_STATEMENT -CALL p0(); - -SET @@max_session_mem_used=DEFAULT; ---ERROR ER_SP_DOES_NOT_EXIST -CALL p0(); - -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; - ---echo # with func() defined ---DELIMITER // -CREATE FUNCTION func(x INT DEFAULT 10) RETURN INT -AS -BEGIN - RETURN x; -END; -// - -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func()) -AS -BEGIN - SELECT x; -END; -// ---DELIMITER ; - -SET SESSION max_session_mem_used=8192; ---ERROR ER_OPTION_PREVENTS_STATEMENT -CALL p0(); - -SET @@max_session_mem_used=DEFAULT; -CALL p0(); - -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; - ---echo # with multiple functions ---DELIMITER // -CREATE FUNCTION func2(x INT DEFAULT 10) RETURN INT -AS -BEGIN - RETURN x; -END; -// - -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2()) -AS -BEGIN - SELECT x, y; -END; -// ---DELIMITER ; - -SET SESSION max_session_mem_used=8192; ---ERROR ER_OPTION_PREVENTS_STATEMENT -CALL p0(); - -SET @@max_session_mem_used=DEFAULT; -CALL p0(); - -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; - ---echo # with function and constant default param ---DELIMITER // -CREATE OR REPLACE PROCEDURE p0 (x INT DEFAULT func(), y INT DEFAULT func2(), z INT DEFAULT 10) -AS -BEGIN - SELECT x, y, z; -END; -// ---DELIMITER ; - -SET SESSION max_session_mem_used=8192; ---ERROR ER_OPTION_PREVENTS_STATEMENT -CALL p0(); - -SET @@max_session_mem_used=DEFAULT; -CALL p0(); - -SELECT * FROM information_schema.PARAMETERS where specific_name = 'p0'; - -DROP PROCEDURE p0; -DROP FUNCTION func; -DROP FUNCTION func2; - --echo # End of 11.8 tests diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 3cda08c6590..d4237f7886e 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -624,6 +624,41 @@ id name 4 xxx 5 yyy DEALLOCATE PREPARE stmt; +# +# FederatedX error 10000 on multi-table UPDATE/DELETE +# +connection slave; +DROP TABLE IF EXISTS federated.t1, federated.t2; +CREATE TABLE federated.t1 (a int, b int); +INSERT INTO federated.t1 VALUES (1,1), (2,2), (3,3); +CREATE TABLE federated.t2 (a int, b int); +INSERT INTO federated.t2 VALUES (1,1), (2,2), (4,4); +connection master; +DROP TABLE IF EXISTS federated.t1, federated.t2; +CREATE TABLE federated.t1 (a int, b int) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'; +CREATE TABLE federated.t2 (a int, b int) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t2'; +use federated; +# Multi-table UPDATE +UPDATE t1, t2 SET t1.a = 2 WHERE t1.a=t2.a; +# Check the result +SELECT * FROM t1; +a b +2 1 +2 2 +3 3 +# Multi-table DELETE +DELETE FROM t1 USING t1 JOIN t2 ON t1.a = t2.a WHERE t2.b > 1; +SELECT * FROM t1; +a b +3 3 +# Another form of multi-table DELETE +DELETE FROM a1 USING t1 AS a1; +SELECT * FROM t1; +a b DROP TABLES federated.t1, federated.t2, federated.t3, federated.t10, federated.t11; connection slave; diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test index a19effc2f1a..b63121bd789 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.test +++ b/mysql-test/suite/federated/federatedx_create_handlers.test @@ -440,6 +440,50 @@ EXECUTE stmt; EXECUTE stmt; DEALLOCATE PREPARE stmt; +--echo # +--echo # FederatedX error 10000 on multi-table UPDATE/DELETE +--echo # + +connection slave; +DROP TABLE IF EXISTS federated.t1, federated.t2; + +CREATE TABLE federated.t1 (a int, b int); +INSERT INTO federated.t1 VALUES (1,1), (2,2), (3,3); + +CREATE TABLE federated.t2 (a int, b int); +INSERT INTO federated.t2 VALUES (1,1), (2,2), (4,4); + +connection master; +DROP TABLE IF EXISTS federated.t1, federated.t2; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval +CREATE TABLE federated.t1 (a int, b int) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; + +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval +CREATE TABLE federated.t2 (a int, b int) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t2'; + +use federated; + +--echo # Multi-table UPDATE +UPDATE t1, t2 SET t1.a = 2 WHERE t1.a=t2.a; + +--echo # Check the result +SELECT * FROM t1; + +--echo # Multi-table DELETE +DELETE FROM t1 USING t1 JOIN t2 ON t1.a = t2.a WHERE t2.b > 1; + +SELECT * FROM t1; + +--echo # Another form of multi-table DELETE +DELETE FROM a1 USING t1 AS a1; + +SELECT * FROM t1; DROP TABLES federated.t1, federated.t2, federated.t3, federated.t10, federated.t11; diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index bbcba108fee..814642423c9 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -15,3 +15,4 @@ galera_vote_rejoin_ddl : MDEV-35940 Unallowed state transition: donor -> synced galera_vote_rejoin_dml : MDEV-35964 Assertion `ist_seqno >= cc_seqno' failed in galera_vote_rejoin_dml galera_var_notify_cmd : MDEV-37257 WSREP: Notification command failed: 1 (Operation not permitted) galera_var_notify_ssl_ipv6 : MDEV-37257 WSREP: Notification command failed: 1 (Operation not permitted) +MDEV-26266 : cannot work reliably diff --git a/mysql-test/suite/galera/r/MDEV-37056.result b/mysql-test/suite/galera/r/MDEV-37056.result new file mode 100644 index 00000000000..6870e2dbb3e --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-37056.result @@ -0,0 +1,15 @@ +connection node_2; +connection node_1; +connection node_1; +SET SESSION wsrep_on=OFF; +SET default_storage_engine=MYISAM; +CREATE SEQUENCE t; +SET SESSION wsrep_on=ON; +CREATE INDEX idx ON t (a); +ERROR HY000: Sequence 'test.t' table structure is invalid (Sequence tables cannot have any keys) +DROP SEQUENCE t; +SET default_storage_engine='MYISAM'; +CREATE SEQUENCE t INCREMENT BY 0 CACHE=0 ENGINE=InnoDB; +CREATE INDEX c ON t (c); +ERROR HY000: Sequence 'test.t' table structure is invalid (Sequence tables cannot have any keys) +DROP SEQUENCE t; diff --git a/mysql-test/suite/galera/r/MDEV-37857.result b/mysql-test/suite/galera/r/MDEV-37857.result new file mode 100644 index 00000000000..33497c50da6 --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-37857.result @@ -0,0 +1,44 @@ +connection node_2; +connection node_1; +drop table if exists t1; +drop view if exists t1; +connection node_2; +SELECT @@character_set_server, @@collation_server; +@@character_set_server @@collation_server +utf8mb4 utf8mb4_uca1400_ai_ci +SELECT @@character_set_client, @@collation_connection; +@@character_set_client @@collation_connection +latin1 latin1_swedish_ci +connection node_1; +SET NAMES latin1 COLLATE latin1_bin; +SELECT @@character_set_server, @@collation_server; +@@character_set_server @@collation_server +utf8mb4 utf8mb4_uca1400_ai_ci +SELECT @@character_set_client, @@collation_connection; +@@character_set_client @@collation_connection +latin1 latin1_bin +create table t1 (a int); +insert into t1 values (1); +create view v1 as select a from t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_bin +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +connection node_2; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_bin +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci +connection node_1; +DROP VIEW v1; +DROP TABLE t1; +disconnect node_2; +disconnect node_1; diff --git a/mysql-test/suite/galera/r/galera_create_function.result b/mysql-test/suite/galera/r/galera_create_function.result index d01989c0603..67eb582ee06 100644 --- a/mysql-test/suite/galera/r/galera_create_function.result +++ b/mysql-test/suite/galera/r/galera_create_function.result @@ -37,7 +37,7 @@ Function sql_mode Create Function character_set_client collation_connection Data f1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` FUNCTION `f1`(param INTEGER) RETURNS varchar(200) CHARSET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci MODIFIES SQL DATA COMMENT 'f1_comment' -RETURN 'abc' utf8mb4 utf8mb4_uca1400_ai_ci utf8mb4_uca1400_ai_ci +RETURN 'abc' latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci connection node_1; SHOW CREATE FUNCTION f2; Function sql_mode Create Function character_set_client collation_connection Database Collation @@ -53,7 +53,7 @@ f2 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_ NO SQL DETERMINISTIC SQL SECURITY INVOKER -RETURN 123 utf8mb4 utf8mb4_uca1400_ai_ci utf8mb4_uca1400_ai_ci +RETURN 123 latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci SELECT f1(1) = 'abc'; f1(1) = 'abc' 1 diff --git a/mysql-test/suite/galera/r/galera_create_procedure.result b/mysql-test/suite/galera/r/galera_create_procedure.result index c6606519405..f011a33b4a3 100644 --- a/mysql-test/suite/galera/r/galera_create_procedure.result +++ b/mysql-test/suite/galera/r/galera_create_procedure.result @@ -36,7 +36,7 @@ Procedure sql_mode Create Procedure character_set_client collation_connection Da p1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`user1`@`%` PROCEDURE `p1`(IN param1 INTEGER, OUT param2 INTEGER, INOUT param3 INTEGER) MODIFIES SQL DATA COMMENT 'p1_comment' -INSERT INTO t1 VALUES (1) utf8mb4 utf8mb4_uca1400_ai_ci utf8mb4_uca1400_ai_ci +INSERT INTO t1 VALUES (1) latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci connection node_1; SHOW CREATE PROCEDURE p2; Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation @@ -52,7 +52,7 @@ p2 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_ NO SQL DETERMINISTIC SQL SECURITY INVOKER -BEGIN END utf8mb4 utf8mb4_uca1400_ai_ci utf8mb4_uca1400_ai_ci +BEGIN END latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci CALL p1(@a, @b, @c); CALL p2('abc'); connection node_1; diff --git a/mysql-test/suite/galera/r/galera_partitioned_tables.result b/mysql-test/suite/galera/r/galera_partitioned_tables.result index 4d856fefa5a..ccfc9dacc2a 100644 --- a/mysql-test/suite/galera/r/galera_partitioned_tables.result +++ b/mysql-test/suite/galera/r/galera_partitioned_tables.result @@ -59,10 +59,10 @@ t2_v2 CREATE TABLE `t2_v2` ( PARTITIONS 2 SHOW CREATE VIEW x1; View Create View character_set_client collation_connection -x1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `x1` AS select `t1_v2`.`v1` AS `v1`,`t1_v2`.`v2` AS `v2`,`t1_v2`.`v3` AS `v3` from `t1_v2` utf8mb4 utf8mb4_uca1400_ai_ci +x1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `x1` AS select `t1_v2`.`v1` AS `v1`,`t1_v2`.`v2` AS `v2`,`t1_v2`.`v3` AS `v3` from `t1_v2` latin1 latin1_swedish_ci SHOW CREATE VIEW x2; View Create View character_set_client collation_connection -x2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `x2` AS select `t2_v2`.`v1` AS `v1`,`t2_v2`.`v2` AS `v2`,`t2_v2`.`v3` AS `v3` from `t2_v2` utf8mb4 utf8mb4_uca1400_ai_ci +x2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `x2` AS select `t2_v2`.`v1` AS `v1`,`t2_v2`.`v2` AS `v2`,`t2_v2`.`v3` AS `v3` from `t2_v2` latin1 latin1_swedish_ci SELECT * FROM t1_v2; v1 v2 v3 SELECT * FROM t2_v2; @@ -148,7 +148,7 @@ t2 CREATE TABLE `t2` ( PARTITIONS 2 SHOW CREATE VIEW x1; View Create View character_set_client collation_connection -x1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `x1` AS select `t1_v2`.`v1` AS `v1`,`t1_v2`.`v2` AS `v2` from `t1_v2` utf8mb4 utf8mb4_uca1400_ai_ci +x1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `x1` AS select `t1_v2`.`v1` AS `v1`,`t1_v2`.`v2` AS `v2` from `t1_v2` latin1 latin1_swedish_ci SELECT * FROM t1_v2; v1 v2 SELECT * FROM t2; diff --git a/mysql-test/suite/galera/r/galera_sync_wait_show.result b/mysql-test/suite/galera/r/galera_sync_wait_show.result index 864b045f4b1..78d92c5aded 100644 --- a/mysql-test/suite/galera/r/galera_sync_wait_show.result +++ b/mysql-test/suite/galera/r/galera_sync_wait_show.result @@ -15,7 +15,7 @@ connection node_2; SHOW CREATE PROCEDURE p1; Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation p1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() -SELECT 1 FROM DUAL utf8mb4 utf8mb4_uca1400_ai_ci utf8mb4_uca1400_ai_ci +SELECT 1 FROM DUAL latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci DROP PROCEDURE p1; connection node_1; CREATE PROCEDURE p1 () SELECT 1 FROM DUAL; @@ -30,7 +30,7 @@ connection node_2; SHOW CREATE FUNCTION f1; Function sql_mode Create Function character_set_client collation_connection Database Collation f1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) -RETURN 123 utf8mb4 utf8mb4_uca1400_ai_ci utf8mb4_uca1400_ai_ci +RETURN 123 latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci DROP FUNCTION f1; connection node_1; CREATE FUNCTION f1 () RETURNS INTEGER RETURN 123; @@ -45,12 +45,12 @@ CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a'; connection node_2; SHOW CREATE TRIGGER tr1; Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation Created -tr1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a' utf8mb4 utf8mb4_uca1400_ai_ci utf8mb4_uca1400_ai_ci # +tr1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.f1 = 'a' latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci # DROP TABLE t1; connection node_1; CREATE EVENT event1 ON SCHEDULE AT '2038-01-01 23:59:59' DO SELECT 1; connection node_2; SHOW CREATE EVENT event1; Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -event1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `event1` ON SCHEDULE AT '2038-01-01 23:59:59' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO SELECT 1 utf8mb4 utf8mb4_uca1400_ai_ci utf8mb4_uca1400_ai_ci +event1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `event1` ON SCHEDULE AT '2038-01-01 23:59:59' ON COMPLETION NOT PRESERVE DISABLE ON SLAVE DO SELECT 1 latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci DROP EVENT event1; diff --git a/mysql-test/suite/galera/r/view.result b/mysql-test/suite/galera/r/view.result index 4d369b0b691..45d5b422f3f 100644 --- a/mysql-test/suite/galera/r/view.result +++ b/mysql-test/suite/galera/r/view.result @@ -22,16 +22,16 @@ connection node_2; USE test; SHOW CREATE VIEW v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci SHOW CREATE VIEW v2; View Create View character_set_client collation_connection -v2 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci +v2 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci SHOW CREATE VIEW v3; View Create View character_set_client collation_connection -v3 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci +v3 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci SHOW CREATE VIEW v4; View Create View character_set_client collation_connection -v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci +v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci # On node_1 connection node_1; ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; @@ -42,16 +42,16 @@ ALTER ALGORITHM=TEMPTABLE DEFINER=CURRENT_USER VIEW v4 AS SELECT * FROM t1; connection node_2; SHOW CREATE VIEW v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci +v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci SHOW CREATE VIEW v2; View Create View character_set_client collation_connection -v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci SHOW CREATE VIEW v3; View Create View character_set_client collation_connection -v3 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci +v3 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci SHOW CREATE VIEW v4; View Create View character_set_client collation_connection -v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`i` AS `i` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci +v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci # Cleanup DROP VIEW v1, v2, v3, v4; DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MDEV-37056.test b/mysql-test/suite/galera/t/MDEV-37056.test new file mode 100644 index 00000000000..d442c6d99cf --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-37056.test @@ -0,0 +1,18 @@ +--source include/galera_cluster.inc + +--connection node_1 +SET SESSION wsrep_on=OFF; +SET default_storage_engine=MYISAM; +CREATE SEQUENCE t; +SET SESSION wsrep_on=ON; +--error ER_SEQUENCE_INVALID_TABLE_STRUCTURE +CREATE INDEX idx ON t (a); +DROP SEQUENCE t; + +SET default_storage_engine='MYISAM'; +CREATE SEQUENCE t INCREMENT BY 0 CACHE=0 ENGINE=InnoDB; +--error ER_SEQUENCE_INVALID_TABLE_STRUCTURE +CREATE INDEX c ON t (c); + +# cleanup +DROP SEQUENCE t; \ No newline at end of file diff --git a/mysql-test/suite/galera/t/MDEV-37857.test b/mysql-test/suite/galera/t/MDEV-37857.test new file mode 100644 index 00000000000..8a950d39bcf --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-37857.test @@ -0,0 +1,29 @@ +--source include/galera_cluster.inc + +--disable_warnings +drop table if exists t1; +drop view if exists t1; +--enable_warnings + +--connection node_2 +SELECT @@character_set_server, @@collation_server; +SELECT @@character_set_client, @@collation_connection; +--connection node_1 +SET NAMES latin1 COLLATE latin1_bin; +SELECT @@character_set_server, @@collation_server; +SELECT @@character_set_client, @@collation_connection; +create table t1 (a int); +insert into t1 values (1); +create view v1 as select a from t1; +SHOW CREATE VIEW v1; +SHOW CREATE TABLE t1; + +--connection node_2 +SHOW CREATE VIEW v1; +SHOW CREATE TABLE t1; + +--connection node_1 +DROP VIEW v1; +DROP TABLE t1; + +--source include/galera_end.inc diff --git a/mysql-test/suite/innodb/r/innodb_bug12400341.result b/mysql-test/suite/innodb/r/innodb_bug12400341.result deleted file mode 100644 index f4114595819..00000000000 --- a/mysql-test/suite/innodb/r/innodb_bug12400341.result +++ /dev/null @@ -1,18 +0,0 @@ -call mtr.add_suppression("\\[Warning\\] InnoDB: Cannot find a free slot for an undo log. Do you have too"); -drop database if exists mysqltest; -create database mysqltest; -CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB; -select count(*) from information_schema.processlist where command != 'Daemon'; -count(*) -33 -connection default; -CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB; -ERROR HY000: Can't create table `mysqltest`.`testtable` (errno: 177 "Too many active concurrent transactions") -select count(*) from information_schema.processlist where command != 'Daemon'; -count(*) -33 -connection default; -select count(*) from information_schema.processlist where command != 'Daemon'; -count(*) -33 -drop database mysqltest; diff --git a/mysql-test/suite/innodb/t/innodb_bug12400341.test b/mysql-test/suite/innodb/t/innodb_bug12400341.test deleted file mode 100644 index 13eadc70bee..00000000000 --- a/mysql-test/suite/innodb/t/innodb_bug12400341.test +++ /dev/null @@ -1,102 +0,0 @@ -# Test for bug #12400341: INNODB CAN LEAVE ORPHAN IBD FILES AROUND - --- source include/have_debug.inc --- source include/have_innodb.inc --- source include/have_innodb_16k.inc - -# Don't test under valgrind, undo slots of the previous test might exist still -# and cause unstable result. ---source include/not_valgrind.inc -# undo slots of the previous test might exist still ---source include/not_windows.inc - -call mtr.add_suppression("\\[Warning\\] InnoDB: Cannot find a free slot for an undo log. Do you have too"); - ---disable_query_log -set @old_innodb_trx_rseg_n_slots_debug = @@innodb_trx_rseg_n_slots_debug; -set global innodb_trx_rseg_n_slots_debug = 32; ---enable_query_log - ---disable_warnings -drop database if exists mysqltest; ---enable_warnings - -create database mysqltest; -CREATE TABLE mysqltest.transtable (id int unsigned NOT NULL PRIMARY KEY, val int DEFAULT 0) ENGINE=InnoDB; - ---disable_query_log -# -# Insert in 1 transaction which needs over 1 page undo record to avoid the insert_undo cached, -# because the cached insert_undo can be reused at "CREATE TABLE" statement later. -# -START TRANSACTION; -let $c = 1024; -while ($c) -{ - eval INSERT INTO mysqltest.transtable (id) VALUES ($c); - dec $c; -} -COMMIT; - -let $c = 32; -while ($c) -{ - # if failed at here, it might be shortage of file descriptors limit. - connect (con$c,localhost,root,,); - dec $c; -} ---enable_query_log - -select count(*) from information_schema.processlist where command != 'Daemon'; - -# -# fill the all undo slots -# ---disable_query_log -let $c = 32; -while ($c) -{ - connection con$c; - START TRANSACTION; - eval UPDATE mysqltest.transtable SET val = 1 WHERE id = 33 - $c; - dec $c; -} ---enable_query_log - -connection default; - ---error ER_CANT_CREATE_TABLE -CREATE TABLE mysqltest.testtable (id int unsigned not null primary key) ENGINE=InnoDB; - -select count(*) from information_schema.processlist where command != 'Daemon'; - ---disable_query_log -let $c = 32; -while ($c) -{ - connection con$c; - ROLLBACK; - dec $c; -} ---enable_query_log - -connection default; -select count(*) from information_schema.processlist where command != 'Daemon'; - ---disable_query_log -let $c = 32; -while ($c) -{ - disconnect con$c; - dec $c; -} ---enable_query_log - -# -# If the isolated .ibd file remained, the drop database should fail. -# -drop database mysqltest; - ---disable_query_log -set global innodb_trx_rseg_n_slots_debug = @old_innodb_trx_rseg_n_slots_debug; ---enable_query_log diff --git a/mysql-test/suite/innodb_gis/r/rtree_split.result b/mysql-test/suite/innodb_gis/r/rtree_split.result index 74b44e8cbc1..4efefdcd66a 100644 --- a/mysql-test/suite/innodb_gis/r/rtree_split.result +++ b/mysql-test/suite/innodb_gis/r/rtree_split.result @@ -72,4 +72,108 @@ INSERT INTO t1 SELECT POINTFROMTEXT ('POINT(0 0)') FROM seq_1_to_6; ROLLBACK; SET GLOBAL innodb_limit_optimistic_insert_debug=@save_limit; DROP TABLE t1; +# +# MDEV-27675 Incorrect r-tree split after group +# assignment causes page overflow +# +CREATE TABLE t1 (f1 INT, f2 INT, f3 VARCHAR(2500), +f4 MULTIPOLYGON NOT NULL, +PRIMARY KEY (f1,f2,f3), SPATIAL(f4)) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(1,1,'id',MULTIPOLYGONFromText('MULTIPOLYGON(((0.12 0.53,0.23 0.92,0.12 0.53)))')), +(2,2,REPEAT('s',853),MULTIPOLYGONFromText('MULTIPOLYGON(((0.09 0.71,0.92 0.49,0.09 0.71)))')), +(3,3,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.62 0.71,0.62 0.71)))')), +(4,4,'j',MULTIPOLYGONFromText('MULTIPOLYGON(((0.00 0.06,0.40 0.39,0.61 0.20,0.69 0.91,0.13 0.45,0.71 0.49,0.81 0.52,0.08 0.02,0.00 0.06)))')), +(5,5,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.05 0.20,0.45 0.96,0.59 0.46,0.26 0.12,0.45 0.68,0.41 0.10,0.05 0.20)))')), +(6,6,'j',MULTIPOLYGONFromText('MULTIPOLYGON(((0.30 0.09,0.42 0.27,0.96 0.83,0.81 0.89,0.42 0.16,0.89 0.64,0.30 0.09)))')), +(7,7,'f',MULTIPOLYGONFromText('MULTIPOLYGON(((0.62 0.42,0.12 0.70,0.07 0.24,0.10 0.07,0.92 0.29,0.20 0.52,0.62 0.42)))')), +(8,8,'a',MULTIPOLYGONFromText('MULTIPOLYGON(((0.74 0.96,0.80 0.93,0.61 0.40,0.23 0.49,0.79 0.96,0.67 0.30,0.67 0.25,0.74 0.96)))')), +(9,9,'j',MULTIPOLYGONFromText('MULTIPOLYGON(((0.18 0.56,0.03 0.48,0.89 0.30,0.79 0.85,0.40 0.92,0.47 0.34,0.38 0.48,0.18 0.56)))')), +(10,10,'ko',MULTIPOLYGONFromText('MULTIPOLYGON(((0.60 0.23,0.03 0.43,0.33 0.94,0.20 0.37,0.60 0.23)))')), +(11,11,'o',MULTIPOLYGONFromText('MULTIPOLYGON(((0.94 0.33,0.16 0.47,0.94 0.33)))')), +(12,12,'bs',MULTIPOLYGONFromText('MULTIPOLYGON(((0.78 0.81,0.71 0.29,0.03 0.85,0.54 0.16,0.23 0.20,0.86 0.77,0.41 0.96,0.85 0.67,0.78 0.81)))')), +(13,13,'z',MULTIPOLYGONFromText('MULTIPOLYGON(((0.70 0.92,0.61 0.64,0.05 0.75,0.60 1.00,0.47 0.14,0.70 0.92)))')), +(14,14,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.03 0.78,0.83 0.08,0.18 0.49,0.02 0.88,0.62 0.46,0.25 0.53,0.03 0.78)))')), +(15,15,'oaz',MULTIPOLYGONFromText('MULTIPOLYGON(((0.12 0.22,0.73 0.35,0.08 0.39,0.23 0.31,0.84 0.19,0.46 0.77,0.63 0.69,0.12 0.22)))')), +(16,16,'a',MULTIPOLYGONFromText('MULTIPOLYGON(((0.50 0.49,0.48 0.69,0.25 0.87,0.85 0.62,0.96 0.28,0.07 0.70,0.45 0.79,0.87 0.36,0.50 0.49)))')), +(17,17,'cj',MULTIPOLYGONFromText('MULTIPOLYGON(((0.72 0.93,0.03 0.94,0.77 0.06,0.29 0.76,0.82 0.68,0.16 0.59,0.15 0.73,0.72 0.93)))')), +(18,18,REPEAT('r',149),MULTIPOLYGONFromText('MULTIPOLYGON(((0.02 0.67,0.05 0.90,0.68 0.02,0.02 0.67)))')), +(19,19,'ihb',MULTIPOLYGONFromText('MULTIPOLYGON(((0.61 0.40,0.77 0.06,0.61 0.40)),((0.43 0.52,0.77 0.27,0.31 0.49,0.43 0.52)))')), +(20,20,'h',MULTIPOLYGONFromText('MULTIPOLYGON(((0.37 0.98,0.88 0.84,0.18 0.47,0.15 0.77,0.82 0.92,0.66 0.55,0.60 0.02,0.17 0.09,0.37 0.98)))')), +(21,21,'i',MULTIPOLYGONFromText('MULTIPOLYGON(((0.89 0.55,0.85 0.85,0.68 0.24,0.20 0.42,0.67 0.36,0.35 0.25,0.48 0.20,0.89 0.55)))')), +(22,22,'q',MULTIPOLYGONFromText('MULTIPOLYGON(((0.67 0.40,0.63 0.18,0.80 0.66,0.65 0.47,0.66 0.56,0.64 0.97,0.00 0.92,0.66 0.18,0.67 0.40)))')), +(23,23,'kh',MULTIPOLYGONFromText('MULTIPOLYGON(((0.89 0.31,0.33 0.68,0.75 0.35,0.40 0.57,0.94 0.91,0.88 0.23,0.89 0.31)))')), +(24,24,'hbtgc',MULTIPOLYGONFromText('MULTIPOLYGON(((0.99 0.12,0.73 0.75,0.46 0.85,0.55 0.92,0.12 0.44,0.22 0.13,0.11 0.61,0.99 0.12)))')), +(25,25,REPEAT('t',71),MULTIPOLYGONFromText('MULTIPOLYGON(((0.72 0.06,0.31 0.98,0.95 0.02,0.84 0.77,0.46 0.09,0.63 0.92,0.35 0.90,0.72 0.06)))')), +(26,26,'g',MULTIPOLYGONFromText('MULTIPOLYGON(((0.18 0.27,0.28 0.15,0.18 0.27)),((0.22 0.55,0.22 0.55)),((0.28 0.70,0.28 0.70)))')), +(27,27,'c',MULTIPOLYGONFromText('MULTIPOLYGON(((0.72 0.28,0.62 0.71,0.04 1.00,0.12 0.57,0.72 0.28)))')), +(28,28,REPEAT('q',885),MULTIPOLYGONFromText('MULTIPOLYGON(((0.70 0.04,0.62 0.29,0.42 0.82,0.90 0.87,0.79 0.69,0.59 0.99,0.24 0.24,0.69 0.96,0.70 0.04)))')), +(29,29,'oy',MULTIPOLYGONFromText('MULTIPOLYGON(((0.23 0.87,0.51 0.65,0.70 0.97,0.44 0.14,0.25 0.83,0.23 0.87)))')), +(30,30,REPEAT('k',1684),MULTIPOLYGONFromText('MULTIPOLYGON(((0.99 0.78,0.78 0.99,0.76 0.51,0.25 0.31,0.13 0.86,0.16 0.11,0.45 0.94,0.23 0.98,0.99 0.78)))')), +(31,31,'ylsmiix',MULTIPOLYGONFromText('MULTIPOLYGON(((0.85 0.35,0.03 0.75,0.18 0.31,0.84 0.36,0.92 0.72,0.52 0.93,0.65 0.10,0.55 0.80,0.85 0.35)))')), +(32,32,'ojouw',MULTIPOLYGONFromText('MULTIPOLYGON(((0.72 0.00,0.83 0.45,0.32 0.62,0.36 0.40,0.19 0.95,0.50 0.38,0.30 0.76,0.72 0.00)))')), +(33,33,'ou',MULTIPOLYGONFromText('MULTIPOLYGON(((0.98 0.02,0.01 0.23,0.27 0.11,0.98 0.02)),((0.44 0.54,0.44 0.54)),((0.86 0.97,0.86 0.97)))')), +(34,34,'u',MULTIPOLYGONFromText('MULTIPOLYGON(((0.13 0.07,0.29 0.09,0.53 0.79,0.85 0.66,0.64 0.17,0.22 0.18,0.35 0.39,0.30 0.28,0.13 0.07)))')), +(35,35,'sax',MULTIPOLYGONFromText('MULTIPOLYGON(((0.26 0.03,0.24 0.93,0.15 0.48,0.26 0.03)),((0.73 0.46,0.35 0.63,0.73 0.46)))')), +(36,36,'xmet',MULTIPOLYGONFromText('MULTIPOLYGON(((0.23 0.35,0.35 0.82,0.23 0.35)),((0.29 0.61,0.82 0.54,0.29 0.61)))')), +(37,37,REPEAT('e',276),MULTIPOLYGONFromText('MULTIPOLYGON(((0.65 0.67,0.65 0.67)))')), +(38,38,'ty',MULTIPOLYGONFromText('MULTIPOLYGON(((0.43 0.44,0.64 0.76,0.92 0.59,0.73 0.23,0.43 0.44)))')), +(39,39,'yq',MULTIPOLYGONFromText('MULTIPOLYGON(((0.84 0.27,0.19 0.67,0.84 0.27)),((0.55 0.13,0.39 0.64,0.21 0.70,0.18 0.45,0.55 0.13)))')), +(40,40,'hcsv',MULTIPOLYGONFromText('MULTIPOLYGON(((0.61 0.79,0.83 0.16,0.63 0.80,0.78 0.28,0.88 0.66,0.61 0.79)))')), +(41,41,'csvhlr',MULTIPOLYGONFromText('MULTIPOLYGON(((0.82 0.24,0.31 0.52,0.61 0.67,0.99 0.90,0.05 0.73,0.52 0.18,0.71 0.87,0.82 0.24)))')), +(42,42,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.09 0.21,0.37 0.57,0.81 0.75,0.61 0.16,0.48 0.17,0.29 0.28,0.72 0.46,0.09 0.21)))')), +(43,43,'wd',MULTIPOLYGONFromText('MULTIPOLYGON(((0.06 0.25,0.52 0.23,0.02 0.05,0.06 0.25)),((0.70 0.52,0.44 0.46,0.95 0.47,0.70 0.52)))')), +(44,44,'dg',MULTIPOLYGONFromText('MULTIPOLYGON(((0.81 0.28,0.19 0.17,0.81 0.28)))')), +(45,45,'qtqkyyhkayeoopxmexd',MULTIPOLYGONFromText('MULTIPOLYGON(((0.80 0.66,0.81 0.12,0.83 0.31,0.52 0.29,0.08 0.04,0.80 0.66)))')), +(46,46,'tqk',MULTIPOLYGONFromText('MULTIPOLYGON(((0.95 0.08,0.95 0.08)),((0.09 0.31,0.09 0.31)),((0.38 0.75,0.30 0.04,0.38 0.75)))')), +(47,47,REPEAT('q',925),MULTIPOLYGONFromText('MULTIPOLYGON(((0.56 0.73,0.87 0.11,0.37 0.86,0.48 0.05,0.82 0.55,0.25 0.06,0.19 0.85,0.10 0.75,0.56 0.73)))')), +(48,48,'yhk',MULTIPOLYGONFromText('MULTIPOLYGON(((0.06 0.67,0.41 0.51,0.03 0.83,0.40 0.20,0.16 0.87,0.16 0.07,0.29 0.52,0.06 0.67)))')), +(49,49,'k',MULTIPOLYGONFromText('MULTIPOLYGON(((0.16 0.14,0.16 0.14)),((0.97 0.69,0.45 0.32,0.45 0.38,0.97 0.69)))')), +(50,50,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.70 0.00,0.70 0.00)),((0.88 0.53,0.90 0.16,0.88 0.53)))')), +(51,51,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.48 0.06,0.45 0.05,0.03 0.12,0.27 0.80,0.22 0.75,0.53 0.55,0.48 0.06)))')), +(52,52,'o',MULTIPOLYGONFromText('MULTIPOLYGON(((0.32 0.76,0.17 0.43,0.32 0.76)),((0.40 0.79,0.40 0.79)),((0.42 0.34,0.42 0.34)))')), +(53,53,'pxme',MULTIPOLYGONFromText('MULTIPOLYGON(((0.44 0.08,0.02 0.74,0.26 0.21,0.75 0.42,0.91 0.32,0.24 0.65,0.67 0.50,0.44 0.08)))')), +(54,54,'m',MULTIPOLYGONFromText('MULTIPOLYGON(((0.86 0.13,0.21 0.34,0.00 0.87,0.76 0.23,0.69 0.73,0.13 0.63,0.86 0.13)))')), +(55,55,'mex',MULTIPOLYGONFromText('MULTIPOLYGON(((0.84 0.11,0.63 0.13,0.51 0.81,0.58 0.25,0.53 0.29,0.53 0.42,0.84 0.11)))')), +(56,56,REPEAT('e',504),MULTIPOLYGONFromText('MULTIPOLYGON(((0.27 0.84,0.65 0.26,0.75 0.44,0.29 0.52,0.27 0.84)))')), +(57,57,'i',MULTIPOLYGONFromText('MULTIPOLYGON(((0.71 0.84,0.77 0.27,0.45 0.71,0.91 0.01,0.84 0.35,0.71 0.84)))')), +(58,58,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.12 0.36,0.02 0.47,0.57 0.76,0.15 0.54,0.12 0.36)))')), +(59,59,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.77 0.80,0.25 0.69,0.34 0.68,0.77 0.80)))')), +(60,60,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.57 0.30,0.58 0.81,0.57 0.30)))')), +(61,61,'nh',MULTIPOLYGONFromText('MULTIPOLYGON(((0.42 0.99,0.42 0.99)))')), +(62,62,'hwi',MULTIPOLYGONFromText('MULTIPOLYGON(((0.40 0.50,0.97 0.34,0.60 0.75,0.26 0.74,0.40 0.50)))')), +(63,63,'id',MULTIPOLYGONFromText('MULTIPOLYGON(((0.30 0.67,0.13 0.43,0.16 0.64,0.04 0.72,0.95 0.87,0.83 0.24,0.17 0.82,0.30 0.67)))')), +(64,64,'toy',MULTIPOLYGONFromText('MULTIPOLYGON(((0.68 0.75,0.92 0.90,0.68 0.75)),((0.58 0.03,0.41 0.09,0.62 0.05,0.58 0.03)))')), +(65,65,'yhawdptl',MULTIPOLYGONFromText('MULTIPOLYGON(((0.95 0.50,0.61 0.35,0.78 0.07,0.67 0.43,0.50 0.70,0.48 0.98,0.95 0.50)))')), +(66,66,'gs',MULTIPOLYGONFromText('MULTIPOLYGON(((0.59 0.06,0.12 0.94,0.05 0.90,0.99 0.22,0.13 0.55,0.59 0.06)))')), +(67,67,'bplb',MULTIPOLYGONFromText('MULTIPOLYGON(((0.33 0.90,0.54 0.11,0.05 0.04,0.59 0.66,0.33 0.90)))')), +(68,68,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.50 0.52,0.23 0.54,0.80 0.14,0.88 0.70,0.13 0.67,0.68 0.66,0.50 0.52)))')), +(69,69,'p',MULTIPOLYGONFromText('MULTIPOLYGON(((0.07 0.99,0.11 0.79,0.07 0.99)),((0.50 0.22,0.77 0.58,0.50 0.22)))')), +(70,70,'l',MULTIPOLYGONFromText('MULTIPOLYGON(((0.21 0.75,0.21 0.75)))')), +(71,71,'rwkqhip',MULTIPOLYGONFromText('MULTIPOLYGON(((0.99 0.89,0.25 0.77,0.99 0.89)))')), +(72,72,'n',MULTIPOLYGONFromText('MULTIPOLYGON(((0.01 0.10,0.01 0.20,0.01 0.10)),((0.83 0.75,0.29 0.21,0.83 0.75)))')), +(73,73,'q',MULTIPOLYGONFromText('MULTIPOLYGON(((0.12 0.03,0.51 0.05,0.27 0.77,0.74 0.06,0.12 0.03)))')), +(74,74,'hipd',MULTIPOLYGONFromText('MULTIPOLYGON(((0.89 0.94,0.54 0.92,0.37 0.71,0.89 0.94)))')), +(75,75,'ipdec',MULTIPOLYGONFromText('MULTIPOLYGON(((0.50 0.48,0.07 0.31,0.19 0.23,0.51 0.74,0.50 0.48)))')), +(76,76,'pde',MULTIPOLYGONFromText('MULTIPOLYGON(((0.79 0.42,0.61 0.98,0.13 0.85,0.52 0.16,0.79 0.42)))')), +(77,77,REPEAT('e',1432),MULTIPOLYGONFromText('MULTIPOLYGON(((0.78 0.29,0.42 0.20,0.88 0.86,0.99 0.81,0.78 0.29)))')), +(78,78,'cyhr',MULTIPOLYGONFromText('MULTIPOLYGON(((0.61 0.16,0.62 0.19,0.61 0.16)),((0.62 0.94,0.65 0.53,0.15 0.25,0.71 0.41,0.62 0.94)),((0.67 0.63,0.86 0.60,0.67 0.63)))')), +(79,79,'n',MULTIPOLYGONFromText('MULTIPOLYGON(((0.39 0.89,0.25 0.77,0.22 0.21,0.51 0.19,0.71 0.51,0.39 0.89)))')), +(80,80,'y',MULTIPOLYGONFromText('MULTIPOLYGON(((0.29 0.36,0.29 0.36)))')), +(81,81,'r',MULTIPOLYGONFromText('MULTIPOLYGON(((0.05 0.94,0.93 0.37,0.22 0.07,0.73 0.75,0.99 0.35,0.05 0.94)))')), +(82,82,'w',MULTIPOLYGONFromText('MULTIPOLYGON(((0.33 0.37,0.06 0.59,0.34 0.82,0.73 0.86,0.18 0.78,0.99 0.03,0.33 0.37)))')), +(83,83,REPEAT('g',74),MULTIPOLYGONFromText('MULTIPOLYGON(((0.60 0.54,0.25 0.31,0.60 0.54)))')), +(84,84,REPEAT('s',214),MULTIPOLYGONFromText('MULTIPOLYGON(((0.80 0.34,0.09 0.74,0.47 0.96,0.55 0.19,0.80 0.34)))')), +(85,85,REPEAT('h',223),MULTIPOLYGONFromText('MULTIPOLYGON(((0.76 0.26,0.16 0.85,0.91 0.75,0.64 0.83,0.47 0.02,0.92 0.58,0.76 0.26)))')), +(86,86,'l',MULTIPOLYGONFromText('MULTIPOLYGON(((0.11 0.64,0.41 0.64,0.64 0.64,0.11 0.64)))')), +(87,87,'hj',MULTIPOLYGONFromText('MULTIPOLYGON(((0.66 1.00,0.21 0.96,0.52 0.44,0.94 0.06,0.80 0.39,0.33 0.57,0.30 0.89,0.66 1.00)))')), +(88,88,'axcs',MULTIPOLYGONFromText('MULTIPOLYGON(((0.20 0.66,0.71 0.41,0.32 0.94,0.30 0.66,0.50 0.49,0.60 0.67,0.20 0.66)))')), +(89,89,'cs',MULTIPOLYGONFromText('MULTIPOLYGON(((0.02 0.69,0.80 0.21,0.09 0.23,0.45 0.66,0.10 0.72,0.02 0.69)))')), +(90,90,'f',MULTIPOLYGONFromText('MULTIPOLYGON(((0.87 0.14,0.54 0.83,0.87 0.42,0.36 0.58,0.87 0.14)))')), +(91,91,'icq',MULTIPOLYGONFromText('MULTIPOLYGON(((0.73 0.57,0.36 0.41,0.86 0.33,0.76 0.49,0.44 0.83,0.73 0.57)))')), +(92,92,REPEAT('z',783),MULTIPOLYGONFromText('MULTIPOLYGON(((0.28 0.98,0.05 0.26,0.09 0.59,1.00 0.17,0.55 0.68,0.12 0.04,0.28 0.98)))')), +(93,93,'z',MULTIPOLYGONFromText('MULTIPOLYGON(((0.05 0.89,0.05 0.89)))')), +(94,94,REPEAT('x',1412),MULTIPOLYGONFromText('MULTIPOLYGON(((0.79 0.83,0.12 0.49,0.54 0.63,0.79 0.83)))')), +(95,95,REPEAT('u',2500),MULTIPOLYGONFromText('MULTIPOLYGON(((0.50 0.55,0.13 0.19,0.72 0.06,0.50 0.55)),((0.73 0.92,0.02 0.48,0.73 0.92)))')); +DROP TABLE t1; # End of 10.6 tests diff --git a/mysql-test/suite/innodb_gis/t/rtree_split.test b/mysql-test/suite/innodb_gis/t/rtree_split.test index 78ca9641e96..743132856ae 100644 --- a/mysql-test/suite/innodb_gis/t/rtree_split.test +++ b/mysql-test/suite/innodb_gis/t/rtree_split.test @@ -87,4 +87,109 @@ ROLLBACK; SET GLOBAL innodb_limit_optimistic_insert_debug=@save_limit; DROP TABLE t1; +--echo # +--echo # MDEV-27675 Incorrect r-tree split after group +--echo # assignment causes page overflow +--echo # +CREATE TABLE t1 (f1 INT, f2 INT, f3 VARCHAR(2500), + f4 MULTIPOLYGON NOT NULL, + PRIMARY KEY (f1,f2,f3), SPATIAL(f4)) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(1,1,'id',MULTIPOLYGONFromText('MULTIPOLYGON(((0.12 0.53,0.23 0.92,0.12 0.53)))')), +(2,2,REPEAT('s',853),MULTIPOLYGONFromText('MULTIPOLYGON(((0.09 0.71,0.92 0.49,0.09 0.71)))')), +(3,3,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.62 0.71,0.62 0.71)))')), +(4,4,'j',MULTIPOLYGONFromText('MULTIPOLYGON(((0.00 0.06,0.40 0.39,0.61 0.20,0.69 0.91,0.13 0.45,0.71 0.49,0.81 0.52,0.08 0.02,0.00 0.06)))')), +(5,5,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.05 0.20,0.45 0.96,0.59 0.46,0.26 0.12,0.45 0.68,0.41 0.10,0.05 0.20)))')), +(6,6,'j',MULTIPOLYGONFromText('MULTIPOLYGON(((0.30 0.09,0.42 0.27,0.96 0.83,0.81 0.89,0.42 0.16,0.89 0.64,0.30 0.09)))')), +(7,7,'f',MULTIPOLYGONFromText('MULTIPOLYGON(((0.62 0.42,0.12 0.70,0.07 0.24,0.10 0.07,0.92 0.29,0.20 0.52,0.62 0.42)))')), +(8,8,'a',MULTIPOLYGONFromText('MULTIPOLYGON(((0.74 0.96,0.80 0.93,0.61 0.40,0.23 0.49,0.79 0.96,0.67 0.30,0.67 0.25,0.74 0.96)))')), +(9,9,'j',MULTIPOLYGONFromText('MULTIPOLYGON(((0.18 0.56,0.03 0.48,0.89 0.30,0.79 0.85,0.40 0.92,0.47 0.34,0.38 0.48,0.18 0.56)))')), +(10,10,'ko',MULTIPOLYGONFromText('MULTIPOLYGON(((0.60 0.23,0.03 0.43,0.33 0.94,0.20 0.37,0.60 0.23)))')), +(11,11,'o',MULTIPOLYGONFromText('MULTIPOLYGON(((0.94 0.33,0.16 0.47,0.94 0.33)))')), +(12,12,'bs',MULTIPOLYGONFromText('MULTIPOLYGON(((0.78 0.81,0.71 0.29,0.03 0.85,0.54 0.16,0.23 0.20,0.86 0.77,0.41 0.96,0.85 0.67,0.78 0.81)))')), +(13,13,'z',MULTIPOLYGONFromText('MULTIPOLYGON(((0.70 0.92,0.61 0.64,0.05 0.75,0.60 1.00,0.47 0.14,0.70 0.92)))')), +(14,14,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.03 0.78,0.83 0.08,0.18 0.49,0.02 0.88,0.62 0.46,0.25 0.53,0.03 0.78)))')), +(15,15,'oaz',MULTIPOLYGONFromText('MULTIPOLYGON(((0.12 0.22,0.73 0.35,0.08 0.39,0.23 0.31,0.84 0.19,0.46 0.77,0.63 0.69,0.12 0.22)))')), +(16,16,'a',MULTIPOLYGONFromText('MULTIPOLYGON(((0.50 0.49,0.48 0.69,0.25 0.87,0.85 0.62,0.96 0.28,0.07 0.70,0.45 0.79,0.87 0.36,0.50 0.49)))')), +(17,17,'cj',MULTIPOLYGONFromText('MULTIPOLYGON(((0.72 0.93,0.03 0.94,0.77 0.06,0.29 0.76,0.82 0.68,0.16 0.59,0.15 0.73,0.72 0.93)))')), +(18,18,REPEAT('r',149),MULTIPOLYGONFromText('MULTIPOLYGON(((0.02 0.67,0.05 0.90,0.68 0.02,0.02 0.67)))')), +(19,19,'ihb',MULTIPOLYGONFromText('MULTIPOLYGON(((0.61 0.40,0.77 0.06,0.61 0.40)),((0.43 0.52,0.77 0.27,0.31 0.49,0.43 0.52)))')), +(20,20,'h',MULTIPOLYGONFromText('MULTIPOLYGON(((0.37 0.98,0.88 0.84,0.18 0.47,0.15 0.77,0.82 0.92,0.66 0.55,0.60 0.02,0.17 0.09,0.37 0.98)))')), +(21,21,'i',MULTIPOLYGONFromText('MULTIPOLYGON(((0.89 0.55,0.85 0.85,0.68 0.24,0.20 0.42,0.67 0.36,0.35 0.25,0.48 0.20,0.89 0.55)))')), +(22,22,'q',MULTIPOLYGONFromText('MULTIPOLYGON(((0.67 0.40,0.63 0.18,0.80 0.66,0.65 0.47,0.66 0.56,0.64 0.97,0.00 0.92,0.66 0.18,0.67 0.40)))')), +(23,23,'kh',MULTIPOLYGONFromText('MULTIPOLYGON(((0.89 0.31,0.33 0.68,0.75 0.35,0.40 0.57,0.94 0.91,0.88 0.23,0.89 0.31)))')), +(24,24,'hbtgc',MULTIPOLYGONFromText('MULTIPOLYGON(((0.99 0.12,0.73 0.75,0.46 0.85,0.55 0.92,0.12 0.44,0.22 0.13,0.11 0.61,0.99 0.12)))')), +(25,25,REPEAT('t',71),MULTIPOLYGONFromText('MULTIPOLYGON(((0.72 0.06,0.31 0.98,0.95 0.02,0.84 0.77,0.46 0.09,0.63 0.92,0.35 0.90,0.72 0.06)))')), +(26,26,'g',MULTIPOLYGONFromText('MULTIPOLYGON(((0.18 0.27,0.28 0.15,0.18 0.27)),((0.22 0.55,0.22 0.55)),((0.28 0.70,0.28 0.70)))')), +(27,27,'c',MULTIPOLYGONFromText('MULTIPOLYGON(((0.72 0.28,0.62 0.71,0.04 1.00,0.12 0.57,0.72 0.28)))')), +(28,28,REPEAT('q',885),MULTIPOLYGONFromText('MULTIPOLYGON(((0.70 0.04,0.62 0.29,0.42 0.82,0.90 0.87,0.79 0.69,0.59 0.99,0.24 0.24,0.69 0.96,0.70 0.04)))')), +(29,29,'oy',MULTIPOLYGONFromText('MULTIPOLYGON(((0.23 0.87,0.51 0.65,0.70 0.97,0.44 0.14,0.25 0.83,0.23 0.87)))')), +(30,30,REPEAT('k',1684),MULTIPOLYGONFromText('MULTIPOLYGON(((0.99 0.78,0.78 0.99,0.76 0.51,0.25 0.31,0.13 0.86,0.16 0.11,0.45 0.94,0.23 0.98,0.99 0.78)))')), +(31,31,'ylsmiix',MULTIPOLYGONFromText('MULTIPOLYGON(((0.85 0.35,0.03 0.75,0.18 0.31,0.84 0.36,0.92 0.72,0.52 0.93,0.65 0.10,0.55 0.80,0.85 0.35)))')), +(32,32,'ojouw',MULTIPOLYGONFromText('MULTIPOLYGON(((0.72 0.00,0.83 0.45,0.32 0.62,0.36 0.40,0.19 0.95,0.50 0.38,0.30 0.76,0.72 0.00)))')), +(33,33,'ou',MULTIPOLYGONFromText('MULTIPOLYGON(((0.98 0.02,0.01 0.23,0.27 0.11,0.98 0.02)),((0.44 0.54,0.44 0.54)),((0.86 0.97,0.86 0.97)))')), +(34,34,'u',MULTIPOLYGONFromText('MULTIPOLYGON(((0.13 0.07,0.29 0.09,0.53 0.79,0.85 0.66,0.64 0.17,0.22 0.18,0.35 0.39,0.30 0.28,0.13 0.07)))')), +(35,35,'sax',MULTIPOLYGONFromText('MULTIPOLYGON(((0.26 0.03,0.24 0.93,0.15 0.48,0.26 0.03)),((0.73 0.46,0.35 0.63,0.73 0.46)))')), +(36,36,'xmet',MULTIPOLYGONFromText('MULTIPOLYGON(((0.23 0.35,0.35 0.82,0.23 0.35)),((0.29 0.61,0.82 0.54,0.29 0.61)))')), +(37,37,REPEAT('e',276),MULTIPOLYGONFromText('MULTIPOLYGON(((0.65 0.67,0.65 0.67)))')), +(38,38,'ty',MULTIPOLYGONFromText('MULTIPOLYGON(((0.43 0.44,0.64 0.76,0.92 0.59,0.73 0.23,0.43 0.44)))')), +(39,39,'yq',MULTIPOLYGONFromText('MULTIPOLYGON(((0.84 0.27,0.19 0.67,0.84 0.27)),((0.55 0.13,0.39 0.64,0.21 0.70,0.18 0.45,0.55 0.13)))')), +(40,40,'hcsv',MULTIPOLYGONFromText('MULTIPOLYGON(((0.61 0.79,0.83 0.16,0.63 0.80,0.78 0.28,0.88 0.66,0.61 0.79)))')), +(41,41,'csvhlr',MULTIPOLYGONFromText('MULTIPOLYGON(((0.82 0.24,0.31 0.52,0.61 0.67,0.99 0.90,0.05 0.73,0.52 0.18,0.71 0.87,0.82 0.24)))')), +(42,42,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.09 0.21,0.37 0.57,0.81 0.75,0.61 0.16,0.48 0.17,0.29 0.28,0.72 0.46,0.09 0.21)))')), +(43,43,'wd',MULTIPOLYGONFromText('MULTIPOLYGON(((0.06 0.25,0.52 0.23,0.02 0.05,0.06 0.25)),((0.70 0.52,0.44 0.46,0.95 0.47,0.70 0.52)))')), +(44,44,'dg',MULTIPOLYGONFromText('MULTIPOLYGON(((0.81 0.28,0.19 0.17,0.81 0.28)))')), +(45,45,'qtqkyyhkayeoopxmexd',MULTIPOLYGONFromText('MULTIPOLYGON(((0.80 0.66,0.81 0.12,0.83 0.31,0.52 0.29,0.08 0.04,0.80 0.66)))')), +(46,46,'tqk',MULTIPOLYGONFromText('MULTIPOLYGON(((0.95 0.08,0.95 0.08)),((0.09 0.31,0.09 0.31)),((0.38 0.75,0.30 0.04,0.38 0.75)))')), +(47,47,REPEAT('q',925),MULTIPOLYGONFromText('MULTIPOLYGON(((0.56 0.73,0.87 0.11,0.37 0.86,0.48 0.05,0.82 0.55,0.25 0.06,0.19 0.85,0.10 0.75,0.56 0.73)))')), +(48,48,'yhk',MULTIPOLYGONFromText('MULTIPOLYGON(((0.06 0.67,0.41 0.51,0.03 0.83,0.40 0.20,0.16 0.87,0.16 0.07,0.29 0.52,0.06 0.67)))')), +(49,49,'k',MULTIPOLYGONFromText('MULTIPOLYGON(((0.16 0.14,0.16 0.14)),((0.97 0.69,0.45 0.32,0.45 0.38,0.97 0.69)))')), +(50,50,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.70 0.00,0.70 0.00)),((0.88 0.53,0.90 0.16,0.88 0.53)))')), +(51,51,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.48 0.06,0.45 0.05,0.03 0.12,0.27 0.80,0.22 0.75,0.53 0.55,0.48 0.06)))')), +(52,52,'o',MULTIPOLYGONFromText('MULTIPOLYGON(((0.32 0.76,0.17 0.43,0.32 0.76)),((0.40 0.79,0.40 0.79)),((0.42 0.34,0.42 0.34)))')), +(53,53,'pxme',MULTIPOLYGONFromText('MULTIPOLYGON(((0.44 0.08,0.02 0.74,0.26 0.21,0.75 0.42,0.91 0.32,0.24 0.65,0.67 0.50,0.44 0.08)))')), +(54,54,'m',MULTIPOLYGONFromText('MULTIPOLYGON(((0.86 0.13,0.21 0.34,0.00 0.87,0.76 0.23,0.69 0.73,0.13 0.63,0.86 0.13)))')), +(55,55,'mex',MULTIPOLYGONFromText('MULTIPOLYGON(((0.84 0.11,0.63 0.13,0.51 0.81,0.58 0.25,0.53 0.29,0.53 0.42,0.84 0.11)))')), +(56,56,REPEAT('e',504),MULTIPOLYGONFromText('MULTIPOLYGON(((0.27 0.84,0.65 0.26,0.75 0.44,0.29 0.52,0.27 0.84)))')), +(57,57,'i',MULTIPOLYGONFromText('MULTIPOLYGON(((0.71 0.84,0.77 0.27,0.45 0.71,0.91 0.01,0.84 0.35,0.71 0.84)))')), +(58,58,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.12 0.36,0.02 0.47,0.57 0.76,0.15 0.54,0.12 0.36)))')), +(59,59,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.77 0.80,0.25 0.69,0.34 0.68,0.77 0.80)))')), +(60,60,'',MULTIPOLYGONFromText('MULTIPOLYGON(((0.57 0.30,0.58 0.81,0.57 0.30)))')), +(61,61,'nh',MULTIPOLYGONFromText('MULTIPOLYGON(((0.42 0.99,0.42 0.99)))')), +(62,62,'hwi',MULTIPOLYGONFromText('MULTIPOLYGON(((0.40 0.50,0.97 0.34,0.60 0.75,0.26 0.74,0.40 0.50)))')), +(63,63,'id',MULTIPOLYGONFromText('MULTIPOLYGON(((0.30 0.67,0.13 0.43,0.16 0.64,0.04 0.72,0.95 0.87,0.83 0.24,0.17 0.82,0.30 0.67)))')), +(64,64,'toy',MULTIPOLYGONFromText('MULTIPOLYGON(((0.68 0.75,0.92 0.90,0.68 0.75)),((0.58 0.03,0.41 0.09,0.62 0.05,0.58 0.03)))')), +(65,65,'yhawdptl',MULTIPOLYGONFromText('MULTIPOLYGON(((0.95 0.50,0.61 0.35,0.78 0.07,0.67 0.43,0.50 0.70,0.48 0.98,0.95 0.50)))')), +(66,66,'gs',MULTIPOLYGONFromText('MULTIPOLYGON(((0.59 0.06,0.12 0.94,0.05 0.90,0.99 0.22,0.13 0.55,0.59 0.06)))')), +(67,67,'bplb',MULTIPOLYGONFromText('MULTIPOLYGON(((0.33 0.90,0.54 0.11,0.05 0.04,0.59 0.66,0.33 0.90)))')), +(68,68,'b',MULTIPOLYGONFromText('MULTIPOLYGON(((0.50 0.52,0.23 0.54,0.80 0.14,0.88 0.70,0.13 0.67,0.68 0.66,0.50 0.52)))')), +(69,69,'p',MULTIPOLYGONFromText('MULTIPOLYGON(((0.07 0.99,0.11 0.79,0.07 0.99)),((0.50 0.22,0.77 0.58,0.50 0.22)))')), +(70,70,'l',MULTIPOLYGONFromText('MULTIPOLYGON(((0.21 0.75,0.21 0.75)))')), +(71,71,'rwkqhip',MULTIPOLYGONFromText('MULTIPOLYGON(((0.99 0.89,0.25 0.77,0.99 0.89)))')), +(72,72,'n',MULTIPOLYGONFromText('MULTIPOLYGON(((0.01 0.10,0.01 0.20,0.01 0.10)),((0.83 0.75,0.29 0.21,0.83 0.75)))')), +(73,73,'q',MULTIPOLYGONFromText('MULTIPOLYGON(((0.12 0.03,0.51 0.05,0.27 0.77,0.74 0.06,0.12 0.03)))')), +(74,74,'hipd',MULTIPOLYGONFromText('MULTIPOLYGON(((0.89 0.94,0.54 0.92,0.37 0.71,0.89 0.94)))')), +(75,75,'ipdec',MULTIPOLYGONFromText('MULTIPOLYGON(((0.50 0.48,0.07 0.31,0.19 0.23,0.51 0.74,0.50 0.48)))')), +(76,76,'pde',MULTIPOLYGONFromText('MULTIPOLYGON(((0.79 0.42,0.61 0.98,0.13 0.85,0.52 0.16,0.79 0.42)))')), +(77,77,REPEAT('e',1432),MULTIPOLYGONFromText('MULTIPOLYGON(((0.78 0.29,0.42 0.20,0.88 0.86,0.99 0.81,0.78 0.29)))')), +(78,78,'cyhr',MULTIPOLYGONFromText('MULTIPOLYGON(((0.61 0.16,0.62 0.19,0.61 0.16)),((0.62 0.94,0.65 0.53,0.15 0.25,0.71 0.41,0.62 0.94)),((0.67 0.63,0.86 0.60,0.67 0.63)))')), +(79,79,'n',MULTIPOLYGONFromText('MULTIPOLYGON(((0.39 0.89,0.25 0.77,0.22 0.21,0.51 0.19,0.71 0.51,0.39 0.89)))')), +(80,80,'y',MULTIPOLYGONFromText('MULTIPOLYGON(((0.29 0.36,0.29 0.36)))')), +(81,81,'r',MULTIPOLYGONFromText('MULTIPOLYGON(((0.05 0.94,0.93 0.37,0.22 0.07,0.73 0.75,0.99 0.35,0.05 0.94)))')), +(82,82,'w',MULTIPOLYGONFromText('MULTIPOLYGON(((0.33 0.37,0.06 0.59,0.34 0.82,0.73 0.86,0.18 0.78,0.99 0.03,0.33 0.37)))')), +(83,83,REPEAT('g',74),MULTIPOLYGONFromText('MULTIPOLYGON(((0.60 0.54,0.25 0.31,0.60 0.54)))')), +(84,84,REPEAT('s',214),MULTIPOLYGONFromText('MULTIPOLYGON(((0.80 0.34,0.09 0.74,0.47 0.96,0.55 0.19,0.80 0.34)))')), +(85,85,REPEAT('h',223),MULTIPOLYGONFromText('MULTIPOLYGON(((0.76 0.26,0.16 0.85,0.91 0.75,0.64 0.83,0.47 0.02,0.92 0.58,0.76 0.26)))')), +(86,86,'l',MULTIPOLYGONFromText('MULTIPOLYGON(((0.11 0.64,0.41 0.64,0.64 0.64,0.11 0.64)))')), +(87,87,'hj',MULTIPOLYGONFromText('MULTIPOLYGON(((0.66 1.00,0.21 0.96,0.52 0.44,0.94 0.06,0.80 0.39,0.33 0.57,0.30 0.89,0.66 1.00)))')), +(88,88,'axcs',MULTIPOLYGONFromText('MULTIPOLYGON(((0.20 0.66,0.71 0.41,0.32 0.94,0.30 0.66,0.50 0.49,0.60 0.67,0.20 0.66)))')), +(89,89,'cs',MULTIPOLYGONFromText('MULTIPOLYGON(((0.02 0.69,0.80 0.21,0.09 0.23,0.45 0.66,0.10 0.72,0.02 0.69)))')), +(90,90,'f',MULTIPOLYGONFromText('MULTIPOLYGON(((0.87 0.14,0.54 0.83,0.87 0.42,0.36 0.58,0.87 0.14)))')), +(91,91,'icq',MULTIPOLYGONFromText('MULTIPOLYGON(((0.73 0.57,0.36 0.41,0.86 0.33,0.76 0.49,0.44 0.83,0.73 0.57)))')), +(92,92,REPEAT('z',783),MULTIPOLYGONFromText('MULTIPOLYGON(((0.28 0.98,0.05 0.26,0.09 0.59,1.00 0.17,0.55 0.68,0.12 0.04,0.28 0.98)))')), +(93,93,'z',MULTIPOLYGONFromText('MULTIPOLYGON(((0.05 0.89,0.05 0.89)))')), +(94,94,REPEAT('x',1412),MULTIPOLYGONFromText('MULTIPOLYGON(((0.79 0.83,0.12 0.49,0.54 0.63,0.79 0.83)))')), +(95,95,REPEAT('u',2500),MULTIPOLYGONFromText('MULTIPOLYGON(((0.50 0.55,0.13 0.19,0.72 0.06,0.50 0.55)),((0.73 0.92,0.02 0.48,0.73 0.92)))')); +DROP TABLE t1; + --echo # End of 10.6 tests diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result index 484610574a3..cef56670120 100644 --- a/mysql-test/suite/json/r/json_table.result +++ b/mysql-test/suite/json/r/json_table.result @@ -1088,13 +1088,8 @@ show create view v; View Create View character_set_client collation_connection v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `T`.`col1` AS `col1` from JSON_TABLE('{"a": "b"}', '$' COLUMNS (`col1` varchar(32) PATH '$.fooo' DEFAULT 'asdf' ON EMPTY)) `T` latin1 latin1_swedish_ci drop view v; -# # End of 10.6 tests # -# -# Start of 10.9 tests -# -# # MDEV-27743 Remove Lex::charset # SELECT collation(name) @@ -1214,12 +1209,11 @@ name ENUM('Laptop') CHARACTER SET BINARY PATH '$.name') ) AS jt; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ENUM('Laptop') CHARACTER SET BINARY PATH '$.name') ) AS jt' at line 6 -# # End of 10.9 tests # -# # MDEV-27898 CREATE VIEW AS SELECT FROM JSON_TABLE column requires global privileges # +# Beginning of 10.11 tests create view v1 as (select * from json_table('[{"a":"1"}]', '$[*]' columns(a int path '$.a') ) as jt); create user u1@localhost; @@ -1232,7 +1226,58 @@ connection default; DROP VIEW v2; DROP VIEW v1; DROP USER u1@localhost; -# End of 10.11 tests +# +# MDEV-34081: View containing JSON_TABLE does not return JSON +# +CREATE OR REPLACE VIEW test_view AS SELECT * FROM JSON_TABLE(' +[ + { + "caption": "First Element", + "value": 1 + }, + { + "caption": "Second Element", + "value": 2 + } +] +', '$[*]' COLUMNS( +caption VARCHAR(200) PATH '$.caption', +whole_block JSON PATH '$')) t; +SELECT * FROM test_view; +caption whole_block +First Element { + "caption": "First Element", + "value": 1 + } +Second Element { + "caption": "Second Element", + "value": 2 + } +SELECT * FROM JSON_TABLE(' +[ + { + "caption": "First Element", + "value": 1 + }, + { + "caption": "Second Element", + "value": 2 + } +] +', '$[*]' COLUMNS( +caption VARCHAR(200) PATH '$.caption', +whole_block JSON PATH '$')) t; +caption whole_block +First Element { + "caption": "First Element", + "value": 1 + } +Second Element { + "caption": "Second Element", + "value": 2 + } +DROP VIEW test_view; +# End of 10.11 test # # MDEV-29390: Improve coverage for UPDATE and DELETE statements in MTR test suites # @@ -1331,7 +1376,5 @@ Laptop black 20000.00 2 Jacket brown 5000.00 1 Jeans blue 5000.00 2 drop table t1; -# # End of 11.0 tests -# ALTER DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test index 0614b678048..01370cbc2e9 100644 --- a/mysql-test/suite/json/t/json_table.test +++ b/mysql-test/suite/json/t/json_table.test @@ -920,13 +920,7 @@ show create view v; drop view v; ---echo # --echo # End of 10.6 tests ---echo # - ---echo # ---echo # Start of 10.9 tests ---echo # --echo # --echo # MDEV-27743 Remove Lex::charset @@ -1041,14 +1035,14 @@ COLUMNS name ENUM('Laptop') CHARACTER SET BINARY PATH '$.name') ) AS jt; ---echo # --echo # End of 10.9 tests ---echo # --echo # --echo # MDEV-27898 CREATE VIEW AS SELECT FROM JSON_TABLE column requires global privileges --echo # +--echo # Beginning of 10.11 tests + create view v1 as (select * from json_table('[{"a":"1"}]', '$[*]' columns(a int path '$.a') ) as jt); @@ -1066,7 +1060,45 @@ DROP VIEW v2; DROP VIEW v1; DROP USER u1@localhost; ---echo # End of 10.11 tests +--echo # +--echo # MDEV-34081: View containing JSON_TABLE does not return JSON +--echo # + +CREATE OR REPLACE VIEW test_view AS SELECT * FROM JSON_TABLE(' +[ + { + "caption": "First Element", + "value": 1 + }, + { + "caption": "Second Element", + "value": 2 + } +] +', '$[*]' COLUMNS( + caption VARCHAR(200) PATH '$.caption', + whole_block JSON PATH '$')) t; + +SELECT * FROM test_view; + +SELECT * FROM JSON_TABLE(' +[ + { + "caption": "First Element", + "value": 1 + }, + { + "caption": "Second Element", + "value": 2 + } +] +', '$[*]' COLUMNS( + caption VARCHAR(200) PATH '$.caption', + whole_block JSON PATH '$')) t; + +DROP VIEW test_view; + +--echo # End of 10.11 test --echo # --echo # MDEV-29390: Improve coverage for UPDATE and DELETE statements in MTR test suites @@ -1158,8 +1190,6 @@ select * from t1; drop table t1; ---echo # --echo # End of 11.0 tests ---echo # --source include/test_db_charset_restore.inc diff --git a/mysql-test/suite/maria/repair.result b/mysql-test/suite/maria/repair.result index 59164486dde..9e68c723fb1 100644 --- a/mysql-test/suite/maria/repair.result +++ b/mysql-test/suite/maria/repair.result @@ -23,16 +23,6 @@ i 1 UNLOCK TABLES; DROP TABLE t1; -# -# MDEV-23824 SIGSEGV in end_io_cache on REPAIR LOCAL TABLE for Aria table -# -CREATE TABLE t1 (i INT) ENGINE=Aria; -INSERT INTO t1 VALUES (1); -SET max_session_mem_used=50000; -REPAIR LOCAL TABLE t1 USE_FRM; -REPAIR LOCAL TABLE t1; -DROP TABLE t1; -SET max_session_mem_used=default; # MDEV-17223 Assertion `thd->killed != 0' failed in # ha_maria::enable_indexes diff --git a/mysql-test/suite/maria/repair.test b/mysql-test/suite/maria/repair.test index 1f12f5d4e73..af5542f45ec 100644 --- a/mysql-test/suite/maria/repair.test +++ b/mysql-test/suite/maria/repair.test @@ -1,8 +1,3 @@ -# We should not run this test with embedded as we are using -# max_session_mem_used, which causes things to fail/not fail randomly -# as memory usage is different compared to normal server. - ---source include/not_embedded.inc --source include/have_sequence.inc --source include/test_db_charset_latin1.inc @@ -31,20 +26,6 @@ SELECT * FROM t1; UNLOCK TABLES; DROP TABLE t1; ---echo # ---echo # MDEV-23824 SIGSEGV in end_io_cache on REPAIR LOCAL TABLE for Aria table ---echo # - -CREATE TABLE t1 (i INT) ENGINE=Aria; -INSERT INTO t1 VALUES (1); -SET max_session_mem_used=50000; ---disable_result_log -REPAIR LOCAL TABLE t1 USE_FRM; -REPAIR LOCAL TABLE t1; ---enable_result_log -DROP TABLE t1; -SET max_session_mem_used=default; - --echo --echo # MDEV-17223 Assertion `thd->killed != 0' failed in --echo # ha_maria::enable_indexes diff --git a/mysql-test/suite/merge/merge.result b/mysql-test/suite/merge/merge.result index 40de15c074d..679f3fbd312 100644 --- a/mysql-test/suite/merge/merge.result +++ b/mysql-test/suite/merge/merge.result @@ -882,6 +882,7 @@ SELECT COUNT(*) FROM t3 WHERE a=0xDF AND b=2; COUNT(*) 2 DROP TABLE t1,t2,t3; +# End of 4.1 tests create table t1 (b bit(1)); create table t2 (b bit(1)); create table tm (b bit(1)) engine = merge union = (t1,t2); @@ -1007,7 +1008,7 @@ ERROR HY000: Unable to open underlying table which is differently defined or of SELECT * FROM m2; a DROP TABLE t1, t2, m1, m2; -End of 5.0 tests +# End of 5.0 tests create table t1 (c1 int, index(c1)); create table t2 (c1 int, index(c1)) engine=merge union=(t1); insert into t1 values (1); @@ -2419,7 +2420,7 @@ check table tm_temp_temp; Table Op Msg_type Msg_text test.tm_temp_temp check status OK drop temporary table t1_temp, tm_temp_temp; -End of 5.1 tests +# End of 5.1 tests # # MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg # @@ -2550,7 +2551,7 @@ i a b filler 2 999 999 filler-data-FILLER-DATA-qqq drop table t5; drop table t1,t2,t3,t4; -End of 5.3 tests +# End of 5.3 tests CREATE TABLE t1(a INT, KEY(a)) ENGINE=merge; SELECT MAX(a) FROM t1; MAX(a) @@ -3800,10 +3801,8 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status Table is already up to date DEALLOCATE PREPARE stmt; DROP TABLE t1, tmerge; -# # End of 5.5 tests # -# # Additional coverage for refactoring which is made as part # of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege # to allow temp table operations". @@ -3898,7 +3897,7 @@ f foo bar DROP TABLE mrg, t1; -# End of 10.5 tests +# End of 10.0 tests # # MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results # @@ -3921,10 +3920,8 @@ a 2 1 drop table tm, t; -# # End of 10.8 tests # -# # MDEV-35816 ASAN use-after-poison in st_select_lex::print # CREATE TABLE t1 (a INT); @@ -3961,10 +3958,8 @@ a 4 5 DROP TABLE t1; -# # End of 10.11 tests # -# # MDEV-30088 Assertion `cond_selectivity <= 1.0' failed in get_range_limit_read_cost # CREATE TABLE t1 (a TIMESTAMP, KEY(a)) ENGINE=MRG_MyISAM; @@ -4017,10 +4012,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL i1 5 NULL 1 Using index for group-by drop table t1; set use_stat_tables=default; -# # End of 11.0 tests # -# # MDEV-29174: UPDATE of view that uses MERGE table # CREATE TABLE t1 (a int) ENGINE=MERGE; @@ -4029,3 +4022,4 @@ UPDATE v1 SET a=0; DROP VIEW v1; DROP TABLE t1; # End of 11.1 tests +ALTER DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; diff --git a/mysql-test/suite/merge/merge.test b/mysql-test/suite/merge/merge.test index b8687557199..42f510d4d1a 100644 --- a/mysql-test/suite/merge/merge.test +++ b/mysql-test/suite/merge/merge.test @@ -520,7 +520,7 @@ INSERT INTO t2 VALUES ('ss',2),(0xDF,2); SELECT COUNT(*) FROM t3 WHERE a=0xDF AND b=2; DROP TABLE t1,t2,t3; -# End of 4.1 tests +--echo # End of 4.1 tests # # BUG#19648 - Merge table does not work with bit types @@ -629,7 +629,7 @@ SELECT * FROM m1; SELECT * FROM m2; DROP TABLE t1, t2, m1, m2; ---echo End of 5.0 tests +--echo # End of 5.0 tests # @@ -1826,7 +1826,7 @@ alter table tm_temp_temp insert_method=first; check table tm_temp_temp; drop temporary table t1_temp, tm_temp_temp; ---echo End of 5.1 tests +--echo # End of 5.1 tests --echo # --echo # MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg @@ -1863,7 +1863,7 @@ select * from t2, t5 where t5.a=999 and t5.b=999; drop table t5; drop table t1,t2,t3,t4; ---echo End of 5.3 tests +--echo # End of 5.3 tests # # BUG#35274 - merge table doesn't need any base tables, gives error 124 when @@ -2770,9 +2770,7 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t1, tmerge; ---echo # --echo # End of 5.5 tests ---echo # --echo # --echo # Additional coverage for refactoring which is made as part @@ -2853,7 +2851,7 @@ CREATE TABLE mrg (f TEXT) ENGINE=MERGE, UNION(t1); SELECT * FROM mrg; DROP TABLE mrg, t1; ---echo # End of 10.5 tests +--echo # End of 10.0 tests --echo # --echo # MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results @@ -2875,9 +2873,7 @@ insert into tm () values (); select * from tm; drop table tm, t; ---echo # --echo # End of 10.8 tests ---echo # --echo # --echo # MDEV-35816 ASAN use-after-poison in st_select_lex::print @@ -2893,9 +2889,7 @@ EXECUTE nested; EXECUTE nested; DROP TABLE t1; ---echo # --echo # End of 10.11 tests ---echo # --echo # --echo # MDEV-30088 Assertion `cond_selectivity <= 1.0' failed in get_range_limit_read_cost @@ -2942,9 +2936,8 @@ EXPLAIN SELECT DISTINCT a FROM t1; drop table t1; set use_stat_tables=default; ---echo # --echo # End of 11.0 tests ---echo # + --echo # --echo # MDEV-29174: UPDATE of view that uses MERGE table --echo # @@ -2956,3 +2949,4 @@ DROP VIEW v1; DROP TABLE t1; --echo # End of 11.1 tests +--source include/test_db_charset_restore.inc diff --git a/mysql-test/suite/perfschema/t/misc_session_status.test b/mysql-test/suite/perfschema/t/misc_session_status.test index afb08eb4e9d..f32896d6077 100644 --- a/mysql-test/suite/perfschema/t/misc_session_status.test +++ b/mysql-test/suite/perfschema/t/misc_session_status.test @@ -1,5 +1,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc +--source include/not_msan.inc +--source include/not_valgrind.inc # This does not crash on 32 bit because of less memory used --source include/have_64bit.inc --echo # @@ -16,7 +18,9 @@ set max_session_mem_used=32768; select * from performance_schema.session_status; --enable_result_log # this used to cause mutex lock order violation when OOM happened under LOCK_global_system_variables +--disable_ps_protocol # different memory requirements set global innodb_io_capacity_max=100; set max_session_mem_used=default; +--enable_ps_protocol set global innodb_io_capacity=@old_innodb_io_capacity; set global innodb_io_capacity_max=@old_innodb_io_capacity_max; diff --git a/mysql-test/suite/perfschema/t/show_sanity.test b/mysql-test/suite/perfschema/t/show_sanity.test index 9e303c58577..5e2ac4565b9 100644 --- a/mysql-test/suite/perfschema/t/show_sanity.test +++ b/mysql-test/suite/perfschema/t/show_sanity.test @@ -488,7 +488,6 @@ insert into test.sanity values ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_SYNC_SPIN_LOOPS"), ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_TEMP_DATA_FILE_PATH"), ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_TRX_PURGE_VIEW_UPDATE_ONLY_DEBUG"), - ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_TRX_RSEG_N_SLOTS_DEBUG"), ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_UNDO_DIRECTORY"), ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_UNDO_LOG_TRUNCATE"), ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_UNDO_TABLESPACES"), diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result index 66cb7048d45..eab3ebf598a 100644 --- a/mysql-test/suite/plugins/r/server_audit.result +++ b/mysql-test/suite/plugins/r/server_audit.result @@ -245,6 +245,8 @@ insert delayed into t1 values (1); connection default; # Waiting until INSERT DELAYED thread does the insert. drop table t1; +create table test_partitions (i int) partition by hash (i) partitions 4; +drop table test_partitions; set global server_audit_logging= off; set global server_audit_incl_users='root'; set global server_audit_logging= on; diff --git a/mysql-test/suite/plugins/t/server_audit.test b/mysql-test/suite/plugins/t/server_audit.test index 7f9583d7027..5d2acdb408f 100644 --- a/mysql-test/suite/plugins/t/server_audit.test +++ b/mysql-test/suite/plugins/t/server_audit.test @@ -2,6 +2,7 @@ --source include/not_embedded.inc --source include/have_ssl_communication.inc --source include/no_view_protocol.inc +--source include/have_partition.inc if (!$SERVER_AUDIT_SO) { skip No SERVER_AUDIT plugin; @@ -179,12 +180,20 @@ connect (cn1,127.0.0.1,user1,,sa_db,$MASTER_MYPORT); create table t1(id int) engine=myisam; insert delayed into t1 values (1); + connection default; + --echo # Waiting until INSERT DELAYED thread does the insert. let $wait_condition= SELECT COUNT(*) = 1 FROM t1; --source include/wait_condition.inc drop table t1; +# +# MDEV-7451 Server audit: Table events for partitioned tables are duplicated for each partition. +# +create table test_partitions (i int) partition by hash (i) partitions 4; +drop table test_partitions; + set global server_audit_logging= off; set global server_audit_incl_users='root'; set global server_audit_logging= on; diff --git a/mysql-test/suite/sql_sequence/other.result b/mysql-test/suite/sql_sequence/other.result index 7ab7f174b26..93920f91939 100644 --- a/mysql-test/suite/sql_sequence/other.result +++ b/mysql-test/suite/sql_sequence/other.result @@ -382,6 +382,35 @@ disconnect con1; connection default; drop sequence s1; drop sequence s2; -# # End of 10.4 tests # +# MDEV-37906 Server crash or UBSAN errors in Item_func_nextval::update_table upon INSERT DELAYED +# +create sequence s engine=myisam; +create table t (id bigint default(nextval(s))) engine=myisam; +insert delayed into t () values(); +drop table t; +drop sequence s; +# +# MDEV-37345 Item_func_nextval::val_int() crash on INSERT...SELECT with subqueries +# +create sequence s; +create table t1 (a int, b int default(nextval(s))); +insert into t1 () values (); +create table t2 (c int); +create procedure p() update t1 set a = 0; +create trigger tr after insert on t2 for each row +begin +insert into t1 () values (); +call p(); +end $ +insert into t2 values (); +drop table t1, t2, s; +drop procedure p; +create sequence s; +create temporary table t (f int); +alter table t modify f int default(nextval(s)); +create or replace sequence s; +insert into t values (default); +drop sequence s; +# End of 10.11 tests diff --git a/mysql-test/suite/sql_sequence/other.test b/mysql-test/suite/sql_sequence/other.test index 0d59596fb13..4fcf2d6652d 100644 --- a/mysql-test/suite/sql_sequence/other.test +++ b/mysql-test/suite/sql_sequence/other.test @@ -414,6 +414,43 @@ insert into s1 values (1, 1, 10000, 100, 1, 1000, 0, 0); drop sequence s1; drop sequence s2; ---echo # --echo # End of 10.4 tests + --echo # +--echo # MDEV-37906 Server crash or UBSAN errors in Item_func_nextval::update_table upon INSERT DELAYED +--echo # +create sequence s engine=myisam; +create table t (id bigint default(nextval(s))) engine=myisam; +insert delayed into t () values(); +drop table t; +drop sequence s; + +--echo # +--echo # MDEV-37345 Item_func_nextval::val_int() crash on INSERT...SELECT with subqueries +--echo # +# sequence and prelocking. +create sequence s; +create table t1 (a int, b int default(nextval(s))); +insert into t1 () values (); +create table t2 (c int); +create procedure p() update t1 set a = 0; +--delimiter $ +create trigger tr after insert on t2 for each row +begin + insert into t1 () values (); + call p(); +end $ +--delimiter ; +insert into t2 values (); +drop table t1, t2, s; +drop procedure p; + +# another one, temporary table, ALTER, recreate sequence +create sequence s; +create temporary table t (f int); +alter table t modify f int default(nextval(s)); +create or replace sequence s; +insert into t values (default); +drop sequence s; + +--echo # End of 10.11 tests diff --git a/mysql-test/suite/sys_vars/r/innodb_trx_rseg_n_slots_debug_basic.result b/mysql-test/suite/sys_vars/r/innodb_trx_rseg_n_slots_debug_basic.result deleted file mode 100644 index 7e253c869e3..00000000000 --- a/mysql-test/suite/sys_vars/r/innodb_trx_rseg_n_slots_debug_basic.result +++ /dev/null @@ -1,65 +0,0 @@ -SET @start_global_value = @@global.innodb_trx_rseg_n_slots_debug; -SELECT @start_global_value; -@start_global_value -0 -select @@global.innodb_trx_rseg_n_slots_debug between 0 and 1024; -@@global.innodb_trx_rseg_n_slots_debug between 0 and 1024 -1 -select @@global.innodb_trx_rseg_n_slots_debug; -@@global.innodb_trx_rseg_n_slots_debug -0 -select @@session.innodb_trx_rseg_n_slots_debug; -ERROR HY000: Variable 'innodb_trx_rseg_n_slots_debug' is a GLOBAL variable -show global variables like 'innodb_trx_rseg_n_slots_debug'; -Variable_name Value -innodb_trx_rseg_n_slots_debug 0 -show session variables like 'innodb_trx_rseg_n_slots_debug'; -Variable_name Value -innodb_trx_rseg_n_slots_debug 0 -select * from information_schema.global_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_TRX_RSEG_N_SLOTS_DEBUG 0 -select * from information_schema.session_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_TRX_RSEG_N_SLOTS_DEBUG 0 -set global innodb_trx_rseg_n_slots_debug=1; -select @@global.innodb_trx_rseg_n_slots_debug; -@@global.innodb_trx_rseg_n_slots_debug -1 -select * from information_schema.global_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_TRX_RSEG_N_SLOTS_DEBUG 1 -select * from information_schema.session_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_TRX_RSEG_N_SLOTS_DEBUG 1 -set @@global.innodb_trx_rseg_n_slots_debug=0; -select @@global.innodb_trx_rseg_n_slots_debug; -@@global.innodb_trx_rseg_n_slots_debug -0 -select * from information_schema.global_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_TRX_RSEG_N_SLOTS_DEBUG 0 -select * from information_schema.session_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_TRX_RSEG_N_SLOTS_DEBUG 0 -set session innodb_trx_rseg_n_slots_debug='some'; -ERROR HY000: Variable 'innodb_trx_rseg_n_slots_debug' is a GLOBAL variable and should be set with SET GLOBAL -set @@session.innodb_trx_rseg_n_slots_debug='some'; -ERROR HY000: Variable 'innodb_trx_rseg_n_slots_debug' is a GLOBAL variable and should be set with SET GLOBAL -set global innodb_trx_rseg_n_slots_debug=1.1; -ERROR 42000: Incorrect argument type to variable 'innodb_trx_rseg_n_slots_debug' -set global innodb_trx_rseg_n_slots_debug='foo'; -ERROR 42000: Incorrect argument type to variable 'innodb_trx_rseg_n_slots_debug' -set global innodb_trx_rseg_n_slots_debug=-2; -Warnings: -Warning 1292 Truncated incorrect innodb_trx_rseg_n_slots_debug value: '-2' -set global innodb_trx_rseg_n_slots_debug=1e1; -ERROR 42000: Incorrect argument type to variable 'innodb_trx_rseg_n_slots_debug' -set global innodb_trx_rseg_n_slots_debug=1024; -set global innodb_trx_rseg_n_slots_debug=1025; -Warnings: -Warning 1292 Truncated incorrect innodb_trx_rseg_n_slots_debug value: '1025' -SET @@global.innodb_trx_rseg_n_slots_debug = @start_global_value; -SELECT @@global.innodb_trx_rseg_n_slots_debug; -@@global.innodb_trx_rseg_n_slots_debug -0 diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 42c795a4d9a..b9f1e8b68f6 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -1664,18 +1664,6 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT NULL -VARIABLE_NAME INNODB_TRX_RSEG_N_SLOTS_DEBUG -SESSION_VALUE NULL -DEFAULT_VALUE 0 -VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE INT UNSIGNED -VARIABLE_COMMENT Debug flags for InnoDB to limit TRX_RSEG_N_SLOTS for trx_rsegf_undo_find_free() -NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 1024 -NUMERIC_BLOCK_SIZE 0 -ENUM_VALUE_LIST NULL -READ_ONLY NO -COMMAND_LINE_ARGUMENT NULL VARIABLE_NAME INNODB_UNDO_DIRECTORY SESSION_VALUE NULL DEFAULT_VALUE diff --git a/mysql-test/suite/sys_vars/t/innodb_trx_rseg_n_slots_debug_basic.test b/mysql-test/suite/sys_vars/t/innodb_trx_rseg_n_slots_debug_basic.test deleted file mode 100644 index 858e1b63908..00000000000 --- a/mysql-test/suite/sys_vars/t/innodb_trx_rseg_n_slots_debug_basic.test +++ /dev/null @@ -1,59 +0,0 @@ ---source include/have_innodb.inc ---source include/have_debug.inc - -SET @start_global_value = @@global.innodb_trx_rseg_n_slots_debug; -SELECT @start_global_value; - -# -# exists as global only -# -select @@global.innodb_trx_rseg_n_slots_debug between 0 and 1024; -select @@global.innodb_trx_rseg_n_slots_debug; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -select @@session.innodb_trx_rseg_n_slots_debug; -show global variables like 'innodb_trx_rseg_n_slots_debug'; -show session variables like 'innodb_trx_rseg_n_slots_debug'; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -select * from information_schema.session_variables where variable_name='innodb_trx_rseg_n_slots_debug'; ---enable_warnings - -# -# show that it's writable -# -set global innodb_trx_rseg_n_slots_debug=1; -select @@global.innodb_trx_rseg_n_slots_debug; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -select * from information_schema.session_variables where variable_name='innodb_trx_rseg_n_slots_debug'; ---enable_warnings -set @@global.innodb_trx_rseg_n_slots_debug=0; -select @@global.innodb_trx_rseg_n_slots_debug; ---disable_warnings -select * from information_schema.global_variables where variable_name='innodb_trx_rseg_n_slots_debug'; -select * from information_schema.session_variables where variable_name='innodb_trx_rseg_n_slots_debug'; ---enable_warnings ---error ER_GLOBAL_VARIABLE -set session innodb_trx_rseg_n_slots_debug='some'; ---error ER_GLOBAL_VARIABLE -set @@session.innodb_trx_rseg_n_slots_debug='some'; - -# -# incorrect types -# ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_trx_rseg_n_slots_debug=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_trx_rseg_n_slots_debug='foo'; -set global innodb_trx_rseg_n_slots_debug=-2; ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_trx_rseg_n_slots_debug=1e1; -set global innodb_trx_rseg_n_slots_debug=1024; -set global innodb_trx_rseg_n_slots_debug=1025; - -# -# Cleanup -# - -SET @@global.innodb_trx_rseg_n_slots_debug = @start_global_value; -SELECT @@global.innodb_trx_rseg_n_slots_debug; diff --git a/plugin/query_response_time/plugin.cc b/plugin/query_response_time/plugin.cc index 0dc6fcdcbf0..22c2a4e0891 100644 --- a/plugin/query_response_time/plugin.cc +++ b/plugin/query_response_time/plugin.cc @@ -47,7 +47,6 @@ enum session_stat static const char *session_stat_names[]= {"GLOBAL", "ON", "OFF", NullS}; static TYPELIB session_stat_typelib= CREATE_TYPELIB_FOR(session_stat_names); - static MYSQL_SYSVAR_ULONG(range_base, opt_query_response_time_range_base, PLUGIN_VAR_RQCMDARG, "Select base of log for query_response_time ranges. " diff --git a/scripts/galera_new_cluster.sh b/scripts/galera_new_cluster.sh index 1b6f7c2e6a6..b0aef8e05d2 100644 --- a/scripts/galera_new_cluster.sh +++ b/scripts/galera_new_cluster.sh @@ -21,11 +21,11 @@ EOF exit 0 fi -echo _WSREP_NEW_CLUSTER='--wsrep-new-cluster' > @mysqlunixdir@/"wsrep-new-cluster" && \ +echo _WSREP_NEW_CLUSTER='--wsrep-new-cluster' > "@INSTALL_RUNDATADIR@/wsrep-new-cluster" && \ systemctl restart mariadb.service extcode=$? -rm -f @mysqlunixdir@/"wsrep-new-cluster" +rm -f "@INSTALL_RUNDATADIR@/wsrep-new-cluster" exit $extcode diff --git a/sql/handler.cc b/sql/handler.cc index d3dd6758c9a..93c934417e4 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5969,7 +5969,12 @@ handler::ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info_arg) info_arg->options|= HA_LEX_CREATE_GLOBAL_TMP_TABLE; int error= create(name, form, info_arg); if (!error && - !(info_arg->options & (HA_LEX_CREATE_TMP_TABLE | HA_CREATE_TMP_ALTER))) + !(info_arg->options & (HA_LEX_CREATE_TMP_TABLE | HA_CREATE_TMP_ALTER)) && + /* + DO not notify if not main handler. + So skip notifications for partitions. + */ + form->file == this) mysql_audit_create_table(form); return error; } diff --git a/sql/item_func.h b/sql/item_func.h index eaeb5b1d141..a6c595de070 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -4450,7 +4450,7 @@ protected: bool check_access(THD *, privilege_t); public: Item_func_nextval(THD *thd, TABLE_LIST *table_list_arg): - Item_longlong_func(thd), table_list(table_list_arg) {} + Item_longlong_func(thd), table_list(table_list_arg), table(0) {} longlong val_int() override; LEX_CSTRING func_name_cstring() const override { @@ -4480,14 +4480,8 @@ public: */ void update_table() { - if (!(table= table_list->table)) - { - /* - If nextval was used in DEFAULT then next_local points to - the table_list used by to open the sequence table - */ - table= table_list->next_local->table; - } + table= table_list->table; + DBUG_ASSERT(table); } bool const_item() const override { return 0; } Item *do_get_copy(THD *thd) const override diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index c5a275f3fc0..a947ca34393 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -211,24 +211,23 @@ int json_path_parts_compare( { if (b->type & JSON_PATH_ARRAY) { - int res= 0, corrected_n_item_a= 0; - if (array_sizes) - corrected_n_item_a= a->n_item < 0 ? - array_sizes[b-temp_b] + a->n_item : a->n_item; - if (a->type & JSON_PATH_ARRAY_RANGE) + int res = 0; + if (a->type & JSON_PATH_WILD) + res = 1; + else if (a->type & JSON_PATH_ARRAY_RANGE && array_sizes) { - int corrected_n_item_end_a= 0; - if (array_sizes) - corrected_n_item_end_a= a->n_item_end < 0 ? - array_sizes[b-temp_b] + a->n_item_end : - a->n_item_end; - res= b->n_item >= corrected_n_item_a && - b->n_item <= corrected_n_item_end_a; + int start = (a->n_item >= 0) ? a->n_item + : array_sizes[b - temp_b] + a->n_item; + int end = (a->n_item_end >= 0) ? a->n_item_end + : array_sizes[b - temp_b] + a->n_item_end; + res = (b->n_item >= start && b->n_item <= end); } - else - res= corrected_n_item_a == b->n_item; + else if (a->n_item >= 0) + res = (a->n_item == b->n_item); + else if (a->n_item < 0 && array_sizes) + res = (a->n_item == b->n_item - array_sizes[b - temp_b]); - if ((a->type & JSON_PATH_WILD) || res) + if (res) goto step_fits; goto step_failed; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index bd00ec707b5..9925842f52f 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -4258,9 +4258,21 @@ String *Item_func_hex::val_str_ascii_from_val_str(String *str) { DBUG_ASSERT(&tmp_value != str); String *res= args[0]->val_str(&tmp_value); - DBUG_ASSERT(res != str); + THD *thd= current_thd; + if ((null_value= (res == NULL))) return NULL; + + if (res->length()*2 > thd->variables.max_allowed_packet) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_WARN_ALLOWED_PACKET_OVERFLOWED, + ER_THD(thd, ER_WARN_ALLOWED_PACKET_OVERFLOWED), + func_name(), thd->variables.max_allowed_packet); + null_value= true; + return NULL; + } + return str->set_hex(res->ptr(), res->length()) ? make_empty_result(str) : str; } diff --git a/sql/json_table.cc b/sql/json_table.cc index 29180c260ce..50c2db1d3aa 100644 --- a/sql/json_table.cc +++ b/sql/json_table.cc @@ -978,8 +978,9 @@ int Json_table_column::print(THD *thd, Field **f, String *str) (*f)->sql_type(column_type); - if (str->append(column_type) || - ((*f)->has_charset() && m_explicit_cs && + if ((m_format_json ? str->append(STRING_WITH_LEN(" JSON ")) : str->append(column_type))) + return 1; + if (((*f)->has_charset() && m_explicit_cs && (str->append(STRING_WITH_LEN(" CHARSET ")) || str->append(&m_explicit_cs->cs_name) || (Charset(m_explicit_cs).can_have_collate_clause() && diff --git a/sql/json_table.h b/sql/json_table.h index e7e1489afb7..0d8affcdce0 100644 --- a/sql/json_table.h +++ b/sql/json_table.h @@ -167,6 +167,7 @@ public: { m_on_error.m_response= RESPONSE_NOT_SPECIFIED; m_on_empty.m_response= RESPONSE_NOT_SPECIFIED; + m_format_json= false; } int print(THD *tnd, Field **f, String *str); }; diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index c4df3e27740..5db40c8b72d 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -1914,7 +1914,16 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, if (charset_inited) { rpl_sql_thread_info *sql_info= thd->system_thread_info.rpl_sql_info; - if (thd->slave_thread && sql_info->cached_charset_compare(charset)) + const bool applier= +#ifdef WITH_WSREP + WSREP(thd) ? thd->wsrep_applier : +#endif + false; + + // Event charset should be compared for slave thread + // and applier threads + if ((thd->slave_thread || applier) && + sql_info->cached_charset_compare(charset)) { /* Verify that we support the charsets found in the event. */ if (!(thd->variables.character_set_client= diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ac2d7815012..6dc3548e299 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -10427,8 +10427,6 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) { bool must_be_ored= sel_trees_must_be_ored(param, tree1, tree2, ored_keys); no_imerge_from_ranges= must_be_ored; - if (param->disable_index_merge_plans) - no_imerge_from_ranges= true; if (no_imerge_from_ranges && no_merges1 && no_merges2) { @@ -10478,6 +10476,13 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) DBUG_RETURN(result); } + /* + Ok, the result now has the ranges that one gets for (RT1 OR RT2). + If construction of SEL_IMERGE is disabled, stop right here. + */ + if (param->disable_index_merge_plans) + DBUG_RETURN(result); + SEL_IMERGE *imerge_from_ranges; if (!(imerge_from_ranges= new SEL_IMERGE())) result= NULL; @@ -15852,6 +15857,46 @@ TRP_GROUP_MIN_MAX::make_quick(PARAM *param, bool retrieve_full_rows, } +/* + @brief + Return true if the select is using "Using index for group-by" and also + has "ORDER BY ... FETCH FIRST n ROWS WITH TIES" + + @detail + There is a rewrite that removes the ORDER BY (JOIN::order) if the select + also has a GROUP BY that produces a compatible ordering. + However "FETCH FIRST ... WITH TIES" needs an ORDER BY clause (in + JOIN::alloc_order_fields()). + GROUP BY strategies handle it this way: + - For strategies using temporary table, JOIN::make_aggr_tables_info() will + put the ORDER BY clause back. + - OrderedGroupBy in end_send_group() handles WITH TIES with the GROUP BY + clause (note that SQL doesn't allow "GROUP BY ... WITH TIES"). + - The remaining strategy is QUICK_GROUP_MIN_MAX_SELECT, for which + = the grouping strategy in the quick select doesn't handle WITH TIES. + = end_send() would not handle WITH TIES, because JOIN::order is removed. + + The solution is to NOT remove ORDER BY when QUICK_GROUP_MIN_MAX_SELECT is + used. + + Unfortunately, the optimizer then will not recognize that it can skip + sorting and will use filesort, which will prevent short-cutting the + execution when LIMIT is reached. +*/ + +bool using_with_ties_and_group_min_max(JOIN *join) +{ + if (join->unit->lim.is_with_ties()) + { + JOIN_TAB *tab= &join->join_tab[join->const_tables]; + if (tab->select && tab->select->quick && + tab->select->quick->get_type() == + QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) + return true; + } + return false; +} + /* Construct new quick select for group queries with min/max. diff --git a/sql/opt_range.h b/sql/opt_range.h index ee328079a31..545803e71cb 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -1873,6 +1873,7 @@ public: Explain_quick_select *get_explain(MEM_ROOT *alloc) override; }; +bool using_with_ties_and_group_min_max(JOIN *join); class QUICK_SELECT_DESC: public QUICK_RANGE_SELECT { diff --git a/sql/opt_split.cc b/sql/opt_split.cc index 251150ffa71..7b9ef399268 100644 --- a/sql/opt_split.cc +++ b/sql/opt_split.cc @@ -394,6 +394,7 @@ struct SplM_field_ext_info: public SplM_field_info with available statistics. 10. The select doesn't use WITH ROLLUP (This limitation can probably be lifted) + 11. The select doesn't have ORDER BY with LIMIT @retval true if the answer is positive @@ -429,6 +430,9 @@ bool JOIN::check_for_splittable_materialized() if (!partition_list) return false; + if (select_lex->order_list.elements > 0 && !unit->lim.is_unlimited()) //!(11) + return false; + Json_writer_object trace_wrapper(thd); Json_writer_object trace_split(thd, "check_split_materialized"); diff --git a/sql/sp.cc b/sql/sp.cc index 46c7ef2b479..2669ce41505 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1198,7 +1198,7 @@ Sp_handler::sp_drop_routine_internal(THD *thd, sp_cache **spc= get_cache(thd); DBUG_ASSERT(spc); if ((sp= sp_cache_lookup(spc, name))) - sp_cache_flush_obsolete(spc, &sp); + sp_cache_remove(spc, &sp); /* Drop statistics for this stored program from performance schema. */ MYSQL_DROP_SP(type(), name->m_db.str, static_cast(name->m_db.length), name->m_name.str, static_cast(name->m_name.length)); @@ -2901,10 +2901,12 @@ int Sp_handler::sp_cache_routine(THD *thd, DBUG_ASSERT(spc); *sp= sp_cache_lookup(spc, name); + thd->set_sp_cache_version_if_needed(sp_cache_version()); if (*sp) { - sp_cache_flush_obsolete(spc, sp); + if ((*sp)->sp_cache_version() < thd->sp_cache_version()) + sp_cache_remove(spc, sp); if (*sp) DBUG_RETURN(SP_OK); } diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index 60e01a99d10..f28bc87adae 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -229,14 +229,10 @@ void sp_cache_invalidate() inside SP'. */ -void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp) +void sp_cache_remove(sp_cache **cp, sp_head **sp) { - if ((*sp)->sp_cache_version() < Cversion && !(*sp)->is_invoked()) - { - DBUG_EXECUTE_IF("check_sp_cache_not_invalidated", DBUG_SUICIDE();); - (*cp)->remove(*sp); - *sp= NULL; - } + (*cp)->remove(*sp); + *sp= NULL; } /** diff --git a/sql/sp_cache.h b/sql/sp_cache.h index d9ded06a43d..473629ed56d 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -55,7 +55,7 @@ void sp_cache_clear(sp_cache **cp); void sp_cache_insert(sp_cache **cp, sp_head *sp); sp_head *sp_cache_lookup(sp_cache **cp, const Database_qualified_name *name); void sp_cache_invalidate(); -void sp_cache_flush_obsolete(sp_cache **cp, sp_head **sp); +void sp_cache_remove(sp_cache **cp, sp_head **sp); ulong sp_cache_version(); void sp_cache_enforce_limit(sp_cache *cp, ulong upper_limit_for_elements); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index aea4aa4d1c1..c0ea53758c2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2045,7 +2045,14 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) table->query_id == 0)) { int distance= ((int) table->reginfo.lock_type - - (int) table_list->lock_type); + (int) table_list->lock_type) * 2; + /* + if we need a table for inserting, make sure it has + its internal tables (a.k.a. sequences) ready + */ + if (table->internal_tables && + table_list->for_insert_data == !table->internal_tables->table) + distance|= 1; /* Find a table that either has the exact lock type requested, @@ -2448,6 +2455,11 @@ retry_share: DBUG_ASSERT(table->file->pushed_cond == NULL); table_list->updatable= 1; // It is not derived table nor non-updatable VIEW table_list->table= table; + if (table_list->linked_table) + { + /* Update link for sequence tables in default */ + table_list->linked_table->table= table; + } if (!from_share && table->vcol_fix_expr(thd)) DBUG_RETURN(true); @@ -3210,7 +3222,7 @@ static bool check_and_update_routine_version(THD *thd, Sroutine_hash_entry *rt, sp_head *sp) { - ulong spc_version= sp_cache_version(); + ulong spc_version= thd->sp_cache_version(); /* sp is NULL if there is no such routine. */ ulong version= sp ? sp->sp_cache_version() : spc_version; /* @@ -3220,7 +3232,7 @@ check_and_update_routine_version(THD *thd, Sroutine_hash_entry *rt, Sic: version != spc_version <--> sp is not NULL. */ if (rt->m_sp_cache_version != version || - (version != spc_version && !sp->is_invoked())) + (version < spc_version && !sp->is_invoked())) { if (thd->m_reprepare_observer && thd->m_reprepare_observer->report_error(thd)) @@ -5079,7 +5091,7 @@ add_internal_tables(THD *thd, Query_tables_list *prelocking_ctx, next_local value as it may have been changed by a previous statement using the same table. */ - tables->next_local= tmp; + tmp->linked_table= tables; continue; } @@ -5094,10 +5106,10 @@ add_internal_tables(THD *thd, Query_tables_list *prelocking_ctx, &prelocking_ctx->query_tables_last, tables->for_insert_data); /* - Store link to the new table_list that will be used by open so that - Item_func_nextval() can find it + Store link to the sequences table so that we can in open_table() update + it to point to the opened table. */ - tables->next_local= tl; + tl->linked_table= tables; DBUG_PRINT("info", ("table name: %s added", tables->table_name.str)); } while ((tables= tables->next_global)); DBUG_RETURN(FALSE); diff --git a/sql/sql_class.h b/sql/sql_class.h index 478ebc5cdb5..428e5e71314 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -235,6 +235,7 @@ void old_mode_deprecated_warnings(ulonglong v); #define NEW_MODE_TEST_WARNING1 NOW_DEFAULT #define NEW_MODE_TEST_WARNING2 NOW_DEFAULT #define NEW_MODE_FIX_DISK_TMPTABLE_COSTS NOW_DEFAULT +#define NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS NOW_DEFAULT #define TEST_NEW_MODE_FLAG(thd, flag) \ (flag == NOW_DEFAULT ? TRUE : thd->variables.new_behavior & flag) @@ -2824,16 +2825,16 @@ struct wait_for_commit class Sp_caches { +protected: + ulong m_sp_cache_version; public: sp_cache *sp_proc_cache; sp_cache *sp_func_cache; sp_cache *sp_package_spec_cache; sp_cache *sp_package_body_cache; Sp_caches() - :sp_proc_cache(NULL), - sp_func_cache(NULL), - sp_package_spec_cache(NULL), - sp_package_body_cache(NULL) + :m_sp_cache_version(0), sp_proc_cache(NULL), sp_func_cache(NULL), + sp_package_spec_cache(NULL), sp_package_body_cache(NULL) { } ~Sp_caches() { @@ -2843,19 +2844,22 @@ public: DBUG_ASSERT(sp_package_spec_cache == NULL); DBUG_ASSERT(sp_package_body_cache == NULL); } - void sp_caches_swap(Sp_caches &rhs) - { - swap_variables(sp_cache*, sp_proc_cache, rhs.sp_proc_cache); - swap_variables(sp_cache*, sp_func_cache, rhs.sp_func_cache); - swap_variables(sp_cache*, sp_package_spec_cache, rhs.sp_package_spec_cache); - swap_variables(sp_cache*, sp_package_body_cache, rhs.sp_package_body_cache); - } void sp_caches_clear(); /** Clear content of sp related caches. Don't delete cache objects itself. */ void sp_caches_empty(); + ulong sp_cache_version() const + { + DBUG_ASSERT(m_sp_cache_version); + return m_sp_cache_version; + } + void set_sp_cache_version_if_needed(ulong version) + { + if (!m_sp_cache_version) + m_sp_cache_version= version; + } }; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 5fa19025113..99323b99d4e 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -41,6 +41,8 @@ typedef bool (*dt_processor)(THD *thd, LEX *lex, TABLE_LIST *derived); static bool mysql_derived_init(THD *thd, LEX *lex, TABLE_LIST *derived); static bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived); static bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived); +static bool mysql_derived_optimize_stage2(THD *thd, LEX *lex, + TABLE_LIST *derived); static bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived); static bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived); static bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived); @@ -58,6 +60,7 @@ dt_processor processors[]= &mysql_derived_create, &mysql_derived_fill, &mysql_derived_reinit, + &mysql_derived_optimize_stage2 }; /* @@ -109,8 +112,8 @@ mysql_handle_derived(LEX *lex, uint phases) { if (!cursor->is_view_or_derived() && phases == DT_MERGE_FOR_INSERT) continue; - uint8 allowed_phases= (cursor->is_merged_derived() ? DT_PHASES_MERGE : - DT_PHASES_MATERIALIZE | DT_MERGE_FOR_INSERT); + uint allowed_phases= (cursor->is_merged_derived() ? DT_PHASES_MERGE : + DT_PHASES_MATERIALIZE | DT_MERGE_FOR_INSERT); /* Skip derived tables to which the phase isn't applicable. TODO: mark derived at the parse time, later set it's type @@ -170,7 +173,7 @@ bool mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases) { bool res= FALSE; - uint8 allowed_phases= (derived->is_merged_derived() ? DT_PHASES_MERGE : + uint allowed_phases= (derived->is_merged_derived() ? DT_PHASES_MERGE : DT_PHASES_MATERIALIZE); DBUG_ENTER("mysql_handle_single_derived"); DBUG_PRINT("enter", ("phases: 0x%x allowed: 0x%x alias: '%s'", @@ -1071,6 +1074,43 @@ err: } +/* + @brief + Call JOIN::optimize_stage2_and_finish() for all child selects that use + two-phase optimization. +*/ + +static +bool mysql_derived_optimize_stage2(THD *thd, LEX *lex, TABLE_LIST *derived) +{ + SELECT_LEX_UNIT *unit= derived->get_unit(); + SELECT_LEX *first_select= unit->first_select(); + SELECT_LEX *save_current_select= lex->current_select; + bool res= FALSE; + + if (derived->merged || unit->is_unit_op()) + { + /* + Two-phase join optimization is not applicable for merged derived tables + and UNIONs. + */ + return FALSE; + } + + lex->current_select= first_select; + /* Same condition as in mysql_derived_optimize(): */ + if (unit->derived && !derived->is_merged_derived()) + { + JOIN *join= first_select->join; + if (join && join->optimization_state == JOIN::OPTIMIZATION_PHASE_1_DONE) + res= join->optimize_stage2_and_finish(); + } + + lex->current_select= save_current_select; + return res; +} + + /** Actually create result table for a materialized derived table/view. diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 80708349311..d0aa138abd6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3476,11 +3476,11 @@ bool Delayed_insert::open_and_lock_table() return TRUE; } - if (table->triggers || table->check_constraints) + if (table->triggers || table->check_constraints || table->internal_tables) { /* - Table has triggers or check constraints. This is not an error, but we do - not support these with delayed insert. Terminate the delayed + Table uses triggers, check constraints or sequences. This is not an error, + but we do not support these with delayed insert. Terminate the delayed thread without an error and thus request lock upgrade. */ return TRUE; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index b5e7d2da36f..bef1c492af4 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2035,6 +2035,12 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd) const uchar *const state_map= cs->state_map; const uchar *const ident_map= cs->ident_map; + if (thd->killed) + { + thd->send_kill_message(); + return END_OF_INPUT; + } + start_token(); state= next_state; next_state= MY_LEX_OPERATOR_OR_IDENT; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index eec249749a0..bd23392a84e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7472,6 +7472,7 @@ void THD::reset_for_next_command(bool do_clear_error) binlog_unsafe_warning_flags= 0; save_prep_leaf_list= false; + m_sp_cache_version= 0; #if defined(WITH_WSREP) && !defined(DBUG_OFF) if (mysql_bin_log.is_open()) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8e73128253d..bcaad940bf1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1996,7 +1996,6 @@ bool JOIN::build_explain() int JOIN::optimize() { int res= 0; - join_optimization_state init_state= optimization_state; if (select_lex->pushdown_select) { if (optimization_state == JOIN::OPTIMIZATION_DONE) @@ -2013,18 +2012,18 @@ int JOIN::optimize() } with_two_phase_optimization= false; } - else if (optimization_state == JOIN::OPTIMIZATION_PHASE_1_DONE) - res= optimize_stage2(); else { - // to prevent double initialization on EXPLAIN + /* + This function may be invoked multiple times. Do nothing if the + optimization (either full or stage1) are already done. + */ if (optimization_state != JOIN::NOT_OPTIMIZED) return FALSE; optimization_state= JOIN::OPTIMIZATION_IN_PROGRESS; res= optimize_inner(); } - if (!with_two_phase_optimization || - init_state == JOIN::OPTIMIZATION_PHASE_1_DONE) + if (!with_two_phase_optimization) { if (!res && have_query_plan != QEP_DELETED) res= build_explain(); @@ -2041,6 +2040,29 @@ int JOIN::optimize() } +/* + @brief + Call optimize_stage2() and save the query plan. +*/ + +int JOIN::optimize_stage2_and_finish() +{ + int res= 0; + DBUG_ASSERT(with_two_phase_optimization); + DBUG_ASSERT(optimization_state == OPTIMIZATION_PHASE_1_DONE); + + if (optimize_stage2()) + res= 1; + else + { + if (have_query_plan != JOIN::QEP_DELETED) + res= build_explain(); + optimization_state= JOIN::OPTIMIZATION_DONE; + } + return res; +} + + /** @brief Create range filters objects needed in execution for all join tables @@ -2777,6 +2799,19 @@ setup_subq_exit: } +/* + @brief + In the Stage 1 we've picked the join order. + Now, refine the query plan and sort out all the details. + The choice how to handle GROUP/ORDER BY is also made here. + + @detail + The main reason this is a separate function is Split-Materialized + optimization. There, we first consider doing non-split Materialization for + a SELECT. After that, the parent SELECT will attempt doing Splitting in + multiple ways and make the final choice. +*/ + int JOIN::optimize_stage2() { ulonglong select_opts_for_readinfo; @@ -2797,7 +2832,7 @@ int JOIN::optimize_stage2() if (make_range_rowid_filters()) DBUG_RETURN(1); - if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE)) + if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE_STAGE2)) DBUG_RETURN(1); /* @@ -3272,9 +3307,14 @@ int JOIN::optimize_stage2() (as MariaDB is by default sorting on GROUP BY) or if there is no GROUP BY and aggregate functions are used (as the result will only contain one row). + + (1) - Do not remove ORDER BY if we have WITH TIES and are using + QUICK_GROUP_MIN_MAX_SELECT to handle GROUP BY. See the comment + for using_with_ties_and_group_min_max() for details. */ if (order && (test_if_subpart(group_list, order) || - (!group_list && tmp_table_param.sum_func_count))) + (!group_list && tmp_table_param.sum_func_count)) && + !using_with_ties_and_group_min_max(this)) // (1) order=0; // Can't use sort on head table if using join buffering @@ -3588,7 +3628,7 @@ setup_subq_exit: some of the derived tables, and never did stage 2. Do it now, otherwise Explain data structure will not be complete. */ - if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE)) + if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE_STAGE2)) DBUG_RETURN(1); } /* @@ -4868,6 +4908,7 @@ bool JOIN::save_explain_data(Explain_query *output, bool can_overwrite, int JOIN::exec() { int res; + DBUG_ASSERT(optimization_state == OPTIMIZATION_DONE); DBUG_EXECUTE_IF("show_explain_probe_join_exec_start", if (dbug_user_var_equals_int(thd, "show_explain_probe_select_id", @@ -8813,7 +8854,26 @@ best_access_path(JOIN *join, ulong key_flags; uint key_parts; key_part_map found_part= 0; - /* key parts which won't have NULL in lookup tuple */ + + /* + Bitmap indicating which key parts are used with NULL-rejecting + conditions. + + A bit is set to 1 for a key part if it's used with a + NULL-rejecting condition (i.e., the condition will never be + satisfied when the indexed column contains NULL). A bit is 0 if + the key part is used with a non-NULL-rejecting condition (i.e., + the condition can be satisfied even when the indexed column + contains NULL, e.g., is NULL or <=>). + + Example: for condition + t1.keypart1 = t2.col1 AND t1.keypart2 <=> t2.col2 AND + t1.keypart3 = t2.col3 + the notnull_part bitmap will be 101 (binary), because: + - keypart1: '=' is NULL-rejecting (bit 1) + - keypart2: '<=>' is NOT NULL-rejecting (bit 0) + - keypart3: '=' is NULL-rejecting (bit 1) + */ key_part_map notnull_part=0; table_map found_ref= 0; uint key= keyuse->key; @@ -9068,7 +9128,8 @@ best_access_path(JOIN *join, } else { - if (!(records= keyinfo->actual_rec_per_key(key_parts-1))) + if (!(records= + keyinfo->rec_per_key_null_aware(key_parts-1, notnull_part))) { /* Prefer longer keys */ trace_access_idx.add("rec_per_key_stats_missing", true); records= @@ -9200,7 +9261,9 @@ best_access_path(JOIN *join, else { /* Check if we have statistic about the distribution */ - if ((records= keyinfo->actual_rec_per_key(max_key_part-1))) + if ((records= + keyinfo->rec_per_key_null_aware(max_key_part-1, + notnull_part))) { /* Fix for the case where the index statistics is too @@ -13556,6 +13619,7 @@ static bool create_hj_key_for_table(JOIN *join, JOIN_TAB *join_tab, keyinfo->algorithm= HA_KEY_ALG_UNDEF; keyinfo->flags= HA_GENERATED_KEY; keyinfo->is_statistics_from_stat_tables= FALSE; + keyinfo->all_nulls_key_parts= 0; keyinfo->name.str= "$hj"; keyinfo->name.length= 3; keyinfo->rec_per_key= thd->calloc(key_parts); @@ -14754,7 +14818,20 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) if (build_tmp_join_prefix_cond(join, tab, &sel->cond)) return true; - /* + /* + To be removed in 11.0+: + Caution: we can reach this point with quick=NULL. Below, we'll + use tab->keys and not tab->const_keys like + get_quick_record_count() did. If we have constructed a + group-min-max quick select, make sure we're able to construct it + again + */ + if (sel->quick && sel->quick->get_type() == + QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) + { + tab->keys.set_bit(sel->quick->index); + } + /* We can't call sel->cond->fix_fields, as it will break tab->on_expr if it's AND condition (fix_fields currently removes extra AND/OR levels). @@ -22611,6 +22688,7 @@ bool Create_tmp_table::finalize(THD *thd, keyinfo->collected_stats= NULL; keyinfo->algorithm= HA_KEY_ALG_UNDEF; keyinfo->is_statistics_from_stat_tables= FALSE; + keyinfo->all_nulls_key_parts= 0; keyinfo->name= group_key; keyinfo->comment.str= 0; ORDER *cur_group= m_group; @@ -22732,6 +22810,7 @@ bool Create_tmp_table::finalize(THD *thd, keyinfo->name= distinct_key; keyinfo->algorithm= HA_KEY_ALG_UNDEF; keyinfo->is_statistics_from_stat_tables= FALSE; + keyinfo->all_nulls_key_parts= 0; keyinfo->read_stats= NULL; keyinfo->collected_stats= NULL; diff --git a/sql/sql_select.h b/sql/sql_select.h index ea0f43f81c4..de761002cab 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1793,6 +1793,7 @@ public: int optimize(); int optimize_inner(); int optimize_stage2(); + int optimize_stage2_and_finish(); bool build_explain(); int reinit(); int init_execution(); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e2538a16e0e..afe8b20821e 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5301,21 +5301,19 @@ static int fill_schema_table_from_frm(THD *thd, MEM_ROOT *mem_root, res= open_table_from_share(thd, share, table_name, 0, EXTRA_RECORD | OPEN_FRM_FILE_ONLY, thd->open_options, &tbl, FALSE); - if (res && hide_object_error(thd->get_stmt_da()->sql_errno())) - res= 0; + if (res) + { + if (hide_object_error(thd->get_stmt_da()->sql_errno())) + res= 0; + } else { - char buf[NAME_CHAR_LEN + 1]; - if (unlikely(res)) - get_table_engine_for_i_s(thd, buf, &table_list, db_name, table_name); - tbl.s= share; table_list.table= &tbl; table_list.view= (LEX*) share->is_view; bool res2= schema_table->process_table(thd, &table_list, table, res, db_name, table_name); - if (res == 0) - closefrm(&tbl); + closefrm(&tbl); res= res2; } @@ -5458,30 +5456,6 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) uint table_open_method= tables->table_open_method; bool can_deadlock; MEM_ROOT tmp_mem_root; - /* - We're going to open FRM files for tables. - In case of VIEWs that contain stored function calls, - these stored functions will be parsed and put to the SP cache. - - Suppose we have a view containing a stored function call: - CREATE VIEW v1 AS SELECT f1() AS c1; - and now we're running: - SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=f1(); - If a parallel thread invalidates the cache, - e.g. by creating or dropping some stored routine, - the SELECT query will re-parse f1() when processing "v1" - and replace the outdated cached version of f1() to a new one. - But the old version of f1() is referenced from the m_sp member - of the Item_func_sp instances used in the WHERE condition. - We cannot destroy it. To avoid such clashes, let's remember - all old routines into a temporary SP cache collection - and process tables with a new empty temporary SP cache collection. - Then restore to the old SP cache collection at the end. - */ - Sp_caches old_sp_caches; - - old_sp_caches.sp_caches_swap(*thd); - bzero(&tmp_mem_root, sizeof(tmp_mem_root)); /* @@ -5706,14 +5680,6 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) err: thd->restore_backup_open_tables_state(&open_tables_state_backup); free_root(&tmp_mem_root, 0); - - /* - Now restore to the saved SP cache collection - and clear the temporary SP cache collection. - */ - old_sp_caches.sp_caches_swap(*thd); - old_sp_caches.sp_caches_clear(); - DBUG_RETURN(error); } diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index e37df74f538..74ba27f2649 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -3122,7 +3122,10 @@ read_statistics_for_table(THD *thd, TABLE *table, found|= index_stat.get_stat_values(index_statistics); } if (found) + { new_stats_cb->stats_available|= TABLE_STAT_INDEX; + index_statistics->mark_stats_as_read(); + } key_part_map ext_key_part_map= key_info->ext_key_part_map; if (key_info->user_defined_key_parts != key_info->ext_key_parts && @@ -4156,11 +4159,35 @@ void set_statistics_for_table(THD *thd, TABLE *table) for (key_info= table->key_info, key_info_end= key_info+table->s->keys; key_info < key_info_end; key_info++) { + key_info->all_nulls_key_parts= 0; key_info->is_statistics_from_stat_tables= - (check_eits_preferred(thd) && - table->stats_is_read && - key_info->read_stats->avg_frequency_is_inited() && - key_info->read_stats->get_avg_frequency(0) > 0.5); + (check_eits_preferred(thd) && + table->stats_is_read && + key_info->read_stats->avg_frequency_is_inited() && + key_info->read_stats->has_stats(thd)); + + // Fill out `all_nulls_key_parts` bitmap + if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS) && + key_info->is_statistics_from_stat_tables) + { + for (uint part_idx= 0; part_idx < key_info->usable_key_parts; part_idx++) + { + Field *field= + table->field[key_info->key_part[part_idx].field->field_index]; + if (!field->read_stats) + { + // No column statistics available + continue; + } + + // Check if all values in this column are NULL according to statistics + double nulls_ratio= field->read_stats->get_nulls_ratio(); + if (nulls_ratio == 1.0) + { + key_info->all_nulls_key_parts |= (1 << part_idx); + } + } + } } } diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h index 8f7b55e97e1..9319b50c6f6 100644 --- a/sql/sql_statistics.h +++ b/sql/sql_statistics.h @@ -603,10 +603,24 @@ private: k-component prefixes among them */ ulonglong *avg_frequency; + bool stats_were_read; public: + void init_avg_frequency(ulonglong *ptr) + { + avg_frequency= ptr; + stats_were_read= false; + } - void init_avg_frequency(ulonglong *ptr) { avg_frequency= ptr; } + void mark_stats_as_read() { stats_were_read= true; } + + bool has_stats(THD *thd) const + { + if (TEST_NEW_MODE_FLAG(thd, NEW_MODE_FIX_INDEX_STATS_FOR_ALL_NULLS)) + return stats_were_read; + else + return get_avg_frequency(0) > 0.5; + } bool avg_frequency_is_inited() { return avg_frequency != NULL; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c83a71861a7..62e14c138a5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5111,32 +5111,35 @@ bool wsrep_check_sequence(THD* thd, const bool used_engine) { enum legacy_db_type db_type; + const LEX_CSTRING *engine_name; DBUG_ASSERT(WSREP(thd)); if (used_engine) { db_type= thd->lex->create_info.db_type->db_type; + // Currently any dynamic storage engine is not possible to identify + // using DB_TYPE_XXXX and ENGINE=SEQUENCE is one of them. + // Therefore, we get storage engine name from lex. + engine_name= + thd->lex->m_sql_cmd->option_storage_engine_name()->name(); } else { const handlerton *hton= ha_default_handlerton(thd); db_type= hton->db_type; + engine_name= hton_name(hton); } // In Galera cluster we support only InnoDB sequences if (db_type != DB_TYPE_INNODB) { - // Currently any dynamic storage engine is not possible to identify - // using DB_TYPE_XXXX and ENGINE=SEQUENCE is one of them. - // Therefore, we get storage engine name from lex. - const LEX_CSTRING *tb_name= thd->lex->m_sql_cmd->option_storage_engine_name()->name(); // (1) CREATE TABLE ... ENGINE=SEQUENCE OR // (2) ALTER TABLE ... ENGINE= OR // Note in ALTER TABLE table->s->sequence != nullptr // (3) CREATE SEQUENCE ... ENGINE= if ((thd->lex->sql_command == SQLCOM_CREATE_TABLE && - lex_string_eq(tb_name, STRING_WITH_LEN("SEQUENCE"))) || + lex_string_eq(engine_name, STRING_WITH_LEN("SEQUENCE"))) || (thd->lex->sql_command == SQLCOM_ALTER_TABLE) || (thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE)) { @@ -5144,7 +5147,8 @@ bool wsrep_check_sequence(THD* thd, "non-InnoDB sequences in Galera cluster"); push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_NOT_SUPPORTED_YET, - "ENGINE=%s not supported by Galera", tb_name->str); + "ENGINE=%s not supported by Galera", + engine_name->str); return(true); } } @@ -11972,6 +11976,7 @@ alter_copy: } else { + /* MERGE TABLE */ if (!table->s->tmp_table && wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN)) goto err_new_table_cleanup; @@ -11980,6 +11985,8 @@ alter_copy: alter_info->keys_onoff); if (trans_commit_stmt(thd) || trans_commit_implicit(thd)) goto err_new_table_cleanup; + /* Ensure that the ALTER is binlogged as a DDL */ + thd->transaction->stmt.mark_trans_did_ddl(); } thd->count_cuted_fields= CHECK_FIELD_IGNORE; diff --git a/sql/structs.h b/sql/structs.h index 3dda2047d0b..8bd22ecae49 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -173,7 +173,17 @@ typedef struct st_key { engine_option_value *option_list; ha_index_option_struct *option_struct; /* structure with parsed options */ - double actual_rec_per_key(uint i) const; + /* + Bitmap of key parts where all values are NULL (nulls_ratio == 1.0). + Bit N set means key part N has all NULLs in the corresponding column. + Used for NULL-aware cardinality estimation. + It is computed based on EITS data, otherwise it is 0. + */ + key_part_map all_nulls_key_parts; + + double actual_rec_per_key(uint last_key_part_in_prefix) const; + double rec_per_key_null_aware(uint last_key_part_in_prefix, + key_part_map notnull_part) const; } KEY; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 18d3436687c..0d5dddf8c30 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4175,6 +4175,7 @@ static Sys_var_set Sys_old_behavior( static const char *new_mode_all_names[]= { "FIX_DISK_TMPTABLE_COSTS", + "FIX_INDEX_STATS_FOR_ALL_NULLS", "TEST_WARNING1", // Default from here, See NEW_MODE_MAX "TEST_WARNING2", 0 @@ -4183,9 +4184,10 @@ static const char *new_mode_all_names[]= static int new_mode_hidden_names[] = { 0, // FIX_DISK_TMPTABLE_COSTS - 1, // TEST_WARNING1 - 2, // TEST_WARNING2 - -1 // End of list + 1, // FIX_INDEX_STATS_FOR_ALL_NULLS + 2, // TEST_WARNING1 + 3, // TEST_WARNING2 + -1 }; /* diff --git a/sql/table.cc b/sql/table.cc index 9c0e64926b2..3241d8b0f3c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8728,6 +8728,7 @@ bool TABLE::add_tmp_key(uint key, uint key_parts, bzero(keyinfo->rec_per_key, sizeof(ulong)*key_parts); keyinfo->read_stats= NULL; keyinfo->collected_stats= NULL; + keyinfo->all_nulls_key_parts= 0; for (i= 0; i < key_parts; i++) { @@ -10488,12 +10489,68 @@ uint TABLE_SHARE::actual_n_key_parts(THD *thd) } -double KEY::actual_rec_per_key(uint i) const +/** + Get records-per-key estimate for an index prefix. + + Returns average number of records per key value for the given index prefix. + Prefers engine-independent statistics (EITS) if available and falls back + to engine-dependent statistics otherwise. + + @param last_key_part_in_prefix Index of the last key part + in the prefix (0-based) + + @return Estimated records per key value: + - 0.0 if no statistics available + - avg_frequency from EITS if available + - rec_per_key from engine statistics if EITS is not available +*/ +double KEY::actual_rec_per_key(uint last_key_part_in_prefix) const { - if (rec_per_key == 0) - return 0; - return (is_statistics_from_stat_tables ? - read_stats->get_avg_frequency(i) : (double) rec_per_key[i]); + if (is_statistics_from_stat_tables) + { + // Use engine-independent statistics (EITS) + return read_stats->get_avg_frequency(last_key_part_in_prefix); + } + // Fall back to engine-dependent statistics if EITS is not available + return rec_per_key ? (double) rec_per_key[last_key_part_in_prefix] : 0.0; +} + + +/** + Get records-per-key estimate for an index prefix with NULL-aware optimization. + + Returns average number of records per key value for the given index prefix. + When EITS statistics show avg_frequency == 0 (typically all NULL values) and + the query uses NULL-rejecting conditions (e.g., =), returns 1.0 to indicate + high selectivity since NULL = NULL never matches. + + @param last_key_part_in_prefix Index of the last key part + in the prefix (0-based) + @param notnull_part Bitmap indicating which key parts have NULL-rejecting + conditions (bit N set means key part N uses =, not <=>) + + @return Estimated records per key value: + - 0.0 if no statistics available + - avg_frequency from EITS if available + - 1.0 if all values are NULL with NULL-rejecting condition + - rec_per_key from engine statistics if EITS is not available +*/ +double KEY::rec_per_key_null_aware(uint last_key_part_in_prefix, + key_part_map notnull_part) const +{ + if (notnull_part & all_nulls_key_parts) + { + /* + For NULL-rejecting conditions like `t1.key_col = t2.col`, we know + there will be no matches (since NULL = NULL is never true). + If at least one NULL-rejecting condition is present, and all + corresponding key part values are NULL, return number of records 1.0 + (highly selective), indicating no expected matches. + */ + return 1.0; + } + + return actual_rec_per_key(last_key_part_in_prefix); } /* diff --git a/sql/table.h b/sql/table.h index c3e44de5761..4c7d5254c46 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2197,9 +2197,13 @@ class IS_table_read_plan; #define DT_CREATE 32U #define DT_FILL 64U #define DT_REINIT 128U -#define DT_PHASES 8U + +#define DT_OPTIMIZE_STAGE2 256U + +/* Number of bits used by all phases: */ +#define DT_PHASES 9U /* Phases that are applicable to all derived tables. */ -#define DT_COMMON (DT_INIT + DT_PREPARE + DT_REINIT + DT_OPTIMIZE) +#define DT_COMMON (DT_INIT + DT_PREPARE + DT_REINIT + DT_OPTIMIZE + DT_OPTIMIZE_STAGE2) /* Phases that are applicable only to materialized derived tables. */ #define DT_MATERIALIZE (DT_CREATE + DT_FILL) @@ -2585,6 +2589,7 @@ struct TABLE_LIST TABLE_LIST *next_local; /* link in a global list of all queries tables */ TABLE_LIST *next_global, **prev_global; + TABLE_LIST *linked_table; // For sequence tables used in default Lex_ident_db db; Lex_ident_table table_name; Lex_ident_i_s_table schema_table_name; diff --git a/storage/columnstore/columnstore b/storage/columnstore/columnstore index 22454e6eef5..e3a2563b588 160000 --- a/storage/columnstore/columnstore +++ b/storage/columnstore/columnstore @@ -1 +1 @@ -Subproject commit 22454e6eef5ba17c573f7602203e997c9331748d +Subproject commit e3a2563b58898de8117199eddfd7845c5a24886d diff --git a/storage/federatedx/federatedx_pushdown.cc b/storage/federatedx/federatedx_pushdown.cc index 6253fca75a0..0ec661888bc 100644 --- a/storage/federatedx/federatedx_pushdown.cc +++ b/storage/federatedx/federatedx_pushdown.cc @@ -206,6 +206,12 @@ int federatedx_handler_base::end_scan_() } +static bool is_supported_by_select_handler(enum_sql_command sql_command) +{ + return sql_command == SQLCOM_SELECT || sql_command == SQLCOM_INSERT_SELECT; +} + + /* Create FederatedX select handler for processing either a single select (in this case sel_lex is initialized and lex_unit==NULL) @@ -216,7 +222,7 @@ static select_handler * create_federatedx_select_handler(THD *thd, SELECT_LEX *sel_lex, SELECT_LEX_UNIT *lex_unit) { - if (!use_pushdown) + if (!use_pushdown || !is_supported_by_select_handler(thd->lex->sql_command)) return nullptr; auto tbl= get_fed_table_for_pushdown(sel_lex); diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index 7d0921112fb..05e3d67ae2c 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -374,18 +374,16 @@ ATTRIBUTE_COLD void btr_search_lazy_free(dict_index_t *index) noexcept UT_LIST_REMOVE(table->freed_indexes, index); index->lock.free(); dict_mem_index_free(index); + const bool destroy= !table->id && !UT_LIST_GET_LEN(table->freed_indexes) && + !UT_LIST_GET_LEN(table->indexes); + table->autoinc_mutex.wr_unlock(); - if (!UT_LIST_GET_LEN(table->freed_indexes) && - !UT_LIST_GET_LEN(table->indexes)) + if (destroy) { - ut_ad(!table->id); - table->autoinc_mutex.wr_unlock(); table->autoinc_mutex.destroy(); dict_mem_table_free(table); return; } - - table->autoinc_mutex.wr_unlock(); } ATTRIBUTE_COLD bool btr_sea::disable_and_lock() noexcept diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 5f6d677aa80..4a4cc9e129e 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -2183,10 +2183,24 @@ ATTRIBUTE_COLD void buf_flush_ahead(lsn_t lsn, bool furious) noexcept if (limit < lsn) { limit= lsn; - buf_pool.page_cleaner_set_idle(false); - pthread_cond_signal(&buf_pool.do_flush_list); if (furious) + { + /* Request any concurrent threads to wait for this batch to complete, + in log_free_check(). */ log_sys.set_check_for_checkpoint(); + /* Immediately wake up buf_flush_page_cleaner(), even when it + is in the middle of a 1-second my_cond_timedwait(). */ + wake: + buf_pool.page_cleaner_set_idle(false); + pthread_cond_signal(&buf_pool.do_flush_list); + } + else if (buf_pool.page_cleaner_idle()) + /* In non-furious mode, concurrent writes to the log will remain + possible, and we are gently requesting buf_flush_page_cleaner() + to do more work to avoid a later call with furious=true. + We will only wake the buf_flush_page_cleaner() from an indefinite + my_cond_wait(), but we will not disturb the regular 1-second sleep. */ + goto wake; } mysql_mutex_unlock(&buf_pool.flush_list_mutex); } diff --git a/storage/innobase/gis/gis0geo.cc b/storage/innobase/gis/gis0geo.cc index 4c3ff1881d0..28d39d11610 100644 --- a/storage/innobase/gis/gis0geo.cc +++ b/storage/innobase/gis/gis0geo.cc @@ -445,7 +445,7 @@ pick_next( double* g1, /*!< in: mbr of group 1. */ double* g2, /*!< in: mbr of group 2. */ rtr_split_node_t** choice, /*!< out: the next node.*/ - int* n_group, /*!< out: group number.*/ + uint16_t* n_group, /*!< out: 1 or 2 */ int n_dim) /*!< in: dimensions. */ { rtr_split_node_t* cur = node; @@ -487,7 +487,7 @@ mark_all_entries( /*=============*/ rtr_split_node_t* node, /*!< in/out: split nodes. */ int n_entries, /*!< in: entries number. */ - int n_group) /*!< in: group number. */ + uint16_t n_group) /*!< in: 1 or 2 */ { rtr_split_node_t* cur = node; rtr_split_node_t* end = node + n_entries; @@ -522,7 +522,7 @@ split_rtree_node( double* g1 = reserve_coords(d_buffer, n_dim); double* g2 = reserve_coords(d_buffer, n_dim); rtr_split_node_t* next = NULL; - int next_node = 0; + uint16_t next_node = 0; int i; int first_rec_group = 1; rtr_split_node_t* end = node + n_entries; @@ -542,9 +542,9 @@ split_rtree_node( b->n_node = 2; copy_coords(g1, a->coords, n_dim); - size1 += key_size; + size1 += a->key_len; copy_coords(g2, b->coords, n_dim); - size2 += key_size; + size2 += b->key_len; for (i = n_entries - 2; i > 0; --i) { /* Can't write into group 2 */ @@ -561,10 +561,10 @@ split_rtree_node( pick_next(node, n_entries, g1, g2, &next, &next_node, n_dim); if (next_node == 1) { - size1 += key_size; + size1 += next->key_len; mbr_join(g1, next->coords, n_dim); } else { - size2 += key_size; + size2 += next->key_len; mbr_join(g2, next->coords, n_dim); } diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index 87c0e65e969..8046af7e804 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -96,6 +96,7 @@ rtr_page_split_initialize_nodes( for (cur = task; cur < stop - 1; ++cur) { cur->coords = reserve_coords(buf_pos, SPDIMS); cur->key = rec; + cur->key_len = static_cast(len); memcpy(cur->coords, source_cur, DATA_MBR_LEN); @@ -109,11 +110,11 @@ rtr_page_split_initialize_nodes( source_cur = static_cast(dfield_get_data( dtuple_get_nth_field(tuple, 0))); cur->coords = reserve_coords(buf_pos, SPDIMS); - rec = (byte*) mem_heap_alloc( - heap, rec_get_converted_size(cursor->index(), tuple, 0)); - + len = rec_get_converted_size(cursor->index(), tuple, 0); + rec = (byte*) mem_heap_alloc(heap, len); rec = rec_convert_dtuple_to_rec(rec, cursor->index(), tuple, 0); cur->key = rec; + cur->key_len = static_cast(len); memcpy(cur->coords, source_cur, DATA_MBR_LEN); @@ -1102,8 +1103,10 @@ corrupted: /* Reposition the cursor for insert and try insertion */ page_cursor = btr_cur_get_page_cur(cursor); - page_cursor->block = cur_split_node->n_node != first_rec_group - ? new_block : block; + buf_block_t *insert_block = (cur_split_node->n_node != first_rec_group) + ? new_block + : block; + page_cursor->block = insert_block; uint16_t up_match = 0, low_match = 0; @@ -1130,7 +1133,7 @@ corrupted: attempted this already. */ if (rec == NULL) { if (!is_page_cur_get_page_zip(page_cursor) - && btr_page_reorganize(page_cursor, mtr)) { + && !btr_page_reorganize(page_cursor, mtr)) { rec = page_cur_tuple_insert(page_cursor, tuple, offsets, heap, n_ext, mtr); @@ -1183,11 +1186,11 @@ after_insert: IF_DBUG(iterated=true,); rec_t* i_rec = page_rec_get_next(page_get_infimum_rec( - buf_block_get_frame(block))); + buf_block_get_frame(insert_block))); if (UNIV_UNLIKELY(!i_rec)) { goto corrupted; } - btr_cur_position(cursor->index(), i_rec, block, cursor); + btr_cur_position(cursor->index(), i_rec, insert_block, cursor); goto func_start; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a2e21377da1..eacde4912b8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -19835,11 +19835,6 @@ static MYSQL_SYSVAR_ENUM(default_row_format, innodb_default_row_format, &innodb_default_row_format_typelib); #ifdef UNIV_DEBUG -static MYSQL_SYSVAR_UINT(trx_rseg_n_slots_debug, trx_rseg_n_slots_debug, - PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_NOCMDOPT, - "Debug flags for InnoDB to limit TRX_RSEG_N_SLOTS for trx_rsegf_undo_find_free()", - NULL, NULL, 0, 0, 1024, 0); - static MYSQL_SYSVAR_UINT(limit_optimistic_insert_debug, btr_cur_limit_optimistic_insert_debug, PLUGIN_VAR_RQCMDARG, "Artificially limit the number of records per B-tree page (0=unlimited)", @@ -20120,7 +20115,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(compression_pad_pct_max), MYSQL_SYSVAR(default_row_format), #ifdef UNIV_DEBUG - MYSQL_SYSVAR(trx_rseg_n_slots_debug), MYSQL_SYSVAR(limit_optimistic_insert_debug), MYSQL_SYSVAR(trx_purge_view_update_only_debug), MYSQL_SYSVAR(evict_tables_on_commit_debug), diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h index d4885186087..98a99847285 100644 --- a/storage/innobase/include/data0type.h +++ b/storage/innobase/include/data0type.h @@ -342,16 +342,6 @@ inline uint32_t dtype_form_prtype(ulint old_prtype, ulint charset_coll) return uint32_t(old_prtype | (charset_coll << 16)); } -/*********************************************************************//** -Determines if a MySQL string type is a subset of UTF-8. This function -may return false negatives, in case further character-set collation -codes are introduced in MySQL later. -@return whether a subset of UTF-8 */ -UNIV_INLINE -bool -dtype_is_utf8( -/*==========*/ - ulint prtype);/*!< in: precise data type */ /*********************************************************************//** Gets the type length. @return fixed length of the type, in bytes, or 0 if variable-length */ diff --git a/storage/innobase/include/data0type.inl b/storage/innobase/include/data0type.inl index add6c211bb9..4a77a039fb8 100644 --- a/storage/innobase/include/data0type.inl +++ b/storage/innobase/include/data0type.inl @@ -27,31 +27,6 @@ Created 1/16/1996 Heikki Tuuri #include "mach0data.h" #include "ha_prototypes.h" -/*********************************************************************//** -Determines if a MySQL string type is a subset of UTF-8. This function -may return false negatives, in case further character-set collation -codes are introduced in MySQL later. -@return whether a subset of UTF-8 */ -UNIV_INLINE -bool -dtype_is_utf8( -/*==========*/ - ulint prtype) /*!< in: precise data type */ -{ - /* These codes have been copied from strings/ctype-extra.c - and strings/ctype-utf8.c. */ - switch (dtype_get_charset_coll(prtype)) { - case 11: /* ascii_general_ci */ - case 65: /* ascii_bin */ - case 33: /* utf8_general_ci */ - case 83: /* utf8_bin */ - case 254: /* utf8_general_cs */ - return true; - } - - return false; -} - /*********************************************************************//** Gets the MySQL type code from a dtype. @return MySQL type code; this is NOT an InnoDB type code! */ diff --git a/storage/innobase/include/gis0geo.h b/storage/innobase/include/gis0geo.h index 3fd01a3ae54..906f0507dde 100644 --- a/storage/innobase/include/gis0geo.h +++ b/storage/innobase/include/gis0geo.h @@ -70,7 +70,8 @@ rtree_mbr_from_wkb( struct rtr_split_node_t { double square; /* square of the mbr.*/ - int n_node; /* which group in.*/ + uint16_t n_node; /* group: 1 or 2, or 0=unassigned */ + uint16_t key_len; /* key length */ uchar* key; /* key. */ double* coords; /* mbr. */ }; diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index b48b174df6f..06e3966db86 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -647,17 +647,6 @@ public: /** Note that log_sys.latch is no longer being held exclusively. */ void flag_wr_unlock() noexcept { ut_ad(m_latch_ex); m_latch_ex= false; } - /** type of page flushing is needed during commit() */ - enum page_flush_ahead - { - /** no need to trigger page cleaner */ - PAGE_FLUSH_NO= 0, - /** asynchronous flushing is needed */ - PAGE_FLUSH_ASYNC, - /** furious flushing is needed */ - PAGE_FLUSH_SYNC - }; - private: /** Handle any pages that were freed during the mini-transaction. */ void process_freed_pages(); @@ -704,29 +693,31 @@ private: /** Commit the mini-transaction log. @tparam pmem log_sys.is_mmap() @param mtr mini-transaction - @param lsns {start_lsn,flush_ahead} */ + @param lsns {start_lsn,flush_ahead_lsn} */ template - static void commit_log(mtr_t *mtr, std::pair lsns) - noexcept; + static void commit_log(mtr_t *mtr, std::pair lsns) noexcept; + + /** Release log_sys.latch. */ + void commit_log_release() noexcept; /** Append the redo log records to the redo log buffer. - @return {start_lsn,flush_ahead} */ - std::pair do_write(); + @return {start_lsn,flush_ahead_lsn} */ + std::pair do_write() noexcept; /** Append the redo log records to the redo log buffer. @tparam mmap log_sys.is_mmap() @param mtr mini-transaction @param len number of bytes to write - @return {start_lsn,flush_ahead} */ + @return {start_lsn,flush_ahead_lsn} */ template static - std::pair finish_writer(mtr_t *mtr, size_t len); + std::pair finish_writer(mtr_t *mtr, size_t len); /** The applicable variant of commit_log() */ - static void (*commit_logger)(mtr_t *, std::pair); + static void (*commit_logger)(mtr_t *, std::pair); /** The applicable variant of finish_writer() */ - static std::pair (*finisher)(mtr_t *, size_t); + static std::pair (*finisher)(mtr_t *, size_t); - std::pair finish_write(size_t len) + std::pair finish_write(size_t len) { return finisher(this, len); } public: /** Update finisher when spin_wait_delay is changing to or from 0. */ diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 256b0b73613..84879968236 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -73,11 +73,6 @@ inline buf_block_t *trx_sysf_get(mtr_t* mtr, bool rw= true) 0, rw ? RW_X_LATCH : RW_S_LATCH, mtr); } -#ifdef UNIV_DEBUG -/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ -extern uint trx_rseg_n_slots_debug; -#endif - /** Write DB_TRX_ID. @param[out] db_trx_id the DB_TRX_ID field to be written to @param[in] id transaction ID */ diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 8ea19514ce6..7d7f74a98eb 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -1321,10 +1321,10 @@ func_exit: } const lsn_t lsn= log_sys.get_lsn(); - const lsn_t checkpoint= log_sys.last_checkpoint_lsn; - const lsn_t sync_lsn= checkpoint + log_sys.max_checkpoint_age; + const lsn_t max_age= log_sys.max_checkpoint_age; + const lsn_t age= lsn_t(lsn - log_sys.last_checkpoint_lsn); - if (lsn <= sync_lsn) + if (age <= max_age) { #ifndef DBUG_OFF skip_checkpoint: @@ -1337,7 +1337,7 @@ func_exit: log_sys.latch.wr_unlock(); /* We must wait to prevent the tail of the log overwriting the head. */ - buf_flush_wait_flushed(std::min(sync_lsn, checkpoint + (1U << 20))); + buf_flush_wait_flushed(lsn - max_age); /* Sleep to avoid a thundering herd */ std::this_thread::sleep_for(std::chrono::milliseconds(10)); } diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index bea84de6d47..bffbd6e6ff2 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -39,10 +39,10 @@ Created 11/26/1995 Heikki Tuuri #include "my_cpu.h" #ifdef HAVE_PMEM -void (*mtr_t::commit_logger)(mtr_t *, std::pair); +void (*mtr_t::commit_logger)(mtr_t *, std::pair); #endif -std::pair (*mtr_t::finisher)(mtr_t *, size_t); +std::pair (*mtr_t::finisher)(mtr_t *, size_t); void mtr_t::finisher_update() { @@ -335,9 +335,25 @@ void mtr_t::release() m_memo.clear(); } +ATTRIBUTE_NOINLINE void mtr_t::commit_log_release() noexcept +{ + if (m_latch_ex) + { + log_sys.latch.wr_unlock(); + m_latch_ex= false; + } + else + log_sys.latch.rd_unlock(); +} + +static ATTRIBUTE_NOINLINE ATTRIBUTE_COLD +void mtr_flush_ahead(lsn_t flush_lsn) noexcept +{ + buf_flush_ahead(flush_lsn, bool(flush_lsn & 1)); +} + template -void mtr_t::commit_log(mtr_t *mtr, std::pair lsns) - noexcept +void mtr_t::commit_log(mtr_t *mtr, std::pair lsns) noexcept { size_t modified= 0; @@ -378,25 +394,12 @@ void mtr_t::commit_log(mtr_t *mtr, std::pair lsns) buf_pool.page_cleaner_wakeup(); mysql_mutex_unlock(&buf_pool.flush_list_mutex); - if (mtr->m_latch_ex) - { - log_sys.latch.wr_unlock(); - mtr->m_latch_ex= false; - } - else - log_sys.latch.rd_unlock(); - + mtr->commit_log_release(); mtr->release(); } else { - if (mtr->m_latch_ex) - { - log_sys.latch.wr_unlock(); - mtr->m_latch_ex= false; - } - else - log_sys.latch.rd_unlock(); + mtr->commit_log_release(); for (auto it= mtr->m_memo.rbegin(); it != mtr->m_memo.rend(); ) { @@ -458,8 +461,11 @@ void mtr_t::commit_log(mtr_t *mtr, std::pair lsns) if (ha_handler_stats *stats= mtr->trx->active_handler_stats) stats->pages_updated+= modified; - if (UNIV_UNLIKELY(lsns.second != PAGE_FLUSH_NO)) - buf_flush_ahead(mtr->m_commit_lsn, lsns.second == PAGE_FLUSH_SYNC); + if (UNIV_UNLIKELY(lsns.second != 0)) + { + ut_ad(lsns.second < mtr->m_commit_lsn); + mtr_flush_ahead(lsns.second); + } } /** Commit a mini-transaction. */ @@ -481,7 +487,7 @@ void mtr_t::commit() } ut_ad(!srv_read_only_mode); - std::pair lsns{do_write()}; + std::pair lsns{do_write()}; process_freed_pages(); #ifdef HAVE_PMEM commit_logger(this, lsns); @@ -973,24 +979,44 @@ std::pair log_t::append_prepare(size_t size, bool ex) noexcept /** Finish appending data to the log. @param lsn the end LSN of the log record -@return whether buf_flush_ahead() will have to be invoked */ -static mtr_t::page_flush_ahead log_close(lsn_t lsn) noexcept +@return lsn for invoking buf_flush_ahead() on, with "furious" flag in the LSB +@retval 0 if buf_flush_ahead() will not have to be invoked */ +static lsn_t log_close(lsn_t lsn) noexcept { ut_ad(log_sys.latch_have_any()); const lsn_t checkpoint_age= lsn - log_sys.last_checkpoint_lsn; + const lsn_t max_age= log_sys.max_modified_age_async; if (UNIV_UNLIKELY(checkpoint_age >= log_sys.log_capacity) && /* silence message on create_log_file() after the log had been deleted */ checkpoint_age != lsn) log_overwrite_warning(lsn); - else if (UNIV_LIKELY(checkpoint_age <= log_sys.max_modified_age_async)) - return mtr_t::PAGE_FLUSH_NO; - else if (UNIV_LIKELY(checkpoint_age <= log_sys.max_checkpoint_age)) - return mtr_t::PAGE_FLUSH_ASYNC; + else if (UNIV_LIKELY(checkpoint_age <= max_age)) + return 0; - log_sys.set_check_for_checkpoint(); - return mtr_t::PAGE_FLUSH_SYNC; + /* The last checkpoint is too old. Let us set an appropriate + checkpoint age target, that is, a checkpoint LSN target that is the + current LSN minus the maximum age. Let us see if are exceeding the + log_checkpoint_margin() limit that will involve a synchronous wait + in each write operation. */ + + const bool furious{checkpoint_age >= log_sys.max_checkpoint_age}; + + /* If furious==true, we could set a less aggressive target + (lsn - log_sys.max_checkpoint_age) instead of what we will be using + in both cases (lsn - log_sys.max_checkpoint_age_async). + + The aim of the more aggressive target is that mtr_flush_ahead() will + request more progress in buf_flush_page_cleaner() sooner, so that it + will be less likely that several threads will end up waiting in + log_checkpoint_margin(). That function will use the less aggressive + limit (lsn - log_sys.max_checkpoint_age) in order to minimize the + synchronous wait time. */ + if (furious) + log_sys.set_check_for_checkpoint(); + + return ((lsn - max_age) & ~lsn_t{1}) | lsn_t{furious}; } inline void mtr_t::page_checksum(const buf_page_t &bpage) @@ -1036,7 +1062,7 @@ inline void mtr_t::page_checksum(const buf_page_t &bpage) m_log.close(l + 4); } -std::pair mtr_t::do_write() +std::pair mtr_t::do_write() noexcept { ut_ad(!recv_no_log_write); ut_ad(is_logged()); @@ -1188,8 +1214,7 @@ inline void log_t::append(byte *&d, const void *s, size_t size) noexcept } template -std::pair -mtr_t::finish_writer(mtr_t *mtr, size_t len) +std::pair mtr_t::finish_writer(mtr_t *mtr, size_t len) { ut_ad(log_sys.is_latest()); ut_ad(!recv_no_log_write); diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc index 33aa1f8ccd5..47c3b925919 100644 --- a/storage/innobase/row/row0row.cc +++ b/storage/innobase/row/row0row.cc @@ -1366,18 +1366,18 @@ row_raw_format_str( charset_coll = dtype_get_charset_coll(prtype); - if (UNIV_LIKELY(dtype_is_utf8(prtype))) { - + switch (charset_coll) { + case 11: /* ascii_general_ci */ + case 65: /* ascii_bin */ + case 33: /* utf8_general_ci */ + case 83: /* utf8_bin */ + case 254: /* utf8_general_cs */ return(ut_str_sql_format(data, data_len, buf, buf_size)); - } - /* else */ - - if (charset_coll == DATA_MYSQL_BINARY_CHARSET_COLL) { - + case 0: + case DATA_MYSQL_BINARY_CHARSET_COLL: *format_in_hex = TRUE; return(0); } - /* else */ return(innobase_raw_format(data, data_len, charset_coll, buf, buf_size)); @@ -1438,9 +1438,18 @@ row_raw_format( break; case DATA_CHAR: case DATA_VARCHAR: + /* FTS_%_CONFIG.key are incorrectly created with prtype==0. + The DATA_ENGLISH is being used for CHAR columns of the + InnoDB internal SQL parser, such as SYS_FOREIGN.ID. + For these, we will eventually goto format_in_hex. */ + ut_ad(dtype_get_charset_coll(prtype) == 8 + || (mtype == DATA_VARCHAR + && (prtype == 0 || prtype == DATA_ENGLISH))); + goto format_str; case DATA_MYSQL: case DATA_VARMYSQL: - + ut_ad(dtype_get_charset_coll(prtype)); + format_str: ret = row_raw_format_str(data, data_len, prtype, buf, buf_size, &format_in_hex); if (format_in_hex) { diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index b3e0e79a6a9..9ba4a8f3e19 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -420,7 +420,6 @@ loop: rollback segment. */ if (!(rseg.SKIP & rseg_ref) && !freed && - ut_d(!trx_rseg_n_slots_debug &&) &rseg == &trx_sys.rseg_array[purge_sys.skipped_rseg]) /* If rseg.space == purge_sys.truncate_undo_space.current the following will be a no-op. A possible conflict diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 8010d32700b..2f2265a3df1 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -45,9 +45,6 @@ Created 3/26/1996 Heikki Tuuri trx_sys_t trx_sys; #ifdef UNIV_DEBUG -/* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ -uint trx_rseg_n_slots_debug = 0; - void rw_trx_hash_t::validate_element(trx_t *trx) { ut_ad(!trx->read_only || !trx->rsegs.m_redo.rseg); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 6dbb69f6083..987e719d4e9 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -821,7 +821,6 @@ static void trx_assign_rseg_low(trx_t *trx) undo tablespaces that are scheduled for truncation. */ static Atomic_counter rseg_slot; unsigned slot = rseg_slot++ % TRX_SYS_N_RSEGS; - ut_d(if (trx_rseg_n_slots_debug) slot = 0); ut_d(const auto start_scan_slot = slot); ut_d(bool look_for_rollover = false); trx_rseg_t* rseg; @@ -833,7 +832,6 @@ static void trx_assign_rseg_low(trx_t *trx) rseg = &trx_sys.rseg_array[slot]; ut_ad(!look_for_rollover || start_scan_slot != slot); ut_d(look_for_rollover = true); - ut_d(if (!trx_rseg_n_slots_debug)) slot = (slot + 1) % TRX_SYS_N_RSEGS; if (!rseg->space) { diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 911c1c98a85..6ed3ff27f88 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -436,11 +436,6 @@ static ulint trx_rsegf_undo_find_free(const buf_block_t *rseg_header) { ulint max_slots= TRX_RSEG_N_SLOTS; -#ifdef UNIV_DEBUG - if (trx_rseg_n_slots_debug) - max_slots= std::min(trx_rseg_n_slots_debug, TRX_RSEG_N_SLOTS); -#endif - for (ulint i= 0; i < max_slots; i++) if (trx_rsegf_get_nth_undo(rseg_header, i) == FIL_NULL) return i; diff --git a/storage/spider/CODING_STADNARDS.org b/storage/spider/CODING_STADNARDS.org new file mode 100644 index 00000000000..445b92fe42b --- /dev/null +++ b/storage/spider/CODING_STADNARDS.org @@ -0,0 +1,81 @@ +#+title Spider Development Documentation + +** Testing + :PROPERTIES: + :UPDATED: [2025-10-15 Wed 15:33] + :END: + +*** Run spider test suites + :PROPERTIES: + :UPDATED: [2025-10-15 Wed 15:39] + :END: + +Spider has sub-suites. Assuming temporary WIP spider tests are placed +under the spider/temp suite, to run a test on all spider tests, do + +#+begin_src sh +./mysql-test/mtr --suite spider,spider/*,spider/*/* \ +--skip-test="spider/temp.*|.*/t\..*" --parallel=auto --big-test \ +--force --max-test-fail=0 +#+end_src + +Tests should be run normally, but also with --ps-protocol, +--view-protocol and ASAN. + +For 10.11+ tests should also be run with +--mysqld=--loose-disable-spider-group-by-handler. This will be done +automatically after MDEV-37810. + +*** Where to place new tests + :PROPERTIES: + :UPDATED: [2025-10-15 Wed 15:35] + :END: + +- spider/bugfix suite for bugfixes +- spider/feature suite for new features +- spider suite for all else, such as generic tests to improve coverage + +*** Use engine defined attributes in tests whenever possible + :PROPERTIES: + :UPDATED: [2025-10-15 Wed 15:52] + :END: + +In versions of at least 10.11, when writing new tests or updating +existing tests, use engine defined attributes for spider table +connection info instead of table comments + +#+begin_src sql +# Do this for 10.11+ +CREATE TABLE t (c int) ENGINE=SPIDER REMOTE_SERVER=s1 REMOTE_TABLE=t1; +# Do this for 10.6 +CREATE TABLE t (c int) ENGINE=SPIDER COMMENT='srv "s1", table "t1"'; +#+end_src + +However, if the spider table has connection info that is not +REMOTE_SERVER, REMOTE_TABLE, or REMOTE_DATABASE, comments are still +needed for 10.11: + +#+begin_src sql +# Do this for 10.6 and 10.11 +CREATE TABLE t (c int) ENGINE=SPIDER COMMENT='srv "s1", table "t1", read_only_mode "1"'; +# Do this for 11.4+ +CREATE TABLE t (c int) ENGINE=SPIDER REMOTE_SERVER=s1 REMOTE_TABLE=t1 READ_ONLY=1; +#+end_src + +Don't mix engine defined attributes with COMMENT, unless the mixing is +part of the test. + +#+begin_src sql +# Don't do this +CREATE TABLE t (c int) ENGINE=SPIDER REMOTE_SERVER=s1 REMOTE_TABLE=t1 COMMENT='read_only_mode "1"'; +#+end_src + +WRAPPER by default is mysql, so it is ok to do the following +conversion in 10.11+: + +#+begin_src sql +# From +CREATE TABLE t (c int) ENGINE=SPIDER COMMENT='wrapper "mysql", srv "s1", table "t1"'; +# to +CREATE TABLE t (c int) ENGINE=SPIDER REMOTE_SERVER=s1 REMOTE_TABLE=t1; +#+end_src diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 9994121ba47..3f063075a4c 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -59,12 +59,56 @@ public: char *conn_keys_first_ptr; char **conn_keys; SPIDER_CONN **conns; - /* array of indexes of active servers */ + /* + Array of indexes of active servers. + + For a spider table or partition with multiple remotes (HA), the + remotes are divided into n groups of active links, where n is the + number of "active link count", equal to share->link_count aka + share->active_link_count. For example, if a spider table has 11 + remotes (i.e. share->all_link_count == 11), and + share->active_link_count == 3, then we have 3 link groups with + group 0 consisting of the 0th, 3rd, 6th and 9th remotes and so on: + + group 0: 0, 3, 6, 9 + group 1: 1, 4, 7, 10 + group 2: 2, 5, 8 + + conn_link_idx[i] is the "current" remote chosen for the ith group, + and it can only take a value in the ith group. + + Continue with the example above, at some point, we could end up + with: + + conn_link_idx[0] == 3 + conn_link_idx[1] == 1 + conn_link_idx[2] == 8 + + conn_link_idx is set in spider_trx_set_link_idx_for_all(). + + By default, active_link_idx is the same number as all_link_count, + i.e. 11 in the above example. + + If spider HA is gone (MDEV-28862), this will be no longer needed. + + Typically, to distinguish the ith group and ith link, we use + variable names link_idx and all_link_idx respectively, so we often + have + + all_link_idx == conn_link_idx[link_idx] + + spider->conns[link_idx] is created using connection info of the + `conn_link_idx[link_idx]'th remote. + + When only one of the indexes is used, we simply use variable name + link_idx + */ uint *conn_link_idx; /* A bitmap indicating whether each active server have some higher numbered server in the same "group" left to try (can fail over) */ uchar *conn_can_fo; void **quick_targets; + /* indexed on active servers */ int *need_mons; query_id_t search_link_query_id; int search_link_idx; @@ -89,8 +133,17 @@ public: bool da_status; bool use_spatial_index; + /* + Index of the table in FROM tables, for the use of direct + execution by gbh + */ uint idx_for_direct_join; + /* + Whether using a spider_fields, only applicable to direct + execution by gbh + */ bool use_fields; + /* If use_fields == true, the spider_fields in use for gbh */ spider_fields *fields; SPIDER_LINK_IDX_CHAIN *link_idx_chain; SPIDER_LINK_IDX_CHAIN *result_link_idx_chain; diff --git a/storage/spider/mysql-test/spider/bg/combinations b/storage/spider/mysql-test/spider/bg/combinations new file mode 100644 index 00000000000..cad4d107176 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/combinations @@ -0,0 +1,5 @@ +[group_by_handler] +loose_spider_disable_group_by_handler=0 + +[usual_handler] +loose_spider_disable_group_by_handler=1 diff --git a/storage/spider/mysql-test/spider/bg/r/direct_aggregate,usual_handler.rdiff b/storage/spider/mysql-test/spider/bg/r/direct_aggregate,usual_handler.rdiff new file mode 100644 index 00000000000..2ba8144bc16 --- /dev/null +++ b/storage/spider/mysql-test/spider/bg/r/direct_aggregate,usual_handler.rdiff @@ -0,0 +1,39 @@ +--- ../src/storage/spider/mysql-test/spider/bg/r/direct_aggregate.result 2024-06-21 13:50:21.429397065 +1000 ++++ ../src/storage/spider/mysql-test/spider/bg/r/direct_aggregate.reject 2025-10-22 17:39:27.706744886 +1100 +@@ -54,31 +54,31 @@ + 5 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SELECT MAX(a) FROM ta_l; + MAX(a) + 5 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SELECT MIN(a) FROM ta_l; + MIN(a) + 1 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SELECT MAX(a) FROM ta_l WHERE a < 5; + MAX(a) + 4 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SELECT MIN(a) FROM ta_l WHERE a > 1; + MIN(a) + 2 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + + deinit + connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/t/basic_sql.test b/storage/spider/mysql-test/spider/bg/t/basic_sql.test index 7b3ec715f86..0c9f6ce660d 100644 --- a/storage/spider/mysql-test/spider/bg/t/basic_sql.test +++ b/storage/spider/mysql-test/spider/bg/t/basic_sql.test @@ -476,11 +476,8 @@ SELECT count(*) FROM ta_l ORDER BY a; --enable_query_log --enable_result_log --connection master_1 -# MDEV-36357 ---disable_view_protocol SELECT a.a, a.b, date_format(a.c, '%Y-%m-%d %H:%i:%s') FROM tb_l a WHERE EXISTS (SELECT * FROM ta_l b WHERE b.b = a.b) ORDER BY a.a; ---enable_view_protocol --disable_query_log --disable_result_log --connection child2_1 diff --git a/storage/spider/mysql-test/spider/bugfix/combinations b/storage/spider/mysql-test/spider/bugfix/combinations new file mode 100644 index 00000000000..cad4d107176 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/combinations @@ -0,0 +1,5 @@ +[group_by_handler] +loose_spider_disable_group_by_handler=0 + +[usual_handler] +loose_spider_disable_group_by_handler=1 diff --git a/storage/spider/mysql-test/spider/bugfix/disabled.def b/storage/spider/mysql-test/spider/bugfix/disabled.def index 9009cd2565d..62605347130 100644 --- a/storage/spider/mysql-test/spider/bugfix/disabled.def +++ b/storage/spider/mysql-test/spider/bugfix/disabled.def @@ -2,4 +2,3 @@ wait_timeout : MDEV-26045 mdev_29676 : MDEV-31138 mdev_27239: MDEV-32046 mdev_27575 : MDEV-32997 -mdev_28739_simple : MDEV-33343 diff --git a/storage/spider/mysql-test/spider/bugfix/r/index.result b/storage/spider/mysql-test/spider/bugfix/r/index.result index a3c6549631c..d36d5113994 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/index.result +++ b/storage/spider/mysql-test/spider/bugfix/r/index.result @@ -10,21 +10,29 @@ set global spider_same_server_link= on; select @@spider_auto_increment_mode; @@spider_auto_increment_mode 0 -create or replace table auto_test_local.t (id int primary key) engine=InnoDB; +create or replace table auto_test_local.t (id int, primary key(id desc)) engine=InnoDB; create or replace table t_sp1 (id int auto_increment, primary key(id desc)) engine=Spider COMMENT='wrapper "mysql", srv "s_1", table "t"'; Warnings: Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. insert into t_sp1 () values (),(),(); insert into t_sp1 () values (),(),(); +select * from auto_test_local.t; +id +6 +5 +4 +3 +2 +1 select * from t_sp1; id -1 -2 -3 -4 -5 6 +5 +4 +3 +2 +1 drop table t_sp1, auto_test_local.t; # # MDEV-27581 Wrong result with DESC key on partitioned Spider table diff --git a/storage/spider/mysql-test/spider/bugfix/r/insert_select,usual_handler.rdiff b/storage/spider/mysql-test/spider/bugfix/r/insert_select,usual_handler.rdiff new file mode 100644 index 00000000000..a5dc96572eb --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/insert_select,usual_handler.rdiff @@ -0,0 +1,29 @@ +--- ../src/storage/spider/mysql-test/spider/bugfix/r/insert_select.result 2024-05-01 14:39:20.114241787 +1000 ++++ ../src/storage/spider/mysql-test/spider/bugfix/r/insert_select.reject 2025-10-22 17:39:54.450930274 +1100 +@@ -60,16 +60,16 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 4) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 3) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 2) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 1) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 0) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 9) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 8) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 7) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 6) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode +-select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 5) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 4 and `dt` > _latin1'2012-11-21' and ((`skey` = 4) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 3 and `dt` > _latin1'2012-11-21' and ((`skey` = 3) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 2 and `dt` > _latin1'2012-11-21' and ((`skey` = 2) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 1 and `dt` > _latin1'2012-11-21' and ((`skey` = 1) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 0 and `dt` > _latin1'2012-11-21' and ((`skey` = 0) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 9 and `dt` > _latin1'2012-11-21' and ((`skey` = 9) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 8 and `dt` > _latin1'2012-11-21' and ((`skey` = 8) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 7 and `dt` > _latin1'2012-11-21' and ((`skey` = 7) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 6 and `dt` > _latin1'2012-11-21' and ((`skey` = 6) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode ++select `skey`,`dt`,`tm` from `auto_test_remote`.`tbl_a` where `skey` = 5 and `dt` > _latin1'2012-11-21' and ((`skey` = 5) and (`dt` > _latin1'2012-11-21')) order by `dt`,`tm` lock in share mode + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT pkey, dt FROM tbl_b ORDER BY pkey; + pkey dt diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_20100,usual_handler.rdiff b/storage/spider/mysql-test/spider/bugfix/r/mdev_20100,usual_handler.rdiff new file mode 100644 index 00000000000..abfab37f8cb --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_20100,usual_handler.rdiff @@ -0,0 +1,23 @@ +--- ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_20100.result 2024-05-01 14:39:20.114241787 +1000 ++++ ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_20100.reject 2025-10-22 17:39:55.494937566 +1100 +@@ -78,16 +78,16 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t0.`b` `b`,t0.`c` `c` from `auto_test_remote`.`ta_r3` t0 where (t0.`b` = 'c') ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r3` where (`b` = 'c') + select `a`,`b`,`c` from `auto_test_remote`.`ta_r2` + select `a`,`b`,`c` from `auto_test_remote`.`ta_r3` +-select t0.`a` `a`,t0.`b` `b`,t0.`c` `c` from `auto_test_remote`.`ta_r4` t0 where (t0.`b` = 'c') ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r4` where (`b` = 'c') + select `a`,`b`,`c` from `auto_test_remote`.`ta_r2` + select `a`,`b`,`c` from `auto_test_remote`.`ta_r3` +-select t0.`a` `a`,t0.`b` `b`,t0.`c` `c` from `auto_test_remote`.`ta_r2` t0 where (t0.`b` = 'c') ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r2` where (`b` = 'c') + select `a`,`b`,`c` from `auto_test_remote`.`ta_r2` + select `a`,`b`,`c` from `auto_test_remote`.`ta_r4` +-select t0.`a` `a`,t0.`b` `b`,t0.`c` `c` from `auto_test_remote`.`ta_r2` t0 where (t0.`b` = 'c') ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r2` where (`b` = 'c') + select `a`,`b`,`c` from `auto_test_remote`.`ta_r3` + select `a`,`b`,`c` from `auto_test_remote`.`ta_r4` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_20502,usual_handler.rdiff b/storage/spider/mysql-test/spider/bugfix/r/mdev_20502,usual_handler.rdiff new file mode 100644 index 00000000000..fd264d7d9a5 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_20502,usual_handler.rdiff @@ -0,0 +1,21 @@ +--- ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_20502.result 2025-08-01 15:07:36.416896406 +1000 ++++ ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_20502.reject 2025-10-22 17:39:57.398950875 +1100 +@@ -54,14 +54,14 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`id` `id`,0 `const`,t0.`val` `val` from `auto_test_remote`.`tbl_a` t0 + select `id`,`val` from `auto_test_remote`.`tbl_a` +-select (t0.`val` + 1) `tbl_a.val+1` from `auto_test_remote`.`tbl_a` t0 ++select `id`,`val` from `auto_test_remote`.`tbl_a` ++select `val` from `auto_test_remote`.`tbl_a` + select `id`,`val` from `auto_test_remote`.`tbl_a` order by `id` desc limit 1 for update + select `val` from `auto_test_remote`.`tbl_a` group by `val` +-select (t0.`val` + 1) `tbl_a.val+1` from `auto_test_remote`.`tbl_a` t0 limit 1 ++select `val` from `auto_test_remote`.`tbl_a` limit 2 + select max(`id`),min(`id`),`val` from `auto_test_remote`.`tbl_a` group by `val` +-select (t0.`val` + 1) `tbl_a.val+1` from `auto_test_remote`.`tbl_a` t0 limit 1 ++select `val` from `auto_test_remote`.`tbl_a` limit 2 + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT id, val FROM tbl_a ORDER BY id; + id val diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_27172,usual_handler.rdiff b/storage/spider/mysql-test/spider/bugfix/r/mdev_27172,usual_handler.rdiff new file mode 100644 index 00000000000..194eecf3b37 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_27172,usual_handler.rdiff @@ -0,0 +1,12 @@ +--- ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result 2024-11-15 17:14:27.541903833 +1100 ++++ ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.reject 2025-10-22 17:40:25.831151167 +1100 +@@ -66,6 +66,9 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'select `id`,`greeting` from %'; + argument ++select `id`,`greeting` from `auto_test_remote`.`tbl_a` where `greeting` = 'Aloha!' and ((`greeting` = 'Aloha!') and ((case `greeting` when 'Aloha!' then _latin1'one' else _latin1'more' end) = _latin1'one')) ++select `id`,`greeting` from `auto_test_remote`.`tbl_b` where `greeting` like 'Aloha%' and ((`greeting` = 'Aloha!') and ((case `greeting` when 'Aloha!' then _latin1'one' else _latin1'more' end) = _latin1'one')) ++select `id`,`greeting` from `auto_test_remote`.`tbl_c` where `greeting` like 'Aloha%' and ((`greeting` = 'Aloha!') and ((case `greeting` when 'Aloha!' then _latin1'one' else _latin1'more' end) = _latin1'one')) + connection child2_1; + SET @@global.general_log = @general_log_backup; + SET @@global.log_output = @log_output_backup; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29008,usual_handler.rdiff b/storage/spider/mysql-test/spider/bugfix/r/mdev_29008,usual_handler.rdiff new file mode 100644 index 00000000000..a5dbf0cd49c --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29008,usual_handler.rdiff @@ -0,0 +1,15 @@ +--- ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_29008.result 2025-08-01 15:07:36.416896406 +1000 ++++ ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_29008.reject 2025-10-22 17:40:29.191175025 +1100 +@@ -39,8 +39,10 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %'; + argument +-select min(t1.`a`) `f1`,t0.`b` `f2` from `auto_test_remote`.`tbl_a` t0 join `auto_test_remote`.`tbl_a` t1 group by `f2` order by `f1`,`f2` +-select min(t1.`a`) `f1`,t0.`b` `f2` from `auto_test_remote`.`tbl_a` t0 join `auto_test_remote`.`tbl_a` t1 group by `f2` order by min(t1.`a`),max(t1.`a`),`f2` ++select `b` from `auto_test_remote`.`tbl_a` ++select `a` from `auto_test_remote`.`tbl_a` ++select `b` from `auto_test_remote`.`tbl_a` ++select `a` from `auto_test_remote`.`tbl_a` + SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %' + set global log_output=@old_log_output; + set global general_log=@old_general_log; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29502,usual_handler.rdiff b/storage/spider/mysql-test/spider/bugfix/r/mdev_29502,usual_handler.rdiff new file mode 100644 index 00000000000..737f5f70c5a --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29502,usual_handler.rdiff @@ -0,0 +1,36 @@ +--- ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_29502.result 2025-08-01 15:07:36.416896406 +1000 ++++ ../src/storage/spider/mysql-test/spider/bugfix/r/mdev_29502.reject 2025-10-22 17:40:28.295168659 +1100 +@@ -35,7 +35,7 @@ + 48 48 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 8 + DROP TABLE t, t1; + CREATE TABLE t (a INT, b INT); + INSERT INTO t VALUES (23, -1),(48, 97); +@@ -45,7 +45,7 @@ + 145 -25 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 10 + DROP TABLE t, t1; + CREATE TABLE t (a INT); + INSERT INTO t VALUES (23),(97),(42); +@@ -55,13 +55,13 @@ + Y 97 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 2 ++Spider_direct_aggregate 12 + SELECT MAX(a), IF(COUNT(a > 0),'Y','N') FROM t1; + MAX(a) IF(COUNT(a > 0),'Y','N') + 97 Y + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 4 ++Spider_direct_aggregate 14 + DROP TABLE t, t1; + set spider_direct_aggregate=@old_spider_direct_aggregate; + DROP SERVER srv_mdev_29502; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_34659.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_34659.result index 5aa61396051..4cff89d546f 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_34659.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_34659.result @@ -2,6 +2,7 @@ for master_1 for child2 for child3 SET spider_same_server_link= on; +SET spider_disable_group_by_handler= 0; SET sql_mode=''; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote,usual_handler.rdiff b/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote,usual_handler.rdiff new file mode 100644 index 00000000000..f672a4756b6 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote,usual_handler.rdiff @@ -0,0 +1,13 @@ +--- a/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote.result ++++ b/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote.result +@@ -51,8 +51,8 @@ connection child2_1; + SET NAMES utf8; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`pkey` `pkey`,(left(t0.`txt_utf8` , 4)) `LEFT(``txt_utf8``, 4)` from `auto_test_remote`.`tbl_a` t0 order by (left(`txt_utf8` , 4)) limit 3 +-select t0.`pkey` `pkey`,(substr(t0.`txt_utf8` , 1 , 4)) `SUBSTR(``txt_utf8``, 1, 4)` from `auto_test_remote`.`tbl_a` t0 order by (substr(`txt_utf8` , 1 , 4)) limit 3 ++select `pkey`,`txt_utf8` from `auto_test_remote`.`tbl_a` order by (left(`txt_utf8` , 4)) limit 3 ++select `pkey`,`txt_utf8` from `auto_test_remote`.`tbl_a` order by (substr(`txt_utf8` , 1 , 4)) limit 3 + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT pkey, txt_utf8 FROM tbl_a ORDER BY pkey; + pkey txt_utf8 diff --git a/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb,usual_handler.rdiff b/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb,usual_handler.rdiff new file mode 100644 index 00000000000..e1745600f98 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb,usual_handler.rdiff @@ -0,0 +1,11 @@ +--- ../src/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result 2024-05-01 14:39:20.118241872 +1000 ++++ ../src/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.reject 2025-10-22 17:40:53.351347717 +1100 +@@ -47,7 +47,7 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`pkey` `pkey` from `auto_test_remote`.`tbl_a` t0 order by `pkey` ++select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT pkey FROM tbl_a ORDER BY pkey; + pkey diff --git a/storage/spider/mysql-test/spider/bugfix/t/index.test b/storage/spider/mysql-test/spider/bugfix/t/index.test index bef38660a3d..d7f9b2577b2 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/index.test +++ b/storage/spider/mysql-test/spider/bugfix/t/index.test @@ -12,17 +12,15 @@ set global spider_same_server_link= on; --echo # select @@spider_auto_increment_mode; -create or replace table auto_test_local.t (id int primary key) engine=InnoDB; +create or replace table auto_test_local.t (id int, primary key(id desc)) engine=InnoDB; create or replace table t_sp1 (id int auto_increment, primary key(id desc)) engine=Spider COMMENT='wrapper "mysql", srv "s_1", table "t"'; --disable_ps_protocol insert into t_sp1 () values (),(),(); --enable_ps_protocol insert into t_sp1 () values (),(),(); -# MDEV-37568 ---disable_view_protocol +select * from auto_test_local.t; select * from t_sp1; ---enable_view_protocol drop table t_sp1, auto_test_local.t; --echo # diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_22979.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_22979.test index 7f42bd734c6..93e210a9e50 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_22979.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_22979.test @@ -12,7 +12,8 @@ let $PLUGIN_DIR=`select @@plugin_dir`; --write_file $MYSQLTEST_VARDIR/tmp/mdev_22979.sql drop table if exists foo.bar; EOF ---exec $MYSQLD_CMD --datadir=$MYSQLD_DATADIR --bootstrap --plugin-dir=$PLUGIN_DIR --plugin-load-add=ha_spider < $MYSQLTEST_VARDIR/tmp/mdev_22979.sql +--exec $MYSQLD --defaults-group-suffix=.1.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --datadir=$MYSQLD_DATADIR --bootstrap --plugin-dir=$PLUGIN_DIR --plugin-load-add=ha_spider < $MYSQLTEST_VARDIR/tmp/mdev_22979.sql --source include/start_mysqld.inc --disable_query_log --source ../../include/clean_up_spider.inc +--remove_file $MYSQLTEST_VARDIR/tmp/mdev_22979.sql diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test index 4ddf863b2a4..d8392fb71f4 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test @@ -21,6 +21,7 @@ set spider_direct_aggregate=1; eval CREATE TABLE t1 (a INT KEY) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "$srv",TABLE "t"'; +--disable_ps2_protocol --disable_ps_protocol SELECT MAX(a) FROM t1; --enable_ps_protocol @@ -34,6 +35,7 @@ SELECT COUNT(a), MAX(a), SUM(a) FROM t1; SELECT MAX(a), COUNT(a), SUM(a) FROM t1; SELECT MAX(a), MAX(COALESCE(a)) FROM t1; --enable_view_protocol +--enable_ps2_protocol SHOW STATUS LIKE 'Spider_direct_aggregate'; DROP TABLE t, t1; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test index 330b96db6f9..072252eba66 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test @@ -5,6 +5,8 @@ --enable_query_log SET spider_same_server_link= on; +# TODO(MDEV-37923) +SET spider_disable_group_by_handler= 0; SET sql_mode=''; evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); diff --git a/storage/spider/mysql-test/spider/combinations b/storage/spider/mysql-test/spider/combinations new file mode 100644 index 00000000000..cad4d107176 --- /dev/null +++ b/storage/spider/mysql-test/spider/combinations @@ -0,0 +1,5 @@ +[group_by_handler] +loose_spider_disable_group_by_handler=0 + +[usual_handler] +loose_spider_disable_group_by_handler=1 diff --git a/storage/spider/mysql-test/spider/disabled.def b/storage/spider/mysql-test/spider/disabled.def new file mode 100644 index 00000000000..0c0fe4583e1 --- /dev/null +++ b/storage/spider/mysql-test/spider/disabled.def @@ -0,0 +1 @@ +alter_server : MDEV-37787 diff --git a/storage/spider/mysql-test/spider/feature/combinations b/storage/spider/mysql-test/spider/feature/combinations new file mode 100644 index 00000000000..cad4d107176 --- /dev/null +++ b/storage/spider/mysql-test/spider/feature/combinations @@ -0,0 +1,5 @@ +[group_by_handler] +loose_spider_disable_group_by_handler=0 + +[usual_handler] +loose_spider_disable_group_by_handler=1 diff --git a/storage/spider/mysql-test/spider/feature/r/engine_defined_attributes,usual_handler.rdiff b/storage/spider/mysql-test/spider/feature/r/engine_defined_attributes,usual_handler.rdiff new file mode 100644 index 00000000000..a2730ad9686 --- /dev/null +++ b/storage/spider/mysql-test/spider/feature/r/engine_defined_attributes,usual_handler.rdiff @@ -0,0 +1,11 @@ +--- ../src/storage/spider/mysql-test/spider/feature/r/engine_defined_attributes.result 2025-10-15 11:15:55.417080834 +1100 ++++ ../src/storage/spider/mysql-test/spider/feature/r/engine_defined_attributes.reject 2025-10-27 12:30:14.840560596 +1100 +@@ -134,7 +134,7 @@ + connection child2_1; + select argument from mysql.general_log where argument like "select sql_no_cache%" limit 1; + argument +-select sql_no_cache t0.`a` `a`,t0.`b` `b` from `auto_test_remote`.`tbl_a` t0 ++select sql_no_cache `a`,`b` from `auto_test_remote`.`tbl_a` + SET global general_log = @old_general_log; + SET global log_output = @old_log_output; + truncate table mysql.general_log; diff --git a/storage/spider/mysql-test/spider/feature/r/pushdown_case,usual_handler.rdiff b/storage/spider/mysql-test/spider/feature/r/pushdown_case,usual_handler.rdiff new file mode 100644 index 00000000000..d88ddf7ad2a --- /dev/null +++ b/storage/spider/mysql-test/spider/feature/r/pushdown_case,usual_handler.rdiff @@ -0,0 +1,38 @@ +--- ../src/storage/spider/mysql-test/spider/feature/r/pushdown_case.result 2025-08-01 15:07:36.420896283 +1000 ++++ ../src/storage/spider/mysql-test/spider/feature/r/pushdown_case.reject 2025-10-22 17:40:55.815365439 +1100 +@@ -13,7 +13,7 @@ + insert into t1 values (42), (3), (848), (100); + explain select case c when 3 then "three" when 42 then "answer" else "other" end as exp from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select case c when 3 then "three" when 42 then "answer" else "other" end as exp from t1; + exp + answer +@@ -22,7 +22,7 @@ + other + explain select case c when 3 then "three" when 42 then "answer" end from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select case c when 3 then "three" when 42 then "answer" end from t1; + case c when 3 then "three" when 42 then "answer" end + answer +@@ -31,7 +31,7 @@ + NULL + explain select case when c = 3 then "three" when c = 42 then "answer" else "other" end as exp from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select case when c = 3 then "three" when c = 42 then "answer" else "other" end as exp from t1; + exp + answer +@@ -40,7 +40,7 @@ + other + explain select case when c = 3 then "three" when c = 42 then "answer" end from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select case when c = 3 then "three" when c = 42 then "answer" end from t1; + case when c = 3 then "three" when c = 42 then "answer" end + answer diff --git a/storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff,usual_handler.rdiff b/storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff,usual_handler.rdiff new file mode 100644 index 00000000000..a0a92747a15 --- /dev/null +++ b/storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff,usual_handler.rdiff @@ -0,0 +1,83 @@ +--- ../src/storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff.result 2024-11-15 17:14:27.545903808 +1100 ++++ ../src/storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff.reject 2025-10-22 17:40:58.047381510 +1100 +@@ -26,7 +26,7 @@ + interval year + explain select a, b, timestampdiff(year, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(year, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(year, '2000-01-01 00:00:00', c) + 1 a 18 +@@ -35,7 +35,7 @@ + interval quarter + explain select a, b, timestampdiff(quarter, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(quarter, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(quarter, '2000-01-01 00:00:00', c) + 1 a 75 +@@ -44,7 +44,7 @@ + interval month + explain select a, b, timestampdiff(month, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(month, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(month, '2000-01-01 00:00:00', c) + 1 a 226 +@@ -53,7 +53,7 @@ + interval week + explain select a, b, timestampdiff(week, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(week, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(week, '2000-01-01 00:00:00', c) + 1 a 982 +@@ -62,7 +62,7 @@ + interval day + explain select a, b, timestampdiff(day, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(day, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(day, '2000-01-01 00:00:00', c) + 1 a 6879 +@@ -71,7 +71,7 @@ + internal hour + explain select a, b, timestampdiff(hour, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(hour, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(hour, '2000-01-01 00:00:00', c) + 1 a 165106 +@@ -80,7 +80,7 @@ + internal minute + explain select a, b, timestampdiff(minute, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(minute, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(minute, '2000-01-01 00:00:00', c) + 1 a 9906381 +@@ -89,7 +89,7 @@ + internal second + explain select a, b, timestampdiff(second, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(second, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(second, '2000-01-01 00:00:00', c) + 1 a 594382899 +@@ -98,7 +98,7 @@ + internal microsecond + explain select a, b, timestampdiff(microsecond, '2000-01-01 00:00:00', c) from t1; + id select_type table type possible_keys key key_len ref rows Extra +-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY ++1 SIMPLE t1 ALL NULL NULL NULL NULL 2 + select a, b, timestampdiff(microsecond, '2000-01-01 00:00:00', c) from t1; + a b timestampdiff(microsecond, '2000-01-01 00:00:00', c) + 1 a 594382899000000 diff --git a/storage/spider/mysql-test/spider/r/auto_increment,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/auto_increment,usual_handler.rdiff new file mode 100644 index 00000000000..cd378103942 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/auto_increment,usual_handler.rdiff @@ -0,0 +1,11 @@ +--- ../src/storage/spider/mysql-test/spider/r/auto_increment.result 2024-06-21 13:39:03.368040208 +1000 ++++ ../src/storage/spider/mysql-test/spider/r/auto_increment.reject 2025-10-22 17:41:24.231571237 +1100 +@@ -154,7 +154,7 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`col_a` `col_a`,t0.`col_b` `col_b`,t0.`col_c` `col_c` from `auto_test_remote`.`tbl_a` t0 ++select `col_a`,`col_b`,`col_c` from `auto_test_remote`.`tbl_a` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT col_a, col_b, col_c FROM tbl_a ORDER BY col_a; + col_a col_b col_c diff --git a/storage/spider/mysql-test/spider/r/direct_aggregate,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_aggregate,usual_handler.rdiff new file mode 100644 index 00000000000..f7662986ab8 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_aggregate,usual_handler.rdiff @@ -0,0 +1,48 @@ +--- ../src/storage/spider/mysql-test/spider/r/direct_aggregate.result 2024-06-21 13:50:21.433397029 +1000 ++++ ../src/storage/spider/mysql-test/spider/r/direct_aggregate.reject 2025-10-22 17:42:04.239865208 +1100 +@@ -54,31 +54,31 @@ + 5 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SELECT MAX(a) FROM ta_l; + MAX(a) + 5 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SELECT MIN(a) FROM ta_l; + MIN(a) + 1 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SELECT MAX(a) FROM ta_l WHERE a < 5; + MAX(a) + 4 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SELECT MIN(a) FROM ta_l WHERE a > 1; + MIN(a) + 2 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SET spider_direct_aggregate=0; + SELECT COUNT(*) FROM ta_l; + COUNT(*) +@@ -97,7 +97,7 @@ + 2 + SHOW STATUS LIKE 'Spider_direct_aggregate'; + Variable_name Value +-Spider_direct_aggregate 0 ++Spider_direct_aggregate 1 + SET spider_direct_aggregate=1; + + deinit diff --git a/storage/spider/mysql-test/spider/r/direct_join,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_join,usual_handler.rdiff new file mode 100644 index 00000000000..6d48a46c8a9 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_join,usual_handler.rdiff @@ -0,0 +1,30 @@ +--- ../src/storage/spider/mysql-test/spider/r/direct_join.result 2025-08-01 15:07:36.420896283 +1000 ++++ ../src/storage/spider/mysql-test/spider/r/direct_join.reject 2025-10-22 17:42:14.703942870 +1100 +@@ -76,7 +76,17 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc limit 1,2 ++select `a` from `auto_test_remote`.`ta_r_3` where (`a` is not null) limit 6 ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 1 limit 6 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 1 limit 6 ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 2 limit 6 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 2 limit 6 ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 3 limit 6 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 3 limit 6 ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 4 limit 6 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 4 limit 6 ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 5 limit 6 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 5 limit 6 + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') +@@ -167,7 +177,7 @@ + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument + select `id`,`hr_status`,`region_code`,`region` from `auto_test_remote`.`tbl_person` where `id` = '24FC3F0A5119432BAE13DD65AABAA39C' and `region` = 510411 +-select count(0) `count(0)` from (select 1) t0 join `auto_test_remote`.`tbl_ncd_cm_person` t1 where ((t1.`person_id` = '24FC3F0A5119432BAE13DD65AABAA39C') and (t1.`diseaseKind_id` = '52A0328740914BCE86ED10A4D2521816')) ++select `person_id`,`diseaseKind_id` from `auto_test_remote`.`tbl_ncd_cm_person` where ((`person_id` = '24FC3F0A5119432BAE13DD65AABAA39C') and (`diseaseKind_id` = '52A0328740914BCE86ED10A4D2521816')) + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT * FROM tbl_person; + id hr_status region_code region diff --git a/storage/spider/mysql-test/spider/r/direct_join_using,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_join_using,usual_handler.rdiff new file mode 100644 index 00000000000..e3c098240be --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_join_using,usual_handler.rdiff @@ -0,0 +1,21 @@ +--- ../src/storage/spider/mysql-test/spider/r/direct_join_using.result 2025-08-01 15:07:36.420896283 +1000 ++++ ../src/storage/spider/mysql-test/spider/r/direct_join_using.reject 2025-10-22 17:42:20.207983843 +1100 +@@ -79,7 +79,17 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_3` where (`a` is not null) ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 1 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 2 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 3 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r` where `a` = 4 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 4 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r` where `a` = 5 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 5 + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_left_join,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_left_join,usual_handler.rdiff new file mode 100644 index 00000000000..93dc364387d --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_join,usual_handler.rdiff @@ -0,0 +1,17 @@ +--- ../src/storage/spider/mysql-test/spider/r/direct_left_join.result 2025-08-01 15:07:36.420896283 +1000 ++++ ../src/storage/spider/mysql-test/spider/r/direct_left_join.reject 2025-10-22 17:42:25.256021497 +1100 +@@ -79,7 +79,13 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0 left join `auto_test_remote`.`ta_r_3` t1 on (t1.`a` = t0.`a`) left join `auto_test_remote`.`ta_r_int` t2 on (t2.`a` = t0.`a`) where 1 order by t0.`b` desc ++select `a`,`b` from `auto_test_remote`.`ta_r` ++select `a` from `auto_test_remote`.`ta_r_3` ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 1 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 2 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 3 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 4 ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` where `a` = 5 + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_left_join_nullable,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_left_join_nullable,usual_handler.rdiff new file mode 100644 index 00000000000..650addfdcef --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_join_nullable,usual_handler.rdiff @@ -0,0 +1,20 @@ +--- direct_left_join_nullable.result 2025-09-12 13:20:01.514612982 +0200 ++++ direct_left_join_nullable,usual_handler.reject 2025-10-28 09:46:55.953735752 +0100 +@@ -99,7 +99,16 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t0 left join `auto_test_remote`.`ta_r_auto_inc` t1 on ((t1.`a` = t0.`a`) and (t0.`a` is not null)) left join `auto_test_remote`.`ta_r_3` t2 on (t2.`c` = t1.`c`) left join `auto_test_remote`.`ta_r` t3 on ((t3.`b` = t2.`b`) and (t2.`b` is not null)) where 1 order by t0.`a` desc ++select `a` from `auto_test_remote`.`ta_r_no_idx` ++select `a`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `a` = 1 ++select `a`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `a` = 2 ++select `a`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `a` = 3 ++select `a`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `a` = 4 ++select `a`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `a` = 5 ++select `b`,`c` from `auto_test_remote`.`ta_r_3` ++select `a`,`b` from `auto_test_remote`.`ta_r` where `b` = 'a' ++select `a`,`b` from `auto_test_remote`.`ta_r` where `b` = 'b' ++select `a`,`b` from `auto_test_remote`.`ta_r` where `b` = 'c' + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable,usual_handler.rdiff new file mode 100644 index 00000000000..8d883d535ea --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable,usual_handler.rdiff @@ -0,0 +1,41 @@ +--- ../src/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result 2024-11-14 13:59:27.762081104 +1100 ++++ ../src/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.reject 2025-10-22 17:42:33.452082780 +1100 +@@ -87,7 +87,37 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r` t0 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r_auto_inc` t2) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc ++select `a`,`b` from `auto_test_remote`.`ta_r_no_idx` ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable,usual_handler.result b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable,usual_handler.result new file mode 100644 index 00000000000..fc956af5f19 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable,usual_handler.result @@ -0,0 +1,137 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +drop and create databases +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +DROP DATABASE IF EXISTS auto_test_remote; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +test select 1 +connection master_1; +SELECT 1; +1 +1 +connection child2_1; +SELECT 1; +1 +1 + +create table and insert +connection child2_1; +CHILD2_1_DROP_TABLES +CHILD2_1_DROP_TABLES6 +CHILD2_1_DROP_TABLES4 +CHILD2_1_DROP_TABLES3 +CHILD2_1_CREATE_TABLES +CHILD2_1_CREATE_TABLES6 +CHILD2_1_CREATE_TABLES4 +CHILD2_1_CREATE_TABLES3 +TRUNCATE TABLE mysql.general_log; +connection master_1; +DROP TABLE IF EXISTS tbl_a; +CREATE TABLE tbl_a ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +CREATE TABLE tbl_b ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT5_2_1 +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +CREATE TABLE tbl_c ( +a INT AUTO_INCREMENT, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10', +KEY idx0(a), +KEY idx1(b), +KEY idx2(c) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT3_2_1 +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +CREATE TABLE tbl_d ( +a INT DEFAULT 10, +b CHAR(1) DEFAULT 'c', +c DATETIME DEFAULT '1999-10-10 10:10:10' +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT2_2_1 +Warnings: +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +Warning 138 Spider table params in COMMENT or CONNECTION strings have been deprecated and will be removed in a future release. Please use table options instead. +insert into tbl_a values (1,'a','2000/01/01'),(2,'b','2000/01/02'); +insert into tbl_b values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'); +insert into tbl_c values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'); +insert into tbl_d values (1,'a','2000/01/01'),(2,'b','2000/01/02'),(3,'c','2000/01/03'),(4,'d','2000/01/04'),(5,'e','2000/01/05'); + +select test +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT a.a, c.b, c.c, d.a FROM tbl_a a left join tbl_b b on a.a = b.a left join tbl_c c on b.c = c.c right join tbl_d d on c.b = d.b ORDER BY d.a DESC; +a b c a +NULL NULL NULL 5 +NULL NULL NULL 4 +NULL NULL NULL 3 +2 b 2000-01-02 00:00:00 2 +1 a 2000-01-01 00:00:00 1 +connection child2_1; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; +argument +select `a`,`b` from `auto_test_remote`.`ta_r_no_idx` +select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'a' +select `a`,`c` from `auto_test_remote`.`ta_r_3` +select `a` from `auto_test_remote`.`ta_r` where `a` = 1 +select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'b' +select `a`,`c` from `auto_test_remote`.`ta_r_3` +select `a` from `auto_test_remote`.`ta_r` where `a` = 2 +select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'c' +select `a`,`c` from `auto_test_remote`.`ta_r_3` +select `a` from `auto_test_remote`.`ta_r` where `a` = 3 +select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'd' +select `a`,`c` from `auto_test_remote`.`ta_r_3` +select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'e' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' +SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; +a b date_format(c, '%Y-%m-%d %H:%i:%s') +1 a 2000-01-01 00:00:00 +2 b 2000-01-02 00:00:00 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 +child3_1 +child3_2 +child3_3 + +end of test diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable,usual_handler.rdiff new file mode 100644 index 00000000000..e7c3dee5203 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable,usual_handler.rdiff @@ -0,0 +1,19 @@ +--- ../src/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result 2024-11-14 13:59:27.762081104 +1100 ++++ ../src/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.reject 2025-10-22 17:42:33.560083588 +1100 +@@ -86,7 +86,15 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_auto_inc` t2 left join (`auto_test_remote`.`ta_r` t0 join `auto_test_remote`.`ta_r_3` t1) on ((t1.`c` = t2.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null)) left join `auto_test_remote`.`ta_r_no_idx` t3 on (t3.`b` = t2.`b`) where 1 order by t3.`a` desc ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a`,`b` from `auto_test_remote`.`ta_r_no_idx` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_right_join,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_right_join,usual_handler.rdiff new file mode 100644 index 00000000000..97e9bc28bb9 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_right_join,usual_handler.rdiff @@ -0,0 +1,21 @@ +--- ../src/storage/spider/mysql-test/spider/r/direct_right_join.result 2025-08-01 15:07:36.420896283 +1000 ++++ ../src/storage/spider/mysql-test/spider/r/direct_right_join.reject 2025-10-22 17:42:42.744152477 +1100 +@@ -79,7 +79,17 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r_int` t2 left join (`auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t0.`a` = t2.`a`) and (t1.`a` = t2.`a`)) where 1 order by t0.`b` desc ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r_int` ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `a` from `auto_test_remote`.`ta_r_3` ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `a` from `auto_test_remote`.`ta_r_3` ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `a` from `auto_test_remote`.`ta_r_3` ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 4 ++select `a` from `auto_test_remote`.`ta_r_3` ++select `a`,`b` from `auto_test_remote`.`ta_r` where `a` = 5 ++select `a` from `auto_test_remote`.`ta_r_3` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_right_join_nullable,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_right_join_nullable,usual_handler.rdiff new file mode 100644 index 00000000000..ebdbe81e282 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_right_join_nullable,usual_handler.rdiff @@ -0,0 +1,23 @@ +--- direct_right_join_nullable.result 2025-09-12 13:20:01.604613350 +0200 ++++ direct_right_join_nullable,usual_handler.reject 2025-10-30 17:04:09.531951313 +0100 +@@ -99,7 +99,19 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 left join (`auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on (t1.`c` = t2.`c`)) on ((t2.`b` = t3.`b`) and (t3.`b` is not null)) where 1 order by t3.`a` desc ++select `a`,`b` from `auto_test_remote`.`ta_r_no_idx` ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'a' ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'b' ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'c' ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'd' ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'e' + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable,usual_handler.rdiff new file mode 100644 index 00000000000..3797ee142f6 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable,usual_handler.rdiff @@ -0,0 +1,19 @@ +--- ../src/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result 2024-11-14 13:59:27.762081104 +1100 ++++ ../src/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.reject 2025-10-22 17:41:31.051621007 +1100 +@@ -86,7 +86,15 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_auto_inc` t2 left join (`auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r_no_idx` t3 on (t3.`b` = t2.`b`) where 1 order by t3.`a` desc ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a`,`b` from `auto_test_remote`.`ta_r_no_idx` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable,usual_handler.rdiff new file mode 100644 index 00000000000..b492cc9a283 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable,usual_handler.rdiff @@ -0,0 +1,23 @@ +--- direct_right_left_right_join_nullable.result 2025-09-12 13:20:01.653613550 +0200 ++++ direct_right_left_right_join_nullable,usual_handler.reject 2025-10-28 10:25:24.062341489 +0100 +@@ -99,7 +99,19 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) join `auto_test_remote`.`ta_r_auto_inc` t2) on ((t2.`b` = t3.`b`) and (t1.`c` = t2.`c`) and (t3.`b` is not null)) where 1 order by t3.`a` desc ++select `a`,`b` from `auto_test_remote`.`ta_r_no_idx` ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'a' ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 1 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'b' ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 2 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'c' ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `a` from `auto_test_remote`.`ta_r` where `a` = 3 ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'd' ++select `a`,`c` from `auto_test_remote`.`ta_r_3` ++select `b`,`c` from `auto_test_remote`.`ta_r_auto_inc` where `b` = 'e' + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; + a b date_format(c, '%Y-%m-%d %H:%i:%s') diff --git a/storage/spider/mysql-test/spider/r/pushdown_not_like,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/pushdown_not_like,usual_handler.rdiff new file mode 100644 index 00000000000..c1bdac735cd --- /dev/null +++ b/storage/spider/mysql-test/spider/r/pushdown_not_like,usual_handler.rdiff @@ -0,0 +1,11 @@ +--- ../src/storage/spider/mysql-test/spider/r/pushdown_not_like.result 2024-05-01 14:39:20.122241957 +1000 ++++ ../src/storage/spider/mysql-test/spider/r/pushdown_not_like.reject 2025-10-22 17:41:34.179643884 +1100 +@@ -41,7 +41,7 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select%'; + argument +-select t0.`a` `a`,t0.`b` `b`,t0.`c` `c` from `auto_test_remote`.`ta_r` t0 where (t0.`b` not like 'a%') ++select `a`,`b`,`c` from `auto_test_remote`.`ta_r` where (`b` not like 'a%') + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select%' + + deinit diff --git a/storage/spider/mysql-test/spider/r/timestamp,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/timestamp,usual_handler.rdiff new file mode 100644 index 00000000000..427db2383ef --- /dev/null +++ b/storage/spider/mysql-test/spider/r/timestamp,usual_handler.rdiff @@ -0,0 +1,97 @@ +--- a/storage/spider/mysql-test/spider/r/timestamp.result ++++ b/storage/spider/mysql-test/spider/r/timestamp.result +@@ -118,7 +118,7 @@ col_a col_dt col_ts unix_timestamp(col_ts) + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; + col_a col_dt col_ts unix_timestamp(col_ts) +@@ -144,7 +144,7 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; + col_a col_dt col_ts unix_timestamp(col_ts) +@@ -170,7 +170,7 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; + col_a col_dt col_ts unix_timestamp(col_ts) +@@ -198,7 +198,7 @@ + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument + select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` for update +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; + col_a col_dt col_ts unix_timestamp(col_ts) +@@ -256,13 +256,13 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2017-12-31 23:00:00') +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` < _latin1'2018-10-28 01:30:00') +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (_latin1'2018-10-28 01:30:00' > t0.`col_ts`) +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` between _latin1'2018-10-28 00:30:00' and _latin1'2018-10-28 01:30:00') +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= _latin1'2018-10-28 00:30:00') and (t0.`col_ts` <= _latin1'2018-10-28 01:30:00')) +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2018-03-25 01:00:00') +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01') ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > _latin1'2017-12-31 23:00:00') order by `col_ts` ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` < _latin1'2018-10-28 01:30:00') order by `col_ts` ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (_latin1'2018-10-28 01:30:00' > `col_ts`) order by `col_ts` ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where `col_ts` >= _latin1'2018-10-28 00:30:00' and `col_ts` <= _latin1'2018-10-28 01:30:00' and (`col_ts` between _latin1'2018-10-28 00:30:00' and _latin1'2018-10-28 01:30:00') order by `col_ts` ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where `col_ts` >= _latin1'2018-10-28 00:30:00' and `col_ts` <= _latin1'2018-10-28 01:30:00' and ((`col_ts` >= _latin1'2018-10-28 00:30:00') and (`col_ts` <= _latin1'2018-10-28 01:30:00')) order by `col_ts` ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > _latin1'2018-03-25 01:00:00') order by `col_ts` ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > '1970-01-01 00:00:01') order by `col_ts` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; + col_a col_dt col_ts unix_timestamp(col_ts) +@@ -343,13 +343,13 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2017-12-31 23:00:00') +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` < _latin1'2018-10-28 01:30:00') +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (_latin1'2018-10-28 01:30:00' > t0.`col_ts`) +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` between _latin1'2018-10-28 00:30:00' and _latin1'2018-10-28 01:30:00') +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= _latin1'2018-10-28 00:30:00') and (t0.`col_ts` <= _latin1'2018-10-28 01:30:00')) +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2018-03-25 01:00:00') +-select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01') ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > _latin1'2017-12-31 23:00:00') ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` < _latin1'2018-10-28 01:30:00') ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (_latin1'2018-10-28 01:30:00' > `col_ts`) ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` between _latin1'2018-10-28 00:30:00' and _latin1'2018-10-28 01:30:00') ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where ((`col_ts` >= _latin1'2018-10-28 00:30:00') and (`col_ts` <= _latin1'2018-10-28 01:30:00')) ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > _latin1'2018-03-25 01:00:00') ++select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > '1970-01-01 00:00:01') + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; + col_a col_dt col_ts unix_timestamp(col_ts) +@@ -396,11 +396,11 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + argument +-select t0.`col_d` `col_d`,t0.`col_t` `col_t` from `ts_test_remote`.`tbl_f` t0 +-select (timestamp(t0.`col_d` , t0.`col_t`)) `TIMESTAMP(col_d, col_t)` from `ts_test_remote`.`tbl_f` t0 +-select (timestamp(_latin1'2018-06-25' , t0.`col_t`)) `TIMESTAMP('2018-06-25', col_t)` from `ts_test_remote`.`tbl_f` t0 +-select (timestamp(t0.`col_d` , _latin1'10:43:21')) `TIMESTAMP(col_d, '10:43:21')` from `ts_test_remote`.`tbl_f` t0 +-select (timestamp(_latin1'2018-06-25' , _latin1'10:43:21')) `TIMESTAMP('2018-06-25', '10:43:21')` from `ts_test_remote`.`tbl_f` t0 ++select `col_d`,`col_t` from `ts_test_remote`.`tbl_f` ++select `col_d`,`col_t` from `ts_test_remote`.`tbl_f` ++select `col_t` from `ts_test_remote`.`tbl_f` ++select `col_d` from `ts_test_remote`.`tbl_f` ++select 1 from `ts_test_remote`.`tbl_f` + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' + SELECT col_d, col_t FROM tbl_f; + col_d col_t diff --git a/storage/spider/mysql-test/spider/r/udf_pushdown,usual_handler.rdiff b/storage/spider/mysql-test/spider/r/udf_pushdown,usual_handler.rdiff new file mode 100644 index 00000000000..820599b8280 --- /dev/null +++ b/storage/spider/mysql-test/spider/r/udf_pushdown,usual_handler.rdiff @@ -0,0 +1,13 @@ +--- ../src/storage/spider/mysql-test/spider/r/udf_pushdown.result 2022-12-05 17:51:57.843152110 +1100 ++++ ../src/storage/spider/mysql-test/spider/r/udf_pushdown.reject 2025-10-22 17:41:38.167673091 +1100 +@@ -148,8 +148,8 @@ + connection child2_1; + SELECT argument FROM mysql.general_log WHERE argument LIKE "%select%" AND argument NOT LIKE "%argument%"; + argument +-select t0.`id` `id`,t0.`a` `a` from `auto_test_remote`.`ta_r` t0 where (t0.`id` = (`plusone`(1))) +-select t0.`id` `id`,t0.`a` `a` from `auto_test_remote`.`ta_r` t0 where ((t0.`id` in( (`plusone`(1)) , (`plusone`(2)))) and (t0.`a` = (`plusone`(32)))) ++select `id`,`a` from `auto_test_remote`.`ta_r` where (`id` = (`plusone`(1))) ++select `id`,`a` from `auto_test_remote`.`ta_r` where ((`id` in( (`plusone`(1)) , (`plusone`(2)))) and (`a` = (`plusone`(32)))) + + ##### test UPDATEs ##### + connection master_1; diff --git a/storage/spider/mysql-test/spider/regression/e1121/combinations b/storage/spider/mysql-test/spider/regression/e1121/combinations new file mode 100644 index 00000000000..cad4d107176 --- /dev/null +++ b/storage/spider/mysql-test/spider/regression/e1121/combinations @@ -0,0 +1,5 @@ +[group_by_handler] +loose_spider_disable_group_by_handler=0 + +[usual_handler] +loose_spider_disable_group_by_handler=1 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key,usual_handler.rdiff b/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key,usual_handler.rdiff new file mode 100644 index 00000000000..378474bd8d4 --- /dev/null +++ b/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key,usual_handler.rdiff @@ -0,0 +1,11 @@ +--- ../src/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key.result 2024-11-14 13:59:27.762081104 +1100 ++++ ../src/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key.reject 2025-10-22 17:41:34.943649475 +1100 +@@ -46,7 +46,7 @@ + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' ; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%'; + argument +-select t0.`val` `val`,t0.`akey` `akey` from `auto_test_remote`.`tbl_a` t0 join (select 1) t1 where (t0.`akey` = '4') ++select `akey`,`val` from `auto_test_remote`.`tbl_a` where `akey` = 4 + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' ; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%' + argument diff --git a/storage/spider/mysql-test/spider/regression/e112122/combinations b/storage/spider/mysql-test/spider/regression/e112122/combinations new file mode 100644 index 00000000000..cad4d107176 --- /dev/null +++ b/storage/spider/mysql-test/spider/regression/e112122/combinations @@ -0,0 +1,5 @@ +[group_by_handler] +loose_spider_disable_group_by_handler=0 + +[usual_handler] +loose_spider_disable_group_by_handler=1 diff --git a/storage/spider/mysql-test/spider/t/direct_join_using.test b/storage/spider/mysql-test/spider/t/direct_join_using.test index fcc273e5d1e..0a35d719570 100644 --- a/storage/spider/mysql-test/spider/t/direct_join_using.test +++ b/storage/spider/mysql-test/spider/t/direct_join_using.test @@ -126,7 +126,7 @@ insert into tbl_c values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500); TRUNCATE TABLE mysql.general_log; --connection master_1 ---disable_ps2_protocol +--disable_ps_protocol --disable_view_protocol SELECT a.a, c.b, c.c FROM tbl_a a join tbl_b b using(a) join tbl_c c using(a) ORDER BY a.b DESC; --enable_view_protocol @@ -135,7 +135,7 @@ SELECT a.a, c.b, c.c FROM tbl_a a join tbl_b b using(a) join tbl_c c using(a) OR SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --enable_view_protocol SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; ---enable_ps2_protocol +--enable_ps_protocol --echo --echo deinit diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index ed5697b2151..0cc60dfebf1 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -394,8 +394,8 @@ static inline void spider_memcpy_or_null(char **dest, char *alloced, SPIDER_CONN *spider_create_conn( SPIDER_SHARE *share, ha_spider *spider, + int all_link_idx, int link_idx, - int base_link_idx, int *error_num ) { int *need_mon; @@ -415,10 +415,10 @@ SPIDER_CONN *spider_create_conn( } bool tables_on_different_db_are_joinable; - if (share->sql_dbton_ids[link_idx] != SPIDER_DBTON_SIZE) + if (share->sql_dbton_ids[all_link_idx] != SPIDER_DBTON_SIZE) { tables_on_different_db_are_joinable = - spider_dbton[share->sql_dbton_ids[link_idx]].db_util-> + spider_dbton[share->sql_dbton_ids[all_link_idx]].db_util-> tables_on_different_db_are_joinable(); } else { tables_on_different_db_are_joinable = TRUE; @@ -426,38 +426,38 @@ SPIDER_CONN *spider_create_conn( if (!(conn = (SPIDER_CONN *) spider_bulk_malloc(spider_current_trx, SPD_MID_CREATE_CONN_1, MYF(MY_WME | MY_ZEROFILL), &conn, (uint) (sizeof(*conn)), - &tmp_name, (uint) (share->conn_keys_lengths[link_idx] + 1), - &tmp_host, (uint) (share->tgt_hosts_lengths[link_idx] + 1), + &tmp_name, (uint) (share->conn_keys_lengths[all_link_idx] + 1), + &tmp_host, (uint) (share->tgt_hosts_lengths[all_link_idx] + 1), &tmp_username, - (uint) (share->tgt_usernames_lengths[link_idx] + 1), + (uint) (share->tgt_usernames_lengths[all_link_idx] + 1), &tmp_password, - (uint) (share->tgt_passwords_lengths[link_idx] + 1), - &tmp_socket, (uint) (share->tgt_sockets_lengths[link_idx] + 1), + (uint) (share->tgt_passwords_lengths[all_link_idx] + 1), + &tmp_socket, (uint) (share->tgt_sockets_lengths[all_link_idx] + 1), &tmp_wrapper, - (uint) (share->tgt_wrappers_lengths[link_idx] + 1), + (uint) (share->tgt_wrappers_lengths[all_link_idx] + 1), &tmp_db, (uint) (tables_on_different_db_are_joinable ? - 0 : share->tgt_dbs_lengths[link_idx] + 1), - &tmp_ssl_ca, (uint) (share->tgt_ssl_cas_lengths[link_idx] + 1), + 0 : share->tgt_dbs_lengths[all_link_idx] + 1), + &tmp_ssl_ca, (uint) (share->tgt_ssl_cas_lengths[all_link_idx] + 1), &tmp_ssl_capath, - (uint) (share->tgt_ssl_capaths_lengths[link_idx] + 1), + (uint) (share->tgt_ssl_capaths_lengths[all_link_idx] + 1), &tmp_ssl_cert, - (uint) (share->tgt_ssl_certs_lengths[link_idx] + 1), + (uint) (share->tgt_ssl_certs_lengths[all_link_idx] + 1), &tmp_ssl_cipher, - (uint) (share->tgt_ssl_ciphers_lengths[link_idx] + 1), + (uint) (share->tgt_ssl_ciphers_lengths[all_link_idx] + 1), &tmp_ssl_key, - (uint) (share->tgt_ssl_keys_lengths[link_idx] + 1), + (uint) (share->tgt_ssl_keys_lengths[all_link_idx] + 1), &tmp_default_file, - (uint) (share->tgt_default_files_lengths[link_idx] + 1), + (uint) (share->tgt_default_files_lengths[all_link_idx] + 1), &tmp_default_group, - (uint) (share->tgt_default_groups_lengths[link_idx] + 1), + (uint) (share->tgt_default_groups_lengths[all_link_idx] + 1), &tmp_dsn, - (uint) (share->tgt_dsns_lengths[link_idx] + 1), + (uint) (share->tgt_dsns_lengths[all_link_idx] + 1), &tmp_filedsn, - (uint) (share->tgt_filedsns_lengths[link_idx] + 1), + (uint) (share->tgt_filedsns_lengths[all_link_idx] + 1), &tmp_driver, - (uint) (share->tgt_drivers_lengths[link_idx] + 1), + (uint) (share->tgt_drivers_lengths[all_link_idx] + 1), &tmp_odbc_conn_str, - (uint) (share->tgt_odbc_conn_strs_lengths[link_idx] + 1), + (uint) (share->tgt_odbc_conn_strs_lengths[all_link_idx] + 1), &need_mon, (uint) (sizeof(int)), NullS)) ) { @@ -466,80 +466,80 @@ SPIDER_CONN *spider_create_conn( } conn->default_database.init_calc_mem(SPD_MID_CREATE_CONN_2); - conn->conn_key_length = share->conn_keys_lengths[link_idx]; + conn->conn_key_length = share->conn_keys_lengths[all_link_idx]; conn->conn_key = tmp_name; - memcpy(conn->conn_key, share->conn_keys[link_idx], - share->conn_keys_lengths[link_idx]); - conn->conn_key_hash_value = share->conn_keys_hash_value[link_idx]; + memcpy(conn->conn_key, share->conn_keys[all_link_idx], + share->conn_keys_lengths[all_link_idx]); + conn->conn_key_hash_value = share->conn_keys_hash_value[all_link_idx]; spider_memcpy_or_null(&conn->tgt_host, tmp_host, - share->tgt_hosts[link_idx], &conn->tgt_host_length, - share->tgt_hosts_lengths[link_idx]); + share->tgt_hosts[all_link_idx], &conn->tgt_host_length, + share->tgt_hosts_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_username, tmp_username, - share->tgt_usernames[link_idx], + share->tgt_usernames[all_link_idx], &conn->tgt_username_length, - share->tgt_usernames_lengths[link_idx]); + share->tgt_usernames_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_password, tmp_password, - share->tgt_passwords[link_idx], + share->tgt_passwords[all_link_idx], &conn->tgt_password_length, - share->tgt_passwords_lengths[link_idx]); + share->tgt_passwords_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_socket, tmp_socket, - share->tgt_sockets[link_idx], + share->tgt_sockets[all_link_idx], &conn->tgt_socket_length, - share->tgt_sockets_lengths[link_idx]); + share->tgt_sockets_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_wrapper, tmp_wrapper, - share->tgt_wrappers[link_idx], + share->tgt_wrappers[all_link_idx], &conn->tgt_wrapper_length, - share->tgt_wrappers_lengths[link_idx]); + share->tgt_wrappers_lengths[all_link_idx]); if (!tables_on_different_db_are_joinable) { - spider_memcpy_or_null(&conn->tgt_db, tmp_db, share->tgt_dbs[link_idx], + spider_memcpy_or_null(&conn->tgt_db, tmp_db, share->tgt_dbs[all_link_idx], &conn->tgt_db_length, - share->tgt_dbs_lengths[link_idx]); + share->tgt_dbs_lengths[all_link_idx]); } spider_memcpy_or_null(&conn->tgt_ssl_ca, tmp_ssl_ca, - share->tgt_ssl_cas[link_idx], + share->tgt_ssl_cas[all_link_idx], &conn->tgt_ssl_ca_length, - share->tgt_ssl_cas_lengths[link_idx]); + share->tgt_ssl_cas_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_ssl_capath, tmp_ssl_capath, - share->tgt_ssl_capaths[link_idx], + share->tgt_ssl_capaths[all_link_idx], &conn->tgt_ssl_capath_length, - share->tgt_ssl_capaths_lengths[link_idx]); + share->tgt_ssl_capaths_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_ssl_cert, tmp_ssl_cert, - share->tgt_ssl_certs[link_idx], + share->tgt_ssl_certs[all_link_idx], &conn->tgt_ssl_cert_length, - share->tgt_ssl_certs_lengths[link_idx]); + share->tgt_ssl_certs_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_ssl_cipher, tmp_ssl_cipher, - share->tgt_ssl_ciphers[link_idx], + share->tgt_ssl_ciphers[all_link_idx], &conn->tgt_ssl_cipher_length, - share->tgt_ssl_ciphers_lengths[link_idx]); + share->tgt_ssl_ciphers_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_ssl_key, tmp_ssl_key, - share->tgt_ssl_keys[link_idx], + share->tgt_ssl_keys[all_link_idx], &conn->tgt_ssl_key_length, - share->tgt_ssl_keys_lengths[link_idx]); + share->tgt_ssl_keys_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_default_file, tmp_default_file, - share->tgt_default_files[link_idx], + share->tgt_default_files[all_link_idx], &conn->tgt_default_file_length, - share->tgt_default_files_lengths[link_idx]); + share->tgt_default_files_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_default_group, tmp_default_group, - share->tgt_default_groups[link_idx], + share->tgt_default_groups[all_link_idx], &conn->tgt_default_group_length, - share->tgt_default_groups_lengths[link_idx]); - spider_memcpy_or_null(&conn->tgt_dsn, tmp_dsn, share->tgt_dsns[link_idx], + share->tgt_default_groups_lengths[all_link_idx]); + spider_memcpy_or_null(&conn->tgt_dsn, tmp_dsn, share->tgt_dsns[all_link_idx], &conn->tgt_dsn_length, - share->tgt_dsns_lengths[link_idx]); - spider_memcpy_or_null(&conn->tgt_filedsn, tmp_filedsn, share->tgt_filedsns[link_idx], + share->tgt_dsns_lengths[all_link_idx]); + spider_memcpy_or_null(&conn->tgt_filedsn, tmp_filedsn, share->tgt_filedsns[all_link_idx], &conn->tgt_filedsn_length, - share->tgt_filedsns_lengths[link_idx]); - spider_memcpy_or_null(&conn->tgt_driver, tmp_driver, share->tgt_drivers[link_idx], + share->tgt_filedsns_lengths[all_link_idx]); + spider_memcpy_or_null(&conn->tgt_driver, tmp_driver, share->tgt_drivers[all_link_idx], &conn->tgt_driver_length, - share->tgt_drivers_lengths[link_idx]); + share->tgt_drivers_lengths[all_link_idx]); spider_memcpy_or_null(&conn->tgt_odbc_conn_str, tmp_odbc_conn_str, - share->tgt_odbc_conn_strs[link_idx], + share->tgt_odbc_conn_strs[all_link_idx], &conn->tgt_odbc_conn_str_length, - share->tgt_odbc_conn_strs_lengths[link_idx]); - conn->tgt_port = share->tgt_ports[link_idx]; - conn->tgt_ssl_vsc = share->tgt_ssl_vscs[link_idx]; - conn->dbton_id = share->sql_dbton_ids[link_idx]; + share->tgt_odbc_conn_strs_lengths[all_link_idx]); + conn->tgt_port = share->tgt_ports[all_link_idx]; + conn->tgt_ssl_vsc = share->tgt_ssl_vscs[all_link_idx]; + conn->dbton_id = share->sql_dbton_ids[all_link_idx]; if (conn->dbton_id == SPIDER_DBTON_SIZE) { my_printf_error( @@ -564,10 +564,10 @@ SPIDER_CONN *spider_create_conn( conn->semi_trx_isolation = -2; conn->semi_trx_isolation_chk = FALSE; conn->semi_trx_chk = FALSE; - conn->link_idx = base_link_idx; + conn->link_idx = link_idx; conn->conn_need_mon = need_mon; if (spider) - conn->need_mon = &spider->need_mons[base_link_idx]; + conn->need_mon = &spider->need_mons[link_idx]; else conn->need_mon = need_mon; @@ -583,7 +583,7 @@ SPIDER_CONN *spider_create_conn( goto error_conn_init; } - spider_conn_queue_connect(share, conn, link_idx); + spider_conn_queue_connect(share, conn, all_link_idx); conn->ping_time = (time_t) time((time_t*) 0); conn->connect_error_time = conn->ping_time; pthread_mutex_lock(&spider_conn_id_mutex); @@ -654,13 +654,11 @@ SPIDER_CONN *spider_get_conn( int *error_num ) { SPIDER_CONN *conn = NULL; - int base_link_idx = link_idx; + int all_link_idx= link_idx; DBUG_ENTER("spider_get_conn"); if (spider) - link_idx = spider->conn_link_idx[base_link_idx]; - DBUG_PRINT("info",("spider link_idx=%u", link_idx)); - DBUG_PRINT("info",("spider base_link_idx=%u", base_link_idx)); + all_link_idx = spider->conn_link_idx[link_idx]; #ifdef DBUG_TRACE spider_print_keys(conn_key, share->conn_keys_lengths[link_idx]); @@ -669,13 +667,13 @@ SPIDER_CONN *spider_get_conn( (another && !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &trx->trx_another_conn_hash, - share->conn_keys_hash_value[link_idx], - (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) || + share->conn_keys_hash_value[all_link_idx], + (uchar*) conn_key, share->conn_keys_lengths[all_link_idx]))) || (!another && !(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( &trx->trx_conn_hash, - share->conn_keys_hash_value[link_idx], - (uchar*) conn_key, share->conn_keys_lengths[link_idx]))) + share->conn_keys_hash_value[all_link_idx], + (uchar*) conn_key, share->conn_keys_lengths[all_link_idx]))) ) { if ( @@ -687,15 +685,15 @@ SPIDER_CONN *spider_get_conn( ) { pthread_mutex_lock(&spider_conn_mutex); if (!(conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &spider_open_connections, share->conn_keys_hash_value[link_idx], - (uchar*) share->conn_keys[link_idx], - share->conn_keys_lengths[link_idx]))) + &spider_open_connections, share->conn_keys_hash_value[all_link_idx], + (uchar*) share->conn_keys[all_link_idx], + share->conn_keys_lengths[all_link_idx]))) { pthread_mutex_unlock(&spider_conn_mutex); if (spider_param_max_connections()) { /* enable connection pool */ conn= spider_get_conn_from_idle_connection( - share, link_idx, conn_key, spider, base_link_idx, error_num); + share, all_link_idx, conn_key, spider, link_idx, error_num); /* failed get conn, goto error */ if (!conn) goto error; @@ -704,14 +702,14 @@ SPIDER_CONN *spider_get_conn( else { /* did not enable conncetion pool , create_conn */ DBUG_PRINT("info",("spider create new conn")); - if (!(conn= spider_create_conn(share, spider, link_idx, - base_link_idx, error_num))) + if (!(conn= spider_create_conn(share, spider, all_link_idx, + link_idx, error_num))) goto error; *conn->conn_key = *conn_key; if (spider) { - spider->conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + spider->conns[link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, link_idx)) conn->use_for_active_standby = TRUE; } } @@ -721,22 +719,22 @@ SPIDER_CONN *spider_get_conn( DBUG_PRINT("info",("spider get global conn")); if (spider) { - spider->conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + spider->conns[link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, link_idx)) conn->use_for_active_standby = TRUE; } } } else { DBUG_PRINT("info",("spider create new conn")); /* conn_recycle_strict = 0 and conn_recycle_mode = 0 or 2 */ - if (!(conn= spider_create_conn(share, spider, link_idx, base_link_idx, + if (!(conn= spider_create_conn(share, spider, all_link_idx, link_idx, error_num))) goto error; *conn->conn_key = *conn_key; if (spider) { - spider->conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + spider->conns[link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, link_idx)) conn->use_for_active_standby = TRUE; } } @@ -777,26 +775,26 @@ SPIDER_CONN *spider_get_conn( } } else if (spider) { - spider->conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + spider->conns[link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, link_idx)) conn->use_for_active_standby = TRUE; } - conn->link_idx = base_link_idx; + conn->link_idx = link_idx; if (conn->queued_connect) - spider_conn_queue_connect_rewrite(share, conn, link_idx); + spider_conn_queue_connect_rewrite(share, conn, all_link_idx); if (conn->queued_ping) { if (spider) - spider_conn_queue_ping_rewrite(spider, conn, base_link_idx); + spider_conn_queue_ping_rewrite(spider, conn, link_idx); else conn->queued_ping = FALSE; } if (unlikely(spider && spider->wide_handler->top_share && (*error_num = spider_conn_queue_loop_check( - conn, spider, base_link_idx)))) + conn, spider, link_idx)))) { goto error; } @@ -1218,7 +1216,7 @@ int spider_conn_queue_loop_check( int link_idx ) { int error_num = HA_ERR_OUT_OF_MEM; - uint conn_link_idx = spider->conn_link_idx[link_idx], buf_sz; + uint all_link_idx = spider->conn_link_idx[link_idx], buf_sz; char path[FN_REFLEN + 1]; char *tmp_name, *cur_name, *to_name, *full_name, *from_value, *merged_value; @@ -1322,8 +1320,8 @@ int spider_conn_queue_loop_check( is the remote data node table */ to_str.length = build_table_filename(path, FN_REFLEN, - share->tgt_dbs[conn_link_idx] ? share->tgt_dbs[conn_link_idx] : "", - share->tgt_table_names[conn_link_idx], "", 0); + share->tgt_dbs[all_link_idx] ? share->tgt_dbs[all_link_idx] : "", + share->tgt_table_names[all_link_idx], "", 0); to_str.str = path; DBUG_PRINT("info", ("spider to=%s", to_str.str)); buf_sz = from_str.length + top_share->path.length + to_str.length + 3; @@ -3792,10 +3790,10 @@ bool spider_conn_check_recovery_link( SPIDER_CONN* spider_get_conn_from_idle_connection( SPIDER_SHARE *share, - int link_idx, + int all_link_idx, char *conn_key, ha_spider *spider, - int base_link_idx, + int link_idx, int *error_num ) { @@ -3814,8 +3812,8 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( pthread_mutex_lock(&spider_ipport_conn_mutex); if ((ip_port_conn = (SPIDER_IP_PORT_CONN*) my_hash_search_using_hash_value( - &spider_ipport_conns, share->conn_keys_hash_value[link_idx], - (uchar*) share->conn_keys[link_idx], share->conn_keys_lengths[link_idx]))) + &spider_ipport_conns, share->conn_keys_hash_value[all_link_idx], + (uchar*) share->conn_keys[all_link_idx], share->conn_keys_lengths[all_link_idx]))) { /* exists */ pthread_mutex_unlock(&spider_ipport_conn_mutex); pthread_mutex_lock(&ip_port_conn->mutex); @@ -3855,9 +3853,9 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( pthread_mutex_lock(&spider_conn_mutex); if ((conn = (SPIDER_CONN*) my_hash_search_using_hash_value( - &spider_open_connections, share->conn_keys_hash_value[link_idx], - (uchar*) share->conn_keys[link_idx], - share->conn_keys_lengths[link_idx]))) + &spider_open_connections, share->conn_keys_hash_value[all_link_idx], + (uchar*) share->conn_keys[all_link_idx], + share->conn_keys_lengths[all_link_idx]))) { /* get conn from spider_open_connections, then delete conn in spider_open_connections */ my_hash_delete(&spider_open_connections, (uchar*) conn); @@ -3865,8 +3863,8 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( DBUG_PRINT("info",("spider get global conn")); if (spider) { - spider->conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + spider->conns[link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, link_idx)) conn->use_for_active_standby = TRUE; } DBUG_RETURN(conn); @@ -3882,14 +3880,14 @@ SPIDER_CONN* spider_get_conn_from_idle_connection( if (ip_port_conn) pthread_mutex_unlock(&ip_port_conn->mutex); DBUG_PRINT("info",("spider create new conn")); - if (!(conn= spider_create_conn(share, spider, link_idx, base_link_idx, + if (!(conn= spider_create_conn(share, spider, all_link_idx, link_idx, error_num))) DBUG_RETURN(conn); *conn->conn_key = *conn_key; if (spider) { - spider->conns[base_link_idx] = conn; - if (spider_bit_is_set(spider->conn_can_fo, base_link_idx)) + spider->conns[link_idx] = conn; + if (spider_bit_is_set(spider->conn_can_fo, link_idx)) conn->use_for_active_standby = TRUE; } } diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h index f8859365a66..b50c3069993 100644 --- a/storage/spider/spd_conn.h +++ b/storage/spider/spd_conn.h @@ -432,10 +432,10 @@ SPIDER_IP_PORT_CONN *spider_create_ipport_conn(SPIDER_CONN *conn); SPIDER_CONN* spider_get_conn_from_idle_connection ( SPIDER_SHARE *share, - int link_idx, + int all_link_idx, char *conn_key, ha_spider *spider, - int base_link_idx, + int link_idx, int *error_num ); void spider_free_ipport_conn(void *info); diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index f55458ab1e1..667f97e0dd0 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -3104,7 +3104,7 @@ int spider_db_store_result( result_list->quick_phase == 2 ) { if (result_list->low_mem_read && - result_list->current->result->limit_mode() == 0) + conn->db_conn->limit_mode() == 0) { do { spider_db_free_one_result(result_list, diff --git a/storage/spider/spd_db_include.cc b/storage/spider/spd_db_include.cc index 0531f8a8ed9..8f3f6721ba6 100644 --- a/storage/spider/spd_db_include.cc +++ b/storage/spider/spd_db_include.cc @@ -47,13 +47,6 @@ int spider_db_result::fetch_table_checksum( DBUG_RETURN(0); } -uint spider_db_result::limit_mode() -{ - DBUG_ENTER("spider_db_result::limit_mode"); - DBUG_PRINT("info",("spider this=%p", this)); - DBUG_RETURN(spider_dbton[dbton_id].db_util->limit_mode()); -} - spider_db_conn::spider_db_conn( SPIDER_CONN *in_conn ) : conn(in_conn), dbton_id(in_conn->dbton_id) diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index ef49b2d0ef8..a3eda68ed34 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -503,6 +503,7 @@ typedef struct spider_table_holder SPIDER_TABLE_HOLDER; typedef struct spider_link_idx_holder { spider_table_link_idx_holder *table_link_idx_holder; + /* The index of active link */ int link_idx; int link_status; spider_link_idx_holder *next_table; @@ -609,7 +610,7 @@ public: ); SPIDER_CONN_HOLDER *create_conn_holder(); bool has_conn_holder(); - void clear_conn_holder_from_conn(); + void clear_conn_holder_checked(); bool check_conn_same_conn( SPIDER_CONN *conn_arg ); @@ -887,7 +888,6 @@ public: SPIDER_SHARE *spider_share, CHARSET_INFO *access_charset ) = 0; - virtual uint limit_mode(); }; class spider_db_conn diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 2c6f13d5d01..b920a313784 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -3033,7 +3033,7 @@ int spider_db_mbase::append_lock_tables( int error_num; ha_spider *tmp_spider; int lock_type; - uint conn_link_idx; + uint all_link_idx; int tmp_link_idx; SPIDER_LINK_FOR_HASH *tmp_link_for_hash; const char *db_name; @@ -3073,16 +3073,16 @@ int spider_db_mbase::append_lock_tables( tmp_spider->wide_handler->lock_type)); DBUG_RETURN(0); } - conn_link_idx = tmp_spider->conn_link_idx[tmp_link_idx]; + all_link_idx = tmp_spider->conn_link_idx[tmp_link_idx]; spider_mbase_share *db_share = (spider_mbase_share *) tmp_spider->share->dbton_share[conn->dbton_id]; - db_name = db_share->db_names_str[conn_link_idx].ptr(); - db_name_length = db_share->db_names_str[conn_link_idx].length(); + db_name = db_share->db_names_str[all_link_idx].ptr(); + db_name_length = db_share->db_names_str[all_link_idx].length(); db_name_charset = tmp_spider->share->access_charset; - table_name = db_share->table_names_str[conn_link_idx].ptr(); - table_name_length = db_share->table_names_str[conn_link_idx].length(); + table_name = db_share->table_names_str[all_link_idx].ptr(); + table_name_length = db_share->table_names_str[all_link_idx].length(); table_name_charset = tmp_spider->share->access_charset; if ((error_num = spider_db_mbase_utility-> diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 423f493262e..e907d4de33a 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -631,7 +631,8 @@ bool spider_fields::has_conn_holder( DBUG_RETURN(first_conn_holder); } -void spider_fields::clear_conn_holder_from_conn( +/* Mark checked_for_same_conn to false for all conn holders */ +void spider_fields::clear_conn_holder_checked( ) { DBUG_ENTER("spider_fields::clear_conn_checked_for_same_conn"); DBUG_PRINT("info",("spider this=%p", this)); @@ -643,6 +644,9 @@ void spider_fields::clear_conn_holder_from_conn( DBUG_VOID_RETURN; } +/* Set current conn holder to be the first conn holder with a matching + conn and mark its checked_for_same_conn to be true. Return true if + one is found and vice versa. */ bool spider_fields::check_conn_same_conn( SPIDER_CONN *conn_arg ) { @@ -660,6 +664,7 @@ bool spider_fields::check_conn_same_conn( DBUG_RETURN(FALSE); } +/* Remove all conn holders with false checked_for_same_conn */ bool spider_fields::remove_conn_if_not_checked( ) { SPIDER_CONN_HOLDER *conn_holder; @@ -1457,6 +1462,7 @@ group_by_handler *spider_create_group_by_handler( goto skip_free_table_holder; } memset(dbton_bitmap, 0, spider_bitmap_size(SPIDER_DBTON_SIZE)); + /* Find all backends used by the first table. */ for (roop_count = 0; roop_count < (int) share->use_dbton_count; ++roop_count) { dbton_id = share->use_sql_dbton_ids[roop_count]; @@ -1487,6 +1493,7 @@ group_by_handler *spider_create_group_by_handler( DBUG_PRINT("info",("spider can not add a table")); goto skip_free_table_holder; } + /* Find all backends used by the current table */ memset(dbton_bitmap_tmp, 0, spider_bitmap_size(SPIDER_DBTON_SIZE)); for (roop_count = 0; roop_count < (int) share->use_dbton_count; ++roop_count) { @@ -1498,6 +1505,7 @@ group_by_handler *spider_create_group_by_handler( spider_set_bit(dbton_bitmap_tmp, dbton_id); } } + /* Intersect to get common backends used by all tables (so far) */ for (roop_count = 0; roop_count < spider_bitmap_size(SPIDER_DBTON_SIZE); ++roop_count) { @@ -1740,7 +1748,7 @@ group_by_handler *spider_create_group_by_handler( while ((from = from->next_local)) { - fields->clear_conn_holder_from_conn(); + fields->clear_conn_holder_checked(); if (from->table->part_info) { @@ -1774,10 +1782,13 @@ group_by_handler *spider_create_group_by_handler( DBUG_PRINT("info",("spider conn=%p", conn)); if (!fields->check_conn_same_conn(conn)) { - DBUG_PRINT("info",("spider connection %p can not be used for this query with locking", - conn)); if (lock_mode) + { + DBUG_PRINT("info", ("spider connection %p can not be used for this " + "query with locking", + conn)); goto skip_free_fields; + } continue; } if (fields->add_link_idx(conn->conn_holder_for_direct_join, spider, roop_count)) @@ -1795,6 +1806,10 @@ group_by_handler *spider_create_group_by_handler( goto skip_free_fields; } } + /* Do not create if all conn holders have been removed. This + happens if the current table does not share usable conns with + the first table. One typical example is when the current table + is located on a different server from the first table. */ if (!fields->has_conn_holder()) { goto skip_free_fields; diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index f6f007cb1d4..9ca48a9e9fd 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -998,8 +998,12 @@ typedef struct st_spider_share FIXME: consider removing it and using `active_link_count` instead. */ uint link_count; - /* Number of all links, i.e. all remote servers for the spider - table. */ + /* + Number of all links, i.e. all remote servers for the spider + table or partition. + + There's also active_link_count + */ uint all_link_count; /* The bitmap size of ha_spider::conn_can_fo, where the ha_spider diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 79d3a72da8e..51fb79a9f7e 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -1580,11 +1580,11 @@ int spider_ping_table_mon_from_table( SPIDER_TRX *trx, THD *thd, SPIDER_SHARE *share, - int base_link_idx, + int link_idx, /* TODO: unused */ uint32 server_id, char *conv_name, /* Usually fully qualified table name */ uint conv_name_length, - int link_idx, /* The link id to ping */ + int all_link_idx, /* The link id to ping */ char *where_clause, uint where_clause_length, long monitoring_kind, @@ -1629,14 +1629,14 @@ int spider_ping_table_mon_from_table( DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); } - if (share->static_link_ids[link_idx]) + if (share->static_link_ids[all_link_idx]) { - memcpy(link_idx_str, share->static_link_ids[link_idx], - share->static_link_ids_lengths[link_idx] + 1); - link_idx_str_length = share->static_link_ids_lengths[link_idx]; + memcpy(link_idx_str, share->static_link_ids[all_link_idx], + share->static_link_ids_lengths[all_link_idx] + 1); + link_idx_str_length = share->static_link_ids_lengths[all_link_idx]; } else { link_idx_str_length = my_sprintf(link_idx_str, (link_idx_str, "%010d", - link_idx)); + all_link_idx)); } char *buf = (char *) my_alloca(conv_name_length + link_idx_str_length + 1); if (!buf) @@ -1665,9 +1665,9 @@ int spider_ping_table_mon_from_table( /* Get or create `table_mon_list' for `conv_name_str'. */ if (!(table_mon_list = spider_get_ping_table_mon_list(trx, thd, - &conv_name_str, conv_name_length, link_idx, - share->static_link_ids[link_idx], - share->static_link_ids_lengths[link_idx], + &conv_name_str, conv_name_length, all_link_idx, + share->static_link_ids[all_link_idx], + share->static_link_ids_lengths[all_link_idx], server_id, need_lock, &error_num))) { my_afree(buf); @@ -1682,7 +1682,7 @@ int spider_ping_table_mon_from_table( DBUG_PRINT("info", ("spider share->link_statuses[%d]=SPIDER_LINK_STATUS_NG", link_idx)); pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); - share->link_statuses[link_idx] = SPIDER_LINK_STATUS_NG; + share->link_statuses[all_link_idx] = SPIDER_LINK_STATUS_NG; pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); error_num = ER_SPIDER_LINK_MON_NG_NUM; my_printf_error(error_num, @@ -1741,7 +1741,7 @@ int spider_ping_table_mon_from_table( ) { if (!spider_db_udf_ping_table_mon_next( thd, table_mon, mon_conn, &mon_table_result, conv_name, - conv_name_length, link_idx, + conv_name_length, all_link_idx, where_clause, where_clause_length, /*first_sid=*/-1, table_mon_list->list_size, 0, 0, 0, flags, monitoring_limit)) { @@ -1757,11 +1757,11 @@ int spider_ping_table_mon_from_table( DBUG_PRINT("info", ( "spider share->link_statuses[%d]=SPIDER_LINK_STATUS_NG", link_idx)); - share->link_statuses[link_idx] = SPIDER_LINK_STATUS_NG; + share->link_statuses[all_link_idx] = SPIDER_LINK_STATUS_NG; spider_sys_update_tables_link_status(thd, conv_name, - conv_name_length, link_idx, SPIDER_LINK_STATUS_NG); + conv_name_length, all_link_idx, SPIDER_LINK_STATUS_NG); spider_sys_log_tables_link_failed(thd, conv_name, - conv_name_length, link_idx); + conv_name_length, all_link_idx); } pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); } diff --git a/storage/spider/spd_ping_table.h b/storage/spider/spd_ping_table.h index 586ee7afde2..d12976563dd 100644 --- a/storage/spider/spd_ping_table.h +++ b/storage/spider/spd_ping_table.h @@ -105,11 +105,11 @@ int spider_ping_table_mon_from_table( SPIDER_TRX *trx, THD *thd, SPIDER_SHARE *share, - int base_link_idx, + int link_idx, uint32 server_id, char *conv_name, uint conv_name_length, - int link_idx, + int all_link_idx, char *where_clause, uint where_clause_length, long monitoring_kind, diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 5ac4ba408fd..c3855e573d5 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -3584,8 +3584,7 @@ void spider_trx_set_link_idx_for_all( spider_set_bit(conn_can_fo, link_idx); DBUG_PRINT("info",("spider set conn_link_idx[%d]=%d", link_idx, all_link_idx)); - } else - { + } else { conn_link_idx[link_idx] = link_idx; DBUG_PRINT("info",("spider set2 conn_link_idx[%d]=%d", link_idx, link_idx)); diff --git a/strings/ctype-uca-scanner_next.inl b/strings/ctype-uca-scanner_next.inl index e8489ddf191..5c78d751890 100644 --- a/strings/ctype-uca-scanner_next.inl +++ b/strings/ctype-uca-scanner_next.inl @@ -81,7 +81,7 @@ MY_FUNCTION_NAME(scanner_next)(my_uca_scanner *scanner, const uint16 *cweight; #if MY_UCA_ASCII_OPTIMIZE && !defined(SCANNER_NEXT_NCHARS) - if (scanner->sbeg + 1 < scanner->send) + if (scanner->send - scanner->sbeg > 1) { const MY_UCA_2BYTES_ITEM *ww; ww= my_uca_level_booster_2bytes_item_addr_const(param->level->booster, diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 59a5a6b326a..a6bbe821f62 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -212,10 +212,14 @@ IF(UNIX AND NOT WITHOUT_SERVER) ENDIF() IF((HAVE_SYSTEMD OR INSTALL_SYSTEMD_TMPUSERS) AND INSTALL_SYSTEMD_TMPFILESDIR) - get_filename_component(MYSQL_UNIX_DIR ${MYSQL_UNIX_ADDR} DIRECTORY) - IF(MYSQL_DATADIR STREQUAL MYSQL_UNIX_DIR) - SET(DISABLE_TMP "#") + IF(MYSQL_DATADIR STREQUAL INSTALL_RUNDATADIR) + SET(DISABLE_RUNDATADIR "#") ENDIF() + get_filename_component(MYSQL_UNIX_ADDRDIR ${MYSQL_UNIX_ADDR} DIRECTORY) + IF(MYSQL_UNIX_ADDRDIR STREQUAL MYSQL_DATADIR OR MYSQL_UNIX_ADDRDIR STREQUAL INSTALL_RUNDATADIR) + SET(DISABLE_MYSQL_UNIX_ADDRDIR "#") + ENDIF() + CONFIGURE_FILE(tmpfiles.conf.in ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index f1c87b2a700..16c905cdd62 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -63,25 +63,23 @@ ProtectSystem=full ProtectHome=true # Use an environment file to pass variable _WSREP_NEW_CLUSTER -EnvironmentFile=-@mysqlunixdir@/wsrep-new-cluster +EnvironmentFile=-@INSTALL_RUNDATADIR@/wsrep-new-cluster # Use an environment file to pass variable _WSREP_START_POSITION -EnvironmentFile=-@mysqlunixdir@/wsrep-start-position - -@SYSTEMD_EXECSTARTPRE@ +EnvironmentFile=-@INSTALL_RUNDATADIR@/wsrep-start-position # Perform automatic wsrep recovery. When server is started without wsrep, # galera_recovery simply returns an empty string. In any case, however, # the script is not expected to return with a non-zero status. -# It is always safe to remove @mysqlunixdir@/wsrep-start-position +# It is always safe to remove @INSTALL_RUNDATADIR@/wsrep-start-position # environment file. # Do not panic if galera_recovery script is not available. (MDEV-10538) ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \ VAR=`@bindir@/galera_recovery`; [ $? -eq 0 ] \ - && echo _WSREP_START_POSITION=$VAR > @mysqlunixdir@/wsrep-start-position || exit 1" + && echo _WSREP_START_POSITION=$VAR > @INSTALL_RUNDATADIR@/wsrep-start-position || exit 1" # Needed to create system tables etc. -# ExecStartPre=@scriptdir@/mariadb-install-db -u mysql +# ExecStartPre=@scriptdir@/mariadb-install-db # Start main service # MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf @@ -90,8 +88,8 @@ ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \ # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster ExecStart=@sbindir@/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION -# Unset _WSREP_START_POSITION environment variable. -ExecStartPost=/bin/rm -f @mysqlunixdir@/wsrep-start-position +# Unset _WSREP_START_POSITION/_WSREP_NEW_CLUSTER environment variable. +ExecStartPost=/bin/rm -f @INSTALL_RUNDATADIR@/wsrep-start-position @INSTALL_RUNDATADIR@/wsrep-new-cluster @SYSTEMD_EXECSTARTPOST@ diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh index afaba2cecad..8d7e8a3166c 100644 --- a/support-files/rpm/server-postin.sh +++ b/support-files/rpm/server-postin.sh @@ -1,5 +1,6 @@ if [ -f /usr/lib/systemd/system/mariadb.service -a -x /usr/bin/systemctl ]; then systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf + systemd-tmpfiles --create mariadb.conf if [ -x %{_bindir}/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then # Either fresh install or upgrade non-systemd -> systemd mkdir -p /etc/systemd/system/mariadb.service.d diff --git a/support-files/rpm/server-posttrans.sh b/support-files/rpm/server-posttrans.sh index d91ff65e04f..e6c411e4aae 100644 --- a/support-files/rpm/server-posttrans.sh +++ b/support-files/rpm/server-posttrans.sh @@ -3,7 +3,7 @@ if [ -r %{restart_flag} ] ; then # only restart the server if it was already running if [ -x /usr/bin/systemctl ] ; then /usr/bin/systemctl daemon-reload > /dev/null 2>&1 - if /usr/bin/systemctl is-active mysql; then + if /usr/bin/systemctl -q is-active mysql; then /usr/bin/systemctl restart mysql > /dev/null 2>&1 else /usr/bin/systemctl try-restart mariadb.service > /dev/null 2>&1 diff --git a/support-files/tmpfiles.conf.in b/support-files/tmpfiles.conf.in index 70de7a12fdb..6a2a28b59a3 100644 --- a/support-files/tmpfiles.conf.in +++ b/support-files/tmpfiles.conf.in @@ -1,5 +1,9 @@ # This is the directory where the unix socket -# of MariaDB is created. +# of MariaDB may be created. +# +# Under Galera this is where an envfile of +# the Galera start position is stored. +# # Other temporary directories can be created here like: # * tmpdir # * innodb_tmpdir @@ -8,4 +12,5 @@ # etc. # It shouldn't be used for datadir which is why it # may be disabled. -@DISABLE_TMP@d @MYSQL_UNIX_DIR@ 0755 @MYSQLD_USER@ @MYSQLD_USER@ - +@DISABLE_RUNDATADIR@d @INSTALL_RUNDATADIR@ 0755 @MYSQLD_USER@ @MYSQLD_USER@ - +@DISABLE_MYSQL_UNIX_ADDRDIR@d @MYSQL_UNIX_ADDRDIR@ 0755 @MYSQLD_USER@ root -