diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-03-07 09:05:36 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-03-07 09:05:36 +0200 |
commit | 7b97020d402ae96b1da84396c172bdfdc1bccb37 (patch) | |
tree | 6d5d2d3d74c6c5a9db9f6a6218357a070678e3b2 | |
parent | 5172f132bfc925009ec24f175c8d050d0329e3e5 (diff) | |
parent | 02da00a98ceb8f82a65ed72a74b53b6d5ae3d144 (diff) | |
download | mariadb-git-7b97020d402ae96b1da84396c172bdfdc1bccb37.tar.gz |
Merge 10.3 into 10.4
-rw-r--r-- | mysql-test/suite/federated/rpl.test | 1 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/page_reorganize.result | 7 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/page_reorganize.test | 8 | ||||
-rw-r--r-- | mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result | 29 | ||||
-rw-r--r-- | mysql-test/suite/innodb_fts/t/innodb-fts-ddl.opt | 1 | ||||
-rw-r--r-- | mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test | 25 | ||||
-rw-r--r-- | scripts/mysql_install_db.sh | 9 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 1 | ||||
-rw-r--r-- | sql/item_func.cc | 14 | ||||
-rw-r--r-- | storage/innobase/btr/btr0cur.cc | 3 | ||||
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 49 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 67 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.h | 6 | ||||
-rw-r--r-- | storage/innobase/include/fts0fts.h | 23 | ||||
-rw-r--r-- | storage/innobase/row/row0merge.cc | 16 |
15 files changed, 121 insertions, 138 deletions
diff --git a/mysql-test/suite/federated/rpl.test b/mysql-test/suite/federated/rpl.test index 6ec4bec5a1a..cc94ea8b716 100644 --- a/mysql-test/suite/federated/rpl.test +++ b/mysql-test/suite/federated/rpl.test @@ -1,3 +1,4 @@ +source have_federatedx.inc; source include/have_binlog_format_row.inc; source include/master-slave.inc; diff --git a/mysql-test/suite/innodb/r/page_reorganize.result b/mysql-test/suite/innodb/r/page_reorganize.result index 1059fc78531..20e1600bd0d 100644 --- a/mysql-test/suite/innodb/r/page_reorganize.result +++ b/mysql-test/suite/innodb/r/page_reorganize.result @@ -25,3 +25,10 @@ f1 disconnect con1; connection default; drop table t1; +# +# MDEV-27993 Assertion failed in btr_page_reorganize_low() +# +CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB; +SET DEBUG_DBUG = '+d,do_page_reorganize'; +INSERT INTO t1 VALUES(0,0); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/page_reorganize.test b/mysql-test/suite/innodb/t/page_reorganize.test index 7408353976d..c4e0160cb6d 100644 --- a/mysql-test/suite/innodb/t/page_reorganize.test +++ b/mysql-test/suite/innodb/t/page_reorganize.test @@ -53,4 +53,12 @@ connection default; drop table t1; +--echo # +--echo # MDEV-27993 Assertion failed in btr_page_reorganize_low() +--echo # +CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB; +SET DEBUG_DBUG = '+d,do_page_reorganize'; +INSERT INTO t1 VALUES(0,0); +DROP TABLE t1; + --source include/wait_until_count_sessions.inc diff --git a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result index a64086c9802..daf552cde8b 100644 --- a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result +++ b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result @@ -289,3 +289,32 @@ ENGINE=InnoDB; ALTER TABLE t1 ADD c SERIAL; DROP TABLE t1; # End of 10.3 tests +# +# MDEV-27582 Fulltext DDL decrements the FTS_DOC_ID value +# +CREATE TABLE t1 ( +f1 INT NOT NULL PRIMARY KEY, +f2 VARCHAR(64), FULLTEXT ft(f2)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +connect con1,localhost,root,,,; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; +DELETE FROM t1 WHERE f1 = 2; +ALTER TABLE t1 DROP INDEX ft; +ALTER TABLE t1 ADD FULLTEXT INDEX ft (f2); +INSERT INTO t1 VALUES (3, 'innodb fts search'); +SET GLOBAL innodb_optimize_fulltext_only=ON; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SET GLOBAL innodb_ft_aux_table = 'test/t1'; +SELECT max(DOC_ID) FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +max(DOC_ID) +3 +SELECT * FROM t1 WHERE MATCH(f2) AGAINST("+innodb +search" IN BOOLEAN MODE); +f1 f2 +3 innodb fts search +DROP TABLE t1; +disconnect con1; +SET GLOBAL innodb_optimize_fulltext_only=OFF; +SET GLOBAL innodb_ft_aux_table = default; diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.opt b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.opt index e6ae8d0fe0a..5d5cca1c6f2 100644 --- a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.opt +++ b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.opt @@ -1 +1,2 @@ --enable-plugin-innodb-sys-tables +--innodb_ft_index_table diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test index e8a7d603750..1ed164492d5 100644 --- a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test +++ b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test @@ -357,3 +357,28 @@ ALTER TABLE t1 ADD c SERIAL; DROP TABLE t1; --echo # End of 10.3 tests + +--echo # +--echo # MDEV-27582 Fulltext DDL decrements the FTS_DOC_ID value +--echo # +CREATE TABLE t1 ( + f1 INT NOT NULL PRIMARY KEY, + f2 VARCHAR(64), FULLTEXT ft(f2)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +connect(con1,localhost,root,,,); +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +connection default; +DELETE FROM t1 WHERE f1 = 2; +ALTER TABLE t1 DROP INDEX ft; +ALTER TABLE t1 ADD FULLTEXT INDEX ft (f2); +INSERT INTO t1 VALUES (3, 'innodb fts search'); +SET GLOBAL innodb_optimize_fulltext_only=ON; +OPTIMIZE TABLE t1; +SET GLOBAL innodb_ft_aux_table = 'test/t1'; +SELECT max(DOC_ID) FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SELECT * FROM t1 WHERE MATCH(f2) AGAINST("+innodb +search" IN BOOLEAN MODE); +DROP TABLE t1; +disconnect con1; +SET GLOBAL innodb_optimize_fulltext_only=OFF; +SET GLOBAL innodb_ft_aux_table = default; diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 4e61c1016ad..ef8b2414805 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -512,10 +512,11 @@ then args="$args --user=$user" fi -if test -n "$group" -then - args="$args --group=$group" -fi +#To be enabled if/when we enable --group as an option to mysqld +#if test -n "$group" +#then +# args="$args --group=$group" +#fi if test -f "$ldata/mysql/user.frm" then diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 59b487fac13..f37d83d93f4 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -703,6 +703,7 @@ then if test "$user" != "root" -o $SET_USER = 1 then USER_OPTION="--user=$user" + # To be used if/when we enable --system-group as an option to mysqld GROUP_OPTION="--group=$group" fi if test -n "$open_files" diff --git a/sql/item_func.cc b/sql/item_func.cc index d73782dd94e..e0b61e856b5 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2009, 2020, MariaDB + Copyright (c) 2009, 2022, MariaDB 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 @@ -3406,6 +3406,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, thd->alloc(f_args.arg_count*sizeof(Item_result)))) { + err_exit: free_udf(u_d); DBUG_RETURN(TRUE); } @@ -3445,7 +3446,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, func->used_tables_and_const_cache_join(item); f_args.arg_type[i]=item->result_type(); } - if (!(buffers=new (thd->mem_root) String[arg_count]) || + buffers=new (thd->mem_root) String[arg_count]; + if (!buffers || !multi_alloc_root(thd->mem_root, &f_args.args, arg_count * sizeof(char *), &f_args.lengths, arg_count * sizeof(long), @@ -3454,10 +3456,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, &f_args.attributes, arg_count * sizeof(char *), &f_args.attribute_lengths, arg_count * sizeof(long), NullS)) - { - free_udf(u_d); - DBUG_RETURN(TRUE); - } + goto err_exit; } if (func->fix_length_and_dec()) DBUG_RETURN(TRUE); @@ -3525,8 +3524,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, { my_error(ER_CANT_INITIALIZE_UDF, MYF(0), u_d->name.str, init_msg_buff); - free_udf(u_d); - DBUG_RETURN(TRUE); + goto err_exit; } func->max_length=MY_MIN(initid.max_length,MAX_BLOB_WIDTH); func->maybe_null=initid.maybe_null; diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 667f3d6bd37..abb633b51b4 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -3,7 +3,7 @@ Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2015, 2021, MariaDB Corporation. +Copyright (c) 2015, 2022, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -3565,6 +3565,7 @@ fail_err: << ib::hex(thr ? thr->graph->trx->id : 0) << ' ' << rec_printer(entry).str()); DBUG_EXECUTE_IF("do_page_reorganize", + if (n_recs) btr_page_reorganize(page_cursor, index, mtr);); /* Now, try the insert */ diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 0efaf794af2..fbd7dda3787 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -231,18 +231,6 @@ fts_add_doc_by_id( /*==============*/ fts_trx_table_t*ftt, /*!< in: FTS trx table */ doc_id_t doc_id); /*!< in: doc id */ -/******************************************************************//** -Update the last document id. This function could create a new -transaction to update the last document id. -@return DB_SUCCESS if OK */ -static -dberr_t -fts_update_sync_doc_id( -/*===================*/ - const dict_table_t* table, /*!< in: table */ - doc_id_t doc_id, /*!< in: last document id */ - trx_t* trx) /*!< in: update trx, or NULL */ - MY_ATTRIBUTE((nonnull(1))); /** Tokenize a document. @param[in,out] doc document to tokenize @@ -2541,27 +2529,6 @@ fts_get_max_cache_size( #endif /*********************************************************************//** -Update the next and last Doc ID in the CONFIG table to be the input -"doc_id" value (+ 1). We would do so after each FTS index build or -table truncate */ -void -fts_update_next_doc_id( -/*===================*/ - trx_t* trx, /*!< in/out: transaction */ - const dict_table_t* table, /*!< in: table */ - doc_id_t doc_id) /*!< in: DOC ID to set */ -{ - table->fts->cache->synced_doc_id = doc_id; - table->fts->cache->next_doc_id = doc_id + 1; - - table->fts->cache->first_doc_id = table->fts->cache->next_doc_id; - - fts_update_sync_doc_id( - table, table->fts->cache->synced_doc_id, trx); - -} - -/*********************************************************************//** Get the next available document id. @return DB_SUCCESS if OK */ dberr_t @@ -2719,17 +2686,17 @@ func_exit: return(error); } -/*********************************************************************//** -Update the last document id. This function could create a new +/** Update the last document id. This function could create a new transaction to update the last document id. -@return DB_SUCCESS if OK */ -static +@param table table to be updated +@param doc_id last document id +@param trx update trx or null +@retval DB_SUCCESS if OK */ dberr_t fts_update_sync_doc_id( -/*===================*/ - const dict_table_t* table, /*!< in: table */ - doc_id_t doc_id, /*!< in: last document id */ - trx_t* trx) /*!< in: update trx, or NULL */ + const dict_table_t* table, + doc_id_t doc_id, + trx_t* trx) { byte id[FTS_MAX_ID_LEN]; pars_info_t* info; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 07076f0660c..75ad5e55607 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2678,63 +2678,6 @@ overflow: return(~(ulonglong) 0); } -/********************************************************************//** -Reset the autoinc value in the table. -@return DB_SUCCESS if all went well else error code */ -UNIV_INTERN -dberr_t -ha_innobase::innobase_reset_autoinc( -/*================================*/ - ulonglong autoinc) /*!< in: value to store */ -{ - dberr_t error; - - error = innobase_lock_autoinc(); - - if (error == DB_SUCCESS) { - - dict_table_autoinc_initialize(m_prebuilt->table, autoinc); - m_prebuilt->table->autoinc_mutex.unlock(); - } - - return(error); -} - -/*******************************************************************//** -Reset the auto-increment counter to the given value, i.e. the next row -inserted will get the given value. This is called e.g. after TRUNCATE -is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is -returned by storage engines that don't support this operation. -@return 0 or error code */ -UNIV_INTERN -int -ha_innobase::reset_auto_increment( -/*==============================*/ - ulonglong value) /*!< in: new value for table autoinc */ -{ - DBUG_ENTER("ha_innobase::reset_auto_increment"); - - dberr_t error; - - update_thd(ha_thd()); - - error = row_lock_table_autoinc_for_mysql(m_prebuilt); - - if (error != DB_SUCCESS) { - DBUG_RETURN(convert_error_code_to_mysql( - error, m_prebuilt->table->flags, m_user_thd)); - } - - /* The next value can never be 0. */ - if (value == 0) { - value = 1; - } - - innobase_reset_autoinc(value); - - DBUG_RETURN(0); -} - /*********************************************************************//** Initializes some fields in an InnoDB transaction object. */ static @@ -9103,16 +9046,6 @@ ha_innobase::delete_row( error, m_prebuilt->table->flags, m_user_thd)); } -/** Delete all rows from the table. -@return error number or 0 */ - -int -ha_innobase::delete_all_rows() -{ - DBUG_ENTER("ha_innobase::delete_all_rows"); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); -} - /**********************************************************************//** Removes a new lock set on a row, if it was not read optimistically. This can be called after a row has been read in the processing of an UPDATE or a DELETE diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index d27ff67b64c..c522ae753a6 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2021, MariaDB Corporation. +Copyright (c) 2013, 2022, 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 @@ -105,8 +105,6 @@ public: double read_time(uint index, uint ranges, ha_rows rows) override; - int delete_all_rows() override; - int write_row(const uchar * buf) override; int update_row(const uchar * old_data, const uchar * new_data) override; @@ -239,7 +237,6 @@ public: ulonglong nb_desired_values, ulonglong* first_value, ulonglong* nb_reserved_values) override; - int reset_auto_increment(ulonglong value) override; bool get_error_message(int error, String *buf) override; @@ -449,7 +446,6 @@ protected: dberr_t innobase_lock_autoinc(); ulonglong innobase_peek_autoinc(); dberr_t innobase_set_max_autoinc(ulonglong auto_inc); - dberr_t innobase_reset_autoinc(ulonglong auto_inc); /** Resets a query execution 'template'. @see build_template() */ diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index 09f47c071da..d3cfa5b23df 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -402,17 +402,6 @@ fts_get_next_doc_id( /*================*/ const dict_table_t* table, /*!< in: table */ doc_id_t* doc_id);/*!< out: new document id */ -/*********************************************************************//** -Update the next and last Doc ID in the CONFIG table to be the input -"doc_id" value (+ 1). We would do so after each FTS index build or -table truncate */ -void -fts_update_next_doc_id( -/*===================*/ - trx_t* trx, /*!< in/out: transaction */ - const dict_table_t* table, /*!< in: table */ - doc_id_t doc_id) /*!< in: DOC ID to set */ - MY_ATTRIBUTE((nonnull(2))); /******************************************************************//** Create a new fts_doc_ids_t. @@ -964,4 +953,16 @@ bool fts_check_aux_table(const char *name, table_id_t *table_id, index_id_t *index_id); +/** Update the last document id. This function could create a new +transaction to update the last document id. +@param table table to be updated +@param doc_id last document id +@param trx update trx or null +@retval DB_SUCCESS if OK */ +dberr_t +fts_update_sync_doc_id(const dict_table_t *table, + doc_id_t doc_id, + trx_t *trx) +MY_ATTRIBUTE((nonnull(1))); + #endif /*!< fts0fts.h */ diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index a81e47edaf5..008bea1a95c 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2861,7 +2861,21 @@ wait_again: err = fts_sync_table(const_cast<dict_table_t*>(new_table)); if (err == DB_SUCCESS) { - fts_update_next_doc_id(NULL, new_table, max_doc_id); + new_table->fts->cache->synced_doc_id = max_doc_id; + + /* Update the max value as next FTS_DOC_ID */ + if (max_doc_id >= new_table->fts->cache->next_doc_id) { + new_table->fts->cache->next_doc_id = + max_doc_id + 1; + } + + new_table->fts->cache->first_doc_id = + new_table->fts->cache->next_doc_id; + + err= fts_update_sync_doc_id( + new_table, + new_table->fts->cache->synced_doc_id, + NULL); } } |