From 69b118a346a0398b5ca095e49ac95e2447cc844b Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Mon, 31 Jul 2023 14:42:02 +0300 Subject: [PATCH 1/4] Revert "MDEV-30528 Assertion in dtype_get_at_most_n_mbchars" This reverts commit add0c01bae4cd2ed435755feb1240a5dbc1c85c1 Duplicates must be avoided in FTS_DOC_ID_INDEX --- .../suite/innodb_fts/r/innodb_fts_misc.result | 23 ------------------- .../suite/innodb_fts/t/innodb_fts_misc.test | 18 --------------- storage/innobase/row/row0merge.cc | 12 ++++------ 3 files changed, 4 insertions(+), 49 deletions(-) diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result b/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result index d86d44f38de..2cc992be73a 100644 --- a/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result @@ -1393,26 +1393,3 @@ INSERT INTO t1 VALUES(repeat("this is the test case", 500)); ALTER TABLE t1 KEY_BLOCK_SIZE=4; ALTER TABLE t1 KEY_BLOCK_SIZE=0; DROP TABLE t1; -# -# MDEV-30528 Assertion in dtype_get_at_most_n_mbchars -# -create table t (f text) with system versioning character set utf8 engine=innodb; -insert into t (f) values -('mysql from tutorial dbms stands for database ...') , -('when to use mysql well after that you went through a ...'), -('where will optimizing mysql in what tutorial we will show ...'), -('1001 mysql tricks 1. never run mysqld as root. 2. ...'), -('mysql vs. yoursql in the following database comparison ...'), -('mysql security when configured properly, mysql ...'); -delete from t where f like 'mysql%'; -alter table t add fulltext (f); -select * from t where match(f) against ("use"); -f -when to use mysql well after that you went through a ... -select * from t where match(f) against ("run"); -f -1001 mysql tricks 1. never run mysqld as root. 2. ... -select * from t where match(f) against ("tutorial"); -f -where will optimizing mysql in what tutorial we will show ... -drop table t; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test b/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test index bbc4f089001..8f4902fd2de 100644 --- a/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test @@ -1341,21 +1341,3 @@ ALTER TABLE t1 KEY_BLOCK_SIZE=4; ALTER TABLE t1 KEY_BLOCK_SIZE=0; DROP TABLE t1; ---echo # ---echo # MDEV-30528 Assertion in dtype_get_at_most_n_mbchars ---echo # -create table t (f text) with system versioning character set utf8 engine=innodb; -insert into t (f) values - ('mysql from tutorial dbms stands for database ...') , - ('when to use mysql well after that you went through a ...'), - ('where will optimizing mysql in what tutorial we will show ...'), - ('1001 mysql tricks 1. never run mysqld as root. 2. ...'), - ('mysql vs. yoursql in the following database comparison ...'), - ('mysql security when configured properly, mysql ...'); -delete from t where f like 'mysql%'; -alter table t add fulltext (f); -select * from t where match(f) against ("use"); -select * from t where match(f) against ("run"); -select * from t where match(f) against ("tutorial"); -# cleanup -drop table t; diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index aa431886efe..f0aed489f22 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -502,8 +502,7 @@ row_merge_buf_add( VCOL_STORAGE vcol_storage; DBUG_ENTER("row_merge_buf_add"); - if (buf->n_tuples >= buf->max_tuples - || (history_fts && (buf->index->type & DICT_FTS))) { + if (buf->n_tuples >= buf->max_tuples) { error: n_row_added = 0; goto end; @@ -596,8 +595,7 @@ error: /* Tokenize and process data for FTS */ - if (index->type & DICT_FTS) { - ut_ad(!history_fts); + if (!history_fts && (index->type & DICT_FTS)) { fts_doc_item_t* doc_item; byte* value; void* ptr; @@ -1878,7 +1876,6 @@ row_merge_read_clustered_index( mach_write_to_8(new_sys_trx_start, trx->id); mach_write_to_8(new_sys_trx_end, TRX_ID_MAX); uint64_t n_rows = 0; - bool history_row = false; /* Scan the clustered index. */ for (;;) { @@ -1895,7 +1892,7 @@ row_merge_read_clustered_index( dtuple_t* row; row_ext_t* ext; page_cur_t* cur = btr_pcur_get_page_cur(&pcur); - bool history_fts = false; + bool history_row, history_fts = false; page_cur_move_to_next(cur); @@ -2530,8 +2527,7 @@ write_buffers: ut_ad(i == 0); break; } - } else if (!history_row - && dict_index_is_unique(buf->index)) { + } else if (dict_index_is_unique(buf->index)) { row_merge_dup_t dup = { buf->index, table, col_map, 0}; From 4da80a41f67839c68b72e5415e8f562ea42d1a01 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 31 Jul 2023 14:39:05 +0200 Subject: [PATCH 2/4] Fix double definition of CRYPTO_cleanup_all_ex_data --- mysys_ssl/openssl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mysys_ssl/openssl.c b/mysys_ssl/openssl.c index 340ba34ba78..8adaeae4069 100644 --- a/mysys_ssl/openssl.c +++ b/mysys_ssl/openssl.c @@ -15,6 +15,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include +#include #include /* From 4dd38f9f39ca8ff7adfbdbfe8cd53d15244d2fc3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 31 Jul 2023 20:36:19 +0200 Subject: [PATCH 3/4] MDEV-31800 Problem with open ranges on prefix blobs keys don't construct open ranges from prefix blob keys for < (less than) just as it's already done for > (greater than) because prefix KEY_PART doesn't create prefix Field for blobs (see open_table_from_share() near "Create a new field for the key part"), so stored_field_cmp_to_item() will compare the original field to the value not taking the prefix length into account. --- mysql-test/main/type_blob.result | 13 +++++++++++++ mysql-test/main/type_blob.test | 10 ++++++++++ sql/opt_range.cc | 19 +++++++++++++------ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/mysql-test/main/type_blob.result b/mysql-test/main/type_blob.result index 1318807542d..67186e10659 100644 --- a/mysql-test/main/type_blob.result +++ b/mysql-test/main/type_blob.result @@ -1140,5 +1140,18 @@ c d DROP TABLE t1, t2; SET @@sql_mode=@save_sql_mode; # +# MDEV-31800 Problem with open ranges on prefix blobs keys +# +create table t1 (d text not null, key a (d(6))) ; +insert into t1 values ('prefix 2' ), ('prefix 0' ); +select d from t1 where d >= 'prefix 1' and d < 'prefix 3'; +d +prefix 2 +alter table t1 drop index a; +select d from t1 where d >= 'prefix 1' and d < 'prefix 3'; +d +prefix 2 +drop table t1; +# # End of 10.4 test # diff --git a/mysql-test/main/type_blob.test b/mysql-test/main/type_blob.test index a9b044b5318..54102c7f004 100644 --- a/mysql-test/main/type_blob.test +++ b/mysql-test/main/type_blob.test @@ -756,6 +756,16 @@ select * from t2; DROP TABLE t1, t2; SET @@sql_mode=@save_sql_mode; +--echo # +--echo # MDEV-31800 Problem with open ranges on prefix blobs keys +--echo # +create table t1 (d text not null, key a (d(6))) ; +insert into t1 values ('prefix 2' ), ('prefix 0' ); +select d from t1 where d >= 'prefix 1' and d < 'prefix 3'; +alter table t1 drop index a; +select d from t1 where d >= 'prefix 1' and d < 'prefix 3'; +drop table t1; + --echo # --echo # End of 10.4 test --echo # diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 6ada4675ae6..0049be0daf4 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1947,18 +1947,25 @@ public: Use this constructor if value->save_in_field() went precisely, without any data rounding or truncation. */ - SEL_ARG_LT(const uchar *key, Field *field) + SEL_ARG_LT(const uchar *key, const KEY_PART *key_part, Field *field) :SEL_ARG_LE(key, field) - { max_flag= NEAR_MAX; } + { + // Don't use open ranges for partial key_segments + if (!(key_part->flag & HA_PART_KEY_SEG)) + max_flag= NEAR_MAX; + } /* Use this constructor if value->save_in_field() returned success, but we don't know if rounding or truncation happened (as some Field::store() do not report minor data changes). */ - SEL_ARG_LT(THD *thd, const uchar *key, Field *field, Item *value) + SEL_ARG_LT(THD *thd, const uchar *key, + const KEY_PART *key_part, Field *field, Item *value) :SEL_ARG_LE(key, field) { - if (stored_field_cmp_to_item(thd, field, value) == 0) + // Don't use open ranges for partial key_segments + if (!(key_part->flag & HA_PART_KEY_SEG) && + stored_field_cmp_to_item(thd, field, value) == 0) max_flag= NEAR_MAX; } }; @@ -9032,7 +9039,7 @@ SEL_ARG *Field::stored_field_make_mm_leaf(RANGE_OPT_PARAM *param, case SCALAR_CMP_LE: DBUG_RETURN(new (mem_root) SEL_ARG_LE(str, this)); case SCALAR_CMP_LT: - DBUG_RETURN(new (mem_root) SEL_ARG_LT(thd, str, this, value)); + DBUG_RETURN(new (mem_root) SEL_ARG_LT(thd, str, key_part, this, value)); case SCALAR_CMP_GT: DBUG_RETURN(new (mem_root) SEL_ARG_GT(thd, str, key_part, this, value)); case SCALAR_CMP_GE: @@ -9061,7 +9068,7 @@ SEL_ARG *Field::stored_field_make_mm_leaf_exact(RANGE_OPT_PARAM *param, case SCALAR_CMP_LE: DBUG_RETURN(new (param->mem_root) SEL_ARG_LE(str, this)); case SCALAR_CMP_LT: - DBUG_RETURN(new (param->mem_root) SEL_ARG_LT(str, this)); + DBUG_RETURN(new (param->mem_root) SEL_ARG_LT(str, key_part, this)); case SCALAR_CMP_GT: DBUG_RETURN(new (param->mem_root) SEL_ARG_GT(str, key_part, this)); case SCALAR_CMP_GE: From ab10a675acb8198d4c772b807b81b50f97480d28 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 31 Jul 2023 17:36:59 +0200 Subject: [PATCH 4/4] MDEV-31092 mysqldump --force doesn't ignore error as it should failed SHOW CREATE FUNCTION means we don't dump this function, but should still try to dump all other functions --- client/mysqldump.c | 6 +-- mysql-test/main/mysqldump.result | 64 ++++++++++++++++++++++++++++++++ mysql-test/main/mysqldump.test | 24 ++++++++++++ 3 files changed, 89 insertions(+), 5 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index a961071bf79..d0797c2721b 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2723,11 +2723,7 @@ static uint dump_routines_for_db(char *db) routine_type[i], routine_name); if (mysql_query_with_error_report(mysql, &routine_res, query_buff)) - { - mysql_free_result(routine_list_res); - routine_list_res= 0; - DBUG_RETURN(1); - } + continue; while ((row= mysql_fetch_row(routine_res))) { diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index 25597d46b75..8334c50080a 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -6342,6 +6342,7 @@ END utf8 utf8_general_ci latin1_swedish_ci DROP DATABASE test1; DROP DATABASE test2; SET sql_mode=@save_sql_mode; +use test; # # MDEV-4875 Can't restore a mysqldump if --add-drop-database meets general_log # @@ -6435,4 +6436,67 @@ TABLE 1 SET GLOBAL LOG_OUTPUT=DEFAULT, GLOBAL GENERAL_LOG=@save_general_log; TRUNCATE TABLE mysql.general_log; DROP DATABASE test1; +# # End of 10.3 tests +# +# +# MDEV-31092 mysqldump --force doesn't ignore error as it should +# +create function f1() returns int return 1; +create function f2() returns int return 2; +update mysql.proc set body='return no_such_var' where db='test' and name='f1'; +create event e1 on schedule every 1 year starts '2030-01-01' do select 1; +Warnings: +Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. +update mysql.event set body ='select not_a_value' where db='test' and name='e1'; +create table t1 (i int); +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +mysqldump: Couldn't execute 'SHOW CREATE FUNCTION `f1`': Undeclared variable: no_such_var (1327) +/*!50106 SET @save_time_zone= @@TIME_ZONE */ ; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8 */ ;; +/*!50003 SET character_set_results = utf8 */ ;; +/*!50003 SET collation_connection = utf8_general_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = '' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `e1` ON SCHEDULE EVERY 1 YEAR STARTS '2030-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO select not_a_value */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; +DELIMITER ; +/*!50106 SET TIME_ZONE= @save_time_zone */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `f2`() RETURNS int(11) +return 2 ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +drop function f1; +drop function f2; +drop event e1; +drop table t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test index 2720b27a18c..64a9a8e7c2e 100644 --- a/mysql-test/main/mysqldump.test +++ b/mysql-test/main/mysqldump.test @@ -2921,6 +2921,7 @@ DROP DATABASE test1; DROP DATABASE test2; SET sql_mode=@save_sql_mode; --remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql +use test; --echo # --echo # MDEV-4875 Can't restore a mysqldump if --add-drop-database meets general_log @@ -2981,4 +2982,27 @@ TRUNCATE TABLE mysql.general_log; DROP DATABASE test1; --remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql +--echo # --echo # End of 10.3 tests +--echo # + +--echo # +--echo # MDEV-31092 mysqldump --force doesn't ignore error as it should +--echo # +create function f1() returns int return 1; +create function f2() returns int return 2; +update mysql.proc set body='return no_such_var' where db='test' and name='f1'; +create event e1 on schedule every 1 year starts '2030-01-01' do select 1; +update mysql.event set body ='select not_a_value' where db='test' and name='e1'; +create table t1 (i int); +--replace_result mysqldump.exe mysqldump +--error 2 +--exec $MYSQL_DUMP --compact --events --routines --force test 2>&1 +drop function f1; +drop function f2; +drop event e1; +drop table t1; + +--echo # +--echo # End of 10.4 tests +--echo #