diff options
47 files changed, 723 insertions, 188 deletions
diff --git a/cmake/check_linker_flag.cmake b/cmake/check_linker_flag.cmake index ff4b91e89f6..1ea1772d79e 100644 --- a/cmake/check_linker_flag.cmake +++ b/cmake/check_linker_flag.cmake @@ -6,11 +6,11 @@ FUNCTION(MY_CHECK_AND_SET_LINKER_FLAG flag_to_set) RETURN() ENDIF() STRING(REGEX REPLACE "[-,= +]" "_" result "HAVE_LINK_FLAG_${flag_to_set}") - SET(SAVE_CMAKE_REQUIRED_LINK_OPTIONS "${CMAKE_REQUIRED_LINK_OPTIONS}") + SET(SAVE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set}) - SET(CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS} ${flag_to_check}) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${flag_to_check}) CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result}) - SET(CMAKE_REQUIRED_LINK_OPTIONS "${SAVE_CMAKE_REQUIRED_LINK_OPTIONS}") + SET(CMAKE_REQUIRED_LIBRARIES "${SAVE_CMAKE_REQUIRED_LIBRARIES}") IF (${result}) FOREACH(linktype SHARED MODULE EXE) IF(ARGN) diff --git a/man/mysqlimport.1 b/man/mysqlimport.1 index 98d68e956c5..16112399dab 100644 --- a/man/mysqlimport.1 +++ b/man/mysqlimport.1 @@ -57,13 +57,13 @@ all would be imported into a table named patient\&. .PP .PP -\fBmysqldump\fR +\fBmysqlimport\fR supports the following options, which can be specified on the command line or in the -[mysqldump] +[mysqlimport] and [client] option file groups\&. -\fBmysqldump\fR +\fBmysqlimport\fR also supports the options for processing option files\&. .sp .RS 4 @@ -267,17 +267,17 @@ Empty the table before importing the text file\&. .sp -1 .IP \(bu 2.3 .\} -.\" mysqldump: fields-terminated-by option -.\" fields-terminated-by option: mysqldump +.\" mysqlimport: fields-terminated-by option +.\" fields-terminated-by option: mysqlimport \fB\-\-fields\-terminated\-by=\&.\&.\&.\fR, -.\" mysqldump: fields-enclosed-by option -.\" fields-enclosed-by option: mysqldump +.\" mysqlimport: fields-enclosed-by option +.\" fields-enclosed-by option: mysqlimport \fB\-\-fields\-enclosed\-by=\&.\&.\&.\fR, -.\" mysqldump: fields-optionally-enclosed-by option -.\" fields-optionally-enclosed-by option: mysqldump +.\" mysqlimport: fields-optionally-enclosed-by option +.\" fields-optionally-enclosed-by option: mysqlimport \fB\-\-fields\-optionally\-enclosed\-by=\&.\&.\&.\fR, -.\" mysqldump: fields-escaped-by option -.\" fields-escaped-by option: mysqldump +.\" mysqlimport: fields-escaped-by option +.\" fields-escaped-by option: mysqlimport \fB\-\-fields\-escaped\-by=\&.\&.\&.\fR .sp These options have the same meaning as the corresponding clauses for @@ -379,8 +379,8 @@ lines of the data file\&. .sp -1 .IP \(bu 2.3 .\} -.\" mysqldump: lines-terminated-by option -.\" lines-terminated-by option: mysqldump +.\" mysqlimport: lines-terminated-by option +.\" lines-terminated-by option: mysqlimport \fB\-\-lines\-terminated\-by=\&.\&.\&.\fR .sp This option has the same meaning as the corresponding clause for diff --git a/mysql-test/include/icp_debug_kill.inc b/mysql-test/include/icp_debug_kill.inc new file mode 100644 index 00000000000..d0ecc842869 --- /dev/null +++ b/mysql-test/include/icp_debug_kill.inc @@ -0,0 +1,50 @@ +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/count_sessions.inc + +--disable_warnings +drop table if exists t0,t1,t2; +--enable_warnings + +create table t0(a int primary key); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1(a int primary key); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; + +create table t2 ( + kp1 int, + kp2 int, + col char(100), + key(kp1, kp2) +); +insert into t2 select a, a, a from t1; + +select engine from information_schema.tables +where table_schema=database() and table_name='t2'; + +explain +select * from t2 where kp1 between 10 and 20 and kp2 +1 >100; + +let $target_id= `select connection_id()`; + +set debug_sync='handler_index_cond_check SIGNAL at_icp_check WAIT_FOR go'; +send +select * from t2 where kp1 between 10 and 20 and kp2 +1 >100; + +connect (con1, localhost, root,,); +connection con1; +set debug_sync='now WAIT_FOR at_icp_check'; +evalp kill query $target_id; +set debug_sync='now SIGNAL go'; + +connection default; + +--error ER_QUERY_INTERRUPTED +reap; +set debug_sync='RESET'; + +disconnect con1; +drop table t0,t1,t2; +--source include/wait_until_count_sessions.inc + diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ef3fd6294f4..900ef736a45 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -6546,7 +6546,7 @@ Options for debugging the product debug-server Use debug version of server, but without turning on tracing debugger=NAME Start mysqld in the selected debugger - gdb Start the mysqld(s) in gdb + gdb[=gdb_arguments] Start the mysqld(s) in gdb manual-debug Let user manually start mysqld in debugger, before running test(s) manual-gdb Let user manually start mysqld in gdb, before running diff --git a/mysql-test/r/limit_rows_examined.result b/mysql-test/r/limit_rows_examined.result index 2b5bca2fb47..8d9ebab7631 100644 --- a/mysql-test/r/limit_rows_examined.result +++ b/mysql-test/r/limit_rows_examined.result @@ -861,3 +861,18 @@ Warnings: Warning 1931 Query execution was interrupted. The query examined at least 22 rows, which exceeds LIMIT ROWS EXAMINED (21). The query result may be incomplete drop view v; drop table t1, t2; +# +# 10.1 Test +# +# MDEV-17729: Assertion `! is_set() || m_can_overwrite_status' +# failed in Diagnostics_area::set_error_status +# +set @old_mode= @@sql_mode; +CREATE TABLE t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,k INT, c CHAR(20)); +INSERT INTO t1 (k,c) VALUES(0,'0'), (0,'0'),(0,'0'),(0,'0'),(0,'0'),(0,'0'),(0,'0'); +SET @@sql_mode='STRICT_TRANS_TABLES'; +INSERT INTO t1 (c) SELECT k FROM t1 LIMIT ROWS EXAMINED 2; +Warnings: +Warning 1931 Query execution was interrupted. The query examined at least 3 rows, which exceeds LIMIT ROWS EXAMINED (2). The query result may be incomplete +SET @@sql_mode=@old_mode; +DROP TABLE t1; diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index 6b5a2ad1577..925dce117e9 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -380,6 +380,14 @@ slow_log slow_log_new drop table slow_log_new, general_log_new; use test; +SET GLOBAL LOG_OUTPUT = 'FILE'; +SET GLOBAL slow_query_log = 1; +SET GLOBAL general_log = 1; +ALTER TABLE mysql.slow_log ADD COLUMN comment_text TEXT NOT NULL; +ALTER TABLE mysql.general_log ADD COLUMN comment_text TEXT NOT NULL; +SET GLOBAL LOG_OUTPUT = 'NONE'; +ALTER TABLE mysql.slow_log DROP COLUMN comment_text; +ALTER TABLE mysql.general_log DROP COLUMN comment_text; SET GLOBAL LOG_OUTPUT = 'TABLE'; SET GLOBAL general_log = 0; FLUSH LOGS; diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 6d04efeaf94..b70d4235c01 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -2796,5 +2796,16 @@ id 16 drop table t1; # +# MDEV-5628: Assertion `! is_set()' or `!is_set() || +# (m_status == DA_OK_BULK && is_bulk_op())' fails on UPDATE on a +# partitioned table with subquery (MySQL:71630) +# +CREATE TABLE t1 (a INT) PARTITION BY HASH(a) PARTITIONS 2; +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); +UPDATE t1 SET a = 7 WHERE a = ( SELECT b FROM t2 ) ORDER BY a LIMIT 6; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1,t2; +# # End of 10.1 tests # diff --git a/mysql-test/suite/binlog/r/binlog_recover_checksum_error.result b/mysql-test/suite/binlog/r/binlog_recover_checksum_error.result new file mode 100644 index 00000000000..f65f7797d7f --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_recover_checksum_error.result @@ -0,0 +1,7 @@ +set @@global.binlog_checksum = CRC32; +call mtr.add_suppression("Replication event checksum verification failed"); +call mtr.add_suppression("Error in Log_event::read_log_event"); +set @@global.debug_dbug = VALUE; +set @@global.master_verify_checksum = DO_CHECKSUM; +set @@global.binlog_checksum = BINLOG_CHECKSUM; +# EOF the test diff --git a/mysql-test/suite/binlog/t/binlog_recover_checksum_error.test b/mysql-test/suite/binlog/t/binlog_recover_checksum_error.test new file mode 100644 index 00000000000..12c9f3d914f --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_recover_checksum_error.test @@ -0,0 +1,37 @@ +# The test verifies server binlog-based recovery. +# +# MDEV-23832 checksum error at server binlog recovery should not crash + +# The test logic really requires --log-bin. +--source include/have_binlog_format_mixed.inc +--source include/have_debug.inc + +--let $do_checksum = `SELECT @@global.master_verify_checksum` +--let $debug_dbug_saved = `SELECT @@global.debug_dbug` +--let $binlog_checksum = `SELECT @@global.binlog_checksum` +set @@global.binlog_checksum = CRC32; + +call mtr.add_suppression("Replication event checksum verification failed"); +call mtr.add_suppression("Error in Log_event::read_log_event"); + +# Proof of no crash follows. +# There's no need for actual bin-loggable queries to the server +--let $restart_parameters= --master_verify_checksum=ON --debug_dbug="+d,corrupt_read_log_event_char" +--let $shutdown_timeout=0 +--source include/restart_mysqld.inc +--let $restart_parameters= +--let $shutdown_timeout= + +# +# Cleanup + +--replace_regex /= .*/= VALUE/ +--eval set @@global.debug_dbug = "$debug_dbug_saved" + +--replace_result $do_checksum DO_CHECKSUM +--eval set @@global.master_verify_checksum = $do_checksum +--replace_result $binlog_checksum BINLOG_CHECKSUM +--eval set @@global.binlog_checksum = $binlog_checksum +# +--echo # EOF the test +# diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result index ad774ff90bb..8101ae6bea2 100644 --- a/mysql-test/suite/innodb/r/foreign_key.result +++ b/mysql-test/suite/innodb/r/foreign_key.result @@ -420,6 +420,41 @@ connection default; XA END 'xid'; XA ROLLBACK 'xid'; DROP TABLE t1; +CREATE TABLE t1 (pk INT PRIMARY KEY, +f1 VARCHAR(10), f2 VARCHAR(10), +f3 VARCHAR(10), f4 VARCHAR(10), +f5 VARCHAR(10), f6 VARCHAR(10), +f7 VARCHAR(10), f8 VARCHAR(10), +INDEX(f1), INDEX(f2), INDEX(f3), INDEX(f4), +INDEX(f5), INDEX(f6), INDEX(f7), INDEX(f8)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 'mariadb', 'mariadb', 'mariadb', 'mariadb', +'mariadb', 'mariadb', 'mariadb', 'mariadb'), +(2, 'mariadb', 'mariadb', 'mariadb', 'mariadb', +'mariadb', 'mariadb', 'mariadb', 'mariadb'), +(3, 'innodb', 'innodb', 'innodb', 'innodb', +'innodb', 'innodb', 'innodb', 'innodb'); +ALTER TABLE t1 ADD FOREIGN KEY (f1) REFERENCES t1 (f2) ON DELETE SET NULL; +START TRANSACTION; +DELETE FROM t1 where f1='mariadb'; +SELECT * FROM t1; +pk f1 f2 f3 f4 f5 f6 f7 f8 +2 NULL mariadb mariadb mariadb mariadb mariadb mariadb mariadb +3 innodb innodb innodb innodb innodb innodb innodb innodb +ROLLBACK; +ALTER TABLE t1 ADD FOREIGN KEY (f3) REFERENCES t1 (f4) ON DELETE CASCADE; +START TRANSACTION; +DELETE FROM t1 where f3='mariadb'; +SELECT * FROM t1; +pk f1 f2 f3 f4 f5 f6 f7 f8 +3 innodb innodb innodb innodb innodb innodb innodb innodb +ROLLBACK; +ALTER TABLE t1 ADD FOREIGN KEY (f5) REFERENCES t1 (f6) ON UPDATE SET NULL; +UPDATE t1 SET f6='update'; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_3` FOREIGN KEY (`f5`) REFERENCES `t1` (`f6`) ON UPDATE SET NULL) +ALTER TABLE t1 ADD FOREIGN KEY (f7) REFERENCES t1 (f8) ON UPDATE CASCADE; +UPDATE t1 SET f6='cascade'; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_3` FOREIGN KEY (`f5`) REFERENCES `t1` (`f6`) ON UPDATE SET NULL) +DROP TABLE t1; # Start of 10.2 tests # # MDEV-13246 Stale rows despite ON DELETE CASCADE constraint diff --git a/mysql-test/suite/innodb/r/innodb_stats_drop_locked.result b/mysql-test/suite/innodb/r/innodb_stats_drop_locked.result index b8f312ccd63..1567ac6cb0a 100644 --- a/mysql-test/suite/innodb/r/innodb_stats_drop_locked.result +++ b/mysql-test/suite/innodb/r/innodb_stats_drop_locked.result @@ -47,3 +47,5 @@ innodb_stats_drop_locked innodb_stats_drop_locked innodb_stats_drop_locked innodb_stats_drop_locked +DELETE FROM mysql.innodb_index_stats WHERE database_name='test' AND table_name='innodb_stats_drop_locked'; +DELETE FROM mysql.innodb_table_stats WHERE database_name='test' AND table_name='innodb_stats_drop_locked'; diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test index 190461a4f7b..380d4520d87 100644 --- a/mysql-test/suite/innodb/t/foreign_key.test +++ b/mysql-test/suite/innodb/t/foreign_key.test @@ -421,6 +421,41 @@ ALTER TABLE t1 ADD FOREIGN KEY f (a) REFERENCES t1 (pk), LOCK=EXCLUSIVE;# Cleanu XA END 'xid'; XA ROLLBACK 'xid'; DROP TABLE t1; + +CREATE TABLE t1 (pk INT PRIMARY KEY, + f1 VARCHAR(10), f2 VARCHAR(10), + f3 VARCHAR(10), f4 VARCHAR(10), + f5 VARCHAR(10), f6 VARCHAR(10), + f7 VARCHAR(10), f8 VARCHAR(10), + INDEX(f1), INDEX(f2), INDEX(f3), INDEX(f4), + INDEX(f5), INDEX(f6), INDEX(f7), INDEX(f8)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 'mariadb', 'mariadb', 'mariadb', 'mariadb', + 'mariadb', 'mariadb', 'mariadb', 'mariadb'), + (2, 'mariadb', 'mariadb', 'mariadb', 'mariadb', + 'mariadb', 'mariadb', 'mariadb', 'mariadb'), + (3, 'innodb', 'innodb', 'innodb', 'innodb', + 'innodb', 'innodb', 'innodb', 'innodb'); +ALTER TABLE t1 ADD FOREIGN KEY (f1) REFERENCES t1 (f2) ON DELETE SET NULL; +START TRANSACTION; +DELETE FROM t1 where f1='mariadb'; +SELECT * FROM t1; +ROLLBACK; + +ALTER TABLE t1 ADD FOREIGN KEY (f3) REFERENCES t1 (f4) ON DELETE CASCADE; + +START TRANSACTION; +DELETE FROM t1 where f3='mariadb'; +SELECT * FROM t1; +ROLLBACK; + +ALTER TABLE t1 ADD FOREIGN KEY (f5) REFERENCES t1 (f6) ON UPDATE SET NULL; +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1 SET f6='update'; + +ALTER TABLE t1 ADD FOREIGN KEY (f7) REFERENCES t1 (f8) ON UPDATE CASCADE; +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1 SET f6='cascade'; +DROP TABLE t1; # # End of 10.1 tests # diff --git a/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test b/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test index 26367b8e6ae..07c77299451 100644 --- a/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test +++ b/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test @@ -56,6 +56,8 @@ WHERE table_name='innodb_stats_drop_locked'; SELECT table_name FROM mysql.innodb_index_stats WHERE table_name='innodb_stats_drop_locked'; +DELETE FROM mysql.innodb_index_stats WHERE database_name='test' AND table_name='innodb_stats_drop_locked'; +DELETE FROM mysql.innodb_table_stats WHERE database_name='test' AND table_name='innodb_stats_drop_locked'; --disable_query_log call mtr.add_suppression("Unable to delete statistics for table test.innodb_stats_drop_locked: Lock wait timeout. They can be deleted later using DELETE FROM mysql.innodb_index_stats WHERE database_name"); --enable_query_log diff --git a/mysql-test/suite/innodb_fts/r/basic.result b/mysql-test/suite/innodb_fts/r/basic.result index d96127fbc34..b3fd94509c3 100644 --- a/mysql-test/suite/innodb_fts/r/basic.result +++ b/mysql-test/suite/innodb_fts/r/basic.result @@ -132,6 +132,27 @@ id title body 3 Optimizing MySQL In this tutorial we will show ... 4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... 5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((vs))))))))))))))))))))))))))))))),(((to)))' + IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+ MySQL + (>Well < stands)' IN BOOLEAN MODE); id title body diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result b/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result index b76784d4ffd..e039b7e77d9 100644 --- a/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result @@ -919,4 +919,46 @@ DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; DROP TABLE t4; +# +# InnoDB: Failing assertion: result != FTS_INVALID in +# fts_trx_row_get_new_state +# +SET FOREIGN_KEY_CHECKS=1; +CREATE TABLE t1 (pk INT PRIMARY KEY, +f1 VARCHAR(10), f2 VARCHAR(10), +f3 VARCHAR(10), f4 VARCHAR(10), +f5 VARCHAR(10), f6 VARCHAR(10), +f7 VARCHAR(10), f8 VARCHAR(10), +FULLTEXT(f1), FULLTEXT(f2), FULLTEXT(f3), FULLTEXT(f4), +FULLTEXT(f5), FULLTEXT(f6), FULLTEXT(f7), FULLTEXT(f8), +INDEX(f1), INDEX(f2), INDEX(f3), INDEX(f4), +INDEX(f5), INDEX(f6), INDEX(f7), INDEX(f8)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 'mariadb', 'mariadb', 'mariadb', 'mariadb', +'mariadb', 'mariadb', 'mariadb', 'mariadb'), +(2, 'mariadb', 'mariadb', 'mariadb', 'mariadb', +'mariadb', 'mariadb', 'mariadb', 'mariadb'), +(3, 'innodb', 'innodb', 'innodb', 'innodb', +'innodb', 'innodb', 'innodb', 'innodb'); +ALTER TABLE t1 ADD FOREIGN KEY (f1) REFERENCES t1 (f2) ON DELETE SET NULL; +START TRANSACTION; +DELETE FROM t1 where f1='mariadb'; +SELECT * FROM t1; +pk f1 f2 f3 f4 f5 f6 f7 f8 +2 NULL mariadb mariadb mariadb mariadb mariadb mariadb mariadb +3 innodb innodb innodb innodb innodb innodb innodb innodb +ROLLBACK; +ALTER TABLE t1 ADD FOREIGN KEY (f3) REFERENCES t1 (f4) ON DELETE CASCADE; +START TRANSACTION; +DELETE FROM t1 where f3='mariadb'; +SELECT * FROM t1; +pk f1 f2 f3 f4 f5 f6 f7 f8 +3 innodb innodb innodb innodb innodb innodb innodb innodb +ROLLBACK; +ALTER TABLE t1 ADD FOREIGN KEY (f5) REFERENCES t1 (f6) ON UPDATE SET NULL; +UPDATE t1 SET f6='update'; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_3` FOREIGN KEY (`f5`) REFERENCES `t1` (`f6`) ON UPDATE SET NULL) +ALTER TABLE t1 ADD FOREIGN KEY (f7) REFERENCES t1 (f8) ON UPDATE CASCADE; +UPDATE t1 SET f6='cascade'; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_3` FOREIGN KEY (`f5`) REFERENCES `t1` (`f6`) ON UPDATE SET NULL) +DROP TABLE t1; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; diff --git a/mysql-test/suite/innodb_fts/t/basic.test b/mysql-test/suite/innodb_fts/t/basic.test index 0c0920c5f16..7a5c83ffb06 100644 --- a/mysql-test/suite/innodb_fts/t/basic.test +++ b/mysql-test/suite/innodb_fts/t/basic.test @@ -107,6 +107,26 @@ SELECT * FROM articles WHERE MATCH (title,body) SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+ MySQL - (Well stands)' IN BOOLEAN MODE); +--error 128 +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((vs))))))))))))))))))))))))))))))),(((to)))' + IN BOOLEAN MODE); + +--error ER_PARSE_ERROR +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +--error ER_PARSE_ERROR +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); + # Test sub-expression boolean search. Find rows contain # "MySQL" and "Well" or "MySQL" and "stands". But rank the # doc with "Well" higher, and doc with "stands" lower. diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test index 3c794ec6440..46b65590298 100644 --- a/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test @@ -889,4 +889,46 @@ DROP TABLE t2; DROP TABLE t3; DROP TABLE t4; +--echo # +--echo # InnoDB: Failing assertion: result != FTS_INVALID in +--echo # fts_trx_row_get_new_state +--echo # +SET FOREIGN_KEY_CHECKS=1; +CREATE TABLE t1 (pk INT PRIMARY KEY, + f1 VARCHAR(10), f2 VARCHAR(10), + f3 VARCHAR(10), f4 VARCHAR(10), + f5 VARCHAR(10), f6 VARCHAR(10), + f7 VARCHAR(10), f8 VARCHAR(10), + FULLTEXT(f1), FULLTEXT(f2), FULLTEXT(f3), FULLTEXT(f4), + FULLTEXT(f5), FULLTEXT(f6), FULLTEXT(f7), FULLTEXT(f8), + INDEX(f1), INDEX(f2), INDEX(f3), INDEX(f4), + INDEX(f5), INDEX(f6), INDEX(f7), INDEX(f8)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 'mariadb', 'mariadb', 'mariadb', 'mariadb', + 'mariadb', 'mariadb', 'mariadb', 'mariadb'), + (2, 'mariadb', 'mariadb', 'mariadb', 'mariadb', + 'mariadb', 'mariadb', 'mariadb', 'mariadb'), + (3, 'innodb', 'innodb', 'innodb', 'innodb', + 'innodb', 'innodb', 'innodb', 'innodb'); +ALTER TABLE t1 ADD FOREIGN KEY (f1) REFERENCES t1 (f2) ON DELETE SET NULL; +START TRANSACTION; +DELETE FROM t1 where f1='mariadb'; +SELECT * FROM t1; +ROLLBACK; + +ALTER TABLE t1 ADD FOREIGN KEY (f3) REFERENCES t1 (f4) ON DELETE CASCADE; + +START TRANSACTION; +DELETE FROM t1 where f3='mariadb'; +SELECT * FROM t1; +ROLLBACK; + +ALTER TABLE t1 ADD FOREIGN KEY (f5) REFERENCES t1 (f6) ON UPDATE SET NULL; +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1 SET f6='update'; + +ALTER TABLE t1 ADD FOREIGN KEY (f7) REFERENCES t1 (f8) ON UPDATE CASCADE; +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1 SET f6='cascade'; +DROP TABLE t1; + SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; diff --git a/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result b/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result index 1f352e68bc7..35e5de7b15a 100644 --- a/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result +++ b/mysql-test/suite/rpl/r/rpl_mysql_upgrade.result @@ -3,20 +3,66 @@ include/master-slave.inc call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); call mtr.add_suppression("table or database name 'mysqltest-1'"); connection master; -DROP DATABASE IF EXISTS `#mysql50#mysqltest-1`; -CREATE DATABASE `#mysql50#mysqltest-1`; +CREATE DATABASE `mysqltest-1`; connection slave; connection master; connection slave; connection master; Master position is not changed connection slave; -STOP SLAVE SQL_THREAD; -include/wait_for_slave_sql_to_stop.inc +SET @old_general_log_state = @@global.general_log; +SET @old_slow_log_state = @@global.slow_query_log; +SET @old_log_output = @@global.log_output; +SET GLOBAL general_log = 'ON'; +SET GLOBAL slow_query_log = 'ON'; +SET GLOBAL log_output = 'FILE'; +connection master; +ALTER TABLE mysql.slow_log DROP COLUMN thread_id, DROP COLUMN rows_affected; +DROP DATABASE `mysqltest-1`; +connection slave; +connection slave; +SHOW CREATE TABLE mysql.slow_log; +Table Create Table +slow_log CREATE TABLE `slow_log` ( + `start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), + `user_host` mediumtext NOT NULL, + `query_time` time(6) NOT NULL, + `lock_time` time(6) NOT NULL, + `rows_sent` int(11) NOT NULL, + `rows_examined` int(11) NOT NULL, + `db` varchar(512) NOT NULL, + `last_insert_id` int(11) NOT NULL, + `insert_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `sql_text` mediumtext NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' connection master; connection master; Master position has been changed -DROP DATABASE `mysqltest-1`; connection slave; -DROP DATABASE `#mysql50#mysqltest-1`; +connection slave; +SHOW CREATE TABLE mysql.slow_log; +Table Create Table +slow_log CREATE TABLE `slow_log` ( + `start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), + `user_host` mediumtext NOT NULL, + `query_time` time(6) NOT NULL, + `lock_time` time(6) NOT NULL, + `rows_sent` int(11) NOT NULL, + `rows_examined` int(11) NOT NULL, + `db` varchar(512) NOT NULL, + `last_insert_id` int(11) NOT NULL, + `insert_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `sql_text` mediumtext NOT NULL, + `thread_id` bigint(21) unsigned NOT NULL, + `rows_affected` int(11) NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log' +SET GLOBAL general_log = 'OFF'; +SET GLOBAL slow_query_log = 'OFF'; +truncate mysql.slow_log; +truncate mysql.general_log; +SET GLOBAL general_log = @old_general_log_state; +SET GLOBAL slow_query_log = @old_slow_log_state; +SET GLOBAL log_output = @old_log_output; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test index 1931e2eab2a..f44c883ef4e 100644 --- a/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test +++ b/mysql-test/suite/rpl/t/rpl_mysql_upgrade.test @@ -14,8 +14,7 @@ call mtr.add_suppression("table or database name 'mysqltest-1'"); connection master; --disable_warnings -DROP DATABASE IF EXISTS `#mysql50#mysqltest-1`; -CREATE DATABASE `#mysql50#mysqltest-1`; +CREATE DATABASE `mysqltest-1`; --enable_warnings sync_slave_with_master; @@ -34,13 +33,25 @@ if ($before_position == $after_position) echo Master position is not changed; } -#Some log events of the mysql_upgrade's will cause errors on slave. +# Some log events of the mysql_upgrade previously caused errors on slave, +# however with MDEV-4851 this should be ok, so we test it: connection slave; -STOP SLAVE SQL_THREAD; -source include/wait_for_slave_sql_to_stop.inc; +SET @old_general_log_state = @@global.general_log; +SET @old_slow_log_state = @@global.slow_query_log; +SET @old_log_output = @@global.log_output; +SET GLOBAL general_log = 'ON'; +SET GLOBAL slow_query_log = 'ON'; +SET GLOBAL log_output = 'FILE'; connection master; #With '--force' option, mysql_upgrade always executes all sql statements for upgrading. +ALTER TABLE mysql.slow_log DROP COLUMN thread_id, DROP COLUMN rows_affected; +DROP DATABASE `mysqltest-1`; +sync_slave_with_master; + +connection slave; +SHOW CREATE TABLE mysql.slow_log; +connection master; --exec $MYSQL_UPGRADE --skip-verbose --write-binlog --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade.log 2>&1 let $datadir= `select @@datadir`; @@ -55,8 +66,15 @@ if ($before_position != $after_position) echo Master position has been changed; } -DROP DATABASE `mysqltest-1`; +sync_slave_with_master; connection slave; -DROP DATABASE `#mysql50#mysqltest-1`; ---let $rpl_only_running_threads= 1 +SHOW CREATE TABLE mysql.slow_log; +SET GLOBAL general_log = 'OFF'; +SET GLOBAL slow_query_log = 'OFF'; +truncate mysql.slow_log; +truncate mysql.general_log; +SET GLOBAL general_log = @old_general_log_state; +SET GLOBAL slow_query_log = @old_slow_log_state; +SET GLOBAL log_output = @old_log_output; + --source include/rpl_end.inc diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff-disabled b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff-disabled index c8a0250504e..802932602af 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff-disabled +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff-disabled @@ -1214,7 +1214,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL --GLOBAL_VALUE 5.6.49 +-GLOBAL_VALUE 5.6.50 +GLOBAL_VALUE 5.6.49-89.0 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff-disabled b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff-disabled index af9060d7334..12aeecc58b4 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff-disabled +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff-disabled @@ -684,7 +684,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL --GLOBAL_VALUE 5.6.49 +-GLOBAL_VALUE 5.6.50 +GLOBAL_VALUE 5.6.49-89.0 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL diff --git a/mysql-test/t/aria_icp_debug.result b/mysql-test/t/aria_icp_debug.result new file mode 100644 index 00000000000..fc01ee4fb3b --- /dev/null +++ b/mysql-test/t/aria_icp_debug.result @@ -0,0 +1,34 @@ +set default_storage_engine=aria; +drop table if exists t0,t1,t2; +create table t0(a int primary key); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int primary key); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; +create table t2 ( +kp1 int, +kp2 int, +col char(100), +key(kp1, kp2) +); +insert into t2 select a, a, a from t1; +select engine from information_schema.tables +where table_schema=database() and table_name='t2'; +engine +Aria +explain +select * from t2 where kp1 between 10 and 20 and kp2 +1 >100; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range kp1 kp1 5 NULL 10 Using index condition +set debug_sync='handler_index_cond_check SIGNAL at_icp_check WAIT_FOR go'; +select * from t2 where kp1 between 10 and 20 and kp2 +1 >100; +connect con1, localhost, root,,; +connection con1; +set debug_sync='now WAIT_FOR at_icp_check'; +kill query $target_id; +set debug_sync='now SIGNAL go'; +connection default; +ERROR 70100: Query execution was interrupted +set debug_sync='RESET'; +disconnect con1; +drop table t0,t1,t2; +set default_storage_engine=default; diff --git a/mysql-test/t/aria_icp_debug.test b/mysql-test/t/aria_icp_debug.test new file mode 100644 index 00000000000..bbdd59d6012 --- /dev/null +++ b/mysql-test/t/aria_icp_debug.test @@ -0,0 +1,5 @@ + +set default_storage_engine=aria; +--source include/icp_debug_kill.inc +set default_storage_engine=default; + diff --git a/mysql-test/t/innodb_icp_debug.result b/mysql-test/t/innodb_icp_debug.result new file mode 100644 index 00000000000..5a169650c8e --- /dev/null +++ b/mysql-test/t/innodb_icp_debug.result @@ -0,0 +1,34 @@ +set default_storage_engine=innodb; +drop table if exists t0,t1,t2; +create table t0(a int primary key); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int primary key); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; +create table t2 ( +kp1 int, +kp2 int, +col char(100), +key(kp1, kp2) +); +insert into t2 select a, a, a from t1; +select engine from information_schema.tables +where table_schema=database() and table_name='t2'; +engine +InnoDB +explain +select * from t2 where kp1 between 10 and 20 and kp2 +1 >100; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range kp1 kp1 5 NULL 11 Using index condition +set debug_sync='handler_index_cond_check SIGNAL at_icp_check WAIT_FOR go'; +select * from t2 where kp1 between 10 and 20 and kp2 +1 >100; +connect con1, localhost, root,,; +connection con1; +set debug_sync='now WAIT_FOR at_icp_check'; +kill query $target_id; +set debug_sync='now SIGNAL go'; +connection default; +ERROR 70100: Query execution was interrupted +set debug_sync='RESET'; +disconnect con1; +drop table t0,t1,t2; +set default_storage_engine=default; diff --git a/mysql-test/t/innodb_icp_debug.test b/mysql-test/t/innodb_icp_debug.test new file mode 100644 index 00000000000..4aa08c61e87 --- /dev/null +++ b/mysql-test/t/innodb_icp_debug.test @@ -0,0 +1,6 @@ +--source include/have_innodb.inc + +set default_storage_engine=innodb; +--source include/icp_debug_kill.inc +set default_storage_engine=default; + diff --git a/mysql-test/t/limit_rows_examined.test b/mysql-test/t/limit_rows_examined.test index 28b39a4caa1..4ccf25dc17a 100644 --- a/mysql-test/t/limit_rows_examined.test +++ b/mysql-test/t/limit_rows_examined.test @@ -577,3 +577,20 @@ EXECUTE ps; drop view v; drop table t1, t2; + +--echo # +--echo # 10.1 Test +--echo # +--echo # MDEV-17729: Assertion `! is_set() || m_can_overwrite_status' +--echo # failed in Diagnostics_area::set_error_status +--echo # +set @old_mode= @@sql_mode; + +CREATE TABLE t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,k INT, c CHAR(20)); +INSERT INTO t1 (k,c) VALUES(0,'0'), (0,'0'),(0,'0'),(0,'0'),(0,'0'),(0,'0'),(0,'0'); + +SET @@sql_mode='STRICT_TRANS_TABLES'; +INSERT INTO t1 (c) SELECT k FROM t1 LIMIT ROWS EXAMINED 2; + +SET @@sql_mode=@old_mode; +DROP TABLE t1; diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 1146611ac6c..6e02b80caef 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -54,7 +54,7 @@ select * from general_log where argument like '%general_log%'; # # Check some basic queries interfering with the log tables. -# In our test we'll use a tbale with verbose comments to the short +# In our test we'll use a table with verbose comments to the short # command type names, used in the tables # @@ -475,6 +475,24 @@ drop table slow_log_new, general_log_new; use test; # +# Bug#69953 / MDEV-4851 +# Log tables should be modifable on LOG_OUTPUT != TABLE +# +# + +SET GLOBAL LOG_OUTPUT = 'FILE'; +SET GLOBAL slow_query_log = 1; +SET GLOBAL general_log = 1; + +ALTER TABLE mysql.slow_log ADD COLUMN comment_text TEXT NOT NULL; +ALTER TABLE mysql.general_log ADD COLUMN comment_text TEXT NOT NULL; + +SET GLOBAL LOG_OUTPUT = 'NONE'; +ALTER TABLE mysql.slow_log DROP COLUMN comment_text; +ALTER TABLE mysql.general_log DROP COLUMN comment_text; + + +# # Bug#27857 (Log tables supplies the wrong value for generating # AUTO_INCREMENT numbers) # diff --git a/mysql-test/t/myisam_icp_debug.result b/mysql-test/t/myisam_icp_debug.result new file mode 100644 index 00000000000..cb45a0e2274 --- /dev/null +++ b/mysql-test/t/myisam_icp_debug.result @@ -0,0 +1,32 @@ +drop table if exists t0,t1,t2; +create table t0(a int primary key); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1(a int primary key); +insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C; +create table t2 ( +kp1 int, +kp2 int, +col char(100), +key(kp1, kp2) +); +insert into t2 select a, a, a from t1; +select engine from information_schema.tables +where table_schema=database() and table_name='t2'; +engine +MyISAM +explain +select * from t2 where kp1 between 10 and 20 and kp2 +1 >100; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range kp1 kp1 5 NULL 11 Using index condition +set debug_sync='handler_index_cond_check SIGNAL at_icp_check WAIT_FOR go'; +select * from t2 where kp1 between 10 and 20 and kp2 +1 >100; +connect con1, localhost, root,,; +connection con1; +set debug_sync='now WAIT_FOR at_icp_check'; +kill query $target_id; +set debug_sync='now SIGNAL go'; +connection default; +ERROR 70100: Query execution was interrupted +set debug_sync='RESET'; +disconnect con1; +drop table t0,t1,t2; diff --git a/mysql-test/t/myisam_icp_debug.test b/mysql-test/t/myisam_icp_debug.test new file mode 100644 index 00000000000..d5b1af799fa --- /dev/null +++ b/mysql-test/t/myisam_icp_debug.test @@ -0,0 +1 @@ +--source include/icp_debug_kill.inc diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 23f3fa0b4d8..b82485dfc5c 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -2999,5 +2999,21 @@ select id from t1 where data = 'ab' order by id; drop table t1; --echo # +--echo # MDEV-5628: Assertion `! is_set()' or `!is_set() || +--echo # (m_status == DA_OK_BULK && is_bulk_op())' fails on UPDATE on a +--echo # partitioned table with subquery (MySQL:71630) +--echo # + +CREATE TABLE t1 (a INT) PARTITION BY HASH(a) PARTITIONS 2; + +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (1),(2); + +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET a = 7 WHERE a = ( SELECT b FROM t2 ) ORDER BY a LIMIT 6; + +DROP TABLE t1,t2; + +--echo # --echo # End of 10.1 tests --echo # diff --git a/scripts/convert-debug-for-diff.sh b/scripts/convert-debug-for-diff.sh index 60b328d946b..5b3ce05b815 100755 --- a/scripts/convert-debug-for-diff.sh +++ b/scripts/convert-debug-for-diff.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env perl -i +#!/usr/bin/perl -i # # This script converts all numbers that look like addresses or memory sizes, # in a debug files generated by --debug (like mysqld --debug-dbug), to #. diff --git a/sql/handler.cc b/sql/handler.cc index 0a5ed2dffbb..d2408767530 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5608,6 +5608,7 @@ extern "C" enum icp_result handler_index_cond_check(void* h_arg) THD *thd= h->table->in_use; enum icp_result res; + DEBUG_SYNC(thd, "handler_index_cond_check"); enum thd_kill_levels abort_at= h->has_transactions() ? THD_ABORT_SOFTLY : THD_ABORT_ASAP; if (thd_kill_level(thd) > abort_at) diff --git a/sql/log.cc b/sql/log.cc index c784dc1c308..54a8bd9552f 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -543,9 +543,11 @@ bool LOGGER::is_log_table_enabled(uint log_table_type) { switch (log_table_type) { case QUERY_LOG_SLOW: - return (table_log_handler != NULL) && global_system_variables.sql_log_slow; + return (table_log_handler != NULL) && global_system_variables.sql_log_slow + && (log_output_options & LOG_TABLE); case QUERY_LOG_GENERAL: - return (table_log_handler != NULL) && opt_log ; + return (table_log_handler != NULL) && opt_log + && (log_output_options & LOG_TABLE); default: DBUG_ASSERT(0); return FALSE; /* make compiler happy */ diff --git a/sql/log_event.cc b/sql/log_event.cc index 5fd977da511..097cbe8da9d 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2037,7 +2037,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, else DBUG_RETURN(NULL); #else - *error= ER(ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE); + *error= ER_THD_OR_DEFAULT(current_thd, ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE); sql_print_error("%s", *error); DBUG_RETURN(NULL); #endif diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 19a9cdad184..3b090093060 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -383,11 +383,14 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, If LIMIT ROWS EXAMINED interrupted query execution, issue a warning, continue with normal processing and produce an incomplete query result. */ + bool saved_abort_on_warning= thd->abort_on_warning; + thd->abort_on_warning= false; push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT, ER_THD(thd, ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT), thd->accessed_rows_and_keys, thd->lex->limit_rows_examined->val_uint()); + thd->abort_on_warning= saved_abort_on_warning; thd->reset_killed(); } /* Disable LIMIT ROWS EXAMINED after query execution. */ diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 2e9752eeabd..5e40cd242a4 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -417,6 +417,8 @@ int mysql_update(THD *thd, query_plan.set_no_partitions(); if (thd->lex->describe || thd->lex->analyze_stmt) goto produce_explain_and_leave; + if (thd->is_error()) + DBUG_RETURN(1); my_ok(thd); // No matching records DBUG_RETURN(0); diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index 8327318e46c..639fdbac22b 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -96,6 +96,28 @@ operator<<( return(s << ut_get_name(NULL, table_name.m_name)); } +/** @return whether a table belongs to a system database */ +static bool dict_mem_table_is_system(char *name) +{ + /* table has the following format: database/table + and some system table are of the form SYS_* */ + if (strchr(name, '/')) { + size_t table_len = strlen(name); + const char *system_db; + int i = 0; + while ((system_db = innobase_system_databases[i++]) + && (system_db != NullS)) { + size_t len = strlen(system_db); + if (table_len > len && !strncmp(name, system_db, len)) { + return true; + } + } + return false; + } else { + return true; + } +} + /**********************************************************************//** Creates a table memory object. @return own: table object */ @@ -1195,31 +1217,20 @@ operator<< (std::ostream& out, const dict_foreign_set& fk_set) return(out); } -/****************************************************************//** -Determines if a table belongs to a system database -@return */ -bool -dict_mem_table_is_system( -/*================*/ - char *name) /*!< in: table name */ +/** Check whether fulltext index gets affected by foreign +key constraint. */ +bool dict_foreign_t::affects_fulltext() const { - ut_ad(name); - - /* table has the following format: database/table - and some system table are of the form SYS_* */ - if (strchr(name, '/')) { - size_t table_len = strlen(name); - const char *system_db; - int i = 0; - while ((system_db = innobase_system_databases[i++]) - && (system_db != NullS)) { - size_t len = strlen(system_db); - if (table_len > len && !strncmp(name, system_db, len)) { - return true; - } - } - return false; - } else { - return true; - } + if (foreign_table == referenced_table || !foreign_table->fts) + return false; + + for (ulint i= 0; i < n_fields; i++) + { + const dict_col_t *col= dict_index_get_nth_col(foreign_index, i); + if (dict_table_is_fts_column(foreign_table->fts->indexes, col->ind, + col->is_virtual()) != ULINT_UNDEFINED) + return true; + } + + return false; } diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index 6396dad4aa5..be758c13d52 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2020, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -144,6 +144,8 @@ struct fts_query_t { ib_rbt_t* wildcard_words; /*!< words with wildcard */ bool multi_exist; /*!< multiple FTS_EXIST oper */ + byte visiting_sub_exp; /*!< count of nested + fts_ast_visit_sub_exp() */ st_mysql_ftparser* parser; /*!< fts plugin parser */ }; @@ -2963,6 +2965,8 @@ fts_query_get_token( return(new_ptr); } +static dberr_t fts_ast_visit_sub_exp(fts_ast_node_t*, fts_ast_callback, void*); + /*****************************************************************//** Visit every node of the AST. */ static @@ -3087,6 +3091,14 @@ fts_ast_visit_sub_exp( ut_a(node->type == FTS_AST_SUBEXP_LIST); + /* To avoid stack overflow, we limit the mutual recursion + depth between fts_ast_visit(), fts_query_visitor() and + fts_ast_visit_sub_exp(). */ + if (query->visiting_sub_exp++ > 31) { + query->error = DB_OUT_OF_MEMORY; + DBUG_RETURN(query->error); + } + cur_oper = query->oper; /* Save current result set */ @@ -3109,6 +3121,7 @@ fts_ast_visit_sub_exp( /* Reinstate parent node state */ query->multi_exist = multi_exist; query->oper = cur_oper; + query->visiting_sub_exp--; /* Merge the sub-expression result with the parent result set. */ subexpr_doc_ids = query->doc_ids; diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 21d9e763178..e8005cbc352 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -314,14 +314,6 @@ dict_mem_table_create( ulint n_v_cols, /*!< in: number of virtual columns */ ulint flags, /*!< in: table flags */ ulint flags2); /*!< in: table flags2 */ -/**********************************************************************//** -Determines if a table belongs to a system database -@return */ -UNIV_INTERN -bool -dict_mem_table_is_system( -/*==================*/ - char *name); /*!< in: table name */ /****************************************************************//** Free a table memory object. */ void @@ -1214,6 +1206,10 @@ struct dict_foreign_t{ dict_vcol_set* v_cols; /*!< set of virtual columns affected by foreign key constraint. */ + + /** Check whether the fulltext index gets affected by + foreign key constraint */ + bool affects_fulltext() const; }; std::ostream& diff --git a/storage/innobase/include/fts0ast.h b/storage/innobase/include/fts0ast.h index bad040fdcda..5799776c32d 100644 --- a/storage/innobase/include/fts0ast.h +++ b/storage/innobase/include/fts0ast.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2018, MariaDB Corporation. +Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 87f62125c03..ca04be71953 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -496,7 +496,7 @@ row_ins_cascade_calc_update_vec( n_fields_updated = 0; - bool affects_fulltext = false; + bool affects_fulltext = foreign->affects_fulltext(); if (table->fts) { doc_id_pos = dict_table_get_nth_col_pos( @@ -617,17 +617,6 @@ row_ins_cascade_calc_update_vec( padded_data, min_size); } - /* Check whether the current column has - FTS index on it */ - if (table->fts - && dict_table_is_fts_column( - table->fts->indexes, - dict_col_get_no(col), - dict_col_is_virtual(col)) - != ULINT_UNDEFINED) { - affects_fulltext = true; - } - /* If Doc ID is updated, check whether the Doc ID is valid */ if (table->fts @@ -1257,8 +1246,6 @@ row_ins_foreign_check_on_constraint( update->n_fields * sizeof *update->fields); #endif /* HAVE_valgrind_or_MSAN */ - bool affects_fulltext = false; - for (ulint i = 0; i < foreign->n_fields; i++) { upd_field_t* ufield = &update->fields[i]; ulint col_no = dict_index_get_nth_col_no( @@ -1274,19 +1261,9 @@ row_ins_foreign_check_on_constraint( ufield->orig_len = 0; ufield->exp = NULL; dfield_set_null(&ufield->new_val); - - if (!affects_fulltext - && table->fts && dict_table_is_fts_column( - table->fts->indexes, - dict_index_get_nth_col_no(index, i), - dict_col_is_virtual( - dict_index_get_nth_col(index, i))) - != ULINT_UNDEFINED) { - affects_fulltext = true; - } } - if (affects_fulltext) { + if (foreign->affects_fulltext()) { fts_trx_add_op(trx, table, doc_id, FTS_DELETE, NULL); } @@ -1300,25 +1277,9 @@ row_ins_foreign_check_on_constraint( goto nonstandard_exit_func; } } - } else if (table->fts && cascade->is_delete) { - /* DICT_FOREIGN_ON_DELETE_CASCADE case */ - bool affects_fulltext = false; - - for (ulint i = 0; i < foreign->n_fields; i++) { - if (dict_table_is_fts_column( - table->fts->indexes, - dict_index_get_nth_col_no(index, i), - dict_col_is_virtual( - dict_index_get_nth_col(index, i))) - != ULINT_UNDEFINED) { - affects_fulltext = true; - break; - } - } - - if (affects_fulltext) { - fts_trx_add_op(trx, table, doc_id, FTS_DELETE, NULL); - } + } else if (table->fts && cascade->is_delete + && foreign->affects_fulltext()) { + fts_trx_add_op(trx, table, doc_id, FTS_DELETE, NULL); } if (!node->is_delete diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index c07b42ea8d7..0451a240ffc 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -4024,7 +4024,7 @@ row_sel_try_search_shortcut_for_mysql( /*********************************************************************//** Check a pushed-down index condition. -@return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ +@return ICP_ABORTED_BY_USER, ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ static ICP_RESULT row_search_idx_cond_check( @@ -4551,10 +4551,13 @@ row_search_mvcc( switch (row_search_idx_cond_check( buf, prebuilt, rec, offsets)) { - case ICP_NO_MATCH: - case ICP_OUT_OF_RANGE: case ICP_ABORTED_BY_USER: + mtr_commit(&mtr); + err = DB_INTERRUPTED; + goto unlock_and_exit; case ICP_ERROR: + case ICP_NO_MATCH: + case ICP_OUT_OF_RANGE: goto shortcut_mismatch; case ICP_MATCH: goto shortcut_match; @@ -4582,14 +4585,11 @@ row_search_mvcc( shortcut_match: mtr.commit(); - + err = DB_SUCCESS; + unlock_and_exit: /* NOTE that we do NOT store the cursor position */ - - err = DB_SUCCESS; - rw_lock_s_unlock(latch); - goto func_exit; case SEL_EXHAUSTED: @@ -4597,13 +4597,7 @@ row_search_mvcc( mtr.commit(); err = DB_RECORD_NOT_FOUND; - - rw_lock_s_unlock(latch); - - /* NOTE that we do NOT store the cursor - position */ - - goto func_exit; + goto unlock_and_exit; case SEL_RETRY: break; @@ -5336,8 +5330,10 @@ no_gap_lock: buf, prebuilt, rec, offsets)) { case ICP_NO_MATCH: goto next_rec; - case ICP_OUT_OF_RANGE: case ICP_ABORTED_BY_USER: + err = DB_INTERRUPTED; + goto idx_cond_failed; + case ICP_OUT_OF_RANGE: case ICP_ERROR: err = DB_RECORD_NOT_FOUND; goto idx_cond_failed; @@ -5396,9 +5392,11 @@ locks_ok_del_marked: row_unlock_for_mysql(prebuilt, TRUE); } goto next_rec; + case ICP_ABORTED_BY_USER: + err = DB_INTERRUPTED; + goto idx_cond_failed; case ICP_OUT_OF_RANGE: - case ICP_ABORTED_BY_USER: - case ICP_ERROR: + case ICP_ERROR: err = DB_RECORD_NOT_FOUND; goto idx_cond_failed; case ICP_MATCH: diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc index 89b9bd9aead..82480b13827 100644 --- a/storage/xtradb/dict/dict0mem.cc +++ b/storage/xtradb/dict/dict0mem.cc @@ -853,3 +853,22 @@ operator<< (std::ostream& out, const dict_foreign_set& fk_set) return(out); } +/** Check whether fulltext index gets affected by foreign +key constraint. */ +bool dict_foreign_t::affects_fulltext() const +{ + if (foreign_table == referenced_table || !foreign_table->fts) + return false; + + for (ulint i = 0; i < n_fields; i++) + { + if (dict_table_is_fts_column( + foreign_table->fts->indexes, + dict_index_get_nth_col_no(foreign_index, i)) + != ULINT_UNDEFINED) + return true; + } + + return false; +} + diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc index 8fce8efac2b..0c51e702907 100644 --- a/storage/xtradb/fts/fts0que.cc +++ b/storage/xtradb/fts/fts0que.cc @@ -1,7 +1,7 @@ /***************************************************************************** -Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2007, 2020, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -146,6 +146,8 @@ struct fts_query_t { fts_word_freq_t */ bool multi_exist; /*!< multiple FTS_EXIST oper */ + byte visiting_sub_exp; /*!< count of nested + fts_ast_visit_sub_exp() */ }; /** For phrase matching, first we collect the documents and the positions @@ -2856,6 +2858,8 @@ fts_query_get_token( return(new_ptr); } +static dberr_t fts_ast_visit_sub_exp(fts_ast_node_t*, fts_ast_callback, void*); + /*****************************************************************//** Visit every node of the AST. */ static @@ -2945,7 +2949,7 @@ Process (nested) sub-expression, create a new result set to store the sub-expression result by processing nodes under current sub-expression list. Merge the sub-expression result with that of parent expression list. @return DB_SUCCESS if all well */ -UNIV_INTERN +static dberr_t fts_ast_visit_sub_exp( /*==================*/ @@ -2965,6 +2969,14 @@ fts_ast_visit_sub_exp( ut_a(node->type == FTS_AST_SUBEXP_LIST); + /* To avoid stack overflow, we limit the mutual recursion + depth between fts_ast_visit(), fts_query_visitor() and + fts_ast_visit_sub_exp(). */ + if (query->visiting_sub_exp++ > 31) { + query->error = DB_OUT_OF_MEMORY; + DBUG_RETURN(query->error); + } + cur_oper = query->oper; /* Save current result set */ @@ -2987,6 +2999,7 @@ fts_ast_visit_sub_exp( /* Reinstate parent node state */ query->multi_exist = multi_exist; query->oper = cur_oper; + query->visiting_sub_exp--; /* Merge the sub-expression result with the parent result set. */ subexpr_doc_ids = query->doc_ids; diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h index 1dcc3ebdd0c..f39c89d8e4b 100644 --- a/storage/xtradb/include/dict0mem.h +++ b/storage/xtradb/include/dict0mem.h @@ -864,6 +864,10 @@ struct dict_foreign_t{ does not generate new indexes implicitly */ dict_index_t* referenced_index;/*!< referenced index */ + + /** Check whether the fulltext index gets affected by + foreign key constraint */ + bool affects_fulltext() const; }; std::ostream& diff --git a/storage/xtradb/include/fts0ast.h b/storage/xtradb/include/fts0ast.h index b7d467e0082..b7870cbc7bc 100644 --- a/storage/xtradb/include/fts0ast.h +++ b/storage/xtradb/include/fts0ast.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2018, MariaDB Corporation. +Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -204,19 +204,6 @@ fts_ast_visit( operator, currently we only ignore FTS_IGNORE operator */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -/*****************************************************************//** -Process (nested) sub-expression, create a new result set to store the -sub-expression result by processing nodes under current sub-expression -list. Merge the sub-expression result with that of parent expression list. -@return DB_SUCCESS if all went well */ -UNIV_INTERN -dberr_t -fts_ast_visit_sub_exp( -/*==================*/ - fts_ast_node_t* node, /*!< in: instance to traverse*/ - fts_ast_callback visitor, /*!< in: callback */ - void* arg) /*!< in: callback arg */ - MY_ATTRIBUTE((nonnull, warn_unused_result)); /******************************************************************** Create a lex instance.*/ UNIV_INTERN diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index f7371d6b83e..c78f5bc8dc4 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -516,7 +516,7 @@ row_ins_cascade_calc_update_vec( n_fields_updated = 0; - *fts_col_affected = FALSE; + *fts_col_affected = foreign->affects_fulltext(); if (table->fts) { doc_id_pos = dict_table_get_nth_col_pos( @@ -637,16 +637,6 @@ row_ins_cascade_calc_update_vec( padded_data, min_size); } - /* Check whether the current column has - FTS index on it */ - if (table->fts - && dict_table_is_fts_column( - table->fts->indexes, - dict_col_get_no(col)) - != ULINT_UNDEFINED) { - *fts_col_affected = TRUE; - } - /* If Doc ID is updated, check whether the Doc ID is valid */ if (table->fts @@ -983,7 +973,6 @@ row_ins_foreign_check_on_constraint( upd_t* update; ulint n_to_update; dberr_t err; - ulint i; trx_t* trx; mem_heap_t* tmp_heap = NULL; doc_id_t doc_id = FTS_NULL_DOC_ID; @@ -1197,7 +1186,7 @@ row_ins_foreign_check_on_constraint( UNIV_MEM_INVALID(update->fields, update->n_fields * sizeof *update->fields); - for (i = 0; i < foreign->n_fields; i++) { + for (ulint i = 0; i < foreign->n_fields; i++) { upd_field_t* ufield = &update->fields[i]; ufield->field_no = dict_table_get_nth_col_pos( @@ -1206,32 +1195,14 @@ row_ins_foreign_check_on_constraint( ufield->orig_len = 0; ufield->exp = NULL; dfield_set_null(&ufield->new_val); - - if (table->fts && dict_table_is_fts_column( - table->fts->indexes, - dict_index_get_nth_col_no(index, i)) - != ULINT_UNDEFINED) { - fts_col_affacted = TRUE; - } } - if (fts_col_affacted) { - fts_trx_add_op(trx, table, doc_id, FTS_DELETE, NULL); - } - } else if (table->fts && cascade->is_delete) { - /* DICT_FOREIGN_ON_DELETE_CASCADE case */ - for (i = 0; i < foreign->n_fields; i++) { - if (table->fts && dict_table_is_fts_column( - table->fts->indexes, - dict_index_get_nth_col_no(index, i)) - != ULINT_UNDEFINED) { - fts_col_affacted = TRUE; - } - } - - if (fts_col_affacted) { + if (foreign->affects_fulltext()) { fts_trx_add_op(trx, table, doc_id, FTS_DELETE, NULL); } + } else if (table->fts && cascade->is_delete + && foreign->affects_fulltext()) { + fts_trx_add_op(trx, table, doc_id, FTS_DELETE, NULL); } if (!node->is_delete |