From 7bcacd767a5451e0ccf99b44950451ff9cf57019 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 13 Mar 2024 12:21:53 +0100 Subject: [PATCH 001/313] MDEV-21864 Commands start-all-slaves and stop-all-slaves are not listed in mysqladmin help Added commands to the help --- client/mysqladmin.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 05abec9fe61..4210a4f7939 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -1418,7 +1418,9 @@ static void usage(void) refresh Flush all tables and close and open logfiles\n\ shutdown Take server down\n\ status Gives a short status message from the server\n\ + start-all-slaves Start all slaves\n\ start-slave Start slave\n\ + stop-all-slaves Stop all slaves\n\ stop-slave Stop slave\n\ variables Prints variables available\n\ version Get version info from server"); From 0a6f46965af3e4d223facbc4870f6fdd182c464e Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Fri, 8 Mar 2024 22:18:44 +0100 Subject: [PATCH 002/313] MDEV-33475: --gtid-ignore-duplicate can double-apply event in case of parallel replication retry When rolling back and retrying a transaction in parallel replication, don't release the domain ownership (for --gtid-ignore-duplicates) as part of the rollback. Otherwise another master connection could grab the ownership and double-apply the transaction in parallel with the retry. Reviewed-by: Brandon Nesterenko Signed-off-by: Kristian Nielsen --- .../gtid_ignore_duplicates.result | 108 +++++++++++++++++- .../multi_source/gtid_ignore_duplicates.test | 68 ++++++++++- sql/rpl_parallel.cc | 15 ++- sql/rpl_rli.cc | 4 +- sql/rpl_rli.h | 2 +- 5 files changed, 185 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/multi_source/gtid_ignore_duplicates.result b/mysql-test/suite/multi_source/gtid_ignore_duplicates.result index e142ff8b981..88b525e21ff 100644 --- a/mysql-test/suite/multi_source/gtid_ignore_duplicates.result +++ b/mysql-test/suite/multi_source/gtid_ignore_duplicates.result @@ -174,6 +174,105 @@ a 10 11 12 +*** MDEV-33475: --gtid-ignore-duplicate can double-apply event in case of parallel replication retry +connection server_2; +STOP SLAVE "c2b"; +SET default_master_connection = "c2b"; +include/wait_for_slave_to_stop.inc +STOP SLAVE "a2b"; +SET default_master_connection = "a2b"; +include/wait_for_slave_to_stop.inc +connection server_1; +CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +BEGIN; +INSERT INTO t2 VALUES (0, 0); +INSERT INTO t2 VALUES (1, 0); +INSERT INTO t2 VALUES (2, 0); +INSERT INTO t2 VALUES (3, 0); +INSERT INTO t2 VALUES (4, 0); +INSERT INTO t2 VALUES (5, 0); +INSERT INTO t2 VALUES (6, 0); +INSERT INTO t2 VALUES (7, 0); +INSERT INTO t2 VALUES (8, 0); +INSERT INTO t2 VALUES (9, 0); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (0+10, 100); +UPDATE t2 SET b=0 WHERE a<10; +INSERT INTO t2 VALUES (0+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (1+10, 100); +UPDATE t2 SET b=1 WHERE a<10; +INSERT INTO t2 VALUES (1+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (2+10, 100); +UPDATE t2 SET b=2 WHERE a<10; +INSERT INTO t2 VALUES (2+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (3+10, 100); +UPDATE t2 SET b=3 WHERE a<10; +INSERT INTO t2 VALUES (3+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (4+10, 100); +UPDATE t2 SET b=4 WHERE a<10; +INSERT INTO t2 VALUES (4+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (5+10, 100); +UPDATE t2 SET b=5 WHERE a<10; +INSERT INTO t2 VALUES (5+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (6+10, 100); +UPDATE t2 SET b=6 WHERE a<10; +INSERT INTO t2 VALUES (6+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (7+10, 100); +UPDATE t2 SET b=7 WHERE a<10; +INSERT INTO t2 VALUES (7+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (8+10, 100); +UPDATE t2 SET b=8 WHERE a<10; +INSERT INTO t2 VALUES (8+20, 200); +COMMIT; +BEGIN; +INSERT INTO t2 VALUES (9+10, 100); +UPDATE t2 SET b=9 WHERE a<10; +INSERT INTO t2 VALUES (9+20, 200); +COMMIT; +SELECT COUNT(*), SUM(a), SUM(b) FROM t2; +COUNT(*) SUM(a) SUM(b) +30 435 3090 +include/save_master_gtid.inc +connection server_2; +SET @old_mode= @@GLOBAL.slave_parallel_mode; +SET GLOBAL slave_parallel_mode=aggressive; +SET default_master_connection = "a2b"; +START SLAVE; +include/wait_for_slave_to_start.inc +SET default_master_connection = "c2b"; +START SLAVE; +include/wait_for_slave_to_start.inc +include/sync_with_master_gtid.inc +SELECT COUNT(*), SUM(a), SUM(b) FROM t2; +COUNT(*) SUM(a) SUM(b) +30 435 3090 +connection server_3; +include/sync_with_master_gtid.inc +SELECT COUNT(*), SUM(a), SUM(b) FROM t2; +COUNT(*) SUM(a) SUM(b) +30 435 3090 +connection server_4; +include/sync_with_master_gtid.inc +SELECT COUNT(*), SUM(a), SUM(b) FROM t2; +COUNT(*) SUM(a) SUM(b) +30 435 3090 *** Test also with not using parallel replication. connection server_1; SET default_master_connection = "b2a"; @@ -474,6 +573,7 @@ Warnings: Note 1938 SLAVE 'a2b' stopped Note 1938 SLAVE 'c2b' stopped SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL slave_parallel_mode= @old_mode; SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; connection server_3; SET GLOBAL gtid_domain_id=0; @@ -491,22 +591,22 @@ Note 1938 SLAVE 'a2d' stopped SET GLOBAL slave_parallel_threads= @old_parallel; SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; connection server_1; -DROP TABLE t1; +DROP TABLE t1, t2; ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; include/reset_master_slave.inc disconnect server_1; connection server_2; -DROP TABLE t1; +DROP TABLE t1, t2; ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; include/reset_master_slave.inc disconnect server_2; connection server_3; -DROP TABLE t1; +DROP TABLE t1, t2; ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; include/reset_master_slave.inc disconnect server_3; connection server_4; -DROP TABLE t1; +DROP TABLE t1, t2; ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; include/reset_master_slave.inc disconnect server_4; diff --git a/mysql-test/suite/multi_source/gtid_ignore_duplicates.test b/mysql-test/suite/multi_source/gtid_ignore_duplicates.test index 3d2d151bd0d..cbc06920b41 100644 --- a/mysql-test/suite/multi_source/gtid_ignore_duplicates.test +++ b/mysql-test/suite/multi_source/gtid_ignore_duplicates.test @@ -173,6 +173,65 @@ SET default_master_connection = "a2b"; SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +--echo *** MDEV-33475: --gtid-ignore-duplicate can double-apply event in case of parallel replication retry + +# Create a bunch of transactions that will cause conflicts and retries. +# The bug was that the retry code was not handling the --gtid-ignore-duplicates +# option, so events could be doubly-applied. + +--connection server_2 +STOP SLAVE "c2b"; +SET default_master_connection = "c2b"; +--source include/wait_for_slave_to_stop.inc +STOP SLAVE "a2b"; +SET default_master_connection = "a2b"; +--source include/wait_for_slave_to_stop.inc + +--connection server_1 +CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +BEGIN; +--let $i= 0 +while ($i < 10) { + eval INSERT INTO t2 VALUES ($i, 0); + inc $i; +} +COMMIT; + +--let $i= 0 +while ($i < 10) { + BEGIN; + eval INSERT INTO t2 VALUES ($i+10, 100); + eval UPDATE t2 SET b=$i WHERE a<10; + eval INSERT INTO t2 VALUES ($i+20, 200); + COMMIT; + inc $i; +} + +SELECT COUNT(*), SUM(a), SUM(b) FROM t2; +--source include/save_master_gtid.inc + +--connection server_2 +SET @old_mode= @@GLOBAL.slave_parallel_mode; +SET GLOBAL slave_parallel_mode=aggressive; +SET default_master_connection = "a2b"; +START SLAVE; +--source include/wait_for_slave_to_start.inc +SET default_master_connection = "c2b"; +START SLAVE; +--source include/wait_for_slave_to_start.inc + +--source include/sync_with_master_gtid.inc +SELECT COUNT(*), SUM(a), SUM(b) FROM t2; + +--connection server_3 +--source include/sync_with_master_gtid.inc +SELECT COUNT(*), SUM(a), SUM(b) FROM t2; + +--connection server_4 +--source include/sync_with_master_gtid.inc +SELECT COUNT(*), SUM(a), SUM(b) FROM t2; + + --echo *** Test also with not using parallel replication. --connection server_1 @@ -414,6 +473,7 @@ SET GLOBAL gtid_domain_id=0; --sorted_result STOP ALL SLAVES; SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL slave_parallel_mode= @old_mode; SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; --connection server_3 @@ -431,25 +491,25 @@ SET GLOBAL slave_parallel_threads= @old_parallel; SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; --connection server_1 -DROP TABLE t1; +DROP TABLE t1, t2; ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; --source include/reset_master_slave.inc --disconnect server_1 --connection server_2 -DROP TABLE t1; +DROP TABLE t1, t2; ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; --source include/reset_master_slave.inc --disconnect server_2 --connection server_3 -DROP TABLE t1; +DROP TABLE t1, t2; ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; --source include/reset_master_slave.inc --disconnect server_3 --connection server_4 -DROP TABLE t1; +DROP TABLE t1, t2; ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; --source include/reset_master_slave.inc --disconnect server_4 diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index ac96d92eb5d..84307a40418 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -211,6 +211,13 @@ finish_event_group(rpl_parallel_thread *rpt, uint64 sub_id, signal_error_to_sql_driver_thread(thd, rgi, err); thd->wait_for_commit_ptr= NULL; + /* + Calls to check_duplicate_gtid() must match up with + record_and_update_gtid() (or release_domain_owner() in error case). This + assertion tries to catch any missing release of the domain. + */ + DBUG_ASSERT(rgi->gtid_ignore_duplicate_state != rpl_group_info::GTID_DUPLICATE_OWNER); + mysql_mutex_lock(&entry->LOCK_parallel_entry); /* We need to mark that this event group started its commit phase, in case we @@ -868,7 +875,13 @@ do_retry: }); #endif - rgi->cleanup_context(thd, 1); + /* + We are still applying the event group, even though we will roll it back + and retry it. So for --gtid-ignore-duplicates, keep ownership of the + domain during the retry so another master connection will not try to take + over and duplicate apply the same event group (MDEV-33475). + */ + rgi->cleanup_context(thd, 1, 1 /* keep_domain_owner */); wait_for_pending_deadlock_kill(thd, rgi); thd->reset_killed(); thd->clear_error(); diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 95566b2f6c7..1af38be1787 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -2248,7 +2248,7 @@ delete_or_keep_event_post_apply(rpl_group_info *rgi, } -void rpl_group_info::cleanup_context(THD *thd, bool error) +void rpl_group_info::cleanup_context(THD *thd, bool error, bool keep_domain_owner) { DBUG_ENTER("rpl_group_info::cleanup_context"); DBUG_PRINT("enter", ("error: %d", (int) error)); @@ -2298,7 +2298,7 @@ void rpl_group_info::cleanup_context(THD *thd, bool error) Ensure we always release the domain for others to process, when using --gtid-ignore-duplicates. */ - if (gtid_ignore_duplicate_state != GTID_DUPLICATE_NULL) + if (gtid_ignore_duplicate_state != GTID_DUPLICATE_NULL && !keep_domain_owner) rpl_global_gtid_slave_state->release_domain_owner(this); } diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 9fc1a384355..91628bee3c7 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -917,7 +917,7 @@ struct rpl_group_info } void clear_tables_to_lock(); - void cleanup_context(THD *, bool); + void cleanup_context(THD *, bool, bool keep_domain_owner= false); void slave_close_thread_tables(THD *); void mark_start_commit_no_lock(); void mark_start_commit(); From d7758debaee4f9f928e4fecfeea8c9df1964dce3 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 13 Mar 2024 20:07:04 +0700 Subject: [PATCH 003/313] MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed in st_select_lex::fix_prepare_information In case there is a view that queried from a stored routine or a prepared statement and this temporary table is dropped between executions of SP/PS, then it leads to hitting an assertion at the SELECT_LEX::fix_prepare_information. The fired assertion was added by the commit 85f2e4f8e8c82978bd9cc0af9bfd2b549ea04d65 (MDEV-32466: Potential memory leak on executing of create view statement). Firing of this assertion means memory leaking on execution of SP/PS. Moreover, if the added assert be commented out, different result sets can be produced by the statement SELECT * FROM the hidden table. Both hitting the assertion and different result sets have the same root cause. This cause is usage of temporary table's metadata after the table itself has been dropped. To fix the issue, reload the cache of stored routines. To do it cache of stored routines is reset at the end of execution of the function dispatch_command(). Next time any stored routine be called it will be loaded from the table mysql.proc. This happens inside the method Sp_handler::sp_cache_routine where loading of a stored routine is performed in case it missed in cache. Loading is performed unconditionally while previously it was controlled by the parameter lookup_only. By that reason the signature of the method Sroutine_hash_entry::sp_cache_routine was changed by removing unused parameter lookup_only. Clearing of sp caches affects the test main.lock_sync since it forces opening and locking the table mysql.proc but the test assumes that each statement locks its tables once during its execution. To keep this invariant the debug sync points with names "before_lock_tables_takes_lock" and "after_lock_tables_takes_lock" are not activated on handling the table mysql.proc --- mysql-test/main/ps.result | 13 ++++++++ mysql-test/main/ps.test | 12 +++++++ mysql-test/main/sp.result | 3 +- mysql-test/main/sp.test | 2 -- mysql-test/main/temp_table.result | 49 ++++++++++++++++++++++++++++ mysql-test/main/temp_table.test | 54 +++++++++++++++++++++++++++++++ sql/sp.cc | 22 ++++--------- sql/sp.h | 16 ++++----- sql/sp_cache.cc | 18 +++++++++++ sql/sql_base.cc | 18 ++++++++--- sql/sql_class.cc | 1 + sql/sql_class.h | 12 ++++++- sql/sql_parse.cc | 9 +++++- sql/sql_table.cc | 5 +++ 14 files changed, 200 insertions(+), 34 deletions(-) diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index aeed24f253b..7b5b9779624 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -5982,6 +5982,19 @@ EXECUTE stmt USING DEFAULT; # Clean up DEALLOCATE PREPARE stmt; DROP TABLE t1, t2; +# MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. in st_select_lex::fix_prepare_information +CREATE TABLE t1 AS SELECT 1 f; +PREPARE stmt FROM 'SHOW CREATE TABLE t1'; +DROP TABLE t1; +EXECUTE stmt; +ERROR 42S02: Table 'test.t1' doesn't exist +CREATE VIEW t1 AS SELECT 1; +EXECUTE stmt; +View Create View character_set_client collation_connection +t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `t1` AS select 1 AS `1` latin1 latin1_swedish_ci +# Clean up +DEALLOCATE PREPARE stmt; +DROP VIEW t1; # # End of 10.4 tests # diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 61d1513fa0b..99a479f854c 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -5416,6 +5416,18 @@ EXECUTE stmt USING DEFAULT; DEALLOCATE PREPARE stmt; DROP TABLE t1, t2; +--echo # MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. in st_select_lex::fix_prepare_information +CREATE TABLE t1 AS SELECT 1 f; +PREPARE stmt FROM 'SHOW CREATE TABLE t1'; +DROP TABLE t1; +--error ER_NO_SUCH_TABLE +EXECUTE stmt; +CREATE VIEW t1 AS SELECT 1; +EXECUTE stmt; +--echo # Clean up +DEALLOCATE PREPARE stmt; +DROP VIEW t1; + --echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 2f733107e8a..bcd9e728921 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -7184,15 +7184,14 @@ CREATE VIEW t1 AS SELECT 10 AS f1; CALL p1(1); ERROR HY000: The target table t1 of the INSERT is not insertable-into CREATE TEMPORARY TABLE t1 (f1 INT); -# t1 still refers to the view since it was inlined CALL p1(2); -ERROR HY000: The target table t1 of the INSERT is not insertable-into DROP VIEW t1; # t1 now refers to the temporary table CALL p1(3); # Check which values were inserted into the temp table. SELECT * FROM t1; f1 +2 3 DROP TEMPORARY TABLE t1; DROP PROCEDURE p1; diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index 50d9a611db9..d417bc636d4 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -8633,8 +8633,6 @@ CALL p1(1); CREATE TEMPORARY TABLE t1 (f1 INT); ---echo # t1 still refers to the view since it was inlined ---error ER_NON_INSERTABLE_TABLE CALL p1(2); DROP VIEW t1; diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result index 33ea1700474..bf5015d44d4 100644 --- a/mysql-test/main/temp_table.result +++ b/mysql-test/main/temp_table.result @@ -616,5 +616,54 @@ Tables_in_test # in 11.2 and above here should be listed above used temporary tables DROP TEMPORARY TABLE t1, t2; # +# MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. in st_select_lex::fix_prepare_information +# +CREATE VIEW v1 AS SELECT 5; +CREATE PROCEDURE sp() SELECT * FROM v1; +CREATE TEMPORARY TABLE v1 as SELECT 7; +# sp() accesses the temporary table v1 that hides the view with the same name +# Therefore expected output is the row (7) +CALL sp(); +7 +7 +DROP TEMPORARY TABLE v1; +# After the temporary table v1 has been dropped the next invocation of sp() +# accesses the view v1. So, expected output is the row (5) +CALL sp(); +5 +5 +# Clean up +DROP VIEW v1; +DROP PROCEDURE sp; +# Another use case is when a temporary table hides a view is dropped +# inside a stored routine being called. +CREATE VIEW t1 AS SELECT 1; +CREATE PROCEDURE p1() +BEGIN +DROP TEMPORARY TABLE t1; +END +| +CREATE FUNCTION f1() RETURNS INT +BEGIN +CALL p1(); +RETURN 1; +END +| +CREATE TEMPORARY TABLE t1 AS SELECT 1 AS a; +PREPARE stmt FROM 'SELECT f1()'; +EXECUTE stmt; +f1() +1 +# The temporary table t1 has been dropped on first +# execution of the prepared statement 'stmt', +# next time this statement is run it results in issuing +# the error ER_BAD_TABLE_ERROR +EXECUTE stmt; +ERROR 42S02: Unknown table 'test.t1' +# Clean up +DROP VIEW t1; +DROP FUNCTION f1; +DROP PROCEDURE p1; +# # End of 10.4 tests # diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test index e1e671f5ae9..3984b447e91 100644 --- a/mysql-test/main/temp_table.test +++ b/mysql-test/main/temp_table.test @@ -674,6 +674,60 @@ SHOW TABLES; DROP TEMPORARY TABLE t1, t2; +--echo # +--echo # MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. in st_select_lex::fix_prepare_information +--echo # +CREATE VIEW v1 AS SELECT 5; +CREATE PROCEDURE sp() SELECT * FROM v1; +CREATE TEMPORARY TABLE v1 as SELECT 7; +--echo # sp() accesses the temporary table v1 that hides the view with the same name +--echo # Therefore expected output is the row (7) +CALL sp(); +DROP TEMPORARY TABLE v1; +--echo # After the temporary table v1 has been dropped the next invocation of sp() +--echo # accesses the view v1. So, expected output is the row (5) +CALL sp(); + +--echo # Clean up +DROP VIEW v1; +DROP PROCEDURE sp; + +--echo # Another use case is when a temporary table hides a view is dropped +--echo # inside a stored routine being called. + +CREATE VIEW t1 AS SELECT 1; + +--delimiter | +CREATE PROCEDURE p1() +BEGIN + DROP TEMPORARY TABLE t1; +END +| + +CREATE FUNCTION f1() RETURNS INT +BEGIN + CALL p1(); + RETURN 1; +END +| + +--delimiter ; + +CREATE TEMPORARY TABLE t1 AS SELECT 1 AS a; +PREPARE stmt FROM 'SELECT f1()'; +EXECUTE stmt; +--echo # The temporary table t1 has been dropped on first +--echo # execution of the prepared statement 'stmt', +--echo # next time this statement is run it results in issuing +--echo # the error ER_BAD_TABLE_ERROR +--error ER_BAD_TABLE_ERROR +EXECUTE stmt; + +--echo # Clean up +DROP VIEW t1; +DROP FUNCTION f1; +DROP PROCEDURE p1; + --echo # --echo # End of 10.4 tests --echo # diff --git a/sql/sp.cc b/sql/sp.cc index d25c7353ca4..d3b128d5c99 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1907,7 +1907,7 @@ Sp_handler::sp_show_create_routine(THD *thd, DBUG_EXECUTE_IF("cache_sp_in_show_create", /* Some tests need just need a way to cache SP without other side-effects.*/ - sp_cache_routine(thd, name, false, &sp); + sp_cache_routine(thd, name, &sp); sp->show_create_routine(thd, this); DBUG_RETURN(false); ); @@ -2331,7 +2331,7 @@ Sp_handler::sp_cache_routine_reentrant(THD *thd, int ret; Parser_state *oldps= thd->m_parser_state; thd->m_parser_state= NULL; - ret= sp_cache_routine(thd, name, false, sp); + ret= sp_cache_routine(thd, name, sp); thd->m_parser_state= oldps; return ret; } @@ -2738,7 +2738,6 @@ void sp_update_stmt_used_routines(THD *thd, Query_tables_list *prelocking_ctx, */ int Sroutine_hash_entry::sp_cache_routine(THD *thd, - bool lookup_only, sp_head **sp) const { char qname_buff[NAME_LEN*2+1+1]; @@ -2751,7 +2750,7 @@ int Sroutine_hash_entry::sp_cache_routine(THD *thd, */ DBUG_ASSERT(mdl_request.ticket || this == thd->lex->sroutines_list.first); - return m_handler->sp_cache_routine(thd, &name, lookup_only, sp); + return m_handler->sp_cache_routine(thd, &name, sp); } @@ -2763,9 +2762,6 @@ int Sroutine_hash_entry::sp_cache_routine(THD *thd, @param[in] thd Thread context. @param[in] name Name of routine. - @param[in] lookup_only Only check that the routine is in the cache. - If it's not, don't try to load. If it is present, - but old, don't try to reload. @param[out] sp Pointer to sp_head object for routine, NULL if routine was not found. @@ -2776,7 +2772,6 @@ int Sroutine_hash_entry::sp_cache_routine(THD *thd, int Sp_handler::sp_cache_routine(THD *thd, const Database_qualified_name *name, - bool lookup_only, sp_head **sp) const { int ret= 0; @@ -2788,9 +2783,6 @@ int Sp_handler::sp_cache_routine(THD *thd, *sp= sp_cache_lookup(spc, name); - if (lookup_only) - DBUG_RETURN(SP_OK); - if (*sp) { sp_cache_flush_obsolete(spc, sp); @@ -2842,7 +2834,6 @@ int Sp_handler::sp_cache_routine(THD *thd, * name->m_db is a database name, e.g. "dbname" * name->m_name is a package-qualified name, e.g. "pkgname.spname" - @param lookup_only - don't load mysql.proc if not cached @param [OUT] sp - the result is returned here. @retval false - loaded or does not exists @retval true - error while loading mysql.proc @@ -2852,14 +2843,13 @@ int Sp_handler::sp_cache_package_routine(THD *thd, const LEX_CSTRING &pkgname_cstr, const Database_qualified_name *name, - bool lookup_only, sp_head **sp) const + sp_head **sp) const { DBUG_ENTER("sp_cache_package_routine"); DBUG_ASSERT(type() == TYPE_ENUM_FUNCTION || type() == TYPE_ENUM_PROCEDURE); sp_name pkgname(&name->m_db, &pkgname_cstr, false); sp_head *ph= NULL; int ret= sp_handler_package_body.sp_cache_routine(thd, &pkgname, - lookup_only, &ph); if (!ret) { @@ -2894,12 +2884,12 @@ Sp_handler::sp_cache_package_routine(THD *thd, int Sp_handler::sp_cache_package_routine(THD *thd, const Database_qualified_name *name, - bool lookup_only, sp_head **sp) const + sp_head **sp) const { DBUG_ENTER("Sp_handler::sp_cache_package_routine"); Prefix_name_buf pkgname(thd, name->m_name); DBUG_ASSERT(pkgname.length); - DBUG_RETURN(sp_cache_package_routine(thd, pkgname, name, lookup_only, sp)); + DBUG_RETURN(sp_cache_package_routine(thd, pkgname, name, sp)); } diff --git a/sql/sp.h b/sql/sp.h index 56007a2fa72..75347464c8a 100644 --- a/sql/sp.h +++ b/sql/sp.h @@ -101,10 +101,10 @@ protected: int sp_cache_package_routine(THD *thd, const LEX_CSTRING &pkgname_cstr, const Database_qualified_name *name, - bool lookup_only, sp_head **sp) const; + sp_head **sp) const; int sp_cache_package_routine(THD *thd, const Database_qualified_name *name, - bool lookup_only, sp_head **sp) const; + sp_head **sp) const; sp_head *sp_find_package_routine(THD *thd, const LEX_CSTRING pkgname_str, const Database_qualified_name *name, @@ -202,7 +202,7 @@ public: const Database_qualified_name *name, bool cache_only) const; virtual int sp_cache_routine(THD *thd, const Database_qualified_name *name, - bool lookup_only, sp_head **sp) const; + sp_head **sp) const; int sp_cache_routine_reentrant(THD *thd, const Database_qualified_name *nm, @@ -283,9 +283,9 @@ class Sp_handler_package_procedure: public Sp_handler_procedure { public: int sp_cache_routine(THD *thd, const Database_qualified_name *name, - bool lookup_only, sp_head **sp) const + sp_head **sp) const { - return sp_cache_package_routine(thd, name, lookup_only, sp); + return sp_cache_package_routine(thd, name, sp); } sp_head *sp_find_routine(THD *thd, const Database_qualified_name *name, @@ -332,9 +332,9 @@ class Sp_handler_package_function: public Sp_handler_function { public: int sp_cache_routine(THD *thd, const Database_qualified_name *name, - bool lookup_only, sp_head **sp) const + sp_head **sp) const { - return sp_cache_package_routine(thd, name, lookup_only, sp); + return sp_cache_package_routine(thd, name, sp); } sp_head *sp_find_routine(THD *thd, const Database_qualified_name *name, @@ -632,7 +632,7 @@ public: const Sp_handler *m_handler; - int sp_cache_routine(THD *thd, bool lookup_only, sp_head **sp) const; + int sp_cache_routine(THD *thd, sp_head **sp) const; }; diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index cfdfea9ae0a..c1b9815d26e 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -78,6 +78,8 @@ private: /* All routines in this cache */ HASH m_hashtable; +public: + void clear(); }; // class sp_cache #ifdef HAVE_PSI_INTERFACE @@ -313,6 +315,10 @@ sp_cache::cleanup() my_hash_free(&m_hashtable); } +void sp_cache::clear() +{ + my_hash_reset(&m_hashtable); +} void Sp_caches::sp_caches_clear() { @@ -321,3 +327,15 @@ void Sp_caches::sp_caches_clear() sp_cache_clear(&sp_package_spec_cache); sp_cache_clear(&sp_package_body_cache); } + +void Sp_caches::sp_caches_empty() +{ + if (sp_proc_cache) + sp_proc_cache->clear(); + if (sp_func_cache) + sp_func_cache->clear(); + if (sp_package_spec_cache) + sp_package_spec_cache->clear(); + if (sp_package_body_cache) + sp_package_body_cache->clear(); +} diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e6a7110d45b..cffe1085302 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3563,7 +3563,7 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx, DBUG_RETURN(TRUE); /* Ensures the routine is up-to-date and cached, if exists. */ - if (rt->sp_cache_routine(thd, has_prelocking_list, &sp)) + if (rt->sp_cache_routine(thd, &sp)) DBUG_RETURN(TRUE); /* Remember the version of the routine in the parse tree. */ @@ -3604,7 +3604,7 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx, Validating routine version is unnecessary, since CALL does not affect the prepared statement prelocked list. */ - if (rt->sp_cache_routine(thd, false, &sp)) + if (rt->sp_cache_routine(thd, &sp)) DBUG_RETURN(TRUE); } } @@ -5566,13 +5566,23 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, uint flags) *(ptr++)= table->table; } - DEBUG_SYNC(thd, "before_lock_tables_takes_lock"); +#ifdef ENABLED_DEBUG_SYNC + if (!tables || + !(strcmp(tables->db.str, "mysql") == 0 && + strcmp(tables->table_name.str, "proc") == 0)) + DEBUG_SYNC(thd, "before_lock_tables_takes_lock"); +#endif if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start), flags))) DBUG_RETURN(TRUE); - DEBUG_SYNC(thd, "after_lock_tables_takes_lock"); +#ifdef ENABLED_DEBUG_SYNC + if (!tables || + !(strcmp(tables->db.str, "mysql") == 0 && + strcmp(tables->table_name.str, "proc") == 0)) + DEBUG_SYNC(thd, "after_lock_tables_takes_lock"); +#endif if (thd->lex->requires_prelocking() && thd->lex->sql_command != SQLCOM_LOCK_TABLES) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 179e2a1a9a5..4f7759716dc 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -848,6 +848,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) prepare_derived_at_open= FALSE; create_tmp_table_for_derived= FALSE; save_prep_leaf_list= FALSE; + reset_sp_cache= false; org_charset= 0; /* Restore THR_THD */ set_current_thd(old_THR_THD); diff --git a/sql/sql_class.h b/sql/sql_class.h index e849b21b95b..a6c56a6e023 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1,5 +1,4 @@ /* - Copyright (c) 2000, 2016, Oracle and/or its affiliates. Copyright (c) 2009, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify @@ -2268,6 +2267,11 @@ public: 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(); }; @@ -2569,6 +2573,12 @@ public: bool save_prep_leaf_list; + /** + The data member reset_sp_cache is to signal that content of sp_cache + must be reset (all items be removed from it). + */ + bool reset_sp_cache; + /* container for handler's private per-connection data */ Ha_data ha_data[MAX_HA]; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7ca63b06c6b..68e5cbc8ca3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2402,6 +2402,7 @@ dispatch_end: { WSREP_DEBUG("THD is killed at dispatch_end"); } + wsrep_after_command_before_result(thd); if (wsrep_current_error(thd) && !wsrep_command_no_result(command)) { @@ -2429,6 +2430,12 @@ dispatch_end: #endif /* WITH_WSREP */ + if (thd->reset_sp_cache) + { + thd->sp_caches_empty(); + thd->reset_sp_cache= false; + } + if (do_end_of_statement) { DBUG_ASSERT(thd->derived_tables == NULL && @@ -6071,7 +6078,7 @@ mysql_execute_command(THD *thd) if (sph->sp_resolve_package_routine(thd, thd->lex->sphead, lex->spname, &sph, &pkgname)) return true; - if (sph->sp_cache_routine(thd, lex->spname, false, &sp)) + if (sph->sp_cache_routine(thd, lex->spname, &sp)) goto error; if (!sp || sp->show_routine_code(thd)) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4a4d6f9cca2..d6ccd03cd42 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2393,6 +2393,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, goto err; } table->table= 0; + thd->reset_sp_cache= true; } if ((drop_temporary && if_exists) || !real_table) @@ -2629,8 +2630,11 @@ log_query: } DBUG_PRINT("table", ("table: %p s: %p", table->table, table->table ? table->table->s : NULL)); + if (is_temporary_table(table)) + thd->reset_sp_cache= true; } DEBUG_SYNC(thd, "rm_table_no_locks_before_binlog"); + thd->thread_specific_used= TRUE; error= 0; err: @@ -5236,6 +5240,7 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db, if (is_trans != NULL) *is_trans= table->file->has_transactions(); + thd->reset_sp_cache= true; thd->thread_specific_used= TRUE; create_info->table= table; // Store pointer to table } From ae063e4ff58eab76f8ca7b09611f4cac0683f55b Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 1 Mar 2024 11:21:50 +0200 Subject: [PATCH 004/313] Fixed random failure in main.kill_processlist-6619 The problem was that SHOW PROCESSLIST was done before the command of the default connection was cleared. Reviewer: Sergei Golubchik --- mysql-test/main/kill_processlist-6619.result | 6 ++++++ mysql-test/main/kill_processlist-6619.test | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/mysql-test/main/kill_processlist-6619.result b/mysql-test/main/kill_processlist-6619.result index 7dd42790cc7..25831a1f63b 100644 --- a/mysql-test/main/kill_processlist-6619.result +++ b/mysql-test/main/kill_processlist-6619.result @@ -1,4 +1,8 @@ +SET DEBUG_SYNC='dispatch_command_end SIGNAL ready WAIT_FOR go'; +select 1; connect con1,localhost,root,,; +SET DEBUG_SYNC='now wait_for ready'; +SET DEBUG_SYNC='now signal go'; SHOW PROCESSLIST; Id User Host db Command Time State Info Progress # root # test Sleep # # NULL 0.000 @@ -6,6 +10,8 @@ Id User Host db Command Time State Info Progress SET DEBUG_SYNC='before_execute_sql_command SIGNAL ready WAIT_FOR go'; SHOW PROCESSLIST; connection default; +1 +1 SET DEBUG_SYNC='now WAIT_FOR ready'; KILL QUERY con_id; SET DEBUG_SYNC='now SIGNAL go'; diff --git a/mysql-test/main/kill_processlist-6619.test b/mysql-test/main/kill_processlist-6619.test index c272e68a877..7330c79acd8 100644 --- a/mysql-test/main/kill_processlist-6619.test +++ b/mysql-test/main/kill_processlist-6619.test @@ -4,7 +4,14 @@ --source include/not_embedded.inc --source include/have_debug_sync.inc +# This is to ensure that the following SHOW PROCESSLIST does not show the query +SET DEBUG_SYNC='dispatch_command_end SIGNAL ready WAIT_FOR go'; +--send select 1 + --connect (con1,localhost,root,,) +SET DEBUG_SYNC='now wait_for ready'; +SET DEBUG_SYNC='now signal go'; + --let $con_id = `SELECT CONNECTION_ID()` --replace_result Execute Query --replace_column 1 # 3 # 6 # 7 # @@ -12,6 +19,8 @@ SHOW PROCESSLIST; SET DEBUG_SYNC='before_execute_sql_command SIGNAL ready WAIT_FOR go'; send SHOW PROCESSLIST; --connection default +--reap + # We must wait for the SHOW PROCESSLIST query to have started before sending # the kill. Otherwise, the KILL may be lost since it is reset at the start of # query execution. From ef7abc881c770e7ee3f8c9611566697915a18c69 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Thu, 14 Mar 2024 22:48:12 +0100 Subject: [PATCH 005/313] MDEV-10793: MDEV-33292: main.kill_processlist-6619 fails sporadically in buildbot There were several races in the main.kill_processlist-6619 testcase: - Lingering connections from a previous test case could be visible in SHOW PROCESSLIST and cause .result diff. - A sync point "dispatch_command_end" was ineffective, as it was consumed at the end of the SET DEBUG command itself. - The signal from sync point "before_execute_sql_command" could override an earlier signal, causing DEBUG_SYNC timeout and test failure. - The final SHOW PROCESSLIST could occasionally see a connection in state "Busy" instead of the expected "Sleep". Signed-off-by: Kristian Nielsen --- mysql-test/main/kill_processlist-6619.result | 11 ++++++-- mysql-test/main/kill_processlist-6619.test | 29 +++++++++++++++++--- sql/sql_parse.cc | 1 + 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/mysql-test/main/kill_processlist-6619.result b/mysql-test/main/kill_processlist-6619.result index 25831a1f63b..d93404e2e33 100644 --- a/mysql-test/main/kill_processlist-6619.result +++ b/mysql-test/main/kill_processlist-6619.result @@ -1,8 +1,15 @@ -SET DEBUG_SYNC='dispatch_command_end SIGNAL ready WAIT_FOR go'; -select 1; +SET DEBUG_SYNC='dispatch_command_end2 SIGNAL ready EXECUTE 3'; connect con1,localhost,root,,; SET DEBUG_SYNC='now wait_for ready'; +connection default; +SET DEBUG_SYNC='dispatch_command_end WAIT_FOR go EXECUTE 2'; +select 1; +connection con1; SET DEBUG_SYNC='now signal go'; +SET DEBUG_SYNC='now wait_for ready'; +SET DEBUG_SYNC='now signal go'; +SET DEBUG_SYNC='now wait_for ready'; +SET DEBUG_SYNC='RESET'; SHOW PROCESSLIST; Id User Host db Command Time State Info Progress # root # test Sleep # # NULL 0.000 diff --git a/mysql-test/main/kill_processlist-6619.test b/mysql-test/main/kill_processlist-6619.test index 7330c79acd8..9d523b2264b 100644 --- a/mysql-test/main/kill_processlist-6619.test +++ b/mysql-test/main/kill_processlist-6619.test @@ -4,13 +4,34 @@ --source include/not_embedded.inc --source include/have_debug_sync.inc -# This is to ensure that the following SHOW PROCESSLIST does not show the query -SET DEBUG_SYNC='dispatch_command_end SIGNAL ready WAIT_FOR go'; ---send select 1 +# Ensure no lingering connections from an earlier test run, which can very +# rarely still be visible in SHOW PROCESSLIST here. +--let $wait_condition= SELECT COUNT(*) = 1 from information_schema.processlist +--source include/wait_condition.inc +# This is to ensure that the following SHOW PROCESSLIST does not show the query +# +# The use of DEBUG_SYNC here is quite tricky, and there were several bugs in +# this test case before. The dispatch_command_end* sync points will trigger at +# the end of the statement that sets them, so we need to use EXECUTE 2/3 to +# make them trigger also during the "select 1" statement. And we need to use +# two separate sync points so that we can wait first and signal after; +# otherwise the last wait from dispatch_command_end may time out as its signal +# gets overridden from the later sync point "before_execute_sql_command". +# +SET DEBUG_SYNC='dispatch_command_end2 SIGNAL ready EXECUTE 3'; --connect (con1,localhost,root,,) SET DEBUG_SYNC='now wait_for ready'; +--connection default +SET DEBUG_SYNC='dispatch_command_end WAIT_FOR go EXECUTE 2'; +--send select 1 + +--connection con1 SET DEBUG_SYNC='now signal go'; +SET DEBUG_SYNC='now wait_for ready'; +SET DEBUG_SYNC='now signal go'; +SET DEBUG_SYNC='now wait_for ready'; +SET DEBUG_SYNC='RESET'; --let $con_id = `SELECT CONNECTION_ID()` --replace_result Execute Query @@ -36,7 +57,7 @@ SET DEBUG_SYNC='reset'; # Wait until default connection has reset query string let $wait_condition= SELECT COUNT(*) = 1 from information_schema.processlist - WHERE info is NULL; + WHERE Command = "Sleep" AND info is NULL; --source include/wait_condition.inc --replace_result Execute Query diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 68e5cbc8ca3..4d52e515710 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2504,6 +2504,7 @@ dispatch_end: MYSQL_COMMAND_DONE(res); } DEBUG_SYNC(thd,"dispatch_command_end"); + DEBUG_SYNC(thd,"dispatch_command_end2"); /* Check that some variables are reset properly */ DBUG_ASSERT(thd->abort_on_warning == 0); From f5df4482e0d6efa619a9cf61cf8ee68a030eb435 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 15 Mar 2024 13:32:22 +0530 Subject: [PATCH 006/313] MDEV-33214 Table is getting rebuild with ALTER TABLE ADD COLUMN Problem: ====== - InnoDB fail to do instant operation while adding the variable length column. Problem is that InnoDB wrongly assumes that variable character length can never part of externally stored page. Solution: ======== instant_alter_column_possible(): Variable length character field can be stored as externally stored page. --- .../innodb/r/instant_alter_extend.result | Bin 9115 -> 9503 bytes .../suite/innodb/t/instant_alter_extend.test | 13 +++++++++++++ storage/innobase/handler/handler0alter.cc | 6 +----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_extend.result b/mysql-test/suite/innodb/r/instant_alter_extend.result index 33a5f57c7b64609b71ec4960780c7a545e240e38..c22043eceb16df8e6475296e3873f461c247961e 100644 GIT binary patch delta 399 zcmZvY!D_-l5QdM1eTsn`l0aIrQK1k#tjSbU)}*Yf^d`~l+JLNJR(kY7JoFX%h}}qQ zd+6L|`1twezf3=#KQG?dBOc6iT-^@_2_1s0H+uzb2RmhLYj$u{n^U`Q;JvkP4*eO% zB?^#i!Vy@WLss$Syd)kubqcKNY)UeLOyW0VX`m?-rHnu)uwo*cF%i)C9EO19v?y_0 z7<0%ckmD0uatS@KKsi2H{n*EI7j|9NJ7v_d-mkZ9N{VuULiWKGSn7iL5*GoD{CczX z!zf51zfsx`Q}Wl?k-c=F2j`p1D30UM*$r=(Bo5ty@o6OrIh&7L)7jd%&;E(hBary& hzWc?Unq;L+NiM3FTMelz5lsUJ4K#ij-d)S;$QNEFZCC&R delta 7 OcmbR5HQRl|Y-Ioqr~^6x diff --git a/mysql-test/suite/innodb/t/instant_alter_extend.test b/mysql-test/suite/innodb/t/instant_alter_extend.test index 7258ba6d238..636527e598c 100644 --- a/mysql-test/suite/innodb/t/instant_alter_extend.test +++ b/mysql-test/suite/innodb/t/instant_alter_extend.test @@ -256,3 +256,16 @@ select * from t1; check table t1; drop database best; + +--echo # +--echo # MDEV-33214 Table is getting rebuild with +--echo # ALTER TABLE ADD COLUMN +--echo # +use test; +CREATE TABLE t1(f1 INT, f2 VARCHAR(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; +INSERT INTO t1 VALUES(1,'abc'),(2,'def'); +ALTER TABLE t1 ADD (f3 VARCHAR(5000), f4 VARCHAR(20)), ALGORITHM=instant; +ALTER TABLE t1 ADD f5 TEXT, ALGORITHM=INSTANT; +DROP TABLE t1; + +--echo # End of 10.4 tests diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 400828b41df..b5e1f31df28 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1581,11 +1581,9 @@ instant_alter_column_possible( ut_ad(!is_null || nullable); n_nullable += nullable; n_add++; - uint l; + uint l = (*af)->pack_length(); switch ((*af)->type()) { case MYSQL_TYPE_VARCHAR: - l = reinterpret_cast - (*af)->get_length(); variable_length: if (l >= min_local_len) { max_size += blob_prefix @@ -1599,7 +1597,6 @@ instant_alter_column_possible( if (!is_null) { min_size += l; } - l = (*af)->pack_length(); max_size += l; lenlen += l > 255 ? 2 : 1; } @@ -1613,7 +1610,6 @@ instant_alter_column_possible( ((*af))->get_length(); goto variable_length; default: - l = (*af)->pack_length(); if (l > 255 && ib_table.not_redundant()) { goto variable_length; } From d912a6369c6f7f8ba233ac88436d59f6e420c368 Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Thu, 14 Mar 2024 18:59:47 +0530 Subject: [PATCH 007/313] MDEV-31154 Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column MDEV-33558 Fatal error InnoDB: Clustered record field for column x not found This is issue is about row ID filtering used with index on virtual column(s). We hit debug assert and crash while building the record template in Innodb. The primary reason is that we try to force the code path to use the ICP path. With ICP, we don't support index with virtual column and we validate it while index condition is pushed. Simplify the code for building template to handle both ICP and Row ID filtering by skipping virtual columns. --- mysql-test/main/rowid_filter_innodb.result | 99 ++++++++++++++++++++++ mysql-test/main/rowid_filter_innodb.test | 75 ++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 83 +++++++++++------- 3 files changed, 228 insertions(+), 29 deletions(-) diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index 6248932d666..fcdcac56582 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -3769,4 +3769,103 @@ Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where !<`test`.`t1`.`c1`,`test`.`t1`.`pk`>((`test`.`t1`.`c1`,(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t1` `a1` where `test`.`t2`.`i1` = `test`.`t1`.`pk` and `test`.`t2`.`i1` between 3 and 5 and trigcond((`test`.`t1`.`c1`) = `test`.`t2`.`c1`)))) DROP TABLE t1,t2; +# +# MDEV-31154: Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column +# +# Test with auto generated Primary Key +# +SET @save_optimizer_switch= @@optimizer_switch; +SET optimizer_switch='rowid_filter=on'; +CREATE TABLE t0(a int); +INSERT INTO t0 SELECT seq FROM seq_1_to_20; +ANALYZE TABLE t0 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t0 analyze status Engine-independent statistics collected +test.t0 analyze status OK +CREATE TABLE t1 ( +a int, +b int as (a * 2) VIRTUAL, +f char(200), /* Filler */ +key (b), +key (a) +) engine=innodb; +INSERT INTO t1 (a, f) SELECT seq, seq FROM seq_1_to_1000; +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 +# Test for type 'ref|filter' +EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 ref|filter b,a b|a 5|5 test.t0.a 1 (2%) Using where; Using rowid filter +SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20; +count(*) +10 +EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 ref|filter b,a b|a 5|5 test.t0.a 1 (2%) Using where; Using rowid filter +SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE; +count(*) +10 +# Test for type 'range|filter' +EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range|filter b,a b|a 5|5 NULL 49 (10%) Using where; Using rowid filter +SELECT count(*) FROM t1 WHERE a<100 and b <100; +count(*) +49 +EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range|filter b,a b|a 5|5 NULL 49 (10%) Using where; Using rowid filter +SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE; +count(*) +49 +# Test with Primary Key +# +DROP TABLE t1; +CREATE TABLE t1 ( +p int PRIMARY KEY AUTO_INCREMENT, +a int, +b int as (a * 2) VIRTUAL, +f char(200), /* Filler */ +key (b), +key (a) +) engine=innodb; +INSERT INTO t1 (a, f) SELECT seq, seq FROM seq_1_to_1000; +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 +# Test for type 'ref|filter' +EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 ref|filter b,a b|a 5|5 test.t0.a 1 (2%) Using where; Using rowid filter +SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20; +count(*) +10 +EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where +1 SIMPLE t1 ref|filter b,a b|a 5|5 test.t0.a 1 (2%) Using where; Using rowid filter +SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE; +count(*) +10 +# Test for type 'range|filter' +EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range|filter b,a b|a 5|5 NULL 49 (10%) Using where; Using rowid filter +SELECT count(*) FROM t1 WHERE a<100 and b <100; +count(*) +49 +EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range|filter b,a b|a 5|5 NULL 49 (10%) Using where; Using rowid filter +SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE; +count(*) +49 +SET optimizer_switch=@save_optimizer_switch; +DROP TABLE t0, t1; # End of 10.4 tests diff --git a/mysql-test/main/rowid_filter_innodb.test b/mysql-test/main/rowid_filter_innodb.test index d5f3e4d4a6b..9321f706cb6 100644 --- a/mysql-test/main/rowid_filter_innodb.test +++ b/mysql-test/main/rowid_filter_innodb.test @@ -1,6 +1,8 @@ --source include/no_valgrind_without_big.inc --source include/have_innodb.inc --source include/have_debug.inc +--source include/have_sequence.inc +--source include/innodb_stable_estimates.inc SET SESSION STORAGE_ENGINE='InnoDB'; @@ -677,4 +679,77 @@ eval EXPLAIN EXTENDED $q; DROP TABLE t1,t2; +--echo # +--echo # MDEV-31154: Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column +--echo # + +--echo # Test with auto generated Primary Key +--echo # + +SET @save_optimizer_switch= @@optimizer_switch; +SET optimizer_switch='rowid_filter=on'; + +CREATE TABLE t0(a int); +INSERT INTO t0 SELECT seq FROM seq_1_to_20; +ANALYZE TABLE t0 PERSISTENT FOR ALL; + +CREATE TABLE t1 ( + a int, + b int as (a * 2) VIRTUAL, + f char(200), /* Filler */ + key (b), + key (a) +) engine=innodb; + +INSERT INTO t1 (a, f) SELECT seq, seq FROM seq_1_to_1000; +ANALYZE TABLE t1 PERSISTENT FOR ALL; + +--echo # Test for type 'ref|filter' +EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20; +SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20; + +EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE; +SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE; + +--echo # Test for type 'range|filter' +EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100; +SELECT count(*) FROM t1 WHERE a<100 and b <100; + +EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE; +SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE; + +--echo # Test with Primary Key +--echo # + +DROP TABLE t1; +CREATE TABLE t1 ( + p int PRIMARY KEY AUTO_INCREMENT, + a int, + b int as (a * 2) VIRTUAL, + f char(200), /* Filler */ + key (b), + key (a) +) engine=innodb; + +INSERT INTO t1 (a, f) SELECT seq, seq FROM seq_1_to_1000; +ANALYZE TABLE t1 PERSISTENT FOR ALL; + +--echo # Test for type 'ref|filter' +EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20; +SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20; + +EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE; +SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE; + +--echo # Test for type 'range|filter' +EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100; +SELECT count(*) FROM t1 WHERE a<100 and b <100; + +EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE; +SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE; + +SET optimizer_switch=@save_optimizer_switch; + +DROP TABLE t0, t1; + --echo # End of 10.4 tests diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 62fe6bda283..67bec7c031a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7730,26 +7730,55 @@ ha_innobase::build_template( ulint num_v = 0; - if (active_index != MAX_KEY - && active_index == pushed_idx_cond_keyno) { - m_prebuilt->idx_cond = this; - goto icp; - } else if (pushed_rowid_filter && rowid_filter_is_active) { -icp: - /* Push down an index condition or an end_range check. */ + /* MDEV-31154: For pushed down index condition we don't support virtual + column and idx_cond_push() does check for it. For row ID filtering we + don't need such restrictions but we get into trouble trying to use the + ICP path. + + 1. It should be fine to follow no_icp path if primary key is generated. + However, with user specified primary key(PK), the row is identified by + the PK and those columns need to be converted to mysql format in + row_search_idx_cond_check before doing the comparison. Since secondary + indexes always have PK appended in innodb, it works with current ICP + handling code when fetch_primary_key_cols is set to TRUE. + + 2. Although ICP comparison and Row ID comparison works on different + columns the current ICP code can be shared by both. + + 3. In most cases, it works today by jumping to goto no_icp when we + encounter a virtual column. This is hackish and already have some + issues as it cannot handle PK and all states are not reset properly, + for example, idx_cond_n_cols is not reset. + + 4. We already encountered MDEV-28747 m_prebuilt->idx_cond was being set. + + Neither ICP nor row ID comparison needs virtual columns and the code is + simplified to handle both. It should handle the issues. */ + + const bool pushed_down = active_index != MAX_KEY + && active_index == pushed_idx_cond_keyno; + + m_prebuilt->idx_cond = pushed_down ? this : nullptr; + + if (m_prebuilt->idx_cond || m_prebuilt->pk_filter) { + /* Push down an index condition, end_range check or row ID + filter */ for (ulint i = 0; i < n_fields; i++) { const Field* field = table->field[i]; const bool is_v = !field->stored_in_db(); - if (is_v && skip_virtual) { - num_v++; - continue; - } + bool index_contains = index->contains_col_or_prefix( is_v ? num_v : i - num_v, is_v); - if (is_v && index_contains) { - m_prebuilt->n_template = 0; - num_v = 0; - goto no_icp; + + if (is_v) { + if (index_contains) { + /* We want to ensure that ICP is not + used with virtual columns. */ + ut_ad(!pushed_down); + m_prebuilt->idx_cond = nullptr; + } + num_v++; + continue; } /* Test if an end_range or an index condition @@ -7769,7 +7798,7 @@ icp: which would be acceptable if end_range==NULL. */ if (build_template_needs_field_in_icp( index, m_prebuilt, index_contains, - is_v ? num_v : i - num_v, is_v)) { + i - num_v, false)) { if (!whole_row) { field = build_template_needs_field( index_contains, @@ -7778,15 +7807,10 @@ icp: fetch_primary_key_cols, index, table, i, num_v); if (!field) { - if (is_v) { - num_v++; - } continue; } } - ut_ad(!is_v); - mysql_row_templ_t* templ= build_template_field( m_prebuilt, clust_index, index, table, field, i - num_v, 0); @@ -7863,15 +7887,16 @@ icp: */ } - if (is_v) { - num_v++; - } } - ut_ad(m_prebuilt->idx_cond_n_cols > 0); - ut_ad(m_prebuilt->idx_cond_n_cols == m_prebuilt->n_template); - num_v = 0; + ut_ad(m_prebuilt->idx_cond_n_cols == m_prebuilt->n_template); + if (m_prebuilt->idx_cond_n_cols == 0) { + /* No columns to push down. It is safe to jump to np ICP + path. */ + m_prebuilt->idx_cond = nullptr; + goto no_icp; + } /* Include the fields that are not needed in index condition pushdown. */ @@ -7886,7 +7911,7 @@ icp: bool index_contains = index->contains_col_or_prefix( is_v ? num_v : i - num_v, is_v); - if (!build_template_needs_field_in_icp( + if (is_v || !build_template_needs_field_in_icp( index, m_prebuilt, index_contains, is_v ? num_v : i - num_v, is_v)) { /* Not needed in ICP */ @@ -7919,7 +7944,7 @@ icp: } else { no_icp: /* No index condition pushdown */ - m_prebuilt->idx_cond = NULL; + ut_ad(!m_prebuilt->idx_cond); ut_ad(num_v == 0); for (ulint i = 0; i < n_fields; i++) { From 5abf0fea519bbb11ca267e6b70bc804c6218e349 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 26 Jan 2024 14:37:26 +0100 Subject: [PATCH 008/313] mtr - synchronize output between different threads on Windows. An attempt to fix lost output sometimes seen on buildbot. --- mysql-test/lib/mtr_report.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index 97c48c19112..0c3c45f3b18 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -87,12 +87,16 @@ sub flush_out { $out_line = ""; } +use if $^O eq "MSWin32", "threads::shared"; +my $flush_lock :shared; + # Print to stdout sub print_out { if(IS_WIN32PERL) { $out_line .= $_[0]; # Flush buffered output on new lines. if (rindex($_[0], "\n") != -1) { + lock($flush_lock); flush_out(); } } else { From af85e2ba19c2bcf857d66cfa0991c0ea595c68b9 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 18 Mar 2024 22:07:32 +0100 Subject: [PATCH 009/313] MTR, Windows - remove --verbose-restart output on buildbot run MTR buildbot output suggest that buildbot can lose some stdout information by overwriting it with stderr, which is captured separately This is bad, since stdout contains information about failing test. So, this is an attempt to minimize the damage by excluding most frequent stderr messages - those about restart. --- mysql-test/collections/buildbot_suites.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/collections/buildbot_suites.bat b/mysql-test/collections/buildbot_suites.bat index 0880e0124dd..dac273a4033 100644 --- a/mysql-test/collections/buildbot_suites.bat +++ b/mysql-test/collections/buildbot_suites.bat @@ -1,5 +1,5 @@ if "%MTR_PARALLEL%"=="" set MTR_PARALLEL=%NUMBER_OF_PROCESSORS% -perl mysql-test-run.pl --verbose-restart --force --suite-timeout=120 --max-test-fail=10 --retry=3 --suite=^ +perl mysql-test-run.pl --force --suite-timeout=120 --max-test-fail=10 --retry=3 --suite=^ vcol,gcol,perfschema,^ main,^ innodb,^ From 2ba42483344f8b87368fa1794d18dfa329443dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 19 Mar 2024 08:07:41 +0200 Subject: [PATCH 010/313] Fix g++-14 -Wcalloc-transposed-args --- plugin/auth_pam/auth_pam_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/auth_pam/auth_pam_base.c b/plugin/auth_pam/auth_pam_base.c index 1e8f4a08def..153712df140 100644 --- a/plugin/auth_pam/auth_pam_base.c +++ b/plugin/auth_pam/auth_pam_base.c @@ -99,7 +99,7 @@ static int conv(int n, const struct pam_message **msg, freeing it is the responsibility of the caller */ if (*resp == 0) { - *resp = calloc(sizeof(struct pam_response), n); + *resp = calloc(n, sizeof(struct pam_response)); if (*resp == 0) return PAM_BUF_ERR; } From 83a87da430dc545a5ed33f7b9252cac283b385e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 19 Mar 2024 08:08:18 +0200 Subject: [PATCH 011/313] Fix g++-14 -Wmaybe-uninitialized --- storage/innobase/fts/fts0fts.cc | 7 ++----- storage/innobase/que/que0que.cc | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 499f826cea0..bc143da449d 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -5420,12 +5420,9 @@ fts_free( dict_table_t* table) /*!< in/out: table with FTS indexes */ { fts_t* fts = table->fts; - - fts->~fts_t(); - - mem_heap_free(fts->fts_heap); - table->fts = NULL; + mem_heap_free(fts->fts_heap); + fts->~fts_t(); } /*********************************************************************//** diff --git a/storage/innobase/que/que0que.cc b/storage/innobase/que/que0que.cc index 961d4804609..fb0c482fe39 100644 --- a/storage/innobase/que/que0que.cc +++ b/storage/innobase/que/que0que.cc @@ -450,15 +450,12 @@ que_graph_free_recursive( ins = static_cast(node); que_graph_free_recursive(ins->select); - ins->select = NULL; - - ins->~ins_node_t(); if (ins->entry_sys_heap != NULL) { mem_heap_free(ins->entry_sys_heap); - ins->entry_sys_heap = NULL; } + ins->~ins_node_t(); break; case QUE_NODE_PURGE: purge = static_cast(node); From 2a8c4ccf2e5e0a378b0ac52843c8baa5a75175e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 19 Mar 2024 08:09:31 +0200 Subject: [PATCH 012/313] Fix g++-14 -Wtemplate-id-cdtor --- plugin/versioning/versioning.cc | 8 ++++---- sql/item_cmpfunc.h | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/plugin/versioning/versioning.cc b/plugin/versioning/versioning.cc index 8b9fb74e77b..4ed847b0882 100644 --- a/plugin/versioning/versioning.cc +++ b/plugin/versioning/versioning.cc @@ -35,8 +35,8 @@ public: static Create_func_trt s_singleton; protected: - Create_func_trt() = default; - virtual ~Create_func_trt() = default; + Create_func_trt() = default; + virtual ~Create_func_trt() = default; }; template @@ -131,8 +131,8 @@ public: static Create_func_trt_trx_sees s_singleton; protected: - Create_func_trt_trx_sees() = default; - virtual ~Create_func_trt_trx_sees() = default; + Create_func_trt_trx_sees() = default; + virtual ~Create_func_trt_trx_sees() = default; }; template diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 1ae0e652e88..a8868c26899 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -3301,13 +3301,11 @@ template class LI, typename T> class Item_equal_iterator { protected: Item_equal *item_equal; - Item *curr_item; + Item *curr_item= nullptr; public: - Item_equal_iterator(Item_equal &item_eq) - :LI (item_eq.equal_items) + Item_equal_iterator(Item_equal &item_eq) + :LI (item_eq.equal_items), item_equal(&item_eq) { - curr_item= NULL; - item_equal= &item_eq; if (item_eq.with_const) { LI *list_it= this; From 59e7289b6ce93e52b251466e18a2e0eab8b47c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 19 Mar 2024 08:10:42 +0200 Subject: [PATCH 013/313] Fix g++-14 -Wmaybe-uninitialized --- sql/sql_repl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 437c594450d..2b82002afd5 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -222,7 +222,7 @@ static int fake_rotate_event(binlog_send_info *info, ulonglong position, char* p = info->log_file_name+dirname_length(info->log_file_name); uint ident_len = (uint) strlen(p); String *packet= info->packet; - ha_checksum crc; + ha_checksum crc= 0; /* reset transmit packet for the fake rotate event below */ if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg)) @@ -263,7 +263,7 @@ static int fake_gtid_list_event(binlog_send_info *info, { my_bool do_checksum; int err; - ha_checksum crc; + ha_checksum crc= 0; char buf[128]; String str(buf, sizeof(buf), system_charset_info); String* packet= info->packet; From 5d857499530055b6865fe23eaf0b52e1fe89da56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 21 Mar 2024 14:20:33 +0200 Subject: [PATCH 014/313] Cleanup: Remove unused DYN_BLOCK_FULL_FLAG This had become unused in commit 2e814d4702d71a04388386a9f591d14a35980bfe or mysql/mysql-server@eca5b0fc17a5bd6d4833d35a0d08c8549dd3b5ec. This cleanup affects mtr_buf_t::used(). --- storage/innobase/include/dyn0buf.h | 5 ++--- storage/innobase/include/dyn0types.h | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/storage/innobase/include/dyn0buf.h b/storage/innobase/include/dyn0buf.h index bd883eb796c..fdc2ebf3d92 100644 --- a/storage/innobase/include/dyn0buf.h +++ b/storage/innobase/include/dyn0buf.h @@ -60,7 +60,7 @@ public: ulint used() const MY_ATTRIBUTE((warn_unused_result)) { - return(static_cast(m_used & ~DYN_BLOCK_FULL_FLAG)); + return m_used; } /** @@ -153,8 +153,7 @@ public: /** Storage */ byte m_data[MAX_DATA_SIZE]; - /** number of data bytes used in this block; - DYN_BLOCK_FULL_FLAG is set when the block becomes full */ + /** number of data bytes used in this block */ uint32_t m_used; friend class mtr_buf_t; diff --git a/storage/innobase/include/dyn0types.h b/storage/innobase/include/dyn0types.h index 06d837081a1..40e3f4c1965 100644 --- a/storage/innobase/include/dyn0types.h +++ b/storage/innobase/include/dyn0types.h @@ -33,7 +33,4 @@ Created 2013-03-16 Sunny Bains this must be > MLOG_BUF_MARGIN + 30! */ #define DYN_ARRAY_DATA_SIZE 512 -/** Flag for dyn_block_t::used that indicates a full block */ -#define DYN_BLOCK_FULL_FLAG 0x1000000UL - #endif /* dyn0types_h */ From 2250b42f522ef6a0ca676620ef56ae80af061efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 21 Mar 2024 16:01:29 +0200 Subject: [PATCH 015/313] Fix heap-use-after-free in fts_free() This fixes up 83a87da430dc545a5ed33f7b9252cac283b385e6 --- storage/innobase/fts/fts0fts.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index bc143da449d..39698cc5e1e 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -5421,8 +5421,8 @@ fts_free( { fts_t* fts = table->fts; table->fts = NULL; - mem_heap_free(fts->fts_heap); fts->~fts_t(); + mem_heap_free(fts->fts_heap); } /*********************************************************************//** From ef9cdacf51320fbb2935c03d406b22a3688bf295 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 21 Mar 2024 17:17:53 +1100 Subject: [PATCH 016/313] MDEV-33220 Fix -wmaybe-uninitialized warnings for g++-13 --- sql/item_strfunc.cc | 4 +-- sql/mysqld.cc | 2 +- storage/spider/ha_spider.cc | 23 +++++++++++---- storage/spider/hs_client/config.cpp | 31 ++++++++++---------- storage/spider/spd_copy_tables.cc | 43 +++++---------------------- storage/spider/spd_db_mysql.cc | 45 +++++++++++++++-------------- storage/spider/spd_table.cc | 12 ++++---- 7 files changed, 72 insertions(+), 88 deletions(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 697d4fdf2ea..f7a2b1aa176 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1383,7 +1383,7 @@ String *Item_func_regexp_replace::val_str_internal(String *str, char buff2[MAX_FIELD_WIDTH]; String tmp0(buff0,sizeof(buff0),&my_charset_bin); String tmp2(buff2,sizeof(buff2),&my_charset_bin); - String *source, *replace; + String *source, *replace= 0; LEX_CSTRING src, rpl; int startoffset= 0; @@ -1584,7 +1584,7 @@ String *Item_str_conv::val_str(String *str) { DBUG_ASSERT(fixed == 1); String *res; - size_t alloced_length, len; + size_t alloced_length= 0, len; if ((null_value= (!(res= args[0]->val_str(&tmp_value)) || str->alloc((alloced_length= res->length() * multiply))))) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4d0a891faf9..879159c68fd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6390,7 +6390,7 @@ void create_new_thread(CONNECT *connect) void handle_accepted_socket(MYSQL_SOCKET new_sock, MYSQL_SOCKET sock) { CONNECT *connect; - bool is_unix_sock; + bool is_unix_sock= false; #ifdef FD_CLOEXEC (void) fcntl(mysql_socket_getfd(new_sock), F_SETFD, FD_CLOEXEC); diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 89d86a9ca75..90dd37b78aa 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -509,12 +509,23 @@ int ha_spider::open( result_list.last = NULL; result_list.current = NULL; result_list.record_num = 0; - if ( - !(result_list.sqls = new spider_string[share->link_count]) || - !(result_list.insert_sqls = new spider_string[share->link_count]) || - !(result_list.update_sqls = new spider_string[share->link_count]) || - !(result_list.tmp_sqls = new spider_string[share->link_count]) - ) { + if (!(result_list.sqls = new spider_string[share->link_count])) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_result_list; + } + if (!(result_list.insert_sqls = new spider_string[share->link_count])) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_result_list; + } + if (!(result_list.update_sqls = new spider_string[share->link_count])) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error_init_result_list; + } + if (!(result_list.tmp_sqls = new spider_string[share->link_count])) + { error_num = HA_ERR_OUT_OF_MEM; goto error_init_result_list; } diff --git a/storage/spider/hs_client/config.cpp b/storage/spider/hs_client/config.cpp index 97d479220e0..d2759e37d8f 100644 --- a/storage/spider/hs_client/config.cpp +++ b/storage/spider/hs_client/config.cpp @@ -228,23 +228,22 @@ config::operator =(const config& x) conf_param *param, *new_param; for(ulong i = 0; i < x.conf_hash.records; i++) { - if ( - (param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i)) && - (new_param = new conf_param()) - ) { - if ( - !new_param->key.copy(param->key) && - !new_param->val.copy(param->val) - ) { - new_param->key.c_ptr_safe(); - new_param->val.c_ptr_safe(); - DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", - new_param->key.ptr(), new_param->val.ptr())); - if (my_hash_insert(&conf_hash, (uchar*) new_param)) + if ((param = (conf_param *) my_hash_element((HASH *) &x.conf_hash, i))) + if ((new_param = new conf_param())) + { + if ( + !new_param->key.copy(param->key) && + !new_param->val.copy(param->val) + ) { + new_param->key.c_ptr_safe(); + new_param->val.c_ptr_safe(); + DENA_VERBOSE(10, fprintf(stderr, "CONFIG: %s=%s\n", + new_param->key.ptr(), new_param->val.ptr())); + if (my_hash_insert(&conf_hash, (uchar*) new_param)) + delete new_param; + } else delete new_param; - } else - delete new_param; - } + } } } DENA_VERBOSE(10, fprintf(stderr, "config operator = end %p", this)); diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index 6e9d1f2bcc6..34e3cb66712 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -1002,7 +1002,12 @@ long long spider_copy_tables_body( all_link_cnt = copy_tables->link_idx_count[0] + copy_tables->link_idx_count[1]; if ( - !(tmp_sql = new spider_string[all_link_cnt]) || + !(tmp_sql = new spider_string[all_link_cnt]) + ) { + my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); + goto error; + } + if ( !(spider = new ha_spider[all_link_cnt]) ) { my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); @@ -1029,13 +1034,6 @@ long long spider_copy_tables_body( } tmp_spider->share = table_conn->share; tmp_spider->trx = copy_tables->trx; -/* - if (spider_db_append_set_names(table_conn->share)) - { - my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); - goto error_append_set_names; - } -*/ tmp_spider->conns = &table_conn->conn; tmp_sql[roop_count].init_calc_mem(SPD_MID_COPY_TABLES_BODY_3); tmp_sql[roop_count].set_charset(copy_tables->access_charset); @@ -1073,13 +1071,6 @@ long long spider_copy_tables_body( } tmp_spider->share = table_conn->share; tmp_spider->trx = copy_tables->trx; -/* - if (spider_db_append_set_names(table_conn->share)) - { - my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); - goto error_append_set_names; - } -*/ tmp_spider->conns = &table_conn->conn; tmp_sql[roop_count].init_calc_mem(SPD_MID_COPY_TABLES_BODY_5); tmp_sql[roop_count].set_charset(copy_tables->access_charset); @@ -1106,14 +1097,6 @@ long long spider_copy_tables_body( bulk_insert_rows))) goto error_db_udf_copy_tables; -/* - for (table_conn = copy_tables->table_conn[0]; - table_conn; table_conn = table_conn->next) - spider_db_free_set_names(table_conn->share); - for (table_conn = copy_tables->table_conn[1]; - table_conn; table_conn = table_conn->next) - spider_db_free_set_names(table_conn->share); -*/ if (table_list->table) { #if MYSQL_VERSION_ID < 50500 @@ -1138,8 +1121,7 @@ long long spider_copy_tables_body( } delete [] spider; } - if (tmp_sql) - delete [] tmp_sql; + delete [] tmp_sql; spider_udf_free_copy_tables_alloc(copy_tables); DBUG_RETURN(1); @@ -1147,17 +1129,6 @@ long long spider_copy_tables_body( error_db_udf_copy_tables: error_create_dbton_handler: error_init_dbton_handler: -/* -error_append_set_names: -*/ -/* - for (table_conn = copy_tables->table_conn[0]; - table_conn; table_conn = table_conn->next) - spider_db_free_set_names(table_conn->share); - for (table_conn = copy_tables->table_conn[1]; - table_conn; table_conn = table_conn->next) - spider_db_free_set_names(table_conn->share); -*/ error: if (spider) { diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index fe83c652260..a7bf14b7fed 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -7218,11 +7218,9 @@ int spider_mbase_share::init() DBUG_RETURN(HA_ERR_OUT_OF_MEM); } - if (keys > 0 && - !(key_hint = new spider_string[keys]) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } + if (keys > 0) + if (!(key_hint = new spider_string[keys])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); for (roop_count = 0; roop_count < keys; roop_count++) { key_hint[roop_count].init_calc_mem(SPD_MID_MBASE_SHARE_INIT_2); @@ -7230,12 +7228,12 @@ int spider_mbase_share::init() } DBUG_PRINT("info",("spider key_hint=%p", key_hint)); - if ( - !(table_select = new spider_string[1]) || - (keys > 0 && - !(key_select = new spider_string[keys]) - ) || - (error_num = create_table_names_str()) || + if (!(table_select = new spider_string[1])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (keys > 0) + if (!(key_select = new spider_string[keys])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if ((error_num = create_table_names_str()) || (table_share && ( (error_num = create_column_name_str()) || @@ -7386,11 +7384,18 @@ int spider_mbase_share::create_table_names_str() table_names_str = NULL; db_names_str = NULL; db_table_str = NULL; - if ( - !(table_names_str = new spider_string[spider_share->all_link_count]) || - !(db_names_str = new spider_string[spider_share->all_link_count]) || - !(db_table_str = new spider_string[spider_share->all_link_count]) - ) { + if (!(table_names_str = new spider_string[spider_share->all_link_count])) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (!(db_names_str = new spider_string[spider_share->all_link_count])) + { + error_num = HA_ERR_OUT_OF_MEM; + goto error; + } + if (!(db_table_str = new spider_string[spider_share->all_link_count])) + { error_num = HA_ERR_OUT_OF_MEM; goto error; } @@ -7541,11 +7546,9 @@ int spider_mbase_share::create_column_name_str() Field **field; TABLE_SHARE *table_share = spider_share->table_share; DBUG_ENTER("spider_mbase_share::create_column_name_str"); - if ( - table_share->fields && - !(column_name_str = new spider_string[table_share->fields]) - ) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (table_share->fields) + if (!(column_name_str = new spider_string[table_share->fields])) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); for (field = table_share->field, str = column_name_str; *field; field++, str++) { diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index e47b8eff7a2..fae239c57db 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -4217,12 +4217,12 @@ SPIDER_SHARE *spider_create_share( share->table.read_set = &table_share->all_set; #endif - if (table_share->keys > 0 && - !(share->key_hint = new spider_string[table_share->keys]) - ) { - *error_num = HA_ERR_OUT_OF_MEM; - goto error_init_hint_string; - } + if (table_share->keys > 0) + if (!(share->key_hint = new spider_string[table_share->keys])) + { + *error_num = HA_ERR_OUT_OF_MEM; + goto error_init_hint_string; + } for (roop_count = 0; roop_count < (int) table_share->keys; roop_count++) share->key_hint[roop_count].init_calc_mem(SPD_MID_CREATE_SHARE_2); DBUG_PRINT("info",("spider share->key_hint=%p", share->key_hint)); From e0c8165487ecfbee1d25625422a91a6352d7e522 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 21 Mar 2024 14:03:19 +0100 Subject: [PATCH 017/313] MDEV-33509 Failed to apply write set with flags=(rollback|pa_unsafe) Fix function `remove_fragment()` in wsrep_schema so that no error is raised if the fragment to be removed is not found in the wsrep_streaming_log table. This is necessary to handle the case where streaming transaction in idle state is BF aborted. This may result in the case where the rollbacker thread successfully removes the transaction's fragments, followed by the applier's attempt to remove the same fragments. Causing the node to leave the cluster after reporting a "Failed to apply write set" error. Signed-off-by: Julius Goryavsky --- .../r/galera_sr_bf_abort_idle.result | 33 +++++++++ .../galera_sr/t/galera_sr_bf_abort_idle.test | 68 +++++++++++++++++++ sql/wsrep_schema.cc | 5 +- 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera_sr/r/galera_sr_bf_abort_idle.result create mode 100644 mysql-test/suite/galera_sr/t/galera_sr_bf_abort_idle.test diff --git a/mysql-test/suite/galera_sr/r/galera_sr_bf_abort_idle.result b/mysql-test/suite/galera_sr/r/galera_sr_bf_abort_idle.result new file mode 100644 index 00000000000..a1495f1c138 --- /dev/null +++ b/mysql-test/suite/galera_sr/r/galera_sr_bf_abort_idle.result @@ -0,0 +1,33 @@ +connection node_2; +connection node_1; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1); +SET SESSION wsrep_trx_fragment_size=10; +SET SESSION wsrep_trx_fragment_unit='rows'; +START TRANSACTION; +UPDATE t1 SET f2 = f2 + 10; +connection node_2; +INSERT INTO t1 VALUES (10,2); +connection node_1a; +connection node_1; +INSERT INTO t1 VALUES (9,1); +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ROLLBACK; +DROP TABLE t1; +connection node_1; +CREATE TABLE t1(f1 INTEGER PRIMARY KEY, f2 INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1); +SET SESSION wsrep_trx_fragment_size=5; +SET SESSION wsrep_trx_fragment_unit='rows'; +START TRANSACTION; +UPDATE t1 SET f2 = f2 + 10; +connection node_2; +INSERT INTO t1 VALUES (10,2); +connection node_1a; +connection node_1; +INSERT INTO t1 VALUES (9,1); +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ROLLBACK; +DROP TABLE t1; diff --git a/mysql-test/suite/galera_sr/t/galera_sr_bf_abort_idle.test b/mysql-test/suite/galera_sr/t/galera_sr_bf_abort_idle.test new file mode 100644 index 00000000000..66259b790cc --- /dev/null +++ b/mysql-test/suite/galera_sr/t/galera_sr_bf_abort_idle.test @@ -0,0 +1,68 @@ +# +# Test BF abort for idle SR transactions +# + +--source include/galera_cluster.inc + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 + +# +# Case 1: BF abort idle SR transaction that has not yet replicated any fragments +# +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1); + +--let $bf_count = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.global_status WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` + +SET SESSION wsrep_trx_fragment_size=10; +SET SESSION wsrep_trx_fragment_unit='rows'; +START TRANSACTION; +UPDATE t1 SET f2 = f2 + 10; + +--connection node_2 +INSERT INTO t1 VALUES (10,2); + +# Wait for SR transaction to be BF aborted +--connection node_1a +--let $wait_condition = SELECT VARIABLE_VALUE = $bf_count + 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts' +--source include/wait_condition.inc + + +--connection node_1 +--error ER_LOCK_DEADLOCK +INSERT INTO t1 VALUES (9,1); +ROLLBACK; + +DROP TABLE t1; + + +# +# Case 2: BF abort idle SR transaction that has already replicated a fragment +# +--connection node_1 +CREATE TABLE t1(f1 INTEGER PRIMARY KEY, f2 INTEGER); +INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1); + +--let $bf_count = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.global_status WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` + + +SET SESSION wsrep_trx_fragment_size=5; +SET SESSION wsrep_trx_fragment_unit='rows'; +START TRANSACTION; +UPDATE t1 SET f2 = f2 + 10; + +--connection node_2 +INSERT INTO t1 VALUES (10,2); + +# Wait for SR transaction to be BF aborted +--connection node_1a +--let $wait_condition = SELECT VARIABLE_VALUE = $bf_count + 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts' +--source include/wait_condition.inc + +--connection node_1 +--error ER_LOCK_DEADLOCK +INSERT INTO t1 VALUES (9,1); +ROLLBACK; + +DROP TABLE t1; diff --git a/sql/wsrep_schema.cc b/sql/wsrep_schema.cc index a59d13dd839..1c4f827ae97 100644 --- a/sql/wsrep_schema.cc +++ b/sql/wsrep_schema.cc @@ -1117,7 +1117,10 @@ static int remove_fragment(THD* thd, seqno.get(), error); } - ret= error; + else + { + ret= error; + } } else if (Wsrep_schema_impl::delete_row(frag_table)) { From 9b7c2c6b0050967733de0d084bfb179f96973f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 26 Mar 2024 10:47:43 +0200 Subject: [PATCH 018/313] MDEV-33220 fixup: Remove some initialization --- sql/item_strfunc.cc | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f7a2b1aa176..427c39a6812 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1383,19 +1383,20 @@ String *Item_func_regexp_replace::val_str_internal(String *str, char buff2[MAX_FIELD_WIDTH]; String tmp0(buff0,sizeof(buff0),&my_charset_bin); String tmp2(buff2,sizeof(buff2),&my_charset_bin); - String *source, *replace= 0; + String *source, *replace; LEX_CSTRING src, rpl; int startoffset= 0; - if ((null_value= - (!(source= args[0]->val_str(&tmp0)) || - !(replace= args[2]->val_str_null_to_empty(&tmp2, null_to_empty)) || - re.recompile(args[1])))) - return (String *) 0; - + source= args[0]->val_str(&tmp0); + if (!source) + goto err; + replace= args[2]->val_str_null_to_empty(&tmp2, null_to_empty); + if (!replace || re.recompile(args[1])) + goto err; if (!(source= re.convert_if_needed(source, &re.subject_converter)) || !(replace= re.convert_if_needed(replace, &re.replace_converter))) goto err; + null_value= false; src= source->lex_cstring(); rpl= replace->lex_cstring(); @@ -1439,7 +1440,7 @@ String *Item_func_regexp_replace::val_str_internal(String *str, err: null_value= true; - return (String *) 0; + return nullptr; } @@ -1583,13 +1584,21 @@ bool Item_func_insert::fix_length_and_dec() String *Item_str_conv::val_str(String *str) { DBUG_ASSERT(fixed == 1); - String *res; - size_t alloced_length= 0, len; + String *res= args[0]->val_str(&tmp_value); - if ((null_value= (!(res= args[0]->val_str(&tmp_value)) || - str->alloc((alloced_length= res->length() * multiply))))) - return 0; + if (!res) + { + err: + null_value= true; + return nullptr; + } + size_t alloced_length= res->length() * multiply, len; + + if (str->alloc((alloced_length))) + goto err; + + null_value= false; len= converter(collation.collation, (char*) res->ptr(), res->length(), (char*) str->ptr(), alloced_length); DBUG_ASSERT(len <= alloced_length); From 17573166c4980c86907176064ad61d36da5d753f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 26 Mar 2024 10:47:50 +0200 Subject: [PATCH 019/313] MDEV-22742 fixup: Remove a suppression --- mysql-test/mysql-test-run.pl | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index cdd8f0bf6cd..4313cfa6a89 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4472,8 +4472,6 @@ sub extract_warning_lines ($$) { qr/Dump thread [0-9]+ last sent to server [0-9]+ binlog file:pos .+/, qr/Detected table cache mutex contention at instance .* waits. Additional table cache instance cannot be activated: consider raising table_open_cache_instances. Number of active instances/, - # for UBSAN - qr/decimal\.c.*: runtime error: signed integer overflow/, # Disable test for UBSAN on dynamically loaded objects qr/runtime error: member call.*object.*'Handler_share'/, qr/sql_type\.cc.* runtime error: member call.*object.* 'Type_collection'/, From ed027d65f145621bdf0b34586522356bf7766dc5 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 22 Mar 2024 14:04:46 +0300 Subject: [PATCH 020/313] MDEV-33747: Optimization of (SELECT) IN (SELECT ...) executes subquery at prepare stage Make IN->EXISTS rewrite not to compute constant left expression if it has a subquery in it. --- mysql-test/main/subselect4.result | 29 +++++++++++++++++++++++++++++ mysql-test/main/subselect4.test | 15 +++++++++++++++ sql/item_cmpfunc.cc | 8 +++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index 4edcffa0ee5..d609fe4ce96 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -3292,4 +3292,33 @@ a 2 DEALLOCATE PREPARE stmt; DROP TABLE t1,t2,t3; +# +# MDEV-33747: Optimization of (SELECT) IN (SELECT ...) executes subquery at prepare stage +# +create table t1 (a int, b int); +insert into t1 select seq, seq from seq_1_to_200; +create table t2 as select * from t1; +create table t3 as select * from t1; +analyze table t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status OK +select @@expensive_subquery_limit < 200 as DEFAULTS_ARE_SUITABLE; +DEFAULTS_ARE_SUITABLE +1 +flush status; +explain select * from t1 where a<3 or (select max(a) from t2) in (select b from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 200 Using where +3 SUBQUERY t3 ALL NULL NULL NULL NULL 200 Using where +2 SUBQUERY t2 ALL NULL NULL NULL NULL 200 +# Must show 0. If this shows 200, this means subquery was executed and you have a bug: +show status like 'Handler_read_rnd_next%'; +Variable_name Value +Handler_read_rnd_next 0 +drop table t1,t2,t3; # End of 10.4 tests diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test index d5871f1202c..8ab6fa3afd6 100644 --- a/mysql-test/main/subselect4.test +++ b/mysql-test/main/subselect4.test @@ -2666,4 +2666,19 @@ DEALLOCATE PREPARE stmt; DROP TABLE t1,t2,t3; +--echo # +--echo # MDEV-33747: Optimization of (SELECT) IN (SELECT ...) executes subquery at prepare stage +--echo # +create table t1 (a int, b int); +insert into t1 select seq, seq from seq_1_to_200; +create table t2 as select * from t1; +create table t3 as select * from t1; +analyze table t1,t2,t3; +select @@expensive_subquery_limit < 200 as DEFAULTS_ARE_SUITABLE; +flush status; +explain select * from t1 where a<3 or (select max(a) from t2) in (select b from t3); +--echo # Must show 0. If this shows 200, this means subquery was executed and you have a bug: +show status like 'Handler_read_rnd_next%'; +drop table t1,t2,t3; + --echo # End of 10.4 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index cffd2e8add8..1dc555dad3a 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1363,7 +1363,13 @@ bool Item_in_optimizer::fix_left(THD *thd) copy_with_sum_func(args[0]); with_param= args[0]->with_param || args[1]->with_param; with_field= args[0]->with_field; - if ((const_item_cache= args[0]->const_item())) + + /* + If left expression is a constant, cache its value. + But don't do that if that involves computing a subquery, as we are in a + prepare-phase rewrite. + */ + if ((const_item_cache= args[0]->const_item()) && !args[0]->with_subquery()) { cache->store(args[0]); cache->cache_value(); From d695e2de5447727be029dc9ef0e2f1a54a8a9844 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 26 Mar 2024 13:10:16 +0100 Subject: [PATCH 021/313] MDEV-33506 Show original IP in the "aborted" message. Add "real ip:" part to the aborted message Only for proxy-protocoled connection, so it does not not to cause confusion to normal users. --- include/mysql_com.h | 1 + mysql-test/main/mysql_client_test.result | 1 + mysql-test/main/mysql_client_test.test | 6 +++++ sql/net_serv.cc | 3 +++ sql/share/errmsg-utf8.txt | 32 ++++++++++++------------ sql/sql_class.h | 20 ++++++++++++++- sql/sql_connect.cc | 2 +- tests/mysql_client_test.c | 6 ++++- 8 files changed, 52 insertions(+), 19 deletions(-) diff --git a/include/mysql_com.h b/include/mysql_com.h index 2e51f67b662..3d760ef28d4 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -456,6 +456,7 @@ typedef struct st_net { my_bool thread_specific_malloc; unsigned char compress; my_bool unused3; /* Please remove with the next incompatible ABI change. */ + my_bool using_proxy_protocol; /* Pointer to query object in query cache, do not equal NULL (0) for queries in cache that have not stored its results yet diff --git a/mysql-test/main/mysql_client_test.result b/mysql-test/main/mysql_client_test.result index dbc1feaa23b..dbd5aaeaae5 100644 --- a/mysql-test/main/mysql_client_test.result +++ b/mysql-test/main/mysql_client_test.result @@ -261,3 +261,4 @@ SET @@global.character_set_server= @save_character_set_server; SET @@global.collation_server= @save_collation_server; SET @@global.character_set_client= @save_character_set_client; SET @@global.collation_connection= @save_collation_connection; +FOUND 1 /Aborted connection.*'u' host: '192.0.2.1' real ip: '(localhost|::1)'/ in mysqld.1.err diff --git a/mysql-test/main/mysql_client_test.test b/mysql-test/main/mysql_client_test.test index 9fb7bcd81c9..09efc99796d 100644 --- a/mysql-test/main/mysql_client_test.test +++ b/mysql-test/main/mysql_client_test.test @@ -59,3 +59,9 @@ SET @@global.character_set_server= @save_character_set_server; SET @@global.collation_server= @save_collation_server; SET @@global.character_set_client= @save_character_set_client; SET @@global.collation_connection= @save_collation_connection; + +# Search for "real ip" in Aborted message +# This is indicator for abort of the proxied connections. +let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err; +let SEARCH_PATTERN= Aborted connection.*'u' host: '192.0.2.1' real ip: '(localhost|::1)'; +source include/search_pattern_in_file.inc; diff --git a/sql/net_serv.cc b/sql/net_serv.cc index c52083f8c2a..ecba6af0c86 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -151,6 +151,7 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags) net->where_b = net->remain_in_buf=0; net->net_skip_rest_factor= 0; net->last_errno=0; + net->using_proxy_protocol= 0; net->thread_specific_malloc= MY_TEST(my_flags & MY_THREAD_SPECIFIC); net->thd= 0; #ifdef MYSQL_SERVER @@ -192,6 +193,7 @@ void net_end(NET *net) DBUG_ENTER("net_end"); my_free(net->buff); net->buff=0; + net->using_proxy_protocol= 0; DBUG_VOID_RETURN; } @@ -908,6 +910,7 @@ static handle_proxy_header_result handle_proxy_header(NET *net) return RETRY; /* Change peer address in THD and ACL structures.*/ uint host_errors; + net->using_proxy_protocol= 1; return (handle_proxy_header_result)thd_set_peer_addr(thd, &(peer_info.peer_addr), NULL, peer_info.port, false, &host_errors); diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index eda61fbe218..c80f35ce341 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -4252,22 +4252,22 @@ ER_ERROR_DURING_CHECKPOINT swe "Fick fel %M vid CHECKPOINT" ukr "Отримано помилку %M під Ñ‡Ð°Ñ CHECKPOINT" ER_NEW_ABORTING_CONNECTION 08S01 - chi "终止的连接 %lld 到数æ®åº“: '%-.192s' 用户: '%-.48s' 主机: '%-.64s' (%-.64s)" - cze "Spojení %lld do databáze: '%-.192s' uživatel: '%-.48s' stroj: '%-.64s' (%-.64s) bylo pÅ™eruÅ¡eno" - dan "Afbrød forbindelsen %lld til databasen '%-.192s' bruger: '%-.48s' vært: '%-.64s' (%-.64s)" - eng "Aborted connection %lld to db: '%-.192s' user: '%-.48s' host: '%-.64s' (%-.64s)" - est "Ühendus katkestatud %lld andmebaas: '%-.192s' kasutaja: '%-.48s' masin: '%-.64s' (%-.64s)" - fre "Connection %lld avortée vers la bd: '%-.192s' utilisateur: '%-.48s' hôte: '%-.64s' (%-.64s)" - ger "Abbruch der Verbindung %lld zur Datenbank '%-.192s'. Benutzer: '%-.48s', Host: '%-.64s' (%-.64s)" - ita "Interrotta la connessione %lld al db: ''%-.192s' utente: '%-.48s' host: '%-.64s' (%-.64s)" - jpn "接続 %lld ãŒä¸­æ–­ã•れã¾ã—ãŸã€‚データベース: '%-.192s' ユーザー: '%-.48s' ホスト: '%-.64s' (%-.64s)" - nla "Afgebroken verbinding %lld naar db: '%-.192s' gebruiker: '%-.48s' host: '%-.64s' (%-.64s)" - por "Conexão %lld abortada para banco de dados '%-.192s' - usuário '%-.48s' - 'host' '%-.64s' ('%-.64s')" - rus "Прервано Ñоединение %lld к базе данных '%-.192s' Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÐµÐ»Ñ '%-.48s' Ñ Ñ…Ð¾Ñта '%-.64s' (%-.64s)" - serbian "Prekinuta konekcija broj %lld ka bazi: '%-.192s' korisnik je bio: '%-.48s' a host: '%-.64s' (%-.64s)" - spa "Abortada conexión %lld para db: '%-.192s' usuario: '%-.48s' servidor: '%-.64s' (%-.64s)" - swe "Avbröt länken för trÃ¥d %lld till db '%-.192s', användare '%-.48s', host '%-.64s' (%-.64s)" - ukr "Перервано з'Ñ”Ð´Ð½Ð°Ð½Ð½Ñ %lld до бази данних: '%-.192s' кориÑтувач: '%-.48s' хоÑÑ‚: '%-.64s' (%-.64s)" + chi "终止的连接 %lld 到数æ®åº“: '%-.192s' 用户: '%-.48s' 主机: '%-.64s'%-.64s (%-.64s)" + cze "Spojení %lld do databáze: '%-.192s' uživatel: '%-.48s' stroj: '%-.64s'%-.64s (%-.64s) bylo pÅ™eruÅ¡eno" + dan "Afbrød forbindelsen %lld til databasen '%-.192s' bruger: '%-.48s' vært: '%-.64s'%-.64s (%-.64s)" + eng "Aborted connection %lld to db: '%-.192s' user: '%-.48s' host: '%-.64s'%-.64s (%-.64s)" + est "Ühendus katkestatud %lld andmebaas: '%-.192s' kasutaja: '%-.48s' masin: '%-.64s'%-.64s (%-.64s)" + fre "Connection %lld avortée vers la bd: '%-.192s' utilisateur: '%-.48s' hôte: '%-.64s'%-.64s (%-.64s)" + ger "Abbruch der Verbindung %lld zur Datenbank '%-.192s'. Benutzer: '%-.48s', Host: '%-.64s'%-.64s (%-.64s)" + ita "Interrotta la connessione %lld al db: ''%-.192s' utente: '%-.48s' host: '%-.64s'%-.64s (%-.64s)" + jpn "接続 %lld ãŒä¸­æ–­ã•れã¾ã—ãŸã€‚データベース: '%-.192s' ユーザー: '%-.48s' ホスト: '%-.64s'%-.64s (%-.64s)" + nla "Afgebroken verbinding %lld naar db: '%-.192s' gebruiker: '%-.48s' host: '%-.64s'%-.64s (%-.64s)" + por "Conexão %lld abortada para banco de dados '%-.192s' - usuário '%-.48s' - 'host' '%-.64s'%-.64s ('%-.64s')" + rus "Прервано Ñоединение %lld к базе данных '%-.192s' Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÐµÐ»Ñ '%-.48s' Ñ Ñ…Ð¾Ñта '%-.64s'%-.64s (%-.64s)" + serbian "Prekinuta konekcija broj %lld ka bazi: '%-.192s' korisnik je bio: '%-.48s' a host: '%-.64s'%-.64s (%-.64s)" + spa "Abortada conexión %lld a la base de datos: '%-.192s' usuario: '%-.48s' equipo: '%-.64s'%-.64s (%-.64s)" + swe "Avbröt länken för trÃ¥d %lld till db '%-.192s', användare '%-.48s', host '%-.64s'%-.64s (%-.64s)" + ukr "Перервано з'Ñ”Ð´Ð½Ð°Ð½Ð½Ñ %lld до бази данних: '%-.192s' кориÑтувач: '%-.48s' хоÑÑ‚: '%-.64s'%-.64s (%-.64s)" ER_UNUSED_10 eng "You should never see it" ER_FLUSH_MASTER_BINLOG_CLOSED diff --git a/sql/sql_class.h b/sql/sql_class.h index a6c56a6e023..e71f802b8c1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4773,11 +4773,29 @@ public: { if (global_system_variables.log_warnings > threshold) { + char real_ip_str[64]; + real_ip_str[0]= 0; + + /* For proxied connections, add the real IP to the warning message */ + if (net.using_proxy_protocol && net.vio) + { + if(net.vio->localhost) + snprintf(real_ip_str, sizeof(real_ip_str), " real ip: 'localhost'"); + else + { + char buf[INET6_ADDRSTRLEN]; + if (!vio_getnameinfo((sockaddr *)&(net.vio->remote), buf, + sizeof(buf),NULL, 0, NI_NUMERICHOST)) + { + snprintf(real_ip_str, sizeof(real_ip_str), " real ip: '%s'",buf); + } + } + } Security_context *sctx= &main_security_ctx; sql_print_warning(ER_THD(this, ER_NEW_ABORTING_CONNECTION), thread_id, (db.str ? db.str : "unconnected"), sctx->user ? sctx->user : "unauthenticated", - sctx->host_or_ip, reason); + sctx->host_or_ip, real_ip_str, reason); } } diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index eae30ce76aa..a633064bae2 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1282,7 +1282,7 @@ void prepare_new_connection_state(THD* thd) thd->thread_id, thd->db.str ? thd->db.str : "unconnected", sctx->user ? sctx->user : "unauthenticated", - sctx->host_or_ip, "init_connect command failed"); + sctx->host_or_ip, "", "init_connect command failed"); thd->server_status&= ~SERVER_STATUS_CLEAR_SET; thd->protocol->end_statement(); thd->killed = KILL_CONNECTION; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index da04b078e76..cf6e8155533 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -20546,7 +20546,6 @@ typedef struct { #ifndef EMBEDDED_LIBRARY static void test_proxy_header_tcp(const char *ipaddr, int port) { - int rc; MYSQL_RES *result; int family = (strchr(ipaddr,':') == NULL)?AF_INET:AF_INET6; @@ -20621,6 +20620,11 @@ static void test_proxy_header_tcp(const char *ipaddr, int port) DIE_UNLESS(strncmp(row[0], normalized_addr, addrlen) == 0); DIE_UNLESS(atoi(row[0] + addrlen+1) == port); mysql_free_result(result); + if (i == 0 && !strcmp(ipaddr,"192.0.2.1")) + { + /* do "dirty" close, to get aborted message in error log.*/ + mariadb_cancel(m); + } mysql_close(m); } sprintf(query,"DROP USER 'u'@'%s'",normalized_addr); From bf49e7cfc78999aaaaf549bc44ba8548cc98bab8 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 26 Mar 2024 15:29:33 +0530 Subject: [PATCH 022/313] MDEV-33770 Alter operation hangs when encryption thread works on the same tablespace - Background encryption threads wait for stop flag to exit early from the tablespace. Alter operation fails to set the stop flag before waiting for the encryption thread to stop using the tablespace. --- storage/innobase/fil/fil0crypt.cc | 2 +- storage/innobase/fil/fil0fil.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 49cb8ee6024..ad02f1c3393 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2755,7 +2755,7 @@ fil_space_crypt_close_tablespace( << " seconds to drop space: " << space->name << " (" << space->id << ") active threads " - << cnt << "flushing=" + << cnt << " flushing=" << flushing << "."; last = now; } diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 45f8c341ee2..44e061b9400 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -2288,13 +2288,13 @@ fil_check_pending_operations( fil_space_t* sp = fil_space_get_by_id(id); if (sp) { + sp->set_stopping(true); if (sp->crypt_data && sp->acquire()) { mutex_exit(&fil_system.mutex); fil_space_crypt_close_tablespace(sp); mutex_enter(&fil_system.mutex); sp->release(); } - sp->set_stopping(true); } /* Check for pending operations. */ From 9d34939c6e9f8fe138717e66633809d0f2370f49 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 20 Feb 2024 11:20:21 +1100 Subject: [PATCH 023/313] MDEV-33494 fix spider init with no_zero_date global sql mode Like the fix for MDEV-32753 and MDEV-33242, spider init queries creates new connections that use the global sql_mode of the existing connection. --- .../mysql-test/spider/bugfix/r/mdev_33494.result | 4 ++++ .../spider/mysql-test/spider/bugfix/t/mdev_33494.test | 11 +++++++++++ storage/spider/spd_init_query.h | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_33494.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_33494.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33494.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33494.result new file mode 100644 index 00000000000..3db28c0f08e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33494.result @@ -0,0 +1,4 @@ +set @old_sql_mode=@@global.sql_mode; +set global sql_mode=(SELECT CONCAT (@@sql_mode,',no_zero_date')); +install soname 'ha_spider'; +set global sql_mode=@old_sql_mode; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33494.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33494.test new file mode 100644 index 00000000000..30beca77f35 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33494.test @@ -0,0 +1,11 @@ +# This test tests spider init with global no_zero_date sql mode +set @old_sql_mode=@@global.sql_mode; +set global sql_mode=(SELECT CONCAT (@@sql_mode,',no_zero_date')); +install soname 'ha_spider'; +set global sql_mode=@old_sql_mode; + +--disable_query_log +--disable_result_log +--source ../../include/clean_up_spider.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_init_query.h b/storage/spider/spd_init_query.h index b8d1751a21b..c83bf56c4dd 100644 --- a/storage/spider/spd_init_query.h +++ b/storage/spider/spd_init_query.h @@ -21,7 +21,7 @@ static LEX_STRING spider_init_queries[] = { {C_STRING_WITH_LEN( - "SET @@SQL_MODE = REPLACE(@@SQL_MODE, 'ORACLE', '');" + "SET @@SQL_MODE = REGEXP_REPLACE(@@SQL_MODE, '(ORACLE|NO_ZERO_DATE)', '');" )}, {C_STRING_WITH_LEN( "create table if not exists mysql.spider_xa(" From db0b9ec37ba16bb17fc41a39522a7a1898df6902 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 27 Mar 2024 11:40:41 +1100 Subject: [PATCH 024/313] MDEV-33584 Use the default SQL_MODE for spider init queries This should fix all future problems caused by a non-default global sql_mode from the server where spider is to be installed. --- .../mysql-test/spider/bugfix/r/mdev_33584.result | 4 ++++ .../spider/mysql-test/spider/bugfix/t/mdev_33584.test | 11 +++++++++++ storage/spider/spd_init_query.h | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_33584.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_33584.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33584.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33584.result new file mode 100644 index 00000000000..796c75cc560 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33584.result @@ -0,0 +1,4 @@ +set @old_sql_mode=@@global.sql_mode; +set global sql_mode='traditional'; +install soname 'ha_spider'; +set global sql_mode=@old_sql_mode; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33584.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33584.test new file mode 100644 index 00000000000..886449716eb --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33584.test @@ -0,0 +1,11 @@ +# This test tests spider init with global no_zero_date sql mode +set @old_sql_mode=@@global.sql_mode; +set global sql_mode='traditional'; +install soname 'ha_spider'; +set global sql_mode=@old_sql_mode; + +--disable_query_log +--disable_result_log +--source ../../include/clean_up_spider.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_init_query.h b/storage/spider/spd_init_query.h index c83bf56c4dd..1311384c7ce 100644 --- a/storage/spider/spd_init_query.h +++ b/storage/spider/spd_init_query.h @@ -20,8 +20,10 @@ */ static LEX_STRING spider_init_queries[] = { + /* Use the default SQL_MODE for this connection. */ {C_STRING_WITH_LEN( - "SET @@SQL_MODE = REGEXP_REPLACE(@@SQL_MODE, '(ORACLE|NO_ZERO_DATE)', '');" + "SET @@SQL_MODE = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO," + "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';" )}, {C_STRING_WITH_LEN( "create table if not exists mysql.spider_xa(" From c71dc395292f41685530c0fa92c5ce4d78eabfa0 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 24 Nov 2022 14:47:18 +0100 Subject: [PATCH 025/313] MDEV-26499 Fix error "mysql_shutdown failed" during MTR tests - Fix to avoid mysqltest client getting killed abruptly during mysql_shutdown(). When Galera replication is shutdown, wait for THDs with `thd->stmt_da()->is_eof()` to disconnect (these are about to disconnect anyway). - Extract duplicate code from `wsrep_stop_replication()` and `wsrep_shutdown_replication()` in a new function. - No need to use a custom `shutdown_mysqld.inc` in galera suite. Delete it, so that the one in `mysql-test/include/` is used. Signed-off-by: Julius Goryavsky --- .../suite/galera/include/shutdown_mysqld.inc | 18 ----- mysql-test/suite/galera/r/MDEV-26499.result | 6 ++ mysql-test/suite/galera/t/MDEV-26499.test | 20 ++++++ sql/sql_parse.cc | 1 + sql/wsrep_mysqld.cc | 70 ++++++++++--------- 5 files changed, 64 insertions(+), 51 deletions(-) delete mode 100644 mysql-test/suite/galera/include/shutdown_mysqld.inc create mode 100644 mysql-test/suite/galera/r/MDEV-26499.result create mode 100644 mysql-test/suite/galera/t/MDEV-26499.test diff --git a/mysql-test/suite/galera/include/shutdown_mysqld.inc b/mysql-test/suite/galera/include/shutdown_mysqld.inc deleted file mode 100644 index 793be8d76ac..00000000000 --- a/mysql-test/suite/galera/include/shutdown_mysqld.inc +++ /dev/null @@ -1,18 +0,0 @@ -# This is the first half of include/restart_mysqld.inc. -if ($rpl_inited) -{ - if (!$allow_rpl_inited) - { - --die ERROR IN TEST: When using the replication test framework (master-slave.inc, rpl_init.inc etc), use rpl_restart_server.inc instead of restart_mysqld.inc. If you know what you are doing and you really have to use restart_mysqld.inc, set allow_rpl_inited=1 before you source restart_mysqld.inc - } -} - -# Write file to make mysql-test-run.pl expect the "crash", but don't start it ---let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` ---let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect ---exec echo "wait" > $_expect_file_name - -# Send shutdown to the connected server ---shutdown_server ---source include/wait_until_disconnected.inc - diff --git a/mysql-test/suite/galera/r/MDEV-26499.result b/mysql-test/suite/galera/r/MDEV-26499.result new file mode 100644 index 00000000000..15d372470a4 --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-26499.result @@ -0,0 +1,6 @@ +connection node_2; +connection node_1; +connection node_1; +connection node_2; +connection node_2; +SET GLOBAL debug_dbug="+d,simulate_slow_client_at_shutdown"; diff --git a/mysql-test/suite/galera/t/MDEV-26499.test b/mysql-test/suite/galera/t/MDEV-26499.test new file mode 100644 index 00000000000..824b28c14f3 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-26499.test @@ -0,0 +1,20 @@ +# +# MDEV-26499 +# +# This test reproduces some failure on mysql_shutdown() call +# which manifests sporadically in some galera MTR tests during +# restart of a node. +# + +--source include/galera_cluster.inc +--source include/have_debug_sync.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--connection node_2 +SET GLOBAL debug_dbug="+d,simulate_slow_client_at_shutdown"; +--source include/restart_mysqld.inc + +--source include/auto_increment_offset_restore.inc diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4d52e515710..0fa793cea1a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2208,6 +2208,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, my_eof(thd); kill_mysql(thd); error=TRUE; + DBUG_EXECUTE_IF("simulate_slow_client_at_shutdown", my_sleep(2000000);); break; } #endif diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 5ec96478e4a..2e5bf3f426e 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1014,10 +1014,8 @@ void wsrep_recover() WSREP_INFO("Recovered position: %s", oss.str().c_str()); } - -void wsrep_stop_replication(THD *thd) +static void wsrep_stop_replication_common(THD *thd) { - WSREP_INFO("Stop replication by %llu", (thd) ? thd->thread_id : 0); if (Wsrep_server_state::instance().state() != Wsrep_server_state::s_disconnected) { @@ -1030,40 +1028,30 @@ void wsrep_stop_replication(THD *thd) } } - /* my connection, should not terminate with wsrep_close_client_connection(), - make transaction to rollback - */ - if (thd && !thd->wsrep_applier) trans_rollback(thd); + /* my connection, should not terminate with + wsrep_close_client_connections(), make transaction to rollback */ + if (thd && !thd->wsrep_applier) + trans_rollback(thd); wsrep_close_client_connections(TRUE, thd); - + /* wait until appliers have stopped */ wsrep_wait_appliers_close(thd); node_uuid= WSREP_UUID_UNDEFINED; } +void wsrep_stop_replication(THD *thd) +{ + WSREP_INFO("Stop replication by %llu", (thd) ? thd->thread_id : 0); + wsrep_stop_replication_common(thd); +} + void wsrep_shutdown_replication() { WSREP_INFO("Shutdown replication"); - if (Wsrep_server_state::instance().state() != wsrep::server_state::s_disconnected) - { - WSREP_DEBUG("Disconnect provider"); - Wsrep_server_state::instance().disconnect(); - if (Wsrep_server_state::instance().wait_until_state( - Wsrep_server_state::s_disconnected)) - { - WSREP_WARN("Wsrep interrupted while waiting for disconnected state"); - } - } - - wsrep_close_client_connections(TRUE); - - /* wait until appliers have stopped */ - wsrep_wait_appliers_close(NULL); - node_uuid= WSREP_UUID_UNDEFINED; - + wsrep_stop_replication_common(nullptr); /* Undocking the thread specific data. */ - my_pthread_setspecific_ptr(THR_THD, NULL); + my_pthread_setspecific_ptr(THR_THD, nullptr); } bool wsrep_start_replication(const char *wsrep_cluster_address) @@ -2644,14 +2632,19 @@ static my_bool have_client_connections(THD *thd, void*) { DBUG_PRINT("quit",("Informing thread %lld that it's time to die", (longlong) thd->thread_id)); - if (is_client_connection(thd) && thd->killed == KILL_CONNECTION) + if (is_client_connection(thd)) { - WSREP_DEBUG("Informing thread %lld that it's time to die", - thd->thread_id); - (void)abort_replicated(thd); - return true; + if (thd->killed == KILL_CONNECTION) + { + (void)abort_replicated(thd); + return true; + } + if (thd->get_stmt_da()->is_eof()) + { + return true; + } } - return 0; + return false; } static void wsrep_close_thread(THD *thd) @@ -2691,14 +2684,24 @@ static my_bool kill_all_threads(THD *thd, THD *caller_thd) /* We skip slave threads & scheduler on this first loop through. */ if (is_client_connection(thd) && thd != caller_thd) { + if (thd->get_stmt_da()->is_eof()) + { + return 0; + } + if (is_replaying_connection(thd)) + { thd->set_killed(KILL_CONNECTION); - else if (!abort_replicated(thd)) + return 0; + } + + if (!abort_replicated(thd)) { /* replicated transactions must be skipped */ WSREP_DEBUG("closing connection %lld", (longlong) thd->thread_id); /* instead of wsrep_close_thread() we do now soft kill by THD::awake */ thd->awake(KILL_CONNECTION); + return 0; } } return 0; @@ -2710,6 +2713,7 @@ static my_bool kill_remaining_threads(THD *thd, THD *caller_thd) if (is_client_connection(thd) && !abort_replicated(thd) && !is_replaying_connection(thd) && + !thd->get_stmt_da()->is_eof() && thd_is_connection_alive(thd) && thd != caller_thd) { From fa1ae367f174e6b9c9d6c0274d61a56c8dba13b3 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 27 Mar 2024 01:23:42 +0100 Subject: [PATCH 026/313] galera: wsrep-lib submodule update --- wsrep-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wsrep-lib b/wsrep-lib index a5d95f0175f..dfc4bdb8a5d 160000 --- a/wsrep-lib +++ b/wsrep-lib @@ -1 +1 @@ -Subproject commit a5d95f0175f10b6127ea039c542725f6c4aa5cb9 +Subproject commit dfc4bdb8a5dcbd6fbea007ad3beff899a6b5b7bd From c77680768c154778068f68b4cb08b5720ef42ec7 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 14:20:12 +0100 Subject: [PATCH 027/313] MDEV-33460 use the correct sql_mode and fix for --view --- mysql-test/main/empty_string_literal.result | 5 +++-- mysql-test/main/empty_string_literal.test | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/empty_string_literal.result b/mysql-test/main/empty_string_literal.result index 569b9d5e9ca..a0d05fd6e6b 100644 --- a/mysql-test/main/empty_string_literal.result +++ b/mysql-test/main/empty_string_literal.result @@ -208,12 +208,13 @@ t1 CREATE TABLE `t1` ( KEY `a` (`a`,`b`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; +set sql_mode= default; # # MDEV-33460 select '123' 'x'; unexpected result # SELECT ''; -NULL -NULL + + SELECT '' 'b' 'c'; bc bc diff --git a/mysql-test/main/empty_string_literal.test b/mysql-test/main/empty_string_literal.test index 3320841fb42..e3ae009445b 100644 --- a/mysql-test/main/empty_string_literal.test +++ b/mysql-test/main/empty_string_literal.test @@ -25,12 +25,15 @@ flush tables; update t1 set a = 2; show create table t1; drop table t1; +set sql_mode= default; --echo # --echo # MDEV-33460 select '123' 'x'; unexpected result --echo # +--disable_view_protocol SELECT ''; +--enable_view_protocol SELECT '' 'b' 'c'; SELECT '' '' 'c'; SELECT 'a' '' 'c'; From c84d67a302bc8b197b2da1ddb02d5e29abc3e23e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 25 Mar 2024 12:20:16 +0100 Subject: [PATCH 028/313] reenable main.mysqldump-system test --- mysql-test/main/mysqldump-system.test | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mysql-test/main/mysqldump-system.test b/mysql-test/main/mysqldump-system.test index c1965410167..9aaa5fff6f9 100644 --- a/mysql-test/main/mysqldump-system.test +++ b/mysql-test/main/mysqldump-system.test @@ -3,10 +3,6 @@ --source include/have_udf.inc --source include/platform.inc -if (!$AUTH_SOCKET_SO) { - --skip Need auth socket plugin -} - --echo # --echo # MDEV-23630: mysqldump to logically dump system tables --echo # From 353f904ea91af919016633ed057e52aedfa9f235 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 25 Mar 2024 14:44:31 +0100 Subject: [PATCH 029/313] MDEV-31379 Undefined behavior in the reference Ed25519 implementation apply the fix from MXS-4686 --- plugin/auth_ed25519/ref10/fe_mul.c | 21 +++++---- plugin/auth_ed25519/ref10/fe_sq.c | 21 +++++---- plugin/auth_ed25519/ref10/fe_sq2.c | 21 +++++---- plugin/auth_ed25519/ref10/fe_tobytes.c | 37 +++++++-------- .../auth_ed25519/ref10/ge_scalarmult_base.c | 2 +- plugin/auth_ed25519/ref10/sc_muladd.c | 46 +++++++++---------- plugin/auth_ed25519/ref10/sc_reduce.c | 34 +++++++------- 7 files changed, 93 insertions(+), 89 deletions(-) diff --git a/plugin/auth_ed25519/ref10/fe_mul.c b/plugin/auth_ed25519/ref10/fe_mul.c index 26ca8b3682d..8ccad3c30d8 100644 --- a/plugin/auth_ed25519/ref10/fe_mul.c +++ b/plugin/auth_ed25519/ref10/fe_mul.c @@ -1,5 +1,6 @@ #include "fe.h" #include "crypto_int64.h" +#include "crypto_uint64.h" /* h = f * g @@ -179,16 +180,16 @@ void fe_mul(fe h,const fe f,const fe g) crypto_int64 h7 = f0g7+f1g6 +f2g5 +f3g4 +f4g3 +f5g2 +f6g1 +f7g0 +f8g9_19+f9g8_19; crypto_int64 h8 = f0g8+f1g7_2 +f2g6 +f3g5_2 +f4g4 +f5g3_2 +f6g2 +f7g1_2 +f8g0 +f9g9_38; crypto_int64 h9 = f0g9+f1g8 +f2g7 +f3g6 +f4g5 +f5g4 +f6g3 +f7g2 +f8g1 +f9g0 ; - crypto_int64 carry0; - crypto_int64 carry1; - crypto_int64 carry2; - crypto_int64 carry3; - crypto_int64 carry4; - crypto_int64 carry5; - crypto_int64 carry6; - crypto_int64 carry7; - crypto_int64 carry8; - crypto_int64 carry9; + crypto_uint64 carry0; + crypto_uint64 carry1; + crypto_uint64 carry2; + crypto_uint64 carry3; + crypto_uint64 carry4; + crypto_uint64 carry5; + crypto_uint64 carry6; + crypto_uint64 carry7; + crypto_uint64 carry8; + crypto_uint64 carry9; /* |h0| <= (1.65*1.65*2^52*(1+19+19+19+19)+1.65*1.65*2^50*(38+38+38+38+38)) diff --git a/plugin/auth_ed25519/ref10/fe_sq.c b/plugin/auth_ed25519/ref10/fe_sq.c index 8dd119841c6..3c718033a0a 100644 --- a/plugin/auth_ed25519/ref10/fe_sq.c +++ b/plugin/auth_ed25519/ref10/fe_sq.c @@ -1,5 +1,6 @@ #include "fe.h" #include "crypto_int64.h" +#include "crypto_uint64.h" /* h = f * f @@ -106,16 +107,16 @@ void fe_sq(fe h,const fe f) crypto_int64 h7 = f0f7_2+f1f6_2 +f2f5_2 +f3f4_2 +f8f9_38; crypto_int64 h8 = f0f8_2+f1f7_4 +f2f6_2 +f3f5_4 +f4f4 +f9f9_38; crypto_int64 h9 = f0f9_2+f1f8_2 +f2f7_2 +f3f6_2 +f4f5_2; - crypto_int64 carry0; - crypto_int64 carry1; - crypto_int64 carry2; - crypto_int64 carry3; - crypto_int64 carry4; - crypto_int64 carry5; - crypto_int64 carry6; - crypto_int64 carry7; - crypto_int64 carry8; - crypto_int64 carry9; + crypto_uint64 carry0; + crypto_uint64 carry1; + crypto_uint64 carry2; + crypto_uint64 carry3; + crypto_uint64 carry4; + crypto_uint64 carry5; + crypto_uint64 carry6; + crypto_uint64 carry7; + crypto_uint64 carry8; + crypto_uint64 carry9; carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; diff --git a/plugin/auth_ed25519/ref10/fe_sq2.c b/plugin/auth_ed25519/ref10/fe_sq2.c index 026ed3aacf5..97c03cf4899 100644 --- a/plugin/auth_ed25519/ref10/fe_sq2.c +++ b/plugin/auth_ed25519/ref10/fe_sq2.c @@ -1,5 +1,6 @@ #include "fe.h" #include "crypto_int64.h" +#include "crypto_uint64.h" /* h = 2 * f * f @@ -106,16 +107,16 @@ void fe_sq2(fe h,const fe f) crypto_int64 h7 = f0f7_2+f1f6_2 +f2f5_2 +f3f4_2 +f8f9_38; crypto_int64 h8 = f0f8_2+f1f7_4 +f2f6_2 +f3f5_4 +f4f4 +f9f9_38; crypto_int64 h9 = f0f9_2+f1f8_2 +f2f7_2 +f3f6_2 +f4f5_2; - crypto_int64 carry0; - crypto_int64 carry1; - crypto_int64 carry2; - crypto_int64 carry3; - crypto_int64 carry4; - crypto_int64 carry5; - crypto_int64 carry6; - crypto_int64 carry7; - crypto_int64 carry8; - crypto_int64 carry9; + crypto_uint64 carry0; + crypto_uint64 carry1; + crypto_uint64 carry2; + crypto_uint64 carry3; + crypto_uint64 carry4; + crypto_uint64 carry5; + crypto_uint64 carry6; + crypto_uint64 carry7; + crypto_uint64 carry8; + crypto_uint64 carry9; h0 += h0; h1 += h1; diff --git a/plugin/auth_ed25519/ref10/fe_tobytes.c b/plugin/auth_ed25519/ref10/fe_tobytes.c index 0a63baf9c17..a4dff2c1574 100644 --- a/plugin/auth_ed25519/ref10/fe_tobytes.c +++ b/plugin/auth_ed25519/ref10/fe_tobytes.c @@ -1,4 +1,5 @@ #include "fe.h" +#include "crypto_uint32.h" /* Preconditions: @@ -38,16 +39,16 @@ void fe_tobytes(unsigned char *s,const fe h) crypto_int32 h8 = h[8]; crypto_int32 h9 = h[9]; crypto_int32 q; - crypto_int32 carry0; - crypto_int32 carry1; - crypto_int32 carry2; - crypto_int32 carry3; - crypto_int32 carry4; - crypto_int32 carry5; - crypto_int32 carry6; - crypto_int32 carry7; - crypto_int32 carry8; - crypto_int32 carry9; + crypto_uint32 carry0; + crypto_uint32 carry1; + crypto_uint32 carry2; + crypto_uint32 carry3; + crypto_uint32 carry4; + crypto_uint32 carry5; + crypto_uint32 carry6; + crypto_uint32 carry7; + crypto_uint32 carry8; + crypto_uint32 carry9; q = (19 * h9 + (((crypto_int32) 1) << 24)) >> 25; q = (h0 + q) >> 26; @@ -87,32 +88,32 @@ void fe_tobytes(unsigned char *s,const fe h) s[0] = h0 >> 0; s[1] = h0 >> 8; s[2] = h0 >> 16; - s[3] = (h0 >> 24) | (h1 << 2); + s[3] = (h0 >> 24) | ((crypto_uint32)h1 << 2); s[4] = h1 >> 6; s[5] = h1 >> 14; - s[6] = (h1 >> 22) | (h2 << 3); + s[6] = (h1 >> 22) | ((crypto_uint32)h2 << 3); s[7] = h2 >> 5; s[8] = h2 >> 13; - s[9] = (h2 >> 21) | (h3 << 5); + s[9] = (h2 >> 21) | ((crypto_uint32)h3 << 5); s[10] = h3 >> 3; s[11] = h3 >> 11; - s[12] = (h3 >> 19) | (h4 << 6); + s[12] = (h3 >> 19) | ((crypto_uint32)h4 << 6); s[13] = h4 >> 2; s[14] = h4 >> 10; s[15] = h4 >> 18; s[16] = h5 >> 0; s[17] = h5 >> 8; s[18] = h5 >> 16; - s[19] = (h5 >> 24) | (h6 << 1); + s[19] = (h5 >> 24) | ((crypto_uint32)h6 << 1); s[20] = h6 >> 7; s[21] = h6 >> 15; - s[22] = (h6 >> 23) | (h7 << 3); + s[22] = (h6 >> 23) | ((crypto_uint32)h7 << 3); s[23] = h7 >> 5; s[24] = h7 >> 13; - s[25] = (h7 >> 21) | (h8 << 4); + s[25] = (h7 >> 21) | ((crypto_uint32)h8 << 4); s[26] = h8 >> 4; s[27] = h8 >> 12; - s[28] = (h8 >> 20) | (h9 << 6); + s[28] = (h8 >> 20) | ((crypto_uint32)h9 << 6); s[29] = h9 >> 2; s[30] = h9 >> 10; s[31] = h9 >> 18; diff --git a/plugin/auth_ed25519/ref10/ge_scalarmult_base.c b/plugin/auth_ed25519/ref10/ge_scalarmult_base.c index 421e4fa0fba..9a4ced2182f 100644 --- a/plugin/auth_ed25519/ref10/ge_scalarmult_base.c +++ b/plugin/auth_ed25519/ref10/ge_scalarmult_base.c @@ -35,7 +35,7 @@ static void select(ge_precomp *t,int pos,signed char b) { ge_precomp minust; unsigned char bnegative = negative(b); - unsigned char babs = b - (((-bnegative) & b) << 1); + unsigned char babs = b - ((unsigned char)((-bnegative) & b) << 1); ge_precomp_0(t); cmov(t,&base[pos][0],equal(babs,1)); diff --git a/plugin/auth_ed25519/ref10/sc_muladd.c b/plugin/auth_ed25519/ref10/sc_muladd.c index 6f1e9d02d60..7bf222be815 100644 --- a/plugin/auth_ed25519/ref10/sc_muladd.c +++ b/plugin/auth_ed25519/ref10/sc_muladd.c @@ -95,29 +95,29 @@ void sc_muladd(unsigned char *s,const unsigned char *a,const unsigned char *b,co crypto_int64 s21; crypto_int64 s22; crypto_int64 s23; - crypto_int64 carry0; - crypto_int64 carry1; - crypto_int64 carry2; - crypto_int64 carry3; - crypto_int64 carry4; - crypto_int64 carry5; - crypto_int64 carry6; - crypto_int64 carry7; - crypto_int64 carry8; - crypto_int64 carry9; - crypto_int64 carry10; - crypto_int64 carry11; - crypto_int64 carry12; - crypto_int64 carry13; - crypto_int64 carry14; - crypto_int64 carry15; - crypto_int64 carry16; - crypto_int64 carry17; - crypto_int64 carry18; - crypto_int64 carry19; - crypto_int64 carry20; - crypto_int64 carry21; - crypto_int64 carry22; + crypto_uint64 carry0; + crypto_uint64 carry1; + crypto_uint64 carry2; + crypto_uint64 carry3; + crypto_uint64 carry4; + crypto_uint64 carry5; + crypto_uint64 carry6; + crypto_uint64 carry7; + crypto_uint64 carry8; + crypto_uint64 carry9; + crypto_uint64 carry10; + crypto_uint64 carry11; + crypto_uint64 carry12; + crypto_uint64 carry13; + crypto_uint64 carry14; + crypto_uint64 carry15; + crypto_uint64 carry16; + crypto_uint64 carry17; + crypto_uint64 carry18; + crypto_uint64 carry19; + crypto_uint64 carry20; + crypto_uint64 carry21; + crypto_uint64 carry22; s0 = c0 + a0*b0; s1 = c1 + a0*b1 + a1*b0; diff --git a/plugin/auth_ed25519/ref10/sc_reduce.c b/plugin/auth_ed25519/ref10/sc_reduce.c index d01f5a5737e..422d94b6faf 100644 --- a/plugin/auth_ed25519/ref10/sc_reduce.c +++ b/plugin/auth_ed25519/ref10/sc_reduce.c @@ -58,23 +58,23 @@ void sc_reduce(unsigned char *s) crypto_int64 s21 = 2097151 & (load_3(s + 55) >> 1); crypto_int64 s22 = 2097151 & (load_4(s + 57) >> 6); crypto_int64 s23 = (load_4(s + 60) >> 3); - crypto_int64 carry0; - crypto_int64 carry1; - crypto_int64 carry2; - crypto_int64 carry3; - crypto_int64 carry4; - crypto_int64 carry5; - crypto_int64 carry6; - crypto_int64 carry7; - crypto_int64 carry8; - crypto_int64 carry9; - crypto_int64 carry10; - crypto_int64 carry11; - crypto_int64 carry12; - crypto_int64 carry13; - crypto_int64 carry14; - crypto_int64 carry15; - crypto_int64 carry16; + crypto_uint64 carry0; + crypto_uint64 carry1; + crypto_uint64 carry2; + crypto_uint64 carry3; + crypto_uint64 carry4; + crypto_uint64 carry5; + crypto_uint64 carry6; + crypto_uint64 carry7; + crypto_uint64 carry8; + crypto_uint64 carry9; + crypto_uint64 carry10; + crypto_uint64 carry11; + crypto_uint64 carry12; + crypto_uint64 carry13; + crypto_uint64 carry14; + crypto_uint64 carry15; + crypto_uint64 carry16; s11 += s23 * 666643; s12 += s23 * 470296; From 89fd381be854c244fd412d56da02b829ce15bce8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 25 Mar 2024 19:34:41 +0100 Subject: [PATCH 030/313] MDEV-25252 main.type_float fails in new buildbot disable approximate math in icx. and disable ansi aliasing too (aria loghandler unit tests fail) --- configure.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.cmake b/configure.cmake index fcfce85edb9..1ac875cde35 100644 --- a/configure.cmake +++ b/configure.cmake @@ -991,3 +991,8 @@ IF(have_C__Werror) ) SET(CMAKE_REQUIRED_FLAGS ${SAVE_CMAKE_REQUIRED_FLAGS}) ENDIF() + +IF(CMAKE_C_COMPILER_ID MATCHES "Intel") + MY_CHECK_AND_SET_COMPILER_FLAG("-no-ansi-alias") + MY_CHECK_AND_SET_COMPILER_FLAG("-fp-model precise") +ENDIF() From 8bb8820df2bd5340c80416c83c87561120915c90 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 26 Mar 2024 20:59:42 +0100 Subject: [PATCH 031/313] MDEV-22949 perfschema.memory_aggregate_no_a_no_u fails sporadically in buildbot with wrong result perfschema aggregation, like SHOW STATUS, is only statistically correct. It doesn't use atomics for performance reasons and might miss individual increments, particularly when two connections are disconnecting at the same time. To have stable results tests should avoid doing it. --- mysql-test/suite/perfschema/include/memory_aggregate_load.inc | 3 ++- mysql-test/suite/perfschema/r/memory_aggregate.result | 2 +- mysql-test/suite/perfschema/r/memory_aggregate_no_a.result | 2 +- .../suite/perfschema/r/memory_aggregate_no_a_no_h.result | 2 +- .../suite/perfschema/r/memory_aggregate_no_a_no_u.result | 2 +- .../suite/perfschema/r/memory_aggregate_no_a_no_u_no_h.result | 2 +- mysql-test/suite/perfschema/r/memory_aggregate_no_h.result | 2 +- mysql-test/suite/perfschema/r/memory_aggregate_no_u.result | 2 +- .../suite/perfschema/r/memory_aggregate_no_u_no_h.result | 2 +- 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mysql-test/suite/perfschema/include/memory_aggregate_load.inc b/mysql-test/suite/perfschema/include/memory_aggregate_load.inc index 7a54d25216e..c6e58d094d6 100644 --- a/mysql-test/suite/perfschema/include/memory_aggregate_load.inc +++ b/mysql-test/suite/perfschema/include/memory_aggregate_load.inc @@ -274,7 +274,6 @@ execute dump_users; execute dump_hosts; --disconnect con1 ---disconnect con5 --connection default @@ -283,6 +282,8 @@ let $wait_condition= select count(*) = 0 from performance_schema.threads where `TYPE`='FOREGROUND' and PROCESSLIST_USER= 'user1'; --source include/wait_condition.inc + +--disconnect con5 let $wait_condition= select count(*) = 1 from performance_schema.threads where `TYPE`='FOREGROUND' and PROCESSLIST_USER= 'user4'; diff --git a/mysql-test/suite/perfschema/r/memory_aggregate.result b/mysql-test/suite/perfschema/r/memory_aggregate.result index 69eb033e74b..1d963dd8caa 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate.result @@ -2507,8 +2507,8 @@ execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 6 6 disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/memory_aggregate_no_a.result b/mysql-test/suite/perfschema/r/memory_aggregate_no_a.result index b5c8e1cd3c7..abac503b965 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate_no_a.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate_no_a.result @@ -1903,8 +1903,8 @@ execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 6 6 disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_h.result b/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_h.result index cc0e0c03dcf..f63e6f1d002 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_h.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_h.result @@ -1653,8 +1653,8 @@ user4 2 2 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_u.result b/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_u.result index 8b24b5b565b..32785952fe7 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_u.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_u.result @@ -1343,8 +1343,8 @@ execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 6 6 disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_u_no_h.result b/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_u_no_h.result index 45cbaf88372..e68f0e1baf6 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_u_no_h.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate_no_a_no_u_no_h.result @@ -1093,8 +1093,8 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/memory_aggregate_no_h.result b/mysql-test/suite/perfschema/r/memory_aggregate_no_h.result index 35d528bf63c..e3b7cd0f998 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate_no_h.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate_no_h.result @@ -2257,8 +2257,8 @@ user4 2 2 execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/memory_aggregate_no_u.result b/mysql-test/suite/perfschema/r/memory_aggregate_no_u.result index 1f800ce4ba6..fd9f2c69a42 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate_no_u.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate_no_u.result @@ -1947,8 +1947,8 @@ execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 6 6 disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); diff --git a/mysql-test/suite/perfschema/r/memory_aggregate_no_u_no_h.result b/mysql-test/suite/perfschema/r/memory_aggregate_no_u_no_h.result index b1ac5f24ec9..fdbd2d75d56 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate_no_u_no_h.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate_no_u_no_h.result @@ -1697,8 +1697,8 @@ USER CURRENT_CONNECTIONS TOTAL_CONNECTIONS execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); From 49f2e9f700c2a3e3972fc1872eecac444b030a50 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 00:05:00 +0100 Subject: [PATCH 032/313] update bison version dependency need at least 2.4 because we use per-type %destructor that was added after 2.3 in 2.3a --- sql/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index c33e6454e20..bb86d5cac66 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -65,7 +65,7 @@ ADD_CUSTOM_COMMAND( DEPENDS gen_lex_token ) -FIND_PACKAGE(BISON 2.0) +FIND_PACKAGE(BISON 2.4) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yy_mariadb.yy From dc681953cf57da17cf566f4ef14e15589507955f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 09:51:28 +0100 Subject: [PATCH 033/313] events in perfschema tests: use ON COMPLETION NOT PRESERVE when the execution is very slow, under valgrind, the event might manage to fire more than once, making the test to fail --- mysql-test/suite/perfschema/include/program_execution.inc | 2 +- .../r/statement_program_nesting_event_check.result | 4 ++-- .../suite/perfschema/r/statement_program_non_nested.result | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/perfschema/include/program_execution.inc b/mysql-test/suite/perfschema/include/program_execution.inc index 8c0bc691898..f774a4d7b50 100644 --- a/mysql-test/suite/perfschema/include/program_execution.inc +++ b/mysql-test/suite/perfschema/include/program_execution.inc @@ -32,7 +32,7 @@ SET GLOBAL event_scheduler=ON; CREATE TABLE table_t(a INT); DELIMITER |; -CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND DO +CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND ON COMPLETION NOT PRESERVE DO BEGIN INSERT INTO table_t VALUES(1); END| diff --git a/mysql-test/suite/perfschema/r/statement_program_nesting_event_check.result b/mysql-test/suite/perfschema/r/statement_program_nesting_event_check.result index 5e376a12a18..1a973c9448b 100644 --- a/mysql-test/suite/perfschema/r/statement_program_nesting_event_check.result +++ b/mysql-test/suite/perfschema/r/statement_program_nesting_event_check.result @@ -145,7 +145,7 @@ Bollywood # Event SET GLOBAL event_scheduler=ON; CREATE TABLE table_t(a INT); -CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND DO +CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND ON COMPLETION NOT PRESERVE DO BEGIN INSERT INTO table_t VALUES(1); END| @@ -165,7 +165,7 @@ statement/sql/call_procedure CALL SampleProc1(30,40,50) NULL NULL 0 statement/sql/call_procedure CALL SampleProc2("Jwalamukhi",34) NULL NULL 0 statement/sql/call_procedure CALL SampleProc3() NULL NULL 0 statement/sql/call_procedure CALL SampleProc4() NULL NULL 0 -statement/sql/create_event CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND DO +statement/sql/create_event CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND ON COMPLETION NOT PRESERVE DO BEGIN INSERT INTO table_t VALUES(1); END NULL NULL 0 diff --git a/mysql-test/suite/perfschema/r/statement_program_non_nested.result b/mysql-test/suite/perfschema/r/statement_program_non_nested.result index af9807cbc97..1c75dac11ac 100644 --- a/mysql-test/suite/perfschema/r/statement_program_non_nested.result +++ b/mysql-test/suite/perfschema/r/statement_program_non_nested.result @@ -145,7 +145,7 @@ Bollywood # Event SET GLOBAL event_scheduler=ON; CREATE TABLE table_t(a INT); -CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND DO +CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND ON COMPLETION NOT PRESERVE DO BEGIN INSERT INTO table_t VALUES(1); END| @@ -182,7 +182,7 @@ statement/sql/call_procedure CALL SampleProc1(30,40,50) stored_programs NULL NUL statement/sql/call_procedure CALL SampleProc2("Jwalamukhi",34) stored_programs NULL NULL NULL NULL 0 statement/sql/call_procedure CALL SampleProc3() stored_programs NULL NULL NULL NULL 0 statement/sql/call_procedure CALL SampleProc4() stored_programs NULL NULL NULL NULL 0 -statement/sql/create_event CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND DO +statement/sql/create_event CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND ON COMPLETION NOT PRESERVE DO BEGIN INSERT INTO table_t VALUES(1); END stored_programs NULL NULL NULL NULL 0 @@ -553,7 +553,7 @@ Bollywood # Event SET GLOBAL event_scheduler=ON; CREATE TABLE table_t(a INT); -CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND DO +CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND ON COMPLETION NOT PRESERVE DO BEGIN INSERT INTO table_t VALUES(1); END| From f50694c52be8de72adca27e1f9623aa90ed26a48 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 09:53:56 +0100 Subject: [PATCH 034/313] remove pointless test --- .../r/innodb_purge_threads_basic.result | 41 -------------- .../t/innodb_purge_threads_basic.test | 53 ------------------- 2 files changed, 94 deletions(-) delete mode 100644 mysql-test/suite/sys_vars/r/innodb_purge_threads_basic.result delete mode 100644 mysql-test/suite/sys_vars/t/innodb_purge_threads_basic.test diff --git a/mysql-test/suite/sys_vars/r/innodb_purge_threads_basic.result b/mysql-test/suite/sys_vars/r/innodb_purge_threads_basic.result deleted file mode 100644 index 2cb697acb6d..00000000000 --- a/mysql-test/suite/sys_vars/r/innodb_purge_threads_basic.result +++ /dev/null @@ -1,41 +0,0 @@ -SELECT COUNT(@@GLOBAL.innodb_purge_threads); -COUNT(@@GLOBAL.innodb_purge_threads) -1 -1 Expected -SELECT COUNT(@@innodb_purge_threads); -COUNT(@@innodb_purge_threads) -1 -1 Expected -SET @@GLOBAL.innodb_purge_threads=1; -ERROR HY000: Variable 'innodb_purge_threads' is a read only variable -Expected error 'Read-only variable' -SELECT innodb_purge_threads = @@SESSION.innodb_purge_threads; -ERROR 42S22: Unknown column 'innodb_purge_threads' in 'field list' -Expected error 'Read-only variable' -SELECT @@GLOBAL.innodb_purge_threads = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='innodb_purge_threads'; -@@GLOBAL.innodb_purge_threads = VARIABLE_VALUE -1 -1 Expected -SELECT COUNT(VARIABLE_VALUE) -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='innodb_purge_threads'; -COUNT(VARIABLE_VALUE) -1 -1 Expected -SELECT @@innodb_purge_threads = @@GLOBAL.innodb_purge_threads; -@@innodb_purge_threads = @@GLOBAL.innodb_purge_threads -1 -1 Expected -SELECT COUNT(@@local.innodb_purge_threads); -ERROR HY000: Variable 'innodb_purge_threads' is a GLOBAL variable -Expected error 'Variable is a GLOBAL variable' -SELECT COUNT(@@SESSION.innodb_purge_threads); -ERROR HY000: Variable 'innodb_purge_threads' is a GLOBAL variable -Expected error 'Variable is a GLOBAL variable' -SELECT VARIABLE_NAME, VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME = 'innodb_purge_threads'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_PURGE_THREADS 4 diff --git a/mysql-test/suite/sys_vars/t/innodb_purge_threads_basic.test b/mysql-test/suite/sys_vars/t/innodb_purge_threads_basic.test deleted file mode 100644 index 4d039601e40..00000000000 --- a/mysql-test/suite/sys_vars/t/innodb_purge_threads_basic.test +++ /dev/null @@ -1,53 +0,0 @@ -# Variable name: innodb_purge_threads -# Scope: Global -# Access type: Static -# Data type: numeric - ---source include/have_innodb.inc - -SELECT COUNT(@@GLOBAL.innodb_purge_threads); ---echo 1 Expected - -SELECT COUNT(@@innodb_purge_threads); ---echo 1 Expected - ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -SET @@GLOBAL.innodb_purge_threads=1; ---echo Expected error 'Read-only variable' - ---Error ER_BAD_FIELD_ERROR -SELECT innodb_purge_threads = @@SESSION.innodb_purge_threads; ---echo Expected error 'Read-only variable' - ---disable_warnings -SELECT @@GLOBAL.innodb_purge_threads = VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='innodb_purge_threads'; ---enable_warnings ---echo 1 Expected - ---disable_warnings -SELECT COUNT(VARIABLE_VALUE) -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME='innodb_purge_threads'; ---enable_warnings ---echo 1 Expected - -SELECT @@innodb_purge_threads = @@GLOBAL.innodb_purge_threads; ---echo 1 Expected - ---Error ER_INCORRECT_GLOBAL_LOCAL_VAR -SELECT COUNT(@@local.innodb_purge_threads); ---echo Expected error 'Variable is a GLOBAL variable' - ---Error ER_INCORRECT_GLOBAL_LOCAL_VAR -SELECT COUNT(@@SESSION.innodb_purge_threads); ---echo Expected error 'Variable is a GLOBAL variable' - -# Check the default value ---disable_warnings -SELECT VARIABLE_NAME, VARIABLE_VALUE -FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES -WHERE VARIABLE_NAME = 'innodb_purge_threads'; ---enable_warnings - From 721a6a5e6be2c76f3806de36f80e4c6e09795daf Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 11:38:36 +0100 Subject: [PATCH 035/313] plugins.test_sql_service --valgrind plugin var check function must store the new variable value in *save --- plugin/test_sql_service/test_sql_service.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/test_sql_service/test_sql_service.c b/plugin/test_sql_service/test_sql_service.c index 4ea6533af84..94031e36231 100644 --- a/plugin/test_sql_service/test_sql_service.c +++ b/plugin/test_sql_service/test_sql_service.c @@ -129,6 +129,7 @@ void auditing(MYSQL_THD thd, unsigned int event_class, const void *ev) static int run_test(MYSQL_THD thd, struct st_mysql_sys_var *var, void *save, struct st_mysql_value *value) { + *(my_bool*)save= 1; // must initialize the return value return (test_passed= (do_tests() == 0)) == 0; } @@ -139,6 +140,7 @@ static int run_sql(MYSQL *mysql, void *save, struct st_mysql_value *value) int len= 0; MYSQL_RES *res; + *(my_bool*)save= 1; // must initialize the return value str= value->val_str(value, NULL, &len); if (mysql_real_query(mysql, str, len)) From 58c7f63176fa63c4df25e01f48ac4edd4acb76db Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 15:01:28 +0100 Subject: [PATCH 036/313] mysqltest: better error reporting when "shutdown" fails as a side effect --replace and --error now work for shutdown command --- client/mysqltest.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 7a36f460799..f1ddea7c083 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5199,7 +5199,11 @@ void do_shutdown_server(struct st_command *command) */ if (timeout && mysql_shutdown(mysql, SHUTDOWN_DEFAULT)) - die("mysql_shutdown failed"); + { + handle_error(command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + DBUG_VOID_RETURN; + } if (!timeout || wait_until_dead(pid, timeout)) { @@ -8191,7 +8195,7 @@ static int match_expected_error(struct st_command *command, SYNOPSIS handle_error() - q - query context + command - command err_errno - error number err_error - error message err_sqlstate - sql state From 3226787bba5d8e825e7d32e864e3a522b9ded65f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 15:14:31 +0100 Subject: [PATCH 037/313] Revert "Fixed random failure in main.kill_processlist-6619" This reverts commit 8b3f470c0bdf183b26cb2b06a9ae416aa7f16b04. because it doesn't work, the test still fails, and even more than before --- mysql-test/main/kill_processlist-6619.result | 6 ------ mysql-test/main/kill_processlist-6619.test | 9 --------- 2 files changed, 15 deletions(-) diff --git a/mysql-test/main/kill_processlist-6619.result b/mysql-test/main/kill_processlist-6619.result index 25831a1f63b..7dd42790cc7 100644 --- a/mysql-test/main/kill_processlist-6619.result +++ b/mysql-test/main/kill_processlist-6619.result @@ -1,8 +1,4 @@ -SET DEBUG_SYNC='dispatch_command_end SIGNAL ready WAIT_FOR go'; -select 1; connect con1,localhost,root,,; -SET DEBUG_SYNC='now wait_for ready'; -SET DEBUG_SYNC='now signal go'; SHOW PROCESSLIST; Id User Host db Command Time State Info Progress # root # test Sleep # # NULL 0.000 @@ -10,8 +6,6 @@ Id User Host db Command Time State Info Progress SET DEBUG_SYNC='before_execute_sql_command SIGNAL ready WAIT_FOR go'; SHOW PROCESSLIST; connection default; -1 -1 SET DEBUG_SYNC='now WAIT_FOR ready'; KILL QUERY con_id; SET DEBUG_SYNC='now SIGNAL go'; diff --git a/mysql-test/main/kill_processlist-6619.test b/mysql-test/main/kill_processlist-6619.test index 7330c79acd8..c272e68a877 100644 --- a/mysql-test/main/kill_processlist-6619.test +++ b/mysql-test/main/kill_processlist-6619.test @@ -4,14 +4,7 @@ --source include/not_embedded.inc --source include/have_debug_sync.inc -# This is to ensure that the following SHOW PROCESSLIST does not show the query -SET DEBUG_SYNC='dispatch_command_end SIGNAL ready WAIT_FOR go'; ---send select 1 - --connect (con1,localhost,root,,) -SET DEBUG_SYNC='now wait_for ready'; -SET DEBUG_SYNC='now signal go'; - --let $con_id = `SELECT CONNECTION_ID()` --replace_result Execute Query --replace_column 1 # 3 # 6 # 7 # @@ -19,8 +12,6 @@ SHOW PROCESSLIST; SET DEBUG_SYNC='before_execute_sql_command SIGNAL ready WAIT_FOR go'; send SHOW PROCESSLIST; --connection default ---reap - # We must wait for the SHOW PROCESSLIST query to have started before sending # the kill. Otherwise, the KILL may be lost since it is reset at the start of # query execution. From 81f75ca83ae618bcdd5893fa690aaded35cba0e9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 15:21:49 +0100 Subject: [PATCH 038/313] Fixed random failure in main.kill_processlist-6619 wait for all previous connections to disconnect and for all previous queries to finish running --- mysql-test/main/kill_processlist-6619.test | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mysql-test/main/kill_processlist-6619.test b/mysql-test/main/kill_processlist-6619.test index c272e68a877..09c41f28a8f 100644 --- a/mysql-test/main/kill_processlist-6619.test +++ b/mysql-test/main/kill_processlist-6619.test @@ -4,8 +4,15 @@ --source include/not_embedded.inc --source include/have_debug_sync.inc +let $wait_condition=select count(*) = 1 from information_schema.processlist; +source include/wait_condition.inc; + --connect (con1,localhost,root,,) --let $con_id = `SELECT CONNECTION_ID()` + +let $wait_condition=select info is NULL from information_schema.processlist where id != $con_id; +source include/wait_condition.inc; + --replace_result Execute Query --replace_column 1 # 3 # 6 # 7 # SHOW PROCESSLIST; From 0b627377a95d01c3f1dd1bfff52523bb48d5d5e7 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 13 Mar 2024 13:10:47 +1100 Subject: [PATCH 039/313] MDEV-33661 MENT-1591 Documenting spider_mon_table_cache and friends. Partial documentation due to time constraints. Will improve over time. Also removed a redundant parameter link_idx from spider_get_sys_tables_connect_info(). And deleted some commented out code. --- storage/spider/spd_copy_tables.cc | 2 +- storage/spider/spd_include.h | 1 + storage/spider/spd_ping_table.cc | 128 ++++++++++++++++++++---------- storage/spider/spd_sys_table.cc | 71 ++++++++++------- storage/spider/spd_sys_table.h | 3 +- storage/spider/spd_table.cc | 48 ++++------- 6 files changed, 150 insertions(+), 103 deletions(-) diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index 34e3cb66712..d205cd244ca 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -307,7 +307,7 @@ int spider_udf_get_copy_tgt_tables( if ( (error_num = spider_get_sys_tables_connect_info( - table_tables, tmp_share, 0, mem_root)) || + table_tables, tmp_share, mem_root)) || (error_num = spider_get_sys_tables_link_status( table_tables, tmp_share, 0, mem_root)) || (error_num = spider_get_sys_tables_link_idx( diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 0e72ce26696..51fac2a4cea 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -1606,6 +1606,7 @@ typedef struct st_spider_table_mon st_spider_table_mon *next; } SPIDER_TABLE_MON; +/* List of `SPIDER_TABLE_MON's */ typedef struct st_spider_table_mon_list { char *key; diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 34d643d3555..92f5ff9e69f 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -54,6 +54,8 @@ extern PSI_mutex_key spd_key_mutex_mon_list_update_status; extern PSI_mutex_key spd_key_mutex_mon_table_cache; #endif +/* Array (of size `spider_udf_table_mon_mutex_count') of hashes of +`SPIDER_TABLE_MON_LIST'. */ HASH *spider_udf_table_mon_list_hash; uint spider_udf_table_mon_list_hash_id; const char *spider_udf_table_mon_list_hash_func_name; @@ -63,23 +65,43 @@ pthread_mutex_t *spider_udf_table_mon_mutexes; pthread_cond_t *spider_udf_table_mon_conds; pthread_mutex_t spider_mon_table_cache_mutex; +/* A cache to store distinct SPIDER_MON_KEYs with db name, table name +and link id read from mysql.spider_link_mon_servers table. Initialised +and populated in spider_init_ping_table_mon_cache(), and used in +spider_ping_table_cache_compare(). The udf +spider_flush_table_mon_cache is used to flag a initialisation. */ DYNAMIC_ARRAY spider_mon_table_cache; uint spider_mon_table_cache_id; const char *spider_mon_table_cache_func_name; const char *spider_mon_table_cache_file_name; ulong spider_mon_table_cache_line_no; +/* The mon table cache version, initialised at 0, and always no +greater than spider_mon_table_cache_version_req. When the inequality +is strict, an initialisation of spider_mon_table_cache will be +triggered. */ volatile ulonglong spider_mon_table_cache_version = 0; +/* The required mon table cache version, incremented by one by the +udf spider_flush_table_mon_cache */ volatile ulonglong spider_mon_table_cache_version_req = 1; + /* Get or create a `SPIDER_TABLE_MON_LIST' for a key `str' */ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( SPIDER_TRX *trx, THD *thd, - spider_string *str, + spider_string *str, /* The key to search in + `spider_udf_table_mon_list_hash', + usually in the format of + "./$db_name/$table_name000000000$link_idx" */ uint conv_name_length, int link_idx, char *static_link_id, uint static_link_id_length, - uint32 server_id, + uint32 server_id, /* The server id of the monitor + server, used for creating a new + table mon list having a + `SPIDER_TABLE_MON' corresponding to + the server id as the `current' + field */ bool need_lock, int *error_num ) { @@ -91,6 +113,7 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( my_hash_value_type hash_value; #endif DBUG_ENTER("spider_get_ping_table_mon_list"); + /* Reset the cache if the version does not match the requirement */ if (spider_mon_table_cache_version != spider_mon_table_cache_version_req) { SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME)); @@ -103,6 +126,9 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( free_root(&mem_root, MYF(0)); } + /* Search for the table mon list in the hash, if one is not found or + if it is found but has the wrong cache version, create and + initialise a new one. */ mutex_hash = spider_udf_calc_hash(str->c_ptr(), spider_param_udf_table_mon_mutex_count()); DBUG_PRINT("info",("spider hash key=%s", str->c_ptr())); @@ -129,12 +155,15 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( ) #endif { + /* If table_mon_list is found but the cache version does not + match, remove it from the hash and free it. */ if ( table_mon_list && table_mon_list->mon_table_cache_version != mon_table_cache_version ) spider_release_ping_table_mon_list_loop(mutex_hash, table_mon_list); - + /* create and initialise `table_mon_list' and insert it into the + hash */ if (!(table_mon_list = spider_get_ping_table_tgt(thd, str->c_ptr(), conv_name_length, link_idx, static_link_id, static_link_id_length, server_id, str, need_lock, error_num))) @@ -277,6 +306,14 @@ int spider_release_ping_table_mon_list( DBUG_RETURN(0); } +/* + Look for a `SPIDER_MON_KEY` in `spider_mon_table_cache' whose db and + table name and link_idx matching `name' and `link_idx' with wild + card matching. If a match is found, create `SPIDER_TABLE_MON's from + all rows in mysql.spider_link_mon_servers that match the info in the + `SPIDER_MON_KEY' and populate the `table_mon_list' with these + `SPIDER_TABLE_MON's. +*/ int spider_get_ping_table_mon( THD *thd, SPIDER_TABLE_MON_LIST *table_mon_list, @@ -357,6 +394,8 @@ int spider_get_ping_table_mon( goto error; create_table_mon: + /* Find the first row in mysql.spider_link_mon_servers matching the + db name, table name and link_idx */ if ((error_num = spider_get_sys_table_by_idx(table_link_mon, table_key, table_link_mon->s->primary_key, 3))) { @@ -364,6 +403,9 @@ create_table_mon: goto error; } + /* create one `SPIDER_TABLE_MON' per row in + mysql.spider_link_mon_servers with matching db name, table name and + link_idx, and add it to `table_mon_list'. */ do { if (!(table_mon = (SPIDER_TABLE_MON *) spider_bulk_malloc(spider_current_trx, SPD_MID_GET_PING_TABLE_MON_1, MYF(MY_WME | MY_ZEROFILL), @@ -394,7 +436,7 @@ create_table_mon: (error_num = spider_get_sys_link_mon_server_id( table_link_mon, &table_mon->server_id, mem_root)) || (error_num = spider_get_sys_link_mon_connect_info( - table_link_mon, tmp_share, 0, mem_root)) + table_link_mon, tmp_share, mem_root)) ) { table_link_mon->file->print_error(error_num, MYF(0)); spider_sys_index_end(table_link_mon); @@ -458,15 +500,21 @@ error: DBUG_RETURN(error_num); } +/* + creates and return table_mon_list associated with table with `name' + and `link_idx'th link. +*/ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( THD *thd, - char *name, + char *name, /* The table name, usually fully qualified */ uint name_length, int link_idx, char *static_link_id, uint static_link_id_length, - uint32 server_id, - spider_string *str, + uint32 server_id, /* The server_id will determine the + `current' field of the returned + `SPIDER_TABLE_MON_LIST'. */ + spider_string *str, /* str->c_ptr() == name */ bool need_lock, int *error_num ) { @@ -511,6 +559,7 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( memcpy(key_str, str->ptr(), table_mon_list->key_length); tmp_share->access_charset = thd->variables.character_set_client; + /* Open mysql.spider_tables */ if ( !(table_tables = spider_open_sys_table( thd, SPIDER_SYS_TABLES_TABLE_NAME_STR, @@ -520,6 +569,8 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( my_error(*error_num, MYF(0)); goto error; } + /* store db and table names and link idx in mysql.spider_tables for + reading */ spider_store_tables_name(table_tables, name, name_length); if (static_link_id) { @@ -543,9 +594,10 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( goto error; } } + /* Populate tmp_share with info read from mysql.spider_tables */ if ( (*error_num = spider_get_sys_tables_connect_info( - table_tables, tmp_share, 0, &mem_root)) || + table_tables, tmp_share, &mem_root)) || (*error_num = spider_get_sys_tables_link_status( table_tables, tmp_share, 0, &mem_root)) ) { @@ -569,9 +621,8 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( tmp_share, name, name_length )) || (*error_num = spider_create_conn_keys(tmp_share)) || -/* - (*error_num = spider_db_create_table_names_str(tmp_share)) || -*/ + /* Pinally, populate `table_mon_list' with newly created + `SPIDER_TABLE_MON's */ (*error_num = spider_get_ping_table_mon( thd, table_mon_list, name, name_length, link_idx, server_id, &mem_root, need_lock)) @@ -836,6 +887,11 @@ error_open_table_tables: DBUG_RETURN(error_num); } +/* + Initialise `spider_mon_table_cache' by scanning the + mysql.spider_link_mon_servers table, creating distinct + `SPIDER_MON_KEY's with the info and inserting them into the cache. +*/ int spider_init_ping_table_mon_cache( THD *thd, MEM_ROOT *mem_root, @@ -867,6 +923,7 @@ int spider_init_ping_table_mon_cache( /* reset */ spider_mon_table_cache.elements = 0; + /* start at the first row */ if ((error_num = spider_sys_index_first(table_link_mon, table_link_mon->s->primary_key))) { @@ -883,10 +940,16 @@ int spider_init_ping_table_mon_cache( mon_key.table_name_length = SPIDER_SYS_LINK_MON_TABLE_TABLE_NAME_SIZE + 1; mon_key.link_id_length = SPIDER_SYS_LINK_MON_TABLE_LINK_ID_SIZE + 1; do { + /* update content of `mon_key' */ if ((error_num = spider_get_sys_link_mon_key(table_link_mon, &mon_key, mem_root, &same))) goto error_get_sys_link_mon_key; + /* `mon_key' has changed content. since + mysql.spider_link_mon_servers is indexed by db_name, + table_name, link_idx, and server_id, it is possible that + different server_ids share the same mon_key which only has + db_name, table_name, link_idx */ if (!same) { mon_key.sort = spider_calc_for_sort(3, mon_key.db_name, @@ -941,6 +1004,13 @@ error_open_sys_table: DBUG_RETURN(error_num); } +/* + Read from msyql.spider_link_mon_servers table fields the db name, + table name and link_id and search for them with wild card matching + in `spider_mon_table_cache'. store the db name, table name, and + link_id of the matching `SPIDER_MON_KEY' back to the table field on + success. +*/ int spider_ping_table_cache_compare( TABLE *table, MEM_ROOT *mem_root @@ -1239,9 +1309,6 @@ long long spider_ping_table_body( DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_NG 2")); if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) { -/* - pthread_mutex_lock(&table_mon_list->update_status_mutex); -*/ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) { @@ -1256,9 +1323,6 @@ long long spider_ping_table_body( conv_name.c_ptr(), conv_name_length, link_idx, TRUE); status_changed_to_ng = TRUE; } -/* - pthread_mutex_unlock(&table_mon_list->update_status_mutex); -*/ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); if (status_changed_to_ng) { @@ -1312,9 +1376,6 @@ long long spider_ping_table_body( DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_NG 3")); if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) { -/* - pthread_mutex_lock(&table_mon_list->update_status_mutex); -*/ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) { @@ -1329,9 +1390,6 @@ long long spider_ping_table_body( conv_name.c_ptr(), conv_name_length, link_idx, TRUE); status_changed_to_ng = TRUE; } -/* - pthread_mutex_unlock(&table_mon_list->update_status_mutex); -*/ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); if (status_changed_to_ng) { @@ -1375,9 +1433,6 @@ long long spider_ping_table_body( mon_table_result->result_status == SPIDER_LINK_MON_NG && table_mon_list->mon_status != SPIDER_LINK_MON_NG ) { -/* - pthread_mutex_lock(&table_mon_list->update_status_mutex); -*/ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) { @@ -1392,9 +1447,6 @@ long long spider_ping_table_body( conv_name.c_ptr(), conv_name_length, link_idx, TRUE); status_changed_to_ng = TRUE; } -/* - pthread_mutex_unlock(&table_mon_list->update_status_mutex); -*/ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); if (status_changed_to_ng) { @@ -1565,9 +1617,9 @@ int spider_ping_table_mon_from_table( SPIDER_SHARE *share, int base_link_idx, uint32 server_id, - char *conv_name, + char *conv_name, /* Usually fully qualified table name */ uint conv_name_length, - int link_idx, + int link_idx, /* The link id to ping */ char *where_clause, uint where_clause_length, long monitoring_kind, @@ -1577,9 +1629,6 @@ int spider_ping_table_mon_from_table( ) { int error_num = 0, current_mon_count, flags; uint32 first_sid; -/* - THD *thd = trx->thd; -*/ SPIDER_TABLE_MON_LIST *table_mon_list; SPIDER_TABLE_MON *table_mon; SPIDER_MON_TABLE_RESULT mon_table_result; @@ -1648,6 +1697,7 @@ int spider_ping_table_mon_from_table( if (monitoring_flag & 1) flags |= SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES; + /* 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], @@ -1679,6 +1729,8 @@ int spider_ping_table_mon_from_table( table_mon = table_mon_list->current; first_sid = table_mon->server_id; current_mon_count = 1; + /* Call spider_ping_table on each table_mon of `table_mon_list', + until one succeeds */ while (TRUE) { DBUG_PRINT("info",("spider thd->killed=%s", @@ -1723,16 +1775,13 @@ 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, - where_clause, where_clause_length, -1, table_mon_list->list_size, + where_clause, where_clause_length, /*first_sid=*/-1, table_mon_list->list_size, 0, 0, 0, flags, monitoring_limit)) { if ( mon_table_result.result_status == SPIDER_LINK_MON_NG && table_mon_list->mon_status != SPIDER_LINK_MON_NG ) { -/* - pthread_mutex_lock(&table_mon_list->update_status_mutex); -*/ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); if (table_mon_list->mon_status != SPIDER_LINK_MON_NG) { @@ -1747,9 +1796,6 @@ int spider_ping_table_mon_from_table( spider_sys_log_tables_link_failed(thd, conv_name, conv_name_length, link_idx, need_lock); } -/* - pthread_mutex_unlock(&table_mon_list->update_status_mutex); -*/ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]); } table_mon_list->last_caller_result = mon_table_result.result_status; diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index f33a5373168..10f9fdedd5b 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -570,6 +570,11 @@ int spider_check_sys_table_for_update_all_columns( #endif } +/* + Creates a key (`table_key') consisting of `col_count' key parts of + `idx'th index of the table, then positions an index cursor to that + key. +*/ int spider_get_sys_table_by_idx( TABLE *table, char *table_key, @@ -602,17 +607,6 @@ int spider_get_sys_table_by_idx( key_length); if ( -/* -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 - (error_num = table->file->ha_index_read_idx_map( - table->record[0], idx, (uchar *) table_key, - make_prev_keypart_map(col_count), HA_READ_KEY_EXACT)) -#else - (error_num = table->file->index_read_idx_map( - table->record[0], idx, (uchar *) table_key, - make_prev_keypart_map(col_count), HA_READ_KEY_EXACT)) -#endif -*/ #if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 (error_num = table->file->ha_index_read_map( table->record[0], (uchar *) table_key, @@ -649,7 +643,7 @@ int spider_sys_index_next_same( int spider_sys_index_first( TABLE *table, - const int idx + const int idx /* which index to use */ ) { int error_num; DBUG_ENTER("spider_sys_index_first"); @@ -870,6 +864,10 @@ void spider_store_xa_member_info( DBUG_VOID_RETURN; } +/* + Store db and table names from `name' to `table's corresponding + fields +*/ void spider_store_tables_name( TABLE *table, const char *name, @@ -2064,14 +2062,16 @@ int spider_get_sys_tables( DBUG_RETURN(0); } +/* Read table info from mysql.spider_tables into a `SPIDER_SHARE' */ int spider_get_sys_tables_connect_info( - TABLE *table, - SPIDER_SHARE *share, - int link_idx, + TABLE *table, /* The mysql.spider_tables table */ + SPIDER_SHARE *share, /* The `SPIDER_SHARE' to + update info */ MEM_ROOT *mem_root ) { char *ptr; int error_num = 0; + const int link_idx= 0; DBUG_ENTER("spider_get_sys_tables_connect_info"); if ((ptr = get_field(mem_root, table->field[3]))) { @@ -2297,9 +2297,14 @@ int spider_get_sys_tables_monitoring_binlog_pos_at_failing( DBUG_RETURN(error_num); } +/* + Read the link status from mysql.spider_tables into a `SPIDER_SHARE' + with default value 1 (`SPIDER_LINK_STATUS_OK') +*/ int spider_get_sys_tables_link_status( - TABLE *table, - SPIDER_SHARE *share, + TABLE *table, /* The mysql.spider_tables table */ + SPIDER_SHARE *share, /* The share to read link + status into */ int link_idx, MEM_ROOT *mem_root ) { @@ -2484,11 +2489,17 @@ error: DBUG_RETURN(error_num); } +/* Populate `mon_key' from the current row in `table' */ int spider_get_sys_link_mon_key( - TABLE *table, - SPIDER_MON_KEY *mon_key, + TABLE *table, /* the mysql.spider_link_mon_servers + table */ + SPIDER_MON_KEY *mon_key, /* output, to be populated in this + function */ MEM_ROOT *mem_root, - int *same + int *same /* output, true if the data from the + current row in the table agrees with + existing data in `mon_key' and false + otherwise */ ) { char *db_name, *table_name, *link_id; uint db_name_length, table_name_length, link_id_length; @@ -2504,6 +2515,7 @@ int spider_get_sys_link_mon_key( DBUG_RETURN(ER_SPIDER_SYS_TABLE_VERSION_NUM); } + /* get data for `mon_key' from the table record */ if (!(db_name = get_field(mem_root, table->field[0]))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); if (!(table_name = get_field(mem_root, table->field[1]))) @@ -2549,9 +2561,12 @@ int spider_get_sys_link_mon_key( DBUG_RETURN(0); } +/* Get the server id from the spider_link_mon_servers table field */ int spider_get_sys_link_mon_server_id( - TABLE *table, - uint32 *server_id, + TABLE *table, /* the + mysql.spider_link_mon_servers + table */ + uint32 *server_id, /* output to server_id */ MEM_ROOT *mem_root ) { char *ptr; @@ -2564,14 +2579,17 @@ int spider_get_sys_link_mon_server_id( DBUG_RETURN(error_num); } +/* Get connect info from the spider_link_mon_servers table fields */ int spider_get_sys_link_mon_connect_info( - TABLE *table, - SPIDER_SHARE *share, - int link_idx, + TABLE *table, /* The + mysql.spider_link_mon_servers + table */ + SPIDER_SHARE *share, /* The output spider_share */ MEM_ROOT *mem_root ) { char *ptr; int error_num = 0; + const int link_idx= 0; DBUG_ENTER("spider_get_sys_link_mon_connect_info"); if ( !table->field[4]->is_null() && @@ -2753,9 +2771,6 @@ int spider_get_link_statuses( if ( (error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE) ) { -/* - table->file->print_error(error_num, MYF(0)); -*/ DBUG_RETURN(error_num); } } else if ((error_num = diff --git a/storage/spider/spd_sys_table.h b/storage/spider/spd_sys_table.h index 53ef3b82465..fca38c67683 100644 --- a/storage/spider/spd_sys_table.h +++ b/storage/spider/spd_sys_table.h @@ -56,6 +56,7 @@ #define SPIDER_SYS_LINK_MON_TABLE_TABLE_NAME_SIZE 64 #define SPIDER_SYS_LINK_MON_TABLE_LINK_ID_SIZE 64 +/* For insertion into `spider_mon_table_cache'. */ class SPIDER_MON_KEY: public SPIDER_SORT { public: @@ -425,7 +426,6 @@ int spider_get_sys_tables( int spider_get_sys_tables_connect_info( TABLE *table, SPIDER_SHARE *share, - int link_idx, MEM_ROOT *mem_root ); @@ -502,7 +502,6 @@ int spider_get_sys_link_mon_server_id( int spider_get_sys_link_mon_connect_info( TABLE *table, SPIDER_SHARE *share, - int link_idx, MEM_ROOT *mem_root ); diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index fae239c57db..610fbeda1f3 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -3421,13 +3421,15 @@ error_alloc_conn_string: DBUG_RETURN(error_num); } +/* Set default connect info of a SPIDER_SHARE if needed */ int spider_set_connect_info_default( - SPIDER_SHARE *share, + SPIDER_SHARE *share, /* The `SPIDER_SHARE' to set + default connect info */ #ifdef WITH_PARTITION_STORAGE_ENGINE - partition_element *part_elem, - partition_element *sub_elem, + partition_element *part_elem, /* partition info used as input */ + partition_element *sub_elem, /* subpartition info used as input */ #endif - TABLE_SHARE *table_share + TABLE_SHARE *table_share /* table share info used as input */ ) { int error_num, roop_count; DBUG_ENTER("spider_set_connect_info_default"); @@ -3558,22 +3560,6 @@ int spider_set_connect_info_default( } } -/* - if (!share->static_link_ids[roop_count]) - { - DBUG_PRINT("info",("spider create default static_link_ids")); - share->static_link_ids_lengths[roop_count] = - SPIDER_DB_STATIC_LINK_ID_LEN; - if ( - !(share->static_link_ids[roop_count] = spider_create_string( - SPIDER_DB_STATIC_LINK_ID_STR, - share->static_link_ids_lengths[roop_count])) - ) { - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - } - } -*/ - if (share->tgt_ports[roop_count] == -1) { share->tgt_ports[roop_count] = MYSQL_PORT; @@ -3705,6 +3691,11 @@ int spider_set_connect_info_default( DBUG_RETURN(0); } +/* + This function is a no-op if all share->tgt_dbs and + share->tgt_table_names are non-null, otherwise it may assign them + with db_name and table_name +*/ int spider_set_connect_info_default_db_table( SPIDER_SHARE *share, const char *db_name, @@ -3748,6 +3739,11 @@ int spider_set_connect_info_default_db_table( DBUG_RETURN(0); } +/* + Parse `dbtable_name' into db name and table name, and call + spider_set_connect_info_default_db_table() to set the db/table name + values of `share' if needed +*/ int spider_set_connect_info_default_dbtable( SPIDER_SHARE *share, const char *dbtable_name, @@ -6062,7 +6058,7 @@ int spider_open_all_tables( (error_num = spider_get_sys_tables( table_tables, &db_name, &table_name, &mem_root)) || (error_num = spider_get_sys_tables_connect_info( - table_tables, &tmp_share, 0, &mem_root)) || + table_tables, &tmp_share, &mem_root)) || (error_num = spider_set_connect_info_default( &tmp_share, #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -6676,16 +6672,6 @@ int spider_db_init( #ifdef HTON_CAN_READ_CONNECT_STRING_IN_PARTITION spider_hton->flags |= HTON_CAN_READ_CONNECT_STRING_IN_PARTITION; #endif - /* spider_hton->db_type = DB_TYPE_SPIDER; */ - /* - spider_hton->savepoint_offset; - spider_hton->savepoint_set = spider_savepoint_set; - spider_hton->savepoint_rollback = spider_savepoint_rollback; - spider_hton->savepoint_release = spider_savepoint_release; - spider_hton->create_cursor_read_view = spider_create_cursor_read_view; - spider_hton->set_cursor_read_view = spider_set_cursor_read_view; - spider_hton->close_cursor_read_view = spider_close_cursor_read_view; - */ spider_hton->panic = spider_panic; spider_hton->close_connection = spider_close_connection; spider_hton->start_consistent_snapshot = spider_start_consistent_snapshot; From e6d12bb45947fd9358e0925c9a513ca66c705686 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 13 Mar 2024 13:11:07 +1100 Subject: [PATCH 040/313] MDEV-33661 MENT-1591 Fix spider/bugfix.mdev_28856 because of MDEV-29718. The failure should be table not found, rather than no spider same server link --- storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result | 3 +++ storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result index 7e4fd3cd084..5fd412b69ea 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_28856.result @@ -5,6 +5,8 @@ for master_1 for child2 for child3 set spider_same_server_link=1; +set @old_spider_same_server_link=@@global.spider_same_server_link; +set global spider_same_server_link=1; CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); # testing monitoring_* @@ -173,6 +175,7 @@ max(d) 93 drop table t1, t2; drop server srv; +set global spider_same_server_link=@old_spider_same_server_link; for master_1 for child2 for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test index a1642f7a9cd..9ccfc3784ef 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_28856.test @@ -10,6 +10,9 @@ # This test covers some table params under consideration for inclusion # in the engine-defined options to be implemented in MDEV-28856. set spider_same_server_link=1; +set @old_spider_same_server_link=@@global.spider_same_server_link; +set global spider_same_server_link=1; + evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); @@ -153,6 +156,7 @@ select max(d) from t1; drop table t1, t2; drop server srv; +set global spider_same_server_link=@old_spider_same_server_link; --disable_query_log --disable_result_log From 7890388d9145ab5000e945b7a518caffd1fc197e Mon Sep 17 00:00:00 2001 From: Anson Chung Date: Mon, 18 Mar 2024 20:45:45 +0000 Subject: [PATCH 041/313] MDEV-33044 Loading time zones does not work with alter_algorithm INPLACE $MYSQL_TZINFO_TO_SQL works by truncating tables. Truncation is an operation that cannot be done in-place and therefore is fundamentally incompatible with alter_algorithm='INPLACE'. As a result, we override the default alter_algorithm setting in tztime.cc to alter_algorithm='COPY' so that timezones can be loaded regardless of the previously set alter_algorithm. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- ...ezones_with_alter_algorithm_inplace.result | 18 +++++++++ ...imezones_with_alter_algorithm_inplace.test | 38 +++++++++++++++++++ .../main/mysql_tzinfo_to_sql_symlink.result | 18 +++++++++ sql/tztime.cc | 5 +++ 4 files changed, 79 insertions(+) create mode 100644 mysql-test/main/load_timezones_with_alter_algorithm_inplace.result create mode 100644 mysql-test/main/load_timezones_with_alter_algorithm_inplace.test diff --git a/mysql-test/main/load_timezones_with_alter_algorithm_inplace.result b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.result new file mode 100644 index 00000000000..4992e7ed93b --- /dev/null +++ b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.result @@ -0,0 +1,18 @@ +set global alter_algorithm=INPLACE; +RENAME TABLE mysql.time_zone TO mysql.time_zone_BACKUP; +RENAME TABLE mysql.time_zone_name TO mysql.time_zone_name_BACKUP; +RENAME TABLE mysql.time_zone_transition TO mysql.time_zone_transition_BACKUP; +RENAME TABLE mysql.time_zone_transition_type TO mysql.time_zone_transition_type_BACKUP; +CREATE TABLE mysql.time_zone LIKE mysql.time_zone_BACKUP; +CREATE TABLE mysql.time_zone_name LIKE mysql.time_zone_name_BACKUP; +CREATE TABLE mysql.time_zone_transition LIKE mysql.time_zone_transition_BACKUP; +CREATE TABLE mysql.time_zone_transition_type LIKE mysql.time_zone_transition_type_BACKUP; +DROP TABLE mysql.time_zone; +DROP TABLE mysql.time_zone_name; +DROP TABLE mysql.time_zone_transition; +DROP TABLE mysql.time_zone_transition_type; +RENAME TABLE mysql.time_zone_BACKUP TO mysql.time_zone; +RENAME TABLE mysql.time_zone_name_BACKUP TO mysql.time_zone_name; +RENAME TABLE mysql.time_zone_transition_BACKUP TO mysql.time_zone_transition; +RENAME TABLE mysql.time_zone_transition_type_BACKUP TO mysql.time_zone_transition_type; +set global alter_algorithm=DEFAULT; diff --git a/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test new file mode 100644 index 00000000000..e840ae94a74 --- /dev/null +++ b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test @@ -0,0 +1,38 @@ +# MDEV-33044 Loading time zones does not work with alter_algorithm INPLACE + +set global alter_algorithm=INPLACE; + +# Because loading timezones alters the mysql tables, +# this test will leave mysql in a different state than when it started. +# Furthermore, checksums on the various mysql.timezone_x tables will fail. + +# Therefore we: +# 1. Make "backups" of the existing tables by renaming them +# 2. Make dummy clones of the tables we just backed up +# 3. Load timezones with alterations made to the dummy clone tables +# 4. Drop the newly made tables with changes made to them +# 5. Restore the backed up tables so the checksums will pass + +RENAME TABLE mysql.time_zone TO mysql.time_zone_BACKUP; +RENAME TABLE mysql.time_zone_name TO mysql.time_zone_name_BACKUP; +RENAME TABLE mysql.time_zone_transition TO mysql.time_zone_transition_BACKUP; +RENAME TABLE mysql.time_zone_transition_type TO mysql.time_zone_transition_type_BACKUP; + +CREATE TABLE mysql.time_zone LIKE mysql.time_zone_BACKUP; +CREATE TABLE mysql.time_zone_name LIKE mysql.time_zone_name_BACKUP; +CREATE TABLE mysql.time_zone_transition LIKE mysql.time_zone_transition_BACKUP; +CREATE TABLE mysql.time_zone_transition_type LIKE mysql.time_zone_transition_type_BACKUP; + +--exec $MYSQL_TZINFO_TO_SQL std_data/zoneinfo | $MYSQL mysql + +DROP TABLE mysql.time_zone; +DROP TABLE mysql.time_zone_name; +DROP TABLE mysql.time_zone_transition; +DROP TABLE mysql.time_zone_transition_type; + +RENAME TABLE mysql.time_zone_BACKUP TO mysql.time_zone; +RENAME TABLE mysql.time_zone_name_BACKUP TO mysql.time_zone_name; +RENAME TABLE mysql.time_zone_transition_BACKUP TO mysql.time_zone_transition; +RENAME TABLE mysql.time_zone_transition_type_BACKUP TO mysql.time_zone_transition_type; + +set global alter_algorithm=DEFAULT; \ No newline at end of file diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result index a9ada2d6fdb..ea1a09f66d6 100644 --- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result @@ -20,12 +20,16 @@ ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB; ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +SET @old_alter_alg=@@SESSION.alter_algorithm; +SET session alter_algorithm='COPY'; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition_type; START TRANSACTION; ELSE +SET @old_alter_alg=@@SESSION.alter_algorithm; +SET session alter_algorithm='COPY'; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -62,6 +66,7 @@ ALTER TABLE time_zone_transition ENGINE=Aria, ORDER BY Time_zone_id, Transition_ ALTER TABLE time_zone_transition_type ENGINE=Aria, ORDER BY Time_zone_id, Transition_type_id; END IF| \d ; +SET session alter_algorithm=@old_alter_alg; SELECT COUNT(*) FROM time_zone; COUNT(*) 0 @@ -85,12 +90,16 @@ ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB; ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +SET @old_alter_alg=@@SESSION.alter_algorithm; +SET session alter_algorithm='COPY'; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition_type; START TRANSACTION; ELSE +SET @old_alter_alg=@@SESSION.alter_algorithm; +SET session alter_algorithm='COPY'; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -124,6 +133,7 @@ ALTER TABLE time_zone_transition ENGINE=Aria, ORDER BY Time_zone_id, Transition_ ALTER TABLE time_zone_transition_type ENGINE=Aria, ORDER BY Time_zone_id, Transition_type_id; END IF| \d ; +SET session alter_algorithm=@old_alter_alg; SELECT COUNT(*) FROM time_zone; COUNT(*) 2 @@ -145,6 +155,8 @@ COUNT(*) set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION WSREP_ON=OFF', 'do 0'); SET SESSION SQL_LOG_BIN=0; execute immediate @prep1; +SET @old_alter_alg=@@SESSION.alter_algorithm; +SET session alter_algorithm='COPY'; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -172,6 +184,7 @@ UNLOCK TABLES; COMMIT; ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; +SET session alter_algorithm=@old_alter_alg; SELECT COUNT(*) FROM time_zone; COUNT(*) 2 @@ -432,12 +445,16 @@ ALTER TABLE time_zone ENGINE=InnoDB; ALTER TABLE time_zone_name ENGINE=InnoDB; ALTER TABLE time_zone_transition ENGINE=InnoDB; ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +SET @old_alter_alg=@@SESSION.alter_algorithm; +SET session alter_algorithm='COPY'; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition_type; START TRANSACTION; ELSE +SET @old_alter_alg=@@SESSION.alter_algorithm; +SET session alter_algorithm='COPY'; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -457,6 +474,7 @@ ALTER TABLE time_zone_transition ENGINE=Aria, ORDER BY Time_zone_id, Transition_ ALTER TABLE time_zone_transition_type ENGINE=Aria, ORDER BY Time_zone_id, Transition_type_id; END IF| \d ; +SET session alter_algorithm=@old_alter_alg; DROP TABLE time_zone; DROP TABLE time_zone_name; DROP TABLE time_zone_transition; diff --git a/sql/tztime.cc b/sql/tztime.cc index 45a11942966..1480de96333 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2718,6 +2718,8 @@ static const char *lock_tables= " time_zone_transition WRITE,\n" " time_zone_transition_type WRITE;\n"; static const char *trunc_tables_const= + "SET @old_alter_alg=@@SESSION.alter_algorithm;\n" + "SET session alter_algorithm='COPY';\n" "TRUNCATE TABLE time_zone;\n" "TRUNCATE TABLE time_zone_name;\n" "TRUNCATE TABLE time_zone_transition;\n" @@ -2833,6 +2835,9 @@ main(int argc, char **argv) "END IF|\n" "\\d ;\n"); + if (argc == 1 && !opt_leap) + printf("SET session alter_algorithm=@old_alter_alg;\n"); + free_allocated_data(); my_end(0); return 0; From 9f1019ba3ddec192ca0c1822710d654b0c42e4dd Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 28 Mar 2024 13:53:52 +1100 Subject: [PATCH 042/313] MDEV-33044 Loading time zones does not work with alter_algorithm INPLACE (postfix) Test case doesn't work on embedded builds. --- .../main/load_timezones_with_alter_algorithm_inplace.test | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test index e840ae94a74..809f147fe04 100644 --- a/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test +++ b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test @@ -1,3 +1,5 @@ +--source include/not_embedded.inc + # MDEV-33044 Loading time zones does not work with alter_algorithm INPLACE set global alter_algorithm=INPLACE; @@ -35,4 +37,4 @@ RENAME TABLE mysql.time_zone_name_BACKUP TO mysql.time_zone_name; RENAME TABLE mysql.time_zone_transition_BACKUP TO mysql.time_zone_transition; RENAME TABLE mysql.time_zone_transition_type_BACKUP TO mysql.time_zone_transition_type; -set global alter_algorithm=DEFAULT; \ No newline at end of file +set global alter_algorithm=DEFAULT; From c81139357a4bb5bb1c774fa6d813166ef32e3735 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 28 Mar 2024 11:48:32 +0700 Subject: [PATCH 043/313] MDEV-14959: the follow-up patch to turn on the option -DWITH_PROTECT_STATEMENT_MEMROOT by default --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9605d786c93..6f668139b50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,9 +197,10 @@ OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system librar # Enable protection of statement's memory root after first SP/PS execution. # Can be switched on only for debug build. # -OPTION(WITH_PROTECT_STATEMENT_MEMROOT "Enable protection of statement's memory root after first SP/PS execution. Turned into account only for debug build" OFF) -IF (CMAKE_BUILD_TYPE MATCHES "Debug" AND WITH_PROTECT_STATEMENT_MEMROOT) - ADD_DEFINITIONS(-DPROTECT_STATEMENT_MEMROOT) +OPTION(WITH_PROTECT_STATEMENT_MEMROOT "Enable protection of statement's memory root after first SP/PS execution. Turned into account only for debug build" ON) +IF (WITH_PROTECT_STATEMENT_MEMROOT) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DPROTECT_STATEMENT_MEMROOT") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DPROTECT_STATEMENT_MEMROOT") ENDIF() INCLUDE(check_compiler_flag) From f44e41db38c44b1d6f6238aa1e1b0936814c43fb Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 27 Mar 2024 22:55:15 +0700 Subject: [PATCH 044/313] MDEV-33767: Memory leaks found in some tests run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT Found memory leaks were introduced by the commit a896bebfa6d00b0bb7685956196a7977d9273652 MDEV-18844 Implement EXCEPT ALL and INTERSECT ALL operations and caused by using a statement arena instead a runtime arena for allocation of objects having temporary life span by their nature. Aforementioned memory leaks were produced by running queries that typically use select with intersect, union or table values constructors. To fix these memory leaks use the runtime arena for allocation of Item_field objects used by set operations. Additionally, OOM handling added on allocation of aforementioned Item_field objects. --- sql/sql_union.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 96929a128ac..c3c4198439a 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1263,26 +1263,21 @@ bool st_select_lex_unit::join_union_item_types(THD *thd_arg, } -bool init_item_int(THD* thd, Item_int* &item) +static bool init_item_int(THD* thd, Item_int* &item) { if (!item) { - Query_arena *arena, backup_arena; - arena= thd->activate_stmt_arena_if_needed(&backup_arena); - item= new (thd->mem_root) Item_int(thd, 0); - if (arena) - thd->restore_active_arena(arena, &backup_arena); - if (!item) - return false; + return true; } else { item->value= 0; } - return true; + + return false; } @@ -1762,8 +1757,12 @@ cont: for(uint i= 0; i< hidden; i++) { - init_item_int(thd, addon_fields[i]); - types.push_front(addon_fields[i]); + if (init_item_int(thd, addon_fields[i]) || + types.push_front(addon_fields[i])) + { + types.empty(); + goto err; + } addon_fields[i]->name.str= i ? "__CNT_1" : "__CNT_2"; addon_fields[i]->name.length= 7; } From e1876e7f78f6011a5759e4a2a549c057f21efcc9 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 27 Mar 2024 20:44:05 +0700 Subject: [PATCH 045/313] MDEV-33768: Memory leak found in the test main.constraints run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT The discovered memory leak was introduced by the commit 762bf7a03b6214f091a66ca8683df341112d7d4a (MDEV-22602 Disable UPDATE CASCADE for SQL constraints) The reason why a memory leaked on running the test main.constraints is that a statement arena was used for allocation a memory for storing a constraint name. A constraint name is an entity having temporary nature by its design so runtime arena should be used for its allocation. --- mysql-test/main/constraints.result | 13 +++++++++++++ mysql-test/main/constraints.test | 15 +++++++++++++++ sql/sql_table.cc | 3 ++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/constraints.result b/mysql-test/main/constraints.result index 105ea7cf1f4..77a25f5ad46 100644 --- a/mysql-test/main/constraints.result +++ b/mysql-test/main/constraints.result @@ -235,3 +235,16 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop procedure sp; drop table t1; +# +# MDEV-33768: Memory leak found in the test main.constraints run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT +# This test case was added by reviewer's request. +# +PREPARE stmt FROM 'CREATE TABLE t1 (a INT)'; +EXECUTE stmt; +DROP TABLE t1; +EXECUTE stmt; +EXECUTE stmt; +ERROR 42S01: Table 't1' already exists +# Clean up +DROP TABLE t1; +DEALLOCATE PREPARE stmt; diff --git a/mysql-test/main/constraints.test b/mysql-test/main/constraints.test index 5c673f9be81..83f3394d6f6 100644 --- a/mysql-test/main/constraints.test +++ b/mysql-test/main/constraints.test @@ -189,3 +189,18 @@ call sp; show create table t1; drop procedure sp; drop table t1; + +--echo # +--echo # MDEV-33768: Memory leak found in the test main.constraints run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT +--echo # This test case was added by reviewer's request. +--echo # +PREPARE stmt FROM 'CREATE TABLE t1 (a INT)'; +EXECUTE stmt; +DROP TABLE t1; +EXECUTE stmt; +--error ER_TABLE_EXISTS_ERROR +EXECUTE stmt; + +--echo # Clean up +DROP TABLE t1; +DEALLOCATE PREPARE stmt; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 839438dfc30..dc1a7060643 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5861,7 +5861,8 @@ static bool make_unique_constraint_name(THD *thd, LEX_CSTRING *name, if (!check) // Found unique name { name->length= (size_t) (real_end - buff); - name->str= strmake_root(thd->stmt_arena->mem_root, buff, name->length); + name->str= thd->strmake(buff, name->length); + return (name->str == NULL); } } From a618ff2b1c3980d20d258d7da0afb1e7b7ec1516 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 10 Jan 2024 14:34:12 +0100 Subject: [PATCH 046/313] MDEV-33216 stack-use-after-return in Wsrep_schema_impl::open_table() Fix a case of stack-use-after-return reported by ASAN in Wsrep_schema_impl::open_table(). This function has a stack allocated TABLE_LIST object and return TABLE_LIST::table to the caller. Changed the function to take a TABLE_LIST pointer as argument. Signed-off-by: Julius Goryavsky --- sql/wsrep_schema.cc | 143 +++++++++++++++++++++++++++----------------- 1 file changed, 89 insertions(+), 54 deletions(-) diff --git a/sql/wsrep_schema.cc b/sql/wsrep_schema.cc index 1c4f827ae97..6d435a3a1b5 100644 --- a/sql/wsrep_schema.cc +++ b/sql/wsrep_schema.cc @@ -245,58 +245,51 @@ static void finish_stmt(THD* thd) { close_thread_tables(thd); } -static int open_table(THD* thd, - const LEX_CSTRING *schema_name, - const LEX_CSTRING *table_name, - enum thr_lock_type const lock_type, - TABLE** table) { - assert(table); - *table= NULL; - +static int open_table(THD *thd, const LEX_CSTRING *schema_name, + const LEX_CSTRING *table_name, + enum thr_lock_type const lock_type, + TABLE_LIST *table_list) +{ + assert(table_list); DBUG_ENTER("Wsrep_schema::open_table()"); - - TABLE_LIST tables; - uint flags= (MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | - MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY | - MYSQL_OPEN_IGNORE_FLUSH | - MYSQL_LOCK_IGNORE_TIMEOUT); - - tables.init_one_table(schema_name, - table_name, - NULL, lock_type); + const uint flags= (MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | + MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY | + MYSQL_OPEN_IGNORE_FLUSH | MYSQL_LOCK_IGNORE_TIMEOUT); + table_list->init_one_table(schema_name, table_name, NULL, lock_type); thd->lex->query_tables_own_last= 0; - - if (!open_n_lock_single_table(thd, &tables, tables.lock_type, flags)) { + if (!open_n_lock_single_table(thd, table_list, table_list->lock_type, flags)) + { close_thread_tables(thd); DBUG_RETURN(1); } - *table= tables.table; - (*table)->use_all_columns(); + table_list->table->use_all_columns(); DBUG_RETURN(0); } - -static int open_for_write(THD* thd, const char* table_name, TABLE** table) { +static int open_for_write(THD* thd, const char* table_name, TABLE_LIST* table_list) +{ LEX_CSTRING schema_str= { wsrep_schema_str.c_str(), wsrep_schema_str.length() }; LEX_CSTRING table_str= { table_name, strlen(table_name) }; if (Wsrep_schema_impl::open_table(thd, &schema_str, &table_str, TL_WRITE, - table)) { + table_list)) + { // No need to log an error if the query was bf aborted, // thd client will get ER_LOCK_DEADLOCK in the end. const bool interrupted= thd->killed || (thd->is_error() && (thd->get_stmt_da()->sql_errno() == ER_QUERY_INTERRUPTED)); - if (!interrupted) { + if (!interrupted) + { WSREP_ERROR("Failed to open table %s.%s for writing", schema_str.str, table_name); } return 1; } - empty_record(*table); - (*table)->use_all_columns(); - restore_record(*table, s->default_values); + empty_record(table_list->table); + table_list->table->use_all_columns(); + restore_record(table_list->table, s->default_values); return 0; } @@ -438,19 +431,21 @@ static int delete_row(TABLE* table) { return 0; } -static int open_for_read(THD* thd, const char* table_name, TABLE** table) { - +static int open_for_read(THD *thd, const char *table_name, + TABLE_LIST *table_list) +{ LEX_CSTRING schema_str= { wsrep_schema_str.c_str(), wsrep_schema_str.length() }; LEX_CSTRING table_str= { table_name, strlen(table_name) }; if (Wsrep_schema_impl::open_table(thd, &schema_str, &table_str, TL_READ, - table)) { + table_list)) + { WSREP_ERROR("Failed to open table %s.%s for reading", schema_str.str, table_name); return 1; } - empty_record(*table); - (*table)->use_all_columns(); - restore_record(*table, s->default_values); + empty_record(table_list->table); + table_list->table->use_all_columns(); + restore_record(table_list->table, s->default_values); return 0; } @@ -706,8 +701,10 @@ int Wsrep_schema::store_view(THD* thd, const Wsrep_view& view) assert(view.status() == Wsrep_view::primary); int ret= 1; int error; + TABLE_LIST cluster_table_l; TABLE* cluster_table= 0; - TABLE* members_table= 0; + TABLE_LIST members_table_l; + TABLE* members_table = 0; #ifdef WSREP_SCHEMA_MEMBERS_HISTORY TABLE* members_history_table= 0; #endif /* WSREP_SCHEMA_MEMBERS_HISTORY */ @@ -732,11 +729,13 @@ int Wsrep_schema::store_view(THD* thd, const Wsrep_view& view) Store cluster view info */ Wsrep_schema_impl::init_stmt(thd); - if (Wsrep_schema_impl::open_for_write(thd, cluster_table_str.c_str(), &cluster_table)) + if (Wsrep_schema_impl::open_for_write(thd, cluster_table_str.c_str(), &cluster_table_l)) { goto out; } + cluster_table= cluster_table_l.table; + Wsrep_schema_impl::store(cluster_table, 0, view.state_id().id()); Wsrep_schema_impl::store(cluster_table, 1, view.view_seqno().get()); Wsrep_schema_impl::store(cluster_table, 2, view.state_id().seqno().get()); @@ -756,12 +755,14 @@ int Wsrep_schema::store_view(THD* thd, const Wsrep_view& view) */ Wsrep_schema_impl::init_stmt(thd); if (Wsrep_schema_impl::open_for_write(thd, members_table_str.c_str(), - &members_table)) + &members_table_l)) { WSREP_ERROR("failed to open wsrep.members table"); goto out; } + members_table= members_table_l.table; + for (size_t i= 0; i < view.members().size(); ++i) { Wsrep_schema_impl::store(members_table, 0, view.members()[i].id()); @@ -815,8 +816,10 @@ Wsrep_view Wsrep_schema::restore_view(THD* thd, const Wsrep_id& own_id) const { int ret= 1; int error; + TABLE_LIST cluster_table_l; TABLE* cluster_table= 0; bool end_cluster_scan= false; + TABLE_LIST members_table_l; TABLE* members_table= 0; bool end_members_scan= false; @@ -842,8 +845,12 @@ Wsrep_view Wsrep_schema::restore_view(THD* thd, const Wsrep_id& own_id) const { Read cluster info from cluster table */ Wsrep_schema_impl::init_stmt(thd); - if (Wsrep_schema_impl::open_for_read(thd, cluster_table_str.c_str(), &cluster_table) || - Wsrep_schema_impl::init_for_scan(cluster_table)) { + if (Wsrep_schema_impl::open_for_read(thd, cluster_table_str.c_str(), &cluster_table_l)) { + goto out; + } + cluster_table = cluster_table_l.table; + + if (Wsrep_schema_impl::init_for_scan(cluster_table)) { goto out; } @@ -867,8 +874,14 @@ Wsrep_view Wsrep_schema::restore_view(THD* thd, const Wsrep_id& own_id) const { Read members from members table */ Wsrep_schema_impl::init_stmt(thd); - if (Wsrep_schema_impl::open_for_read(thd, members_table_str.c_str(), &members_table) || - Wsrep_schema_impl::init_for_scan(members_table)) { + if (Wsrep_schema_impl::open_for_read(thd, members_table_str.c_str(), + &members_table_l)) + { + goto out; + } + + members_table= members_table_l.table; + if (Wsrep_schema_impl::init_for_scan(members_table)) { goto out; } end_members_scan= true; @@ -972,14 +985,15 @@ int Wsrep_schema::append_fragment(THD* thd, Wsrep_schema_impl::sql_safe_updates sql_safe_updates(thd); Wsrep_schema_impl::init_stmt(thd); - TABLE* frag_table= 0; - if (Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table)) + TABLE_LIST frag_table_l; + if (Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table_l)) { trans_rollback_stmt(thd); thd->lex->restore_backup_query_tables_list(&query_tables_list_backup); DBUG_RETURN(1); } + TABLE* frag_table= frag_table_l.table; Wsrep_schema_impl::store(frag_table, 0, server_id); Wsrep_schema_impl::store(frag_table, 1, transaction_id.get()); Wsrep_schema_impl::store(frag_table, 2, seqno.get()); @@ -1023,13 +1037,15 @@ int Wsrep_schema::update_fragment_meta(THD* thd, uchar *key=NULL; key_part_map key_map= 0; TABLE* frag_table= 0; + TABLE_LIST frag_table_l; Wsrep_schema_impl::init_stmt(thd); - if (Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table)) + if (Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table_l)) { thd->lex->restore_backup_query_tables_list(&query_tables_list_backup); DBUG_RETURN(1); } + frag_table= frag_table_l.table; /* Find record with the given uuid, trx id, and seqno -1 */ Wsrep_schema_impl::store(frag_table, 0, ws_meta.server_id()); @@ -1152,12 +1168,14 @@ int Wsrep_schema::remove_fragments(THD* thd, thd->reset_n_backup_open_tables_state(&open_tables_backup); TABLE* frag_table= 0; - if (Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table)) + TABLE_LIST frag_table_l; + if (Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table_l)) { ret= 1; } else { + frag_table= frag_table_l.table; for (std::vector::const_iterator i= fragments.begin(); i != fragments.end(); ++i) { @@ -1218,6 +1236,7 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, int ret= 1; int error; TABLE* frag_table= 0; + TABLE_LIST frag_table_l; uchar *key=NULL; key_part_map key_map= 0; @@ -1225,12 +1244,13 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, i != fragments.end(); ++i) { Wsrep_schema_impl::init_stmt(&thd); - if ((error= Wsrep_schema_impl::open_for_read(&thd, sr_table_str.c_str(), &frag_table))) + if ((error= Wsrep_schema_impl::open_for_read(&thd, sr_table_str.c_str(), &frag_table_l))) { WSREP_WARN("Could not open SR table for read: %d", error); Wsrep_schema_impl::finish_stmt(&thd); DBUG_RETURN(1); } + frag_table= frag_table_l.table; Wsrep_schema_impl::store(frag_table, 0, ws_meta.server_id()); Wsrep_schema_impl::store(frag_table, 1, ws_meta.transaction_id().get()); @@ -1276,12 +1296,13 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, if ((error= Wsrep_schema_impl::open_for_write(&thd, sr_table_str.c_str(), - &frag_table))) + &frag_table_l))) { WSREP_WARN("Could not open SR table for write: %d", error); Wsrep_schema_impl::finish_stmt(&thd); DBUG_RETURN(1); } + frag_table= frag_table_l.table; error= Wsrep_schema_impl::init_for_index_scan(frag_table, key, @@ -1323,7 +1344,9 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) (char*) &storage_thd); wsrep_assign_from_threadvars(&storage_thd); TABLE* frag_table= 0; + TABLE_LIST frag_table_l; TABLE* cluster_table= 0; + TABLE_LIST cluster_table_l; Wsrep_storage_service storage_service(&storage_thd); Wsrep_schema_impl::binlog_off binlog_off(&storage_thd); Wsrep_schema_impl::wsrep_off wsrep_off(&storage_thd); @@ -1338,10 +1361,15 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) Wsrep_schema_impl::init_stmt(&storage_thd); storage_thd.wsrep_skip_locking= FALSE; - if (Wsrep_schema_impl::open_for_read(&storage_thd, - cluster_table_str.c_str(), - &cluster_table) || - Wsrep_schema_impl::init_for_scan(cluster_table)) + if (Wsrep_schema_impl::open_for_read(&storage_thd, cluster_table_str.c_str(), + &cluster_table_l)) + { + Wsrep_schema_impl::finish_stmt(&storage_thd); + DBUG_RETURN(1); + } + cluster_table= cluster_table_l.table; + + if (Wsrep_schema_impl::init_for_scan(cluster_table)) { Wsrep_schema_impl::finish_stmt(&storage_thd); DBUG_RETURN(1); @@ -1379,12 +1407,19 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) Open the table for reading and writing so that fragments without valid seqno can be deleted. */ - if (Wsrep_schema_impl::open_for_write(&storage_thd, sr_table_str.c_str(), &frag_table) || - Wsrep_schema_impl::init_for_scan(frag_table)) + if (Wsrep_schema_impl::open_for_write(&storage_thd, sr_table_str.c_str(), + &frag_table_l)) { WSREP_ERROR("Failed to open SR table for write"); goto out; } + frag_table= frag_table_l.table; + + if (Wsrep_schema_impl::init_for_scan(frag_table)) + { + WSREP_ERROR("Failed to init for index scan"); + goto out; + } while (true) { From 29bb321f0497b4a30d4a2b1b19d7a6a924d22c3a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 28 Mar 2024 14:01:43 +0400 Subject: [PATCH 047/313] MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol Item_func_dyncol_create::print_arguments() printed only CHARSET clause without COLLATE. Therefore, HEX(column_create(1,'1212' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) inside a VIEW changed to just: HEX(column_create(1,'1212' AS CHAR CHARACTER SET utf8mb3)) which changed the collation ID seen in the HEX output. Note, the collation ID inside column_create() is not really much important. (It's only important what the character set is). And for COLLATE, the more important thing is what's later written in the AS clause of COLUMN_GET: SELECT COLUMN_GET( column_create(1,'1212' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin) column_nr AS type -- this type is more important ); Still, let's add the COLLATE clause into the COLUMN_CREATE() print output, although it's not important for now for anything else than just the HEX output. At least to make VIEW work in a more predictable way with HEX(COLUMN_CREATE()). Also, in the future we can start using somehow the collation ID written inside COLUMN_CREATE(), for example by making the `AS type` clause optional in COLUMN_GET(): COLUMN_GET(dyncol_blob, column_nr [AS type]); instead of: COLUMN_GET(dyncol_blob, column_nr AS type); SQL Server compatibility layer may need this for the SQL_Variant data type support. --- mysql-test/main/create.result | 2 +- mysql-test/main/dyncol.result | 28 ++++++++++++++++++++++++---- mysql-test/main/dyncol.test | 21 +++++++++++++++++++++ sql/item_strfunc.cc | 5 +++++ 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result index cec7452affd..fc508108a97 100644 --- a/mysql-test/main/create.result +++ b/mysql-test/main/create.result @@ -1806,7 +1806,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `color` char(32) GENERATED ALWAYS AS (column_get(`dynamic_cols`,1 as char charset latin1)) STORED, - `cl` char(32) GENERATED ALWAYS AS (column_get(column_add(column_create(1,'blue' AS char charset latin1 ),2,'ttt'),`i` as char charset latin1)) STORED, + `cl` char(32) GENERATED ALWAYS AS (column_get(column_add(column_create(1,'blue' AS char charset latin1 collate latin1_swedish_ci ),2,'ttt'),`i` as char charset latin1)) STORED, `item_name` varchar(32) NOT NULL, `i` int(11) DEFAULT NULL, `dynamic_cols` blob DEFAULT NULL, diff --git a/mysql-test/main/dyncol.result b/mysql-test/main/dyncol.result index 6135be649b2..eb1e0464570 100644 --- a/mysql-test/main/dyncol.result +++ b/mysql-test/main/dyncol.result @@ -150,7 +150,7 @@ select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8, id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select hex(column_create(1,'afaf' AS char charset utf8 ,2,1212 AS unsigned int,3,1212 AS int,4,12.12 AS double,4 + 1,12.12 AS decimal,6,'2011-04-05' AS date,7,'- 0:45:49.000001' AS time,8,'2011-04-05 0:45:49.000001' AS datetime)) AS `ex` +Note 1003 select hex(column_create(1,'afaf' AS char charset utf8 collate utf8_general_ci ,2,1212 AS unsigned int,3,1212 AS int,4,12.12 AS double,4 + 1,12.12 AS decimal,6,'2011-04-05' AS date,7,'- 0:45:49.000001' AS time,8,'2011-04-05 0:45:49.000001' AS datetime)) AS `ex` select hex(column_create(1, 0.0 AS decimal)); hex(column_create(1, 0.0 AS decimal)) 000100010004 @@ -354,7 +354,7 @@ select column_get(column_create(1, "1212" AS char charset utf8), 1 as char chars id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 ),1 as char charset utf8) AS `ex` +Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 collate utf8_general_ci ),1 as char charset utf8) AS `ex` select column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8) as ex; ex 1212 @@ -414,7 +414,7 @@ select column_get(column_create(1, "1212" AS char charset utf8), 1 as char chars id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 ),1 as char charset binary) AS `ex` +Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 collate utf8_general_ci ),1 as char charset binary) AS `ex` # # column get real # @@ -1882,7 +1882,7 @@ drop table t1; create view v1 as select column_get(column_add(column_create(1 , 'blue' as char), 2, 'ttt'), 1 as char); 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 column_get(column_add(column_create(1,'blue' AS char charset utf8 ),2,'ttt'),1 as char charset utf8) AS `Name_exp_1` utf8 utf8_general_ci +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select column_get(column_add(column_create(1,'blue' AS char charset utf8 collate utf8_general_ci ),2,'ttt'),1 as char charset utf8) AS `Name_exp_1` utf8 utf8_general_ci select * from v1; Name_exp_1 blue @@ -1949,3 +1949,23 @@ ex # # End of 10.4 tests # +# +# Start of 10.5 tests +# +# +# Start of 10.5 tests +# +# +# MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol +# +SELECT hex(column_create(1,'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) AS ex; +ex +0001000100035361 +SELECT hex(column_add(column_create( +1, 'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin), +2, 'b' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci)) AS ex; +ex +00020001000302001353612162 +# +# Start of 10.5 tests +# diff --git a/mysql-test/main/dyncol.test b/mysql-test/main/dyncol.test index 630ed122347..16cf8a2306d 100644 --- a/mysql-test/main/dyncol.test +++ b/mysql-test/main/dyncol.test @@ -1000,3 +1000,24 @@ SELECT HEX(COLUMN_ADD(COLUMN_CREATE(1,10),2,NULL,1,NULL)) as ex; --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol +--echo # + +SELECT hex(column_create(1,'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) AS ex; +SELECT hex(column_add(column_create( + 1, 'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin), + 2, 'b' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci)) AS ex; + +--echo # +--echo # Start of 10.5 tests +--echo # diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 4f4b0a20b29..1317d8fdfa9 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -4670,6 +4670,11 @@ void Item_func_dyncol_create::print_arguments(String *str, { str->append(STRING_WITH_LEN(" charset ")); str->append(defs[i].cs->csname); + if (Charset(defs[i].cs).can_have_collate_clause()) + { + str->append(STRING_WITH_LEN(" collate ")); + str->append(defs[i].cs->name); + } str->append(' '); } break; From 4987b5e3b125db2ea52525afefeae97976e2e828 Mon Sep 17 00:00:00 2001 From: joshhn Date: Tue, 2 Apr 2024 00:07:12 -0500 Subject: [PATCH 048/313] MDEV-33803 Error 4162 "Operator does not exists" is incorrectly-worded "Operator does not exists" should rather read "Operator does not exist". --- mysql-test/main/gis.result | 32 ++++++++++----------- mysql-test/suite/compat/oracle/r/gis.result | 32 ++++++++++----------- sql/share/errmsg-utf8.txt | 2 +- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index 258d0c2f050..e8c5e5c8e73 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -5072,37 +5072,37 @@ ERROR 42000: Incorrect parameter count in the call to native function 'WITHIN(PO # MDEV-20009 Add CAST(expr AS pluggable_type) # SELECT CAST(1 AS GEOMETRY); -ERROR HY000: Operator does not exists: 'CAST(expr AS geometry)' +ERROR HY000: Operator does not exist: 'CAST(expr AS geometry)' SELECT CAST(1 AS GEOMETRYCOLLECTION); -ERROR HY000: Operator does not exists: 'CAST(expr AS geometrycollection)' +ERROR HY000: Operator does not exist: 'CAST(expr AS geometrycollection)' SELECT CAST(1 AS POINT); -ERROR HY000: Operator does not exists: 'CAST(expr AS point)' +ERROR HY000: Operator does not exist: 'CAST(expr AS point)' SELECT CAST(1 AS LINESTRING); -ERROR HY000: Operator does not exists: 'CAST(expr AS linestring)' +ERROR HY000: Operator does not exist: 'CAST(expr AS linestring)' SELECT CAST(1 AS POLYGON); -ERROR HY000: Operator does not exists: 'CAST(expr AS polygon)' +ERROR HY000: Operator does not exist: 'CAST(expr AS polygon)' SELECT CAST(1 AS MULTIPOINT); -ERROR HY000: Operator does not exists: 'CAST(expr AS multipoint)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multipoint)' SELECT CAST(1 AS MULTILINESTRING); -ERROR HY000: Operator does not exists: 'CAST(expr AS multilinestring)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multilinestring)' SELECT CAST(1 AS MULTIPOLYGON); -ERROR HY000: Operator does not exists: 'CAST(expr AS multipolygon)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multipolygon)' SELECT CONVERT(1, GEOMETRY); -ERROR HY000: Operator does not exists: 'CAST(expr AS geometry)' +ERROR HY000: Operator does not exist: 'CAST(expr AS geometry)' SELECT CONVERT(1, GEOMETRYCOLLECTION); -ERROR HY000: Operator does not exists: 'CAST(expr AS geometrycollection)' +ERROR HY000: Operator does not exist: 'CAST(expr AS geometrycollection)' SELECT CONVERT(1, POINT); -ERROR HY000: Operator does not exists: 'CAST(expr AS point)' +ERROR HY000: Operator does not exist: 'CAST(expr AS point)' SELECT CONVERT(1, LINESTRING); -ERROR HY000: Operator does not exists: 'CAST(expr AS linestring)' +ERROR HY000: Operator does not exist: 'CAST(expr AS linestring)' SELECT CONVERT(1, POLYGON); -ERROR HY000: Operator does not exists: 'CAST(expr AS polygon)' +ERROR HY000: Operator does not exist: 'CAST(expr AS polygon)' SELECT CONVERT(1, MULTIPOINT); -ERROR HY000: Operator does not exists: 'CAST(expr AS multipoint)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multipoint)' SELECT CONVERT(1, MULTILINESTRING); -ERROR HY000: Operator does not exists: 'CAST(expr AS multilinestring)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multilinestring)' SELECT CONVERT(1, MULTIPOLYGON); -ERROR HY000: Operator does not exists: 'CAST(expr AS multipolygon)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multipolygon)' # # MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY # diff --git a/mysql-test/suite/compat/oracle/r/gis.result b/mysql-test/suite/compat/oracle/r/gis.result index 113cb0ea402..8145b97d695 100644 --- a/mysql-test/suite/compat/oracle/r/gis.result +++ b/mysql-test/suite/compat/oracle/r/gis.result @@ -33,37 +33,37 @@ ERROR 42000: Incorrect parameter count in the call to native function 'WITHIN(PO # MDEV-20009 Add CAST(expr AS pluggable_type) # SELECT CAST(1 AS GEOMETRY); -ERROR HY000: Operator does not exists: 'CAST(expr AS geometry)' +ERROR HY000: Operator does not exist: 'CAST(expr AS geometry)' SELECT CAST(1 AS GEOMETRYCOLLECTION); -ERROR HY000: Operator does not exists: 'CAST(expr AS geometrycollection)' +ERROR HY000: Operator does not exist: 'CAST(expr AS geometrycollection)' SELECT CAST(1 AS POINT); -ERROR HY000: Operator does not exists: 'CAST(expr AS point)' +ERROR HY000: Operator does not exist: 'CAST(expr AS point)' SELECT CAST(1 AS LINESTRING); -ERROR HY000: Operator does not exists: 'CAST(expr AS linestring)' +ERROR HY000: Operator does not exist: 'CAST(expr AS linestring)' SELECT CAST(1 AS POLYGON); -ERROR HY000: Operator does not exists: 'CAST(expr AS polygon)' +ERROR HY000: Operator does not exist: 'CAST(expr AS polygon)' SELECT CAST(1 AS MULTIPOINT); -ERROR HY000: Operator does not exists: 'CAST(expr AS multipoint)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multipoint)' SELECT CAST(1 AS MULTILINESTRING); -ERROR HY000: Operator does not exists: 'CAST(expr AS multilinestring)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multilinestring)' SELECT CAST(1 AS MULTIPOLYGON); -ERROR HY000: Operator does not exists: 'CAST(expr AS multipolygon)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multipolygon)' SELECT CONVERT(1, GEOMETRY); -ERROR HY000: Operator does not exists: 'CAST(expr AS geometry)' +ERROR HY000: Operator does not exist: 'CAST(expr AS geometry)' SELECT CONVERT(1, GEOMETRYCOLLECTION); -ERROR HY000: Operator does not exists: 'CAST(expr AS geometrycollection)' +ERROR HY000: Operator does not exist: 'CAST(expr AS geometrycollection)' SELECT CONVERT(1, POINT); -ERROR HY000: Operator does not exists: 'CAST(expr AS point)' +ERROR HY000: Operator does not exist: 'CAST(expr AS point)' SELECT CONVERT(1, LINESTRING); -ERROR HY000: Operator does not exists: 'CAST(expr AS linestring)' +ERROR HY000: Operator does not exist: 'CAST(expr AS linestring)' SELECT CONVERT(1, POLYGON); -ERROR HY000: Operator does not exists: 'CAST(expr AS polygon)' +ERROR HY000: Operator does not exist: 'CAST(expr AS polygon)' SELECT CONVERT(1, MULTIPOINT); -ERROR HY000: Operator does not exists: 'CAST(expr AS multipoint)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multipoint)' SELECT CONVERT(1, MULTILINESTRING); -ERROR HY000: Operator does not exists: 'CAST(expr AS multilinestring)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multilinestring)' SELECT CONVERT(1, MULTIPOLYGON); -ERROR HY000: Operator does not exists: 'CAST(expr AS multipolygon)' +ERROR HY000: Operator does not exist: 'CAST(expr AS multipolygon)' # # End of 10.5 tests # diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 1d9a88c51fc..33c66f75a20 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -9082,7 +9082,7 @@ ER_TOO_LONG_DATABASE_COMMENT ER_UNKNOWN_DATA_TYPE eng "Unknown data type: '%-.64s'" ER_UNKNOWN_OPERATOR - eng "Operator does not exists: '%-.128s'" + eng "Operator does not exist: '%-.128s'" ER_WARN_HISTORY_ROW_START_TIME eng "Table `%s.%s` history row start '%s' is later than row end '%s'" ER_PART_STARTS_BEYOND_INTERVAL From 722df777caca6d4823e867362aff4da79ae8b2c3 Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Sat, 23 Mar 2024 21:37:55 +0300 Subject: [PATCH 049/313] MDEV-33757 Get rid of TrxUndoRsegs code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TrxUndoRsegs is wrapper for vector of trx_rseg_t*. It has two constructors, both initialize the vector with only one element. And they are used to push transactions rseg(the singular) to purge queue. There is no function to add elements to the vector. The default constructor is used only for declaration of NullElement. The TrxUndoRsegs was introduced in WL#6915 in MySQL 5.7 and. MySQL 5.7 would unnecessarily let the purge of history parse the temporary undo records, and then look up the table (via a global hash table), and only at the point of processing the parsed undo log record determine that the table is a temporary table and the undo record must be thrown away. In MariaDB 10.2 we have two disjoint sets of rollback segments (128 for persistent, 128 for temporary), and purge does not even see the temporary tables. The only reason why temporary tables are visible to other threads is a SQL layer bug (MDEV-17805). purge_sys_t::choose_next_log(): merge the relevant part of TrxUndoRsegsIterator::set_next() to the start of purge_sys_t::choose_next_log(). purge_sys_t::rseg_get_next_history_log(): add a tail call of purge_sys_t::choose_next_log() and adjust the callers, to simplify the control flow further. purge_sys.pq_mutex and purge_sys.purge_queue: make it private by adding some simple accessor function. trx_purge_cleanse_purge_queue(): make it a member of purge_sys_t to have have access to private purge_sys.pq_mutex and purge_sys.purge_queue, simplify the code with using simple array copy and clearing purge queue instead of poping each purge queue element. rseg_t::last_commit_and_offset: exchange trx_no and offset bits to avoid bitwise operations during pushing to/popping from purge queue. Thanks Marko Mäkelä for historical overview of TrxUndoRsegs development. Reviewed by: Marko Mäkelä --- storage/innobase/include/trx0purge.h | 177 +++++++++++++++------------ storage/innobase/include/trx0rseg.h | 10 +- storage/innobase/trx/trx0purge.cc | 176 ++++++++------------------ storage/innobase/trx/trx0rseg.cc | 17 ++- storage/innobase/trx/trx0trx.cc | 16 ++- 5 files changed, 177 insertions(+), 219 deletions(-) diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index a836c134c02..53f66d4930d 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -55,80 +55,79 @@ Run a purge batch. @return number of undo log pages handled in the batch */ ulint trx_purge(ulint n_tasks, ulint history_size); -/** Rollback segements from a given transaction with trx-no -scheduled for purge. */ -class TrxUndoRsegs { -private: - typedef std::vector > - trx_rsegs_t; -public: - typedef trx_rsegs_t::iterator iterator; - typedef trx_rsegs_t::const_iterator const_iterator; - - TrxUndoRsegs() = default; - - /** Constructor */ - TrxUndoRsegs(trx_rseg_t& rseg) - : trx_no(rseg.last_trx_no()), m_rsegs(1, &rseg) {} - /** Constructor */ - TrxUndoRsegs(trx_id_t trx_no, trx_rseg_t& rseg) - : trx_no(trx_no), m_rsegs(1, &rseg) {} - - bool operator!=(const TrxUndoRsegs& other) const - { return trx_no != other.trx_no; } - bool empty() const { return m_rsegs.empty(); } - void erase(iterator& it) { m_rsegs.erase(it); } - iterator begin() { return(m_rsegs.begin()); } - iterator end() { return(m_rsegs.end()); } - const_iterator begin() const { return m_rsegs.begin(); } - const_iterator end() const { return m_rsegs.end(); } - - /** Compare two TrxUndoRsegs based on trx_no. - @param elem1 first element to compare - @param elem2 second element to compare - @return true if elem1 > elem2 else false.*/ - bool operator()(const TrxUndoRsegs& lhs, const TrxUndoRsegs& rhs) - { - return(lhs.trx_no > rhs.trx_no); - } - - /** Copy of trx_rseg_t::last_trx_no() */ - trx_id_t trx_no= 0; -private: - /** Rollback segments of a transaction, scheduled for purge. */ - trx_rsegs_t m_rsegs{}; -}; - -typedef std::priority_queue< - TrxUndoRsegs, - std::vector >, - TrxUndoRsegs> purge_pq_t; - -/** Chooses the rollback segment with the oldest committed transaction */ -struct TrxUndoRsegsIterator { - /** Constructor */ - TrxUndoRsegsIterator(); - /** Sets the next rseg to purge in purge_sys. - Executed in the purge coordinator thread. - @retval false when nothing is to be purged - @retval true when purge_sys.rseg->latch was locked */ - inline bool set_next(); - -private: - // Disable copying - TrxUndoRsegsIterator(const TrxUndoRsegsIterator&); - TrxUndoRsegsIterator& operator=(const TrxUndoRsegsIterator&); - - /** The current element to process */ - TrxUndoRsegs m_rsegs; - /** Track the current element in m_rsegs */ - TrxUndoRsegs::const_iterator m_iter; -}; - /** The control structure used in the purge operation */ class purge_sys_t { - friend TrxUndoRsegsIterator; + /** Min-heap based priority queue over fixed size array */ + class purge_queue + { + /** Array of indexes in trx_sys.rseg_array. */ + alignas(CPU_LEVEL1_DCACHE_LINESIZE) byte m_array[TRX_SYS_N_RSEGS]; + /** Pointer to the end of m_array. */ + byte *m_end= m_array; + + public: + struct trx_rseg_cmp + { + /** Compare two trx_rseg_t* based on trx_no. + @param lhs first index in trx_sys.rseg_array to compare + @param rhs second index in trx_sys.rseg_array to compare + @return whether lhs>rhs */ + bool operator()(const byte lhs, const byte rhs) + { + ut_ad(lhs < TRX_SYS_N_RSEGS); + ut_ad(rhs < TRX_SYS_N_RSEGS); + /* We can compare without trx_rseg_t::latch, because rseg last + commit is always set before pushing rseg to purge queue. */ + return trx_sys.rseg_array[lhs].last_commit_and_offset > + trx_sys.rseg_array[rhs].last_commit_and_offset; + } + }; + byte *begin() { return m_array; } + byte *end() { return m_end; } + const byte *c_begin() const { return m_array; } + const byte *c_end() const { return m_end; } + size_t size() const + { + size_t s= c_end() - c_begin(); + ut_ad(s <= TRX_SYS_N_RSEGS); + return s; + } + bool empty() const { return !size(); } + void clear() { m_end= m_array; } + + /** Push index of trx_sys.rseg_array into min-heap. + @param i index to push */ + void push_rseg_index(byte i) + { + ut_ad(i < TRX_SYS_N_RSEGS); + ut_ad(size() + 1 <= TRX_SYS_N_RSEGS); + *m_end++= i; + std::push_heap(begin(), end(), trx_rseg_cmp()); + } + + /** Push rseg to priority queue. + @param rseg trx_rseg_t pointer to push */ + void push(const trx_rseg_t *rseg) + { + ut_ad(rseg >= trx_sys.rseg_array); + ut_ad(rseg < trx_sys.rseg_array + TRX_SYS_N_RSEGS); + byte i= byte(rseg - trx_sys.rseg_array); + push_rseg_index(i); + } + + /** Pop rseg from priority queue. + @return pointer to popped trx_rseg_t object */ + trx_rseg_t *pop() + { + ut_ad(!empty()); + std::pop_heap(begin(), end(), trx_rseg_cmp()); + byte i= *--m_end; + ut_ad(i < TRX_SYS_N_RSEGS); + return &trx_sys.rseg_array[i]; + } + }; + public: /** latch protecting view, m_enabled */ alignas(CPU_LEVEL1_DCACHE_LINESIZE) mutable srw_spin_lock latch; @@ -244,15 +243,27 @@ private: record */ uint16_t hdr_offset; /*!< Header byte offset on the page */ + /** Binary min-heap of indexes in trx_sys.rseg_array, ordered on + rseg_t::last_trx_no(). It is protected by the pq_mutex */ + purge_queue purge_queue; + + /** Mutex protecting purge_queue */ + mysql_mutex_t pq_mutex; - TrxUndoRsegsIterator - rseg_iter; /*!< Iterator to get the next rseg - to process */ public: - purge_pq_t purge_queue; /*!< Binary min-heap, ordered on - TrxUndoRsegs::trx_no. It is protected - by the pq_mutex */ - mysql_mutex_t pq_mutex; /*!< Mutex protecting purge_queue */ + /** Push to purge queue without acquiring pq_mutex. + @param rseg rseg to push */ + void enqueue(trx_rseg_t &rseg) + { + mysql_mutex_assert_owner(&pq_mutex); + purge_queue.push(&rseg); + } + + /** Acquare purge_queue_mutex */ + void queue_lock() { mysql_mutex_lock(&pq_mutex); } + + /** Release purge queue mutex */ + void queue_unlock() { mysql_mutex_unlock(&pq_mutex); } /** innodb_undo_log_truncate=ON state; only modified by purge_coordinator_callback() */ @@ -332,8 +343,9 @@ private: /** Update the last not yet purged history log info in rseg when we have purged a whole undo log. Advances also purge_trx_no - past the purged log. */ - void rseg_get_next_history_log(); + past the purged log. + @return whether anything is to be purged */ + bool rseg_get_next_history_log(); public: /** @@ -438,6 +450,11 @@ public: @param already_stopped True indicates purge threads were already stopped */ void stop_FTS(const dict_table_t &table, bool already_stopped=false); + + /** Cleanse purge queue to remove the rseg that reside in undo-tablespace + marked for truncate. + @param space undo tablespace being truncated */ + void cleanse_purge_queue(const fil_space_t &space); }; /** The global data structure coordinating a purge */ diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index 7211d9cba1a..e3d7a63efbb 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -170,19 +170,21 @@ public: /** Last not yet purged undo log header; FIL_NULL if all purged */ uint32_t last_page_no; - /** trx_t::no | last_offset << 48 */ + /** trx_t::no << 16 | last_offset */ uint64_t last_commit_and_offset; /** @return the commit ID of the last committed transaction */ trx_id_t last_trx_no() const - { return last_commit_and_offset & ((1ULL << 48) - 1); } + { return last_commit_and_offset >> 16; } /** @return header offset of the last committed transaction */ uint16_t last_offset() const - { return static_cast(last_commit_and_offset >> 48); } + { + return static_cast(last_commit_and_offset & ((1ULL << 16) - 1)); + } void set_last_commit(uint16_t last_offset, trx_id_t trx_no) { - last_commit_and_offset= static_cast(last_offset) << 48 | trx_no; + last_commit_and_offset= trx_no << 16 | static_cast(last_offset); } /** @return the page identifier */ diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 5101879ddab..2fa202e8459 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -56,84 +56,6 @@ purge_sys_t purge_sys; my_bool srv_purge_view_update_only_debug; #endif /* UNIV_DEBUG */ -/** Sentinel value */ -static const TrxUndoRsegs NullElement; - -/** Default constructor */ -TrxUndoRsegsIterator::TrxUndoRsegsIterator() - : m_rsegs(NullElement), m_iter(m_rsegs.begin()) -{ -} - -/** Sets the next rseg to purge in purge_sys. -Executed in the purge coordinator thread. -@retval false when nothing is to be purged -@retval true when purge_sys.rseg->latch was locked */ -inline bool TrxUndoRsegsIterator::set_next() -{ - ut_ad(!purge_sys.next_stored); - mysql_mutex_lock(&purge_sys.pq_mutex); - - /* Only purge consumes events from the priority queue, user - threads only produce the events. */ - - /* Check if there are more rsegs to process in the - current element. */ - if (m_iter != m_rsegs.end()) { - /* We are still processing rollback segment from - the same transaction and so expected transaction - number shouldn't increase. Undo the increment of - expected commit done by caller assuming rollback - segments from given transaction are done. */ - purge_sys.tail.trx_no = (*m_iter)->last_trx_no(); - } else if (!purge_sys.purge_queue.empty()) { - m_rsegs = purge_sys.purge_queue.top(); - purge_sys.purge_queue.pop(); - ut_ad(purge_sys.purge_queue.empty() - || purge_sys.purge_queue.top() != m_rsegs); - m_iter = m_rsegs.begin(); - } else { - /* Queue is empty, reset iterator. */ - purge_sys.rseg = NULL; - mysql_mutex_unlock(&purge_sys.pq_mutex); - m_rsegs = NullElement; - m_iter = m_rsegs.begin(); - return false; - } - - purge_sys.rseg = *m_iter++; - mysql_mutex_unlock(&purge_sys.pq_mutex); - - /* We assume in purge of externally stored fields that space - id is in the range of UNDO tablespace space ids */ - ut_ad(purge_sys.rseg->space->id == TRX_SYS_SPACE - || srv_is_undo_tablespace(purge_sys.rseg->space->id)); - - purge_sys.rseg->latch.wr_lock(SRW_LOCK_CALL); - trx_id_t last_trx_no = purge_sys.rseg->last_trx_no(); - purge_sys.hdr_offset = purge_sys.rseg->last_offset(); - purge_sys.hdr_page_no = purge_sys.rseg->last_page_no; - - /* Only the purge_coordinator_task will access this object - purge_sys.rseg_iter, or any of purge_sys.hdr_page_no, - purge_sys.tail. - The field purge_sys.head and purge_sys.view are modified by - purge_sys_t::clone_end_view() - in the purge_coordinator_task - while holding exclusive purge_sys.latch. - The purge_sys.view may also be modified by - purge_sys_t::wake_if_not_active() while holding exclusive - purge_sys.latch. - The purge_sys.head may be read by - purge_truncation_callback(). */ - ut_ad(last_trx_no == m_rsegs.trx_no); - ut_a(purge_sys.hdr_page_no != FIL_NULL); - ut_a(purge_sys.tail.trx_no <= last_trx_no); - purge_sys.tail.trx_no = last_trx_no; - - return(true); -} - /** Build a purge 'query' graph. The actual purge is performed by executing this query graph. @return own: the query graph */ @@ -571,42 +493,17 @@ loop: goto loop; } -/** Cleanse purge queue to remove the rseg that reside in undo-tablespace -marked for truncate. -@param[in] space undo tablespace being truncated */ -static void trx_purge_cleanse_purge_queue(const fil_space_t& space) +void purge_sys_t::cleanse_purge_queue(const fil_space_t &space) { - typedef std::vector purge_elem_list_t; - purge_elem_list_t purge_elem_list; - - mysql_mutex_lock(&purge_sys.pq_mutex); - - /* Remove rseg instances that are in the purge queue before we start - truncate of corresponding UNDO truncate. */ - while (!purge_sys.purge_queue.empty()) { - purge_elem_list.push_back(purge_sys.purge_queue.top()); - purge_sys.purge_queue.pop(); - } - - for (purge_elem_list_t::iterator it = purge_elem_list.begin(); - it != purge_elem_list.end(); - ++it) { - - for (TrxUndoRsegs::iterator it2 = it->begin(); - it2 != it->end(); - ++it2) { - if ((*it2)->space == &space) { - it->erase(it2); - break; - } - } - - if (!it->empty()) { - purge_sys.purge_queue.push(*it); - } - } - - mysql_mutex_unlock(&purge_sys.pq_mutex); + byte purge_elem_list[TRX_SYS_N_RSEGS]; + mysql_mutex_lock(&pq_mutex); + std::copy(purge_queue.c_begin(), purge_queue.c_end(), purge_elem_list); + byte *purge_list_end = purge_elem_list + purge_queue.size(); + purge_queue.clear(); + for (byte *elem = purge_elem_list; elem < purge_list_end; ++elem) + if (trx_sys.rseg_array[*elem].space != &space) + purge_queue.push_rseg_index(*elem); + mysql_mutex_unlock(&pq_mutex); } dberr_t purge_sys_t::iterator::free_history() const @@ -750,7 +647,7 @@ not_free: const char *file_name= UT_LIST_GET_FIRST(space->chain)->name; sql_print_information("InnoDB: Truncating %s", file_name); - trx_purge_cleanse_purge_queue(*space); + purge_sys.cleanse_purge_queue(*space); /* Lock all modified pages of the tablespace. @@ -869,7 +766,7 @@ buf_block_t *purge_sys_t::get_page(page_id_t id) return nullptr; } -void purge_sys_t::rseg_get_next_history_log() +bool purge_sys_t::rseg_get_next_history_log() { fil_addr_t prev_log_addr; @@ -917,12 +814,13 @@ void purge_sys_t::rseg_get_next_history_log() can never produce events from an empty rollback segment. */ mysql_mutex_lock(&pq_mutex); - purge_queue.push(*rseg); + purge_queue.push(rseg); mysql_mutex_unlock(&pq_mutex); } } rseg->latch.wr_unlock(); + return choose_next_log(); } /** Position the purge sys "iterator" on the undo record to use for purging. @@ -930,11 +828,37 @@ void purge_sys_t::rseg_get_next_history_log() @retval true when purge_sys.rseg->latch was locked */ bool purge_sys_t::choose_next_log() { - if (!rseg_iter.set_next()) - return false; + ut_ad(!next_stored); - hdr_offset= rseg->last_offset(); - hdr_page_no= rseg->last_page_no; + mysql_mutex_lock(&pq_mutex); + if (purge_queue.empty()) { + rseg = nullptr; + mysql_mutex_unlock(&purge_sys.pq_mutex); + return false; + } + rseg= purge_queue.pop(); + mysql_mutex_unlock(&purge_sys.pq_mutex); + + /* We assume in purge of externally stored fields that space + id is in the range of UNDO tablespace space ids */ + ut_ad(rseg->space == fil_system.sys_space || + srv_is_undo_tablespace(rseg->space->id)); + + rseg->latch.wr_lock(SRW_LOCK_CALL); + trx_id_t last_trx_no = rseg->last_trx_no(); + hdr_offset = rseg->last_offset(); + hdr_page_no = rseg->last_page_no; + + /* Only the purge_coordinator_task will access this any of + purge_sys.hdr_page_no, purge_sys.tail. The field purge_sys.head and + purge_sys.view are modified by clone_end_view() in the + purge_coordinator_task while holding exclusive purge_sys.latch. The + purge_sys.view may also be modified by wake_if_not_active() while holding + exclusive purge_sys.latch. The purge_sys.head may be read by + purge_truncation_callback(). */ + ut_a(hdr_page_no != FIL_NULL); + ut_a(tail.trx_no <= last_trx_no); + tail.trx_no = last_trx_no; if (!rseg->needs_purge) { @@ -993,12 +917,9 @@ inline trx_purge_rec_t purge_sys_t::get_next_rec(roll_ptr_t roll_ptr) if (!offset) { - /* It is the dummy undo log record, which means that there is no - need to purge this undo log */ - rseg_get_next_history_log(); - - /* Look for the next undo log and record to purge */ - if (choose_next_log()) + /* It is the dummy undo log record, which means that there is no need to + purge this undo log. Look for the next undo log and record to purge */ + if (rseg_get_next_history_log()) rseg->latch.wr_unlock(); return {nullptr, 1}; } @@ -1046,9 +967,8 @@ inline trx_purge_rec_t purge_sys_t::get_next_rec(roll_ptr_t roll_ptr) else { got_no_rec: - rseg_get_next_history_log(); /* Look for the next undo log and record to purge */ - locked= choose_next_log(); + locked= rseg_get_next_history_log(); } if (locked) diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index 26d09f5fbbe..8732ae81005 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -544,7 +544,7 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, mtr_t *mtr) if (rseg->last_page_no != FIL_NULL) /* There is no need to cover this operation by the purge mutex because we are still bootstrapping. */ - purge_sys.purge_queue.push(*rseg); + purge_sys.enqueue(*rseg); } return err; @@ -584,7 +584,17 @@ dberr_t trx_rseg_array_init() #endif mtr_t mtr; dberr_t err = DB_SUCCESS; - + /* mariabackup --prepare only deals with the redo log and the data + files, not with transactions or the data dictionary, that's why + trx_lists_init_at_db_start() does not invoke purge_sys.create() and + purge queue mutex stays uninitialized, and trx_rseg_mem_restore() quits + before initializing undo log lists. */ + if (srv_operation != SRV_OPERATION_RESTORE) + /* Acquiring purge queue mutex here should be fine from the + deadlock prevention point of view, because executing that + function is a prerequisite for starting the purge subsystem or + any transactions. */ + purge_sys.queue_lock(); for (ulint rseg_id = 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) { mtr.start(); if (const buf_block_t* sys = trx_sysf_get(&mtr, false)) { @@ -640,7 +650,8 @@ dberr_t trx_rseg_array_init() mtr.commit(); } - + if (srv_operation != SRV_OPERATION_RESTORE) + purge_sys.queue_unlock(); if (err != DB_SUCCESS) { for (auto& rseg : trx_sys.rseg_array) { while (auto u = UT_LIST_GET_FIRST(rseg.undo_list)) { diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 59685e21cfb..dbbdb8bace1 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1138,15 +1138,23 @@ inline void trx_t::write_serialisation_history(mtr_t *mtr) } else if (rseg->last_page_no == FIL_NULL) { - mysql_mutex_lock(&purge_sys.pq_mutex); + /* trx_sys.assign_new_trx_no() and + purge_sys.enqueue() must be invoked in the same + critical section protected with purge queue mutex to avoid rseg with + greater last commit number to be pushed to purge queue prior to rseg with + lesser last commit number. In other words pushing to purge queue must be + serialized along with assigning trx_no. Otherwise purge coordinator + thread can also fetch redo log records from rseg with greater last commit + number before rseg with lesser one. */ + purge_sys.queue_lock(); trx_sys.assign_new_trx_no(this); const trx_id_t end{rw_trx_hash_element->no}; + rseg->last_page_no= undo->hdr_page_no; /* end cannot be less than anything in rseg. User threads only produce events when a rollback segment is empty. */ - purge_sys.purge_queue.push(TrxUndoRsegs{end, *rseg}); - mysql_mutex_unlock(&purge_sys.pq_mutex); - rseg->last_page_no= undo->hdr_page_no; rseg->set_last_commit(undo->hdr_offset, end); + purge_sys.enqueue(*rseg); + purge_sys.queue_unlock(); } else trx_sys.assign_new_trx_no(this); From 9a4991a089532ca0fe803e646a24c639c47c34b8 Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Mon, 1 Apr 2024 09:46:50 -0600 Subject: [PATCH 050/313] MDEV-33799: mysql_manager_submit Segfault at Startup Still Possible During Recovery MDEV-26473 fixed a segmentation fault at startup between the handle manager thread and the binlog background thread, such that the binlog background thread could be started and submit a job to the handle manager, before it had initialized. Where MDEV-26473 made it so the handle manager would initialize before the main thread started the normal binary logs, it did not account for the recovery case. That is, there is still a possibility of a segmentation fault when a server is recovering using the binary logs such that it can open the binary logs, start the binlog background thread, and submit a job to the handle manager before it is initialized. This patch fixes this by moving the initialization of the mysql handler manager to happen prior to recovery. Reviewed By: ============ Andrei Elkin --- .../r/rpl_mysql_manager_race_condition.result | 31 +++++++++ .../t/rpl_mysql_manager_race_condition.test | 64 +++++++++++++++++++ sql/mysqld.cc | 7 +- 3 files changed, 99 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_mysql_manager_race_condition.result b/mysql-test/suite/rpl/r/rpl_mysql_manager_race_condition.result index 1172d8e39a9..740d1ddfcfa 100644 --- a/mysql-test/suite/rpl/r/rpl_mysql_manager_race_condition.result +++ b/mysql-test/suite/rpl/r/rpl_mysql_manager_race_condition.result @@ -17,6 +17,36 @@ include/sync_with_master_gtid.inc include/rpl_restart_server.inc [server_number=2 parameters: --debug_dbug="+d,delay_start_handle_manager"] include/start_slave.inc # +# MDEV-33799 +# Ensure that when the binary log is used for recovery (as tc log), that +# the recovery process cannot start the binlog background thread before +# the mysql handle manager has started. +connection slave; +# Add test suppresssions so crash recovery messages don't fail the test +set session sql_log_bin=0; +call mtr.add_suppression("mariadbd: Got error '145.*"); +call mtr.add_suppression("Checking table:.*"); +call mtr.add_suppression("mysql.gtid_slave_pos:.*hasn't closed the table properly"); +call mtr.add_suppression("Can't init tc log"); +call mtr.add_suppression("Aborting"); +set session sql_log_bin=1; +# Create slave-side only table +create table t2 (a int) engine=innodb; +# Crash mariadbd when binlogging transaction to corrupt database state +connection slave1; +set @@session.debug_dbug="+d,crash_before_writing_xid"; +insert into t2 values (1); +connection slave; +connection slave1; +Got one of the listed errors +# Restart mariadbd in recovery mode. Note --tc-heuristic-recover +# forces mysqld to exit with error, so we run mariadbd via CLI +# MYSQLD_LAST_CMD --debug_dbug="+d,delay_start_handle_manager" --tc-heuristic-recover=COMMIT +connection server_2; +connection slave1; +connection slave; +include/start_slave.inc +# # Cleanup # connection master; @@ -24,4 +54,5 @@ drop table t1; include/save_master_gtid.inc connection slave; include/sync_with_master_gtid.inc +drop table t2; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition.test b/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition.test index 751da3158b7..dd4a0fbbc99 100644 --- a/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition.test +++ b/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition.test @@ -18,8 +18,14 @@ # associated with this test should enforce that the binlog background thread is # not created before the handle manager is initialized. # +# Addendum 1) This test is extended for MDEV-33799, as the original fix +# left out the possibility that the binlog background thread can be +# started during recovery if the binary log is used as the transaction +# coordinator. This resulted in similar segfaults as seen by MDEV-26473. +# # References: # MDEV-26473 mysqld got exception 0xc0000005 (rpl_slave_state/rpl_load_gtid_slave_state) +# MDEV-33799 mysql_manager_submit Segfault at Startup Still Possible During Recovery # --source include/have_debug.inc @@ -53,6 +59,63 @@ create table t1 (a int); --source include/start_slave.inc +--echo # +--echo # MDEV-33799 +--echo # Ensure that when the binary log is used for recovery (as tc log), that +--echo # the recovery process cannot start the binlog background thread before +--echo # the mysql handle manager has started. +--connection slave + +--echo # Add test suppresssions so crash recovery messages don't fail the test +set session sql_log_bin=0; +call mtr.add_suppression("mariadbd: Got error '145.*"); +call mtr.add_suppression("Checking table:.*"); +call mtr.add_suppression("mysql.gtid_slave_pos:.*hasn't closed the table properly"); +call mtr.add_suppression("Can't init tc log"); +call mtr.add_suppression("Aborting"); +set session sql_log_bin=1; + +--echo # Create slave-side only table +create table t2 (a int) engine=innodb; + +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +wait +EOF + +--echo # Crash mariadbd when binlogging transaction to corrupt database state +--connection slave1 +set @@session.debug_dbug="+d,crash_before_writing_xid"; +--send insert into t2 values (1) + +--connection slave +--source include/wait_until_disconnected.inc + +--connection slave1 +--error 2013,ER_CONNECTION_KILLED +--reap + +--echo # Restart mariadbd in recovery mode. Note --tc-heuristic-recover +--echo # forces mysqld to exit with error, so we run mariadbd via CLI +--echo # MYSQLD_LAST_CMD --debug_dbug="+d,delay_start_handle_manager" --tc-heuristic-recover=COMMIT +--error 1 +--exec $MYSQLD_LAST_CMD --debug_dbug="+d,delay_start_handle_manager" --tc-heuristic-recover=COMMIT + +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +restart +EOF + +--connection server_2 +--enable_reconnect +--source include/wait_until_connected_again.inc +--connection slave1 +--enable_reconnect +--source include/wait_until_connected_again.inc +--connection slave +--enable_reconnect +--source include/wait_until_connected_again.inc +--source include/start_slave.inc + + --echo # --echo # Cleanup --echo # @@ -63,5 +126,6 @@ drop table t1; --connection slave --source include/sync_with_master_gtid.inc +drop table t2; --source include/rpl_end.inc diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c29bfc2ed50..d10c342a6dc 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5383,6 +5383,10 @@ static int init_server_components() if (ddl_log_initialize()) unireg_abort(1); +#ifndef EMBEDDED_LIBRARY + start_handle_manager(); +#endif + tc_log= get_tc_log_implementation(); if (tc_log->open(opt_bin_log ? opt_bin_logname : opt_tc_log_file)) @@ -5394,9 +5398,6 @@ static int init_server_components() if (ha_recover(0)) unireg_abort(1); -#ifndef EMBEDDED_LIBRARY - start_handle_manager(); -#endif if (opt_bin_log) { int error; From 8cc36fb7434114fce06725cc607c2f7c65ac3ac7 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 20 Mar 2024 13:09:12 +0300 Subject: [PATCH 051/313] MDEV-21102: Server crashes in JOIN_CACHE::write_record_data upon EXPLAIN with subqueries JOIN_CACHE has a light-weight initialization mode that's targeted at EXPLAINs. In that mode, JOIN_CACHE objects are not able to execute. Light-weight mode was used whenever the statement was an EXPLAIN. However the EXPLAIN can execute subqueries, provided they enumerate less than @@expensive_subquery_limit rows. Make sure we use light-weight initialization mode only when the select is more expensive @@expensive_subquery_limit. Also add an assert into JOIN_CACHE::put_record() which prevents its use if it was initialized for EXPLAIN only. --- mysql-test/main/join_cache.result | 22 ++++++++++++++++++++++ mysql-test/main/join_cache.test | 21 +++++++++++++++++++++ sql/item_subselect.cc | 2 ++ sql/sql_join_cache.cc | 1 + sql/sql_select.cc | 23 ++++++++++++++++++++++- 5 files changed, 68 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index c07a8b1bf6b..49f3b0910fa 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -6396,5 +6396,27 @@ b b d c c 10 NULL NULL NULL NULL DROP TABLE t1,t2,t3,t4; # +# MDEV-21102: Server crashes in JOIN_CACHE::write_record_data upon EXPLAIN with subqueries and constant tables +# +CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; +CREATE TABLE t2 (c int, d int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,10); +CREATE TABLE t3 (e int, key (e)) ENGINE=MyISAM; +INSERT INTO t3 VALUES (2),(3); +# Must not crash, must use join buffer in subquery +EXPLAIN +SELECT * FROM t1 +WHERE a > b OR a IN ( +SELECT c FROM t2 WHERE EXISTS ( +SELECT * FROM t3 t3a JOIN t3 t3b WHERE t3a.e < d +) +); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 +3 SUBQUERY t3a index e e 5 NULL 2 Using where; Using index +3 SUBQUERY t3b index NULL e 5 NULL 2 Using index; Using join buffer (flat, BNL join) +DROP TABLE t1,t2,t3; +# # End of 10.4 tests # diff --git a/mysql-test/main/join_cache.test b/mysql-test/main/join_cache.test index 868fc3f7e8a..8d341c9e0fc 100644 --- a/mysql-test/main/join_cache.test +++ b/mysql-test/main/join_cache.test @@ -4305,6 +4305,27 @@ eval $q2; DROP TABLE t1,t2,t3,t4; +--echo # +--echo # MDEV-21102: Server crashes in JOIN_CACHE::write_record_data upon EXPLAIN with subqueries and constant tables +--echo # +CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; + +CREATE TABLE t2 (c int, d int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,10); + +CREATE TABLE t3 (e int, key (e)) ENGINE=MyISAM; +INSERT INTO t3 VALUES (2),(3); + +--echo # Must not crash, must use join buffer in subquery +EXPLAIN +SELECT * FROM t1 +WHERE a > b OR a IN ( + SELECT c FROM t2 WHERE EXISTS ( + SELECT * FROM t3 t3a JOIN t3 t3b WHERE t3a.e < d + ) +); +DROP TABLE t1,t2,t3; + --echo # --echo # End of 10.4 tests --echo # diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index a8824adbdd8..d39c85e6f76 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -562,6 +562,8 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent, This measure is used instead of JOIN::read_time, because it is considered to be much more reliable than the cost estimate. + Note: the logic in this function must agree with JOIN::init_join_caches(). + @return true if the subquery is expensive @return false otherwise */ diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 41d7dd89f55..c33c2f029cd 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -1589,6 +1589,7 @@ bool JOIN_CACHE::put_record() { bool is_full; uchar *link= 0; + DBUG_ASSERT(!for_explain_only); if (prev_cache) link= prev_cache->get_curr_rec_link(); write_record_data(link, &is_full); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9e8b8e4ebe0..efcd42be074 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1876,6 +1876,26 @@ JOIN::init_range_rowid_filters() int JOIN::init_join_caches() { + bool init_for_explain= false; + + /* + Can we use lightweight initalization mode just for EXPLAINs? We can if + we're certain that the optimizer will not execute the subquery. + The optimzier will not execute the subquery if it's too expensive. For + the exact criteria, see Item_subselect::is_expensive(). + Note that the subquery might be a UNION and we might not yet know if it is + expensive. + What we do know is that if this SELECT is too expensive, then the whole + subquery will be too expensive as well. + So, we can use lightweight initialization (init_for_explain=true) if this + SELECT examines more than @@expensive_subquery_limit rows. + */ + if ((select_options & SELECT_DESCRIBE) && + get_examined_rows() >= thd->variables.expensive_subquery_limit) + { + init_for_explain= true; + } + JOIN_TAB *tab; for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); @@ -1895,7 +1915,8 @@ int JOIN::init_join_caches() { table->prepare_for_keyread(tab->index, table->read_set); } - if (tab->cache && tab->cache->init(select_options & SELECT_DESCRIBE)) + + if (tab->cache && tab->cache->init(init_for_explain)) revise_cache_usage(tab); else tab->remove_redundant_bnl_scan_conds(); From 2fcf2ec229862fe24a97c54db4e62f1ae8f9ed63 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Thu, 4 Apr 2024 17:12:09 +0300 Subject: [PATCH 052/313] MDEV-33749 hyphen in table name can cause galera certification failures Fix in this commit handles foreign key value appending into write set so that db and table names are converted from the filepath format to tablename format. This is compatible with key values appended from elsewhere in the code base There is a mtr test galera.galera_table_with_hyphen for regression testing Reviewer: monty@mariadb.com --- .../galera/r/galera_table_with_hyphen.result | 52 +++++++++++++++++++ .../galera/t/galera_table_with_hyphen.inc | 48 +++++++++++++++++ .../galera/t/galera_table_with_hyphen.test | 34 ++++++++++++ sql/handler.cc | 11 +++- storage/innobase/handler/ha_innodb.cc | 43 ++++++++++----- 5 files changed, 173 insertions(+), 15 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_table_with_hyphen.result create mode 100644 mysql-test/suite/galera/t/galera_table_with_hyphen.inc create mode 100644 mysql-test/suite/galera/t/galera_table_with_hyphen.test diff --git a/mysql-test/suite/galera/r/galera_table_with_hyphen.result b/mysql-test/suite/galera/r/galera_table_with_hyphen.result new file mode 100644 index 00000000000..c9993004b53 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_table_with_hyphen.result @@ -0,0 +1,52 @@ +connection node_2; +connection node_1; +connection node_1; +set wsrep_sync_wait=0; +connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET SESSION wsrep_sync_wait = 0; +connection node_1; +SET GLOBAL wsrep_slave_threads=2; +CREATE TABLE `par-ent` ( id INT AUTO_INCREMENT PRIMARY KEY, j INT) ENGINE=InnoDB; +CREATE TABLE `child` (id INT AUTO_INCREMENT PRIMARY KEY, parent_id INT, j INT, FOREIGN KEY (parent_id) REFERENCES `par-ent`(id)) ENGINE=InnoDB; +INSERT INTO `par-ent` VALUES (23,0); +connection node_2; +connection node_1a; +SET GLOBAL DEBUG_DBUG='+d,wsrep_ha_write_row'; +connection node_2; +INSERT INTO `child` VALUES (21,23,0),(22,23,0),(23,23,0); +connection node_1a; +SET DEBUG_SYNC='now WAIT_FOR wsrep_ha_write_row_reached'; +connection node_2; +UPDATE `par-ent` SET j=2 WHERE id=23; +connection node_1a; +SET GLOBAL DEBUG_DBUG='-d,wsrep_ha_write_row'; +SET DEBUG_SYNC='now SIGNAL wsrep_ha_write_row_continue'; +SET GLOBAL DEBUG_DBUG="RESET"; +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL wsrep_slave_threads=DEFAULT; +connection node_2; +drop table `child`; +drop table `par-ent`; +connection node_1; +SET GLOBAL wsrep_slave_threads=2; +CREATE TABLE `p-arent-` ( id INT AUTO_INCREMENT PRIMARY KEY, j INT) ENGINE=InnoDB; +CREATE TABLE `c-hild` (id INT AUTO_INCREMENT PRIMARY KEY, parent_id INT, j INT, FOREIGN KEY (parent_id) REFERENCES `p-arent-`(id)) ENGINE=InnoDB; +INSERT INTO `p-arent-` VALUES (23,0); +connection node_2; +connection node_1a; +SET GLOBAL DEBUG_DBUG='+d,wsrep_ha_write_row'; +connection node_2; +INSERT INTO `c-hild` VALUES (21,23,0),(22,23,0),(23,23,0); +connection node_1a; +SET DEBUG_SYNC='now WAIT_FOR wsrep_ha_write_row_reached'; +connection node_2; +UPDATE `p-arent-` SET j=2 WHERE id=23; +connection node_1a; +SET GLOBAL DEBUG_DBUG='-d,wsrep_ha_write_row'; +SET DEBUG_SYNC='now SIGNAL wsrep_ha_write_row_continue'; +SET GLOBAL DEBUG_DBUG="RESET"; +SET DEBUG_SYNC = 'RESET'; +SET GLOBAL wsrep_slave_threads=DEFAULT; +connection node_2; +drop table `c-hild`; +drop table `p-arent-`; diff --git a/mysql-test/suite/galera/t/galera_table_with_hyphen.inc b/mysql-test/suite/galera/t/galera_table_with_hyphen.inc new file mode 100644 index 00000000000..ac79d864e82 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_table_with_hyphen.inc @@ -0,0 +1,48 @@ +# +# parameters: +# $fk_child - child table name +# $fk_parent - parent table name +# +--connection node_1 +SET GLOBAL wsrep_slave_threads=2; + +--eval CREATE TABLE `$fk_parent` ( id INT AUTO_INCREMENT PRIMARY KEY, j INT) ENGINE=InnoDB + +--eval CREATE TABLE `$fk_child` (id INT AUTO_INCREMENT PRIMARY KEY, parent_id INT, j INT, FOREIGN KEY (parent_id) REFERENCES `$fk_parent`(id)) ENGINE=InnoDB + +--eval INSERT INTO `$fk_parent` VALUES (23,0) + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM `$fk_parent`; +--source include/wait_condition.inc + +--connection node_1a +SET GLOBAL DEBUG_DBUG='+d,wsrep_ha_write_row'; + +--connection node_2 +--eval INSERT INTO `$fk_child` VALUES (21,23,0),(22,23,0),(23,23,0) + +--connection node_1a +SET DEBUG_SYNC='now WAIT_FOR wsrep_ha_write_row_reached'; + +--let $wsrep_received_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_received'` + +--connection node_2 +--eval UPDATE `$fk_parent` SET j=2 WHERE id=23 + +--connection node_1a +--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_received_before + 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_received' +--source include/wait_condition.inc + +SET GLOBAL DEBUG_DBUG='-d,wsrep_ha_write_row'; +SET DEBUG_SYNC='now SIGNAL wsrep_ha_write_row_continue'; + +SET GLOBAL DEBUG_DBUG="RESET"; +SET DEBUG_SYNC = 'RESET'; + +SET GLOBAL wsrep_slave_threads=DEFAULT; + +--connection node_2 +--eval drop table `$fk_child` +--eval drop table `$fk_parent` + diff --git a/mysql-test/suite/galera/t/galera_table_with_hyphen.test b/mysql-test/suite/galera/t/galera_table_with_hyphen.test new file mode 100644 index 00000000000..1b28bdeb3ca --- /dev/null +++ b/mysql-test/suite/galera/t/galera_table_with_hyphen.test @@ -0,0 +1,34 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +# +# Testing how tables and databases with special characters +# are treated in certification +# +# The test creates two tables having foreign key constraint +# reference and executes two transactions which modify +# same rows. The same test is executed with different names +# containin special characters to see if the certification +# can detect the conflicts +# +# Actual test is in include file galera_table_with_hyphen.inc +# It create the test tables from parameters $fk_child and +# $fk_parent +# +--connection node_1 +set wsrep_sync_wait=0; + +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET SESSION wsrep_sync_wait = 0; + +--let $fk_child = child +--let $fk_parent = par-ent + +--source galera_table_with_hyphen.inc + +--let $fk_child = c-hild +--let $fk_parent = p-arent- + +--source galera_table_with_hyphen.inc diff --git a/sql/handler.cc b/sql/handler.cc index 352076a9e21..24bc845c694 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7270,7 +7270,16 @@ int handler::ha_write_row(const uchar *buf) m_lock_type == F_WRLCK); DBUG_ENTER("handler::ha_write_row"); DEBUG_SYNC_C("ha_write_row_start"); - +#ifdef WITH_WSREP + DBUG_EXECUTE_IF("wsrep_ha_write_row", + { + const char act[]= + "now " + "SIGNAL wsrep_ha_write_row_reached " + "WAIT_FOR wsrep_ha_write_row_continue"; + DBUG_ASSERT(!debug_sync_set_action(ha_thd(), STRING_WITH_LEN(act))); + }); +#endif /* WITH_WSREP */ if ((error= ha_check_overlaps(NULL, buf))) DBUG_RETURN(error); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 19cfa21c84e..01c881e1bb8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9786,7 +9786,8 @@ wsrep_append_foreign_key( } ulint rcode = DB_SUCCESS; - char cache_key[513] = {'\0'}; + char cache_key[MAX_FULL_NAME_LEN] = {'\0'}; + char db_name[MAX_DATABASE_NAME_LEN+1] = {'\0'}; size_t cache_key_len = 0; if ( !((referenced) ? @@ -9871,14 +9872,38 @@ wsrep_append_foreign_key( return DB_ERROR; } - strncpy(cache_key, + char * fk_table = (wsrep_protocol_version > 1) ? ((referenced) ? foreign->referenced_table->name.m_name : foreign->foreign_table->name.m_name) : - foreign->foreign_table->name.m_name, sizeof(cache_key) - 1); - cache_key_len = strlen(cache_key); + foreign->foreign_table->name.m_name; + /* convert db and table name parts separately to system charset */ + ulint db_name_len = dict_get_db_name_len(fk_table); + strmake(db_name, fk_table, db_name_len); + uint errors; + cache_key_len= innobase_convert_to_system_charset(cache_key, + db_name, sizeof(cache_key), &errors); + if (errors) { + WSREP_WARN("unexpected foreign key table %s %s", + foreign->referenced_table->name.m_name, + foreign->foreign_table->name.m_name); + return DB_ERROR; + } + + /* after db name adding 0 and then converted table name */ + cache_key[db_name_len]= '\0'; + cache_key_len++; + + cache_key_len+= innobase_convert_to_system_charset(cache_key+cache_key_len, + fk_table+db_name_len+1, sizeof(cache_key), &errors); + if (errors) { + WSREP_WARN("unexpected foreign key table %s %s", + foreign->referenced_table->name.m_name, + foreign->foreign_table->name.m_name); + return DB_ERROR; + } #ifdef WSREP_DEBUG_PRINT ulint j; fprintf(stderr, "FK parent key, table: %s %s len: %lu ", @@ -9888,16 +9913,6 @@ wsrep_append_foreign_key( } fprintf(stderr, "\n"); #endif - char *p = strchr(cache_key, '/'); - - if (p) { - *p = '\0'; - } else { - WSREP_WARN("unexpected foreign key table %s %s", - foreign->referenced_table->name.m_name, - foreign->foreign_table->name.m_name); - } - wsrep_buf_t wkey_part[3]; wsrep_key_t wkey = {wkey_part, 3}; From a202371f0b0b2d07cf24660efff648b17aeb6af5 Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Thu, 4 Apr 2024 16:38:26 +0300 Subject: [PATCH 053/313] MDEV-33757 Get rid of TrxUndoRsegs code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post-push fix: purge queue array can't be fixed size, because the elements of the array is the analogue of undo logs, which must be processed in the order of transaction commits, and the array can contain more elements, than trx_sys.rseg_array. Also it's necessary to maintain min-heap property by the trx_no of transaction, which produced the first non-purged undo log in all rsegs. That's why the element of purge queue aray must contain not only trx_sys.rseg_array index, but also trx_no of committed transacion, i.e. the pair (trx_no, trx_sys.rseg_array index), which is encoded as uint64_t((trx_no << 8) | (trx_sys.rseg_array index)). Reviewed by: Marko Mäkelä --- storage/innobase/include/trx0purge.h | 116 ++++++++++++++------------- storage/innobase/include/trx0rseg.h | 2 +- storage/innobase/trx/trx0purge.cc | 12 ++- storage/innobase/trx/trx0trx.cc | 2 +- 4 files changed, 67 insertions(+), 65 deletions(-) diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index 53f66d4930d..dc28c866c74 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -58,62 +58,47 @@ ulint trx_purge(ulint n_tasks, ulint history_size); /** The control structure used in the purge operation */ class purge_sys_t { - /** Min-heap based priority queue over fixed size array */ + /** Min-heap based priority queue of (trx_no, trx_sys.rseg_array index) + pairs, ordered on trx_no. The highest 64-TRX_NO_SHIFT bits of each element is + trx_no, the lowest 8 bits is rseg's index in trx_sys.rseg_array. */ class purge_queue { - /** Array of indexes in trx_sys.rseg_array. */ - alignas(CPU_LEVEL1_DCACHE_LINESIZE) byte m_array[TRX_SYS_N_RSEGS]; - /** Pointer to the end of m_array. */ - byte *m_end= m_array; - public: - struct trx_rseg_cmp - { - /** Compare two trx_rseg_t* based on trx_no. - @param lhs first index in trx_sys.rseg_array to compare - @param rhs second index in trx_sys.rseg_array to compare - @return whether lhs>rhs */ - bool operator()(const byte lhs, const byte rhs) - { - ut_ad(lhs < TRX_SYS_N_RSEGS); - ut_ad(rhs < TRX_SYS_N_RSEGS); - /* We can compare without trx_rseg_t::latch, because rseg last - commit is always set before pushing rseg to purge queue. */ - return trx_sys.rseg_array[lhs].last_commit_and_offset > - trx_sys.rseg_array[rhs].last_commit_and_offset; - } - }; - byte *begin() { return m_array; } - byte *end() { return m_end; } - const byte *c_begin() const { return m_array; } - const byte *c_end() const { return m_end; } - size_t size() const - { - size_t s= c_end() - c_begin(); - ut_ad(s <= TRX_SYS_N_RSEGS); - return s; - } - bool empty() const { return !size(); } - void clear() { m_end= m_array; } + typedef std::vector> container_type; + /** Number of bits reseved to shift trx_no in purge queue element */ + static constexpr unsigned TRX_NO_SHIFT= 8; - /** Push index of trx_sys.rseg_array into min-heap. - @param i index to push */ - void push_rseg_index(byte i) + bool empty() const { return m_array.empty(); } + void clear() { m_array.clear(); } + + /** Push (trx_no, trx_sys.rseg_array index) into min-heap. + @param trx_no_rseg (trx_no << TRX_NO_SHIFT | (trx_sys.rseg_array index)) */ + void push_trx_no_rseg(container_type::value_type trx_no_rseg) { - ut_ad(i < TRX_SYS_N_RSEGS); - ut_ad(size() + 1 <= TRX_SYS_N_RSEGS); - *m_end++= i; - std::push_heap(begin(), end(), trx_rseg_cmp()); + m_array.push_back(trx_no_rseg); + std::push_heap(m_array.begin(), m_array.end(), + std::greater()); } /** Push rseg to priority queue. - @param rseg trx_rseg_t pointer to push */ - void push(const trx_rseg_t *rseg) + @param trx_no trx_no of committed transaction + @param rseg rseg of committed transaction*/ + void push(trx_id_t trx_no, const trx_rseg_t &rseg) { - ut_ad(rseg >= trx_sys.rseg_array); - ut_ad(rseg < trx_sys.rseg_array + TRX_SYS_N_RSEGS); - byte i= byte(rseg - trx_sys.rseg_array); - push_rseg_index(i); + ut_ad(trx_no < 1ULL << (DATA_TRX_ID_LEN * CHAR_BIT)); + ut_ad(&rseg >= trx_sys.rseg_array); + ut_ad(&rseg < trx_sys.rseg_array + TRX_SYS_N_RSEGS); + push_trx_no_rseg(trx_no << TRX_NO_SHIFT | + byte(&rseg - trx_sys.rseg_array)); + } + + /** Extracts rseg from (trx_no, trx_sys.rseg_array index) pair. + @param trx_no_rseg (trx_no << TRX_NO_SHIFT | (trx_sys.rseg_array index) + @return pointer to rseg in trx_sys.rseg_array */ + static trx_rseg_t *rseg(container_type::value_type trx_no_rseg) { + byte i= static_cast(trx_no_rseg); + ut_ad(i < TRX_SYS_N_RSEGS); + return &trx_sys.rseg_array[i]; } /** Pop rseg from priority queue. @@ -121,13 +106,23 @@ class purge_sys_t trx_rseg_t *pop() { ut_ad(!empty()); - std::pop_heap(begin(), end(), trx_rseg_cmp()); - byte i= *--m_end; - ut_ad(i < TRX_SYS_N_RSEGS); - return &trx_sys.rseg_array[i]; + std::pop_heap(m_array.begin(), m_array.end(), + std::greater()); + trx_rseg_t *r = rseg(m_array.back()); + m_array.pop_back(); + return r; } + + /** Clone m_array. + @return m_array clone */ + container_type clone_container() const{ return m_array; } + + private: + /** Array of (trx_no, trx_sys.rseg_array index) pairs. */ + container_type m_array; }; + public: /** latch protecting view, m_enabled */ alignas(CPU_LEVEL1_DCACHE_LINESIZE) mutable srw_spin_lock latch; @@ -243,20 +238,29 @@ private: record */ uint16_t hdr_offset; /*!< Header byte offset on the page */ - /** Binary min-heap of indexes in trx_sys.rseg_array, ordered on - rseg_t::last_trx_no(). It is protected by the pq_mutex */ + /** Binary min-heap of (trx_no, trx_sys.rseg_array index) pairs, ordered on + trx_no. It is protected by the pq_mutex */ purge_queue purge_queue; /** Mutex protecting purge_queue */ mysql_mutex_t pq_mutex; public: + + void enqueue(trx_id_t trx_no, const trx_rseg_t &rseg) { + mysql_mutex_assert_owner(&pq_mutex); + purge_queue.push(trx_no, rseg); + } + /** Push to purge queue without acquiring pq_mutex. @param rseg rseg to push */ - void enqueue(trx_rseg_t &rseg) - { + void enqueue(const trx_rseg_t &rseg) { enqueue(rseg.last_trx_no(), rseg); } + + /** Clone purge queue container. + @return purge queue container clone */ + purge_queue::container_type clone_queue_container() const { mysql_mutex_assert_owner(&pq_mutex); - purge_queue.push(&rseg); + return purge_queue.clone_container(); } /** Acquare purge_queue_mutex */ diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index e3d7a63efbb..24ba845271d 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -179,7 +179,7 @@ public: /** @return header offset of the last committed transaction */ uint16_t last_offset() const { - return static_cast(last_commit_and_offset & ((1ULL << 16) - 1)); + return static_cast(last_commit_and_offset); } void set_last_commit(uint16_t last_offset, trx_id_t trx_no) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 2fa202e8459..2445b85939d 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -495,14 +495,12 @@ loop: void purge_sys_t::cleanse_purge_queue(const fil_space_t &space) { - byte purge_elem_list[TRX_SYS_N_RSEGS]; mysql_mutex_lock(&pq_mutex); - std::copy(purge_queue.c_begin(), purge_queue.c_end(), purge_elem_list); - byte *purge_list_end = purge_elem_list + purge_queue.size(); + auto purge_elem_list= clone_queue_container(); purge_queue.clear(); - for (byte *elem = purge_elem_list; elem < purge_list_end; ++elem) - if (trx_sys.rseg_array[*elem].space != &space) - purge_queue.push_rseg_index(*elem); + for (auto elem : purge_elem_list) + if (purge_queue::rseg(elem)->space != &space) + purge_queue.push_trx_no_rseg(elem); mysql_mutex_unlock(&pq_mutex); } @@ -814,7 +812,7 @@ bool purge_sys_t::rseg_get_next_history_log() can never produce events from an empty rollback segment. */ mysql_mutex_lock(&pq_mutex); - purge_queue.push(rseg); + enqueue(*rseg); mysql_mutex_unlock(&pq_mutex); } } diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index dbbdb8bace1..e6068f51e04 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1153,7 +1153,7 @@ inline void trx_t::write_serialisation_history(mtr_t *mtr) /* end cannot be less than anything in rseg. User threads only produce events when a rollback segment is empty. */ rseg->set_last_commit(undo->hdr_offset, end); - purge_sys.enqueue(*rseg); + purge_sys.enqueue(end, *rseg); purge_sys.queue_unlock(); } else From faf686db9e9d7dd85f5f917d1d8c3fa0a5ab27cc Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 28 Mar 2024 18:23:11 +0100 Subject: [PATCH 054/313] MDEV-22955 innodb.innodb-alter fails in buildbot with extra warning add 10.5-specific global suppression. the extra warning is gone in 10.6 --- mysql-test/mysql-test-run.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6834a499c6e..14a6293ac29 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4518,6 +4518,9 @@ sub extract_warning_lines ($$) { qr/sql_type\.cc.* runtime error: member call.*object.* 'Type_collection'/, ); + push @antipatterns, qr/though there are still open handles to table/ + if $mysql_version_id < 100600; + my $matched_lines= []; LINE: foreach my $line ( @lines ) { From a58a570c071f4639492dc8b6b85f46c44c8be68e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 17:17:53 +0100 Subject: [PATCH 055/313] innodb.monitor test: wait for the correct value on a busy system it might take time for buffer_page_written_index_leaf to reach the correct value. Wait for it. also, tag identical statements to be different in the result file. --- mysql-test/suite/innodb/r/monitor.result | 12 ++++++------ mysql-test/suite/innodb/t/monitor.test | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result index d55f1230ed7..aed1e3e99e3 100644 --- a/mysql-test/suite/innodb/r/monitor.result +++ b/mysql-test/suite/innodb/r/monitor.result @@ -627,7 +627,7 @@ set global innodb_monitor_reset_all = default; # MONITORS # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*1*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; NAME COUNT > 0 buffer_page_written_index_leaf 0 @@ -635,13 +635,13 @@ SET GLOBAL innodb_monitor_enable='module_buffer_page'; INSERT INTO t1 VALUES (1), (2), (3), (4); FLUSH TABLES t1 FOR EXPORT; UNLOCK TABLES; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*2*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; NAME COUNT > 0 buffer_page_written_index_leaf 1 SET GLOBAL innodb_monitor_disable='module_buffer_page'; SET GLOBAL innodb_monitor_reset_all='module_buffer_page'; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*3*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; NAME COUNT > 0 buffer_page_written_index_leaf 0 @@ -651,13 +651,13 @@ ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value o INSERT INTO t1 VALUES (5), (6), (7), (8); FLUSH TABLES t1 FOR EXPORT; UNLOCK TABLES; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*4*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; NAME COUNT > 0 buffer_page_written_index_leaf 1 SET GLOBAL innodb_monitor_disable='%'; SET GLOBAL innodb_monitor_reset_all='%'; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*5*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; NAME COUNT > 0 buffer_page_written_index_leaf 0 @@ -665,7 +665,7 @@ SET GLOBAL innodb_monitor_enable='ALL'; INSERT INTO t1 VALUES (9), (10), (11), (12); FLUSH TABLES t1 FOR EXPORT; UNLOCK TABLES; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*6*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; NAME COUNT > 0 buffer_page_written_index_leaf 1 diff --git a/mysql-test/suite/innodb/t/monitor.test b/mysql-test/suite/innodb/t/monitor.test index 584dd635dcf..3fff9a1e98f 100644 --- a/mysql-test/suite/innodb/t/monitor.test +++ b/mysql-test/suite/innodb/t/monitor.test @@ -418,18 +418,22 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; let $innodb_monitor_enable = `SELECT @@innodb_monitor_enable`; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*1*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; SET GLOBAL innodb_monitor_enable='module_buffer_page'; INSERT INTO t1 VALUES (1), (2), (3), (4); FLUSH TABLES t1 FOR EXPORT; UNLOCK TABLES; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME + +let $wait_condition= select count > 0 from information_schema.innodb_metrics where name like 'buffer_page_written_index_leaf'; +source include/wait_condition.inc; + +SELECT /*2*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; SET GLOBAL innodb_monitor_disable='module_buffer_page'; SET GLOBAL innodb_monitor_reset_all='module_buffer_page'; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*3*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; SET GLOBAL innodb_monitor_enable='%'; @@ -437,18 +441,22 @@ SET GLOBAL innodb_monitor_enable='%'; SET GLOBAL innodb_monitor_reset_all= '%', innodb_compression_algorithm= foo; INSERT INTO t1 VALUES (5), (6), (7), (8); FLUSH TABLES t1 FOR EXPORT; UNLOCK TABLES; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME + +let $wait_condition= select count > 0 from information_schema.innodb_metrics where name like 'buffer_page_written_index_leaf'; +source include/wait_condition.inc; + +SELECT /*4*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; SET GLOBAL innodb_monitor_disable='%'; SET GLOBAL innodb_monitor_reset_all='%'; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*5*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; SET GLOBAL innodb_monitor_enable='ALL'; INSERT INTO t1 VALUES (9), (10), (11), (12); FLUSH TABLES t1 FOR EXPORT; UNLOCK TABLES; -SELECT NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME +SELECT /*6*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE 'buffer_page_written_index_leaf'; DROP TABLE t1; From b067df321363b759e5766cea8417c66469442d1d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 28 Mar 2024 16:09:15 +0100 Subject: [PATCH 056/313] innodb.innodb_defrag_stats wait for the correct value failed on amd64-centos-stream8 --- mysql-test/suite/innodb/t/innodb_defrag_stats.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/t/innodb_defrag_stats.test b/mysql-test/suite/innodb/t/innodb_defrag_stats.test index 799faa93ff0..189809b82e4 100644 --- a/mysql-test/suite/innodb/t/innodb_defrag_stats.test +++ b/mysql-test/suite/innodb/t/innodb_defrag_stats.test @@ -35,7 +35,7 @@ SELECT @@GLOBAL.innodb_force_recovery<2 "have background defragmentation"; # Wait for defrag_pool to be processed. let $wait_timeout=30; -let $wait_condition = SELECT COUNT(*)>0 FROM mysql.innodb_index_stats; +let $wait_condition = SELECT COUNT(*)>5 FROM mysql.innodb_index_stats; --source include/wait_condition.inc --sorted_result From bd0e7515494a57ca83e437bd7d6578847eb36e1d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 20:45:36 +0100 Subject: [PATCH 057/313] rpl.rpl_domain_id_filter_master_crash failed on msan builder it seems that the test can get IO thread running or not, there's a comment about it. Thus stop_slave_io.inc is told to ignore errors. Make stop_slave_io.inc also disable warnings in this case, in particular "1255 Slave already has been stopped" --- mysql-test/include/stop_slave_io.inc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mysql-test/include/stop_slave_io.inc b/mysql-test/include/stop_slave_io.inc index ddc83782311..a9d97f2f8a1 100644 --- a/mysql-test/include/stop_slave_io.inc +++ b/mysql-test/include/stop_slave_io.inc @@ -34,8 +34,17 @@ if (!$rpl_debug) --disable_query_log } - +let $_enable_warnings=0; +if ($rpl_allow_error) { + if ($ENABLED_WARNINGS) { + let $_enable_warnings=1; + disable_warnings; + } +} STOP SLAVE IO_THREAD; +if ($_enable_warnings) { + enable_warnings; +} --source include/wait_for_slave_io_to_stop.inc From fc6711c636a8407ab99d06763f731b6bea7ccb71 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 27 Mar 2024 22:30:29 +0100 Subject: [PATCH 058/313] mtr: increase timeouts under ASAN/UBSAN/MSAN not only under valgrind --- mysql-test/include/shutdown_mysqld.inc | 7 ++----- mysql-test/include/slow_environ.inc | 9 +++++++++ mysql-test/include/sync_slave_sql_with_io.inc | 7 ++----- mysql-test/include/sync_with_master_gtid.inc | 7 ++----- mysql-test/include/wait_for_slave_param.inc | 7 ++----- 5 files changed, 17 insertions(+), 20 deletions(-) create mode 100644 mysql-test/include/slow_environ.inc diff --git a/mysql-test/include/shutdown_mysqld.inc b/mysql-test/include/shutdown_mysqld.inc index fc2972560c3..2db4624e4ac 100644 --- a/mysql-test/include/shutdown_mysqld.inc +++ b/mysql-test/include/shutdown_mysqld.inc @@ -31,11 +31,8 @@ if ($rpl_inited) set @@global.log_warnings=0; --enable_query_log ---let $server_shutdown_timeout= 60 -if ($VALGRIND_TEST) -{ - --let $server_shutdown_timeout= 300 -} +--source include/slow_environ.inc +--let $server_shutdown_timeout= 60$_timeout_adjustment if ($shutdown_timeout) { diff --git a/mysql-test/include/slow_environ.inc b/mysql-test/include/slow_environ.inc new file mode 100644 index 00000000000..761147fd288 --- /dev/null +++ b/mysql-test/include/slow_environ.inc @@ -0,0 +1,9 @@ +if (!$slow_environ_check) +{ + let $_timeout_adjustment=; + if (`select $VALGRIND_TEST + count(*) from information_schema.system_variables where variable_name='have_sanitizer' and global_value like '%SAN%'`) + { + let $_timeout_adjustment=0; + } + let $slow_environ_check=1; +} diff --git a/mysql-test/include/sync_slave_sql_with_io.inc b/mysql-test/include/sync_slave_sql_with_io.inc index 9efede9a61f..c16d28edbb9 100644 --- a/mysql-test/include/sync_slave_sql_with_io.inc +++ b/mysql-test/include/sync_slave_sql_with_io.inc @@ -25,11 +25,8 @@ let $_slave_timeout= $slave_timeout; if (!$_slave_timeout) { - let $_slave_timeout= 300; - if ($VALGRIND_TEST) - { - let $_slave_timeout= 1500; - } + source include/slow_environ.inc; + let $_slave_timeout= 300$_timeout_adjustment; } --let $_master_log_file= query_get_value(SHOW SLAVE STATUS, Master_Log_File, 1) diff --git a/mysql-test/include/sync_with_master_gtid.inc b/mysql-test/include/sync_with_master_gtid.inc index 777711b979c..0ca2c90784e 100644 --- a/mysql-test/include/sync_with_master_gtid.inc +++ b/mysql-test/include/sync_with_master_gtid.inc @@ -33,11 +33,8 @@ let $_slave_timeout= $slave_timeout; if (!$_slave_timeout) { - let $_slave_timeout= 120; - if ($VALGRIND_TEST) - { - let $_slave_timeout= 1200; - } + source include/slow_environ.inc; + let $_slave_timeout= 120$_timeout_adjustment; } --let $_result= `SELECT master_gtid_wait('$master_pos', $_slave_timeout)` diff --git a/mysql-test/include/wait_for_slave_param.inc b/mysql-test/include/wait_for_slave_param.inc index ed81c55963f..6802cd41203 100644 --- a/mysql-test/include/wait_for_slave_param.inc +++ b/mysql-test/include/wait_for_slave_param.inc @@ -49,11 +49,8 @@ let $_slave_timeout= $slave_timeout; if (!$_slave_timeout) { - let $_slave_timeout= 300; - if ($VALGRIND_TEST) - { - let $_slave_timeout= 1500; - } + source include/slow_environ.inc; + let $_slave_timeout= 300$_timeout_adjustment; } let $_slave_param_comparison= $slave_param_comparison; From 53af3d8c255c62278c6b312b67edabf486d3ccd0 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 29 Feb 2024 16:51:17 +0200 Subject: [PATCH 059/313] Fixed memory leaks in embedded server and mysqltest This commit fixes the following issues: - memory leak checking enabled for mysqltest. This cover all cases except calls to 'die()' that only happens in case of internal failures in mysqltest. die() is not called anymore in the result files differs. - One can now run mtr --embedded without failures (this crashed or hang before) - cleanup_and_exit() has a new parameter that indicates that it is called from die(), in which case we should not do memory leak checks. We now always call cleanup_and_exit() instead of exit() to be able to free up memory and discover memory leaks. - Lots of new assert to catch error conditions - More DBUG statements. - Fixed that all results are freed in mysqltest (Fixed a memory leak in mysqltest when using prepared statements). - Fixed race condition in do_stmt_close() that caused embedded server to not free memory. (Memory leak in mysqltest with embedded server). - Fixed two memory leaks in embedded server when using prepared statements. These memory leaks caused timeout hangs in mtr when server was compiled with safemalloc. This issue was not noticed (except as timeouts) as memory report checking was done but output of it was disabled. --- client/mysqltest.cc | 133 ++++++++++++++++++++++++++----------------- libmysqld/lib_sql.cc | 2 + 2 files changed, 82 insertions(+), 53 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index f1ddea7c083..7267cd6e036 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -616,7 +616,7 @@ void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds, const char *from); ATTRIBUTE_NORETURN -static void cleanup_and_exit(int exit_code); +static void cleanup_and_exit(int exit_code, bool called_from_die); ATTRIBUTE_NORETURN static void really_die(const char *msg); @@ -933,6 +933,7 @@ pthread_attr_t cn_thd_attrib; pthread_handler_t connection_thread(void *arg) { struct st_connection *cn= (struct st_connection*)arg; + DBUG_ENTER("connection_thread"); mysql_thread_init(); while (cn->command != EMB_END_CONNECTION) @@ -944,6 +945,7 @@ pthread_handler_t connection_thread(void *arg) pthread_cond_wait(&cn->query_cond, &cn->query_mutex); pthread_mutex_unlock(&cn->query_mutex); } + DBUG_PRINT("info", ("executing command: %d", cn->command)); switch (cn->command) { case EMB_END_CONNECTION: @@ -964,24 +966,26 @@ pthread_handler_t connection_thread(void *arg) break; case EMB_CLOSE_STMT: cn->result= mysql_stmt_close(cn->stmt); + cn->stmt= 0; break; default: DBUG_ASSERT(0); } - cn->command= 0; pthread_mutex_lock(&cn->result_mutex); cn->query_done= 1; + cn->command= 0; pthread_cond_signal(&cn->result_cond); pthread_mutex_unlock(&cn->result_mutex); } end_thread: - cn->query_done= 1; + DBUG_ASSERT(cn->stmt == 0); mysql_close(cn->mysql); cn->mysql= 0; + cn->query_done= 1; mysql_thread_end(); pthread_exit(0); - return 0; + DBUG_RETURN(0); } static void wait_query_thread_done(struct st_connection *con) @@ -999,12 +1003,16 @@ static void wait_query_thread_done(struct st_connection *con) static void signal_connection_thd(struct st_connection *cn, int command) { + DBUG_ENTER("signal_connection_thd"); + DBUG_PRINT("enter", ("command: %d", command)); + DBUG_ASSERT(cn->has_thread); cn->query_done= 0; - cn->command= command; pthread_mutex_lock(&cn->query_mutex); + cn->command= command; pthread_cond_signal(&cn->query_cond); pthread_mutex_unlock(&cn->query_mutex); + DBUG_VOID_RETURN; } @@ -1066,27 +1074,38 @@ static int do_stmt_execute(struct st_connection *cn) static int do_stmt_close(struct st_connection *cn) { - /* The cn->stmt is already set. */ + DBUG_ENTER("do_stmt_close"); if (!cn->has_thread) - return mysql_stmt_close(cn->stmt); + { + /* The cn->stmt is already set. */ + int res= mysql_stmt_close(cn->stmt); + cn->stmt= 0; + DBUG_RETURN(res); + } + wait_query_thread_done(cn); signal_connection_thd(cn, EMB_CLOSE_STMT); wait_query_thread_done(cn); - return cn->result; + DBUG_ASSERT(cn->stmt == 0); + DBUG_RETURN(cn->result); } static void emb_close_connection(struct st_connection *cn) { + DBUG_ENTER("emb_close_connection"); if (!cn->has_thread) - return; + DBUG_VOID_RETURN; wait_query_thread_done(cn); signal_connection_thd(cn, EMB_END_CONNECTION); pthread_join(cn->tid, NULL); cn->has_thread= FALSE; + DBUG_ASSERT(cn->mysql == 0); + DBUG_ASSERT(cn->stmt == 0); pthread_mutex_destroy(&cn->query_mutex); pthread_cond_destroy(&cn->query_cond); pthread_mutex_destroy(&cn->result_mutex); pthread_cond_destroy(&cn->result_cond); + DBUG_VOID_RETURN; } @@ -1110,7 +1129,13 @@ static void init_connection_thd(struct st_connection *cn) #define do_read_query_result(cn) mysql_read_query_result(cn->mysql) #define do_stmt_prepare(cn, q, q_len) mysql_stmt_prepare(cn->stmt, q, (ulong)q_len) #define do_stmt_execute(cn) mysql_stmt_execute(cn->stmt) -#define do_stmt_close(cn) mysql_stmt_close(cn->stmt) + +static int do_stmt_close(struct st_connection *cn) +{ + int res= mysql_stmt_close(cn->stmt); + cn->stmt= 0; + return res; +} #endif /*EMBEDDED_LIBRARY*/ @@ -1438,7 +1463,6 @@ void close_statements() { if (con->stmt) do_stmt_close(con); - con->stmt= 0; } DBUG_VOID_RETURN; } @@ -1505,7 +1529,8 @@ void free_used_memory() } -ATTRIBUTE_NORETURN static void cleanup_and_exit(int exit_code) +ATTRIBUTE_NORETURN static void cleanup_and_exit(int exit_code, + bool called_from_die) { free_used_memory(); @@ -1513,16 +1538,6 @@ ATTRIBUTE_NORETURN static void cleanup_and_exit(int exit_code) if (server_initialized) mysql_server_end(); - /* - mysqltest is fundamentally written in a way that makes impossible - to free all memory before exit (consider memory allocated - for frame local DYNAMIC_STRING's and die() invoked down the stack. - - We close stderr here to stop unavoidable safemalloc reports - from polluting the output. - */ - fclose(stderr); - my_end(my_end_arg); if (!silent) { @@ -1542,6 +1557,11 @@ ATTRIBUTE_NORETURN static void cleanup_and_exit(int exit_code) } } + /* + Report memory leaks, if not called from 'die()', as die() will not release + all memory. + */ + sf_leaking_memory= called_from_die; exit(exit_code); } @@ -1608,7 +1628,7 @@ static void really_die(const char *msg) second time, just exit */ if (dying) - cleanup_and_exit(1); + cleanup_and_exit(1, 1); dying= 1; log_file.show_tail(opt_tail_lines); @@ -1620,7 +1640,7 @@ static void really_die(const char *msg) if (cur_con && !cur_con->pending) show_warnings_before_error(cur_con->mysql); - cleanup_and_exit(1); + cleanup_and_exit(1, 1); } void report_or_die(const char *fmt, ...) @@ -1674,7 +1694,7 @@ void abort_not_supported_test(const char *fmt, ...) } va_end(args); - cleanup_and_exit(62); + cleanup_and_exit(62, 0); } @@ -2220,14 +2240,14 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) check_result RETURN VALUES - error - the function will not return - + 0 ok + 1 error */ -void check_result() +int check_result() { const char *mess= 0; - + int error= 1; DBUG_ENTER("check_result"); DBUG_ASSERT(result_file_name); DBUG_PRINT("enter", ("result_file_name: %s", result_file_name)); @@ -2235,7 +2255,10 @@ void check_result() switch (compare_files(log_file.file_name(), result_file_name)) { case RESULT_OK: if (!error_count) + { + error= 0; break; /* ok */ + } mess= "Got errors while running test"; /* Fallthrough */ case RESULT_LENGTH_MISMATCH: @@ -2274,14 +2297,13 @@ void check_result() log_file.file_name(), reject_file, errno); show_diff(NULL, result_file_name, reject_file); - die("%s", mess); + fprintf(stderr, "%s", mess); break; } default: /* impossible */ die("Unknown error code from dyn_string_cmp()"); } - - DBUG_VOID_RETURN; + DBUG_RETURN(error); } @@ -5631,7 +5653,6 @@ void do_close_connection(struct st_command *command) #endif /*!EMBEDDED_LIBRARY*/ if (con->stmt) do_stmt_close(con); - con->stmt= 0; #ifdef EMBEDDED_LIBRARY /* As query could be still executed in a separate thread @@ -7308,17 +7329,17 @@ get_one_option(const struct my_option *opt, const char *argument, const char *) break; case 'V': print_version(); - exit(0); + cleanup_and_exit(0,0); case OPT_MYSQL_PROTOCOL: #ifndef EMBEDDED_LIBRARY if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, opt->name)) <= 0) - exit(1); + cleanup_and_exit(1,0); #endif break; case '?': usage(); - exit(0); + cleanup_and_exit(0,0); } return 0; } @@ -7330,12 +7351,12 @@ int parse_args(int argc, char **argv) default_argv= argv; if ((handle_options(&argc, &argv, my_long_options, get_one_option))) - exit(1); + cleanup_and_exit(1, 0); if (argc > 1) { usage(); - exit(1); + cleanup_and_exit(1, 0); } if (argc == 1) opt_db= *argv; @@ -8445,7 +8466,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, my_bool ds_res_1st_execution_init = FALSE; my_bool compare_2nd_execution = TRUE; int query_match_ps2_re; - + MYSQL_RES *res; DBUG_ENTER("run_query_stmt"); DBUG_PRINT("query", ("'%-.60s'", query)); @@ -8631,10 +8652,13 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, The --enable_prepare_warnings command can be used to change this so that warnings from both the prepare and execute phase are shown. */ - if ((mysql_stmt_result_metadata(stmt) != NULL) && - !disable_warnings && - !prepare_warnings_enabled) - dynstr_set(&ds_prepare_warnings, NULL); + if ((res= mysql_stmt_result_metadata(stmt))) + { + if (!disable_warnings && + !prepare_warnings_enabled) + dynstr_set(&ds_prepare_warnings, NULL); + mysql_free_result(res); + } /* Fetch info before fetching warnings, since it will be reset @@ -9729,6 +9753,7 @@ static sig_handler signal_handler(int sig) fflush(stderr); my_write_core(sig); #ifndef _WIN32 + sf_leaking_memory= 1; exit(1); // Shouldn't get here but just in case #endif } @@ -9802,12 +9827,10 @@ int main(int argc, char **argv) uint command_executed= 0, last_command_executed= 0; char save_file[FN_REFLEN]; bool empty_result= FALSE; + int error= 0; MY_INIT(argv[0]); DBUG_ENTER("main"); - /* mysqltest has no way to free all its memory correctly */ - sf_leaking_memory= 1; - save_file[0]= 0; TMPDIR[0]= 0; @@ -10486,7 +10509,7 @@ int main(int argc, char **argv) die("Test ended with parsing disabled"); /* - The whole test has been executed _successfully_. + The whole test has been executed successfully. Time to compare result or save it to record file. The entire output from test is in the log file */ @@ -10509,7 +10532,7 @@ int main(int argc, char **argv) else { /* Check that the output from test is equal to result file */ - check_result(); + error= check_result(); } } } @@ -10519,7 +10542,8 @@ int main(int argc, char **argv) if (! result_file_name || record || compare_files (log_file.file_name(), result_file_name)) { - die("The test didn't produce any output"); + fprintf(stderr, "mysqltest: The test didn't produce any output\n"); + error= 1; } else { @@ -10528,12 +10552,15 @@ int main(int argc, char **argv) } if (!command_executed && result_file_name && !empty_result) - die("No queries executed but non-empty result file found!"); + { + fprintf(stderr, "mysqltest: No queries executed but non-empty result file found!\n"); + error= 1; + } - verbose_msg("Test has succeeded!"); + if (!error) + verbose_msg("Test has succeeded!"); timer_output(); - /* Yes, if we got this far the test has succeeded! Sakila smiles */ - cleanup_and_exit(0); + cleanup_and_exit(error, 0); return 0; /* Keep compiler happy too */ } diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 41eee607d23..377d1d7a573 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -266,6 +266,7 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) mysql->server_status|= SERVER_STATUS_IN_TRANS; stmt->fields= mysql->fields; + free_root(&stmt->mem_root, MYF(0)); stmt->mem_root= res->alloc; mysql->fields= NULL; my_free(res); @@ -375,6 +376,7 @@ int emb_read_binary_rows(MYSQL_STMT *stmt) set_stmt_errmsg(stmt, &stmt->mysql->net); return 1; } + free_root(&stmt->result.alloc, MYF(0)); stmt->result= *data; my_free(data); set_stmt_errmsg(stmt, &stmt->mysql->net); From 190280205b83be33aeb2bc3b637ad5919896f611 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 28 Mar 2024 21:31:24 +0100 Subject: [PATCH 060/313] perfschema is disabled until it's enabled as it was thinking it was enabled even if initialize_performance_schema wasn't called at all --- storage/perfschema/pfs_instr_class.cc | 2 +- storage/perfschema/unittest/pfs_instr_class-t.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc index 2b1a80d3e11..fa85d8610bf 100644 --- a/storage/perfschema/pfs_instr_class.cc +++ b/storage/perfschema/pfs_instr_class.cc @@ -55,7 +55,7 @@ Indicate if the performance schema is enabled. This flag is set at startup, and never changes. */ -my_bool pfs_enabled= TRUE; +my_bool pfs_enabled= FALSE; /** PFS_INSTRUMENT option settings array diff --git a/storage/perfschema/unittest/pfs_instr_class-t.cc b/storage/perfschema/unittest/pfs_instr_class-t.cc index 7651898d684..76e3668d378 100644 --- a/storage/perfschema/unittest/pfs_instr_class-t.cc +++ b/storage/perfschema/unittest/pfs_instr_class-t.cc @@ -743,6 +743,7 @@ void do_all_tests() int main(int argc, char **argv) { plan(209); + pfs_enabled= 1; MY_INIT(argv[0]); do_all_tests(); my_end(0); From cb41757f0254d715464bce55ce45e3dfe56fd685 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 29 Mar 2024 08:39:42 +0100 Subject: [PATCH 061/313] cleanup: perfschema.threads_history improve debuggability --- .../suite/perfschema/r/threads_history.result | 404 +++++++++++--- .../suite/perfschema/t/threads_history.test | 494 ++++++++---------- 2 files changed, 554 insertions(+), 344 deletions(-) diff --git a/mysql-test/suite/perfschema/r/threads_history.result b/mysql-test/suite/perfschema/r/threads_history.result index aaf2cd09e31..9d361ac24e2 100644 --- a/mysql-test/suite/perfschema/r/threads_history.result +++ b/mysql-test/suite/perfschema/r/threads_history.result @@ -24,27 +24,22 @@ events_waits_history_long YES global_instrumentation YES thread_instrumentation YES statements_digest YES -# Switch to (con1, localhost, user1, , ) connect con1, localhost, user1, , ; update performance_schema.threads set INSTRUMENTED='YES', HISTORY='YES' where PROCESSLIST_ID = connection_id(); -# Switch to (con2, localhost, user2, , ) connect con2, localhost, user2, , ; update performance_schema.threads set INSTRUMENTED='YES', HISTORY='NO' where PROCESSLIST_ID = connection_id(); -# Switch to (con3, localhost, user3, , ) connect con3, localhost, user3, , ; update performance_schema.threads set INSTRUMENTED='NO', HISTORY='YES' where PROCESSLIST_ID = connection_id(); -# Switch to (con4, localhost, user4, , ) connect con4, localhost, user4, , ; update performance_schema.threads set INSTRUMENTED='NO', HISTORY='NO' where PROCESSLIST_ID = connection_id(); -# Switch to connection default connection default; truncate table performance_schema.events_transactions_current; truncate table performance_schema.events_transactions_history; @@ -58,7 +53,6 @@ truncate table performance_schema.events_stages_history_long; truncate table performance_schema.events_waits_current; truncate table performance_schema.events_waits_history; truncate table performance_schema.events_waits_history_long; -# Switch to connection con1 connection con1; XA START 'XA_CON1', 'XA_BQUAL', 12; select "Hi from con1"; @@ -67,7 +61,6 @@ Hi from con1 XA END 'XA_CON1', 'XA_BQUAL', 12; XA PREPARE 'XA_CON1', 'XA_BQUAL', 12; XA COMMIT 'XA_CON1', 'XA_BQUAL', 12; -# Switch to connection con2 connection con2; XA START 'XA_CON2', 'XA_BQUAL', 12; select "Hi from con2"; @@ -76,7 +69,6 @@ Hi from con2 XA END 'XA_CON2', 'XA_BQUAL', 12; XA PREPARE 'XA_CON2', 'XA_BQUAL', 12; XA COMMIT 'XA_CON2', 'XA_BQUAL', 12; -# Switch to connection con3 connection con3; XA START 'XA_CON3', 'XA_BQUAL', 12; select "Hi from con3"; @@ -85,7 +77,6 @@ Hi from con3 XA END 'XA_CON3', 'XA_BQUAL', 12; XA PREPARE 'XA_CON3', 'XA_BQUAL', 12; XA COMMIT 'XA_CON3', 'XA_BQUAL', 12; -# Switch to connection con4 connection con4; XA START 'XA_CON4', 'XA_BQUAL', 12; select "Hi from con4"; @@ -95,72 +86,124 @@ XA END 'XA_CON4', 'XA_BQUAL', 12; XA PREPARE 'XA_CON4', 'XA_BQUAL', 12; XA COMMIT 'XA_CON4', 'XA_BQUAL', 12; connection default; -"=========================== Transactions user 1" +########################### Transactions user 1 - 1 +select /*1-1*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +where THREAD_ID = $con1_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON1 XA_BQUAL +select /*1-1*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history +where THREAD_ID = $con1_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON1 XA_BQUAL +select /*1-1*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long +where THREAD_ID = $con1_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON1 XA_BQUAL -"=========================== Transactions user 2" +########################### Transactions user 2 - 1 +select /*2-1*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +where THREAD_ID = $con2_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON2 XA_BQUAL +select /*2-1*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-1*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Transactions user 3" +########################### Transactions user 3 - 1 +select /*3-1*/ count(*) from performance_schema.events_transactions_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-1*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-1*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Transactions user 4" +########################### Transactions user 4 - 1 +select /*4-1*/ count(*) from performance_schema.events_transactions_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-1*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-1*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Statements user 1" +########################### Statements user 1 - 1 +select /*1-1*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_commit XA COMMIT 'XA_CON1', 'XA_BQUAL', 12 +select /*1-1*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_start XA START 'XA_CON1', 'XA_BQUAL', 12 statement/sql/select select "Hi from con1" statement/sql/xa_end XA END 'XA_CON1', 'XA_BQUAL', 12 statement/sql/xa_prepare XA PREPARE 'XA_CON1', 'XA_BQUAL', 12 statement/sql/xa_commit XA COMMIT 'XA_CON1', 'XA_BQUAL', 12 +select /*1-1*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_start XA START 'XA_CON1', 'XA_BQUAL', 12 statement/sql/select select "Hi from con1" statement/sql/xa_end XA END 'XA_CON1', 'XA_BQUAL', 12 statement/sql/xa_prepare XA PREPARE 'XA_CON1', 'XA_BQUAL', 12 statement/sql/xa_commit XA COMMIT 'XA_CON1', 'XA_BQUAL', 12 -"=========================== Statements user 2" +########################### Statements user 2 - 1 +select /*2-1*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_commit XA COMMIT 'XA_CON2', 'XA_BQUAL', 12 +select /*2-1*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-1*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Statements user 3" +########################### Statements user 3 - 1 +select /*3-1*/ count(*) from performance_schema.events_statements_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-1*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-1*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Statements user 4" +########################### Statements user 4 - 1 +select /*4-1*/ count(*) from performance_schema.events_statements_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-1*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-1*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Stages user 1" +########################### Stages user 1 - 1 +select /*1-1*/ EVENT_NAME from performance_schema.events_stages_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME +select /*1-1*/ EVENT_NAME from performance_schema.events_stages_history +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME stage/sql/Starting cleanup stage/sql/Freeing items @@ -172,6 +215,8 @@ stage/sql/closing tables stage/sql/Starting cleanup stage/sql/Freeing items stage/sql/Reset for next command +select /*1-1*/ EVENT_NAME from performance_schema.events_stages_history_long +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME stage/sql/starting stage/sql/Query end @@ -215,55 +260,96 @@ stage/sql/closing tables stage/sql/Starting cleanup stage/sql/Freeing items stage/sql/Reset for next command -"=========================== Stages user 2" +########################### Stages user 2 - 1 +select /*2-1*/ EVENT_NAME from performance_schema.events_stages_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME +select /*2-1*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-1*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Stages user 3" +########################### Stages user 3 - 1 +select /*3-1*/ count(*) from performance_schema.events_stages_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-1*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-1*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Stages user 4" +########################### Stages user 4 - 1 +select /*4-1*/ count(*) from performance_schema.events_stages_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-1*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-1*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Waits user 1" +########################### Waits user 1 - 1 +select /*1-1*/ EVENT_NAME from performance_schema.events_waits_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME idle +select /*1-1*/ (count(*) > 5) as has_waits from performance_schema.events_waits_history +where THREAD_ID = $con1_thread_id; has_waits 1 +select /*1-1*/ (count(*) > 15) as has_waits from performance_schema.events_waits_history_long +where THREAD_ID = $con1_thread_id; has_waits 1 -"=========================== Waits user 2" +########################### Waits user 2 - 1 +select /*2-1*/ EVENT_NAME from performance_schema.events_waits_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME idle +select /*2-1*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-1*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Waits user 3" +########################### Waits user 3 - 1 +select /*3-1*/ count(*) from performance_schema.events_waits_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-1*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-1*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Waits user 4" +########################### Waits user 4 - 1 +select /*4-1*/ count(*) from performance_schema.events_waits_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-1*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-1*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -# Switch to connection default, disable consumers connection default; update performance_schema.setup_consumers set enabled='NO' where name like "%history%"; @@ -296,7 +382,6 @@ truncate table performance_schema.events_stages_history_long; truncate table performance_schema.events_waits_current; truncate table performance_schema.events_waits_history; truncate table performance_schema.events_waits_history_long; -# Switch to connection con1 connection con1; XA START 'XA_CON1', 'XA_BQUAL', 12; select "Hi from con1"; @@ -305,7 +390,6 @@ Hi from con1 XA END 'XA_CON1', 'XA_BQUAL', 12; XA PREPARE 'XA_CON1', 'XA_BQUAL', 12; XA COMMIT 'XA_CON1', 'XA_BQUAL', 12; -# Switch to connection con2 connection con2; XA START 'XA_CON2', 'XA_BQUAL', 12; select "Hi from con2"; @@ -314,7 +398,6 @@ Hi from con2 XA END 'XA_CON2', 'XA_BQUAL', 12; XA PREPARE 'XA_CON2', 'XA_BQUAL', 12; XA COMMIT 'XA_CON2', 'XA_BQUAL', 12; -# Switch to connection con3 connection con3; XA START 'XA_CON3', 'XA_BQUAL', 12; select "Hi from con3"; @@ -323,7 +406,6 @@ Hi from con3 XA END 'XA_CON3', 'XA_BQUAL', 12; XA PREPARE 'XA_CON3', 'XA_BQUAL', 12; XA COMMIT 'XA_CON3', 'XA_BQUAL', 12; -# Switch to connection con4 connection con4; XA START 'XA_CON4', 'XA_BQUAL', 12; select "Hi from con4"; @@ -333,117 +415,212 @@ XA END 'XA_CON4', 'XA_BQUAL', 12; XA PREPARE 'XA_CON4', 'XA_BQUAL', 12; XA COMMIT 'XA_CON4', 'XA_BQUAL', 12; connection default; -"=========================== Transactions user 1" +########################### Transactions user 1 - 2 +select /*1-2*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +where THREAD_ID = $con1_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON1 XA_BQUAL +select /*1-2*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con1_thread_id; count(*) 0 +select /*1-2*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con1_thread_id; count(*) 0 -"=========================== Transactions user 2" +########################### Transactions user 2 - 2 +select /*2-2*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +where THREAD_ID = $con2_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON2 XA_BQUAL +select /*2-2*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-2*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Transactions user 3" +########################### Transactions user 3 - 2 +select /*3-2*/ count(*) from performance_schema.events_transactions_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-2*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-2*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Transactions user 4" +########################### Transactions user 4 - 2 +select /*4-2*/ count(*) from performance_schema.events_transactions_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-2*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-2*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Statements user 1" +########################### Statements user 1 - 2 +select /*1-2*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_commit XA COMMIT 'XA_CON1', 'XA_BQUAL', 12 +select /*1-2*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con1_thread_id; count(*) 0 +select /*1-2*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con1_thread_id; count(*) 0 -"=========================== Statements user 2" +########################### Statements user 2 - 2 +select /*2-2*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_commit XA COMMIT 'XA_CON2', 'XA_BQUAL', 12 +select /*2-2*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-2*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Statements user 3" +########################### Statements user 3 - 2 +select /*3-2*/ count(*) from performance_schema.events_statements_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-2*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-2*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Statements user 4" +########################### Statements user 4 - 2 +select /*4-2*/ count(*) from performance_schema.events_statements_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-2*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-2*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Stages user 1" +########################### Stages user 1 - 2 +select /*1-2*/ EVENT_NAME from performance_schema.events_stages_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME +select /*1-2*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con1_thread_id; count(*) 0 +select /*1-2*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con1_thread_id; count(*) 0 -"=========================== Stages user 2" +########################### Stages user 2 - 2 +select /*2-2*/ EVENT_NAME from performance_schema.events_stages_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME +select /*2-2*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-2*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Stages user 3" +########################### Stages user 3 - 2 +select /*3-2*/ count(*) from performance_schema.events_stages_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-2*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-2*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Stages user 4" +########################### Stages user 4 - 2 +select /*4-2*/ count(*) from performance_schema.events_stages_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-2*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-2*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Waits user 1" +########################### Waits user 1 - 2 +select /*1-2*/ EVENT_NAME from performance_schema.events_waits_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME idle +select /*1-2*/ count(*) as has_waits from performance_schema.events_waits_history +where THREAD_ID = $con1_thread_id; has_waits 0 +select /*1-2*/ count(*) as has_waits from performance_schema.events_waits_history_long +where THREAD_ID = $con1_thread_id; has_waits 0 -"=========================== Waits user 2" +########################### Waits user 2 - 2 +select /*2-2*/ EVENT_NAME from performance_schema.events_waits_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME idle +select /*2-2*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-2*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Waits user 3" +########################### Waits user 3 - 2 +select /*3-2*/ count(*) from performance_schema.events_waits_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-2*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-2*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Waits user 4" +########################### Waits user 4 - 2 +select /*4-2*/ count(*) from performance_schema.events_waits_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-2*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-2*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -# Switch to connection default, enable consumers connection default; update performance_schema.setup_consumers set enabled='YES' where name like "%history%"; @@ -476,7 +653,6 @@ truncate table performance_schema.events_stages_history_long; truncate table performance_schema.events_waits_current; truncate table performance_schema.events_waits_history; truncate table performance_schema.events_waits_history_long; -# Switch to connection con1 connection con1; XA START 'XA_CON1', 'XA_BQUAL', 12; select "Hi from con1"; @@ -485,7 +661,6 @@ Hi from con1 XA END 'XA_CON1', 'XA_BQUAL', 12; XA PREPARE 'XA_CON1', 'XA_BQUAL', 12; XA COMMIT 'XA_CON1', 'XA_BQUAL', 12; -# Switch to connection con2 connection con2; XA START 'XA_CON2', 'XA_BQUAL', 12; select "Hi from con2"; @@ -494,7 +669,6 @@ Hi from con2 XA END 'XA_CON2', 'XA_BQUAL', 12; XA PREPARE 'XA_CON2', 'XA_BQUAL', 12; XA COMMIT 'XA_CON2', 'XA_BQUAL', 12; -# Switch to connection con3 connection con3; XA START 'XA_CON3', 'XA_BQUAL', 12; select "Hi from con3"; @@ -503,7 +677,6 @@ Hi from con3 XA END 'XA_CON3', 'XA_BQUAL', 12; XA PREPARE 'XA_CON3', 'XA_BQUAL', 12; XA COMMIT 'XA_CON3', 'XA_BQUAL', 12; -# Switch to connection con4 connection con4; XA START 'XA_CON4', 'XA_BQUAL', 12; select "Hi from con4"; @@ -513,72 +686,124 @@ XA END 'XA_CON4', 'XA_BQUAL', 12; XA PREPARE 'XA_CON4', 'XA_BQUAL', 12; XA COMMIT 'XA_CON4', 'XA_BQUAL', 12; connection default; -"=========================== Transactions user 1" +########################### Transactions user 1 - 3 +select /*1-3*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +where THREAD_ID = $con1_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON1 XA_BQUAL +select /*1-3*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history +where THREAD_ID = $con1_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON1 XA_BQUAL +select /*1-3*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long +where THREAD_ID = $con1_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON1 XA_BQUAL -"=========================== Transactions user 2" +########################### Transactions user 2 - 3 +select /*2-3*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +where THREAD_ID = $con2_thread_id; XID_FORMAT_ID XID_GTRID XID_BQUAL 12 XA_CON2 XA_BQUAL +select /*2-3*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-3*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Transactions user 3" +########################### Transactions user 3 - 3 +select /*3-3*/ count(*) from performance_schema.events_transactions_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-3*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-3*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Transactions user 4" +########################### Transactions user 4 - 3 +select /*4-3*/ count(*) from performance_schema.events_transactions_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-3*/ count(*) from performance_schema.events_transactions_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-3*/ count(*) from performance_schema.events_transactions_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Statements user 1" +########################### Statements user 1 - 3 +select /*1-3*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_commit XA COMMIT 'XA_CON1', 'XA_BQUAL', 12 +select /*1-3*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_start XA START 'XA_CON1', 'XA_BQUAL', 12 statement/sql/select select "Hi from con1" statement/sql/xa_end XA END 'XA_CON1', 'XA_BQUAL', 12 statement/sql/xa_prepare XA PREPARE 'XA_CON1', 'XA_BQUAL', 12 statement/sql/xa_commit XA COMMIT 'XA_CON1', 'XA_BQUAL', 12 +select /*1-3*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_start XA START 'XA_CON1', 'XA_BQUAL', 12 statement/sql/select select "Hi from con1" statement/sql/xa_end XA END 'XA_CON1', 'XA_BQUAL', 12 statement/sql/xa_prepare XA PREPARE 'XA_CON1', 'XA_BQUAL', 12 statement/sql/xa_commit XA COMMIT 'XA_CON1', 'XA_BQUAL', 12 -"=========================== Statements user 2" +########################### Statements user 2 - 3 +select /*2-3*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME SQL_TEXT statement/sql/xa_commit XA COMMIT 'XA_CON2', 'XA_BQUAL', 12 +select /*2-3*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-3*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Statements user 3" +########################### Statements user 3 - 3 +select /*3-3*/ count(*) from performance_schema.events_statements_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-3*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-3*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Statements user 4" +########################### Statements user 4 - 3 +select /*4-3*/ count(*) from performance_schema.events_statements_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-3*/ count(*) from performance_schema.events_statements_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-3*/ count(*) from performance_schema.events_statements_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Stages user 1" +########################### Stages user 1 - 3 +select /*1-3*/ EVENT_NAME from performance_schema.events_stages_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME +select /*1-3*/ EVENT_NAME from performance_schema.events_stages_history +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME stage/sql/Starting cleanup stage/sql/Freeing items @@ -590,6 +815,8 @@ stage/sql/closing tables stage/sql/Starting cleanup stage/sql/Freeing items stage/sql/Reset for next command +select /*1-3*/ EVENT_NAME from performance_schema.events_stages_history_long +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME stage/sql/starting stage/sql/Query end @@ -633,55 +860,96 @@ stage/sql/closing tables stage/sql/Starting cleanup stage/sql/Freeing items stage/sql/Reset for next command -"=========================== Stages user 2" +########################### Stages user 2 - 3 +select /*2-3*/ EVENT_NAME from performance_schema.events_stages_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME +select /*2-3*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-3*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Stages user 3" +########################### Stages user 3 - 3 +select /*3-3*/ count(*) from performance_schema.events_stages_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-3*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-3*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Stages user 4" +########################### Stages user 4 - 3 +select /*4-3*/ count(*) from performance_schema.events_stages_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-3*/ count(*) from performance_schema.events_stages_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-3*/ count(*) from performance_schema.events_stages_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -"=========================== Waits user 1" +########################### Waits user 1 - 3 +select /*1-3*/ EVENT_NAME from performance_schema.events_waits_current +where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME idle +select /*1-3*/ (count(*) > 5) as has_waits from performance_schema.events_waits_history +where THREAD_ID = $con1_thread_id; has_waits 1 +select /*1-3*/ (count(*) > 15) as has_waits from performance_schema.events_waits_history_long +where THREAD_ID = $con1_thread_id; has_waits 1 -"=========================== Waits user 2" +########################### Waits user 2 - 3 +select /*2-3*/ EVENT_NAME from performance_schema.events_waits_current +where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; EVENT_NAME idle +select /*2-3*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con2_thread_id; count(*) 0 +select /*2-3*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con2_thread_id; count(*) 0 -"=========================== Waits user 3" +########################### Waits user 3 - 3 +select /*3-3*/ count(*) from performance_schema.events_waits_current +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-3*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con3_thread_id; count(*) 0 +select /*3-3*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con3_thread_id; count(*) 0 -"=========================== Waits user 4" +########################### Waits user 4 - 3 +select /*4-3*/ count(*) from performance_schema.events_waits_current +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-3*/ count(*) from performance_schema.events_waits_history +where THREAD_ID = $con4_thread_id; count(*) 0 +select /*4-3*/ count(*) from performance_schema.events_waits_history_long +where THREAD_ID = $con4_thread_id; count(*) 0 -# Switch to connection default connection default; revoke all privileges, grant option from user1@localhost; revoke all privileges, grant option from user2@localhost; diff --git a/mysql-test/suite/perfschema/t/threads_history.test b/mysql-test/suite/perfschema/t/threads_history.test index f42dd6d0ab4..aee983339d2 100644 --- a/mysql-test/suite/perfschema/t/threads_history.test +++ b/mysql-test/suite/perfschema/t/threads_history.test @@ -23,7 +23,6 @@ flush privileges; select * from performance_schema.setup_consumers; ---echo # Switch to (con1, localhost, user1, , ) connect (con1, localhost, user1, , ); update performance_schema.threads @@ -33,7 +32,6 @@ update performance_schema.threads let $con1_thread_id= `select THREAD_ID from performance_schema.threads where PROCESSLIST_ID = connection_id()`; ---echo # Switch to (con2, localhost, user2, , ) connect (con2, localhost, user2, , ); update performance_schema.threads @@ -43,7 +41,6 @@ update performance_schema.threads let $con2_thread_id= `select THREAD_ID from performance_schema.threads where PROCESSLIST_ID = connection_id()`; ---echo # Switch to (con3, localhost, user3, , ) connect (con3, localhost, user3, , ); update performance_schema.threads @@ -53,7 +50,6 @@ update performance_schema.threads let $con3_thread_id= `select THREAD_ID from performance_schema.threads where PROCESSLIST_ID = connection_id()`; ---echo # Switch to (con4, localhost, user4, , ) connect (con4, localhost, user4, , ); update performance_schema.threads @@ -63,7 +59,6 @@ update performance_schema.threads let $con4_thread_id= `select THREAD_ID from performance_schema.threads where PROCESSLIST_ID = connection_id()`; ---echo # Switch to connection default --connection default truncate table performance_schema.events_transactions_current; @@ -79,7 +74,6 @@ truncate table performance_schema.events_waits_current; truncate table performance_schema.events_waits_history; truncate table performance_schema.events_waits_history_long; ---echo # Switch to connection con1 --connection con1 XA START 'XA_CON1', 'XA_BQUAL', 12; @@ -88,7 +82,6 @@ XA END 'XA_CON1', 'XA_BQUAL', 12; XA PREPARE 'XA_CON1', 'XA_BQUAL', 12; XA COMMIT 'XA_CON1', 'XA_BQUAL', 12; ---echo # Switch to connection con2 --connection con2 XA START 'XA_CON2', 'XA_BQUAL', 12; @@ -97,7 +90,6 @@ XA END 'XA_CON2', 'XA_BQUAL', 12; XA PREPARE 'XA_CON2', 'XA_BQUAL', 12; XA COMMIT 'XA_CON2', 'XA_BQUAL', 12; ---echo # Switch to connection con3 --connection con3 XA START 'XA_CON3', 'XA_BQUAL', 12; @@ -106,7 +98,6 @@ XA END 'XA_CON3', 'XA_BQUAL', 12; XA PREPARE 'XA_CON3', 'XA_BQUAL', 12; XA COMMIT 'XA_CON3', 'XA_BQUAL', 12; ---echo # Switch to connection con4 --connection con4 XA START 'XA_CON4', 'XA_BQUAL', 12; @@ -117,165 +108,150 @@ XA COMMIT 'XA_CON4', 'XA_BQUAL', 12; --connection default ---disable_query_log +echo ########################### Transactions user 1 - 1; -echo "=========================== Transactions user 1"; - -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +evalp select /*1-1*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current where THREAD_ID = $con1_thread_id; -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history +evalp select /*1-1*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history where THREAD_ID = $con1_thread_id; -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long +evalp select /*1-1*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long where THREAD_ID = $con1_thread_id; -echo "=========================== Transactions user 2"; +echo ########################### Transactions user 2 - 1; -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +evalp select /*2-1*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*2-1*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*2-1*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Transactions user 3"; +echo ########################### Transactions user 3 - 1; -eval select count(*) from performance_schema.events_transactions_current +evalp select /*3-1*/ count(*) from performance_schema.events_transactions_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*3-1*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*3-1*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Transactions user 4"; +echo ########################### Transactions user 4 - 1; -eval select count(*) from performance_schema.events_transactions_current +evalp select /*4-1*/ count(*) from performance_schema.events_transactions_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*4-1*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*4-1*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Statements user 1"; +echo ########################### Statements user 1 - 1; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; +evalp select /*1-1*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-1*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-1*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; -echo "=========================== Statements user 2"; +echo ########################### Statements user 2 - 1; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_statements_history +evalp select /*2-1*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-1*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*2-1*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Statements user 3"; +echo ########################### Statements user 3 - 1; -eval select count(*) from performance_schema.events_statements_current +evalp select /*3-1*/ count(*) from performance_schema.events_statements_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_statements_history +evalp select /*3-1*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*3-1*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Statements user 4"; +echo ########################### Statements user 4 - 1; -eval select count(*) from performance_schema.events_statements_current +evalp select /*4-1*/ count(*) from performance_schema.events_statements_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_statements_history +evalp select /*4-1*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*4-1*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Stages user 1"; +echo ########################### Stages user 1 - 1; -eval select EVENT_NAME from performance_schema.events_stages_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select EVENT_NAME from performance_schema.events_stages_history - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select EVENT_NAME from performance_schema.events_stages_history_long - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; +evalp select /*1-1*/ EVENT_NAME from performance_schema.events_stages_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-1*/ EVENT_NAME from performance_schema.events_stages_history + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-1*/ EVENT_NAME from performance_schema.events_stages_history_long + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; -echo "=========================== Stages user 2"; +echo ########################### Stages user 2 - 1; -eval select EVENT_NAME from performance_schema.events_stages_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_stages_history +evalp select /*2-1*/ EVENT_NAME from performance_schema.events_stages_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-1*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*2-1*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Stages user 3"; +echo ########################### Stages user 3 - 1; -eval select count(*) from performance_schema.events_stages_current +evalp select /*3-1*/ count(*) from performance_schema.events_stages_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_stages_history +evalp select /*3-1*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*3-1*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Stages user 4"; +echo ########################### Stages user 4 - 1; -eval select count(*) from performance_schema.events_stages_current +evalp select /*4-1*/ count(*) from performance_schema.events_stages_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_stages_history +evalp select /*4-1*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*4-1*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Waits user 1"; +echo ########################### Waits user 1 - 1; -eval select EVENT_NAME from performance_schema.events_waits_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select (count(*) > 5) as has_waits from performance_schema.events_waits_history +evalp select /*1-1*/ EVENT_NAME from performance_schema.events_waits_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-1*/ (count(*) > 5) as has_waits from performance_schema.events_waits_history where THREAD_ID = $con1_thread_id; -eval select (count(*) > 15) as has_waits from performance_schema.events_waits_history_long +evalp select /*1-1*/ (count(*) > 15) as has_waits from performance_schema.events_waits_history_long where THREAD_ID = $con1_thread_id; -echo "=========================== Waits user 2"; +echo ########################### Waits user 2 - 1; -eval select EVENT_NAME from performance_schema.events_waits_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_waits_history +evalp select /*2-1*/ EVENT_NAME from performance_schema.events_waits_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-1*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*2-1*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Waits user 3"; +echo ########################### Waits user 3 - 1; -eval select count(*) from performance_schema.events_waits_current +evalp select /*3-1*/ count(*) from performance_schema.events_waits_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_waits_history +evalp select /*3-1*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*3-1*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Waits user 4"; +echo ########################### Waits user 4 - 1; -eval select count(*) from performance_schema.events_waits_current +evalp select /*4-1*/ count(*) from performance_schema.events_waits_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_waits_history +evalp select /*4-1*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*4-1*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con4_thread_id; ---enable_query_log - ---echo # Switch to connection default, disable consumers --connection default update performance_schema.setup_consumers @@ -296,7 +272,6 @@ truncate table performance_schema.events_waits_current; truncate table performance_schema.events_waits_history; truncate table performance_schema.events_waits_history_long; ---echo # Switch to connection con1 --connection con1 XA START 'XA_CON1', 'XA_BQUAL', 12; @@ -305,7 +280,6 @@ XA END 'XA_CON1', 'XA_BQUAL', 12; XA PREPARE 'XA_CON1', 'XA_BQUAL', 12; XA COMMIT 'XA_CON1', 'XA_BQUAL', 12; ---echo # Switch to connection con2 --connection con2 XA START 'XA_CON2', 'XA_BQUAL', 12; @@ -314,7 +288,6 @@ XA END 'XA_CON2', 'XA_BQUAL', 12; XA PREPARE 'XA_CON2', 'XA_BQUAL', 12; XA COMMIT 'XA_CON2', 'XA_BQUAL', 12; ---echo # Switch to connection con3 --connection con3 XA START 'XA_CON3', 'XA_BQUAL', 12; @@ -323,7 +296,6 @@ XA END 'XA_CON3', 'XA_BQUAL', 12; XA PREPARE 'XA_CON3', 'XA_BQUAL', 12; XA COMMIT 'XA_CON3', 'XA_BQUAL', 12; ---echo # Switch to connection con4 --connection con4 XA START 'XA_CON4', 'XA_BQUAL', 12; @@ -334,161 +306,150 @@ XA COMMIT 'XA_CON4', 'XA_BQUAL', 12; --connection default ---disable_query_log +echo ########################### Transactions user 1 - 2; -echo "=========================== Transactions user 1"; - -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +evalp select /*1-2*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current where THREAD_ID = $con1_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*1-2*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con1_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*1-2*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con1_thread_id; -echo "=========================== Transactions user 2"; +echo ########################### Transactions user 2 - 2; -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +evalp select /*2-2*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*2-2*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*2-2*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Transactions user 3"; +echo ########################### Transactions user 3 - 2; -eval select count(*) from performance_schema.events_transactions_current +evalp select /*3-2*/ count(*) from performance_schema.events_transactions_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*3-2*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*3-2*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Transactions user 4"; +echo ########################### Transactions user 4 - 2; -eval select count(*) from performance_schema.events_transactions_current +evalp select /*4-2*/ count(*) from performance_schema.events_transactions_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*4-2*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*4-2*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Statements user 1"; +echo ########################### Statements user 1 - 2; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_statements_history +evalp select /*1-2*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-2*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con1_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*1-2*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con1_thread_id; -echo "=========================== Statements user 2"; +echo ########################### Statements user 2 - 2; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_statements_history +evalp select /*2-2*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-2*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*2-2*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Statements user 3"; +echo ########################### Statements user 3 - 2; -eval select count(*) from performance_schema.events_statements_current +evalp select /*3-2*/ count(*) from performance_schema.events_statements_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_statements_history +evalp select /*3-2*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*3-2*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Statements user 4"; +echo ########################### Statements user 4 - 2; -eval select count(*) from performance_schema.events_statements_current +evalp select /*4-2*/ count(*) from performance_schema.events_statements_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_statements_history +evalp select /*4-2*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*4-2*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Stages user 1"; +echo ########################### Stages user 1 - 2; -eval select EVENT_NAME from performance_schema.events_stages_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_stages_history +evalp select /*1-2*/ EVENT_NAME from performance_schema.events_stages_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-2*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con1_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*1-2*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con1_thread_id; -echo "=========================== Stages user 2"; +echo ########################### Stages user 2 - 2; -eval select EVENT_NAME from performance_schema.events_stages_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_stages_history +evalp select /*2-2*/ EVENT_NAME from performance_schema.events_stages_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-2*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*2-2*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Stages user 3"; +echo ########################### Stages user 3 - 2; -eval select count(*) from performance_schema.events_stages_current +evalp select /*3-2*/ count(*) from performance_schema.events_stages_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_stages_history +evalp select /*3-2*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*3-2*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Stages user 4"; +echo ########################### Stages user 4 - 2; -eval select count(*) from performance_schema.events_stages_current +evalp select /*4-2*/ count(*) from performance_schema.events_stages_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_stages_history +evalp select /*4-2*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*4-2*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Waits user 1"; +echo ########################### Waits user 1 - 2; -eval select EVENT_NAME from performance_schema.events_waits_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) as has_waits from performance_schema.events_waits_history +evalp select /*1-2*/ EVENT_NAME from performance_schema.events_waits_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-2*/ count(*) as has_waits from performance_schema.events_waits_history where THREAD_ID = $con1_thread_id; -eval select count(*) as has_waits from performance_schema.events_waits_history_long +evalp select /*1-2*/ count(*) as has_waits from performance_schema.events_waits_history_long where THREAD_ID = $con1_thread_id; -echo "=========================== Waits user 2"; +echo ########################### Waits user 2 - 2; -eval select EVENT_NAME from performance_schema.events_waits_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_waits_history +evalp select /*2-2*/ EVENT_NAME from performance_schema.events_waits_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-2*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*2-2*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Waits user 3"; +echo ########################### Waits user 3 - 2; -eval select count(*) from performance_schema.events_waits_current +evalp select /*3-2*/ count(*) from performance_schema.events_waits_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_waits_history +evalp select /*3-2*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*3-2*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Waits user 4"; +echo ########################### Waits user 4 - 2; -eval select count(*) from performance_schema.events_waits_current +evalp select /*4-2*/ count(*) from performance_schema.events_waits_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_waits_history +evalp select /*4-2*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*4-2*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con4_thread_id; ---enable_query_log - ---echo # Switch to connection default, enable consumers --connection default update performance_schema.setup_consumers @@ -509,7 +470,6 @@ truncate table performance_schema.events_waits_current; truncate table performance_schema.events_waits_history; truncate table performance_schema.events_waits_history_long; ---echo # Switch to connection con1 --connection con1 XA START 'XA_CON1', 'XA_BQUAL', 12; @@ -518,7 +478,6 @@ XA END 'XA_CON1', 'XA_BQUAL', 12; XA PREPARE 'XA_CON1', 'XA_BQUAL', 12; XA COMMIT 'XA_CON1', 'XA_BQUAL', 12; ---echo # Switch to connection con2 --connection con2 XA START 'XA_CON2', 'XA_BQUAL', 12; @@ -527,7 +486,6 @@ XA END 'XA_CON2', 'XA_BQUAL', 12; XA PREPARE 'XA_CON2', 'XA_BQUAL', 12; XA COMMIT 'XA_CON2', 'XA_BQUAL', 12; ---echo # Switch to connection con3 --connection con3 XA START 'XA_CON3', 'XA_BQUAL', 12; @@ -536,7 +494,6 @@ XA END 'XA_CON3', 'XA_BQUAL', 12; XA PREPARE 'XA_CON3', 'XA_BQUAL', 12; XA COMMIT 'XA_CON3', 'XA_BQUAL', 12; ---echo # Switch to connection con4 --connection con4 XA START 'XA_CON4', 'XA_BQUAL', 12; @@ -547,165 +504,150 @@ XA COMMIT 'XA_CON4', 'XA_BQUAL', 12; --connection default ---disable_query_log +echo ########################### Transactions user 1 - 3; -echo "=========================== Transactions user 1"; - -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +evalp select /*1-3*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current where THREAD_ID = $con1_thread_id; -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history +evalp select /*1-3*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history where THREAD_ID = $con1_thread_id; -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long +evalp select /*1-3*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long where THREAD_ID = $con1_thread_id; -echo "=========================== Transactions user 2"; +echo ########################### Transactions user 2 - 3; -eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current +evalp select /*2-3*/ XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*2-3*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*2-3*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Transactions user 3"; +echo ########################### Transactions user 3 - 3; -eval select count(*) from performance_schema.events_transactions_current +evalp select /*3-3*/ count(*) from performance_schema.events_transactions_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*3-3*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*3-3*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Transactions user 4"; +echo ########################### Transactions user 4 - 3; -eval select count(*) from performance_schema.events_transactions_current +evalp select /*4-3*/ count(*) from performance_schema.events_transactions_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_transactions_history +evalp select /*4-3*/ count(*) from performance_schema.events_transactions_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_transactions_history_long +evalp select /*4-3*/ count(*) from performance_schema.events_transactions_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Statements user 1"; +echo ########################### Statements user 1 - 3; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; +evalp select /*1-3*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-3*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-3*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; -echo "=========================== Statements user 2"; +echo ########################### Statements user 2 - 3; -eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_statements_history +evalp select /*2-3*/ EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-3*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*2-3*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Statements user 3"; +echo ########################### Statements user 3 - 3; -eval select count(*) from performance_schema.events_statements_current +evalp select /*3-3*/ count(*) from performance_schema.events_statements_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_statements_history +evalp select /*3-3*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*3-3*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Statements user 4"; +echo ########################### Statements user 4 - 3; -eval select count(*) from performance_schema.events_statements_current +evalp select /*4-3*/ count(*) from performance_schema.events_statements_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_statements_history +evalp select /*4-3*/ count(*) from performance_schema.events_statements_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_statements_history_long +evalp select /*4-3*/ count(*) from performance_schema.events_statements_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Stages user 1"; +echo ########################### Stages user 1 - 3; -eval select EVENT_NAME from performance_schema.events_stages_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select EVENT_NAME from performance_schema.events_stages_history - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select EVENT_NAME from performance_schema.events_stages_history_long - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; +evalp select /*1-3*/ EVENT_NAME from performance_schema.events_stages_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-3*/ EVENT_NAME from performance_schema.events_stages_history + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-3*/ EVENT_NAME from performance_schema.events_stages_history_long + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; -echo "=========================== Stages user 2"; +echo ########################### Stages user 2 - 3; -eval select EVENT_NAME from performance_schema.events_stages_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_stages_history +evalp select /*2-3*/ EVENT_NAME from performance_schema.events_stages_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-3*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*2-3*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Stages user 3"; +echo ########################### Stages user 3 - 3; -eval select count(*) from performance_schema.events_stages_current +evalp select /*3-3*/ count(*) from performance_schema.events_stages_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_stages_history +evalp select /*3-3*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*3-3*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Stages user 4"; +echo ########################### Stages user 4 - 3; -eval select count(*) from performance_schema.events_stages_current +evalp select /*4-3*/ count(*) from performance_schema.events_stages_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_stages_history +evalp select /*4-3*/ count(*) from performance_schema.events_stages_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_stages_history_long +evalp select /*4-3*/ count(*) from performance_schema.events_stages_history_long where THREAD_ID = $con4_thread_id; -echo "=========================== Waits user 1"; +echo ########################### Waits user 1 - 3; -eval select EVENT_NAME from performance_schema.events_waits_current - where THREAD_ID = $con1_thread_id - order by THREAD_ID, EVENT_ID; -eval select (count(*) > 5) as has_waits from performance_schema.events_waits_history +evalp select /*1-3*/ EVENT_NAME from performance_schema.events_waits_current + where THREAD_ID = $con1_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*1-3*/ (count(*) > 5) as has_waits from performance_schema.events_waits_history where THREAD_ID = $con1_thread_id; -eval select (count(*) > 15) as has_waits from performance_schema.events_waits_history_long +evalp select /*1-3*/ (count(*) > 15) as has_waits from performance_schema.events_waits_history_long where THREAD_ID = $con1_thread_id; -echo "=========================== Waits user 2"; +echo ########################### Waits user 2 - 3; -eval select EVENT_NAME from performance_schema.events_waits_current - where THREAD_ID = $con2_thread_id - order by THREAD_ID, EVENT_ID; -eval select count(*) from performance_schema.events_waits_history +evalp select /*2-3*/ EVENT_NAME from performance_schema.events_waits_current + where THREAD_ID = $con2_thread_id order by THREAD_ID, EVENT_ID; +evalp select /*2-3*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con2_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*2-3*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con2_thread_id; -echo "=========================== Waits user 3"; +echo ########################### Waits user 3 - 3; -eval select count(*) from performance_schema.events_waits_current +evalp select /*3-3*/ count(*) from performance_schema.events_waits_current where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_waits_history +evalp select /*3-3*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con3_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*3-3*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con3_thread_id; -echo "=========================== Waits user 4"; +echo ########################### Waits user 4 - 3; -eval select count(*) from performance_schema.events_waits_current +evalp select /*4-3*/ count(*) from performance_schema.events_waits_current where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_waits_history +evalp select /*4-3*/ count(*) from performance_schema.events_waits_history where THREAD_ID = $con4_thread_id; -eval select count(*) from performance_schema.events_waits_history_long +evalp select /*4-3*/ count(*) from performance_schema.events_waits_history_long where THREAD_ID = $con4_thread_id; ---enable_query_log - ---echo # Switch to connection default --connection default revoke all privileges, grant option from user1@localhost; From 075dd73641bfa2c388a6aebf82dad0a7bb72974e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 28 Mar 2024 13:10:12 +1100 Subject: [PATCH 062/313] MDEV-33290: Disable ColumnStore based on boost version (postfix) Its important to fail early and only contine with the include after the boost version check succeeds. Needs to succeed on ealier verisons too so can't just fail if too new. As such, do a version check. --- storage/columnstore/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/storage/columnstore/CMakeLists.txt b/storage/columnstore/CMakeLists.txt index 644f0ca8984..be46caee2a6 100644 --- a/storage/columnstore/CMakeLists.txt +++ b/storage/columnstore/CMakeLists.txt @@ -13,15 +13,17 @@ endmacro() IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") - add_subdirectory(columnstore) + cmake_policy(SET CMP0093 NEW) # https://jira.mariadb.org/browse/MCOL-5611 - FIND_PACKAGE(Boost 1.80.0 COMPONENTS system filesystem thread regex date_time chrono atomic) - IF (Boost_FOUND) + FIND_PACKAGE(Boost COMPONENTS system filesystem thread regex date_time chrono atomic) + IF (Boost_VERSION VERSION_GREATER "1.79.0") MESSAGE_ONCE(CS_NO_BOOST "Boost Libraries >= 1.80.0 not supported!") return() ENDIF() + add_subdirectory(columnstore) + IF(TARGET columnstore) # Needed to bump the component changes up to the main scope APPEND_FOR_CPACK(CPACK_COMPONENTS_ALL) From b3e29da540caf96cc3c17b512b999a4cd2d34824 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 4 Apr 2024 18:23:52 +0200 Subject: [PATCH 063/313] MDEV-33290: Disable ColumnStore based on boost version (post-postfix) policy CMP0093 was added in cmake 3.15 let's support cmake from 2.8.12, that's what our CMAKE_MINIMUM_REQUIRED() says --- storage/columnstore/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/columnstore/CMakeLists.txt b/storage/columnstore/CMakeLists.txt index be46caee2a6..1b3b739b706 100644 --- a/storage/columnstore/CMakeLists.txt +++ b/storage/columnstore/CMakeLists.txt @@ -13,11 +13,10 @@ endmacro() IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") - cmake_policy(SET CMP0093 NEW) # https://jira.mariadb.org/browse/MCOL-5611 FIND_PACKAGE(Boost COMPONENTS system filesystem thread regex date_time chrono atomic) - IF (Boost_VERSION VERSION_GREATER "1.79.0") + IF (${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_GREATER "1.79") MESSAGE_ONCE(CS_NO_BOOST "Boost Libraries >= 1.80.0 not supported!") return() ENDIF() From 96533bae54bed2216039cd7cdee97d9e5a1042da Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 5 Apr 2024 10:41:01 +0200 Subject: [PATCH 064/313] suppress a transient galera warning these warnings are expected and are auto-resolved by galera --- mysql-test/suite/galera/suite.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index f6caecdc36a..d09cb89df5c 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -63,6 +63,7 @@ push @::global_suppressions, qr(WSREP: Failed to remove page file .*), qr(WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to .*), qr|WSREP: Sending JOIN failed: -107 \(Transport endpoint is not connected\). Will retry in new primary component.|, + qr|WSREP: Send action {.* STATE_REQUEST} returned -107 \(Transport endpoint is not connected\)|, qr|WSREP: Trying to continue unpaused monitor|, qr|WSREP: Wait for gtid returned error 3 while waiting for prior transactions to commit before setting position|, qr|WSREP: Failed to report last committed|, From 429fdb5bd6d3e59a08cf1e0e90f8159df2c81afc Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 5 Apr 2024 15:47:03 +0200 Subject: [PATCH 065/313] MDEV-29171 disable failing galera test --- mysql-test/suite/galera_3nodes/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index 730f98667e6..e1b4c2d5d5f 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -16,3 +16,4 @@ galera_ssl_reload : MDEV-32778 galera_ssl_reload failed with warning message galera_ipv6_mariabackup : temporarily disabled at the request of Codership galera_pc_bootstrap : temporarily disabled at the request of Codership galera_ipv6_mariabackup_section : temporarily disabled at the request of Codership +MDEV-29171 : MDEV-33842 galera_3nodes.MDEV-29171 fails on shutdown_server From 9b5d711ac384e4f3ce397746aa1711cdf284b9ab Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 5 Apr 2024 16:09:56 +0530 Subject: [PATCH 066/313] MDEV-20094 InnoDB blob allocation allocates extra extents - InnoDB reserves the free extents unnecessarily during blob page allocation even though btr_page_alloc() can handle reserving the extent when the existing ran out of pages to be used. --- .../innodb/r/check_ibd_filesize,32k.rdiff | 6 +++--- .../innodb/r/check_ibd_filesize,4k.rdiff | 6 +++--- .../innodb/r/check_ibd_filesize,64k.rdiff | 6 +++--- .../innodb/r/check_ibd_filesize,8k.rdiff | 6 +++--- .../suite/innodb/r/check_ibd_filesize.result | 2 +- storage/innobase/btr/btr0cur.cc | 20 ++++++++----------- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff index 44446602b9f..ad1f3a447c2 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 -+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:29:25.129637040 +0530 +--- mysql-test/suite/innodb/r/check_ibd_filesize.result ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject @@ -3,18 +3,12 @@ # SPACE IN 5.7 THAN IN 5.6 # @@ -14,7 +14,7 @@ -# bytes: 65536 +# bytes: 131072 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; --# bytes: 4194304 +-# bytes: 2097152 -DROP TABLE t1; -CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) -ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff index ef55ad971fe..1412df393ff 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 -+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:39.288769153 +0530 +--- mysql-test/suite/innodb/r/check_ibd_filesize.result ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject @@ -3,18 +3,18 @@ # SPACE IN 5.7 THAN IN 5.6 # @@ -13,7 +13,7 @@ -# bytes: 65536 +# bytes: 16384 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; - # bytes: 4194304 + # bytes: 2097152 DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff index bcdcea31160..156925597ab 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 -+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:30:28.957174270 +0530 +--- mysql-test/suite/innodb/r/check_ibd_filesize.result ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject @@ -3,18 +3,12 @@ # SPACE IN 5.7 THAN IN 5.6 # @@ -14,7 +14,7 @@ -# bytes: 65536 +# bytes: 262144 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; --# bytes: 4194304 +-# bytes: 2097152 -DROP TABLE t1; -CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) -ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff index 7b699ef4cea..55cf59737d3 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff +++ b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff @@ -1,5 +1,5 @@ ---- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530 -+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:03.516962339 +0530 +--- mysql-test/suite/innodb/r/check_ibd_filesize.result ++++ mysql-test/suite/innodb/r/check_ibd_filesize.reject @@ -3,18 +3,18 @@ # SPACE IN 5.7 THAN IN 5.6 # @@ -13,7 +13,7 @@ -# bytes: 65536 +# bytes: 32768 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; - # bytes: 4194304 + # bytes: 2097152 DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize.result b/mysql-test/suite/innodb/r/check_ibd_filesize.result index 0d224d6ac5f..b0f376183ea 100644 --- a/mysql-test/suite/innodb/r/check_ibd_filesize.result +++ b/mysql-test/suite/innodb/r/check_ibd_filesize.result @@ -10,7 +10,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB; # bytes: 65536 INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20; -# bytes: 4194304 +# bytes: 2097152 DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 38bbf2d1bc1..bd88582d4f4 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -7684,7 +7684,6 @@ btr_store_big_rec_extern_fields( buf_block_t* block; page_t* page; const ulint commit_freq = 4; - ulint r_extents; ut_ad(page_align(field_ref) == page_align(rec)); @@ -7723,20 +7722,17 @@ btr_store_big_rec_extern_fields( alloc_mtr = &mtr; } - if (!fsp_reserve_free_extents(&r_extents, - index->table->space, 1, - FSP_BLOB, alloc_mtr, - 1)) { - - alloc_mtr->commit(); - error = DB_OUT_OF_FILE_SPACE; - goto func_exit; - } - block = btr_page_alloc(index, hint_page_no, FSP_NO_DIR, 0, alloc_mtr, &mtr); - index->table->space->release_free_extents(r_extents); + if (!block) { + error = DB_OUT_OF_FILE_SPACE; + alloc_mtr->commit(); + if (op == BTR_STORE_INSERT_BULK) { + mtr.commit(); + } + goto func_exit; + } if (UNIV_UNLIKELY(op == BTR_STORE_INSERT_BULK)) { mtr_bulk.commit(); From 12d448fde9793551a1604f129ef2ca338eeb43b2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 6 Apr 2024 00:31:08 +0200 Subject: [PATCH 067/313] mtr: increase more timeouts under debuggers in particular, debug_sync timeout and wait_for_pos timeout --- mysql-test/lib/My/Debugger.pm | 1 + mysql-test/mysql-test-run.pl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mysql-test/lib/My/Debugger.pm b/mysql-test/lib/My/Debugger.pm index bfa27b8dd3a..c852c767055 100644 --- a/mysql-test/lib/My/Debugger.pm +++ b/mysql-test/lib/My/Debugger.pm @@ -256,6 +256,7 @@ sub pre_setup() { $::opt_suite_timeout= 7 * 24 * 60; # in minutes $::opt_shutdown_timeout= 24 * 60 *60; # in seconds $::opt_start_timeout= 24 * 60 * 60; # in seconds + $::opt_debug_sync_timeout= 3000; # in seconds } } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 14a6293ac29..c418e5169c6 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5662,6 +5662,8 @@ sub start_mysqltest ($) { mtr_add_arg($args, "--result-file=%s", $tinfo->{'result_file'}); } + mtr_add_arg($args, "--wait-for-pos-timeout=%d", $opt_debug_sync_timeout); + client_debug_arg($args, "mysqltest"); if ( $opt_record ) From a7bf0a42d0c1a5540c0b32a8284c1462d7c8c9a8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 6 Apr 2024 23:05:57 +0200 Subject: [PATCH 068/313] sporadic failures of main.mdl_sync main.mdl_sync 'innodb' w32 [ fail ] Test ended at 2024-04-06 14:11:15 CURRENT_TEST: main.mdl_sync --- main/mdl_sync.result +++ main/mdl_sync.reject @@ -2458,6 +2458,7 @@ SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME MDL_BACKUP_FTWRL2 Backup lock +MDL_SHARED Table metadata lock test t2 unlock tables; connection default; # Reaping UPDATE --- mysql-test/main/mdl_sync.result | 4 ++++ mysql-test/main/mdl_sync.test | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/mysql-test/main/mdl_sync.result b/mysql-test/main/mdl_sync.result index ae36a65aab4..9abeb05b011 100644 --- a/mysql-test/main/mdl_sync.result +++ b/mysql-test/main/mdl_sync.result @@ -2433,6 +2433,9 @@ create table t1 (a int) engine=myisam; create table t2 (a int) stats_persistent=0, engine=innodb; insert into t1 values (1); insert into t2 values (1); +connect con1, localhost, root; +start transaction with consistent snapshot; +connection default; SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait execute 2'; update t1,t2 set t1.a=2,t2.a=3; connection con2; @@ -2464,6 +2467,7 @@ connection default; SET DEBUG_SYNC= 'RESET'; drop table t1,t2; disconnect con2; +disconnect con1; # # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null' # failed in open_ltable() diff --git a/mysql-test/main/mdl_sync.test b/mysql-test/main/mdl_sync.test index 8ce4d1eb2b5..40a1112a6d4 100644 --- a/mysql-test/main/mdl_sync.test +++ b/mysql-test/main/mdl_sync.test @@ -3117,6 +3117,12 @@ create table t2 (a int) stats_persistent=0, engine=innodb; insert into t1 values (1); insert into t2 values (1); +connect (con1, localhost, root); +# disable innodb purge thread, otherwise it might start purging t2, +# and will take an mdl, affecting metadata_lock_info output. +start transaction with consistent snapshot; +connection default; + SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait execute 2'; --send update t1,t2 set t1.a=2,t2.a=3 @@ -3162,6 +3168,7 @@ connection default; SET DEBUG_SYNC= 'RESET'; drop table t1,t2; disconnect con2; +disconnect con1; --echo # --echo # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null' From 2b0e0730c7d1401620a603a3ed14f9409d75203a Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Wed, 3 Apr 2024 20:43:57 +0000 Subject: [PATCH 069/313] Add cpu-limit option for mini-benchmark As performance improves, the permitted number of CPU cycles to be used during the benchmark should be lowered to catch performance regressions. An option is added to better support this. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- support-files/mini-benchmark.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/support-files/mini-benchmark.sh b/support-files/mini-benchmark.sh index a7bf3591a39..c7734348545 100755 --- a/support-files/mini-benchmark.sh +++ b/support-files/mini-benchmark.sh @@ -26,6 +26,8 @@ display_help() { echo " sysbench runs" echo " --perf-flamegraph record performance counters in perf.data.* and" echo " generate flamegraphs automatically" + echo " --cpu-limit upper limit on the number of CPU cycles (in billions) used for the benchmark" + echo " default: 750" echo " -h, --help display this help and exit" } @@ -79,6 +81,11 @@ do PERF_RECORD=true shift ;; + --cpu-limit) + shift + CPU_CYCLE_LIMIT=$1 + shift + ;; -*) echo "Error: Unknown option: $1" >&2 ## or call function display_help @@ -247,12 +254,21 @@ then echo "Total: $(grep -h -e instructions sysbench-run-*.log | sort -k 1 | awk '{s+=$1}END{print s}')" echo # Newline improves readability + if [ -z "$CPU_CYCLE_LIMIT" ] + then + # 04-04-2024: We found this to be an appropriate default limit after running a few benchmarks + # Configure the limit with --cpu-limit if needed + CPU_CYCLE_LIMIT=750 + fi + CPU_CYCLE_LIMIT_LONG="${CPU_CYCLE_LIMIT}000000000" + # Final verdict based on cpu cycle count RESULT="$(grep -h -e cycles sysbench-run-*.log | sort -k 1 | awk '{s+=$1}END{print s}')" - if [ "$RESULT" -gt 850 ] + if [ "$RESULT" -gt "$CPU_CYCLE_LIMIT_LONG" ] then echo # Newline improves readability - echo "Benchmark exceeded 850 billion cpu cycles, performance most likely regressed!" + echo "Benchmark exceeded the allowed limit of ${CPU_CYCLE_LIMIT} billion CPU cycles" + echo "Performance most likely regressed!" exit 1 fi fi From 535711055643952df05774ddb0c94858101be5f6 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Thu, 4 Apr 2024 03:29:39 +0000 Subject: [PATCH 070/313] Fix error behaviour in mini-benchmark In commit f5ca4077, an the "--log" option was added but it was implemented by invoking a sub-shell. Any errors in the sub-shell would not be propagated and thus cause mini-benchmark to suppress errors. The fix here is to propagate the exit status of the sub-shell. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- support-files/mini-benchmark.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mini-benchmark.sh b/support-files/mini-benchmark.sh index c7734348545..a405b6c469c 100755 --- a/support-files/mini-benchmark.sh +++ b/support-files/mini-benchmark.sh @@ -310,4 +310,4 @@ case $RESULT in esac # Record the output into the log file, if requested ) 2>&1 | ($LOG && tee "$BENCHMARK_NAME"-"$TIMESTAMP".log) - +exit ${PIPESTATUS[0]} # Propagate errors in the sub-shell From 54ad3b0e9eddee432f1422506fbbda5900a41da8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 7 Apr 2024 12:01:24 +0200 Subject: [PATCH 071/313] MDEV-22949 perfschema.memory_aggregate_no_a_no_u fails sporadically in buildbot with wrong result 32-bit followup for 8bb8820df2b --- mysql-test/suite/perfschema/r/memory_aggregate_32bit.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/perfschema/r/memory_aggregate_32bit.result b/mysql-test/suite/perfschema/r/memory_aggregate_32bit.result index 2b8ee675650..387af11f91a 100644 --- a/mysql-test/suite/perfschema/r/memory_aggregate_32bit.result +++ b/mysql-test/suite/perfschema/r/memory_aggregate_32bit.result @@ -2507,8 +2507,8 @@ execute dump_hosts; HOST CURRENT_CONNECTIONS TOTAL_CONNECTIONS localhost 6 6 disconnect con1; -disconnect con5; connection default; +disconnect con5; "================== con1/con5 disconnected ==================" "================== Step 10 ==================" call dump_thread(); From e1825e39cae73f43f20ed7ae856f167b0ecf4598 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 7 Apr 2024 22:29:51 +0200 Subject: [PATCH 072/313] increase performance-schema-max-thread-instances the value of 200 isn't enough for some tests anymore, this causes some random threads to become not instrumented and any table operations there are not reflected in the perfschema. If, say, a DROP TABLE doesn't change perfschema state, perfschema tables might show ghost tables that no longer exist in the server --- mysql-test/include/default_mysqld.cnf | 2 +- mysql-test/suite/perfschema/r/max_program_zero.result | 2 +- mysql-test/suite/perfschema/r/misc.result | 2 +- mysql-test/suite/perfschema/r/ortho_iter.result | 2 +- mysql-test/suite/perfschema/r/privilege_table_io.result | 2 +- .../suite/perfschema/r/start_server_disable_idle.result | 2 +- .../suite/perfschema/r/start_server_disable_stages.result | 2 +- .../suite/perfschema/r/start_server_disable_statements.result | 2 +- .../perfschema/r/start_server_disable_transactions.result | 2 +- .../suite/perfschema/r/start_server_disable_waits.result | 2 +- mysql-test/suite/perfschema/r/start_server_innodb.result | 2 +- mysql-test/suite/perfschema/r/start_server_low_index.result | 2 +- .../suite/perfschema/r/start_server_low_table_lock.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_account.result | 2 +- .../suite/perfschema/r/start_server_no_cond_class.result | 2 +- .../suite/perfschema/r/start_server_no_cond_inst.result | 2 +- .../suite/perfschema/r/start_server_no_file_class.result | 2 +- .../suite/perfschema/r/start_server_no_file_inst.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_host.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_index.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_mdl.result | 2 +- .../suite/perfschema/r/start_server_no_memory_class.result | 2 +- .../suite/perfschema/r/start_server_no_mutex_class.result | 2 +- .../suite/perfschema/r/start_server_no_mutex_inst.result | 2 +- .../r/start_server_no_prepared_stmts_instances.result | 2 +- .../suite/perfschema/r/start_server_no_rwlock_class.result | 2 +- .../suite/perfschema/r/start_server_no_rwlock_inst.result | 2 +- .../suite/perfschema/r/start_server_no_setup_actors.result | 2 +- .../suite/perfschema/r/start_server_no_setup_objects.result | 2 +- .../suite/perfschema/r/start_server_no_socket_class.result | 2 +- .../suite/perfschema/r/start_server_no_socket_inst.result | 2 +- .../suite/perfschema/r/start_server_no_stage_class.result | 2 +- .../suite/perfschema/r/start_server_no_stages_history.result | 2 +- .../perfschema/r/start_server_no_stages_history_long.result | 2 +- .../suite/perfschema/r/start_server_no_statement_class.result | 2 +- .../perfschema/r/start_server_no_statements_history.result | 2 +- .../r/start_server_no_statements_history_long.result | 2 +- .../suite/perfschema/r/start_server_no_table_hdl.result | 2 +- .../suite/perfschema/r/start_server_no_table_inst.result | 2 +- .../suite/perfschema/r/start_server_no_table_lock.result | 2 +- .../suite/perfschema/r/start_server_no_thread_class.result | 2 +- .../perfschema/r/start_server_no_transactions_history.result | 2 +- .../r/start_server_no_transactions_history_long.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_user.result | 2 +- .../suite/perfschema/r/start_server_no_waits_history.result | 2 +- .../perfschema/r/start_server_no_waits_history_long.result | 2 +- mysql-test/suite/perfschema/r/start_server_off.result | 2 +- mysql-test/suite/perfschema/r/start_server_on.result | 2 +- mysql-test/suite/perfschema/r/start_server_variables.result | 4 ++-- .../suite/perfschema/r/statement_program_lost_inst.result | 2 +- 50 files changed, 51 insertions(+), 51 deletions(-) diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index cccf72591cc..40bf19ac922 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -92,7 +92,7 @@ loose-performance-schema-events-statements-history-size=10 loose-performance-schema-events-statements-history-long-size=1000 loose-performance-schema-events-transactions-history-size=10 loose-performance-schema-events-transactions-history-long-size=1000 -loose-performance-schema-max-thread-instances=200 +loose-performance-schema-max-thread-instances=400 loose-performance-schema-session-connect-attrs-size=2048 loose-performance-schema-max-metadata-locks=10000 diff --git a/mysql-test/suite/perfschema/r/max_program_zero.result b/mysql-test/suite/perfschema/r/max_program_zero.result index 85b9f49501c..d2e4526d307 100644 --- a/mysql-test/suite/perfschema/r/max_program_zero.result +++ b/mysql-test/suite/perfschema/r/max_program_zero.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/misc.result b/mysql-test/suite/perfschema/r/misc.result index df9942a170f..7468eeddb4c 100644 --- a/mysql-test/suite/perfschema/r/misc.result +++ b/mysql-test/suite/perfschema/r/misc.result @@ -94,7 +94,7 @@ test t_60905 NULL 5 5 0 1 DROP TABLE t_60905; show global variables like "performance_schema_max_thread_instances"; Variable_name Value -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 explain select * from performance_schema.threads; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE threads ALL NULL NULL NULL NULL 256 diff --git a/mysql-test/suite/perfschema/r/ortho_iter.result b/mysql-test/suite/perfschema/r/ortho_iter.result index 9489c1049e5..2dacee0ac27 100644 --- a/mysql-test/suite/perfschema/r/ortho_iter.result +++ b/mysql-test/suite/perfschema/r/ortho_iter.result @@ -261,7 +261,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/privilege_table_io.result b/mysql-test/suite/perfschema/r/privilege_table_io.result index 1755c89137d..2b40cdec14b 100644 --- a/mysql-test/suite/perfschema/r/privilege_table_io.result +++ b/mysql-test/suite/perfschema/r/privilege_table_io.result @@ -63,7 +63,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_idle.result b/mysql-test/suite/perfschema/r/start_server_disable_idle.result index 00baba09fb6..8b609de4534 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_idle.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_idle.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_stages.result b/mysql-test/suite/perfschema/r/start_server_disable_stages.result index 6fe051b3c42..b31430eada3 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_stages.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_stages.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_statements.result b/mysql-test/suite/perfschema/r/start_server_disable_statements.result index b582ca072c8..c37509c98ab 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_statements.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_statements.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_transactions.result b/mysql-test/suite/perfschema/r/start_server_disable_transactions.result index 1431f925ae2..7fa2125b20e 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_transactions.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_transactions.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_waits.result b/mysql-test/suite/perfschema/r/start_server_disable_waits.result index 1b9356b34a2..b6bb1a989ac 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_waits.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_waits.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_innodb.result b/mysql-test/suite/perfschema/r/start_server_innodb.result index c64e4f8416d..8cad1f4d414 100644 --- a/mysql-test/suite/perfschema/r/start_server_innodb.result +++ b/mysql-test/suite/perfschema/r/start_server_innodb.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_low_index.result b/mysql-test/suite/perfschema/r/start_server_low_index.result index 9fd9a8a447c..54441252db2 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_index.result +++ b/mysql-test/suite/perfschema/r/start_server_low_index.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_low_table_lock.result b/mysql-test/suite/perfschema/r/start_server_low_table_lock.result index 981fa297971..9164fe18775 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_table_lock.result +++ b/mysql-test/suite/perfschema/r/start_server_low_table_lock.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 1 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_account.result b/mysql-test/suite/perfschema/r/start_server_no_account.result index 4333c6f74d2..9ec22e633d1 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_account.result +++ b/mysql-test/suite/perfschema/r/start_server_no_account.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result index 74c4bed9696..e554b1e9aa4 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result index 03a7f935317..be07f77b99b 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_file_class.result b/mysql-test/suite/perfschema/r/start_server_no_file_class.result index c962a74e0db..f5367f17973 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result index ef80d6e3a2d..e9db05a1364 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_host.result b/mysql-test/suite/perfschema/r/start_server_no_host.result index b58acf57362..8298ca3a828 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_host.result +++ b/mysql-test/suite/perfschema/r/start_server_no_host.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_index.result b/mysql-test/suite/perfschema/r/start_server_no_index.result index 9e7a2bf34a7..50c693e4489 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_index.result +++ b/mysql-test/suite/perfschema/r/start_server_no_index.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_mdl.result b/mysql-test/suite/perfschema/r/start_server_no_mdl.result index 886a1ee1633..a495471f994 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_mdl.result +++ b/mysql-test/suite/perfschema/r/start_server_no_mdl.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_memory_class.result b/mysql-test/suite/perfschema/r/start_server_no_memory_class.result index a6605cc5ffb..a598db77dc9 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_memory_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_memory_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result index ae30ac59bdb..cc72db98662 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result index 1f4086500a0..ee1507c8c59 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_prepared_stmts_instances.result b/mysql-test/suite/perfschema/r/start_server_no_prepared_stmts_instances.result index 32356175e82..4b779b919df 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_prepared_stmts_instances.result +++ b/mysql-test/suite/perfschema/r/start_server_no_prepared_stmts_instances.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result index 75ebff83745..4c480f75b3b 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result index d7ebfb33d5b..d0f76f6a8a3 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result index b4b79d02b32..43e98074842 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result +++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 0 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result index aef0eb7c14d..b8c5e26d6cc 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result +++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 0 diff --git a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result index 4695c03dc34..de55a7ff938 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result index 45f668bd668..57f7a5a3647 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_stage_class.result b/mysql-test/suite/perfschema/r/start_server_no_stage_class.result index cccc88ea078..fdefd3ad1f7 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_stage_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_stage_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result index 3631b3e401f..ac0355c51c6 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result +++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result index bb17a80d853..dd8fc35984e 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result +++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_statement_class.result b/mysql-test/suite/perfschema/r/start_server_no_statement_class.result index 61cf11f2238..49fdd561ad9 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_statement_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_statement_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result index 94811c40c53..612b305f6e6 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result +++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result index 4d61bf58fca..92a654bdab4 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result +++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result index 49b59cbc48c..b7204361047 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result +++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 0 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result index 17a10cf715e..943e1e92dc2 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 0 performance_schema_max_table_lock_stat 0 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_lock.result b/mysql-test/suite/perfschema/r/start_server_no_table_lock.result index a93f900f650..4996016b4af 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_table_lock.result +++ b/mysql-test/suite/perfschema/r/start_server_no_table_lock.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 0 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result index 051c81dd12f..374d3bb400b 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 0 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_transactions_history.result b/mysql-test/suite/perfschema/r/start_server_no_transactions_history.result index 1d5597f554b..0ce961296bb 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_transactions_history.result +++ b/mysql-test/suite/perfschema/r/start_server_no_transactions_history.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_transactions_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_transactions_history_long.result index 99e170c9bb1..4b92d21150d 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_transactions_history_long.result +++ b/mysql-test/suite/perfschema/r/start_server_no_transactions_history_long.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_user.result b/mysql-test/suite/perfschema/r/start_server_no_user.result index 46aaa06bf65..2ac41042d03 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_user.result +++ b/mysql-test/suite/perfschema/r/start_server_no_user.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_waits_history.result b/mysql-test/suite/perfschema/r/start_server_no_waits_history.result index 1b717b9f768..570900fca79 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_waits_history.result +++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result index 5691b0e7826..dbcd2100141 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result +++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_off.result b/mysql-test/suite/perfschema/r/start_server_off.result index 06af389a857..f9de9146a13 100644 --- a/mysql-test/suite/perfschema/r/start_server_off.result +++ b/mysql-test/suite/perfschema/r/start_server_off.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_on.result b/mysql-test/suite/perfschema/r/start_server_on.result index c64e4f8416d..8cad1f4d414 100644 --- a/mysql-test/suite/perfschema/r/start_server_on.result +++ b/mysql-test/suite/perfschema/r/start_server_on.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/start_server_variables.result b/mysql-test/suite/perfschema/r/start_server_variables.result index 6ed93360d9b..f7f44904660 100644 --- a/mysql-test/suite/perfschema/r/start_server_variables.result +++ b/mysql-test/suite/perfschema/r/start_server_variables.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 @@ -187,7 +187,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 diff --git a/mysql-test/suite/perfschema/r/statement_program_lost_inst.result b/mysql-test/suite/perfschema/r/statement_program_lost_inst.result index 1723c35da2c..264be0ede45 100644 --- a/mysql-test/suite/perfschema/r/statement_program_lost_inst.result +++ b/mysql-test/suite/perfschema/r/statement_program_lost_inst.result @@ -140,7 +140,7 @@ performance_schema_max_table_handles 1000 performance_schema_max_table_instances 500 performance_schema_max_table_lock_stat 500 performance_schema_max_thread_classes 50 -performance_schema_max_thread_instances 200 +performance_schema_max_thread_instances 400 performance_schema_session_connect_attrs_size 2048 performance_schema_setup_actors_size 100 performance_schema_setup_objects_size 100 From 504925c416e50e78275ae75a7c8ffdb4255b1ab1 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 19 Feb 2024 15:12:16 +1100 Subject: [PATCH 073/313] MDEV-33434 spider direct sql: Check length before memcpy similar to MDEV-30981 --- .../spider/bugfix/r/mdev_33434.result | 12 ++ .../spider/bugfix/t/mdev_33434.test | 15 +++ storage/spider/spd_direct_sql.cc | 115 +++++++----------- 3 files changed, 74 insertions(+), 68 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_33434.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_33434.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33434.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33434.result new file mode 100644 index 00000000000..2cbcff38752 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33434.result @@ -0,0 +1,12 @@ +# +# MDEV-33434 MDEV-33434 UBSAN null pointer passed as argument 2, which is declared to never be null in spider_udf_direct_sql_create_conn +# +INSTALL SONAME 'ha_spider'; +SET character_set_connection=ucs2; +SELECT SPIDER_DIRECT_SQL('SELECT SLEEP(1)', '', 'srv "dummy", port "3307"'); +ERROR HY000: Unable to connect to foreign data source: localhost +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown +# +# end of test mdev_33434 +# diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33434.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33434.test new file mode 100644 index 00000000000..dd9f882f42e --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33434.test @@ -0,0 +1,15 @@ +--echo # +--echo # MDEV-33434 MDEV-33434 UBSAN null pointer passed as argument 2, which is declared to never be null in spider_udf_direct_sql_create_conn +--echo # + +INSTALL SONAME 'ha_spider'; +SET character_set_connection=ucs2; +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +SELECT SPIDER_DIRECT_SQL('SELECT SLEEP(1)', '', 'srv "dummy", port "3307"'); +--disable_query_log +--source ../../include/clean_up_spider.inc +--enable_query_log + +--echo # +--echo # end of test mdev_33434 +--echo # diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 6639fcee79c..c0c37581865 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -387,6 +387,23 @@ int spider_udf_direct_sql_create_conn_key( DBUG_RETURN(0); } +static inline void spider_maybe_memcpy_string( + char **dest, + char *src, + char *tmp, + uint *dest_len, + uint src_len) +{ + *dest_len= src_len; + if (src_len) + { + *dest= tmp; + memcpy(*dest, src, src_len); + } else + *dest= NULL; +} + + SPIDER_CONN *spider_udf_direct_sql_create_conn( const SPIDER_DIRECT_SQL *direct_sql, int *error_num @@ -469,74 +486,36 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( { #endif conn->tgt_port = direct_sql->tgt_port; - conn->tgt_socket_length = direct_sql->tgt_socket_length; - conn->tgt_socket = tmp_socket; - memcpy(conn->tgt_socket, direct_sql->tgt_socket, - direct_sql->tgt_socket_length); - conn->tgt_username_length = direct_sql->tgt_username_length; - conn->tgt_username = tmp_username; - memcpy(conn->tgt_username, direct_sql->tgt_username, - direct_sql->tgt_username_length); - conn->tgt_password_length = direct_sql->tgt_password_length; - conn->tgt_password = tmp_password; - memcpy(conn->tgt_password, direct_sql->tgt_password, - direct_sql->tgt_password_length); - conn->tgt_ssl_ca_length = direct_sql->tgt_ssl_ca_length; - if (conn->tgt_ssl_ca_length) - { - conn->tgt_ssl_ca = tmp_ssl_ca; - memcpy(conn->tgt_ssl_ca, direct_sql->tgt_ssl_ca, - direct_sql->tgt_ssl_ca_length); - } else - conn->tgt_ssl_ca = NULL; - conn->tgt_ssl_capath_length = direct_sql->tgt_ssl_capath_length; - if (conn->tgt_ssl_capath_length) - { - conn->tgt_ssl_capath = tmp_ssl_capath; - memcpy(conn->tgt_ssl_capath, direct_sql->tgt_ssl_capath, - direct_sql->tgt_ssl_capath_length); - } else - conn->tgt_ssl_capath = NULL; - conn->tgt_ssl_cert_length = direct_sql->tgt_ssl_cert_length; - if (conn->tgt_ssl_cert_length) - { - conn->tgt_ssl_cert = tmp_ssl_cert; - memcpy(conn->tgt_ssl_cert, direct_sql->tgt_ssl_cert, - direct_sql->tgt_ssl_cert_length); - } else - conn->tgt_ssl_cert = NULL; - conn->tgt_ssl_cipher_length = direct_sql->tgt_ssl_cipher_length; - if (conn->tgt_ssl_cipher_length) - { - conn->tgt_ssl_cipher = tmp_ssl_cipher; - memcpy(conn->tgt_ssl_cipher, direct_sql->tgt_ssl_cipher, - direct_sql->tgt_ssl_cipher_length); - } else - conn->tgt_ssl_cipher = NULL; - conn->tgt_ssl_key_length = direct_sql->tgt_ssl_key_length; - if (conn->tgt_ssl_key_length) - { - conn->tgt_ssl_key = tmp_ssl_key; - memcpy(conn->tgt_ssl_key, direct_sql->tgt_ssl_key, - direct_sql->tgt_ssl_key_length); - } else - conn->tgt_ssl_key = NULL; - conn->tgt_default_file_length = direct_sql->tgt_default_file_length; - if (conn->tgt_default_file_length) - { - conn->tgt_default_file = tmp_default_file; - memcpy(conn->tgt_default_file, direct_sql->tgt_default_file, - direct_sql->tgt_default_file_length); - } else - conn->tgt_default_file = NULL; - conn->tgt_default_group_length = direct_sql->tgt_default_group_length; - if (conn->tgt_default_group_length) - { - conn->tgt_default_group = tmp_default_group; - memcpy(conn->tgt_default_group, direct_sql->tgt_default_group, - direct_sql->tgt_default_group_length); - } else - conn->tgt_default_group = NULL; + spider_maybe_memcpy_string( + &conn->tgt_socket, direct_sql->tgt_socket, tmp_socket, + &conn->tgt_socket_length, direct_sql->tgt_socket_length); + spider_maybe_memcpy_string( + &conn->tgt_username, direct_sql->tgt_username, tmp_username, + &conn->tgt_username_length, direct_sql->tgt_username_length); + spider_maybe_memcpy_string( + &conn->tgt_password, direct_sql->tgt_password, tmp_password, + &conn->tgt_password_length, direct_sql->tgt_password_length); + spider_maybe_memcpy_string( + &conn->tgt_ssl_ca, direct_sql->tgt_ssl_ca, tmp_ssl_ca, + &conn->tgt_ssl_ca_length, direct_sql->tgt_ssl_ca_length); + spider_maybe_memcpy_string( + &conn->tgt_ssl_capath, direct_sql->tgt_ssl_capath, tmp_ssl_capath, + &conn->tgt_ssl_capath_length, direct_sql->tgt_ssl_capath_length); + spider_maybe_memcpy_string( + &conn->tgt_ssl_cert, direct_sql->tgt_ssl_cert, tmp_ssl_cert, + &conn->tgt_ssl_cert_length, direct_sql->tgt_ssl_cert_length); + spider_maybe_memcpy_string( + &conn->tgt_ssl_cipher, direct_sql->tgt_ssl_cipher, tmp_ssl_cipher, + &conn->tgt_ssl_cipher_length, direct_sql->tgt_ssl_cipher_length); + spider_maybe_memcpy_string( + &conn->tgt_ssl_key, direct_sql->tgt_ssl_key, tmp_ssl_key, + &conn->tgt_ssl_key_length, direct_sql->tgt_ssl_key_length); + spider_maybe_memcpy_string( + &conn->tgt_default_file, direct_sql->tgt_default_file, tmp_default_file, + &conn->tgt_default_file_length, direct_sql->tgt_default_file_length); + spider_maybe_memcpy_string( + &conn->tgt_default_group, direct_sql->tgt_default_group, tmp_default_group, + &conn->tgt_default_group_length, direct_sql->tgt_default_group_length); conn->tgt_ssl_vsc = direct_sql->tgt_ssl_vsc; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) } else { From 11fe2ee0af6d27cae17a85fc3874b27550cef3b7 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 21 Feb 2024 14:17:34 +1100 Subject: [PATCH 074/313] MDEV-33493 Spider: Make a symlink result file a normal file --- .../r/udf_mysql_func_early_init_file.result | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) mode change 120000 => 100644 storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result diff --git a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result deleted file mode 120000 index 045ddc4372c..00000000000 --- a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result +++ /dev/null @@ -1 +0,0 @@ -udf_mysql_func_early.result \ No newline at end of file diff --git a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result new file mode 100644 index 00000000000..b84f60a67fb --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result @@ -0,0 +1,43 @@ +# +# Test that udf created by inserting into mysql_func works as expected +# +CREATE SERVER s_1 FOREIGN DATA WRAPPER mysql OPTIONS ( +HOST 'localhost', +DATABASE 'auto_test_local', +USER 'root', +PASSWORD '', +SOCKET '$MASTER_1_MYSOCK' + ); +CREATE SERVER s_2_1 FOREIGN DATA WRAPPER mysql OPTIONS ( +HOST 'localhost', +DATABASE 'auto_test_remote', +USER 'root', +PASSWORD '', +SOCKET '$CHILD2_1_MYSOCK' + ); +connect master_1, localhost, root, , , $MASTER_1_MYPORT, $MASTER_1_MYSOCK; +connect child2_1, localhost, root, , , $CHILD2_1_MYPORT, $CHILD2_1_MYSOCK; +connection child2_1; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +CREATE TABLE tbl_a ( +a INT +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +insert into tbl_a values (42); +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +CREATE TABLE tbl_a ( +a INT +) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"'; +create temporary table results (a int); +SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"'); +SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') +1 +select * from results; +a +42 +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; From 44c88faecaa76ad2368101001f30bcb504ff2c7e Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 20 Mar 2024 10:36:25 +1100 Subject: [PATCH 075/313] MDEV-28992 Spider group by handler: Push down TIMESTAMPDIFF function Also removed ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC. Similar to pr#2225, with the testcase adapted from that patch: --8<---------------cut here---------------start------------->8--- From 884f7c6df16236748ca975339e0b1c267e195309 Mon Sep 17 00:00:00 2001 From: "Norio Akagi (norakagi)" Date: Wed, 3 Aug 2022 23:30:34 -0700 Subject: [PATCH] [MDEV-28992] Push down TIMESTAMP_DIFF in spider This changes so that TIMESTAMP_DIFF function in a query is pushed down and works natively in Spider. Instead of directly accessing item's member, now we can rely on a public accessor method to make it work. Unit tests are added under spider.pushdown_timestamp_diff. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --8<---------------cut here---------------end--------------->8--- --- .../feature/r/pushdown_timestamp_diff.result | 111 ++++++++++++++++++ .../feature/t/pushdown_timestamp_diff.test | 93 +++++++++++++++ storage/spider/spd_db_handlersocket.cc | 6 +- storage/spider/spd_db_mysql.cc | 34 +----- storage/spider/spd_db_oracle.cc | 6 +- 5 files changed, 208 insertions(+), 42 deletions(-) create mode 100644 storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff.result create mode 100644 storage/spider/mysql-test/spider/feature/t/pushdown_timestamp_diff.test diff --git a/storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff.result b/storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff.result new file mode 100644 index 00000000000..3acd89127c0 --- /dev/null +++ b/storage/spider/mysql-test/spider/feature/r/pushdown_timestamp_diff.result @@ -0,0 +1,111 @@ +# +# MDEV-28992 Spider: Push down TIMESTAMPDIFF function +# +for master_1 +for child2 +for child3 +set spider_same_server_link= 1; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +create table t2 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +); +CREATE TABLE t1 ( +a INT, +b CHAR(1), +c DATETIME, +PRIMARY KEY(a) +) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; +INSERT INTO t1 (a, b, c) VALUES +(1, 'a', '2018-11-01 10:21:39'), +(2, 'b', '2015-06-30 23:59:59'), +(3, 'c', '2013-11-01 01:01:01'); +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 +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 +2 b 15 +3 c 13 +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 +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 +2 b 61 +3 c 55 +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 +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 +2 b 185 +3 c 166 +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 +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 +2 b 808 +3 c 721 +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 +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 +2 b 5659 +3 c 5053 +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 +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 +2 b 135839 +3 c 121273 +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 +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 +2 b 8150399 +3 c 7276381 +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 +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 +2 b 489023999 +3 c 436582861 +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 +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 +2 b 489023999000000 +3 c 436582861000000 +drop table t1, t2; +drop server srv; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/feature/t/pushdown_timestamp_diff.test b/storage/spider/mysql-test/spider/feature/t/pushdown_timestamp_diff.test new file mode 100644 index 00000000000..81251860f74 --- /dev/null +++ b/storage/spider/mysql-test/spider/feature/t/pushdown_timestamp_diff.test @@ -0,0 +1,93 @@ +--echo # +--echo # MDEV-28992 Spider: Push down TIMESTAMPDIFF function +--echo # +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +set spider_same_server_link= 1; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); + +create table t2 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +); +CREATE TABLE t1 ( + a INT, + b CHAR(1), + c DATETIME, + PRIMARY KEY(a) +) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; + +INSERT INTO t1 (a, b, c) VALUES + (1, 'a', '2018-11-01 10:21:39'), + (2, 'b', '2015-06-30 23:59:59'), + (3, 'c', '2013-11-01 01:01:01'); + +--echo interval year +let $query= +select a, b, timestampdiff(year, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +--echo interval quarter +let $query= +select a, b, timestampdiff(quarter, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +--echo interval month +let $query= +select a, b, timestampdiff(month, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +--echo interval week +let $query= +select a, b, timestampdiff(week, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +--echo interval day +let $query= +select a, b, timestampdiff(day, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +--echo internal hour +let $query= +select a, b, timestampdiff(hour, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +--echo internal minute +let $query= +select a, b, timestampdiff(minute, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +--echo internal second +let $query= +select a, b, timestampdiff(second, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +--echo internal microsecond +let $query= +select a, b, timestampdiff(microsecond, '2000-01-01 00:00:00', c) from t1; +eval explain $query; +eval $query; + +drop table t1, t2; +drop server srv; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc index 03d8b505bfe..137aa47e3d6 100644 --- a/storage/spider/spd_db_handlersocket.cc +++ b/storage/spider/spd_db_handlersocket.cc @@ -3178,14 +3178,13 @@ int spider_db_handlersocket_util::open_item_func( alias, alias_length, dbton_id, use_fields, fields)); } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) { -#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC Item_func_timestamp_diff *item_func_timestamp_diff = (Item_func_timestamp_diff *) item_func; if (str) { const char *interval_str; uint interval_len; - switch (item_func_timestamp_diff->int_type) + switch (item_func_timestamp_diff->get_int_type()) { case INTERVAL_YEAR: interval_str = SPIDER_SQL_YEAR_STR; @@ -3257,9 +3256,6 @@ int spider_db_handlersocket_util::open_item_func( SPIDER_SQL_CLOSE_PAREN_LEN); } DBUG_RETURN(0); -#else - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); -#endif } } else if (func_name_length == 14) { diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index a7bf14b7fed..68f5821d47e 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -5533,14 +5533,6 @@ int spider_db_mbase_util::open_item_func( alias_length, use_fields, fields)); } -static bool item_func_is_timestampdiff( - const char *func_name, - int func_name_length -) { - return func_name_length == 13 && - !strncasecmp("timestampdiff", func_name, func_name_length); -} - static bool not_func_should_be_skipped( Item_func *item_func ){ @@ -5610,10 +5602,6 @@ int spider_db_mbase_util::check_item_func( Item_func::Functype func_type = item_func->functype(); DBUG_PRINT("info",("spider functype = %d", func_type)); - const char *func_name = (char*) item_func->func_name(); - int func_name_length = strlen(func_name); - DBUG_PRINT("info",("spider func_name = %s", func_name)); - /* The blacklist of the functions that cannot be pushed down */ switch (func_type) { @@ -5628,14 +5616,6 @@ int spider_db_mbase_util::check_item_func( break; case Item_func::FUNC_SP: case Item_func::UDF_FUNC: - /* Notes on merging regarding MDEV-29447: please refer to the - following commits for build error or merge conflicts: - 10.5: d7b564da2a634dcf86798d6b86bd127e7eef9286 - 10.6: 1ed20b993b0dd4e95450cab2e8347e5bf4617a69 - 10.9: dd316b6e20265cfd832bb5585cb4c96e716387c8 - 10.10-11: 3f67f110ba1b23a89c5ede0fbeeb203cf5e164f4 - 11.0-1: 17ba6748afa8834df5658361088e6c8e65aca16f - Please remove this comment after merging. */ use_pushdown_udf= spider_param_use_pushdown_udf( spider->trx->thd, spider->share->use_pushdown_udf); if (!use_pushdown_udf) @@ -5645,12 +5625,6 @@ int spider_db_mbase_util::check_item_func( if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); break; -#ifndef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC - case Item_func::UNKNOWN_FUNC: - if (item_func_is_timestampdiff(func_name, func_name_length)) - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); - break; -#endif default: break; } @@ -6015,12 +5989,11 @@ int spider_db_mbase_util::print_item_func( alias, alias_length, dbton_id, use_fields, fields)); } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) { -#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC Item_func_timestamp_diff *item_func_timestamp_diff = (Item_func_timestamp_diff *) item_func; const char *interval_str; uint interval_len; - switch (item_func_timestamp_diff->int_type) + switch (item_func_timestamp_diff->get_int_type()) { case INTERVAL_YEAR: interval_str = SPIDER_SQL_YEAR_STR; @@ -6071,7 +6044,7 @@ int spider_db_mbase_util::print_item_func( str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN); str->q_append(interval_str, interval_len); str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN); - + if ((error_num = spider_db_print_item_type(item_list[0], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); @@ -6092,9 +6065,6 @@ int spider_db_mbase_util::print_item_func( SPIDER_SQL_CLOSE_PAREN_LEN); } DBUG_RETURN(0); -#else - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); -#endif } } else if (func_name_length == 14) { diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 6d52f3827ea..769aab21c46 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -3424,14 +3424,13 @@ int spider_db_oracle_util::open_item_func( alias, alias_length, dbton_id, use_fields, fields)); } else if (!strncasecmp("timestampdiff", func_name, func_name_length)) { -#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC Item_func_timestamp_diff *item_func_timestamp_diff = (Item_func_timestamp_diff *) item_func; if (str) { const char *interval_str; uint interval_len; - switch (item_func_timestamp_diff->int_type) + switch (item_func_timestamp_diff->get_int_type()) { case INTERVAL_YEAR: interval_str = SPIDER_SQL_YEAR_STR; @@ -3503,9 +3502,6 @@ int spider_db_oracle_util::open_item_func( SPIDER_SQL_CLOSE_PAREN_LEN); } DBUG_RETURN(0); -#else - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); -#endif } } else if (func_name_length == 14) { From 9c93d41ad7b6efcbad38fe19a994a76c1c4b5c32 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 20 Mar 2024 14:03:52 +1100 Subject: [PATCH 076/313] MDEV-33728 spider: remove use of MYSQL_VERSION_ID and MARIADB_BASE_VERSION change created by: unifdef -DMYSQL_VERSION_ID=100400 -DMARIADB_BASE_VERSION -m storage/spider/spd_* storage/spider/ha_spider.* storage/spider/hs_client/* basically MDEV-27637, MDEV-27641, MDEV-27655 --- storage/spider/ha_spider.cc | 162 --------------------- storage/spider/ha_spider.h | 37 ----- storage/spider/hs_client/config.cpp | 5 - storage/spider/hs_client/config.hpp | 5 - storage/spider/hs_client/fatal.cpp | 5 - storage/spider/hs_client/fatal.hpp | 5 - storage/spider/hs_client/hs_compat.h | 12 -- storage/spider/hs_client/hstcpcli.cpp | 5 - storage/spider/hs_client/hstcpcli.hpp | 5 - storage/spider/hs_client/socket.cpp | 7 - storage/spider/hs_client/socket.hpp | 5 - storage/spider/hs_client/string_util.cpp | 5 - storage/spider/spd_conn.cc | 102 ------------- storage/spider/spd_copy_tables.cc | 39 ----- storage/spider/spd_db_conn.cc | 70 --------- storage/spider/spd_db_handlersocket.cc | 21 --- storage/spider/spd_db_include.cc | 5 - storage/spider/spd_db_include.h | 24 --- storage/spider/spd_db_mysql.cc | 63 -------- storage/spider/spd_db_oracle.cc | 25 ---- storage/spider/spd_direct_sql.cc | 59 -------- storage/spider/spd_environ.h | 12 -- storage/spider/spd_group_by_handler.cc | 5 - storage/spider/spd_i_s.cc | 9 -- storage/spider/spd_include.h | 114 --------------- storage/spider/spd_malloc.cc | 5 - storage/spider/spd_param.cc | 130 ----------------- storage/spider/spd_param.h | 3 - storage/spider/spd_ping_table.cc | 61 -------- storage/spider/spd_sys_table.cc | 177 ----------------------- storage/spider/spd_sys_table.h | 19 --- storage/spider/spd_table.cc | 176 ---------------------- storage/spider/spd_trx.cc | 64 -------- 33 files changed, 1441 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 90dd37b78aa..b0671cb6f1a 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -22,10 +22,6 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" @@ -33,7 +29,6 @@ #ifdef HANDLER_HAS_DIRECT_AGGREGATE #include "sql_select.h" #endif -#endif #include "ha_partition.h" #include "spd_param.h" #include "spd_err.h" @@ -48,15 +43,9 @@ #include "spd_ping_table.h" #include "spd_malloc.h" -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 #define SPIDER_CAN_BG_SEARCH (1LL << 37) #define SPIDER_CAN_BG_INSERT (1LL << 38) #define SPIDER_CAN_BG_UPDATE (1LL << 39) -#else -#define SPIDER_CAN_BG_SEARCH (LL(1) << 37) -#define SPIDER_CAN_BG_INSERT (LL(1) << 38) -#define SPIDER_CAN_BG_UPDATE (LL(1) << 39) -#endif extern handlerton *spider_hton_ptr; extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; @@ -1253,9 +1242,6 @@ int ha_spider::external_lock( DBUG_ENTER("ha_spider::external_lock"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider lock_type=%x", lock_type)); -#if MYSQL_VERSION_ID < 50500 - DBUG_PRINT("info",("spider thd->options=%x", (int) thd->options)); -#endif #ifdef HANDLER_HAS_NEED_INFO_FOR_AUTO_INC info_auto_called = FALSE; #endif @@ -1943,14 +1929,11 @@ int ha_spider::extra( if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num))) DBUG_RETURN(error_num); break; -#if MYSQL_VERSION_ID < 50500 -#else case HA_EXTRA_ADD_CHILDREN_LIST: DBUG_PRINT("info",("spider HA_EXTRA_ADD_CHILDREN_LIST")); if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num))) DBUG_RETURN(error_num); break; -#endif #if defined(HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN) || defined(HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF) #ifdef HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN case HA_EXTRA_STARTING_ORDERED_INDEX_SCAN: @@ -4430,7 +4413,6 @@ bool ha_spider::check_no_where_cond() } #ifdef HA_MRR_USE_DEFAULT_IMPL -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 ha_rows ha_spider::multi_range_read_info_const( uint keyno, RANGE_SEQ_IF *seq, @@ -4440,17 +4422,6 @@ ha_rows ha_spider::multi_range_read_info_const( uint *flags, Cost_estimate *cost ) -#else -ha_rows ha_spider::multi_range_read_info_const( - uint keyno, - RANGE_SEQ_IF *seq, - void *seq_init_param, - uint n_ranges, - uint *bufsz, - uint *flags, - COST_VECT *cost -) -#endif { DBUG_ENTER("ha_spider::multi_range_read_info_const"); DBUG_PRINT("info",("spider this=%p", this)); @@ -4494,7 +4465,6 @@ ha_rows ha_spider::multi_range_read_info_const( DBUG_RETURN(rows); } -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 ha_rows ha_spider::multi_range_read_info( uint keyno, uint n_ranges, @@ -4504,17 +4474,6 @@ ha_rows ha_spider::multi_range_read_info( uint *flags, Cost_estimate *cost ) -#else -ha_rows ha_spider::multi_range_read_info( - uint keyno, - uint n_ranges, - uint keys, - uint key_parts, - uint *bufsz, - uint *flags, - COST_VECT *cost -) -#endif { DBUG_ENTER("ha_spider::multi_range_read_info"); DBUG_PRINT("info",("spider this=%p", this)); @@ -4586,16 +4545,10 @@ int ha_spider::multi_range_read_init( #endif #ifdef HA_MRR_USE_DEFAULT_IMPL -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 int ha_spider::multi_range_read_next_first( range_id_t *range_info ) #else -int ha_spider::multi_range_read_next_first( - char **range_info -) -#endif -#else int ha_spider::read_multi_range_first_internal( uchar *buf, KEY_MULTI_RANGE **found_range_p, @@ -5081,19 +5034,11 @@ int ha_spider::read_multi_range_first_internal( DBUG_PRINT("info",("spider free multi_range_keys=%p", multi_range_keys)); spider_free(spider_current_trx, multi_range_keys, MYF(0)); } -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 if (!(multi_range_keys = (range_id_t *) spider_malloc(spider_current_trx, SPD_MID_HA_SPIDER_MULTI_RANGE_READ_NEXT_FIRST_1, sizeof(range_id_t) * (multi_range_num < result_list.multi_split_read ? multi_range_num : result_list.multi_split_read), MYF(MY_WME))) ) -#else - if (!(multi_range_keys = (char **) - spider_malloc(spider_current_trx, SPD_MID_HA_SPIDER_MULTI_RANGE_READ_NEXT_FIRST_2, sizeof(char *) * - (multi_range_num < result_list.multi_split_read ? - multi_range_num : result_list.multi_split_read), MYF(MY_WME))) - ) -#endif DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_PRINT("info",("spider alloc multi_range_keys=%p", multi_range_keys)); if (!mrr_key_buff) @@ -5311,11 +5256,7 @@ int ha_spider::read_multi_range_first_internal( } #ifdef HA_MRR_USE_DEFAULT_IMPL -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 multi_range_keys[multi_range_cnt] = mrr_cur_range.ptr; -#else - multi_range_keys[multi_range_cnt] = (char *) mrr_cur_range.ptr; -#endif #endif if (bka_mode == 2) { @@ -5438,11 +5379,7 @@ int ha_spider::read_multi_range_first_internal( { #ifdef HA_MRR_USE_DEFAULT_IMPL DBUG_PRINT("info",("spider range_res7=%d", range_res)); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 multi_range_keys[multi_range_cnt] = mrr_cur_range.ptr; -#else - multi_range_keys[multi_range_cnt] = (char *) mrr_cur_range.ptr; -#endif #endif if ((error_num = spider_db_append_select(this))) DBUG_RETURN(error_num); @@ -5986,15 +5923,9 @@ int ha_spider::pre_multi_range_read_next( DBUG_RETURN(0); } -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 int ha_spider::multi_range_read_next( range_id_t *range_info ) -#else -int ha_spider::multi_range_read_next( - char **range_info -) -#endif { int error_num; DBUG_ENTER("ha_spider::multi_range_read_next"); @@ -6072,16 +6003,10 @@ int ha_spider::read_multi_range_first( #endif #ifdef HA_MRR_USE_DEFAULT_IMPL -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 int ha_spider::multi_range_read_next_next( range_id_t *range_info ) #else -int ha_spider::multi_range_read_next_next( - char **range_info -) -#endif -#else int ha_spider::read_multi_range_next( KEY_MULTI_RANGE **found_range_p ) @@ -6797,11 +6722,7 @@ int ha_spider::read_multi_range_next( } #ifdef HA_MRR_USE_DEFAULT_IMPL -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 multi_range_keys[multi_range_cnt] = mrr_cur_range.ptr; -#else - multi_range_keys[multi_range_cnt] = (char *) mrr_cur_range.ptr; -#endif #endif if (bka_mode == 2) { @@ -6922,11 +6843,7 @@ int ha_spider::read_multi_range_next( #endif { #ifdef HA_MRR_USE_DEFAULT_IMPL -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 multi_range_keys[multi_range_cnt] = mrr_cur_range.ptr; -#else - multi_range_keys[multi_range_cnt] = (char *) mrr_cur_range.ptr; -#endif #endif if ((error_num = spider_db_append_select(this))) DBUG_RETURN(error_num); @@ -9952,29 +9869,15 @@ int ha_spider::write_row( bulk_access_pre_called = FALSE; DBUG_RETURN(spider_db_bulk_bulk_insert(this)); } -#if MYSQL_VERSION_ID < 50500 - option_backup = thd->options; - thd->options &= ~OPTION_BIN_LOG; -#else option_backup = thd->variables.option_bits; thd->variables.option_bits &= ~OPTION_BIN_LOG; -#endif error_num = bulk_access_link_exec_tgt->spider->ha_write_row(buf); -#if MYSQL_VERSION_ID < 50500 - thd->options = option_backup; -#else thd->variables.option_bits = option_backup; -#endif DBUG_RETURN(error_num); } #endif #ifndef SPIDER_WITHOUT_HA_STATISTIC_INCREMENT ha_statistic_increment(&SSV::ha_write_count); -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 -#else - if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) - table->timestamp_field->set_time(); #endif if (!bulk_insert) store_last_insert_id = 0; @@ -10069,21 +9972,12 @@ int ha_spider::pre_write_row( THD *thd = trx->thd; DBUG_ENTER("ha_spider::pre_write_row"); DBUG_PRINT("info",("spider this=%p", this)); -#if MYSQL_VERSION_ID < 50500 - option_backup = thd->options; - thd->options &= ~OPTION_BIN_LOG; -#else option_backup = thd->variables.option_bits; thd->variables.option_bits &= ~OPTION_BIN_LOG; -#endif error_num = bulk_access_link_current->spider->ha_write_row(buf); bulk_access_link_current->spider->bulk_access_pre_called = TRUE; bulk_access_link_current->called = TRUE; -#if MYSQL_VERSION_ID < 50500 - thd->options = option_backup; -#else thd->variables.option_bits = option_backup; -#endif DBUG_RETURN(error_num); } #endif @@ -10206,20 +10100,11 @@ int ha_spider::update_row( bulk_access_link_exec_tgt->called ) { ulonglong option_backup = 0; -#if MYSQL_VERSION_ID < 50500 - option_backup = thd->options; - thd->options &= ~OPTION_BIN_LOG; -#else option_backup = thd->variables.option_bits; thd->variables.option_bits &= ~OPTION_BIN_LOG; -#endif error_num = bulk_access_link_exec_tgt->spider->ha_update_row( old_data, new_data); -#if MYSQL_VERSION_ID < 50500 - thd->options = option_backup; -#else thd->variables.option_bits = option_backup; -#endif DBUG_RETURN(error_num); } #endif @@ -10228,11 +10113,6 @@ int ha_spider::update_row( #endif #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS do_direct_update = FALSE; -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 -#else - if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) - table->timestamp_field->set_time(); #endif if ((error_num = spider_db_update(this, table, old_data))) DBUG_RETURN(check_error_mode(error_num)); @@ -10349,14 +10229,10 @@ int ha_spider::direct_update_rows_init( direct_update_fields ) { if ( -#if MYSQL_VERSION_ID < 50500 - !thd->variables.engine_condition_pushdown || -#else #ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #else !(thd->variables.optimizer_switch & OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || -#endif #endif !select_lex || select_lex->table_list.elements != 1 || @@ -10516,14 +10392,10 @@ int ha_spider::direct_update_rows_init() if (direct_update_fields) { if ( -#if MYSQL_VERSION_ID < 50500 - !thd->variables.engine_condition_pushdown || -#else #ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #else !(thd->variables.optimizer_switch & OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || -#endif #endif !select_lex || select_lex->table_list.elements != 1 || @@ -10843,19 +10715,10 @@ int ha_spider::delete_row( bulk_access_link_exec_tgt->called ) { ulonglong option_backup = 0; -#if MYSQL_VERSION_ID < 50500 - option_backup = thd->options; - thd->options &= ~OPTION_BIN_LOG; -#else option_backup = thd->variables.option_bits; thd->variables.option_bits &= ~OPTION_BIN_LOG; -#endif error_num = bulk_access_link_exec_tgt->spider->ha_delete_row(buf); -#if MYSQL_VERSION_ID < 50500 - thd->options = option_backup; -#else thd->variables.option_bits = option_backup; -#endif DBUG_RETURN(error_num); } #endif @@ -10920,14 +10783,10 @@ int ha_spider::direct_delete_rows_init( if (!range_count) { if ( -#if MYSQL_VERSION_ID < 50500 - !thd->variables.engine_condition_pushdown || -#else #ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #else !(thd->variables.optimizer_switch & OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || -#endif #endif !select_lex || select_lex->table_list.elements != 1 || @@ -11020,14 +10879,10 @@ int ha_spider::direct_delete_rows_init() cond_check = FALSE; spider_get_select_limit(this, &select_lex, &select_limit, &offset_limit); if ( -#if MYSQL_VERSION_ID < 50500 - !thd->variables.engine_condition_pushdown || -#else #ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #else !(thd->variables.optimizer_switch & OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || -#endif #endif !select_lex || select_lex->table_list.elements != 1 || @@ -11441,11 +11296,7 @@ int ha_spider::create( uint sql_command = thd_sql_command(thd), roop_count; SPIDER_TRX *trx; TABLE *table_tables = NULL; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif bool need_lock = FALSE; DBUG_ENTER("ha_spider::create"); DBUG_PRINT("info",("spider this=%p", this)); @@ -11686,11 +11537,7 @@ int ha_spider::rename_table( TABLE *table_tables = NULL; SPIDER_ALTER_TABLE *alter_table_from, *alter_table_to; SPIDER_LGTM_TBLHND_SHARE *from_lgtm_tblhnd_share, *to_lgtm_tblhnd_share; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif bool need_lock = FALSE; DBUG_ENTER("ha_spider::rename_table"); DBUG_PRINT("info",("spider this=%p", this)); @@ -11914,11 +11761,7 @@ int ha_spider::delete_table( TABLE *table_tables = NULL; uint sql_command = thd_sql_command(thd); SPIDER_ALTER_TABLE *alter_table; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif bool need_lock = FALSE; DBUG_ENTER("ha_spider::delete_table"); DBUG_PRINT("info",("spider this=%p", this)); @@ -15854,13 +15697,8 @@ int ha_spider::bulk_tmp_table_rnd_next() if (tmp_table[roop_count]) { if ( -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 !(error_num = tmp_table[roop_count]->file->ha_rnd_next( tmp_table[roop_count]->record[0])) -#else - !(error_num = tmp_table[roop_count]->file->rnd_next( - tmp_table[roop_count]->record[0])) -#endif ) { DBUG_RETURN(error_num); } diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index 543b92629da..f5a597b88a7 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -147,11 +147,7 @@ public: bool have_second_range; KEY_MULTI_RANGE mrr_second_range; spider_string *mrr_key_buff; -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 range_id_t *multi_range_keys; -#else - char **multi_range_keys; -#endif #else KEY_MULTI_RANGE *multi_range_ranges; #endif @@ -357,7 +353,6 @@ public: void reset_no_where_cond(); bool check_no_where_cond(); #ifdef HA_MRR_USE_DEFAULT_IMPL -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 ha_rows multi_range_read_info_const( uint keyno, RANGE_SEQ_IF *seq, @@ -376,26 +371,6 @@ public: uint *flags, Cost_estimate *cost ); -#else - ha_rows multi_range_read_info_const( - uint keyno, - RANGE_SEQ_IF *seq, - void *seq_init_param, - uint n_ranges, - uint *bufsz, - uint *flags, - COST_VECT *cost - ); - ha_rows multi_range_read_info( - uint keyno, - uint n_ranges, - uint keys, - uint key_parts, - uint *bufsz, - uint *flags, - COST_VECT *cost - ); -#endif int multi_range_read_init( RANGE_SEQ_IF *seq, void *seq_init_param, @@ -403,7 +378,6 @@ public: uint mode, HANDLER_BUFFER *buf ); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 int multi_range_read_next( range_id_t *range_info ); @@ -413,17 +387,6 @@ public: int multi_range_read_next_next( range_id_t *range_info ); -#else - int multi_range_read_next( - char **range_info - ); - int multi_range_read_next_first( - char **range_info - ); - int multi_range_read_next_next( - char **range_info - ); -#endif #else int read_multi_range_first( KEY_MULTI_RANGE **found_range_p, diff --git a/storage/spider/hs_client/config.cpp b/storage/spider/hs_client/config.cpp index d2759e37d8f..9c6f936b8a8 100644 --- a/storage/spider/hs_client/config.cpp +++ b/storage/spider/hs_client/config.cpp @@ -9,13 +9,8 @@ #include #include "mysql_version.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" -#endif #include "config.hpp" diff --git a/storage/spider/hs_client/config.hpp b/storage/spider/hs_client/config.hpp index 2880f2f5a33..a3a986cc1fd 100644 --- a/storage/spider/hs_client/config.hpp +++ b/storage/spider/hs_client/config.hpp @@ -11,14 +11,9 @@ #define DENA_CONFIG_HPP #include "mysql_version.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" -#endif #define DENA_VERBOSE(lv, x) if (dena::verbose_level >= (lv)) { (x); } diff --git a/storage/spider/hs_client/fatal.cpp b/storage/spider/hs_client/fatal.cpp index cfbc14df64a..1ed20189a93 100644 --- a/storage/spider/hs_client/fatal.cpp +++ b/storage/spider/hs_client/fatal.cpp @@ -9,13 +9,8 @@ #include #include "mysql_version.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" -#endif #include "fatal.hpp" diff --git a/storage/spider/hs_client/fatal.hpp b/storage/spider/hs_client/fatal.hpp index 38fc149e98e..859b695baf3 100644 --- a/storage/spider/hs_client/fatal.hpp +++ b/storage/spider/hs_client/fatal.hpp @@ -11,14 +11,9 @@ #define DENA_FATAL_HPP #include "mysql_version.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" -#endif namespace dena { diff --git a/storage/spider/hs_client/hs_compat.h b/storage/spider/hs_client/hs_compat.h index 8505d7978b7..e466dee67a7 100644 --- a/storage/spider/hs_client/hs_compat.h +++ b/storage/spider/hs_client/hs_compat.h @@ -16,21 +16,9 @@ #ifndef HS_COMPAT_H #define HS_COMPAT_H -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100213 #define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ my_init_dynamic_array2(A, B, C, D, E, F) #define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ init_alloc_root(A, "spider", B, C, D) -#elif defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 -#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ - my_init_dynamic_array2(A, B, C, D, E, F) -#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ - init_alloc_root(A, B, C, D) -#else -#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ - my_init_dynamic_array2(A, B, C, D, E) -#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ - init_alloc_root(A, B, C) -#endif #endif diff --git a/storage/spider/hs_client/hstcpcli.cpp b/storage/spider/hs_client/hstcpcli.cpp index 4c93b5a3a49..791ee9a9e4c 100644 --- a/storage/spider/hs_client/hstcpcli.cpp +++ b/storage/spider/hs_client/hstcpcli.cpp @@ -10,14 +10,9 @@ #include #include "mysql_version.h" #include "hs_compat.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" -#endif #include "hstcpcli.hpp" #include "auto_file.hpp" diff --git a/storage/spider/hs_client/hstcpcli.hpp b/storage/spider/hs_client/hstcpcli.hpp index aac02ce7f46..06044f169a3 100644 --- a/storage/spider/hs_client/hstcpcli.hpp +++ b/storage/spider/hs_client/hstcpcli.hpp @@ -13,13 +13,8 @@ #define HANDLERSOCKET_MYSQL_UTIL 1 #include "mysql_version.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" -#endif #include "config.hpp" #include "socket.hpp" diff --git a/storage/spider/hs_client/socket.cpp b/storage/spider/hs_client/socket.cpp index 45b8100e64c..469acb2725f 100644 --- a/storage/spider/hs_client/socket.cpp +++ b/storage/spider/hs_client/socket.cpp @@ -16,16 +16,9 @@ #include "mysql_version.h" #include "hs_compat.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 #include -#endif #include "sql_priv.h" #include "probes_mysql.h" -#endif #include "socket.hpp" #include "string_util.hpp" diff --git a/storage/spider/hs_client/socket.hpp b/storage/spider/hs_client/socket.hpp index a3e6527a46d..e4f7530aec9 100644 --- a/storage/spider/hs_client/socket.hpp +++ b/storage/spider/hs_client/socket.hpp @@ -11,13 +11,8 @@ #define DENA_SOCKET_HPP #include "mysql_version.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" -#endif #include "auto_addrinfo.hpp" #include "auto_file.hpp" diff --git a/storage/spider/hs_client/string_util.cpp b/storage/spider/hs_client/string_util.cpp index 39934148cb8..647cf877805 100644 --- a/storage/spider/hs_client/string_util.cpp +++ b/storage/spider/hs_client/string_util.cpp @@ -10,13 +10,8 @@ #include #include "mysql_version.h" #include "hs_compat.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" -#endif #include "string_util.hpp" diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index ba8a579b1ac..be9b27d83ad 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -18,16 +18,11 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "sql_partition.h" #include "tztime.h" -#endif #include "spd_err.h" #include "spd_param.h" #include "spd_db_include.h" @@ -733,12 +728,8 @@ SPIDER_CONN *spider_create_conn( else conn->need_mon = need_mon; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_mta_conn_mutex_init; @@ -1883,43 +1874,27 @@ int spider_create_conn_thread( DBUG_ENTER("spider_create_conn_thread"); if (conn && !conn->bg_init) { -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&conn->bg_conn_chain_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_bg_conn_chain, &conn->bg_conn_chain_mutex, MY_MUTEX_INIT_FAST)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_chain_mutex_init; } conn->bg_conn_chain_mutex_ptr = NULL; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&conn->bg_conn_sync_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_bg_conn_sync, &conn->bg_conn_sync_mutex, MY_MUTEX_INIT_FAST)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_sync_mutex_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&conn->bg_conn_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_bg_conn, &conn->bg_conn_mutex, MY_MUTEX_INIT_FAST)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_mutex_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&conn->bg_job_stack_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_bg_job_stack, &conn->bg_job_stack_mutex, MY_MUTEX_INIT_FAST)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_job_stack_mutex_init; @@ -1936,36 +1911,22 @@ int spider_create_conn_thread( conn->bg_job_stack.max_element * conn->bg_job_stack.size_of_element); conn->bg_job_stack_cur_pos = 0; -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&conn->bg_conn_sync_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_conn_sync, &conn->bg_conn_sync_cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_sync_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&conn->bg_conn_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_conn, &conn->bg_conn_cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_cond_init; } pthread_mutex_lock(&conn->bg_conn_mutex); -#if MYSQL_VERSION_ID < 50500 - if (pthread_create(&conn->bg_thread, &spider_pt_attr, - spider_bg_conn_action, (void *) conn) - ) -#else if (mysql_thread_create(spd_key_thd_bg, &conn->bg_thread, &spider_pt_attr, spider_bg_conn_action, (void *) conn) ) -#endif { pthread_mutex_unlock(&conn->bg_conn_mutex); error_num = HA_ERR_OUT_OF_MEM; @@ -2936,35 +2897,21 @@ int spider_create_sts_thread( DBUG_ENTER("spider_create_sts_thread"); if (!share->bg_sts_init) { -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&share->bg_sts_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_sts, &share->bg_sts_cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&share->bg_sts_sync_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_sts_sync, &share->bg_sts_sync_cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_sync_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_create(&share->bg_sts_thread, &spider_pt_attr, - spider_bg_sts_action, (void *) share) - ) -#else if (mysql_thread_create(spd_key_thd_bg_sts, &share->bg_sts_thread, &spider_pt_attr, spider_bg_sts_action, (void *) share) ) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_thread_create; @@ -3301,35 +3248,21 @@ int spider_create_crd_thread( DBUG_ENTER("spider_create_crd_thread"); if (!share->bg_crd_init) { -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&share->bg_crd_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_crd, &share->bg_crd_cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&share->bg_crd_sync_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_crd_sync, &share->bg_crd_sync_cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_sync_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_create(&share->bg_crd_thread, &spider_pt_attr, - spider_bg_crd_action, (void *) share) - ) -#else if (mysql_thread_create(spd_key_thd_bg_crd, &share->bg_crd_thread, &spider_pt_attr, spider_bg_crd_action, (void *) share) ) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_thread_create; @@ -3743,13 +3676,8 @@ int spider_create_mon_threads( { if ( share->monitoring_bg_kind[roop_count] && -#if MYSQL_VERSION_ID < 50500 - pthread_mutex_init(&share->bg_mon_mutexes[roop_count], - MY_MUTEX_INIT_FAST) -#else mysql_mutex_init(spd_key_mutex_bg_mon, &share->bg_mon_mutexes[roop_count], MY_MUTEX_INIT_FAST) -#endif ) { error_num = HA_ERR_OUT_OF_MEM; my_afree(buf); @@ -3761,12 +3689,8 @@ int spider_create_mon_threads( { if ( share->monitoring_bg_kind[roop_count] && -#if MYSQL_VERSION_ID < 50500 - pthread_cond_init(&share->bg_mon_conds[roop_count], NULL) -#else mysql_cond_init(spd_key_cond_bg_mon, &share->bg_mon_conds[roop_count], NULL) -#endif ) { error_num = HA_ERR_OUT_OF_MEM; my_afree(buf); @@ -3778,12 +3702,8 @@ int spider_create_mon_threads( { if ( share->monitoring_bg_kind[roop_count] && -#if MYSQL_VERSION_ID < 50500 - pthread_cond_init(&share->bg_mon_sleep_conds[roop_count], NULL) -#else mysql_cond_init(spd_key_cond_bg_mon_sleep, &share->bg_mon_sleep_conds[roop_count], NULL) -#endif ) { error_num = HA_ERR_OUT_OF_MEM; my_afree(buf); @@ -3798,16 +3718,10 @@ int spider_create_mon_threads( { link_pack.link_idx = roop_count; pthread_mutex_lock(&share->bg_mon_mutexes[roop_count]); -#if MYSQL_VERSION_ID < 50500 - if (pthread_create(&share->bg_mon_threads[roop_count], - &spider_pt_attr, spider_bg_mon_action, (void *) &link_pack) - ) -#else if (mysql_thread_create(spd_key_thd_bg_mon, &share->bg_mon_threads[roop_count], &spider_pt_attr, spider_bg_mon_action, (void *) &link_pack) ) -#endif { error_num = HA_ERR_OUT_OF_MEM; my_afree(buf); @@ -4061,17 +3975,9 @@ int spider_conn_first_link_idx( my_afree(link_idxs); DBUG_RETURN(-1); } -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 DBUG_PRINT("info",("spider server_id=%lu", thd->variables.server_id)); -#else - DBUG_PRINT("info",("spider server_id=%u", thd->server_id)); -#endif DBUG_PRINT("info",("spider thread_id=%lu", thd_get_thread_id(thd))); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 rand_val = spider_rand(thd->variables.server_id + thd_get_thread_id(thd)); -#else - rand_val = spider_rand(thd->server_id + thd_get_thread_id(thd)); -#endif DBUG_PRINT("info",("spider rand_val=%f", rand_val)); balance_val = (longlong) (rand_val * balance_total); DBUG_PRINT("info",("spider balance_val=%lld", balance_val)); @@ -4597,21 +4503,13 @@ SPIDER_IP_PORT_CONN* spider_create_ipport_conn(SPIDER_CONN *conn) goto err_return_direct; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&ret->mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_conn_i, &ret->mutex, MY_MUTEX_INIT_FAST)) -#endif { //error goto err_malloc_key; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&ret->cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_conn_i, &ret->cond, NULL)) -#endif { pthread_mutex_destroy(&ret->mutex); goto err_malloc_key; diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index d205cd244ca..a63d63ca430 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -17,17 +17,12 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "sql_base.h" #include "sql_partition.h" #include "transaction.h" -#endif #include "spd_err.h" #include "spd_param.h" #include "spd_db_include.h" @@ -250,11 +245,7 @@ int spider_udf_get_copy_tgt_tables( ) { int error_num, roop_count; TABLE *table_tables = NULL; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif char table_key[MAX_KEY_LENGTH]; SPIDER_COPY_TABLE_CONN *table_conn = NULL, *src_table_conn_prev = NULL, *dst_table_conn_prev = NULL; @@ -744,13 +735,8 @@ long long spider_copy_tables_body( thd->handler_tables_hash.records != 0 || thd->derived_tables != 0 || thd->lock != 0 || -#if MYSQL_VERSION_ID < 50500 - thd->locked_tables != 0 || - thd->prelocked_mode != NON_PRELOCKED -#else thd->locked_tables_list.locked_tables() || thd->locked_tables_mode != LTM_NONE -#endif ) { if (thd->open_tables != 0) { @@ -773,18 +759,6 @@ long long spider_copy_tables_body( my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), "thd->lock", thd->lock); -#if MYSQL_VERSION_ID < 50500 - } else if (thd->locked_tables != 0) - { - my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, - ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), - "thd->locked_tables", thd->locked_tables); - } else if (thd->prelocked_mode != NON_PRELOCKED) - { - my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, - ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), - "thd->prelocked_mode", (longlong) thd->prelocked_mode); -#else } else if (thd->locked_tables_list.locked_tables()) { my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, @@ -796,7 +770,6 @@ long long spider_copy_tables_body( my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), "thd->locked_tables_mode", (longlong) thd->locked_tables_mode); -#endif } goto error; } @@ -888,9 +861,6 @@ long long spider_copy_tables_body( copy_tables->trx->trx_start = TRUE; copy_tables->trx->updated_in_this_trx = FALSE; DBUG_PRINT("info",("spider trx->updated_in_this_trx=FALSE")); -#if MYSQL_VERSION_ID < 50500 - if (open_and_lock_tables(thd, table_list)) -#else table_list->mdl_request.init( MDL_key::TABLE, SPIDER_TABLE_LIST_db_str(table_list), @@ -899,7 +869,6 @@ long long spider_copy_tables_body( MDL_TRANSACTION ); if (open_and_lock_tables(thd, table_list, FALSE, 0)) -#endif { thd->m_reprepare_observer = reprepare_observer_backup; copy_tables->trx->trx_start = FALSE; @@ -1099,11 +1068,7 @@ long long spider_copy_tables_body( if (table_list->table) { -#if MYSQL_VERSION_ID < 50500 - ha_autocommit_or_rollback(thd, 0); -#else (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd)); -#endif close_thread_tables(thd); } if (spider) @@ -1149,11 +1114,7 @@ error: } if (table_list && table_list->table) { -#if MYSQL_VERSION_ID < 50500 - ha_autocommit_or_rollback(thd, 0); -#else (thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd)); -#endif close_thread_tables(thd); } if (spider) diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 52fde02ad0c..40dc15a2149 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -18,10 +18,6 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" @@ -33,7 +29,6 @@ #ifdef HANDLER_HAS_DIRECT_AGGREGATE #include "sql_select.h" #endif -#endif #include "sql_common.h" #include #include "spd_err.h" @@ -1930,10 +1925,8 @@ int spider_db_append_key_where_internal( DBUG_PRINT("info", ("spider start_key->flag=%d", start_key->flag)); switch (start_key->flag) { -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 case HA_READ_PREFIX_LAST: result_list->desc_flg = TRUE; -#endif /* fall through */ case HA_READ_KEY_EXACT: if (sql_kind == SPIDER_SQL_KIND_SQL) @@ -2169,12 +2162,6 @@ int spider_db_append_key_where_internal( } #endif break; -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 -#else - case HA_READ_PREFIX_LAST: - result_list->limit_num = 1; - /* fall through */ -#endif case HA_READ_KEY_OR_PREV: case HA_READ_PREFIX_LAST_OR_PREV: result_list->desc_flg = TRUE; @@ -3016,13 +3003,8 @@ int spider_db_get_row_from_tmp_tbl( current->result_tmp_tbl_inited = 1; } if ( -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 (error_num = current->result_tmp_tbl->file->ha_rnd_next( current->result_tmp_tbl->record[0])) -#else - (error_num = current->result_tmp_tbl->file->rnd_next( - current->result_tmp_tbl->record[0])) -#endif ) { DBUG_RETURN(error_num); } @@ -3050,13 +3032,8 @@ int spider_db_get_row_from_tmp_tbl_pos( result->result_tmp_tbl_inited = 2; } if ( -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 (error_num = tmp_tbl->file->ha_rnd_pos(tmp_tbl->record[0], (uchar *) &pos->tmp_tbl_pos)) -#else - (error_num = tmp_tbl->file->rnd_pos(tmp_tbl->record[0], - (uchar *) &pos->tmp_tbl_pos)) -#endif ) { DBUG_RETURN(error_num); } @@ -6573,11 +6550,7 @@ int spider_db_update_auto_increment( if ( table->s->next_number_keypart == 0 && mysql_bin_log.is_open() && -#if MYSQL_VERSION_ID < 50500 - !thd->current_stmt_binlog_row_based -#else !thd->is_current_stmt_binlog_format_row() -#endif ) { if ( spider->check_partitioned() && @@ -6606,11 +6579,7 @@ int spider_db_update_auto_increment( if ( table->s->next_number_keypart == 0 && mysql_bin_log.is_open() && -#if MYSQL_VERSION_ID < 50500 - !thd->current_stmt_binlog_row_based -#else !thd->is_current_stmt_binlog_format_row() -#endif ) { for (roop_count = 0; roop_count < (int) affected_rows; roop_count++) push_warning_printf(thd, SPIDER_WARN_LEVEL_NOTE, @@ -6849,9 +6818,7 @@ int spider_db_update( ) { conn = spider->conns[roop_count]; spider_db_handler *dbton_hdl = spider->dbton_handler[conn->dbton_id]; -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 conn->ignore_dup_key = spider->ignore_dup_key; -#endif pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); if ((error_num = dbton_hdl->set_sql_for_exec( SPIDER_SQL_TYPE_UPDATE_SQL, roop_count))) @@ -8980,11 +8947,7 @@ int spider_db_print_item_type_default( { if (spider->share->access_charset->cset == system_charset_info->cset) { -#if MYSQL_VERSION_ID < 50500 - item->print(str->get_str(), QT_IS); -#else item->print(str->get_str(), QT_TO_SYSTEM_CHARSET); -#endif } else { item->print(str->get_str(), QT_ORDINARY); } @@ -10155,13 +10118,8 @@ int spider_db_udf_direct_sql( spider_param_ping_interval_at_trx_start(thd); time_t tmp_time = (time_t) time((time_t*) 0); bool need_trx_end, need_all_commit, insert_start = FALSE; -#if MYSQL_VERSION_ID < 50500 -#else enum_sql_command sql_command_backup; -#endif DBUG_ENTER("spider_db_udf_direct_sql"); -#if MYSQL_VERSION_ID < 50500 -#else if (direct_sql->real_table_used) { if (spider_sys_open_tables(c_thd, &direct_sql->table_list_first, @@ -10180,7 +10138,6 @@ int spider_db_udf_direct_sql( direct_sql->open_tables_thd = c_thd; roop_count = 0; } -#endif if (c_thd != thd) { @@ -10188,21 +10145,15 @@ int spider_db_udf_direct_sql( need_trx_end = TRUE; } else { need_all_commit = FALSE; -#if MYSQL_VERSION_ID < 50500 -#else if (direct_sql->real_table_used) { need_trx_end = TRUE; } else { -#endif if (c_thd->transaction.stmt.ha_list) need_trx_end = FALSE; else need_trx_end = TRUE; -#if MYSQL_VERSION_ID < 50500 -#else } -#endif } if (!conn->disable_reconnect) @@ -10222,11 +10173,8 @@ int spider_db_udf_direct_sql( DBUG_RETURN(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM); } -#if MYSQL_VERSION_ID < 50500 -#else sql_command_backup = c_thd->lex->sql_command; c_thd->lex->sql_command = SQLCOM_INSERT; -#endif pthread_mutex_assert_not_owner(&conn->mta_conn_mutex); pthread_mutex_lock(&conn->mta_conn_mutex); @@ -10252,10 +10200,7 @@ int spider_db_udf_direct_sql( if ((error_num = conn->db_conn->append_sql( direct_sql->sql, direct_sql->sql_length, &request_key))) { -#if MYSQL_VERSION_ID < 50500 -#else c_thd->lex->sql_command = sql_command_backup; -#endif DBUG_RETURN(error_num); } } @@ -10329,9 +10274,6 @@ int spider_db_udf_direct_sql( for (; roop_count2 < set_off; roop_count2++) bitmap_clear_bit(table->write_set, (uint) roop_count2); -#if MYSQL_VERSION_ID < 50500 - if (table->file->has_transactions()) -#endif { THR_LOCK_DATA *to[2]; table->file->store_lock(table->in_use, to, @@ -10342,8 +10284,6 @@ int spider_db_udf_direct_sql( table->file->print_error(error_num, MYF(0)); break; } -#if MYSQL_VERSION_ID < 50500 -#else if ( table->s->tmp_table == NO_TMP_TABLE && table->pos_in_table_list @@ -10365,7 +10305,6 @@ int spider_db_udf_direct_sql( next_tables = next_tables->next_global; } } -#endif } if (direct_sql->iop) @@ -10427,13 +10366,8 @@ int spider_db_udf_direct_sql( else if (direct_sql->iop[roop_count] == 2) table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); } -#if MYSQL_VERSION_ID < 50500 - if (table->file->has_transactions()) -#endif { table->file->ha_external_lock(table->in_use, F_UNLCK); -#if MYSQL_VERSION_ID < 50500 -#else if ( table->s->tmp_table == NO_TMP_TABLE && table->pos_in_table_list @@ -10449,7 +10383,6 @@ int spider_db_udf_direct_sql( next_tables = next_tables->next_global; } } -#endif } table->file->ha_reset(); table->in_use = thd; @@ -10512,10 +10445,7 @@ int spider_db_udf_direct_sql( } } } -#if MYSQL_VERSION_ID < 50500 -#else c_thd->lex->sql_command = sql_command_backup; -#endif DBUG_RETURN(error_num); } diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc index 137aa47e3d6..5d04fa8084d 100644 --- a/storage/spider/spd_db_handlersocket.cc +++ b/storage/spider/spd_db_handlersocket.cc @@ -17,14 +17,9 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_analyse.h" -#endif #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) #include "spd_err.h" @@ -3297,11 +3292,7 @@ int spider_db_handlersocket_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); } -#if MYSQL_VERSION_ID < 50500 - item_func->print(tmp_str.get_str(), QT_IS); -#else item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); -#endif tmp_str.mem_calc(); if (tmp_str.reserve(1)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3431,11 +3422,7 @@ int spider_db_handlersocket_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); } -#if MYSQL_VERSION_ID < 50500 - item_func->print(tmp_str.get_str(), QT_IS); -#else item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); -#endif tmp_str.mem_calc(); if (tmp_str.reserve(1)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3585,11 +3572,7 @@ int spider_db_handlersocket_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); } -#if MYSQL_VERSION_ID < 50500 - item_func->print(tmp_str.get_str(), QT_IS); -#else item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); -#endif tmp_str.mem_calc(); if (tmp_str.reserve(1)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3720,11 +3703,7 @@ int spider_db_handlersocket_util::open_item_func( last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; -#ifdef MARIADB_BASE_VERSION case Item_func::XOR_FUNC: -#else - case Item_func::COND_XOR_FUNC: -#endif if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); DBUG_RETURN( diff --git a/storage/spider/spd_db_include.cc b/storage/spider/spd_db_include.cc index 7f600142187..7363564aa04 100644 --- a/storage/spider/spd_db_include.cc +++ b/storage/spider/spd_db_include.cc @@ -17,14 +17,9 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" -#endif #include "sql_common.h" #include #include diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 5add9fac3e4..20bd82e48da 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -23,56 +23,32 @@ #define SPIDER_DB_WRAPPER_MYSQL "mysql" #define SPIDER_DB_WRAPPER_MARIADB "mariadb" -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100204 #define PLUGIN_VAR_CAN_MEMALLOC /* #define ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC #define HASH_UPDATE_WITH_HASH_VALUE */ -#else -#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS -#define HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS -#endif -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 #define SPIDER_HAS_DISCOVER_TABLE_STRUCTURE #define SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE #define SPIDER_HAS_SHOW_SIMPLE_FUNC #define SPIDER_HAS_JT_HASH_INDEX_MERGE #define SPIDER_HAS_EXPR_CACHE_ITEM -#else -#define SPIDER_NEED_CHECK_CONDITION_AT_CHECKING_DIRECT_ORDER_LIMIT -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100007 #define SPIDER_ITEM_HAS_CMP_TYPE -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100004 #define SPIDER_HAS_TIME_STATUS #define SPIDER_HAS_DECIMAL_OPERATION_RESULTS_VALUE_TYPE -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100014 #define SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100 #define SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR -#endif -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100108 #define SPIDER_HAS_GROUP_BY_HANDLER -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100200 #define SPIDER_ORDER_HAS_ENUM_ORDER -#endif -#if defined(MARIADB_BASE_VERSION) #define SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR #define SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR -#endif class spider_db_conn; typedef spider_db_conn SPIDER_DB_CONN; diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 68f5821d47e..c239baf636d 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -17,10 +17,6 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" @@ -31,7 +27,6 @@ #ifdef HANDLER_HAS_DIRECT_AGGREGATE #include "sql_select.h" #endif -#endif #include "sql_common.h" #include #include @@ -811,11 +806,7 @@ int spider_db_mbase_result::fetch_table_status( int error_num; MYSQL_ROW mysql_row; MYSQL_TIME mysql_time; -#ifdef MARIADB_BASE_VERSION uint not_used_uint; -#else - my_bool not_used_my_bool; -#endif #ifdef SPIDER_HAS_TIME_STATUS MYSQL_TIME_STATUS time_status; #else @@ -893,13 +884,8 @@ int spider_db_mbase_result::fetch_table_status( #endif SPIDER_str_to_datetime(mysql_row[11], strlen(mysql_row[11]), &mysql_time, 0, &time_status); -#ifdef MARIADB_BASE_VERSION stat.create_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); -#else - stat.create_time = (time_t) my_system_gmt_sec(&mysql_time, - ¬_used_long, ¬_used_my_bool); -#endif } else stat.create_time = (time_t) 0; #ifdef DBUG_TRACE @@ -918,13 +904,8 @@ int spider_db_mbase_result::fetch_table_status( #endif SPIDER_str_to_datetime(mysql_row[12], strlen(mysql_row[12]), &mysql_time, 0, &time_status); -#ifdef MARIADB_BASE_VERSION stat.update_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); -#else - stat.update_time = (time_t) my_system_gmt_sec(&mysql_time, - ¬_used_long, ¬_used_my_bool); -#endif } else stat.update_time = (time_t) 0; #ifndef DBUG_OFF @@ -943,13 +924,8 @@ int spider_db_mbase_result::fetch_table_status( #endif SPIDER_str_to_datetime(mysql_row[13], strlen(mysql_row[13]), &mysql_time, 0, &time_status); -#ifdef MARIADB_BASE_VERSION stat.check_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); -#else - stat.check_time = (time_t) my_system_gmt_sec(&mysql_time, - ¬_used_long, ¬_used_my_bool); -#endif } else stat.check_time = (time_t) 0; #ifdef DBUG_TRACE @@ -1022,13 +998,8 @@ int spider_db_mbase_result::fetch_table_status( #endif SPIDER_str_to_datetime(mysql_row[6], strlen(mysql_row[6]), &mysql_time, 0, &time_status); -#ifdef MARIADB_BASE_VERSION stat.create_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); -#else - stat.create_time = (time_t) my_system_gmt_sec(&mysql_time, - ¬_used_long, ¬_used_my_bool); -#endif } else stat.create_time = (time_t) 0; #ifdef DBUG_TRACE @@ -1047,13 +1018,8 @@ int spider_db_mbase_result::fetch_table_status( #endif SPIDER_str_to_datetime(mysql_row[7], strlen(mysql_row[7]), &mysql_time, 0, &time_status); -#ifdef MARIADB_BASE_VERSION stat.update_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); -#else - stat.update_time = (time_t) my_system_gmt_sec(&mysql_time, - ¬_used_long, ¬_used_my_bool); -#endif } else stat.update_time = (time_t) 0; #ifdef DBUG_TRACE @@ -1072,13 +1038,8 @@ int spider_db_mbase_result::fetch_table_status( #endif SPIDER_str_to_datetime(mysql_row[8], strlen(mysql_row[8]), &mysql_time, 0, &time_status); -#ifdef MARIADB_BASE_VERSION stat.check_time = (time_t) my_system_gmt_sec(&mysql_time, ¬_used_long, ¬_used_uint); -#else - stat.check_time = (time_t) my_system_gmt_sec(&mysql_time, - ¬_used_long, ¬_used_my_bool); -#endif } else stat.check_time = (time_t) 0; #ifdef DBUG_TRACE @@ -2391,11 +2352,7 @@ int spider_db_mbase::next_result() strmov(db_conn->net.sqlstate, "00000"); db_conn->affected_rows = ~(my_ulonglong) 0; -#if MYSQL_VERSION_ID < 50500 - if (db_conn->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) -#else if (db_conn->server_status & SERVER_MORE_RESULTS_EXISTS) -#endif { if ((status = db_conn->methods->read_query_result(db_conn)) > 0) DBUG_RETURN(spider_db_errorno(conn)); @@ -2409,11 +2366,7 @@ uint spider_db_mbase::affected_rows() MYSQL *last_used_con; DBUG_ENTER("spider_db_mbase::affected_rows"); DBUG_PRINT("info",("spider this=%p", this)); -#if MYSQL_VERSION_ID < 50500 - last_used_con = db_conn->last_used_con; -#else last_used_con = db_conn; -#endif DBUG_RETURN((uint) last_used_con->affected_rows); } @@ -2422,11 +2375,7 @@ uint spider_db_mbase::matched_rows() MYSQL *last_used_con; DBUG_ENTER("spider_db_mysql::matched_rows"); DBUG_PRINT("info", ("spider this=%p", this)); -#if MYSQL_VERSION_ID < 50500 - last_used_con = db_conn->last_used_con; -#else last_used_con = db_conn; -#endif /* Rows matched: 65 Changed: 65 Warnings: 0 */ const char *info = last_used_con->info; if (!info) @@ -2451,11 +2400,7 @@ bool spider_db_mbase::inserted_info( { DBUG_RETURN(TRUE); } -#if MYSQL_VERSION_ID < 50500 - last_used_con = db_conn->last_used_con; -#else last_used_con = db_conn; -#endif /* Records: 10 Duplicates: 4 Warnings: 0 */ const char *info = last_used_con->info; if (!info) @@ -2497,11 +2442,7 @@ ulonglong spider_db_mbase::last_insert_id() MYSQL *last_used_con; DBUG_ENTER("spider_db_mbase::last_insert_id"); DBUG_PRINT("info",("spider this=%p", this)); -#if MYSQL_VERSION_ID < 50500 - last_used_con = db_conn->last_used_con; -#else last_used_con = db_conn; -#endif DBUG_RETURN((uint) last_used_con->insert_id); } @@ -12891,11 +12832,7 @@ int spider_mbase_handler::bulk_tmp_table_rnd_next() int error_num; DBUG_ENTER("spider_mbase_handler::bulk_tmp_table_rnd_next"); DBUG_PRINT("info",("spider this=%p", this)); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 error_num = upd_tmp_tbl->file->ha_rnd_next(upd_tmp_tbl->record[0]); -#else - error_num = upd_tmp_tbl->file->rnd_next(upd_tmp_tbl->record[0]); -#endif if (!error_num) { error_num = restore_sql_from_bulk_tmp_table(&insert_sql, upd_tmp_tbl); diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc index 769aab21c46..b15bda5e77d 100644 --- a/storage/spider/spd_db_oracle.cc +++ b/storage/spider/spd_db_oracle.cc @@ -17,10 +17,6 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_partition.h" @@ -28,7 +24,6 @@ #ifdef HANDLER_HAS_DIRECT_AGGREGATE #include "sql_select.h" #endif -#endif #ifdef HAVE_ORACLE_OCI #if (defined(WIN32) || defined(_WIN32) || defined(WINDOWS) || defined(_WINDOWS)) @@ -3543,11 +3538,7 @@ int spider_db_oracle_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); } -#if MYSQL_VERSION_ID < 50500 - item_func->print(tmp_str.get_str(), QT_IS); -#else item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); -#endif tmp_str.mem_calc(); if (tmp_str.reserve(1)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3677,11 +3668,7 @@ int spider_db_oracle_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); } -#if MYSQL_VERSION_ID < 50500 - item_func->print(tmp_str.get_str(), QT_IS); -#else item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); -#endif tmp_str.mem_calc(); if (tmp_str.reserve(1)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -3967,11 +3954,7 @@ int spider_db_oracle_util::open_item_func( DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_CAST_STR, SPIDER_SQL_CAST_LEN); } -#if MYSQL_VERSION_ID < 50500 - item_func->print(tmp_str.get_str(), QT_IS); -#else item_func->print(tmp_str.get_str(), QT_TO_SYSTEM_CHARSET); -#endif tmp_str.mem_calc(); if (tmp_str.reserve(1)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -4102,11 +4085,7 @@ int spider_db_oracle_util::open_item_func( last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; -#ifdef MARIADB_BASE_VERSION case Item_func::XOR_FUNC: -#else - case Item_func::COND_XOR_FUNC: -#endif if (str) str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN); DBUG_RETURN( @@ -10446,11 +10425,7 @@ int spider_oracle_handler::bulk_tmp_table_rnd_next() int error_num; DBUG_ENTER("spider_oracle_handler::bulk_tmp_table_rnd_next"); DBUG_PRINT("info",("spider this=%p", this)); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 error_num = upd_tmp_tbl->file->ha_rnd_next(upd_tmp_tbl->record[0]); -#else - error_num = upd_tmp_tbl->file->rnd_next(upd_tmp_tbl->record[0]); -#endif if (!error_num) { error_num = restore_sql_from_bulk_tmp_table(&insert_sql, upd_tmp_tbl); diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index c0c37581865..d23b7053840 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -17,10 +17,6 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" @@ -28,7 +24,6 @@ #include "sql_base.h" #include "sql_servers.h" #include "tztime.h" -#endif #include "spd_err.h" #include "spd_param.h" #include "spd_db_include.h" @@ -43,9 +38,7 @@ #include "spd_udf.h" #include "spd_malloc.h" -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100004 #define SPIDER_NEED_INIT_ONE_TABLE_FOR_FIND_TEMPORARY_TABLE -#endif extern const char **spd_defaults_extra_file; extern const char **spd_defaults_file; @@ -114,21 +107,6 @@ int spider_udf_direct_sql_create_table_list( } else break; } -#if MYSQL_VERSION_ID < 50500 - if (!(direct_sql->db_names = (char**) - spider_bulk_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_TABLE_LIST_1, MYF(MY_WME | MY_ZEROFILL), - &direct_sql->db_names, sizeof(char*) * table_count, - &direct_sql->table_names, sizeof(char*) * table_count, - &direct_sql->tables, sizeof(TABLE*) * table_count, - &tmp_name_ptr, sizeof(char) * ( - table_name_list_length + - thd->db_length * table_count + - 2 * table_count - ), - &direct_sql->iop, sizeof(int) * table_count, - NullS)) - ) -#else if (!(direct_sql->db_names = (char**) spider_bulk_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_TABLE_LIST_2, MYF(MY_WME | MY_ZEROFILL), &direct_sql->db_names, sizeof(char*) * table_count, @@ -144,7 +122,6 @@ int spider_udf_direct_sql_create_table_list( &direct_sql->real_table_bitmap, sizeof(uchar) * ((table_count + 7) / 8), NullS)) ) -#endif DBUG_RETURN(HA_ERR_OUT_OF_MEM); tmp_ptr = table_name_list; @@ -561,12 +538,8 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( } #endif -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_mta_conn, &conn->mta_conn_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_mta_conn_mutex_init; @@ -1061,10 +1034,7 @@ static void spider_minus_1(SPIDER_DIRECT_SQL *direct_sql) #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) direct_sql->access_mode = -1; #endif -#if MYSQL_VERSION_ID < 50500 -#else direct_sql->use_real_table = -1; -#endif direct_sql->error_rw_mode = -1; for (int i = 0; i < direct_sql->table_count; i++) direct_sql->iop[i] = -1; @@ -1132,10 +1102,7 @@ int spider_udf_parse_direct_sql_param( SPIDER_PARAM_STR("srv", server_name); SPIDER_PARAM_INT_WITH_MAX("svc", tgt_ssl_vsc, 0, 1); SPIDER_PARAM_INT_WITH_MAX("tlm", table_loop_mode, 0, 2); -#if MYSQL_VERSION_ID < 50500 -#else SPIDER_PARAM_INT_WITH_MAX("urt", use_real_table, 0, 1); -#endif SPIDER_PARAM_INT("wto", net_write_timeout, 0); error_num= parse.fail(true); goto error; @@ -1186,10 +1153,7 @@ int spider_udf_parse_direct_sql_param( error_num= parse.fail(true); goto error; case 14: -#if MYSQL_VERSION_ID < 50500 -#else SPIDER_PARAM_INT_WITH_MAX("use_real_table", use_real_table, 0, 1); -#endif error_num= parse.fail(true); goto error; case 15: @@ -1394,14 +1358,11 @@ void spider_udf_free_direct_sql_alloc( pthread_mutex_unlock(direct_sql->bg_mutex); } #endif -#if MYSQL_VERSION_ID < 50500 -#else if (direct_sql->real_table_used && direct_sql->open_tables_thd) { spider_sys_close_table(direct_sql->open_tables_thd, &direct_sql->open_tables_backup); } -#endif if (direct_sql->server_name) { spider_free(spider_current_trx, direct_sql->server_name, MYF(0)); @@ -1485,11 +1446,8 @@ long long spider_direct_sql_body( char *sql; TABLE_LIST table_list; SPIDER_BG_DIRECT_SQL *bg_direct_sql; -#if MYSQL_VERSION_ID < 50500 -#else TABLE_LIST *real_table_list_last = NULL; uint use_real_table = 0; -#endif DBUG_ENTER("spider_direct_sql_body"); SPIDER_BACKUP_DASTATUS; if (!(direct_sql = (SPIDER_DIRECT_SQL *) @@ -1580,11 +1538,8 @@ long long spider_direct_sql_body( #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) } #endif -#if MYSQL_VERSION_ID < 50500 -#else use_real_table = spider_param_udf_ds_use_real_table(thd, direct_sql->use_real_table); -#endif for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++) { #ifdef SPIDER_NEED_INIT_ONE_TABLE_FOR_FIND_TEMPORARY_TABLE @@ -1615,19 +1570,14 @@ long long spider_direct_sql_body( if (!(direct_sql->tables[roop_count] = spider_find_temporary_table(thd, &table_list))) { -#if MYSQL_VERSION_ID < 50500 -#else if (!use_real_table) { -#endif error_num = ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM; my_printf_error(ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM, ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_STR, MYF(0), SPIDER_TABLE_LIST_db_str(&table_list), SPIDER_TABLE_LIST_table_name_str(&table_list)); goto error; -#if MYSQL_VERSION_ID < 50500 -#else } TABLE_LIST *tables = &direct_sql->table_list[roop_count]; tables->mdl_request.init(MDL_key::TABLE, @@ -1643,7 +1593,6 @@ long long spider_direct_sql_body( real_table_list_last = tables; spider_set_bit(direct_sql->real_table_bitmap, roop_count); direct_sql->real_table_used = TRUE; -#endif } } if ((error_num = spider_udf_direct_sql_create_conn_key(direct_sql))) @@ -1760,22 +1709,14 @@ my_bool spider_direct_sql_init_body( strcpy(message, "spider_bg_direct_sql() out of memory"); goto error; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&bg_direct_sql->bg_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_bg_direct_sql, &bg_direct_sql->bg_mutex, MY_MUTEX_INIT_FAST)) -#endif { strcpy(message, "spider_bg_direct_sql() out of memory"); goto error_mutex_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&bg_direct_sql->bg_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_direct_sql, &bg_direct_sql->bg_cond, NULL)) -#endif { strcpy(message, "spider_bg_direct_sql() out of memory"); goto error_cond_init; diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 728cc7e1781..5a6b824fd30 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -19,16 +19,11 @@ #ifndef SPD_ENVIRON_INCLUDED -#if (defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000) #define SPIDER_HANDLER_START_BULK_INSERT_HAS_FLAGS -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100 #define SPIDER_SUPPORT_CREATE_OR_REPLACE_TABLE #define SPIDER_NET_HAS_THD -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100211 #define HANDLER_HAS_TOP_TABLE_FIELDS #define HANDLER_HAS_DIRECT_UPDATE_ROWS #define HANDLER_HAS_DIRECT_AGGREGATE @@ -37,20 +32,13 @@ #define HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC #define HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100300 #define SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100309 #define SPIDER_MDEV_16246 -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100400 #define SPIDER_USE_CONST_ITEM_FOR_STRING_INT_REAL_DECIMAL_DATE_ITEM #define SPIDER_SQL_CACHE_IS_IN_LEX #define SPIDER_LIKE_FUNC_HAS_GET_NEGATED #define HA_HAS_CHECKSUM_EXTENDED -#endif #endif /* SPD_ENVIRON_INCLUDED */ diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 2985c9f1302..167f8c3adff 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -17,17 +17,12 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "sql_partition.h" #include "sql_select.h" #include "ha_partition.h" -#endif #include "sql_common.h" #include #include "spd_err.h" diff --git a/storage/spider/spd_i_s.cc b/storage/spider/spd_i_s.cc index c43c666601f..c4d66f01fb6 100644 --- a/storage/spider/spd_i_s.cc +++ b/storage/spider/spd_i_s.cc @@ -17,16 +17,11 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "sql_partition.h" #include "sql_show.h" -#endif #include "spd_db_include.h" #include "spd_include.h" #include "spd_table.h" @@ -144,12 +139,9 @@ struct st_mysql_plugin spider_i_s_alloc_mem = NULL, NULL, NULL, -#if MYSQL_VERSION_ID >= 50600 0, -#endif }; -#ifdef MARIADB_BASE_VERSION struct st_maria_plugin spider_i_s_alloc_mem_maria = { MYSQL_INFORMATION_SCHEMA_PLUGIN, @@ -166,4 +158,3 @@ struct st_maria_plugin spider_i_s_alloc_mem_maria = "1.0", MariaDB_PLUGIN_MATURITY_STABLE, }; -#endif diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 51fac2a4cea..76844b6b428 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -17,11 +17,6 @@ #define SPIDER_DETAIL_VERSION "3.3.15" #define SPIDER_HEX_VERSION 0x0303 -#if MYSQL_VERSION_ID < 50500 -#define spider_my_free(A,B) my_free(A,B) -#define pthread_mutex_assert_owner(A) -#define pthread_mutex_assert_not_owner(A) -#else #define spider_my_free(A,B) my_free(A) #ifdef pthread_mutex_t #undef pthread_mutex_t @@ -70,129 +65,50 @@ #endif #define pthread_cond_destroy mysql_cond_destroy #define my_sprintf(A,B) sprintf B -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100004 #define spider_stmt_da_message(A) thd_get_error_message(A) #define spider_stmt_da_sql_errno(A) thd_get_error_number(A) #define spider_user_defined_key_parts(A) (A)->user_defined_key_parts #define spider_join_table_count(A) (A)->table_count #define SPIDER_CAN_BG_UPDATE (1LL << 39) -#if MYSQL_VERSION_ID >= 100304 #define SPIDER_ALTER_PARTITION_ADD ALTER_PARTITION_ADD #define SPIDER_ALTER_PARTITION_DROP ALTER_PARTITION_DROP #define SPIDER_ALTER_PARTITION_COALESCE ALTER_PARTITION_COALESCE #define SPIDER_ALTER_PARTITION_REORGANIZE ALTER_PARTITION_REORGANIZE #define SPIDER_ALTER_PARTITION_TABLE_REORG ALTER_PARTITION_TABLE_REORG #define SPIDER_ALTER_PARTITION_REBUILD ALTER_PARTITION_REBUILD -#else -#define SPIDER_ALTER_PARTITION_ADD Alter_info::ALTER_ADD_PARTITION -#define SPIDER_ALTER_PARTITION_DROP Alter_info::ALTER_DROP_PARTITION -#define SPIDER_ALTER_PARTITION_COALESCE Alter_info::ALTER_COALESCE_PARTITION -#define SPIDER_ALTER_PARTITION_REORGANIZE Alter_info::ALTER_REORGANIZE_PARTITION -#define SPIDER_ALTER_PARTITION_TABLE_REORG Alter_info::ALTER_TABLE_REORG -#define SPIDER_ALTER_PARTITION_REBUILD Alter_info::ALTER_REBUILD_PARTITION -#endif #define SPIDER_WARN_LEVEL_WARN Sql_condition::WARN_LEVEL_WARN #define SPIDER_WARN_LEVEL_NOTE Sql_condition::WARN_LEVEL_NOTE #define SPIDER_THD_KILL_CONNECTION KILL_CONNECTION -#else -#if MYSQL_VERSION_ID < 50500 -#define spider_stmt_da_message(A) (A)->main_da.message() -#define spider_stmt_da_sql_errno(A) (A)->main_da.sql_errno() -#else -#if MYSQL_VERSION_ID < 50600 -#define spider_stmt_da_message(A) (A)->stmt_da->message() -#define spider_stmt_da_sql_errno(A) (A)->stmt_da->sql_errno() -#else -#define spider_stmt_da_message(A) (A)->get_stmt_da()->message() -#define spider_stmt_da_sql_errno(A) (A)->get_stmt_da()->sql_errno() -#endif -#endif -#define spider_user_defined_key_parts(A) (A)->key_parts -#define spider_join_table_count(A) (A)->tables -#define SPIDER_ALTER_PARTITION_ADD ALTER_ADD_PARTITION -#define SPIDER_ALTER_PARTITION_DROP ALTER_DROP_PARTITION -#define SPIDER_ALTER_PARTITION_COALESCE ALTER_COALESCE_PARTITION -#define SPIDER_ALTER_PARTITION_REORGANIZE ALTER_REORGANIZE_PARTITION -#define SPIDER_ALTER_PARTITION_TABLE_REORG ALTER_TABLE_REORG -#define SPIDER_ALTER_PARTITION_REBUILD ALTER_REBUILD_PARTITION -#define SPIDER_WARN_LEVEL_WARN MYSQL_ERROR::WARN_LEVEL_WARN -#define SPIDER_WARN_LEVEL_NOTE MYSQL_ERROR::WARN_LEVEL_NOTE -#define SPIDER_THD_KILL_CONNECTION THD::KILL_CONNECTION -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100005 #define SPIDER_HAS_EXPLAIN_QUERY -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100009 #define SPIDER_TEST(A) MY_TEST(A) -#else -#define SPIDER_TEST(A) test(A) -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100 #define SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR #define SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #define SPIDER_XID_USES_xid_cache_iterate -#else -#define SPIDER_XID_STATE_HAS_in_thd -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100108 #define SPIDER_Item_args_arg_count_IS_PROTECTED -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100112 #define SPIDER_Item_func_conv_charset_conv_charset collation.collation -#else -#define SPIDER_Item_func_conv_charset_conv_charset conv_charset -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100200 #define SPIDER_WITHOUT_HA_STATISTIC_INCREMENT #define SPIDER_init_read_record(A,B,C,D,E,F,G,H) init_read_record(A,B,C,D,E,F,G,H) #define SPIDER_HAS_NEXT_THREAD_ID #define SPIDER_new_THD(A) (new THD(A)) #define SPIDER_order_direction_is_asc(A) (A->direction == ORDER::ORDER_ASC) -#else -#define SPIDER_init_read_record(A,B,C,D,E,F,G,H) init_read_record(A,B,C,D,F,G,H) -#define SPIDER_new_THD(A) (new THD()) -#define SPIDER_order_direction_is_asc(A) (A->asc) -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100201 #define SPIDER_HAS_MY_CHARLEN #define SPIDER_open_temporary_table -#endif -#if defined(MARIADB_BASE_VERSION) -#if MYSQL_VERSION_ID >= 100209 #define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) generate_partition_syntax(A,B,C,E,F,G) -#elif MYSQL_VERSION_ID >= 100200 -#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) generate_partition_syntax(A,B,C,D,E,F,G,H) -#elif MYSQL_VERSION_ID >= 100007 -#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) generate_partition_syntax(B,C,D,E,F,G,H) -#else -#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) generate_partition_syntax(B,C,D,E,F,G) -#endif -#else -#define SPIDER_generate_partition_syntax(A,B,C,D,E,F,G,H) -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100209 #define SPIDER_create_partition_name(A,B,C,D,E,F) create_partition_name(A,B,C,D,E,F) #define SPIDER_create_subpartition_name(A,B,C,D,E,F) create_subpartition_name(A,B,C,D,E,F) #define SPIDER_free_part_syntax(A,B) -#else -#define SPIDER_create_partition_name(A,B,C,D,E,F) create_partition_name(A,C,D,E,F) -#define SPIDER_create_subpartition_name(A,B,C,D,E,F) create_subpartition_name(A,C,D,E,F) -#define SPIDER_free_part_syntax(A,B) spider_my_free(A,B) -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100306 #define SPIDER_read_record_read_record(A) read_record() #define SPIDER_has_Item_with_subquery #define SPIDER_use_LEX_CSTRING_for_KEY_Field_name @@ -211,36 +127,12 @@ #define SPIDER_item_name_str(A) (A)->name.str #define SPIDER_item_name_length(A) (A)->name.length const LEX_CSTRING SPIDER_empty_string = {"", 0}; -#else -#define SPIDER_read_record_read_record(A) read_record(A) -#define SPIDER_THD_db_str(A) (A)->db -#define SPIDER_THD_db_length(A) (A)->db_length -#define SPIDER_TABLE_LIST_db_str(A) (A)->db -#define SPIDER_TABLE_LIST_db_length(A) (A)->db_length -#define SPIDER_TABLE_LIST_table_name_str(A) (A)->table_name -#define SPIDER_TABLE_LIST_table_name_length(A) (A)->table_name_length -#define SPIDER_TABLE_LIST_alias_str(A) (A)->alias -#define SPIDER_TABLE_LIST_alias_length(A) strlen((A)->alias) -#define SPIDER_field_name_str(A) (A)->field_name -#define SPIDER_field_name_length(A) strlen((A)->field_name) -#define SPIDER_item_name_str(A) (A)->name -#define SPIDER_item_name_length(A) strlen((A)->name) -const char SPIDER_empty_string = ""; -#endif -#if MYSQL_VERSION_ID >= 50500 #define SPIDER_HAS_HASH_VALUE_TYPE -#endif -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100400 #define SPIDER_date_mode_t(A) date_mode_t(A) #define SPIDER_str_to_datetime(A,B,C,D,E) str_to_datetime_or_date(A,B,C,D,E) #define SPIDER_get_linkage(A) A->get_linkage() -#else -#define SPIDER_date_mode_t(A) A -#define SPIDER_str_to_datetime(A,B,C,D,E) str_to_datetime(A,B,C,D,E) -#define SPIDER_get_linkage(A) A->linkage -#endif #define spider_bitmap_size(A) ((A + 7) / 8) #define spider_set_bit(BITMAP, BIT) \ @@ -1501,8 +1393,6 @@ typedef struct st_spider_direct_sql TABLE **tables; int *iop; -#if MYSQL_VERSION_ID < 50500 -#else /* for using real table */ bool real_table_used; TABLE_LIST *table_list_first; @@ -1510,7 +1400,6 @@ typedef struct st_spider_direct_sql uchar *real_table_bitmap; Open_tables_backup open_tables_backup; THD *open_tables_thd; -#endif char *sql; ulong sql_length; @@ -1530,10 +1419,7 @@ typedef struct st_spider_direct_sql #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) int access_mode; #endif -#if MYSQL_VERSION_ID < 50500 -#else int use_real_table; -#endif int error_rw_mode; char *server_name; diff --git a/storage/spider/spd_malloc.cc b/storage/spider/spd_malloc.cc index f43131d630d..a4aec9a3712 100644 --- a/storage/spider/spd_malloc.cc +++ b/storage/spider/spd_malloc.cc @@ -18,15 +18,10 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "sql_analyse.h" -#endif #include "spd_db_include.h" #include "spd_include.h" #include "spd_malloc.h" diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index 5c86af68c0a..ce87afbdee7 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -38,15 +38,10 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "sql_partition.h" -#endif #include #include "spd_err.h" #include "spd_db_include.h" @@ -56,9 +51,7 @@ #include "spd_trx.h" extern struct st_mysql_plugin spider_i_s_alloc_mem; -#ifdef MARIADB_BASE_VERSION extern struct st_maria_plugin spider_i_s_alloc_mem_maria; -#endif extern volatile ulonglong spider_mon_table_cache_version; extern volatile ulonglong spider_mon_table_cache_version_req; @@ -231,13 +224,8 @@ struct st_mysql_show_var spider_status_variables[] = }; typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_int_t, int); -#if MYSQL_VERSION_ID < 50500 -extern bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd, - const char *name, long long val); -#else extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed, bool is_unsignd, longlong v); -#endif static my_bool spider_support_xa; static MYSQL_SYSVAR_BOOL( @@ -700,14 +688,9 @@ static int spider_param_semi_table_lock_check( (long) ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->blk_sz; options.arg_type = REQUIRED_ARG; *((int *) save) = (int) getopt_ll_limit_value(tmp, &options, &fixed); -#if MYSQL_VERSION_ID < 50500 - DBUG_RETURN(throw_bounds_warning(thd, fixed, FALSE, - ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, (long long) tmp)); -#else DBUG_RETURN(throw_bounds_warning(thd, ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, fixed, FALSE, (longlong) tmp)); -#endif } /* @@ -758,14 +741,9 @@ static int spider_param_semi_table_lock_connection_check( (long) ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->blk_sz; options.arg_type = REQUIRED_ARG; *((int *) save) = (int) getopt_ll_limit_value(tmp, &options, &fixed); -#if MYSQL_VERSION_ID < 50500 - DBUG_RETURN(throw_bounds_warning(thd, fixed, FALSE, - ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, (long long) tmp)); -#else DBUG_RETURN(throw_bounds_warning(thd, ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, fixed, FALSE, (longlong) tmp)); -#endif } /* @@ -1738,7 +1716,6 @@ SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, udf_ds_table_loop_mode) static char *spider_remote_access_charset; /* */ -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 static MYSQL_SYSVAR_STR( remote_access_charset, spider_remote_access_charset, @@ -1749,30 +1726,6 @@ static MYSQL_SYSVAR_STR( NULL, NULL ); -#else -#ifdef PLUGIN_VAR_CAN_MEMALLOC -static MYSQL_SYSVAR_STR( - remote_access_charset, - spider_remote_access_charset, - PLUGIN_VAR_MEMALLOC | - PLUGIN_VAR_RQCMDARG, - "Set remote access charset at connecting for improvement performance of connection if you know", - NULL, - NULL, - NULL -); -#else -static MYSQL_SYSVAR_STR( - remote_access_charset, - spider_remote_access_charset, - PLUGIN_VAR_RQCMDARG, - "Set remote access charset at connecting for improvement performance of connection if you know", - NULL, - NULL, - NULL -); -#endif -#endif SPIDER_SYSVAR_VALUE_FUNC(char*, remote_access_charset) @@ -1800,7 +1753,6 @@ SPIDER_SYSVAR_VALUE_FUNC(int, remote_autocommit) static char *spider_remote_time_zone; /* */ -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 static MYSQL_SYSVAR_STR( remote_time_zone, spider_remote_time_zone, @@ -1811,30 +1763,6 @@ static MYSQL_SYSVAR_STR( NULL, NULL ); -#else -#ifdef PLUGIN_VAR_CAN_MEMALLOC -static MYSQL_SYSVAR_STR( - remote_time_zone, - spider_remote_time_zone, - PLUGIN_VAR_MEMALLOC | - PLUGIN_VAR_RQCMDARG, - "Set remote time_zone at connecting for improvement performance of connection if you know", - NULL, - NULL, - NULL -); -#else -static MYSQL_SYSVAR_STR( - remote_time_zone, - spider_remote_time_zone, - PLUGIN_VAR_RQCMDARG, - "Set remote time_zone at connecting for improvement performance of connection if you know", - NULL, - NULL, - NULL -); -#endif -#endif SPIDER_SYSVAR_VALUE_FUNC(char *, remote_time_zone) @@ -1885,7 +1813,6 @@ SPIDER_SYSVAR_VALUE_FUNC(int, remote_trx_isolation) static char *spider_remote_default_database; /* */ -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 static MYSQL_SYSVAR_STR( remote_default_database, spider_remote_default_database, @@ -1896,30 +1823,6 @@ static MYSQL_SYSVAR_STR( NULL, NULL ); -#else -#ifdef PLUGIN_VAR_CAN_MEMALLOC -static MYSQL_SYSVAR_STR( - remote_default_database, - spider_remote_default_database, - PLUGIN_VAR_MEMALLOC | - PLUGIN_VAR_RQCMDARG, - "Set remote database at connecting for improvement performance of connection if you know", - NULL, - NULL, - NULL -); -#else -static MYSQL_SYSVAR_STR( - remote_default_database, - spider_remote_default_database, - PLUGIN_VAR_RQCMDARG, - "Set remote database at connecting for improvement performance of connection if you know", - NULL, - NULL, - NULL -); -#endif -#endif SPIDER_SYSVAR_VALUE_FUNC(char *, remote_default_database) @@ -1973,7 +1876,6 @@ int spider_param_connect_retry_count( /* */ -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 static MYSQL_THDVAR_STR( bka_engine, /* name */ PLUGIN_VAR_MEMALLOC | @@ -1983,28 +1885,6 @@ static MYSQL_THDVAR_STR( NULL, /* update */ NULL /* def */ ); -#else -#ifdef PLUGIN_VAR_CAN_MEMALLOC -static MYSQL_THDVAR_STR( - bka_engine, /* name */ - PLUGIN_VAR_MEMALLOC | - PLUGIN_VAR_RQCMDARG, - "Temporary table's engine for BKA", /* comment */ - NULL, /* check */ - NULL, /* update */ - NULL /* def */ -); -#else -static MYSQL_THDVAR_STR( - bka_engine, /* name */ - PLUGIN_VAR_RQCMDARG, - "Temporary table's engine for BKA", /* comment */ - NULL, /* check */ - NULL, /* update */ - NULL /* def */ -); -#endif -#endif char *spider_param_bka_engine( THD *thd, @@ -2365,8 +2245,6 @@ static MYSQL_SYSVAR_INT( SPIDER_SYSVAR_OVERRIDE_VALUE_FUN(int, bulk_access_free) #endif -#if MYSQL_VERSION_ID < 50500 -#else /* -1 :fallback to default 0 :can not use @@ -2385,7 +2263,6 @@ static MYSQL_THDVAR_INT( ); SPIDER_THDVAR_OVERRIDE_VALUE_FUNC(int, udf_ds_use_real_table) -#endif static my_bool spider_general_log; static MYSQL_SYSVAR_BOOL( @@ -2950,10 +2827,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = { #ifdef HA_CAN_BULK_ACCESS MYSQL_SYSVAR(bulk_access_free), #endif -#if MYSQL_VERSION_ID < 50500 -#else MYSQL_SYSVAR(udf_ds_use_real_table), -#endif MYSQL_SYSVAR(general_log), MYSQL_SYSVAR(index_hint_pushdown), MYSQL_SYSVAR(max_connections), @@ -2993,14 +2867,11 @@ mysql_declare_plugin(spider) spider_status_variables, spider_system_variables, NULL, -#if MYSQL_VERSION_ID >= 50600 0, -#endif }, spider_i_s_alloc_mem mysql_declare_plugin_end; -#ifdef MARIADB_BASE_VERSION maria_declare_plugin(spider) { MYSQL_STORAGE_ENGINE_PLUGIN, @@ -3019,4 +2890,3 @@ maria_declare_plugin(spider) }, spider_i_s_alloc_mem_maria maria_declare_plugin_end; -#endif diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h index 9ffb9e8c278..e4f5fde1110 100644 --- a/storage/spider/spd_param.h +++ b/storage/spider/spd_param.h @@ -371,13 +371,10 @@ int spider_param_bulk_access_free( int bulk_access_free ); #endif -#if MYSQL_VERSION_ID < 50500 -#else int spider_param_udf_ds_use_real_table( THD *thd, int udf_ds_use_real_table ); -#endif my_bool spider_param_general_log(); my_bool spider_param_index_hint_pushdown( THD *thd diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 92f5ff9e69f..4d2c826aa28 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -17,16 +17,11 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "sql_partition.h" #include "sql_acl.h" -#endif #include "spd_err.h" #include "spd_param.h" #include "spd_db_include.h" @@ -326,11 +321,7 @@ int spider_get_ping_table_mon( ) { int error_num; TABLE *table_link_mon = NULL; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif char table_key[MAX_KEY_LENGTH]; SPIDER_TABLE_MON *table_mon, *table_mon_prev = NULL; SPIDER_SHARE *tmp_share; @@ -519,11 +510,7 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( int *error_num ) { TABLE *table_tables = NULL; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif char table_key[MAX_KEY_LENGTH]; SPIDER_TABLE_MON_LIST *table_mon_list = NULL; @@ -632,43 +619,26 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt( if (tmp_share->link_statuses[0] == SPIDER_LINK_STATUS_NG) table_mon_list->mon_status = SPIDER_LINK_MON_NG; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&table_mon_list->caller_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_mon_list_caller, &table_mon_list->caller_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_caller_mutex_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&table_mon_list->receptor_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_mon_list_receptor, &table_mon_list->receptor_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_receptor_mutex_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&table_mon_list->monitor_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_mon_list_monitor, &table_mon_list->monitor_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_monitor_mutex_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&table_mon_list->update_status_mutex, - MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_mon_list_update_status, &table_mon_list->update_status_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_update_status_mutex_init; @@ -741,13 +711,8 @@ int spider_get_ping_table_gtid_pos( int error_num, source_link_idx, need_mon; char table_key[MAX_KEY_LENGTH]; TABLE *table_tables, *table_gtid_pos; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup_tables; - Open_tables_state open_tables_backup_gtid_pos; -#else Open_tables_backup open_tables_backup_tables; Open_tables_backup open_tables_backup_gtid_pos; -#endif MEM_ROOT mem_root; long link_status; long monitoring_binlog_pos_at_failing; @@ -899,11 +864,7 @@ int spider_init_ping_table_mon_cache( ) { int error_num, same; TABLE *table_link_mon = NULL; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif SPIDER_MON_KEY mon_key; DBUG_ENTER("spider_init_ping_table_mon_cache"); @@ -1101,23 +1062,14 @@ long long spider_ping_table_body( conv_name.init_calc_mem(SPD_MID_PING_TABLE_BODY_1); tmp_str.init_calc_mem(SPD_MID_PING_TABLE_BODY_2); conv_name.length(0); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 server_id = global_system_variables.server_id; -#else - server_id = thd->server_id; -#endif if ( thd->open_tables != 0 || thd->handler_tables_hash.records != 0 || thd->derived_tables != 0 || thd->lock != 0 || -#if MYSQL_VERSION_ID < 50500 - thd->locked_tables != 0 || - thd->prelocked_mode != NON_PRELOCKED -#else thd->locked_tables_list.locked_tables() || thd->locked_tables_mode != LTM_NONE -#endif ) { if (thd->open_tables != 0) { @@ -1140,18 +1092,6 @@ long long spider_ping_table_body( my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), "thd->lock", thd->lock); -#if MYSQL_VERSION_ID < 50500 - } else if (thd->locked_tables != 0) - { - my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, - ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_PTR, MYF(0), - "thd->locked_tables", thd->locked_tables); - } else if (thd->prelocked_mode != NON_PRELOCKED) - { - my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, - ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), - "thd->prelocked_mode", (longlong) thd->prelocked_mode); -#else } else if (thd->locked_tables_list.locked_tables()) { my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, @@ -1163,7 +1103,6 @@ long long spider_ping_table_body( my_printf_error(ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_NUM, ER_SPIDER_UDF_CANT_USE_IF_OPEN_TABLE_STR_WITH_NUM, MYF(0), "thd->locked_tables_mode", (longlong) thd->locked_tables_mode); -#endif } goto error; } diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index 10f9fdedd5b..a0440c294c2 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -17,17 +17,12 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "key.h" #include "sql_base.h" #include "tztime.h" -#endif #include "sql_select.h" #include "spd_err.h" #include "spd_param.h" @@ -121,17 +116,6 @@ inline int spider_delete_sys_table_row(TABLE *table, int record_number = 0, return error_num; } -#if MYSQL_VERSION_ID < 50500 -TABLE *spider_open_sys_table( - THD *thd, - const char *table_name, - int table_name_length, - bool write, - Open_tables_state *open_tables_backup, - bool need_lock, - int *error_num -) -#else TABLE *spider_open_sys_table( THD *thd, const char *table_name, @@ -141,26 +125,11 @@ TABLE *spider_open_sys_table( bool need_lock, int *error_num ) -#endif { TABLE *table; TABLE_LIST tables; -#if MYSQL_VERSION_ID < 50500 - TABLE_SHARE *table_share; - char table_key[MAX_DBKEY_LENGTH]; - uint table_key_length; -#endif DBUG_ENTER("spider_open_sys_table"); -#if MYSQL_VERSION_ID < 50500 - memset(&tables, 0, sizeof(TABLE_LIST)); - SPIDER_TABLE_LIST_db_str(&tables) = (char*)"mysql"; - SPIDER_TABLE_LIST_db_length(&tables) = sizeof("mysql") - 1; - SPIDER_TABLE_LIST_alias_str(&tables) = - SPIDER_TABLE_LIST_table_name_str(&tables) = (char *) table_name; - SPIDER_TABLE_LIST_table_name_length(&tables) = table_name_length; - tables.lock_type = (write ? TL_WRITE : TL_READ); -#else #ifdef SPIDER_use_LEX_CSTRING_for_database_tablename_alias LEX_CSTRING db_name = { @@ -178,18 +147,8 @@ TABLE *spider_open_sys_table( "mysql", sizeof("mysql") - 1, table_name, table_name_length, table_name, (write ? TL_WRITE : TL_READ)); #endif -#endif -#if MYSQL_VERSION_ID < 50500 - if (need_lock) - { -#endif -#if MYSQL_VERSION_ID < 50500 - if (!(table = open_performance_schema_table(thd, &tables, - open_tables_backup))) -#else if (!(table = spider_sys_open_table(thd, &tables, open_tables_backup))) -#endif { my_printf_error(ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM, ER_SPIDER_CANT_OPEN_SYS_TABLE_STR, MYF(0), @@ -197,38 +156,6 @@ TABLE *spider_open_sys_table( *error_num = ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM; DBUG_RETURN(NULL); } -#if MYSQL_VERSION_ID < 50500 - } else { - thd->reset_n_backup_open_tables_state(open_tables_backup); - - if (!(table = (TABLE*) spider_malloc(spider_current_trx, SPD_MID_OPEN_SYS_TABLE_1, - sizeof(*table), MYF(MY_WME)))) - { - *error_num = HA_ERR_OUT_OF_MEM; - goto error_malloc; - } - - table_key_length = - create_table_def_key(thd, table_key, &tables, FALSE); - - if (!(table_share = get_table_share(thd, - &tables, table_key, table_key_length, 0, error_num))) - goto error; - if (open_table_from_share(thd, table_share, tables.alias, - (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX), - READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD, - (uint) HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_FROM_SQL_LAYER, - table, FALSE) - ) { - release_table_share(table_share, RELEASE_NORMAL); - my_printf_error(ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM, - ER_SPIDER_CANT_OPEN_SYS_TABLE_STR, MYF(0), - "mysql", table_name); - *error_num = ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM; - goto error; - } - } -#endif switch (table_name_length) { case 9: @@ -370,51 +297,22 @@ TABLE *spider_open_sys_table( } DBUG_RETURN(table); -#if MYSQL_VERSION_ID < 50500 -error: - spider_free(spider_current_trx, table, MYF(0)); -error_malloc: - thd->restore_backup_open_tables_state(open_tables_backup); -#endif error_col_num_chk: DBUG_RETURN(NULL); } -#if MYSQL_VERSION_ID < 50500 -void spider_close_sys_table( - THD *thd, - TABLE *table, - Open_tables_state *open_tables_backup, - bool need_lock -) -#else void spider_close_sys_table( THD *thd, TABLE *table, Open_tables_backup *open_tables_backup, bool need_lock ) -#endif { DBUG_ENTER("spider_close_sys_table"); -#if MYSQL_VERSION_ID < 50500 - if (need_lock) - { - close_performance_schema_table(thd, open_tables_backup); - } else { - table->file->ha_reset(); - closefrm(table, TRUE); - spider_free(spider_current_trx, table, MYF(0)); - thd->restore_backup_open_tables_state(open_tables_backup); - } -#else spider_sys_close_table(thd, open_tables_backup); -#endif DBUG_VOID_RETURN; } -#if MYSQL_VERSION_ID < 50500 -#else bool spider_sys_open_tables( THD *thd, TABLE_LIST **tables, @@ -467,7 +365,6 @@ void spider_sys_close_table( thd->restore_backup_open_tables_state(open_tables_backup); DBUG_VOID_RETURN; } -#endif int spider_sys_index_init( TABLE *table, @@ -512,15 +409,9 @@ int spider_check_sys_table( table->key_info, table->key_info->key_length); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 DBUG_RETURN(table->file->ha_index_read_idx_map( table->record[0], 0, (uchar *) table_key, HA_WHOLE_KEY, HA_READ_KEY_EXACT)); -#else - DBUG_RETURN(table->file->index_read_idx_map( - table->record[0], 0, (uchar *) table_key, - HA_WHOLE_KEY, HA_READ_KEY_EXACT)); -#endif } int spider_check_sys_table_with_find_flag( @@ -536,15 +427,9 @@ int spider_check_sys_table_with_find_flag( table->key_info, table->key_info->key_length); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 DBUG_RETURN(table->file->ha_index_read_idx_map( table->record[0], 0, (uchar *) table_key, HA_WHOLE_KEY, find_flag)); -#else - DBUG_RETURN(table->file->index_read_idx_map( - table->record[0], 0, (uchar *) table_key, - HA_WHOLE_KEY, find_flag)); -#endif } int spider_check_sys_table_for_update_all_columns( @@ -559,15 +444,9 @@ int spider_check_sys_table_for_update_all_columns( table->key_info, table->key_info->key_length); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 DBUG_RETURN(table->file->ha_index_read_idx_map( table->record[1], 0, (uchar *) table_key, HA_WHOLE_KEY, HA_READ_KEY_EXACT)); -#else - DBUG_RETURN(table->file->index_read_idx_map( - table->record[1], 0, (uchar *) table_key, - HA_WHOLE_KEY, HA_READ_KEY_EXACT)); -#endif } /* @@ -607,15 +486,9 @@ int spider_get_sys_table_by_idx( key_length); if ( -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 (error_num = table->file->ha_index_read_map( table->record[0], (uchar *) table_key, make_prev_keypart_map(col_count), HA_READ_KEY_EXACT)) -#else - (error_num = table->file->index_read_map( - table->record[0], (uchar *) table_key, - make_prev_keypart_map(col_count), HA_READ_KEY_EXACT)) -#endif ) { spider_sys_index_end(table); DBUG_RETURN(error_num); @@ -628,17 +501,10 @@ int spider_sys_index_next_same( char *table_key ) { DBUG_ENTER("spider_sys_index_next_same"); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 DBUG_RETURN(table->file->ha_index_next_same( table->record[0], (const uchar*) table_key, table->key_info->key_length)); -#else - DBUG_RETURN(table->file->index_next_same( - table->record[0], - (const uchar*) table_key, - table->key_info->key_length)); -#endif } int spider_sys_index_first( @@ -651,11 +517,7 @@ int spider_sys_index_first( DBUG_RETURN(error_num); if ( -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 (error_num = table->file->ha_index_first(table->record[0])) -#else - (error_num = table->file->index_first(table->record[0])) -#endif ) { spider_sys_index_end(table); DBUG_RETURN(error_num); @@ -673,11 +535,7 @@ int spider_sys_index_last( DBUG_RETURN(error_num); if ( -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 (error_num = table->file->ha_index_last(table->record[0])) -#else - (error_num = table->file->index_last(table->record[0])) -#endif ) { spider_sys_index_end(table); DBUG_RETURN(error_num); @@ -689,11 +547,7 @@ int spider_sys_index_next( TABLE *table ) { DBUG_ENTER("spider_sys_index_next"); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 DBUG_RETURN(table->file->ha_index_next(table->record[0])); -#else - DBUG_RETURN(table->file->index_next(table->record[0])); -#endif } void spider_store_xa_pk( @@ -1412,11 +1266,6 @@ int spider_log_tables_link_failed( table->use_all_columns(); spider_store_tables_name(table, name, name_length); spider_store_tables_link_idx(table, link_idx); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 -#else - if (table->field[3] == table->timestamp_field) - table->timestamp_field->set_time(); -#endif if ((error_num = spider_write_sys_table_row(table))) { DBUG_RETURN(error_num); @@ -1449,11 +1298,6 @@ int spider_log_xa_failed( (uint) strlen(status), system_charset_info); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 -#else - if (table->field[20] == table->timestamp_field) - table->timestamp_field->set_time(); -#endif if ((error_num = spider_write_sys_table_row(table))) { DBUG_RETURN(error_num); @@ -2385,11 +2229,7 @@ int spider_sys_update_tables_link_status( ) { int error_num; TABLE *table_tables = NULL; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif DBUG_ENTER("spider_sys_update_tables_link_status"); if ( !(table_tables = spider_open_sys_table( @@ -2423,11 +2263,7 @@ int spider_sys_log_tables_link_failed( ) { int error_num; TABLE *table_tables = NULL; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif DBUG_ENTER("spider_sys_log_tables_link_failed"); if ( !(table_tables = spider_open_sys_table( @@ -2462,11 +2298,7 @@ int spider_sys_log_xa_failed( ) { int error_num; TABLE *table_tables = NULL; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif DBUG_ENTER("spider_sys_log_xa_failed"); if ( !(table_tables = spider_open_sys_table( @@ -2802,12 +2634,8 @@ int spider_sys_replace( if (table->file->ha_table_flags() & HA_DUPLICATE_POS) { -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 error_num = table->file->ha_rnd_pos(table->record[1], table->file->dup_ref); -#else - error_num = table->file->rnd_pos(table->record[1], table->file->dup_ref); -#endif if (error_num) { if (error_num == HA_ERR_RECORD_DELETED) @@ -2820,13 +2648,8 @@ int spider_sys_replace( key_copy((uchar*)table_key, table->record[0], table->key_info + key_num, 0); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 50200 error_num = table->file->ha_index_read_idx_map(table->record[1], key_num, (const uchar*)table_key, HA_WHOLE_KEY, HA_READ_KEY_EXACT); -#else - error_num = table->file->index_read_idx_map(table->record[1], key_num, - (const uchar*)table_key, HA_WHOLE_KEY, HA_READ_KEY_EXACT); -#endif if (error_num) { if (error_num == HA_ERR_RECORD_DELETED) diff --git a/storage/spider/spd_sys_table.h b/storage/spider/spd_sys_table.h index fca38c67683..f0d0d19439e 100644 --- a/storage/spider/spd_sys_table.h +++ b/storage/spider/spd_sys_table.h @@ -68,24 +68,6 @@ public: uint link_id_length; }; -#if MYSQL_VERSION_ID < 50500 -TABLE *spider_open_sys_table( - THD *thd, - const char *table_name, - int table_name_length, - bool write, - Open_tables_state *open_tables_backup, - bool need_lock, - int *error_num -); - -void spider_close_sys_table( - THD *thd, - TABLE *table, - Open_tables_state *open_tables_backup, - bool need_lock -); -#else TABLE *spider_open_sys_table( THD *thd, const char *table_name, @@ -119,7 +101,6 @@ void spider_sys_close_table( THD *thd, Open_tables_backup *open_tables_backup ); -#endif int spider_sys_index_init( TABLE *table, diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 610fbeda1f3..60e1ce6bad2 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -18,10 +18,6 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "my_getopt.h" @@ -31,7 +27,6 @@ #include "sql_select.h" #include "tztime.h" #include "sql_parse.h" -#endif #include "spd_err.h" #include "spd_param.h" #include "spd_db_include.h" @@ -3612,11 +3607,7 @@ int spider_set_connect_info_default( if (share->monitoring_limit[roop_count] == -1) share->monitoring_limit[roop_count] = 1; if (share->monitoring_sid[roop_count] == -1) -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 share->monitoring_sid[roop_count] = global_system_variables.server_id; -#else - share->monitoring_sid[roop_count] = current_thd->server_id; -#endif #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) if (share->hs_read_ports[roop_count] == -1) @@ -4257,34 +4248,22 @@ SPIDER_SHARE *spider_create_share( if (share->table_count_mode & 2) share->additional_table_flags |= HA_HAS_RECORDS; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_share, &share->mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_mutex; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&share->sts_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_share_sts, &share->sts_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_sts_mutex; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&share->crd_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_share_crd, &share->crd_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_crd_mutex; @@ -4411,11 +4390,7 @@ SPIDER_SHARE *spider_get_share( int semi_table_lock_conn; int search_link_idx; uint sql_command = thd_sql_command(thd); -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif MEM_ROOT mem_root; TABLE *table_tables = NULL; bool init_mem_root = FALSE; @@ -5714,13 +5689,8 @@ SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share( lgtm_tblhnd_share->table_path_hash_value = hash_value; #endif -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&lgtm_tblhnd_share->auto_increment_mutex, - MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_share_auto_increment, &lgtm_tblhnd_share->auto_increment_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_auto_increment_mutex; @@ -5830,35 +5800,22 @@ SPIDER_PARTITION_SHARE *spider_get_pt_share( partition_share->crd_get_time = partition_share->sts_get_time = share->crd_get_time; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&partition_share->sts_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_pt_share_sts, &partition_share->sts_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_sts_mutex; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&partition_share->crd_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_pt_share_crd, &partition_share->crd_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_crd_mutex; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&partition_share->pt_handler_mutex, - MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_pt_handler, &partition_share->pt_handler_mutex, MY_MUTEX_INIT_FAST)) -#endif { *error_num = HA_ERR_OUT_OF_MEM; goto error_init_pt_handler_mutex; @@ -6012,11 +5969,7 @@ int spider_open_all_tables( long *long_info; longlong *longlong_info; MEM_ROOT mem_root; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif DBUG_ENTER("spider_open_all_tables"); if ( !(table_tables = spider_open_sys_table( @@ -6722,13 +6675,8 @@ int spider_db_init( GetProcAddress(current_module, "?xid_cache@@3PAUst_hash@@A")); #else spd_db_att_LOCK_xid_cache = (pthread_mutex_t *) -#if MYSQL_VERSION_ID < 50500 - GetProcAddress(current_module, - "?LOCK_xid_cache@@3U_RTL_CRITICAL_SECTION@@A"); -#else GetProcAddress(current_module, "?LOCK_xid_cache@@3Ust_mysql_mutex@@A"); -#endif spd_db_att_xid_cache = (HASH *) GetProcAddress(current_module, "?xid_cache@@3Ust_hash@@A"); #endif @@ -6788,117 +6736,61 @@ int spider_db_init( */ #endif -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_tbl_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_tbl, &spider_tbl_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_tbl_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_thread_id_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_thread_id, &spider_thread_id_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_thread_id_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_conn_id_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_conn_id, &spider_conn_id_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_conn_id_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_ipport_conn_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_ipport_count, &spider_ipport_conn_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_ipport_count_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_init_error_tbl_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_init_error_tbl, &spider_init_error_tbl_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_init_error_tbl_mutex_init; #ifdef WITH_PARTITION_STORAGE_ENGINE -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_pt_share_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_pt_share, &spider_pt_share_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_pt_share_mutex_init; #endif -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_lgtm_tblhnd_share_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_lgtm_tblhnd_share, &spider_lgtm_tblhnd_share_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_lgtm_tblhnd_share_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_conn_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_conn, &spider_conn_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_conn_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_open_conn_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_open_conn, &spider_open_conn_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_open_conn_mutex_init; #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_hs_r_conn_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_hs_r_conn, &spider_hs_r_conn_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_hs_r_conn_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_hs_w_conn_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_hs_w_conn, &spider_hs_w_conn_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_hs_w_conn_mutex_init; #endif -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_allocated_thds_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_allocated_thds, &spider_allocated_thds_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_allocated_thds_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_mon_table_cache_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_mon_table_cache, &spider_mon_table_cache_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_mon_table_cache_mutex_init; -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_mem_calc_mutex, MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_mem_calc, &spider_mem_calc_mutex, MY_MUTEX_INIT_FAST)) -#endif goto error_mem_calc_mutex_init; if (my_hash_init(&spider_open_tables, spd_charset_utf8_bin, 32, 0, 0, @@ -7011,25 +6903,16 @@ int spider_db_init( roop_count < (int) spider_param_udf_table_mon_mutex_count(); roop_count++) { -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_udf_table_mon_mutexes[roop_count], - MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_udf_table_mon, &spider_udf_table_mon_mutexes[roop_count], MY_MUTEX_INIT_FAST)) -#endif goto error_init_udf_table_mon_mutex; } for (roop_count = 0; roop_count < (int) spider_param_udf_table_mon_mutex_count(); roop_count++) { -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&spider_udf_table_mon_conds[roop_count], NULL)) -#else if (mysql_cond_init(spd_key_cond_udf_table_mon, &spider_udf_table_mon_conds[roop_count], NULL)) -#endif goto error_init_udf_table_mon_cond; } for (roop_count = 0; @@ -8492,10 +8375,8 @@ bool spider_check_direct_order_limit( spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit); bool first_check = TRUE; DBUG_PRINT("info",("spider select_lex=%p", select_lex)); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 DBUG_PRINT("info",("spider leaf_tables.elements=%u", select_lex ? select_lex->leaf_tables.elements : 0)); -#endif if (select_lex && (select_lex->options & SELECT_DISTINCT)) { @@ -8508,22 +8389,16 @@ bool spider_check_direct_order_limit( DBUG_PRINT("info",("spider select_limit=%lld", select_limit)); DBUG_PRINT("info",("spider offset_limit=%lld", offset_limit)); if ( -#if MYSQL_VERSION_ID < 50500 - !thd->variables.engine_condition_pushdown || -#else #ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #else !(thd->variables.optimizer_switch & OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || #endif -#endif #ifdef SPIDER_NEED_CHECK_CONDITION_AT_CHECKING_DIRECT_ORDER_LIMIT !spider->condition || #endif !select_lex || -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 select_lex->leaf_tables.elements != 1 || -#endif select_lex->table_list.elements != 1 ) { DBUG_PRINT("info",("spider first_check is FALSE")); @@ -8802,14 +8677,10 @@ int spider_set_direct_limit_offset( // contain where if ( -#if MYSQL_VERSION_ID < 50500 - !thd->variables.engine_condition_pushdown || -#else #ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON #else !(thd->variables.optimizer_switch & OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) || -#endif #endif spider->condition // conditions is null may be no where condition in rand_init ) @@ -8955,20 +8826,11 @@ ulong spider_calc_for_sort( double spider_rand( uint32 rand_source ) { -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 struct my_rnd_struct rand; -#else - struct rand_struct rand; -#endif DBUG_ENTER("spider_rand"); /* generate same as rand function for applications */ -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 my_rnd_init(&rand, (uint32) (rand_source * 65537L + 55555555L), (uint32) (rand_source * 268435457L)); -#else - randominit(&rand, (uint32) (rand_source * 65537L + 55555555L), - (uint32) (rand_source * 268435457L)); -#endif DBUG_RETURN(my_rnd(&rand)); } @@ -9499,46 +9361,27 @@ int spider_create_sts_threads( ) { int error_num; DBUG_ENTER("spider_create_sts_threads"); -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_thread->mutex, - MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_bg_stss, &spider_thread->mutex, MY_MUTEX_INIT_FAST)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_mutex_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&spider_thread->cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_stss, &spider_thread->cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&spider_thread->sync_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_sts_syncs, &spider_thread->sync_cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_sync_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_create(&spider_thread->thread, &spider_pt_attr, - spider_table_bg_sts_action, (void *) spider_thread) - ) -#else if (mysql_thread_create(spd_key_thd_bg_stss, &spider_thread->thread, &spider_pt_attr, spider_table_bg_sts_action, (void *) spider_thread) ) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_thread_create; @@ -9586,46 +9429,27 @@ int spider_create_crd_threads( ) { int error_num; DBUG_ENTER("spider_create_crd_threads"); -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&spider_thread->mutex, - MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_bg_crds, &spider_thread->mutex, MY_MUTEX_INIT_FAST)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_mutex_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&spider_thread->cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_crds, &spider_thread->cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_cond_init(&spider_thread->sync_cond, NULL)) -#else if (mysql_cond_init(spd_key_cond_bg_crd_syncs, &spider_thread->sync_cond, NULL)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_sync_cond_init; } -#if MYSQL_VERSION_ID < 50500 - if (pthread_create(&spider_thread->thread, &spider_pt_attr, - spider_table_bg_crd_action, (void *) spider_thread) - ) -#else if (mysql_thread_create(spd_key_thd_bg_crds, &spider_thread->thread, &spider_pt_attr, spider_table_bg_crd_action, (void *) spider_thread) ) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_thread_create; diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index 29b5497dd81..bdea13e7d3b 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -18,16 +18,11 @@ #include #include "mysql_version.h" #include "spd_environ.h" -#if MYSQL_VERSION_ID < 50500 -#include "mysql_priv.h" -#include -#else #include "sql_priv.h" #include "probes_mysql.h" #include "sql_class.h" #include "sql_partition.h" #include "records.h" -#endif #include "spd_err.h" #include "spd_param.h" #include "spd_db_include.h" @@ -1194,13 +1189,8 @@ SPIDER_TRX *spider_get_trx( roop_count < (int) spider_param_udf_table_lock_mutex_count(); roop_count++) { -#if MYSQL_VERSION_ID < 50500 - if (pthread_mutex_init(&trx->udf_table_mutexes[roop_count], - MY_MUTEX_INIT_FAST)) -#else if (mysql_mutex_init(spd_key_mutex_udf_table, &trx->udf_table_mutexes[roop_count], MY_MUTEX_INIT_FAST)) -#endif goto error_init_udf_table_mutex; } @@ -1898,17 +1888,10 @@ int spider_internal_start_trx( (trx->xid.data, "%lx%016llx", thd_get_thread_id(thd), thd->query_id)); } -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100002 trx->xid.bqual_length = my_sprintf(trx->xid.data + trx->xid.gtrid_length, (trx->xid.data + trx->xid.gtrid_length, "%lx", thd->variables.server_id)); -#else - trx->xid.bqual_length - = my_sprintf(trx->xid.data + trx->xid.gtrid_length, - (trx->xid.data + trx->xid.gtrid_length, "%x", - thd->server_id)); -#endif #ifdef SPIDER_XID_STATE_HAS_in_thd trx->internal_xid_state.in_thd = 1; @@ -2018,11 +2001,7 @@ int spider_internal_xa_commit( SPIDER_CONN *conn; uint force_commit = spider_param_force_commit(thd); MEM_ROOT mem_root; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif bool table_xa_opened = FALSE; bool table_xa_member_opened = FALSE; DBUG_ENTER("spider_internal_xa_commit"); @@ -2206,11 +2185,7 @@ int spider_internal_xa_rollback( SPIDER_CONN *conn; uint force_commit = spider_param_force_commit(thd); MEM_ROOT mem_root; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif bool server_lost = FALSE; bool table_xa_opened = FALSE; bool table_xa_member_opened = FALSE; @@ -2448,11 +2423,7 @@ int spider_internal_xa_prepare( int error_num; SPIDER_CONN *conn; uint force_commit = spider_param_force_commit(thd); -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif bool table_xa_opened = FALSE; bool table_xa_member_opened = FALSE; DBUG_ENTER("spider_internal_xa_prepare"); @@ -2623,11 +2594,7 @@ int spider_internal_xa_recover( int cnt = 0; char xa_key[MAX_KEY_LENGTH]; MEM_ROOT mem_root; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif DBUG_ENTER("spider_internal_xa_recover"); /* select @@ -2685,21 +2652,13 @@ int spider_initinal_xa_recover( static THD *thd = NULL; static TABLE *table_xa = NULL; static READ_RECORD *read_record = NULL; -#if MYSQL_VERSION_ID < 50500 - static Open_tables_state *open_tables_backup = NULL; -#else static Open_tables_backup *open_tables_backup = NULL; -#endif int cnt = 0; MEM_ROOT mem_root; DBUG_ENTER("spider_initinal_xa_recover"); if (!open_tables_backup) { -#if MYSQL_VERSION_ID < 50500 - if (!(open_tables_backup = new Open_tables_state)) -#else if (!(open_tables_backup = new Open_tables_backup)) -#endif { error_num = HA_ERR_OUT_OF_MEM; goto error_create_state; @@ -2810,11 +2769,7 @@ int spider_internal_xa_commit_by_xid( SPIDER_CONN *conn; uint force_commit = spider_param_force_commit(thd); MEM_ROOT mem_root; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif bool table_xa_opened = FALSE; bool table_xa_member_opened = FALSE; DBUG_ENTER("spider_internal_xa_commit_by_xid"); @@ -3045,11 +3000,7 @@ int spider_internal_xa_rollback_by_xid( SPIDER_CONN *conn; uint force_commit = spider_param_force_commit(thd); MEM_ROOT mem_root; -#if MYSQL_VERSION_ID < 50500 - Open_tables_state open_tables_backup; -#else Open_tables_backup open_tables_backup; -#endif bool table_xa_opened = FALSE; bool table_xa_member_opened = FALSE; DBUG_ENTER("spider_internal_xa_rollback_by_xid"); @@ -4109,19 +4060,8 @@ THD *spider_create_tmp_thd() DBUG_ENTER("spider_create_tmp_thd"); if (!(thd = SPIDER_new_THD((my_thread_id) 0))) DBUG_RETURN(NULL); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 thd->killed = NOT_KILLED; -#else - thd->killed = THD::NOT_KILLED; -#endif -#if MYSQL_VERSION_ID < 50500 - thd->locked_tables = FALSE; -#endif thd->proc_info = ""; -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100200 -#else - thd->thread_id = thd->variables.pseudo_thread_id = 0; -#endif thd->thread_stack = (char*) &thd; if (thd->store_globals()) DBUG_RETURN(NULL); @@ -4134,11 +4074,7 @@ void spider_free_tmp_thd( ) { DBUG_ENTER("spider_free_tmp_thd"); thd->cleanup(); -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000 thd->reset_globals(); -#else - thd->restore_globals(); -#endif delete thd; DBUG_VOID_RETURN; } From 860c1ca9ad90654f5064796e0989f29dd3ac1b59 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 18 Mar 2024 13:11:49 +1100 Subject: [PATCH 077/313] MDEV-33679 Spider group by handler: skip on multiple equalities The spider group by handler is created in JOIN::make_aggr_tables_info(), by which time calls to substitute_for_best_equal_field() should have already removed all the multiple equalities (i.e. Item_equal, with MULT_EQUAL_FUNC func_type). Therefore, if there is still such items, it is deemed as an optimizer bug and should be skipped. --- .../spider/bugfix/r/mdev_33679.result | 27 +++++++++++++++++ .../spider/bugfix/t/mdev_33679.test | 29 +++++++++++++++++++ storage/spider/spd_db_mysql.cc | 22 ++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_33679.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result new file mode 100644 index 00000000000..0a11fe429cb --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result @@ -0,0 +1,27 @@ +# +# MDEV-33679 spider returns parsing failure on valid left join select by translating the on expression to () +# +for master_1 +for child2 +for child3 +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +CREATE TABLE `t1` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) ENGINE=MYISAM; +CREATE TABLE `t2` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL ) ENGINE=MYISAM; +SET spider_same_server_link= on; +CREATE TABLE `t1_spider` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) COMMENT='wrapper "mysql",srv "srv", table "t1"' ENGINE=SPIDER; +CREATE TABLE `t2_spider` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL +, PRIMARY KEY (`a`) USING BTREE +) COMMENT='wrapper "mysql",srv "srv",table "t2"' ENGINE=SPIDER; +INSERT INTO t1_spider VALUES(1,'oooo'); +INSERT INTO t2_spider VALUES(1,1); +SELECT t2_spider.a,t1_spider.c FRoM t2_spider LEFT join t1_spider ON (t2_spider.c = t1_spider.c) WHERE t2_spider.a = 1; +a c +1 1 +Warnings: +Warning 1815 Internal error: Spider group by handler: Encountered multiple equalities, likely an optimizer bug +drop table t1, t2, t1_spider, t2_spider; +drop server srv; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33679.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33679.test new file mode 100644 index 00000000000..eee47a21163 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33679.test @@ -0,0 +1,29 @@ +--echo # +--echo # MDEV-33679 spider returns parsing failure on valid left join select by translating the on expression to () +--echo # +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); + +CREATE TABLE `t1` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) ENGINE=MYISAM; +CREATE TABLE `t2` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL ) ENGINE=MYISAM; +SET spider_same_server_link= on; +CREATE TABLE `t1_spider` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) COMMENT='wrapper "mysql",srv "srv", table "t1"' ENGINE=SPIDER; +CREATE TABLE `t2_spider` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL +, PRIMARY KEY (`a`) USING BTREE +) COMMENT='wrapper "mysql",srv "srv",table "t2"' ENGINE=SPIDER; +INSERT INTO t1_spider VALUES(1,'oooo'); +INSERT INTO t2_spider VALUES(1,1); +SELECT t2_spider.a,t1_spider.c FRoM t2_spider LEFT join t1_spider ON (t2_spider.c = t1_spider.c) WHERE t2_spider.a = 1; + +drop table t1, t2, t1_spider, t2_spider; +drop server srv; +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index c239baf636d..a2262956d44 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -5566,6 +5566,17 @@ int spider_db_mbase_util::check_item_func( if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY) DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); break; + case Item_func::MULT_EQUAL_FUNC: + /* If there is still Item_equal by the time of + JOIN::make_aggr_tables_info() where the spider group by handler + is created, it indicates a bug in the optimizer, because there + shouldn't be any. */ + push_warning_printf( + spider->trx->thd, SPIDER_WARN_LEVEL_WARN, ER_INTERNAL_ERROR, + ER_THD(spider->trx->thd, ER_INTERNAL_ERROR), + "Spider group by handler: Encountered multiple equalities, likely " + "an optimizer bug"); + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); default: break; } @@ -6492,6 +6503,17 @@ int spider_db_mbase_util::print_item_func( last_str = SPIDER_SQL_CLOSE_PAREN_STR; last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN; break; + case Item_func::MULT_EQUAL_FUNC: + /* If there is still Item_equal by the time of + JOIN::make_aggr_tables_info() where the spider group by handler + is created, it indicates a bug in the optimizer, because there + shouldn't be any. */ + push_warning_printf( + spider->trx->thd, SPIDER_WARN_LEVEL_WARN, ER_INTERNAL_ERROR, + ER_THD(spider->trx->thd, ER_INTERNAL_ERROR), + "Spider group by handler: Encountered multiple equalities, likely " + "an optimizer bug"); + DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); default: THD *thd = spider->trx->thd; SPIDER_SHARE *share = spider->share; From e865ef6a04db3d54acd43b748633376f85a6689e Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 25 Mar 2024 14:06:27 +1100 Subject: [PATCH 078/313] MDEV-33742 Remove macro PARTITION_HAS_GET_CHILD_HANDLERS Similar to MDEV-27658. Also fixing the positioning of #ifdef WITH_PARTITION_STORAGE_ENGINE blocks and add missing ones. --- storage/spider/spd_environ.h | 1 - storage/spider/spd_group_by_handler.cc | 30 ++++++-------------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/storage/spider/spd_environ.h b/storage/spider/spd_environ.h index 5a6b824fd30..247b3bc525f 100644 --- a/storage/spider/spd_environ.h +++ b/storage/spider/spd_environ.h @@ -27,7 +27,6 @@ #define HANDLER_HAS_TOP_TABLE_FIELDS #define HANDLER_HAS_DIRECT_UPDATE_ROWS #define HANDLER_HAS_DIRECT_AGGREGATE -#define PARTITION_HAS_GET_CHILD_HANDLERS #define PARTITION_HAS_GET_PART_SPEC #define HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN #define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 167f8c3adff..2f8f40eaa97 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1433,38 +1433,32 @@ group_by_handler *spider_create_group_by_handler( break; } -#ifdef WITH_PARTITION_STORAGE_ENGINE from = query->from; do { DBUG_PRINT("info",("spider from=%p", from)); ++table_count; +#ifdef WITH_PARTITION_STORAGE_ENGINE if (from->table->part_info) { DBUG_PRINT("info",("spider partition handler")); -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) partition_info *part_info = from->table->part_info; uint bits = bitmap_bits_set(&part_info->read_partitions); DBUG_PRINT("info",("spider bits=%u", bits)); if (bits != 1) { DBUG_PRINT("info",("spider using multiple partitions is not supported by this feature yet")); -#else - DBUG_PRINT("info",("spider partition is not supported by this feature yet")); -#endif DBUG_RETURN(NULL); -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) } -#endif } - } while ((from = from->next_local)); #endif + } while ((from = from->next_local)); if (!(table_holder= spider_create_table_holder(table_count))) DBUG_RETURN(NULL); table_idx = 0; from = query->from; -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) +#ifdef WITH_PARTITION_STORAGE_ENGINE if (from->table->part_info) { partition_info *part_info = from->table->part_info; @@ -1473,9 +1467,7 @@ group_by_handler *spider_create_group_by_handler( handler **handlers = partition->get_child_handlers(); spider = (ha_spider *) handlers[part]; } else { -#endif spider = (ha_spider *) from->table->file; -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) } #endif share = spider->share; @@ -1499,7 +1491,7 @@ group_by_handler *spider_create_group_by_handler( } while ((from = from->next_local)) { -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) +#ifdef WITH_PARTITION_STORAGE_ENGINE if (from->table->part_info) { partition_info *part_info = from->table->part_info; @@ -1508,9 +1500,7 @@ group_by_handler *spider_create_group_by_handler( handler **handlers = partition->get_child_handlers(); spider = (ha_spider *) handlers[part]; } else { -#endif spider = (ha_spider *) from->table->file; -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) } #endif share = spider->share; @@ -1541,7 +1531,7 @@ group_by_handler *spider_create_group_by_handler( from = query->from; do { -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) +#ifdef WITH_PARTITION_STORAGE_ENGINE if (from->table->part_info) { partition_info *part_info = from->table->part_info; @@ -1550,9 +1540,7 @@ group_by_handler *spider_create_group_by_handler( handler **handlers = partition->get_child_handlers(); spider = (ha_spider *) handlers[part]; } else { -#endif spider = (ha_spider *) from->table->file; -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) } #endif share = spider->share; @@ -1684,7 +1672,7 @@ group_by_handler *spider_create_group_by_handler( goto skip_free_table_holder; from = query->from; -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) +#ifdef WITH_PARTITION_STORAGE_ENGINE if (from->table->part_info) { partition_info *part_info = from->table->part_info; @@ -1693,9 +1681,7 @@ group_by_handler *spider_create_group_by_handler( handler **handlers = partition->get_child_handlers(); spider = (ha_spider *) handlers[part]; } else { -#endif spider = (ha_spider *) from->table->file; -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) } #endif share = spider->share; @@ -1758,7 +1744,7 @@ group_by_handler *spider_create_group_by_handler( { fields->clear_conn_holder_from_conn(); -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) +#ifdef WITH_PARTITION_STORAGE_ENGINE if (from->table->part_info) { partition_info *part_info = from->table->part_info; @@ -1767,9 +1753,7 @@ group_by_handler *spider_create_group_by_handler( handler **handlers = partition->get_child_handlers(); spider = (ha_spider *) handlers[part]; } else { -#endif spider = (ha_spider *) from->table->file; -#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) } #endif share = spider->share; From f9e0ebeca49b706fa6c8b39d29eb86b57dcf957d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 8 Apr 2024 14:28:23 +1000 Subject: [PATCH 079/313] MDEV-33742 Do not create group by handler when all tables are constant --- sql/sql_select.cc | 2 +- storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result | 2 -- storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result | 2 -- .../r/partition_join_pushdown_for_single_partition.result | 2 -- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index efcd42be074..af51c3334a8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3367,7 +3367,7 @@ bool JOIN::make_aggr_tables_info() distinct in the engine, so we do this for all queries, not only GROUP BY queries. */ - if (tables_list && top_join_tab_count && !procedure) + if (tables_list && top_join_tab_count && !only_const_tables() && !procedure) { /* At the moment we only support push down for queries where diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result index edb45e4a62a..5d483481edd 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result @@ -72,7 +72,6 @@ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; argument select `pkey`,`val` from `auto_test_remote`.`tbl_a` select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 1 -select 1 from (select 1) t0 select `pkey`,`val` from `auto_test_remote`.`tbl_a` select `pkey`,`val` from `auto_test_remote`.`tbl_a` SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' @@ -86,7 +85,6 @@ argument select `pkey`,`val` from `auto_test_remote2`.`tbl_a` select `pkey`,`val` from `auto_test_remote2`.`tbl_a` select `pkey`,`val` from `auto_test_remote2`.`tbl_a` where `pkey` = 2 -select 1 from (select 1) t0 select `pkey`,`val` from `auto_test_remote2`.`tbl_a` SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' SELECT pkey, val FROM tbl_a ORDER BY pkey; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result index 0a11fe429cb..c021bc70e57 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33679.result @@ -18,8 +18,6 @@ INSERT INTO t2_spider VALUES(1,1); SELECT t2_spider.a,t1_spider.c FRoM t2_spider LEFT join t1_spider ON (t2_spider.c = t1_spider.c) WHERE t2_spider.a = 1; a c 1 1 -Warnings: -Warning 1815 Internal error: Spider group by handler: Encountered multiple equalities, likely an optimizer bug drop table t1, t2, t1_spider, t2_spider; drop server srv; for master_1 diff --git a/storage/spider/mysql-test/spider/r/partition_join_pushdown_for_single_partition.result b/storage/spider/mysql-test/spider/r/partition_join_pushdown_for_single_partition.result index 5026025dfd0..899788ae1c1 100644 --- a/storage/spider/mysql-test/spider/r/partition_join_pushdown_for_single_partition.result +++ b/storage/spider/mysql-test/spider/r/partition_join_pushdown_for_single_partition.result @@ -86,10 +86,8 @@ SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; argument select `value` from `auto_test_remote2`.`tbl_a` where `value` = 5 select `value2` from `auto_test_remote2`.`tbl_b` where `value2` = 5 -select sum('5') `sum(a.value)`,count('5') `count(b.value2)` from (select 1) t0 join (select 1) t1 select `value` from `auto_test_remote2`.`tbl_a` where `value` = 5 select `value2` from `auto_test_remote2`.`tbl_b` where `value2` = 5 -select sum('5') `sum(a.value)`,count('5') `count(b.value2)` from (select 1) t0 join (select 1) t1 SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' SELECT value FROM tbl_a ORDER BY value; value From a73c3f1077d3dd46f9a51e53a1666ab76b7d52e0 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 8 Apr 2024 16:35:21 +1000 Subject: [PATCH 080/313] MDEV-21007 Do not assert auto_increment_value unless all parts open Commit 6dce6aecebe6ef78a14cb5c5c5daa8a355551e40 breaks out of a loop in ha_partition::info when some partitions aren't opened, in which case auto_increment_value assertion will fail. This commit patches that hole. --- mysql-test/suite/parts/r/mdev_21007.result | 5 +++++ mysql-test/suite/parts/t/mdev_21007.test | 9 +++++++++ sql/ha_partition.cc | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/parts/r/mdev_21007.result create mode 100644 mysql-test/suite/parts/t/mdev_21007.test diff --git a/mysql-test/suite/parts/r/mdev_21007.result b/mysql-test/suite/parts/r/mdev_21007.result new file mode 100644 index 00000000000..fb2417ac3ae --- /dev/null +++ b/mysql-test/suite/parts/r/mdev_21007.result @@ -0,0 +1,5 @@ +CREATE TABLE t1 (a INT) PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (1), PARTITION p1 VALUES LESS THAN (MAXVALUE)); +INSERT INTO t1 VALUES (1),(2); +ALTER TABLE t1 MODIFY a INT AUTO_INCREMENT PRIMARY KEY; +UPDATE t1 PARTITION (p1) SET a=9 ORDER BY a LIMIT 1; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/mdev_21007.test b/mysql-test/suite/parts/t/mdev_21007.test new file mode 100644 index 00000000000..ec6fbe4d108 --- /dev/null +++ b/mysql-test/suite/parts/t/mdev_21007.test @@ -0,0 +1,9 @@ +--source include/have_partition.inc + +CREATE TABLE t1 (a INT) PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (1), PARTITION p1 VALUES LESS THAN (MAXVALUE)); +INSERT INTO t1 VALUES (1),(2); +ALTER TABLE t1 MODIFY a INT AUTO_INCREMENT PRIMARY KEY; +UPDATE t1 PARTITION (p1) SET a=9 ORDER BY a LIMIT 1; + +# Cleanup +DROP TABLE t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index f0421fa4026..f6acaa8c77e 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -8416,7 +8416,7 @@ int ha_partition::info(uint flag) file->stats.auto_increment_value); } while (*(++file_array)); - DBUG_ASSERT(auto_increment_value); + DBUG_ASSERT(!all_parts_opened || auto_increment_value); stats.auto_increment_value= auto_increment_value; if (all_parts_opened && auto_inc_is_first_in_idx) { From 73291de74e49a84700ce4e2aa2c7ec6769d884dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 8 Apr 2024 11:48:46 +0300 Subject: [PATCH 081/313] MDEV-33819 The purge of committed history is mis-parsing some log In commit aa719b5010c929132b4460b78113fbd07497d9c8 (part of MDEV-32050) a bug was introduced in the function purge_sys_t::choose_next_log(), which reimplements some logic that previously was part of trx_purge_read_undo_rec(). We must invoke trx_undo_get_first_rec() with the page number and offset of the undo log header, but we were incorrectly invoking it on the current undo page number, which caused us to parse undo records starting at an incorrect offset. purge_sys_t::choose_next_log(): Pass the correct parameter to trx_undo_page_get_first_rec(). trx_undo_page_get_next_rec(), trx_undo_page_get_first_rec(), trx_undo_page_get_last_rec(): Add debug assertions and make the code more robust by returning nullptr on corruption. Should we detect any corrupted undo logs during the purge of committed transaction history, the sanest thing to do is to pretend that the end of an undo log was reached. If any garbage is left in the tables, it will be ignored by anything else than CHECK TABLE ... EXTENDED, and it can be removed by OPTIMIZE TABLE. Thanks to Matthias Leich for providing an "rr replay" trace where this bug could be found. Reviewed by: Vladislav Lesin --- storage/innobase/include/trx0undo.inl | 3 ++- storage/innobase/trx/trx0purge.cc | 5 ++--- storage/innobase/trx/trx0undo.cc | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/storage/innobase/include/trx0undo.inl b/storage/innobase/include/trx0undo.inl index 9f05989f634..023e2b98fb2 100644 --- a/storage/innobase/include/trx0undo.inl +++ b/storage/innobase/include/trx0undo.inl @@ -125,5 +125,6 @@ trx_undo_page_get_next_rec(const buf_block_t *undo_page, uint16_t rec, { uint16_t end= trx_undo_page_get_end(undo_page, page_no, offset); uint16_t next= mach_read_from_2(undo_page->page.frame + rec); - return next == end ? nullptr : undo_page->page.frame + next; + ut_ad(next <= end); + return next >= end ? nullptr : undo_page->page.frame + next; } diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 2445b85939d..0f5d59ffb2d 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -793,8 +793,7 @@ bool purge_sys_t::rseg_get_next_history_log() /* Read the previous log header. */ trx_id_t trx_no= 0; if (const buf_block_t* undo_page= - get_page(page_id_t(rseg->space->id, - prev_log_addr.page))) + get_page(page_id_t(rseg->space->id, prev_log_addr.page))) { const byte *log_hdr= undo_page->page.frame + prev_log_addr.boffset; trx_no= mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO); @@ -887,7 +886,7 @@ bool purge_sys_t::choose_next_log() if (!b) goto purge_nothing; undo_rec= - trx_undo_page_get_first_rec(b, page_no, hdr_offset); + trx_undo_page_get_first_rec(b, hdr_page_no, hdr_offset); if (!undo_rec) goto purge_nothing; } diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index ccc68dfeef7..8f1ff53e9d8 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -134,8 +134,9 @@ trx_undo_page_get_first_rec(const buf_block_t *block, uint32_t page_no, uint16_t offset) { uint16_t start= trx_undo_page_get_start(block, page_no, offset); - return start == trx_undo_page_get_end(block, page_no, offset) - ? nullptr : block->page.frame + start; + uint16_t end= trx_undo_page_get_end(block, page_no, offset); + ut_ad(start <= end); + return start >= end ? nullptr : block->page.frame + start; } /** Get the last undo log record on a page. @@ -149,8 +150,10 @@ trx_undo_rec_t* trx_undo_page_get_last_rec(const buf_block_t *block, uint32_t page_no, uint16_t offset) { + uint16_t start= trx_undo_page_get_start(block, page_no, offset); uint16_t end= trx_undo_page_get_end(block, page_no, offset); - return trx_undo_page_get_start(block, page_no, offset) == end + ut_ad(start <= end); + return start >= end ? nullptr : block->page.frame + mach_read_from_2(block->page.frame + end - 2); } From 188c5da72a0057e4572b1d7e4efcd0c39332a839 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 8 Apr 2024 14:24:20 +0530 Subject: [PATCH 082/313] MDEV-32453 Bulk insert fails to apply when trigger does insert operation Reason: ======= - InnoDB fails to apply the buffered insert operation if the after insert trigger does change the same table. This behaviour leads to empty table for the subsequent insert operation and server abort. Solution: ======== - InnoDB should apply buffered insert operation if "after insert" trigger changes the same table. --- .../suite/innodb/r/insert_into_empty.result | 12 +++++++ .../suite/innodb/t/insert_into_empty.test | 13 +++++++ storage/innobase/handler/ha_innodb.cc | 4 +-- storage/innobase/include/trx0trx.h | 6 ++++ storage/innobase/row/row0merge.cc | 35 +++++++++++++------ 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index 0cdee172696..5e358ee8836 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -467,3 +467,15 @@ DROP TABLE t1; CREATE TABLE t (a CHAR CHARACTER SET utf8) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; INSERT t SELECT left(seq,1) FROM seq_1_to_43691; DROP TABLE t; +# +# MDEV-32453 Bulk insert fails to apply when trigger +# does insert operation +# +CREATE TABLE t(c INT)ENGINE=InnoDB; +CREATE TRIGGER t2_ai AFTER INSERT ON t FOR EACH ROW SET @a:=(SELECT * FROM t); +BEGIN; +INSERT INTO t VALUES (1),(1); +ERROR 21000: Subquery returns more than 1 row +COMMIT; +DROP TABLE t; +# End of 10.11 tests diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index baba5a146cc..3c3efc2381e 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -495,3 +495,16 @@ DROP TABLE t1; CREATE TABLE t (a CHAR CHARACTER SET utf8) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; INSERT t SELECT left(seq,1) FROM seq_1_to_43691; DROP TABLE t; + +--echo # +--echo # MDEV-32453 Bulk insert fails to apply when trigger +--echo # does insert operation +--echo # +CREATE TABLE t(c INT)ENGINE=InnoDB; +CREATE TRIGGER t2_ai AFTER INSERT ON t FOR EACH ROW SET @a:=(SELECT * FROM t); +BEGIN; +--error ER_SUBQUERY_NO_1_ROW +INSERT INTO t VALUES (1),(1); +COMMIT; +DROP TABLE t; +--echo # End of 10.11 tests diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0b6eb2e0259..13f46d8582a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -15824,7 +15824,7 @@ ha_innobase::start_stmt( } /* fall through */ default: - trx->end_bulk_insert(*m_prebuilt->table); + trx->bulk_insert_apply_for_table(m_prebuilt->table); if (!trx->bulk_insert) { break; } @@ -16018,7 +16018,7 @@ ha_innobase::external_lock( } /* fall through */ default: - trx->end_bulk_insert(*m_prebuilt->table); + trx->bulk_insert_apply_for_table(m_prebuilt->table); if (!trx->bulk_insert) { break; } diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index d815e7930bd..152553544df 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1188,10 +1188,16 @@ public: return UNIV_UNLIKELY(bulk_insert) ? bulk_insert_apply_low(): DB_SUCCESS; } + /** Do the bulk insert for the buffered insert operation of a table. + @param table bulk insert operation + @return DB_SUCCESS or error code. */ + dberr_t bulk_insert_apply_for_table(dict_table_t *table); private: /** Apply the buffered bulk inserts. */ dberr_t bulk_insert_apply_low(); + /** Rollback the bulk insert operation for the transaction */ + void bulk_rollback_low(); /** Assign a rollback segment for modifying temporary tables. @return the assigned rollback segment */ trx_rseg_t *assign_temp_rseg(); diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 54d7abb4527..ca9f47c8d86 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -5351,18 +5351,8 @@ dberr_t trx_mod_table_time_t::write_bulk(dict_table_t *table, trx_t *trx) return err; } -dberr_t trx_t::bulk_insert_apply_low() +void trx_t::bulk_rollback_low() { - ut_ad(bulk_insert); - ut_ad(!check_unique_secondary); - ut_ad(!check_foreigns); - dberr_t err; - for (auto& t : mod_tables) - if (t.second.is_bulk_insert()) - if ((err= t.second.write_bulk(t.first, this)) != DB_SUCCESS) - goto bulk_rollback; - return DB_SUCCESS; -bulk_rollback: undo_no_t low_limit= UINT64_MAX; for (auto& t : mod_tables) { @@ -5376,5 +5366,28 @@ bulk_rollback: } trx_savept_t bulk_save{low_limit}; rollback(&bulk_save); +} + +dberr_t trx_t::bulk_insert_apply_for_table(dict_table_t *table) +{ + auto t= check_bulk_buffer(table); + if (!t || !t->is_bulk_insert()) + return DB_SUCCESS; + dberr_t err= t->write_bulk(table, this); + if (err != DB_SUCCESS) + bulk_rollback_low(); return err; } + +dberr_t trx_t::bulk_insert_apply_low() +{ + ut_ad(bulk_insert); + for (auto& t : mod_tables) + if (t.second.is_bulk_insert()) + if (dberr_t err= t.second.write_bulk(t.first, this)) + { + bulk_rollback_low(); + return err; + } + return DB_SUCCESS; +} From 11986ec6541733477cb5dd312bac1dc64ed7e57c Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Apr 2024 14:56:31 +0400 Subject: [PATCH 083/313] MDEV-31251 MDEV-30968 breaks running mariabackup on older mariadb (opendir(NULL)) The problem happened when running mariabackup agains a pre-MDEV-30971 server, i.e. not having yet the system variable @@aria_log_dir_path. As a result, backup_start() called the function backup_files_from_datadir() with a NULL value, which further caused a crash. Fix: Perform this call: backup_files_from_datadir(.., aria_log_dir_path, ..) only if aria_log_dir_path is not NULL. Otherwise, assume that Aria log files are in their default location, so they've just copied by the previous call: backup_files_from_datadir(.., fil_path_to_mysql_datadir, ..) Thanks to Walter Doekes for a patch proposal. --- extra/mariabackup/backup_copy.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index 7b3336f67b7..90081ccb650 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1439,9 +1439,10 @@ bool backup_start(ds_ctxt *ds_data, ds_ctxt *ds_meta, if (!backup_files_from_datadir(ds_data, fil_path_to_mysql_datadir, "aws-kms-key") || - !backup_files_from_datadir(ds_data, - aria_log_dir_path, - "aria_log")) { + (aria_log_dir_path && + !backup_files_from_datadir(ds_data, + aria_log_dir_path, + "aria_log"))) { return false; } From 3c40f8bafba8d525b2b9b2c3b1c3427b20848d01 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Fri, 5 Apr 2024 18:08:53 +0530 Subject: [PATCH 084/313] MDEV-31402: SIGSEGV in json_get_path_next | Item_func_json_extract::read_json --- mysql-test/main/func_json.result | 7 +++++++ mysql-test/main/func_json.test | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index d6b25cfcb2a..e40951a0b1f 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1690,5 +1690,12 @@ select json_arrayagg('ä'), json_objectagg(1, 'ä'); json_arrayagg('ä') json_objectagg(1, 'ä') ["ä"] {"1":"ä"} # +# MDEV-31402: SIGSEGV in json_get_path_next | Item_func_json_extract::read_json +# +CREATE TABLE t (id CHAR AS (JSON_COMPACT (JSON_EXTRACT(doc,"$._id"))) UNIQUE KEY,doc JSON,CONSTRAINT notnu CHECK (id IS NOT NULL)); +INSERT INTO t (doc) VALUES ('{ "_id" : { "$oid" : "0ca0b0f0" },"a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" :0} ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] }'); +ERROR 22001: Data too long for column 'id' at row 1 +DROP TABLE t; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index dd6e393501f..c881ede45ce 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1115,6 +1115,16 @@ set names latin1; select json_arrayagg('ä'), json_objectagg(1, 'ä'); --enable_service_connection +--echo # +--echo # MDEV-31402: SIGSEGV in json_get_path_next | Item_func_json_extract::read_json +--echo # + +CREATE TABLE t (id CHAR AS (JSON_COMPACT (JSON_EXTRACT(doc,"$._id"))) UNIQUE KEY,doc JSON,CONSTRAINT notnu CHECK (id IS NOT NULL)); +--error ER_DATA_TOO_LONG +INSERT INTO t (doc) VALUES ('{ "_id" : { "$oid" : "0ca0b0f0" },"a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" :0} ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] }'); + +DROP TABLE t; + --echo # --echo # End of 10.5 tests --echo # From 89c907bd4f713b77e248f7c8e6247b5f3be18fb4 Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Wed, 13 Mar 2024 14:42:28 -0600 Subject: [PATCH 085/313] MDEV-33672: Gtid_log_event Construction from File Should Ensure Event Length When Using Extra Flags A GTID event can have variable length, with contributing factors such as the variable length from the flags2 and optional extra flags fields. These fields are bitmaps, where each set bit indicates an additional value that should be appended to the event, e.g. multi-engine transactions append a number to indicate the number of additional engines a transaction uses. However, if a flags bit is set, and no additional fields are appended to the event, MDEV-33672 reports that the server can still try to read from memory as if it did exist. Note, however, in debug builds, this condition is asserted for FL_EXTRA_MULTI_ENGINE. This patch fixes this to check that the length of the event is aligned with the expectation set by the flags for FL_PREPARED_XA, FL_COMPLETED_XA, and FL_EXTRA_MULTI_ENGINE. Reviewed By ============ Kristian Nielsen --- .../suite/rpl/r/rpl_gtid_header_valid.result | 122 ++++++++++++ .../suite/rpl/t/rpl_gtid_header_valid.test | 181 ++++++++++++++++++ sql/log_event.cc | 17 +- sql/log_event.h | 11 +- sql/log_event_server.cc | 22 ++- 5 files changed, 349 insertions(+), 4 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_gtid_header_valid.result create mode 100644 mysql-test/suite/rpl/t/rpl_gtid_header_valid.test diff --git a/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result b/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result new file mode 100644 index 00000000000..fd440feb3c9 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result @@ -0,0 +1,122 @@ +include/master-slave.inc +[connection master] +# +# Initialize test data +connection master; +create table t1 (a int) engine=innodb; +include/save_master_gtid.inc +set @@SESSION.debug_dbug= "+d,binlog_force_commit_id"; +connection slave; +set SQL_LOG_BIN= 0; +call mtr.add_suppression('Found invalid event in binary log'); +call mtr.add_suppression('Slave SQL.*Relay log read failure: Could not parse relay log event entry.* 1594'); +set SQL_LOG_BIN= 1; +include/sync_with_master_gtid.inc +include/stop_slave.inc +include/start_slave.inc +# +# Test FL_PREPARED_XA +connection master; +set @@SESSION.debug_dbug= "+d,negate_xid_from_gtid"; +set @commit_id= 100; +XA START 'x1'; +insert into t1 values (1); +XA END 'x1'; +XA PREPARE 'x1'; +set @@SESSION.debug_dbug= "-d,negate_xid_from_gtid"; +XA COMMIT 'x1'; +include/save_master_gtid.inc +# Waiting for slave to find invalid event.. +connection slave; +include/wait_for_slave_sql_error.inc [errno=1594] +STOP SLAVE IO_THREAD; +# Reset master binlogs (as there is an invalid event) and slave state +connection master; +RESET MASTER; +connection slave; +RESET MASTER; +RESET SLAVE; +set @@global.gtid_slave_pos=""; +include/start_slave.inc +# +# Test FL_COMPLETED_XA +connection master; +set @commit_id= 101; +XA START 'x1'; +insert into t1 values (2); +XA END 'x1'; +XA PREPARE 'x1'; +set @@SESSION.debug_dbug= "+d,negate_xid_from_gtid"; +XA COMMIT 'x1'; +set @@SESSION.debug_dbug= "-d,negate_xid_from_gtid"; +include/save_master_gtid.inc +# Waiting for slave to find invalid event.. +connection slave; +include/wait_for_slave_sql_error.inc [errno=1594] +STOP SLAVE IO_THREAD; +# Cleanup hanging XA PREPARE on slave +set statement SQL_LOG_BIN=0 for XA COMMIT 'x1'; +# Reset master binlogs (as there is an invalid event) and slave state +connection master; +RESET MASTER; +connection slave; +RESET MASTER; +RESET SLAVE; +set @@global.gtid_slave_pos=""; +include/start_slave.inc +# +# Test Missing xid.data (but has format id and length description parts) +connection master; +set @commit_id= 101; +XA START 'x1'; +insert into t1 values (1); +XA END 'x1'; +XA PREPARE 'x1'; +set @@SESSION.debug_dbug= "+d,negate_xid_data_from_gtid"; +XA COMMIT 'x1'; +set @@SESSION.debug_dbug= "-d,negate_xid_data_from_gtid"; +include/save_master_gtid.inc +# Waiting for slave to find invalid event.. +connection slave; +include/wait_for_slave_sql_error.inc [errno=1594] +STOP SLAVE IO_THREAD; +# Cleanup hanging XA PREPARE on slave +set statement SQL_LOG_BIN=0 for XA COMMIT 'x1'; +# Reset master binlogs (as there is an invalid event) and slave state +connection master; +RESET MASTER; +connection slave; +RESET MASTER; +RESET SLAVE; +set @@global.gtid_slave_pos=""; +include/start_slave.inc +# +# Test FL_EXTRA_MULTI_ENGINE +connection master; +set @old_dbug= @@SESSION.debug_dbug; +set @@SESSION.debug_dbug= "+d,inject_fl_extra_multi_engine_into_gtid"; +set @commit_id= 102; +insert into t1 values (3); +include/save_master_gtid.inc +set @@SESSION.debug_dbug=@old_dbug; +connection slave; +# Waiting for slave to find invalid event.. +include/wait_for_slave_sql_error.inc [errno=1594] +STOP SLAVE IO_THREAD; +# Reset master binlogs (as there is an invalid event) and slave state +connection master; +RESET MASTER; +connection slave; +RESET SLAVE; +RESET MASTER; +set @@global.gtid_slave_pos=""; +include/start_slave.inc +# +# Cleanup +connection master; +drop table t1; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +include/rpl_end.inc +# End of rpl_gtid_header_valid.test diff --git a/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test b/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test new file mode 100644 index 00000000000..db546787914 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test @@ -0,0 +1,181 @@ +# +# This test ensures that, when a GTID event is constructed by reading its +# content from a binlog file, the reader (e.g. replica, in this test) cannot +# read beyond the length of the GTID event. That is, we ensure that the +# structure indicated by its flags and extra_flags are consistent with the +# actual content of the event. +# +# To spoof a broken GTID log event, we use the DEBUG_DBUG mechanism to inject +# the master to write invalid GTID events for each flag. The transaction is +# given a commit id to ensure the event is not shorter than GTID_HEADER_LEN, +# which would result in zero padding up to GTID_HEADER_LEN. +# +# +# References: +# MDEV-33672: Gtid_log_event Construction from File Should Ensure Event +# Length When Using Extra Flags +# + +--source include/have_debug.inc + +# GTID event extra_flags are format independent +--source include/have_binlog_format_row.inc +--source include/have_innodb.inc +--source include/master-slave.inc + +--echo # +--echo # Initialize test data +--connection master +create table t1 (a int) engine=innodb; +--source include/save_master_gtid.inc +set @@SESSION.debug_dbug= "+d,binlog_force_commit_id"; + +--connection slave +set SQL_LOG_BIN= 0; +call mtr.add_suppression('Found invalid event in binary log'); +call mtr.add_suppression('Slave SQL.*Relay log read failure: Could not parse relay log event entry.* 1594'); +set SQL_LOG_BIN= 1; +--source include/sync_with_master_gtid.inc +--source include/stop_slave.inc +--source include/start_slave.inc +--let $cid_ctr= 100 + + +--echo # +--echo # Test FL_PREPARED_XA +--connection master +set @@SESSION.debug_dbug= "+d,negate_xid_from_gtid"; +--eval set @commit_id= $cid_ctr + +XA START 'x1'; +insert into t1 values (1); +XA END 'x1'; +XA PREPARE 'x1'; +set @@SESSION.debug_dbug= "-d,negate_xid_from_gtid"; +XA COMMIT 'x1'; +--source include/save_master_gtid.inc + +--echo # Waiting for slave to find invalid event.. +--connection slave +let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE +source include/wait_for_slave_sql_error.inc; +STOP SLAVE IO_THREAD; + +--echo # Reset master binlogs (as there is an invalid event) and slave state +--connection master +RESET MASTER; +--connection slave +RESET MASTER; +RESET SLAVE; +set @@global.gtid_slave_pos=""; +--source include/start_slave.inc + + +--echo # +--echo # Test FL_COMPLETED_XA +--connection master +--inc $cid_ctr +--eval set @commit_id= $cid_ctr +XA START 'x1'; +--let $next_val = `SELECT max(a)+1 FROM t1` +--eval insert into t1 values ($next_val) +XA END 'x1'; +XA PREPARE 'x1'; +set @@SESSION.debug_dbug= "+d,negate_xid_from_gtid"; +XA COMMIT 'x1'; +set @@SESSION.debug_dbug= "-d,negate_xid_from_gtid"; +--source include/save_master_gtid.inc + +--echo # Waiting for slave to find invalid event.. +--connection slave +let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE +source include/wait_for_slave_sql_error.inc; +STOP SLAVE IO_THREAD; + +--echo # Cleanup hanging XA PREPARE on slave +set statement SQL_LOG_BIN=0 for XA COMMIT 'x1'; + +--echo # Reset master binlogs (as there is an invalid event) and slave state +--connection master +RESET MASTER; +--connection slave +RESET MASTER; +RESET SLAVE; +set @@global.gtid_slave_pos=""; +--source include/start_slave.inc + + +--echo # +--echo # Test Missing xid.data (but has format id and length description parts) + +--connection master +--eval set @commit_id= $cid_ctr + +XA START 'x1'; +insert into t1 values (1); +XA END 'x1'; +XA PREPARE 'x1'; +set @@SESSION.debug_dbug= "+d,negate_xid_data_from_gtid"; +XA COMMIT 'x1'; +set @@SESSION.debug_dbug= "-d,negate_xid_data_from_gtid"; +--source include/save_master_gtid.inc + +--echo # Waiting for slave to find invalid event.. +--connection slave +let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE +source include/wait_for_slave_sql_error.inc; +STOP SLAVE IO_THREAD; + +--echo # Cleanup hanging XA PREPARE on slave +set statement SQL_LOG_BIN=0 for XA COMMIT 'x1'; + +--echo # Reset master binlogs (as there is an invalid event) and slave state +--connection master +RESET MASTER; +--connection slave +RESET MASTER; +RESET SLAVE; +set @@global.gtid_slave_pos=""; +--source include/start_slave.inc + + +--echo # +--echo # Test FL_EXTRA_MULTI_ENGINE +--connection master +set @old_dbug= @@SESSION.debug_dbug; +set @@SESSION.debug_dbug= "+d,inject_fl_extra_multi_engine_into_gtid"; +--inc $cid_ctr +--eval set @commit_id= $cid_ctr +--let $next_val = `SELECT max(a)+1 FROM t1` +--eval insert into t1 values ($next_val) +--source include/save_master_gtid.inc +set @@SESSION.debug_dbug=@old_dbug; + +--connection slave +--echo # Waiting for slave to find invalid event.. +let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE +source include/wait_for_slave_sql_error.inc; +STOP SLAVE IO_THREAD; + +--echo # Reset master binlogs (as there is an invalid event) and slave state +--connection master +RESET MASTER; + +--connection slave +RESET SLAVE; +RESET MASTER; +set @@global.gtid_slave_pos=""; +--source include/start_slave.inc + +--echo # +--echo # Cleanup + +--connection master +drop table t1; +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--source include/rpl_end.inc +--echo # End of rpl_gtid_header_valid.test diff --git a/sql/log_event.cc b/sql/log_event.cc index 6779419e682..501dfffb774 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2629,6 +2629,11 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, } if (flags2 & (FL_PREPARED_XA | FL_COMPLETED_XA)) { + if (event_len < static_cast(buf - buf_0) + 6) + { + seq_no= 0; + return; + } xid.formatID= uint4korr(buf); buf+= 4; @@ -2637,6 +2642,11 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, buf+= 2; long data_length= xid.bqual_length + xid.gtrid_length; + if (event_len < static_cast(buf - buf_0) + data_length) + { + seq_no= 0; + return; + } memcpy(xid.data, buf, data_length); buf+= data_length; } @@ -2651,8 +2661,11 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, */ if (flags_extra & FL_EXTRA_MULTI_ENGINE) { - DBUG_ASSERT(static_cast(buf - buf_0) < event_len); - + if (event_len < static_cast(buf - buf_0) + 1) + { + seq_no= 0; + return; + } extra_engines= *buf++; DBUG_ASSERT(extra_engines > 0); diff --git a/sql/log_event.h b/sql/log_event.h index fca4015a15d..879a5a78270 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -3666,7 +3666,16 @@ public: { return GTID_HEADER_LEN + ((flags2 & FL_GROUP_COMMIT_ID) ? 2 : 0); } - bool is_valid() const { return seq_no != 0; } + + bool is_valid() const + { + /* + seq_no is set to 0 if the structure of a serialized GTID event does not + align with that as indicated by flags and extra_flags. + */ + return seq_no != 0; + } + #ifdef MYSQL_SERVER bool write(); static int make_compatible_event(String *packet, bool *need_dummy_event, diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 77856cde6f1..f4fddcd1f65 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -3411,21 +3411,41 @@ Gtid_log_event::write() write_len= GTID_HEADER_LEN + 2; } - if (flags2 & (FL_PREPARED_XA | FL_COMPLETED_XA)) + if (flags2 & (FL_PREPARED_XA | FL_COMPLETED_XA) +#ifndef DBUG_OFF + && DBUG_EVALUATE_IF("negate_xid_from_gtid", 0, 1) +#endif + ) { int4store(&buf[write_len], xid.formatID); buf[write_len +4]= (uchar) xid.gtrid_length; buf[write_len +4+1]= (uchar) xid.bqual_length; write_len+= 6; long data_length= xid.bqual_length + xid.gtrid_length; + +#ifndef DBUG_OFF + if (DBUG_EVALUATE_IF("negate_xid_data_from_gtid", 0, 1)) + { +#endif memcpy(buf+write_len, xid.data, data_length); write_len+= data_length; +#ifndef DBUG_OFF + } +#endif } + + DBUG_EXECUTE_IF("inject_fl_extra_multi_engine_into_gtid", { + flags_extra|= FL_EXTRA_MULTI_ENGINE; + }); if (flags_extra > 0) { buf[write_len]= flags_extra; write_len++; } + DBUG_EXECUTE_IF("inject_fl_extra_multi_engine_into_gtid", { + flags_extra&= ~FL_EXTRA_MULTI_ENGINE; + }); + if (flags_extra & FL_EXTRA_MULTI_ENGINE) { buf[write_len]= extra_engines; From fcd345de485fc849fc6cf5177e680b3d423eb291 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Fri, 10 Nov 2023 16:01:15 +0530 Subject: [PATCH 086/313] MDEV-32726: Fix failing test fir freebsd for json Json test about max statement time fails with freebsd because on some architectures the test might execute faster and the statement may not fail. To simulate failure regardless of architecture, introduce a wait of seconds longer than the max_statement_time. --- mysql-test/main/func_json_notembedded.result | 3 + mysql-test/main/func_json_notembedded.test | 4 ++ sql/item_func.cc | 70 ++++++++++++-------- sql/item_func.h | 1 + sql/item_jsonfunc.cc | 29 ++++++++ 5 files changed, 81 insertions(+), 26 deletions(-) diff --git a/mysql-test/main/func_json_notembedded.result b/mysql-test/main/func_json_notembedded.result index 756d2e85f7c..ba4d38dd623 100644 --- a/mysql-test/main/func_json_notembedded.result +++ b/mysql-test/main/func_json_notembedded.result @@ -10,6 +10,8 @@ select length(@obj), length(@arr); length(@obj) length(@arr) 5000009 5000009 set max_statement_time=0.0001; +SET @old_debug= @@debug_dbug; +SET debug_dbug='+d,debug_max_statement_time exceeded'; select json_array_append(@arr, '$[0]', 1); ERROR 70100: Query execution was interrupted (max_statement_time exceeded) select json_array_insert(@arr, '$[0]', 1); @@ -34,6 +36,7 @@ select json_replace(@obj,'$.foo',1); ERROR 70100: Query execution was interrupted (max_statement_time exceeded) select json_set(@arr,'$[1000]',1); ERROR 70100: Query execution was interrupted (max_statement_time exceeded) +SET debug_dbug= @old_debug; disconnect u; connection default; set global max_allowed_packet=default; diff --git a/mysql-test/main/func_json_notembedded.test b/mysql-test/main/func_json_notembedded.test index 893b248301c..1e05571e16f 100644 --- a/mysql-test/main/func_json_notembedded.test +++ b/mysql-test/main/func_json_notembedded.test @@ -1,6 +1,7 @@ source include/have_profiling.inc; source include/not_embedded.inc; source include/no_valgrind_without_big.inc; +source include/have_debug.inc; set global max_allowed_packet=1073741824; connect u,localhost,root; @@ -16,6 +17,8 @@ select length(@obj), length(@arr); set max_statement_time=0.0001; disable_abort_on_error; +SET @old_debug= @@debug_dbug; +SET debug_dbug='+d,debug_max_statement_time exceeded'; select json_array_append(@arr, '$[0]', 1); select json_array_insert(@arr, '$[0]', 1); select json_insert(@obj, '$.meta', 1); @@ -29,6 +32,7 @@ select json_remove(@obj,'$.foo'); select json_replace(@obj,'$.foo',1); select json_set(@arr,'$[1000]',1); enable_abort_on_error; +SET debug_dbug= @old_debug; disconnect u; connection default; set global max_allowed_packet=default; diff --git a/sql/item_func.cc b/sql/item_func.cc index 0d798847a5a..f2d35887c14 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -72,6 +72,9 @@ bool check_reserved_words(const LEX_CSTRING *name) return FALSE; } +void pause_execution(THD *thd, double timeout); +static int do_pause(THD *thd, Interruptible_wait *timed_cond, + mysql_cond_t *cond, double timeout); /** Test if the sum of arguments overflows the ulonglong range. @@ -4612,32 +4615,7 @@ longlong Item_func_sleep::val_int() if (timeout < 0.00001) return 0; - timed_cond.set_timeout((ulonglong) (timeout * 1000000000.0)); - - mysql_cond_init(key_item_func_sleep_cond, &cond, NULL); - mysql_mutex_lock(&LOCK_item_func_sleep); - - THD_STAGE_INFO(thd, stage_user_sleep); - thd->mysys_var->current_mutex= &LOCK_item_func_sleep; - thd->mysys_var->current_cond= &cond; - - error= 0; - thd_wait_begin(thd, THD_WAIT_SLEEP); - while (!thd->killed) - { - error= timed_cond.wait(&cond, &LOCK_item_func_sleep); - if (error == ETIMEDOUT || error == ETIME) - break; - error= 0; - } - thd_wait_end(thd); - mysql_mutex_unlock(&LOCK_item_func_sleep); - mysql_mutex_lock(&thd->mysys_var->mutex); - thd->mysys_var->current_mutex= 0; - thd->mysys_var->current_cond= 0; - mysql_mutex_unlock(&thd->mysys_var->mutex); - - mysql_cond_destroy(&cond); + error= do_pause(thd, &timed_cond, &cond, timeout); #ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sleep_inject_query_done_debug_sync", { @@ -7358,3 +7336,43 @@ void fix_rownum_pointers(THD *thd, SELECT_LEX *select_lex, ha_rows *ptr) ((Item_func_rownum*) item)->store_pointer_to_row_counter(ptr); } } + +static int do_pause(THD *thd, Interruptible_wait *timed_cond, mysql_cond_t *cond, double timeout) +{ + int error= 0; + timed_cond->set_timeout((ulonglong) (timeout * 1000000000.0)); + + mysql_cond_init(key_item_func_sleep_cond, cond, NULL); + mysql_mutex_lock(&LOCK_item_func_sleep); + + THD_STAGE_INFO(thd, stage_user_sleep); + thd->mysys_var->current_mutex= &LOCK_item_func_sleep; + thd->mysys_var->current_cond= cond; + + thd_wait_begin(thd, THD_WAIT_SLEEP); + while (!thd->killed) + { + error= timed_cond->wait(cond, &LOCK_item_func_sleep); + if (error == ETIMEDOUT || error == ETIME) + break; + error= 0; + } + thd_wait_end(thd); + mysql_mutex_unlock(&LOCK_item_func_sleep); + mysql_mutex_lock(&thd->mysys_var->mutex); + thd->mysys_var->current_mutex= 0; + thd->mysys_var->current_cond= 0; + mysql_mutex_unlock(&thd->mysys_var->mutex); + + mysql_cond_destroy(cond); + + return error; +} + +void pause_execution(THD *thd, double timeout) +{ + Interruptible_wait timed_cond(thd); + mysql_cond_t cond; + + do_pause(thd, &timed_cond, &cond, timeout); +} diff --git a/sql/item_func.h b/sql/item_func.h index 0f34f3f6c0e..749c8fc4dd4 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -4312,6 +4312,7 @@ public: { return get_item_copy(thd, this); } }; +class Interruptible_wait; Item *get_system_var(THD *thd, enum_var_type var_type, const LEX_CSTRING *name, const LEX_CSTRING *component); diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index f5d321b57e1..603e8220aed 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -29,6 +29,23 @@ static int dbug_json_check_min_stack_requirement() } #endif +extern void pause_execution(THD *thd, double timeout); + +/* + Allocating memory and *also* using it (reading and + writing from it) because some build instructions cause + compiler to optimize out stack_used_up. Since alloca() + here depends on stack_used_up, it doesnt get executed + correctly and causes json_debug_nonembedded to fail + ( --error ER_STACK_OVERRUN_NEED_MORE does not occur). +*/ + +#define JSON_DO_PAUSE_EXECUTION(A, B) do \ + { \ + DBUG_EXECUTE_IF("json_pause_execution", \ + { pause_execution(A, B); }); \ + } while(0) + /* Compare ASCII string against the string with the specified character set. @@ -1965,6 +1982,8 @@ err_return: bool Item_func_json_array_append::fix_length_and_dec(THD *thd) { + JSON_DO_PAUSE_EXECUTION(thd, 0.0002); + uint n_arg; ulonglong char_length; @@ -2123,6 +2142,8 @@ String *Item_func_json_array_insert::val_str(String *str) uint n_arg, n_path; THD *thd= current_thd; + JSON_DO_PAUSE_EXECUTION(thd, 0.0002); + DBUG_ASSERT(fixed()); if ((null_value= args[0]->null_value)) @@ -2528,6 +2549,8 @@ String *Item_func_json_merge::val_str(String *str) THD *thd= current_thd; LINT_INIT(js2); + JSON_DO_PAUSE_EXECUTION(thd, 0.0002); + if (args[0]->null_value) goto null_return; @@ -2837,6 +2860,8 @@ String *Item_func_json_merge_patch::val_str(String *str) bool empty_result, merge_to_null; THD *thd= current_thd; + JSON_DO_PAUSE_EXECUTION(thd, 0.0002); + /* To report errors properly if some JSON is invalid. */ je1.s.error= je2.s.error= 0; merge_to_null= args[0]->null_value; @@ -3129,6 +3154,8 @@ bool Item_func_json_insert::fix_length_and_dec(THD *thd) uint n_arg; ulonglong char_length; + JSON_DO_PAUSE_EXECUTION(thd, 0.0002); + collation.set(args[0]->collation); char_length= args[0]->max_char_length(); @@ -3423,6 +3450,8 @@ String *Item_func_json_remove::val_str(String *str) DBUG_ASSERT(fixed()); + JSON_DO_PAUSE_EXECUTION(thd, 0.0002); + if (args[0]->null_value) goto null_return; From d32b6f69b30803fdd2f223c0eb6ed2e173b1ab81 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 8 Apr 2024 17:22:06 +0200 Subject: [PATCH 087/313] update C/C fixes sporadic unit.conc_ps_bugs failures --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 9155b19b462..1d3fd5818a0 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 9155b19b462ac15fc69d0b58ae51370b7523ced5 +Subproject commit 1d3fd5818a0f97832b69bb60ee1a49d5c1faea4c From 50803bc456c14ff5b7e86d88bb90fcf063b1fb1c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 8 Apr 2024 18:43:24 +0200 Subject: [PATCH 088/313] MDEV-25614 disable failing galera test --- mysql-test/suite/galera_3nodes/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index e1b4c2d5d5f..02479c1362e 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -17,3 +17,4 @@ galera_ipv6_mariabackup : temporarily disabled at the request of Codership galera_pc_bootstrap : temporarily disabled at the request of Codership galera_ipv6_mariabackup_section : temporarily disabled at the request of Codership MDEV-29171 : MDEV-33842 galera_3nodes.MDEV-29171 fails on shutdown_server +GCF-354 : MDEV-25614 Galera test failure on GCF-354 From 7e3090a8a0da030a6874da074c5dc909fcc22c87 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 8 Apr 2024 20:52:14 +0200 Subject: [PATCH 089/313] fix perfschema.misc when previous tests used lots of threads --- mysql-test/suite/perfschema/t/misc.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/perfschema/t/misc.test b/mysql-test/suite/perfschema/t/misc.test index 848be3beea1..b0a16fc5f99 100644 --- a/mysql-test/suite/perfschema/t/misc.test +++ b/mysql-test/suite/perfschema/t/misc.test @@ -175,6 +175,7 @@ DROP TABLE t_60905; # show global variables like "performance_schema_max_thread_instances"; +replace_result 512 256; explain select * from performance_schema.threads; # From b7b58a231099e21513f7a60835759260106b81a3 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 8 Apr 2024 16:24:46 +1000 Subject: [PATCH 090/313] MDEV-33731 Only iterate over m_locked_partitions in update_next_auto_inc_val() Only locked will participate in the query in this case. Chances are that not-locked partitions were not opened, which is the cause of the crash in the added test case spider/bugfix.mdev_33731 without this patch. --- sql/ha_partition.cc | 9 +++++---- .../mysql-test/spider/bugfix/r/mdev_33731.result | 10 ++++++++++ .../mysql-test/spider/bugfix/t/mdev_33731.test | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_33731.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_33731.test diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index c13b60f2cd8..952c6dd212f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -10753,18 +10753,19 @@ int ha_partition::update_next_auto_inc_val() bool ha_partition::need_info_for_auto_inc() { - handler **file= m_file; DBUG_ENTER("ha_partition::need_info_for_auto_inc"); - do + for (uint i= bitmap_get_first_set(&m_locked_partitions); + i < m_tot_parts; + i= bitmap_get_next_set(&m_locked_partitions, i)) { - if ((*file)->need_info_for_auto_inc()) + if ((m_file[i])->need_info_for_auto_inc()) { /* We have to get new auto_increment values from handler */ part_share->auto_inc_initialized= FALSE; DBUG_RETURN(TRUE); } - } while (*(++file)); + } DBUG_RETURN(FALSE); } diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33731.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33731.result new file mode 100644 index 00000000000..a63830f194c --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33731.result @@ -0,0 +1,10 @@ +for master_1 +for child2 +for child3 +CREATE TABLE t (a INT) ENGINE=Spider PARTITION BY LIST (a) PARTITIONS 2 (PARTITION p1 VALUES IN (0,1),PARTITION p2 VALUES IN (2,3)); +DELETE FROM t PARTITION (p2); +ERROR HY000: Unable to connect to foreign data source: localhost +drop table t; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33731.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33731.test new file mode 100644 index 00000000000..b98c9620414 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33731.test @@ -0,0 +1,16 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +CREATE TABLE t (a INT) ENGINE=Spider PARTITION BY LIST (a) PARTITIONS 2 (PARTITION p1 VALUES IN (0,1),PARTITION p2 VALUES IN (2,3)); +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +DELETE FROM t PARTITION (p2); +drop table t; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log From 09bae92c16f9c37c931ab3f7932664f55bb9a842 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 8 Apr 2024 16:34:38 +0200 Subject: [PATCH 091/313] MDEV-33840 tpool : switch off maintenance timer when not needed. Before patch, maintenance timer will tick every 0.4 seconds. After this patch, timer will tick every 0.4 seconds when necessary( there are delayed thread creation), switching off completely after 20 seconds of being idle. --- tpool/tpool_generic.cc | 70 ++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc index 8dbd7c94d30..0a2f9f8f5e1 100644 --- a/tpool/tpool_generic.cc +++ b/tpool/tpool_generic.cc @@ -270,10 +270,10 @@ class thread_pool_generic : public thread_pool OFF, ON }; timer_state_t m_timer_state= timer_state_t::OFF; - void switch_timer(timer_state_t state); + void switch_timer(timer_state_t state,std::unique_lock &lk); /* Updates idle_since, and maybe switches the timer off */ - void check_idle(std::chrono::system_clock::time_point now); + void check_idle(std::chrono::system_clock::time_point now, std::unique_lock &lk); /** time point when timer last ran, used as a coarse clock. */ std::chrono::system_clock::time_point m_timestamp; @@ -306,9 +306,9 @@ class thread_pool_generic : public thread_pool { ((thread_pool_generic *)arg)->maintenance(); } - bool add_thread(); + bool add_thread(std::unique_lock &lk); bool wake(worker_wake_reason reason, task *t = nullptr); - void maybe_wake_or_create_thread(); + void maybe_wake_or_create_thread(std::unique_lock &lk); bool too_many_active_threads(); bool get_task(worker_data *thread_var, task **t); bool wait_for_tasks(std::unique_lock &lk, @@ -616,11 +616,11 @@ void thread_pool_generic::worker_main(worker_data *thread_var) */ static const auto invalid_timestamp= std::chrono::system_clock::time_point::max(); -constexpr auto max_idle_time= std::chrono::minutes(1); +constexpr auto max_idle_time= std::chrono::seconds(20); /* Time since maintenance timer had nothing to do */ static std::chrono::system_clock::time_point idle_since= invalid_timestamp; -void thread_pool_generic::check_idle(std::chrono::system_clock::time_point now) +void thread_pool_generic::check_idle(std::chrono::system_clock::time_point now, std::unique_lock &lk) { DBUG_ASSERT(m_task_queue.empty()); @@ -647,7 +647,7 @@ void thread_pool_generic::check_idle(std::chrono::system_clock::time_point now) if (now - idle_since > max_idle_time) { idle_since= invalid_timestamp; - switch_timer(timer_state_t::OFF); + switch_timer(timer_state_t::OFF,lk); } } @@ -681,7 +681,7 @@ void thread_pool_generic::maintenance() if (m_task_queue.empty()) { - check_idle(m_timestamp); + check_idle(m_timestamp, lk); m_last_activity = m_tasks_dequeued + m_wakeups; return; } @@ -701,7 +701,7 @@ void thread_pool_generic::maintenance() } } - maybe_wake_or_create_thread(); + maybe_wake_or_create_thread(lk); size_t thread_cnt = (int)thread_count(); if (m_last_activity == m_tasks_dequeued + m_wakeups && @@ -709,7 +709,7 @@ void thread_pool_generic::maintenance() { // no progress made since last iteration. create new // thread - add_thread(); + add_thread(lk); } m_last_activity = m_tasks_dequeued + m_wakeups; m_last_thread_count= thread_cnt; @@ -736,14 +736,14 @@ static int throttling_interval_ms(size_t n_threads,size_t concurrency) } /* Create a new worker.*/ -bool thread_pool_generic::add_thread() +bool thread_pool_generic::add_thread(std::unique_lock &lk) { size_t n_threads = thread_count(); if (n_threads >= m_max_threads) return false; - if (n_threads >= m_min_threads) + if (n_threads >= m_min_threads && m_min_threads != m_max_threads) { auto now = std::chrono::system_clock::now(); if (now - m_last_thread_creation < @@ -753,7 +753,7 @@ bool thread_pool_generic::add_thread() Throttle thread creation and wakeup deadlock detection timer, if is it off. */ - switch_timer(timer_state_t::ON); + switch_timer(timer_state_t::ON, lk); return false; } @@ -835,12 +835,10 @@ thread_pool_generic::thread_pool_generic(int min_threads, int max_threads) : if (!m_concurrency) m_concurrency = 1; - // start the timer - m_maintenance_timer.set_time(0, (int)m_timer_interval.count()); } -void thread_pool_generic::maybe_wake_or_create_thread() +void thread_pool_generic::maybe_wake_or_create_thread(std::unique_lock &lk) { if (m_task_queue.empty()) return; @@ -853,7 +851,7 @@ void thread_pool_generic::maybe_wake_or_create_thread() } else { - add_thread(); + add_thread(lk); } } @@ -872,7 +870,7 @@ void thread_pool_generic::submit_task(task* task) task->add_ref(); m_tasks_enqueued++; m_task_queue.push(task); - maybe_wake_or_create_thread(); + maybe_wake_or_create_thread(lk); } @@ -895,7 +893,7 @@ void thread_pool_generic::wait_begin() m_waiting_task_count++; /* Maintain concurrency */ - maybe_wake_or_create_thread(); + maybe_wake_or_create_thread(lk); } @@ -910,26 +908,30 @@ void thread_pool_generic::wait_end() } -void thread_pool_generic::switch_timer(timer_state_t state) +void thread_pool_generic::switch_timer(timer_state_t state, std::unique_lock &lk) { if (m_timer_state == state) return; - /* - We can't use timer::set_time, because mysys timers are deadlock - prone. + /* No maintenance timer for fixed threadpool size.*/ + DBUG_ASSERT(m_min_threads != m_max_threads); + DBUG_ASSERT(lk.owns_lock()); - Instead, to switch off we increase the timer period - and decrease period to switch on. - - This might introduce delays in thread creation when needed, - as period will only be changed when timer fires next time. - For this reason, we can't use very long periods for the "off" state. - */ m_timer_state= state; - long long period= (state == timer_state_t::OFF) ? - m_timer_interval.count()*10: m_timer_interval.count(); - - m_maintenance_timer.set_period((int)period); + if(state == timer_state_t::OFF) + { + m_maintenance_timer.set_period(0); + } + else + { + /* + It is necessary to unlock the thread_pool::m_mtx + to avoid the deadlock with thr_timer's LOCK_timer. + Otherwise, lock order would be violated. + */ + lk.unlock(); + m_maintenance_timer.set_time(0, (int)m_timer_interval.count()); + lk.lock(); + } } From 0892e6d028f7b08da938defd9443ecbb45cda612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 9 Apr 2024 09:32:47 +0300 Subject: [PATCH 092/313] MDEV-33585 The maximum innodb_log_buffer_size is too large On Microsoft Windows, ReadFile() as well as WriteFile() limit the size of the request to DWORD, which is 32 bits (at most 4 GiB - 1) also on 64-bit systems. On FreeBSD, sysctl debug.iosize_max_clamp could limit the size of a write request to INT_MAX. The size of a read request is always limited to INT_MAX. This would allow the request size to be 4095 bytes more than the Linux limit (0x7ffff000 according to "man 2 read" and "man 2 write"). On OpenBSD, Solaris and possibly NetBSD, the read request size is limited to SSIZE_T_MAX, which would be half the current maximum innodb_log_buffer_size. This should be not much of an issue anyway, because on contemporary 64-bit platforms, the virtual addresses are limited to 48 bits. IBM AIX documentation mentions OFF_MAX which would apply when a 64-bit application is running on a 32-bit kernel. Let us declare innodb_log_buffer_size as 32-bit unsigned and make the maximum 0x7ffff000, to be compatible with the least common denominator (Linux). The maximum innodb_sort_buffer_size already was 64 MiB, which is not a problem. SyncFileIO::execute(): Assert that the size of a synchronous read or write request is limited to the maximum. Reviewed by: Vladislav Vaintroub --- extra/mariabackup/xtrabackup.cc | 4 +- .../sys_vars/r/sysvars_innodb,32bit.rdiff | 77 ++++++++----------- .../suite/sys_vars/r/sysvars_innodb.result | 4 +- storage/innobase/handler/ha_innodb.cc | 4 +- storage/innobase/include/log0log.h | 5 +- storage/innobase/include/os0file.h | 12 +++ storage/innobase/os/os0file.cc | 2 + 7 files changed, 57 insertions(+), 51 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index c53ff0792c3..f9993965092 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1888,8 +1888,8 @@ struct my_option xb_server_options[] = {"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE, "Redo log buffer size in bytes.", (G_PTR*) &log_sys.buf_size, (G_PTR*) &log_sys.buf_size, 0, - IF_WIN(GET_ULL,GET_ULONG), REQUIRED_ARG, 2U << 20, - 2U << 20, SIZE_T_MAX, 0, 4096, 0}, + GET_UINT, REQUIRED_ARG, 2U << 20, + 2U << 20, log_sys.buf_size_max, 0, 4096, 0}, #if defined __linux__ || defined _WIN32 {"innodb_log_file_buffering", OPT_INNODB_LOG_FILE_BUFFERING, "Whether the file system cache for ib_logfile0 is enabled during --backup", diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff index 9ae5049be2d..81db8629d19 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff @@ -1,4 +1,6 @@ -@@ -49,7 +49,7 @@ +--- sysvars_innodb.result ++++ sysvars_innodb.result,32bit +@@ -47,7 +47,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 8 VARIABLE_SCOPE GLOBAL @@ -7,7 +9,7 @@ VARIABLE_COMMENT Number of InnoDB Adaptive Hash Index Partitions (default 8) NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 512 -@@ -73,7 +73,7 @@ +@@ -71,7 +71,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 1 VARIABLE_SCOPE GLOBAL @@ -16,7 +18,7 @@ VARIABLE_COMMENT The AUTOINC lock modes supported by InnoDB: 0 => Old style AUTOINC locking (for backward compatibility); 1 => New style AUTOINC locking; 2 => No AUTOINC locking (unsafe for SBR) NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -85,10 +85,10 @@ +@@ -83,10 +83,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -29,7 +31,7 @@ NUMERIC_BLOCK_SIZE 1048576 ENUM_VALUE_LIST NULL READ_ONLY YES -@@ -121,7 +121,7 @@ +@@ -119,7 +119,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 25 VARIABLE_SCOPE GLOBAL @@ -38,7 +40,7 @@ VARIABLE_COMMENT Dump only the hottest N% of each buffer pool, defaults to 25 NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 100 -@@ -205,7 +205,7 @@ +@@ -203,7 +203,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -47,7 +49,7 @@ VARIABLE_COMMENT A number between [0, 100] that tells how oftern buffer pool dump status in percentages should be printed. E.g. 10 means that buffer pool dump status is printed when every 10% of number of buffer pool pages are dumped. Default is 0 (only start and end status is printed). NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 100 -@@ -325,7 +325,7 @@ +@@ -323,7 +323,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 5 VARIABLE_SCOPE GLOBAL @@ -56,7 +58,7 @@ VARIABLE_COMMENT If the compression failure rate of a table is greater than this number more padding is added to the pages to reduce the failures. A value of zero implies no padding NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 100 -@@ -349,7 +349,7 @@ +@@ -347,7 +347,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 50 VARIABLE_SCOPE GLOBAL @@ -65,7 +67,7 @@ VARIABLE_COMMENT Percentage of empty space on a data page that can be reserved to make the page compressible. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 75 -@@ -625,7 +625,7 @@ +@@ -623,7 +623,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 600 VARIABLE_SCOPE GLOBAL @@ -74,7 +76,7 @@ VARIABLE_COMMENT Maximum number of seconds that semaphore times out in InnoDB. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 -@@ -673,7 +673,7 @@ +@@ -671,7 +671,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 30 VARIABLE_SCOPE GLOBAL @@ -83,7 +85,7 @@ VARIABLE_COMMENT Number of iterations over which the background flushing is averaged. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 1000 -@@ -697,7 +697,7 @@ +@@ -695,7 +695,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 1 VARIABLE_SCOPE GLOBAL @@ -92,7 +94,7 @@ VARIABLE_COMMENT Controls the durability/speed trade-off for commits. Set to 0 (write and flush redo log to disk only once per second), 1 (flush to disk at each commit), 2 (write to log at commit but flush to disk only once per second) or 3 (flush to disk at prepare and at commit, slower and usually redundant). 1 and 3 guarantees that after a crash, committed transactions will not be lost and will be consistent with the binlog and other transactional engines. 2 can get inconsistent and lose transactions if there is a power failure or kernel crash but not if mysqld crashes. 0 has no guarantees in case of crash. 0 and 2 can be faster than 1 or 3. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 3 -@@ -721,7 +721,7 @@ +@@ -719,7 +719,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 1 VARIABLE_SCOPE GLOBAL @@ -101,7 +103,7 @@ VARIABLE_COMMENT Set to 0 (don't flush neighbors from buffer pool), 1 (flush contiguous neighbors from buffer pool) or 2 (flush neighbors from buffer pool), when flushing a block NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 2 -@@ -757,7 +757,7 @@ +@@ -755,7 +755,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -110,7 +112,7 @@ VARIABLE_COMMENT Helps to save your data in case the disk image of the database becomes corrupt. Value 5 can return bogus data, and 6 can permanently corrupt data. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 6 -@@ -781,10 +781,10 @@ +@@ -779,10 +779,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 8000000 VARIABLE_SCOPE GLOBAL @@ -123,7 +125,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -817,7 +817,7 @@ +@@ -815,7 +815,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 84 VARIABLE_SCOPE GLOBAL @@ -132,7 +134,7 @@ VARIABLE_COMMENT InnoDB Fulltext search maximum token size in characters NUMERIC_MIN_VALUE 10 NUMERIC_MAX_VALUE 84 -@@ -829,7 +829,7 @@ +@@ -827,7 +827,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 3 VARIABLE_SCOPE GLOBAL @@ -141,7 +143,7 @@ VARIABLE_COMMENT InnoDB Fulltext search minimum token size in characters NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 16 -@@ -841,7 +841,7 @@ +@@ -839,7 +839,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 2000 VARIABLE_SCOPE GLOBAL @@ -150,7 +152,7 @@ VARIABLE_COMMENT InnoDB Fulltext search number of words to optimize for each optimize table call NUMERIC_MIN_VALUE 1000 NUMERIC_MAX_VALUE 10000 -@@ -853,10 +853,10 @@ +@@ -851,10 +851,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 2000000000 VARIABLE_SCOPE GLOBAL @@ -163,7 +165,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -877,7 +877,7 @@ +@@ -875,7 +875,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 2 VARIABLE_SCOPE GLOBAL @@ -172,7 +174,7 @@ VARIABLE_COMMENT InnoDB Fulltext search parallel sort degree, will round up to nearest power of 2 number NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 16 -@@ -889,10 +889,10 @@ +@@ -887,10 +887,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 640000000 VARIABLE_SCOPE GLOBAL @@ -185,7 +187,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -937,22 +937,22 @@ +@@ -935,22 +935,22 @@ SESSION_VALUE NULL DEFAULT_VALUE 200 VARIABLE_SCOPE GLOBAL @@ -213,20 +215,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -985,10 +985,10 @@ - SESSION_VALUE NULL - DEFAULT_VALUE 16777216 - VARIABLE_SCOPE GLOBAL --VARIABLE_TYPE BIGINT UNSIGNED -+VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Redo log buffer size in bytes. - NUMERIC_MIN_VALUE 2097152 --NUMERIC_MAX_VALUE 18446744073709551615 -+NUMERIC_MAX_VALUE 4294967295 - NUMERIC_BLOCK_SIZE 4096 - ENUM_VALUE_LIST NULL - READ_ONLY YES -@@ -1033,10 +1033,10 @@ +@@ -1043,10 +1043,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 32 VARIABLE_SCOPE GLOBAL @@ -239,7 +228,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1045,10 +1045,10 @@ +@@ -1055,10 +1055,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 1536 VARIABLE_SCOPE GLOBAL @@ -252,7 +241,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1081,10 +1081,10 @@ +@@ -1091,10 +1091,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -265,7 +254,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1093,7 +1093,7 @@ +@@ -1103,7 +1103,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -274,7 +263,7 @@ VARIABLE_COMMENT Maximum delay of user threads in micro-seconds NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 10000000 -@@ -1225,10 +1225,10 @@ +@@ -1235,10 +1235,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL @@ -287,7 +276,7 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY YES -@@ -1249,7 +1249,7 @@ +@@ -1259,7 +1259,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 16384 VARIABLE_SCOPE GLOBAL @@ -296,7 +285,7 @@ VARIABLE_COMMENT Page size to use for all InnoDB tablespaces. NUMERIC_MIN_VALUE 4096 NUMERIC_MAX_VALUE 65536 -@@ -1285,7 +1285,7 @@ +@@ -1295,7 +1295,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 1000 VARIABLE_SCOPE GLOBAL @@ -305,7 +294,7 @@ VARIABLE_COMMENT Number of UNDO log pages to purge in one batch from the history list. NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 5000 -@@ -1297,7 +1297,7 @@ +@@ -1307,7 +1307,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 128 VARIABLE_SCOPE GLOBAL @@ -314,7 +303,7 @@ VARIABLE_COMMENT Deprecated parameter with no effect NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 128 -@@ -1333,7 +1333,7 @@ +@@ -1343,7 +1343,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 56 VARIABLE_SCOPE GLOBAL @@ -323,7 +312,7 @@ VARIABLE_COMMENT Number of pages that must be accessed sequentially for InnoDB to trigger a readahead. NUMERIC_MIN_VALUE 0 NUMERIC_MAX_VALUE 64 -@@ -1405,7 +1405,7 @@ +@@ -1427,7 +1427,7 @@ SESSION_VALUE NULL DEFAULT_VALUE 1048576 VARIABLE_SCOPE GLOBAL @@ -332,7 +321,7 @@ VARIABLE_COMMENT Memory buffer size for index creation NUMERIC_MIN_VALUE 65536 NUMERIC_MAX_VALUE 67108864 -@@ -1573,10 +1573,10 @@ +@@ -1595,10 +1595,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 30 VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 623a32b640a..6a7e184f68e 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -983,10 +983,10 @@ VARIABLE_NAME INNODB_LOG_BUFFER_SIZE SESSION_VALUE NULL DEFAULT_VALUE 16777216 VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Redo log buffer size in bytes. NUMERIC_MIN_VALUE 2097152 -NUMERIC_MAX_VALUE 18446744073709551615 +NUMERIC_MAX_VALUE 2147479552 NUMERIC_BLOCK_SIZE 4096 ENUM_VALUE_LIST NULL READ_ONLY YES diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 13f46d8582a..9dbee523536 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -19316,10 +19316,10 @@ static MYSQL_SYSVAR_ULONG(page_size, srv_page_size, NULL, NULL, UNIV_PAGE_SIZE_DEF, UNIV_PAGE_SIZE_MIN, UNIV_PAGE_SIZE_MAX, 0); -static MYSQL_SYSVAR_SIZE_T(log_buffer_size, log_sys.buf_size, +static MYSQL_SYSVAR_UINT(log_buffer_size, log_sys.buf_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "Redo log buffer size in bytes.", - NULL, NULL, 16U << 20, 2U << 20, SIZE_T_MAX, 4096); + NULL, NULL, 16U << 20, 2U << 20, log_sys.buf_size_max, 4096); #if defined __linux__ || defined _WIN32 static MYSQL_SYSVAR_BOOL(log_file_buffering, log_sys.log_buffered, diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 48ac99fb817..f553b9bddd4 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -132,6 +132,9 @@ public: /** Redo log buffer */ struct log_t { + /** The maximum buf_size */ + static constexpr unsigned buf_size_max= os_file_request_size_max; + /** The original (not version-tagged) InnoDB redo log format */ static constexpr uint32_t FORMAT_3_23= 0; /** The MySQL 5.7.9/MariaDB 10.2.2 log format */ @@ -187,7 +190,7 @@ public: /** number of append_prepare_wait(); protected by lock_lsn() or lsn_lock */ size_t waits; /** innodb_log_buffer_size (size of buf,flush_buf if !is_pmem(), in bytes) */ - size_t buf_size; + unsigned buf_size; /** log file size in bytes, including the header */ lsn_t file_size; diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index a5953dcfd51..7eba359fbd3 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -46,6 +46,18 @@ Created 10/21/1995 Heikki Tuuri #include #endif /* !_WIN32 */ +/** The maximum size of a read or write request. + +According to Linux "man 2 read" and "man 2 write" this applies to +both 32-bit and 64-bit systems. + +On FreeBSD, the limit is close to the Linux one, INT_MAX. + +On Microsoft Windows, the limit is UINT_MAX (4 GiB - 1). + +On other systems, the limit typically is up to SSIZE_T_MAX. */ +static constexpr unsigned os_file_request_size_max= 0x7ffff000; + extern bool os_has_said_disk_full; /** File offset in bytes */ diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 04835377f8a..672902a0d68 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -678,6 +678,8 @@ ssize_t SyncFileIO::execute(const IORequest& request) { ssize_t n_bytes; + ut_ad(m_n > 0); + ut_ad(m_n <= os_file_request_size_max); if (request.is_read()) { #ifdef _WIN32 From 42bda685db6679437b26d641d25c4f98a343ad95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 9 Apr 2024 09:36:45 +0300 Subject: [PATCH 093/313] MDEV-33585 follow-up optimization log_t: Define buf_size, max_buf_free as 32-bit and next_checkpoint_no as byte (we only need a bit) and rearrange some data members, so that on AMD64 we can fit log_sys.latch and log_sys.log in the same 64-byte cache line. mtr_t::commit_log(), mtr_t::commit_logger: A part of mtr_t::commit() split into a separate function, so that we will not unnecessarily invoke log_sys.get_write_target() when running on a memory-mapped log file, or log_sys.is_pmem(). Reviewed by: Vladislav Vaintroub Tested by: Matthias Leich --- storage/innobase/include/log0log.h | 9 +- storage/innobase/include/mtr0mtr.h | 9 + storage/innobase/log/log0log.cc | 2 +- storage/innobase/mtr/mtr0mtr.cc | 274 +++++++++++++++-------------- 4 files changed, 160 insertions(+), 134 deletions(-) diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index f553b9bddd4..cef0dcae1b0 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -230,8 +230,6 @@ public: /** Last written LSN */ lsn_t write_lsn; - /** recommended maximum buf_free size, after which the buffer is flushed */ - size_t max_buf_free; /** buffer for writing data to ib_logfile0, or nullptr if is_pmem() In write_buf(), buf and flush_buf are swapped */ @@ -241,6 +239,10 @@ public: std::atomic need_checkpoint; /** whether a checkpoint is pending; protected by latch.wr_lock() */ Atomic_relaxed checkpoint_pending; + /** next checkpoint number (protected by latch.wr_lock()) */ + byte next_checkpoint_no; + /** recommended maximum buf_free size, after which the buffer is flushed */ + unsigned max_buf_free; /** Log sequence number when a log file overwrite (broken crash recovery) was noticed. Protected by latch.wr_lock(). */ lsn_t overwrite_warned; @@ -249,8 +251,6 @@ public: Atomic_relaxed last_checkpoint_lsn; /** next checkpoint LSN (protected by latch.wr_lock()) */ lsn_t next_checkpoint_lsn; - /** next checkpoint number (protected by latch.wr_lock()) */ - ulint next_checkpoint_no; /** Log file */ log_file_t log; @@ -323,6 +323,7 @@ public: /** whether there is capacity in the log buffer */ bool buf_free_ok() const noexcept { + ut_ad(!is_pmem()); return (buf_free.load(std::memory_order_relaxed) & ~buf_free_LOCK) < max_buf_free; } diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index d180fe57e38..bfa66216184 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -695,6 +695,13 @@ private: /** Encrypt the log */ ATTRIBUTE_NOINLINE void encrypt(); + /** Commit the mini-transaction log. + @tparam pmem log_sys.is_pmem() + @param mtr mini-transaction + @param lsns {start_lsn,flush_ahead} */ + template + static void commit_log(mtr_t *mtr, std::pair lsns); + /** Append the redo log records to the redo log buffer. @return {start_lsn,flush_ahead} */ std::pair do_write(); @@ -708,6 +715,8 @@ private: template static std::pair finish_writer(mtr_t *mtr, size_t len); + /** The applicable variant of commit_log() */ + static void (*commit_logger)(mtr_t *, std::pair); /** The applicable variant of finish_writer() */ static std::pair (*finisher)(mtr_t *, size_t); diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 2e209adaab9..022843fdd1e 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -235,7 +235,7 @@ void log_t::attach_low(log_file_t file, os_offset_t size) log.close(); mprotect(ptr, size_t(size), PROT_READ); buf= static_cast(ptr); - max_buf_free= size; + max_buf_free= 1; # if defined __linux__ || defined _WIN32 set_block_size(CPU_LEVEL1_DCACHE_LINESIZE); # endif diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 1b2546733d4..c9325b8df79 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -39,19 +39,26 @@ Created 11/26/1995 Heikki Tuuri #include "mariadb_stats.h" #include "my_cpu.h" +#ifdef HAVE_PMEM +void (*mtr_t::commit_logger)(mtr_t *, std::pair); +#endif std::pair (*mtr_t::finisher)(mtr_t *, size_t); unsigned mtr_t::spin_wait_delay; void mtr_t::finisher_update() { ut_ad(log_sys.latch_have_wr()); - finisher= #ifdef HAVE_PMEM - log_sys.is_pmem() - ? (spin_wait_delay - ? mtr_t::finish_writer : mtr_t::finish_writer) - : + if (log_sys.is_pmem()) + { + commit_logger= mtr_t::commit_log; + finisher= spin_wait_delay + ? mtr_t::finish_writer : mtr_t::finish_writer; + return; + } + commit_logger= mtr_t::commit_log; #endif + finisher= (spin_wait_delay ? mtr_t::finish_writer : mtr_t::finish_writer); } @@ -336,7 +343,6 @@ inline lsn_t log_t::get_write_target() const ut_ad(latch_have_any()); if (UNIV_LIKELY(buf_free_ok())) return 0; - ut_ad(!is_pmem()); /* The LSN corresponding to the end of buf is write_lsn - (first_lsn & 4095) + buf_free, but we use simpler arithmetics to return a smaller write target in @@ -345,6 +351,134 @@ inline lsn_t log_t::get_write_target() const return write_lsn + max_buf_free / 2; } +template +void mtr_t::commit_log(mtr_t *mtr, std::pair lsns) +{ + size_t modified= 0; + const lsn_t write_lsn= pmem ? 0 : log_sys.get_write_target(); + + if (mtr->m_made_dirty) + { + auto it= mtr->m_memo.rbegin(); + + mysql_mutex_lock(&buf_pool.flush_list_mutex); + + buf_page_t *const prev= + buf_pool.prepare_insert_into_flush_list(lsns.first); + + while (it != mtr->m_memo.rend()) + { + const mtr_memo_slot_t &slot= *it++; + if (slot.type & MTR_MEMO_MODIFY) + { + ut_ad(slot.type == MTR_MEMO_PAGE_X_MODIFY || + slot.type == MTR_MEMO_PAGE_SX_MODIFY); + modified++; + buf_block_t *b= static_cast(slot.object); + ut_ad(b->page.id() < end_page_id); + ut_d(const auto s= b->page.state()); + ut_ad(s > buf_page_t::FREED); + ut_ad(s < buf_page_t::READ_FIX); + ut_ad(mach_read_from_8(b->page.frame + FIL_PAGE_LSN) <= + mtr->m_commit_lsn); + mach_write_to_8(b->page.frame + FIL_PAGE_LSN, mtr->m_commit_lsn); + if (UNIV_LIKELY_NULL(b->page.zip.data)) + memcpy_aligned<8>(FIL_PAGE_LSN + b->page.zip.data, + FIL_PAGE_LSN + b->page.frame, 8); + buf_pool.insert_into_flush_list(prev, b, lsns.first); + } + } + + ut_ad(modified); + buf_pool.flush_list_requests+= modified; + 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->release(); + } + else + { + if (mtr->m_latch_ex) + { + log_sys.latch.wr_unlock(); + mtr->m_latch_ex= false; + } + else + log_sys.latch.rd_unlock(); + + for (auto it= mtr->m_memo.rbegin(); it != mtr->m_memo.rend(); ) + { + const mtr_memo_slot_t &slot= *it++; + ut_ad(slot.object); + switch (slot.type) { + case MTR_MEMO_S_LOCK: + static_cast(slot.object)->s_unlock(); + break; + case MTR_MEMO_SPACE_X_LOCK: + static_cast(slot.object)->set_committed_size(); + static_cast(slot.object)->x_unlock(); + break; + case MTR_MEMO_X_LOCK: + case MTR_MEMO_SX_LOCK: + static_cast(slot.object)-> + u_or_x_unlock(slot.type == MTR_MEMO_SX_LOCK); + break; + default: + buf_page_t *bpage= static_cast(slot.object); + ut_d(const auto s=) + bpage->unfix(); + if (slot.type & MTR_MEMO_MODIFY) + { + ut_ad(slot.type == MTR_MEMO_PAGE_X_MODIFY || + slot.type == MTR_MEMO_PAGE_SX_MODIFY); + ut_ad(bpage->oldest_modification() > 1); + ut_ad(bpage->oldest_modification() < mtr->m_commit_lsn); + ut_ad(bpage->id() < end_page_id); + ut_ad(s >= buf_page_t::FREED); + ut_ad(s < buf_page_t::READ_FIX); + ut_ad(mach_read_from_8(bpage->frame + FIL_PAGE_LSN) <= + mtr->m_commit_lsn); + mach_write_to_8(bpage->frame + FIL_PAGE_LSN, mtr->m_commit_lsn); + if (UNIV_LIKELY_NULL(bpage->zip.data)) + memcpy_aligned<8>(FIL_PAGE_LSN + bpage->zip.data, + FIL_PAGE_LSN + bpage->frame, 8); + modified++; + } + switch (auto latch= slot.type & ~MTR_MEMO_MODIFY) { + case MTR_MEMO_PAGE_S_FIX: + bpage->lock.s_unlock(); + continue; + case MTR_MEMO_PAGE_SX_FIX: + case MTR_MEMO_PAGE_X_FIX: + bpage->lock.u_or_x_unlock(latch == MTR_MEMO_PAGE_SX_FIX); + continue; + default: + ut_ad(latch == MTR_MEMO_BUF_FIX); + } + } + } + + buf_pool.add_flush_list_requests(modified); + mtr->m_memo.clear(); + } + + mariadb_increment_pages_updated(modified); + + if (UNIV_UNLIKELY(lsns.second != PAGE_FLUSH_NO)) + buf_flush_ahead(mtr->m_commit_lsn, lsns.second == PAGE_FLUSH_SYNC); + + if (!pmem && UNIV_UNLIKELY(write_lsn != 0)) + log_write_up_to(write_lsn, false); +} + /** Commit a mini-transaction. */ void mtr_t::commit() { @@ -367,129 +501,11 @@ void mtr_t::commit() ut_ad(!srv_read_only_mode); std::pair lsns{do_write()}; process_freed_pages(); - size_t modified= 0; - const lsn_t write_lsn= log_sys.get_write_target(); - - if (m_made_dirty) - { - auto it= m_memo.rbegin(); - - mysql_mutex_lock(&buf_pool.flush_list_mutex); - - buf_page_t *const prev= - buf_pool.prepare_insert_into_flush_list(lsns.first); - - while (it != m_memo.rend()) - { - const mtr_memo_slot_t &slot= *it++; - if (slot.type & MTR_MEMO_MODIFY) - { - ut_ad(slot.type == MTR_MEMO_PAGE_X_MODIFY || - slot.type == MTR_MEMO_PAGE_SX_MODIFY); - modified++; - buf_block_t *b= static_cast(slot.object); - ut_ad(b->page.id() < end_page_id); - ut_d(const auto s= b->page.state()); - ut_ad(s > buf_page_t::FREED); - ut_ad(s < buf_page_t::READ_FIX); - ut_ad(mach_read_from_8(b->page.frame + FIL_PAGE_LSN) <= - m_commit_lsn); - mach_write_to_8(b->page.frame + FIL_PAGE_LSN, m_commit_lsn); - if (UNIV_LIKELY_NULL(b->page.zip.data)) - memcpy_aligned<8>(FIL_PAGE_LSN + b->page.zip.data, - FIL_PAGE_LSN + b->page.frame, 8); - buf_pool.insert_into_flush_list(prev, b, lsns.first); - } - } - - ut_ad(modified); - buf_pool.flush_list_requests+= modified; - buf_pool.page_cleaner_wakeup(); - mysql_mutex_unlock(&buf_pool.flush_list_mutex); - - if (m_latch_ex) - { - log_sys.latch.wr_unlock(); - m_latch_ex= false; - } - else - log_sys.latch.rd_unlock(); - - release(); - } - else - { - if (m_latch_ex) - { - log_sys.latch.wr_unlock(); - m_latch_ex= false; - } - else - log_sys.latch.rd_unlock(); - - for (auto it= m_memo.rbegin(); it != m_memo.rend(); ) - { - const mtr_memo_slot_t &slot= *it++; - ut_ad(slot.object); - switch (slot.type) { - case MTR_MEMO_S_LOCK: - static_cast(slot.object)->s_unlock(); - break; - case MTR_MEMO_SPACE_X_LOCK: - static_cast(slot.object)->set_committed_size(); - static_cast(slot.object)->x_unlock(); - break; - case MTR_MEMO_X_LOCK: - case MTR_MEMO_SX_LOCK: - static_cast(slot.object)-> - u_or_x_unlock(slot.type == MTR_MEMO_SX_LOCK); - break; - default: - buf_page_t *bpage= static_cast(slot.object); - ut_d(const auto s=) - bpage->unfix(); - if (slot.type & MTR_MEMO_MODIFY) - { - ut_ad(slot.type == MTR_MEMO_PAGE_X_MODIFY || - slot.type == MTR_MEMO_PAGE_SX_MODIFY); - ut_ad(bpage->oldest_modification() > 1); - ut_ad(bpage->oldest_modification() < m_commit_lsn); - ut_ad(bpage->id() < end_page_id); - ut_ad(s >= buf_page_t::FREED); - ut_ad(s < buf_page_t::READ_FIX); - ut_ad(mach_read_from_8(bpage->frame + FIL_PAGE_LSN) <= - m_commit_lsn); - mach_write_to_8(bpage->frame + FIL_PAGE_LSN, m_commit_lsn); - if (UNIV_LIKELY_NULL(bpage->zip.data)) - memcpy_aligned<8>(FIL_PAGE_LSN + bpage->zip.data, - FIL_PAGE_LSN + bpage->frame, 8); - modified++; - } - switch (auto latch= slot.type & ~MTR_MEMO_MODIFY) { - case MTR_MEMO_PAGE_S_FIX: - bpage->lock.s_unlock(); - continue; - case MTR_MEMO_PAGE_SX_FIX: - case MTR_MEMO_PAGE_X_FIX: - bpage->lock.u_or_x_unlock(latch == MTR_MEMO_PAGE_SX_FIX); - continue; - default: - ut_ad(latch == MTR_MEMO_BUF_FIX); - } - } - } - - buf_pool.add_flush_list_requests(modified); - m_memo.clear(); - } - - mariadb_increment_pages_updated(modified); - - if (UNIV_UNLIKELY(lsns.second != PAGE_FLUSH_NO)) - buf_flush_ahead(m_commit_lsn, lsns.second == PAGE_FLUSH_SYNC); - - if (UNIV_UNLIKELY(write_lsn != 0)) - log_write_up_to(write_lsn, false); +#ifdef HAVE_PMEM + commit_logger(this, lsns); +#else + commit_log(this, lsns); +#endif } else { From f9ecaa87cebb3043afec5da73fb665c24a30cc98 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Tue, 27 Feb 2024 12:19:18 +0100 Subject: [PATCH 094/313] MDEV-33668: Refactor parallel replication round-robin scheduling to use explicit FIFO This is a preparatory patch to facilitate the next commit to improve the scheduling of XA transactions in parallel replication. When choosing the scheduling bucket for the next event group in rpl_parallel_entry::choose_thread(), use an explicit FIFO for the round-robin selection instead of a simple cyclic counter i := (i+1) % N. This allows to schedule XA COMMIT/ROLLBACK dependencies explicitly without changing the round-robin scheduling of other event groups. Reviewed-by: Andrei Elkin Signed-off-by: Kristian Nielsen --- sql/rpl_parallel.cc | 54 +++++++++++++++++++++++++++------------------ sql/rpl_parallel.h | 13 ++++++++--- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index a63fa4a4b6b..68e42ecd03f 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -2357,33 +2357,38 @@ rpl_parallel_entry::choose_thread(rpl_group_info *rgi, bool *did_enter_cond, PSI_stage_info *old_stage, Gtid_log_event *gtid_ev) { - uint32 idx; + sched_bucket *cur_thr; Relay_log_info *rli= rgi->rli; rpl_parallel_thread *thr; - idx= rpl_thread_idx; if (gtid_ev) { + /* New event group; cycle the thread scheduling buckets round-robin. */ + thread_sched_fifo->push_back(thread_sched_fifo->get()); + if (gtid_ev->flags2 & (Gtid_log_event::FL_COMPLETED_XA | Gtid_log_event::FL_PREPARED_XA)) - idx= my_hash_sort(&my_charset_bin, gtid_ev->xid.key(), - gtid_ev->xid.key_length()) % rpl_thread_max; - else { - ++idx; - if (idx >= rpl_thread_max) - idx= 0; + /* + For XA COMMIT/ROLLBACK, choose the same bucket as the XA PREPARE, + overriding the round-robin scheduling. + */ + uint32 idx= my_hash_sort(&my_charset_bin, gtid_ev->xid.key(), + gtid_ev->xid.key_length()) % rpl_thread_max; + rpl_threads[idx].unlink(); + thread_sched_fifo->append(rpl_threads + idx); } - rpl_thread_idx= idx; } - thr= rpl_threads[idx]; + cur_thr= thread_sched_fifo->head(); + + thr= cur_thr->thr; if (thr) { *did_enter_cond= false; mysql_mutex_lock(&thr->LOCK_rpl_thread); for (;;) { - if (thr->current_owner != &rpl_threads[idx]) + if (thr->current_owner != &cur_thr->thr) { /* The worker thread became idle, and returned to the free list and @@ -2450,8 +2455,8 @@ rpl_parallel_entry::choose_thread(rpl_group_info *rgi, bool *did_enter_cond, } } if (!thr) - rpl_threads[idx]= thr= global_rpl_thread_pool.get_thread(&rpl_threads[idx], - this); + cur_thr->thr= thr= + global_rpl_thread_pool.get_thread(&cur_thr->thr, this); return thr; } @@ -2508,15 +2513,20 @@ rpl_parallel::find(uint32 domain_id) ulong count= opt_slave_domain_parallel_threads; if (count == 0 || count > opt_slave_parallel_threads) count= opt_slave_parallel_threads; - rpl_parallel_thread **p; + rpl_parallel_entry::sched_bucket *p; + I_List *fifo; if (!my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME|MY_ZEROFILL), &e, sizeof(*e), &p, count*sizeof(*p), + &fifo, sizeof(*fifo), NULL)) { my_error(ER_OUTOFMEMORY, MYF(0), (int)(sizeof(*e)+count*sizeof(*p))); return NULL; } + e->thread_sched_fifo = new (fifo) I_List; + for (ulong i= 0; i < count; ++i) + e->thread_sched_fifo->push_back(::new (p+i) rpl_parallel_entry::sched_bucket); e->rpl_threads= p; e->rpl_thread_max= count; e->domain_id= domain_id; @@ -2582,10 +2592,10 @@ rpl_parallel::wait_for_done(THD *thd, Relay_log_info *rli) mysql_mutex_unlock(&e->LOCK_parallel_entry); for (j= 0; j < e->rpl_thread_max; ++j) { - if ((rpt= e->rpl_threads[j])) + if ((rpt= e->rpl_threads[j].thr)) { mysql_mutex_lock(&rpt->LOCK_rpl_thread); - if (rpt->current_owner == &e->rpl_threads[j]) + if (rpt->current_owner == &e->rpl_threads[j].thr) mysql_cond_signal(&rpt->COND_rpl_thread); mysql_mutex_unlock(&rpt->LOCK_rpl_thread); } @@ -2605,10 +2615,10 @@ rpl_parallel::wait_for_done(THD *thd, Relay_log_info *rli) e= (struct rpl_parallel_entry *)my_hash_element(&domain_hash, i); for (j= 0; j < e->rpl_thread_max; ++j) { - if ((rpt= e->rpl_threads[j])) + if ((rpt= e->rpl_threads[j].thr)) { mysql_mutex_lock(&rpt->LOCK_rpl_thread); - while (rpt->current_owner == &e->rpl_threads[j]) + while (rpt->current_owner == &e->rpl_threads[j].thr) mysql_cond_wait(&rpt->COND_rpl_thread_stop, &rpt->LOCK_rpl_thread); mysql_mutex_unlock(&rpt->LOCK_rpl_thread); } @@ -2655,7 +2665,7 @@ int rpl_parallel_entry::queue_master_restart(rpl_group_info *rgi, Format_description_log_event *fdev) { - uint32 idx; + sched_bucket *cur_thr; rpl_parallel_thread *thr; rpl_parallel_thread::queued_event *qev; Relay_log_info *rli= rgi->rli; @@ -2670,12 +2680,12 @@ rpl_parallel_entry::queue_master_restart(rpl_group_info *rgi, Thus there is no need for the full complexity of choose_thread(). We only need to check if we have a current worker thread, and queue for it if so. */ - idx= rpl_thread_idx; - thr= rpl_threads[idx]; + cur_thr= thread_sched_fifo->head(); + thr= cur_thr->thr; if (!thr) return 0; mysql_mutex_lock(&thr->LOCK_rpl_thread); - if (thr->current_owner != &rpl_threads[idx]) + if (thr->current_owner != &cur_thr->thr) { /* No active worker thread, so no need to queue the master restart. */ mysql_mutex_unlock(&thr->LOCK_rpl_thread); diff --git a/sql/rpl_parallel.h b/sql/rpl_parallel.h index bcce54bc0ec..9ba86453d06 100644 --- a/sql/rpl_parallel.h +++ b/sql/rpl_parallel.h @@ -326,6 +326,11 @@ struct rpl_parallel_thread_pool { struct rpl_parallel_entry { + struct sched_bucket : public ilink { + sched_bucket() : thr(nullptr) { } + rpl_parallel_thread *thr; + }; + mysql_mutex_t LOCK_parallel_entry; mysql_cond_t COND_parallel_entry; uint32 domain_id; @@ -355,17 +360,19 @@ struct rpl_parallel_entry { uint64 stop_sub_id; /* - Cyclic array recording the last rpl_thread_max worker threads that we + Array recording the last rpl_thread_max worker threads that we queued event for. This is used to limit how many workers a single domain can occupy (--slave-domain-parallel-threads). + The array is structured as a FIFO using an I_List thread_sched_fifo. + Note that workers are never explicitly deleted from the array. Instead, we need to check (under LOCK_rpl_thread) that the thread still belongs to us before re-using (rpl_thread::current_owner). */ - rpl_parallel_thread **rpl_threads; + sched_bucket *rpl_threads; + I_List *thread_sched_fifo; uint32 rpl_thread_max; - uint32 rpl_thread_idx; /* The sub_id of the last transaction to commit within this domain_id. Must be accessed under LOCK_parallel_entry protection. From d90a2b44addef766cb59cb4e68c0b00d77aee160 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Tue, 27 Feb 2024 19:08:20 +0100 Subject: [PATCH 095/313] MDEV-33668: More precise dependency tracking of XA XID in parallel replication Keep track of each recently active XID, recording which worker it was queued on. If an XID might still be active, choose the same worker to queue event groups that refer to the same XID to avoid conflicts. Otherwise, schedule the XID freely in the next round-robin slot. This way, XA PREPARE can normally be scheduled without restrictions (unless duplicate XID transactions come close together). This improves scheduling and parallelism over the old method, where the worker thread to schedule XA PREPARE on was fixed based on a hash value of the XID. XA COMMIT will normally be scheduled on the same worker as XA PREPARE, but can be a different one if the XA PREPARE is far back in the event history. Testcase and code for trimming dynamic array due to Andrei. Reviewed-by: Andrei Elkin Signed-off-by: Kristian Nielsen --- .../rpl/r/rpl_parallel_multi_domain_xa.result | 55 ++++++ .../rpl/t/rpl_parallel_multi_domain_xa.test | 173 ++++++++++++++++++ sql/log_event_server.cc | 3 +- sql/rpl_parallel.cc | 131 +++++++++++-- sql/rpl_parallel.h | 41 +++++ 5 files changed, 391 insertions(+), 12 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_parallel_multi_domain_xa.result create mode 100644 mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test diff --git a/mysql-test/suite/rpl/r/rpl_parallel_multi_domain_xa.result b/mysql-test/suite/rpl/r/rpl_parallel_multi_domain_xa.result new file mode 100644 index 00000000000..defab6aef52 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_parallel_multi_domain_xa.result @@ -0,0 +1,55 @@ +include/master-slave.inc +[connection master] +call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); +call mtr.add_suppression("WSREP: handlerton rollback failed"); +connection master; +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +connection slave; +include/stop_slave.inc +SET @old_parallel_threads = @@GLOBAL.slave_parallel_threads; +SET @old_slave_domain_parallel_threads = @@GLOBAL.slave_domain_parallel_threads; +SET @@global.slave_parallel_threads = 5; +SET @@global.slave_domain_parallel_threads = 3; +SET @old_parallel_mode = @@GLOBAL.slave_parallel_mode; +CHANGE MASTER TO master_use_gtid=slave_pos; +connection master; +CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 0); +include/save_master_gtid.inc +connection slave; +include/start_slave.inc +include/sync_with_master_gtid.inc +include/stop_slave.inc +SET @@global.slave_parallel_mode ='optimistic'; +connection master; +include/save_master_gtid.inc +connection slave; +include/start_slave.inc +include/sync_with_master_gtid.inc +include/stop_slave.inc +connection master; +include/save_master_gtid.inc +connection slave; +SET @@global.slave_parallel_mode ='conservative'; +include/start_slave.inc +include/sync_with_master_gtid.inc +include/stop_slave.inc +include/save_master_gtid.inc +connection slave; +SET @@global.slave_parallel_mode = 'optimistic'; +include/start_slave.inc +include/sync_with_master_gtid.inc +include/diff_tables.inc [master:t1, slave:t1] +connection slave; +include/stop_slave.inc +SET @@global.slave_parallel_mode = @old_parallel_mode; +SET @@global.slave_parallel_threads = @old_parallel_threads; +SET @@global.slave_domain_parallel_threads = @old_slave_domain_parallel_threads; +include/start_slave.inc +connection master; +DROP TABLE t1; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +connection master; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test b/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test new file mode 100644 index 00000000000..da1aaea130f --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test @@ -0,0 +1,173 @@ +# Similar to rpl_parallel_optimistic_xa to verify XA +# parallel execution with multiple gtid domain. +# References: +# MDEV-33668 Adapt parallel slave's round-robin scheduling to XA events + +--source include/have_innodb.inc +--source include/have_perfschema.inc +--source include/master-slave.inc + +# Tests' global declarations +--let $trx = _trx_ + +call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); +call mtr.add_suppression("WSREP: handlerton rollback failed"); + +--connection master +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +--save_master_pos + +# Prepare to restart slave into optimistic parallel mode +--connection slave +--sync_with_master +--source include/stop_slave.inc +SET @old_parallel_threads = @@GLOBAL.slave_parallel_threads; +SET @old_slave_domain_parallel_threads = @@GLOBAL.slave_domain_parallel_threads; +SET @@global.slave_parallel_threads = 5; +SET @@global.slave_domain_parallel_threads = 3; +SET @old_parallel_mode = @@GLOBAL.slave_parallel_mode; + +CHANGE MASTER TO master_use_gtid=slave_pos; + +--connection master +CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 0); +--source include/save_master_gtid.inc + +--connection slave +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +--source include/stop_slave.inc + +--let $mode = 2 +# mode = 2 is optimistic +SET @@global.slave_parallel_mode ='optimistic'; +while ($mode) +{ + --connection master + # + # create XA events alternating gtid domains to run them in parallel on slave. + # + --let $domain_num = 3 + --let $trx_num = 777 + --let $i = $trx_num + --let $conn = master + --disable_query_log + while($i > 0) + { + --let $domain_id = `SELECT $i % $domain_num` + --eval set @@gtid_domain_id = $domain_id + # 'decision' to commit 0, or rollback 1 + --let $decision = `SELECT $i % 2` + --eval XA START '$conn$trx$i' + --eval UPDATE t1 SET b = 1 - 2 * $decision WHERE a = 1 + --eval XA END '$conn$trx$i' + --eval XA PREPARE '$conn$trx$i' + --let $term = COMMIT + if ($decision) + { + --let $term = ROLLBACK + } + --eval XA $term '$conn$trx$i' + + --dec $i + } + --enable_query_log + --source include/save_master_gtid.inc + + --connection slave + if (`select $mode = 1`) + { + SET @@global.slave_parallel_mode ='conservative'; + } + --source include/start_slave.inc + --source include/sync_with_master_gtid.inc + --source include/stop_slave.inc + + --dec $mode +} + + +# Generations test. +# Create few ranges of XAP groups length of greater than +# 3 * slave_parallel_threads + 1 +# terminated upon each range. +--let $iter = 3 +--let $generation_len = @@global.slave_parallel_threads +--let $domain_num = 3 +--disable_query_log +--connection master +while ($iter) +{ + --let $k = `select 3 * 3 * $generation_len` + --let $_k = $k + while ($k) + { + --source include/count_sessions.inc + --connect(con$k,localhost,root,,) + # + # create XA events alternating gtid domains to run them in parallel on slave. + # + --let $domain_id = `SELECT $k % $domain_num` + --eval set @@gtid_domain_id = $domain_id + --eval XA START '$trx$k' + --eval INSERT INTO t1 VALUES ($k + 1, $iter) + --eval XA END '$trx$k' + --eval XA PREPARE '$trx$k' + + --disconnect con$k + --connection master + --source include/wait_until_count_sessions.inc + + --dec $k + } + + --connection master + --let $k = $_k + while ($k) + { + --let $term = COMMIT + --let $decision = `SELECT $k % 2` + if ($decision) + { + --let $term = ROLLBACK + } + --eval XA $term '$trx$k' + } + --dec $iter +} +--enable_query_log +--source include/save_master_gtid.inc + +--connection slave +SET @@global.slave_parallel_mode = 'optimistic'; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc + + +# +# Overall consistency check +# +--let $diff_tables= master:t1, slave:t1 +--source include/diff_tables.inc + + +# +# Clean up. +# +--connection slave +--source include/stop_slave.inc +SET @@global.slave_parallel_mode = @old_parallel_mode; +SET @@global.slave_parallel_threads = @old_parallel_threads; +SET @@global.slave_domain_parallel_threads = @old_slave_domain_parallel_threads; +--source include/start_slave.inc + +--connection master +DROP TABLE t1; +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--connection master +--source include/rpl_end.inc diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index f4fddcd1f65..262c571c771 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -4199,7 +4199,8 @@ int XA_prepare_log_event::do_commit() thd->lex->xid= &xid; if (!one_phase) { - if ((res= thd->wait_for_prior_commit())) + if (thd->is_current_stmt_binlog_disabled() && + (res= thd->wait_for_prior_commit())) return res; thd->lex->sql_command= SQLCOM_XA_PREPARE; diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 68e42ecd03f..fdc960a8fc6 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -2325,6 +2325,80 @@ rpl_parallel_thread_pool::copy_pool_for_pfs(Relay_log_info *rli) } } + +/* + Check when we have done a complete round of scheduling for workers + 0, 1, ..., (rpl_thread_max-1), in this order. + This often occurs every rpl_thread_max event group, but XA XID dependency + restrictions can cause insertion of extra out-of-order worker scheduling + in-between the normal round-robin scheduling. +*/ +void +rpl_parallel_entry::check_scheduling_generation(sched_bucket *cur) +{ + uint32 idx= static_cast(cur - rpl_threads); + DBUG_ASSERT(cur >= rpl_threads); + DBUG_ASSERT(cur < rpl_threads + rpl_thread_max); + if (idx == current_generation_idx) + { + ++idx; + if (idx >= rpl_thread_max) + { + /* A new generation; all workers have been scheduled at least once. */ + idx= 0; + ++current_generation; + } + current_generation_idx= idx; + } +} + + +rpl_parallel_entry::sched_bucket * +rpl_parallel_entry::check_xa_xid_dependency(xid_t *xid) +{ + uint64 cur_gen= current_generation; + my_off_t i= 0; + while (i < maybe_active_xid.elements) + { + /* + Purge no longer active XID from the list: + + - In generation N, XID might have been scheduled for worker W. + - Events in generation (N+1) might run freely in parallel with W. + - Events in generation (N+2) will have done wait_for_prior_commit for + the event group with XID (or a later one), but the XID might still be + active for a bit longer after wakeup_prior_commit(). + - Events in generation (N+3) will have done wait_for_prior_commit() for + an event in W _after_ the XID, so are sure not to see the XID active. + + Therefore, XID can be safely scheduled to a different worker in + generation (N+3) when last prior use was in generation N (or earlier). + */ + xid_active_generation *a= + dynamic_element(&maybe_active_xid, i, xid_active_generation *); + if (a->generation + 3 <= cur_gen) + { + *a= *((xid_active_generation *)pop_dynamic(&maybe_active_xid)); + continue; + } + if (xid->eq(&a->xid)) + { + /* Update the last used generation and return the match. */ + a->generation= cur_gen; + return a->thr; + } + ++i; + } + /* try to keep allocated memory in the range of [2,10] * initial_chunk_size */ + if (maybe_active_xid.elements <= 2 * active_xid_init_alloc() && + maybe_active_xid.max_element > 10 * active_xid_init_alloc()) + freeze_size(&maybe_active_xid); + + /* No matching XID conflicts. */ + return nullptr; +} + + /* Obtain a worker thread that we can queue an event to. @@ -2369,17 +2443,36 @@ rpl_parallel_entry::choose_thread(rpl_group_info *rgi, bool *did_enter_cond, if (gtid_ev->flags2 & (Gtid_log_event::FL_COMPLETED_XA | Gtid_log_event::FL_PREPARED_XA)) { - /* - For XA COMMIT/ROLLBACK, choose the same bucket as the XA PREPARE, - overriding the round-robin scheduling. - */ - uint32 idx= my_hash_sort(&my_charset_bin, gtid_ev->xid.key(), - gtid_ev->xid.key_length()) % rpl_thread_max; - rpl_threads[idx].unlink(); - thread_sched_fifo->append(rpl_threads + idx); + if ((cur_thr= check_xa_xid_dependency(>id_ev->xid))) + { + /* + A previously scheduled event group with the same XID might still be + active in a worker, so schedule this event group in the same worker + to avoid a conflict. + */ + cur_thr->unlink(); + thread_sched_fifo->append(cur_thr); + } + else + { + /* Record this XID now active. */ + xid_active_generation *a= + (xid_active_generation *)alloc_dynamic(&maybe_active_xid); + if (!a) + return NULL; + a->thr= cur_thr= thread_sched_fifo->head(); + a->generation= current_generation; + a->xid.set(>id_ev->xid); + } } + else + cur_thr= thread_sched_fifo->head(); + + check_scheduling_generation(cur_thr); } - cur_thr= thread_sched_fifo->head(); + else + cur_thr= thread_sched_fifo->head(); + thr= cur_thr->thr; if (thr) @@ -2471,6 +2564,7 @@ free_rpl_parallel_entry(void *element) dealloc_gco(e->current_gco); e->current_gco= prev_gco; } + delete_dynamic(&e->maybe_active_xid); mysql_cond_destroy(&e->COND_parallel_entry); mysql_mutex_destroy(&e->LOCK_parallel_entry); my_free(e); @@ -2524,11 +2618,26 @@ rpl_parallel::find(uint32 domain_id) my_error(ER_OUTOFMEMORY, MYF(0), (int)(sizeof(*e)+count*sizeof(*p))); return NULL; } + /* Initialize a FIFO of scheduled worker threads. */ e->thread_sched_fifo = new (fifo) I_List; - for (ulong i= 0; i < count; ++i) - e->thread_sched_fifo->push_back(::new (p+i) rpl_parallel_entry::sched_bucket); + /* + (We cycle the FIFO _before_ allocating next entry in + rpl_parallel_entry::choose_thread(). So initialize the FIFO with the + highest element at the front, just so that the first event group gets + scheduled on entry 0). + */ + e->thread_sched_fifo-> + push_back(::new (p+count-1) rpl_parallel_entry::sched_bucket); + for (ulong i= 0; i < count-1; ++i) + e->thread_sched_fifo-> + push_back(::new (p+i) rpl_parallel_entry::sched_bucket); e->rpl_threads= p; e->rpl_thread_max= count; + e->current_generation = 0; + e->current_generation_idx = 0; + init_dynamic_array2(PSI_INSTRUMENT_ME, &e->maybe_active_xid, + sizeof(rpl_parallel_entry::xid_active_generation), + 0, e->active_xid_init_alloc(), 0, MYF(0)); e->domain_id= domain_id; e->stop_on_error_sub_id= (uint64)ULONGLONG_MAX; e->pause_sub_id= (uint64)ULONGLONG_MAX; diff --git a/sql/rpl_parallel.h b/sql/rpl_parallel.h index 9ba86453d06..a605b977473 100644 --- a/sql/rpl_parallel.h +++ b/sql/rpl_parallel.h @@ -326,10 +326,26 @@ struct rpl_parallel_thread_pool { struct rpl_parallel_entry { + /* + A small struct to put worker threads references into a FIFO (using an + I_List) for round-robin scheduling. + */ struct sched_bucket : public ilink { sched_bucket() : thr(nullptr) { } rpl_parallel_thread *thr; }; + /* + A struct to keep track of into which "generation" an XA XID was last + scheduled. A "generation" means that we know that every worker thread + slot in the rpl_parallel_entry was scheduled at least once. When more + that two generations have passed, we can safely reuse the XID in a + different worker. + */ + struct xid_active_generation { + uint64 generation; + sched_bucket *thr; + xid_t xid; + }; mysql_mutex_t LOCK_parallel_entry; mysql_cond_t COND_parallel_entry; @@ -373,6 +389,23 @@ struct rpl_parallel_entry { sched_bucket *rpl_threads; I_List *thread_sched_fifo; uint32 rpl_thread_max; + /* + Keep track of all XA XIDs that may still be active in a worker thread. + The elements are of type xid_active_generation. + */ + DYNAMIC_ARRAY maybe_active_xid; + /* + Keeping track of the current scheduling generation. + + A new generation means that every worker thread in the rpl_threads array + have been scheduled at least one event group. + + When we have scheduled to slot current_generation_idx= 0, 1, ..., N-1 in this + order, we know that (at least) one generation has passed. + */ + uint64 current_generation; + uint32 current_generation_idx; + /* The sub_id of the last transaction to commit within this domain_id. Must be accessed under LOCK_parallel_entry protection. @@ -426,11 +459,19 @@ struct rpl_parallel_entry { /* The group_commit_orderer object for the events currently being queued. */ group_commit_orderer *current_gco; + void check_scheduling_generation(sched_bucket *cur); + sched_bucket *check_xa_xid_dependency(xid_t *xid); rpl_parallel_thread * choose_thread(rpl_group_info *rgi, bool *did_enter_cond, PSI_stage_info *old_stage, Gtid_log_event *gtid_ev); int queue_master_restart(rpl_group_info *rgi, Format_description_log_event *fdev); + /* + the initial size of maybe_ array corresponds to the case of + each worker receives perhaps unlikely XA-PREPARE and XA-COMMIT within + the same generation. + */ + inline uint active_xid_init_alloc() { return 3 * 2 * rpl_thread_max; } }; struct rpl_parallel { HASH domain_hash; From 6606abb6a46dac883552fc5096c4744781310215 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 9 Apr 2024 13:25:55 +0400 Subject: [PATCH 096/313] MDEV-18319 BIGINT UNSIGNED Performance issue The patch for MDEV-18319 BIGINT UNSIGNED Performance issue fixed this problem in 10.5.23. This patch adds only an MTR test to cover MDEV-18319. --- mysql-test/main/func_in.result | 24 ++++++++++++++++++++++++ mysql-test/main/func_in.test | 21 +++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result index e81ececf752..21b11d74896 100644 --- a/mysql-test/main/func_in.result +++ b/mysql-test/main/func_in.result @@ -979,5 +979,29 @@ c1 9223372036854775808 drop table `a`; # +# MDEV-18319 BIGINT UNSIGNED Performance issue +# +CREATE OR REPLACE TABLE t1 ( +id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +); +FOR i IN 0..255 +DO +INSERT INTO t1 VALUES (); +END FOR +$$ +SELECT MIN(id), MAX(id), COUNT(*) FROM t1; +MIN(id) MAX(id) COUNT(*) +1 256 256 +EXPLAIN SELECT id FROM t1 WHERE id IN (1,2); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL 2 Using where; Using index +EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775806, 9223372036854775807); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL 2 Using where; Using index +EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775807, 9223372036854775808); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL 2 Using where; Using index +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_in.test b/mysql-test/main/func_in.test index 6cddf1dea5c..d24725dbca4 100644 --- a/mysql-test/main/func_in.test +++ b/mysql-test/main/func_in.test @@ -756,6 +756,27 @@ SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775807 ); SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775808 ); drop table `a`; +--echo # +--echo # MDEV-18319 BIGINT UNSIGNED Performance issue +--echo # + +CREATE OR REPLACE TABLE t1 ( + id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +); +DELIMITER $$; +FOR i IN 0..255 +DO + INSERT INTO t1 VALUES (); +END FOR +$$ +DELIMITER ;$$ +SELECT MIN(id), MAX(id), COUNT(*) FROM t1; +EXPLAIN SELECT id FROM t1 WHERE id IN (1,2); +EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775806, 9223372036854775807); +EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775807, 9223372036854775808); +DROP TABLE t1; + + --echo # --echo # End of 10.5 tests --echo # From a4cda66e2df93f039ee536421095e05f52ddd17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 9 Apr 2024 12:48:01 +0300 Subject: [PATCH 097/313] MDEV-33588 buf::Block_hint is a performance hog In so-called optimistic buffer pool lookups, we must not dereference a block descriptor before we have made sure that it is accessible. While buf_pool_t::resize() is running, block descriptors could become invalid. The buf::Block_hint class was essentially duplicating a buf_pool.page_hash lookup that was executed in buf_page_optimistic_get() anyway. For better locality of reference, we had better execute that lookup only once. buf_page_optimistic_fix(): Prepare for buf_page_optimistic_get(). This basically is a simpler version of Buf::Block_hint. buf_page_optimistic_get(): Assume that buf_page_optimistic_fix() has been called and the page identifier verified. Should the block be evicted, the block->modify_clock will be invalidated; we do not need to check the block->page.id() again. It suffices to check the block->modify_clock after acquiring the page latch. btr_pcur_t::old_page_id: Store the expected page identifier for buf_page_optimistic_fix(). btr_pcur_t::block_when_stored: Remove. This was duplicating page_cur_t::block. btr_pcur_optimistic_latch_leaves(): Remove redundant parameters. First, invoke buf_page_optimistic_fix() on the requested page. If needed, acquire a latch on the left page. Finally, acquire a latch on the target page and recheck the block->modify_clock. If the page had been freed while we were not holding a page latch, fall back to the slow path. Validate the FIL_PAGE_PREV after acquiring a latch on the current page. The block->modify_clock is only being incremented when records are deleted or pages reorganized or evicted; it does not guard against concurrent page splits. Reviewed by: Debarun Banerjee --- storage/innobase/CMakeLists.txt | 1 - storage/innobase/btr/btr0btr.cc | 78 +++---- storage/innobase/btr/btr0bulk.cc | 2 +- storage/innobase/btr/btr0cur.cc | 90 +++++--- storage/innobase/btr/btr0pcur.cc | 192 +++++++---------- storage/innobase/buf/buf0block_hint.cc | 59 ------ storage/innobase/buf/buf0buf.cc | 245 +++++++++++----------- storage/innobase/gis/gis0sea.cc | 38 ++-- storage/innobase/include/btr0pcur.h | 5 +- storage/innobase/include/buf0block_hint.h | 76 ------- storage/innobase/include/buf0buf.h | 30 +-- storage/innobase/include/buf0buf.inl | 14 -- storage/innobase/mtr/mtr0mtr.cc | 2 +- 13 files changed, 342 insertions(+), 490 deletions(-) delete mode 100644 storage/innobase/buf/buf0block_hint.cc delete mode 100644 storage/innobase/include/buf0block_hint.h diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 2f0ab232fc4..aaf0640cebd 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -143,7 +143,6 @@ SET(INNOBASE_SOURCES btr/btr0pcur.cc btr/btr0sea.cc btr/btr0defragment.cc - buf/buf0block_hint.cc buf/buf0buddy.cc buf/buf0buf.cc buf/buf0dblwr.cc diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 36abb31303e..6b42b3e14ec 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -264,6 +264,8 @@ btr_root_block_get( mtr_t* mtr, /*!< in: mtr */ dberr_t* err) /*!< out: error code */ { + ut_ad(mode != RW_NO_LATCH); + if (!index->table || !index->table->space) { *err= DB_TABLESPACE_NOT_FOUND; @@ -285,13 +287,12 @@ btr_root_block_get( if (UNIV_LIKELY(block != nullptr)) { - if (UNIV_UNLIKELY(mode == RW_NO_LATCH)); - else if (!!page_is_comp(block->page.frame) != - index->table->not_redundant() || - btr_page_get_index_id(block->page.frame) != index->id || - !fil_page_index_page_check(block->page.frame) || - index->is_spatial() != - (fil_page_get_type(block->page.frame) == FIL_PAGE_RTREE)) + if (!!page_is_comp(block->page.frame) != + index->table->not_redundant() || + btr_page_get_index_id(block->page.frame) != index->id || + !fil_page_index_page_check(block->page.frame) || + index->is_spatial() != + (fil_page_get_type(block->page.frame) == FIL_PAGE_RTREE)) { *err= DB_PAGE_CORRUPTED; block= nullptr; @@ -568,6 +569,31 @@ btr_page_alloc_for_ibuf( return new_block; } +static MY_ATTRIBUTE((nonnull, warn_unused_result)) +/** Acquire a latch on the index root page for allocating or freeing pages. +@param index index tree +@param mtr mini-transaction +@param err error code +@return root page +@retval nullptr if an error occurred */ +buf_block_t *btr_root_block_sx(dict_index_t *index, mtr_t *mtr, dberr_t *err) +{ + buf_block_t *root= + mtr->get_already_latched(page_id_t{index->table->space_id, index->page}, + MTR_MEMO_PAGE_SX_FIX); + if (!root) + { + root= btr_root_block_get(index, RW_SX_LATCH, mtr, err); + if (UNIV_UNLIKELY(!root)) + return root; + } +#ifdef BTR_CUR_HASH_ADAPT + else + ut_ad(!root->index || !root->index->freed()); +#endif + return root; +} + /**************************************************************//** Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents! @@ -589,21 +615,9 @@ btr_page_alloc_low( page should be initialized. */ dberr_t* err) /*!< out: error code */ { - const auto savepoint= mtr->get_savepoint(); - buf_block_t *root= btr_root_block_get(index, RW_NO_LATCH, mtr, err); + buf_block_t *root= btr_root_block_sx(index, mtr, err); if (UNIV_UNLIKELY(!root)) return root; - - const bool have_latch= mtr->have_u_or_x_latch(*root); -#ifdef BTR_CUR_HASH_ADAPT - ut_ad(!have_latch || !root->index || !root->index->freed()); -#endif - mtr->rollback_to_savepoint(savepoint); - - if (!have_latch && - UNIV_UNLIKELY(!(root= btr_root_block_get(index, RW_SX_LATCH, mtr, err)))) - return root; - fseg_header_t *seg_header= root->page.frame + (level ? PAGE_HEADER + PAGE_BTR_SEG_TOP : PAGE_HEADER + PAGE_BTR_SEG_LEAF); return fseg_alloc_free_page_general(seg_header, hint_page_no, file_direction, @@ -696,24 +710,16 @@ dberr_t btr_page_free(dict_index_t* index, buf_block_t* block, mtr_t* mtr, fil_space_t *space= index->table->space; dberr_t err; - const auto savepoint= mtr->get_savepoint(); - if (buf_block_t *root= btr_root_block_get(index, RW_NO_LATCH, mtr, &err)) + if (buf_block_t *root= btr_root_block_sx(index, mtr, &err)) { - const bool have_latch= mtr->have_u_or_x_latch(*root); -#ifdef BTR_CUR_HASH_ADAPT - ut_ad(!have_latch || !root->index || !root->index->freed()); -#endif - mtr->rollback_to_savepoint(savepoint); - if (have_latch || - (root= btr_root_block_get(index, RW_SX_LATCH, mtr, &err))) - err= fseg_free_page(&root->page.frame[blob || - page_is_leaf(block->page.frame) - ? PAGE_HEADER + PAGE_BTR_SEG_LEAF - : PAGE_HEADER + PAGE_BTR_SEG_TOP], - space, page, mtr, space_latched); + err= fseg_free_page(&root->page.frame[blob || + page_is_leaf(block->page.frame) + ? PAGE_HEADER + PAGE_BTR_SEG_LEAF + : PAGE_HEADER + PAGE_BTR_SEG_TOP], + space, page, mtr, space_latched); + if (err == DB_SUCCESS) + buf_page_free(space, page, mtr); } - if (err == DB_SUCCESS) - buf_page_free(space, page, mtr); /* The page was marked free in the allocation bitmap, but it should remain exclusively latched until mtr_t::commit() or until it diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index eead663b32c..5dcd19fec64 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -837,7 +837,7 @@ PageBulk::release() m_block->page.fix(); /* No other threads can modify this block. */ - m_modify_clock = buf_block_get_modify_clock(m_block); + m_modify_clock = m_block->modify_clock; m_mtr.commit(); } diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index dc8e9159e6e..aa8ff37272c 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -935,7 +935,7 @@ static inline page_cur_mode_t btr_cur_nonleaf_mode(page_cur_mode_t mode) return PAGE_CUR_LE; } -static MY_ATTRIBUTE((nonnull)) +MY_ATTRIBUTE((nonnull,warn_unused_result)) /** Acquire a latch on the previous page without violating the latching order. @param block index page @param page_id page identifier with valid space identifier @@ -946,8 +946,9 @@ static MY_ATTRIBUTE((nonnull)) @retval 0 if an error occurred @retval 1 if the page could be latched in the wrong order @retval -1 if the latch on block was temporarily released */ -int btr_latch_prev(buf_block_t *block, page_id_t page_id, ulint zip_size, - rw_lock_type_t rw_latch, mtr_t *mtr, dberr_t *err) +static int btr_latch_prev(buf_block_t *block, page_id_t page_id, + ulint zip_size, + rw_lock_type_t rw_latch, mtr_t *mtr, dberr_t *err) { ut_ad(rw_latch == RW_S_LATCH || rw_latch == RW_X_LATCH); ut_ad(page_id.space() == block->page.id().space()); @@ -955,47 +956,80 @@ int btr_latch_prev(buf_block_t *block, page_id_t page_id, ulint zip_size, const auto prev_savepoint= mtr->get_savepoint(); ut_ad(block == mtr->at_savepoint(prev_savepoint - 1)); - page_id.set_page_no(btr_page_get_prev(block->page.frame)); + const page_t *const page= block->page.frame; + page_id.set_page_no(btr_page_get_prev(page)); + /* We are holding a latch on the current page. + + We will start by buffer-fixing the left sibling. Waiting for a latch + on it while holding a latch on the current page could lead to a + deadlock, because another thread could hold that latch and wait for + a right sibling page latch (the current page). + + If there is a conflict, we will temporarily release our latch on the + current block while waiting for a latch on the left sibling. The + buffer-fixes on both blocks will prevent eviction. */ + + retry: buf_block_t *prev= buf_page_get_gen(page_id, zip_size, RW_NO_LATCH, nullptr, BUF_GET, mtr, err, false); if (UNIV_UNLIKELY(!prev)) return 0; int ret= 1; - if (UNIV_UNLIKELY(rw_latch == RW_S_LATCH)) + static_assert(MTR_MEMO_PAGE_S_FIX == mtr_memo_type_t(BTR_SEARCH_LEAF), ""); + static_assert(MTR_MEMO_PAGE_X_FIX == mtr_memo_type_t(BTR_MODIFY_LEAF), ""); + + if (rw_latch == RW_S_LATCH + ? prev->page.lock.s_lock_try() : prev->page.lock.x_lock_try()) { - if (UNIV_LIKELY(prev->page.lock.s_lock_try())) + mtr->lock_register(prev_savepoint, mtr_memo_type_t(rw_latch)); + if (UNIV_UNLIKELY(prev->page.id() != page_id)) { - mtr->lock_register(prev_savepoint, MTR_MEMO_PAGE_S_FIX); - goto prev_latched; + fail: + /* the page was just read and found to be corrupted */ + mtr->rollback_to_savepoint(prev_savepoint); + return 0; } - block->page.lock.s_unlock(); } else { - if (UNIV_LIKELY(prev->page.lock.x_lock_try())) + ut_ad(mtr->at_savepoint(mtr->get_savepoint() - 1)->page.id() == page_id); + mtr->release_last_page(); + if (rw_latch == RW_S_LATCH) + block->page.lock.s_unlock(); + else + block->page.lock.x_unlock(); + + prev= buf_page_get_gen(page_id, zip_size, rw_latch, prev, + BUF_GET, mtr, err); + if (rw_latch == RW_S_LATCH) + block->page.lock.s_lock(); + else + block->page.lock.x_lock(); + + const page_id_t prev_page_id= page_id; + page_id.set_page_no(btr_page_get_prev(page)); + + if (UNIV_UNLIKELY(page_id != prev_page_id)) { - mtr->lock_register(prev_savepoint, MTR_MEMO_PAGE_X_FIX); - goto prev_latched; + mtr->release_last_page(); + if (page_id.page_no() == FIL_NULL) + return -1; + goto retry; } - block->page.lock.x_unlock(); + + if (UNIV_UNLIKELY(!prev)) + goto fail; + + ret= -1; } - ret= -1; - mtr->lock_register(prev_savepoint - 1, MTR_MEMO_BUF_FIX); - mtr->rollback_to_savepoint(prev_savepoint); - prev= buf_page_get_gen(page_id, zip_size, rw_latch, prev, - BUF_GET, mtr, err, false); - if (UNIV_UNLIKELY(!prev)) - return 0; - mtr->upgrade_buffer_fix(prev_savepoint - 1, rw_latch); - - prev_latched: - if (memcmp_aligned<2>(FIL_PAGE_TYPE + prev->page.frame, - FIL_PAGE_TYPE + block->page.frame, 2) || - memcmp_aligned<2>(PAGE_HEADER + PAGE_INDEX_ID + prev->page.frame, - PAGE_HEADER + PAGE_INDEX_ID + block->page.frame, 8) || - page_is_comp(prev->page.frame) != page_is_comp(block->page.frame)) + const page_t *const p= prev->page.frame; + if (memcmp_aligned<4>(FIL_PAGE_NEXT + p, FIL_PAGE_OFFSET + page, 4) || + memcmp_aligned<2>(FIL_PAGE_TYPE + p, FIL_PAGE_TYPE + page, 2) || + memcmp_aligned<2>(PAGE_HEADER + PAGE_INDEX_ID + p, + PAGE_HEADER + PAGE_INDEX_ID + page, 8) || + page_is_comp(p) != page_is_comp(page)) { ut_ad("corrupted" == 0); // FIXME: remove this *err= DB_CORRUPTION; diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index 0be12523ae1..3ecdf64fb5f 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -179,10 +179,8 @@ before_first: cursor->old_n_fields, &cursor->old_rec_buf, &cursor->buf_size); - cursor->block_when_stored.store(block); - - /* Function try to check if block is S/X latch. */ - cursor->modify_clock = buf_block_get_modify_clock(block); + cursor->old_page_id = block->page.id(); + cursor->modify_clock = block->modify_clock; } /**************************************************************//** @@ -214,101 +212,80 @@ btr_pcur_copy_stored_position( } /** Optimistically latches the leaf page or pages requested. -@param[in] block guessed buffer block -@param[in,out] pcur cursor -@param[in,out] latch_mode BTR_SEARCH_LEAF, ... -@param[in,out] mtr mini-transaction -@return true if success */ +@param pcur persistent cursor +@param latch_mode BTR_SEARCH_LEAF, ... +@param mtr mini-transaction +@return true on success */ TRANSACTIONAL_TARGET -static bool btr_pcur_optimistic_latch_leaves(buf_block_t *block, - btr_pcur_t *pcur, +static bool btr_pcur_optimistic_latch_leaves(btr_pcur_t *pcur, btr_latch_mode *latch_mode, mtr_t *mtr) { - ut_ad(block->page.buf_fix_count()); - ut_ad(block->page.in_file()); - ut_ad(block->page.frame); - static_assert(BTR_SEARCH_PREV & BTR_SEARCH_LEAF, ""); static_assert(BTR_MODIFY_PREV & BTR_MODIFY_LEAF, ""); static_assert((BTR_SEARCH_PREV ^ BTR_MODIFY_PREV) == (RW_S_LATCH ^ RW_X_LATCH), ""); + buf_block_t *const block= + buf_page_optimistic_fix(pcur->btr_cur.page_cur.block, pcur->old_page_id); + + if (!block) + return false; + + if (*latch_mode == BTR_SEARCH_LEAF || *latch_mode == BTR_MODIFY_LEAF) + return buf_page_optimistic_get(block, rw_lock_type_t(*latch_mode), + pcur->modify_clock, mtr); + + ut_ad(*latch_mode == BTR_SEARCH_PREV || *latch_mode == BTR_MODIFY_PREV); const rw_lock_type_t mode= rw_lock_type_t(*latch_mode & (RW_X_LATCH | RW_S_LATCH)); - switch (*latch_mode) { - default: - ut_ad(*latch_mode == BTR_SEARCH_LEAF || *latch_mode == BTR_MODIFY_LEAF); - return buf_page_optimistic_get(mode, block, pcur->modify_clock, mtr); - case BTR_SEARCH_PREV: - case BTR_MODIFY_PREV: - page_id_t id{0}; - uint32_t left_page_no; - ulint zip_size; - buf_block_t *left_block= nullptr; - { - transactional_shared_lock_guard g{block->page.lock}; - if (block->modify_clock != pcur->modify_clock) - return false; - id= block->page.id(); - zip_size= block->zip_size(); - left_page_no= btr_page_get_prev(block->page.frame); - } + uint64_t modify_clock; + uint32_t left_page_no; + const page_t *const page= block->page.frame; + { + transactional_shared_lock_guard g{block->page.lock}; + modify_clock= block->modify_clock; + left_page_no= btr_page_get_prev(page); + } - if (left_page_no != FIL_NULL) - { - left_block= - buf_page_get_gen(page_id_t(id.space(), left_page_no), zip_size, - mode, nullptr, BUF_GET_POSSIBLY_FREED, mtr); + const auto savepoint= mtr->get_savepoint(); + mtr->memo_push(block, MTR_MEMO_BUF_FIX); - if (!left_block); - else if (btr_page_get_next(left_block->page.frame) != id.page_no()) - { -release_left_block: - mtr->release_last_page(); - return false; - } - else - buf_page_make_young_if_needed(&left_block->page); - } - - if (buf_page_optimistic_get(mode, block, pcur->modify_clock, mtr)) - { - if (btr_page_get_prev(block->page.frame) == left_page_no) - { - /* block was already buffer-fixed while entering the function and - buf_page_optimistic_get() buffer-fixes it again. */ - ut_ad(2 <= block->page.buf_fix_count()); - *latch_mode= btr_latch_mode(mode); - return true; - } - - mtr->release_last_page(); - } - - ut_ad(block->page.buf_fix_count()); - if (left_block) - goto release_left_block; + if (UNIV_UNLIKELY(modify_clock != pcur->modify_clock)) + { + fail: + mtr->rollback_to_savepoint(savepoint); return false; } -} -/** Structure acts as functor to do the latching of leaf pages. -It returns true if latching of leaf pages succeeded and false -otherwise. */ -struct optimistic_latch_leaves -{ - btr_pcur_t *const cursor; - btr_latch_mode *const latch_mode; - mtr_t *const mtr; - - bool operator()(buf_block_t *hint) const + buf_block_t *prev; + if (left_page_no != FIL_NULL) { - return hint && - btr_pcur_optimistic_latch_leaves(hint, cursor, latch_mode, mtr); + prev= buf_page_get_gen(page_id_t(pcur->old_page_id.space(), + left_page_no), block->zip_size(), + mode, nullptr, BUF_GET_POSSIBLY_FREED, mtr); + if (!prev || + page_is_comp(prev->page.frame) != page_is_comp(block->page.frame) || + memcmp_aligned<2>(block->page.frame, prev->page.frame, 2) || + memcmp_aligned<2>(block->page.frame + PAGE_HEADER + PAGE_INDEX_ID, + prev->page.frame + PAGE_HEADER + PAGE_INDEX_ID, 8)) + goto fail; } -}; + else + prev= nullptr; + + mtr->upgrade_buffer_fix(savepoint, mode); + + if (UNIV_UNLIKELY(block->modify_clock != modify_clock) || + UNIV_UNLIKELY(block->page.is_freed()) || + (prev && + memcmp_aligned<4>(FIL_PAGE_NEXT + prev->page.frame, + FIL_PAGE_OFFSET + page, 4))) + goto fail; + + return true; +} /** Restores the stored position of a persistent cursor bufferfixing the page and obtaining the specified latches. If the cursor position @@ -331,6 +308,7 @@ btr_pcur_t::SAME_UNIQ cursor position is on user rec and points on the record with the same unique field values as in the stored record, btr_pcur_t::NOT_SAME cursor position is not on user rec or points on the record with not the samebuniq field values as in the stored */ +TRANSACTIONAL_TARGET btr_pcur_t::restore_status btr_pcur_t::restore_position(btr_latch_mode restore_latch_mode, mtr_t *mtr) { @@ -361,7 +339,6 @@ btr_pcur_t::restore_position(btr_latch_mode restore_latch_mode, mtr_t *mtr) latch_mode = BTR_LATCH_MODE_WITHOUT_INTENTION(restore_latch_mode); pos_state = BTR_PCUR_IS_POSITIONED; - block_when_stored.clear(); return restore_status::NOT_SAME; } @@ -378,9 +355,8 @@ btr_pcur_t::restore_position(btr_latch_mode restore_latch_mode, mtr_t *mtr) case BTR_SEARCH_PREV: case BTR_MODIFY_PREV: /* Try optimistic restoration. */ - if (block_when_stored.run_with_hint( - optimistic_latch_leaves{this, &restore_latch_mode, - mtr})) { + if (btr_pcur_optimistic_latch_leaves(this, &restore_latch_mode, + mtr)) { pos_state = BTR_PCUR_IS_POSITIONED; latch_mode = restore_latch_mode; @@ -485,9 +461,8 @@ btr_pcur_t::restore_position(btr_latch_mode restore_latch_mode, mtr_t *mtr) since the cursor can now be on a different page! But we can retain the value of old_rec */ - block_when_stored.store(btr_pcur_get_block(this)); - modify_clock= buf_block_get_modify_clock( - block_when_stored.block()); + old_page_id = btr_cur.page_cur.block->page.id(); + modify_clock = btr_cur.page_cur.block->modify_clock; mem_heap_free(heap); @@ -612,40 +587,33 @@ btr_pcur_move_backward_from_page( return true; } - buf_block_t* block = btr_pcur_get_block(cursor); + buf_block_t* block = mtr->at_savepoint(0); + ut_ad(block == btr_pcur_get_block(cursor)); + const page_t* const page = block->page.frame; + /* btr_pcur_optimistic_latch_leaves() will acquire a latch on + the preceding page if one exists; + if that fails, btr_cur_t::search_leaf() invoked by + btr_pcur_open_with_no_init() will also acquire a latch on the + succeeding page. Our caller only needs one page latch. */ + ut_ad(mtr->get_savepoint() <= 3); - if (page_has_prev(block->page.frame)) { - buf_block_t* left_block - = mtr->at_savepoint(mtr->get_savepoint() - 1); - const page_t* const left = left_block->page.frame; - if (memcmp_aligned<4>(left + FIL_PAGE_NEXT, - block->page.frame - + FIL_PAGE_OFFSET, 4)) { - /* This should be the right sibling page, or - if there is none, the current block. */ - ut_ad(left_block == block - || !memcmp_aligned<4>(left + FIL_PAGE_PREV, - block->page.frame - + FIL_PAGE_OFFSET, 4)); - /* The previous one must be the left sibling. */ - left_block - = mtr->at_savepoint(mtr->get_savepoint() - 2); - ut_ad(!memcmp_aligned<4>(left_block->page.frame - + FIL_PAGE_NEXT, - block->page.frame - + FIL_PAGE_OFFSET, 4)); - } + if (page_has_prev(page)) { + buf_block_t* const left_block = mtr->at_savepoint(1); + ut_ad(!memcmp_aligned<4>(page + FIL_PAGE_OFFSET, + left_block->page.frame + + FIL_PAGE_NEXT, 4)); if (btr_pcur_is_before_first_on_page(cursor)) { + /* Reposition on the previous page. */ page_cur_set_after_last(left_block, &cursor->btr_cur.page_cur); /* Release the right sibling. */ - } else { - /* Release the left sibling. */ + mtr->rollback_to_savepoint(0, 1); block = left_block; } - mtr->release(*block); } + mtr->rollback_to_savepoint(1); + ut_ad(block == mtr->at_savepoint(0)); cursor->latch_mode = latch_mode; cursor->old_rec = nullptr; return false; diff --git a/storage/innobase/buf/buf0block_hint.cc b/storage/innobase/buf/buf0block_hint.cc deleted file mode 100644 index 6bd01faa279..00000000000 --- a/storage/innobase/buf/buf0block_hint.cc +++ /dev/null @@ -1,59 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2020, 2021, MariaDB Corporation. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License, version 2.0, as published by the -Free Software Foundation. - -This program is also distributed with certain software (including but not -limited to OpenSSL) that is licensed under separate terms, as designated in a -particular file or component or in included license documentation. The authors -of MySQL hereby grant you an additional permission to link the program and -your derivative works with the separately licensed software that they have -included with MySQL. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, -for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*****************************************************************************/ - -#include "buf0block_hint.h" -namespace buf { - -TRANSACTIONAL_TARGET -void Block_hint::buffer_fix_block_if_still_valid() -{ - /* To check if m_block belongs to the current buf_pool, we must - prevent freeing memory while we check, and until we buffer-fix the - block. For this purpose it is enough to latch any of the many - latches taken by buf_pool_t::resize(). - - Similar to buf_page_optimistic_get(), we must validate - m_block->page.id() after acquiring the hash_lock, because the object - may have been freed and not actually attached to buf_pool.page_hash - at the moment. (The block could have been reused to store a - different page, and that slice of buf_pool.page_hash could be protected - by another hash_lock that we are not holding.) - - Finally, we must ensure that the block is not being freed. */ - if (m_block) - { - auto &cell= buf_pool.page_hash.cell_get(m_page_id.fold()); - transactional_shared_lock_guard g - {buf_pool.page_hash.lock_get(cell)}; - if (buf_pool.is_uncompressed(m_block) && m_page_id == m_block->page.id() && - m_block->page.frame && m_block->page.in_file()) - m_block->page.fix(); - else - clear(); - } -} -} // namespace buf diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 90f47f1fbf0..dc90160a668 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2562,9 +2562,10 @@ got_block_fixed: if (state > buf_page_t::READ_FIX && state < buf_page_t::WRITE_FIX) { if (mode == BUF_PEEK_IF_IN_POOL) { ignore_block: + block->unfix(); +ignore_unfixed: ut_ad(mode == BUF_GET_POSSIBLY_FREED || mode == BUF_PEEK_IF_IN_POOL); - block->unfix(); if (err) { *err = DB_CORRUPTION; } @@ -2585,9 +2586,17 @@ ignore_block: const page_id_t id{block->page.id()}; block->page.lock.s_unlock(); - if (UNIV_UNLIKELY(id != page_id)) { - ut_ad(id == page_id_t{~0ULL}); + if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) { block->page.unfix(); + if (UNIV_UNLIKELY(id == page_id)) { + /* The page read was completed, and + another thread marked the page as free + while we were waiting. */ + goto ignore_unfixed; + } + + ut_ad(id == page_id_t{~0ULL}); + if (++retries < BUF_PAGE_READ_MAX_RETRIES) { goto loop; } @@ -2598,6 +2607,7 @@ ignore_block: return nullptr; } + ut_ad(id == page_id); } else if (mode != BUF_PEEK_IF_IN_POOL) { } else if (!mtr) { ut_ad(!block->page.oldest_modification()); @@ -2804,83 +2814,72 @@ re_evict_fail: #endif /* UNIV_DEBUG */ ut_ad(block->page.frame); + /* The state = block->page.state() may be stale at this point, + and in fact, at any point of time if we consider its + buffer-fix component. If the block is being read into the + buffer pool, it is possible that buf_page_t::read_complete() + will invoke buf_pool_t::corrupted_evict() and therefore + invalidate it (invoke buf_page_t::set_corrupt_id() and set the + state to FREED). Therefore, after acquiring the page latch we + must recheck the state. */ + if (state >= buf_page_t::UNFIXED && allow_ibuf_merge && fil_page_get_type(block->page.frame) == FIL_PAGE_INDEX && page_is_leaf(block->page.frame)) { block->page.lock.x_lock(); - ut_ad(block->page.id() == page_id - || (state >= buf_page_t::READ_FIX - && state < buf_page_t::WRITE_FIX)); - -#ifdef BTR_CUR_HASH_ADAPT - btr_search_drop_page_hash_index(block, true); -#endif /* BTR_CUR_HASH_ADAPT */ - - dberr_t e; - - if (UNIV_UNLIKELY(block->page.id() != page_id)) { -page_id_mismatch: - state = block->page.state(); - e = DB_CORRUPTION; -ibuf_merge_corrupted: - if (err) { - *err = e; - } - - if (block->page.id().is_corrupted()) { - buf_pool.corrupted_evict(&block->page, state); - } - return nullptr; - } - state = block->page.state(); ut_ad(state < buf_page_t::READ_FIX); if (state >= buf_page_t::IBUF_EXIST && state < buf_page_t::REINIT) { block->page.clear_ibuf_exist(); - e = ibuf_merge_or_delete_for_page(block, page_id, - block->zip_size()); - if (UNIV_UNLIKELY(e != DB_SUCCESS)) { - goto ibuf_merge_corrupted; + if (dberr_t local_err = + ibuf_merge_or_delete_for_page(block, page_id, + block->zip_size())) { + if (err) { + *err = local_err; + } + goto release_and_ignore_block; } + } else if (state < buf_page_t::UNFIXED) { +release_and_ignore_block: + block->page.lock.x_unlock(); + goto ignore_block; } - if (rw_latch == RW_X_LATCH) { - goto get_latch_valid; - } else { +#ifdef BTR_CUR_HASH_ADAPT + btr_search_drop_page_hash_index(block, true); +#endif /* BTR_CUR_HASH_ADAPT */ + + switch (rw_latch) { + case RW_NO_LATCH: block->page.lock.x_unlock(); - goto get_latch; + break; + case RW_S_LATCH: + block->page.lock.x_unlock(); + block->page.lock.s_lock(); + break; + case RW_SX_LATCH: + block->page.lock.x_u_downgrade(); + break; + default: + ut_ad(rw_latch == RW_X_LATCH); } + + mtr->memo_push(block, mtr_memo_type_t(rw_latch)); } else { -get_latch: switch (rw_latch) { case RW_NO_LATCH: mtr->memo_push(block, MTR_MEMO_BUF_FIX); return block; case RW_S_LATCH: block->page.lock.s_lock(); - ut_ad(!block->page.is_read_fixed()); - if (UNIV_UNLIKELY(block->page.id() != page_id)) { - block->page.lock.s_unlock(); - block->page.lock.x_lock(); - goto page_id_mismatch; - } -get_latch_valid: - mtr->memo_push(block, mtr_memo_type_t(rw_latch)); -#ifdef BTR_CUR_HASH_ADAPT - btr_search_drop_page_hash_index(block, true); -#endif /* BTR_CUR_HASH_ADAPT */ break; case RW_SX_LATCH: block->page.lock.u_lock(); ut_ad(!block->page.is_io_fixed()); - if (UNIV_UNLIKELY(block->page.id() != page_id)) { - block->page.lock.u_x_upgrade(); - goto page_id_mismatch; - } - goto get_latch_valid; + break; default: ut_ad(rw_latch == RW_X_LATCH); if (block->page.lock.x_lock_upgraded()) { @@ -2889,17 +2888,26 @@ get_latch_valid: mtr->page_lock_upgrade(*block); return block; } - if (UNIV_UNLIKELY(block->page.id() != page_id)) { - goto page_id_mismatch; - } - goto get_latch_valid; } - ut_ad(page_id_t(page_get_space_id(block->page.frame), - page_get_page_no(block->page.frame)) - == page_id); + mtr->memo_push(block, mtr_memo_type_t(rw_latch)); + state = block->page.state(); + + if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) { + mtr->release_last_page(); + goto ignore_unfixed; + } + + ut_ad(state < buf_page_t::READ_FIX + || state > buf_page_t::WRITE_FIX); + +#ifdef BTR_CUR_HASH_ADAPT + btr_search_drop_page_hash_index(block, true); +#endif /* BTR_CUR_HASH_ADAPT */ } + ut_ad(page_id_t(page_get_space_id(block->page.frame), + page_get_page_no(block->page.frame)) == page_id); return block; } @@ -2995,83 +3003,76 @@ buf_page_get_gen( return block; } -/********************************************************************//** -This is the general function used to get optimistic access to a database -page. -@return TRUE if success */ TRANSACTIONAL_TARGET -bool buf_page_optimistic_get(ulint rw_latch, buf_block_t *block, - uint64_t modify_clock, mtr_t *mtr) +buf_block_t *buf_page_optimistic_fix(buf_block_t *block, page_id_t id) +{ + buf_pool_t::hash_chain &chain= buf_pool.page_hash.cell_get(id.fold()); + transactional_shared_lock_guard g + {buf_pool.page_hash.lock_get(chain)}; + if (UNIV_UNLIKELY(!buf_pool.is_uncompressed(block) || + id != block->page.id() || !block->page.frame)) + return nullptr; + const auto state= block->page.state(); + if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED || + state >= buf_page_t::READ_FIX)) + return nullptr; + block->page.fix(); + return block; +} + +buf_block_t *buf_page_optimistic_get(buf_block_t *block, + rw_lock_type_t rw_latch, + uint64_t modify_clock, mtr_t *mtr) { - ut_ad(block); - ut_ad(mtr); ut_ad(mtr->is_active()); ut_ad(rw_latch == RW_S_LATCH || rw_latch == RW_X_LATCH); + ut_ad(block->page.buf_fix_count()); - if (have_transactional_memory); - else if (UNIV_UNLIKELY(!block->page.frame)) - return false; - else + if (rw_latch == RW_S_LATCH) { - const auto state= block->page.state(); - if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED || - state >= buf_page_t::READ_FIX)) - return false; - } - - bool success; - const page_id_t id{block->page.id()}; - buf_pool_t::hash_chain &chain= buf_pool.page_hash.cell_get(id.fold()); - bool have_u_not_x= false; - - { - transactional_shared_lock_guard g - {buf_pool.page_hash.lock_get(chain)}; - if (UNIV_UNLIKELY(id != block->page.id() || !block->page.frame)) - return false; - const auto state= block->page.state(); - if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED || - state >= buf_page_t::READ_FIX)) - return false; - - if (rw_latch == RW_S_LATCH) - success= block->page.lock.s_lock_try(); - else + if (!block->page.lock.s_lock_try()) { - have_u_not_x= block->page.lock.have_u_not_x(); - success= have_u_not_x || block->page.lock.x_lock_try(); + fail: + block->page.unfix(); + return nullptr; } - } - if (!success) - return false; - - if (have_u_not_x) - { - block->page.lock.u_x_upgrade(); - mtr->page_lock_upgrade(*block); - ut_ad(id == block->page.id()); - ut_ad(modify_clock == block->modify_clock); - } - else - { - ut_ad(rw_latch == RW_S_LATCH || !block->page.is_io_fixed()); - ut_ad(id == block->page.id()); - ut_ad(!ibuf_inside(mtr) || ibuf_page(id, block->zip_size(), nullptr)); + ut_ad(!ibuf_inside(mtr) || + ibuf_page(block->page.id(), block->zip_size(), nullptr)); if (modify_clock != block->modify_clock || block->page.is_freed()) { - if (rw_latch == RW_S_LATCH) - block->page.lock.s_unlock(); - else - block->page.lock.x_unlock(); - return false; + block->page.lock.s_unlock(); + goto fail; } - block->page.fix(); ut_ad(!block->page.is_read_fixed()); buf_page_make_young_if_needed(&block->page); - mtr->memo_push(block, mtr_memo_type_t(rw_latch)); + mtr->memo_push(block, MTR_MEMO_PAGE_S_FIX); + } + else if (block->page.lock.have_u_not_x()) + { + block->page.lock.u_x_upgrade(); + block->page.unfix(); + mtr->page_lock_upgrade(*block); + ut_ad(modify_clock == block->modify_clock); + } + else if (!block->page.lock.x_lock_try()) + goto fail; + else + { + ut_ad(!block->page.is_io_fixed()); + ut_ad(!ibuf_inside(mtr) || + ibuf_page(block->page.id(), block->zip_size(), nullptr)); + + if (modify_clock != block->modify_clock || block->page.is_freed()) + { + block->page.lock.x_unlock(); + goto fail; + } + + buf_page_make_young_if_needed(&block->page); + mtr->memo_push(block, MTR_MEMO_PAGE_X_FIX); } ut_d(if (!(++buf_dbg_counter % 5771)) buf_pool.validate()); @@ -3081,7 +3082,7 @@ bool buf_page_optimistic_get(ulint rw_latch, buf_block_t *block, ut_ad(~buf_page_t::LRU_MASK & state); ut_ad(block->page.frame); - return true; + return block; } /** Try to S-latch a page. diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 0df9a7ded9a..fb4fcf7bc8d 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -672,8 +672,13 @@ dberr_t rtr_search_to_nth_level(ulint level, const dtuple_t *tuple, buf_mode, mtr, &err, false); if (!block) { - if (err == DB_DECRYPTION_FAILED) - btr_decryption_failed(*index); + if (err) + { + err_exit: + if (err == DB_DECRYPTION_FAILED) + btr_decryption_failed(*index); + mtr->rollback_to_savepoint(savepoint); + } func_exit: if (UNIV_LIKELY_NULL(heap)) mem_heap_free(heap); @@ -737,7 +742,8 @@ dberr_t rtr_search_to_nth_level(ulint level, const dtuple_t *tuple, #endif } - if (height == 0) { + if (height == 0) + { if (rw_latch == RW_NO_LATCH) { ut_ad(block == mtr->at_savepoint(block_savepoint)); @@ -821,7 +827,7 @@ dberr_t rtr_search_to_nth_level(ulint level, const dtuple_t *tuple, if (page_cur_search_with_match(tuple, page_mode, &up_match, &low_match, &cur->page_cur, nullptr)) { err= DB_CORRUPTION; - goto func_exit; + goto err_exit; } } @@ -1584,23 +1590,6 @@ rtr_check_discard_page( lock_sys.prdt_page_free_from_discard(id, true); } -/** Structure acts as functor to get the optimistic access of the page. -It returns true if it successfully gets the page. */ -struct optimistic_get -{ - btr_pcur_t *const r_cursor; - mtr_t *const mtr; - - optimistic_get(btr_pcur_t *r_cursor,mtr_t *mtr) - :r_cursor(r_cursor), mtr(mtr) {} - - bool operator()(buf_block_t *hint) const - { - return hint && buf_page_optimistic_get( - RW_X_LATCH, hint, r_cursor->modify_clock, mtr); - } -}; - /** Restore the stored position of a persistent cursor bufferfixing the page */ static bool @@ -1632,8 +1621,11 @@ rtr_cur_restore_position( r_cursor->modify_clock = 100; ); - if (r_cursor->block_when_stored.run_with_hint( - optimistic_get(r_cursor, mtr))) { + if (buf_page_optimistic_fix(r_cursor->btr_cur.page_cur.block, + r_cursor->old_page_id) + && buf_page_optimistic_get(r_cursor->btr_cur.page_cur.block, + RW_X_LATCH, r_cursor->modify_clock, + mtr)) { ut_ad(r_cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(r_cursor->rel_pos == BTR_PCUR_ON); diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index c66a3bfa329..775f1536f83 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -28,7 +28,6 @@ Created 2/23/1996 Heikki Tuuri #include "dict0dict.h" #include "btr0cur.h" -#include "buf0block_hint.h" #include "btr0btr.h" #include "gis0rtree.h" @@ -332,8 +331,8 @@ struct btr_pcur_t /** BTR_PCUR_ON, BTR_PCUR_BEFORE, or BTR_PCUR_AFTER, depending on whether cursor was on, before, or after the old_rec record */ btr_pcur_pos_t rel_pos= btr_pcur_pos_t(0); - /** buffer block when the position was stored */ - buf::Block_hint block_when_stored; + /** the page identifier of old_rec */ + page_id_t old_page_id{0,0}; /** the modify clock value of the buffer block when the cursor position was stored */ ib_uint64_t modify_clock= 0; diff --git a/storage/innobase/include/buf0block_hint.h b/storage/innobase/include/buf0block_hint.h deleted file mode 100644 index d4fee7c1e99..00000000000 --- a/storage/innobase/include/buf0block_hint.h +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2020, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 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, version 2.0, as published by the -Free Software Foundation. - -This program is also distributed with certain software (including but not -limited to OpenSSL) that is licensed under separate terms, as designated in a -particular file or component or in included license documentation. The authors -of MySQL hereby grant you an additional permission to link the program and -your derivative works with the separately licensed software that they have -included with MySQL. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, -for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*****************************************************************************/ -#pragma once -#include "buf0buf.h" - -namespace buf { -class Block_hint { -public: - /** Stores the pointer to the block, which is currently buffer-fixed. - @param block a pointer to a buffer-fixed block to be stored */ - inline void store(buf_block_t *block) - { - ut_ad(block->page.buf_fix_count()); - m_block= block; - m_page_id= block->page.id(); - } - - /** Clears currently stored pointer. */ - inline void clear() { m_block= nullptr; } - - /** Invoke f on m_block(which may be null) - @param f The function to be executed. It will be passed the pointer. - If you wish to use the block pointer subsequently, - you need to ensure you buffer-fix it before returning from f. - @return the return value of f - */ - template - bool run_with_hint(const F &f) - { - buffer_fix_block_if_still_valid(); - /* m_block could be changed during f() call, so we use local - variable to remember which block we need to unfix */ - buf_block_t *block= m_block; - bool res= f(block); - if (block) - block->page.unfix(); - return res; - } - - buf_block_t *block() const { return m_block; } - - private: - /** The block pointer stored by store(). */ - buf_block_t *m_block= nullptr; - /** If m_block is non-null, the m_block->page.id at time it was stored. */ - page_id_t m_page_id{0, 0}; - - /** A helper function which checks if m_block is not a dangling pointer and - still points to block with page with m_page_id and if so, buffer-fixes it, - otherwise clear()s it */ - void buffer_fix_block_if_still_valid(); -}; -} // namespace buf diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 51e30c88a86..2a79b112bab 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -158,14 +158,25 @@ buf_block_free( #define buf_page_get(ID, SIZE, LA, MTR) \ buf_page_get_gen(ID, SIZE, LA, NULL, BUF_GET, MTR) -/** Try to acquire a page latch. -@param rw_latch RW_S_LATCH or RW_X_LATCH +/** Try to buffer-fix a page. @param block guessed block +@param id expected block->page.id() +@return block if it was buffer-fixed +@retval nullptr if the block no longer is valid */ +buf_block_t *buf_page_optimistic_fix(buf_block_t *block, page_id_t id) + MY_ATTRIBUTE((nonnull, warn_unused_result)); + +/** Try to acquire a page latch after buf_page_optimistic_fix(). +@param block buffer-fixed block +@param rw_latch RW_S_LATCH or RW_X_LATCH @param modify_clock expected value of block->modify_clock @param mtr mini-transaction -@return whether the latch was acquired (the page is an allocated file page) */ -bool buf_page_optimistic_get(ulint rw_latch, buf_block_t *block, - uint64_t modify_clock, mtr_t *mtr); +@return block if the latch was acquired +@retval nullptr if block->unfix() was called because it no longer is valid */ +buf_block_t *buf_page_optimistic_get(buf_block_t *block, + rw_lock_type_t rw_latch, + uint64_t modify_clock, mtr_t *mtr) + MY_ATTRIBUTE((nonnull, warn_unused_result)); /** Try to S-latch a page. Suitable for using when holding the lock_sys latches (as it avoids deadlock). @@ -290,15 +301,6 @@ on the block. */ UNIV_INLINE void buf_block_modify_clock_inc( -/*=======================*/ - buf_block_t* block); /*!< in: block */ -/********************************************************************//** -Returns the value of the modify clock. The caller must have an s-lock -or x-lock on the block. -@return value */ -UNIV_INLINE -ib_uint64_t -buf_block_get_modify_clock( /*=======================*/ buf_block_t* block); /*!< in: block */ #endif /* !UNIV_INNOCHECKSUM */ diff --git a/storage/innobase/include/buf0buf.inl b/storage/innobase/include/buf0buf.inl index f1af9963ab0..a72ff61161f 100644 --- a/storage/innobase/include/buf0buf.inl +++ b/storage/innobase/include/buf0buf.inl @@ -116,17 +116,3 @@ buf_block_modify_clock_inc( block->modify_clock++; } - -/********************************************************************//** -Returns the value of the modify clock. The caller must have an s-lock -or x-lock on the block. -@return value */ -UNIV_INLINE -ib_uint64_t -buf_block_get_modify_clock( -/*=======================*/ - buf_block_t* block) /*!< in: block */ -{ - ut_ad(block->page.lock.have_any()); - return(block->modify_clock); -} diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 4456d7d0d75..3f3158e7db4 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -985,7 +985,7 @@ void mtr_t::upgrade_buffer_fix(ulint savepoint, rw_lock_type_t rw_latch) ut_ad(slot.type == MTR_MEMO_BUF_FIX); buf_block_t *block= static_cast(slot.object); ut_d(const auto state= block->page.state()); - ut_ad(state > buf_page_t::UNFIXED); + ut_ad(state > buf_page_t::FREED); ut_ad(state > buf_page_t::WRITE_FIX || state < buf_page_t::READ_FIX); static_assert(int{MTR_MEMO_PAGE_S_FIX} == int{RW_S_LATCH}, ""); static_assert(int{MTR_MEMO_PAGE_X_FIX} == int{RW_X_LATCH}, ""); From 4aa92911c7edc99d98dd4f86c93cba2ed8fb77c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 9 Apr 2024 12:50:24 +0300 Subject: [PATCH 098/313] MDEV-33802 Weird read view after ROLLBACK of another transaction Even after commit b8a671988954870b7db22e20d1a1409fd40f8e3d there is an anomaly where a locking read could return inconsistent results. If a locking read would have to wait for a record lock, then by the definition of a read view, the modifications made by the current lock holder cannot be visible in the read view. This is because the read view must exclude any transactions that had not been committed at the time when the read view was created. lock_rec_convert_impl_to_expl_for_trx(), lock_rec_convert_impl_to_expl(): Return an unsafe-to-dereference pointer to a transaction that holds or held the lock, or nullptr if the lock was available. lock_clust_rec_modify_check_and_lock(), lock_sec_rec_read_check_and_lock(), lock_clust_rec_read_check_and_lock(): Return DB_RECORD_CHANGED if innodb_strict_isolation=ON and the lock was being held by another transaction. The test case, which is based on a bug report by Zhuang Liu, covers the function lock_sec_rec_read_check_and_lock(). Reviewed by: Vladislav Lesin --- .../suite/innodb/r/lock_isolation.result | 33 ++++- mysql-test/suite/innodb/t/lock_isolation.test | 43 +++++- storage/innobase/lock/lock0lock.cc | 134 ++++++++++-------- 3 files changed, 148 insertions(+), 62 deletions(-) diff --git a/mysql-test/suite/innodb/r/lock_isolation.result b/mysql-test/suite/innodb/r/lock_isolation.result index 88a2ad9326e..eaba6b899a1 100644 --- a/mysql-test/suite/innodb/r/lock_isolation.result +++ b/mysql-test/suite/innodb/r/lock_isolation.result @@ -82,7 +82,6 @@ SELECT * FROM t; a b 10 20 10 20 -disconnect consistent; connection default; TRUNCATE TABLE t; INSERT INTO t VALUES(NULL, 1), (2, 2); @@ -99,10 +98,40 @@ a b COMMIT; connection con_weird; COMMIT; -disconnect con_weird; connection default; SELECT * FROM t; a b 10 1 10 20 DROP TABLE t; +# +# MDEV-33802 Weird read view after ROLLBACK of other transactions +# +CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB; +INSERT INTO t SET a=1; +BEGIN; +INSERT INTO t SET a=2; +connection consistent; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +ERROR HY000: Record has changed since last read in table 't' +connection con_weird; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +connection default; +ROLLBACK; +connection con_weird; +a b +1 NULL +1 NULL +SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +a b +1 NULL +disconnect con_weird; +connection consistent; +SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +a b +1 NULL +disconnect consistent; +connection default; +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/lock_isolation.test b/mysql-test/suite/innodb/t/lock_isolation.test index 30d2978f4f2..5c60f6e707c 100644 --- a/mysql-test/suite/innodb/t/lock_isolation.test +++ b/mysql-test/suite/innodb/t/lock_isolation.test @@ -79,7 +79,6 @@ COMMIT; --connection consistent --reap SELECT * FROM t; ---disconnect consistent --connection default TRUNCATE TABLE t; @@ -103,8 +102,48 @@ COMMIT; --connection con_weird --reap COMMIT; ---disconnect con_weird --connection default SELECT * FROM t; DROP TABLE t; + +--echo # +--echo # MDEV-33802 Weird read view after ROLLBACK of other transactions +--echo # + +CREATE TABLE t(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB; +INSERT INTO t SET a=1; + +BEGIN; INSERT INTO t SET a=2; + +--connection consistent +START TRANSACTION WITH CONSISTENT SNAPSHOT; +--disable_ps2_protocol +--error ER_CHECKREAD +SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +--enable_ps2_protocol + +--connection con_weird +START TRANSACTION WITH CONSISTENT SNAPSHOT; +send +SELECT * FROM t FORCE INDEX (b) FOR UPDATE; + +--connection default +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = 'Sending data' + and info LIKE 'SELECT * FROM t %'; +--source include/wait_condition.inc +ROLLBACK; + +--connection con_weird +--reap +SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +--disconnect con_weird + +--connection consistent +SELECT * FROM t FORCE INDEX (b) FOR UPDATE; +--disconnect consistent + +--connection default +DROP TABLE t; diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 69b3dd1f5c2..a210700727c 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -5586,47 +5586,43 @@ lock_rec_insert_check_and_lock( return err; } -/*********************************************************************//** -Creates an explicit record lock for a running transaction that currently only -has an implicit lock on the record. The transaction instance must have a -reference count > 0 so that it can't be committed and freed before this -function has completed. */ -static -bool -lock_rec_convert_impl_to_expl_for_trx( -/*==================================*/ - trx_t* trx, /*!< in/out: active transaction */ - const page_id_t id, /*!< in: page identifier */ - const rec_t* rec, /*!< in: user record on page */ - dict_index_t* index) /*!< in: index of record */ +/** Create an explicit record lock for a transaction that currently only +has an implicit lock on the record. +@param trx referenced, active transaction, or nullptr +@param id page identifier +@param rec record in the page +@param index the index B-tree that the record belongs to +@return trx, with the reference released */ +static trx_t *lock_rec_convert_impl_to_expl_for_trx(trx_t *trx, + const page_id_t id, + const rec_t *rec, + dict_index_t *index) { - if (!trx) - return false; - - ut_ad(trx->is_referenced()); - ut_ad(page_rec_is_leaf(rec)); - ut_ad(!rec_is_metadata(rec, *index)); - - DEBUG_SYNC_C("before_lock_rec_convert_impl_to_expl_for_trx"); - ulint heap_no= page_rec_get_heap_no(rec); - + if (trx) { - LockGuard g{lock_sys.rec_hash, id}; - trx->mutex_lock(); - ut_ad(!trx_state_eq(trx, TRX_STATE_NOT_STARTED)); + ut_ad(trx->is_referenced()); + ut_ad(page_rec_is_leaf(rec)); + ut_ad(!rec_is_metadata(rec, *index)); - if (!trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY) && - !lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, g.cell(), id, heap_no, - trx)) - lock_rec_add_to_queue(LOCK_X | LOCK_REC_NOT_GAP, g.cell(), id, - page_align(rec), heap_no, index, trx, true); + ulint heap_no= page_rec_get_heap_no(rec); + + { + LockGuard g{lock_sys.rec_hash, id}; + trx->mutex_lock(); + ut_ad(!trx_state_eq(trx, TRX_STATE_NOT_STARTED)); + + if (!trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY) && + !lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, g.cell(), id, heap_no, + trx)) + lock_rec_add_to_queue(LOCK_X | LOCK_REC_NOT_GAP, g.cell(), id, + page_align(rec), heap_no, index, trx, true); + } + + trx->release_reference(); + trx->mutex_unlock(); } - trx->mutex_unlock(); - trx->release_reference(); - - DEBUG_SYNC_C("after_lock_rec_convert_impl_to_expl_for_trx"); - return false; + return trx; } @@ -5717,10 +5713,11 @@ should be created. @param[in] rec record on the leaf page @param[in] index the index of the record @param[in] offsets rec_get_offsets(rec,index) -@return whether caller_trx already holds an exclusive lock on rec */ +@return unsafe pointer to a transaction that held an exclusive lock on rec +@retval nullptr if no transaction held an exclusive lock */ template static -bool +const trx_t * lock_rec_convert_impl_to_expl( trx_t* caller_trx, page_id_t id, @@ -5744,10 +5741,10 @@ lock_rec_convert_impl_to_expl( trx_id = lock_clust_rec_some_has_impl(rec, index, offsets); if (trx_id == 0) { - return false; + return nullptr; } if (UNIV_UNLIKELY(trx_id == caller_trx->id)) { - return true; + return caller_trx; } trx = trx_sys.find(caller_trx, trx_id); @@ -5758,7 +5755,7 @@ lock_rec_convert_impl_to_expl( offsets); if (trx == caller_trx) { trx->release_reference(); - return true; + return trx; } ut_d(lock_rec_other_trx_holds_expl(caller_trx, trx, rec, id)); @@ -5803,11 +5800,18 @@ lock_clust_rec_modify_check_and_lock( /* If a transaction has no explicit x-lock set on the record, set one for it */ - if (lock_rec_convert_impl_to_expl(thr_get_trx(thr), - block->page.id(), + trx_t *trx = thr_get_trx(thr); + if (const trx_t *owner = + lock_rec_convert_impl_to_expl(trx, block->page.id(), rec, index, offsets)) { - /* We already hold an implicit exclusive lock. */ - return DB_SUCCESS; + if (owner == trx) { + /* We already hold an exclusive lock. */ + return DB_SUCCESS; + } + + if (trx->snapshot_isolation && trx->read_view.is_open()) { + return DB_RECORD_CHANGED; + } } err = lock_rec_lock(true, LOCK_X | LOCK_REC_NOT_GAP, @@ -5970,12 +5974,19 @@ lock_sec_rec_read_check_and_lock( return DB_SUCCESS; } - if (!page_rec_is_supremum(rec) - && lock_rec_convert_impl_to_expl( - trx, block->page.id(), rec, index, offsets) - && gap_mode == LOCK_REC_NOT_GAP) { - /* We already hold an implicit exclusive lock. */ - return DB_SUCCESS; + if (page_rec_is_supremum(rec)) { + } else if (const trx_t *owner = + lock_rec_convert_impl_to_expl(trx, block->page.id(), + rec, index, offsets)) { + if (owner == trx) { + if (gap_mode == LOCK_REC_NOT_GAP) { + /* We already hold an exclusive lock. */ + return DB_SUCCESS; + } + } else if (trx->snapshot_isolation + && trx->read_view.is_open()) { + return DB_RECORD_CHANGED; + } } #ifdef WITH_WSREP @@ -6055,13 +6066,20 @@ lock_clust_rec_read_check_and_lock( ulint heap_no = page_rec_get_heap_no(rec); trx_t *trx = thr_get_trx(thr); - if (!lock_table_has(trx, index->table, LOCK_X) - && heap_no != PAGE_HEAP_NO_SUPREMUM - && lock_rec_convert_impl_to_expl(trx, id, - rec, index, offsets) - && gap_mode == LOCK_REC_NOT_GAP) { - /* We already hold an implicit exclusive lock. */ - return DB_SUCCESS; + if (lock_table_has(trx, index->table, LOCK_X) + || heap_no == PAGE_HEAP_NO_SUPREMUM) { + } else if (const trx_t *owner = + lock_rec_convert_impl_to_expl(trx, id, + rec, index, offsets)) { + if (owner == trx) { + if (gap_mode == LOCK_REC_NOT_GAP) { + /* We already hold an exclusive lock. */ + return DB_SUCCESS; + } + } else if (trx->snapshot_isolation + && trx->read_view.is_open()) { + return DB_RECORD_CHANGED; + } } if (heap_no > PAGE_HEAP_NO_SUPREMUM && gap_mode != LOCK_GAP From 3003a3dab0697db4da3dc70cd09707b773fac1dd Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 5 Apr 2024 11:22:28 +0200 Subject: [PATCH 099/313] galera: wsrep-lib submodule update --- wsrep-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wsrep-lib b/wsrep-lib index 7d108eb8706..dfc4bdb8a5d 160000 --- a/wsrep-lib +++ b/wsrep-lib @@ -1 +1 @@ -Subproject commit 7d108eb8706962abc74705bedfc60cfc3f296ea6 +Subproject commit dfc4bdb8a5dcbd6fbea007ad3beff899a6b5b7bd From 7aa86eb1e183178063527c90094bdc2b2ed2c44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 4 Apr 2024 14:30:59 +0300 Subject: [PATCH 100/313] MDEV-33828 : Transactional commit not supported by involved engine(s) Problem was too tight condition on ha_commit_trans to not allow non transactional storage engines participate 2pc in Galera case. This is required because transaction using e.g. procedures might read mysql.proc table inside a trasaction and these tables use at the moment Aria storage engine that does not support 2pc. Fixed by allowing read only transactions to storage engines that do not support two phase commit to participate 2pc transaction. These will be committed later separately. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/r/MDEV-33828.result | 41 +++++++++++++++++++ mysql-test/suite/galera/r/mdev-22063.result | 26 ++++++------ mysql-test/suite/galera/t/MDEV-33828.cnf | 4 ++ mysql-test/suite/galera/t/MDEV-33828.test | 45 +++++++++++++++++++++ mysql-test/suite/galera/t/mdev-22063.test | 12 ++---- sql/handler.cc | 41 +++++++++++++++---- 6 files changed, 140 insertions(+), 29 deletions(-) create mode 100644 mysql-test/suite/galera/r/MDEV-33828.result create mode 100644 mysql-test/suite/galera/t/MDEV-33828.cnf create mode 100644 mysql-test/suite/galera/t/MDEV-33828.test diff --git a/mysql-test/suite/galera/r/MDEV-33828.result b/mysql-test/suite/galera/r/MDEV-33828.result new file mode 100644 index 00000000000..a3ce68166ab --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-33828.result @@ -0,0 +1,41 @@ +connection node_2; +connection node_1; +SET AUTOCOMMIT=ON; +SELECT @@autocommit; +@@autocommit +1 +SET LOCAL enforce_storage_engine=InnoDB; +CREATE TABLE t1(id int not null primary key auto_increment, name varchar(64)) ENGINE=InnoDB; +INSERT INTO t1(name) VALUES ('name1'),('name3'),('name6'),('name2'); +CREATE PROCEDURE sel_proc() +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SELECT * FROM t1; +END| +CREATE PROCEDURE ins_proc() +BEGIN +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +INSERT INTO t1 VALUES ('name_proc'); +END| +SET AUTOCOMMIT=OFF; +SELECT @@autocommit; +@@autocommit +0 +START TRANSACTION; +insert into t1(name) values('name10'); +select param_list, returns, db, type from mysql.proc where name='sel_proc'; +param_list returns db type + test PROCEDURE +call ins_proc(); +COMMIT; +SET AUTOCOMMIT=ON; +SELECT * FROM t1; +id name +1 name1 +3 name3 +5 name6 +7 name2 +9 name10 +DROP TABLE t1; +DROP PROCEDURE sel_proc; +DROP PROCEDURE ins_proc; diff --git a/mysql-test/suite/galera/r/mdev-22063.result b/mysql-test/suite/galera/r/mdev-22063.result index 0f1a51e44d4..5773e70cc9d 100644 --- a/mysql-test/suite/galera/r/mdev-22063.result +++ b/mysql-test/suite/galera/r/mdev-22063.result @@ -79,7 +79,6 @@ INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000; REPLACE INTO t4 SELECT * FROM t1; REPLACE INTO t5 SELECT * FROM t2; REPLACE INTO t6 SELECT * FROM t3; -ERROR HY000: Transactional commit not supported by involved engine(s) REPLACE INTO t7 SELECT * FROM t2; REPLACE INTO t8 SELECT * FROM t3; SELECT COUNT(*) AS EXPECT_1000 FROM t1; @@ -97,9 +96,9 @@ EXPECT_1000 SELECT COUNT(*) AS EXPECT_1000 FROM t5; EXPECT_1000 1000 -SELECT COUNT(*) AS EXPECT_0 FROM t6; -EXPECT_0 -0 +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +EXPECT_1000 +1000 SELECT COUNT(*) AS EXPECT_1000 FROM t7; EXPECT_1000 1000 @@ -122,9 +121,9 @@ EXPECT_1000 SELECT COUNT(*) AS EXPECT_1000 FROM t5; EXPECT_1000 1000 -SELECT COUNT(*) AS EXPECT_0 FROM t6; -EXPECT_0 -0 +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +EXPECT_1000 +1000 SELECT COUNT(*) AS EXPECT_1000 FROM t7; EXPECT_1000 1000 @@ -148,7 +147,6 @@ INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000; INSERT INTO t4 SELECT * FROM t1; INSERT INTO t5 SELECT * FROM t2; INSERT INTO t6 SELECT * FROM t3; -ERROR HY000: Transactional commit not supported by involved engine(s) INSERT INTO t7 SELECT * FROM t2; INSERT INTO t8 SELECT * FROM t3; SELECT COUNT(*) AS EXPECT_1000 FROM t1; @@ -166,9 +164,9 @@ EXPECT_1000 SELECT COUNT(*) AS EXPECT_1000 FROM t5; EXPECT_1000 1000 -SELECT COUNT(*) AS EXPECT_0 FROM t6; -EXPECT_0 -0 +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +EXPECT_1000 +1000 SELECT COUNT(*) AS EXPECT_1000 FROM t7; EXPECT_1000 1000 @@ -191,9 +189,9 @@ EXPECT_1000 SELECT COUNT(*) AS EXPECT_1000 FROM t5; EXPECT_1000 1000 -SELECT COUNT(*) AS EXPECT_0 FROM t6; -EXPECT_0 -0 +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +EXPECT_1000 +1000 SELECT COUNT(*) AS EXPECT_1000 FROM t7; EXPECT_1000 1000 diff --git a/mysql-test/suite/galera/t/MDEV-33828.cnf b/mysql-test/suite/galera/t/MDEV-33828.cnf new file mode 100644 index 00000000000..4c62448fe3d --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-33828.cnf @@ -0,0 +1,4 @@ +!include ../galera_2nodes.cnf + +[mysqld] +log-bin diff --git a/mysql-test/suite/galera/t/MDEV-33828.test b/mysql-test/suite/galera/t/MDEV-33828.test new file mode 100644 index 00000000000..8e30481beee --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-33828.test @@ -0,0 +1,45 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_aria.inc + +SET AUTOCOMMIT=ON; +SELECT @@autocommit; + +SET LOCAL enforce_storage_engine=InnoDB; + +CREATE TABLE t1(id int not null primary key auto_increment, name varchar(64)) ENGINE=InnoDB; +INSERT INTO t1(name) VALUES ('name1'),('name3'),('name6'),('name2'); + +DELIMITER |; +CREATE PROCEDURE sel_proc() +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + SELECT * FROM t1; +END| + +CREATE PROCEDURE ins_proc() +BEGIN + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + INSERT INTO t1 VALUES ('name_proc'); +END| +DELIMITER ;| + +SET AUTOCOMMIT=OFF; +SELECT @@autocommit; + +START TRANSACTION; + +insert into t1(name) values('name10'); + +select param_list, returns, db, type from mysql.proc where name='sel_proc'; + +call ins_proc(); + +COMMIT; + +SET AUTOCOMMIT=ON; + +SELECT * FROM t1; +DROP TABLE t1; +DROP PROCEDURE sel_proc; +DROP PROCEDURE ins_proc; diff --git a/mysql-test/suite/galera/t/mdev-22063.test b/mysql-test/suite/galera/t/mdev-22063.test index 043c5e253fd..a8e7b87ad38 100644 --- a/mysql-test/suite/galera/t/mdev-22063.test +++ b/mysql-test/suite/galera/t/mdev-22063.test @@ -81,8 +81,6 @@ INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000; REPLACE INTO t4 SELECT * FROM t1; REPLACE INTO t5 SELECT * FROM t2; -# For some reason Aria storage engine does register_ha ---error ER_ERROR_DURING_COMMIT REPLACE INTO t6 SELECT * FROM t3; REPLACE INTO t7 SELECT * FROM t2; REPLACE INTO t8 SELECT * FROM t3; @@ -92,7 +90,7 @@ SELECT COUNT(*) AS EXPECT_1000 FROM t2; SELECT COUNT(*) AS EXPECT_1000 FROM t3; SELECT COUNT(*) AS EXPECT_1000 FROM t4; SELECT COUNT(*) AS EXPECT_1000 FROM t5; -SELECT COUNT(*) AS EXPECT_0 FROM t6; +SELECT COUNT(*) AS EXPECT_1000 FROM t6; SELECT COUNT(*) AS EXPECT_1000 FROM t7; SELECT COUNT(*) AS EXPECT_1000 FROM t8; @@ -107,7 +105,7 @@ SELECT COUNT(*) AS EXPECT_1000 FROM t2; SELECT COUNT(*) AS EXPECT_1000 FROM t3; SELECT COUNT(*) AS EXPECT_1000 FROM t4; SELECT COUNT(*) AS EXPECT_1000 FROM t5; -SELECT COUNT(*) AS EXPECT_0 FROM t6; +SELECT COUNT(*) AS EXPECT_1000 FROM t6; SELECT COUNT(*) AS EXPECT_1000 FROM t7; SELECT COUNT(*) AS EXPECT_1000 FROM t8; @@ -131,8 +129,6 @@ INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000; INSERT INTO t4 SELECT * FROM t1; INSERT INTO t5 SELECT * FROM t2; -# For some reason Aria storage engine does register_ha ---error ER_ERROR_DURING_COMMIT INSERT INTO t6 SELECT * FROM t3; INSERT INTO t7 SELECT * FROM t2; INSERT INTO t8 SELECT * FROM t3; @@ -142,7 +138,7 @@ SELECT COUNT(*) AS EXPECT_1000 FROM t2; SELECT COUNT(*) AS EXPECT_1000 FROM t3; SELECT COUNT(*) AS EXPECT_1000 FROM t4; SELECT COUNT(*) AS EXPECT_1000 FROM t5; -SELECT COUNT(*) AS EXPECT_0 FROM t6; +SELECT COUNT(*) AS EXPECT_1000 FROM t6; SELECT COUNT(*) AS EXPECT_1000 FROM t7; SELECT COUNT(*) AS EXPECT_1000 FROM t8; @@ -157,7 +153,7 @@ SELECT COUNT(*) AS EXPECT_1000 FROM t2; SELECT COUNT(*) AS EXPECT_1000 FROM t3; SELECT COUNT(*) AS EXPECT_1000 FROM t4; SELECT COUNT(*) AS EXPECT_1000 FROM t5; -SELECT COUNT(*) AS EXPECT_0 FROM t6; +SELECT COUNT(*) AS EXPECT_1000 FROM t6; SELECT COUNT(*) AS EXPECT_1000 FROM t7; SELECT COUNT(*) AS EXPECT_1000 FROM t8; diff --git a/sql/handler.cc b/sql/handler.cc index 24bc845c694..40dfbffa667 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1531,6 +1531,29 @@ ha_check_and_coalesce_trx_read_only(THD *thd, Ha_trx_info *ha_list, return rw_ha_count; } +#ifdef WITH_WSREP +/** + Check if transaction contains storage engine not supporting + two-phase commit and transaction is read-write. + + @retval + true Transaction contains storage engine not supporting + two phase commit and transaction is read-write + @retval + false otherwise +*/ +static bool wsrep_have_no2pc_rw_ha(Ha_trx_info* ha_list) +{ + for (Ha_trx_info *ha_info=ha_list; ha_info; ha_info= ha_info->next()) + { + handlerton *ht= ha_info->ht(); + // Transaction is read-write and handler does not support 2pc + if (ha_info->is_trx_read_write() && ht->prepare==0) + return true; + } + return false; +} +#endif /* WITH_WSREP */ /** @retval @@ -1734,14 +1757,18 @@ int ha_commit_trans(THD *thd, bool all) */ if (run_wsrep_hooks) { - // This commit involves more than one storage engine and requires - // two phases, but some engines don't support it. - // Issue a message to the client and roll back the transaction. - if (trans->no_2pc && rw_ha_count > 1) + // This commit involves storage engines that do not support two phases. + // We allow read only transactions to such storage engines but not + // read write transactions. + if (trans->no_2pc && rw_ha_count > 1 && wsrep_have_no2pc_rw_ha(trans->ha_list)) { - // REPLACE|INSERT INTO ... SELECT uses TOI for MyISAM|Aria - if (WSREP(thd) && thd->wsrep_cs().mode() != wsrep::client_state::m_toi) - { + // This commit involves more than one storage engine and requires + // two phases, but some engines don't support it. + // Issue a message to the client and roll back the transaction. + + // REPLACE|INSERT INTO ... SELECT uses TOI for MyISAM|Aria + if (WSREP(thd) && thd->wsrep_cs().mode() != wsrep::client_state::m_toi) + { my_message(ER_ERROR_DURING_COMMIT, "Transactional commit not supported " "by involved engine(s)", MYF(0)); error= 1; From d4936c8b26c88ef29eecabb13ff5c1cd6d15c590 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 9 Apr 2024 14:18:29 +0400 Subject: [PATCH 101/313] MDEV-18898 SELECT using wrong index when using operator IN with mixed types These patches: # commit 74891ed257c431e5e8b4bc9479ca6456563d592f # # MDEV-11514, MDEV-11497, MDEV-11554, MDEV-11555 - IN and CASE type aggregation problems # commit 53499cd1ea1c8092460924224d78a286d617492d # # MDEV-31303 Key not used when IN clause has both signed and usigned values earlier fixed MDEV-18898. Adding only an MTR case. modified: mysql-test/main/func_in.result modified: mysql-test/main/func_in.test --- mysql-test/main/func_in.result | 54 ++++++++++++++++++++++++++++++++++ mysql-test/main/func_in.test | 39 ++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result index 21b11d74896..36b61a782bd 100644 --- a/mysql-test/main/func_in.result +++ b/mysql-test/main/func_in.result @@ -1003,5 +1003,59 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL 2 Using where; Using index DROP TABLE t1; # +# MDEV-18898 SELECT using wrong index when using operator IN with mixed types +# +CREATE TEMPORARY TABLE t1 ( +id int(10) unsigned NOT NULL AUTO_INCREMENT, +name varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, +PRIMARY KEY (`id`), +UNIQUE KEY `name` (`name`) +); +FOR i IN 1..255 +DO +INSERT INTO t1 VALUES (i, MD5(i)); +END FOR +$$ +# +# Constants alone +# +ANALYZE SELECT id, name FROM t1 WHERE id = 1; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 NULL 100.00 NULL +ANALYZE SELECT id, name FROM t1 WHERE id = '2'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 NULL 100.00 NULL +# +# Two constants using IN +# +ANALYZE SELECT id, name FROM t1 WHERE id IN (1, 2); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition +ANALYZE SELECT id, name FROM t1 WHERE id IN ('1', 2) /* Used a wrong index */; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition +ANALYZE SELECT id, name FROM t1 WHERE id IN (1, '2') /* Used a wrong index */; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition +ANALYZE SELECT id, name FROM t1 WHERE id IN ('1', '2'); +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition +# +# Two constants using OR +# +ANALYZE SELECT id, name FROM t1 WHERE id = 1 OR id = 2; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition +ANALYZE SELECT id, name FROM t1 WHERE id = '1' OR id = '2'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition +ANALYZE SELECT id, name FROM t1 WHERE id = 1 OR id = '2'; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition +ANALYZE SELECT id, name FROM t1 WHERE id = '1' OR id = 2; +id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_in.test b/mysql-test/main/func_in.test index d24725dbca4..1e335b4b4ad 100644 --- a/mysql-test/main/func_in.test +++ b/mysql-test/main/func_in.test @@ -777,6 +777,45 @@ EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775807, 9223372036854775808) DROP TABLE t1; +--echo # +--echo # MDEV-18898 SELECT using wrong index when using operator IN with mixed types +--echo # + +CREATE TEMPORARY TABLE t1 ( + id int(10) unsigned NOT NULL AUTO_INCREMENT, + name varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +); +DELIMITER $$; +FOR i IN 1..255 +DO + INSERT INTO t1 VALUES (i, MD5(i)); +END FOR +$$ +DELIMITER ;$$ +--echo # +--echo # Constants alone +--echo # +ANALYZE SELECT id, name FROM t1 WHERE id = 1; +ANALYZE SELECT id, name FROM t1 WHERE id = '2'; +--echo # +--echo # Two constants using IN +--echo # +ANALYZE SELECT id, name FROM t1 WHERE id IN (1, 2); +ANALYZE SELECT id, name FROM t1 WHERE id IN ('1', 2) /* Used a wrong index */; +ANALYZE SELECT id, name FROM t1 WHERE id IN (1, '2') /* Used a wrong index */; +ANALYZE SELECT id, name FROM t1 WHERE id IN ('1', '2'); +--echo # +--echo # Two constants using OR +--echo # +ANALYZE SELECT id, name FROM t1 WHERE id = 1 OR id = 2; +ANALYZE SELECT id, name FROM t1 WHERE id = '1' OR id = '2'; +ANALYZE SELECT id, name FROM t1 WHERE id = 1 OR id = '2'; +ANALYZE SELECT id, name FROM t1 WHERE id = '1' OR id = 2; +DROP TABLE t1; + + --echo # --echo # End of 10.5 tests --echo # From 33af5575a976c86163752cce77dddb640ffeef00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 4 Sep 2023 12:22:51 +0300 Subject: [PATCH 102/313] MDEV-25731 : Assertion `mode_ == m_local' failed in void wsrep::client_state::streaming_params(wsrep::streaming_context::fragment_unit, size_t) Problem was that if wsrep_load_data_splitting was used streaming replication (SR) parameters were set for MyISAM table. Galera does not currently support SR for MyISAM. Fix is to ignore wsrep_load_data_splitting setting (with warning) if table is not InnoDB table. This is 10.6+ case of fix. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/r/MDEV-25731.result | 23 ++++++++++++++------- mysql-test/suite/galera/t/MDEV-25731.test | 17 ++++++++++----- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/galera/r/MDEV-25731.result b/mysql-test/suite/galera/r/MDEV-25731.result index 92e1704e658..11a72730fb1 100644 --- a/mysql-test/suite/galera/r/MDEV-25731.result +++ b/mysql-test/suite/galera/r/MDEV-25731.result @@ -4,9 +4,7 @@ connection node_1; SET GLOBAL wsrep_load_data_splitting=ON; Warnings: Warning 1287 '@@wsrep_load_data_splitting' is deprecated and will be removed in a future release -SET GLOBAL wsrep_replicate_myisam=ON; -Warnings: -Warning 1287 '@@wsrep_replicate_myisam' is deprecated and will be removed in a future release. Please use '@@wsrep_mode=REPLICATE_MYISAM' instead +SET GLOBAL wsrep_mode=REPLICATE_MYISAM; CREATE TABLE t1 (c1 int) ENGINE=MYISAM; LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; Warnings: @@ -19,8 +17,11 @@ SELECT COUNT(*) AS EXPECT_6 FROM t1; EXPECT_6 6 connection node_1; -ALTER TABLE t1 ENGINE=InnoDB; +ALTER TABLE t1 ENGINE=Aria; +SET GLOBAL wsrep_mode=REPLICATE_ARIA; LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; +Warnings: +Warning 1235 wsrep_load_data_splitting for other than InnoDB tables SELECT COUNT(*) AS EXPECT_12 FROM t1; EXPECT_12 12 @@ -29,10 +30,18 @@ SELECT COUNT(*) AS EXPECT_12 FROM t1; EXPECT_12 12 connection node_1; +ALTER TABLE t1 ENGINE=InnoDB; +LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; +SELECT COUNT(*) AS EXPECT_18 FROM t1; +EXPECT_18 +18 +connection node_2; +SELECT COUNT(*) AS EXPECT_18 FROM t1; +EXPECT_18 +18 +connection node_1; DROP TABLE t1; SET GLOBAL wsrep_load_data_splitting=OFF; Warnings: Warning 1287 '@@wsrep_load_data_splitting' is deprecated and will be removed in a future release -SET GLOBAL wsrep_replicate_myisam=OFF; -Warnings: -Warning 1287 '@@wsrep_replicate_myisam' is deprecated and will be removed in a future release. Please use '@@wsrep_mode=REPLICATE_MYISAM' instead +SET GLOBAL wsrep_mode=DEFAULT; diff --git a/mysql-test/suite/galera/t/MDEV-25731.test b/mysql-test/suite/galera/t/MDEV-25731.test index c26fad2fa6a..893cccbb2bd 100644 --- a/mysql-test/suite/galera/t/MDEV-25731.test +++ b/mysql-test/suite/galera/t/MDEV-25731.test @@ -3,7 +3,7 @@ --connection node_1 SET GLOBAL wsrep_load_data_splitting=ON; -SET GLOBAL wsrep_replicate_myisam=ON; +SET GLOBAL wsrep_mode=REPLICATE_MYISAM; CREATE TABLE t1 (c1 int) ENGINE=MYISAM; LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; SELECT COUNT(*) AS EXPECT_6 FROM t1; @@ -12,16 +12,23 @@ SELECT COUNT(*) AS EXPECT_6 FROM t1; SELECT COUNT(*) AS EXPECT_6 FROM t1; --connection node_1 -ALTER TABLE t1 ENGINE=InnoDB; +ALTER TABLE t1 ENGINE=Aria; +SET GLOBAL wsrep_mode=REPLICATE_ARIA; LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; SELECT COUNT(*) AS EXPECT_12 FROM t1; --connection node_2 SELECT COUNT(*) AS EXPECT_12 FROM t1; +--connection node_1 +ALTER TABLE t1 ENGINE=InnoDB; +LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; +SELECT COUNT(*) AS EXPECT_18 FROM t1; + +--connection node_2 +SELECT COUNT(*) AS EXPECT_18 FROM t1; + --connection node_1 DROP TABLE t1; SET GLOBAL wsrep_load_data_splitting=OFF; -SET GLOBAL wsrep_replicate_myisam=OFF; - - +SET GLOBAL wsrep_mode=DEFAULT; From 4980fcb9909449f4d65886ee2c1d1080bb3d55a5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 9 Apr 2024 13:07:23 +0200 Subject: [PATCH 103/313] MDEV-33867 main.query_cache_debug fails with heap-use-after-free What's happening: 1. Query_cache::insert() locks the QC and verifies that it's enabled 2. parallel thread tries to disable it. trylock fails (QC is locked) so the status becomes DISABLE_REQUEST 3. Query_cache::insert() calls Query_cache::write_result_data() which allocates a new block and unlocks the QC. 4. Query_cache::unlock() notices there are no more QC users and a pending DISABLE_REQUEST so it disables the QC and frees all the memory, including the new block that was just allocated 5. Query_cache::write_result_data() proceeds to write into the freed block Fix: change m_cache_status under a mutex. Approved by Oleksandr Byelkin --- sql/sql_cache.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 8655a75a455..c876636d383 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2530,14 +2530,9 @@ void Query_cache::destroy() void Query_cache::disable_query_cache(THD *thd) { + lock(thd); m_cache_status= DISABLE_REQUEST; - /* - If there is no requests in progress try to free buffer. - try_lock(TRY) will exit immediately if there is lock. - unlock() should free block. - */ - if (m_requests_in_progress == 0 && !try_lock(thd, TRY)) - unlock(); + unlock(); } From d8a60dd4c96230a4ea0102cac145993abcdbb8ea Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Tue, 9 Apr 2024 17:11:49 +0200 Subject: [PATCH 104/313] Fix a typo which lead to compiler error on 32 bit systems --- extra/mariabackup/aria_backup_client.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/mariabackup/aria_backup_client.cc b/extra/mariabackup/aria_backup_client.cc index 1ea1486d7cb..25468148fe4 100644 --- a/extra/mariabackup/aria_backup_client.cc +++ b/extra/mariabackup/aria_backup_client.cc @@ -752,7 +752,7 @@ repeat: goto exit; } DBUG_ASSERT(file_offset <= static_cast(stat_info.st_size)); - to_copy_size = static_cast(stat_info.st_size) - file_offset; + to_copy_size = static_cast(stat_info.st_size - file_offset); to_copy_size = to_copy_size >= TRANSLOG_PAGE_SIZE ? (align_down(to_copy_size, TRANSLOG_PAGE_SIZE) - TRANSLOG_PAGE_SIZE) : 0; } From 952ab9a59659b28f10ce2770e17249e0ff5b0681 Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Mon, 8 Apr 2024 13:04:59 -0600 Subject: [PATCH 105/313] MDEV-30260: Slave crashed:reload_acl_and_cache during shutdown The signal handler thread can use various different runtime resources when processing a SIGHUP (e.g. master-info information) due to calling into reload_acl_and_cache(). Currently, the shutdown process waits for the termination of the signal thread after performing cleanup. However, this could cause resources actively used by the signal handler to be freed while reload_acl_and_cache() is processing. The specific resource that caused MDEV-30260 is a race condition for the hostname_cache, such that mysqld would delete it in clean_up()::hostname_cache_free(), before the signal handler would use it in reload_acl_and_cache()::hostname_cache_refresh(). Another similar resource is the active_mi/master_info_index. There was a race between its deletion by the main thread in end_slave(), and their usage by the Signal Handler as a part of Master_info_index::flush_all_relay_logs.read(active_mi) in reload_acl_and_cache(). This patch fixes these race conditions by relocating where server shutdown waits for the signal handler to die until after server-level threads have been killed (i.e., as a last step of close_connections()). With respect to the hostname_cache, active_mi and master_info_cache, this ensures that they cannot be destroyed while the signal handler is still active, and potentially using them. Additionally: 1) This requires that Events memory is still in place for SIGHUP handling's mysql_print_status(). So event deinitialization is moved into clean_up(), but the event scheduler still needs to be stopped in close_connections() at the same spot. 2) The function kill_server_thread is no longer used, so it is deleted 3) The timeout to wait for the death of the signal thread was not consistent with the comment. The comment mentioned up to 10 seconds, whereas it was actually 0.01s. The code has been fixed to wait up to 10 seconds. 4) A warning has been added if the signal handler thread fails to exit in time. 5) Added pthread_join() to end of wait_for_signal_thread_to_end() if it hadn't ended in 10s with a warning. Note this also removes the pthread_detached attribute from the signal_thread to allow for the pthread_join(). Reviewed By: =========== Vladislav Vaintroub Andrei Elkin --- .../suite/rpl/r/rpl_shutdown_sighup.result | 50 ++++++ .../suite/rpl/t/rpl_shutdown_sighup.test | 154 ++++++++++++++++++ sql/mysqld.cc | 67 ++++---- sql/sql_reload.cc | 23 +++ 4 files changed, 259 insertions(+), 35 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_shutdown_sighup.result create mode 100644 mysql-test/suite/rpl/t/rpl_shutdown_sighup.test diff --git a/mysql-test/suite/rpl/r/rpl_shutdown_sighup.result b/mysql-test/suite/rpl/r/rpl_shutdown_sighup.result new file mode 100644 index 00000000000..01b35f1dc58 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_shutdown_sighup.result @@ -0,0 +1,50 @@ +include/master-slave.inc +[connection master] +connection slave; +set statement sql_log_bin=0 for call mtr.add_suppression("Signal handler thread did not exit in a timely manner"); +# +# Main test +connection master; +create table t1 (a int); +insert into t1 values (1); +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +set @@global.debug_dbug= "+d,hold_sighup_log_refresh"; +# Waiting for sighup to reach reload_acl_and_cache.. +set debug_sync="now wait_for in_reload_acl_and_cache"; +# Signalling signal handler to proceed to sleep before REFRESH_HOSTS +set debug_sync="now signal refresh_logs"; +# Starting shutdown (note this will take 3+ seconds due to DBUG my_sleep in reload_acl_and_cache) +shutdown; +connection server_2; +connection slave; +include/assert_grep.inc [Ensure Mariadbd did not segfault when shutting down] +connection master; +connection slave; +# +# Error testcase to ensure an error message is shown if the signal +# takes longer than the timeout while processing the SIGHUP +connection slave; +set @@global.debug_dbug= "+d,force_sighup_processing_timeout"; +set @@global.debug_dbug= "+d,hold_sighup_log_refresh"; +connection master; +insert into t1 values (1); +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +# Waiting for sighup to reach reload_acl_and_cache.. +set debug_sync="now wait_for in_reload_acl_and_cache"; +# Signalling signal handler to proceed to sleep before REFRESH_HOSTS +set debug_sync="now signal refresh_logs"; +# Starting shutdown (note this will take 3+ seconds due to DBUG my_sleep in reload_acl_and_cache) +shutdown; +connection server_2; +connection slave; +include/assert_grep.inc [Ensure warning is issued that signal handler thread is still processing] +# +# Cleanup +connection master; +drop table t1; +include/rpl_end.inc +# End of rpl_shutdown_sighup.test diff --git a/mysql-test/suite/rpl/t/rpl_shutdown_sighup.test b/mysql-test/suite/rpl/t/rpl_shutdown_sighup.test new file mode 100644 index 00000000000..d1940f81a85 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_shutdown_sighup.test @@ -0,0 +1,154 @@ +# +# The signal handler thread can use various different runtime resources when +# processing a SIGHUP (e.g. master-info information), as the logic calls into +# reload_acl_and_cache(). This test ensures that SIGHUP processing, when +# concurrent with server shutdown, the shutdown logic must wait for the SIGHUP +# processing to finish before cleaning up any resources. +# +# Additionally, the error case is tested such that the signal handler thread +# takes too long processing a SIGHUP, and the main mysqld thread must skip its +# wait and output a warning. +# +# Note the SIGHUP is sent via the command-line kill program via a perl script. +# +# References: +# MDEV-30260: Slave crashed:reload_acl_and_cache during shutdown +# + +--source include/not_windows.inc +--source include/not_embedded.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +# Binlog format doesn't matter +--source include/have_binlog_format_statement.inc +--source include/master-slave.inc + +# For error test case which forces timeout +--connection slave +set statement sql_log_bin=0 for call mtr.add_suppression("Signal handler thread did not exit in a timely manner"); + + +--echo # +--echo # Main test +--connection master +create table t1 (a int); +insert into t1 values (1); +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +# Make signal handler handle SIGHUP.. +set @@global.debug_dbug= "+d,hold_sighup_log_refresh"; +--let KILL_NODE_PIDFILE = `SELECT @@pid_file` +--perl + my $kill_sig = $ENV{'KILL_SIGNAL_VALUE'}; + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -HUP $mysqld_pid"); + exit(0); +EOF + +--echo # Waiting for sighup to reach reload_acl_and_cache.. +set debug_sync="now wait_for in_reload_acl_and_cache"; +--echo # Signalling signal handler to proceed to sleep before REFRESH_HOSTS +set debug_sync="now signal refresh_logs"; + +# ..while we are shutting down +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +wait +EOF +--echo # Starting shutdown (note this will take 3+ seconds due to DBUG my_sleep in reload_acl_and_cache) +shutdown; + +--source include/wait_until_disconnected.inc +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +restart: --skip-slave-start=0 +EOF + +--connection server_2 +--enable_reconnect +--source include/wait_until_connected_again.inc + +--connection slave +--enable_reconnect +--source include/wait_until_connected_again.inc + +--let $assert_text= Ensure Mariadbd did not segfault when shutting down +--let $assert_select= got signal 11 +--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err +--let $assert_count= 0 +--let $assert_only_after = CURRENT_TEST: rpl.rpl_shutdown_sighup +--source include/assert_grep.inc + +--connection master +--sync_slave_with_master + + +--echo # +--echo # Error testcase to ensure an error message is shown if the signal +--echo # takes longer than the timeout while processing the SIGHUP + +--connection slave +set @@global.debug_dbug= "+d,force_sighup_processing_timeout"; +set @@global.debug_dbug= "+d,hold_sighup_log_refresh"; + +--connection master +insert into t1 values (1); +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +# Make signal handler handle SIGHUP.. +--let KILL_NODE_PIDFILE = `SELECT @@pid_file` +--perl + my $kill_sig = $ENV{'KILL_SIGNAL_VALUE'}; + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -HUP $mysqld_pid"); + exit(0); +EOF +--echo # Waiting for sighup to reach reload_acl_and_cache.. +set debug_sync="now wait_for in_reload_acl_and_cache"; +--echo # Signalling signal handler to proceed to sleep before REFRESH_HOSTS +set debug_sync="now signal refresh_logs"; + +# ..while we are shutting down +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +wait +EOF +--echo # Starting shutdown (note this will take 3+ seconds due to DBUG my_sleep in reload_acl_and_cache) +shutdown; + +--source include/wait_until_disconnected.inc +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +restart: --skip-slave-start=0 +EOF + +--connection server_2 +--enable_reconnect +--source include/wait_until_connected_again.inc + +--connection slave +--enable_reconnect +--source include/wait_until_connected_again.inc + +--let $assert_text= Ensure warning is issued that signal handler thread is still processing +--let $assert_select= Signal handler thread did not exit in a timely manner. +--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err +--let $assert_count= 1 +--let $assert_only_after = CURRENT_TEST: rpl.rpl_shutdown_sighup +--source include/assert_grep.inc + + +--echo # +--echo # Cleanup +--connection master +drop table t1; + +--source include/rpl_end.inc +--echo # End of rpl_shutdown_sighup.test diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5d23a972cdc..5ba51bdfb74 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1766,7 +1766,8 @@ static void close_connections(void) DBUG_EXECUTE_IF("delay_shutdown_phase_2_after_semisync_wait", my_sleep(500000);); - Events::deinit(); + if (Events::inited) + Events::stop(); slave_prepare_for_shutdown(); ack_receiver.stop(); @@ -1827,6 +1828,12 @@ static void close_connections(void) } /* End of kill phase 2 */ + /* + The signal thread can use server resources, e.g. when processing SIGHUP, + and it must end gracefully before clean_up() + */ + wait_for_signal_thread_to_end(); + DBUG_PRINT("quit",("close_connections thread")); DBUG_VOID_RETURN; } @@ -1930,14 +1937,8 @@ extern "C" void unireg_abort(int exit_code) static void mysqld_exit(int exit_code) { DBUG_ENTER("mysqld_exit"); - /* - Important note: we wait for the signal thread to end, - but if a kill -15 signal was sent, the signal thread did - spawn the kill_server_thread thread, which is running concurrently. - */ rpl_deinit_gtid_waiting(); rpl_deinit_gtid_slave_state(); - wait_for_signal_thread_to_end(); #ifdef WITH_WSREP wsrep_deinit_server(); wsrep_sst_auth_free(); @@ -2016,6 +2017,9 @@ static void clean_up(bool print_message) free_status_vars(); end_thr_alarm(1); /* Free allocated memory */ end_thr_timer(); +#ifndef EMBEDDED_LIBRARY + Events::deinit(); +#endif my_free_open_file_info(); if (defaults_argv) free_defaults(defaults_argv); @@ -2083,16 +2087,32 @@ static void clean_up(bool print_message) */ static void wait_for_signal_thread_to_end() { - uint i; + uint i, n_waits= DBUG_EVALUATE("force_sighup_processing_timeout", 5, 100); + int err= 0; /* Wait up to 10 seconds for signal thread to die. We use this mainly to avoid getting warnings that my_thread_end has not been called */ - for (i= 0 ; i < 100 && signal_thread_in_use; i++) + for (i= 0 ; i < n_waits && signal_thread_in_use; i++) { - if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL) == ESRCH) + err= pthread_kill(signal_thread, MYSQL_KILL_SIGNAL); + if (err) break; - my_sleep(100); // Give it time to die + my_sleep(100000); // Give it time to die, .1s per iteration + } + + if (err && err != ESRCH) + { + sql_print_error("Failed to send kill signal to signal handler thread, " + "pthread_kill() errno: %d", + err); + } + + if (i == n_waits && signal_thread_in_use) + { + sql_print_warning("Signal handler thread did not exit in a timely manner. " + "Continuing to wait for it to stop.."); + pthread_join(signal_thread, NULL); } } #endif /*EMBEDDED_LIBRARY*/ @@ -2916,7 +2936,6 @@ static void start_signal_handler(void) (void) pthread_attr_init(&thr_attr); pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM); - (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); (void) my_setstacksize(&thr_attr,my_thread_stack_size); mysql_mutex_lock(&LOCK_start_thread); @@ -2936,18 +2955,6 @@ static void start_signal_handler(void) } -#if defined(USE_ONE_SIGNAL_HAND) -pthread_handler_t kill_server_thread(void *arg __attribute__((unused))) -{ - my_thread_init(); // Initialize new thread - break_connect_loop(); - my_thread_end(); - pthread_exit(0); - return 0; -} -#endif - - /** This threads handles all signals and alarms. */ /* ARGSUSED */ pthread_handler_t signal_hand(void *arg __attribute__((unused))) @@ -3004,7 +3011,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) int origin; while ((error= my_sigwait(&set, &sig, &origin)) == EINTR) /* no-op */; - if (cleanup_done) + if (abort_loop) { DBUG_PRINT("quit",("signal_handler: calling my_thread_end()")); my_thread_end(); @@ -3027,18 +3034,8 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) { /* Delete the instrumentation for the signal thread */ PSI_CALL_delete_current_thread(); -#ifdef USE_ONE_SIGNAL_HAND - pthread_t tmp; - if (unlikely((error= mysql_thread_create(0, /* Not instrumented */ - &tmp, &connection_attrib, - kill_server_thread, - (void*) &sig)))) - sql_print_error("Can't create thread to kill server (errno= %d)", - error); -#else my_sigset(sig, SIG_IGN); break_connect_loop(); // MIT THREAD has a alarm thread -#endif } break; case SIGHUP: diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index cd75cd45319..4f6356cff54 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -67,6 +67,15 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, bool result=0; select_errors=0; /* Write if more errors */ int tmp_write_to_binlog= *write_to_binlog= 1; +#ifndef DBUG_OFF + /* + When invoked for handling a SIGHUP by rpl_shutdown_sighup.test, we need to + force the signal handler to wait after REFRESH_TABLES, as that will check + for a killed server, and we need to call hostname_cache_refresh after + server cleanup has happened to trigger MDEV-30260. + */ + int do_dbug_sleep= 0; +#endif DBUG_ASSERT(!thd || !thd->in_sub_stmt); @@ -99,6 +108,15 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, */ my_error(ER_UNKNOWN_ERROR, MYF(0)); } + +#ifndef DBUG_OFF + DBUG_EXECUTE_IF("hold_sighup_log_refresh", { + DBUG_ASSERT(!debug_sync_set_action( + thd, STRING_WITH_LEN("now SIGNAL in_reload_acl_and_cache " + "WAIT_FOR refresh_logs"))); + do_dbug_sleep= 1; + }); +#endif } opt_noacl= 0; @@ -351,6 +369,11 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, } my_dbopt_cleanup(); } + +#ifndef DBUG_OFF + if (do_dbug_sleep) + my_sleep(3000000); // 3s +#endif if (options & REFRESH_HOSTS) hostname_cache_refresh(); if (thd && (options & REFRESH_STATUS)) From 662bb176b412993a085fe329af559ddc3dc83ec3 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 13 Mar 2024 13:11:15 +1100 Subject: [PATCH 106/313] MDEV-33661 MENT-1591 Keep spider in memory until exit in ASAN builds Same as MDEV-29579. For some reason, libodbc does not clean up properly if unloaded too early with the dlclose() of spider. So we add UNIQUE symbols to spider so the spider does not reload in dlclose(). This change, however, uncovers some hidden problems in the spider codebase, for which we move the initialisation of some spider global variables into the initialisation of spider itself. Spider has some global variables. Their initialisation should be done in the initialisation of spider itself, otherwise, if spider were re-initialised without these symbol being unloaded, the values could be inconsistent and causing issues. One such issue is caused by the variables spider_mon_table_cache_version and spider_mon_table_cache_version_req. They are used for resetting the spider monitoring table cache and have initial values of 0 and 1 respectively. We have that always spider_mon_table_cache_version_req >= spider_mon_table_cache_version, and when the relation is strict, the cache is reset, spider_mon_table_cache_version is brought to be equal to spider_mon_table_cache_version_req, and the cache is searched for matching table_name, db_name and link_idx. If the relation is equal, no reset would happen and the cache would be searched directly. When spider is re-inited without resetting the values of spider_mon_table_cache_version and spider_mon_table_cache_version_req that were set to be equal in the previous cache reset action, the cache was emptied in the previous spider deinit, which would result in HA_ERR_KEY_NOT_FOUND unexpectedly. An alternative way to fix this issue would be to call the spider udf spider_flush_mon_cache_table(), which increments spider_mon_table_cache_version_req thus making sure the inequality is strict. However, there's no reason for spider to initialise these global variables on dlopen(), rather than on spider init, which is cleaner and "purer". To reproduce this issue, simply revert the changes involving the two variables and then run: mtr --no-reorder spider.ha{,_part} --- storage/spider/ha_spider.h | 23 +++++++++++++++++++++++ storage/spider/spd_conn.cc | 4 ++-- storage/spider/spd_db_conn.cc | 2 +- storage/spider/spd_ping_table.cc | 4 ++-- storage/spider/spd_table.cc | 11 +++++++++++ storage/spider/spd_trx.cc | 2 +- 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index f5a597b88a7..3434add965c 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -1219,3 +1219,26 @@ public: int init_union_table_name_pos_sql(); int set_union_table_name_pos_sql(); }; + + +/* This is a hack for ASAN + * Libraries such as libxml2 and libodbc do not like being unloaded before + * exit and will show as a leak in ASAN with no stack trace (as the plugin + * has been unloaded from memory). + * + * The below is designed to trick the compiler into adding a "UNIQUE" symbol + * which can be seen using: + * readelf -s storage/spider/ha_spider.so | grep UNIQUE + * + * Having this symbol means that the plugin remains in memory after dlclose() + * has been called. Thereby letting the libraries clean up properly. + */ +#if defined(__SANITIZE_ADDRESS__) +__attribute__((__used__)) +inline int dummy(void) +{ + static int d; + d++; + return d; +} +#endif diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc index be9b27d83ad..b55dc0fd4db 100644 --- a/storage/spider/spd_conn.cc +++ b/storage/spider/spd_conn.cc @@ -53,7 +53,7 @@ extern handlerton *spider_hton_ptr; extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; pthread_mutex_t spider_conn_id_mutex; pthread_mutex_t spider_ipport_conn_mutex; -ulonglong spider_conn_id = 1; +ulonglong spider_conn_id; #ifndef WITHOUT_SPIDER_BG_SEARCH extern pthread_attr_t spider_pt_attr; @@ -93,7 +93,7 @@ extern sql_mode_t pushdown_sql_mode; HASH spider_open_connections; uint spider_open_connections_id; HASH spider_ipport_conns; -long spider_conn_mutex_id = 0; +long spider_conn_mutex_id; const char *spider_open_connections_func_name; const char *spider_open_connections_file_name; diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 40dc15a2149..fd10c7cee8b 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -67,7 +67,7 @@ pthread_mutex_t spider_open_conn_mutex; const char spider_dig_upper[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /* UTC time zone for timestamp columns */ -Time_zone *UTC = 0; +Time_zone *UTC; int spider_db_connect( const SPIDER_SHARE *share, diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index 4d2c826aa28..1f5230829c3 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -74,10 +74,10 @@ ulong spider_mon_table_cache_line_no; greater than spider_mon_table_cache_version_req. When the inequality is strict, an initialisation of spider_mon_table_cache will be triggered. */ -volatile ulonglong spider_mon_table_cache_version = 0; +volatile ulonglong spider_mon_table_cache_version; /* The required mon table cache version, incremented by one by the udf spider_flush_table_mon_cache */ -volatile ulonglong spider_mon_table_cache_version_req = 1; +volatile ulonglong spider_mon_table_cache_version_req; /* Get or create a `SPIDER_TABLE_MON_LIST' for a key `str' */ SPIDER_TABLE_MON_LIST *spider_get_ping_table_mon_list( diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 60e1ce6bad2..c1435e0216e 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -139,6 +139,11 @@ extern SPIDER_DBTON spider_dbton_oracle; SPIDER_THREAD *spider_table_sts_threads; SPIDER_THREAD *spider_table_crd_threads; #endif +extern volatile ulonglong spider_mon_table_cache_version; +extern volatile ulonglong spider_mon_table_cache_version_req; +extern ulonglong spider_conn_id; +extern Time_zone *UTC; +extern ulonglong spider_thread_id; #ifdef HAVE_PSI_INTERFACE PSI_mutex_key spd_key_mutex_tbl; @@ -6614,6 +6619,12 @@ int spider_db_init( handlerton *spider_hton = (handlerton *)p; DBUG_ENTER("spider_db_init"); + spider_mon_table_cache_version= 0; + spider_mon_table_cache_version_req= 1; + spider_conn_id= 1; + spider_conn_mutex_id= 0; + UTC = 0; + spider_thread_id = 1; const LEX_CSTRING aria_name={STRING_WITH_LEN("Aria")}; if (!plugin_is_ready(&aria_name, MYSQL_STORAGE_ENGINE_PLUGIN)) DBUG_RETURN(HA_ERR_RETRY_INIT); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index bdea13e7d3b..7a92a6e3f17 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -49,7 +49,7 @@ extern struct charset_info_st *spd_charset_utf8_bin; extern handlerton *spider_hton_ptr; extern SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE]; pthread_mutex_t spider_thread_id_mutex; -ulonglong spider_thread_id = 1; +ulonglong spider_thread_id; #ifdef HAVE_PSI_INTERFACE extern PSI_mutex_key spd_key_mutex_udf_table; From 9fb8881ef832371b905231cd5893e738f957d315 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 9 Apr 2024 17:37:08 +0400 Subject: [PATCH 107/313] MDEV-28366 GLOBAL debug_dbug setting affected by collation_connection=utf16... When the system variables @@debug_dbug was assigned to some expression, Sys_debug_dbug::do_check() did not properly convert the value from the expression character set to utf8. So the value was erroneously re-interpretted as utf8 without conversion. In case of a tricky expression character set (e.g. utf16le), this led to unexpected results. Fix: Re-using Sys_var_charptr::do_string_check() in Sys_debug_dbug::do_check(). --- .../sys_vars/r/debug_dbug_utf16le.result | 31 +++++++++++++++++++ .../suite/sys_vars/t/debug_dbug_utf16le.test | 29 +++++++++++++++++ sql/sys_vars.inl | 17 ++-------- 3 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 mysql-test/suite/sys_vars/r/debug_dbug_utf16le.result create mode 100644 mysql-test/suite/sys_vars/t/debug_dbug_utf16le.test diff --git a/mysql-test/suite/sys_vars/r/debug_dbug_utf16le.result b/mysql-test/suite/sys_vars/r/debug_dbug_utf16le.result new file mode 100644 index 00000000000..83b378f2adf --- /dev/null +++ b/mysql-test/suite/sys_vars/r/debug_dbug_utf16le.result @@ -0,0 +1,31 @@ +# +# Start of 10.5 tests +# +# +# MDEV-28366 GLOBAL debug_dbug setting affected by collation_connection=utf16... +# +SET NAMES utf8; +SET collation_connection=utf16le_general_ci; +SET debug_dbug='d,any_random_string'; +SELECT @@debug_dbug; +@@debug_dbug +d,any_random_string +SET debug_dbug=CONCAT('d,', _latin1 0xDF); +SELECT @@debug_dbug; +@@debug_dbug +d,ß +SELECT HEX(@@debug_dbug); +HEX(@@debug_dbug) +642CC39F +SET @@debug_dbug=NULL; +SELECT @@debug_dbug; +@@debug_dbug + +SET @@debug_dbug=DEFAULT; +SELECT @@debug_dbug; +@@debug_dbug + +SET NAMES latin1; +# +# End of 10.5 tests +# diff --git a/mysql-test/suite/sys_vars/t/debug_dbug_utf16le.test b/mysql-test/suite/sys_vars/t/debug_dbug_utf16le.test new file mode 100644 index 00000000000..0c4d8f92e93 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/debug_dbug_utf16le.test @@ -0,0 +1,29 @@ +--source include/have_debug.inc +--source include/have_utf16.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-28366 GLOBAL debug_dbug setting affected by collation_connection=utf16... +--echo # + +SET NAMES utf8; +SET collation_connection=utf16le_general_ci; +SET debug_dbug='d,any_random_string'; +SELECT @@debug_dbug; +SET debug_dbug=CONCAT('d,', _latin1 0xDF); +SELECT @@debug_dbug; +SELECT HEX(@@debug_dbug); + +SET @@debug_dbug=NULL; +SELECT @@debug_dbug; + +SET @@debug_dbug=DEFAULT; +SELECT @@debug_dbug; +SET NAMES latin1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/sql/sys_vars.inl b/sql/sys_vars.inl index 881a2233739..a0f2a7268a7 100644 --- a/sql/sys_vars.inl +++ b/sql/sys_vars.inl @@ -947,21 +947,10 @@ public: { option.var_type|= GET_STR; } bool do_check(THD *thd, set_var *var) { - char buff[STRING_BUFFER_USUAL_SIZE]; - String str(buff, sizeof(buff), system_charset_info), *res; - - if (!(res=var->value->val_str(&str))) - { + bool rc= Sys_var_charptr::do_string_check(thd, var, charset(thd)); + if (var->save_result.string_value.str == nullptr) var->save_result.string_value.str= const_cast(""); - var->save_result.string_value.length= 0; - } - else - { - size_t len= res->length(); - var->save_result.string_value.str= thd->strmake(res->ptr(), len); - var->save_result.string_value.length= len; - } - return false; + return rc; } bool session_update(THD *thd, set_var *var) { From 0304dbc3275fd6492dc5a1250d5c5e0aacd6890b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 1 Nov 2023 11:07:16 +0200 Subject: [PATCH 108/313] MDEV-25089 : Assertion `error.len > 0' failed in galera::ReplicatorSMM::handle_apply_error() Additional corrections after merge from 10.4 branch Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/disabled.def | 1 - mysql-test/suite/galera/t/mdev-30013.test | 1 + sql/sql_table.cc | 16 +++++++--------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 1f41e521bd3..a5a1a6f18b1 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -18,7 +18,6 @@ galera_concurrent_ctas : MDEV-32779 galera_concurrent_ctas: assertion in the gal galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() galera_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() galera_sst_mysqldump_with_key : MDEV-32782 galera_sst_mysqldump_with_key test failed -mdev-31285 : MDEV-25089 Assertion `error.len > 0' failed in galera::ReplicatorSMM::handle_apply_error() galera_var_ignore_apply_errors : MENT-1997 galera_var_ignore_apply_errors test freezes MDEV-22232 : temporarily disabled at the request of Codership MW-402 : temporarily disabled at the request of Codership diff --git a/mysql-test/suite/galera/t/mdev-30013.test b/mysql-test/suite/galera/t/mdev-30013.test index 038b66600ce..3795dd32306 100644 --- a/mysql-test/suite/galera/t/mdev-30013.test +++ b/mysql-test/suite/galera/t/mdev-30013.test @@ -1,4 +1,5 @@ --source include/galera_cluster.inc +--source include/force_restart.inc # ARCHIVE plugin must be uninstalled if (!$HA_ARCHIVE_SO) { skip Needs Archive loadable plugin; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dc1a7060643..c8f1d698ff6 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10294,14 +10294,14 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, if we can support implementing storage engine. */ if (WSREP(thd) && table && table->s->sequence && - wsrep_check_sequence(thd, thd->lex->create_info.seq_create_info, used_engine)) + wsrep_check_sequence(thd, create_info->seq_create_info, used_engine)) DBUG_RETURN(TRUE); - if (WSREP(thd) && + if (WSREP(thd) && table && (thd->lex->sql_command == SQLCOM_ALTER_TABLE || thd->lex->sql_command == SQLCOM_CREATE_INDEX || thd->lex->sql_command == SQLCOM_DROP_INDEX) && - !wsrep_should_replicate_ddl(thd, table_list->table->s->db_type()->db_type)) + !wsrep_should_replicate_ddl(thd, table->s->db_type()->db_type)) DBUG_RETURN(true); #endif /* WITH_WSREP */ @@ -12539,12 +12539,10 @@ bool Sql_cmd_create_table_like::execute(THD *thd) wsrep_check_sequence(thd, lex->create_info.seq_create_info, used_engine)) DBUG_RETURN(true); - WSREP_TO_ISOLATION_BEGIN_ALTER(create_table->db.str, - create_table->table_name.str, - first_table, &alter_info, NULL, - &create_info) - { - WSREP_WARN("CREATE TABLE isolation failure"); + WSREP_TO_ISOLATION_BEGIN_ALTER(create_table->db.str, create_table->table_name.str, + first_table, &alter_info, NULL, &create_info) + { + WSREP_WARN("CREATE TABLE isolation failure"); res= true; goto end_with_restore_list; } From d8249775980f9a6cb1a85e4799e1c1be452c2f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 10 Apr 2024 09:47:44 +0300 Subject: [PATCH 109/313] MDEV-33512 Corrupted table after IMPORT TABLESPACE and restart In commit d74d95961a31b47986d943216489513896108782 (MDEV-18543) there was an error that would cause the hidden metadata record to be deleted, and therefore cause the table to appear corrupted when it is reloaded into the data dictionary cache. PageConverter::update_records(): Do not delete the metadata record, but do validate it. RecIterator::open(): Make the API more similar to 10.6, to simplify merges. --- .../innodb/r/instant_alter_import.result | 1 + .../suite/innodb/t/instant_alter_import.test | 1 + storage/innobase/row/row0import.cc | 46 +++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_import.result b/mysql-test/suite/innodb/r/instant_alter_import.result index 9a20ed606bd..55a49e81057 100644 --- a/mysql-test/suite/innodb/r/instant_alter_import.result +++ b/mysql-test/suite/innodb/r/instant_alter_import.result @@ -61,6 +61,7 @@ alter table t1 discard tablespace; flush tables t2 for export; unlock tables; alter table t1 import tablespace; +# restart select * from t1; z 42 diff --git a/mysql-test/suite/innodb/t/instant_alter_import.test b/mysql-test/suite/innodb/t/instant_alter_import.test index 7bd5645436c..50eda83f4b0 100644 --- a/mysql-test/suite/innodb/t/instant_alter_import.test +++ b/mysql-test/suite/innodb/t/instant_alter_import.test @@ -79,6 +79,7 @@ flush tables t2 for export; unlock tables; alter table t1 import tablespace; +--source include/restart_mysqld.inc select * from t1; drop table t2; diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index a029873da90..b47333113aa 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -252,13 +252,13 @@ public: } /** Position the cursor on the first user record. */ - void open(buf_block_t* block) UNIV_NOTHROW + rec_t* open(buf_block_t* block, const dict_index_t* index) noexcept + MY_ATTRIBUTE((warn_unused_result)) { + m_cur.index = const_cast(index); page_cur_set_before_first(block, &m_cur); - - if (!end()) { - next(); - } + next(); + return page_cur_get_rec(&m_cur); } /** Move to the next record. */ @@ -1848,12 +1848,39 @@ PageConverter::update_records( bool clust_index = m_index->m_srv_index == m_cluster_index; /* This will also position the cursor on the first user record. */ + rec_t* rec = m_rec_iter.open(block, m_index->m_srv_index); - m_rec_iter.open(block); + if (!rec) { + return DB_CORRUPTION; + } + + ulint deleted; + + if (!page_has_prev(block->frame) + && m_index->m_srv_index->is_instant()) { + /* Expect to find the hidden metadata record */ + if (page_rec_is_supremum(rec)) { + return DB_CORRUPTION; + } + + const ulint info_bits = rec_get_info_bits(rec, comp); + + if (!(info_bits & REC_INFO_MIN_REC_FLAG)) { + return DB_CORRUPTION; + } + + if (!(info_bits & REC_INFO_DELETED_FLAG) + != !m_index->m_srv_index->table->instant) { + return DB_CORRUPTION; + } + + deleted = 0; + goto first; + } while (!m_rec_iter.end()) { - rec_t* rec = m_rec_iter.current(); - ibool deleted = rec_get_deleted_flag(rec, comp); + rec = m_rec_iter.current(); + deleted = rec_get_deleted_flag(rec, comp); /* For the clustered index we have to adjust the BLOB reference and the system fields irrespective of the @@ -1861,6 +1888,7 @@ PageConverter::update_records( cluster records is required for purge to work later. */ if (deleted || clust_index) { +first: m_offsets = rec_get_offsets( rec, m_index->m_srv_index, m_offsets, m_index->m_srv_index->n_core_fields, @@ -3158,7 +3186,7 @@ static size_t get_buf_size() ; } -/* find, parse instant metadata, performing variaous checks, +/* find, parse instant metadata, performing various checks, and apply it to dict_table_t @return DB_SUCCESS or some error */ static dberr_t handle_instant_metadata(dict_table_t *table, From 5faf2fdc3bfd6764740620f20151a5f5441bf9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 10 Apr 2024 10:37:18 +0300 Subject: [PATCH 110/313] MDEV-33585 fixup: GCC -Wsign-compare --- storage/innobase/os/os0file.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 672902a0d68..e72dd96cf0e 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -679,7 +679,7 @@ SyncFileIO::execute(const IORequest& request) { ssize_t n_bytes; ut_ad(m_n > 0); - ut_ad(m_n <= os_file_request_size_max); + ut_ad(size_t(m_n) <= os_file_request_size_max); if (request.is_read()) { #ifdef _WIN32 From b697dce8ca378835ae94b16cec715d88d4bf17c7 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 10 Apr 2024 11:12:47 +0400 Subject: [PATCH 111/313] MDEV-29149 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed TIME-alike string and numeric arguments to TIMEDIFF() can get additional fractional seconds during the supported TIME range adjustment in get_time(). For example, during TIMEDIFF('839:00:00','00:00:00') evaluation in Item_func_timediff::get_date(), the call for args[0]->get_time() returns MYSQL_TIME '838:59:59.999999'. Item_func_timediff::get_date() did not handle these extra digits and returned a MYSQL_TIME result with fractional digits outside of Item_func_timediff::decimals. This mismatch could further be caught by a DBUG_ASSERT() in various other pieces of the code, leading to a crash. Fix: In case if get_time() returned MYSQL_TIMESTAMP_TIME, let's truncate all extra digits using my_time_trunc(&l_time,decimals). This guarantees that the rest of the code returns a MYSQL_TIME with second_part not conflicting with Item_func_timediff::decimals. --- mysql-test/main/func_time.result | 54 ++++++++++++++++++++++++++++++++ mysql-test/main/func_time.test | 39 +++++++++++++++++++++++ sql/item_timefunc.cc | 18 +++++++++++ 3 files changed, 111 insertions(+) diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result index 0f807a691b3..eaf30f5f925 100644 --- a/mysql-test/main/func_time.result +++ b/mysql-test/main/func_time.result @@ -6373,3 +6373,57 @@ NULL SELECT FROM_UNIXTIME(LEAST(3696610869, NULL)); FROM_UNIXTIME(LEAST(3696610869, NULL)) NULL +# +# Start of 10.5 tests +# +# +# MDEV-29149 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed +# +SET @@timestamp= UNIX_TIMESTAMP('2022-07-21 23:00:00'); +SELECT DATE_SUB('2022-07-21 00:00:00', INTERVAL 800 HOUR) AS expected_result; +expected_result +2022-06-17 16:00:00 +SELECT +IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE)) AS c1, +IF(1,TIMEDIFF('-839:00:00','-38:59:59'),CAST('2022-12-12' AS DATE)) AS c2; +c1 c2 +2022-06-17 16:00:00 2022-06-17 16:00:00 +Warnings: +Warning 1292 Truncated incorrect time value: '839:00:00' +Warning 1292 Truncated incorrect time value: '-839:00:00' +SELECT +IF(1,TIMEDIFF(385959,8390000),CAST('2022-12-12' AS DATE)) AS c1, +IF(1,TIMEDIFF(-8390000,-385959),CAST('2022-12-12' AS DATE)) AS c2; +c1 c2 +2022-06-17 16:00:00 2022-06-17 16:00:00 +Warnings: +Warning 1292 Truncated incorrect time value: '8390000' +Warning 1292 Truncated incorrect time value: '-8390000' +SELECT +TIMEDIFF('38:59:59','839:00:00') AS c1, +CAST(TIMEDIFF('38:59:59','839:00:00') AS TIME(6)) AS c2, +TIMEDIFF('839:00:00','38:59:59') AS c3, +CAST(TIMEDIFF('839:00:00','38:59:59') AS TIME(6)) AS c4; +c1 c2 c3 c4 +-800:00:00 -800:00:00.000000 800:00:00 800:00:00.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '839:00:00' +Warning 1292 Truncated incorrect time value: '839:00:00' +Warning 1292 Truncated incorrect time value: '839:00:00' +Warning 1292 Truncated incorrect time value: '839:00:00' +SELECT +TIMEDIFF(385959,8390000) AS c1, +CAST(TIMEDIFF(385959,8390000) AS TIME(6)) AS c2, +TIMEDIFF(8390000,385959) AS c3, +CAST(TIMEDIFF(8390000,385959) AS TIME(6)) AS c4; +c1 c2 c3 c4 +-800:00:00 -800:00:00.000000 800:00:00 800:00:00.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '8390000' +Warning 1292 Truncated incorrect time value: '8390000' +Warning 1292 Truncated incorrect time value: '8390000' +Warning 1292 Truncated incorrect time value: '8390000' +SET @@timestamp= DEFAULT; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 089ab4b0b72..4b046ac166a 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -3213,3 +3213,42 @@ SELECT CONCAT(MAKETIME('01', '01', LEAST( -100, NULL ))); --echo # SELECT FROM_UNIXTIME(LEAST(3696610869, NULL)); + + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-29149 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed +--echo # + +SET @@timestamp= UNIX_TIMESTAMP('2022-07-21 23:00:00'); + +SELECT DATE_SUB('2022-07-21 00:00:00', INTERVAL 800 HOUR) AS expected_result; + +SELECT + IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE)) AS c1, + IF(1,TIMEDIFF('-839:00:00','-38:59:59'),CAST('2022-12-12' AS DATE)) AS c2; + +SELECT + IF(1,TIMEDIFF(385959,8390000),CAST('2022-12-12' AS DATE)) AS c1, + IF(1,TIMEDIFF(-8390000,-385959),CAST('2022-12-12' AS DATE)) AS c2; + +SELECT + TIMEDIFF('38:59:59','839:00:00') AS c1, + CAST(TIMEDIFF('38:59:59','839:00:00') AS TIME(6)) AS c2, + TIMEDIFF('839:00:00','38:59:59') AS c3, + CAST(TIMEDIFF('839:00:00','38:59:59') AS TIME(6)) AS c4; + +SELECT + TIMEDIFF(385959,8390000) AS c1, + CAST(TIMEDIFF(385959,8390000) AS TIME(6)) AS c2, + TIMEDIFF(8390000,385959) AS c3, + CAST(TIMEDIFF(8390000,385959) AS TIME(6)) AS c4; + +SET @@timestamp= DEFAULT; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index a58f3593463..2f689acc54c 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2706,6 +2706,24 @@ bool Item_func_timediff::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzy if (l_time1.neg != l_time2.neg) l_sign= -l_sign; + if (l_time1.time_type == MYSQL_TIMESTAMP_TIME) + { + /* + In case of TIME-alike arguments: + TIMEDIFF('38:59:59', '839:00:00') + let's truncate extra fractional seconds that might appear if the argument + values were out of the supported TIME range. For example, args[n]->get_time() + for the string literal '839:00:00' returns TIME'838:59:59.999999'. + The fractional part must be truncated according to this->decimals, + to avoid returning more fractional seconds than it was detected + during this->fix_length_and_dec(). + Note, the thd rounding mode should not be important here, as we're removing + redundant digits from the maximum possible value: '838:59:59.999999'. + */ + my_time_trunc(&l_time1, decimals); + my_time_trunc(&l_time2, decimals); + } + if (calc_time_diff(&l_time1, &l_time2, l_sign, &l_time3, fuzzydate)) return (null_value= 1); From 3655cefc42902a3b3f584d252de7af488feaff55 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 9 Apr 2024 20:56:57 +0300 Subject: [PATCH 112/313] MDEV-33813 ERROR 1021 (HY000): Disk full (./org/test1.MAI); waiting for someone to free some space Fixed that internal temporary tables are not waiting for freed disk space. Other things: - 'kill id' will now kill a query waiting for free disk space instantly. Before it could take up to 60 seconds for the kill would be noticed. - Fixed that sorting one index is not using MY_WAIT_IF_FULL for temp files. - Fixed bug where share->write_flag set MY_WAIT_IF_FULL for temp files. It is quite hard to do a test case for this. Instead I tested all combinations interactively. --- include/my_sys.h | 1 + mysys/errors.c | 9 ++++++++- sql/mysqld.cc | 4 ++++ sql/mysqld.h | 1 + sql/sql_class.cc | 28 ++++++++++++++++++++++++++++ sql/sql_class.h | 3 +++ storage/maria/ma_check.c | 2 +- storage/maria/ma_extra.c | 14 ++++++++++++++ storage/maria/ma_open.c | 2 +- storage/maria/ma_pagecache.c | 2 ++ storage/maria/maria_def.h | 1 + 11 files changed, 64 insertions(+), 3 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index da336bdf8c9..84a1e6a4752 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -652,6 +652,7 @@ extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count, myf MyFlags); extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); extern my_off_t my_ftell(FILE *stream,myf MyFlags); +extern void (*my_sleep_for_space)(unsigned int seconds); /* implemented in my_memmem.c */ extern void *my_memmem(const void *haystack, size_t haystacklen, diff --git a/mysys/errors.c b/mysys/errors.c index d88540fe277..a8be37bf2b6 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -112,6 +112,13 @@ void init_glob_errs() } #endif +static void my_space_sleep(uint seconds) +{ + sleep(seconds); +} + +void (*my_sleep_for_space)(uint seconds)= my_space_sleep; + void wait_for_free_space(const char *filename, int errors) { if (errors == 0) @@ -123,7 +130,7 @@ void wait_for_free_space(const char *filename, int errors) MYF(ME_BELL | ME_ERROR_LOG | ME_WARNING), MY_WAIT_FOR_USER_TO_FIX_PANIC, MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC ); - (void) sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC); + my_sleep_for_space(MY_WAIT_FOR_USER_TO_FIX_PANIC); } const char **get_global_errmsgs(int nr __attribute__((unused))) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d10c342a6dc..16820300f1c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4880,6 +4880,9 @@ static int init_server_components() error_handler_hook= my_message_sql; proc_info_hook= set_thd_stage_info; + /* Set up hook to handle disk full */ + my_sleep_for_space= mariadb_sleep_for_space; + /* Print source revision hash, as one of the first lines, if not the first in error log, for troubleshooting and debugging purposes @@ -9216,6 +9219,7 @@ PSI_stage_info stage_user_lock= { 0, "User lock", 0}; PSI_stage_info stage_user_sleep= { 0, "User sleep", 0}; PSI_stage_info stage_verifying_table= { 0, "Verifying table", 0}; PSI_stage_info stage_waiting_for_delay_list= { 0, "Waiting for delay_list", 0}; +PSI_stage_info stage_waiting_for_disk_space= {0, "Waiting for someone to free space", 0}; PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log= { 0, "Waiting for GTID to be written to binary log", 0}; PSI_stage_info stage_waiting_for_handler_insert= { 0, "Waiting for handler insert", 0}; PSI_stage_info stage_waiting_for_handler_lock= { 0, "Waiting for handler lock", 0}; diff --git a/sql/mysqld.h b/sql/mysqld.h index c0a55ce49c7..fe73f14ee62 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -644,6 +644,7 @@ extern PSI_stage_info stage_user_sleep; extern PSI_stage_info stage_verifying_table; extern PSI_stage_info stage_waiting_for_ddl; extern PSI_stage_info stage_waiting_for_delay_list; +extern PSI_stage_info stage_waiting_for_disk_space; extern PSI_stage_info stage_waiting_for_flush; extern PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log; extern PSI_stage_info stage_waiting_for_handler_insert; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 35ab93cc8ba..6cabd7fbabd 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -8323,6 +8323,34 @@ wait_for_commit::unregister_wait_for_prior_commit2() mysql_mutex_unlock(&LOCK_wait_commit); } +/* + Wait # seconds or until someone sends a signal (through kill) + + Note that this must have same prototype as my_sleep_for_space() +*/ + +C_MODE_START + +void mariadb_sleep_for_space(unsigned int seconds) +{ + THD *thd= current_thd; + PSI_stage_info old_stage; + if (!thd) + { + sleep(seconds); + return; + } + mysql_mutex_lock(&thd->LOCK_wakeup_ready); + thd->ENTER_COND(&thd->COND_wakeup_ready, &thd->LOCK_wakeup_ready, + &stage_waiting_for_disk_space, &old_stage); + if (!thd->killed) + mysql_cond_wait(&thd->COND_wakeup_ready, &thd->LOCK_wakeup_ready); + thd->EXIT_COND(&old_stage); + return; +} + +C_MODE_END + bool Discrete_intervals_list::append(ulonglong start, ulonglong val, ulonglong incr) diff --git a/sql/sql_class.h b/sql/sql_class.h index 29efb45e097..84665979d6e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -8185,6 +8185,9 @@ extern THD_list server_threads; void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps, uint field_count); +C_MODE_START +void mariadb_sleep_for_space(unsigned int seconds); +C_MODE_END #endif /* MYSQL_SERVER */ #endif /* SQL_CLASS_INCLUDED */ diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 044be038607..ac3ede3865c 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -3390,7 +3390,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info, length= page.size; bzero(buff+length,keyinfo->block_length-length); if (write_page(share, new_file, buff, keyinfo->block_length, - new_page_pos, MYF(MY_NABP | MY_WAIT_IF_FULL))) + new_page_pos, MYF(MY_NABP | MY_WAIT_IF_FULL) & param->myf_rw)) { _ma_check_print_error(param,"Can't write indexblock, error: %d",my_errno); goto err; diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 49b731af5fc..9116edbd671 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -601,6 +601,20 @@ uint _ma_file_callback_to_id(void *callback_data) return share ? share->id : 0; } +/* + Disable MY_WAIT_IF_FULL flag for temporary tables + + Temporary tables does not have MY_WAIT_IF_FULL in share->write_flags +*/ + +uint _ma_write_flags_callback(void *callback_data, myf flags) +{ + MARIA_SHARE *share= (MARIA_SHARE*) callback_data; + if (share) + flags&= ~(~share->write_flag & MY_WAIT_IF_FULL); + return flags; +} + /** @brief flushes the data and/or index file of a table diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 6d9ae62ca8e..2497bc41e8f 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -172,7 +172,6 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, mysql_mutex_lock(&share->intern_lock); info.read_record= share->read_record; share->reopen++; - share->write_flag=MYF(MY_NABP | MY_WAIT_IF_FULL); if (share->options & HA_OPTION_READ_ONLY_DATA) { info.lock_type=F_RDLCK; @@ -987,6 +986,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags, share->options|= HA_OPTION_READ_ONLY_DATA; share->is_log_table= FALSE; + share->write_flag=MYF(MY_NABP | MY_WAIT_IF_FULL); if (open_flags & HA_OPEN_TMP_TABLE || share->options & HA_OPTION_TMP_TABLE) { share->options|= HA_OPTION_TMP_TABLE; diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index 144b10a86da..49981e7964a 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -687,6 +687,8 @@ static my_bool pagecache_fwrite(PAGECACHE *pagecache, /* FIXME: ENGINE=Aria occasionally writes uninitialized data */ __msan_unpoison(args.page, pagecache->block_size); #endif + /* Reset MY_WAIT_IF_FULL for temporary tables */ + flags= _ma_write_flags_callback(filedesc->callback_data, flags); res= (int)my_pwrite(filedesc->file, args.page, pagecache->block_size, ((my_off_t) pageno << pagecache->shift), flags); (*filedesc->post_write_hook)(res, &args); diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index f3303884200..b12f21e39f9 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -1745,6 +1745,7 @@ extern my_bool ma_yield_and_check_if_killed(MARIA_HA *info, int inx); extern my_bool ma_killed_standalone(MARIA_HA *); extern uint _ma_file_callback_to_id(void *callback_data); +extern uint _ma_write_flags_callback(void *callback_data, myf flags); extern void free_maria_share(MARIA_SHARE *share); static inline void unmap_file(MARIA_HA *info __attribute__((unused))) From da47c0370dda125a941cebed8abeb724a78ef4d1 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 9 Apr 2024 21:05:14 +0300 Subject: [PATCH 113/313] Fixed calculating of last_master_timestamp for parallel replication. This effects the Seconds_Behind_Master value. --- sql/rpl_rli.h | 4 ++++ sql/slave.cc | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 5e259d5c8a1..151317930c3 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -564,6 +564,10 @@ private: Guarded by data_lock. Written by the sql thread. Read by client threads executing SHOW SLAVE STATUS. + + This is calculated as: + clock_time_for_event_on_master + clock_difference_between_master_and_slave + + SQL_DELAY. */ time_t sql_delay_end; diff --git a/sql/slave.cc b/sql/slave.cc index 63346d29bbb..71931df009b 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4342,6 +4342,13 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, rli->last_inuse_relaylog->dequeued_count))) && event_can_update_last_master_timestamp(ev)) { + /* + This is the first event from the master after the slave was up to date + and has been waiting for new events. + We update last_master_timestamp before executing the event to not + have Seconds_after_master == 0 while executing the event. + last_master_timestamp will be updated again when the event is commited. + */ if (rli->last_master_timestamp < ev->when) { rli->last_master_timestamp= ev->when; @@ -4378,7 +4385,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, Seconds_Behind_Master is zero. */ if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT && - rli->last_master_timestamp < ev->when) + rli->last_master_timestamp < ev->when + (time_t) ev->exec_time) rli->last_master_timestamp= ev->when + (time_t) ev->exec_time; DBUG_ASSERT(rli->last_master_timestamp >= 0); From 0da1653f1bce3c238c6c0bb4a5c3a1fcde06b238 Mon Sep 17 00:00:00 2001 From: Andrei Date: Wed, 10 Apr 2024 18:19:43 +0300 Subject: [PATCH 114/313] MDEV-31779 Server crash in Rows_log_event::update_sequence upon replaying binary log The crash at running mysqlbinlog on a SEQUENCE containing binlog file was caused MDEV-29621 fixes that did not check which of the slave or binlog applier executes a block introduced there. The block is meaningful only for the parallel slave applier, so it's safe to fix this bug with identified the actual applier and skipping the block when it's the mysqlbinlog one. --- mysql-test/suite/rpl/r/rpl_parallel_seq.result | 10 ++++++++++ mysql-test/suite/rpl/t/rpl_parallel_seq.test | 18 ++++++++++++++++++ sql/log_event_server.cc | 1 + 3 files changed, 29 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_parallel_seq.result b/mysql-test/suite/rpl/r/rpl_parallel_seq.result index 8f55f52e54c..02287d54e33 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_seq.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_seq.result @@ -127,4 +127,14 @@ CREATE SEQUENCE s4; DROP SEQUENCE s2,s3,s4; DROP TABLE ti; connection slave; +connection master; +CREATE SEQUENCE s; +SELECT NEXTVAL(s); +NEXTVAL(s) +1 +flush binary logs; +DROP SEQUENCE s; +DROP SEQUENCE s; +connection slave; +connection master; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_parallel_seq.test b/mysql-test/suite/rpl/t/rpl_parallel_seq.test index b1b15412b16..cc361a7b35b 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_seq.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_seq.test @@ -195,4 +195,22 @@ DROP TABLE ti; --sync_slave_with_master +# MDEV-31779 server crash in Rows_log_event::update_sequence at replaying binlog +--connection master +--let $binlog_file = query_get_value(SHOW MASTER STATUS, File, 1) +--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) +CREATE SEQUENCE s; +--disable_ps2_protocol +SELECT NEXTVAL(s); +--enable_ps2_protocol +flush binary logs; +DROP SEQUENCE s; +--exec $MYSQL_BINLOG $datadir/$binlog_file | $MYSQL test +DROP SEQUENCE s; + +--sync_slave_with_master + +--connection master + + --source include/rpl_end.inc diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index f51f5b7deec..313df13f400 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -7544,6 +7544,7 @@ int Rows_log_event::update_sequence() #if defined(WITH_WSREP) ! WSREP(thd) && #endif + table->in_use->rgi_slave && !(table->in_use->rgi_slave->gtid_ev_flags2 & Gtid_log_event::FL_DDL) && !(old_master= rpl_master_has_bug(thd->rgi_slave->rli, From 2d2172a5cf1bcc66810fa4ee07219e8c4c9a41d3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 10 Apr 2024 19:34:15 +0200 Subject: [PATCH 115/313] sporadic failures of rpl.rpl_semi_sync_master_shutdown increase the MASTER_CONNECT_RETRY time under valgrind, otherwise the slave gives up retrying before the master is ready also, cosmetic cleanup of rpl_semi_sync_master_shutdown.test --- mysql-test/include/rpl_change_topology.inc | 5 +++-- .../suite/rpl/r/rpl_semi_sync_master_shutdown.result | 3 +-- .../suite/rpl/t/rpl_semi_sync_master_shutdown.test | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/mysql-test/include/rpl_change_topology.inc b/mysql-test/include/rpl_change_topology.inc index 1ee6e711372..2b75579568b 100644 --- a/mysql-test/include/rpl_change_topology.inc +++ b/mysql-test/include/rpl_change_topology.inc @@ -96,10 +96,11 @@ # Remove whitespace from $rpl_topology --let $rpl_topology= `SELECT REPLACE('$rpl_topology', ' ', '')` +--source include/slow_environ.inc + --let $include_filename= rpl_change_topology.inc [new topology=$rpl_topology] --source include/begin_include_file.inc - if ($rpl_debug) { --echo ---- Check input ---- @@ -233,7 +234,7 @@ if (!$rpl_skip_change_master) --echo "\$rpl_master_log_pos parameter not set for the master: $_rpl_master. Set log position to empty." } } - eval CHANGE MASTER TO MASTER_HOST = '127.0.0.1', MASTER_PORT = $_rpl_port, MASTER_USER = 'root', MASTER_LOG_FILE = '$_rpl_master_log_file'$_rpl_master_log_pos, MASTER_CONNECT_RETRY = 1; + eval CHANGE MASTER TO MASTER_HOST = '127.0.0.1', MASTER_PORT = $_rpl_port, MASTER_USER = 'root', MASTER_LOG_FILE = '$_rpl_master_log_file'$_rpl_master_log_pos, MASTER_CONNECT_RETRY = 1$_timeout_adjustment; } if ($_rpl_master == '') { diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_master_shutdown.result b/mysql-test/suite/rpl/r/rpl_semi_sync_master_shutdown.result index 6124ba01679..8803b4c3392 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_master_shutdown.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_master_shutdown.result @@ -4,7 +4,7 @@ connection master; SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; connection slave; include/stop_slave.inc -SET @@GLOBAL. rpl_semi_sync_slave_enabled = 1; +SET @@GLOBAL.rpl_semi_sync_slave_enabled = 1; include/start_slave.inc connection master; CREATE TABLE t1 (a INT); @@ -21,7 +21,6 @@ connection slave; include/wait_for_slave_sql_to_start.inc include/wait_for_slave_io_to_start.inc connection master; -SET @@GLOBAL.debug_dbug=""; SET @@GLOBAL. rpl_semi_sync_master_enabled = 0; connection master; DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_master_shutdown.test b/mysql-test/suite/rpl/t/rpl_semi_sync_master_shutdown.test index 05e6fcca143..d653d84c3b4 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_master_shutdown.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_master_shutdown.test @@ -4,19 +4,17 @@ # finishes off as specified in particular trying to connect even to a shut down # master for a semisync firewell routine. -source include/not_embedded.inc; -source include/have_debug.inc; source include/master-slave.inc; --connection master ---let $sav_enabled_master=`SELECT @@GLOBAL.rpl_semi_sync_master_enabled ` +--let $sav_enabled_master=`SELECT @@GLOBAL.rpl_semi_sync_master_enabled` SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; --connection slave source include/stop_slave.inc; ---let $sav_enabled_slave=`SELECT @@GLOBAL.rpl_semi_sync_slave_enabled ` -SET @@GLOBAL. rpl_semi_sync_slave_enabled = 1; +--let $sav_enabled_slave=`SELECT @@GLOBAL.rpl_semi_sync_slave_enabled` +SET @@GLOBAL.rpl_semi_sync_slave_enabled = 1; source include/start_slave.inc; --connection master @@ -52,7 +50,6 @@ source include/rpl_start_server.inc; #--source include/start_slave.inc --connection master -SET @@GLOBAL.debug_dbug=""; --eval SET @@GLOBAL. rpl_semi_sync_master_enabled = $sav_enabled_master --connection master From 37fd497c7b949be9646c213bee8fda3debb429ac Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 10 Apr 2024 17:58:36 +0400 Subject: [PATCH 116/313] MDEV-32458 ASAN unknown-crash in Inet6::ascii_to_fbt when casting character string to inet6 The condition checked the value of the leftmost byte before checking if at least one byte is still available in the buffer. Changing the order in the condition: check for a byte availability before checking the byte value. --- .../type_inet/mysql-test/type_inet/type_inet6.result | 11 +++++++++++ plugin/type_inet/mysql-test/type_inet/type_inet6.test | 10 ++++++++++ plugin/type_inet/sql_type_inet.cc | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.result b/plugin/type_inet/mysql-test/type_inet/type_inet6.result index 7484a10962c..9e48f396daf 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result @@ -2330,3 +2330,14 @@ Warning 1292 Incorrect inet6 value: '' Warning 1292 Incorrect inet6 value: '' Warning 1292 Incorrect inet6 value: '' DROP TABLE t1; +# +# MDEV-32458 ASAN unknown-crash in Inet6::ascii_to_fbt when casting character string to inet6 +# +CREATE TABLE t1 (c CHAR(3)); +INSERT INTO t1 VALUES ('1:0'),('00:'); +SELECT * FROM t1 WHERE c>CAST('::1' AS INET6); +c +Warnings: +Warning 1292 Incorrect inet6 value: '1:0' +Warning 1292 Incorrect inet6 value: '00:' +DROP TABLE t1; diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.test b/plugin/type_inet/mysql-test/type_inet/type_inet6.test index abe9071962f..41cfa0b06ae 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.test +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.test @@ -1686,3 +1686,13 @@ SELECT 1.00 + (b = a) AS f FROM t1 ORDER BY f; SELECT 1.00 + (b BETWEEN a AND '') AS f FROM t1 ORDER BY f; SELECT 1.00 + (b IN (a,'')) AS f FROM t1 ORDER BY f; DROP TABLE t1; + + +--echo # +--echo # MDEV-32458 ASAN unknown-crash in Inet6::ascii_to_fbt when casting character string to inet6 +--echo # + +CREATE TABLE t1 (c CHAR(3)); +INSERT INTO t1 VALUES ('1:0'),('00:'); +SELECT * FROM t1 WHERE c>CAST('::1' AS INET6); +DROP TABLE t1; diff --git a/plugin/type_inet/sql_type_inet.cc b/plugin/type_inet/sql_type_inet.cc index 5817bdecc4b..3f457fd52db 100644 --- a/plugin/type_inet/sql_type_inet.cc +++ b/plugin/type_inet/sql_type_inet.cc @@ -229,7 +229,7 @@ bool Inet6::ascii_to_ipv6(const char *str, size_t str_length) continue; } - if (!*p || p >= str_end) + if (p >= str_end || !*p) { DBUG_PRINT("error", ("ascii_to_ipv6(%.*s): invalid IPv6 address: " "ending at ':'.", (int) str_length, str)); From 263932d505cb895367fea9f106a9e66664ae3832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 11 Apr 2024 09:58:53 +0300 Subject: [PATCH 117/313] MDEV-33325 Crash in flst_read_addr on corrupted data flst_read_addr(): Remove assertions. Instead, we will check these conditions in the callers and avoid a crash in case of corruption. We will check the conditions more carefully, because the callers know more exact bounds for the page numbers and the byte offsets withing pages. flst_remove(), flst_add_first(), flst_add_last(): Add a parameter for passing fil_space_t::free_limit. None of the lists may point to pages that are beyond the current initialized length of the tablespace. trx_rseg_mem_restore(): Access the first page of the tablespace, so that we will correctly recover rseg->space->free_limit in case some log based recovery is pending. ibuf_remove_free_page(): Only look up the root page once, and validate the last page number. Reviewed by: Debarun Banerjee --- storage/innobase/btr/btr0btr.cc | 6 +- storage/innobase/fsp/fsp0fsp.cc | 143 +++++++++++++++++++++-------- storage/innobase/fut/fut0lst.cc | 135 ++++++++++++++++----------- storage/innobase/ibuf/ibuf0ibuf.cc | 33 +++---- storage/innobase/include/fut0lst.h | 50 +++++----- storage/innobase/trx/trx0purge.cc | 52 +++++++++-- storage/innobase/trx/trx0rseg.cc | 12 +++ storage/innobase/trx/trx0undo.cc | 33 +++++-- 8 files changed, 313 insertions(+), 151 deletions(-) diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 6b42b3e14ec..93ad4b671c8 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -562,7 +562,8 @@ btr_page_alloc_for_ibuf( { buf_page_make_young_if_needed(&new_block->page); *err= flst_remove(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, new_block, - PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, mtr); + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, + fil_system.sys_space->free_limit, mtr); } ut_d(if (*err == DB_SUCCESS) flst_validate(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, mtr)); @@ -666,7 +667,8 @@ btr_page_free_for_ibuf( buf_block_t *root= btr_get_latched_root(*index, mtr); dberr_t err= flst_add_first(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, - block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, mtr); + block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, + fil_system.sys_space->free_limit, mtr); ut_d(if (err == DB_SUCCESS) flst_validate(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, mtr)); return err; diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 747a397fe92..314a3ae6952 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -261,6 +261,7 @@ inline void xdes_init(const buf_block_t &block, xdes_t *descr, mtr_t *mtr) } /** Mark a page used in an extent descriptor. +@param[in] space tablespace @param[in,out] seg_inode segment inode @param[in,out] iblock segment inode page @param[in] page page number @@ -270,7 +271,8 @@ inline void xdes_init(const buf_block_t &block, xdes_t *descr, mtr_t *mtr) @return error code */ static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t -fseg_mark_page_used(fseg_inode_t *seg_inode, buf_block_t *iblock, +fseg_mark_page_used(const fil_space_t *space, + fseg_inode_t *seg_inode, buf_block_t *iblock, uint32_t page, xdes_t *descr, buf_block_t *xdes, mtr_t *mtr) { ut_ad(fil_page_get_type(iblock->page.frame) == FIL_PAGE_INODE); @@ -280,15 +282,16 @@ fseg_mark_page_used(fseg_inode_t *seg_inode, buf_block_t *iblock, const uint16_t xoffset= uint16_t(descr - xdes->page.frame + XDES_FLST_NODE); const uint16_t ioffset= uint16_t(seg_inode - iblock->page.frame); + const uint32_t limit= space->free_limit; if (!xdes_get_n_used(descr)) { /* We move the extent from the free list to the NOT_FULL list */ if (dberr_t err= flst_remove(iblock, uint16_t(FSEG_FREE + ioffset), - xdes, xoffset, mtr)) + xdes, xoffset, limit, mtr)) return err; if (dberr_t err= flst_add_last(iblock, uint16_t(FSEG_NOT_FULL + ioffset), - xdes, xoffset, mtr)) + xdes, xoffset, limit, mtr)) return err; } @@ -305,10 +308,10 @@ fseg_mark_page_used(fseg_inode_t *seg_inode, buf_block_t *iblock, { /* We move the extent from the NOT_FULL list to the FULL list */ if (dberr_t err= flst_remove(iblock, uint16_t(FSEG_NOT_FULL + ioffset), - xdes, xoffset, mtr)) + xdes, xoffset, limit, mtr)) return err; if (dberr_t err= flst_add_last(iblock, uint16_t(FSEG_FULL + ioffset), - xdes, xoffset, mtr)) + xdes, xoffset, limit, mtr)) return err; mtr->write<4>(*iblock, seg_inode + FSEG_NOT_FULL_N_USED, not_full_n_used - FSP_EXTENT_SIZE); @@ -891,7 +894,7 @@ fsp_fill_free_list( xdes_set_free(*xdes, descr, FSP_IBUF_BITMAP_OFFSET, mtr); xdes_set_state(*xdes, descr, XDES_FREE_FRAG, mtr); if (dberr_t err= flst_add_last(header, FSP_HEADER_OFFSET + FSP_FREE_FRAG, - xdes, xoffset, mtr)) + xdes, xoffset, space->free_limit, mtr)) return err; byte *n_used= FSP_HEADER_OFFSET + FSP_FRAG_N_USED + header->page.frame; mtr->write<4>(*header, n_used, 2U + mach_read_from_4(n_used)); @@ -900,7 +903,7 @@ fsp_fill_free_list( { if (dberr_t err= flst_add_last(header, FSP_HEADER_OFFSET + FSP_FREE, - xdes, xoffset, mtr)) + xdes, xoffset, space->free_limit, mtr)) return err; count++; } @@ -951,7 +954,11 @@ corrupted: first = flst_get_first(FSP_HEADER_OFFSET + FSP_FREE + header->page.frame); - if (first.page == FIL_NULL) { + if (first.page >= space->free_limit) { + if (first.page != FIL_NULL) { + goto flst_corrupted; + } + *err = fsp_fill_free_list(false, space, header, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) { goto corrupted; @@ -962,6 +969,17 @@ corrupted: if (first.page == FIL_NULL) { return nullptr; /* No free extents left */ } + if (first.page >= space->free_limit) { + goto flst_corrupted; + } + } + + if (first.boffset < FSP_HEADER_OFFSET + FSP_HEADER_SIZE + || first.boffset >= space->physical_size() + - (XDES_SIZE + FIL_PAGE_DATA_END)) { + flst_corrupted: + *err = DB_CORRUPTION; + goto corrupted; } descr = xdes_lst_get_descriptor(*space, first, mtr, @@ -974,7 +992,7 @@ corrupted: *err = flst_remove(header, FSP_HEADER_OFFSET + FSP_FREE, desc_block, static_cast(descr - desc_block->page.frame + XDES_FLST_NODE), - mtr); + space->free_limit, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) { return nullptr; } @@ -991,11 +1009,12 @@ MY_ATTRIBUTE((nonnull, warn_unused_result)) @param[in,out] xdes extent descriptor page @param[in,out] descr extent descriptor @param[in] bit slot to allocate in the extent +@param[in] space tablespace @param[in,out] mtr mini-transaction @return error code */ static dberr_t fsp_alloc_from_free_frag(buf_block_t *header, buf_block_t *xdes, xdes_t *descr, - uint32_t bit, mtr_t *mtr) + uint32_t bit, fil_space_t *space, mtr_t *mtr) { if (UNIV_UNLIKELY(xdes_get_state(descr) != XDES_FREE_FRAG || !xdes_is_free(descr, bit))) @@ -1008,14 +1027,15 @@ fsp_alloc_from_free_frag(buf_block_t *header, buf_block_t *xdes, xdes_t *descr, if (xdes_is_full(descr)) { + const uint32_t limit= space->free_limit; /* The fragment is full: move it to another list */ const uint16_t xoffset= static_cast(descr - xdes->page.frame + XDES_FLST_NODE); if (dberr_t err= flst_remove(header, FSP_HEADER_OFFSET + FSP_FREE_FRAG, - xdes, xoffset, mtr)) + xdes, xoffset, limit, mtr)) return err; if (dberr_t err= flst_add_last(header, FSP_HEADER_OFFSET + FSP_FULL_FRAG, - xdes, xoffset, mtr)) + xdes, xoffset, limit, mtr)) return err; xdes_set_state(*xdes, descr, XDES_FULL_FRAG, mtr); n_used-= FSP_EXTENT_SIZE; @@ -1079,8 +1099,11 @@ buf_block_t *fsp_alloc_free_page(fil_space_t *space, uint32_t hint, /* Else take the first extent in free_frag list */ fil_addr_t first = flst_get_first(FSP_HEADER_OFFSET + FSP_FREE_FRAG + block->page.frame); - if (first.page == FIL_NULL) + if (first.page >= space->free_limit) { + if (first.page != FIL_NULL) + goto flst_corrupted; + /* There are no partially full fragments: allocate a free extent and add it to the FREE_FRAG list. NOTE that the allocation may have as a side-effect that an extent containing a descriptor @@ -1091,13 +1114,23 @@ buf_block_t *fsp_alloc_free_page(fil_space_t *space, uint32_t hint, return nullptr; *err= flst_add_last(block, FSP_HEADER_OFFSET + FSP_FREE_FRAG, xdes, static_cast(descr - xdes->page.frame + - XDES_FLST_NODE), mtr); + XDES_FLST_NODE), + space->free_limit, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) return nullptr; xdes_set_state(*xdes, descr, XDES_FREE_FRAG, mtr); } else { + if (first.boffset < FSP_HEADER_OFFSET + FSP_HEADER_SIZE || + first.boffset >= space->physical_size() - + (XDES_SIZE + FIL_PAGE_DATA_END)) + { + flst_corrupted: + *err= DB_CORRUPTION; + goto err_exit; + } + descr= xdes_lst_get_descriptor(*space, first, mtr, &xdes, err); if (!descr) return nullptr; @@ -1144,7 +1177,7 @@ buf_block_t *fsp_alloc_free_page(fil_space_t *space, uint32_t hint, } } - *err= fsp_alloc_from_free_frag(block, xdes, descr, free, mtr); + *err= fsp_alloc_from_free_frag(block, xdes, descr, free, space, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) goto corrupted; return fsp_page_create(space, page_no, init_mtr); @@ -1183,7 +1216,8 @@ static dberr_t fsp_free_extent(fil_space_t* space, page_no_t offset, space->free_len++; return flst_add_last(block, FSP_HEADER_OFFSET + FSP_FREE, xdes, static_cast(descr - xdes->page.frame + - XDES_FLST_NODE), mtr); + XDES_FLST_NODE), + space->free_limit, mtr); } MY_ATTRIBUTE((nonnull)) @@ -1237,16 +1271,17 @@ static dberr_t fsp_free_page(fil_space_t *space, page_no_t offset, mtr_t *mtr) const uint16_t xoffset= static_cast(descr - xdes->page.frame + XDES_FLST_NODE); + const uint32_t limit = space->free_limit; if (state == XDES_FULL_FRAG) { /* The fragment was full: move it to another list */ err = flst_remove(header, FSP_HEADER_OFFSET + FSP_FULL_FRAG, - xdes, xoffset, mtr); + xdes, xoffset, limit, mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { return err; } err = flst_add_last(header, FSP_HEADER_OFFSET + FSP_FREE_FRAG, - xdes, xoffset, mtr); + xdes, xoffset, limit, mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { return err; } @@ -1268,7 +1303,7 @@ static dberr_t fsp_free_page(fil_space_t *space, page_no_t offset, mtr_t *mtr) if (!xdes_get_n_used(descr)) { /* The extent has become free: move it to another list */ err = flst_remove(header, FSP_HEADER_OFFSET + FSP_FREE_FRAG, - xdes, xoffset, mtr); + xdes, xoffset, limit, mtr); if (err == DB_SUCCESS) { err = fsp_free_extent(space, offset, mtr); } @@ -1362,7 +1397,7 @@ static dberr_t fsp_alloc_seg_inode_page(fil_space_t *space, #endif return flst_add_last(header, FSP_HEADER_OFFSET + FSP_SEG_INODES_FREE, - block, FSEG_INODE_PAGE_NODE, mtr); + block, FSEG_INODE_PAGE_NODE, space->free_limit, mtr); } MY_ATTRIBUTE((nonnull, warn_unused_result)) @@ -1418,12 +1453,13 @@ fsp_alloc_seg_inode(fil_space_t *space, buf_block_t *header, { /* There are no other unused headers left on the page: move it to another list */ + const uint32_t limit= space->free_limit; *err= flst_remove(header, FSP_HEADER_OFFSET + FSP_SEG_INODES_FREE, - block, FSEG_INODE_PAGE_NODE, mtr); + block, FSEG_INODE_PAGE_NODE, limit, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) return nullptr; *err= flst_add_last(header, FSP_HEADER_OFFSET + FSP_SEG_INODES_FULL, - block, FSEG_INODE_PAGE_NODE, mtr); + block, FSEG_INODE_PAGE_NODE, limit, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) return nullptr; } @@ -1456,16 +1492,17 @@ static void fsp_free_seg_inode(fil_space_t *space, fseg_inode_t *inode, } const ulint physical_size= space->physical_size(); + const uint32_t limit= space->free_limit; if (ULINT_UNDEFINED == fsp_seg_inode_page_find_free(iblock->page.frame, 0, physical_size)) { /* Move the page to another list */ if (flst_remove(header, FSP_HEADER_OFFSET + FSP_SEG_INODES_FULL, - iblock, FSEG_INODE_PAGE_NODE, mtr) != DB_SUCCESS) + iblock, FSEG_INODE_PAGE_NODE, limit, mtr) != DB_SUCCESS) return; if (flst_add_last(header, FSP_HEADER_OFFSET + FSP_SEG_INODES_FREE, - iblock, FSEG_INODE_PAGE_NODE, mtr) != DB_SUCCESS) + iblock, FSEG_INODE_PAGE_NODE, limit, mtr) != DB_SUCCESS) return; } @@ -1477,7 +1514,7 @@ static void fsp_free_seg_inode(fil_space_t *space, fseg_inode_t *inode, /* There are no other used headers left on the page: free it */ if (flst_remove(header, FSP_HEADER_OFFSET + FSP_SEG_INODES_FREE, - iblock, FSEG_INODE_PAGE_NODE, mtr) == DB_SUCCESS) + iblock, FSEG_INODE_PAGE_NODE, limit, mtr) == DB_SUCCESS) fsp_free_page(space, iblock->page.id().page_no(), mtr); } @@ -1850,7 +1887,8 @@ static dberr_t fseg_fill_free_list(const fseg_inode_t *inode, static_cast(inode - iblock->page.frame + FSEG_FREE), xdes, static_cast(descr - xdes->page.frame + - XDES_FLST_NODE), mtr)) + XDES_FLST_NODE), + space->free_limit, mtr)) return err; xdes_set_state(*xdes, descr, XDES_FSEG, mtr); mtr->memcpy(*xdes, descr + XDES_ID, inode + FSEG_ID, 8); @@ -1885,11 +1923,25 @@ fseg_alloc_free_extent( ut_ad(!memcmp(FSEG_MAGIC_N_BYTES, FSEG_MAGIC_N + inode, 4)); ut_d(space->modify_check(*mtr)); + if (UNIV_UNLIKELY(page_offset(inode) < FSEG_ARR_OFFSET)) + { + corrupted: + *err= DB_CORRUPTION; + space->set_corrupted(); + return nullptr; + } + if (flst_get_len(inode + FSEG_FREE)) { + const fil_addr_t first= flst_get_first(inode + FSEG_FREE); + if (first.page >= space->free_limit || + first.boffset < FSP_HEADER_OFFSET + FSP_HEADER_SIZE || + first.boffset >= space->physical_size() - + (XDES_SIZE + FIL_PAGE_DATA_END)) + goto corrupted; + /* Segment free list is not empty, allocate from it */ - return xdes_lst_get_descriptor(*space, flst_get_first(inode + FSEG_FREE), - mtr, xdes, err); + return xdes_lst_get_descriptor(*space, first, mtr, xdes, err); } xdes_t* descr= fsp_alloc_free_extent(space, 0, xdes, mtr, err); @@ -1901,7 +1953,8 @@ fseg_alloc_free_extent( static_cast(inode - iblock->page.frame + FSEG_FREE), *xdes, static_cast(descr - (*xdes)->page.frame + - XDES_FLST_NODE), mtr); + XDES_FLST_NODE), + space->free_limit, mtr); if (UNIV_LIKELY(*err != DB_SUCCESS)) return nullptr; /* Try to fill the segment free list */ @@ -2042,7 +2095,8 @@ take_hinted_page: + FSEG_FREE), xdes, static_cast(ret_descr - xdes->page.frame - + XDES_FLST_NODE), mtr); + + XDES_FLST_NODE), + space->free_limit, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) { return nullptr; } @@ -2088,6 +2142,14 @@ take_hinted_page: return nullptr; } + if (first.page >= space->free_limit + || first.boffset < FSP_HEADER_OFFSET + FSP_HEADER_SIZE + || first.boffset >= space->physical_size() + - (XDES_SIZE + FIL_PAGE_DATA_END)) { + *err= DB_CORRUPTION; + return nullptr; + } + ret_descr = xdes_lst_get_descriptor(*space, first, mtr, &xdes); if (!ret_descr) { return nullptr; @@ -2181,8 +2243,8 @@ got_hinted_page: ut_ad(xdes == xxdes); ut_ad(xdes_is_free(ret_descr, ret_page % extent_size)); - *err = fseg_mark_page_used(seg_inode, iblock, ret_page, - ret_descr, xdes, mtr); + *err = fseg_mark_page_used(space, seg_inode, iblock, ret_page, + ret_descr, xdes, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) { return nullptr; } @@ -2524,18 +2586,19 @@ corrupted: const uint16_t xoffset= uint16_t(descr - xdes->page.frame + XDES_FLST_NODE); const uint16_t ioffset= uint16_t(seg_inode - iblock->page.frame); + const uint32_t limit = space->free_limit; if (xdes_is_full(descr)) { /* The fragment is full: move it to another list */ err = flst_remove(iblock, static_cast(FSEG_FULL + ioffset), - xdes, xoffset, mtr); + xdes, xoffset, limit, mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { return err; } err = flst_add_last(iblock, static_cast(FSEG_NOT_FULL + ioffset), - xdes, xoffset, mtr); + xdes, xoffset, limit, mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { return err; } @@ -2553,7 +2616,7 @@ corrupted: if (!xdes_get_n_used(descr)) { err = flst_remove(iblock, static_cast(FSEG_NOT_FULL + ioffset), - xdes, xoffset, mtr); + xdes, xoffset, limit, mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { return err; } @@ -2698,11 +2761,12 @@ fseg_free_extent( #endif /* BTR_CUR_HASH_ADAPT */ uint16_t lst; + uint32_t limit = space->free_limit; if (xdes_is_full(descr)) { lst = static_cast(FSEG_FULL + ioffset); remove: - err = flst_remove(iblock, lst, xdes, xoffset, mtr); + err = flst_remove(iblock, lst, xdes, xoffset, limit, mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { return err; } @@ -2712,7 +2776,7 @@ remove: } else { err = flst_remove( iblock, static_cast(FSEG_NOT_FULL + ioffset), - xdes, xoffset, mtr); + xdes, xoffset, limit, mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { return err; } @@ -2962,7 +3026,10 @@ fseg_get_first_extent( return nullptr; } - if (first.page == FIL_NULL) + if (first.page >= space->free_limit || + first.boffset < FSP_HEADER_OFFSET + FSP_HEADER_SIZE || + first.boffset >= space->physical_size() - + (XDES_SIZE + FIL_PAGE_DATA_END)) goto corrupted; return xdes_lst_get_descriptor(*space, first, mtr, nullptr, err); diff --git a/storage/innobase/fut/fut0lst.cc b/storage/innobase/fut/fut0lst.cc index a52027f28bc..48e2fbe38aa 100644 --- a/storage/innobase/fut/fut0lst.cc +++ b/storage/innobase/fut/fut0lst.cc @@ -113,17 +113,18 @@ static void flst_add_to_empty(buf_block_t *base, uint16_t boffset, } /** Insert a node after another one. -@param[in,out] base base node block -@param[in] boffset byte offset of the base node -@param[in,out] cur insert position block -@param[in] coffset byte offset of the insert position -@param[in,out] add block to be added -@param[in] aoffset byte offset of the block to be added -@param[in,out] mtr mini-transaction */ +@param base base node block +@param boffset byte offset of the base node +@param cur insert position block +@param coffset byte offset of the insert position +@param add block to be added +@param aoffset byte offset of the block to be added +@param limit fil_space_t::free_limit +@param mtr mini-transaction */ static dberr_t flst_insert_after(buf_block_t *base, uint16_t boffset, buf_block_t *cur, uint16_t coffset, buf_block_t *add, uint16_t aoffset, - mtr_t *mtr) + uint32_t limit, mtr_t *mtr) { ut_ad(base != cur || boffset != coffset); ut_ad(base != add || boffset != aoffset); @@ -139,6 +140,15 @@ static dberr_t flst_insert_after(buf_block_t *base, uint16_t boffset, MTR_MEMO_PAGE_SX_FIX)); fil_addr_t next_addr= flst_get_next_addr(cur->page.frame + coffset); + if (next_addr.page >= limit) + { + if (UNIV_UNLIKELY(next_addr.page != FIL_NULL)) + return DB_CORRUPTION; + } + else if (UNIV_UNLIKELY(next_addr.boffset < FIL_PAGE_DATA || + next_addr.boffset >= base->physical_size() - + FIL_PAGE_DATA_END)) + return DB_CORRUPTION; flst_write_addr(*add, add->page.frame + aoffset + FLST_PREV, cur->page.id().page_no(), coffset, mtr); @@ -167,18 +177,19 @@ static dberr_t flst_insert_after(buf_block_t *base, uint16_t boffset, } /** Insert a node before another one. -@param[in,out] base base node block -@param[in] boffset byte offset of the base node -@param[in,out] cur insert position block -@param[in] coffset byte offset of the insert position -@param[in,out] add block to be added -@param[in] aoffset byte offset of the block to be added -@param[in,out] mtr mini-transaction +@param base base node block +@param boffset byte offset of the base node +@param cur insert position block +@param coffset byte offset of the insert position +@param add block to be added +@param aoffset byte offset of the block to be added +@param limit fil_space_t::free_limit +@param mtr mini-transaction @return error code */ static dberr_t flst_insert_before(buf_block_t *base, uint16_t boffset, buf_block_t *cur, uint16_t coffset, buf_block_t *add, uint16_t aoffset, - mtr_t *mtr) + uint32_t limit, mtr_t *mtr) { ut_ad(base != cur || boffset != coffset); ut_ad(base != add || boffset != aoffset); @@ -194,6 +205,15 @@ static dberr_t flst_insert_before(buf_block_t *base, uint16_t boffset, MTR_MEMO_PAGE_SX_FIX)); fil_addr_t prev_addr= flst_get_prev_addr(cur->page.frame + coffset); + if (prev_addr.page >= limit) + { + if (UNIV_UNLIKELY(prev_addr.page != FIL_NULL)) + return DB_CORRUPTION; + } + else if (UNIV_UNLIKELY(prev_addr.boffset < FIL_PAGE_DATA || + prev_addr.boffset >= base->physical_size() - + FIL_PAGE_DATA_END)) + return DB_CORRUPTION; flst_write_addr(*add, add->page.frame + aoffset + FLST_PREV, prev_addr.page, prev_addr.boffset, mtr); @@ -234,14 +254,9 @@ void flst_init(const buf_block_t& block, byte *base, mtr_t *mtr) flst_zero_both(block, base + FLST_FIRST, mtr); } -/** Append a file list node to a list. -@param[in,out] base base node block -@param[in] boffset byte offset of the base node -@param[in,out] add block to be added -@param[in] aoffset byte offset of the node to be added -@param[in,outr] mtr mini-transaction */ dberr_t flst_add_last(buf_block_t *base, uint16_t boffset, - buf_block_t *add, uint16_t aoffset, mtr_t *mtr) + buf_block_t *add, uint16_t aoffset, + uint32_t limit, mtr_t *mtr) { ut_ad(base != add || boffset != aoffset); ut_ad(boffset < base->physical_size()); @@ -258,6 +273,13 @@ dberr_t flst_add_last(buf_block_t *base, uint16_t boffset, else { fil_addr_t addr= flst_get_last(base->page.frame + boffset); + if (UNIV_UNLIKELY(addr.page >= limit)) + return DB_CORRUPTION; + else if (UNIV_UNLIKELY(addr.boffset < FIL_PAGE_DATA || + addr.boffset >= base->physical_size() - + FIL_PAGE_DATA_END)) + return DB_CORRUPTION; + buf_block_t *cur= add; dberr_t err; if (addr.page != add->page.id().page_no() && @@ -266,19 +288,13 @@ dberr_t flst_add_last(buf_block_t *base, uint16_t boffset, BUF_GET_POSSIBLY_FREED, mtr, &err))) return err; return flst_insert_after(base, boffset, cur, addr.boffset, - add, aoffset, mtr); + add, aoffset, limit, mtr); } } -/** Prepend a file list node to a list. -@param[in,out] base base node block -@param[in] boffset byte offset of the base node -@param[in,out] add block to be added -@param[in] aoffset byte offset of the node to be added -@param[in,out] mtr mini-transaction -@return error code */ dberr_t flst_add_first(buf_block_t *base, uint16_t boffset, - buf_block_t *add, uint16_t aoffset, mtr_t *mtr) + buf_block_t *add, uint16_t aoffset, + uint32_t limit, mtr_t *mtr) { ut_ad(base != add || boffset != aoffset); ut_ad(boffset < base->physical_size()); @@ -296,6 +312,12 @@ dberr_t flst_add_first(buf_block_t *base, uint16_t boffset, else { fil_addr_t addr= flst_get_first(base->page.frame + boffset); + if (UNIV_UNLIKELY(addr.page >= limit)) + return DB_CORRUPTION; + else if (UNIV_UNLIKELY(addr.boffset < FIL_PAGE_DATA || + addr.boffset >= base->physical_size() - + FIL_PAGE_DATA_END)) + return DB_CORRUPTION; buf_block_t *cur= add; dberr_t err; if (addr.page != add->page.id().page_no() && @@ -304,19 +326,13 @@ dberr_t flst_add_first(buf_block_t *base, uint16_t boffset, BUF_GET_POSSIBLY_FREED, mtr, &err))) return err; return flst_insert_before(base, boffset, cur, addr.boffset, - add, aoffset, mtr); + add, aoffset, limit, mtr); } } -/** Remove a file list node. -@param[in,out] base base node block -@param[in] boffset byte offset of the base node -@param[in,out] cur block to be removed -@param[in] coffset byte offset of the current record to be removed -@param[in,out] mtr mini-transaction -@return error code */ dberr_t flst_remove(buf_block_t *base, uint16_t boffset, - buf_block_t *cur, uint16_t coffset, mtr_t *mtr) + buf_block_t *cur, uint16_t coffset, + uint32_t limit, mtr_t *mtr) { ut_ad(boffset < base->physical_size()); ut_ad(coffset < cur->physical_size()); @@ -329,9 +345,27 @@ dberr_t flst_remove(buf_block_t *base, uint16_t boffset, const fil_addr_t next_addr= flst_get_next_addr(cur->page.frame + coffset); dberr_t err= DB_SUCCESS; - if (prev_addr.page == FIL_NULL) + if (next_addr.page >= limit) + { + if (next_addr.page != FIL_NULL) + return DB_CORRUPTION; + } + else if (UNIV_UNLIKELY(next_addr.boffset < FIL_PAGE_DATA || + next_addr.boffset >= base->physical_size() - + FIL_PAGE_DATA_END)) + return DB_CORRUPTION; + + if (prev_addr.page >= limit) + { + if (prev_addr.page != FIL_NULL) + return DB_CORRUPTION; flst_write_addr(*base, base->page.frame + boffset + FLST_FIRST, next_addr.page, next_addr.boffset, mtr); + } + else if (UNIV_UNLIKELY(prev_addr.boffset < FIL_PAGE_DATA || + prev_addr.boffset >= base->physical_size() - + FIL_PAGE_DATA_END)) + return DB_CORRUPTION; else { buf_block_t *b= cur; @@ -375,25 +409,19 @@ void flst_validate(const buf_block_t *base, uint16_t boffset, mtr_t *mtr) ut_ad(mtr->memo_contains_flagged(base, MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX)); - /* We use two mini-transaction handles: the first is used to lock - the base node, and prevent other threads from modifying the list. - The second is used to traverse the list. We cannot run the second - mtr without committing it at times, because if the list is long, - the x-locked pages could fill the buffer, resulting in a deadlock. */ - mtr_t mtr2; - const uint32_t len= flst_get_len(base->page.frame + boffset); fil_addr_t addr= flst_get_first(base->page.frame + boffset); for (uint32_t i= len; i--; ) { - mtr2.start(); + ut_ad(addr.boffset >= FIL_PAGE_DATA); + ut_ad(addr.boffset < base->physical_size() - FIL_PAGE_DATA_END); const buf_block_t *b= buf_page_get_gen(page_id_t(base->page.id().space(), addr.page), base->zip_size(), RW_SX_LATCH, nullptr, BUF_GET, mtr); ut_ad(b); addr= flst_get_next_addr(b->page.frame + addr.boffset); - mtr2.commit(); + mtr->release_last_page(); } ut_ad(addr.page == FIL_NULL); @@ -402,13 +430,14 @@ void flst_validate(const buf_block_t *base, uint16_t boffset, mtr_t *mtr) for (uint32_t i= len; i--; ) { - mtr2.start(); + ut_ad(addr.boffset >= FIL_PAGE_DATA); + ut_ad(addr.boffset < base->physical_size() - FIL_PAGE_DATA_END); const buf_block_t *b= buf_page_get_gen(page_id_t(base->page.id().space(), addr.page), base->zip_size(), RW_SX_LATCH, nullptr, BUF_GET, mtr); ut_ad(b); addr= flst_get_prev_addr(b->page.frame + addr.boffset); - mtr2.commit(); + mtr->release_last_page(); } ut_ad(addr.page == FIL_NULL); diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index d627c8843a1..70824cff8a5 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1831,7 +1831,7 @@ corrupted: err = flst_add_last(ibuf_root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, - &mtr); + fil_system.sys_space->free_limit, &mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { goto corrupted; } @@ -1862,7 +1862,6 @@ Removes a page from the free list and frees it to the fsp system. */ static void ibuf_remove_free_page() { mtr_t mtr; - mtr_t mtr2; page_t* header_page; log_free_check(); @@ -1889,26 +1888,28 @@ early_exit: return; } - ibuf_mtr_start(&mtr2); - - buf_block_t* root = ibuf_tree_root_get(&mtr2); + const auto root_savepoint = mtr.get_savepoint(); + buf_block_t* root = ibuf_tree_root_get(&mtr); if (UNIV_UNLIKELY(!root)) { - ibuf_mtr_commit(&mtr2); goto early_exit; } - mysql_mutex_unlock(&ibuf_mutex); - const uint32_t page_no = flst_get_last(PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST + root->page.frame).page; + if (page_no >= fil_system.sys_space->free_limit) { + goto early_exit; + } + + mysql_mutex_unlock(&ibuf_mutex); + /* NOTE that we must release the latch on the ibuf tree root because in fseg_free_page we access level 1 pages, and the root is a level 2 page. */ - - ibuf_mtr_commit(&mtr2); + root->page.lock.u_unlock(); + mtr.lock_register(root_savepoint, MTR_MEMO_BUF_FIX); ibuf_exit(&mtr); /* Since pessimistic inserts were prevented, we know that the @@ -1931,15 +1932,7 @@ early_exit: ibuf_enter(&mtr); mysql_mutex_lock(&ibuf_mutex); - - root = ibuf_tree_root_get(&mtr, &err); - if (UNIV_UNLIKELY(!root)) { - mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); - goto func_exit; - } - - ut_ad(page_no == flst_get_last(PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST - + root->page.frame).page); + mtr.upgrade_buffer_fix(root_savepoint, RW_X_LATCH); /* Remove the page from the free list and update the ibuf size data */ if (buf_block_t* block = @@ -1948,7 +1941,7 @@ early_exit: err = flst_remove(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, - &mtr); + fil_system.sys_space->free_limit, &mtr); } mysql_mutex_unlock(&ibuf_pessimistic_insert_mutex); diff --git a/storage/innobase/include/fut0lst.h b/storage/innobase/include/fut0lst.h index 746dab80400..1adec365f2b 100644 --- a/storage/innobase/include/fut0lst.h +++ b/storage/innobase/include/fut0lst.h @@ -78,34 +78,40 @@ void flst_init(const buf_block_t &block, byte *base, mtr_t *mtr) MY_ATTRIBUTE((nonnull)); /** Append a file list node to a list. -@param[in,out] base base node block -@param[in] boffset byte offset of the base node -@param[in,out] add block to be added -@param[in] aoffset byte offset of the node to be added -@param[in,out] mtr mini-transaction +@param base base node block +@param boffset byte offset of the base node +@param add block to be added +@param aoffset byte offset of the node to be added +@param limit fil_space_t::free_limit +@param mtr mini-transaction @return error code */ dberr_t flst_add_last(buf_block_t *base, uint16_t boffset, - buf_block_t *add, uint16_t aoffset, mtr_t *mtr) + buf_block_t *add, uint16_t aoffset, + uint32_t limit, mtr_t *mtr) MY_ATTRIBUTE((nonnull, warn_unused_result)); /** Prepend a file list node to a list. -@param[in,out] base base node block -@param[in] boffset byte offset of the base node -@param[in,out] add block to be added -@param[in] aoffset byte offset of the node to be added -@param[in,out] mtr mini-transaction +@param base base node block +@param boffset byte offset of the base node +@param add block to be added +@param aoffset byte offset of the node to be added +@param limit fil_space_t::free_limit +@param mtr mini-transaction @return error code */ dberr_t flst_add_first(buf_block_t *base, uint16_t boffset, - buf_block_t *add, uint16_t aoffset, mtr_t *mtr) + buf_block_t *add, uint16_t aoffset, + uint32_t limit, mtr_t *mtr) MY_ATTRIBUTE((nonnull, warn_unused_result)); /** Remove a file list node. -@param[in,out] base base node block -@param[in] boffset byte offset of the base node -@param[in,out] cur block to be removed -@param[in] coffset byte offset of the current record to be removed -@param[in,out] mtr mini-transaction +@param base base node block +@param boffset byte offset of the base node +@param cur block to be removed +@param coffset byte offset of the current record to be removed +@param limit fil_space_t::free_limit +@param mtr mini-transaction @return error code */ dberr_t flst_remove(buf_block_t *base, uint16_t boffset, - buf_block_t *cur, uint16_t coffset, mtr_t *mtr) + buf_block_t *cur, uint16_t coffset, + uint32_t limit, mtr_t *mtr) MY_ATTRIBUTE((nonnull, warn_unused_result)); /** @return the length of a list */ @@ -117,11 +123,9 @@ inline uint32_t flst_get_len(const flst_base_node_t *base) /** @return a file address */ inline fil_addr_t flst_read_addr(const byte *faddr) { - fil_addr_t addr= { mach_read_from_4(faddr + FIL_ADDR_PAGE), - mach_read_from_2(faddr + FIL_ADDR_BYTE) }; - ut_a(addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA); - ut_a(ut_align_offset(faddr, srv_page_size) >= FIL_PAGE_DATA); - return addr; + ut_ad(ut_align_offset(faddr, srv_page_size) >= FIL_PAGE_DATA); + return fil_addr_t{mach_read_from_4(faddr + FIL_ADDR_PAGE), + mach_read_from_2(faddr + FIL_ADDR_BYTE)}; } /** @return list first node address */ diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 0f5d59ffb2d..00cd2b89e3a 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -266,7 +266,8 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr) that is known to be corrupted. */ ut_a(flst_add_first(rseg_header, TRX_RSEG + TRX_RSEG_HISTORY, undo_page, uint16_t(page_offset(undo_header) + - TRX_UNDO_HISTORY_NODE), mtr) == DB_SUCCESS); + TRX_UNDO_HISTORY_NODE), rseg->space->free_limit, + mtr) == DB_SUCCESS); mtr->write<2>(*undo_page, TRX_UNDO_SEG_HDR + TRX_UNDO_STATE + undo_page->page.frame, undo_state); @@ -356,6 +357,19 @@ inline dberr_t purge_sys_t::iterator::free_history_rseg(trx_rseg_t &rseg) const mtr_t mtr; bool freed= false; uint32_t rseg_ref= 0; + const auto last_boffset= srv_page_size - TRX_UNDO_LOG_OLD_HDR_SIZE; + /* Technically, rseg.space->free_limit is not protected by + rseg.latch, which we are holding, but rseg.space->latch. The value + that we are reading may become stale (too small) if other pages are + being allocated in this tablespace, for other rollback + segments. Nothing can be added to this rseg without holding + rseg.latch, and hence we can validate the entire file-based list + against the limit that we are reading here. + + Note: The read here may look like a data race. On none of our target + architectures this should be an actual problem, because the uint32_t + value should always fit in a register and be correctly aligned. */ + const auto last_page= rseg.space->free_limit; mtr.start(); @@ -371,13 +385,23 @@ func_exit: } hdr_addr= flst_get_last(TRX_RSEG + TRX_RSEG_HISTORY + rseg_hdr->page.frame); + + if (hdr_addr.page == FIL_NULL) + goto func_exit; + + if (hdr_addr.page >= last_page || + hdr_addr.boffset < TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE || + hdr_addr.boffset >= last_boffset) + { + corrupted: + err= DB_CORRUPTION; + goto func_exit; + } + hdr_addr.boffset= static_cast(hdr_addr.boffset - TRX_UNDO_HISTORY_NODE); loop: - if (hdr_addr.page == FIL_NULL) - goto func_exit; - buf_block_t *b= buf_page_get_gen(page_id_t(rseg.space->id, hdr_addr.page), 0, RW_X_LATCH, nullptr, BUF_GET_POSSIBLY_FREED, @@ -426,11 +450,18 @@ loop: fil_addr_t prev_hdr_addr= flst_get_prev_addr(b->page.frame + hdr_addr.boffset + TRX_UNDO_HISTORY_NODE); + if (prev_hdr_addr.page == FIL_NULL); + else if (prev_hdr_addr.page >= last_page || + prev_hdr_addr.boffset < TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE || + prev_hdr_addr.boffset >= last_boffset) + goto corrupted; + prev_hdr_addr.boffset= static_cast(prev_hdr_addr.boffset - TRX_UNDO_HISTORY_NODE); err= flst_remove(rseg_hdr, TRX_RSEG + TRX_RSEG_HISTORY, b, - uint16_t(hdr_addr.boffset + TRX_UNDO_HISTORY_NODE), &mtr); + uint16_t(hdr_addr.boffset + TRX_UNDO_HISTORY_NODE), + last_page, &mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) goto func_exit; @@ -490,6 +521,9 @@ loop: ut_ad(rseg_hdr->page.id() == rseg.page_id()); mtr.memo_push(rseg_hdr, MTR_MEMO_PAGE_X_FIX); + if (hdr_addr.page == FIL_NULL) + goto func_exit; + goto loop; } @@ -780,13 +814,17 @@ bool purge_sys_t::rseg_get_next_history_log() { const byte *log_hdr= undo_page->page.frame + rseg->last_offset(); prev_log_addr= flst_get_prev_addr(log_hdr + TRX_UNDO_HISTORY_NODE); + if (prev_log_addr.boffset < TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE || + prev_log_addr.boffset >= srv_page_size - TRX_UNDO_LOG_OLD_HDR_SIZE) + goto corrupted; prev_log_addr.boffset = static_cast(prev_log_addr.boffset - TRX_UNDO_HISTORY_NODE); } else - prev_log_addr.page= FIL_NULL; + goto corrupted; - if (prev_log_addr.page == FIL_NULL) + if (prev_log_addr.page >= rseg->space->free_limit) + corrupted: rseg->last_page_no= FIL_NULL; else { diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index 8732ae81005..86f5b064b7f 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -448,7 +448,14 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, mtr_t *mtr) { if (!rseg->space) return DB_TABLESPACE_NOT_FOUND; + + /* Access the tablespace header page to recover rseg->space->free_limit */ + page_id_t page_id{rseg->space->id, 0}; dberr_t err; + if (!buf_page_get_gen(page_id, 0, RW_S_LATCH, nullptr, BUF_GET, mtr, &err)) + return err; + mtr->release_last_page(); + page_id.set_page_no(rseg->page_no); const buf_block_t *rseg_hdr= buf_page_get_gen(rseg->page_id(), 0, RW_S_LATCH, nullptr, BUF_GET, mtr, &err); @@ -518,6 +525,11 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, mtr_t *mtr) fil_addr_t node_addr= flst_get_last(TRX_RSEG + TRX_RSEG_HISTORY + rseg_hdr->page.frame); + if (node_addr.page >= rseg->space->free_limit || + node_addr.boffset < TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE || + node_addr.boffset >= srv_page_size - TRX_UNDO_LOG_OLD_HDR_SIZE) + return DB_CORRUPTION; + node_addr.boffset= static_cast(node_addr.boffset - TRX_UNDO_HISTORY_NODE); rseg->last_page_no= node_addr.page; diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 8f1ff53e9d8..c0f5b1fb22c 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -513,7 +513,7 @@ trx_undo_seg_create(fil_space_t *space, buf_block_t *rseg_hdr, ulint *id, *err = flst_add_last(block, TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST, block, TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, - mtr); + space->free_limit, mtr); *id = slot_no; mtr->write<4>(*rseg_hdr, TRX_RSEG + TRX_RSEG_UNDO_SLOTS @@ -696,7 +696,8 @@ buf_block_t *trx_undo_add_page(trx_undo_t *undo, mtr_t *mtr, dberr_t *err) mtr->undo_create(*new_block); trx_undo_page_init(*new_block); *err= flst_add_last(header_block, TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST, - new_block, TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, mtr); + new_block, TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, + rseg->space->free_limit, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) new_block= nullptr; else @@ -747,9 +748,11 @@ trx_undo_free_page( buf_page_make_young_if_needed(&header_block->page); + const uint32_t limit = rseg->space->free_limit; + *err = flst_remove(header_block, TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST, undo_block, TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE, - mtr); + limit, mtr); if (UNIV_UNLIKELY(*err != DB_SUCCESS)) { return FIL_NULL; @@ -758,7 +761,13 @@ trx_undo_free_page( const fil_addr_t last_addr = flst_get_last( TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + header_block->page.frame); - if (UNIV_UNLIKELY(last_addr.page == page_no)) { + if (UNIV_UNLIKELY(last_addr.page == page_no) + || UNIV_UNLIKELY(last_addr.page != FIL_NULL + && last_addr.page >= limit) + || UNIV_UNLIKELY(last_addr.boffset < TRX_UNDO_PAGE_HDR + + TRX_UNDO_PAGE_NODE) + || UNIV_UNLIKELY(last_addr.boffset >= srv_page_size + - TRX_UNDO_LOG_OLD_HDR_SIZE)) { *err = DB_CORRUPTION; return FIL_NULL; } @@ -975,8 +984,8 @@ trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no) ut_ad(id < TRX_RSEG_N_SLOTS); mtr.start(); - const buf_block_t* block = buf_page_get( - page_id_t(rseg->space->id, page_no), 0, RW_X_LATCH, &mtr); + const page_id_t page_id{rseg->space->id, page_no}; + const buf_block_t* block = buf_page_get(page_id, 0, RW_X_LATCH, &mtr); if (UNIV_UNLIKELY(!block)) { corrupted: mtr.commit(); @@ -1078,6 +1087,15 @@ corrupted_type: fil_addr_t last_addr = flst_get_last( TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + block->page.frame); + if (last_addr.page >= rseg->space->free_limit + || last_addr.boffset < TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_NODE + || last_addr.boffset >= srv_page_size + - TRX_UNDO_LOG_OLD_HDR_SIZE) { + corrupted_undo: + ut_free(undo); + goto corrupted; + } + undo->last_page_no = last_addr.page; undo->top_page_no = last_addr.page; @@ -1086,8 +1104,7 @@ corrupted_type: RW_X_LATCH, &mtr); if (UNIV_UNLIKELY(!last)) { - ut_free(undo); - goto corrupted; + goto corrupted_undo; } if (const trx_undo_rec_t* rec = trx_undo_page_get_last_rec( From cac0fc97cca4d12625da4c46d7a75581adae87ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 12 Mar 2024 11:47:47 +0200 Subject: [PATCH 118/313] MDEV-32974 : Member fails to join due to old seqno in GTID Before MDEV-15158, wsrep xid information was stored in only one place: in the TRX_SYS page. Starting with 10.3, it is not stored there but in the rollback segment header pages, and the latest one is what matters. MDEV-19229 allows the undo tablespaces to be rebuilt when innodb_undo_tablespaces is changed on startup. Previously it was not possible to change that parameter. These changes caused the fact that rollback segment header pages could contain several wsrep xid's stored and when undo tablespaces were rebuilt there was a effort to restore wsrep xid back to rollback segment header page but because there was several of them the latest wsrep xid was overwritten with older one. trx_rseg_read_wsrep_checkpoint trx_rseg_init_wsrep_xid Return true if read xid is wsrep xid, false if not trx_rseg_mem_restore Try to read wsrep xid and if it is found copy it to trx_sys.recovered_wsrep_xid if read xid has larger seqno. --- .../r/galera_sst_mariabackup,debug.rdiff | 11 ++++---- .../galera/r/galera_sst_mariabackup.result | 20 ++++++++++++++ .../suite/galera/t/galera_sst_mariabackup.cnf | 5 ++++ .../galera/t/galera_sst_mariabackup.test | 27 +++++++++++++++++++ storage/innobase/trx/trx0rseg.cc | 18 +++++++++---- 5 files changed, 71 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_sst_mariabackup,debug.rdiff b/mysql-test/suite/galera/r/galera_sst_mariabackup,debug.rdiff index 3aad611cacb..9dc845499ad 100644 --- a/mysql-test/suite/galera/r/galera_sst_mariabackup,debug.rdiff +++ b/mysql-test/suite/galera/r/galera_sst_mariabackup,debug.rdiff @@ -1,6 +1,6 @@ ---- r/galera_sst_mariabackup.result -+++ r/galera_sst_mariabackup.reject -@@ -516,5 +516,189 @@ +--- galera/r/galera_sst_mariabackup.result 2024-04-11 09:53:12.950512316 +0300 ++++ galera/r/galera_sst_mariabackup,debug.reject 2024-04-11 10:00:36.771144955 +0300 +@@ -524,6 +524,190 @@ 1 DROP TABLE t1; COMMIT; @@ -188,5 +188,6 @@ +DROP TABLE t1; +COMMIT; +SET GLOBAL debug_dbug = $debug_orig; - disconnect node_2; - disconnect node_1; + connection node_2; + Shutting down server ... + connection node_1; diff --git a/mysql-test/suite/galera/r/galera_sst_mariabackup.result b/mysql-test/suite/galera/r/galera_sst_mariabackup.result index caf602c017c..374f714efb3 100644 --- a/mysql-test/suite/galera/r/galera_sst_mariabackup.result +++ b/mysql-test/suite/galera/r/galera_sst_mariabackup.result @@ -2,6 +2,14 @@ connection node_2; connection node_1; connection node_1; connection node_2; +connection node_1; +select @@innodb_undo_tablespaces; +@@innodb_undo_tablespaces +0 +connection node_2; +select @@innodb_undo_tablespaces; +@@innodb_undo_tablespaces +3 Performing State Transfer on a server that has been shut down cleanly and restarted connection node_1; CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; @@ -516,5 +524,17 @@ COUNT(*) = 0 1 DROP TABLE t1; COMMIT; +connection node_2; +Shutting down server ... +connection node_1; +connection node_2; +Starting server ... +Using --wsrep-start-position when starting mysqld ... +connection node_1; +connection node_2; +select @@innodb_undo_tablespaces; +@@innodb_undo_tablespaces +3 +call mtr.add_suppression("InnoDB: Cannot change innodb_undo_tablespaces=3 because previous shutdown was not with innodb_fast_shutdown=0"); disconnect node_2; disconnect node_1; diff --git a/mysql-test/suite/galera/t/galera_sst_mariabackup.cnf b/mysql-test/suite/galera/t/galera_sst_mariabackup.cnf index 857a4101406..6cb80831d1f 100644 --- a/mysql-test/suite/galera/t/galera_sst_mariabackup.cnf +++ b/mysql-test/suite/galera/t/galera_sst_mariabackup.cnf @@ -7,9 +7,14 @@ wsrep_debug=1 [mysqld.1] wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' +innodb_fast_shutdown=0 +innodb_undo_tablespaces=0 [mysqld.2] wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' +innodb_fast_shutdown=0 +innodb_undo_tablespaces=3 +innodb_log_file_buffering [sst] transferfmt=@ENV.MTR_GALERA_TFMT diff --git a/mysql-test/suite/galera/t/galera_sst_mariabackup.test b/mysql-test/suite/galera/t/galera_sst_mariabackup.test index bcb9ade3a25..7dead49eb98 100644 --- a/mysql-test/suite/galera/t/galera_sst_mariabackup.test +++ b/mysql-test/suite/galera/t/galera_sst_mariabackup.test @@ -8,12 +8,39 @@ --let $node_2=node_2 --source include/auto_increment_offset_save.inc +--connection node_1 +select @@innodb_undo_tablespaces; + +--connection node_2 +select @@innodb_undo_tablespaces; + --source suite/galera/include/galera_st_shutdown_slave.inc --source suite/galera/include/galera_st_clean_slave.inc --source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc +--connection node_2 +--echo Shutting down server ... +--source include/shutdown_mysqld.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +--connection node_2 +--echo Starting server ... +--source include/start_mysqld.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +--connection node_2 +select @@innodb_undo_tablespaces; + +call mtr.add_suppression("InnoDB: Cannot change innodb_undo_tablespaces=3 because previous shutdown was not with innodb_fast_shutdown=0"); + # Restore original auto_increment_offset values. --source include/auto_increment_offset_restore.inc diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index 8226e89a30c..271f5ea38ae 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -201,7 +201,7 @@ bool trx_rseg_read_wsrep_checkpoint(const buf_block_t *rseg_header, XID &xid) memcpy(xid.data, TRX_RSEG + TRX_RSEG_WSREP_XID_DATA + rseg_header->page.frame, XIDDATASIZE); - return true; + return wsrep_is_wsrep_xid(&xid); } /** Read the WSREP XID from the TRX_SYS page (in case of upgrade). @@ -237,7 +237,8 @@ static bool trx_rseg_init_wsrep_xid(const page_t* page, XID& xid) memcpy(xid.data, TRX_SYS + TRX_SYS_WSREP_XID_INFO + TRX_SYS_WSREP_XID_DATA + page, XIDDATASIZE); - return true; + + return wsrep_is_wsrep_xid(&xid); } /** Recover the latest WSREP checkpoint XID. @@ -498,10 +499,17 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, mtr_t *mtr) trx_sys.recovered_binlog_offset= binlog_offset; trx_sys.recovered_binlog_is_legacy_pos= false; } -#ifdef WITH_WSREP - trx_rseg_read_wsrep_checkpoint(rseg_hdr, trx_sys.recovered_wsrep_xid); -#endif } +#ifdef WITH_WSREP + XID tmp_xid; + tmp_xid.null(); + /* Update recovered wsrep xid only if we found wsrep xid from + rseg header page and read xid seqno is larger than currently + recovered xid seqno. */ + if (trx_rseg_read_wsrep_checkpoint(rseg_hdr, tmp_xid) && + wsrep_xid_seqno(&tmp_xid) > wsrep_xid_seqno(&trx_sys.recovered_wsrep_xid)) + trx_sys.recovered_wsrep_xid.set(&tmp_xid); +#endif } if (srv_operation == SRV_OPERATION_RESTORE) From 863f5996f25eadea6349f0133ad56f3f40e6d6af Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 10 Apr 2024 13:52:04 +0530 Subject: [PATCH 119/313] MDEV-33868 Assertion `trx->bulk_insert' failed in innodb_prepare_commit_versioned - This issue is caused by commit 188c5da72a0057e4572b1d7e4efcd0c39332a839 (MDEV-32453). InnoDB fails to end the bulk insert for the table after applying the bulk insert operation. This leads to assertion during commit process. --- .../suite/innodb/r/insert_into_empty.result | 10 ++++++++++ .../suite/innodb/t/insert_into_empty.test | 16 ++++++++++++++++ storage/innobase/row/row0merge.cc | 19 +++++++++++++------ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index 5e358ee8836..2219b6f3c31 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -478,4 +478,14 @@ INSERT INTO t VALUES (1),(1); ERROR 21000: Subquery returns more than 1 row COMMIT; DROP TABLE t; +# +# MDEV-33868 Assertion `trx->bulk_insert' failed in +# innodb_prepare_commit_versioned +# +CREATE TABLE t (id INT) ENGINE=InnoDB; +select 1 into outfile "VARDIR/tmp/t.outfile"; +BEGIN; +LOAD DATA INFILE 'VARDIR/tmp/t.outfile' INTO TABLE t; +COMMIT; +DROP TABLE t; # End of 10.11 tests diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index 3c3efc2381e..88ee2b53697 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -507,4 +507,20 @@ BEGIN; INSERT INTO t VALUES (1),(1); COMMIT; DROP TABLE t; + +--echo # +--echo # MDEV-33868 Assertion `trx->bulk_insert' failed in +--echo # innodb_prepare_commit_versioned +--echo # +CREATE TABLE t (id INT) ENGINE=InnoDB; +--replace_result $MYSQLTEST_VARDIR VARDIR +--disable_ps2_protocol +eval select 1 into outfile "$MYSQLTEST_VARDIR/tmp/t.outfile"; +--enable_ps2_protocol +BEGIN; +--replace_result $MYSQLTEST_VARDIR VARDIR +eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t.outfile' INTO TABLE t; +COMMIT; +DROP TABLE t; +--remove_file $MYSQLTEST_VARDIR/tmp/t.outfile --echo # End of 10.11 tests diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index ca9f47c8d86..465a5965b6c 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -5362,6 +5362,7 @@ void trx_t::bulk_rollback_low() low_limit= t.second.get_first(); delete t.second.bulk_store; t.second.bulk_store= nullptr; + t.second.end_bulk_insert(); } } trx_savept_t bulk_save{low_limit}; @@ -5370,13 +5371,19 @@ void trx_t::bulk_rollback_low() dberr_t trx_t::bulk_insert_apply_for_table(dict_table_t *table) { - auto t= check_bulk_buffer(table); - if (!t || !t->is_bulk_insert()) + if (UNIV_UNLIKELY(!bulk_insert)) return DB_SUCCESS; - dberr_t err= t->write_bulk(table, this); - if (err != DB_SUCCESS) - bulk_rollback_low(); - return err; + ut_ad(!check_unique_secondary); + ut_ad(!check_foreigns); + auto it= mod_tables.find(table); + if (it != mod_tables.end() && it->second.bulk_store) + if (dberr_t err= it->second.write_bulk(table, this)) + { + bulk_rollback_low(); + return err; + } + it->second.end_bulk_insert(); + return DB_SUCCESS; } dberr_t trx_t::bulk_insert_apply_low() From 8785b79763af4f8894be6124d27e885c0a5948a9 Mon Sep 17 00:00:00 2001 From: Ian Gilfillan Date: Mon, 8 Apr 2024 23:11:14 +0200 Subject: [PATCH 120/313] Update README.md --- README.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 58dbf105fb9..f721e0d9a75 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Code status: * [![Appveyor CI status](https://ci.appveyor.com/api/projects/status/4u6pexmtpuf8jq66?svg=true)](https://ci.appveyor.com/project/rasmushoj/server) ci.appveyor.com -## MariaDB: The open source relational database +## MariaDB: The innovative open source database MariaDB was designed as a drop-in replacement of MySQL(R) with more features, new storage engines, fewer bugs, and better performance. @@ -37,24 +37,14 @@ Help ----- More help is available from the Maria Discuss mailing list -https://launchpad.net/~maria-discuss, MariaDB's Zulip +https://lists.mariadb.org/postorius/lists/discuss.lists.mariadb.org/ and MariaDB's Zulip instance, https://mariadb.zulipchat.com/ -Live QA for beginner contributors ----- -MariaDB has a dedicated time each week when we answer new contributor questions live on Zulip. -From 8:00 to 10:00 UTC on Mondays, and 10:00 to 12:00 UTC on Thursdays, -anyone can ask any questions they’d like, and a live developer will be available to assist. - -New contributors can ask questions any time, but we will provide immediate feedback during that interval. - Licensing --------- *************************************************************************** -NOTE: - MariaDB is specifically available only under version 2 of the GNU General Public License (GPLv2). (I.e. Without the "any later version" clause.) This is inherited from MySQL. Please see the README file in From f131c609380a246f193ce09d8616efa6c7a159ce Mon Sep 17 00:00:00 2001 From: anson1014 <56494179+anson1014@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:20:18 -0700 Subject: [PATCH 121/313] Link beginner instructions in README.md When navigating through the existing links in the README, it is not immediately obvious where to go to find instructions in building and testing the source code. Since the README is often the first thing people see when looking at a repository, this information should be front and centre so that newcomers to the project can get setup as quickly as possible. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index f721e0d9a75..5fe95f46a6b 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,11 @@ https://mariadb.com/kb/en/mariadb-versus-mysql-compatibility/ https://mariadb.com/kb/en/new-and-old-releases/ +Getting the code, building it and testing it +--------------------------------------------------------------- + +Refer to the following guide: https://mariadb.org/get-involved/getting-started-for-developers/get-code-build-test/ which outlines how to correctly build the source code and run the MariaDB testing framework. + Help ----- From 04be12a8f5f8060869b9995898d53dc7c4cee86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 11 Apr 2024 15:51:30 +0300 Subject: [PATCH 122/313] Fix g++-14 -Wtemplate-id-cdtor --- storage/perfschema/pfs_buffer_container.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/perfschema/pfs_buffer_container.h b/storage/perfschema/pfs_buffer_container.h index d5745e76249..b5506fe0195 100644 --- a/storage/perfschema/pfs_buffer_container.h +++ b/storage/perfschema/pfs_buffer_container.h @@ -1084,8 +1084,7 @@ template class PFS_buffer_processor { public: - virtual ~PFS_buffer_processor () - {} + virtual ~PFS_buffer_processor()= default; virtual void operator()(T *element) = 0; }; From e5c9904ebaab48b42b34c79b699a3e2c5a1dd933 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 11 Apr 2024 14:53:12 +0200 Subject: [PATCH 123/313] make innodb.monitor test idempotent --- mysql-test/suite/innodb/r/monitor.result | 44 ++++++++++++++++++++++-- mysql-test/suite/innodb/t/monitor.test | 44 ++++++++++++++++++++---- 2 files changed, 78 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result index 8240c0f4321..ec160a8b4fe 100644 --- a/mysql-test/suite/innodb/r/monitor.result +++ b/mysql-test/suite/innodb/r/monitor.result @@ -213,6 +213,7 @@ icp_attempts disabled icp_no_match disabled icp_out_of_range disabled icp_match disabled +create temporary table orig_innodb_metrics as select name, enabled from information_schema.innodb_metrics; set global innodb_monitor_disable = All; select name from information_schema.innodb_metrics where enabled; name @@ -745,6 +746,43 @@ DROP TABLE t1; DROP TABLE fl2; DROP TABLE fl1; DROP TABLE fl0; -SET GLOBAL innodb_monitor_enable=default; -SET GLOBAL innodb_monitor_disable=default; -SET GLOBAL innodb_monitor_reset_all=default; +set global innodb_monitor_disable = 'adaptive\\_hash\\_p%'; +set global innodb_monitor_disable = 'adaptive\\_hash\\_r%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_batch\\_n%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_batch\\_s%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_g%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_s%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_u%'; +set global innodb_monitor_disable = 'buffer\\_f%'; +set global innodb_monitor_disable = 'buffer\\_page\\_%'; +set global innodb_monitor_disable = 'c%'; +set global innodb_monitor_disable = 'ddl%'; +set global innodb_monitor_disable = 'dml\\_reads%'; +set global innodb_monitor_disable = 'icp%'; +set global innodb_monitor_disable = 'index\\_p%'; +set global innodb_monitor_disable = 'innodb\\_di%'; +set global innodb_monitor_disable = 'innodb\\_l%'; +set global innodb_monitor_disable = 'innodb\\_m%'; +set global innodb_monitor_disable = 'lock\\_re%'; +set global innodb_monitor_disable = 'lock\\_ta%'; +set global innodb_monitor_disable = 'log%'; +set global innodb_monitor_disable = 'm%'; +set global innodb_monitor_disable = 'p%'; +set global innodb_monitor_disable = 't%'; +set global innodb_monitor_enable = 'log_padded'; +set global innodb_monitor_enable = 'log\\_w%'; +set global innodb_monitor_enable = 'trx_rseg_history_len'; +set global innodb_monitor_enable = 'trx_undo_slots_cached'; +set global innodb_monitor_enable=default; +Warnings: +Warning 1230 Default value is not defined for this set option. Please specify correct counter or module name. +set global innodb_monitor_disable=default; +Warnings: +Warning 1230 Default value is not defined for this set option. Please specify correct counter or module name. +set global innodb_monitor_reset_all=default; +Warnings: +Warning 1230 Default value is not defined for this set option. Please specify correct counter or module name. +select name, orig.enabled, new.enabled from +orig_innodb_metrics orig join information_schema.innodb_metrics new using(name) +where orig.enabled != new.enabled; +name enabled enabled diff --git a/mysql-test/suite/innodb/t/monitor.test b/mysql-test/suite/innodb/t/monitor.test index b07f2d32daa..a39e5982b79 100644 --- a/mysql-test/suite/innodb/t/monitor.test +++ b/mysql-test/suite/innodb/t/monitor.test @@ -5,11 +5,11 @@ # sys_vars.innodb_monitor_enable_basic --source include/have_innodb.inc -# Test turn on/off the monitor counter with "all" option -# By default, they will be off. select name, if(enabled,'enabled','disabled') status from information_schema.innodb_metrics; +create temporary table orig_innodb_metrics as select name, enabled from information_schema.innodb_metrics; + set global innodb_monitor_disable = All; select name from information_schema.innodb_metrics where enabled; @@ -557,8 +557,38 @@ DROP TABLE fl2; DROP TABLE fl1; DROP TABLE fl0; ---disable_warnings -SET GLOBAL innodb_monitor_enable=default; -SET GLOBAL innodb_monitor_disable=default; -SET GLOBAL innodb_monitor_reset_all=default; ---enable_warnings +set global innodb_monitor_disable = 'adaptive\\_hash\\_p%'; +set global innodb_monitor_disable = 'adaptive\\_hash\\_r%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_batch\\_n%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_batch\\_s%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_g%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_s%'; +set global innodb_monitor_disable = 'buffer\\_LRU\\_u%'; +set global innodb_monitor_disable = 'buffer\\_f%'; +set global innodb_monitor_disable = 'buffer\\_page\\_%'; +set global innodb_monitor_disable = 'c%'; +set global innodb_monitor_disable = 'ddl%'; +set global innodb_monitor_disable = 'dml\\_reads%'; +set global innodb_monitor_disable = 'icp%'; +set global innodb_monitor_disable = 'index\\_p%'; +set global innodb_monitor_disable = 'innodb\\_di%'; +set global innodb_monitor_disable = 'innodb\\_l%'; +set global innodb_monitor_disable = 'innodb\\_m%'; +set global innodb_monitor_disable = 'lock\\_re%'; +set global innodb_monitor_disable = 'lock\\_ta%'; +set global innodb_monitor_disable = 'log%'; +set global innodb_monitor_disable = 'm%'; +set global innodb_monitor_disable = 'p%'; +set global innodb_monitor_disable = 't%'; +set global innodb_monitor_enable = 'log_padded'; +set global innodb_monitor_enable = 'log\\_w%'; +set global innodb_monitor_enable = 'trx_rseg_history_len'; +set global innodb_monitor_enable = 'trx_undo_slots_cached'; + +set global innodb_monitor_enable=default; +set global innodb_monitor_disable=default; +set global innodb_monitor_reset_all=default; + +select name, orig.enabled, new.enabled from + orig_innodb_metrics orig join information_schema.innodb_metrics new using(name) + where orig.enabled != new.enabled; From 340d93a8ccb7de2747dc0d267ad7dc8cc1745a5d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 11 Apr 2024 15:06:39 +0200 Subject: [PATCH 124/313] cleanup: rpl.rpl_semi_sync_shutdown_await_ack avoid using multiple files with the same functionality. --- .../rpl/r/rpl_semi_sync_shutdown_await_ack.result | 4 ++-- .../rpl/t/rpl_semi_sync_shutdown_await_ack.test | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_shutdown_await_ack.result b/mysql-test/suite/rpl/r/rpl_semi_sync_shutdown_await_ack.result index a8e158a25e4..3048b6b5635 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_shutdown_await_ack.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_shutdown_await_ack.result @@ -505,8 +505,8 @@ disconnect con1; connection default; connection con2; SHUTDOWN WAIT FOR ALL SLAVES; -connection server_2; -include/assert_grep.inc [Ensure the primary waited for the ACK of the killed thread] +# Ensure the primary waited for the ACK of the killed thread +FOUND 5 /Delaying shutdown to await semi-sync ACK/ in mysqld.1.err connection default; connection server_1; connection server_2; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.test b/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.test index c321f2bf72f..4ed9ca0aa7c 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.test @@ -206,7 +206,6 @@ SET GLOBAL debug_dbug="+d,simulate_delay_semisync_slave_reply"; --echo # Wait for thd to begin semi-sync wait.. --let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state = 'Waiting for semi-sync ACK from slave' --source include/wait_condition.inc ---source include/wait_condition.inc --echo # ..done --disconnect con1 @@ -220,15 +219,10 @@ EOF SHUTDOWN WAIT FOR ALL SLAVES; --source include/wait_until_disconnected.inc -# Run assert_grep on server_2 as it uses SQL commands for verification, but -# server_1 has gone away ---connection server_2 ---let $assert_text= Ensure the primary waited for the ACK of the killed thread ---let $assert_select= Delaying shutdown to await semi-sync ACK ---let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err ---let $assert_count= 5 ---let $assert_only_after=CURRENT_TEST ---source include/assert_grep.inc +--echo # Ensure the primary waited for the ACK of the killed thread +--let $SEARCH_PATTERN= Delaying shutdown to await semi-sync ACK +--let $SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err +--source include/search_pattern_in_file.inc --connection default --source include/wait_until_disconnected.inc From a6aecbb036a0511c9275b0aa31e5d33126d26971 Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Thu, 11 Apr 2024 09:48:07 -0600 Subject: [PATCH 125/313] MDEV-10684: rpl.rpl_domain_id_filter_restart fails in buildbot The test failure in rpl.rpl_domain_id_filter_restart is caused by MDEV-33887. That is, the test uses master_pos_wait() (called indirectly by sync_slave_with_master) to try and wait for the replica to catch up to the master. However, the waited on transaction is ignored by the configured CHANGE MASTER TO IGNORE_DOMAIN_IDS=() As MDEV-33887 reports, due to the IO thread updating the binlog coordinates and the SQL thread updating the GTID state, if the replica is stopped in-between these updates, the replica state will be inconsistent. That is, the test expects that the GTID state will be updated, so upon restart, the replica will be up-to-date. However, if the replica is stopped before the SQL thread updates its GTID state, then upon restart, the replica will fetch the previously ignored event, which is no longer ignored upon restart, and execute it. This leads to the sporadic extra row in t2. This patch changes master_pos_wait() to use master_gtid_wait() to ensure the replica state is consistent with the master state. --- mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result | 3 ++- mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result index f6eff3f9efc..948b4f48737 100644 --- a/mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result +++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_restart.result @@ -21,8 +21,9 @@ INSERT INTO t2 VALUES(1); SELECT * FROM t2; i 1 +include/save_master_gtid.inc connection slave; -connection slave; +include/sync_with_master_gtid.inc SELECT * FROM t1; i 1 diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test index 8083b8f232f..38cbbdec7f3 100644 --- a/mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test +++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_restart.test @@ -35,9 +35,10 @@ SET @@session.gtid_domain_id= 1; INSERT INTO t2 VALUES(1); SELECT * FROM t2; -sync_slave_with_master; +source include/save_master_gtid.inc; connection slave; +source include/sync_with_master_gtid.inc; SELECT * FROM t1; SELECT * FROM t2; From 8dda6027019c93fb58d34095cb15908cdfa209e6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 11 Apr 2024 21:00:39 +0200 Subject: [PATCH 126/313] spider should suppress errors in close_connection because stmt_da no longer expects errors at this stage, but mysql_close() call can still hit my_error() in net_serv.cc --- storage/spider/mysql-test/spider/include/clean_up_spider.inc | 1 - storage/spider/spd_table.cc | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/spider/mysql-test/spider/include/clean_up_spider.inc b/storage/spider/mysql-test/spider/include/clean_up_spider.inc index 1c977bfb66f..249606ec774 100644 --- a/storage/spider/mysql-test/spider/include/clean_up_spider.inc +++ b/storage/spider/mysql-test/spider/include/clean_up_spider.inc @@ -3,7 +3,6 @@ DROP FUNCTION spider_copy_tables; DROP FUNCTION spider_ping_table; DROP FUNCTION spider_bg_direct_sql; DROP FUNCTION spider_direct_sql; ---replace_regex /\.dll/.so/ UNINSTALL SONAME IF EXISTS 'ha_spider'; DROP TABLE IF EXISTS mysql.spider_xa; DROP TABLE IF EXISTS mysql.spider_xa_member; diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 9defa33c8f1..27f11a8d96c 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -6813,7 +6813,11 @@ int spider_close_connection( } spider_rollback(spider_hton_ptr, thd, TRUE); + + Dummy_error_handler deh; // suppress network errors at this stage + thd->push_internal_handler(&deh); spider_free_trx(trx, TRUE, false); + thd->pop_internal_handler(); DBUG_RETURN(0); } From d7fc975cfe3326c7cdbc188250a8a0bed9d9968d Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Tue, 2 Apr 2024 20:45:29 +0300 Subject: [PATCH 127/313] MDEV-33802 Weird read view after ROLLBACK of other transactions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the case if some unique key fields are nullable, there can be several records with the same key fields in unique index with at least one key field equal to NULL, as NULL != NULL. When transaction is resumed after waiting on the record with at least one key field equal to NULL, and stored in persistent cursor record is deleted, persistent cursor can be restored to the record with all key fields equal to the stored ones, but with at least one field equal to NULL. And such record is wrongly treated as a record with the same unique key as stored in persistent cursor record one, what is wrong as NULL != NULL. The fix is to check if at least one unique field is NULL in restored persistent cursor position, and, if so, then don't treat the record as one with the same unique key as in the stored record key. dict_index_t::nulls_equal was removed, as it was initially developed for never existed in MariaDB "intrinsic tables", and there is no code, which would set it to "true". Reviewed by Marko Mäkelä. --- .../r/cursor-restore-unique-null.result | 24 +++++++++++++ .../innodb/t/cursor-restore-unique-null.test | 36 +++++++++++++++++++ storage/innobase/btr/btr0pcur.cc | 11 ++++-- storage/innobase/dict/dict0dict.cc | 1 - storage/innobase/include/data0data.h | 13 +++---- storage/innobase/include/data0data.inl | 30 ++++++---------- storage/innobase/include/dict0mem.h | 2 -- storage/innobase/include/dict0mem.inl | 1 - storage/innobase/row/row0ins.cc | 14 ++------ 9 files changed, 87 insertions(+), 45 deletions(-) create mode 100644 mysql-test/suite/innodb/r/cursor-restore-unique-null.result create mode 100644 mysql-test/suite/innodb/t/cursor-restore-unique-null.test diff --git a/mysql-test/suite/innodb/r/cursor-restore-unique-null.result b/mysql-test/suite/innodb/r/cursor-restore-unique-null.result new file mode 100644 index 00000000000..b5e2de88e7a --- /dev/null +++ b/mysql-test/suite/innodb/r/cursor-restore-unique-null.result @@ -0,0 +1,24 @@ +CREATE TABLE t(a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `b_c` (`b`,`c`)) +ENGINE=InnoDB, STATS_PERSISTENT=0; +INSERT INTO t SET a = 1, c = 2; +connect con1,localhost,root; +BEGIN; +INSERT INTO t SET a=2, c=2; +connection default; +BEGIN; +SET DEBUG_SYNC="lock_wait_suspend_thread_enter SIGNAL select_locked"; +SELECT * FROM t FORCE INDEX(b) FOR UPDATE; +connection con1; +SET DEBUG_SYNC="now WAIT_FOR select_locked"; +ROLLBACK; +connection default; +# If the bug is not fixed, and the both unique index key fields are +# NULL, there will be two (1, NULL, 2) rows in the result, +# because cursor will be restored to (NULL, 2, 1) position for +# secondary key instead of "supremum". +a b c +1 NULL 2 +COMMIT; +SET DEBUG_SYNC="RESET"; +disconnect con1; +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/cursor-restore-unique-null.test b/mysql-test/suite/innodb/t/cursor-restore-unique-null.test new file mode 100644 index 00000000000..c22ddf89d8f --- /dev/null +++ b/mysql-test/suite/innodb/t/cursor-restore-unique-null.test @@ -0,0 +1,36 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/count_sessions.inc + + +CREATE TABLE t(a INT PRIMARY KEY, b INT, c INT, UNIQUE KEY `b_c` (`b`,`c`)) + ENGINE=InnoDB, STATS_PERSISTENT=0; +INSERT INTO t SET a = 1, c = 2; + +--connect con1,localhost,root +BEGIN; + INSERT INTO t SET a=2, c=2; + +--connection default +BEGIN; +SET DEBUG_SYNC="lock_wait_suspend_thread_enter SIGNAL select_locked"; +--send SELECT * FROM t FORCE INDEX(b) FOR UPDATE + +--connection con1 +SET DEBUG_SYNC="now WAIT_FOR select_locked"; +ROLLBACK; + +--connection default +--echo # If the bug is not fixed, and the both unique index key fields are +--echo # NULL, there will be two (1, NULL, 2) rows in the result, +--echo # because cursor will be restored to (NULL, 2, 1) position for +--echo # secondary key instead of "supremum". +--reap +COMMIT; + +SET DEBUG_SYNC="RESET"; + +--disconnect con1 +DROP TABLE t; +--source include/wait_until_count_sessions.inc diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index 90084ef4379..4296d94fe5e 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -453,8 +453,15 @@ btr_pcur_t::restore_position(ulint restore_latch_mode, const char *file, return SAME_ALL; } - if (n_matched_fields >= index->n_uniq) - ret_val= SAME_UNIQ; + if (n_matched_fields >= index->n_uniq + /* Unique indexes can contain "NULL" keys, and if all + unique fields are NULL and not all tuple + fields match to record fields, then treat it as if + restored cursor position points to the record with + not the same unique key. */ + && !(index->n_nullable + && dtuple_contains_null(tuple, index->n_uniq))) + ret_val= SAME_UNIQ; } mem_heap_free(heap); diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index d0f8ac21dd8..26671d85b3d 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1849,7 +1849,6 @@ dict_index_add_to_cache( new_index->n_fields = new_index->n_def; new_index->trx_id = index->trx_id; new_index->set_committed(index->is_committed()); - new_index->nulls_equal = index->nulls_equal; #ifdef MYSQL_INDEX_DISABLE_AHI new_index->disable_ahi = index->disable_ahi; #endif diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index c2b8c3e00b6..a2c39ecaed8 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -349,15 +349,12 @@ dtuple_set_types_binary( dtuple_t* tuple, /*!< in: data tuple */ ulint n) /*!< in: number of fields to set */ MY_ATTRIBUTE((nonnull)); -/**********************************************************************//** -Checks if a dtuple contains an SQL null value. -@return TRUE if some field is SQL null */ +/** Checks if a dtuple contains an SQL null value. +@param tuple tuple +@param fields_number number of fields in the tuple to check +@return true if some field is SQL null */ UNIV_INLINE -ibool -dtuple_contains_null( -/*=================*/ - const dtuple_t* tuple) /*!< in: dtuple */ - MY_ATTRIBUTE((nonnull, warn_unused_result)); +bool dtuple_contains_null(const dtuple_t *tuple, ulint fields_number = 0); /**********************************************************//** Checks that a data field is typed. Asserts an error if not. @return TRUE if ok */ diff --git a/storage/innobase/include/data0data.inl b/storage/innobase/include/data0data.inl index 39ade7b1e09..f4ae7528d3f 100644 --- a/storage/innobase/include/data0data.inl +++ b/storage/innobase/include/data0data.inl @@ -599,28 +599,18 @@ data_write_sql_null( memset(data, 0, len); } -/**********************************************************************//** -Checks if a dtuple contains an SQL null value. -@return TRUE if some field is SQL null */ +/** Checks if a dtuple contains an SQL null value. +@param tuple tuple +@param fields_number number of fields in the tuple to check +@return true if some field is SQL null */ UNIV_INLINE -ibool -dtuple_contains_null( -/*=================*/ - const dtuple_t* tuple) /*!< in: dtuple */ +bool dtuple_contains_null(const dtuple_t *tuple, ulint fields_number) { - ulint n; - ulint i; - - n = dtuple_get_n_fields(tuple); - - for (i = 0; i < n; i++) { - if (dfield_is_null(dtuple_get_nth_field(tuple, i))) { - - return(TRUE); - } - } - - return(FALSE); + ulint n= fields_number ? fields_number : dtuple_get_n_fields(tuple); + for (ulint i= 0; i < n; i++) + if (dfield_is_null(dtuple_get_nth_field(tuple, i))) + return true; + return false; } /**************************************************************//** diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index f0d4eb7bebf..d81bbb51b43 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1011,8 +1011,6 @@ struct dict_index_t { /*!< number of columns the user defined to be in the index: in the internal representation we add more columns */ - unsigned nulls_equal:1; - /*!< if true, SQL NULL == SQL NULL */ #ifdef BTR_CUR_HASH_ADAPT #ifdef MYSQL_INDEX_DISABLE_AHI unsigned disable_ahi:1; diff --git a/storage/innobase/include/dict0mem.inl b/storage/innobase/include/dict0mem.inl index 090ec73278b..28900c9062f 100644 --- a/storage/innobase/include/dict0mem.inl +++ b/storage/innobase/include/dict0mem.inl @@ -63,7 +63,6 @@ dict_mem_fill_index_struct( index->n_core_fields = (unsigned int) n_fields; /* The '1 +' above prevents allocation of an empty mem block */ - index->nulls_equal = false; #ifdef BTR_CUR_HASH_ADAPT #ifdef MYSQL_INDEX_DISABLE_AHI index->disable_ahi = false; diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 088981e5b5b..6e68f46825a 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2038,7 +2038,7 @@ row_ins_dupl_error_with_rec( /* In a unique secondary index we allow equal key values if they contain SQL NULLs */ - if (!dict_index_is_clust(index) && !index->nulls_equal) { + if (!dict_index_is_clust(index)) { for (i = 0; i < n_unique; i++) { if (dfield_is_null(dtuple_get_nth_field(entry, i))) { @@ -2143,16 +2143,8 @@ row_ins_scan_sec_index_for_duplicate( /* If the secondary index is unique, but one of the fields in the n_unique first fields is NULL, a unique key violation cannot occur, since we define NULL != NULL in this case */ - - if (!index->nulls_equal) { - for (ulint i = 0; i < n_unique; i++) { - if (UNIV_SQL_NULL == dfield_get_len( - dtuple_get_nth_field(entry, i))) { - - DBUG_RETURN(DB_SUCCESS); - } - } - } + if (index->n_nullable && dtuple_contains_null(entry, n_unique)) + DBUG_RETURN(DB_SUCCESS); /* Store old value on n_fields_cmp */ From dd639985c179e484115bfabd83dbbd2c4ab3f392 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Fri, 8 Mar 2024 22:56:14 +0000 Subject: [PATCH 128/313] Simplify MTR for handling multiple invalid options In 69a4d6ae, an MTR test was added to verify that we handled multiple invalid options. However, the logic to perform this test relied on a non-trivial regex to filter out the noise in the logs. Instead, we now just simply search for what we expect to be in the logs. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- mysql-test/main/mysqld_option_err.result | 12 ++++++------ mysql-test/main/mysqld_option_err.test | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mysql-test/main/mysqld_option_err.result b/mysql-test/main/mysqld_option_err.result index e2c7b0bd213..13a004b77d1 100644 --- a/mysql-test/main/mysqld_option_err.result +++ b/mysql-test/main/mysqld_option_err.result @@ -4,13 +4,13 @@ Test bad default storage engine. Test non-numeric value passed to number option. Test that bad value for plugin enum option is rejected correctly. Test to see if multiple unknown options will be displayed in the error output -unknown option '--nonexistentoption' -unknown option '--alsononexistent' -unknown variable 'nonexistentvariable=1' +FOUND 1 /unknown option '--nonexistentoption2'/ in mysqltest.log +FOUND 1 /unknown option '--alsononexistent'/ in mysqltest.log +FOUND 1 /unknown variable 'nonexistentvariable=1'/ in mysqltest.log Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output -Error while setting value 'invalid_value' to 'sql_mode' -ambiguous option '--character' (character-set-client-handshake, character_sets_dir) -option '--bootstrap' cannot take an argument +FOUND 1 /Error while setting value 'invalid_value' to 'sql_mode'/ in mysqltest.log +FOUND 1 /ambiguous option '--character'/ in mysqltest.log +FOUND 1 /option '--bootstrap' cannot take an argument/ in mysqltest.log Test that --help --verbose works Test that --not-known-option --help --verbose gives error Done. diff --git a/mysql-test/main/mysqld_option_err.test b/mysql-test/main/mysqld_option_err.test index ad4df61b0f8..2c77b868ebf 100644 --- a/mysql-test/main/mysqld_option_err.test +++ b/mysql-test/main/mysqld_option_err.test @@ -46,17 +46,29 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --error 7 --exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --plugin-dir=$MYSQLTEST_VARDIR/plugins --plugin-load=example=ha_example.so --plugin-example-enum-var=noexist >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 +--let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log + --echo Test to see if multiple unknown options will be displayed in the error output -# Remove the noise to make the test robust ---replace_regex /^((?!nonexistent).)*$// /.*unknown/unknown/ --error 7 ---exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --nonexistentoption --alsononexistent --nonexistentvariable=1 2>&1 +--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --nonexistentoption2 --alsononexistent --nonexistentvariable=1 >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + +--let SEARCH_PATTERN=unknown option '--nonexistentoption2' +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=unknown option '--alsononexistent' +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=unknown variable 'nonexistentvariable=1' +--source include/search_pattern_in_file.inc --echo Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output -# Remove the noise to make the test robust ---replace_regex /^((?!('sql_mode'|'--character'|'--bootstrap')).)*$// /.*Error while setting value/Error while setting value/ /.*ambiguous option/ambiguous option/ /.*option '--bootstrap'/option '--bootstrap'/ --error 1 ---exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob 2>&1 +--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 + +--let SEARCH_PATTERN=Error while setting value 'invalid_value' to 'sql_mode' +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=ambiguous option '--character' +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=option '--bootstrap' cannot take an argument +--source include/search_pattern_in_file.inc # # Test that an wrong option with --help --verbose gives an error From 47d75cdd80133c4e488d293533a124defd645040 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Sun, 25 Feb 2024 02:03:44 +0000 Subject: [PATCH 129/313] MDEV-33469 Fix behavior on invalid arguments When passing in an invalid value (e.g. incorrect data type) for a variable, the server startup will fail with misleading error messages. The behavior **before** this change: For server options: - The error message will indicate that the argument is being adjusted to a valid value - Server startup still fails For plugin options: - The error message will indicate that the argument is being adjusted to a valid value - The plugin is still disabled - Server startup fails with a message that it does not recognize the plugin option The behavior **after** this change: For server options: - Output that an invalid argument was provided - Exit server startup For plugin options: - Output that an invalid argument was provided - Disable the plugin - Attempt to continue server startup All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- mysql-test/main/mysqld_option_err.result | 2 ++ mysql-test/main/mysqld_option_err.test | 6 +++++- mysys/my_getopt.c | 6 +++++- sql/sql_plugin.cc | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/mysqld_option_err.result b/mysql-test/main/mysqld_option_err.result index 13a004b77d1..2ad24ffe195 100644 --- a/mysql-test/main/mysqld_option_err.result +++ b/mysql-test/main/mysqld_option_err.result @@ -11,6 +11,8 @@ Test to see if multiple ambiguous options and invalid arguments will be displaye FOUND 1 /Error while setting value 'invalid_value' to 'sql_mode'/ in mysqltest.log FOUND 1 /ambiguous option '--character'/ in mysqltest.log FOUND 1 /option '--bootstrap' cannot take an argument/ in mysqltest.log +FOUND 1 /Incorrect integer value: '18446744073709551616'/ in mysqltest.log +FOUND 1 /Error while setting value '18446744073709551616' to 'binlog_cache_size'/ in mysqltest.log Test that --help --verbose works Test that --not-known-option --help --verbose gives error Done. diff --git a/mysql-test/main/mysqld_option_err.test b/mysql-test/main/mysqld_option_err.test index 2c77b868ebf..e89eba33199 100644 --- a/mysql-test/main/mysqld_option_err.test +++ b/mysql-test/main/mysqld_option_err.test @@ -61,7 +61,7 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --echo Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output --error 1 ---exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 +--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob --binlog_cache_size=18446744073709551616 >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 --let SEARCH_PATTERN=Error while setting value 'invalid_value' to 'sql_mode' --source include/search_pattern_in_file.inc @@ -69,6 +69,10 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=option '--bootstrap' cannot take an argument --source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=Incorrect integer value: '18446744073709551616' +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=Error while setting value '18446744073709551616' to 'binlog_cache_size' +--source include/search_pattern_in_file.inc # # Test that an wrong option with --help --verbose gives an error diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index be8a89d2b08..e67407ca188 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -133,7 +133,7 @@ double getopt_ulonglong2double(ulonglong v) return u.dbl; } -#define SET_HO_ERROR_AND_CONTINUE(e) { ho_error= (e); continue; } +#define SET_HO_ERROR_AND_CONTINUE(e) { ho_error= (e); (*argc)--; continue; } /** Handle command line options. @@ -1077,6 +1077,8 @@ static ulonglong eval_num_suffix_ull(char *argument, static longlong getopt_ll(char *arg, const struct my_option *optp, int *err) { longlong num=eval_num_suffix_ll(arg, err, (char*) optp->name); + if (*err) + return(0); return getopt_ll_limit_value(num, optp, NULL); } @@ -1154,6 +1156,8 @@ longlong getopt_ll_limit_value(longlong num, const struct my_option *optp, static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err) { ulonglong num= eval_num_suffix_ull(arg, err, (char*) optp->name); + if (*err) + return(0); return getopt_ull_limit_value(num, optp, NULL); } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 84ea95305ba..979407bf3ea 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -4258,7 +4258,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, if (unlikely(error)) { - sql_print_error("Parsing options for plugin '%s' failed.", + sql_print_error("Parsing options for plugin '%s' failed. Disabling plugin", tmp->name.str); goto err; } From 79706fd386ac29f85b13e906b55b70fe2d4b5ae2 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Fri, 8 Mar 2024 23:53:24 +0000 Subject: [PATCH 130/313] Minor improvements to options error handling - Add additional MTRs for more coverage on invalid options - Updating a few error messages to be more informative - Use the exit code from handle_options() when there is an error processing user options All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- mysql-test/main/mysqld_option_err.result | 4 +++- mysql-test/main/mysqld_option_err.test | 14 ++++++++----- mysys/my_getopt.c | 26 +++++++++++++----------- sql/mysqld.cc | 5 +++-- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/mysql-test/main/mysqld_option_err.result b/mysql-test/main/mysqld_option_err.result index 2ad24ffe195..e740cb7631b 100644 --- a/mysql-test/main/mysqld_option_err.result +++ b/mysql-test/main/mysqld_option_err.result @@ -11,8 +11,10 @@ Test to see if multiple ambiguous options and invalid arguments will be displaye FOUND 1 /Error while setting value 'invalid_value' to 'sql_mode'/ in mysqltest.log FOUND 1 /ambiguous option '--character'/ in mysqltest.log FOUND 1 /option '--bootstrap' cannot take an argument/ in mysqltest.log -FOUND 1 /Incorrect integer value: '18446744073709551616'/ in mysqltest.log +FOUND 1 /Integer value out of range for uint64: '18446744073709551616'/ in mysqltest.log FOUND 1 /Error while setting value '18446744073709551616' to 'binlog_cache_size'/ in mysqltest.log +FOUND 1 /Unknown suffix 'y' used for variable 'bulk_insert_buffer_size' \(value '123y'\). Legal suffix characters are: K, M, G, T, P, E/ in mysqltest.log +FOUND 1 /Error while setting value '123y' to 'bulk_insert_buffer_size'/ in mysqltest.log Test that --help --verbose works Test that --not-known-option --help --verbose gives error Done. diff --git a/mysql-test/main/mysqld_option_err.test b/mysql-test/main/mysqld_option_err.test index e89eba33199..88c53794f53 100644 --- a/mysql-test/main/mysqld_option_err.test +++ b/mysql-test/main/mysqld_option_err.test @@ -25,7 +25,7 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --echo Test bad binlog format. ---error 1 +--error 13 --exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --log-bin --binlog-format=badformat >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 @@ -35,7 +35,7 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --echo Test non-numeric value passed to number option. ---error 1 +--error 9 --exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --min-examined-row-limit=notanumber >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 @@ -60,8 +60,8 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --source include/search_pattern_in_file.inc --echo Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output ---error 1 ---exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob --binlog_cache_size=18446744073709551616 >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 +--error 9 +--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob --binlog_cache_size=18446744073709551616 --bulk_insert_buffer_size=123y >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 --let SEARCH_PATTERN=Error while setting value 'invalid_value' to 'sql_mode' --source include/search_pattern_in_file.inc @@ -69,10 +69,14 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=option '--bootstrap' cannot take an argument --source include/search_pattern_in_file.inc ---let SEARCH_PATTERN=Incorrect integer value: '18446744073709551616' +--let SEARCH_PATTERN=Integer value out of range for uint64: '18446744073709551616' --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=Error while setting value '18446744073709551616' to 'binlog_cache_size' --source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=Unknown suffix 'y' used for variable 'bulk_insert_buffer_size' \(value '123y'\). Legal suffix characters are: K, M, G, T, P, E +--source include/search_pattern_in_file.inc +--let SEARCH_PATTERN=Error while setting value '123y' to 'bulk_insert_buffer_size' +--source include/search_pattern_in_file.inc # # Test that an wrong option with --help --verbose gives an error diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index e67407ca188..bed80d3efe2 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -858,7 +858,7 @@ static int setval(const struct my_option *opts, void *value, char *argument, } if (err) { - res= EXIT_UNKNOWN_SUFFIX; + res= err; goto ret; }; } @@ -992,7 +992,7 @@ static inline ulonglong eval_num_suffix(char *suffix, int *error) case 'E': return 1ULL << 60; default: - *error= 1; + *error= EXIT_UNKNOWN_SUFFIX; return 0ULL; } } @@ -1018,15 +1018,16 @@ static longlong eval_num_suffix_ll(char *argument, if (errno == ERANGE) { my_getopt_error_reporter(ERROR_LEVEL, - "Incorrect integer value: '%s'", argument); - *error= 1; + "Integer value out of range for int64: '%s'", argument); + *error= EXIT_ARGUMENT_INVALID; DBUG_RETURN(0); } num*= eval_num_suffix(endchar, error); if (*error) - fprintf(stderr, - "Unknown suffix '%c' used for variable '%s' (value '%s')\n", - *endchar, option_name, argument); + my_getopt_error_reporter(ERROR_LEVEL, + "Unknown suffix '%c' used for variable '%s' (value '%s'). " + "Legal suffix characters are: K, M, G, T, P, E", + *endchar, option_name, argument); DBUG_RETURN(num); } @@ -1050,15 +1051,16 @@ static ulonglong eval_num_suffix_ull(char *argument, if (errno == ERANGE) { my_getopt_error_reporter(ERROR_LEVEL, - "Incorrect integer value: '%s'", argument); - *error= 1; + "Integer value out of range for uint64: '%s'", argument); + *error= EXIT_ARGUMENT_INVALID; DBUG_RETURN(0); } num*= eval_num_suffix(endchar, error); if (*error) - fprintf(stderr, - "Unknown suffix '%c' used for variable '%s' (value '%s')\n", - *endchar, option_name, argument); + my_getopt_error_reporter(ERROR_LEVEL, + "Unknown suffix '%c' used for variable '%s' (value '%s'). " + "Legal suffix characters are: K, M, G, T, P, E", + *endchar, option_name, argument); DBUG_RETURN(num); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5ba51bdfb74..128899cb347 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3860,8 +3860,9 @@ static int init_common_variables() SQLCOM_END + 11); #endif - if (get_options(&remaining_argc, &remaining_argv)) - exit(1); + int opt_err; + if ((opt_err= get_options(&remaining_argc, &remaining_argv))) + exit(opt_err); if (IS_SYSVAR_AUTOSIZE(&server_version_ptr)) set_server_version(server_version, sizeof(server_version)); From 69b5fdf32a7f4a51b8bd28a29fd1d7cbc696e5ad Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 11 Apr 2024 16:19:13 +0200 Subject: [PATCH 131/313] galera/suite.pm: perl warning Unescaped left brace in regex is passed through in regex --- mysql-test/suite/galera/suite.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index d09cb89df5c..4c4d26db4c5 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -1,5 +1,6 @@ package My::Suite::Galera; +use warnings; use lib 'suite'; use wsrep::common; @@ -63,7 +64,7 @@ push @::global_suppressions, qr(WSREP: Failed to remove page file .*), qr(WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to .*), qr|WSREP: Sending JOIN failed: -107 \(Transport endpoint is not connected\). Will retry in new primary component.|, - qr|WSREP: Send action {.* STATE_REQUEST} returned -107 \(Transport endpoint is not connected\)|, + qr|WSREP: Send action \{.* STATE_REQUEST} returned -107 \(Transport endpoint is not connected\)|, qr|WSREP: Trying to continue unpaused monitor|, qr|WSREP: Wait for gtid returned error 3 while waiting for prior transactions to commit before setting position|, qr|WSREP: Failed to report last committed|, From 6a4ac4c72d41cb2edbcc5ff27c354783afce2c1a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 13 Apr 2024 14:36:15 +0200 Subject: [PATCH 132/313] Fixed random failure in main.kill_processlist-6619 (take 3) followup for 81f75ca83ae6 improve over take 2. It's technically possible, though unlikely, to see THD after it already reset the info to NULL, but has not changed the command to COM_SLEEP yet (see THD::mark_connection_idle()). Let's wait for "Sleep", not for NULL. --- mysql-test/main/kill_processlist-6619.test | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/kill_processlist-6619.test b/mysql-test/main/kill_processlist-6619.test index 09c41f28a8f..36692b18ec9 100644 --- a/mysql-test/main/kill_processlist-6619.test +++ b/mysql-test/main/kill_processlist-6619.test @@ -10,7 +10,7 @@ source include/wait_condition.inc; --connect (con1,localhost,root,,) --let $con_id = `SELECT CONNECTION_ID()` -let $wait_condition=select info is NULL from information_schema.processlist where id != $con_id; +let $wait_condition=select command = 'sleep' from information_schema.processlist where id != $con_id; source include/wait_condition.inc; --replace_result Execute Query @@ -32,9 +32,7 @@ reap; SET DEBUG_SYNC='reset'; # Wait until default connection has reset query string -let $wait_condition= - SELECT COUNT(*) = 1 from information_schema.processlist - WHERE info is NULL; +let $wait_condition=select command = 'sleep' from information_schema.processlist where id != $con_id; --source include/wait_condition.inc --replace_result Execute Query From 8bc32410160265dcd27d595ed610843d08d32034 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 13 Apr 2024 16:27:08 +0200 Subject: [PATCH 133/313] feedback plugin: abort sending the report on server shutdown network timeouts might be rather large and feedback plugin waits forever for the sender thread to exit. an alternative could've been to use GNU-specific pthread_timedjoin_np(), where _np mean "not portable". --- plugin/feedback/feedback.cc | 4 ++++ plugin/feedback/feedback.h | 1 + plugin/feedback/url_http.cc | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc index 160545995d0..c1794f0987e 100644 --- a/plugin/feedback/feedback.cc +++ b/plugin/feedback/feedback.cc @@ -340,6 +340,10 @@ static int free(void *p) shutdown_plugin= true; mysql_cond_signal(&sleep_condition); mysql_mutex_unlock(&sleep_mutex); + + for (uint i= 0; i < url_count; i++) + urls[i]->abort(); + pthread_join(sender_thread, NULL); mysql_mutex_destroy(&sleep_mutex); diff --git a/plugin/feedback/feedback.h b/plugin/feedback/feedback.h index 04fe1ab6aa1..6021eb85860 100644 --- a/plugin/feedback/feedback.h +++ b/plugin/feedback/feedback.h @@ -52,6 +52,7 @@ class Url { const char *url() { return full_url.str; } size_t url_length() { return full_url.length; } + virtual void abort() = 0; virtual int send(const char* data, size_t data_length) = 0; virtual int set_proxy(const char *proxy, size_t proxy_len) { diff --git a/plugin/feedback/url_http.cc b/plugin/feedback/url_http.cc index 98116dd04f1..590bb06cc5f 100644 --- a/plugin/feedback/url_http.cc +++ b/plugin/feedback/url_http.cc @@ -37,8 +37,9 @@ static const uint FOR_WRITING= 1; class Url_http: public Url { protected: const LEX_STRING host, port, path; - bool ssl; LEX_STRING proxy_host, proxy_port; + my_socket fd; + bool ssl; bool use_proxy() { @@ -47,7 +48,8 @@ class Url_http: public Url { Url_http(LEX_STRING &url_arg, LEX_STRING &host_arg, LEX_STRING &port_arg, LEX_STRING &path_arg, bool ssl_arg) : - Url(url_arg), host(host_arg), port(port_arg), path(path_arg), ssl(ssl_arg) + Url(url_arg), host(host_arg), port(port_arg), path(path_arg), + fd(INVALID_SOCKET), ssl(ssl_arg) { proxy_host.length= 0; } @@ -60,6 +62,7 @@ class Url_http: public Url { } public: + void abort(); int send(const char* data, size_t data_length); int set_proxy(const char *proxy, size_t proxy_len) { @@ -158,13 +161,18 @@ Url* http_create(const char *url, size_t url_length) return new Url_http(full_url, host, port, path, ssl); } +void Url_http::abort() +{ + if (fd != INVALID_SOCKET) + closesocket(fd); // interrupt I/O waits +} + /* do the vio_write and check that all data were sent ok */ #define write_check(VIO, DATA, LEN) \ (vio_write((VIO), (uchar*)(DATA), (LEN)) != (LEN)) int Url_http::send(const char* data, size_t data_length) { - my_socket fd= INVALID_SOCKET; char buf[1024]; size_t len= 0; @@ -180,6 +188,7 @@ int Url_http::send(const char* data, size_t data_length) return 1; } + DBUG_ASSERT(fd == INVALID_SOCKET); for (addr= addrs; addr != NULL; addr= addr->ai_next) { fd= socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); @@ -208,6 +217,7 @@ int Url_http::send(const char* data, size_t data_length) sql_print_error("feedback plugin: vio_new failed for url '%s'", full_url.str); closesocket(fd); + fd= INVALID_SOCKET; return 1; } @@ -236,6 +246,7 @@ int Url_http::send(const char* data, size_t data_length) free_vio_ssl_acceptor_fd(ssl_fd); closesocket(fd); vio_delete(vio); + fd= INVALID_SOCKET; return 1; } } @@ -334,6 +345,7 @@ int Url_http::send(const char* data, size_t data_length) } #endif + fd= INVALID_SOCKET; return res; } From 99dc0f030f049ba41e19f31d82734a96a1082da0 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 20 Mar 2024 17:23:49 +1100 Subject: [PATCH 134/313] MDEV-28993 spider: revert removal of ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC It was done in MDEV-29447. --- storage/spider/spd_db_mysql.cc | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index a2262956d44..2691f62a5c1 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -5548,7 +5548,9 @@ int spider_db_mbase_util::check_item_func( { case Item_func::TRIG_COND_FUNC: case Item_func::CASE_SEARCHED_FUNC: +#ifndef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC case Item_func::CASE_SIMPLE_FUNC: +#endif DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); case Item_func::NOT_FUNC: /* Why the following check is necessary? */ @@ -6488,7 +6490,70 @@ int spider_db_mbase_util::print_item_func( DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); case Item_func::CASE_SEARCHED_FUNC: case Item_func::CASE_SIMPLE_FUNC: +#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC + Item_func_case *item_func_case = (Item_func_case *) item_func; + if (str) + { + if (str->reserve(SPIDER_SQL_CASE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN); + } + if (item_func_case->first_expr_num != -1) + { + if ((error_num = spider_db_print_item_type( + item_list[item_func_case->first_expr_num], NULL, spider, str, + alias, alias_length, dbton_id, use_fields, fields))) + DBUG_RETURN(error_num); + } + for (roop_count = 0; roop_count < item_func_case->ncases; + roop_count += 2) + { + if (str) + { + if (str->reserve(SPIDER_SQL_WHEN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[roop_count], NULL, spider, str, + alias, alias_length, dbton_id, use_fields, fields))) + DBUG_RETURN(error_num); + if (str) + { + if (str->reserve(SPIDER_SQL_THEN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[roop_count + 1], NULL, spider, str, + alias, alias_length, dbton_id, use_fields, fields))) + DBUG_RETURN(error_num); + } + if (item_func_case->else_expr_num != -1) + { + if (str) + { + if (str->reserve(SPIDER_SQL_ELSE_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); + } + if ((error_num = spider_db_print_item_type( + item_list[item_func_case->else_expr_num], NULL, spider, str, + alias, alias_length, dbton_id, use_fields, fields))) + DBUG_RETURN(error_num); + } + if (str) + { + if (str->reserve(SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + str->q_append(SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN); + str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, + SPIDER_SQL_CLOSE_PAREN_LEN); + } + DBUG_RETURN(0); +#else DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); +#endif case Item_func::JSON_EXTRACT_FUNC: func_name = (char*) item_func->func_name(); func_name_length = strlen(func_name); From 18b93d6eb074ab183e08ed0da0d9106017aa648d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 20 Mar 2024 17:20:39 +1100 Subject: [PATCH 135/313] MDEV-28993 Spider: Push down CASE statement --- .../spider/bugfix/r/mdev_27172.result | 6 +- .../spider/feature/r/pushdown_case.result | 57 +++++++++++++++++++ .../spider/feature/t/pushdown_case.test | 50 ++++++++++++++++ storage/spider/spd_db_include.h | 3 - storage/spider/spd_db_mysql.cc | 57 +++++++++++-------- 5 files changed, 143 insertions(+), 30 deletions(-) create mode 100644 storage/spider/mysql-test/spider/feature/r/pushdown_case.result create mode 100644 storage/spider/mysql-test/spider/feature/t/pushdown_case.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result index d4c8c7e8ec2..1be2b98964a 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_27172.result @@ -66,9 +66,9 @@ id greeting connection child2_1; SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %'; argument -select `id`,`greeting` from `auto_test_remote`.`tbl_a` where `greeting` = 'Aloha!' and ((`greeting` = 'Aloha!')) -select `id`,`greeting` from `auto_test_remote`.`tbl_b` where `greeting` like 'Aloha%' and ((`greeting` = 'Aloha!')) -select `id`,`greeting` from `auto_test_remote`.`tbl_c` where `greeting` like 'Aloha%' and ((`greeting` = 'Aloha!')) +select t0.`id` `id`,t0.`greeting` `greeting` from `auto_test_remote`.`tbl_a` t0 where ((t0.`greeting` = 'Aloha!') and ((case t0.`greeting` when 'Aloha!' then _latin1'one' else _latin1'more' end) = _latin1'one')) +select t0.`id` `id`,t0.`greeting` `greeting` from `auto_test_remote`.`tbl_b` t0 where ((t0.`greeting` = 'Aloha!') and ((case t0.`greeting` when 'Aloha!' then _latin1'one' else _latin1'more' end) = _latin1'one')) +select t0.`id` `id`,t0.`greeting` `greeting` from `auto_test_remote`.`tbl_c` t0 where ((t0.`greeting` = 'Aloha!') and ((case t0.`greeting` when 'Aloha!' then _latin1'one' else _latin1'more' end) = _latin1'one')) SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %' connection child2_1; SET @@global.general_log = @general_log_backup; diff --git a/storage/spider/mysql-test/spider/feature/r/pushdown_case.result b/storage/spider/mysql-test/spider/feature/r/pushdown_case.result new file mode 100644 index 00000000000..613ce377865 --- /dev/null +++ b/storage/spider/mysql-test/spider/feature/r/pushdown_case.result @@ -0,0 +1,57 @@ +# +# MDEV-28993 Spider: Push down CASE statement +# +for master_1 +for child2 +for child3 +set spider_same_server_link= 1; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +create table t2 (c int); +create table t1 (c int) ENGINE=Spider +COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; +insert into t1 values (42), (3), (848), (100); +explain select case c when 3 then "three" when 42 then "answer" else "other" 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 +select case c when 3 then "three" when 42 then "answer" else "other" end from t1; +case c when 3 then "three" when 42 then "answer" else "other" end +answer +three +other +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 +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 +three +NULL +NULL +explain select case when c = 3 then "three" when c = 42 then "answer" else "other" 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 +select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1; +case when c = 3 then "three" when c = 42 then "answer" else "other" end +answer +three +other +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 +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 +three +NULL +NULL +drop table t1, t2; +drop server srv; +for master_1 +for child2 +for child3 +# +# end of test pushdown_case +# diff --git a/storage/spider/mysql-test/spider/feature/t/pushdown_case.test b/storage/spider/mysql-test/spider/feature/t/pushdown_case.test new file mode 100644 index 00000000000..b86edceb615 --- /dev/null +++ b/storage/spider/mysql-test/spider/feature/t/pushdown_case.test @@ -0,0 +1,50 @@ +--echo # +--echo # MDEV-28993 Spider: Push down CASE statement +--echo # +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log +set spider_same_server_link= 1; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +create table t2 (c int); +create table t1 (c int) ENGINE=Spider +COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; +insert into t1 values (42), (3), (848), (100); + +# everything +let $query= +select case c when 3 then "three" when 42 then "answer" else "other" end from t1; +eval explain $query; +eval $query; + +# no else +let $query= +select case c when 3 then "three" when 42 then "answer" end from t1; +eval explain $query; +eval $query; + +# no value +let $query= +select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1; +eval explain $query; +eval $query; + +# neither +let $query= +select case when c = 3 then "three" when c = 42 then "answer" end from t1; +eval explain $query; +eval $query; + +drop table t1, t2; +drop server srv; +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log +--echo # +--echo # end of test pushdown_case +--echo # diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index 20bd82e48da..7c07b6998d4 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -25,7 +25,6 @@ #define PLUGIN_VAR_CAN_MEMALLOC /* -#define ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC #define HASH_UPDATE_WITH_HASH_VALUE */ @@ -106,7 +105,6 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_HS_LTEQUAL_STR "<=" #define SPIDER_SQL_HS_LTEQUAL_LEN (sizeof(SPIDER_SQL_HS_LTEQUAL_STR) - 1) -#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC #define SPIDER_SQL_CASE_STR "case " #define SPIDER_SQL_CASE_LEN (sizeof(SPIDER_SQL_CASE_STR) - 1) #define SPIDER_SQL_WHEN_STR " when " @@ -117,7 +115,6 @@ typedef st_spider_result SPIDER_RESULT; #define SPIDER_SQL_ELSE_LEN (sizeof(SPIDER_SQL_ELSE_STR) - 1) #define SPIDER_SQL_END_STR " end" #define SPIDER_SQL_END_LEN (sizeof(SPIDER_SQL_END_STR) - 1) -#endif #define SPIDER_SQL_USING_STR " using " #define SPIDER_SQL_USING_LEN (sizeof(SPIDER_SQL_USING_STR) - 1) diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 2691f62a5c1..2624190f432 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -5547,10 +5547,6 @@ int spider_db_mbase_util::check_item_func( switch (func_type) { case Item_func::TRIG_COND_FUNC: - case Item_func::CASE_SEARCHED_FUNC: -#ifndef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC - case Item_func::CASE_SIMPLE_FUNC: -#endif DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); case Item_func::NOT_FUNC: /* Why the following check is necessary? */ @@ -5620,15 +5616,15 @@ int spider_db_mbase_util::print_item_func( Item *item, **item_list = item_func->arguments(); Field *field; spider_string tmp_str; - uint roop_count, item_count = item_func->argument_count(), start_item = 0; + uint i, item_count = item_func->argument_count(), start_item = 0; const char *func_name = SPIDER_SQL_NULL_CHAR_STR, *separator_str = SPIDER_SQL_NULL_CHAR_STR, *last_str = SPIDER_SQL_NULL_CHAR_STR; int func_name_length = SPIDER_SQL_NULL_CHAR_LEN, separator_str_length = SPIDER_SQL_NULL_CHAR_LEN, last_str_length = SPIDER_SQL_NULL_CHAR_LEN; - int use_pushdown_udf; - bool merge_func = FALSE; + int use_pushdown_udf, case_when_start, case_when_count; + bool merge_func = FALSE, case_with_else; DBUG_ENTER("spider_db_mbase_util::print_item_func"); DBUG_ASSERT(!check_item_func(item_func, spider, alias, alias_length, use_fields, fields)); @@ -6490,23 +6486,39 @@ int spider_db_mbase_util::print_item_func( DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); case Item_func::CASE_SEARCHED_FUNC: case Item_func::CASE_SIMPLE_FUNC: -#ifdef ITEM_FUNC_CASE_PARAMS_ARE_PUBLIC - Item_func_case *item_func_case = (Item_func_case *) item_func; + /* + Arrangement of arguments: + - Item_func_case_searched: + when1 when2 ... whenk then1 then2 .. thenk [else] + - Item_func_case_simple: + value when1 when2 ... whenk then1 then2 .. thenk [else] + */ + if (item_func->functype() == Item_func::CASE_SEARCHED_FUNC) + { + case_when_start= 0; + case_when_count= item_count / 2; + case_with_else= item_count % 2; + } + else + { + case_when_start= 1; + case_when_count= (item_count - 1) / 2; + case_with_else= item_count % 2 == 0; + } if (str) { if (str->reserve(SPIDER_SQL_CASE_LEN)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); str->q_append(SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN); } - if (item_func_case->first_expr_num != -1) + if (case_when_start > 0) { if ((error_num = spider_db_print_item_type( - item_list[item_func_case->first_expr_num], NULL, spider, str, + item_list[0], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } - for (roop_count = 0; roop_count < item_func_case->ncases; - roop_count += 2) + for (i = 0; i < (uint) case_when_count; i++) { if (str) { @@ -6515,7 +6527,7 @@ int spider_db_mbase_util::print_item_func( str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN); } if ((error_num = spider_db_print_item_type( - item_list[roop_count], NULL, spider, str, + item_list[i + case_when_start], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); if (str) @@ -6525,11 +6537,11 @@ int spider_db_mbase_util::print_item_func( str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN); } if ((error_num = spider_db_print_item_type( - item_list[roop_count + 1], NULL, spider, str, + item_list[i + case_when_start + case_when_count], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } - if (item_func_case->else_expr_num != -1) + if (case_with_else) { if (str) { @@ -6538,7 +6550,7 @@ int spider_db_mbase_util::print_item_func( str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN); } if ((error_num = spider_db_print_item_type( - item_list[item_func_case->else_expr_num], NULL, spider, str, + item_list[item_count - 1], NULL, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); } @@ -6551,9 +6563,6 @@ int spider_db_mbase_util::print_item_func( SPIDER_SQL_CLOSE_PAREN_LEN); } DBUG_RETURN(0); -#else - DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM); -#endif case Item_func::JSON_EXTRACT_FUNC: func_name = (char*) item_func->func_name(); func_name_length = strlen(func_name); @@ -6607,13 +6616,13 @@ int spider_db_mbase_util::print_item_func( Loop through the items of the current function expression to print its portion of the statement */ - for (roop_count = start_item; roop_count < item_count; roop_count++) + for (i = start_item; i < item_count; i++) { - item = item_list[roop_count]; + item = item_list[i]; if ((error_num = spider_db_print_item_type(item, field, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); - if (roop_count == 1) + if (i == 1) { /* Remaining operands need to be preceded by the separator */ func_name = separator_str; @@ -6627,7 +6636,7 @@ int spider_db_mbase_util::print_item_func( } /* Print the last operand value */ - item = item_list[roop_count]; + item = item_list[i]; if ((error_num = spider_db_print_item_type(item, field, spider, str, alias, alias_length, dbton_id, use_fields, fields))) DBUG_RETURN(error_num); From 051a1fa0e9fb61a3347d7ca8c41ddc8d95261729 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 27 Mar 2024 11:15:25 +1100 Subject: [PATCH 136/313] MDEV-33777 Spider: Correct checks for show index column numbers It was updated for 10.6+ in MDEV-7317. Because a lower version spider node may connect to a higher version data node, we need to change this for 10.4 and 10.5 as well. --- storage/spider/spd_db_mysql.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 2624190f432..aa51b369712 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -1186,9 +1186,9 @@ int spider_db_mbase_result::fetch_table_cardinality( if (mode == 1) { uint num_fields = this->num_fields(); - if (num_fields < 12 || num_fields > 13) + if (num_fields < 12 || num_fields > 14) { - DBUG_PRINT("info",("spider num_fields < 12 || num_fields > 13")); + DBUG_PRINT("info",("spider num_fields < 12 || num_fields > 14")); DBUG_RETURN(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM); } From ea810b04cb9c3f9af812964fb68ef04c1b7058a0 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 6 Mar 2024 15:59:30 +1100 Subject: [PATCH 137/313] MDEV-30676 rpl.parallel_backup* tests sometimes fail Raise innodb_lock_wait_timeout from 1 to 5 --- mysql-test/suite/rpl/r/parallel_backup.result | 4 ++-- mysql-test/suite/rpl/r/parallel_backup_lsu_off.result | 4 ++-- .../suite/rpl/r/parallel_backup_slave_binlog_off.result | 4 ++-- mysql-test/suite/rpl/t/parallel_backup_xa.inc | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/rpl/r/parallel_backup.result b/mysql-test/suite/rpl/r/parallel_backup.result index 570069c731c..1962bc593df 100644 --- a/mysql-test/suite/rpl/r/parallel_backup.result +++ b/mysql-test/suite/rpl/r/parallel_backup.result @@ -124,7 +124,7 @@ include/save_master_gtid.inc connection slave; SET @sav_innodb_lock_wait_timeout = @@global.innodb_lock_wait_timeout; SET @sav_slave_transaction_retries = @@global.slave_transaction_retries; -SET @@global.innodb_lock_wait_timeout =1; +SET @@global.innodb_lock_wait_timeout =5; SET @@global.slave_transaction_retries=0; include/start_slave.inc connection aux_slave; @@ -167,7 +167,7 @@ include/save_master_gtid.inc connection slave; SET @sav_innodb_lock_wait_timeout = @@global.innodb_lock_wait_timeout; SET @sav_slave_transaction_retries = @@global.slave_transaction_retries; -SET @@global.innodb_lock_wait_timeout =1; +SET @@global.innodb_lock_wait_timeout =5; SET @@global.slave_transaction_retries=0; include/start_slave.inc connection aux_slave; diff --git a/mysql-test/suite/rpl/r/parallel_backup_lsu_off.result b/mysql-test/suite/rpl/r/parallel_backup_lsu_off.result index 4e648ae5a7a..cd8ffc9707a 100644 --- a/mysql-test/suite/rpl/r/parallel_backup_lsu_off.result +++ b/mysql-test/suite/rpl/r/parallel_backup_lsu_off.result @@ -127,7 +127,7 @@ include/save_master_gtid.inc connection slave; SET @sav_innodb_lock_wait_timeout = @@global.innodb_lock_wait_timeout; SET @sav_slave_transaction_retries = @@global.slave_transaction_retries; -SET @@global.innodb_lock_wait_timeout =1; +SET @@global.innodb_lock_wait_timeout =5; SET @@global.slave_transaction_retries=0; include/start_slave.inc connection aux_slave; @@ -170,7 +170,7 @@ include/save_master_gtid.inc connection slave; SET @sav_innodb_lock_wait_timeout = @@global.innodb_lock_wait_timeout; SET @sav_slave_transaction_retries = @@global.slave_transaction_retries; -SET @@global.innodb_lock_wait_timeout =1; +SET @@global.innodb_lock_wait_timeout =5; SET @@global.slave_transaction_retries=0; include/start_slave.inc connection aux_slave; diff --git a/mysql-test/suite/rpl/r/parallel_backup_slave_binlog_off.result b/mysql-test/suite/rpl/r/parallel_backup_slave_binlog_off.result index c4bceb41dfe..b179d0d3d20 100644 --- a/mysql-test/suite/rpl/r/parallel_backup_slave_binlog_off.result +++ b/mysql-test/suite/rpl/r/parallel_backup_slave_binlog_off.result @@ -127,7 +127,7 @@ include/save_master_gtid.inc connection slave; SET @sav_innodb_lock_wait_timeout = @@global.innodb_lock_wait_timeout; SET @sav_slave_transaction_retries = @@global.slave_transaction_retries; -SET @@global.innodb_lock_wait_timeout =1; +SET @@global.innodb_lock_wait_timeout =5; SET @@global.slave_transaction_retries=0; include/start_slave.inc connection aux_slave; @@ -170,7 +170,7 @@ include/save_master_gtid.inc connection slave; SET @sav_innodb_lock_wait_timeout = @@global.innodb_lock_wait_timeout; SET @sav_slave_transaction_retries = @@global.slave_transaction_retries; -SET @@global.innodb_lock_wait_timeout =1; +SET @@global.innodb_lock_wait_timeout =5; SET @@global.slave_transaction_retries=0; include/start_slave.inc connection aux_slave; diff --git a/mysql-test/suite/rpl/t/parallel_backup_xa.inc b/mysql-test/suite/rpl/t/parallel_backup_xa.inc index 83a6fb79345..5f287aa0ca6 100644 --- a/mysql-test/suite/rpl/t/parallel_backup_xa.inc +++ b/mysql-test/suite/rpl/t/parallel_backup_xa.inc @@ -41,7 +41,7 @@ if ($slave_ooo_error) { SET @sav_innodb_lock_wait_timeout = @@global.innodb_lock_wait_timeout; SET @sav_slave_transaction_retries = @@global.slave_transaction_retries; - SET @@global.innodb_lock_wait_timeout =1; + SET @@global.innodb_lock_wait_timeout =5; SET @@global.slave_transaction_retries=0; } --source include/start_slave.inc From a032f14b342c782b82dfcd9235805bee446e6fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 15 Apr 2024 09:04:11 +0300 Subject: [PATCH 138/313] MDEV-33559 matched_rec::block should be allocated from the buffer pool matched_rec::rec_buf[], matched_rec::bufp: Remove. matched_rec::block: Make this a pointer to something that is allocated by buf_block_alloc(). In this way, the only case where buf_block_t is constructed outside buf_pool is ALTER TABLE...IMPORT TABLESPACE. rtr_info::heap: Remove. This was only used for allocating matched_rec, which now is smaller. mtr_t::memmove(): Simplify some code to avoid GCC 9.4.0 -Wconversion in the 10.6 branch as a result of these changes. Reviewed by: Debarun Banerjee --- storage/innobase/gis/gis0sea.cc | 81 ++++++----------------------- storage/innobase/include/gis0type.h | 6 +-- storage/innobase/include/mtr0log.h | 25 ++++----- storage/innobase/row/row0sel.cc | 10 ++-- 4 files changed, 36 insertions(+), 86 deletions(-) diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 7432aab1a29..b9567ff03c3 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -498,7 +498,7 @@ rtr_pcur_move_to_next( mutex_exit(&rtr_info->matches->rtr_match_mutex); cursor->btr_cur.page_cur.rec = rec.r_rec; - cursor->btr_cur.page_cur.block = &rtr_info->matches->block; + cursor->btr_cur.page_cur.block = rtr_info->matches->block; DEBUG_SYNC_C("rtr_pcur_move_to_next_return"); return(true); @@ -939,22 +939,14 @@ rtr_create_rtr_info( rtr_info->index = index; if (init_matches) { - rtr_info->heap = mem_heap_create(sizeof(*(rtr_info->matches))); rtr_info->matches = static_cast( - mem_heap_zalloc( - rtr_info->heap, - sizeof(*rtr_info->matches))); + ut_zalloc_nokey(sizeof *rtr_info->matches)); rtr_info->matches->matched_recs = UT_NEW_NOKEY(rtr_rec_vector()); - rtr_info->matches->bufp = page_align(rtr_info->matches->rec_buf - + UNIV_PAGE_SIZE_MAX + 1); mutex_create(LATCH_ID_RTR_MATCH_MUTEX, &rtr_info->matches->rtr_match_mutex); - rw_lock_create(PFS_NOT_INSTRUMENTED, - &(rtr_info->matches->block.lock), - SYNC_LEVEL_VARYING); } rtr_info->path = UT_NEW_NOKEY(rtr_node_path_t()); @@ -1016,7 +1008,6 @@ rtr_init_rtr_info( rtr_info->mbr.ymin = 0.0; rtr_info->mbr.ymax = 0.0; rtr_info->thr = NULL; - rtr_info->heap = NULL; rtr_info->cursor = NULL; rtr_info->index = NULL; rtr_info->need_prdt_lock = false; @@ -1095,17 +1086,15 @@ rtr_clean_rtr_info( if (free_all) { if (rtr_info->matches) { - if (rtr_info->matches->matched_recs != NULL) { - UT_DELETE(rtr_info->matches->matched_recs); + if (rtr_info->matches->block) { + buf_block_free(rtr_info->matches->block); + rtr_info->matches->block = nullptr; } - rw_lock_free(&(rtr_info->matches->block.lock)); + UT_DELETE(rtr_info->matches->matched_recs); mutex_destroy(&rtr_info->matches->rtr_match_mutex); - } - - if (rtr_info->heap) { - mem_heap_free(rtr_info->heap); + ut_free(rtr_info->matches); } if (initialized) { @@ -1215,7 +1204,7 @@ rtr_check_discard_page( if (rtr_info->matches) { mutex_enter(&rtr_info->matches->rtr_match_mutex); - if ((&rtr_info->matches->block)->page.id().page_no() + if (rtr_info->matches->block->page.id().page_no() == pageno) { if (!rtr_info->matches->matched_recs->empty()) { rtr_info->matches->matched_recs->clear(); @@ -1425,7 +1414,7 @@ rtr_leaf_push_match_rec( ulint data_len; rtr_rec_t rtr_rec; - buf = match_rec->block.frame + match_rec->used; + buf = match_rec->block->frame + match_rec->used; ut_ad(page_rec_is_leaf(rec)); copy = rec_copy(buf, rec, offsets); @@ -1522,43 +1511,6 @@ rtr_non_leaf_insert_stack_push( new_seq, level, child_no, my_cursor, mbr_inc); } -/** Copy a buf_block_t, except "block->lock". -@param[in,out] matches copy to match->block -@param[in] block block to copy */ -static -void -rtr_copy_buf( - matched_rec_t* matches, - const buf_block_t* block) -{ - /* Copy all members of "block" to "matches->block" except "lock". - We skip "lock" because it is not used - from the dummy buf_block_t we create here and because memcpy()ing - it generates (valid) compiler warnings that the vtable pointer - will be copied. */ - new (&matches->block.page) buf_page_t(block->page); - matches->block.frame = block->frame; - matches->block.unzip_LRU = block->unzip_LRU; - - ut_d(matches->block.in_unzip_LRU_list = block->in_unzip_LRU_list); - ut_d(matches->block.in_withdraw_list = block->in_withdraw_list); - - /* Skip buf_block_t::lock */ - matches->block.modify_clock = block->modify_clock; -#ifdef BTR_CUR_HASH_ADAPT - matches->block.n_hash_helps = block->n_hash_helps; - matches->block.n_fields = block->n_fields; - matches->block.left_side = block->left_side; -#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG - matches->block.n_pointers = 0; -#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ - matches->block.curr_n_fields = block->curr_n_fields; - matches->block.curr_left_side = block->curr_left_side; - matches->block.index = block->index; -#endif /* BTR_CUR_HASH_ADAPT */ - ut_d(matches->block.debug_latch = NULL); -} - /****************************************************************//** Generate a shadow copy of the page block header to save the matched records */ @@ -1572,17 +1524,18 @@ rtr_init_match( { ut_ad(matches->matched_recs->empty()); matches->locked = false; - rtr_copy_buf(matches, block); - matches->block.frame = matches->bufp; matches->valid = false; - /* We have to copy PAGE_W*_SUPREMUM_END bytes so that we can + if (!matches->block) { + matches->block = buf_block_alloc(); + } + + matches->block->page.init(block->page.id()); + /* We have to copy PAGE_*_SUPREMUM_END bytes so that we can use infimum/supremum of this page as normal btr page for search. */ - memcpy(matches->block.frame, page, page_is_comp(page) - ? PAGE_NEW_SUPREMUM_END - : PAGE_OLD_SUPREMUM_END); matches->used = page_is_comp(page) ? PAGE_NEW_SUPREMUM_END : PAGE_OLD_SUPREMUM_END; + memcpy(matches->block->frame, page, matches->used); #ifdef RTR_SEARCH_DIAGNOSTIC ulint pageno = page_get_page_no(page); fprintf(stderr, "INNODB_RTR: Searching leaf page %d\n", @@ -2002,7 +1955,7 @@ rtr_cur_search_with_match( #endif /* UNIV_DEBUG */ /* Pop the last match record and position on it */ match_rec->matched_recs->pop_back(); - page_cur_position(test_rec.r_rec, &match_rec->block, + page_cur_position(test_rec.r_rec, match_rec->block, cursor); } } else { diff --git a/storage/innobase/include/gis0type.h b/storage/innobase/include/gis0type.h index 55944bfcce3..f964ef9e4f4 100644 --- a/storage/innobase/include/gis0type.h +++ b/storage/innobase/include/gis0type.h @@ -66,10 +66,7 @@ typedef std::vector > rtr_rec_vector; /* Structure for matched records on the leaf page */ typedef struct matched_rec { - byte* bufp; /*!< aligned buffer point */ - byte rec_buf[UNIV_PAGE_SIZE_MAX * 2]; - /*!< buffer used to copy matching rec */ - buf_block_t block; /*!< the shadow buffer block */ + buf_block_t* block; /*!< the shadow buffer block */ ulint used; /*!< memory used */ rtr_rec_vector* matched_recs; /*!< vector holding the matching rec */ ib_mutex_t rtr_match_mutex;/*!< mutex protect the match_recs @@ -113,7 +110,6 @@ typedef struct rtr_info{ on each level and leaf level */ rtr_mbr_t mbr; /*!< the search MBR */ que_thr_t* thr; /*!< the search thread */ - mem_heap_t* heap; /*!< memory heap */ btr_cur_t* cursor; /*!< cursor used for search */ dict_index_t* index; /*!< index it is searching */ bool need_prdt_lock; diff --git a/storage/innobase/include/mtr0log.h b/storage/innobase/include/mtr0log.h index 285672be898..b8455f927bf 100644 --- a/storage/innobase/include/mtr0log.h +++ b/storage/innobase/include/mtr0log.h @@ -347,11 +347,12 @@ inline void mtr_t::memmove(const buf_block_t &b, ulint d, ulint s, ulint len) ut_ad(d >= 8); ut_ad(s >= 8); ut_ad(len); - ut_ad(s <= ulint(srv_page_size)); - ut_ad(s + len <= ulint(srv_page_size)); + ut_d(const ulint ps= srv_page_size); + ut_ad(s <= ps); + ut_ad(s + len <= ps); ut_ad(s != d); - ut_ad(d <= ulint(srv_page_size)); - ut_ad(d + len <= ulint(srv_page_size)); + ut_ad(d <= ps); + ut_ad(d + len <= ps); set_modified(b); if (m_log_mode != MTR_LOG_ALL) @@ -359,17 +360,17 @@ inline void mtr_t::memmove(const buf_block_t &b, ulint d, ulint s, ulint len) static_assert(MIN_4BYTE > UNIV_PAGE_SIZE_MAX, "consistency"); size_t lenlen= (len < MIN_2BYTE ? 1 : len < MIN_3BYTE ? 2 : 3); /* The source offset is encoded relative to the destination offset, - with the sign in the least significant bit. */ - if (s > d) - s= (s - d) << 1; - else - s= (d - s) << 1 | 1; + with the sign in the least significant bit. + Because the source offset 0 is not possible, our encoding + subtracts 1 from the offset. */ + const uint16_t S= s > d + ? uint16_t((s - d - 1) << 1) + : uint16_t((d - s - 1) << 1 | 1); /* The source offset 0 is not possible. */ - s-= 1 << 1; - size_t slen= (s < MIN_2BYTE ? 1 : s < MIN_3BYTE ? 2 : 3); + size_t slen= (S < MIN_2BYTE ? 1 : S < MIN_3BYTE ? 2 : 3); byte *l= log_write(b.page.id(), &b.page, lenlen + slen, true, d); l= mlog_encode_varint(l, len); - l= mlog_encode_varint(l, s); + l= mlog_encode_varint(l, S); m_log.close(l); m_last_offset= static_cast(d + len); } diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 98a9aa8e494..2a34685e7cc 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -1151,10 +1151,10 @@ sel_set_rtr_rec_lock( ut_ad(page_align(first_rec) == cur_block->frame); ut_ad(match->valid); - rw_lock_x_lock(&(match->block.lock)); + rw_lock_x_lock(&match->block->lock); retry: cur_block = btr_pcur_get_block(pcur); - ut_ad(rw_lock_own_flagged(&match->block.lock, + ut_ad(rw_lock_own_flagged(&match->block->lock, RW_LOCK_FLAG_X | RW_LOCK_FLAG_S)); ut_ad(page_is_leaf(buf_block_get_frame(cur_block))); @@ -1255,7 +1255,7 @@ re_scan: ULINT_UNDEFINED, &heap); err = lock_sec_rec_read_check_and_lock( - 0, &match->block, rtr_rec->r_rec, index, + 0, match->block, rtr_rec->r_rec, index, my_offsets, static_cast(mode), type, thr); @@ -1271,7 +1271,7 @@ re_scan: match->locked = true; func_end: - rw_lock_x_unlock(&(match->block.lock)); + rw_lock_x_unlock(&match->block->lock); if (heap != NULL) { mem_heap_free(heap); } @@ -3352,7 +3352,7 @@ Row_sel_get_clust_rec_for_mysql::operator()( if (dict_index_is_spatial(sec_index) && btr_cur->rtr_info->matches && (page_align(rec) - == btr_cur->rtr_info->matches->block.frame + == btr_cur->rtr_info->matches->block->frame || rec != btr_pcur_get_rec(prebuilt->pcur))) { #ifdef UNIV_DEBUG rtr_info_t* rtr_info = btr_cur->rtr_info; From 10272f3709be9dd0bd7871c70b252827c9c5f000 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Mon, 15 Apr 2024 10:23:22 +0200 Subject: [PATCH 139/313] Distinguish "manager stopped" from "manager not started" This way, if manager thread somehow starts and stops again quickly before main thread wakes up to check if it started correctly, we will not hang. Patch suggested by Monty as follow-up to 7f498fbab888bd24d76a0292f4d22cacfb2f95b2 Signed-off-by: Kristian Nielsen --- sql/sql_manager.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc index 5cd66d8047a..a286497235e 100644 --- a/sql/sql_manager.cc +++ b/sql/sql_manager.cc @@ -26,6 +26,10 @@ #include "sql_manager.h" #include "sql_base.h" // flush_tables +/* + Values for manager_thread_in_use: 0 means "not started". 1 means "started + and active". 2 means "stopped". +*/ static bool volatile manager_thread_in_use = 0; static bool abort_manager = false; @@ -44,7 +48,7 @@ static struct handler_cb *cb_list; // protected by LOCK_manager bool mysql_manager_submit(void (*action)(void *), void *data) { bool result= FALSE; - DBUG_ASSERT(manager_thread_in_use); + DBUG_ASSERT(manager_thread_in_use == 1); struct handler_cb **cb; mysql_mutex_lock(&LOCK_manager); cb= &cb_list; @@ -119,7 +123,7 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused))) mysql_mutex_lock(&LOCK_manager); } DBUG_ASSERT(cb_list == NULL); - manager_thread_in_use = 0; + manager_thread_in_use = 2; mysql_mutex_unlock(&LOCK_manager); mysql_mutex_destroy(&LOCK_manager); mysql_cond_destroy(&COND_manager); @@ -148,6 +152,15 @@ void start_handle_manager() } mysql_mutex_lock(&LOCK_manager); + /* + Wait for manager thread to have started, otherwise in extreme cases the + server may start up and have initiated shutdown at the time the manager + thread even starts to run. + + Allow both values 1 and 2 for manager_thread_in_use, so that we will not + get stuck here if the manager thread somehow manages to start up and + abort again before we have time to test it here. + */ while (!manager_thread_in_use) mysql_cond_wait(&COND_manager, &LOCK_manager); mysql_mutex_unlock(&LOCK_manager); From ce104d41714f5d4d68dc5c56e1e9cbe9ef192ba4 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Mon, 15 Apr 2024 18:54:30 +0200 Subject: [PATCH 140/313] Fix windows build failure Signed-off-by: Kristian Nielsen --- sql/sql_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc index a286497235e..b3d95c9ed31 100644 --- a/sql/sql_manager.cc +++ b/sql/sql_manager.cc @@ -30,7 +30,7 @@ Values for manager_thread_in_use: 0 means "not started". 1 means "started and active". 2 means "stopped". */ -static bool volatile manager_thread_in_use = 0; +static int volatile manager_thread_in_use = 0; static bool abort_manager = false; pthread_t manager_thread; From 50998a6c6f82d40c72370bb017669af704565ea0 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 15 Apr 2024 16:39:01 +0200 Subject: [PATCH 141/313] MDEV-33861 main.query_cache fails with embedded after enabling WITH_PROTECT_STATEMENT_MEMROOT Synopsis: If SELECT returned answer from Query Cache it is not really executed. The reason for firing of assertion DBUG_ASSERT((mem_root->flags & ROOT_FLAG_READ_ONLY) == 0); is that in case the query_cache is on and the same query run by different stored routines the following use case can take place: First, lets say that bodies of routines used by the test case are the same and contains the only query 'SELECT * FROM t1'; call p1() -- a result set is stored in query cache for further use. call p2() -- the same query is run against the table t1, that result in not running the actual query but using its cached result. On finishing execution of this routine, its memory root is marked for read only since every SP instruction that this routine contains has been executed. INSERT INT t1 VALUE (1); -- force following invalidation of query cache call p2() -- query the table t1 will result in assertion failure since its execution would require allocation on the memory root that has been already marked as read only memory root The root cause of firing the assertion is that memory root of the stored routine 'p2' was marked as read only although actual execution of the query contained inside hadn't been performed. To fix the issue, mark a SP instruction as not yet run in case its execution doesn't result in real query processing and a result set got from query cache instead. Note that, this issue relates server built in debug mode AND with the protect statement memory root feature turned on. It doesn't affect server built in release mode. --- mysql-test/main/query_cache.result | 27 +++++++++++++++++++++++ mysql-test/main/query_cache.test | 35 ++++++++++++++++++++++++++++++ sql/sp_head.cc | 3 +++ sql/sp_head.h | 18 ++++++++++----- 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/query_cache.result b/mysql-test/main/query_cache.result index fc7ca726c48..a98ab3cab76 100644 --- a/mysql-test/main/query_cache.result +++ b/mysql-test/main/query_cache.result @@ -2207,6 +2207,33 @@ Variable_name Value Qcache_queries_in_cache 0 DROP FUNCTION foo; drop table t1; +# +# MDEV-33861: main.query_cache fails with embedded after +# enabling WITH_PROTECT_STATEMENT_MEMROOT +# +create table t1 (s1 int); +create procedure f3 () begin +select * from t1; +end; +// +create procedure f4 () begin +select * from t1; +end; +// +Call f4(); +s1 +cAll f3(); +s1 +insert into t1 values (2); +caLl f3(); +s1 +2 +drop procedure f3; +drop procedure f4; +drop table t1; +# +# End of 10.4 tests +# restore defaults SET GLOBAL query_cache_type= default; SET GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test index f4913c99d1c..5d523764dce 100644 --- a/mysql-test/main/query_cache.test +++ b/mysql-test/main/query_cache.test @@ -1803,6 +1803,41 @@ show status like "Qcache_queries_in_cache"; DROP FUNCTION foo; drop table t1; + +--echo # +--echo # MDEV-33861: main.query_cache fails with embedded after +--echo # enabling WITH_PROTECT_STATEMENT_MEMROOT +--echo # + +create table t1 (s1 int); +--delimiter // +create procedure f3 () begin +select * from t1; +end; +// +create procedure f4 () begin +select * from t1; +end; +// +--delimiter ; + +Call f4(); + +cAll f3(); + +insert into t1 values (2); + +caLl f3(); + +drop procedure f3; +drop procedure f4; +drop table t1; + + +--echo # +--echo # End of 10.4 tests +--echo # + --echo restore defaults SET GLOBAL query_cache_type= default; SET GLOBAL query_cache_size=@save_query_cache_size; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 312d779b05a..faf483c4a35 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -3702,6 +3702,9 @@ sp_instr_stmt::execute(THD *thd, uint *nextp) thd->update_stats(); thd->lex->sql_command= save_sql_command; *nextp= m_ip+1; +#ifdef PROTECT_STATEMENT_MEMROOT + mark_as_qc_used(); +#endif } thd->set_query(query_backup); thd->query_name_consts= 0; diff --git a/sql/sp_head.h b/sql/sp_head.h index 693a5e78703..c9b6ae63c2b 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -1100,7 +1100,7 @@ public: sp_instr(uint ip, sp_pcontext *ctx) :Query_arena(0, STMT_INITIALIZED_FOR_SP), marked(0), m_ip(ip), m_ctx(ctx) #ifdef PROTECT_STATEMENT_MEMROOT - , m_has_been_run(false) + , m_has_been_run(NON_RUN) #endif {} @@ -1194,21 +1194,29 @@ public: #ifdef PROTECT_STATEMENT_MEMROOT bool has_been_run() const { - return m_has_been_run; + return m_has_been_run == RUN; + } + + void mark_as_qc_used() + { + m_has_been_run= QC; } void mark_as_run() { - m_has_been_run= true; + if (m_has_been_run == QC) + m_has_been_run= NON_RUN; // answer was from WC => not really executed + else + m_has_been_run= RUN; } void mark_as_not_run() { - m_has_been_run= false; + m_has_been_run= NON_RUN; } private: - bool m_has_been_run; + enum {NON_RUN, QC, RUN} m_has_been_run; #endif }; // class sp_instr : public Sql_alloc From 9705d62313680bf5617d828fb1bf53f78e19a3bb Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 16 Apr 2024 11:56:00 +0530 Subject: [PATCH 142/313] MDEV-33809 Bulk insert or DDL fails if a BLOB is too long SyncFileIO should do multiple read/write call when length is greater than os_file_request_size_max value. --- storage/innobase/os/os0file.cc | 58 +++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index e72dd96cf0e..3293db12815 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -320,6 +320,12 @@ private: ssize_t m_n; /** Offset from where to read/write */ os_offset_t m_offset; + + /** Do the read/write + @param request The IO context and type + @param n Number of bytes to read/write + @return the number of bytes read/written or negative value on error */ + ssize_t execute_low(const IORequest& request, ssize_t n); }; #ifndef _WIN32 /* On Microsoft Windows, mandatory locking is used */ @@ -671,32 +677,48 @@ os_file_create_subdirs_if_needed( +/** Do the read/write +@param[in] request The IO context and type +@param[in] n Number of bytes to read/write +@return the number of bytes read/written or negative value on error */ +ssize_t +SyncFileIO::execute_low(const IORequest& request, ssize_t n) +{ + ut_ad(n > 0); + ut_ad(size_t(n) <= os_file_request_size_max); + + if (request.is_read()) + return IF_WIN(tpool::pread(m_fh, m_buf, n, m_offset), pread(m_fh, m_buf, n, m_offset)); + return IF_WIN(tpool::pwrite(m_fh, m_buf, n, m_offset), pwrite(m_fh, m_buf, n, m_offset)); +} + /** Do the read/write @param[in] request The IO context and type @return the number of bytes read/written or negative value on error */ ssize_t SyncFileIO::execute(const IORequest& request) { - ssize_t n_bytes; - ut_ad(m_n > 0); - ut_ad(size_t(m_n) <= os_file_request_size_max); + ssize_t n_bytes= 0; + ut_ad(m_n > 0); - if (request.is_read()) { -#ifdef _WIN32 - n_bytes = tpool::pread(m_fh, m_buf, m_n, m_offset); -#else - n_bytes = pread(m_fh, m_buf, m_n, m_offset); -#endif - } else { - ut_ad(request.is_write()); -#ifdef _WIN32 - n_bytes = tpool::pwrite(m_fh, m_buf, m_n, m_offset); -#else - n_bytes = pwrite(m_fh, m_buf, m_n, m_offset); -#endif - } + while (size_t(m_n) > os_file_request_size_max) + { + ssize_t n_partial_bytes= execute_low(request, os_file_request_size_max); + if (n_partial_bytes < 0) + return n_partial_bytes; + n_bytes+= n_partial_bytes; + if (n_partial_bytes != os_file_request_size_max) + return n_bytes; + advance(os_file_request_size_max); + } - return(n_bytes); + if (ssize_t n= execute_low(request, m_n)) + { + if (n < 0) + return n; + n_bytes += n; + } + return n_bytes; } #ifndef _WIN32 From a8a75ba2d0dd639b2b14337a6c4f495fcaaff7e4 Mon Sep 17 00:00:00 2001 From: Dave Gosselin Date: Fri, 12 Apr 2024 11:35:02 -0400 Subject: [PATCH 143/313] Factor TABLE_LIST creation from add_table_to_list Ideally our methods and functions should do one thing, do that well, and do only that. add_table_to_list does far more than adding a table to a list, so this commit factors the TABLE_LIST creation out to a new TABLE_LIST constructor. It then uses placement new() to create it in the correct memory area (result of thd->calloc). Benefits of this approach: 1. add_table_to_list now returns as early as possible on an error 2. fewer side-effects incurred on creating the TABLE_LIST object 3. TABLE_LIST won't be calloc'd if copy_to_db fails 4. local declarations moved closer to their respective first uses 5. improved code readability and logical flow Also factored a couple of other functions to keep the happy path more to the left, which makes them easier to follow at a glance. --- sql/sql_class.h | 30 +++++++------- sql/sql_lex.cc | 23 +++++------ sql/sql_parse.cc | 101 +++++++++++++++++------------------------------ sql/table.cc | 54 +++++++++++++++++++++++++ sql/table.h | 15 +++++++ 5 files changed, 133 insertions(+), 90 deletions(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 84665979d6e..a9b36f9dfb1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4832,24 +4832,24 @@ public: */ bool copy_db_to(LEX_CSTRING *to) { - if (db.str == NULL) + if (db.str) { - /* - No default database is set. In this case if it's guaranteed that - no CTE can be used in the statement then we can throw an error right - now at the parser stage. Otherwise the decision about throwing such - a message must be postponed until a post-parser stage when we are able - to resolve all CTE names as we don't need this message to be thrown - for any CTE references. - */ - if (!lex->with_cte_resolution) - my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); - return TRUE; + to->str= strmake(db.str, db.length); + to->length= db.length; + return to->str == NULL; /* True on error */ } - to->str= strmake(db.str, db.length); - to->length= db.length; - return to->str == NULL; /* True on error */ + /* + No default database is set. In this case if it's guaranteed that + no CTE can be used in the statement then we can throw an error right + now at the parser stage. Otherwise the decision about throwing such + a message must be postponed until a post-parser stage when we are able + to resolve all CTE names as we don't need this message to be thrown + for any CTE references. + */ + if (!lex->with_cte_resolution) + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); + return TRUE; } /* Get db name or "". Use for printing current db */ const char *get_db() diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5d5d967b9ab..8b9cc2473bf 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -4290,17 +4290,18 @@ uint8 LEX::get_effective_with_check(TABLE_LIST *view) bool LEX::copy_db_to(LEX_CSTRING *to) { - if (sphead && sphead->m_name.str) - { - DBUG_ASSERT(sphead->m_db.str && sphead->m_db.length); - /* - It is safe to assign the string by-pointer, both sphead and - its statements reside in the same memory root. - */ - *to= sphead->m_db; - return FALSE; - } - return thd->copy_db_to(to); + if (!sphead || !sphead->m_name.str) + return thd->copy_db_to(to); + + DBUG_ASSERT(sphead->m_db.str); + DBUG_ASSERT(sphead->m_db.length); + + /* + It is safe to assign the string by-pointer, both sphead and + its statements reside in the same memory root. + */ + *to= sphead->m_db; + return FALSE; } /** diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ad1abc4c4a0..60b4fed9fb3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -8283,10 +8283,6 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, List *partition_names, LEX_STRING *option) { - TABLE_LIST *ptr; - TABLE_LIST *UNINIT_VAR(previous_table_ref); /* The table preceding the current one. */ - LEX_CSTRING alias_str; - LEX *lex= thd->lex; DBUG_ENTER("add_table_to_list"); DBUG_PRINT("enter", ("Table '%s' (%p) Select %p (%u)", (alias ? alias->str : table->table.str), @@ -8296,9 +8292,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, if (unlikely(!table)) DBUG_RETURN(0); // End of memory - alias_str= alias ? *alias : table->table; - DBUG_ASSERT(alias_str.str); - if (!MY_TEST(table_options & TL_OPTION_ALIAS) && + if (!(table_options & TL_OPTION_ALIAS) && unlikely(check_table_name(table->table.str, table->table.length, FALSE))) { my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str); @@ -8313,6 +8307,34 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, DBUG_RETURN(0); } + LEX_CSTRING db{0, 0}; + bool fqtn= false; + LEX *lex= thd->lex; + if (table->db.str) + { + fqtn= TRUE; + db= table->db; + } + else if (!lex->with_cte_resolution && lex->copy_db_to(&db)) + DBUG_RETURN(0); + else + fqtn= FALSE; + bool info_schema= is_infoschema_db(&db); + if (!table->sel && info_schema && + (table_options & TL_OPTION_UPDATING) && + /* Special cases which are processed by commands itself */ + lex->sql_command != SQLCOM_CHECK && + lex->sql_command != SQLCOM_CHECKSUM) + { + my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), + thd->security_ctx->priv_user, + thd->security_ctx->priv_host, + INFORMATION_SCHEMA_NAME.str); + DBUG_RETURN(0); + } + + LEX_CSTRING alias_str= alias ? *alias : table->table; + DBUG_ASSERT(alias_str.str); if (!alias) /* Alias is case sensitive */ { if (unlikely(table->sel)) @@ -8325,65 +8347,15 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, if (unlikely(!(alias_str.str= (char*) thd->memdup(alias_str.str, alias_str.length+1)))) DBUG_RETURN(0); } - if (unlikely(!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))) - DBUG_RETURN(0); /* purecov: inspected */ - if (table->db.str) - { - ptr->is_fqtn= TRUE; - ptr->db= table->db; - } - else if (!lex->with_cte_resolution && lex->copy_db_to(&ptr->db)) - DBUG_RETURN(0); - else - ptr->is_fqtn= FALSE; - ptr->alias= alias_str; - ptr->is_alias= alias ? TRUE : FALSE; - if (lower_case_table_names) - { - if (table->table.length) - table->table.length= my_casedn_str(files_charset_info, - (char*) table->table.str); - if (ptr->db.length && ptr->db.str != any_db.str) - ptr->db.length= my_casedn_str(files_charset_info, (char*) ptr->db.str); - } + bool has_alias_ptr= alias != nullptr; + void *memregion= thd->calloc(sizeof(TABLE_LIST)); + TABLE_LIST *ptr= new (memregion) TABLE_LIST(thd, db, fqtn, alias_str, + has_alias_ptr, table, lock_type, + mdl_type, table_options, + info_schema, this, + index_hints_arg, option); - ptr->table_name= table->table; - ptr->lock_type= lock_type; - ptr->mdl_type= mdl_type; - ptr->table_options= table_options; - ptr->updating= MY_TEST(table_options & TL_OPTION_UPDATING); - /* TODO: remove TL_OPTION_FORCE_INDEX as it looks like it's not used */ - ptr->force_index= MY_TEST(table_options & TL_OPTION_FORCE_INDEX); - ptr->ignore_leaves= MY_TEST(table_options & TL_OPTION_IGNORE_LEAVES); - ptr->sequence= MY_TEST(table_options & TL_OPTION_SEQUENCE); - ptr->derived= table->sel; - if (!ptr->derived && is_infoschema_db(&ptr->db)) - { - if (ptr->updating && - /* Special cases which are processed by commands itself */ - lex->sql_command != SQLCOM_CHECK && - lex->sql_command != SQLCOM_CHECKSUM) - { - my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), - thd->security_ctx->priv_user, - thd->security_ctx->priv_host, - INFORMATION_SCHEMA_NAME.str); - DBUG_RETURN(0); - } - ST_SCHEMA_TABLE *schema_table; - schema_table= find_schema_table(thd, &ptr->table_name); - ptr->schema_table_name= ptr->table_name; - ptr->schema_table= schema_table; - } - ptr->select_lex= this; - /* - We can't cache internal temporary tables between prepares as the - table may be deleted before next exection. - */ - ptr->cacheable_table= !table->is_derived_table(); - ptr->index_hints= index_hints_arg; - ptr->option= option ? option->str : 0; /* check that used name is unique. Sequences are ignored */ if (lock_type != TL_IGNORE && !ptr->sequence) { @@ -8406,6 +8378,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, } } /* Store the table reference preceding the current one. */ + TABLE_LIST *UNINIT_VAR(previous_table_ref); /* The table preceding the current one. */ if (table_list.elements > 0 && likely(!ptr->sequence)) { /* diff --git a/sql/table.cc b/sql/table.cc index cff651f5d1c..9c2423e5a2d 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -49,6 +49,7 @@ #include "wsrep_schema.h" #endif #include "log_event.h" // MAX_TABLE_MAP_ID +#include "sql_class.h" /* For MySQL 5.7 virtual fields */ #define MYSQL57_GENERATED_FIELD 128 @@ -5850,6 +5851,59 @@ void TABLE::reset_item_list(List *item_list, uint skip) const } } +TABLE_LIST::TABLE_LIST(THD *thd, + LEX_CSTRING db_str, + bool fqtn, + LEX_CSTRING alias_str, + bool has_alias_ptr, + Table_ident *table_ident, + thr_lock_type lock_t, + enum_mdl_type mdl_t, + ulong table_opts, + bool info_schema, + st_select_lex *sel, + List *index_hints_ptr, + LEX_STRING *option_ptr) +{ + db= db_str; + is_fqtn= fqtn; + alias= alias_str; + is_alias= has_alias_ptr; + if (lower_case_table_names) + { + if (table_ident->table.length) + table_ident->table.length= my_casedn_str(files_charset_info, + (char*) table_ident->table.str); + if (db.length && db.str != any_db.str) + db.length= my_casedn_str(files_charset_info, (char*) db.str); + } + + table_name= table_ident->table; + lock_type= lock_t; + mdl_type= mdl_t; + table_options= table_opts; + updating= table_options & TL_OPTION_UPDATING; + /* TODO: remove TL_OPTION_FORCE_INDEX as it looks like it's not used */ + force_index= table_options & TL_OPTION_FORCE_INDEX; + ignore_leaves= table_options & TL_OPTION_IGNORE_LEAVES; + sequence= table_options & TL_OPTION_SEQUENCE; + derived= table_ident->sel; + + if (!table_ident->sel && info_schema) + { + schema_table= find_schema_table(thd, &table_name); + schema_table_name= table_name; + } + select_lex= sel; + /* + We can't cache internal temporary tables between prepares as the + table may be deleted before next exection. + */ + cacheable_table= !table_ident->is_derived_table(); + index_hints= index_hints_ptr; + option= option_ptr ? option_ptr->str : 0; +} + /* calculate md5 of query diff --git a/sql/table.h b/sql/table.h index 2ef61ee9f7e..a991462230e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2175,8 +2175,23 @@ struct TABLE_CHAIN void set_end_pos(TABLE_LIST **pos) { end_pos= pos; } }; +class Table_ident; struct TABLE_LIST { + TABLE_LIST(THD *thd, + LEX_CSTRING db_str, + bool fqtn, + LEX_CSTRING alias_str, + bool has_alias_ptr, + Table_ident *table_ident, + thr_lock_type lock_t, + enum_mdl_type mdl_t, + ulong table_opts, + bool info_schema, + st_select_lex *sel, + List *index_hints_ptr, + LEX_STRING *option_ptr); + TABLE_LIST() = default; /* Remove gcc warning */ enum prelocking_types From 41e7ceb0ac5a320e40817c31893dc336c2223713 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 15 Apr 2024 22:54:20 +0200 Subject: [PATCH 144/313] MDEV-33889 Read only server throws error when running a create temporary table as select statement create_partitioning_metadata() should only mark transaction r/w if it actually did anything (that is, the table is partitioned). otherwise it's a no-op, called even for temporary tables and it shouldn't do anything at all --- mysql-test/main/read_only_innodb.result | 25 +++++++++++++++++- mysql-test/main/read_only_innodb.test | 28 ++++++++++++++++++++- mysql-test/suite/galera/r/MDEV-27806.result | 2 +- sql/ha_partition.cc | 1 + sql/handler.cc | 2 -- 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/read_only_innodb.result b/mysql-test/main/read_only_innodb.result index abfc5322ed0..03046f7dad8 100644 --- a/mysql-test/main/read_only_innodb.result +++ b/mysql-test/main/read_only_innodb.result @@ -70,7 +70,7 @@ UNLOCK TABLES; DROP TABLE t1; DROP USER test@localhost; disconnect con1; -echo End of 5.1 tests +# End of 5.1 tests # # Bug#33669: Transactional temporary tables do not work under --read-only # @@ -244,3 +244,26 @@ connection default; SET GLOBAL READ_ONLY = OFF; DROP USER bug33669@localhost; DROP DATABASE db1; +# End of 5.5 tests +# +# MDEV-33889 Read only server throws error when running a create temporary table as select statement +# +create table t1(a int) engine=innodb; +create user u1@localhost; +grant insert, select, update, delete, create temporary tables on test.* to u1@localhost; +insert into t1 values (1); +set global read_only=1; +connect u1,localhost,u1; +set default_tmp_storage_engine=innodb; +create temporary table tt1 (a int); +create temporary table tt2 like t1; +create temporary table tt3 as select * from t1; +select * from tt3; +a +1 +disconnect u1; +connection default; +drop table t1; +drop user u1@localhost; +set global read_only=0; +# End of 10.5 tests diff --git a/mysql-test/main/read_only_innodb.test b/mysql-test/main/read_only_innodb.test index 4b00c32b185..7ad05ca55af 100644 --- a/mysql-test/main/read_only_innodb.test +++ b/mysql-test/main/read_only_innodb.test @@ -103,7 +103,7 @@ DROP USER test@localhost; disconnect con1; ---echo echo End of 5.1 tests +--echo # End of 5.1 tests --echo # --echo # Bug#33669: Transactional temporary tables do not work under --read-only @@ -250,3 +250,29 @@ SET GLOBAL READ_ONLY = OFF; DROP USER bug33669@localhost; DROP DATABASE db1; +--echo # End of 5.5 tests + +--echo # +--echo # MDEV-33889 Read only server throws error when running a create temporary table as select statement +--echo # +create table t1(a int) engine=innodb; +create user u1@localhost; +grant insert, select, update, delete, create temporary tables on test.* to u1@localhost; +insert into t1 values (1); +set global read_only=1; + +connect u1,localhost,u1; +set default_tmp_storage_engine=innodb; + +create temporary table tt1 (a int); +create temporary table tt2 like t1; +create temporary table tt3 as select * from t1; +select * from tt3; +disconnect u1; + +connection default; +drop table t1; +drop user u1@localhost; +set global read_only=0; + +--echo # End of 10.5 tests diff --git a/mysql-test/suite/galera/r/MDEV-27806.result b/mysql-test/suite/galera/r/MDEV-27806.result index 0f7ac79e4cd..6fe288f4e8e 100644 --- a/mysql-test/suite/galera/r/MDEV-27806.result +++ b/mysql-test/suite/galera/r/MDEV-27806.result @@ -37,7 +37,7 @@ mysqld-bin.000002 # Gtid # # BEGIN GTID #-#-# mysqld-bin.000002 # Query # # use `test`; CREATE TABLE `ts1` ( `f1` int(11) NOT NULL ) -mysqld-bin.000002 # Xid # # COMMIT /* XID */ +mysqld-bin.000002 # Query # # COMMIT connection node_2; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index de003bad628..8606c28d046 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -690,6 +690,7 @@ int ha_partition::create_partitioning_metadata(const char *path, partition_element *part; DBUG_ENTER("ha_partition::create_partitioning_metadata"); + mark_trx_read_write(); /* We need to update total number of parts since we might write the handler file as part of a partition management command diff --git a/sql/handler.cc b/sql/handler.cc index 40dfbffa667..8b299ae1b9e 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -5251,8 +5251,6 @@ handler::ha_create_partitioning_metadata(const char *name, DBUG_ASSERT(m_lock_type == F_UNLCK || (!old_name && strcmp(name, table_share->path.str))); - - mark_trx_read_write(); return create_partitioning_metadata(name, old_name, action_flag); } From 4aeba2590b86b41fde0bbb0f16148bf16afb41c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 12 Apr 2024 09:15:53 +0300 Subject: [PATCH 145/313] MDEV-33895 : Galera test failure on galera_sr.MDEV-25718 Test was waiting INSERT-clause to make rollback but wait_condition was too tight. State could be Freeing items or Rollback. Fixed wait_condition to expect one of them. --- mysql-test/suite/galera_sr/t/MDEV-25718.test | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/galera_sr/t/MDEV-25718.test b/mysql-test/suite/galera_sr/t/MDEV-25718.test index 9aebbdc7c5c..037cd300709 100644 --- a/mysql-test/suite/galera_sr/t/MDEV-25718.test +++ b/mysql-test/suite/galera_sr/t/MDEV-25718.test @@ -43,8 +43,9 @@ SET SESSION wsrep_sync_wait = 0; SET debug_sync = "now SIGNAL write_row_continue"; # Let's give the INSERT some time, to make sure it does rollback ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = "INSERT INTO t1 VALUES (1)" AND STATE = "Freeing items"; ---source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = "INSERT INTO t1 VALUES (1)" AND (STATE = "Freeing items" OR STATE = 'Rollback'); +--let $wait_condition_on_error_output = SELECT INFO, STATE FROM INFORMATION_SCHEMA.PROCESSLIST +--source include/wait_condition_with_debug.inc # Resume the DDL in streaming_rollback SET SESSION debug_sync = "now SIGNAL wsrep_streaming_rollback_continue"; From 9164c2b8bbad6e0e8b0729ca0704f8dfcf826a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 17 Apr 2024 10:10:23 +0300 Subject: [PATCH 146/313] Tests: remove a duplicated check This fixes up the merge commit 9b18275623026ccfbffb348d56cb629b6255f574 --- mysql-test/main/kill_processlist-6619.test | 3 --- 1 file changed, 3 deletions(-) diff --git a/mysql-test/main/kill_processlist-6619.test b/mysql-test/main/kill_processlist-6619.test index 3000387f797..9d523b2264b 100644 --- a/mysql-test/main/kill_processlist-6619.test +++ b/mysql-test/main/kill_processlist-6619.test @@ -4,9 +4,6 @@ --source include/not_embedded.inc --source include/have_debug_sync.inc -let $wait_condition=select count(*) = 1 from information_schema.processlist; -source include/wait_condition.inc; - # Ensure no lingering connections from an earlier test run, which can very # rarely still be visible in SHOW PROCESSLIST here. --let $wait_condition= SELECT COUNT(*) = 1 from information_schema.processlist From 2ba79aba2ba44e1774d572f4127c2e69e060dc40 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 17 Apr 2024 09:58:34 +0200 Subject: [PATCH 147/313] Revert "MDEV-33840 tpool : switch off maintenance timer when not needed." This reverts commit 09bae92c16f9c37c931ab3f7932664f55bb9a842. --- tpool/tpool_generic.cc | 70 ++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc index 0a2f9f8f5e1..8dbd7c94d30 100644 --- a/tpool/tpool_generic.cc +++ b/tpool/tpool_generic.cc @@ -270,10 +270,10 @@ class thread_pool_generic : public thread_pool OFF, ON }; timer_state_t m_timer_state= timer_state_t::OFF; - void switch_timer(timer_state_t state,std::unique_lock &lk); + void switch_timer(timer_state_t state); /* Updates idle_since, and maybe switches the timer off */ - void check_idle(std::chrono::system_clock::time_point now, std::unique_lock &lk); + void check_idle(std::chrono::system_clock::time_point now); /** time point when timer last ran, used as a coarse clock. */ std::chrono::system_clock::time_point m_timestamp; @@ -306,9 +306,9 @@ class thread_pool_generic : public thread_pool { ((thread_pool_generic *)arg)->maintenance(); } - bool add_thread(std::unique_lock &lk); + bool add_thread(); bool wake(worker_wake_reason reason, task *t = nullptr); - void maybe_wake_or_create_thread(std::unique_lock &lk); + void maybe_wake_or_create_thread(); bool too_many_active_threads(); bool get_task(worker_data *thread_var, task **t); bool wait_for_tasks(std::unique_lock &lk, @@ -616,11 +616,11 @@ void thread_pool_generic::worker_main(worker_data *thread_var) */ static const auto invalid_timestamp= std::chrono::system_clock::time_point::max(); -constexpr auto max_idle_time= std::chrono::seconds(20); +constexpr auto max_idle_time= std::chrono::minutes(1); /* Time since maintenance timer had nothing to do */ static std::chrono::system_clock::time_point idle_since= invalid_timestamp; -void thread_pool_generic::check_idle(std::chrono::system_clock::time_point now, std::unique_lock &lk) +void thread_pool_generic::check_idle(std::chrono::system_clock::time_point now) { DBUG_ASSERT(m_task_queue.empty()); @@ -647,7 +647,7 @@ void thread_pool_generic::check_idle(std::chrono::system_clock::time_point now, if (now - idle_since > max_idle_time) { idle_since= invalid_timestamp; - switch_timer(timer_state_t::OFF,lk); + switch_timer(timer_state_t::OFF); } } @@ -681,7 +681,7 @@ void thread_pool_generic::maintenance() if (m_task_queue.empty()) { - check_idle(m_timestamp, lk); + check_idle(m_timestamp); m_last_activity = m_tasks_dequeued + m_wakeups; return; } @@ -701,7 +701,7 @@ void thread_pool_generic::maintenance() } } - maybe_wake_or_create_thread(lk); + maybe_wake_or_create_thread(); size_t thread_cnt = (int)thread_count(); if (m_last_activity == m_tasks_dequeued + m_wakeups && @@ -709,7 +709,7 @@ void thread_pool_generic::maintenance() { // no progress made since last iteration. create new // thread - add_thread(lk); + add_thread(); } m_last_activity = m_tasks_dequeued + m_wakeups; m_last_thread_count= thread_cnt; @@ -736,14 +736,14 @@ static int throttling_interval_ms(size_t n_threads,size_t concurrency) } /* Create a new worker.*/ -bool thread_pool_generic::add_thread(std::unique_lock &lk) +bool thread_pool_generic::add_thread() { size_t n_threads = thread_count(); if (n_threads >= m_max_threads) return false; - if (n_threads >= m_min_threads && m_min_threads != m_max_threads) + if (n_threads >= m_min_threads) { auto now = std::chrono::system_clock::now(); if (now - m_last_thread_creation < @@ -753,7 +753,7 @@ bool thread_pool_generic::add_thread(std::unique_lock &lk) Throttle thread creation and wakeup deadlock detection timer, if is it off. */ - switch_timer(timer_state_t::ON, lk); + switch_timer(timer_state_t::ON); return false; } @@ -835,10 +835,12 @@ thread_pool_generic::thread_pool_generic(int min_threads, int max_threads) : if (!m_concurrency) m_concurrency = 1; + // start the timer + m_maintenance_timer.set_time(0, (int)m_timer_interval.count()); } -void thread_pool_generic::maybe_wake_or_create_thread(std::unique_lock &lk) +void thread_pool_generic::maybe_wake_or_create_thread() { if (m_task_queue.empty()) return; @@ -851,7 +853,7 @@ void thread_pool_generic::maybe_wake_or_create_thread(std::unique_lockadd_ref(); m_tasks_enqueued++; m_task_queue.push(task); - maybe_wake_or_create_thread(lk); + maybe_wake_or_create_thread(); } @@ -893,7 +895,7 @@ void thread_pool_generic::wait_begin() m_waiting_task_count++; /* Maintain concurrency */ - maybe_wake_or_create_thread(lk); + maybe_wake_or_create_thread(); } @@ -908,30 +910,26 @@ void thread_pool_generic::wait_end() } -void thread_pool_generic::switch_timer(timer_state_t state, std::unique_lock &lk) +void thread_pool_generic::switch_timer(timer_state_t state) { if (m_timer_state == state) return; - /* No maintenance timer for fixed threadpool size.*/ - DBUG_ASSERT(m_min_threads != m_max_threads); - DBUG_ASSERT(lk.owns_lock()); + /* + We can't use timer::set_time, because mysys timers are deadlock + prone. + Instead, to switch off we increase the timer period + and decrease period to switch on. + + This might introduce delays in thread creation when needed, + as period will only be changed when timer fires next time. + For this reason, we can't use very long periods for the "off" state. + */ m_timer_state= state; - if(state == timer_state_t::OFF) - { - m_maintenance_timer.set_period(0); - } - else - { - /* - It is necessary to unlock the thread_pool::m_mtx - to avoid the deadlock with thr_timer's LOCK_timer. - Otherwise, lock order would be violated. - */ - lk.unlock(); - m_maintenance_timer.set_time(0, (int)m_timer_interval.count()); - lk.lock(); - } + long long period= (state == timer_state_t::OFF) ? + m_timer_interval.count()*10: m_timer_interval.count(); + + m_maintenance_timer.set_period((int)period); } From f6e9600f42f7e74e9a26d9a9a12c067b122889f8 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 17 Apr 2024 10:48:24 +0200 Subject: [PATCH 148/313] MDEV-33840 tpool- switch to longer maintainence timer interval, if pool is idle Previous solution, that would entirely switch timer off, turned out to be deadlock prone. This patch fixed previous attempt to switch between long/short interval periods in MDEV-24295. Now, initial state of the timer is fixed (it is ON). Also, avoid switching timer to longer periods if there is any activity in the pool. --- tpool/tpool_generic.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc index 8dbd7c94d30..6d2dc22926b 100644 --- a/tpool/tpool_generic.cc +++ b/tpool/tpool_generic.cc @@ -644,7 +644,7 @@ void thread_pool_generic::check_idle(std::chrono::system_clock::time_point now) } /* Switch timer off after 1 minute of idle time */ - if (now - idle_since > max_idle_time) + if (now - idle_since > max_idle_time && m_active_threads.empty()) { idle_since= invalid_timestamp; switch_timer(timer_state_t::OFF); @@ -743,6 +743,12 @@ bool thread_pool_generic::add_thread() if (n_threads >= m_max_threads) return false; + /* + Deadlock danger exists, so monitor pool health + with maintenance timer. + */ + switch_timer(timer_state_t::ON); + if (n_threads >= m_min_threads) { auto now = std::chrono::system_clock::now(); @@ -753,8 +759,6 @@ bool thread_pool_generic::add_thread() Throttle thread creation and wakeup deadlock detection timer, if is it off. */ - switch_timer(timer_state_t::ON); - return false; } } @@ -837,6 +841,7 @@ thread_pool_generic::thread_pool_generic(int min_threads, int max_threads) : // start the timer m_maintenance_timer.set_time(0, (int)m_timer_interval.count()); + m_timer_state = timer_state_t::ON; } From 040069f4baead789bcb9dd55bb4932f6d1388d7c Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Wed, 17 Apr 2024 15:16:50 +0530 Subject: [PATCH 149/313] MDEV-33431 Latching order violation reported fil_system.sys_space.latch and ibuf_pessimistic_insert_mutex Issue: ------ The actual order of acquisition of the IBUF pessimistic insert mutex (SYNC_IBUF_PESS_INSERT_MUTEX) and IBUF header page latch (SYNC_IBUF_HEADER) w.r.t space latch (SYNC_FSP) differs from the order defined in sync0types.h. It was not discovered earlier as the path to ibuf_remove_free_page was not covered by the mtr test. Ideal order and one defined in sync0types.h is as follows. SYNC_IBUF_HEADER -> SYNC_IBUF_PESS_INSERT_MUTEX -> SYNC_FSP In ibuf_remove_free_page, we acquire space latch earlier and we have the order as follows resulting in the assert with innodb_sync_debug=on. SYNC_FSP -> SYNC_IBUF_HEADER -> SYNC_IBUF_PESS_INSERT_MUTEX Fix: --- We do maintain this order in other places and there doesn't seem to be any real issue here. To reduce impact in GA versions, we avoid doing extensive changes in mutex ordering to match the current SYNC_IBUF_PESS_INSERT_MUTEX order. Instead we relax the ordering check for IBUF pessimistic insert mutex using SYNC_NO_ORDER_CHECK. --- .../suite/innodb/r/change_buffer_free.result | 32 +++++++++++ .../suite/innodb/t/change_buffer_free.opt | 2 + .../suite/innodb/t/change_buffer_free.test | 54 +++++++++++++++++++ storage/innobase/ibuf/ibuf0ibuf.cc | 5 ++ storage/innobase/sync/sync0debug.cc | 19 ++++++- 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/innodb/r/change_buffer_free.result create mode 100644 mysql-test/suite/innodb/t/change_buffer_free.opt create mode 100644 mysql-test/suite/innodb/t/change_buffer_free.test diff --git a/mysql-test/suite/innodb/r/change_buffer_free.result b/mysql-test/suite/innodb/r/change_buffer_free.result new file mode 100644 index 00000000000..a22ed16917e --- /dev/null +++ b/mysql-test/suite/innodb/r/change_buffer_free.result @@ -0,0 +1,32 @@ +SET @saved_change_buffering = @@GLOBAL.innodb_change_buffering; +SET @saved_file_per_table = @@GLOBAL.innodb_file_per_table; +SET @saved_change_buffering_debug = @@GLOBAL.innodb_change_buffering_debug; +SET GLOBAL innodb_change_buffering = NONE; +SET GLOBAL innodb_file_per_table = OFF; +CREATE TABLE t2(c1 INT AUTO_INCREMENT PRIMARY KEY,c2 CHAR(100))ENGINE=InnoDB; +CREATE INDEX i1 ON t2 (c2); +INSERT INTO t2(c2) VALUES('mariadb'); +INSERT INTO t2(c2) SELECT c2 FROM t2; +INSERT INTO t2(c2) SELECT c2 FROM t2; +INSERT INTO t2(c2) SELECT c2 FROM t2; +INSERT INTO t2(c2) SELECT c2 FROM t2; +INSERT INTO t2(c2) SELECT c2 FROM t2; +CREATE TABLE t1(c1 INT AUTO_INCREMENT PRIMARY KEY,c2 CHAR(100))ENGINE=InnoDB; +CREATE INDEX i1 ON t1 (c2); +INSERT INTO t1(c2) VALUES('mariadb'); +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +INSERT INTO t1(c2) SELECT c2 FROM t1; +SET GLOBAL innodb_change_buffering = all; +SET GLOBAL innodb_change_buffering_debug = 1; +SET DEBUG_DBUG='+d,ibuf_force_remove_free_page'; +INSERT INTO t2(c2) SELECT c2 FROM t2 IGNORE INDEX (i1) LIMIT 4; +INSERT INTO t1(c2) SELECT c2 FROM t1 IGNORE INDEX (i1) LIMIT 4; +SET DEBUG_DBUG='-d,ibuf_force_remove_free_page'; +SET GLOBAL innodb_change_buffering_debug = @saved_change_buffering_debug; +SET GLOBAL innodb_change_buffering = @saved_change_buffering; +DROP TABLE t2; +DROP TABLE t1; +SET GLOBAL innodb_file_per_table = @saved_file_per_table; diff --git a/mysql-test/suite/innodb/t/change_buffer_free.opt b/mysql-test/suite/innodb/t/change_buffer_free.opt new file mode 100644 index 00000000000..296def4f05a --- /dev/null +++ b/mysql-test/suite/innodb/t/change_buffer_free.opt @@ -0,0 +1,2 @@ +--innodb-page-size=4k +--innodb_sync_debug=on diff --git a/mysql-test/suite/innodb/t/change_buffer_free.test b/mysql-test/suite/innodb/t/change_buffer_free.test new file mode 100644 index 00000000000..0db9e3186ae --- /dev/null +++ b/mysql-test/suite/innodb/t/change_buffer_free.test @@ -0,0 +1,54 @@ +# +# MDEV 33431: Latching order violation reported fil_system.sys_space.latch and ibuf_pessimistic_insert_mutex +# +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +SET @saved_change_buffering = @@GLOBAL.innodb_change_buffering; +SET @saved_file_per_table = @@GLOBAL.innodb_file_per_table; +SET @saved_change_buffering_debug = @@GLOBAL.innodb_change_buffering_debug; + +SET GLOBAL innodb_change_buffering = NONE; +SET GLOBAL innodb_file_per_table = OFF; + +let $loop=2; +while ($loop) +{ + eval CREATE TABLE t$loop(c1 INT AUTO_INCREMENT PRIMARY KEY,c2 CHAR(100))ENGINE=InnoDB; + eval CREATE INDEX i1 ON t$loop (c2); + + eval INSERT INTO t$loop(c2) VALUES('mariadb'); + eval INSERT INTO t$loop(c2) SELECT c2 FROM t$loop; + eval INSERT INTO t$loop(c2) SELECT c2 FROM t$loop; + eval INSERT INTO t$loop(c2) SELECT c2 FROM t$loop; + eval INSERT INTO t$loop(c2) SELECT c2 FROM t$loop; + eval INSERT INTO t$loop(c2) SELECT c2 FROM t$loop; + + dec $loop; +} + +SET GLOBAL innodb_change_buffering = all; +SET GLOBAL innodb_change_buffering_debug = 1; + +SET DEBUG_DBUG='+d,ibuf_force_remove_free_page'; +let $loop=2; + +while ($loop) +{ + eval INSERT INTO t$loop(c2) SELECT c2 FROM t$loop IGNORE INDEX (i1) LIMIT 4; + dec $loop; +} +SET DEBUG_DBUG='-d,ibuf_force_remove_free_page'; + +SET GLOBAL innodb_change_buffering_debug = @saved_change_buffering_debug; +SET GLOBAL innodb_change_buffering = @saved_change_buffering; + +let $loop=2; +while ($loop) +{ + eval DROP TABLE t$loop; + dec $loop; +} + +SET GLOBAL innodb_file_per_table = @saved_file_per_table; diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index cdb4967b663..8888e538e05 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2011,6 +2011,11 @@ ibuf_free_excess_pages(void) /* Free at most a few pages at a time, so that we do not delay the requested service too much */ + DBUG_EXECUTE_IF("ibuf_force_remove_free_page", + ibuf_remove_free_page(); + return; + ); + for (ulint i = 0; i < 4; i++) { ibool too_much_free; diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc index dd40e95dd50..78f6028b60d 100644 --- a/storage/innobase/sync/sync0debug.cc +++ b/storage/innobase/sync/sync0debug.cc @@ -1208,7 +1208,24 @@ sync_latch_meta_init() LATCH_ADD_MUTEX(IBUF, SYNC_IBUF_MUTEX, ibuf_mutex_key); - LATCH_ADD_MUTEX(IBUF_PESSIMISTIC_INSERT, SYNC_IBUF_PESS_INSERT_MUTEX, + /* The actual order of acquisition of the IBUF pessimistic insert mutex + (SYNC_IBUF_PESS_INSERT_MUTEX) and IBUF header page latch + (SYNC_IBUF_HEADER) w.r.t space latch (SYNC_FSP) differs from the order + defined in sync0types.h. It was not discovered earlier as the path to + ibuf_remove_free_page was not covered by the mtr test. Ideal order and + one defined in sync0types.h is as follows. + SYNC_IBUF_HEADER -> SYNC_IBUF_PESS_INSERT_MUTEX -> SYNC_FSP + + In ibuf_remove_free_page, we acquire space latch earlier and we have + the order as follows resulting in the assert with innodb_sync_debug=on. + SYNC_FSP -> SYNC_IBUF_HEADER -> SYNC_IBUF_PESS_INSERT_MUTEX + + We do maintain this order in other places and there doesn't seem to be + any real issue here. To reduce impact in GA versions, we avoid doing + extensive changes in mutex ordering to match the current + SYNC_IBUF_PESS_INSERT_MUTEX order. Instead we relax the ordering check + for IBUF pessimistic insert mutex using SYNC_NO_ORDER_CHECK. */ + LATCH_ADD_MUTEX(IBUF_PESSIMISTIC_INSERT, SYNC_NO_ORDER_CHECK, ibuf_pessimistic_insert_mutex_key); LATCH_ADD_MUTEX(PURGE_SYS_PQ, SYNC_PURGE_QUEUE, From 46e9e92e22cd9b38b4130cfe0ce9790e04d81380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 17 Apr 2024 13:25:12 +0300 Subject: [PATCH 150/313] MDEV-33855 MSAN use-of-uninitialized-value in rtr_pcur_getnext_from_path() rtr_pcur_getnext_from_path(): Remove a bogus assertion that may cause a data races with buf_LRU_block_free_non_file_page(). If my_latch_mode == BTR_MODIFY_LEAF, we would have released all page latches and buffer-fixes by invoking mtr->rollback_to_savepoint(1). After this point, the btr_cur->page_cur.block is no longer valid and must not be accessed. Before 03ca6495df31313c96e38834b9a235245e2ae2a8 this assertion had been disabled, because the preprocessor symbol UNIV_RTR_DEBUG had never been enabled (except when explicitly specified in CMAKE_CXX_FLAGS). Reviewed by: Debarun Banerjee --- storage/innobase/gis/gis0sea.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index fb4fcf7bc8d..9aedd4af69c 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -289,10 +289,6 @@ rtr_pcur_getnext_from_path( mtr->rollback_to_savepoint(1); } - ut_ad((my_latch_mode | 4) == BTR_CONT_MODIFY_TREE - || !page_is_leaf(btr_cur_get_page(btr_cur)) - || !btr_cur->page_cur.block->page.lock.have_any()); - const auto block_savepoint = mtr->get_savepoint(); block = buf_page_get_gen( page_id_t(index->table->space_id, From e459ce8336ba37ea12a405f29e5fae866fd28701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 17 Apr 2024 16:47:41 +0300 Subject: [PATCH 151/313] MDEV-33779 InnoDB row operations could be faster We have quite a few assertions ut_a(m_prebuilt->trx == thd_to_trx(ha_thd())); in low-level functions. These had better be debug assertions for performance reasons. It should suffice to check that condition in the less frequently invoked ha_innobase::change_active_index(). convert_search_mode_to_innobase(): Return whether the mode is unsupported, and optionally update ha_innobase::m_last_match_mode. ha_innobase::index_read(): Only branch on find_flag once, and simplify the error handling after invoking row_search_mvcc(). ha_innobase::rnd_pos(): Remove an assertion that is duplicating one in ha_innobase::index_read(), which we are calling unconditionally. ha_innobase::records_in_range(): Check only once whether min_key, max_key are null pointers. row_sel_convert_mysql_key_to_innobase(): Declare all parameters except the conversion buffer pointer (buf) to be nonnull. Reviewed by: Debarun Banerjee --- storage/innobase/handler/ha_innodb.cc | 280 ++++++++++++-------------- storage/innobase/include/row0sel.h | 4 +- 2 files changed, 128 insertions(+), 156 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index d6210c5bfaa..418f39885f7 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -8883,47 +8883,63 @@ ha_innobase::index_end(void) DBUG_RETURN(0); } -/*********************************************************************//** -Converts a search mode flag understood by MySQL to a flag understood -by InnoDB. */ -page_cur_mode_t -convert_search_mode_to_innobase( -/*============================*/ - ha_rkey_function find_flag) +/** Convert a MariaDB search mode to an InnoDB search mode. +@tparam last_match whether last_match_mode is to be set +@param find_flag MariaDB search mode +@param mode InnoDB search mode +@param last_match_mode pointer to ha_innobase::m_last_match_mode +@return whether the search mode is unsupported */ +template +static bool convert_search_mode_to_innobase(ha_rkey_function find_flag, + page_cur_mode_t &mode, + uint *last_match_mode= nullptr) { - switch (find_flag) { - case HA_READ_KEY_EXACT: - /* this does not require the index to be UNIQUE */ - case HA_READ_KEY_OR_NEXT: - return(PAGE_CUR_GE); - case HA_READ_AFTER_KEY: - return(PAGE_CUR_G); - case HA_READ_BEFORE_KEY: - return(PAGE_CUR_L); - case HA_READ_KEY_OR_PREV: - case HA_READ_PREFIX_LAST: - case HA_READ_PREFIX_LAST_OR_PREV: - return(PAGE_CUR_LE); - case HA_READ_MBR_CONTAIN: - return(PAGE_CUR_CONTAIN); - case HA_READ_MBR_INTERSECT: - return(PAGE_CUR_INTERSECT); - case HA_READ_MBR_WITHIN: - return(PAGE_CUR_WITHIN); - case HA_READ_MBR_DISJOINT: - return(PAGE_CUR_DISJOINT); - case HA_READ_MBR_EQUAL: - return(PAGE_CUR_MBR_EQUAL); - case HA_READ_PREFIX: - return(PAGE_CUR_UNSUPP); - /* do not use "default:" in order to produce a gcc warning: - enumeration value '...' not handled in switch - (if -Wswitch or -Wall is used) */ - } + mode= PAGE_CUR_LE; + if (last_match) + *last_match_mode= 0; - my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "this functionality"); + switch (find_flag) { + case HA_READ_KEY_EXACT: + /* this does not require the index to be UNIQUE */ + if (last_match) + *last_match_mode= ROW_SEL_EXACT; + /* fall through */ + case HA_READ_KEY_OR_NEXT: + mode= PAGE_CUR_GE; + return false; + case HA_READ_AFTER_KEY: + mode= PAGE_CUR_G; + return false; + case HA_READ_BEFORE_KEY: + mode= PAGE_CUR_L; + return false; + case HA_READ_PREFIX_LAST: + if (last_match) + *last_match_mode= ROW_SEL_EXACT_PREFIX; + /* fall through */ + case HA_READ_KEY_OR_PREV: + case HA_READ_PREFIX_LAST_OR_PREV: + return false; + case HA_READ_MBR_CONTAIN: + mode= PAGE_CUR_CONTAIN; + return false; + case HA_READ_MBR_INTERSECT: + mode= PAGE_CUR_INTERSECT; + return false; + case HA_READ_MBR_WITHIN: + mode= PAGE_CUR_WITHIN; + return false; + case HA_READ_MBR_DISJOINT: + mode= PAGE_CUR_DISJOINT; + return false; + case HA_READ_MBR_EQUAL: + mode= PAGE_CUR_MBR_EQUAL; + return false; + case HA_READ_PREFIX: + break; + } - return(PAGE_CUR_UNSUPP); + return true; } /* @@ -9001,8 +9017,7 @@ ha_innobase::index_read( mariadb_set_stats set_stats_temporary(handler_stats); DEBUG_SYNC_C("ha_innobase_index_read_begin"); - ut_a(m_prebuilt->trx == thd_to_trx(m_user_thd)); - ut_ad(key_len != 0 || find_flag != HA_READ_KEY_EXACT); + ut_ad(m_prebuilt->trx == thd_to_trx(m_user_thd)); dict_index_t* index = m_prebuilt->index; @@ -9038,7 +9053,8 @@ ha_innobase::index_read( build_template(false); } - if (key_ptr != NULL) { + if (key_len) { + ut_ad(key_ptr); /* Convert the search key value to InnoDB format into m_prebuilt->search_tuple */ @@ -9048,42 +9064,31 @@ ha_innobase::index_read( m_prebuilt->srch_key_val_len, index, (byte*) key_ptr, - (ulint) key_len); + key_len); DBUG_ASSERT(m_prebuilt->search_tuple->n_fields > 0); } else { + ut_ad(find_flag != HA_READ_KEY_EXACT); /* We position the cursor to the last or the first entry in the index */ dtuple_set_n_fields(m_prebuilt->search_tuple, 0); } - page_cur_mode_t mode = convert_search_mode_to_innobase(find_flag); + page_cur_mode_t mode; - ulint match_mode = 0; - - if (find_flag == HA_READ_KEY_EXACT) { - - match_mode = ROW_SEL_EXACT; - - } else if (find_flag == HA_READ_PREFIX_LAST) { - - match_mode = ROW_SEL_EXACT_PREFIX; + if (convert_search_mode_to_innobase(find_flag, mode, + &m_last_match_mode)) { + table->status = STATUS_NOT_FOUND; + DBUG_RETURN(HA_ERR_UNSUPPORTED); } - m_last_match_mode = (uint) match_mode; - - dberr_t ret = mode == PAGE_CUR_UNSUPP ? DB_UNSUPPORTED - : row_search_mvcc(buf, mode, m_prebuilt, match_mode, 0); + dberr_t ret = + row_search_mvcc(buf, mode, m_prebuilt, m_last_match_mode, 0); DBUG_EXECUTE_IF("ib_select_query_failure", ret = DB_ERROR;); - int error; - - switch (ret) { - case DB_SUCCESS: - error = 0; - table->status = 0; + if (UNIV_LIKELY(ret == DB_SUCCESS)) { if (m_prebuilt->table->is_system_db) { srv_stats.n_system_rows_read.add( thd_get_thread_id(m_prebuilt->trx->mysql_thd), 1); @@ -9091,48 +9096,33 @@ ha_innobase::index_read( srv_stats.n_rows_read.add( thd_get_thread_id(m_prebuilt->trx->mysql_thd), 1); } - break; + table->status = 0; + DBUG_RETURN(0); + } - case DB_RECORD_NOT_FOUND: - error = HA_ERR_KEY_NOT_FOUND; - table->status = STATUS_NOT_FOUND; - break; - - case DB_END_OF_INDEX: - error = HA_ERR_KEY_NOT_FOUND; - table->status = STATUS_NOT_FOUND; - break; + table->status = STATUS_NOT_FOUND; + switch (ret) { case DB_TABLESPACE_DELETED: ib_senderrf( m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR, ER_TABLESPACE_DISCARDED, table->s->table_name.str); - - table->status = STATUS_NOT_FOUND; - error = HA_ERR_TABLESPACE_MISSING; - break; - + DBUG_RETURN(HA_ERR_TABLESPACE_MISSING); + case DB_RECORD_NOT_FOUND: + case DB_END_OF_INDEX: + DBUG_RETURN(HA_ERR_KEY_NOT_FOUND); case DB_TABLESPACE_NOT_FOUND: - ib_senderrf( m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR, ER_TABLESPACE_MISSING, table->s->table_name.str); - - table->status = STATUS_NOT_FOUND; - error = HA_ERR_TABLESPACE_MISSING; - break; - + DBUG_RETURN(HA_ERR_TABLESPACE_MISSING); default: - error = convert_error_code_to_mysql( - ret, m_prebuilt->table->flags, m_user_thd); - - table->status = STATUS_NOT_FOUND; - break; + DBUG_RETURN(convert_error_code_to_mysql( + ret, m_prebuilt->table->flags, + m_user_thd)); } - - DBUG_RETURN(error); } /*******************************************************************//** @@ -9566,8 +9556,6 @@ ha_innobase::rnd_pos( DBUG_ENTER("rnd_pos"); DBUG_DUMP("key", pos, ref_length); - ut_a(m_prebuilt->trx == thd_to_trx(ha_thd())); - /* Note that we assume the length of the row reference is fixed for the table, and it is == ref_length */ @@ -14301,14 +14289,14 @@ ha_innobase::records_in_range( dict_index_t* index; dtuple_t* range_start; dtuple_t* range_end; - ha_rows n_rows; + ha_rows n_rows = HA_POS_ERROR; page_cur_mode_t mode1; page_cur_mode_t mode2; mem_heap_t* heap; DBUG_ENTER("records_in_range"); - ut_a(m_prebuilt->trx == thd_to_trx(ha_thd())); + ut_ad(m_prebuilt->trx == thd_to_trx(ha_thd())); m_prebuilt->trx->op_info = "estimating records in index range"; @@ -14321,12 +14309,7 @@ ha_innobase::records_in_range( /* There exists possibility of not being able to find requested index due to inconsistency between MySQL and InoDB dictionary info. Necessary message should have been printed in innobase_get_index() */ - if (!m_prebuilt->table->space) { - n_rows = HA_POS_ERROR; - goto func_exit; - } - if (!index) { - n_rows = HA_POS_ERROR; + if (!index || !m_prebuilt->table->space) { goto func_exit; } if (index->is_corrupted()) { @@ -14342,61 +14325,50 @@ ha_innobase::records_in_range( + sizeof(dtuple_t))); range_start = dtuple_create(heap, key->ext_key_parts); - dict_index_copy_types(range_start, index, key->ext_key_parts); range_end = dtuple_create(heap, key->ext_key_parts); - dict_index_copy_types(range_end, index, key->ext_key_parts); - row_sel_convert_mysql_key_to_innobase( - range_start, - m_prebuilt->srch_key_val1, - m_prebuilt->srch_key_val_len, - index, - (byte*) (min_key ? min_key->key : (const uchar*) 0), - (ulint) (min_key ? min_key->length : 0)); - - DBUG_ASSERT(min_key - ? range_start->n_fields > 0 - : range_start->n_fields == 0); - - row_sel_convert_mysql_key_to_innobase( - range_end, - m_prebuilt->srch_key_val2, - m_prebuilt->srch_key_val_len, - index, - (byte*) (max_key ? max_key->key : (const uchar*) 0), - (ulint) (max_key ? max_key->length : 0)); - - DBUG_ASSERT(max_key - ? range_end->n_fields > 0 - : range_end->n_fields == 0); - - mode1 = convert_search_mode_to_innobase( - min_key ? min_key->flag : HA_READ_KEY_EXACT); - - mode2 = convert_search_mode_to_innobase( - max_key ? max_key->flag : HA_READ_KEY_EXACT); - - if (mode1 != PAGE_CUR_UNSUPP && mode2 != PAGE_CUR_UNSUPP) { - - if (dict_index_is_spatial(index)) { - /*Only min_key used in spatial index. */ - n_rows = rtr_estimate_n_rows_in_range( - index, range_start, mode1); - } else { - btr_pos_t tuple1(range_start, mode1, pages->first_page); - btr_pos_t tuple2(range_end, mode2, pages->last_page); - n_rows = btr_estimate_n_rows_in_range( - index, &tuple1, &tuple2); - pages->first_page= tuple1.page_id.raw(); - pages->last_page= tuple2.page_id.raw(); - } + if (!min_key) { + mode1 = PAGE_CUR_GE; + dtuple_set_n_fields(range_start, 0); + } else if (convert_search_mode_to_innobase(min_key->flag, mode1)) { + goto unsupported; } else { - - n_rows = HA_POS_ERROR; + dict_index_copy_types(range_start, index, key->ext_key_parts); + row_sel_convert_mysql_key_to_innobase( + range_start, + m_prebuilt->srch_key_val1, + m_prebuilt->srch_key_val_len, + index, min_key->key, min_key->length); + DBUG_ASSERT(range_start->n_fields > 0); } - mem_heap_free(heap); + if (!max_key) { + mode2 = PAGE_CUR_GE; + dtuple_set_n_fields(range_end, 0); + } else if (convert_search_mode_to_innobase(max_key->flag, mode2)) { + goto unsupported; + } else { + dict_index_copy_types(range_end, index, key->ext_key_parts); + row_sel_convert_mysql_key_to_innobase( + range_end, + m_prebuilt->srch_key_val2, + m_prebuilt->srch_key_val_len, + index, max_key->key, max_key->length); + DBUG_ASSERT(range_end->n_fields > 0); + } + + if (dict_index_is_spatial(index)) { + /*Only min_key used in spatial index. */ + n_rows = rtr_estimate_n_rows_in_range( + index, range_start, mode1); + } else { + btr_pos_t tuple1(range_start, mode1, pages->first_page); + btr_pos_t tuple2(range_end, mode2, pages->last_page); + n_rows = btr_estimate_n_rows_in_range(index, &tuple1, &tuple2); + pages->first_page= tuple1.page_id.raw(); + pages->last_page= tuple2.page_id.raw(); + } DBUG_EXECUTE_IF( "print_btr_estimate_n_rows_in_range_return_value", @@ -14407,11 +14379,7 @@ ha_innobase::records_in_range( (longlong) n_rows); ); -func_exit: - - m_prebuilt->trx->op_info = (char*)""; - - /* The MySQL optimizer seems to believe an estimate of 0 rows is + /* The MariaDB optimizer seems to believe an estimate of 0 rows is always accurate and may return the result 'Empty set' based on that. The accuracy is not guaranteed, and even if it were, for a locking read we should anyway perform the search to set the next-key lock. @@ -14421,6 +14389,10 @@ func_exit: n_rows = 1; } +unsupported: + mem_heap_free(heap); +func_exit: + m_prebuilt->trx->op_info = ""; DBUG_RETURN((ha_rows) n_rows); } diff --git a/storage/innobase/include/row0sel.h b/storage/innobase/include/row0sel.h index 8134c60fe72..54e4a1d283f 100644 --- a/storage/innobase/include/row0sel.h +++ b/storage/innobase/include/row0sel.h @@ -115,8 +115,8 @@ row_sel_convert_mysql_key_to_innobase( ulint buf_len, /*!< in: buffer length */ dict_index_t* index, /*!< in: index of the key value */ const byte* key_ptr, /*!< in: MySQL key value */ - ulint key_len); /*!< in: MySQL key value length */ - + ulint key_len) /*!< in: MySQL key value length */ + MY_ATTRIBUTE((nonnull(1,4,5))); /** Search for rows in the database using cursor. Function is mainly used for tables that are shared across connections and From e87a175b3adcd9e7d25e9f874c2fc640951911e0 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 10 Apr 2024 12:37:06 +0200 Subject: [PATCH 152/313] Fix LTO (aka interprocedural optimization) build with MSVC Also, disable MSVC LTO for static client libraries - they won't be usable for end-users. --- cmake/libutils.cmake | 6 ++++++ cmake/mariadb_connector_c.cmake | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index 4c8401971f6..c1293980717 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -370,5 +370,11 @@ ENDFUNCTION() FUNCTION (MAYBE_DISABLE_IPO target) IF(MSVC AND NOT CLANG_CL) SET_TARGET_PROPERTIES(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) + IF(CMAKE_CONFIGURATION_TYPES) + FOREACH(cfg ${CMAKE_CONFIGURATION_TYPES}) + STRING(TOUPPER "${cfg}" cfg_upper) + SET_TARGET_PROPERTIES(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_${cfg_upper} OFF) + ENDFOREACH() + ENDIF() ENDIF() ENDFUNCTION() diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake index a9b103345cd..b4f56597775 100644 --- a/cmake/mariadb_connector_c.cmake +++ b/cmake/mariadb_connector_c.cmake @@ -40,6 +40,13 @@ SET(CLIENT_PLUGIN_PVIO_SOCKET STATIC) MESSAGE("== Configuring MariaDB Connector/C") ADD_SUBDIRECTORY(libmariadb) +IF(MSVC AND TARGET mariadb_obj AND TARGET mariadbclient) + # With MSVC, do not produce LTCG-compiled static client libraries. + # They are not usable by end-users, being tied to exact compiler version + MAYBE_DISABLE_IPO(mariadb_obj) + MAYBE_DISABLE_IPO(mariadbclient) +ENDIF() + IF(UNIX) INSTALL(CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E make_directory \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}) From 173847b76a72135e1379f0cef7eccde39b570b0f Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 17 Apr 2024 15:56:45 +0200 Subject: [PATCH 153/313] Do not run maria_recover_encrypted with embedded. It uses shutdown/restart etc, features not compatible the embedded. also add have_debug.inc , since it uses debug_dbug variable --- mysql-test/suite/large_tests/t/maria_recover_encrypted.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/suite/large_tests/t/maria_recover_encrypted.test b/mysql-test/suite/large_tests/t/maria_recover_encrypted.test index 4c590e5e1f9..640bbacbc72 100644 --- a/mysql-test/suite/large_tests/t/maria_recover_encrypted.test +++ b/mysql-test/suite/large_tests/t/maria_recover_encrypted.test @@ -3,6 +3,8 @@ --source include/have_maria.inc --source include/default_charset.inc +--source include/not_embedded.inc +--source include/have_debug.inc # Cleanup --disable_warnings From b48de9737b0451a95df68d6327d7271ae54a3f44 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 17 Apr 2024 16:07:15 +0200 Subject: [PATCH 154/313] Remove duplicate key "Language" from .clang-format Latest Visual Studio complains about invalid format, it breaks formatting in the IDE --- .clang-format | 1 - 1 file changed, 1 deletion(-) diff --git a/.clang-format b/.clang-format index 7ce45951173..3633507cb13 100644 --- a/.clang-format +++ b/.clang-format @@ -70,7 +70,6 @@ IndentPPDirectives: None IndentWidth: 2 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: true -Language: Cpp MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 From 061adae9a26e9086f0072e49e06823299f8ce34f Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 15 Apr 2024 15:46:50 +0200 Subject: [PATCH 155/313] MDEV-16944 Fix file sharing issues on Windows in mysqltest On Windows systems, occurrences of ERROR_SHARING_VIOLATION due to conflicting share modes between processes accessing the same file can result in CreateFile failures. mysys' my_open() already incorporates a workaround by implementing wait/retry logic on Windows. But this does not help if files are opened using shell redirection like mysqltest traditionally did it, i.e via --echo exec "some text" > output_file In such cases, it is cmd.exe, that opens the output_file, and it won't do any sharing-violation retries. This commit addresses the issue by introducing a new built-in command, 'write_line', in mysqltest. This new command serves as a brief alternative to 'write_file', with a single line output, that also resolves variables like "exec" would. Internally, this command will use my_open(), and therefore retry-on-error logic. Hopefully this will eliminate the very sporadic "can't open file because it is used by another process" error on CI. --- client/mysqltest.cc | 49 ++++++++++++++++++- mysql-test/include/crash_mysqld.inc | 2 +- mysql-test/include/expect_crash.inc | 2 +- .../include/kill_and_restart_mysqld.inc | 2 +- mysql-test/include/kill_galera.inc | 2 +- mysql-test/include/kill_mysqld.inc | 2 +- mysql-test/include/rpl_start_server.inc | 2 +- mysql-test/include/rpl_stop_server.inc | 2 +- mysql-test/include/search_pattern_in_file.inc | 2 +- mysql-test/include/shutdown_mysqld.inc | 2 +- mysql-test/include/start_mysqld.inc | 4 +- mysql-test/main/crash_commit_before.test | 2 +- mysql-test/main/empty_server_name-8224.test | 4 +- .../main/host_cache_size_functionality.test | 8 +-- .../main/init_file_set_password-7656.test | 4 +- mysql-test/main/log_errchk.test | 4 +- mysql-test/main/lowercase_fs_on.test | 4 +- .../main/myisam_crash_before_flush_keys.test | 4 +- mysql-test/main/mysql_client_test.test | 2 +- mysql-test/main/mysql_client_test_comp.test | 2 +- .../main/mysql_client_test_nonblock.test | 2 +- mysql-test/main/openssl_1.test | 2 +- mysql-test/main/plugin_loaderr.test | 4 +- mysql-test/main/shutdown.test | 4 +- .../suite/binlog/include/binlog_index.inc | 12 ++--- .../t/binlog_autocommit_off_no_hang.test | 4 +- .../suite/binlog/t/binlog_rotate_perf.test | 4 +- .../binlog_encryption/restart_server.inc | 4 +- .../encryption/t/innodb-bad-key-change3.test | 12 ++--- .../encryption/t/innodb_encrypt_freed.test | 2 +- .../suite/galera/include/kill_galera.inc | 2 +- .../suite/galera/include/start_mysqld.inc | 4 +- .../galera/t/galera_ist_restart_joiner.test | 2 +- .../suite/galera/t/galera_pc_recovery.test | 8 +-- .../t/galera_restart_on_unknown_option.test | 4 +- mysql-test/suite/galera/t/mdev-22543.test | 2 +- .../suite/galera_3nodes_sr/t/GCF-832.test | 2 +- mysql-test/suite/innodb/t/alter_crash.test | 6 +-- .../suite/innodb/t/alter_rename_existing.test | 2 +- .../suite/innodb/t/doublewrite_debug.test | 4 +- .../suite/innodb/t/group_commit_crash.test | 2 +- ...group_commit_crash_no_optimize_thread.test | 2 +- .../suite/innodb/t/innodb-alter-tempfile.test | 2 +- .../t/innodb-change-buffer-recovery.test | 2 +- .../innodb/t/innodb-corrupted-table.test | 4 +- .../suite/innodb/t/innodb-wl5522-debug.test | 6 +-- .../suite/innodb/t/innodb_bug60196.test | 4 +- mysql-test/suite/innodb/t/log_file_name.test | 2 +- .../suite/innodb/t/temporary_table.test | 2 +- .../suite/innodb/t/undo_space_dblwr.test | 2 +- mysql-test/suite/innodb_fts/t/sync.test | 2 +- mysql-test/suite/innodb_gis/t/rollback.test | 2 +- mysql-test/suite/innodb_zip/t/restart.test | 18 +++---- .../suite/innodb_zip/t/wl5522_debug_zip.test | 6 +-- .../t/maria_recover_encrypted.test | 6 +-- mysql-test/suite/maria/bulk_insert_crash.test | 2 +- mysql-test/suite/maria/encrypt-no-key.test | 8 +-- mysql-test/suite/maria/encrypt-wrong-key.test | 12 ++--- .../suite/parts/inc/partition_crash.inc | 4 +- mysql-test/suite/perfschema/t/bad_option.test | 4 +- .../suite/perfschema/t/processlist_57.test | 10 ++-- .../t/setup_instruments_defaults.test | 4 +- .../t/statement_program_lost_inst.test | 4 +- .../t/rpl_domain_id_filter_master_crash.test | 4 +- .../suite/rpl/t/rpl_relay_max_extension.test | 4 +- mysql-test/suite/rpl/t/rpl_sync.test | 4 +- 66 files changed, 179 insertions(+), 134 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 7267cd6e036..fdee3e09851 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -398,7 +398,7 @@ enum enum_commands { Q_IF, Q_DISABLE_PARSING, Q_ENABLE_PARSING, Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST, - Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, Q_SKIP, + Q_WRITE_FILE, Q_WRITE_LINE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, Q_SKIP, Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES, Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR, Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE, @@ -501,6 +501,7 @@ const char *command_names[]= "remove_file", "file_exists", "write_file", + "write_line", "copy_file", "perl", "die", @@ -4302,6 +4303,49 @@ void do_write_file(struct st_command *command) do_write_file_command(command, FALSE); } +/** + Write a line to the start of the file. + Truncates existing file, creates new one if it doesn't exist. + + Usage + write_line ; + + Example + --write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + + @note Both the file and the line parameters are evaluated + (can be variables). + + @note This is a better alternative to + exec echo > file, as it doesn't depend on shell, + and can better handle sporadic file access errors caused + by antivirus or backup software on Windows. +*/ +void do_write_line(struct st_command *command) +{ + DYNAMIC_STRING ds_line; + DYNAMIC_STRING ds_filename; + + struct command_arg write_line_args[] = { + { "line", ARG_STRING, FALSE, &ds_line, "line to add" }, + { "filename", ARG_STRING, TRUE, &ds_filename, "File to write to" }, + }; + DBUG_ENTER("do_write_line"); + + check_command_args(command, + command->first_argument, + write_line_args, + sizeof(write_line_args)/sizeof(struct command_arg), + ' '); + + if (bad_path(ds_filename.str)) + DBUG_VOID_RETURN; + dynstr_append_mem(&ds_line, "\n", 1); + str_to_file2(ds_filename.str, ds_line.str, ds_line.length, FALSE); + dynstr_free(&ds_filename); + dynstr_free(&ds_line); + DBUG_VOID_RETURN; +} /* SYNOPSIS @@ -7423,7 +7467,7 @@ void str_to_file2(const char *fname, char *str, size_t size, my_bool append) die("Could not open '%s' for writing, errno: %d", buff, errno); if (append && my_seek(fd, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR) die("Could not find end of file '%s', errno: %d", buff, errno); - if (my_write(fd, (uchar*)str, size, MYF(MY_WME|MY_FNABP))) + if (size > 0 && my_write(fd, (uchar*)str, size, MYF(MY_WME|MY_FNABP))) die("write failed, errno: %d", errno); my_close(fd, MYF(0)); } @@ -10160,6 +10204,7 @@ int main(int argc, char **argv) break; case Q_FILE_EXIST: do_file_exist(command); break; case Q_WRITE_FILE: do_write_file(command); break; + case Q_WRITE_LINE: do_write_line(command); break; case Q_APPEND_FILE: do_append_file(command); break; case Q_DIFF_FILES: do_diff_files(command); break; case Q_SEND_QUIT: do_send_quit(command); break; diff --git a/mysql-test/include/crash_mysqld.inc b/mysql-test/include/crash_mysqld.inc index 4190d24d801..89bc8ced416 100644 --- a/mysql-test/include/crash_mysqld.inc +++ b/mysql-test/include/crash_mysqld.inc @@ -4,7 +4,7 @@ --source include/not_embedded.inc # Write file to make mysql-test-run.pl expect crash and restart ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Setup the mysqld to crash at shutdown SET debug_dbug="d,crash_shutdown"; diff --git a/mysql-test/include/expect_crash.inc b/mysql-test/include/expect_crash.inc index b4bd9828a08..56abc88ae24 100644 --- a/mysql-test/include/expect_crash.inc +++ b/mysql-test/include/expect_crash.inc @@ -2,4 +2,4 @@ --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect # There should be a debug crash after using this .inc file ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name diff --git a/mysql-test/include/kill_and_restart_mysqld.inc b/mysql-test/include/kill_and_restart_mysqld.inc index b67fb7350b4..50b28bcd494 100644 --- a/mysql-test/include/kill_and_restart_mysqld.inc +++ b/mysql-test/include/kill_and_restart_mysqld.inc @@ -7,7 +7,7 @@ if (!$restart_parameters) --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect --echo # Kill and $restart_parameters ---exec echo "$restart_parameters" > $_expect_file_name +--write_line "$restart_parameters" $_expect_file_name --shutdown_server 0 --source include/wait_until_disconnected.inc --enable_reconnect diff --git a/mysql-test/include/kill_galera.inc b/mysql-test/include/kill_galera.inc index aba672d8a89..887e21f5f79 100644 --- a/mysql-test/include/kill_galera.inc +++ b/mysql-test/include/kill_galera.inc @@ -3,7 +3,7 @@ # Write file to make mysql-test-run.pl expect the crash, but don't start it --let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name # Kill the connected server --disable_reconnect diff --git a/mysql-test/include/kill_mysqld.inc b/mysql-test/include/kill_mysqld.inc index 01ee7f82bdc..a41af2d74a6 100644 --- a/mysql-test/include/kill_mysqld.inc +++ b/mysql-test/include/kill_mysqld.inc @@ -2,6 +2,6 @@ --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect --echo # Kill the server ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name --shutdown_server 0 --source include/wait_until_disconnected.inc diff --git a/mysql-test/include/rpl_start_server.inc b/mysql-test/include/rpl_start_server.inc index 932fc9da7ef..0479dbbd8ac 100644 --- a/mysql-test/include/rpl_start_server.inc +++ b/mysql-test/include/rpl_start_server.inc @@ -49,7 +49,7 @@ if ($rpl_server_parameters) --source include/rpl_connection.inc # Write file to make mysql-test-run.pl start up the server again ---exec echo "$_rpl_start_server_command" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect +--write_line "$_rpl_start_server_command" $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect if (!$rpl_server_error) { diff --git a/mysql-test/include/rpl_stop_server.inc b/mysql-test/include/rpl_stop_server.inc index 470e86a139d..1e4a64cca25 100644 --- a/mysql-test/include/rpl_stop_server.inc +++ b/mysql-test/include/rpl_stop_server.inc @@ -44,7 +44,7 @@ if ($rpl_debug) # Write file to make mysql-test-run.pl expect the "crash", but don't start # it until it's told to ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect # Send shutdown to the connected server and give # it 60 seconds (of mysqltest's default) to die before zapping it diff --git a/mysql-test/include/search_pattern_in_file.inc b/mysql-test/include/search_pattern_in_file.inc index a899a9294cc..e02b7ac8d64 100644 --- a/mysql-test/include/search_pattern_in_file.inc +++ b/mysql-test/include/search_pattern_in_file.inc @@ -38,7 +38,7 @@ # let SEARCH_FILE= $error_log; # # Stop the server # let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; -# --exec echo "wait" > $restart_file +# --write_line wait $restart_file # --shutdown_server # --source include/wait_until_disconnected.inc # diff --git a/mysql-test/include/shutdown_mysqld.inc b/mysql-test/include/shutdown_mysqld.inc index 2db4624e4ac..1684d81970a 100644 --- a/mysql-test/include/shutdown_mysqld.inc +++ b/mysql-test/include/shutdown_mysqld.inc @@ -24,7 +24,7 @@ if ($rpl_inited) # Write file to make mysql-test-run.pl expect the "crash", but don't start it --let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name # Avoid warnings from connection threads that does not have time to exit --disable_query_log diff --git a/mysql-test/include/start_mysqld.inc b/mysql-test/include/start_mysqld.inc index 6e448cb2efd..91b06997d6e 100644 --- a/mysql-test/include/start_mysqld.inc +++ b/mysql-test/include/start_mysqld.inc @@ -21,7 +21,7 @@ if ($restart_bindir) if ($restart_parameters) { - --exec echo "$restart_cmd: $restart_parameters" > $_expect_file_name + --write_line "$restart_cmd: $restart_parameters" $_expect_file_name if (!$restart_noprint) { --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -34,7 +34,7 @@ if ($restart_parameters) } if (!$restart_parameters) { - --exec echo "$restart_cmd" > $_expect_file_name + --write_line "$restart_cmd" $_expect_file_name if ($restart_noprint < 2) { --exec echo "# $restart_cmd" diff --git a/mysql-test/main/crash_commit_before.test b/mysql-test/main/crash_commit_before.test index 93b96de6e53..30b59ce4480 100644 --- a/mysql-test/main/crash_commit_before.test +++ b/mysql-test/main/crash_commit_before.test @@ -17,7 +17,7 @@ insert into t1 values(9); SET GLOBAL debug_dbug="d,crash_commit_before"; # Write file to make mysql-test-run.pl expect crash and restart ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Run the crashing query --error 2013 diff --git a/mysql-test/main/empty_server_name-8224.test b/mysql-test/main/empty_server_name-8224.test index 5c5140be2e0..31760713bc8 100644 --- a/mysql-test/main/empty_server_name-8224.test +++ b/mysql-test/main/empty_server_name-8224.test @@ -3,10 +3,10 @@ # --source include/not_embedded.inc create server '' foreign data wrapper w2 options (host '127.0.0.1'); ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect -- source include/wait_until_connected_again.inc diff --git a/mysql-test/main/host_cache_size_functionality.test b/mysql-test/main/host_cache_size_functionality.test index 9ec26010ab6..f37b2ab8c9e 100644 --- a/mysql-test/main/host_cache_size_functionality.test +++ b/mysql-test/main/host_cache_size_functionality.test @@ -43,10 +43,10 @@ select @@global.Host_Cache_Size > 0; --echo # Restart server with Host_Cache_Size 1 let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; ---exec echo "wait" > $restart_file +--write_line wait $restart_file --shutdown_server --source include/wait_until_disconnected.inc --- exec echo "restart:--host_cache_size=1 " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--host_cache_size=1 " $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect -- source include/wait_until_connected_again.inc @@ -142,10 +142,10 @@ SELECT Host_Cache_Size = @@SESSION.Host_Cache_Size; #--remove_file $MYSQL_TMP_DIR/bind_ip #let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; -#--exec echo "wait" > $restart_file +#--write_line wait $restart_file #--shutdown_server #--source include/wait_until_disconnected.inc -#-- exec echo "restart:--bind-address=$bind_ip " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +#-- write_line "restart:--bind-address=$bind_ip " $MYSQLTEST_VARDIR/tmp/mysqld.1.expect #-- enable_reconnect #-- source include/wait_until_connected_again.inc diff --git a/mysql-test/main/init_file_set_password-7656.test b/mysql-test/main/init_file_set_password-7656.test index 7bca34a0fcf..ac5baa3b04f 100644 --- a/mysql-test/main/init_file_set_password-7656.test +++ b/mysql-test/main/init_file_set_password-7656.test @@ -15,12 +15,12 @@ EOF --enable_reconnect ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc ---exec echo "restart:--init-file=$MYSQLTEST_VARDIR/init.file " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--init-file=$MYSQLTEST_VARDIR/init.file " $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc select user,host,password,plugin,authentication_string from mysql.user where user='foo'; diff --git a/mysql-test/main/log_errchk.test b/mysql-test/main/log_errchk.test index 1afc0e29f3a..c64f6e3c106 100644 --- a/mysql-test/main/log_errchk.test +++ b/mysql-test/main/log_errchk.test @@ -30,12 +30,12 @@ --echo # Case 2: Starting server with fifo file as general log file --echo # and slow query log file. # Restart server with fifo file as general log file. ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc --enable_reconnect # Write file to make mysql-test-run.pl start up the server again ---exec echo "restart: --general-log-file=$gen_log_file --slow-query-log-file=$slow_query_log_file" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart: --general-log-file=$gen_log_file --slow-query-log-file=$slow_query_log_file" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc # Error 6 is reported, because the other end is closed diff --git a/mysql-test/main/lowercase_fs_on.test b/mysql-test/main/lowercase_fs_on.test index 1d306826e27..9a7fc369207 100644 --- a/mysql-test/main/lowercase_fs_on.test +++ b/mysql-test/main/lowercase_fs_on.test @@ -16,7 +16,7 @@ let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; --remove_file $SEARCH_FILE #Shutdown the server ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc @@ -30,7 +30,7 @@ let SEARCH_PATTERN= \[ERROR\] The server option \'lower_case_table_names\' is co --source include/search_pattern_in_file.inc #Restart the server ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc #Cleanup diff --git a/mysql-test/main/myisam_crash_before_flush_keys.test b/mysql-test/main/myisam_crash_before_flush_keys.test index 8df81f73ec0..34bd0aa1e10 100644 --- a/mysql-test/main/myisam_crash_before_flush_keys.test +++ b/mysql-test/main/myisam_crash_before_flush_keys.test @@ -26,14 +26,14 @@ INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6); SET SESSION debug_dbug="d,crash_before_flush_keys"; --echo # Write file to make mysql-test-run.pl expect crash ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --echo # Run the crashing query --error 2013 FLUSH TABLE t1; --echo # Write file to make mysql-test-run.pl start the server ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --echo # Turn on reconnect --enable_reconnect diff --git a/mysql-test/main/mysql_client_test.test b/mysql-test/main/mysql_client_test.test index 09efc99796d..2b573702c15 100644 --- a/mysql-test/main/mysql_client_test.test +++ b/mysql-test/main/mysql_client_test.test @@ -25,7 +25,7 @@ call mtr.add_suppression(" IP address .* could not be resolved"); # server or run mysql-test-run --debug mysql_client_test and check # var/log/mysql_client_test.trace ---exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 +--write_line "$MYSQL_CLIENT_TEST" $MYSQLTEST_VARDIR/log/mysql_client_test.out.log --exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 # End of 4.1 tests diff --git a/mysql-test/main/mysql_client_test_comp.test b/mysql-test/main/mysql_client_test_comp.test index 36a12b6691e..f37d82a20e5 100644 --- a/mysql-test/main/mysql_client_test_comp.test +++ b/mysql-test/main/mysql_client_test_comp.test @@ -12,7 +12,7 @@ SET @old_slow_query_log= @@global.slow_query_log; call mtr.add_suppression(" Error reading file './client_test_db/test_frm_bug.frm'"); call mtr.add_suppression(" IP address .* could not be resolved"); ---exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test_comp.out.log 2>&1 +--write_line "$MYSQL_CLIENT_TEST" $MYSQLTEST_VARDIR/log/mysql_client_test_comp.out.log --exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test_comp.out.log 2>&1 # End of test diff --git a/mysql-test/main/mysql_client_test_nonblock.test b/mysql-test/main/mysql_client_test_nonblock.test index 73e7a6d378d..158ddc131f0 100644 --- a/mysql-test/main/mysql_client_test_nonblock.test +++ b/mysql-test/main/mysql_client_test_nonblock.test @@ -19,7 +19,7 @@ call mtr.add_suppression(" IP address .* could not be resolved"); # server or run mysql-test-run --debug mysql_client_test and check # var/log/mysql_client_test.trace ---exec echo "$MYSQL_CLIENT_TEST --non-blocking-api" > $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 +---write_line "$MYSQL_CLIENT_TEST --non-blocking-api" $MYSQLTEST_VARDIR/log/mysql_client_test.out.log --exec $MYSQL_CLIENT_TEST --non-blocking-api --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 # End of 4.1 tests diff --git a/mysql-test/main/openssl_1.test b/mysql-test/main/openssl_1.test index 639fd0a294d..83c176b47fd 100644 --- a/mysql-test/main/openssl_1.test +++ b/mysql-test/main/openssl_1.test @@ -68,7 +68,7 @@ drop table t1; # Test that we can't open connection to server if we are using # a different cacert # ---exec echo "this query should not execute;" > $MYSQLTEST_VARDIR/tmp/test.sql +--write_line "this query should not execute;" $MYSQLTEST_VARDIR/tmp/test.sql # Handle that openssl gives different error messages from YaSSL. --replace_regex /2026 TLS\/SSL error.*/2026 TLS\/SSL error: xxxx/ --error 1 diff --git a/mysql-test/main/plugin_loaderr.test b/mysql-test/main/plugin_loaderr.test index 85621ad047d..1623630bb81 100644 --- a/mysql-test/main/plugin_loaderr.test +++ b/mysql-test/main/plugin_loaderr.test @@ -13,14 +13,14 @@ FROM INFORMATION_SCHEMA.PLUGINS WHERE plugin_name = 'innodb'; --echo # --echo # MDEV-6351 --plugin=force has no effect for built-in plugins --echo # ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc --error 1 --exec $MYSQLD_CMD --innodb=force --innodb-page-size=6000 --disable-log-error ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc --disable_reconnect diff --git a/mysql-test/main/shutdown.test b/mysql-test/main/shutdown.test index 71f2156a17f..b26a6d4b6f6 100644 --- a/mysql-test/main/shutdown.test +++ b/mysql-test/main/shutdown.test @@ -20,13 +20,13 @@ drop procedure try_shutdown; --let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name --send shutdown --connection default --source include/wait_until_disconnected.inc ---exec echo "restart" > $_expect_file_name +--write_line restart $_expect_file_name --enable_reconnect --source include/wait_until_connected_again.inc diff --git a/mysql-test/suite/binlog/include/binlog_index.inc b/mysql-test/suite/binlog/include/binlog_index.inc index d73091d59ab..eee58e78f4b 100644 --- a/mysql-test/suite/binlog/include/binlog_index.inc +++ b/mysql-test/suite/binlog/include/binlog_index.inc @@ -98,7 +98,7 @@ reset master; --echo # crash_purge_before_update_index flush logs; ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect SET SESSION debug_dbug="+d,crash_purge_before_update_index"; --source include/wait_for_binlog_checkpoint.inc --error 2013 @@ -119,7 +119,7 @@ SELECT @index; --echo # crash_purge_non_critical_after_update_index flush logs; ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect SET SESSION debug_dbug="+d,crash_purge_non_critical_after_update_index"; --source include/wait_for_binlog_checkpoint.inc --error 2013 @@ -143,7 +143,7 @@ SELECT @index; --echo # crash_purge_critical_after_update_index flush logs; ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect SET SESSION debug_dbug="+d,crash_purge_critical_after_update_index"; --source include/wait_for_binlog_checkpoint.inc --error 2013 @@ -167,7 +167,7 @@ file_exists $MYSQLD_DATADIR/master-bin.000008; SELECT @index; --echo # crash_create_non_critical_before_update_index ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect SET SESSION debug_dbug="+d,crash_create_non_critical_before_update_index"; --error 2013 flush logs; @@ -185,7 +185,7 @@ file_exists $MYSQLD_DATADIR/master-bin.000009; SELECT @index; --echo # crash_create_critical_before_update_index ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect SET SESSION debug_dbug="+d,crash_create_critical_before_update_index"; --error 2013 flush logs; @@ -205,7 +205,7 @@ file_exists $MYSQLD_DATADIR/master-bin.000011; SELECT @index; --echo # crash_create_after_update_index ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect SET SESSION debug_dbug="+d,crash_create_after_update_index"; --error 2013 flush logs; diff --git a/mysql-test/suite/binlog/t/binlog_autocommit_off_no_hang.test b/mysql-test/suite/binlog/t/binlog_autocommit_off_no_hang.test index 8f1dbb2a2dd..149b1a8d97d 100644 --- a/mysql-test/suite/binlog/t/binlog_autocommit_off_no_hang.test +++ b/mysql-test/suite/binlog/t/binlog_autocommit_off_no_hang.test @@ -26,10 +26,10 @@ ALTER TABLE mysql.gtid_slave_pos ENGINE=innodb; --echo # Restart the server so mysqld reads the gtid_slave_pos using innodb ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc diff --git a/mysql-test/suite/binlog/t/binlog_rotate_perf.test b/mysql-test/suite/binlog/t/binlog_rotate_perf.test index 74c91feca97..512471e2de1 100644 --- a/mysql-test/suite/binlog/t/binlog_rotate_perf.test +++ b/mysql-test/suite/binlog/t/binlog_rotate_perf.test @@ -68,10 +68,10 @@ while ($loop_times) { # try to change the log-bin configs and restart --echo # ======= now try to change the log-bin config for mysqld ======= ---let $restart_parameters="--log-bin=new_log_bin" +--let $restart_parameters=--log-bin=new_log_bin --echo #begin to restart mysqld --source include/restart_mysqld.inc ---let $restart_parameters= "" +--let $restart_parameters= --source include/show_binary_logs.inc let $loop_times= 10; diff --git a/mysql-test/suite/binlog_encryption/restart_server.inc b/mysql-test/suite/binlog_encryption/restart_server.inc index 8f0fe7d8970..f71858be741 100644 --- a/mysql-test/suite/binlog_encryption/restart_server.inc +++ b/mysql-test/suite/binlog_encryption/restart_server.inc @@ -20,7 +20,7 @@ --connection $_cur_con --enable_reconnect ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect shutdown_server; @@ -31,5 +31,5 @@ if ($rpl_server_parameters) { --let $_rpl_start_server_command= restart:$rpl_server_parameters } ---exec echo "$_rpl_start_server_command" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect +--write_line "$_rpl_start_server_command" $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect --source include/wait_until_connected_again.inc diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change3.test b/mysql-test/suite/encryption/t/innodb-bad-key-change3.test index 9c2918f3118..f4065290938 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change3.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change3.test @@ -16,7 +16,7 @@ call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* becau --let $MYSQLD_DATADIR = `SELECT @@datadir` --let SEARCH_RANGE = 10000000 --let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc @@ -25,7 +25,7 @@ call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* becau 4;770A8A65DA156D24EE2A093277530143 EOF ---exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -47,7 +47,7 @@ UNLOCK TABLES; ALTER TABLE t1 DISCARD TABLESPACE; ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc @@ -62,7 +62,7 @@ ib_discard_tablespaces("test", "t1"); ib_restore_tablespaces("test", "t1"); EOF ---exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc --source include/restart_mysqld.inc @@ -80,7 +80,7 @@ SELECT * FROM t1; -- let SEARCH_FILE=$t1_IBD -- source include/search_pattern_in_file.inc ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc --remove_file $MYSQLTEST_VARDIR/keys1.txt @@ -89,7 +89,7 @@ SELECT * FROM t1; 4;770A8A65DA156D24EE2A093277530143 EOF ---exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc DROP TABLE t1; diff --git a/mysql-test/suite/encryption/t/innodb_encrypt_freed.test b/mysql-test/suite/encryption/t/innodb_encrypt_freed.test index 785b4e9e498..3ce5620df98 100644 --- a/mysql-test/suite/encryption/t/innodb_encrypt_freed.test +++ b/mysql-test/suite/encryption/t/innodb_encrypt_freed.test @@ -20,7 +20,7 @@ CREATE TABLE t1(f1 BIGINT PRIMARY KEY, f2 int not null, SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; CREATE TABLE t2 (f1 int not null)engine=innodb; -let $restart_parameters="--debug=d,ib_log_checkpoint_avoid"; +let $restart_parameters=--debug=d,ib_log_checkpoint_avoid; --source include/restart_mysqld.inc # Stop the purge diff --git a/mysql-test/suite/galera/include/kill_galera.inc b/mysql-test/suite/galera/include/kill_galera.inc index 28a1b0f368c..3c218a19bee 100644 --- a/mysql-test/suite/galera/include/kill_galera.inc +++ b/mysql-test/suite/galera/include/kill_galera.inc @@ -8,7 +8,7 @@ if (!$kill_signal) # Write file to make mysql-test-run.pl expect the crash, but don't start it --let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name # Kill the connected server --disable_reconnect diff --git a/mysql-test/suite/galera/include/start_mysqld.inc b/mysql-test/suite/galera/include/start_mysqld.inc index 57af9203d0f..c9bed71f517 100644 --- a/mysql-test/suite/galera/include/start_mysqld.inc +++ b/mysql-test/suite/galera/include/start_mysqld.inc @@ -4,12 +4,12 @@ if ($galera_wsrep_start_position != '') { --echo Using --wsrep-start-position when starting mysqld ... - --exec echo "restart:$start_mysqld_params --wsrep-start-position=$galera_wsrep_start_position" > $_expect_file_name + --write_line "restart:$start_mysqld_params --wsrep-start-position=$galera_wsrep_start_position" $_expect_file_name --let $galera_wsrep_start_position = 0 } if ($galera_wsrep_start_position == '') { - --exec echo "restart:$start_mysqld_params" > $_expect_file_name + --write_line "restart:$start_mysqld_params" $_expect_file_name } --source include/galera_wait_ready.inc diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test index b36a0de57b6..940b511f752 100644 --- a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -37,7 +37,7 @@ UPDATE t1 SET f2 = 'c' WHERE f1 > 2; # Write file to make mysql-test-run.pl expect the crash, but don't start it --let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name --let KILL_NODE_PIDFILE = `SELECT @@pid_file` diff --git a/mysql-test/suite/galera/t/galera_pc_recovery.test b/mysql-test/suite/galera/t/galera_pc_recovery.test index 1621414aff5..16abe6fc9ba 100644 --- a/mysql-test/suite/galera/t/galera_pc_recovery.test +++ b/mysql-test/suite/galera/t/galera_pc_recovery.test @@ -27,8 +27,8 @@ INSERT INTO t1 VALUES (1); SELECT COUNT(*) = 1 FROM t1; --let $NODE_2_PIDFILE = `SELECT @@pid_file` ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --exec kill -9 `cat $NODE_1_PIDFILE` `cat $NODE_2_PIDFILE` # Perform --wsrep-recover and preserve the positions into variables by placing them in $MYSQL_TMP_DIR/galera_wsrep_start_position.inc and then --source'ing it @@ -66,8 +66,8 @@ if ($galera_wsrep_start_position2 == '') { # Instruct MTR to perform the actual restart using --wsrep-start-position . Proper --wsrep_cluster_address is used as my.cnf only contains 'gcomm://' for node #1 ---exec echo "restart: --wsrep-start-position=$galera_wsrep_start_position1 --wsrep_cluster_address=gcomm://127.0.0.1:$NODE_GALERAPORT_1,127.0.0.1:$NODE_GALERAPORT_2" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---exec echo "restart: --wsrep-start-position=$galera_wsrep_start_position2 --wsrep_cluster_address=gcomm://127.0.0.1:$NODE_GALERAPORT_1,127.0.0.1:$NODE_GALERAPORT_2" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--write_line "restart: --wsrep-start-position=$galera_wsrep_start_position1 --wsrep_cluster_address=gcomm://127.0.0.1:$NODE_GALERAPORT_1,127.0.0.1:$NODE_GALERAPORT_2" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart: --wsrep-start-position=$galera_wsrep_start_position2 --wsrep_cluster_address=gcomm://127.0.0.1:$NODE_GALERAPORT_1,127.0.0.1:$NODE_GALERAPORT_2" $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --sleep 5 --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test index 6a0f24dbaae..e3a8b749cb4 100644 --- a/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test +++ b/mysql-test/suite/galera/t/galera_restart_on_unknown_option.test @@ -62,7 +62,7 @@ SELECT * FROM t1; --let $start_mysqld_params=--galera-unknown-option --echo Starting server ... ---exec echo "try:$start_mysqld_params" > $_expect_file_name +--write_line "try:$start_mysqld_params" $_expect_file_name # Sleep to ensure that server exited... @@ -107,7 +107,7 @@ SELECT * FROM t1; --let $start_mysqld_params=--galera-unknown-option --echo Starting server ... ---exec echo "try:$start_mysqld_params" > $_expect_file_name +--write_line "try:$start_mysqld_params" $_expect_file_name # Sleep to ensure that server exited... diff --git a/mysql-test/suite/galera/t/mdev-22543.test b/mysql-test/suite/galera/t/mdev-22543.test index 1e7d3712639..26257b28814 100644 --- a/mysql-test/suite/galera/t/mdev-22543.test +++ b/mysql-test/suite/galera/t/mdev-22543.test @@ -36,7 +36,7 @@ SET DEBUG_SYNC = "now WAIT_FOR sync_point_reached"; # Restart without waiting. The UPDATE should block FTWRL on node_1, # so the SST cannot be completed and node_2 cannot join before # UPDATE connection is signalled to continue. ---exec echo "restart:$start_mysqld_params" > $_expect_file_name +--write_line "restart:$start_mysqld_params" $_expect_file_name # If the bug is present, FTWRL times out on node_1 in couple of # seconds and node_2 fails to join. --sleep 10 diff --git a/mysql-test/suite/galera_3nodes_sr/t/GCF-832.test b/mysql-test/suite/galera_3nodes_sr/t/GCF-832.test index ab8b62b969a..d18ec470c50 100644 --- a/mysql-test/suite/galera_3nodes_sr/t/GCF-832.test +++ b/mysql-test/suite/galera_3nodes_sr/t/GCF-832.test @@ -17,7 +17,7 @@ SET GLOBAL debug_dbug="d,crash_last_fragment_commit_after_fragment_removal"; --let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name CREATE TABLE t1 (f1 VARCHAR(30)) ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/t/alter_crash.test b/mysql-test/suite/innodb/t/alter_crash.test index 6f6a6dc5cbc..2fd8fd735bf 100644 --- a/mysql-test/suite/innodb/t/alter_crash.test +++ b/mysql-test/suite/innodb/t/alter_crash.test @@ -70,7 +70,7 @@ let $orig_table_id = `SELECT table_id WHERE name = 'test/t1'`; # Write file to make mysql-test-run.pl expect crash ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 ALTER TABLE t1 ADD PRIMARY KEY (f2, f1); @@ -123,7 +123,7 @@ let $orig_table_id = `SELECT table_id WHERE name = 'test/t2'`; # Write file to make mysql-test-run.pl expect crash ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 ALTER TABLE t2 ADD PRIMARY KEY (f2, f1); @@ -165,7 +165,7 @@ let $orig_table_id = `select table_id from information_schema.innodb_sys_tables where name = 'test/t1'`; # Write file to make mysql-test-run.pl expect crash ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # --error 2013 ALTER TABLE t1 ADD INDEX (b), CHANGE c d int, ALGORITHM=INPLACE; diff --git a/mysql-test/suite/innodb/t/alter_rename_existing.test b/mysql-test/suite/innodb/t/alter_rename_existing.test index 06602ae8e74..c6886619d73 100644 --- a/mysql-test/suite/innodb/t/alter_rename_existing.test +++ b/mysql-test/suite/innodb/t/alter_rename_existing.test @@ -18,7 +18,7 @@ INSERT INTO t1(b) VALUES('one'), ('two'), ('three'); --echo # --echo # Create a file called MYSQLD_DATADIR/test/t1.ibd ---exec echo "This is not t1.ibd" > $MYSQLD_DATADIR/test/t1.ibd +--write_line "This is not t1.ibd" $MYSQLD_DATADIR/test/t1.ibd --echo # Directory listing of test/*.ibd --echo # diff --git a/mysql-test/suite/innodb/t/doublewrite_debug.test b/mysql-test/suite/innodb/t/doublewrite_debug.test index 3d96a74e698..66c24648a73 100644 --- a/mysql-test/suite/innodb/t/doublewrite_debug.test +++ b/mysql-test/suite/innodb/t/doublewrite_debug.test @@ -45,7 +45,7 @@ commit work; # Slow shutdown and restart to make sure ibuf merge is finished SET GLOBAL innodb_fast_shutdown = 0; let $shutdown_timeout=; -let $restart_parameters="--debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0"; +let $restart_parameters=--debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0; --source include/restart_mysqld.inc --source ../include/no_checkpoint_start.inc begin; @@ -95,7 +95,7 @@ select f1, f2 from t1; --echo # Test Begin: Test if recovery works if 1st page of --echo # system tablespace is corrupted and 2nd page as corrupted. -let $restart_parameters="--debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0"; +let $restart_parameters=--debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0; --source include/restart_mysqld.inc --source ../include/no_checkpoint_start.inc begin; diff --git a/mysql-test/suite/innodb/t/group_commit_crash.test b/mysql-test/suite/innodb/t/group_commit_crash.test index 12f7ba202e3..b0ed854f4f3 100644 --- a/mysql-test/suite/innodb/t/group_commit_crash.test +++ b/mysql-test/suite/innodb/t/group_commit_crash.test @@ -51,7 +51,7 @@ while ($numtests) START TRANSACTION; insert into t1 select * from t2; # Write file to make mysql-test-run.pl expect crash - --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + --write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect eval call setcrash($numtests); diff --git a/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test b/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test index 6115e3f0050..9b7de7cea56 100644 --- a/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test +++ b/mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test @@ -51,7 +51,7 @@ while ($numtests) START TRANSACTION; insert into t1 select * from t2; # Write file to make mysql-test-run.pl expect crash - --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + --write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect eval call setcrash($numtests); diff --git a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test index 26576129a16..81911a558dc 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test +++ b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test @@ -35,7 +35,7 @@ let datadir= `select @@datadir`; CREATE TABLE t1 (f1 INT NOT NULL, f2 INT NOT NULL) ENGINE=innodb; SET debug_dbug='+d,innodb_alter_commit_crash_before_commit'; ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 ALTER TABLE t1 ADD PRIMARY KEY (f2, f1); diff --git a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test b/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test index c15a7a4cb7e..616f8e21705 100644 --- a/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test +++ b/mysql-test/suite/innodb/t/innodb-change-buffer-recovery.test @@ -51,7 +51,7 @@ DELETE FROM t1 WHERE a=1; INSERT INTO t1 VALUES(1,'X',1); SET DEBUG_DBUG='+d,crash_after_log_ibuf_upd_inplace'; ---exec echo "wait" > $_expect_file_name +--write_line wait $_expect_file_name --error 2013 # This should force a change buffer merge SELECT b FROM t1 LIMIT 3; diff --git a/mysql-test/suite/innodb/t/innodb-corrupted-table.test b/mysql-test/suite/innodb/t/innodb-corrupted-table.test index a064f08d677..dcdaa61859f 100644 --- a/mysql-test/suite/innodb/t/innodb-corrupted-table.test +++ b/mysql-test/suite/innodb/t/innodb-corrupted-table.test @@ -23,14 +23,14 @@ alter table t1 add primary key (pk); --echo # Stop the server, replace the frm with the old one and restart the server ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc --remove_file $datadir/test/t1.frm --copy_file $MYSQLTEST_VARDIR/tmp/t1.frm $datadir/test/t1.frm ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test index cebb8ce7ec4..372dfdfdc6a 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test @@ -41,7 +41,7 @@ INSERT INTO t1 VALUES(1),(2),(3); --let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect ---exec echo wait > $_expect_file_name +--write_line wait $_expect_file_name SET SESSION debug_dbug="+d,ib_discard_before_commit_crash"; --error 2013 ALTER TABLE t1 DISCARD TABLESPACE; @@ -55,7 +55,7 @@ SET GLOBAL innodb_file_per_table = 1; CREATE TABLE t1 (c1 INT) ENGINE = InnoDB; INSERT INTO t1 VALUES(1),(2),(3); ---exec echo wait > $_expect_file_name +--write_line wait $_expect_file_name SET SESSION debug_dbug="+d,ib_discard_after_commit_crash"; --error 2013 ALTER TABLE t1 DISCARD TABLESPACE; @@ -99,7 +99,7 @@ EOF --error ER_TABLESPACE_DISCARDED SELECT * FROM t1; ---exec echo wait > $_expect_file_name +--write_line wait $_expect_file_name SET SESSION debug_dbug="+d,ib_import_before_commit_crash"; --error 2013 ALTER TABLE t1 IMPORT TABLESPACE; diff --git a/mysql-test/suite/innodb/t/innodb_bug60196.test b/mysql-test/suite/innodb/t/innodb_bug60196.test index 7f1f5c40585..41b9a4d8476 100644 --- a/mysql-test/suite/innodb/t/innodb_bug60196.test +++ b/mysql-test/suite/innodb/t/innodb_bug60196.test @@ -58,7 +58,7 @@ SELECT * FROM bug_60196; --echo # Restart server. # Write file to make mysql-test-run.pl start up the server again ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Turn on reconnect --enable_reconnect @@ -132,7 +132,7 @@ SELECT * FROM Bug_60309; --echo # Restart server. # Write file to make mysql-test-run.pl start up the server again ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Turn on reconnect --enable_reconnect diff --git a/mysql-test/suite/innodb/t/log_file_name.test b/mysql-test/suite/innodb/t/log_file_name.test index a95b5b37fb9..3d43248491b 100644 --- a/mysql-test/suite/innodb/t/log_file_name.test +++ b/mysql-test/suite/innodb/t/log_file_name.test @@ -205,7 +205,7 @@ print FILE "\0" x 16384; close(FILE); EOF ---exec echo "" > $MYSQLD_DATADIR/test/u2.ibd +--write_line "" $MYSQLD_DATADIR/test/u2.ibd # TODO: Test with this, once # Bug#18131883 IMPROVE INNODB ERROR MESSAGES REGARDING FILES diff --git a/mysql-test/suite/innodb/t/temporary_table.test b/mysql-test/suite/innodb/t/temporary_table.test index 12885f40a92..bbeadcfa98e 100644 --- a/mysql-test/suite/innodb/t/temporary_table.test +++ b/mysql-test/suite/innodb/t/temporary_table.test @@ -135,7 +135,7 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED'); # We cannot use include/restart_mysqld.inc in this particular test, # because SHOW STATUS would fail due to unwritable (nonexistent) tmpdir. --source include/shutdown_mysqld.inc ---exec echo "restart: --tmpdir=/dev/null/$MYSQL_TMP_DIR --skip-innodb-fast-shutdown" > $_expect_file_name +--write_line "restart: --tmpdir=/dev/null/$MYSQL_TMP_DIR --skip-innodb-fast-shutdown" $_expect_file_name --enable_reconnect --disable_result_log --disable_query_log diff --git a/mysql-test/suite/innodb/t/undo_space_dblwr.test b/mysql-test/suite/innodb/t/undo_space_dblwr.test index 3f61e91ddf5..52b19a4b7fb 100644 --- a/mysql-test/suite/innodb/t/undo_space_dblwr.test +++ b/mysql-test/suite/innodb/t/undo_space_dblwr.test @@ -12,7 +12,7 @@ insert into t1 values (1, 1); # Slow shutdown and restart to make sure ibuf merge is finished SET GLOBAL innodb_fast_shutdown = 0; let $shutdown_timeout=; -let $restart_parameters="--debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0"; +let $restart_parameters=--debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0; --source include/restart_mysqld.inc --source ../include/no_checkpoint_start.inc diff --git a/mysql-test/suite/innodb_fts/t/sync.test b/mysql-test/suite/innodb_fts/t/sync.test index 168309a5c92..56b9052a47a 100644 --- a/mysql-test/suite/innodb_fts/t/sync.test +++ b/mysql-test/suite/innodb_fts/t/sync.test @@ -115,7 +115,7 @@ CREATE TABLE t1 ( INSERT INTO t1(title) VALUES('database'); ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect SET debug_dbug = '+d,fts_instrument_sync_debug,fts_write_node_crash'; diff --git a/mysql-test/suite/innodb_gis/t/rollback.test b/mysql-test/suite/innodb_gis/t/rollback.test index fcfe71e2f80..a09986692ee 100644 --- a/mysql-test/suite/innodb_gis/t/rollback.test +++ b/mysql-test/suite/innodb_gis/t/rollback.test @@ -463,7 +463,7 @@ rollback; # Test partial update rollback after recovered. # Crash the server in partial update. ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect set session debug="+d,row_mysql_crash_if_error"; --error 2013 update t1 set a=point(5,5), b=point(5,5), c=5 where i < 3; diff --git a/mysql-test/suite/innodb_zip/t/restart.test b/mysql-test/suite/innodb_zip/t/restart.test index 0c1f11363e6..82090da87f2 100644 --- a/mysql-test/suite/innodb_zip/t/restart.test +++ b/mysql-test/suite/innodb_zip/t/restart.test @@ -426,13 +426,13 @@ SHOW CREATE TABLE t77_restart; --echo # Moving tablespace 't4_restart' from MYSQL_DATA_DIR to MYSQL_TMP_DIR/new_dir --copy_file $MYSQL_DATA_DIR/test/t4_restart.ibd $MYSQL_TMP_DIR/new_dir/test/t4_restart.ibd --remove_file $MYSQL_DATA_DIR/test/t4_restart.ibd ---exec echo $MYSQL_TMP_DIR/new_dir/test/t4_restart.ibd > $MYSQL_DATA_DIR/test/t4_restart.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t4_restart.ibd $MYSQL_DATA_DIR/test/t4_restart.isl --echo # Moving tablespace 't55_restart' from MYSQL_TMP_DIR/alt_dir to MYSQL_TMP_DIR/new_dir --copy_file $MYSQL_TMP_DIR/alt_dir/test/t55_restart.ibd $MYSQL_TMP_DIR/new_dir/test/t55_restart.ibd --remove_file $MYSQL_TMP_DIR/alt_dir/test/t55_restart.ibd --remove_file $MYSQL_DATA_DIR/test/t55_restart.isl ---exec echo $MYSQL_TMP_DIR/new_dir/test/t55_restart.ibd > $MYSQL_DATA_DIR/test/t55_restart.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t55_restart.ibd $MYSQL_DATA_DIR/test/t55_restart.isl --echo # Moving tablespace 't66_restart' from MYSQL_TMP_DIR/alt_dir to MYSQL_TMP_DIR/new_dir --copy_file $MYSQL_TMP_DIR/alt_dir/test/t66_restart#P#p0.ibd $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p0.ibd @@ -444,9 +444,9 @@ SHOW CREATE TABLE t77_restart; --remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p0.isl --remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p1.isl --remove_file $MYSQL_DATA_DIR/test/t66_restart#P#p2.isl ---exec echo $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p0.ibd > $MYSQL_DATA_DIR/test/t66_restart#P#p0.isl ---exec echo $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p1.ibd > $MYSQL_DATA_DIR/test/t66_restart#P#p1.isl ---exec echo $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p2.ibd > $MYSQL_DATA_DIR/test/t66_restart#P#p2.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p0.ibd $MYSQL_DATA_DIR/test/t66_restart#P#p0.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p1.ibd $MYSQL_DATA_DIR/test/t66_restart#P#p1.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t66_restart#P#p2.ibd $MYSQL_DATA_DIR/test/t66_restart#P#p2.isl --echo # Moving tablespace 't77_restart' from MYSQL_TMP_DIR/alt_dir to MYSQL_TMP_DIR/new_dir --copy_file $MYSQL_TMP_DIR/alt_dir/test/t77_restart#P#p0#SP#s0.ibd $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s0.ibd @@ -461,10 +461,10 @@ SHOW CREATE TABLE t77_restart; --remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s1.isl --remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s2.isl --remove_file $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s3.isl ---exec echo $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s0.ibd > $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s0.isl ---exec echo $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s1.ibd > $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s1.isl ---exec echo $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s2.ibd > $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s2.isl ---exec echo $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s3.ibd > $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s3.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s0.ibd $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s0.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p0#SP#s1.ibd $MYSQL_DATA_DIR/test/t77_restart#P#p0#SP#s1.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s2.ibd $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s2.isl +--write_line $MYSQL_TMP_DIR/new_dir/test/t77_restart#P#p1#SP#s3.ibd $MYSQL_DATA_DIR/test/t77_restart#P#p1#SP#s3.isl --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test diff --git a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test index a7916477e0a..05801e53f84 100644 --- a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test +++ b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test @@ -73,7 +73,7 @@ SET SESSION debug_dbug="+d,ib_import_before_commit_crash"; SELECT * FROM t1; # Write file to make mysql-test-run.pl start up the server again ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Execute the statement that causes the crash --error 2013 @@ -94,7 +94,7 @@ SET SESSION debug_dbug="+d,ib_import_before_checkpoint_crash"; SELECT COUNT(*) FROM t1; # Don't start up the server right away. ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Execute the statement that causes the crash --error 2013 @@ -111,7 +111,7 @@ EOF --echo # Restart and reconnect to the server --enable_reconnect ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --disable_reconnect diff --git a/mysql-test/suite/large_tests/t/maria_recover_encrypted.test b/mysql-test/suite/large_tests/t/maria_recover_encrypted.test index 640bbacbc72..1064c2c0884 100644 --- a/mysql-test/suite/large_tests/t/maria_recover_encrypted.test +++ b/mysql-test/suite/large_tests/t/maria_recover_encrypted.test @@ -15,7 +15,7 @@ DROP PROCEDURE IF EXISTS proc_insert_many; # -------- # Configure encryption ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc @@ -23,7 +23,7 @@ DROP PROCEDURE IF EXISTS proc_insert_many; 1;76025E3ADC78D74819927DB02AAA4C35 EOF ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/key.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/key.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -75,7 +75,7 @@ CALL proc_insert_many(); UNLOCK TABLES; # Crash and restart the server while it's still flushing index ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/key.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/key.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect SET debug_dbug="d,crash_shutdown"; --error 2013 shutdown; diff --git a/mysql-test/suite/maria/bulk_insert_crash.test b/mysql-test/suite/maria/bulk_insert_crash.test index d9167c3f0d7..04f3a148ad4 100644 --- a/mysql-test/suite/maria/bulk_insert_crash.test +++ b/mysql-test/suite/maria/bulk_insert_crash.test @@ -12,7 +12,7 @@ # # Write file to make mysql-test-run.pl expect crash and restart ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine=aria transactional=1; insert into t1 values (1000,1000,1000); diff --git a/mysql-test/suite/maria/encrypt-no-key.test b/mysql-test/suite/maria/encrypt-no-key.test index 89c50d79a54..da7bcb0fac5 100644 --- a/mysql-test/suite/maria/encrypt-no-key.test +++ b/mysql-test/suite/maria/encrypt-no-key.test @@ -26,10 +26,10 @@ CREATE TABLE t1 (a INT KEY,b INT,KEY(b)) ENGINE=Aria; --echo # Restart with encryption enabled ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -40,10 +40,10 @@ LOAD INDEX INTO CACHE t1; # Restart without encryption. Above table should be unreadable ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc ---exec echo "restart:--aria-encrypt-tables=0" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--aria-encrypt-tables=0" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc diff --git a/mysql-test/suite/maria/encrypt-wrong-key.test b/mysql-test/suite/maria/encrypt-wrong-key.test index ac060c4e9dd..274a165ca4d 100644 --- a/mysql-test/suite/maria/encrypt-wrong-key.test +++ b/mysql-test/suite/maria/encrypt-wrong-key.test @@ -9,7 +9,7 @@ call mtr.add_suppression("System key id 1 is missing"); call mtr.add_suppression("Unknown key id 1"); call mtr.add_suppression("Initialization of encryption failed.*"); ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc @@ -17,14 +17,14 @@ call mtr.add_suppression("Initialization of encryption failed.*"); 1;770A8A65DA156D24EE2A093277530142 EOF ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc CREATE TABLE t1 (i INT, KEY(i)) ENGINE=Aria; INSERT INTO t1 VALUES (1); ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc @@ -32,7 +32,7 @@ INSERT INTO t1 VALUES (1); 2;770A8A65DA156D24EE2A093277530143 EOF ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -43,11 +43,11 @@ repair table t1; --error HA_ERR_NO_ENCRYPTION INSERT INTO t1 VALUES (2); ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc diff --git a/mysql-test/suite/parts/inc/partition_crash.inc b/mysql-test/suite/parts/inc/partition_crash.inc index 32bf5c10423..fc5fd929c4e 100644 --- a/mysql-test/suite/parts/inc/partition_crash.inc +++ b/mysql-test/suite/parts/inc/partition_crash.inc @@ -12,7 +12,7 @@ SHOW CREATE TABLE t1; --sorted_result SELECT * FROM t1; ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --disable_reconnect # CR_SERVER_LOST --error 2013 @@ -23,7 +23,7 @@ SELECT * FROM t1; --replace_regex /sql-exchange.*\./sql-exchange./ /sql-shadow-[0-9a-f]*-/sql-shadow-/ /#sql-ib[1-9][0-9]*\.ibd\n// --cat_file $DATADIR.files.txt --remove_file $DATADIR.files.txt ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc --echo # State after crash recovery diff --git a/mysql-test/suite/perfschema/t/bad_option.test b/mysql-test/suite/perfschema/t/bad_option.test index 5d4d49ed12c..0989f01f3b3 100644 --- a/mysql-test/suite/perfschema/t/bad_option.test +++ b/mysql-test/suite/perfschema/t/bad_option.test @@ -13,7 +13,7 @@ let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err; let SEARCH_FILE= $error_log; # Stop the server let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; ---exec echo "wait" > $restart_file +--write_line wait $restart_file --shutdown_server --source include/wait_until_disconnected.inc --error 7 @@ -61,7 +61,7 @@ let SEARCH_PATTERN= Can.t change dir to .*bad_option_h_param; --remove_file $error_log # Write file to make mysql-test-run.pl start up the server again ---exec echo "restart" > $restart_file +--write_line restart $restart_file # Turn on reconnect --enable_reconnect diff --git a/mysql-test/suite/perfschema/t/processlist_57.test b/mysql-test/suite/perfschema/t/processlist_57.test index 748d8b7402b..fe8898ed049 100644 --- a/mysql-test/suite/perfschema/t/processlist_57.test +++ b/mysql-test/suite/perfschema/t/processlist_57.test @@ -23,7 +23,7 @@ DROP TABLE performance_schema.processlist; SHOW CREATE TABLE performance_schema.processlist; let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; ---exec echo "wait" > $restart_file +--write_line wait $restart_file --echo ## --echo ## Server shutdown --echo ## @@ -93,7 +93,7 @@ SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; --error ER_BAD_FIELD_ERROR SHOW PROCESSLIST; ---exec echo "wait" > $restart_file +--write_line wait $restart_file --echo ## --echo ## Server shutdown --echo ## @@ -166,7 +166,7 @@ SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; # Works and returns no data, innodb table is empty. SHOW PROCESSLIST; ---exec echo "wait" > $restart_file +--write_line wait $restart_file --echo ## --echo ## Server shutdown --echo ## @@ -231,7 +231,7 @@ SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; # Works and returns no data, innodb table is empty. SHOW PROCESSLIST; ---exec echo "wait" > $restart_file +--write_line wait $restart_file --echo ## --echo ## Server shutdown --echo ## @@ -306,7 +306,7 @@ SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; --replace_column 3 [HOST:PORT] 6 [TIME] SHOW PROCESSLIST; ---exec echo "wait" > $restart_file +--write_line wait $restart_file --echo ## --echo ## Server shutdown --echo ## diff --git a/mysql-test/suite/perfschema/t/setup_instruments_defaults.test b/mysql-test/suite/perfschema/t/setup_instruments_defaults.test index ea59cd4f266..bd33c559d9a 100644 --- a/mysql-test/suite/perfschema/t/setup_instruments_defaults.test +++ b/mysql-test/suite/perfschema/t/setup_instruments_defaults.test @@ -69,7 +69,7 @@ SELECT * FROM performance_schema.setup_instruments WHERE name like "%wait/io/table/sql/handler%"; # Write file to make mysql-test-run.pl wait for the server to stop ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Restart the server --echo # @@ -79,7 +79,7 @@ WHERE name like "%wait/io/table/sql/handler%"; --echo # Restart server with wait/io/table/sql/handler disabled ---exec echo "restart:--loose-performance-schema-instrument=%wait/io/table/sql/%=off" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line "restart:--loose-performance-schema-instrument=%wait/io/table/sql/%=off" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Turn on reconnect --echo # Enable reconnect diff --git a/mysql-test/suite/perfschema/t/statement_program_lost_inst.test b/mysql-test/suite/perfschema/t/statement_program_lost_inst.test index 023180b9d2b..0742043bba3 100644 --- a/mysql-test/suite/perfschema/t/statement_program_lost_inst.test +++ b/mysql-test/suite/perfschema/t/statement_program_lost_inst.test @@ -19,10 +19,10 @@ --source include/have_perfschema.inc let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; ---exec echo "wait" > $restart_file +--write_line wait $restart_file --shutdown_server --source include/wait_until_disconnected.inc ---exec echo "restart:--performance_schema_max_program_instances=7 --performance_schema_max_statement_stack=2 --thread_stack=655360">$restart_file +--write_line "restart:--performance_schema_max_program_instances=7 --performance_schema_max_statement_stack=2 --thread_stack=655360" $restart_file --enable_reconnect --source include/wait_until_connected_again.inc diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test index cdfdc098f5a..f6f2062a252 100644 --- a/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test +++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_master_crash.test @@ -39,7 +39,7 @@ insert into ti set a=null; insert into tm set a=null; set @@global.debug_dbug="+d,crash_before_send_xid"; ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect connection slave; let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); @@ -61,7 +61,7 @@ connection master; --enable_reconnect --let $rpl_server_number=1 --source include/rpl_start_server.inc -#--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +#--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --echo # Master has restarted successfully save_master_pos; diff --git a/mysql-test/suite/rpl/t/rpl_relay_max_extension.test b/mysql-test/suite/rpl/t/rpl_relay_max_extension.test index acca2f6954c..b6a8ccb545c 100644 --- a/mysql-test/suite/rpl/t/rpl_relay_max_extension.test +++ b/mysql-test/suite/rpl/t/rpl_relay_max_extension.test @@ -47,7 +47,7 @@ RESET SLAVE; --echo # --let $datadir = `select @@datadir` ---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --shutdown_server 10 --source include/wait_until_disconnected.inc @@ -64,7 +64,7 @@ RESET SLAVE; --echo # Restart slave server --echo # ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --enable_reconnect --source include/wait_until_connected_again.inc SET @save_slave_parallel_threads= @@GLOBAL.slave_parallel_threads; diff --git a/mysql-test/suite/rpl/t/rpl_sync.test b/mysql-test/suite/rpl/t/rpl_sync.test index 1e2ec2ca83b..3dd99e736f2 100644 --- a/mysql-test/suite/rpl/t/rpl_sync.test +++ b/mysql-test/suite/rpl/t/rpl_sync.test @@ -82,7 +82,7 @@ print FILE "failure"; close ($file); EOF ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.2.expect SET SESSION debug_dbug="d,crash_before_rotate_relaylog"; --error 2013 FLUSH LOGS; @@ -130,7 +130,7 @@ print FILE @content; close FILE; EOF ---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect +--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.2.expect SET SESSION debug_dbug="d,crash_before_rotate_relaylog"; --error 2013 FLUSH LOGS; From 0ad52e4d6aa0204a616b18fa81dc75a46aa356cb Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Wed, 10 Apr 2024 12:00:02 -0600 Subject: [PATCH 156/313] MDEV-27512: Assertion !thd->transaction_rollback_request failed in rows_event_stmt_cleanup If replicating an event in ROW format, and InnoDB detects a deadlock while searching for a row, the row event will error and rollback in InnoDB and indicate that the binlog cache also needs to be cleared, i.e. by marking thd->transaction_rollback_request. In the normal case, this will trigger an error in Rows_log_event::do_apply_event() and cause a rollback. During the Rows_log_event::do_apply_event() cleanup of a successful event application, there is a DBUG_ASSERT in log_event_server.cc::rows_event_stmt_cleanup(), which sets the expectation that thd->transaction_rollback_request cannot be set because the general rollback (i.e. not the InnoDB rollback) should have happened already. However, if the replica is configured to skip deadlock errors, the rows event logic will clear the error and continue on, as if no error happened. This results in thd->transaction_rollback_request being set while in rows_event_stmt_cleanup(), thereby triggering the assertion. This patch fixes this in the following ways: 1) The assertion is invalid, and thereby removed. 2) The rollback case is forced in rows_event_stmt_cleanup() if transaction_rollback_request is set. Note the differing behavior between transactions which are skipped due to deadlock errors and other errors. When a transaction is skipped due to an ignored deadlock error, the entire transaction is rolled back and skipped (though note MDEV-33930 which allows statements in the same transaction after the deadlock-inducing one to commit). When a transaction is skipped due to ignoring a different error, only the erroring statements are rolled-back and skipped - the rest of the transaction will execute as normal. The effect of this can be seen in the test results. The added test case to rpl_skip_error.test shows that only statements which are ignored due to non-deadlock errors are ignored in larger transactions. A diff between rpl_temporary_error2_skip_all.result and rpl_temporary_error2.result shows that all statements in the errored transaction are rolled back (diff pasted below): : diff rpl_temporary_error2.result rpl_temporary_error2_skip_all.result 49c49 < 2 1 --- > 2 NULL 51c51 < 4 1 --- > 4 NULL 53c53 < * There will be two rows in t2 due to the retry. --- > * There will be one row in t2 because the ignored deadlock does not retry. 57d56 < 1 59c58 < 1 --- > 0 Reviewed By: ============ Andrei Elkin --- mysql-test/suite/rpl/r/rpl_skip_error.result | 25 ++++++++ .../r/rpl_temporary_error2_skip_all.result | 64 +++++++++++++++++++ mysql-test/suite/rpl/t/rpl_skip_error.test | 42 +++++++++++- .../suite/rpl/t/rpl_temporary_error2.test | 9 ++- .../t/rpl_temporary_error2_skip_all-slave.opt | 1 + .../rpl/t/rpl_temporary_error2_skip_all.test | 3 + sql/log_event_server.cc | 10 +-- 7 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_temporary_error2_skip_all.result create mode 100644 mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all-slave.opt create mode 100644 mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all.test diff --git a/mysql-test/suite/rpl/r/rpl_skip_error.result b/mysql-test/suite/rpl/r/rpl_skip_error.result index eb6324ff987..03fc8a7836f 100644 --- a/mysql-test/suite/rpl/r/rpl_skip_error.result +++ b/mysql-test/suite/rpl/r/rpl_skip_error.result @@ -122,6 +122,31 @@ connection slave; # Slave_skipped_errros = 5 **** We cannot execute a select as there are differences in the **** behavior between STMT and RBR. +**** +**** Ensure transactions which are skipped due to encountering a +**** non-deadlock error which is present in --slave-skip-errors result +**** in partially committed transactions +connection master; +CREATE TABLE t3 (a INT UNIQUE) ENGINE=InnoDB; +connection slave; +connection slave; +INSERT INTO t3 VALUES (3); +connection master; +BEGIN; +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +INSERT INTO t3 VALUES (3); +INSERT INTO t3 VALUES (4); +COMMIT; +connection slave; +**** Master and slave tables should have the same data, due to the +**** partially replicated transaction's data overlapping with the data +**** that pre-existed on the slave. That is, despite the transaction +**** consisting of 4 statements, the errored statement should be ignored +**** and the other 3 should commit successfully. +include/diff_tables.inc [master:t3,slave:t3] +connection master; +DROP TABLE t3; ==== Clean Up ==== connection master; DROP TABLE t1; diff --git a/mysql-test/suite/rpl/r/rpl_temporary_error2_skip_all.result b/mysql-test/suite/rpl/r/rpl_temporary_error2_skip_all.result new file mode 100644 index 00000000000..9819aafa5cf --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_temporary_error2_skip_all.result @@ -0,0 +1,64 @@ +include/master-slave.inc +[connection master] +call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); +*** Provoke a deadlock on the slave, check that transaction retry succeeds. *** +connection master; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +CREATE TABLE t2 (a INT) ENGINE=InnoDB; +INSERT INTO t1(a) VALUES (1), (2), (3), (4), (5); +connection slave; +SELECT * FROM t1 ORDER BY a; +a b +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +SET sql_log_bin=0; +ALTER TABLE t2 ENGINE=MyISAM; +SET sql_log_bin=1; +connect con_temp1,127.0.0.1,root,,test,$SERVER_MYPORT_2,; +connection con_temp1; +BEGIN; +UPDATE t1 SET b=2 WHERE a=4; +INSERT INTO t2 VALUES (2); +DELETE FROM t2 WHERE a=2; +connection master; +BEGIN; +UPDATE t1 SET b=1 WHERE a=2; +INSERT INTO t2 VALUES (1); +UPDATE t1 SET b=1 WHERE a=4; +COMMIT; +connection slave; +connection con_temp1; +UPDATE t1 SET b=2 WHERE a=2; +SELECT * FROM t1 WHERE a<10 ORDER BY a; +a b +1 NULL +2 2 +3 NULL +4 2 +5 NULL +ROLLBACK; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +connection slave; +SELECT * FROM t1 ORDER BY a; +a b +1 NULL +2 NULL +3 NULL +4 NULL +5 NULL +* There will be one row in t2 because the ignored deadlock does not retry. +SELECT * FROM t2 ORDER BY a; +a +1 +retries +0 +Last_SQL_Errno = '0' +Last_SQL_Error = '' +connection master; +DROP TABLE t1; +DROP TABLE t2; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_skip_error.test b/mysql-test/suite/rpl/t/rpl_skip_error.test index d3ef834e8ec..ee11ce5ac92 100644 --- a/mysql-test/suite/rpl/t/rpl_skip_error.test +++ b/mysql-test/suite/rpl/t/rpl_skip_error.test @@ -3,7 +3,11 @@ # Verify that --slave-skip-errors works correctly. The error messages # specified by --slave-skip-errors on slave should be ignored. If # such errors occur, they should not be reported and not cause the -# slave to stop. +# slave to stop. If a skipped-due-to-error statement is a part of a +# larger transaction, and the error is not a deadlock error, the rest +# of the transaction should still commit, with just the errored statement +# ignored (note transactions which are skipped due to deadlocks are +# rolled back fully, see rpl_temporary_error2_skip_all.test). # # ==== Method ==== # @@ -164,6 +168,42 @@ let $current_skipped_error= query_get_value(show global status like "Slave_skipp --echo **** We cannot execute a select as there are differences in the --echo **** behavior between STMT and RBR. + +--echo **** +--echo **** Ensure transactions which are skipped due to encountering a +--echo **** non-deadlock error which is present in --slave-skip-errors result +--echo **** in partially committed transactions +# Slave will insert 3 first, and master will insert 3 within a larger trx +--let $value_preexisting_on_slave= 3 + +--connection master +CREATE TABLE t3 (a INT UNIQUE) ENGINE=InnoDB; + +--sync_slave_with_master +--connection slave +--eval INSERT INTO t3 VALUES ($value_preexisting_on_slave) + +--connection master +BEGIN; +INSERT INTO t3 VALUES (1); +INSERT INTO t3 VALUES (2); +--eval INSERT INTO t3 VALUES ($value_preexisting_on_slave) +INSERT INTO t3 VALUES (4); +COMMIT; +--sync_slave_with_master + +--echo **** Master and slave tables should have the same data, due to the +--echo **** partially replicated transaction's data overlapping with the data +--echo **** that pre-existed on the slave. That is, despite the transaction +--echo **** consisting of 4 statements, the errored statement should be ignored +--echo **** and the other 3 should commit successfully. +let $diff_tables=master:t3,slave:t3; +source include/diff_tables.inc; + +--connection master +DROP TABLE t3; + + --echo ==== Clean Up ==== connection master; diff --git a/mysql-test/suite/rpl/t/rpl_temporary_error2.test b/mysql-test/suite/rpl/t/rpl_temporary_error2.test index 49194c5d914..3537499d562 100644 --- a/mysql-test/suite/rpl/t/rpl_temporary_error2.test +++ b/mysql-test/suite/rpl/t/rpl_temporary_error2.test @@ -64,7 +64,14 @@ ROLLBACK; --connection slave --sync_with_master SELECT * FROM t1 ORDER BY a; ---echo * There will be two rows in t2 due to the retry. +if (!$ignored_db_deadlock) +{ + --echo * There will be two rows in t2 due to the retry. +} +if ($ignored_db_deadlock) +{ + --echo * There will be one row in t2 because the ignored deadlock does not retry. +} SELECT * FROM t2 ORDER BY a; let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1); --disable_query_log diff --git a/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all-slave.opt b/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all-slave.opt new file mode 100644 index 00000000000..a9ddd73510c --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all-slave.opt @@ -0,0 +1 @@ +--slave-skip-errors=all diff --git a/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all.test b/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all.test new file mode 100644 index 00000000000..6801bf184d5 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all.test @@ -0,0 +1,3 @@ +--source include/have_binlog_format_row.inc +--let $ignored_db_deadlock= 1 +--source rpl_temporary_error2.test diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 313df13f400..38e8b062f18 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -5926,11 +5926,13 @@ static int rows_event_stmt_cleanup(rpl_group_info *rgi, THD * thd) Xid_log_event will come next which will, if some transactional engines are involved, commit the transaction and flush the pending event to the binlog. - If there was a deadlock the transaction should have been rolled back - already. So there should be no need to rollback the transaction. + We check for thd->transaction_rollback_request because it is possible + there was a deadlock that was ignored by slave-skip-errors. Normally, the + deadlock would have been rolled back already. */ - DBUG_ASSERT(! thd->transaction_rollback_request); - error|= (int)(error ? trans_rollback_stmt(thd) : trans_commit_stmt(thd)); + error|= (int) ((error || thd->transaction_rollback_request) + ? trans_rollback_stmt(thd) + : trans_commit_stmt(thd)); /* Now what if this is not a transactional engine? we still need to From 6815ab86d060eb5d4bb3eafccf7fa7231d0fc97b Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Thu, 18 Apr 2024 01:42:39 +0200 Subject: [PATCH 157/313] HASHICORP_KEY_MANAGEMENT: code unification between MariaDB editions --- .../hashicorp_key_management_plugin.cc | 9 ++++----- .../hashicorp_key_management/mysql-test/vault/suite.pm | 4 ++++ .../mysql-test/vault/t/hashicorp_mariabackup.opt | 1 + .../mysql-test/vault/t/hashicorp_mariabackup.test | 6 +++++- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_mariabackup.opt diff --git a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc index bdc2f7345f1..d8baa00455e 100644 --- a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc +++ b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc @@ -13,18 +13,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ -#include #include #include +#include #include +#include +#include +#include #include #include #include #include -#ifdef _WIN32 -#include -#define alloca _alloca -#endif #include #include #include diff --git a/plugin/hashicorp_key_management/mysql-test/vault/suite.pm b/plugin/hashicorp_key_management/mysql-test/vault/suite.pm index fce1737311d..bd08ff4fb18 100644 --- a/plugin/hashicorp_key_management/mysql-test/vault/suite.pm +++ b/plugin/hashicorp_key_management/mysql-test/vault/suite.pm @@ -1,9 +1,13 @@ package My::Suite::Vault; +use My::Platform; @ISA = qw(My::Suite); use strict; +return "Hashicorp Key Management plugin tests are currently not available on Windows" + if IS_WINDOWS; + return "You need to set the value of the VAULT_ADDR variable" unless $ENV{VAULT_ADDR}; diff --git a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_mariabackup.opt b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_mariabackup.opt new file mode 100644 index 00000000000..1df4643562e --- /dev/null +++ b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_mariabackup.opt @@ -0,0 +1 @@ +--innodb --loose-changed_page_bitmaps --innodb-sys-tables --innodb-flush-log-at-trx-commit=2 --sequence diff --git a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_mariabackup.test b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_mariabackup.test index 6ade4e115a1..977535556cc 100644 --- a/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_mariabackup.test +++ b/plugin/hashicorp_key_management/mysql-test/vault/t/hashicorp_mariabackup.test @@ -8,9 +8,13 @@ CREATE TABLE t(i INT) ENGINE INNODB encrypted=yes encryption_key_id=1; INSERT INTO t VALUES(1); -echo # mariabackup backup; let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--error 0,1 +rmdir $targetdir; + +echo # mariabackup backup; + --disable_result_log exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; --enable_result_log From 11aeef2aa2696e5fca26c0606c7da575b1044e66 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Fri, 12 Apr 2024 08:55:27 +0200 Subject: [PATCH 158/313] MDEV-33420: HASHICORP_KEY_MANAGEMENT fails on Windows with libcurl installed - When `libcurl` is installed in path out of default path, like on Windows, `include_directories` failed to find `curl/curl.h`. - Fix `cmake` by using modern syntax with imported target and `find_package` - Fix warnings treated as the errors - Remove `HASHICORP_HAVE_EXCEPTIONS` macro and related code - Add package to `Server` component in Windows - Tested with `$ ./mysql-test/mtr --suite=vault` - Closes PR #3068 - Reviewer: --- .../hashicorp_key_management/CMakeLists.txt | 6 +- .../hashicorp_key_management_plugin.cc | 65 ------------------- win/packaging/CPackWixConfig.cmake | 2 +- 3 files changed, 3 insertions(+), 70 deletions(-) diff --git a/plugin/hashicorp_key_management/CMakeLists.txt b/plugin/hashicorp_key_management/CMakeLists.txt index bd1eee844ab..bef7e65be27 100644 --- a/plugin/hashicorp_key_management/CMakeLists.txt +++ b/plugin/hashicorp_key_management/CMakeLists.txt @@ -1,18 +1,16 @@ -INCLUDE(FindCURL) +FIND_PACKAGE(CURL) IF(NOT CURL_FOUND) # Can't build plugin RETURN() ENDIF() -INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR}) - set(CPACK_RPM_hashicorp-key-management_PACKAGE_SUMMARY "Hashicorp Key Management plugin for MariaDB" PARENT_SCOPE) set(CPACK_RPM_hashicorp-key-management_PACKAGE_DESCRIPTION "This encryption plugin uses Hashicorp Vault for storing encryption keys for MariaDB Data-at-Rest encryption." PARENT_SCOPE) MYSQL_ADD_PLUGIN(HASHICORP_KEY_MANAGEMENT hashicorp_key_management_plugin.cc - LINK_LIBRARIES ${CURL_LIBRARIES} + LINK_LIBRARIES CURL::libcurl CONFIG hashicorp_key_management.cnf COMPONENT hashicorp-key-management MODULE_ONLY) diff --git a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc index d8baa00455e..7bd038ef73a 100644 --- a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc +++ b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc @@ -28,12 +28,6 @@ #include #include -#if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) -#define HASHICORP_HAVE_EXCEPTIONS 1 -#else -#define HASHICORP_HAVE_EXCEPTIONS 0 -#endif - #define HASHICORP_DEBUG_LOGGING 0 #define PLUGIN_ERROR_HEADER "hashicorp: " @@ -208,15 +202,6 @@ unsigned int if (key_version == ENCRYPTION_KEY_VERSION_INVALID) { clock_t timestamp; -#if HASHICORP_HAVE_EXCEPTIONS - try - { - VER_INFO &ver_info = latest_version_cache.at(key_id); - version = ver_info.key_version; - timestamp = ver_info.timestamp; - } - catch (const std::out_of_range &e) -#else VER_MAP::const_iterator ver_iter = latest_version_cache.find(key_id); if (ver_iter != latest_version_cache.end()) { @@ -224,7 +209,6 @@ unsigned int timestamp = ver_iter->second.timestamp; } else -#endif { mtx.unlock(); return ENCRYPTION_KEY_VERSION_INVALID; @@ -245,13 +229,6 @@ unsigned int } } KEY_INFO info; -#if HASHICORP_HAVE_EXCEPTIONS - try - { - info = key_info_cache.at(KEY_ID_AND_VERSION(key_id, version)); - } - catch (const std::out_of_range &e) -#else KEY_MAP::const_iterator key_iter = key_info_cache.find(KEY_ID_AND_VERSION(key_id, version)); if (key_iter != key_info_cache.end()) @@ -259,7 +236,6 @@ unsigned int info = key_iter->second; } else -#endif { mtx.unlock(); return ENCRYPTION_KEY_VERSION_INVALID; @@ -304,20 +280,12 @@ unsigned int HCData::cache_get_version (unsigned int key_id) { unsigned int version; mtx.lock(); -#if HASHICORP_HAVE_EXCEPTIONS - try - { - version = latest_version_cache.at(key_id).key_version; - } - catch (const std::out_of_range &e) -#else VER_MAP::const_iterator ver_iter = latest_version_cache.find(key_id); if (ver_iter != latest_version_cache.end()) { version = ver_iter->second.key_version; } else -#endif { version = ENCRYPTION_KEY_VERSION_INVALID; } @@ -330,15 +298,6 @@ unsigned int HCData::cache_check_version (unsigned int key_id) unsigned int version; clock_t timestamp; mtx.lock(); -#if HASHICORP_HAVE_EXCEPTIONS - try - { - VER_INFO &ver_info = latest_version_cache.at(key_id); - version = ver_info.key_version; - timestamp = ver_info.timestamp; - } - catch (const std::out_of_range &e) -#else VER_MAP::const_iterator ver_iter = latest_version_cache.find(key_id); if (ver_iter != latest_version_cache.end()) { @@ -346,7 +305,6 @@ unsigned int HCData::cache_check_version (unsigned int key_id) timestamp = ver_iter->second.timestamp; } else -#endif { mtx.unlock(); #if HASHICORP_DEBUG_LOGGING @@ -977,29 +935,6 @@ struct st_mariadb_encryption hashicorp_key_management_plugin= { 0, 0, 0, 0, 0 }; -#ifdef _MSC_VER - -static int setenv (const char *name, const char *value, int overwrite) -{ - if (!overwrite) - { - size_t len= 0; - int rc= getenv_s(&len, NULL, 0, name); - if (rc) - { - return rc; - } - if (len) - { - errno = EINVAL; - return EINVAL; - } - } - return _putenv_s(name, value); -} - -#endif - #define MAX_URL_SIZE 32768 int HCData::init () diff --git a/win/packaging/CPackWixConfig.cmake b/win/packaging/CPackWixConfig.cmake index 4ac4d38471e..a4b0731b4b9 100644 --- a/win/packaging/CPackWixConfig.cmake +++ b/win/packaging/CPackWixConfig.cmake @@ -63,7 +63,7 @@ SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DESCRIPTION "Install server") #Miscellaneous (hidden) components, part of server / or client programs - FOREACH(comp connect-engine ClientPlugins gssapi-server gssapi-client aws-key-management rocksdb-engine) + FOREACH(comp connect-engine ClientPlugins gssapi-server gssapi-client aws-key-management rocksdb-engine plugin-hashicorp-key-management) STRING(TOUPPER "${comp}" comp) SET(CPACK_COMPONENT_${comp}_GROUP "MySQLServer") SET(CPACK_COMPONENT_${comp}_HIDDEN 1) From 5928e04d5f9a6900d4ac8f5f296978f01b368be1 Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Tue, 16 Apr 2024 12:25:48 +0530 Subject: [PATCH 159/313] MDEV-32489 Change buffer index fails to delete the records When the change buffer records for a page span across multiple change buffer leaf pages or the starting record is at the beginning of a page with a left sibling, ibuf_delete_recs deletes only the records in first page and fails to move to subsequent pages. Subsequently a slow shutdown hangs trying to delete those left over records. Fix-A: Position the cursor to an user record in B-tree and exit only when all records are exhausted. Fix-B: Make sure we call ibuf_delete_recs during slow shutdown for pages with IBUF entries to cleanup any previously left over records. --- storage/innobase/btr/btr0pcur.cc | 14 +++++++--- storage/innobase/ibuf/ibuf0ibuf.cc | 42 +++++++++++++++------------- storage/innobase/include/btr0pcur.h | 5 ++-- storage/innobase/include/ibuf0ibuf.h | 3 +- storage/innobase/srv/srv0srv.cc | 2 +- 5 files changed, 39 insertions(+), 27 deletions(-) diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index 1358a51d78d..7c28650bfd4 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -657,8 +657,9 @@ user record satisfying the search condition, in the case PAGE_CUR_L or PAGE_CUR_LE, on the last user record. If no such user record exists, then in the first case sets the cursor after last in tree, and in the latter case before first in tree. The latching mode must be BTR_SEARCH_LEAF or -BTR_MODIFY_LEAF. */ -void +BTR_MODIFY_LEAF. +@return DB_SUCCESS or error code */ +dberr_t btr_pcur_open_on_user_rec_func( /*===========================*/ dict_index_t* index, /*!< in: index */ @@ -672,8 +673,12 @@ btr_pcur_open_on_user_rec_func( unsigned line, /*!< in: line where called */ mtr_t* mtr) /*!< in: mtr */ { - btr_pcur_open_low(index, 0, tuple, mode, latch_mode, cursor, - file, line, 0, mtr); + auto err = btr_pcur_open_low(index, 0, tuple, mode, latch_mode, cursor, + file, line, 0, mtr); + + if (UNIV_UNLIKELY(err != DB_SUCCESS)) { + return err; + } if ((mode == PAGE_CUR_GE) || (mode == PAGE_CUR_G)) { @@ -688,4 +693,5 @@ btr_pcur_open_on_user_rec_func( ut_error; } + return DB_SUCCESS; } diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 8888e538e05..33527b11bea 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -24,6 +24,7 @@ Insert buffer Created 7/19/1997 Heikki Tuuri *******************************************************/ +#include #include "ibuf0ibuf.h" #include "sync0sync.h" #include "btr0sea.h" @@ -2331,9 +2332,11 @@ static void ibuf_delete_recs(const page_id_t page_id) loop: btr_pcur_t pcur; ibuf_mtr_start(&mtr); - if (btr_pcur_open(ibuf.index, &tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF, - &pcur, &mtr) != DB_SUCCESS) + if (btr_pcur_open_on_user_rec(ibuf.index, &tuple, PAGE_CUR_GE, + BTR_MODIFY_LEAF, &pcur, &mtr) != DB_SUCCESS) + { goto func_exit; + } if (!btr_pcur_is_on_user_rec(&pcur)) { ut_ad(btr_pcur_is_after_last_on_page(&pcur)); @@ -2370,7 +2373,8 @@ func_exit: /** Merge the change buffer to some pages. */ static void ibuf_read_merge_pages(const uint32_t* space_ids, - const uint32_t* page_nos, ulint n_stored) + const uint32_t* page_nos, ulint n_stored, + bool slow_shutdown_cleanup) { for (ulint i = 0; i < n_stored; i++) { const ulint space_id = space_ids[i]; @@ -2394,26 +2398,25 @@ tablespace_deleted: if (UNIV_LIKELY(page_nos[i] < size)) { mtr.start(); dberr_t err; - buf_block_t *block = + /* Load the page and apply change buffers. */ + std::ignore = buf_page_get_gen(page_id_t(space_id, page_nos[i]), zip_size, RW_X_LATCH, nullptr, BUF_GET_POSSIBLY_FREED, __FILE__, __LINE__, &mtr, &err, true); - bool remove = !block - || fil_page_get_type(block->frame) - != FIL_PAGE_INDEX - || !page_is_leaf(block->frame); mtr.commit(); if (err == DB_TABLESPACE_DELETED) { goto tablespace_deleted; } - if (!remove) { - continue; - } } - if (srv_shutdown_state == SRV_SHUTDOWN_NONE - || srv_fast_shutdown) { + /* During slow shutdown cleanup, we apply all pending IBUF + changes and need to cleanup any left-over IBUF records. There + are a few cases when the changes are already discarded and IBUF + bitmap is cleaned but we miss to delete the record. Even after + the issues are fixed, we need to keep this safety measure for + upgraded DBs with such left over records. */ + if (!slow_shutdown_cleanup) { continue; } @@ -2445,10 +2448,11 @@ tablespace_deleted: } /** Contract the change buffer by reading pages to the buffer pool. +@param slow_shutdown true, if called during slow shutdown @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read @retval 0 if ibuf.empty */ -ulint ibuf_contract() +ulint ibuf_contract(bool slow_shutdown) { if (UNIV_UNLIKELY(!ibuf.index)) return 0; mtr_t mtr; @@ -2492,7 +2496,7 @@ ulint ibuf_contract() ibuf_mtr_commit(&mtr); btr_pcur_close(&pcur); - ibuf_read_merge_pages(space_ids, page_nos, n_pages); + ibuf_read_merge_pages(space_ids, page_nos, n_pages, slow_shutdown); return(sum_sizes + 1); } @@ -2574,7 +2578,7 @@ ibuf_merge_space( } #endif /* UNIV_DEBUG */ - ibuf_read_merge_pages(spaces, pages, n_pages); + ibuf_read_merge_pages(spaces, pages, n_pages, false); } return(n_pages); @@ -2599,7 +2603,7 @@ ibuf_contract_after_insert( ulint size; do { - size = ibuf_contract(); + size = ibuf_contract(false); sum_sizes += size; } while (size > 0 && sum_sizes < entry_size); } @@ -3228,7 +3232,7 @@ ibuf_insert_low( #ifdef UNIV_IBUF_DEBUG fputs("Ibuf too big\n", stderr); #endif - ibuf_contract(); + ibuf_contract(false); return(DB_STRONG_FAIL); } @@ -3478,7 +3482,7 @@ func_exit: #ifdef UNIV_IBUF_DEBUG ut_a(n_stored <= IBUF_MAX_N_PAGES_MERGED); #endif - ibuf_read_merge_pages(space_ids, page_nos, n_stored); + ibuf_read_merge_pages(space_ids, page_nos, n_stored, false); } return(err); diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index 584cc143359..dd44042bf9d 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -181,8 +181,9 @@ user record satisfying the search condition, in the case PAGE_CUR_L or PAGE_CUR_LE, on the last user record. If no such user record exists, then in the first case sets the cursor after last in tree, and in the latter case before first in tree. The latching mode must be BTR_SEARCH_LEAF or -BTR_MODIFY_LEAF. */ -void +BTR_MODIFY_LEAF. +@return DB_SUCCESS or error code */ +dberr_t btr_pcur_open_on_user_rec_func( /*===========================*/ dict_index_t* index, /*!< in: index */ diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h index 73be4b0a8e8..c5a852c3497 100644 --- a/storage/innobase/include/ibuf0ibuf.h +++ b/storage/innobase/include/ibuf0ibuf.h @@ -370,10 +370,11 @@ in DISCARD TABLESPACE, IMPORT TABLESPACE, or read-ahead. void ibuf_delete_for_discarded_space(ulint space); /** Contract the change buffer by reading pages to the buffer pool. +@param slow_shutdown true, if called during slow shutdown @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read @retval 0 if ibuf.empty */ -ulint ibuf_contract(); +ulint ibuf_contract(bool slow_shutdown); /** Contracts insert buffer trees by reading pages referring to space_id to the buffer pool. diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index aaa9dafcbb1..10f9da71df2 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1665,7 +1665,7 @@ void srv_shutdown(bool ibuf_merge) ibuf_read_merge_pages() */ ibuf_max_size_update(0); log_free_check(); - n_read = ibuf_contract(); + n_read = ibuf_contract(true); } if (n_tables_to_drop || ibuf_merge) { From 2e84560dc48a4dc1b43f84056375f1c259b96673 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 18 Apr 2024 09:32:33 +0200 Subject: [PATCH 160/313] MDEV-16944 postfix. Fix a typo --- mysql-test/main/mysql_client_test_nonblock.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/main/mysql_client_test_nonblock.test b/mysql-test/main/mysql_client_test_nonblock.test index 158ddc131f0..c4bc4304307 100644 --- a/mysql-test/main/mysql_client_test_nonblock.test +++ b/mysql-test/main/mysql_client_test_nonblock.test @@ -19,7 +19,7 @@ call mtr.add_suppression(" IP address .* could not be resolved"); # server or run mysql-test-run --debug mysql_client_test and check # var/log/mysql_client_test.trace ----write_line "$MYSQL_CLIENT_TEST --non-blocking-api" $MYSQLTEST_VARDIR/log/mysql_client_test.out.log +--write_line "$MYSQL_CLIENT_TEST --non-blocking-api" $MYSQLTEST_VARDIR/log/mysql_client_test.out.log --exec $MYSQL_CLIENT_TEST --non-blocking-api --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1 # End of 4.1 tests From 8a3755cc29f80bcb22d2753a674de72dc0528810 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 18 Apr 2024 13:29:42 +0530 Subject: [PATCH 161/313] MDEV-33934 Assertion `!check_foreigns' failed in bulk_insert_apply_for_table(dict_table_t*) This issue is caused by commit 188c5da72a0057e4572b1d7e4efcd0c39332a839 (MDEV-32453). trx_t::bulk_insert_apply_for_table(): Remove the assert check_unique_secondary and check_foreigns. InnoDB can apply the bulk insert operation even after disabling the check_foreigns and check_unique_secondary variable. --- mysql-test/suite/innodb/r/insert_into_empty.result | 12 ++++++++++++ mysql-test/suite/innodb/t/insert_into_empty.test | 11 +++++++++++ storage/innobase/row/row0merge.cc | 2 -- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index 2219b6f3c31..429f8d0044a 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -488,4 +488,16 @@ BEGIN; LOAD DATA INFILE 'VARDIR/tmp/t.outfile' INTO TABLE t; COMMIT; DROP TABLE t; +# +# MDEV-33934 Assertion `!check_foreigns' failed in +# trx_t::bulk_insert_apply_for_table(dict_table_t*) +# +CREATE TABLE t1(f1 INT,f2 INT,KEY(f1))engine=innodb; +BEGIN; +INSERT INTO t1 VALUES(); +SET STATEMENT FOREIGN_KEY_CHECKS=1 FOR SELECT * FROM t1; +f1 f2 +NULL NULL +COMMIT; +DROP TABLE t1; # End of 10.11 tests diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index 88ee2b53697..736eca18d7c 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -523,4 +523,15 @@ eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t.outfile' INTO TABLE t; COMMIT; DROP TABLE t; --remove_file $MYSQLTEST_VARDIR/tmp/t.outfile + +--echo # +--echo # MDEV-33934 Assertion `!check_foreigns' failed in +--echo # trx_t::bulk_insert_apply_for_table(dict_table_t*) +--echo # +CREATE TABLE t1(f1 INT,f2 INT,KEY(f1))engine=innodb; +BEGIN; +INSERT INTO t1 VALUES(); +SET STATEMENT FOREIGN_KEY_CHECKS=1 FOR SELECT * FROM t1; +COMMIT; +DROP TABLE t1; --echo # End of 10.11 tests diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 465a5965b6c..bcb93970ffc 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -5373,8 +5373,6 @@ dberr_t trx_t::bulk_insert_apply_for_table(dict_table_t *table) { if (UNIV_UNLIKELY(!bulk_insert)) return DB_SUCCESS; - ut_ad(!check_unique_secondary); - ut_ad(!check_foreigns); auto it= mod_tables.find(table); if (it != mod_tables.end() && it->second.bulk_store) if (dberr_t err= it->second.write_bulk(table, this)) From 3f9f5ca48e6be55613926964314f550c8ca8542d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 Apr 2024 10:54:08 +0300 Subject: [PATCH 162/313] MDEV-33447: libpmem is not available in RHEL 8 Because the Red Hat Enterprise Linux 8 core repository does not include libpmem, let us implement the necessary subset ourselves. pmem_persist(): Implement for 64-bit x86, ARM, POWER, RISC-V, Loongarch in a way that should be compatible with the https://github.com/pmem/pmdk/ implementation of pmem_persist(). The CMake option WITH_INNODB_PMEM can be used for enabling or disabling this interface at compile time. By default, it is enabled on all applicable systems that are covered by our CI system. Note: libpmem had not been previously enabled for Loongarch in our Debian packaging. It was enabled for RISC-V, but we will not enable it by default on RISC-V or Loongarch because we lack CI coverage. The generated code for x86_64 was reviewed and tested on two Intel implementations: one that only supports clflush, and another that supports both clflushopt and clwb. The generated machine code was also reviewed on https://godbolt.org using various compiler versions. Godbolt helpfully includes an option to compile to binary code and display the encoding, which was useful on POWER. Reviewed by: Vladislav Vaintroub --- cmake/FindPMEM.cmake | 18 ---- debian/autobake-deb.sh | 18 ---- debian/control | 1 - debian/rules | 6 -- extra/mariabackup/CMakeLists.txt | 4 - storage/innobase/CMakeLists.txt | 23 +++--- storage/innobase/buf/buf0flu.cc | 2 +- storage/innobase/include/cache.h | 33 ++++++++ storage/innobase/log/log0log.cc | 2 +- storage/innobase/sync/cache.cc | 137 +++++++++++++++++++++++++++++++ 10 files changed, 182 insertions(+), 62 deletions(-) delete mode 100644 cmake/FindPMEM.cmake create mode 100644 storage/innobase/include/cache.h create mode 100644 storage/innobase/sync/cache.cc diff --git a/cmake/FindPMEM.cmake b/cmake/FindPMEM.cmake deleted file mode 100644 index 024436444d2..00000000000 --- a/cmake/FindPMEM.cmake +++ /dev/null @@ -1,18 +0,0 @@ -if(PMEM_LIBRARIES) - set(PMEM_FOUND TRUE) - return() -endif() -if(DEFINED PMEM_LIBRARIES) - set(PMEM_FOUND FALSE) - return() -endif() - -find_path(PMEM_INCLUDE_DIRS NAMES libpmem.h) -find_library(PMEM_LIBRARIES NAMES pmem) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( - PMEM DEFAULT_MSG - PMEM_LIBRARIES PMEM_INCLUDE_DIRS) - -mark_as_advanced(PMEM_INCLUDE_DIRS PMEM_LIBRARIES) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 28ffe15b712..b64e30ac0e3 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -71,12 +71,6 @@ replace_uring_with_aio() -e '/-DWITH_URING=ON/d' -i debian/rules } -disable_pmem() -{ - sed '/libpmem-dev/d' -i debian/control - sed '/-DWITH_PMEM=ON/d' -i debian/rules -} - disable_libfmt() { # 7.0+ required @@ -116,10 +110,6 @@ in "buster") disable_libfmt replace_uring_with_aio - if [ ! "$architecture" = amd64 ] - then - disable_pmem - fi ;& "bullseye") add_lsb_base_depends @@ -127,10 +117,6 @@ in "bookworm") # mariadb-plugin-rocksdb in control is 4 arches covered by the distro rocksdb-tools # so no removal is necessary. - if [[ ! "$architecture" =~ amd64|arm64|ppc64el ]] - then - disable_pmem - fi if [[ ! "$architecture" =~ amd64|arm64|armel|armhf|i386|mips64el|mipsel|ppc64el|s390x ]] then replace_uring_with_aio @@ -149,10 +135,6 @@ in add_lsb_base_depends ;& "lunar"|"mantic") - if [[ ! "$architecture" =~ amd64|arm64|ppc64el ]] - then - disable_pmem - fi if [[ ! "$architecture" =~ amd64|arm64|armhf|ppc64el|s390x ]] then replace_uring_with_aio diff --git a/debian/control b/debian/control index d4458565c68..4290b6960d2 100644 --- a/debian/control +++ b/debian/control @@ -34,7 +34,6 @@ Build-Depends: bison, libnuma-dev [linux-any], libpam0g-dev, libpcre2-dev, - libpmem-dev [amd64 arm64 ppc64el riscv64], libsnappy-dev, libssl-dev, libssl-dev:native, diff --git a/debian/rules b/debian/rules index b4ca7897dcc..47586c462f9 100755 --- a/debian/rules +++ b/debian/rules @@ -51,12 +51,6 @@ ifeq (32,$(DEB_HOST_ARCH_BITS)) CMAKEFLAGS += -DPLUGIN_ROCKSDB=NO endif -# Only attempt to build with PMEM on archs that have package libpmem-dev available -# See https://packages.debian.org/search?searchon=names&keywords=libpmem-dev -ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64 ppc64el riscv64)) - CMAKEFLAGS += -DWITH_PMEM=ON -endif - # Add support for verbose builds MAKEFLAGS += VERBOSE=1 diff --git a/extra/mariabackup/CMakeLists.txt b/extra/mariabackup/CMakeLists.txt index b8d23d4c2e7..63ac8cf33e6 100644 --- a/extra/mariabackup/CMakeLists.txt +++ b/extra/mariabackup/CMakeLists.txt @@ -50,10 +50,6 @@ ADD_DEFINITIONS(-UMYSQL_SERVER) ADD_DEFINITIONS(-DPCRE_STATIC=1) ADD_DEFINITIONS(${SSL_DEFINES}) -IF(PMEM_FOUND) - ADD_COMPILE_FLAGS(xtrabackup.cc COMPILE_FLAGS "-DHAVE_PMEM") -ENDIF() - MYSQL_ADD_EXECUTABLE(mariadb-backup xtrabackup.cc innobackupex.cc diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 9b5024b2421..6f99680eadf 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -48,6 +48,13 @@ IF(UNIX) IF(HAVE_LIBNUMA) LINK_LIBRARIES(numa) ENDIF() + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch|AARCH|p(ower)?pc|x86_|amd)64") + OPTION(WITH_INNODB_PMEM "Support memory-mapped InnoDB redo log" ON) + ELSE() # Disable by default on ISA that are not covered by our CI + OPTION(WITH_INNODB_PMEM "Support memory-mapped InnoDB redo log" OFF) + ENDIF() + ENDIF() ENDIF() ENDIF() @@ -428,18 +435,9 @@ SET(INNOBASE_SOURCES ut/ut0vec.cc ut/ut0wqueue.cc) -OPTION(WITH_PMEM "Support redo log in persistent memory" OFF) -FIND_PACKAGE(PMEM) -IF(PMEM_FOUND) - INCLUDE_DIRECTORIES(${PMEM_INCLUDES}) - ADD_COMPILE_FLAGS(log/log0log.cc log/log0recv.cc - buf/buf0flu.cc mtr/mtr0mtr.cc trx/trx0trx.cc srv/srv0start.cc - COMPILE_FLAGS "-DHAVE_PMEM") - SET(PMEM_LIBRARY ${PMEM_LIBRARIES}) -ELSE() - IF(WITH_PMEM) - MESSAGE(FATAL_ERROR "WITH_PMEM=ON cannot be satisfied") - ENDIF() +IF(WITH_INNODB_PMEM) + ADD_DEFINITIONS(-DHAVE_PMEM) + SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} include/cache.h sync/cache.cc) ENDIF() MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE @@ -447,7 +445,6 @@ MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE DEFAULT RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ${ZLIB_LIBRARY} - ${PMEM_LIBRARY} ${NUMA_LIBRARY} ${LIBSYSTEMD} ${LINKER_SCRIPT}) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index ba64f1fbbfa..08333c84d99 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1733,7 +1733,7 @@ static ulint buf_flush_LRU(ulint max_n) } #ifdef HAVE_PMEM -# include +# include "cache.h" #endif /** Write checkpoint information to the log header and release mutex. diff --git a/storage/innobase/include/cache.h b/storage/innobase/include/cache.h new file mode 100644 index 00000000000..770f4d96477 --- /dev/null +++ b/storage/innobase/include/cache.h @@ -0,0 +1,33 @@ +/***************************************************************************** + +Copyright (c) 2024, MariaDB plc + +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 +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +#pragma once +#include + +#if defined __x86_64__ || defined __aarch64__ +struct pmem_control +{ + void (*persist)(const void *, size_t); +public: + pmem_control(); +}; +extern const pmem_control pmem; +# define pmem_persist(buf, size) pmem.persist(buf, size) +#else +void pmem_persist(const void *buf, size_t size); +#endif diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 022843fdd1e..ea717de226a 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -178,7 +178,7 @@ void log_file_t::write(os_offset_t offset, span buf) noexcept } #ifdef HAVE_PMEM -# include +# include "cache.h" /** Attempt to memory map a file. @param file log file handle diff --git a/storage/innobase/sync/cache.cc b/storage/innobase/sync/cache.cc new file mode 100644 index 00000000000..5c41998f47d --- /dev/null +++ b/storage/innobase/sync/cache.cc @@ -0,0 +1,137 @@ +/***************************************************************************** + +Copyright (c) 2024, MariaDB plc + +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 +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +/* This is based on the implementation of pmem_persist() in +https://github.com/pmem/pmdk/, Copyright 2014-2020, Intel Corporation, +last revised in libpmem-1.12.0. */ + +#include "my_global.h" +#include "cache.h" +#include + +#if defined __x86_64__ || defined __aarch64__ +# ifdef __x86_64__ +static void pmem_clflush(const void *buf, size_t size) +{ + for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), + end= uintptr_t(buf) + size; + u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) + __asm__ __volatile__("clflush %0" :: + "m"(*reinterpret_cast(u)) : "memory"); +} + +static void pmem_clflushopt(const void *buf, size_t size) +{ + for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), + end= uintptr_t(buf) + size; + u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) + __asm__ __volatile__(".byte 0x66; clflush %0" /* clflushopt */ :: + "m"(*reinterpret_cast(u)) : "memory"); + __asm__ __volatile__("sfence" ::: "memory"); +} + +static void pmem_clwb(const void *buf, size_t size) +{ + for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), + end= uintptr_t(buf) + size; + u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) + __asm__ __volatile__(".byte 0x66; xsaveopt %0" /* clwb */ :: + "m"(*reinterpret_cast(u)) : "memory"); + __asm__ __volatile__("sfence" ::: "memory"); +} + +# include +static decltype(pmem_control::persist) pmem_persist_init() +{ + uint32_t eax= 0, ebx= 0, ecx= 0, edx= 0; + __cpuid_count(7, 0, eax, ebx, ecx, edx); + if (ebx & 1U<<24 /* CLWB */) + return pmem_clwb; + else if (ebx & 1U<<23 /* CLFLUSHOPT */) + return pmem_clflushopt; + else + return pmem_clflush; +} +# elif defined __aarch64__ +static void pmem_cvac(const void* buf, size_t size) +{ + for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), + end= uintptr_t(buf) + size; + u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) + __asm__ __volatile__("dc cvac, %0" :: "r"(u) : "memory"); + __asm__ __volatile__("dmb ishst" ::: "memory"); +} + +static void pmem_cvap(const void* buf, size_t size) +{ + for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), + end= uintptr_t(buf) + size; + u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) + __asm__ __volatile__(".arch armv8.2-a\n dc cvap, %0" :: "r"(u) : "memory"); + __asm__ __volatile__("dmb ishst" ::: "memory"); +} + +# include +# include +# ifndef HWCAP_DCPOP +# define HWCAP_DCPOP (1 << 16) +# endif + +static decltype(pmem_control::persist) pmem_persist_init() +{ + return (getauxval(AT_HWCAP) & HWCAP_DCPOP) ? pmem_cvap : pmem_cvac; +} +# endif + +pmem_control::pmem_control() : persist(pmem_persist_init()) {} +const pmem_control pmem; +#else +void pmem_persist(const void *buf, size_t size) +{ +# ifdef __ppc64__ + for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), + end= uintptr_t(buf) + size; + u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) + { + /* GCC is just passing the inline asm snippets to the assembler, + and it does not even define these mnemonics by itself. Clang does, + and it includes a built-in assembler. + + Let us hope that having a recent enough GCC is an adequate proxy + for having a recent enough assembler. */ +# if __GNUC__ >= 11 || (defined __clang_major__ && __clang_major__ >= 12) + __asm__ __volatile__("dcbstps 0,%0" :: r(u) : "memory"); +# else + __asm__ __volatile__(".long (0x7cc000AC | %0 << 11)" :: "r"(u) : "memory"); +# endif + } + +# if __GNUC__ >= 11 || (defined __clang_major__ && __clang_major__ >= 18) + __asm__ __volatile__("phwsync" ::: "memory"); +# else + __asm__ __volatile__(".long 0x7c80040a" ::: "memory"); +# endif +# elif defined __riscv && __riscv_xlen == 64 + __asm__ __volatile__("fence w,w" ::: "memory"); +# elif defined __loongarch64 + __asm__ __volatile__("dbar 0" ::: "memory"); +# else +# error "Missing implementation; recompile with cmake -DWITH_INNODB_PMEM=OFF" +# endif +} +#endif From 8e663f5e9041e8e0998c792bf8d0c297a8b0721a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 Apr 2024 11:04:51 +0300 Subject: [PATCH 163/313] MDEV-32791 MariaDB cannot be installed on Red Hat ubi9 The libpmem dependency that had been added in commit 3daef523af25e4f1e4e75d2c26a9b25475f0c679 (MDEV-17084) did not achieve any measurable performance improvement when comparing the same PMEM device with and without "mount -o dax" using the Linux ext4 file system. Because Red Hat has deprecated libpmem, let us remove the code altogether. Note: This is a 10.6 version of commit 3f9f5ca48e6be55613926964314f550c8ca8542d which will retain PMEM support in MariaDB Server 10.11. --- cmake/FindPMEM.cmake | 18 ----- debian/autobake-deb.sh | 18 ----- debian/control | 1 - debian/rules | 6 -- storage/innobase/CMakeLists.txt | 13 ---- storage/innobase/log/log0log.cc | 114 -------------------------------- 6 files changed, 170 deletions(-) delete mode 100644 cmake/FindPMEM.cmake diff --git a/cmake/FindPMEM.cmake b/cmake/FindPMEM.cmake deleted file mode 100644 index 73e71bc29f4..00000000000 --- a/cmake/FindPMEM.cmake +++ /dev/null @@ -1,18 +0,0 @@ -if(PMEM_LIBRARIES) - set(PMEM_FOUND TRUE) - return() -endif() -if(DEFINED PMEM_LIBRARIES) - set(PMEM_FOUND FALSE) - return() -endif() - -find_path(PMEM_INCLUDE_DIR NAMES libpmem.h) -find_library(PMEM_LIBRARIES NAMES pmem) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( - PMEM DEFAULT_MSG - PMEM_LIBRARIES PMEM_INCLUDE_DIR) - -mark_as_advanced(PMEM_INCLUDE_DIR PMEM_LIBRARIES) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 500fef5a4dd..a0c0f2d30de 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -61,12 +61,6 @@ replace_uring_with_aio() -e '/-DWITH_URING=ON/d' -i debian/rules } -disable_pmem() -{ - sed '/libpmem-dev/d' -i debian/control - sed '/-DWITH_PMEM=ON/d' -i debian/rules -} - architecture=$(dpkg-architecture -q DEB_BUILD_ARCH) # Parse release name and number from Linux standard base release @@ -99,18 +93,10 @@ in # Debian "buster") replace_uring_with_aio - if [ ! "$architecture" = amd64 ] - then - disable_pmem - fi ;& "bullseye"|"bookworm") # mariadb-plugin-rocksdb in control is 4 arches covered by the distro rocksdb-tools # so no removal is necessary. - if [[ ! "$architecture" =~ amd64|arm64|ppc64el ]] - then - disable_pmem - fi if [[ ! "$architecture" =~ amd64|arm64|armel|armhf|i386|mips64el|mipsel|ppc64el|s390x ]] then replace_uring_with_aio @@ -132,10 +118,6 @@ in then remove_rocksdb_tools fi - if [[ ! "$architecture" =~ amd64|arm64|ppc64el ]] - then - disable_pmem - fi if [[ ! "$architecture" =~ amd64|arm64|armhf|ppc64el|s390x ]] then replace_uring_with_aio diff --git a/debian/control b/debian/control index 30a31b6a6f9..2af21b88ded 100644 --- a/debian/control +++ b/debian/control @@ -30,7 +30,6 @@ Build-Depends: bison, libnuma-dev [linux-any], libpam0g-dev, libpcre2-dev, - libpmem-dev [amd64 arm64 ppc64el riscv64], libsnappy-dev, libssl-dev, libssl-dev:native, diff --git a/debian/rules b/debian/rules index 5b797d50648..b92e49e12c5 100755 --- a/debian/rules +++ b/debian/rules @@ -49,12 +49,6 @@ ifeq (32,$(DEB_HOST_ARCH_BITS)) CMAKEFLAGS += -DPLUGIN_ROCKSDB=NO endif -# Only attempt to build with PMEM on archs that have package libpmem-dev available -# See https://packages.debian.org/search?searchon=names&keywords=libpmem-dev -ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64 ppc64el riscv64)) - CMAKEFLAGS += -DWITH_PMEM=ON -endif - # Add support for verbose builds MAKEFLAGS += VERBOSE=1 diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index aaf0640cebd..a554f0e04d7 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -439,24 +439,11 @@ SET(INNOBASE_SOURCES ut/ut0vec.cc ut/ut0wqueue.cc) -OPTION(WITH_PMEM "Support redo log in persistent memory" OFF) -FIND_PACKAGE(PMEM) -IF(PMEM_FOUND) - INCLUDE_DIRECTORIES(${PMEM_INCLUDES}) - ADD_COMPILE_FLAGS(log/log0log.cc COMPILE_FLAGS "-DHAVE_PMEM") - SET(PMEM_LIBRARY ${PMEM_LIBRARIES}) -ELSE() - IF(WITH_PMEM) - MESSAGE(FATAL_ERROR "WITH_PMEM=ON cannot be satisfied") - ENDIF() -ENDIF() - MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE MODULE_OUTPUT_NAME ha_innodb DEFAULT RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ${ZLIB_LIBRARY} - ${PMEM_LIBRARY} ${NUMA_LIBRARY} ${LIBSYSTEMD} ${LINKER_SCRIPT}) diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 666e4418d27..18726f6cbd7 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -295,125 +295,11 @@ dberr_t file_os_io::flush() noexcept return os_file_flush(m_fd) ? DB_SUCCESS : DB_ERROR; } -#ifdef HAVE_PMEM - -#include - -/** Memory mapped file */ -class mapped_file_t -{ -public: - mapped_file_t()= default; - mapped_file_t(const mapped_file_t &)= delete; - mapped_file_t &operator=(const mapped_file_t &)= delete; - mapped_file_t(mapped_file_t &&)= delete; - mapped_file_t &operator=(mapped_file_t &&)= delete; - ~mapped_file_t() noexcept; - - dberr_t map(const char *path, bool read_only= false, - bool nvme= false) noexcept; - dberr_t unmap() noexcept; - byte *data() noexcept { return m_area.data(); } - -private: - span m_area; -}; - -mapped_file_t::~mapped_file_t() noexcept -{ - if (!m_area.empty()) - unmap(); -} - -dberr_t mapped_file_t::map(const char *path, bool read_only, - bool nvme) noexcept -{ - auto fd= mysql_file_open(innodb_log_file_key, path, - read_only ? O_RDONLY : O_RDWR, MYF(MY_WME)); - if (fd == -1) - return DB_ERROR; - - const auto file_size= size_t{os_file_get_size(path).m_total_size}; - - const int nvme_flag= nvme ? MAP_SYNC : 0; - void *ptr= - my_mmap(0, file_size, read_only ? PROT_READ : PROT_READ | PROT_WRITE, - MAP_SHARED_VALIDATE | nvme_flag, fd, 0); - mysql_file_close(fd, MYF(MY_WME)); - - if (ptr == MAP_FAILED) - return DB_ERROR; - - m_area= {static_cast(ptr), file_size}; - return DB_SUCCESS; -} - -dberr_t mapped_file_t::unmap() noexcept -{ - ut_ad(!m_area.empty()); - - if (my_munmap(m_area.data(), m_area.size())) - return DB_ERROR; - - m_area= {}; - return DB_SUCCESS; -} - -static bool is_pmem(const char *path) noexcept -{ - mapped_file_t mf; - return mf.map(path, true, true) == DB_SUCCESS ? true : false; -} - -class file_pmem_io final : public file_io -{ -public: - file_pmem_io() noexcept : file_io(true) {} - - dberr_t open(const char *path, bool read_only) noexcept final - { - return m_file.map(path, read_only, true); - } - dberr_t rename(const char *old_path, const char *new_path) noexcept final - { - return os_file_rename(innodb_log_file_key, old_path, new_path) ? DB_SUCCESS - : DB_ERROR; - } - dberr_t close() noexcept final { return m_file.unmap(); } - __attribute__((warn_unused_result)) - dberr_t read(os_offset_t offset, span buf) noexcept final - { - memcpy(buf.data(), m_file.data() + offset, buf.size()); - return DB_SUCCESS; - } - dberr_t write(const char *, os_offset_t offset, - span buf) noexcept final - { - pmem_memcpy_persist(m_file.data() + offset, buf.data(), buf.size()); - return DB_SUCCESS; - } - dberr_t flush() noexcept final - { - ut_ad(0); - return DB_SUCCESS; - } - -private: - mapped_file_t m_file; -}; -#endif - dberr_t log_file_t::open(bool read_only) noexcept { ut_a(!is_opened()); -#ifdef HAVE_PMEM - auto ptr= is_pmem(m_path.c_str()) - ? std::unique_ptr(new file_pmem_io) - : std::unique_ptr(new file_os_io); -#else auto ptr= std::unique_ptr(new file_os_io); -#endif if (dberr_t err= ptr->open(m_path.c_str(), read_only)) return err; From ec7db2bdf849fc1a5bad906764920edda4121bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 Apr 2024 12:39:48 +0300 Subject: [PATCH 164/313] MDEV-33325 fixup ibuf_remove_free_page(): Correct the calculation of root_savepoint(). The first entry acquired by ibuf_tree_root_get() will be ibuf.index.lock and not the change buffer root page. Thanks to Matthias Leich for finding this bug in RQG. Unfortunately, this code is very difficult to cover in our regression test suite. --- storage/innobase/ibuf/ibuf0ibuf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 70824cff8a5..10310a0b94a 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1888,13 +1888,13 @@ early_exit: return; } - const auto root_savepoint = mtr.get_savepoint(); buf_block_t* root = ibuf_tree_root_get(&mtr); if (UNIV_UNLIKELY(!root)) { goto early_exit; } + const auto root_savepoint = mtr.get_savepoint() - 1; const uint32_t page_no = flst_get_last(PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST + root->page.frame).page; From 4c34339426f390c7d55b8e74376ce3e1bb75f0fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 19 Apr 2024 15:46:21 +0300 Subject: [PATCH 165/313] MDEV-33946: OPT_PAGE_CHECKSUM mismatch due to mtr_t::memmove() mtr_t::memmove(): Revert to the parent of commit a032f14b342c782b82dfcd9235805bee446e6fe8 where there was supposed to be an equivalent change that would avoid hitting a warning in some old version of GCC when this change was part of another 10.6 based developmet branch. For some reason, this change is not equivalent but will cause massive amounts of backup failures in the stress tests run by Matthias Leich, caught by commit 4179f93d28035ea2798cb1c16feeaaef87ab4775 in 10.6. --- storage/innobase/include/mtr0log.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/storage/innobase/include/mtr0log.h b/storage/innobase/include/mtr0log.h index b8455f927bf..285672be898 100644 --- a/storage/innobase/include/mtr0log.h +++ b/storage/innobase/include/mtr0log.h @@ -347,12 +347,11 @@ inline void mtr_t::memmove(const buf_block_t &b, ulint d, ulint s, ulint len) ut_ad(d >= 8); ut_ad(s >= 8); ut_ad(len); - ut_d(const ulint ps= srv_page_size); - ut_ad(s <= ps); - ut_ad(s + len <= ps); + ut_ad(s <= ulint(srv_page_size)); + ut_ad(s + len <= ulint(srv_page_size)); ut_ad(s != d); - ut_ad(d <= ps); - ut_ad(d + len <= ps); + ut_ad(d <= ulint(srv_page_size)); + ut_ad(d + len <= ulint(srv_page_size)); set_modified(b); if (m_log_mode != MTR_LOG_ALL) @@ -360,17 +359,17 @@ inline void mtr_t::memmove(const buf_block_t &b, ulint d, ulint s, ulint len) static_assert(MIN_4BYTE > UNIV_PAGE_SIZE_MAX, "consistency"); size_t lenlen= (len < MIN_2BYTE ? 1 : len < MIN_3BYTE ? 2 : 3); /* The source offset is encoded relative to the destination offset, - with the sign in the least significant bit. - Because the source offset 0 is not possible, our encoding - subtracts 1 from the offset. */ - const uint16_t S= s > d - ? uint16_t((s - d - 1) << 1) - : uint16_t((d - s - 1) << 1 | 1); + with the sign in the least significant bit. */ + if (s > d) + s= (s - d) << 1; + else + s= (d - s) << 1 | 1; /* The source offset 0 is not possible. */ - size_t slen= (S < MIN_2BYTE ? 1 : S < MIN_3BYTE ? 2 : 3); + s-= 1 << 1; + size_t slen= (s < MIN_2BYTE ? 1 : s < MIN_3BYTE ? 2 : 3); byte *l= log_write(b.page.id(), &b.page, lenlen + slen, true, d); l= mlog_encode_varint(l, len); - l= mlog_encode_varint(l, S); + l= mlog_encode_varint(l, s); m_log.close(l); m_last_offset= static_cast(d + len); } From 7432a487b1334aacd1ed535f8a29cf939a13cde7 Mon Sep 17 00:00:00 2001 From: Zhibo Zhang Date: Tue, 19 Mar 2024 19:16:46 +0000 Subject: [PATCH 166/313] Update tests to be compatible with OpenSSL 3.2.0 As of version 3.2.0, OpenSSL updated the error message in new versions ("https://github.com/openssl/openssl/commit/81b741f68984"). Update the tests and result files such that they are compatible with both original and new error messages. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- mysql-test/main/ssl_crl.result | 2 +- mysql-test/main/ssl_crl.test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/ssl_crl.result b/mysql-test/main/ssl_crl.result index d5603254ea5..58e3e07f746 100644 --- a/mysql-test/main/ssl_crl.result +++ b/mysql-test/main/ssl_crl.result @@ -2,4 +2,4 @@ Variable_name Value Ssl_version TLS_VERSION # try logging in with a certificate in the server's --ssl-crl : should fail -ERROR 2026 (HY000): TLS/SSL error: sslv3 alert certificate revoked +ERROR 2026 (HY000): TLS/SSL error: ssl/tls alert certificate revoked diff --git a/mysql-test/main/ssl_crl.test b/mysql-test/main/ssl_crl.test index 7ed5c210215..80188001396 100644 --- a/mysql-test/main/ssl_crl.test +++ b/mysql-test/main/ssl_crl.test @@ -7,7 +7,7 @@ --exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/server-new-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/server-new-cert.pem test -e "SHOW STATUS LIKE 'Ssl_version'" --echo # try logging in with a certificate in the server's --ssl-crl : should fail -# OpenSSL 1.1.1a correctly rejects the certificate, but the error message is different ---replace_regex /ERROR 2013 \(HY000\): Lost connection to MySQL server at '.*', system error: [0-9]+/ERROR 2026 (HY000): TLS\/SSL error: sslv3 alert certificate revoked/ +# OpenSSL 1.1.1a and later releases correctly rejects the certificate, but the error message is different +--replace_regex /(ERROR 2013 \(HY000\): Lost connection to MySQL server at '.*', system error: [0-9]+|ERROR 2026 \(HY000\): TLS\/SSL error: sslv3 alert certificate revoked)/ERROR 2026 (HY000): TLS\/SSL error: ssl\/tls alert certificate revoked/ --error 1 --exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_version'" 2>&1 From 4a2e03453a5b2ae575d87152263f5ff715242dc2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 19 Apr 2024 22:09:06 +0200 Subject: [PATCH 167/313] MDEV-33952 galera_create_table_as_select fails sporadically disable until fixed --- mysql-test/suite/galera/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index a5a1a6f18b1..4aacbd0c699 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -22,3 +22,4 @@ galera_var_ignore_apply_errors : MENT-1997 galera_var_ignore_apply_errors test f MDEV-22232 : temporarily disabled at the request of Codership MW-402 : temporarily disabled at the request of Codership galera_desync_overlapped : MDEV-21538 galera_desync_overlapped MTR failed: Result content mismatch +galera_create_table_as_select : MDEV-33952 fails sporadically From 8fd515e0d24de7e437d988aebfa4cc43af7a2fb0 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Sat, 20 Apr 2024 03:51:31 +0200 Subject: [PATCH 168/313] HASHICORP_KEY_MANAGEMENT: MDEV-33420 post-fix Compilation correction after MDEV-33420. --- plugin/hashicorp_key_management/CMakeLists.txt | 7 ++++++- .../hashicorp_key_management_plugin.cc | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugin/hashicorp_key_management/CMakeLists.txt b/plugin/hashicorp_key_management/CMakeLists.txt index bef7e65be27..809b480f6ac 100644 --- a/plugin/hashicorp_key_management/CMakeLists.txt +++ b/plugin/hashicorp_key_management/CMakeLists.txt @@ -1,16 +1,21 @@ FIND_PACKAGE(CURL) IF(NOT CURL_FOUND) # Can't build plugin + MESSAGE_ONCE(WARNING "Hashicorp Key Management plugin requires curl development package") RETURN() ENDIF() +SET_PACKAGE_PROPERTIES(CURL PROPERTIES TYPE REQUIRED) + +INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) + set(CPACK_RPM_hashicorp-key-management_PACKAGE_SUMMARY "Hashicorp Key Management plugin for MariaDB" PARENT_SCOPE) set(CPACK_RPM_hashicorp-key-management_PACKAGE_DESCRIPTION "This encryption plugin uses Hashicorp Vault for storing encryption keys for MariaDB Data-at-Rest encryption." PARENT_SCOPE) MYSQL_ADD_PLUGIN(HASHICORP_KEY_MANAGEMENT hashicorp_key_management_plugin.cc - LINK_LIBRARIES CURL::libcurl + LINK_LIBRARIES ${CURL_LIBRARIES} CONFIG hashicorp_key_management.cnf COMPONENT hashicorp-key-management MODULE_ONLY) diff --git a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc index 7bd038ef73a..dfeb1aca737 100644 --- a/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc +++ b/plugin/hashicorp_key_management/hashicorp_key_management_plugin.cc @@ -987,7 +987,11 @@ int HCData::init () bool not_equal= token_env != NULL && strcmp(token_env, token) != 0; if (token_env == NULL || not_equal) { - setenv("VAULT_TOKEN", token, 1); +#if defined(HAVE_SETENV) || !defined(_WIN32) + setenv("VAULT_TOKEN", token, 1); +#else + _putenv_s("VAULT_TOKEN", token); +#endif if (not_equal) { my_printf_error(ER_UNKNOWN_ERROR, PLUGIN_ERROR_HEADER From 0c249ad718f2ee96aaceebfa5ce21927cfa2f0d4 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Tue, 16 Apr 2024 10:08:31 +0200 Subject: [PATCH 169/313] MDEV-30232: rpl.rpl_gtid_crash fails sporadically in BB The root cause of the failure is a bug in the Linux network stack: https://lore.kernel.org/netdev/87sf0ldk41.fsf@urd.knielsen-hq.org/T/#u If the slave does a connect(2) at the exact same time that kill -9 of the master process closes the listening socket, the FIN or RST packet is lost in the kernel, and the slave ends up timing out waiting for the initial communication from the server. This timeout defaults to --slave-net-timeout=120, which causes include/master_gtid_wait.inc to time out first and fail the test. Work-around this problem by reducing the --slave-net-timeout for this test case. If this problem turns up in other tests, we can consider reducing the default value for all tests. Signed-off-by: Kristian Nielsen --- mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt b/mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt index 69c1a64e388..5b3fb44c910 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt +++ b/mysql-test/suite/rpl/t/rpl_gtid_crash-slave.opt @@ -1 +1 @@ ---master-retry-count=100 +--master-retry-count=100 --slave-net-timeout=10 From 57f6a1ca98b94e9bed5ba3b8d98ad1a620810089 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Tue, 16 Apr 2024 12:39:54 +0200 Subject: [PATCH 170/313] MDEV-19415: use-after-free on charsets_dir from slave connect The slave IO thread sets MYSQL_SET_CHARSET_DIR. The code for this option however is not thread-safe in sql-common/client.c. The value set is temporarily written to mysys global variable `charsets-dir` and can be seen by other threads running in parallel, which can result in use-after-free error. Problem was visible as random failures of test cases in suite multi_source with Valgrind or MSAN. Work-around by not setting this option for slave connect, it is redundant anyway as it is just setting the default value. Signed-off-by: Kristian Nielsen --- sql/slave.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index f70336e980a..5948d11825d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -7412,9 +7412,6 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, default_client_charset_info->csname); } - /* This one is not strictly needed but we have it here for completeness */ - mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir); - /* Set MYSQL_PLUGIN_DIR in case master asks for an external authentication plugin */ if (opt_plugin_dir_ptr && *opt_plugin_dir_ptr) mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr); @@ -7557,8 +7554,6 @@ MYSQL *rpl_connect_master(MYSQL *mysql) #endif mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname); - /* This one is not strictly needed but we have it here for completeness */ - mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir); if (mi->user == NULL || mi->user[0] == 0 From c7c396718105c74cbaec920f28c90d5b18e39861 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 20 Apr 2024 18:34:03 +0200 Subject: [PATCH 171/313] use correct thd for DEBUG_SYNC in group commit it always has to be current_thd, DBUG_SYNC asserts that. fixes sporadic SIGABRT's in binlog_encryption.rpl_parallel_slave_bgc_kill --- sql/log.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 281bb3eecde..b2f6ef596da 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -8029,9 +8029,9 @@ MYSQL_BIN_LOG::queue_for_group_commit(group_commit_entry *orig_entry) if (entry->cache_mngr->using_xa) { - DEBUG_SYNC(entry->thd, "commit_before_prepare_ordered"); + DEBUG_SYNC(orig_entry->thd, "commit_before_prepare_ordered"); run_prepare_ordered(entry->thd, entry->all); - DEBUG_SYNC(entry->thd, "commit_after_prepare_ordered"); + DEBUG_SYNC(orig_entry->thd, "commit_after_prepare_ordered"); } if (cur) From a4b6409ff6526a4b82934514139e1217910b26f0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 21 Apr 2024 01:15:37 +0200 Subject: [PATCH 172/313] sporadic failures of binlog_encryption.rpl_parallel_slave_bgc_kill do CHANGE MASTER before sync_with_master to have the slave in a predictable fully synced state before the next test --- .../rpl_parallel_slave_bgc_kill.result | 8 +++----- .../suite/rpl/r/rpl_parallel_slave_bgc_kill.result | 8 +++----- .../suite/rpl/t/rpl_parallel_slave_bgc_kill.test | 10 +++------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/mysql-test/suite/binlog_encryption/rpl_parallel_slave_bgc_kill.result b/mysql-test/suite/binlog_encryption/rpl_parallel_slave_bgc_kill.result index ba131ea094f..6b75dbf6181 100644 --- a/mysql-test/suite/binlog_encryption/rpl_parallel_slave_bgc_kill.result +++ b/mysql-test/suite/binlog_encryption/rpl_parallel_slave_bgc_kill.result @@ -206,10 +206,12 @@ RETURN x; END || SET sql_log_bin=1; +include/stop_slave_io.inc connection server_1; INSERT INTO t3 VALUES (49,0); connection server_2; -START SLAVE SQL_THREAD; +CHANGE MASTER TO master_use_gtid=no; +include/start_slave.inc SELECT * FROM t3 WHERE a >= 40 ORDER BY a; a b 41 41 @@ -239,10 +241,6 @@ SET GLOBAL slave_parallel_threads=0; SET GLOBAL slave_parallel_threads=10; include/start_slave.inc *** 3. Same as (2), but not using gtid mode *** -connection server_2; -include/stop_slave.inc -CHANGE MASTER TO master_use_gtid=no; -include/start_slave.inc connection server_1; connection con_temp3; SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1'; diff --git a/mysql-test/suite/rpl/r/rpl_parallel_slave_bgc_kill.result b/mysql-test/suite/rpl/r/rpl_parallel_slave_bgc_kill.result index ba131ea094f..6b75dbf6181 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_slave_bgc_kill.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_slave_bgc_kill.result @@ -206,10 +206,12 @@ RETURN x; END || SET sql_log_bin=1; +include/stop_slave_io.inc connection server_1; INSERT INTO t3 VALUES (49,0); connection server_2; -START SLAVE SQL_THREAD; +CHANGE MASTER TO master_use_gtid=no; +include/start_slave.inc SELECT * FROM t3 WHERE a >= 40 ORDER BY a; a b 41 41 @@ -239,10 +241,6 @@ SET GLOBAL slave_parallel_threads=0; SET GLOBAL slave_parallel_threads=10; include/start_slave.inc *** 3. Same as (2), but not using gtid mode *** -connection server_2; -include/stop_slave.inc -CHANGE MASTER TO master_use_gtid=no; -include/start_slave.inc connection server_1; connection con_temp3; SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1'; diff --git a/mysql-test/suite/rpl/t/rpl_parallel_slave_bgc_kill.test b/mysql-test/suite/rpl/t/rpl_parallel_slave_bgc_kill.test index efb998b0443..94f19a6cdd7 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_slave_bgc_kill.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_slave_bgc_kill.test @@ -295,13 +295,14 @@ CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) || --delimiter ; SET sql_log_bin=1; - +--source include/stop_slave_io.inc --connection server_1 INSERT INTO t3 VALUES (49,0); --save_master_pos --connection server_2 -START SLAVE SQL_THREAD; +CHANGE MASTER TO master_use_gtid=no; +--source include/start_slave.inc --sync_with_master SELECT * FROM t3 WHERE a >= 40 ORDER BY a; # Restore the foo() function. @@ -334,11 +335,6 @@ SET GLOBAL slave_parallel_threads=10; --echo *** 3. Same as (2), but not using gtid mode *** ---connection server_2 ---source include/stop_slave.inc -CHANGE MASTER TO master_use_gtid=no; ---source include/start_slave.inc - --connection server_1 # Set up three transactions on the master that will be group-committed # together so they can be replicated in parallel on the slave. From 1437e734f7e2c7413cf6871e34268b15ce179a5e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 21 Apr 2024 10:47:20 +0200 Subject: [PATCH 173/313] adjust timeout value in main.ssl_timeout test fixes sporadic failures under --valgrind --- mysql-test/main/ssl_timeout.result | 2 +- mysql-test/main/ssl_timeout.test | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/ssl_timeout.result b/mysql-test/main/ssl_timeout.result index 208be527a6b..d94cfed8571 100644 --- a/mysql-test/main/ssl_timeout.result +++ b/mysql-test/main/ssl_timeout.result @@ -1,5 +1,5 @@ # connect with read timeout so SLEEP() should timeout -connect ssl_con,localhost,root,,,,,SSL read_timeout=5; +connect ssl_con,localhost,root,,,,,SSL read_timeout=5$_timeout_adjustment; # Check ssl turned on SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; have_ssl diff --git a/mysql-test/main/ssl_timeout.test b/mysql-test/main/ssl_timeout.test index f5965f874ff..d762ebc35a9 100644 --- a/mysql-test/main/ssl_timeout.test +++ b/mysql-test/main/ssl_timeout.test @@ -1,10 +1,11 @@ --source include/have_ssl_communication.inc +--source include/slow_environ.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc --echo # connect with read timeout so SLEEP() should timeout -connect (ssl_con,localhost,root,,,,,SSL read_timeout=5); +connect (ssl_con,localhost,root,,,,,SSL read_timeout=5$_timeout_adjustment); --echo # Check ssl turned on SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; From 6242783f24092946db695c0ff0b7debba6042059 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 21 Apr 2024 11:14:04 +0200 Subject: [PATCH 174/313] rpl.rpl_semi_sync_fail_over improve debugability --- .../rpl/r/rpl_semi_sync_fail_over.result | 42 ++++++++++++------- .../suite/rpl/t/rpl_semi_sync_crash.inc | 8 +--- .../suite/rpl/t/rpl_semi_sync_fail_over.test | 6 +-- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result b/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result index ca7c802bfbe..96150209af9 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result @@ -44,7 +44,9 @@ SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; connection server_2; include/wait_for_slave_param.inc [Slave_SQL_Running_State] include/stop_slave.inc -include/assert.inc [Table t1 should have 2 rows.] +select count(*) 'on slave must be 2' from t1; +on slave must be 2 +2 SELECT @@GLOBAL.gtid_current_pos; @@GLOBAL.gtid_current_pos 0-1-4 @@ -52,7 +54,9 @@ SELECT @@GLOBAL.gtid_current_pos; connection server_1; # Ensuring variable rpl_semi_sync_slave_enabled is ON.. # Ensuring status rpl_semi_sync_slave_status is OFF.. -include/assert.inc [Table t1 should have 1 rows.] +select count(*) 'on master must be 1' from t1; +on master must be 1 +1 FOUND 1 /truncated binlog file:.*master.*000001/ in mysqld.1.err disconnect conn_client; connection server_2; @@ -79,9 +83,9 @@ SHOW VARIABLES LIKE 'gtid_slave_pos'; Variable_name Value gtid_slave_pos 0-1-4 connection server_1; -SELECT COUNT(*) = 3 as 'true' FROM t1; -true -1 +SELECT COUNT(*) 'must be 3' FROM t1; +must be 3 +3 # ... the gtid states on the slave: SHOW VARIABLES LIKE 'gtid_slave_pos'; Variable_name Value @@ -124,7 +128,9 @@ SET DEBUG_SYNC= "now WAIT_FOR eof_reached"; connection server_1; include/wait_for_slave_param.inc [Slave_SQL_Running_State] include/stop_slave.inc -include/assert.inc [Table t1 should have 5 rows.] +select count(*) 'on slave must be 5' from t1; +on slave must be 5 +5 SELECT @@GLOBAL.gtid_current_pos; @@GLOBAL.gtid_current_pos 0-2-7 @@ -132,7 +138,9 @@ SELECT @@GLOBAL.gtid_current_pos; connection server_2; # Ensuring variable rpl_semi_sync_slave_enabled is ON.. # Ensuring status rpl_semi_sync_slave_status is OFF.. -include/assert.inc [Table t1 should have 3 rows.] +select count(*) 'on master must be 3' from t1; +on master must be 3 +3 FOUND 1 /truncated binlog file:.*slave.*000002.* to remove transactions starting from GTID 0-1-6/ in mysqld.2.err disconnect conn_client; connection server_1; @@ -159,9 +167,9 @@ SHOW VARIABLES LIKE 'gtid_slave_pos'; Variable_name Value gtid_slave_pos 0-2-7 connection server_2; -SELECT COUNT(*) = 6 as 'true' FROM t1; -true -1 +SELECT COUNT(*) 'must be 6 as' FROM t1; +must be 6 as +6 # ... the gtid states on the slave: SHOW VARIABLES LIKE 'gtid_slave_pos'; Variable_name Value @@ -205,7 +213,9 @@ SET DEBUG_SYNC= "now WAIT_FOR con3_ready"; connection server_2; include/wait_for_slave_param.inc [Slave_SQL_Running_State] include/stop_slave.inc -include/assert.inc [Table t1 should have 7 rows.] +select count(*) 'on slave must be 7' from t1; +on slave must be 7 +7 SELECT @@GLOBAL.gtid_current_pos; @@GLOBAL.gtid_current_pos 0-1-9 @@ -213,7 +223,9 @@ SELECT @@GLOBAL.gtid_current_pos; connection server_1; # Ensuring variable rpl_semi_sync_slave_enabled is ON.. # Ensuring status rpl_semi_sync_slave_status is OFF.. -include/assert.inc [Table t1 should have 6 rows.] +select count(*) 'on master must be 6' from t1; +on master must be 6 +6 FOUND 1 /truncated binlog file:.*master.*000002.* to remove transactions starting from GTID 0-1-9/ in mysqld.1.err disconnect conn_client; connection server_2; @@ -242,9 +254,9 @@ Variable_name Value gtid_slave_pos 0-1-9 connection server_1; include/sync_with_master_gtid.inc -SELECT COUNT(*) = 8 as 'true' FROM t1; -true -1 +SELECT COUNT(*) 'must be 8' FROM t1; +must be 8 +8 # ... the gtid states on the slave: SHOW VARIABLES LIKE 'gtid_slave_pos'; Variable_name Value diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc b/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc index b092d0018b0..5454600edf7 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc @@ -68,9 +68,7 @@ source include/wait_for_slave_param.inc; --error 2003 --source include/stop_slave.inc ---let $assert_cond= COUNT(*) = $expected_rows_on_slave FROM t1 ---let $assert_text= Table t1 should have $expected_rows_on_slave rows. ---source include/assert.inc +--eval select count(*) 'on slave must be $expected_rows_on_slave' from t1 SELECT @@GLOBAL.gtid_current_pos; @@ -95,9 +93,7 @@ if (`SELECT strcmp("OFF", "$slave_semi_sync_status") != 0`) --die Slave started with skip-slave-start yet started with rpl_semi_sync_slave_status=ON } ---let $assert_cond= COUNT(*) = $expected_rows_on_master FROM t1 ---let $assert_text= Table t1 should have $expected_rows_on_master rows. ---source include/assert.inc +--eval select count(*) 'on master must be $expected_rows_on_master' from t1 # Check error log for correct messages. let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.$server_to_crash.err; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test b/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test index e1e7a4f1de3..e4d0bc0acd1 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test @@ -83,7 +83,7 @@ SHOW VARIABLES LIKE 'gtid_slave_pos'; --connection server_1 --sync_with_master ---eval SELECT COUNT(*) = $rows_so_far as 'true' FROM t1 +--eval SELECT COUNT(*) 'must be $rows_so_far' FROM t1 --echo # ... the gtid states on the slave: SHOW VARIABLES LIKE 'gtid_slave_pos'; SHOW VARIABLES LIKE 'gtid_binlog_pos'; @@ -134,7 +134,7 @@ SHOW VARIABLES LIKE 'gtid_slave_pos'; --connection server_2 --sync_with_master ---eval SELECT COUNT(*) = $rows_so_far as 'true' FROM t1 +--eval SELECT COUNT(*) 'must be $rows_so_far as' FROM t1 --echo # ... the gtid states on the slave: SHOW VARIABLES LIKE 'gtid_slave_pos'; SHOW VARIABLES LIKE 'gtid_binlog_pos'; @@ -185,7 +185,7 @@ SHOW VARIABLES LIKE 'gtid_slave_pos'; --connection server_1 --source include/sync_with_master_gtid.inc ---eval SELECT COUNT(*) = $rows_so_far as 'true' FROM t1 +--eval SELECT COUNT(*) 'must be $rows_so_far' FROM t1 --echo # ... the gtid states on the slave: SHOW VARIABLES LIKE 'gtid_slave_pos'; SHOW VARIABLES LIKE 'gtid_binlog_pos'; From e83d92ee5e0e071e77d7fd0f73964a6bf8948124 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 21 Apr 2024 18:28:15 +0200 Subject: [PATCH 175/313] sporadic failures of rpl.rpl_semi_sync_fail_over in the $case=2 - it's wrong to kill after the first binlog EOF, because that might happen between INSERT(4) and INSERT(5). So, wait for the slave to acknowledge INSERT(5) before killing the master, that is, both connection threads must pass repl_semisync_master.wait_after_sync() --- mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result | 6 ++++-- mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc | 6 ++++-- sql/sql_repl.cc | 6 ------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result b/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result index 96150209af9..49fdb485c50 100644 --- a/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result @@ -117,13 +117,15 @@ connection server_2; #================================================================= connect conn_client,127.0.0.1,root,,test,$SERVER_MYPORT_2,; SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con1_ready WAIT_FOR con1_go"; +SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync WAIT_FOR con1_go1"; SET STATEMENT server_id=1 FOR INSERT INTO t1 VALUES (4, REPEAT("x", 4100)); connect conn_client_2,127.0.0.1,root,,test,$SERVER_MYPORT_2,; SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; -SET GLOBAL debug_dbug="d,Notify_binlog_EOF"; +SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL con1_go"; +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con2_ready"; INSERT INTO t1 VALUES (5, REPEAT("x", 4100)); connection server_2; -SET DEBUG_SYNC= "now WAIT_FOR eof_reached"; +SET DEBUG_SYNC= "now WAIT_FOR con2_ready"; # Kill the server connection server_1; include/wait_for_slave_param.inc [Slave_SQL_Running_State] diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc b/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc index 5454600edf7..bb705d390ac 100644 --- a/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc @@ -34,14 +34,16 @@ if ($case == 1) if ($case == 2) { SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con1_ready WAIT_FOR con1_go"; + SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync WAIT_FOR con1_go1"; --send_eval $query_to_crash --connect (conn_client_2,127.0.0.1,root,,test,$SERVER_MYPORT_2,) # use the same signal with $query_to_crash SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; - SET GLOBAL debug_dbug="d,Notify_binlog_EOF"; + SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL con1_go"; + SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con2_ready"; --send_eval $query2_to_crash --connection server_$server_to_crash - SET DEBUG_SYNC= "now WAIT_FOR eof_reached"; + SET DEBUG_SYNC= "now WAIT_FOR con2_ready"; --source include/kill_mysqld.inc } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 6cfb10f6bee..f96f7ac6d21 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -2828,12 +2828,6 @@ static int send_one_binlog_file(binlog_send_info *info, */ if (send_events(info, log, linfo, end_pos)) return 1; - DBUG_EXECUTE_IF("Notify_binlog_EOF", - { - const char act[]= "now signal eof_reached"; - DBUG_ASSERT(!debug_sync_set_action(current_thd, - STRING_WITH_LEN(act))); - };); } return 1; From 06a884a570719927864bd65481e94773a110962d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 25 Feb 2024 19:00:48 +0100 Subject: [PATCH 176/313] MDEV-33429 compilation of MariaDB 10.11.7 fails on arm32, sizeof(MYSQL) is wrong --- tests/mysql_client_fw.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index c9e64678527..35348d991aa 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -1430,12 +1430,14 @@ int main(int argc, char **argv) tests_to_run[i]= NULL; } -#ifdef _WIN32 - /* must be the same in C/C and embedded, 1208 on 64bit, 968 on 32bit */ - compile_time_assert(sizeof(MYSQL) == 60*sizeof(void*)+728); -#else - /* must be the same in C/C and embedded, 1272 on 64bit, 964 on 32bit */ - compile_time_assert(sizeof(MYSQL) == 77*sizeof(void*)+656); +/* + this limited check is enough, if sizeof(MYSQL) changes, it changes + everywhere +*/ +#if defined __x86_64__ + compile_time_assert(sizeof(MYSQL) == 1272); +#elif defined __i386__ + compile_time_assert(sizeof(MYSQL) == 964); #endif if (mysql_server_init(embedded_server_arg_count, From 63ac87c121f27db99a15cc9c4230ffc5c0d5a2d4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 19 Apr 2024 22:32:37 +0200 Subject: [PATCH 177/313] make main.mysqlbinlog_row_compressed independent from the environment don't depend on the thread ids, table ids, and current binlog content --- .../main/mysqlbinlog_row_compressed.result | 18 ++++++++++-------- .../main/mysqlbinlog_row_compressed.test | 4 +++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result index 2cf652655e0..e42708f86c9 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.result +++ b/mysql-test/main/mysqlbinlog_row_compressed.result @@ -1,3 +1,5 @@ +set pseudo_thread_id=5; +reset master; SET GLOBAL log_bin_compress=on; SET GLOBAL log_bin_compress_min_len=10; CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1)); @@ -61,7 +63,7 @@ START TRANSACTION #Q> INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "") # server id 1 end_log_pos 917 CRC32 XXX Table_map: `test`.`t1` mapped to number num # at 917 -# server id 1 end_log_pos 985 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F +# server id 1 end_log_pos 985 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -90,7 +92,7 @@ START TRANSACTION #Q> INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL) # server id 1 end_log_pos 1232 CRC32 XXX Table_map: `test`.`t1` mapped to number num # at 1232 -# server id 1 end_log_pos 1299 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F +# server id 1 end_log_pos 1299 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET ### @1=11 /* INT meta=0 nullable=0 is_null=0 */ @@ -119,7 +121,7 @@ START TRANSACTION #Q> INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A") # server id 1 end_log_pos 1548 CRC32 XXX Table_map: `test`.`t1` mapped to number num # at 1548 -# server id 1 end_log_pos 1614 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F +# server id 1 end_log_pos 1614 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET ### @1=12 /* INT meta=0 nullable=0 is_null=0 */ @@ -148,7 +150,7 @@ START TRANSACTION #Q> INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A") # server id 1 end_log_pos 1860 CRC32 XXX Table_map: `test`.`t1` mapped to number num # at 1860 -# server id 1 end_log_pos 1927 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F +# server id 1 end_log_pos 1927 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET ### @1=13 /* INT meta=0 nullable=0 is_null=0 */ @@ -177,7 +179,7 @@ START TRANSACTION #Q> INSERT INTO t2 SELECT * FROM t1 # server id 1 end_log_pos 2152 CRC32 XXX Table_map: `test`.`t2` mapped to number num # at 2152 -# server id 1 end_log_pos 2243 CRC32 XXX Write_compressed_rows: table id 33 flags: STMT_END_F +# server id 1 end_log_pos 2243 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t2` ### SET ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -239,7 +241,7 @@ START TRANSACTION #Q> UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL # server id 1 end_log_pos 2480 CRC32 XXX Table_map: `test`.`t2` mapped to number num # at 2480 -# server id 1 end_log_pos 2579 CRC32 XXX Update_compressed_rows: table id 33 flags: STMT_END_F +# server id 1 end_log_pos 2579 CRC32 XXX Update_compressed_rows: table id flags: STMT_END_F ### UPDATE `test`.`t2` ### WHERE ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -320,7 +322,7 @@ START TRANSACTION #Q> DELETE FROM t1 # server id 1 end_log_pos 2787 CRC32 XXX Table_map: `test`.`t1` mapped to number num # at 2787 -# server id 1 end_log_pos 2879 CRC32 XXX Delete_compressed_rows: table id 32 flags: STMT_END_F +# server id 1 end_log_pos 2879 CRC32 XXX Delete_compressed_rows: table id flags: STMT_END_F ### DELETE FROM `test`.`t1` ### WHERE ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -382,7 +384,7 @@ START TRANSACTION #Q> DELETE FROM t2 # server id 1 end_log_pos 3087 CRC32 XXX Table_map: `test`.`t2` mapped to number num # at 3087 -# server id 1 end_log_pos 3172 CRC32 XXX Delete_compressed_rows: table id 33 flags: STMT_END_F +# server id 1 end_log_pos 3172 CRC32 XXX Delete_compressed_rows: table id flags: STMT_END_F ### DELETE FROM `test`.`t2` ### WHERE ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ diff --git a/mysql-test/main/mysqlbinlog_row_compressed.test b/mysql-test/main/mysqlbinlog_row_compressed.test index 03868d3e6b3..6fe5cabcc40 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.test +++ b/mysql-test/main/mysqlbinlog_row_compressed.test @@ -11,6 +11,8 @@ # mysqlbinlog: compressed row event # # +set pseudo_thread_id=5; +reset master; SET GLOBAL log_bin_compress=on; SET GLOBAL log_bin_compress_min_len=10; @@ -30,7 +32,7 @@ DELETE FROM t2; FLUSH BINARY LOGS; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /\d{6} *\d*:\d\d:\d\d// /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=/ +--replace_regex /\d{6} *\d*:\d\d:\d\d// /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=/ /table id \d+/table id / --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog --echo From f0f9dc863193ebe4984823edf739a078d8586eb5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 19 Apr 2024 23:49:56 +0200 Subject: [PATCH 178/313] enable main.func_sformat in --view --- mysql-test/main/func_sformat.result | 38 +++++++++++-------------- mysql-test/main/func_sformat.test | 43 ++++++----------------------- 2 files changed, 24 insertions(+), 57 deletions(-) diff --git a/mysql-test/main/func_sformat.result b/mysql-test/main/func_sformat.result index 9e8a11677b5..11825604f1d 100644 --- a/mysql-test/main/func_sformat.result +++ b/mysql-test/main/func_sformat.result @@ -23,10 +23,8 @@ select sformat('{} {}', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); -sformat('{} {}', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) as x; +x 0 0 select sformat('{{{}}}', 0); sformat('{{{}}}', 0) @@ -78,10 +76,8 @@ select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, -106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120); -sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} - {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} - {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} +106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120) as x; +x 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 @@ -97,10 +93,8 @@ select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} { '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', -'115', '116', '117', '118', '119', '120'); -sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} - {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} - {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} +'115', '116', '117', '118', '119', '120') as x; +x 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 @@ -159,8 +153,8 @@ insert into t2 values (0.0025, 25, 'A', DATE('2020-06-29')), (0.0005, 5, 'B', DATE('2020-6-29')), (5.5555, -5, 'C', DATE('200629')), (-9, -9, 'D', DATE('20*06*29')); -select sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) from t2; -sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) +select sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) x from t2; +x p1 0.0025 p2 25 p3 A p4 2020-06-29 p1 0.0005 p2 5 p3 B p4 2020-06-29 p1 5.5555 p2 -5 p3 C p4 2020-06-29 @@ -279,14 +273,14 @@ sformat('{: f}; {: f}', 3.14, -3.14) select sformat('{:-f}; {:-f}', 3.14, -3.14); sformat('{:-f}; {:-f}', 3.14, -3.14) 3.140000; -3.140000 -select sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7); -sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7) +select sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7) x; +x The temperature is between -3 and 7 degrees celsius. -select sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7); -sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7) +select sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7) x; +x The temperature is between -3 and 7 degrees celsius. -select sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7); -sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7) +select sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7) x; +x The temperature is between -3 and +7 degrees celsius. select sformat('We have {:<8} chickens.', 49); sformat('We have {:<8} chickens.', 49) @@ -427,8 +421,8 @@ set names utf8; select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442'); sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442') =теÑÑ‚= -select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442')); -hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442')) +select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442')) x; +x 003D0442043504410442003D create table t1 as select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442') as x; show create table t1; diff --git a/mysql-test/main/func_sformat.test b/mysql-test/main/func_sformat.test index 65e4b639179..1f0024d19a7 100644 --- a/mysql-test/main/func_sformat.test +++ b/mysql-test/main/func_sformat.test @@ -14,14 +14,11 @@ select sformat(0); select sformat('C'); select sformat(-4.2); select sformat(5, 5, 5); -#enable after fix MDEV-27871 ---disable_view_protocol select sformat('{} {}', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); ---enable_view_protocol + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) as x; select sformat('{{{}}}', 0); select sformat('{{{}{{', 0); select sformat('{{{{{}{{', 'param1'); @@ -29,18 +26,13 @@ select sformat(' {{ {{ {} {{ ', 'param1'); select sformat(' {{ {} {}', 'param1', 'param2'); select sformat('A{}C{}E{}', 'B', 'D', 'F'); select sformat('{} {}', FALSE, TRUE); -#enable after fix MDEV-29601 ---disable_service_connection select sformat('Add € != {} != {}?', '$', '£'); select sformat('Check {} != {} != {}?', '€', '$', '£'); ---enable_service_connection select sformat('{}{}{}', 1, 2, 3); select sformat('Float {} Boolean {} Number {}', 3.14159, True, -50); select sformat('SUM {} + {} = {}', 2, 3, 2+3); select sformat('Numbers {} {} {}', 1, 1.11, 1.111); select sformat('what {} is {}?', 'time', 'it'); -#enable after fix MDEV-27871 ---disable_view_protocol select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} @@ -49,7 +41,7 @@ select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} { 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120); + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120) as x; select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} @@ -61,8 +53,7 @@ select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} { '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', - '115', '116', '117', '118', '119', '120'); ---enable_view_protocol + '115', '116', '117', '118', '119', '120') as x; echo #; echo # Error Test Cases; @@ -92,10 +83,7 @@ insert into t2 values (0.0025, 25, 'A', DATE('2020-06-29')), (0.0005, 5, 'B', DATE('2020-6-29')), (5.5555, -5, 'C', DATE('200629')), (-9, -9, 'D', DATE('20*06*29')); -#enable after fix MDEV-27871 ---disable_view_protocol -select sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) from t2; ---enable_view_protocol +select sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) x from t2; drop table t2; set names utf8; @@ -127,10 +115,7 @@ echo #; echo # Format Test Cases; echo #; select sformat('Num {:L}', 13800000000); -#enable after fix MDEV-29646 ---disable_view_protocol select sformat('Num [{:20}]', 42); ---enable_view_protocol select sformat('Number: {:*^{}}', 4, 5); select sformat('{:02} - {:02} - {:02}', 1, 2, 3); select sformat('Character {:c}', 104); @@ -141,10 +126,7 @@ select sformat('Float {:.2f}', 42.0); select sformat('Float {:f}', 42.0); select sformat('Number {:d}', 42); select sformat('Number {:{}}', 5, 5); -#enable after fix MDEV-29646 ---disable_view_protocol select sformat('Number [{:10}]', 9999); ---enable_view_protocol select sformat('Number {:.3}', 3.1416); select sformat('int: {0:d}; hex: {0:x}; oct: {0:o}', 42); select sformat('int: {0:d}; hex: {0:#x}; oct: {0:#o}', 42); @@ -155,16 +137,10 @@ select sformat('The binary version of {0} is {0:b}', 5); select sformat('{:+f}; {:+f}', 3.14, -3.14); select sformat('{: f}; {: f}', 3.14, -3.14); select sformat('{:-f}; {:-f}', 3.14, -3.14); -#enable after fix MDEV-27871 ---disable_view_protocol -select sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7); -select sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7); -select sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7); ---enable_view_protocol -#check after fix MDEV-29646 ---disable_view_protocol +select sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7) x; +select sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7) x; +select sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7) x; select sformat('We have {:<8} chickens.', 49); ---enable_view_protocol select sformat('Center alimgn [{:*^10}]', 'data'); select sformat('Center aling [{:^10}].', 'data'); select sformat('Right aling [{:>10}].', 'data'); @@ -219,10 +195,7 @@ echo #; select sformat('={}=', _ucs2 x'006100620063'); set names utf8; select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442'); -#enable after fix MDEV-27871 ---disable_view_protocol -select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442')); ---enable_view_protocol +select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442')) x; create table t1 as select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442') as x; show create table t1; drop table t1; From aa4bcdbbb8806601d2f5d3dbde68f790beb54226 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 20 Apr 2024 00:16:54 +0200 Subject: [PATCH 179/313] main.func_sformat: fixes for fmt 10.2.1 --- mysql-test/main/func_sformat.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mysql-test/main/func_sformat.test b/mysql-test/main/func_sformat.test index 1f0024d19a7..4744229e79a 100644 --- a/mysql-test/main/func_sformat.test +++ b/mysql-test/main/func_sformat.test @@ -151,20 +151,31 @@ select sformat('Change Order {1} {0}', 'second', 'first'); echo #; echo # Failed Format Test Cases; echo #; +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('Test {:c}', 'word'); select sformat('Test {one} {two} {three}', 1, 2, 3); select sformat('Number {:{<}', 8); select sformat('Number {:10000000000}', 5); select sformat('1={1} 2={2} 0={0}', 0, 1); +--replace_regex /invalid format specifier/precision not allowed for this argument type/ select sformat('Number {:.2d}', 42); +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('You scored {:.0%}', 0.25); +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('You scored {:%}', 0.25); +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('The price is {:f} dollars.', 45); +--replace_regex /invalid format specifier/precision not allowed for this argument type/ select sformat('The price is {:.2f} dollars.', 45); +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('We have {:E} chickens.', 5); +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('We have {:e} chickens.', 5); +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('The universe is {:,} years old.', 13800000000); +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('The universe is {:_} years old.', 13800000000); +--replace_regex /invalid format specifier/format specifier requires numeric argument/ select sformat('String {:-}', 'hello'); echo #; @@ -187,6 +198,7 @@ drop table t2; echo #; echo # Unsupported/disabled features; echo #; +--replace_regex /invalid format specifier/invalid type specifier/ select sformat('{:p}', '50'); echo #; @@ -206,6 +218,7 @@ echo # ps parameters; echo #; prepare s from 'select sformat("={:d}=", ?)'; execute s using 100; +--replace_regex /invalid format specifier/invalid type specifier/ execute s using 'abc'; echo #; From 75488a57f23b99f5d531366c4717e2ce63cebd7e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 20 Apr 2024 00:17:30 +0200 Subject: [PATCH 180/313] archive.archive and main.mysqlbinlog_row_compressed fixes for zlib-ng --- .../main/mysqlbinlog_row_compressed.result | 192 +++++++++--------- .../main/mysqlbinlog_row_compressed.test | 3 +- .../main/mysqlbinlog_stmt_compressed.result | 128 ++++++------ .../main/mysqlbinlog_stmt_compressed.test | 3 +- mysql-test/suite/archive/archive.test | 2 +- 5 files changed, 163 insertions(+), 165 deletions(-) diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result index e42708f86c9..410af54441c 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.result +++ b/mysql-test/main/mysqlbinlog_row_compressed.result @@ -17,21 +17,21 @@ FLUSH BINARY LOGS; /*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; -# at 4 -# server id 1 end_log_pos 256 CRC32 XXX Start: xxx +# at +# server id 1 end_log_pos CRC32 XXX Start: xxx ROLLBACK/*!*/; -# at 256 -# server id 1 end_log_pos 285 CRC32 XXX Gtid list [] -# at 285 -# server id 1 end_log_pos 329 CRC32 XXX Binlog checkpoint master-bin.000001 -# at 329 -# server id 1 end_log_pos 371 CRC32 XXX GTID 0-1-1 ddl +# at +# server id 1 end_log_pos CRC32 XXX Gtid list [] +# at +# server id 1 end_log_pos CRC32 XXX Binlog checkpoint master-bin.000001 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-1 ddl /*!100101 SET @@session.skip_parallel_replication=0*//*!*/; /*!100001 SET @@session.gtid_domain_id=0*//*!*/; /*!100001 SET @@session.server_id=1*//*!*/; /*!100001 SET @@session.gtid_seq_no=1*//*!*/; -# at 371 -# server id 1 end_log_pos 542 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; @@ -44,26 +44,26 @@ SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1)) /*!*/; -# at 542 -# server id 1 end_log_pos 584 CRC32 XXX GTID 0-1-2 ddl +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-2 ddl /*!100001 SET @@session.gtid_seq_no=2*//*!*/; -# at 584 -# server id 1 end_log_pos 745 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1)) /*!*/; -# at 745 -# server id 1 end_log_pos 787 CRC32 XXX GTID 0-1-3 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-3 /*!100001 SET @@session.gtid_seq_no=3*//*!*/; START TRANSACTION /*!*/; -# at 787 -# at 861 -# server id 1 end_log_pos 861 CRC32 XXX Annotate_rows: +# at +# at +# server id 1 end_log_pos CRC32 XXX Annotate_rows: #Q> INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "") -# server id 1 end_log_pos 917 CRC32 XXX Table_map: `test`.`t1` mapped to number num -# at 917 -# server id 1 end_log_pos 985 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F +# server id 1 end_log_pos CRC32 XXX Table_map: `test`.`t1` mapped to number num +# at +# server id 1 end_log_pos CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -76,23 +76,23 @@ START TRANSACTION ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # Number of rows: 1 -# at 985 -# server id 1 end_log_pos 1058 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 1058 -# server id 1 end_log_pos 1100 CRC32 XXX GTID 0-1-4 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-4 /*!100001 SET @@session.gtid_seq_no=4*//*!*/; START TRANSACTION /*!*/; -# at 1100 -# at 1176 -# server id 1 end_log_pos 1176 CRC32 XXX Annotate_rows: +# at +# at +# server id 1 end_log_pos CRC32 XXX Annotate_rows: #Q> INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL) -# server id 1 end_log_pos 1232 CRC32 XXX Table_map: `test`.`t1` mapped to number num -# at 1232 -# server id 1 end_log_pos 1299 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F +# server id 1 end_log_pos CRC32 XXX Table_map: `test`.`t1` mapped to number num +# at +# server id 1 end_log_pos CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET ### @1=11 /* INT meta=0 nullable=0 is_null=0 */ @@ -105,23 +105,23 @@ START TRANSACTION ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9=NULL /* STRING(1) meta=65025 nullable=1 is_null=1 */ # Number of rows: 1 -# at 1299 -# server id 1 end_log_pos 1372 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 1372 -# server id 1 end_log_pos 1414 CRC32 XXX GTID 0-1-5 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-5 /*!100001 SET @@session.gtid_seq_no=5*//*!*/; START TRANSACTION /*!*/; -# at 1414 -# at 1492 -# server id 1 end_log_pos 1492 CRC32 XXX Annotate_rows: +# at +# at +# server id 1 end_log_pos CRC32 XXX Annotate_rows: #Q> INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A") -# server id 1 end_log_pos 1548 CRC32 XXX Table_map: `test`.`t1` mapped to number num -# at 1548 -# server id 1 end_log_pos 1614 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F +# server id 1 end_log_pos CRC32 XXX Table_map: `test`.`t1` mapped to number num +# at +# server id 1 end_log_pos CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET ### @1=12 /* INT meta=0 nullable=0 is_null=0 */ @@ -134,23 +134,23 @@ START TRANSACTION ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # Number of rows: 1 -# at 1614 -# server id 1 end_log_pos 1687 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 1687 -# server id 1 end_log_pos 1729 CRC32 XXX GTID 0-1-6 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-6 /*!100001 SET @@session.gtid_seq_no=6*//*!*/; START TRANSACTION /*!*/; -# at 1729 -# at 1804 -# server id 1 end_log_pos 1804 CRC32 XXX Annotate_rows: +# at +# at +# server id 1 end_log_pos CRC32 XXX Annotate_rows: #Q> INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A") -# server id 1 end_log_pos 1860 CRC32 XXX Table_map: `test`.`t1` mapped to number num -# at 1860 -# server id 1 end_log_pos 1927 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F +# server id 1 end_log_pos CRC32 XXX Table_map: `test`.`t1` mapped to number num +# at +# server id 1 end_log_pos CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t1` ### SET ### @1=13 /* INT meta=0 nullable=0 is_null=0 */ @@ -163,23 +163,23 @@ START TRANSACTION ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # Number of rows: 1 -# at 1927 -# server id 1 end_log_pos 2000 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 2000 -# server id 1 end_log_pos 2042 CRC32 XXX GTID 0-1-7 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-7 /*!100001 SET @@session.gtid_seq_no=7*//*!*/; START TRANSACTION /*!*/; -# at 2042 -# at 2096 -# server id 1 end_log_pos 2096 CRC32 XXX Annotate_rows: +# at +# at +# server id 1 end_log_pos CRC32 XXX Annotate_rows: #Q> INSERT INTO t2 SELECT * FROM t1 -# server id 1 end_log_pos 2152 CRC32 XXX Table_map: `test`.`t2` mapped to number num -# at 2152 -# server id 1 end_log_pos 2243 CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F +# server id 1 end_log_pos CRC32 XXX Table_map: `test`.`t2` mapped to number num +# at +# server id 1 end_log_pos CRC32 XXX Write_compressed_rows: table id flags: STMT_END_F ### INSERT INTO `test`.`t2` ### SET ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -225,23 +225,23 @@ START TRANSACTION ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # Number of rows: 4 -# at 2243 -# server id 1 end_log_pos 2316 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 2316 -# server id 1 end_log_pos 2358 CRC32 XXX GTID 0-1-8 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-8 /*!100001 SET @@session.gtid_seq_no=8*//*!*/; START TRANSACTION /*!*/; -# at 2358 -# at 2424 -# server id 1 end_log_pos 2424 CRC32 XXX Annotate_rows: +# at +# at +# server id 1 end_log_pos CRC32 XXX Annotate_rows: #Q> UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL -# server id 1 end_log_pos 2480 CRC32 XXX Table_map: `test`.`t2` mapped to number num -# at 2480 -# server id 1 end_log_pos 2579 CRC32 XXX Update_compressed_rows: table id flags: STMT_END_F +# server id 1 end_log_pos CRC32 XXX Table_map: `test`.`t2` mapped to number num +# at +# server id 1 end_log_pos CRC32 XXX Update_compressed_rows: table id flags: STMT_END_F ### UPDATE `test`.`t2` ### WHERE ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -306,23 +306,23 @@ START TRANSACTION ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # Number of rows: 3 -# at 2579 -# server id 1 end_log_pos 2652 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 2652 -# server id 1 end_log_pos 2694 CRC32 XXX GTID 0-1-9 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-9 /*!100001 SET @@session.gtid_seq_no=9*//*!*/; START TRANSACTION /*!*/; -# at 2694 -# at 2731 -# server id 1 end_log_pos 2731 CRC32 XXX Annotate_rows: +# at +# at +# server id 1 end_log_pos CRC32 XXX Annotate_rows: #Q> DELETE FROM t1 -# server id 1 end_log_pos 2787 CRC32 XXX Table_map: `test`.`t1` mapped to number num -# at 2787 -# server id 1 end_log_pos 2879 CRC32 XXX Delete_compressed_rows: table id flags: STMT_END_F +# server id 1 end_log_pos CRC32 XXX Table_map: `test`.`t1` mapped to number num +# at +# server id 1 end_log_pos CRC32 XXX Delete_compressed_rows: table id flags: STMT_END_F ### DELETE FROM `test`.`t1` ### WHERE ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -368,23 +368,23 @@ START TRANSACTION ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # Number of rows: 4 -# at 2879 -# server id 1 end_log_pos 2952 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 2952 -# server id 1 end_log_pos 2994 CRC32 XXX GTID 0-1-10 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-10 /*!100001 SET @@session.gtid_seq_no=10*//*!*/; START TRANSACTION /*!*/; -# at 2994 -# at 3031 -# server id 1 end_log_pos 3031 CRC32 XXX Annotate_rows: +# at +# at +# server id 1 end_log_pos CRC32 XXX Annotate_rows: #Q> DELETE FROM t2 -# server id 1 end_log_pos 3087 CRC32 XXX Table_map: `test`.`t2` mapped to number num -# at 3087 -# server id 1 end_log_pos 3172 CRC32 XXX Delete_compressed_rows: table id flags: STMT_END_F +# server id 1 end_log_pos CRC32 XXX Table_map: `test`.`t2` mapped to number num +# at +# server id 1 end_log_pos CRC32 XXX Delete_compressed_rows: table id flags: STMT_END_F ### DELETE FROM `test`.`t2` ### WHERE ### @1=10 /* INT meta=0 nullable=0 is_null=0 */ @@ -430,13 +430,13 @@ START TRANSACTION ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # Number of rows: 4 -# at 3172 -# server id 1 end_log_pos 3245 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 3245 -# server id 1 end_log_pos 3293 CRC32 XXX Rotate to master-bin.000002 pos: 4 +# at +# server id 1 end_log_pos CRC32 XXX Rotate to master-bin.000002 pos: 4 DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; diff --git a/mysql-test/main/mysqlbinlog_row_compressed.test b/mysql-test/main/mysqlbinlog_row_compressed.test index 6fe5cabcc40..b3a6add4efc 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.test +++ b/mysql-test/main/mysqlbinlog_row_compressed.test @@ -4,7 +4,6 @@ --source include/have_log_bin.inc --source include/have_binlog_format_row.inc ---source include/have_normal_zlib.inc # # @@ -32,7 +31,7 @@ DELETE FROM t2; FLUSH BINARY LOGS; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /\d{6} *\d*:\d\d:\d\d// /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=/ /table id \d+/table id / +--replace_regex /\d{6} *\d*:\d\d:\d\d// /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=/ /table id \d+/table id / /end_log_pos \d+/end_log_pos / /# at \d+/# at / --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog --echo diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.result b/mysql-test/main/mysqlbinlog_stmt_compressed.result index c0d26f3f9df..471cb4b72c6 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.result +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.result @@ -15,21 +15,21 @@ FLUSH BINARY LOGS; /*!40019 SET @@session.max_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; -# at 4 -# server id 1 end_log_pos 256 CRC32 XXX Start: xxx +# at +# server id 1 end_log_pos CRC32 XXX Start: xxx ROLLBACK/*!*/; -# at 256 -# server id 1 end_log_pos 285 CRC32 XXX Gtid list [] -# at 285 -# server id 1 end_log_pos 329 CRC32 XXX Binlog checkpoint master-bin.000001 -# at 329 -# server id 1 end_log_pos 371 CRC32 XXX GTID 0-1-1 ddl +# at +# server id 1 end_log_pos CRC32 XXX Gtid list [] +# at +# server id 1 end_log_pos CRC32 XXX Binlog checkpoint master-bin.000001 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-1 ddl /*!100101 SET @@session.skip_parallel_replication=0*//*!*/; /*!100001 SET @@session.gtid_domain_id=0*//*!*/; /*!100001 SET @@session.server_id=1*//*!*/; /*!100001 SET @@session.gtid_seq_no=1*//*!*/; -# at 371 -# server id 1 end_log_pos 542 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; @@ -42,136 +42,136 @@ SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1)) /*!*/; -# at 542 -# server id 1 end_log_pos 584 CRC32 XXX GTID 0-1-2 ddl +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-2 ddl /*!100001 SET @@session.gtid_seq_no=2*//*!*/; -# at 584 -# server id 1 end_log_pos 745 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1)) /*!*/; -# at 745 -# server id 1 end_log_pos 787 CRC32 XXX GTID 0-1-3 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-3 /*!100001 SET @@session.gtid_seq_no=3*//*!*/; START TRANSACTION /*!*/; -# at 787 -# server id 1 end_log_pos 915 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "") /*!*/; -# at 915 -# server id 1 end_log_pos 988 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 988 -# server id 1 end_log_pos 1030 CRC32 XXX GTID 0-1-4 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-4 /*!100001 SET @@session.gtid_seq_no=4*//*!*/; START TRANSACTION /*!*/; -# at 1030 -# server id 1 end_log_pos 1158 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL) /*!*/; -# at 1158 -# server id 1 end_log_pos 1231 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 1231 -# server id 1 end_log_pos 1273 CRC32 XXX GTID 0-1-5 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-5 /*!100001 SET @@session.gtid_seq_no=5*//*!*/; START TRANSACTION /*!*/; -# at 1273 -# server id 1 end_log_pos 1403 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A") /*!*/; -# at 1403 -# server id 1 end_log_pos 1476 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 1476 -# server id 1 end_log_pos 1518 CRC32 XXX GTID 0-1-6 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-6 /*!100001 SET @@session.gtid_seq_no=6*//*!*/; START TRANSACTION /*!*/; -# at 1518 -# server id 1 end_log_pos 1645 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A") /*!*/; -# at 1645 -# server id 1 end_log_pos 1718 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 1718 -# server id 1 end_log_pos 1760 CRC32 XXX GTID 0-1-7 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-7 /*!100001 SET @@session.gtid_seq_no=7*//*!*/; START TRANSACTION /*!*/; -# at 1760 -# server id 1 end_log_pos 1868 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; INSERT INTO t2 SELECT * FROM t1 /*!*/; -# at 1868 -# server id 1 end_log_pos 1941 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 1941 -# server id 1 end_log_pos 1983 CRC32 XXX GTID 0-1-8 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-8 /*!100001 SET @@session.gtid_seq_no=8*//*!*/; START TRANSACTION /*!*/; -# at 1983 -# server id 1 end_log_pos 2100 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL /*!*/; -# at 2100 -# server id 1 end_log_pos 2173 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 2173 -# server id 1 end_log_pos 2215 CRC32 XXX GTID 0-1-9 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-9 /*!100001 SET @@session.gtid_seq_no=9*//*!*/; START TRANSACTION /*!*/; -# at 2215 -# server id 1 end_log_pos 2306 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; DELETE FROM t1 /*!*/; -# at 2306 -# server id 1 end_log_pos 2379 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 2379 -# server id 1 end_log_pos 2421 CRC32 XXX GTID 0-1-10 +# at +# server id 1 end_log_pos CRC32 XXX GTID 0-1-10 /*!100001 SET @@session.gtid_seq_no=10*//*!*/; START TRANSACTION /*!*/; -# at 2421 -# server id 1 end_log_pos 2512 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; DELETE FROM t2 /*!*/; -# at 2512 -# server id 1 end_log_pos 2585 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= +# at +# server id 1 end_log_pos CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid= SET TIMESTAMP=X/*!*/; COMMIT /*!*/; -# at 2585 -# server id 1 end_log_pos 2633 CRC32 XXX Rotate to master-bin.000002 pos: 4 +# at +# server id 1 end_log_pos CRC32 XXX Rotate to master-bin.000002 pos: 4 DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.test b/mysql-test/main/mysqlbinlog_stmt_compressed.test index 4a65124339d..5c3fb58c50c 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.test +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.test @@ -4,7 +4,6 @@ --source include/have_log_bin.inc --source include/have_binlog_format_statement.inc ---source include/have_normal_zlib.inc # # # mysqlbinlog: compressed query event @@ -29,7 +28,7 @@ DELETE FROM t2; FLUSH BINARY LOGS; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /\d{6} *\d*:\d\d:\d\d// /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=/ +--replace_regex /\d{6} *\d*:\d\d:\d\d// /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=/ /table id \d+/table id / /end_log_pos \d+/end_log_pos / /# at \d+/# at / --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog --echo diff --git a/mysql-test/suite/archive/archive.test b/mysql-test/suite/archive/archive.test index 430bdd66dd6..1367a30c37a 100644 --- a/mysql-test/suite/archive/archive.test +++ b/mysql-test/suite/archive/archive.test @@ -1609,7 +1609,7 @@ SELECT DATA_LENGTH, AVG_ROW_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test'; INSERT INTO t1 VALUES(1, 'sampleblob1'),(2, 'sampleblob2'); # Compression length depends on zip library ---replace_result 583 584 291 292 +--replace_result 583 584 585 584 291 292 SELECT DATA_LENGTH, AVG_ROW_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test'; DROP TABLE t1; From 52529a528db86532d51bb9c14a467aa25421a3ab Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 22 Apr 2024 15:27:14 +0200 Subject: [PATCH 181/313] MDEV-32932 fix comments to match the code followup for 1c55b845e0fe --- extra/mariabackup/backup_copy.cc | 4 ++-- extra/mariabackup/backup_copy.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index 733281a49de..198da01a223 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1356,7 +1356,7 @@ out: lsn_t server_lsn_after_lock; extern void backup_wait_for_lsn(lsn_t lsn); -/** Release resources after backup_start() */ +/** Release resources after backup_files() */ void backup_release() { if (opt_lock_ddl_per_table) { @@ -1372,7 +1372,7 @@ void backup_release() static const char *default_buffer_pool_file = "ib_buffer_pool"; -/** Finish after backup_start() and backup_release() */ +/** Finish after backup_files() and backup_release() */ bool backup_finish(ds_ctxt *ds_data) { /* Copy buffer pool dump or LRU dump */ diff --git a/extra/mariabackup/backup_copy.h b/extra/mariabackup/backup_copy.h index 43b75e19939..409e783906f 100644 --- a/extra/mariabackup/backup_copy.h +++ b/extra/mariabackup/backup_copy.h @@ -23,9 +23,9 @@ equal_paths(const char *first, const char *second); /** Start --backup */ bool backup_files(ds_ctxt *ds_data, const char *from); -/** Release resources after backup_start() */ +/** Release resources after backup_files() */ void backup_release(); -/** Finish after backup_start() and backup_release() */ +/** Finish after backup_files() and backup_release() */ bool backup_finish(ds_ctxt *ds_data); bool apply_log_finish(); From a2fee2da0b4351dd34929eb4871be59a0c70da01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 18 Apr 2024 15:41:30 +0300 Subject: [PATCH 182/313] MDEV-33928 : Assertion failure on wsrep_thd_is_aborting Problem was assertion assuming we always hold THD::LOCK_thd_data mutex that is not true. In most cases this is true but function is also used from InnoDB lock manager and there we can't take THD::LOCK_thd_data to obey mutex ordering. Removed assertion as wsrep transaction state can't change even that case. Signed-off-by: Julius Goryavsky --- sql/service_wsrep.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/sql/service_wsrep.cc b/sql/service_wsrep.cc index 6a2ee1dd3db..976578b1dbf 100644 --- a/sql/service_wsrep.cc +++ b/sql/service_wsrep.cc @@ -1,4 +1,4 @@ -/* Copyright 2018-2023 Codership Oy +/* Copyright 2018-2024 Codership Oy 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 @@ -283,10 +283,28 @@ extern "C" my_bool wsrep_thd_order_before(const THD *left, const THD *right) return FALSE; } +/** Check if wsrep transaction is aborting state. + +Calling function should make sure that wsrep transaction state +can't change during this function. + +This function is called from +wsrep_abort_thd where we hold THD::LOCK_thd_data +wsrep_handle_mdl_conflict we hold THD::LOCK_thd_data +wsrep_assert_no_bf_bf_wait we hold lock_sys.latch +innobase_kill_query we hold THD::LOCK_thd_data (THD::awake_no_mutex) + +@param thd thread handle + +@return true if wsrep transaction is aborting +@return false if not + +*/ extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd) { const wsrep::client_state& cs(thd->wsrep_cs()); const enum wsrep::transaction::state tx_state(cs.transaction().state()); + switch (tx_state) { case wsrep::transaction::s_must_abort: @@ -296,8 +314,10 @@ extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd) case wsrep::transaction::s_aborted: return true; default: - return false; + break; } + + return false; } static inline enum wsrep::key::type From 466bc8f7e08cecb1a4f137439824e4f0136a4cdf Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 22 Apr 2024 17:22:11 +0200 Subject: [PATCH 183/313] fix failing large_tests.maria_recover_encrypted update results --- mysql-test/suite/large_tests/r/maria_recover_encrypted.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/large_tests/r/maria_recover_encrypted.result b/mysql-test/suite/large_tests/r/maria_recover_encrypted.result index a7293d45db6..fb7f1ef1c2f 100644 --- a/mysql-test/suite/large_tests/r/maria_recover_encrypted.result +++ b/mysql-test/suite/large_tests/r/maria_recover_encrypted.result @@ -36,7 +36,7 @@ CALL proc_insert_many(); UNLOCK TABLES; SET debug_dbug="d,crash_shutdown"; shutdown; -ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to server during query SELECT * FROM t1 ORDER BY 1 DESC LIMIT 10; field1 field2 field3 1069999 2069999 3069999 From 926e38c6b9bc6a86163f295f6579d00bfee60d8e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 22 Apr 2024 16:38:40 +0200 Subject: [PATCH 184/313] MDEV-33447 fixes for ppc64le followup for 3f9f5ca48e6b --- storage/innobase/sync/cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/sync/cache.cc b/storage/innobase/sync/cache.cc index 5c41998f47d..fb0f393df39 100644 --- a/storage/innobase/sync/cache.cc +++ b/storage/innobase/sync/cache.cc @@ -103,7 +103,7 @@ const pmem_control pmem; #else void pmem_persist(const void *buf, size_t size) { -# ifdef __ppc64__ +# ifdef __PPC__ for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), end= uintptr_t(buf) + size; u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) From a74846354ec4aeca26f943c1bf599f5b50def5ee Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 22 Apr 2024 17:22:11 +0200 Subject: [PATCH 185/313] fix failing large_tests.maria_recover_encrypted update results --- mysql-test/suite/large_tests/r/maria_recover_encrypted.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/large_tests/r/maria_recover_encrypted.result b/mysql-test/suite/large_tests/r/maria_recover_encrypted.result index a7293d45db6..fb7f1ef1c2f 100644 --- a/mysql-test/suite/large_tests/r/maria_recover_encrypted.result +++ b/mysql-test/suite/large_tests/r/maria_recover_encrypted.result @@ -36,7 +36,7 @@ CALL proc_insert_many(); UNLOCK TABLES; SET debug_dbug="d,crash_shutdown"; shutdown; -ERROR HY000: Lost connection to MySQL server during query +ERROR HY000: Lost connection to server during query SELECT * FROM t1 ORDER BY 1 DESC LIMIT 10; field1 field2 field3 1069999 2069999 3069999 From f243c73788ba5c8f3a7d009719c825799008b7e6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 22 Apr 2024 21:02:11 +0200 Subject: [PATCH 186/313] sporadic failures of rpl.rpl_rewrite_db_sys_vars first stop the slave, then run commands on the master that are supposed to fail on the slave, then start the slave. if you swap first two steps, the slave might get and execute those commands before it's stopped, which will fail the test. also, improve debugability --- .../rpl/r/rpl_rewrite_db_sys_vars.result | 20 +++++++--------- .../suite/rpl/t/rpl_rewrite_db_sys_vars.test | 23 ++++--------------- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_rewrite_db_sys_vars.result b/mysql-test/suite/rpl/r/rpl_rewrite_db_sys_vars.result index 5720f647b90..1734b2004dc 100644 --- a/mysql-test/suite/rpl/r/rpl_rewrite_db_sys_vars.result +++ b/mysql-test/suite/rpl/r/rpl_rewrite_db_sys_vars.result @@ -12,11 +12,9 @@ select @@session.server_id; create database replica_db1; create database y; create database test_replica; -SELECT @@GLOBAL.replicate_rewrite_db; -@@GLOBAL.replicate_rewrite_db -primary_db1->replica_db1,x->y -# Ensuring SHOW SLAVE STATUS produces correct value for Replicate_Rewrite_DB... -# ...success +SELECT @@GLOBAL.replicate_rewrite_db, 'primary_db1->replica_db1,x->y' as 'Replicate_Rewrite_DB from SHOW SLAVE STATUS'; +@@GLOBAL.replicate_rewrite_db Replicate_Rewrite_DB from SHOW SLAVE STATUS +primary_db1->replica_db1,x->y primary_db1->replica_db1,x->y # Create DBs and tables on primary connection master; create database primary_db1; @@ -60,15 +58,13 @@ SELECT @@GLOBAL.replicate_rewrite_db; @@GLOBAL.replicate_rewrite_db primary_db1->replica_db1,x->y SET @@GLOBAL.replicate_rewrite_db="test_master->test_replica"; -SELECT @@GLOBAL.replicate_rewrite_db; -@@GLOBAL.replicate_rewrite_db -test_master->test_replica SHOW DATABASES like 'test_replica'; Database (test_replica) test_replica include/start_slave.inc -# Ensuring SHOW SLAVE STATUS produces correct value for Replicate_Rewrite_DB... -# ...success +SELECT @@GLOBAL.replicate_rewrite_db, 'test_master->test_replica' as 'Replicate_Rewrite_DB from SHOW SLAVE STATUS'; +@@GLOBAL.replicate_rewrite_db Replicate_Rewrite_DB from SHOW SLAVE STATUS +test_master->test_replica test_master->test_replica # Create DB and tables on primary connection master; create database test_master; @@ -94,6 +90,8 @@ t 3 include/diff_tables.inc [master:test_master.my_table,slave:test_replica.my_table] # Update of values on primary for DB not set in replication_rewrite_db +include/stop_slave.inc +include/reset_slave.inc connection master; use x; insert into my_table values (314); @@ -104,8 +102,6 @@ t 314 include/save_master_gtid.inc connection slave; -include/stop_slave.inc -include/reset_slave.inc include/start_slave.inc SELECT @@GLOBAL.replicate_rewrite_db; @@GLOBAL.replicate_rewrite_db diff --git a/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars.test b/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars.test index 27710063792..fab78a9293b 100644 --- a/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars.test +++ b/mysql-test/suite/rpl/t/rpl_rewrite_db_sys_vars.test @@ -19,15 +19,8 @@ create database replica_db1; create database y; # This DB will be rewrited from test case create database test_replica; -SELECT @@GLOBAL.replicate_rewrite_db; let $rewrite_db_sss= query_get_value(SHOW SLAVE STATUS, Replicate_Rewrite_DB, 1); ---echo # Ensuring SHOW SLAVE STATUS produces correct value for Replicate_Rewrite_DB... -if (`SELECT strcmp(@@global.replicate_rewrite_db, "$rewrite_db_sss") != 0`) -{ - die SHOW SLAVE STATUS Replicate_Rewrite_DB value $rewrite_db_sss does not match variable @@GLOBAL.replicate_rewrite_db; -} ---echo # ...success - +eval SELECT @@GLOBAL.replicate_rewrite_db, '$rewrite_db_sss' as 'Replicate_Rewrite_DB from SHOW SLAVE STATUS'; --echo # Create DBs and tables on primary connection master; @@ -63,16 +56,10 @@ source include/stop_slave.inc; SET @save_replicate_rewrite_db = @@GLOBAL.replicate_rewrite_db; SELECT @@GLOBAL.replicate_rewrite_db; SET @@GLOBAL.replicate_rewrite_db="test_master->test_replica"; -SELECT @@GLOBAL.replicate_rewrite_db; SHOW DATABASES like 'test_replica'; source include/start_slave.inc; let $rewrite_db_sss= query_get_value(SHOW SLAVE STATUS, Replicate_Rewrite_DB, 1); ---echo # Ensuring SHOW SLAVE STATUS produces correct value for Replicate_Rewrite_DB... -if (`SELECT strcmp(@@global.replicate_rewrite_db, "$rewrite_db_sss") != 0`) -{ - die SHOW SLAVE STATUS Replicate_Rewrite_DB value $rewrite_db_sss does not match variable @@GLOBAL.replicate_rewrite_db; -} ---echo # ...success +eval SELECT @@GLOBAL.replicate_rewrite_db, '$rewrite_db_sss' as 'Replicate_Rewrite_DB from SHOW SLAVE STATUS'; --echo # Create DB and tables on primary connection master; @@ -101,6 +88,9 @@ select * from test_replica.my_table; --source include/diff_tables.inc --echo # Update of values on primary for DB not set in replication_rewrite_db +--source include/stop_slave.inc +--source include/reset_slave.inc + connection master; use x; insert into my_table values (314); @@ -108,9 +98,6 @@ select * from my_table; --source include/save_master_gtid.inc connection slave; ---let $rpl_only_running_threads=1 ---source include/stop_slave.inc ---source include/reset_slave.inc --source include/start_slave.inc SELECT @@GLOBAL.replicate_rewrite_db; --source include/sync_with_master_gtid.inc From 361b790392255206eb2750e868dafc42feb964e8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 3 Mar 2024 08:18:55 +0100 Subject: [PATCH 187/313] Remove unnecessary whitespace in mysqldump --- client/mysqldump.c | 5 +++-- mysql-test/main/mysqldump-max.result | 22 +++++++++++----------- mysql-test/main/mysqldump-system.result | 20 ++++++++++---------- mysql-test/main/mysqldump.result | 8 ++++---- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index ae06f1dbf8b..79339fc59b8 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3042,8 +3042,9 @@ static uint get_table_structure(const char *table, const char *db, char *table_t } else dynstr_set_checked(&select_field_names, ""); - insert_option= ((delayed && opt_ignore) ? " DELAYED IGNORE " : - delayed ? " DELAYED " : opt_ignore ? " IGNORE " : ""); + + insert_option= ((delayed && opt_ignore) ? "DELAYED IGNORE " : + delayed ? "DELAYED " : opt_ignore ? "IGNORE " : ""); verbose_msg("-- Retrieving table structure for table %s...\n", table); diff --git a/mysql-test/main/mysqldump-max.result b/mysql-test/main/mysqldump-max.result index eb2cf2aec08..4a53a5f3328 100644 --- a/mysql-test/main/mysqldump-max.result +++ b/mysql-test/main/mysqldump-max.result @@ -102,7 +102,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; DROP TABLE IF EXISTS `t2`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -114,7 +114,7 @@ CREATE TABLE `t2` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t2` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t2` ENABLE KEYS */; DROP TABLE IF EXISTS `t3`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -126,7 +126,7 @@ CREATE TABLE `t3` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t3` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t3` ENABLE KEYS */; DROP TABLE IF EXISTS `t4`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -138,7 +138,7 @@ CREATE TABLE `t4` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t4` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t4` ENABLE KEYS */; DROP TABLE IF EXISTS `t5`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -150,7 +150,7 @@ CREATE TABLE `t5` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t5` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t5` ENABLE KEYS */; DROP TABLE IF EXISTS `t6`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -162,7 +162,7 @@ CREATE TABLE `t6` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t6` DISABLE KEYS */; -INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t6` ENABLE KEYS */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -199,7 +199,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; DROP TABLE IF EXISTS `t2`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -211,7 +211,7 @@ CREATE TABLE `t2` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t2` DISABLE KEYS */; -INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t2` ENABLE KEYS */; DROP TABLE IF EXISTS `t3`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -223,7 +223,7 @@ CREATE TABLE `t3` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t3` DISABLE KEYS */; -INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t3` ENABLE KEYS */; DROP TABLE IF EXISTS `t4`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -235,7 +235,7 @@ CREATE TABLE `t4` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t4` DISABLE KEYS */; -INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t4` ENABLE KEYS */; DROP TABLE IF EXISTS `t5`; /*!40101 SET @saved_cs_client = @@character_set_client */; @@ -247,7 +247,7 @@ CREATE TABLE `t5` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t5` DISABLE KEYS */; -INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); +INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value'); /*!40000 ALTER TABLE `t5` ENABLE KEYS */; DROP TABLE IF EXISTS `t6`; /*!40101 SET @saved_cs_client = @@character_set_client */; diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result index 2fa010b3e4e..bc8229ff42f 100644 --- a/mysql-test/main/mysqldump-system.result +++ b/mysql-test/main/mysqldump-system.result @@ -359,31 +359,31 @@ USE mysql; LOCK TABLES `column_stats` WRITE; /*!40000 ALTER TABLE `column_stats` DISABLE KEYS */; -INSERT IGNORE INTO `column_stats` VALUES ('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿'); +INSERT IGNORE INTO `column_stats` VALUES ('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,254,'DOUBLE_PREC_HB','\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿ÿ¿'); /*!40000 ALTER TABLE `column_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `index_stats` WRITE; /*!40000 ALTER TABLE `index_stats` DISABLE KEYS */; -INSERT IGNORE INTO `index_stats` VALUES ('mysql','tz','PRIMARY',1,98.2500); +INSERT IGNORE INTO `index_stats` VALUES ('mysql','tz','PRIMARY',1,98.2500); /*!40000 ALTER TABLE `index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `table_stats` WRITE; /*!40000 ALTER TABLE `table_stats` DISABLE KEYS */; -INSERT IGNORE INTO `table_stats` VALUES ('mysql','tz',393); +INSERT IGNORE INTO `table_stats` VALUES ('mysql','tz',393); /*!40000 ALTER TABLE `table_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_index_stats` WRITE; /*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */; -INSERT IGNORE INTO `innodb_index_stats` VALUES ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); +INSERT IGNORE INTO `innodb_index_stats` VALUES ('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),('mysql','tz','PRIMARY','2019-12-31 21:00:00','size',1,NULL,'Number of pages in the index'); /*!40000 ALTER TABLE `innodb_index_stats` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `innodb_table_stats` WRITE; /*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */; -INSERT IGNORE INTO `innodb_table_stats` VALUES ('mysql','tz','2019-12-31 21:00:00',393,1,0); +INSERT IGNORE INTO `innodb_table_stats` VALUES ('mysql','tz','2019-12-31 21:00:00',393,1,0); /*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */; UNLOCK TABLES; @@ -391,31 +391,31 @@ USE mysql; LOCK TABLES `time_zone` WRITE; /*!40000 ALTER TABLE `time_zone` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone` VALUES (1,'N'),(2,'N'),(3,'N'),(4,'Y'),(5,'N'); +INSERT IGNORE INTO `time_zone` VALUES (1,'N'),(2,'N'),(3,'N'),(4,'Y'),(5,'N'); /*!40000 ALTER TABLE `time_zone` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `time_zone_name` WRITE; /*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone_name` VALUES ('Europe/Moscow',3),('Japan',5),('leap/Europe/Moscow',4),('MET',1),('Universal',2),('UTC',2); +INSERT IGNORE INTO `time_zone_name` VALUES ('Europe/Moscow',3),('Japan',5),('leap/Europe/Moscow',4),('MET',1),('Universal',2),('UTC',2); /*!40000 ALTER TABLE `time_zone_name` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `time_zone_leap_second` WRITE; /*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone_leap_second` VALUES (78796800,1),(94694401,2),(126230402,3),(157766403,4),(189302404,5),(220924805,6),(252460806,7),(283996807,8),(315532808,9),(362793609,10),(394329610,11),(425865611,12),(489024012,13),(567993613,14),(631152014,15),(662688015,16),(709948816,17),(741484817,18),(773020818,19),(820454419,20),(867715220,21),(915148821,22); +INSERT IGNORE INTO `time_zone_leap_second` VALUES (78796800,1),(94694401,2),(126230402,3),(157766403,4),(189302404,5),(220924805,6),(252460806,7),(283996807,8),(315532808,9),(362793609,10),(394329610,11),(425865611,12),(489024012,13),(567993613,14),(631152014,15),(662688015,16),(709948816,17),(741484817,18),(773020818,19),(820454419,20),(867715220,21),(915148821,22); /*!40000 ALTER TABLE `time_zone_leap_second` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `time_zone_transition` WRITE; /*!40000 ALTER TABLE `time_zone_transition` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone_transition` VALUES (1,-1693706400,0),(1,-1680483600,1),(1,-1663455600,2),(1,-1650150000,3),(1,-1632006000,2),(1,-1618700400,3),(1,-938905200,2),(1,-857257200,3),(1,-844556400,2),(1,-828226800,3),(1,-812502000,2),(1,-796777200,3),(1,228877200,2),(1,243997200,3),(1,260326800,2),(1,276051600,3),(1,291776400,2),(1,307501200,3),(1,323830800,2),(1,338950800,3),(1,354675600,2),(1,370400400,3),(1,386125200,2),(1,401850000,3),(1,417574800,2),(1,433299600,3),(1,449024400,2),(1,465354000,3),(1,481078800,2),(1,496803600,3),(1,512528400,2),(1,528253200,3),(1,543978000,2),(1,559702800,3),(1,575427600,2),(1,591152400,3),(1,606877200,2),(1,622602000,3),(1,638326800,2),(1,654656400,3),(1,670381200,2),(1,686106000,3),(1,701830800,2),(1,717555600,3),(1,733280400,2),(1,749005200,3),(1,764730000,2),(1,780454800,3),(1,796179600,2),(1,811904400,3),(1,828234000,2),(1,846378000,3),(1,859683600,2),(1,877827600,3),(1,891133200,2),(1,909277200,3),(1,922582800,2),(1,941331600,3),(1,954032400,2),(1,972781200,3),(1,985482000,2),(1,1004230800,3),(1,1017536400,2),(1,1035680400,3),(1,1048986000,2),(1,1067130000,3),(1,1080435600,2),(1,1099184400,3),(1,1111885200,2),(1,1130634000,3),(1,1143334800,2),(1,1162083600,3),(1,1174784400,2),(1,1193533200,3),(1,1206838800,2),(1,1224982800,3),(1,1238288400,2),(1,1256432400,3),(1,1269738000,2),(1,1288486800,3),(1,1301187600,2),(1,1319936400,3),(1,1332637200,2),(1,1351386000,3),(1,1364691600,2),(1,1382835600,3),(1,1396141200,2),(1,1414285200,3),(1,1427590800,2),(1,1445734800,3),(1,1459040400,2),(1,1477789200,3),(1,1490490000,2),(1,1509238800,3),(1,1521939600,2),(1,1540688400,3),(1,1553994000,2),(1,1572138000,3),(1,1585443600,2),(1,1603587600,3),(1,1616893200,2),(1,1635642000,3),(1,1648342800,2),(1,1667091600,3),(1,1679792400,2),(1,1698541200,3),(1,1711846800,2),(1,1729990800,3),(1,1743296400,2),(1,1761440400,3),(1,1774746000,2),(1,1792890000,3),(1,1806195600,2),(1,1824944400,3),(1,1837645200,2),(1,1856394000,3),(1,1869094800,2),(1,1887843600,3),(1,1901149200,2),(1,1919293200,3),(1,1932598800,2),(1,1950742800,3),(1,1964048400,2),(1,1982797200,3),(1,1995498000,2),(1,2014246800,3),(1,2026947600,2),(1,2045696400,3),(1,2058397200,2),(1,2077146000,3),(1,2090451600,2),(1,2108595600,3),(1,2121901200,2),(1,2140045200,3),(3,-1688265000,2),(3,-1656819048,1),(3,-1641353448,2),(3,-1627965048,3),(3,-1618716648,1),(3,-1596429048,3),(3,-1593829848,5),(3,-1589860800,4),(3,-1542427200,5),(3,-1539493200,6),(3,-1525323600,5),(3,-1522728000,4),(3,-1491188400,7),(3,-1247536800,4),(3,354920400,5),(3,370728000,4),(3,386456400,5),(3,402264000,4),(3,417992400,5),(3,433800000,4),(3,449614800,5),(3,465346800,8),(3,481071600,9),(3,496796400,8),(3,512521200,9),(3,528246000,8),(3,543970800,9),(3,559695600,8),(3,575420400,9),(3,591145200,8),(3,606870000,9),(3,622594800,8),(3,638319600,9),(3,654649200,8),(3,670374000,10),(3,686102400,11),(3,695779200,8),(3,701812800,5),(3,717534000,4),(3,733273200,9),(3,748998000,8),(3,764722800,9),(3,780447600,8),(3,796172400,9),(3,811897200,8),(3,828226800,9),(3,846370800,8),(3,859676400,9),(3,877820400,8),(3,891126000,9),(3,909270000,8),(3,922575600,9),(3,941324400,8),(3,954025200,9),(3,972774000,8),(3,985474800,9),(3,1004223600,8),(3,1017529200,9),(3,1035673200,8),(3,1048978800,9),(3,1067122800,8),(3,1080428400,9),(3,1099177200,8),(3,1111878000,9),(3,1130626800,8),(3,1143327600,9),(3,1162076400,8),(3,1174777200,9),(3,1193526000,8),(3,1206831600,9),(3,1224975600,8),(3,1238281200,9),(3,1256425200,8),(3,1269730800,9),(3,1288479600,8),(3,1301180400,9),(3,1319929200,8),(3,1332630000,9),(3,1351378800,8),(3,1364684400,9),(3,1382828400,8),(3,1396134000,9),(3,1414278000,8),(3,1427583600,9),(3,1445727600,8),(3,1459033200,9),(3,1477782000,8),(3,1490482800,9),(3,1509231600,8),(3,1521932400,9),(3,1540681200,8),(3,1553986800,9),(3,1572130800,8),(3,1585436400,9),(3,1603580400,8),(3,1616886000,9),(3,1635634800,8),(3,1648335600,9),(3,1667084400,8),(3,1679785200,9),(3,1698534000,8),(3,1711839600,9),(3,1729983600,8),(3,1743289200,9),(3,1761433200,8),(3,1774738800,9),(3,1792882800,8),(3,1806188400,9),(3,1824937200,8),(3,1837638000,9),(3,1856386800,8),(3,1869087600,9),(3,1887836400,8),(3,1901142000,9),(3,1919286000,8),(3,1932591600,9),(3,1950735600,8),(3,1964041200,9),(3,1982790000,8),(3,1995490800,9),(3,2014239600,8),(3,2026940400,9),(3,2045689200,8),(3,2058390000,9),(3,2077138800,8),(3,2090444400,9),(3,2108588400,8),(3,2121894000,9),(3,2140038000,8),(4,-1688265000,2),(4,-1656819048,1),(4,-1641353448,2),(4,-1627965048,3),(4,-1618716648,1),(4,-1596429048,3),(4,-1593829848,5),(4,-1589860800,4),(4,-1542427200,5),(4,-1539493200,6),(4,-1525323600,5),(4,-1522728000,4),(4,-1491188400,7),(4,-1247536800,4),(4,354920409,5),(4,370728010,4),(4,386456410,5),(4,402264011,4),(4,417992411,5),(4,433800012,4),(4,449614812,5),(4,465346812,8),(4,481071612,9),(4,496796413,8),(4,512521213,9),(4,528246013,8),(4,543970813,9),(4,559695613,8),(4,575420414,9),(4,591145214,8),(4,606870014,9),(4,622594814,8),(4,638319615,9),(4,654649215,8),(4,670374016,10),(4,686102416,11),(4,695779216,8),(4,701812816,5),(4,717534017,4),(4,733273217,9),(4,748998018,8),(4,764722818,9),(4,780447619,8),(4,796172419,9),(4,811897219,8),(4,828226820,9),(4,846370820,8),(4,859676420,9),(4,877820421,8),(4,891126021,9),(4,909270021,8),(4,922575622,9),(4,941324422,8),(4,954025222,9),(4,972774022,8),(4,985474822,9),(4,1004223622,8),(4,1017529222,9),(4,1035673222,8),(4,1048978822,9),(4,1067122822,8),(4,1080428422,9),(4,1099177222,8),(4,1111878022,9),(4,1130626822,8),(4,1143327622,9),(4,1162076422,8),(4,1174777222,9),(4,1193526022,8),(4,1206831622,9),(4,1224975622,8),(4,1238281222,9),(4,1256425222,8),(4,1269730822,9),(4,1288479622,8),(4,1301180422,9),(4,1319929222,8),(4,1332630022,9),(4,1351378822,8),(4,1364684422,9),(4,1382828422,8),(4,1396134022,9),(4,1414278022,8),(4,1427583622,9),(4,1445727622,8),(4,1459033222,9),(4,1477782022,8),(4,1490482822,9),(4,1509231622,8),(4,1521932422,9),(4,1540681222,8),(4,1553986822,9),(4,1572130822,8),(4,1585436422,9),(4,1603580422,8),(4,1616886022,9),(4,1635634822,8),(4,1648335622,9),(4,1667084422,8),(4,1679785222,9),(4,1698534022,8),(4,1711839622,9),(4,1729983622,8),(4,1743289222,9),(4,1761433222,8),(4,1774738822,9),(4,1792882822,8),(4,1806188422,9),(4,1824937222,8),(4,1837638022,9),(4,1856386822,8),(4,1869087622,9),(4,1887836422,8),(4,1901142022,9),(4,1919286022,8),(4,1932591622,9),(4,1950735622,8),(4,1964041222,9),(4,1982790022,8),(4,1995490822,9),(4,2014239622,8),(4,2026940422,9),(4,2045689222,8),(4,2058390022,9),(4,2077138822,8),(4,2090444422,9),(4,2108588422,8),(4,2121894022,9),(4,2140038022,8),(5,-1009875600,1); +INSERT IGNORE INTO `time_zone_transition` VALUES (1,-1693706400,0),(1,-1680483600,1),(1,-1663455600,2),(1,-1650150000,3),(1,-1632006000,2),(1,-1618700400,3),(1,-938905200,2),(1,-857257200,3),(1,-844556400,2),(1,-828226800,3),(1,-812502000,2),(1,-796777200,3),(1,228877200,2),(1,243997200,3),(1,260326800,2),(1,276051600,3),(1,291776400,2),(1,307501200,3),(1,323830800,2),(1,338950800,3),(1,354675600,2),(1,370400400,3),(1,386125200,2),(1,401850000,3),(1,417574800,2),(1,433299600,3),(1,449024400,2),(1,465354000,3),(1,481078800,2),(1,496803600,3),(1,512528400,2),(1,528253200,3),(1,543978000,2),(1,559702800,3),(1,575427600,2),(1,591152400,3),(1,606877200,2),(1,622602000,3),(1,638326800,2),(1,654656400,3),(1,670381200,2),(1,686106000,3),(1,701830800,2),(1,717555600,3),(1,733280400,2),(1,749005200,3),(1,764730000,2),(1,780454800,3),(1,796179600,2),(1,811904400,3),(1,828234000,2),(1,846378000,3),(1,859683600,2),(1,877827600,3),(1,891133200,2),(1,909277200,3),(1,922582800,2),(1,941331600,3),(1,954032400,2),(1,972781200,3),(1,985482000,2),(1,1004230800,3),(1,1017536400,2),(1,1035680400,3),(1,1048986000,2),(1,1067130000,3),(1,1080435600,2),(1,1099184400,3),(1,1111885200,2),(1,1130634000,3),(1,1143334800,2),(1,1162083600,3),(1,1174784400,2),(1,1193533200,3),(1,1206838800,2),(1,1224982800,3),(1,1238288400,2),(1,1256432400,3),(1,1269738000,2),(1,1288486800,3),(1,1301187600,2),(1,1319936400,3),(1,1332637200,2),(1,1351386000,3),(1,1364691600,2),(1,1382835600,3),(1,1396141200,2),(1,1414285200,3),(1,1427590800,2),(1,1445734800,3),(1,1459040400,2),(1,1477789200,3),(1,1490490000,2),(1,1509238800,3),(1,1521939600,2),(1,1540688400,3),(1,1553994000,2),(1,1572138000,3),(1,1585443600,2),(1,1603587600,3),(1,1616893200,2),(1,1635642000,3),(1,1648342800,2),(1,1667091600,3),(1,1679792400,2),(1,1698541200,3),(1,1711846800,2),(1,1729990800,3),(1,1743296400,2),(1,1761440400,3),(1,1774746000,2),(1,1792890000,3),(1,1806195600,2),(1,1824944400,3),(1,1837645200,2),(1,1856394000,3),(1,1869094800,2),(1,1887843600,3),(1,1901149200,2),(1,1919293200,3),(1,1932598800,2),(1,1950742800,3),(1,1964048400,2),(1,1982797200,3),(1,1995498000,2),(1,2014246800,3),(1,2026947600,2),(1,2045696400,3),(1,2058397200,2),(1,2077146000,3),(1,2090451600,2),(1,2108595600,3),(1,2121901200,2),(1,2140045200,3),(3,-1688265000,2),(3,-1656819048,1),(3,-1641353448,2),(3,-1627965048,3),(3,-1618716648,1),(3,-1596429048,3),(3,-1593829848,5),(3,-1589860800,4),(3,-1542427200,5),(3,-1539493200,6),(3,-1525323600,5),(3,-1522728000,4),(3,-1491188400,7),(3,-1247536800,4),(3,354920400,5),(3,370728000,4),(3,386456400,5),(3,402264000,4),(3,417992400,5),(3,433800000,4),(3,449614800,5),(3,465346800,8),(3,481071600,9),(3,496796400,8),(3,512521200,9),(3,528246000,8),(3,543970800,9),(3,559695600,8),(3,575420400,9),(3,591145200,8),(3,606870000,9),(3,622594800,8),(3,638319600,9),(3,654649200,8),(3,670374000,10),(3,686102400,11),(3,695779200,8),(3,701812800,5),(3,717534000,4),(3,733273200,9),(3,748998000,8),(3,764722800,9),(3,780447600,8),(3,796172400,9),(3,811897200,8),(3,828226800,9),(3,846370800,8),(3,859676400,9),(3,877820400,8),(3,891126000,9),(3,909270000,8),(3,922575600,9),(3,941324400,8),(3,954025200,9),(3,972774000,8),(3,985474800,9),(3,1004223600,8),(3,1017529200,9),(3,1035673200,8),(3,1048978800,9),(3,1067122800,8),(3,1080428400,9),(3,1099177200,8),(3,1111878000,9),(3,1130626800,8),(3,1143327600,9),(3,1162076400,8),(3,1174777200,9),(3,1193526000,8),(3,1206831600,9),(3,1224975600,8),(3,1238281200,9),(3,1256425200,8),(3,1269730800,9),(3,1288479600,8),(3,1301180400,9),(3,1319929200,8),(3,1332630000,9),(3,1351378800,8),(3,1364684400,9),(3,1382828400,8),(3,1396134000,9),(3,1414278000,8),(3,1427583600,9),(3,1445727600,8),(3,1459033200,9),(3,1477782000,8),(3,1490482800,9),(3,1509231600,8),(3,1521932400,9),(3,1540681200,8),(3,1553986800,9),(3,1572130800,8),(3,1585436400,9),(3,1603580400,8),(3,1616886000,9),(3,1635634800,8),(3,1648335600,9),(3,1667084400,8),(3,1679785200,9),(3,1698534000,8),(3,1711839600,9),(3,1729983600,8),(3,1743289200,9),(3,1761433200,8),(3,1774738800,9),(3,1792882800,8),(3,1806188400,9),(3,1824937200,8),(3,1837638000,9),(3,1856386800,8),(3,1869087600,9),(3,1887836400,8),(3,1901142000,9),(3,1919286000,8),(3,1932591600,9),(3,1950735600,8),(3,1964041200,9),(3,1982790000,8),(3,1995490800,9),(3,2014239600,8),(3,2026940400,9),(3,2045689200,8),(3,2058390000,9),(3,2077138800,8),(3,2090444400,9),(3,2108588400,8),(3,2121894000,9),(3,2140038000,8),(4,-1688265000,2),(4,-1656819048,1),(4,-1641353448,2),(4,-1627965048,3),(4,-1618716648,1),(4,-1596429048,3),(4,-1593829848,5),(4,-1589860800,4),(4,-1542427200,5),(4,-1539493200,6),(4,-1525323600,5),(4,-1522728000,4),(4,-1491188400,7),(4,-1247536800,4),(4,354920409,5),(4,370728010,4),(4,386456410,5),(4,402264011,4),(4,417992411,5),(4,433800012,4),(4,449614812,5),(4,465346812,8),(4,481071612,9),(4,496796413,8),(4,512521213,9),(4,528246013,8),(4,543970813,9),(4,559695613,8),(4,575420414,9),(4,591145214,8),(4,606870014,9),(4,622594814,8),(4,638319615,9),(4,654649215,8),(4,670374016,10),(4,686102416,11),(4,695779216,8),(4,701812816,5),(4,717534017,4),(4,733273217,9),(4,748998018,8),(4,764722818,9),(4,780447619,8),(4,796172419,9),(4,811897219,8),(4,828226820,9),(4,846370820,8),(4,859676420,9),(4,877820421,8),(4,891126021,9),(4,909270021,8),(4,922575622,9),(4,941324422,8),(4,954025222,9),(4,972774022,8),(4,985474822,9),(4,1004223622,8),(4,1017529222,9),(4,1035673222,8),(4,1048978822,9),(4,1067122822,8),(4,1080428422,9),(4,1099177222,8),(4,1111878022,9),(4,1130626822,8),(4,1143327622,9),(4,1162076422,8),(4,1174777222,9),(4,1193526022,8),(4,1206831622,9),(4,1224975622,8),(4,1238281222,9),(4,1256425222,8),(4,1269730822,9),(4,1288479622,8),(4,1301180422,9),(4,1319929222,8),(4,1332630022,9),(4,1351378822,8),(4,1364684422,9),(4,1382828422,8),(4,1396134022,9),(4,1414278022,8),(4,1427583622,9),(4,1445727622,8),(4,1459033222,9),(4,1477782022,8),(4,1490482822,9),(4,1509231622,8),(4,1521932422,9),(4,1540681222,8),(4,1553986822,9),(4,1572130822,8),(4,1585436422,9),(4,1603580422,8),(4,1616886022,9),(4,1635634822,8),(4,1648335622,9),(4,1667084422,8),(4,1679785222,9),(4,1698534022,8),(4,1711839622,9),(4,1729983622,8),(4,1743289222,9),(4,1761433222,8),(4,1774738822,9),(4,1792882822,8),(4,1806188422,9),(4,1824937222,8),(4,1837638022,9),(4,1856386822,8),(4,1869087622,9),(4,1887836422,8),(4,1901142022,9),(4,1919286022,8),(4,1932591622,9),(4,1950735622,8),(4,1964041222,9),(4,1982790022,8),(4,1995490822,9),(4,2014239622,8),(4,2026940422,9),(4,2045689222,8),(4,2058390022,9),(4,2077138822,8),(4,2090444422,9),(4,2108588422,8),(4,2121894022,9),(4,2140038022,8),(5,-1009875600,1); /*!40000 ALTER TABLE `time_zone_transition` ENABLE KEYS */; UNLOCK TABLES; LOCK TABLES `time_zone_transition_type` WRITE; /*!40000 ALTER TABLE `time_zone_transition_type` DISABLE KEYS */; -INSERT IGNORE INTO `time_zone_transition_type` VALUES (1,0,7200,1,'MEST'),(1,1,3600,0,'MET'),(1,2,7200,1,'MEST'),(1,3,3600,0,'MET'),(2,0,0,0,'UTC'),(3,0,9000,0,'MMT'),(3,1,12648,1,'MST'),(3,2,9048,0,'MMT'),(3,3,16248,1,'MDST'),(3,4,10800,0,'MSK'),(3,5,14400,1,'MSD'),(3,6,18000,1,'MSD'),(3,7,7200,0,'EET'),(3,8,10800,0,'MSK'),(3,9,14400,1,'MSD'),(3,10,10800,1,'EEST'),(3,11,7200,0,'EET'),(4,0,9000,0,'MMT'),(4,1,12648,1,'MST'),(4,2,9048,0,'MMT'),(4,3,16248,1,'MDST'),(4,4,10800,0,'MSK'),(4,5,14400,1,'MSD'),(4,6,18000,1,'MSD'),(4,7,7200,0,'EET'),(4,8,10800,0,'MSK'),(4,9,14400,1,'MSD'),(4,10,10800,1,'EEST'),(4,11,7200,0,'EET'),(5,0,32400,0,'CJT'),(5,1,32400,0,'JST'); +INSERT IGNORE INTO `time_zone_transition_type` VALUES (1,0,7200,1,'MEST'),(1,1,3600,0,'MET'),(1,2,7200,1,'MEST'),(1,3,3600,0,'MET'),(2,0,0,0,'UTC'),(3,0,9000,0,'MMT'),(3,1,12648,1,'MST'),(3,2,9048,0,'MMT'),(3,3,16248,1,'MDST'),(3,4,10800,0,'MSK'),(3,5,14400,1,'MSD'),(3,6,18000,1,'MSD'),(3,7,7200,0,'EET'),(3,8,10800,0,'MSK'),(3,9,14400,1,'MSD'),(3,10,10800,1,'EEST'),(3,11,7200,0,'EET'),(4,0,9000,0,'MMT'),(4,1,12648,1,'MST'),(4,2,9048,0,'MMT'),(4,3,16248,1,'MDST'),(4,4,10800,0,'MSK'),(4,5,14400,1,'MSD'),(4,6,18000,1,'MSD'),(4,7,7200,0,'EET'),(4,8,10800,0,'MSK'),(4,9,14400,1,'MSD'),(4,10,10800,1,'EEST'),(4,11,7200,0,'EET'),(5,0,32400,0,'CJT'),(5,1,32400,0,'JST'); /*!40000 ALTER TABLE `time_zone_transition_type` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index c4212ce43b2..a23bf87833d 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -734,7 +734,7 @@ CREATE TABLE `t1` ( LOCK TABLES `t1` WRITE; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); +INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -767,7 +767,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; -INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); +INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -5558,7 +5558,7 @@ CREATE TABLE `nonunique_table_name` ( UNIQUE KEY `i1` (`i1`) ) ENGINE=MEMORY AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT DELAYED INTO `nonunique_table_name` VALUES (1),(2); +INSERT DELAYED INTO `nonunique_table_name` VALUES (1),(2); /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `nonunique_table_view_name` ( @@ -5576,7 +5576,7 @@ CREATE TABLE `basetable` ( `id` smallint(6) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT DELAYED INTO `basetable` VALUES (5),(6); +INSERT DELAYED INTO `basetable` VALUES (5),(6); /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `nonunique_table_name` ( From 24abbb9bdb6adb7af2591f76dfc7b0fe6b3130d9 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 22 Apr 2024 20:22:03 +0400 Subject: [PATCH 188/313] MDEV-21034 GREATEST() and LEAST() malfunction for NULL There is a convention that Item::val_int() and Item::val_real() return SQL NULL doing effectively what this code does: null_value= true; return 0; // Always return 0 for SQL NULL This is done to optimize boolean value evaluation: if Item::val_int() or Item::val_real() returned 1 - that always means TRUE and never can means SQL NULL. This convention helps to avoid unnecessary testing Item::null_value after getting a non-zero return value. Item_func_min_max did not follow this convention. It could return a non-zero value together with null_value==true. This made evaluate_join_record() erroneously misinterpret SQL NULL as TRUE in this call: select_cond_result= MY_TEST(select_cond->val_int()); Fixing Item_func_min_max to follow the convention. --- mysql-test/main/func_hybrid_type.result | 25 +++++++++++++++++++++++++ mysql-test/main/func_hybrid_type.test | 23 +++++++++++++++++++++++ sql/item_func.cc | 4 ++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/func_hybrid_type.result b/mysql-test/main/func_hybrid_type.result index 7276080ed71..f20aad9d726 100644 --- a/mysql-test/main/func_hybrid_type.result +++ b/mysql-test/main/func_hybrid_type.result @@ -4313,5 +4313,30 @@ ERROR HY000: Illegal parameter data types bigint unsigned and row for operation SELECT @@max_allowed_packet=ROW(1,1); ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '=' # +# MDEV-21034 GREATEST() and LEAST() malfunction for NULL +# +SELECT 5 AS c1 FROM dual WHERE GREATEST(1, NULL); +c1 +SELECT 5 AS c1 FROM dual WHERE LEAST(1, NULL); +c1 +CREATE TABLE t0 (c0 INT); +INSERT INTO t0 VALUES (1); +SELECT * FROM t0 WHERE GREATEST(c0, NULL); +c0 +SELECT * FROM t0 WHERE LEAST(c0, NULL); +c0 +DROP TABLE t0; +SELECT 5 AS c1 FROM dual WHERE GREATEST(1e0, NULL); +c1 +SELECT 5 AS c1 FROM dual WHERE LEAST(1e0, NULL); +c1 +CREATE TABLE t0 (c0 DOUBLE); +INSERT INTO t0 VALUES (1); +SELECT * FROM t0 WHERE GREATEST(c0, NULL); +c0 +SELECT * FROM t0 WHERE LEAST(c0, NULL); +c0 +DROP TABLE t0; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_hybrid_type.test b/mysql-test/main/func_hybrid_type.test index 508cdcfb668..2ebfb3cfdf1 100644 --- a/mysql-test/main/func_hybrid_type.test +++ b/mysql-test/main/func_hybrid_type.test @@ -1115,6 +1115,29 @@ SELECT 0x20+ROW(1,1); --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION SELECT @@max_allowed_packet=ROW(1,1); +--echo # +--echo # MDEV-21034 GREATEST() and LEAST() malfunction for NULL +--echo # + +SELECT 5 AS c1 FROM dual WHERE GREATEST(1, NULL); +SELECT 5 AS c1 FROM dual WHERE LEAST(1, NULL); + +CREATE TABLE t0 (c0 INT); +INSERT INTO t0 VALUES (1); +SELECT * FROM t0 WHERE GREATEST(c0, NULL); +SELECT * FROM t0 WHERE LEAST(c0, NULL); +DROP TABLE t0; + +SELECT 5 AS c1 FROM dual WHERE GREATEST(1e0, NULL); +SELECT 5 AS c1 FROM dual WHERE LEAST(1e0, NULL); + +CREATE TABLE t0 (c0 DOUBLE); +INSERT INTO t0 VALUES (1); +SELECT * FROM t0 WHERE GREATEST(c0, NULL); +SELECT * FROM t0 WHERE LEAST(c0, NULL); +DROP TABLE t0; + + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_func.cc b/sql/item_func.cc index f6fa613cba6..b6f601ec82b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3022,7 +3022,7 @@ double Item_func_min_max::val_real_native() value=tmp; } if ((null_value= args[i]->null_value)) - break; + return 0; } return value; } @@ -3043,7 +3043,7 @@ longlong Item_func_min_max::val_int_native() value=tmp; } if ((null_value= args[i]->null_value)) - break; + return 0; } return value; } From fbfb5a6f59ccf6cefffc373e3a5776d49604c64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 18 Apr 2024 15:41:30 +0300 Subject: [PATCH 189/313] MDEV-33928 : Assertion failure on wsrep_thd_is_aborting Problem was assertion assuming we always hold THD::LOCK_thd_data mutex that is not true. In most cases this is true but function is also used from InnoDB lock manager and there we can't take THD::LOCK_thd_data to obey mutex ordering. Removed assertion as wsrep transaction state can't change even that case. Signed-off-by: Julius Goryavsky --- sql/service_wsrep.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sql/service_wsrep.cc b/sql/service_wsrep.cc index 06513387ac7..f8c6ddaa28b 100644 --- a/sql/service_wsrep.cc +++ b/sql/service_wsrep.cc @@ -1,4 +1,4 @@ -/* Copyright 2018-2023 Codership Oy +/* Copyright 2018-2024 Codership Oy 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 @@ -263,12 +263,28 @@ extern "C" my_bool wsrep_thd_order_before(const THD *left, const THD *right) return FALSE; } +/** Check if wsrep transaction is aborting state. + +Calling function should make sure that wsrep transaction state +can't change during this function. + +This function is called from +wsrep_abort_thd where we hold THD::LOCK_thd_data +wsrep_handle_mdl_conflict we hold THD::LOCK_thd_data +wsrep_assert_no_bf_bf_wait we hold lock_sys.latch +innobase_kill_query we hold THD::LOCK_thd_data (THD::awake_no_mutex) + +@param thd thread handle + +@return true if wsrep transaction is aborting +@return false if not + +*/ extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd) { - mysql_mutex_assert_owner(&thd->LOCK_thd_data); - const wsrep::client_state& cs(thd->wsrep_cs()); const enum wsrep::transaction::state tx_state(cs.transaction().state()); + switch (tx_state) { case wsrep::transaction::s_must_abort: @@ -277,7 +293,7 @@ extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd) case wsrep::transaction::s_aborting: return true; default: - return false; + break; } return false; From 0271517495e28b91d8e1fedf8900559854ce5b71 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 20 Feb 2024 17:40:43 +1100 Subject: [PATCH 190/313] MDEV-33492: mysql_install_db fails when baseurl is set auth_map.so isn't guaranteed to be available. Fedora packages it separately. The --base-dir path of mysql_install_db.sh seems to contain historicial heuristics that have been replaced on other branches of the script. We attempt to do the same here placing the basedir original paths so that all components are absolute. --- scripts/mysql_install_db.sh | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 742eb1e17cf..7ad9c338fba 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -344,33 +344,13 @@ then pamtooldir="$builddir/plugin/auth_pam" elif test -n "$basedir" then - bindir="$basedir/bin" # only used in the help text - resolveip=`find_in_dirs resolveip @resolveip_locations@` - if test -z "$resolveip" - then - cannot_find_file resolveip @resolveip_locations@ - exit 1 - fi - mysqld=`find_in_dirs mariadbd @mysqld_locations@` - if test -z "$mysqld" - then - cannot_find_file mariadbd @mysqld_locations@ - exit 1 - fi - langdir=`find_in_dirs --dir errmsg.sys @errmsg_locations@` - if test -z "$langdir" - then - cannot_find_file errmsg.sys @errmsg_locations@ - exit 1 - fi - srcpkgdatadir=`find_in_dirs --dir fill_help_tables.sql @pkgdata_locations@` - buildpkgdatadir=$srcpkgdatadir - if test -z "$srcpkgdatadir" - then - cannot_find_file fill_help_tables.sql @pkgdata_locations@ - exit 1 - fi - plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin` + bindir="$basedir/@INSTALL_BINDIR@" + resolveip="$bindir/resolveip" + mysqld="$basedir/@INSTALL_SBINDIR@/mariadbd" + langdir="$basedir/share/english" + srcpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@" + buildpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@" + plugindir="$basedir/@INSTALL_PLUGINDIR@" pamtooldir=$plugindir # relative from where the script was run for a relocatable install elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mariadbd" From e02077aa03c9451bd89cccb75c6e52597f1c12cf Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 23 Apr 2024 09:55:49 +0400 Subject: [PATCH 191/313] MDEV-21076 NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result This problem was earlier fixed by the patch for MDEV 33344. Adding a test case only. --- mysql-test/main/func_regexp.result | 14 ++++++++++++++ mysql-test/main/func_regexp.test | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/mysql-test/main/func_regexp.result b/mysql-test/main/func_regexp.result index e0a4702c095..8e32732e12d 100644 --- a/mysql-test/main/func_regexp.result +++ b/mysql-test/main/func_regexp.result @@ -178,4 +178,18 @@ select 'foo' regexp x from t1 order by x desc; 0 1 drop table t1; +# +# MDEV-21076 NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result +# +CREATE TABLE t0(c0 INT NOT NULL, c1 CHAR UNIQUE); +INSERT INTO t0 VALUES (0, 1); +INSERT INTO t0 VALUES (0, ''); +SELECT (c1 RLIKE c1), (c0 IS NULL) FROM t0; +(c1 RLIKE c1) (c0 IS NULL) +1 0 +1 0 +SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a; +SUM(a.t) +0 +DROP TABLE t0; # End of 10.5 tests diff --git a/mysql-test/main/func_regexp.test b/mysql-test/main/func_regexp.test index b9e2ef197d6..48a273f6979 100644 --- a/mysql-test/main/func_regexp.test +++ b/mysql-test/main/func_regexp.test @@ -121,4 +121,16 @@ select 'foo' regexp x from t1 order by x asc; select 'foo' regexp x from t1 order by x desc; drop table t1; +--echo # +--echo # MDEV-21076 NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result +--echo # + +CREATE TABLE t0(c0 INT NOT NULL, c1 CHAR UNIQUE); +INSERT INTO t0 VALUES (0, 1); +INSERT INTO t0 VALUES (0, ''); +SELECT (c1 RLIKE c1), (c0 IS NULL) FROM t0; +SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a; +DROP TABLE t0; + + --echo # End of 10.5 tests From e73181112f684debb7246a298fabc4cbce04eb9b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 23 Apr 2024 10:55:17 +0200 Subject: [PATCH 192/313] MDEV-16944 fix galera tests followup for 061adae9a26e --- mysql-test/suite/galera/t/MDEV-26597.test | 2 +- mysql-test/suite/galera/t/MDEV-29142.test | 4 ++-- mysql-test/suite/galera/t/galera_wsrep_new_cluster.test | 2 +- .../suite/galera_sr/t/galera_sr_kill_all_norecovery.test | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/galera/t/MDEV-26597.test b/mysql-test/suite/galera/t/MDEV-26597.test index 783a52cad50..465f1130443 100644 --- a/mysql-test/suite/galera/t/MDEV-26597.test +++ b/mysql-test/suite/galera/t/MDEV-26597.test @@ -18,7 +18,7 @@ SHOW WARNINGS; SET SESSION wsrep_sync_wait = 0; --source include/kill_galera.inc ---let $start_mysqld_params = "" +--let $start_mysqld_params = --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --source include/start_mysqld.inc diff --git a/mysql-test/suite/galera/t/MDEV-29142.test b/mysql-test/suite/galera/t/MDEV-29142.test index 7e9776b005b..f7a8b329089 100644 --- a/mysql-test/suite/galera/t/MDEV-29142.test +++ b/mysql-test/suite/galera/t/MDEV-29142.test @@ -50,12 +50,12 @@ SET SESSION wsrep_sync_wait = 0; --source include/kill_galera.inc --remove_file $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat ---let $start_mysqld_params = "--wsrep-new-cluster" +--let $start_mysqld_params =--wsrep-new-cluster --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/start_mysqld.inc --connection node_2 ---let $start_mysqld_params = "" +--let $start_mysqld_params = --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --source include/start_mysqld.inc diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test index 94ea008cb16..cfa5f8bcead 100644 --- a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test +++ b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test @@ -30,7 +30,7 @@ --echo Starting server ... --let $restart_noprint=2 ---let $start_mysqld_params="--wsrep-new-cluster" +--let $start_mysqld_params=--wsrep-new-cluster --source include/start_mysqld.inc --source include/wait_until_ready.inc diff --git a/mysql-test/suite/galera_sr/t/galera_sr_kill_all_norecovery.test b/mysql-test/suite/galera_sr/t/galera_sr_kill_all_norecovery.test index 5332b1a1579..f6f50fd50c9 100644 --- a/mysql-test/suite/galera_sr/t/galera_sr_kill_all_norecovery.test +++ b/mysql-test/suite/galera_sr/t/galera_sr_kill_all_norecovery.test @@ -38,12 +38,12 @@ SET SESSION wsrep_sync_wait = 0; --source include/kill_galera.inc --remove_file $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat ---let $start_mysqld_params = "--wsrep-new-cluster" +--let $start_mysqld_params =--wsrep-new-cluster --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/start_mysqld.inc --connection node_2 ---let $start_mysqld_params = "" +--let $start_mysqld_params = --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --source include/start_mysqld.inc From f0d0ddc992703f2d31d8ad0d963f127a8b4d05e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 23 Apr 2024 12:04:14 +0300 Subject: [PATCH 193/313] MDEV-33447 fixup for POWER --- storage/innobase/sync/cache.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/sync/cache.cc b/storage/innobase/sync/cache.cc index fb0f393df39..6d3d5b4c4ac 100644 --- a/storage/innobase/sync/cache.cc +++ b/storage/innobase/sync/cache.cc @@ -103,7 +103,7 @@ const pmem_control pmem; #else void pmem_persist(const void *buf, size_t size) { -# ifdef __PPC__ +# ifdef __powerpc64__ for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), end= uintptr_t(buf) + size; u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) @@ -115,7 +115,7 @@ void pmem_persist(const void *buf, size_t size) Let us hope that having a recent enough GCC is an adequate proxy for having a recent enough assembler. */ # if __GNUC__ >= 11 || (defined __clang_major__ && __clang_major__ >= 12) - __asm__ __volatile__("dcbstps 0,%0" :: r(u) : "memory"); + __asm__ __volatile__("dcbstps 0,%0" :: "r"(u) : "memory"); # else __asm__ __volatile__(".long (0x7cc000AC | %0 << 11)" :: "r"(u) : "memory"); # endif From 455a15fd06b0f449e72e6b10b0474e4139eeeca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 23 Apr 2024 12:04:39 +0300 Subject: [PATCH 194/313] MDEV-33972: Memory corruption in innodb.insert_into_empty trx_t::bulk_insert_apply_for_table(dict_table_t *table): Do not write through an invalid iterator. This fixes up commit 863f5996f25eadea6349f0133ad56f3f40e6d6af (MDEV-33868). --- storage/innobase/row/row0merge.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index bcb93970ffc..b726acbd00b 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -5374,13 +5374,15 @@ dberr_t trx_t::bulk_insert_apply_for_table(dict_table_t *table) if (UNIV_UNLIKELY(!bulk_insert)) return DB_SUCCESS; auto it= mod_tables.find(table); - if (it != mod_tables.end() && it->second.bulk_store) + if (it != mod_tables.end()) + { if (dberr_t err= it->second.write_bulk(table, this)) { bulk_rollback_low(); return err; } - it->second.end_bulk_insert(); + it->second.end_bulk_insert(); + } return DB_SUCCESS; } From 07faba08b9e12eeaf35c4afdd99bd2d87a32c02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 23 Apr 2024 12:57:39 +0300 Subject: [PATCH 195/313] MDEV-27924 fixup: cmake -DWITH_INNODB_EXTRA_DEBUG=ON --- storage/innobase/page/page0zip.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 36624f43d10..7c10255c7a0 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -3270,7 +3270,6 @@ page_zip_validate_low( ibool sloppy) /*!< in: FALSE=strict, TRUE=ignore the MIN_REC_FLAG */ { - page_zip_des_t temp_page_zip; ibool valid; if (memcmp(page_zip->data + FIL_PAGE_PREV, page + FIL_PAGE_PREV, @@ -3311,7 +3310,7 @@ page_zip_validate_low( MEM_CHECK_DEFINED(page, srv_page_size); MEM_CHECK_DEFINED(page_zip->data, page_zip_get_size(page_zip)); - temp_page_zip = *page_zip; + page_zip_des_t temp_page_zip(*page_zip); valid = page_zip_decompress_low(&temp_page_zip, temp_page, TRUE); if (!valid) { fputs("page_zip_validate(): failed to decompress\n", stderr); From c3460e690431ce94705888737c2b9de6968665a7 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 23 Apr 2024 16:23:14 +0530 Subject: [PATCH 196/313] MDEV-33970 Assertion `!m.first->second.is_bulk_insert()' failed in trx_undo_report_row_operation() In case of partition insert, InnoDB fails to end the bulk insert for one of the partition. It leads to bulk insert operation for the consecutive delete statement. trx_t::bulk_insert_apply_for_table(): Irrespective of bulk insert value, InnoDB should end the bulk insert for the table. --- mysql-test/suite/innodb/r/insert_into_empty.result | 10 ++++++++++ mysql-test/suite/innodb/t/insert_into_empty.test | 11 +++++++++++ storage/innobase/row/row0merge.cc | 2 -- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index 429f8d0044a..691fbc25fdc 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -500,4 +500,14 @@ f1 f2 NULL NULL COMMIT; DROP TABLE t1; +# +# MDEV-33970 Assertion `!m.first->second.is_bulk_insert()' +# failed in trx_undo_report_row_operation() +# +CREATE TABLE t1(c1 INT,c2 CHAR) ENGINE=INNODB PARTITION BY KEY(c1) PARTITIONS 2; +begin; +INSERT INTO t1 VALUES(2,0); +DELETE FROM t1; +commit; +DROP TABLE t1; # End of 10.11 tests diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index 736eca18d7c..3e5474d54d5 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -534,4 +534,15 @@ INSERT INTO t1 VALUES(); SET STATEMENT FOREIGN_KEY_CHECKS=1 FOR SELECT * FROM t1; COMMIT; DROP TABLE t1; + +--echo # +--echo # MDEV-33970 Assertion `!m.first->second.is_bulk_insert()' +--echo # failed in trx_undo_report_row_operation() +--echo # +CREATE TABLE t1(c1 INT,c2 CHAR) ENGINE=INNODB PARTITION BY KEY(c1) PARTITIONS 2; +begin; +INSERT INTO t1 VALUES(2,0); +DELETE FROM t1; +commit; +DROP TABLE t1; --echo # End of 10.11 tests diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index b726acbd00b..6fb530f0309 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -5371,8 +5371,6 @@ void trx_t::bulk_rollback_low() dberr_t trx_t::bulk_insert_apply_for_table(dict_table_t *table) { - if (UNIV_UNLIKELY(!bulk_insert)) - return DB_SUCCESS; auto it= mod_tables.find(table); if (it != mod_tables.end()) { From 0ccdf54b644352f42e1768bc660be7ab50c1e9d2 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 19 Apr 2024 13:10:58 +0300 Subject: [PATCH 197/313] Check and remove high stack usage I checked all stack overflow potential problems found with gcc -Wstack-usage=16384 and clang -Wframe-larger-than=16384 -no-inline Fixes: Added '#pragma clang diagnostic ignored "-Wframe-larger-than="' to a lot of function to where stack usage large but resonable. - Added stack check warnings to BUILD scrips when using clang and debug. Function changed to use malloc instead allocating things on stack: - read_bootstrap_query() now allocates line_buffer (20000 bytes) with malloc() instead of using stack. This has a small performance impact but this is not releant for bootstrap. - mroonga grn_select() used 65856 bytes on stack. Changed it to use malloc(). - Wsrep_schema::replay_transaction() and Wsrep_schema::recover_sr_transactions(). - Connect zipOpen3() Not fixed: - mroonga/vendor/groonga/lib/expr.c grn_proc_call() uses 43712 byte on stack. However this is not easy to fix as the stack used is caused by a lot of code generated by defines. - Most changes in mroonga/groonga where only adding of pragmas to disable stack warnings. - rocksdb/options/options_helper.cc uses 20288 of stack space. (no reason to fix except to get rid of the compiler warning) - Causes using alloca() where the allocation size is resonable. - An issue in libmariadb (reported to connectors). --- BUILD/SETUP.sh | 6 ++ client/mysqlcheck.c | 7 +- client/mysqlslap.c | 4 + client/mysqltest.cc | 2 +- extra/mariabackup/fil_cur.cc | 4 + include/my_attribute.h | 14 +++ sql/sql_bootstrap.cc | 31 ++++-- sql/sql_statistics.cc | 12 +++ sql/sql_yacc.yy | 3 + sql/wsrep_schema.cc | 99 +++++++++++-------- storage/archive/ha_archive.cc | 18 ++++ storage/connect/ha_connect.cc | 9 ++ storage/connect/tabmul.cpp | 6 +- storage/connect/zip.c | 58 +++++------ storage/innobase/row/row0quiesce.cc | 5 + storage/maria/ma_loghandler.c | 4 + storage/maria/ma_open.c | 4 + storage/maria/ma_recovery.c | 34 ++++--- storage/maria/unittest/ma_test_loghandler-t.c | 3 + storage/mroonga/vendor/groonga/CMakeLists.txt | 1 + storage/mroonga/vendor/groonga/lib/db.c | 18 +++- storage/mroonga/vendor/groonga/lib/load.c | 5 + storage/mroonga/vendor/groonga/lib/operator.c | 5 + .../groonga/lib/proc/proc_object_list.c | 4 + .../vendor/groonga/lib/proc/proc_schema.c | 9 +- .../vendor/groonga/lib/proc/proc_select.c | 20 ++-- storage/perfschema/unittest/pfs_instr-t.cc | 3 + storage/spider/spd_db_conn.cc | 4 + tests/async_queries.c | 2 + tests/mysql_client_fw.c | 4 + unittest/mysys/bitmap-t.c | 4 + unittest/sql/mf_iocache-t.cc | 3 + 32 files changed, 296 insertions(+), 109 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index cab2c0d5f3d..b62497333c3 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -267,6 +267,12 @@ if test `$CC -v 2>&1 | tail -1 | sed 's/ .*$//'` = 'gcc' ; then fi fi +if test `$CC -v 2>&1 | head -1 | sed 's/ .*$//'` = 'clang' ; then + dbug_cflags="$dbug_cflags -Wframe-larger-than=16384 -fno-inline" + c_warnings="$c_warnings -Wframe-larger-than=16384" + cxx_warnings="$cxx_warnings -Wframe-larger-than=16384" +fi + # If ccache (a compiler cache which reduces build time) # (http://samba.org/ccache) is installed, use it. diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index e5f5700ecfd..25c2f795665 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -896,6 +896,7 @@ static int disable_binlog() return run_query("SET SQL_LOG_BIN=0", 0); } + static int handle_request_for_tables(char *tables, size_t length, my_bool view, my_bool dont_quote) { @@ -1027,7 +1028,10 @@ static void insert_table_name(DYNAMIC_ARRAY *arr, char *in, size_t dblen) insert_dynamic(arr, (uchar*) buf); } -static void print_result() +/* Ok as mysqlcheck is not multi threaded */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + +static void __attribute__((noinline)) print_result() { MYSQL_RES *res; MYSQL_ROW row; @@ -1118,6 +1122,7 @@ static void print_result() mysql_free_result(res); DBUG_VOID_RETURN; } +PRAGMA_REENABLE_CHECK_STACK_FRAME static int dbConnect(char *host, char *user, char *passwd) diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 885a5f43e35..ea821242733 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1649,6 +1649,9 @@ drop_primary_key_list(void) return 0; } + +PRAGMA_DISABLE_CHECK_STACK_FRAME + static int create_schema(MYSQL *mysql, const char *db, statement *stmt, option_string *engine_stmt) @@ -1744,6 +1747,7 @@ limit_not_met: DBUG_RETURN(0); } +PRAGMA_REENABLE_CHECK_STACK_FRAME static int drop_schema(MYSQL *mysql, const char *db) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index e0a0cd219c7..ff7e974ee9b 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -78,7 +78,7 @@ static my_bool non_blocking_api_enabled= 0; #define MAX_DELIMITER_LENGTH 16 #define DEFAULT_MAX_CONN 64 -#define DIE_BUFF_SIZE 256*1024 +#define DIE_BUFF_SIZE 15*1024 #define RESULT_STRING_INIT_MEM 2048 #define RESULT_STRING_INCREMENT_MEM 2048 diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index ca64c1c53f6..6f31583072b 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -244,6 +244,9 @@ xb_fil_cur_open( return(XB_FIL_CUR_SUCCESS); } +/* Stack usage 131224 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + static bool page_is_corrupted(const byte *page, ulint page_no, const xb_fil_cur_t *cursor, const fil_space_t *space) @@ -347,6 +350,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no, return buf_page_is_corrupted(true, page, space->flags); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** Reads and verifies the next block of pages from the source file. Positions the cursor after the last read non-corrupted page. diff --git a/include/my_attribute.h b/include/my_attribute.h index c8e980702b6..25d21d5e787 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -70,5 +70,19 @@ # endif /* GNUC >= 3.1 */ #endif +/* Define pragmas to disable warnings for stack frame checking */ +#if defined(__clang__) +#define PRAGMA_DISABLE_CHECK_STACK_FRAME \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Wframe-larger-than=\"") + +#define PRAGMA_REENABLE_CHECK_STACK_FRAME \ +_Pragma("clang diagnostic pop") + +#else +#define PRAGMA_DISABLE_CHECK_STACK_FRAME +#define PRAGMA_REENABLE_CHECK_STACK_FRAME #endif + +#endif /* _my_attribute_h */ diff --git a/sql/sql_bootstrap.cc b/sql/sql_bootstrap.cc index b39d7a57bc0..72821384bb6 100644 --- a/sql/sql_bootstrap.cc +++ b/sql/sql_bootstrap.cc @@ -33,26 +33,35 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, fgets_input_t input, fgets_fn_t fgets_fn, int preserve_delimiter, int *error) { - char line_buffer[MAX_BOOTSTRAP_LINE_SIZE]; + char *line_buffer; const char *line; size_t len; size_t query_len= 0; int fgets_error= 0; + int exit_code= 0; *error= 0; + line_buffer= (char*) malloc(MAX_BOOTSTRAP_LINE_SIZE); + *query_length= 0; for ( ; ; ) { - line= (*fgets_fn)(line_buffer, sizeof(line_buffer), input, &fgets_error); + line= (*fgets_fn)(line_buffer, MAX_BOOTSTRAP_LINE_SIZE, input, &fgets_error); if (error) *error= fgets_error; if (fgets_error != 0) - return READ_BOOTSTRAP_ERROR; + { + exit_code= READ_BOOTSTRAP_ERROR; + break; + } if (line == NULL) - return (query_len == 0) ? READ_BOOTSTRAP_EOF : READ_BOOTSTRAP_ERROR; + { + exit_code= (query_len == 0) ? READ_BOOTSTRAP_EOF : READ_BOOTSTRAP_ERROR; + break; + } len= strlen(line); @@ -98,7 +107,8 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, if (!p || !p[1]) { /* Invalid DELIMITER specifier */ - return READ_BOOTSTRAP_ERROR; + exit_code= READ_BOOTSTRAP_ERROR; + break; } delimiter.assign(p+1); if (preserve_delimiter) @@ -106,7 +116,8 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, memcpy(query,line,len); query[len]=0; *query_length = (int)len; - return READ_BOOTSTRAP_SUCCESS; + exit_code= READ_BOOTSTRAP_SUCCESS; + break; } continue; } @@ -125,7 +136,8 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, } query[query_len]= '\0'; *query_length= (int)query_len; - return READ_BOOTSTRAP_QUERY_SIZE; + exit_code= READ_BOOTSTRAP_QUERY_SIZE; + break; } if (query_len != 0) @@ -152,8 +164,11 @@ extern "C" int read_bootstrap_query(char *query, int *query_length, } query[query_len]= 0; *query_length= (int)query_len; - return READ_BOOTSTRAP_SUCCESS; + exit_code= READ_BOOTSTRAP_SUCCESS; + break; } } + free(line_buffer); + return exit_code; } diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 32fe80c9a9f..3f4f5745565 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2786,6 +2786,9 @@ int collect_statistics_for_table(THD *thd, TABLE *table) After having been updated the statistical system tables are closed. */ +/* Stack usage 20248 from clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int update_statistics_for_table(THD *thd, TABLE *table) { TABLE_LIST tables[STATISTICS_TABLES]; @@ -2870,6 +2873,7 @@ int update_statistics_for_table(THD *thd, TABLE *table) new_trans.restore_old_transaction(); DBUG_RETURN(rc); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** @@ -3282,6 +3286,9 @@ end: The function is called when executing the statement DROP TABLE 'tab'. */ +/* Stack size 20248 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int delete_statistics_for_table(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *tab) { @@ -3350,6 +3357,7 @@ int delete_statistics_for_table(THD *thd, const LEX_CSTRING *db, new_trans.restore_old_transaction(); DBUG_RETURN(rc); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** @@ -3894,6 +3902,9 @@ int rename_indexes_in_stat_table(THD *thd, TABLE *tab, The function is called when executing any statement that renames a table */ +/* Stack size 20968 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int rename_table_in_stat_tables(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *tab, const LEX_CSTRING *new_db, @@ -3971,6 +3982,7 @@ int rename_table_in_stat_tables(THD *thd, const LEX_CSTRING *db, new_trans.restore_old_transaction(); DBUG_RETURN(rc); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a4e3a4c6531..023af109a3f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -80,6 +80,9 @@ #pragma GCC diagnostic ignored "-Wunused-label" /* yyexhaustedlab: */ #endif +/* Stack size 28200 with clang for MYSQLparse() and ORAparse() */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int yylex(void *yylval, void *yythd); #define yyoverflow(A,B,C,D,E,F) \ diff --git a/sql/wsrep_schema.cc b/sql/wsrep_schema.cc index 4ad829c14a6..2473d20b20d 100644 --- a/sql/wsrep_schema.cc +++ b/sql/wsrep_schema.cc @@ -1252,15 +1252,21 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, DBUG_ENTER("Wsrep_schema::replay_transaction"); DBUG_ASSERT(!fragments.empty()); - THD thd(next_thread_id(), true); - thd.thread_stack= (orig_thd ? orig_thd->thread_stack : - (char*) &thd); - wsrep_assign_from_threadvars(&thd); + THD *thd= new THD(next_thread_id(), true); + if (!thd) + { + WSREP_WARN("Could not open allocate memory for THD"); + DBUG_RETURN(1); + } - Wsrep_schema_impl::wsrep_off wsrep_off(&thd); - Wsrep_schema_impl::binlog_off binlog_off(&thd); - Wsrep_schema_impl::sql_safe_updates sql_safe_updates(&thd); - Wsrep_schema_impl::thd_context_switch thd_context_switch(orig_thd, &thd); + thd->thread_stack= (orig_thd ? orig_thd->thread_stack : + (char*) &thd); + wsrep_assign_from_threadvars(thd); + + Wsrep_schema_impl::wsrep_off wsrep_off(thd); + Wsrep_schema_impl::binlog_off binlog_off(thd); + Wsrep_schema_impl::sql_safe_updates sql_safe_updates(thd); + Wsrep_schema_impl::thd_context_switch thd_context_switch(orig_thd, thd); int ret= 1; int error; @@ -1272,11 +1278,12 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, for (std::vector::const_iterator i= fragments.begin(); i != fragments.end(); ++i) { - Wsrep_schema_impl::init_stmt(&thd); - if ((error= Wsrep_schema_impl::open_for_read(&thd, sr_table_str.c_str(), &frag_table_l))) + Wsrep_schema_impl::init_stmt(thd); + if ((error= Wsrep_schema_impl::open_for_read(thd, sr_table_str.c_str(), &frag_table_l))) { WSREP_WARN("Could not open SR table for read: %d", error); - Wsrep_schema_impl::finish_stmt(&thd); + Wsrep_schema_impl::finish_stmt(thd); + my_free(thd); DBUG_RETURN(1); } frag_table= frag_table_l.table; @@ -1308,7 +1315,7 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, frag_table->field[4]->val_str(&buf); { - Wsrep_schema_impl::thd_context_switch thd_context_switch(&thd, orig_thd); + Wsrep_schema_impl::thd_context_switch thd_context_switch(thd, orig_thd); ret= wsrep_apply_events(orig_thd, rli, buf.ptr(), buf.length()); if (ret) @@ -1319,17 +1326,18 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, } Wsrep_schema_impl::end_index_scan(frag_table); - Wsrep_schema_impl::finish_stmt(&thd); + Wsrep_schema_impl::finish_stmt(thd); - Wsrep_schema_impl::init_stmt(&thd); + Wsrep_schema_impl::init_stmt(thd); - if ((error= Wsrep_schema_impl::open_for_write(&thd, + if ((error= Wsrep_schema_impl::open_for_write(thd, sr_table_str.c_str(), &frag_table_l))) { WSREP_WARN("Could not open SR table for write: %d", error); - Wsrep_schema_impl::finish_stmt(&thd); - DBUG_RETURN(1); + Wsrep_schema_impl::finish_stmt(thd); + ret= 1; + break; } frag_table= frag_table_l.table; @@ -1355,60 +1363,68 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, break; } Wsrep_schema_impl::end_index_scan(frag_table); - Wsrep_schema_impl::finish_stmt(&thd); + Wsrep_schema_impl::finish_stmt(thd); my_free(key); key= NULL; } if (key) my_free(key); + delete thd; DBUG_RETURN(ret); } + int Wsrep_schema::recover_sr_transactions(THD *orig_thd) { DBUG_ENTER("Wsrep_schema::recover_sr_transactions"); - THD storage_thd(next_thread_id(), true); - storage_thd.thread_stack= (orig_thd ? orig_thd->thread_stack : + + THD *storage_thd= new THD(next_thread_id(), true); + if (!storage_thd) + { + WSREP_WARN("Could not open allocate memory for THD"); + DBUG_RETURN(1); + } + storage_thd->thread_stack= (orig_thd ? orig_thd->thread_stack : (char*) &storage_thd); - wsrep_assign_from_threadvars(&storage_thd); + wsrep_assign_from_threadvars(storage_thd); TABLE* frag_table= 0; TABLE_LIST frag_table_l; TABLE* cluster_table= 0; TABLE_LIST cluster_table_l; - Wsrep_storage_service storage_service(&storage_thd); - Wsrep_schema_impl::binlog_off binlog_off(&storage_thd); - Wsrep_schema_impl::wsrep_off wsrep_off(&storage_thd); - Wsrep_schema_impl::sql_safe_updates sql_safe_updates(&storage_thd); + Wsrep_storage_service storage_service(storage_thd); + Wsrep_schema_impl::binlog_off binlog_off(storage_thd); + Wsrep_schema_impl::wsrep_off wsrep_off(storage_thd); + Wsrep_schema_impl::sql_safe_updates sql_safe_updates(storage_thd); Wsrep_schema_impl::thd_context_switch thd_context_switch(orig_thd, - &storage_thd); + storage_thd); Wsrep_server_state& server_state(Wsrep_server_state::instance()); int ret= 1; int error; wsrep::id cluster_id; - Wsrep_schema_impl::init_stmt(&storage_thd); - storage_thd.wsrep_skip_locking= FALSE; - if (Wsrep_schema_impl::open_for_read(&storage_thd, cluster_table_str.c_str(), + Wsrep_schema_impl::init_stmt(storage_thd); + storage_thd->wsrep_skip_locking= FALSE; + if (Wsrep_schema_impl::open_for_read(storage_thd, cluster_table_str.c_str(), &cluster_table_l)) { - Wsrep_schema_impl::finish_stmt(&storage_thd); + Wsrep_schema_impl::finish_stmt(storage_thd); DBUG_RETURN(1); } cluster_table= cluster_table_l.table; if (Wsrep_schema_impl::init_for_scan(cluster_table)) { - Wsrep_schema_impl::finish_stmt(&storage_thd); + Wsrep_schema_impl::finish_stmt(storage_thd); DBUG_RETURN(1); } if ((error= Wsrep_schema_impl::next_record(cluster_table))) { Wsrep_schema_impl::end_scan(cluster_table); - Wsrep_schema_impl::finish_stmt(&storage_thd); - trans_commit(&storage_thd); + Wsrep_schema_impl::finish_stmt(storage_thd); + trans_commit(storage_thd); if (error == HA_ERR_END_OF_FILE) { WSREP_INFO("Cluster table is empty, not recovering transactions"); @@ -1423,20 +1439,20 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) Wsrep_schema_impl::scan(cluster_table, 0, cluster_id); Wsrep_schema_impl::end_scan(cluster_table); - Wsrep_schema_impl::finish_stmt(&storage_thd); + Wsrep_schema_impl::finish_stmt(storage_thd); std::ostringstream os; os << cluster_id; WSREP_INFO("Recovered cluster id %s", os.str().c_str()); - storage_thd.wsrep_skip_locking= TRUE; - Wsrep_schema_impl::init_stmt(&storage_thd); + storage_thd->wsrep_skip_locking= TRUE; + Wsrep_schema_impl::init_stmt(storage_thd); /* Open the table for reading and writing so that fragments without valid seqno can be deleted. */ - if (Wsrep_schema_impl::open_for_write(&storage_thd, sr_table_str.c_str(), + if (Wsrep_schema_impl::open_for_write(storage_thd, sr_table_str.c_str(), &frag_table_l)) { WSREP_ERROR("Failed to open SR table for write"); @@ -1492,7 +1508,7 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) transaction_id))) { DBUG_ASSERT(wsrep::starts_transaction(flags)); - applier = wsrep_create_streaming_applier(&storage_thd, "recovery"); + applier = wsrep_create_streaming_applier(storage_thd, "recovery"); server_state.start_streaming_applier(server_id, transaction_id, applier); applier->start_transaction(wsrep::ws_handle(transaction_id, 0), @@ -1520,9 +1536,10 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) } } Wsrep_schema_impl::end_scan(frag_table); - Wsrep_schema_impl::finish_stmt(&storage_thd); - trans_commit(&storage_thd); - storage_thd.set_mysys_var(0); + Wsrep_schema_impl::finish_stmt(storage_thd); + trans_commit(storage_thd); + storage_thd->set_mysys_var(0); out: + delete storage_thd; DBUG_RETURN(ret); } diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 2df54567285..2d623507fd3 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -267,6 +267,9 @@ ha_archive::ha_archive(handlerton *hton, TABLE_SHARE *table_arg) archive_reader_open= FALSE; } +/* Stack size 50264 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int archive_discover(handlerton *hton, THD* thd, TABLE_SHARE *share) { DBUG_ENTER("archive_discover"); @@ -308,6 +311,7 @@ ret: my_free(frm_ptr); DBUG_RETURN(my_errno); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** @brief Read version 1 meta file (5.0 compatibility routine). @@ -478,6 +482,10 @@ int ha_archive::read_data_header(azio_stream *file_to_read) See ha_example.cc for a longer description. */ + +/* Stack size 49608 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + Archive_share *ha_archive::get_share(const char *table_name, int *rc) { Archive_share *tmp_share; @@ -540,6 +548,7 @@ err: DBUG_RETURN(tmp_share); } +PRAGMA_REENABLE_CHECK_STACK_FRAME int Archive_share::init_archive_writer() @@ -761,6 +770,9 @@ int ha_archive::frm_compare(azio_stream *s) of creation. */ +/* Stack size 49608 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int ha_archive::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { @@ -876,6 +888,7 @@ error: /* Return error number, if we got one */ DBUG_RETURN(error ? error : -1); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /* This is where the actual row is written out. @@ -1494,6 +1507,10 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) The table can become fragmented if data was inserted, read, and then inserted again. What we do is open up the file and recompress it completely. */ + +/* Stack size 50152 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) { int rc= 0; @@ -1619,6 +1636,7 @@ error: DBUG_RETURN(rc); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /* Below is an example of how to setup row level locking. diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 253c8e8e305..d2d667d1382 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -6448,6 +6448,9 @@ char *ha_connect::GetDBfromName(const char *name) ha_create_table() in handle.cc */ +/* Stack size 25608 in clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int ha_connect::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { @@ -6989,6 +6992,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, table= st; DBUG_RETURN(rc); } // end of create +PRAGMA_REENABLE_CHECK_STACK_FRAME /** Used to check whether a file based outward table can be populated by @@ -6996,6 +7000,10 @@ int ha_connect::create(const char *name, TABLE *table_arg, - file does not exist or is void - user has file privilege */ + +/* Stack size 16664 in clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + bool ha_connect::FileExists(const char *fn, bool bf) { if (!fn || !*fn) @@ -7046,6 +7054,7 @@ bool ha_connect::FileExists(const char *fn, bool bf) return true; } // end of FileExists +PRAGMA_REENABLE_CHECK_STACK_FRAME // Called by SameString and NoFieldOptionChange bool ha_connect::CheckString(PCSZ str1, PCSZ str2) diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 4fad2b27cd8..d3f86e9cfb1 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -125,8 +125,11 @@ PTDB TDBMUL::Duplicate(PGLOBAL g) /* have a LRECL that is the sum of the lengths of all components. */ /* This is why we use a big filename array to take care of that. */ /***********************************************************************/ + +PRAGMA_DISABLE_CHECK_STACK_FRAME + bool TDBMUL::InitFileNames(PGLOBAL g) - { +{ #define PFNZ 4096 #define FNSZ (_MAX_DRIVE+_MAX_DIR+_MAX_FNAME+_MAX_EXT) PTDBDIR dirp; @@ -241,6 +244,7 @@ bool TDBMUL::InitFileNames(PGLOBAL g) NumFiles = n; return false; } // end of InitFileNames +PRAGMA_REENABLE_CHECK_STACK_FRAME /***********************************************************************/ /* The table column list is the sub-table column list. */ diff --git a/storage/connect/zip.c b/storage/connect/zip.c index 3d3d4caddef..458446c96b1 100644 --- a/storage/connect/zip.c +++ b/storage/connect/zip.c @@ -814,71 +814,66 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { /************************************************************/ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) { - zip64_internal ziinit; zip64_internal* zi; int err=ZIP_OK; - ziinit.z_filefunc.zseek32_file = NULL; - ziinit.z_filefunc.ztell32_file = NULL; - if (pzlib_filefunc64_32_def==NULL) - fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); - else - ziinit.z_filefunc = *pzlib_filefunc64_32_def; + if (!(zi = (zip64_internal*)ALLOC(sizeof(zip64_internal)))) + return NULL; - ziinit.filestream = ZOPEN64(ziinit.z_filefunc, + zi->z_filefunc.zseek32_file = NULL; + zi->z_filefunc.ztell32_file = NULL; + if (pzlib_filefunc64_32_def==NULL) + fill_fopen64_filefunc(&zi->z_filefunc.zfile_func64); + else + zi->z_filefunc = *pzlib_filefunc64_32_def; + + zi->filestream = ZOPEN64(zi->z_filefunc, pathname, (append == APPEND_STATUS_CREATE) ? (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); - if (ziinit.filestream == NULL) - return NULL; - - if (append == APPEND_STATUS_CREATEAFTER) - ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END); - - ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream); - ziinit.in_opened_file_inzip = 0; - ziinit.ci.stream_initialised = 0; - ziinit.number_entry = 0; - ziinit.add_position_when_writing_offset = 0; - init_linkedlist(&(ziinit.central_dir)); - - - - zi = (zip64_internal*)ALLOC(sizeof(zip64_internal)); - if (zi==NULL) + if (zi->filestream == NULL) { - ZCLOSE64(ziinit.z_filefunc,ziinit.filestream); + free(zi); return NULL; } + if (append == APPEND_STATUS_CREATEAFTER) + ZSEEK64(zi->z_filefunc,zi->filestream,0,SEEK_END); + + zi->begin_pos = ZTELL64(zi->z_filefunc,zi->filestream); + zi->in_opened_file_inzip = 0; + zi->ci.stream_initialised = 0; + zi->number_entry = 0; + zi->add_position_when_writing_offset = 0; + init_linkedlist(&(zi->central_dir)); + /* now we add file in a zipfile */ # ifndef NO_ADDFILEINEXISTINGZIP - ziinit.globalcomment = NULL; + zi->globalcomment = NULL; if (append == APPEND_STATUS_ADDINZIP) { // Read and Cache Central Directory Records - err = LoadCentralDirectoryRecord(&ziinit); + err = LoadCentralDirectoryRecord(zi); } if (globalcomment) { - *globalcomment = ziinit.globalcomment; + *globalcomment = zi->globalcomment; } # endif /* !NO_ADDFILEINEXISTINGZIP*/ if (err != ZIP_OK) { # ifndef NO_ADDFILEINEXISTINGZIP - free(ziinit.globalcomment); + free(zi->globalcomment); # endif /* !NO_ADDFILEINEXISTINGZIP*/ free(zi); return NULL; } else { - *zi = ziinit; return (zipFile)zi; } } @@ -1027,7 +1022,6 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c int err = ZIP_OK; # ifdef NOCRYPT - (crcForCrypting); if (password != NULL) return ZIP_PARAMERROR; # endif diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index e927096f296..057b20c77bd 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -431,6 +431,10 @@ row_quiesce_write_header( /*********************************************************************//** Write the table meta data after quiesce. @return DB_SUCCESS or error code */ + +/* Stack size 20904 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_cfg( @@ -488,6 +492,7 @@ row_quiesce_write_cfg( return(err); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /*********************************************************************//** Check whether a table has an FTS index defined on it. diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index ce59f03dd2d..ffbcfecae95 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -3605,6 +3605,9 @@ static my_bool translog_is_LSN_chunk(uchar type) @retval 1 Error */ +/* Stack size 26120 from clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + my_bool translog_init_with_table(const char *directory, uint32 log_file_max_size, uint32 server_version, @@ -4238,6 +4241,7 @@ err: ma_message_no_user(0, "log initialization failed"); DBUG_RETURN(1); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /* diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 2497bc41e8f..39a16ea5df4 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -1558,6 +1558,9 @@ uint _ma_state_info_write(MARIA_SHARE *share, uint pWrite) @retval 1 Error */ +/* Stack size 26376 from clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite) { uchar buff[MARIA_STATE_INFO_SIZE + MARIA_STATE_EXTRA_SIZE]; @@ -1632,6 +1635,7 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite) MYF(MY_NABP)); DBUG_RETURN(res != 0); } +PRAGMA_REENABLE_CHECK_STACK_FRAME static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state, myf flag) diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 006c8bef672..df9b2024086 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -1163,11 +1163,12 @@ end: /* The record may come from REPAIR, ALTER TABLE ENABLE KEYS, OPTIMIZE. */ + prototype_redo_exec_hook(REDO_REPAIR_TABLE) { int error= 1; MARIA_HA *info; - HA_CHECK param; + HA_CHECK *param; char *name; my_bool quick_repair; DBUG_ENTER("exec_REDO_LOGREC_REDO_REPAIR_TABLE"); @@ -1199,35 +1200,39 @@ prototype_redo_exec_hook(REDO_REPAIR_TABLE) */ tprint(tracef, " repairing...\n"); - maria_chk_init(¶m); - param.isam_file_name= name= info->s->open_file_name.str; - param.testflag= uint8korr(rec->header + FILEID_STORE_SIZE); - param.tmpdir= maria_tmpdir; - param.max_trid= max_long_trid; + if (!(param= my_malloc(PSI_INSTRUMENT_ME, sizeof(*param), MYF(MY_WME)))) + DBUG_RETURN(0); + + maria_chk_init(param); + param->isam_file_name= name= info->s->open_file_name.str; + param->testflag= uint8korr(rec->header + FILEID_STORE_SIZE); + param->tmpdir= maria_tmpdir; + param->max_trid= max_long_trid; DBUG_ASSERT(maria_tmpdir); info->s->state.key_map= uint8korr(rec->header + FILEID_STORE_SIZE + 8); - quick_repair= MY_TEST(param.testflag & T_QUICK); + quick_repair= MY_TEST(param->testflag & T_QUICK); - if (param.testflag & T_REP_PARALLEL) + if (param->testflag & T_REP_PARALLEL) { - if (maria_repair_parallel(¶m, info, name, quick_repair)) + if (maria_repair_parallel(param, info, name, quick_repair)) goto end; } - else if (param.testflag & T_REP_BY_SORT) + else if (param->testflag & T_REP_BY_SORT) { - if (maria_repair_by_sort(¶m, info, name, quick_repair)) + if (maria_repair_by_sort(param, info, name, quick_repair)) goto end; } - else if (maria_repair(¶m, info, name, quick_repair)) + else if (maria_repair(param, info, name, quick_repair)) goto end; if (_ma_update_state_lsns(info->s, rec->lsn, trnman_get_min_safe_trid(), - TRUE, !(param.testflag & T_NO_CREATE_RENAME_LSN))) + TRUE, !(param->testflag & T_NO_CREATE_RENAME_LSN))) goto end; error= 0; end: + my_free(param); DBUG_RETURN(error); } @@ -2579,6 +2584,8 @@ prototype_undo_exec_hook(UNDO_BULK_INSERT) return error; } +/* Stack size 18776 in clang. Ok as this is during recover */ +PRAGMA_DISABLE_CHECK_STACK_FRAME static int run_redo_phase(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply) { @@ -2822,6 +2829,7 @@ err: translog_free_record_header(&rec); DBUG_RETURN(1); } +PRAGMA_REENABLE_CHECK_STACK_FRAME /** diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index ccda66af755..800a315d987 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -143,6 +143,8 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec, } +PRAGMA_DISABLE_CHECK_STACK_FRAME + int main(int argc __attribute__((unused)), char *argv[]) { uint32 i; @@ -664,5 +666,6 @@ err: my_end(0); return(MY_TEST(exit_status())); } +PRAGMA_REENABLE_CHECK_STACK_FRAME #include "../ma_check_standalone.h" diff --git a/storage/mroonga/vendor/groonga/CMakeLists.txt b/storage/mroonga/vendor/groonga/CMakeLists.txt index 5b25ada4f5b..cdbfb8f160b 100644 --- a/storage/mroonga/vendor/groonga/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/CMakeLists.txt @@ -200,6 +200,7 @@ endif() include_directories( BEFORE + ${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/lib diff --git a/storage/mroonga/vendor/groonga/lib/db.c b/storage/mroonga/vendor/groonga/lib/db.c index c3bbb64f703..65463bdad20 100644 --- a/storage/mroonga/vendor/groonga/lib/db.c +++ b/storage/mroonga/vendor/groonga/lib/db.c @@ -38,6 +38,7 @@ #include "grn_util.h" #include "grn_cache.h" #include "grn_window_functions.h" +#include #include #include @@ -1060,6 +1061,8 @@ grn_table_create_validate(grn_ctx *ctx, const char *name, unsigned int name_size return ctx->rc; } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static grn_obj * grn_table_create_with_max_n_subrecs(grn_ctx *ctx, const char *name, unsigned int name_size, const char *path, @@ -1238,6 +1241,7 @@ grn_table_create_with_max_n_subrecs(grn_ctx *ctx, const char *name, } return res; } +PRAGMA_REENABLE_CHECK_STACK_FRAME grn_obj * grn_table_create(grn_ctx *ctx, const char *name, unsigned int name_size, @@ -4776,6 +4780,9 @@ _grn_table_key(grn_ctx *ctx, grn_obj *table, grn_id id, uint32_t *key_size) /* column */ + +PRAGMA_DISABLE_CHECK_STACK_FRAME + grn_obj * grn_column_create(grn_ctx *ctx, grn_obj *table, const char *name, unsigned int name_size, @@ -4978,6 +4985,7 @@ exit : if (!res && id) { grn_obj_delete_by_id(ctx, db, id, GRN_TRUE); } GRN_API_RETURN(res); } +PRAGMA_REENABLE_CHECK_STACK_FRAME grn_obj * grn_column_open(grn_ctx *ctx, grn_obj *table, @@ -8540,6 +8548,8 @@ grn_obj_spec_save(grn_ctx *ctx, grn_db_obj *obj) grn_obj_close(ctx, &v); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + inline static void grn_obj_set_info_source_invalid_lexicon_error(grn_ctx *ctx, const char *message, @@ -8590,6 +8600,8 @@ grn_obj_set_info_source_invalid_lexicon_error(grn_ctx *ctx, source_name_size, source_name); } +PRAGMA_REENABLE_CHECK_STACK_FRAME + inline static grn_rc grn_obj_set_info_source_validate(grn_ctx *ctx, grn_obj *obj, grn_obj *value) { @@ -8597,7 +8609,7 @@ grn_obj_set_info_source_validate(grn_ctx *ctx, grn_obj *obj, grn_obj *value) grn_obj *lexicon = NULL; grn_id lexicon_domain_id; grn_obj *lexicon_domain = NULL; - grn_bool lexicon_domain_is_table; + grn_bool lexicon_domain_is_table __attribute__((unused)); grn_bool lexicon_have_tokenizer; grn_id *source_ids; int i, n_source_ids; @@ -9330,7 +9342,7 @@ remove_reference_tables(grn_ctx *ctx, grn_obj *table, grn_obj *db) grn_bool is_close_opened_object_mode = GRN_FALSE; grn_id table_id; char table_name[GRN_TABLE_MAX_KEY_SIZE]; - int table_name_size; + int table_name_size __attribute__((unused)); grn_table_cursor *cursor; if (grn_thread_get_limit() == 1) { @@ -10317,12 +10329,10 @@ grn_db_spec_unpack(grn_ctx *ctx, const char *error_message_tag) { grn_obj *db; - grn_db *db_raw; grn_rc rc; uint32_t spec_size; db = ctx->impl->db; - db_raw = (grn_db *)db; rc = grn_vector_decode(ctx, decoded_spec, diff --git a/storage/mroonga/vendor/groonga/lib/load.c b/storage/mroonga/vendor/groonga/lib/load.c index eb77f2b3849..25d621e7f56 100644 --- a/storage/mroonga/vendor/groonga/lib/load.c +++ b/storage/mroonga/vendor/groonga/lib/load.c @@ -20,6 +20,9 @@ #include "grn_ctx_impl.h" #include "grn_db.h" #include "grn_util.h" +#include + +PRAGMA_DISABLE_CHECK_STACK_FRAME static void grn_loader_save_error(grn_ctx *ctx, grn_loader *loader) @@ -1228,3 +1231,5 @@ grn_load(grn_ctx *ctx, grn_content_type input_type, } GRN_API_RETURN(ctx->rc); } + +PRAGMA_REENABLE_CHECK_STACK_FRAME diff --git a/storage/mroonga/vendor/groonga/lib/operator.c b/storage/mroonga/vendor/groonga/lib/operator.c index 1e1f2cf7e4d..940c0b14a09 100644 --- a/storage/mroonga/vendor/groonga/lib/operator.c +++ b/storage/mroonga/vendor/groonga/lib/operator.c @@ -20,6 +20,7 @@ #include "grn_db.h" #include "grn_str.h" #include "grn_normalizer.h" +#include #include @@ -31,6 +32,8 @@ # include #endif +PRAGMA_DISABLE_CHECK_STACK_FRAME + static const char *operator_names[] = { "push", "pop", @@ -1360,3 +1363,5 @@ grn_operator_exec_regexp(grn_ctx *ctx, grn_obj *target, grn_obj *pattern) } GRN_API_RETURN(matched); } + +PRAGMA_REENABLE_CHECK_STACK_FRAME diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_object_list.c b/storage/mroonga/vendor/groonga/lib/proc/proc_object_list.c index adb4c91bc1f..eaf5504d1fa 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_object_list.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_object_list.c @@ -18,6 +18,7 @@ #include "../grn_proc.h" #include "../grn_db.h" +#include #include @@ -73,6 +74,8 @@ command_object_list_dump_flags(grn_ctx *ctx, grn_obj_spec *spec) GRN_OBJ_FIN(ctx, &flags); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static grn_obj * command_object_list(grn_ctx *ctx, int nargs, @@ -401,6 +404,7 @@ command_object_list(grn_ctx *ctx, return NULL; } +PRAGMA_REENABLE_CHECK_STACK_FRAME void grn_proc_init_object_list(grn_ctx *ctx) diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c b/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c index 061c145a112..7c632f45e53 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_schema.c @@ -17,9 +17,8 @@ */ #include "../grn_proc.h" - #include "../grn_db.h" - +#include #include typedef struct { @@ -572,6 +571,8 @@ command_schema_table_output_token_filters(grn_ctx *ctx, grn_obj *table) GRN_OBJ_FIN(ctx, &token_filters); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static void command_schema_table_command_collect_arguments(grn_ctx *ctx, grn_obj *table, @@ -692,6 +693,7 @@ command_schema_table_command_collect_arguments(grn_ctx *ctx, #undef ADD_OBJECT_NAME #undef ADD } +PRAGMA_REENABLE_CHECK_STACK_FRAME static void command_schema_table_output_command(grn_ctx *ctx, grn_obj *table) @@ -875,6 +877,8 @@ command_schema_output_indexes(grn_ctx *ctx, grn_obj *object) } } +PRAGMA_DISABLE_CHECK_STACK_FRAME + static void command_schema_column_command_collect_arguments(grn_ctx *ctx, grn_obj *table, @@ -973,6 +977,7 @@ command_schema_column_command_collect_arguments(grn_ctx *ctx, #undef ADD_OBJECT_NAME #undef ADD } +PRAGMA_REENABLE_CHECK_STACK_FRAME static void command_schema_column_output_command(grn_ctx *ctx, diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_select.c b/storage/mroonga/vendor/groonga/lib/proc/proc_select.c index a665b1cc898..7588b18a17c 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_select.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_select.c @@ -24,6 +24,7 @@ #include "../grn_util.h" #include "../grn_cache.h" #include "../grn_ii.h" +#include #include "../grn_ts.h" @@ -2912,7 +2913,7 @@ grn_select(grn_ctx *ctx, grn_select_data *data) uint32_t nhits; grn_obj *outbuf = ctx->impl->output.buf; grn_content_type output_type = ctx->impl->output.type; - char cache_key[GRN_CACHE_MAX_KEY_SIZE]; + char *cache_key_buffer= 0; uint32_t cache_key_size; long long int threshold, original_threshold = 0; grn_cache *cache_obj = grn_cache_current_get(ctx); @@ -2985,8 +2986,9 @@ grn_select(grn_ctx *ctx, grn_select_data *data) } GRN_HASH_EACH_END(ctx, cursor); } #undef DRILLDOWN_CACHE_SIZE - if (cache_key_size <= GRN_CACHE_MAX_KEY_SIZE) { - char *cp = cache_key; + if (cache_key_size <= GRN_CACHE_MAX_KEY_SIZE && + (cache_key_buffer= (char*) malloc(cache_key_size+1))) { + char *cp = cache_key_buffer; #define PUT_CACHE_KEY(string) \ if ((string).value) \ @@ -3066,11 +3068,12 @@ grn_select(grn_ctx *ctx, grn_select_data *data) { grn_rc rc; - rc = grn_cache_fetch(ctx, cache_obj, cache_key, cache_key_size, outbuf); + rc = grn_cache_fetch(ctx, cache_obj, cache_key_buffer, cache_key_size, outbuf); if (rc == GRN_SUCCESS) { GRN_QUERY_LOG(ctx, GRN_QUERY_LOG_CACHE, ":", "cache(%" GRN_FMT_LLD ")", (long long int)GRN_TEXT_LEN(outbuf)); + free(cache_key_buffer); return ctx->rc; } } @@ -3119,7 +3122,7 @@ grn_select(grn_ctx *ctx, grn_select_data *data) data->cache.length != 2 || data->cache.value[0] != 'n' || data->cache.value[1] != 'o')) { - grn_cache_update(ctx, cache_obj, cache_key, cache_key_size, outbuf); + grn_cache_update(ctx, cache_obj, cache_key_buffer, cache_key_size, outbuf); } goto exit; } @@ -3186,7 +3189,7 @@ grn_select(grn_ctx *ctx, grn_select_data *data) data->cache.length != 2 || data->cache.value[0] != 'n' || data->cache.value[1] != 'o')) { - grn_cache_update(ctx, cache_obj, cache_key, cache_key_size, outbuf); + grn_cache_update(ctx, cache_obj, cache_key_buffer, cache_key_size, outbuf); } if (data->taintable > 0) { grn_db_touch(ctx, DB_OBJ(data->tables.target)->db); @@ -3200,6 +3203,7 @@ exit : /* GRN_LOG(ctx, GRN_LOG_NONE, "%d", ctx->seqno); */ + free(cache_key_buffer); return ctx->rc; } @@ -3424,6 +3428,9 @@ grn_select_data_fill_drilldown_columns(grn_ctx *ctx, strlen(prefix)); } + +PRAGMA_DISABLE_CHECK_STACK_FRAME + static grn_bool grn_select_data_fill_drilldowns(grn_ctx *ctx, grn_user_data *user_data, @@ -3562,6 +3569,7 @@ grn_select_data_fill_drilldowns(grn_ctx *ctx, return succeeded; } } +PRAGMA_REENABLE_CHECK_STACK_FRAME static grn_obj * command_select(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) diff --git a/storage/perfschema/unittest/pfs_instr-t.cc b/storage/perfschema/unittest/pfs_instr-t.cc index 9667d7ff2be..55c4f61997b 100644 --- a/storage/perfschema/unittest/pfs_instr-t.cc +++ b/storage/perfschema/unittest/pfs_instr-t.cc @@ -86,6 +86,8 @@ void test_no_instruments() cleanup_instruments(); } +PRAGMA_DISABLE_CHECK_STACK_FRAME + void test_no_instances() { int rc; @@ -245,6 +247,7 @@ void test_no_instances() cleanup_file_hash(); cleanup_instruments(); } +PRAGMA_REENABLE_CHECK_STACK_FRAME void test_with_instances() { diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 5333b31fcd1..2dc179f4a28 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -11421,6 +11421,9 @@ int spider_db_udf_ping_table_append_select( DBUG_RETURN(0); } +/* Stack size 33032 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + int spider_db_udf_ping_table_mon_next( THD *thd, SPIDER_TABLE_MON *table_mon, @@ -11567,6 +11570,7 @@ int spider_db_udf_ping_table_mon_next( delete res; DBUG_RETURN(error_num); } +PRAGMA_REENABLE_CHECK_STACK_FRAME int spider_db_udf_copy_key_row( spider_string *str, diff --git a/tests/async_queries.c b/tests/async_queries.c index 8509b414f6e..f0b4fab870a 100644 --- a/tests/async_queries.c +++ b/tests/async_queries.c @@ -358,6 +358,7 @@ handle_option(const struct my_option *opt, const char *arg, return 0; } +PRAGMA_DISABLE_CHECK_STACK_FRAME int main(int argc, char *argv[]) @@ -433,3 +434,4 @@ main(int argc, char *argv[]) return 0; } +PRAGMA_REENABLE_CHECK_STACK_FRAME diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index c9e64678527..173d8a2ea16 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -568,6 +568,9 @@ static int my_process_result(MYSQL *mysql_arg) #define MAX_RES_FIELDS 50 #define MAX_FIELD_DATA_SIZE 255 +/* Stack usage 18888 with clang */ +PRAGMA_DISABLE_CHECK_STACK_FRAME + static int my_process_stmt_result(MYSQL_STMT *stmt) { int field_count; @@ -656,6 +659,7 @@ static int my_process_stmt_result(MYSQL_STMT *stmt) mysql_free_result(result); return row_count; } +PRAGMA_REENABLE_CHECK_STACK_FRAME /* Prepare statement, execute, and process result set for given query */ diff --git a/unittest/mysys/bitmap-t.c b/unittest/mysys/bitmap-t.c index 3698d76654d..8caab0e408e 100644 --- a/unittest/mysys/bitmap-t.c +++ b/unittest/mysys/bitmap-t.c @@ -123,6 +123,8 @@ error6: return TRUE; } +PRAGMA_DISABLE_CHECK_STACK_FRAME + my_bool test_compare_operators(MY_BITMAP *map, uint bitsize) { uint i, j, test_bit1, test_bit2, test_bit3,test_bit4; @@ -228,6 +230,8 @@ error5: test_bit1); return TRUE; } +PRAGMA_REENABLE_CHECK_STACK_FRAME + my_bool test_count_bits_set(MY_BITMAP *map, uint bitsize) { diff --git a/unittest/sql/mf_iocache-t.cc b/unittest/sql/mf_iocache-t.cc index cc97d3b221a..c72e6b7c7e2 100644 --- a/unittest/sql/mf_iocache-t.cc +++ b/unittest/sql/mf_iocache-t.cc @@ -96,6 +96,8 @@ void sql_print_error(const char *format, ...) /*** end of encryption tweaks and stubs ****************************/ +PRAGMA_DISABLE_CHECK_STACK_FRAME + static IO_CACHE info; #define CACHE_SIZE 16384 @@ -472,3 +474,4 @@ int main(int argc __attribute__((unused)),char *argv[]) return exit_status(); } +PRAGMA_REENABLE_CHECK_STACK_FRAME From 55cb2c2916a26b699ed8260427002243682c7110 Mon Sep 17 00:00:00 2001 From: Meng-Hsiu Chiang Date: Wed, 13 Mar 2024 20:16:56 +0000 Subject: [PATCH 198/313] MDEV-29955: Set path for zlib library with pkg-config `FindZLIB` module uses variable `ZLIB_ROOT`[1] to look for libraries. By setting the variable, `FindZLIB` is able to search the libraries that installed in a non-system path (/workspace/mylib for example). And when using `z` in `LINK_LIBRARIES()` CMake tries to lookup the library in system path by default. It doesn't work if the library isn't installed in the path, and use ${ZLIB_LIBRARY} which set by FindZLIB solve the issue. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services. [1]: https://cmake.org/cmake/help/latest/module/FindZLIB.html#hints --- cmake/zlib.cmake | 8 ++++++-- storage/maria/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 9e085189e4f..ee47eb427d9 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -37,10 +37,14 @@ MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) IF(WITH_ZLIB STREQUAL "bundled") MYSQL_USE_BUNDLED_ZLIB() ELSE() - INCLUDE(FindZLIB) + FIND_PACKAGE(PkgConfig QUIET) + IF(PKG_CONFIG_FOUND AND (COMMAND PKG_GET_VARIABLE) AND (NOT WIN32)) + PKG_GET_VARIABLE(ZLIB_ROOT zlib prefix) + ENDIF() + FIND_PACKAGE(ZLIB) IF(ZLIB_FOUND) INCLUDE(CheckFunctionExists) - SET(CMAKE_REQUIRED_LIBRARIES z) + SET(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES}) CHECK_FUNCTION_EXISTS(crc32 HAVE_CRC32) CHECK_FUNCTION_EXISTS(compressBound HAVE_COMPRESSBOUND) CHECK_FUNCTION_EXISTS(deflateBound HAVE_DEFLATEBOUND) diff --git a/storage/maria/CMakeLists.txt b/storage/maria/CMakeLists.txt index f55d78f0162..a566580dca3 100644 --- a/storage/maria/CMakeLists.txt +++ b/storage/maria/CMakeLists.txt @@ -124,7 +124,7 @@ ENDIF() IF (CURL_FOUND) INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) MYSQL_ADD_PLUGIN(s3 ha_s3.cc ${S3_SOURCES} COMPONENT s3-engine - LINK_LIBRARIES ${CURL_LIBRARIES} z STORAGE_ENGINE NOT_EMBEDDED CONFIG s3.cnf) + LINK_LIBRARIES ${CURL_LIBRARIES} ${ZLIB_LIBRARY} STORAGE_ENGINE NOT_EMBEDDED CONFIG s3.cnf) ENDIF() SET(CPACK_RPM_s3-engine_PACKAGE_SUMMARY "Amazon S3 archival storage engine for MariaDB" PARENT_SCOPE) From fb9af3f30e5b545189ae87558977a10637b8073e Mon Sep 17 00:00:00 2001 From: Brian White Date: Mon, 22 Apr 2024 04:04:33 -0400 Subject: [PATCH 199/313] fix build with WITH_EXTRA_CHARSETS=none in cmake --- strings/ctype-uca.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index aa4d366208f..a79a0764840 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -39437,18 +39437,24 @@ my_uca1400_collation_definition_init(MY_CHARSET_LOADER *loader, *dst= nopad ? my_charset_utf8mb4_unicode_520_nopad_ci : my_charset_utf8mb4_unicode_520_ci; break; +#ifdef HAVE_CHARSET_ucs2 case MY_CS_ENCODING_UCS2: *dst= nopad ? my_charset_ucs2_unicode_520_nopad_ci : my_charset_ucs2_unicode_520_ci; break; +#endif +#ifdef HAVE_CHARSET_utf16 case MY_CS_ENCODING_UTF16: *dst= nopad ? my_charset_utf16_unicode_520_nopad_ci : my_charset_utf16_unicode_520_ci; break; +#endif +#ifdef HAVE_CHARSET_utf32 case MY_CS_ENCODING_UTF32: *dst= nopad ? my_charset_utf32_unicode_520_nopad_ci : my_charset_utf32_unicode_520_ci; break; +#endif } dst->number= id; From 720a0f6c78655e9cb29bc4fff4e4aac7e962a7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 24 Apr 2024 12:39:30 +0300 Subject: [PATCH 200/313] MDEV-33447 fixup for POWER 8 pmem_phwsync(): The implementation for POWER ISA v3.1 that is compatible with libpmem. pmem_fence(): A dummy implementation for older ISA. While such systems are unlikely to support MAP_SYNC memory mappings, this could be useful when running tests with memory-mapped /dev/shm/*/ib_logfile0 (the "fake PMEM"), to ensure that mariadb-backup will be able to read the latest redo log contents. pmem_persist_init(): Check the availability of POWER ISA v3.1. Thanks to Daniel Black for suggesting this. --- storage/innobase/include/cache.h | 2 +- storage/innobase/sync/cache.cc | 41 +++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/storage/innobase/include/cache.h b/storage/innobase/include/cache.h index 770f4d96477..0647cbe6dc4 100644 --- a/storage/innobase/include/cache.h +++ b/storage/innobase/include/cache.h @@ -19,7 +19,7 @@ this program; if not, write to the Free Software Foundation, Inc., #pragma once #include -#if defined __x86_64__ || defined __aarch64__ +#if defined __x86_64__ || defined __aarch64__ || defined __powerpc64__ struct pmem_control { void (*persist)(const void *, size_t); diff --git a/storage/innobase/sync/cache.cc b/storage/innobase/sync/cache.cc index 6d3d5b4c4ac..43d642d05b5 100644 --- a/storage/innobase/sync/cache.cc +++ b/storage/innobase/sync/cache.cc @@ -24,7 +24,7 @@ last revised in libpmem-1.12.0. */ #include "cache.h" #include -#if defined __x86_64__ || defined __aarch64__ +#if defined __x86_64__ || defined __aarch64__ || defined __powerpc64__ # ifdef __x86_64__ static void pmem_clflush(const void *buf, size_t size) { @@ -96,14 +96,9 @@ static decltype(pmem_control::persist) pmem_persist_init() { return (getauxval(AT_HWCAP) & HWCAP_DCPOP) ? pmem_cvap : pmem_cvac; } -# endif - -pmem_control::pmem_control() : persist(pmem_persist_init()) {} -const pmem_control pmem; -#else -void pmem_persist(const void *buf, size_t size) +# elif defined __powerpc64__ +static void pmem_phwsync(const void* buf, size_t size) { -# ifdef __powerpc64__ for (uintptr_t u= uintptr_t(buf) & ~(CPU_LEVEL1_DCACHE_LINESIZE), end= uintptr_t(buf) + size; u < end; u+= CPU_LEVEL1_DCACHE_LINESIZE) @@ -126,7 +121,35 @@ void pmem_persist(const void *buf, size_t size) # else __asm__ __volatile__(".long 0x7c80040a" ::: "memory"); # endif -# elif defined __riscv && __riscv_xlen == 64 +} + +# include +static void pmem_fence(const void*, size_t) +{ + std::atomic_thread_fence(std::memory_order_seq_cst); +} + +# include +# ifndef AT_HWCAP2 +# define AT_HWCAP2 26 +# endif +# ifndef PPC_FEATURE2_ARCH_3_1 +# define PPC_FEATURE2_ARCH_3_1 4 +# endif + +static decltype(pmem_control::persist) pmem_persist_init() +{ + return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_3_1) + ? pmem_phwsync : pmem_fence; +} +# endif + +pmem_control::pmem_control() : persist(pmem_persist_init()) {} +const pmem_control pmem; +#else +void pmem_persist(const void *buf, size_t size) +{ +# if defined __riscv && __riscv_xlen == 64 __asm__ __volatile__("fence w,w" ::: "memory"); # elif defined __loongarch64 __asm__ __volatile__("dbar 0" ::: "memory"); From 0c55d854fe96a2ef3bced360e7d0c10623442400 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 24 Apr 2024 13:13:57 +0530 Subject: [PATCH 201/313] MDEV-33334 mariadb-backup fails to preserve innodb_encrypt_tables Problem: ======== mariabackup --prepare fails to write the pages in encrypted format. This issue happens only for default encrypted table when innodb_encrypt_tables variable is enabled. Fix: ==== backup process should write the value of innodb_encrypt_tables variable in configuration file. prepare should enable the variable based on configuration file. --- extra/mariabackup/encryption_plugin.cc | 22 +++++++++++++- .../suite/mariabackup/encrypted_export.opt | 6 ++++ .../suite/mariabackup/encrypted_export.result | 14 +++++++++ .../suite/mariabackup/encrypted_export.test | 29 +++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/mariabackup/encrypted_export.opt create mode 100644 mysql-test/suite/mariabackup/encrypted_export.result create mode 100644 mysql-test/suite/mariabackup/encrypted_export.test diff --git a/extra/mariabackup/encryption_plugin.cc b/extra/mariabackup/encryption_plugin.cc index dbaa67e1324..ab87ce0b7bd 100644 --- a/extra/mariabackup/encryption_plugin.cc +++ b/extra/mariabackup/encryption_plugin.cc @@ -71,7 +71,16 @@ static std::string get_encryption_plugin_from_cnf() plugin_load = line + 12; // remote \n at the end of string plugin_load.resize(plugin_load.size() - 1); - break; + } + + if (strncmp(line, "innodb_encrypt_tables=", 22) == 0) + { + if (!strncmp(line + 22, "ON", 2) || + !strncmp(line + 22, "1", 1)) + srv_encrypt_tables= 1; + else if (!strncmp(line + 22, "FORCE", 5) || + !strncmp(line + 22, "2", 1)) + srv_encrypt_tables= 2; } } fclose(f); @@ -154,6 +163,17 @@ void encryption_plugin_backup_init(MYSQL *mysql) mysql_free_result(result); + result = xb_mysql_query(mysql, "select @@innodb_encrypt_tables", true, true); + row = mysql_fetch_row(result); + if (!row); + else if (const char *r= row[0]) + { + if (!strcmp(r, "ON")) srv_encrypt_tables= 1; + else if (!strcmp(r, "FORCE")) srv_encrypt_tables= 2; + oss << "innodb_encrypt_tables=" << r << std::endl; + } + + mysql_free_result(result); encryption_plugin_config = oss.str(); argc = 0; diff --git a/mysql-test/suite/mariabackup/encrypted_export.opt b/mysql-test/suite/mariabackup/encrypted_export.opt new file mode 100644 index 00000000000..227c2e03f2f --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_export.opt @@ -0,0 +1,6 @@ +--innodb_encrypt_tables=1 +--plugin-load-add=$FILE_KEY_MANAGEMENT_SO +--loose-file-key-management +--loose-file-key-management-filekey=FILE:$MTR_SUITE_DIR/filekeys-data.key +--loose-file-key-management-filename=$MTR_SUITE_DIR/filekeys-data.enc +--loose-file-key-management-encryption-algorithm=aes_cbc diff --git a/mysql-test/suite/mariabackup/encrypted_export.result b/mysql-test/suite/mariabackup/encrypted_export.result new file mode 100644 index 00000000000..b2add8e6136 --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_export.result @@ -0,0 +1,14 @@ +CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB; +insert into t1 values(repeat('a',100)); +select @@innodb_encrypt_tables; +@@innodb_encrypt_tables +ON +# xtrabackup backup +# xtrabackup prepare export +# restart +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/encrypted_export.test b/mysql-test/suite/mariabackup/encrypted_export.test new file mode 100644 index 00000000000..d1802118a09 --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_export.test @@ -0,0 +1,29 @@ +--source include/have_file_key_management.inc +--source include/have_innodb.inc + +CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB; +insert into t1 values(repeat('a',100)); + +select @@innodb_encrypt_tables; +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=10 --target-dir=$targetdir; +--enable_result_log +--source include/shutdown_mysqld.inc + +echo # xtrabackup prepare export; +--disable_result_log +exec $XTRABACKUP --prepare --export --target-dir=$targetdir; +--enable_result_log + +--source include/start_mysqld.inc +let MYSQLD_DATADIR=`select @@datadir`; +ALTER TABLE t1 DISCARD TABLESPACE; +copy_file $targetdir/test/t1.ibd $MYSQLD_DATADIR/test/t1.ibd; +copy_file $targetdir/test/t1.cfg $MYSQLD_DATADIR/test/t1.cfg; +ALTER TABLE t1 IMPORT TABLESPACE; +CHECK TABLE t1; +DROP TABLE t1; +rmdir $targetdir; From 8c7992165baeb80a80a8d7a9aa0b6a3810fb7e5c Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Tue, 9 Apr 2024 11:35:22 -0600 Subject: [PATCH 202/313] MDEV-33672: 10.11 Fix for Two Phase Alter Flags Extends 89c907bd4f713b77e248f7c8e6247b5f3be18fb4 to account for binlog_two_phase_alter flags in a Gtid log event. I.e., if the FL_COMMIT_ALTER_E1 or FL_ROLLBACK_ALTER_E2 flags are set in the event flags, yet the length of the event is too short to hold the value, then set the event as invalid --- .../suite/rpl/r/rpl_gtid_header_valid.result | 24 ++++++++++++++ .../suite/rpl/t/rpl_gtid_header_valid.test | 32 +++++++++++++++++++ sql/log_event.cc | 5 +++ sql/log_event_server.cc | 4 ++- 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result b/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result index fd440feb3c9..6731abc27b7 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result @@ -112,6 +112,30 @@ RESET MASTER; set @@global.gtid_slave_pos=""; include/start_slave.inc # +# Test FL_COMMIT_ALTER +connection master; +set @old_dbug= @@SESSION.debug_dbug; +set @@SESSION.debug_dbug= "+d,negate_alter_fl_from_gtid"; +set @old_alter_tp= @@SESSION.binlog_alter_two_phase; +set @@SESSION.binlog_alter_two_phase= 1; +alter table t1 add column (nc int); +include/save_master_gtid.inc +set @@SESSION.debug_dbug=@old_dbug; +set @@SESSION.binlog_alter_two_phase=@old_alter_tp; +connection slave; +# Waiting for slave to find invalid event.. +include/wait_for_slave_sql_error.inc [errno=1594] +STOP SLAVE IO_THREAD; +# Reset master binlogs (as there is an invalid event) and slave state +connection master; +RESET MASTER; +connection slave; +SET STATEMENT sql_log_bin=0 FOR alter table t1 add column (nc int); +RESET SLAVE; +RESET MASTER; +set @@global.gtid_slave_pos=""; +include/start_slave.inc +# # Cleanup connection master; drop table t1; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test b/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test index db546787914..d4d75ba8928 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test @@ -167,6 +167,38 @@ RESET MASTER; set @@global.gtid_slave_pos=""; --source include/start_slave.inc + +--echo # +--echo # Test FL_COMMIT_ALTER +--connection master +set @old_dbug= @@SESSION.debug_dbug; +set @@SESSION.debug_dbug= "+d,negate_alter_fl_from_gtid"; +set @old_alter_tp= @@SESSION.binlog_alter_two_phase; +set @@SESSION.binlog_alter_two_phase= 1; +alter table t1 add column (nc int); +--source include/save_master_gtid.inc +set @@SESSION.debug_dbug=@old_dbug; +set @@SESSION.binlog_alter_two_phase=@old_alter_tp; + +--connection slave +--echo # Waiting for slave to find invalid event.. +let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE +source include/wait_for_slave_sql_error.inc; +STOP SLAVE IO_THREAD; + +--echo # Reset master binlogs (as there is an invalid event) and slave state +--connection master +RESET MASTER; + +--connection slave +# Just to keep tables consistent between master/slave +SET STATEMENT sql_log_bin=0 FOR alter table t1 add column (nc int); +RESET SLAVE; +RESET MASTER; +set @@global.gtid_slave_pos=""; +--source include/start_slave.inc + + --echo # --echo # Cleanup diff --git a/sql/log_event.cc b/sql/log_event.cc index bf3d93c903d..09a11219949 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2688,6 +2688,11 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, } if (flags_extra & (FL_COMMIT_ALTER_E1 | FL_ROLLBACK_ALTER_E1)) { + if (event_len < static_cast(buf - buf_0) + 8) + { + seq_no= 0; + return; + } sa_seq_no= uint8korr(buf); buf+= 8; } diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 6b72efdd206..003774c24aa 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -3759,7 +3759,9 @@ Gtid_log_event::write() write_len++; } - if (flags_extra & (FL_COMMIT_ALTER_E1 | FL_ROLLBACK_ALTER_E1)) + if (flags_extra & (FL_COMMIT_ALTER_E1 | FL_ROLLBACK_ALTER_E1) + && !DBUG_IF("negate_alter_fl_from_gtid") + ) { int8store(buf + write_len, sa_seq_no); write_len+= 8; From e2f95ebbcbb958825294a3c58369037b4991cc6b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 23 Apr 2024 14:45:23 +0200 Subject: [PATCH 203/313] fix galera_3nodes.galera_gtid_consistency to work with nc like other galera tests do --- mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf b/mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf index 5bd03178d1f..c27490faf36 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf +++ b/mysql-test/suite/galera_3nodes/t/galera_gtid_consistency.cnf @@ -33,3 +33,6 @@ log_slave_updates=ON log_bin=mariadb-bin-log binlog-format=row wsrep-gtid-mode=ON + +[sst] +transferfmt=@ENV.MTR_GALERA_TFMT From 259394aed7d3411bb582354fbc31d2257f231f70 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 23 Apr 2024 15:11:52 +0200 Subject: [PATCH 204/313] disable mariabackup.incremental_encrypted,64k on 32bit it allocates 1GB of memory, it causes failures in CI --- mysql-test/suite/mariabackup/incremental_encrypted.test | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql-test/suite/mariabackup/incremental_encrypted.test b/mysql-test/suite/mariabackup/incremental_encrypted.test index d5570f20006..a2fb7e74565 100644 --- a/mysql-test/suite/mariabackup/incremental_encrypted.test +++ b/mysql-test/suite/mariabackup/incremental_encrypted.test @@ -7,6 +7,12 @@ if (!$EXAMPLE_KEY_MANAGEMENT_SO) } call mtr.add_suppression("InnoDB: New log files created"); +if (`select @@innodb_page_size=65536`) +{ + # this needs too much memory for 32bit + source include/have_64bit.inc; +} + let $basedir=$MYSQLTEST_VARDIR/tmp/backup; let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; From 7d5e08de6bc14da565f2f73a85814a6431295814 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 24 Apr 2024 18:08:46 +0200 Subject: [PATCH 205/313] MDEV-20157 perfschema.stage_mdl_function failed in buildbot with wrong result MDL wait consists of short 1 second waits (this is not configurable) repeated until lock_wait_timeout is reached. The stage is changed to Waiting and back every second. To have predictable result in the test the query should filter all sequences of X, "Waiting for MDL", X, leaving just X. --- .../suite/perfschema/include/stage_setup.inc | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/perfschema/include/stage_setup.inc b/mysql-test/suite/perfschema/include/stage_setup.inc index 683c4561c15..ba97d9094a9 100644 --- a/mysql-test/suite/perfschema/include/stage_setup.inc +++ b/mysql-test/suite/perfschema/include/stage_setup.inc @@ -121,12 +121,23 @@ begin where thread_id = my_thread_id and nesting_event_id = my_statement_id order by event_id asc; - # Ignore query cache as it may not be enabled - select username, event_name, nesting_event_type - from performance_schema.events_stages_history - where thread_id = my_thread_id - and nesting_event_id = my_statement_id and - event_name not like "%query cache%" + # 1. Ignore query cache as it may not be enabled + # 2. MDL wait consists of short 1 second waits (this is not configurable) + # repeated until lock_wait_timeout is reached. The stage is changed + # to Waiting and back every second. To have predictable result here + # the query filters all sequences of X, "Waiting for MDL", X, + # leaving just X. + with h as ( + select event_id, username, event_name, nesting_event_type, + lag(event_name) over (order by event_id) = lead(event_name) over (order by event_id) + and event_name = "stage/sql/Waiting for stored function metadata lock" as v1, + lag(event_name, 2) over (order by event_id) = event_name + and lag(event_name, 1) over (order by event_id) = "stage/sql/Waiting for stored function metadata lock" as v2 + from performance_schema.events_stages_history + where thread_id = my_thread_id + and nesting_event_id = my_statement_id and + event_name not like "%query cache%" + ) select username, event_name, nesting_event_type from h where v1 is not true and v2 is not true order by event_id asc; end; else From 9cf718859f60ebe2fb7d382a6bf5a5f645757651 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 24 Apr 2024 22:08:52 +0200 Subject: [PATCH 206/313] cleanup: use THD_STAGE_INFO, not thd_proc_info and put master-slave.inc *last* in the series of includes --- mysql-test/suite/rpl/t/rpl_parallel_sbm.test | 2 +- sql/rpl_rli.cc | 2 -- sql/rpl_rli.h | 7 +------ sql/slave.cc | 2 +- storage/perfschema/table_replication_applier_status.cc | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test index 9c502ff6cb9..3bf39b47f69 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test @@ -1,9 +1,9 @@ # # Ensure that Seconds_Behind_Master works correctly on the parallel replica. # ---source include/master-slave.inc --source include/have_log_bin.inc --source include/have_debug.inc +--source include/master-slave.inc --echo # --echo # MDEV-29639: Seconds_Behind_Master is incorrect for Delayed, Parallel Replicas diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index a8503650ab7..a8e59f286fd 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -44,8 +44,6 @@ rpl_slave_state *rpl_global_gtid_slave_state; /* Object used for MASTER_GTID_WAIT(). */ gtid_waiting rpl_global_gtid_waiting; -const char *const Relay_log_info::state_delaying_string = "Waiting until MASTER_DELAY seconds after master executed event"; - Relay_log_info::Relay_log_info(bool is_slave_recovery, const char* thread_name) :Slave_reporting_capability(thread_name), replicate_same_server_id(::replicate_same_server_id), diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 8d4688c0794..cf991584573 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -506,11 +506,6 @@ public: m_flags&= ~flag; } - /** - Text used in THD::proc_info when the slave SQL thread is delaying. - */ - static const char *const state_delaying_string; - bool flush(); /** @@ -533,7 +528,7 @@ public: { mysql_mutex_assert_owner(&data_lock); sql_delay_end= delay_end; - thd_proc_info(sql_driver_thd, state_delaying_string); + THD_STAGE_INFO(sql_driver_thd, stage_sql_thd_waiting_until_delay); } int32 get_sql_delay() { return sql_delay; } diff --git a/sql/slave.cc b/sql/slave.cc index bd39cf51759..1d98d51473a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3384,7 +3384,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, // to ensure that we use the same value throughout this function. const char *slave_sql_running_state= mi->rli.sql_driver_thd ? mi->rli.sql_driver_thd->proc_info : ""; - if (slave_sql_running_state == Relay_log_info::state_delaying_string) + if (slave_sql_running_state == stage_sql_thd_waiting_until_delay.m_name) { time_t t= my_time(0), sql_delay_end= mi->rli.get_sql_delay_end(); protocol->store((uint32)(t < sql_delay_end ? sql_delay_end - t : 0)); diff --git a/storage/perfschema/table_replication_applier_status.cc b/storage/perfschema/table_replication_applier_status.cc index fda3c9274d9..94981482e56 100644 --- a/storage/perfschema/table_replication_applier_status.cc +++ b/storage/perfschema/table_replication_applier_status.cc @@ -166,7 +166,7 @@ void table_replication_applier_status::make_row(Master_info *mi) m_row.service_state= PS_RPL_NO; m_row.remaining_delay= 0; - if (slave_sql_running_state == Relay_log_info::state_delaying_string) + if (slave_sql_running_state == stage_sql_thd_waiting_until_delay.m_name) { time_t t= my_time(0), sql_delay_end= mi->rli.get_sql_delay_end(); m_row.remaining_delay= (uint)(t < sql_delay_end ? From 7229384256f370c819bc2685bf8160be8f5cba79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 07:48:57 +0300 Subject: [PATCH 207/313] MDEV-23974 fixup: Cover all debug builds While commit 75b7cd680b8272ac5a0848791757c1d310501574 was a significant improvement, we occasionally got test failures of debug builds. One of the affected tests is innodb.innodb-64k-crash. --- mysql-test/include/have_innodb.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/include/have_innodb.inc b/mysql-test/include/have_innodb.inc index 8c9cdb54363..1e853d186b1 100644 --- a/mysql-test/include/have_innodb.inc +++ b/mysql-test/include/have_innodb.inc @@ -3,6 +3,11 @@ # will be skipped unless innodb is enabled # --disable_query_log +if (`select version() like '%debug%'`) +{ +SET STATEMENT sql_log_bin=0 FOR +call mtr.add_suppression("InnoDB: Trying to delete tablespace.*pending operations"); +} if (`select count(*) from information_schema.system_variables where variable_name='have_sanitizer' and global_value like 'MSAN%'`) { SET STATEMENT sql_log_bin=0 FOR From 8c8b7da0179929058e4a68541fb3d11ac87d48f0 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 25 Apr 2024 10:50:34 +0530 Subject: [PATCH 208/313] MDEV-33979 Disallow bulk insert operation during partition update statement Problem: ======== - Partition update operation enables the bulk insert for the transaction while moving the row between partitions. This leads to debug assert failure while removing the row from one of the partition. Solution: ======== - Disallow the bulk insert operation for non-insert operation of partition table. --- mysql-test/suite/innodb/r/insert_into_empty.result | 9 +++++++++ mysql-test/suite/innodb/t/insert_into_empty.test | 10 ++++++++++ storage/innobase/handler/ha_innodb.cc | 1 + storage/innobase/row/row0ins.cc | 4 +++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index ef7d015f7f3..fdf66681b5d 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -251,4 +251,13 @@ c1 1984 3331 DROP TABLE t1; +# +# MDEV-33979 Disallow bulk insert operation during +# partition update statement +# +CREATE TABLE t1(a INT KEY)ENGINE=InnoDB +PARTITION BY KEY(a) PARTITIONS 16; +INSERT INTO t1 VALUES(1); +UPDATE t1 SET a = 2 WHERE a = 1; +DROP TABLE t1; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index 010b7ecb43a..67afaeb8eba 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -269,4 +269,14 @@ connection default; disconnect con1; SELECT * FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-33979 Disallow bulk insert operation during +--echo # partition update statement +--echo # +CREATE TABLE t1(a INT KEY)ENGINE=InnoDB + PARTITION BY KEY(a) PARTITIONS 16; +INSERT INTO t1 VALUES(1); +UPDATE t1 SET a = 2 WHERE a = 1; +DROP TABLE t1; --echo # End of 10.6 tests diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 418f39885f7..7099680d2b2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -8776,6 +8776,7 @@ ha_innobase::delete_row( : PLAIN_DELETE; trx->fts_next_doc_id = 0; + ut_ad(!trx->is_bulk_insert()); error = row_update_for_mysql(m_prebuilt); #ifdef WITH_WSREP diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 9897c813f02..6995a0d5c7b 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2708,7 +2708,9 @@ err_exit: && !index->table->skip_alter_undo && !index->table->n_rec_locks && !index->table->is_active_ddl() - && !index->table->versioned()) { + && !index->table->versioned() + && (!dict_table_is_partition(index->table) + || thd_sql_command(trx->mysql_thd) == SQLCOM_INSERT)) { DEBUG_SYNC_C("empty_root_page_insert"); if (!index->table->is_temporary()) { From a1c1f5029e2e394b83a19e13b8a8c05e148409aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 11:05:03 +0300 Subject: [PATCH 209/313] MDEV-33974 Enable GNU libstdc++ debugging Starting with GCC 10, let us enable _GLIBCXX_DEBUG as well as _GLIBCXX_ASSERTIONS which have an impact on the GNU libstdc++. On GCC 8, we observed a compilation failure related to some missing type conversion. Even though clang on GNU/Linux would default to using libstdc++ and enabling the debugging seems to work with clang-18, we will not enable this on clang, in case it would lead to compilation errors. For the clang libc++ before clang-15 there was _LIBCPP_DEBUG, but according to llvm/llvm-project@f3966eaf869b7bdd9113ab9d5b78469eb0f5f028 and llvm/llvm-project@13ea1343231fa4ae12fe9fba4c789728465783d7 and llvm/llvm-project@ff573a42cd1f1d05508f165dc3e645a0ec17edb5 it looks like that for proper results, a specially built debug version of libc++ would have to be used in order to enable equivalent checks. This should help catch bugs like the one that commit 455a15fd06b0f449e72e6b10b0474e4139eeeca2 fixed. Reviewed by: Sergei Golubchik --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 129e25f8e8b..a01ebcf57eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,8 +276,6 @@ IF(SECURITY_HARDENED AND NOT WITH_ASAN AND NOT WITH_UBSAN AND NOT WITH_TSAN AND MY_CHECK_AND_SET_COMPILER_FLAG("-D_FORTIFY_SOURCE=2" RELEASE RELWITHDEBINFO) ENDIF() -INCLUDE(wsrep) - OPTION(WITH_DBUG_TRACE "Enable DBUG_ENTER()/DBUG_RETURN()/DBUG_PRINT()" ON) IF(WITH_DBUG_TRACE) FOREACH(LANG C CXX) @@ -288,7 +286,12 @@ ENDIF() # Always enable debug sync for debug builds. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC") - + +IF(CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10") + # Enable extra checks when using a recent enough version of GNU libstdc++ + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG -D_GLIBCXX_ASSERTIONS") +ENDIF() + OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF) IF (ENABLE_GCOV) MY_CHECK_AND_SET_COMPILER_FLAG("-fprofile-arcs -ftest-coverage -lgcov" DEBUG) @@ -349,6 +352,8 @@ ELSEIF(TRASH_FREED_MEMORY MATCHES "AUTO" AND NOT WIN32 AND NOT WITH_VALGRIND AND SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTRASH_FREED_MEMORY") ENDIF() +INCLUDE(wsrep) + # Set commonly used variables IF(WIN32) SET(DEFAULT_MYSQL_HOME "C:/Program Files/MariaDB ${MYSQL_BASE_VERSION}") From 553a4d6271104f96717d3846dd389ba0c603a036 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Tue, 23 Apr 2024 21:02:08 +0200 Subject: [PATCH 210/313] MDEV-33602: Sporadic test failure in rpl.rpl_gtid_stop_start The test could fail with a duplicate key error because switching to non-GTID mode could start at the wrong old-style position. The position could be wrong when the previous GTID connect was stopped before receiving the fake GTID list event which gives the old-style position corresponding to the GTID connected position. Work-around by injecting an extra event and syncing the slave before switching to non-GTID mode. Signed-off-by: Kristian Nielsen --- .../suite/rpl/r/rpl_gtid_stop_start.result | 4 ++++ .../suite/rpl/t/rpl_gtid_stop_start.test | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result index 50f24d56e9a..788f8bdfc06 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_stop_start.result @@ -112,6 +112,10 @@ a 6 7 *** MDEV-4486: Allow to start old-style replication even if mysql.gtid_slave_pos is unavailable +connection server_1; +INSERT INTO t1 VALUES (8); +DELETE FROM t1 WHERE a=8; +connection server_2; connection server_2; include/stop_slave.inc CHANGE MASTER TO master_use_gtid= no; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test index 8e41d6162ea..fc8c513e80d 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test @@ -170,6 +170,24 @@ SELECT * FROM t1 ORDER BY a; --echo *** MDEV-4486: Allow to start old-style replication even if mysql.gtid_slave_pos is unavailable +# In GTID mode, the old-style replication position is also updated. But during +# GTID connect, the old-style position is not known until receiving the fake +# GTID list event, which contains the required position value. If we happened +# to stop the slave above before this fake GTID list event, the test could fail +# with duplicate key errors due to switching to non-GTID mode at a wrong +# position too far back in the binlog. +# +# Work-around this by injecting an extra dummt event and syncing the slave to +# it, ensuring the old-style position will be updated. +# +# This work-around could be removed after MDEV-33996 is fixed. +--connection server_1 +INSERT INTO t1 VALUES (8); +DELETE FROM t1 WHERE a=8; +--save_master_pos +--connection server_2 +--sync_with_master + --connection server_2 --source include/stop_slave.inc CHANGE MASTER TO master_use_gtid= no; From 77d5104feed6f2d549d28f05828038862593ba74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 12:58:32 +0300 Subject: [PATCH 211/313] Remove a bogus workaround for old GCC At least starting with ca83115b3e77ffa696527d82640d5f16810294a2 the source code cannot be compiled with anything older than GCC 4.8.5. Furthermore, 64-bit atomic read-modify-write operations on IA-32 would depend on the LOCK CMPXCHG8B instruction, which was introduced in the Intel Pentium. Our IA-32 builds ought to be -march=i686 starting with commit 9cabc9fd8ac4d249d95ff7140371533070dedd4e. Approved by Sergei Golubchik --- configure.cmake | 9 --------- 1 file changed, 9 deletions(-) diff --git a/configure.cmake b/configure.cmake index 55affd756d3..0fa35f8e89a 100644 --- a/configure.cmake +++ b/configure.cmake @@ -60,15 +60,6 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND (NOT MSVC)) ENDIF() ENDIF() -# workaround for old gcc on x86, gcc atomic ops only work under -march=i686 -IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND - CMAKE_C_COMPILER_VERSION VERSION_LESS "4.4.0") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686") - # query_response_time.cc causes "error: unable to find a register to spill" - SET(PLUGIN_QUERY_RESPONSE_TIME NO CACHE BOOL "Disabled, gcc is too old") -ENDIF() - # use runtime atomic-support detection in aarch64 IF(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") MY_CHECK_AND_SET_COMPILER_FLAG("-moutline-atomics") From 0936c13809f85972ed176abb764b925edd954256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 13:44:10 +0300 Subject: [PATCH 212/313] MDEV-33993 Possible server hang on DROP INDEX or RENAME INDEX commit_try_norebuild(): Add the parameter statistics_exist, similar to commit_try_rebuild(). If the InnoDB statistics tables did not exist, we will not attempt to update statistics later on during the transaction. Thanks to Matthias Leich for originally reproducing this scenario. --- .../suite/innodb/r/innodb-alter-debug.result | 15 +++++++++++-- .../suite/innodb/t/innodb-alter-debug.test | 22 +++++++++++++++---- storage/innobase/handler/handler0alter.cc | 16 ++++++++++++-- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter-debug.result b/mysql-test/suite/innodb/r/innodb-alter-debug.result index c55b4a3ddd5..fd33581ffab 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-debug.result +++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result @@ -108,11 +108,11 @@ DROP TABLE t; # MDEV-26772 InnoDB DDL fails with DUPLICATE KEY error # create table t1(f1 int not null primary key, -f2 int not null, index idx(f2))engine=innodb; +f2 int not null, index idx(f2), index i(f2,f1))engine=innodb; insert into t1 values(1, 1); connect con1,localhost,root,,,; SET DEBUG_SYNC='before_delete_table_stats SIGNAL blocked WAIT_FOR go'; -SET innodb_lock_wait_timeout=0; +SET STATEMENT innodb_lock_wait_timeout=0 FOR ALTER TABLE t1 FORCE, ALGORITHM=COPY; connection default; SET DEBUG_SYNC='now WAIT_FOR blocked'; @@ -124,6 +124,17 @@ connection con1; connection default; COMMIT; SET DEBUG_SYNC=RESET; +RENAME TABLE mysql.innodb_table_stats TO mysql.innodb_table_stats_hidden; +connection con1; +SET DEBUG_SYNC='innodb_commit_inplace_before_lock SIGNAL blocked WAIT_FOR go'; +ALTER TABLE t1 DROP INDEX i; +connection default; +SET DEBUG_SYNC='now WAIT_FOR blocked'; +RENAME TABLE mysql.innodb_table_stats_hidden TO mysql.innodb_table_stats; +SET DEBUG_SYNC='now SIGNAL go'; +connection con1; +connection default; +SET DEBUG_SYNC=RESET; connection con1; ALTER TABLE t1 RENAME KEY idx TO idx1, ALGORITHM=COPY; disconnect con1; diff --git a/mysql-test/suite/innodb/t/innodb-alter-debug.test b/mysql-test/suite/innodb/t/innodb-alter-debug.test index c4a68ac71b7..6b94bfd214f 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-debug.test +++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test @@ -144,15 +144,14 @@ DROP TABLE t; --echo # create table t1(f1 int not null primary key, - - f2 int not null, index idx(f2))engine=innodb; + f2 int not null, index idx(f2), index i(f2,f1))engine=innodb; insert into t1 values(1, 1); connect(con1,localhost,root,,,); SET DEBUG_SYNC='before_delete_table_stats SIGNAL blocked WAIT_FOR go'; -SET innodb_lock_wait_timeout=0; -send ALTER TABLE t1 FORCE, ALGORITHM=COPY; +send SET STATEMENT innodb_lock_wait_timeout=0 FOR +ALTER TABLE t1 FORCE, ALGORITHM=COPY; connection default; SET DEBUG_SYNC='now WAIT_FOR blocked'; @@ -167,6 +166,21 @@ connection default; COMMIT; SET DEBUG_SYNC=RESET; +RENAME TABLE mysql.innodb_table_stats TO mysql.innodb_table_stats_hidden; +connection con1; +SET DEBUG_SYNC='innodb_commit_inplace_before_lock SIGNAL blocked WAIT_FOR go'; +send ALTER TABLE t1 DROP INDEX i; + +connection default; +SET DEBUG_SYNC='now WAIT_FOR blocked'; +RENAME TABLE mysql.innodb_table_stats_hidden TO mysql.innodb_table_stats; +SET DEBUG_SYNC='now SIGNAL go'; + +connection con1; +reap; +connection default; +SET DEBUG_SYNC=RESET; + connection con1; ALTER TABLE t1 RENAME KEY idx TO idx1, ALGORITHM=COPY; disconnect con1; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 087a0c32319..63a5e56e666 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -10228,6 +10228,7 @@ when rebuilding the table. @param ctx In-place ALTER TABLE context @param altered_table MySQL table that is being altered @param old_table MySQL table as it is before the ALTER operation +@param statistics_exist whether to update InnoDB persistent statistics @param trx Data dictionary transaction @param table_name Table name in MySQL @retval true Failure @@ -10501,6 +10502,7 @@ when not rebuilding the table. @param ha_alter_info Data used during in-place alter @param ctx In-place ALTER TABLE context @param old_table MySQL table as it is before the ALTER operation +@param statistics_exist whether to update InnoDB persistent statistics @param trx Data dictionary transaction @param table_name Table name in MySQL @retval true Failure @@ -10514,6 +10516,7 @@ commit_try_norebuild( ha_innobase_inplace_ctx*ctx, TABLE* altered_table, const TABLE* old_table, + bool statistics_exist, trx_t* trx, const char* table_name) { @@ -10628,6 +10631,10 @@ commit_try_norebuild( goto handle_error; } + if (!statistics_exist) { + continue; + } + error = dict_stats_delete_from_index_stats(db, table, index->name, trx); switch (error) { @@ -10639,7 +10646,8 @@ commit_try_norebuild( } } - if (const size_t size = ha_alter_info->rename_keys.size()) { + if (!statistics_exist) { + } else if (const size_t size = ha_alter_info->rename_keys.size()) { char tmp_name[5]; char db[MAX_DB_UTF8_LEN], table[MAX_TABLE_UTF8_LEN]; @@ -11386,6 +11394,8 @@ err_index: } } + DEBUG_SYNC(m_user_thd, "innodb_commit_inplace_before_lock"); + DBUG_EXECUTE_IF("stats_lock_fail", error = DB_LOCK_WAIT_TIMEOUT; trx_rollback_for_mysql(trx);); @@ -11469,7 +11479,9 @@ fail: goto fail; } } else if (commit_try_norebuild(ha_alter_info, ctx, - altered_table, table, trx, + altered_table, table, + table_stats && index_stats, + trx, table_share->table_name.str)) { goto fail; } From 9e92582024df51d17f51391e2d542b277d7f3f17 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 25 Apr 2024 12:47:23 +0200 Subject: [PATCH 213/313] sporadic failures of rpl.rpl_parallel_sbm the test waits for the event to get stuck on MASTER_DELAY, but on a slow/overloaded slave the event might pass MASTER_DELAY before the test starts waiting. Wait for the event to get stuck on the LOCK TABLES (after MASTER_DELAY), the event cannot avoid that, --- mysql-test/suite/rpl/r/rpl_parallel_sbm.result | 2 +- mysql-test/suite/rpl/t/rpl_parallel_sbm.test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_parallel_sbm.result b/mysql-test/suite/rpl/r/rpl_parallel_sbm.result index e349353ac59..75012c93f3b 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_sbm.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_sbm.result @@ -34,7 +34,7 @@ connection server_2; LOCK TABLES t1 WRITE; include/start_slave.inc connection slave; -# Waiting for replica to resume the delay for the transaction +# Waiting for replica to get blocked by the table lock # Sleeping 1s to increment SBM # Ensuring Seconds_Behind_Master increases after sleeping.. # ..done diff --git a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test index 3bf39b47f69..90753caf143 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test @@ -77,8 +77,8 @@ LOCK TABLES t1 WRITE; --source include/start_slave.inc --connection slave ---echo # Waiting for replica to resume the delay for the transaction ---let $wait_condition= SELECT count(*) FROM information_schema.processlist WHERE state LIKE 'Waiting until MASTER_DELAY seconds after master executed event'; +--echo # Waiting for replica to get blocked by the table lock +--let $wait_condition= SELECT count(*) FROM information_schema.processlist WHERE state LIKE 'Waiting for table metadata lock'; --source include/wait_condition.inc --echo # Sleeping 1s to increment SBM From 62287320d43fffda20f11d8672ef35fc5d9f6d82 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Tue, 23 Apr 2024 11:37:11 +0200 Subject: [PATCH 214/313] MDEV-33790 Incorrect DEFAULT expression evaluated in UPDATE The problem was that Item_default_value::associate_with_target_field assigned passed as argument field as an argument which changed argument in case of default() call with certain field (i.e. deault(field)). There is no way to get wrong field in constructor so we will not reassign parameter. --- mysql-test/main/function_defaults.result | 25 ++++++++++++++++++++++++ mysql-test/main/function_defaults.test | 23 ++++++++++++++++++++++ sql/item.cc | 10 +++++++--- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/function_defaults.result b/mysql-test/main/function_defaults.result index 697e2e0d063..41bd0140a23 100644 --- a/mysql-test/main/function_defaults.result +++ b/mysql-test/main/function_defaults.result @@ -3145,3 +3145,28 @@ a b c 2 2010-10-10 10:10:10 x drop table t1; set timestamp=default; +# +# MDEV-33790: Incorrect DEFAULT expression evaluated in UPDATE +# +create table t1 ( +a int, +b timestamp default '2010-10-10 10:10:10' on update now(), +c varchar(100) default 'x'); +create table t2 (a int primary key); +insert t1 (a) values (1),(2); +insert t2 (a) values (1),(2); +select * from t1; +a b c +1 2010-10-10 10:10:10 x +2 2010-10-10 10:10:10 x +set timestamp=unix_timestamp('2011-11-11 11-11-11'); +update t1,t2 set b=default, c=default(b) where t1.a=1 and t1.a= t2.a; +select * from t1; +a b c +1 2010-10-10 10:10:10 2010-10-10 10:10:10 +2 2010-10-10 10:10:10 x +drop table t1, t2; +set timestamp=default; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/function_defaults.test b/mysql-test/main/function_defaults.test index dd3ba109b2a..59776118e56 100644 --- a/mysql-test/main/function_defaults.test +++ b/mysql-test/main/function_defaults.test @@ -67,3 +67,26 @@ update t1 set b=default, c=default(b) where a=1; select * from t1; drop table t1; set timestamp=default; + +--echo # +--echo # MDEV-33790: Incorrect DEFAULT expression evaluated in UPDATE +--echo # + +create table t1 ( + a int, + b timestamp default '2010-10-10 10:10:10' on update now(), + c varchar(100) default 'x'); +create table t2 (a int primary key); +insert t1 (a) values (1),(2); +insert t2 (a) values (1),(2); + +select * from t1; +set timestamp=unix_timestamp('2011-11-11 11-11-11'); +update t1,t2 set b=default, c=default(b) where t1.a=1 and t1.a= t2.a; +select * from t1; +drop table t1, t2; +set timestamp=default; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/sql/item.cc b/sql/item.cc index f70775b86e8..c951a94b226 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -9748,11 +9748,15 @@ Item *Item_default_value::transform(THD *thd, Item_transformer transformer, } -bool Item_default_value::associate_with_target_field(THD *thd, - Item_field *field) +bool Item_default_value:: + associate_with_target_field(THD *thd, + Item_field *field __attribute__((unused))) { m_associated= true; - arg= field; + /* + arg set correctly in constructor (can also differ from field if + it is function with an argument) + */ return tie_field(thd); } From 10d251e05a4b797860081c9c289d9d2e6ed08703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 25 Apr 2024 15:52:38 +0300 Subject: [PATCH 215/313] MDEV-26450 fixup: Remove a bogus assertion mtr_t::commit_shrink(): Do not assert that some previously clean pages will be flagged as modified by this mini-transaction. It could be the case that there had been no recent write-back of any of the undo tablespace pages that we are modifying when truncating the tablespace. It suffices to assert that some pages were modified again: ut_ad(m_modifications). This fixes up commit f5fddae3cbcff2d2531f0ce61bd144212379aa42 --- storage/innobase/mtr/mtr0mtr.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index bf4b2b6b07c..4f730dd4eff 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -572,7 +572,6 @@ void mtr_t::commit_shrink(fil_space_t &space) ut_ad(!is_inside_ibuf()); ut_ad(!high_level_read_only); ut_ad(m_modifications); - ut_ad(m_made_dirty); ut_ad(!recv_recovery_is_on()); ut_ad(m_log_mode == MTR_LOG_ALL); ut_ad(UT_LIST_GET_LEN(space.chain) == 1); From b3e531a3cc5292536f2e6edf3746ff1f8c35775f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 12 Apr 2024 10:10:29 +0300 Subject: [PATCH 216/313] MDEV-33896 : Galera test failure on galera_3nodes.MDEV-29171 Based on logs we might start SST before donor has reached Primary state. Because this test shutdowns all nodes we need to make sure when we start nodes that previous nodes have reached Primary state and joined the cluster. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera_3nodes/disabled.def | 1 - .../suite/galera_3nodes/r/MDEV-29171.result | 20 ++++++++++ .../suite/galera_3nodes/t/MDEV-29171.test | 37 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index 02479c1362e..de7d8e755c7 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -16,5 +16,4 @@ galera_ssl_reload : MDEV-32778 galera_ssl_reload failed with warning message galera_ipv6_mariabackup : temporarily disabled at the request of Codership galera_pc_bootstrap : temporarily disabled at the request of Codership galera_ipv6_mariabackup_section : temporarily disabled at the request of Codership -MDEV-29171 : MDEV-33842 galera_3nodes.MDEV-29171 fails on shutdown_server GCF-354 : MDEV-25614 Galera test failure on GCF-354 diff --git a/mysql-test/suite/galera_3nodes/r/MDEV-29171.result b/mysql-test/suite/galera_3nodes/r/MDEV-29171.result index 371ce006dd3..55513ff53af 100644 --- a/mysql-test/suite/galera_3nodes/r/MDEV-29171.result +++ b/mysql-test/suite/galera_3nodes/r/MDEV-29171.result @@ -19,20 +19,40 @@ connection node_2; connection node_1; connection node_1; # restart: --wsrep_new_cluster --wsrep_gtid_domain_id=200 +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +VARIABLE_VALUE +Primary +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +VARIABLE_VALUE +Synced show variables like 'wsrep_gtid_domain_id'; Variable_name Value wsrep_gtid_domain_id 200 connection node_2; # restart +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +VARIABLE_VALUE +Primary +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +VARIABLE_VALUE +Synced show variables like 'wsrep_gtid_domain_id'; Variable_name Value wsrep_gtid_domain_id 200 +connection node_1; connection node_3; # restart: --wsrep_sst_donor=node2 +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +VARIABLE_VALUE +Primary +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +VARIABLE_VALUE +Synced show variables like 'wsrep_gtid_domain_id'; Variable_name Value wsrep_gtid_domain_id 200 connection node_1; +connection node_1; set global wsrep_gtid_domain_id=100; connection node_2; set global wsrep_gtid_domain_id=100; diff --git a/mysql-test/suite/galera_3nodes/t/MDEV-29171.test b/mysql-test/suite/galera_3nodes/t/MDEV-29171.test index bfb7abf9a8b..1ce33bee974 100644 --- a/mysql-test/suite/galera_3nodes/t/MDEV-29171.test +++ b/mysql-test/suite/galera_3nodes/t/MDEV-29171.test @@ -50,6 +50,16 @@ select @@wsrep_gtid_domain_id,@@wsrep_node_name; --connection node_1 --let $restart_parameters = --wsrep_new_cluster --wsrep_gtid_domain_id=200 --source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; show variables like 'wsrep_gtid_domain_id'; # @@ -59,8 +69,21 @@ show variables like 'wsrep_gtid_domain_id'; --let $restart_parameters = --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; show variables like 'wsrep_gtid_domain_id'; +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc # # Restart node_3, select node_2 as donor @@ -70,9 +93,23 @@ show variables like 'wsrep_gtid_domain_id'; --let $restart_parameters = --wsrep_sst_donor="node2" --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.3.expect --source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment' +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; + # Expect domain id 200 show variables like 'wsrep_gtid_domain_id'; +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc # # Cleanup From 22a69c782710b2bb53917603f5ecc8f6e0d0819a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 25 Apr 2024 20:26:06 +0200 Subject: [PATCH 217/313] MDEV-33492 fix installation of rpm/deb packages followup for 0271517495e2 --- scripts/mysql_install_db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 7ad9c338fba..f38c1d7f98b 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -347,7 +347,7 @@ then bindir="$basedir/@INSTALL_BINDIR@" resolveip="$bindir/resolveip" mysqld="$basedir/@INSTALL_SBINDIR@/mariadbd" - langdir="$basedir/share/english" + langdir="$basedir/@INSTALL_MYSQLSHAREDIR@/english" srcpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@" buildpkgdatadir="$basedir/@INSTALL_MYSQLSHAREDIR@" plugindir="$basedir/@INSTALL_PLUGINDIR@" From ef7a2344af2392365333da9ca40ede159e3fc398 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Thu, 25 Apr 2024 15:21:16 +0200 Subject: [PATCH 218/313] Fixup 0ccdf54b644352f42e1768bc660be7ab50c1e9d 0ccdf54 removed stack allocated THD objects from functions Wsrep_schema::replay_transaction(). However, it inadvertedly anticipated the destruction of the THD, causing assertions and usage of THD after it was destroyed. The fix consists in extracting the original function into a separate function, and leave the allocation and destruction of the THD object in Wsrep_schema::replay_transaction(), making sure that using the heap allocated THD has no side effects. Same for Wsrep_schema::recover_sr_transactions(). Signed-off-by: Julius Goryavsky --- sql/wsrep_schema.cc | 91 +++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/sql/wsrep_schema.cc b/sql/wsrep_schema.cc index 2473d20b20d..32ce8310bc4 100644 --- a/sql/wsrep_schema.cc +++ b/sql/wsrep_schema.cc @@ -1244,25 +1244,12 @@ int Wsrep_schema::remove_fragments(THD* thd, DBUG_RETURN(ret); } -int Wsrep_schema::replay_transaction(THD* orig_thd, - Relay_log_info* rli, - const wsrep::ws_meta& ws_meta, - const std::vector& fragments) +static int replay_transaction(THD* thd, + THD* orig_thd, + Relay_log_info* rli, + const wsrep::ws_meta& ws_meta, + const std::vector& fragments) { - DBUG_ENTER("Wsrep_schema::replay_transaction"); - DBUG_ASSERT(!fragments.empty()); - - THD *thd= new THD(next_thread_id(), true); - if (!thd) - { - WSREP_WARN("Could not open allocate memory for THD"); - DBUG_RETURN(1); - } - - thd->thread_stack= (orig_thd ? orig_thd->thread_stack : - (char*) &thd); - wsrep_assign_from_threadvars(thd); - Wsrep_schema_impl::wsrep_off wsrep_off(thd); Wsrep_schema_impl::binlog_off binlog_off(thd); Wsrep_schema_impl::sql_safe_updates sql_safe_updates(thd); @@ -1283,8 +1270,7 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, { WSREP_WARN("Could not open SR table for read: %d", error); Wsrep_schema_impl::finish_stmt(thd); - my_free(thd); - DBUG_RETURN(1); + return 1; } frag_table= frag_table_l.table; @@ -1370,24 +1356,36 @@ int Wsrep_schema::replay_transaction(THD* orig_thd, if (key) my_free(key); + + return ret; +} + +int Wsrep_schema::replay_transaction(THD* orig_thd, + Relay_log_info* rli, + const wsrep::ws_meta& ws_meta, + const std::vector& fragments) +{ + DBUG_ENTER("Wsrep_schema::replay_transaction"); + DBUG_ASSERT(!fragments.empty()); + + THD *thd= new THD(next_thread_id(), true); + if (!thd) + { + WSREP_WARN("Could not allocate memory for THD"); + DBUG_RETURN(1); + } + + thd->thread_stack= (orig_thd ? orig_thd->thread_stack : (char *) &thd); + wsrep_assign_from_threadvars(thd); + + int ret= ::replay_transaction(thd, orig_thd, rli, ws_meta, fragments); + delete thd; DBUG_RETURN(ret); } - -int Wsrep_schema::recover_sr_transactions(THD *orig_thd) +static int recover_sr_transactions(THD* storage_thd, THD* orig_thd) { - DBUG_ENTER("Wsrep_schema::recover_sr_transactions"); - - THD *storage_thd= new THD(next_thread_id(), true); - if (!storage_thd) - { - WSREP_WARN("Could not open allocate memory for THD"); - DBUG_RETURN(1); - } - storage_thd->thread_stack= (orig_thd ? orig_thd->thread_stack : - (char*) &storage_thd); - wsrep_assign_from_threadvars(storage_thd); TABLE* frag_table= 0; TABLE_LIST frag_table_l; TABLE* cluster_table= 0; @@ -1410,14 +1408,14 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) &cluster_table_l)) { Wsrep_schema_impl::finish_stmt(storage_thd); - DBUG_RETURN(1); + return 1; } cluster_table= cluster_table_l.table; if (Wsrep_schema_impl::init_for_scan(cluster_table)) { Wsrep_schema_impl::finish_stmt(storage_thd); - DBUG_RETURN(1); + return 1; } if ((error= Wsrep_schema_impl::next_record(cluster_table))) @@ -1428,12 +1426,12 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) if (error == HA_ERR_END_OF_FILE) { WSREP_INFO("Cluster table is empty, not recovering transactions"); - DBUG_RETURN(0); + return 0; } else { WSREP_ERROR("Failed to read cluster table: %d", error); - DBUG_RETURN(1); + return 1; } } @@ -1540,6 +1538,25 @@ int Wsrep_schema::recover_sr_transactions(THD *orig_thd) trans_commit(storage_thd); storage_thd->set_mysys_var(0); out: + return ret; +} + +int Wsrep_schema::recover_sr_transactions(THD *orig_thd) +{ + DBUG_ENTER("Wsrep_schema::recover_sr_transactions"); + + THD *storage_thd= new THD(next_thread_id(), true); + if (!storage_thd) + { + WSREP_WARN("Could not allocate memory for THD"); + DBUG_RETURN(1); + } + storage_thd->thread_stack= + (orig_thd ? orig_thd->thread_stack : (char *) &storage_thd); + wsrep_assign_from_threadvars(storage_thd); + + int ret= ::recover_sr_transactions(storage_thd, orig_thd); + delete storage_thd; DBUG_RETURN(ret); } From 45846bacb3386924a95f1ef8449a40e90e5c7145 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 26 Apr 2024 13:02:47 +0200 Subject: [PATCH 219/313] v5.7.0-stable --- extra/wolfssl/wolfssl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/wolfssl/wolfssl b/extra/wolfssl/wolfssl index 66596ad9e1d..8970ff4c340 160000 --- a/extra/wolfssl/wolfssl +++ b/extra/wolfssl/wolfssl @@ -1 +1 @@ -Subproject commit 66596ad9e1d7efa8479656872cf09c9c1870a02e +Subproject commit 8970ff4c34034dbb3594943d11f8c9d4c5512bd5 From 5aff13b65c16e05f31347ed1b039f22bd743374b Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 26 Apr 2024 13:18:51 +0200 Subject: [PATCH 220/313] zlib 1.3.1 --- zlib/CMakeLists.txt | 37 +- zlib/ChangeLog | 10 + zlib/FAQ | 3 +- zlib/Makefile.in | 16 +- zlib/README | 6 +- zlib/configure | 9 +- zlib/contrib/delphi/ZLib.pas | 2 +- zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs | 2 +- zlib/contrib/dotzlib/DotZLib/UnitTests.cs | 2 +- zlib/contrib/infback9/inftree9.c | 6 +- zlib/contrib/infback9/inftree9.h | 4 +- zlib/contrib/iostream3/zfstream.h | 4 +- zlib/contrib/minizip/Makefile | 2 +- zlib/contrib/minizip/configure.ac | 2 +- zlib/contrib/minizip/ioapi.h | 2 +- zlib/contrib/minizip/miniunz.c | 18 +- zlib/contrib/minizip/unzip.c | 8 +- zlib/contrib/minizip/unzip.h | 2 +- zlib/contrib/minizip/zip.c | 21 +- zlib/contrib/minizip/zip.h | 4 +- zlib/contrib/nuget/nuget.csproj | 43 + zlib/contrib/nuget/nuget.sln | 22 + zlib/contrib/pascal/zlibpas.pas | 2 +- zlib/contrib/puff/puff.c | 8 +- zlib/contrib/vstudio/readme.txt | 156 ++-- zlib/contrib/vstudio/vc10/zlib.rc | 8 +- zlib/contrib/vstudio/vc10/zlibvc.def | 2 +- zlib/contrib/vstudio/vc11/zlib.rc | 8 +- zlib/contrib/vstudio/vc11/zlibvc.def | 2 +- zlib/contrib/vstudio/vc12/zlib.rc | 8 +- zlib/contrib/vstudio/vc12/zlibvc.def | 2 +- zlib/contrib/vstudio/vc14/zlib.rc | 8 +- zlib/contrib/vstudio/vc14/zlibvc.def | 2 +- zlib/contrib/vstudio/vc17/miniunz.vcxproj | 409 ++++++++ zlib/contrib/vstudio/vc17/minizip.vcxproj | 405 ++++++++ zlib/contrib/vstudio/vc17/testzlib.vcxproj | 473 ++++++++++ zlib/contrib/vstudio/vc17/testzlibdll.vcxproj | 409 ++++++++ zlib/contrib/vstudio/vc17/zlib.rc | 32 + zlib/contrib/vstudio/vc17/zlibstat.vcxproj | 602 ++++++++++++ zlib/contrib/vstudio/vc17/zlibvc.def | 158 ++++ zlib/contrib/vstudio/vc17/zlibvc.sln | 179 ++++ zlib/contrib/vstudio/vc17/zlibvc.vcxproj | 875 ++++++++++++++++++ zlib/contrib/vstudio/vc9/zlib.rc | 8 +- zlib/contrib/vstudio/vc9/zlibvc.def | 2 +- zlib/deflate.c | 47 +- zlib/deflate.h | 35 +- zlib/doc/algorithm.txt | 2 +- zlib/examples/gzlog.c | 4 +- zlib/examples/zran.c | 2 +- zlib/gzguts.h | 8 +- zlib/gzlib.c | 12 +- zlib/inflate.c | 2 +- zlib/inftrees.c | 6 +- zlib/inftrees.h | 4 +- zlib/old/visual-basic.txt | 2 +- zlib/os400/README400 | 2 +- zlib/os400/zlib.inc | 6 +- zlib/qnx/package.qpg | 10 +- zlib/test/example.c | 25 +- zlib/test/minigzip.c | 32 +- zlib/treebuild.xml | 4 +- zlib/trees.c | 20 +- zlib/win32/DLL_FAQ.txt | 20 +- zlib/win32/README-WIN32.txt | 8 +- zlib/zconf.h | 10 +- zlib/zconf.h.cmakein | 10 +- zlib/zconf.h.in | 10 +- zlib/zlib.3 | 6 +- zlib/zlib.3.pdf | Bin 19505 -> 25523 bytes zlib/zlib.h | 22 +- zlib/zlib.map | 200 ++-- zlib/zutil.h | 27 +- 72 files changed, 4089 insertions(+), 430 deletions(-) create mode 100644 zlib/contrib/nuget/nuget.csproj create mode 100644 zlib/contrib/nuget/nuget.sln create mode 100644 zlib/contrib/vstudio/vc17/miniunz.vcxproj create mode 100644 zlib/contrib/vstudio/vc17/minizip.vcxproj create mode 100644 zlib/contrib/vstudio/vc17/testzlib.vcxproj create mode 100644 zlib/contrib/vstudio/vc17/testzlibdll.vcxproj create mode 100644 zlib/contrib/vstudio/vc17/zlib.rc create mode 100644 zlib/contrib/vstudio/vc17/zlibstat.vcxproj create mode 100644 zlib/contrib/vstudio/vc17/zlibvc.def create mode 100644 zlib/contrib/vstudio/vc17/zlibvc.sln create mode 100644 zlib/contrib/vstudio/vc17/zlibvc.vcxproj diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 7f1b69f4a37..15ceebe787e 100644 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -3,7 +3,9 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) project(zlib C) -set(VERSION "1.3") +set(VERSION "1.3.1") + +option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON) set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") @@ -148,7 +150,9 @@ if(MINGW) endif(MINGW) add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) set_target_properties(zlib PROPERTIES SOVERSION 1) @@ -166,7 +170,7 @@ endif() if(UNIX) # On unix-like platforms the library is almost always called libz set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) - if(NOT APPLE) + if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX)) set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") endif() elseif(BUILD_SHARED_LIBS AND WIN32) @@ -193,21 +197,22 @@ endif() #============================================================================ # Example binaries #============================================================================ +if(ZLIB_BUILD_EXAMPLES) + add_executable(example test/example.c) + target_link_libraries(example zlib) + add_test(example example) -add_executable(example test/example.c) -target_link_libraries(example zlib) -add_test(example example) + add_executable(minigzip test/minigzip.c) + target_link_libraries(minigzip zlib) -add_executable(minigzip test/minigzip.c) -target_link_libraries(minigzip zlib) + if(HAVE_OFF64_T) + add_executable(example64 test/example.c) + target_link_libraries(example64 zlib) + set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + add_test(example64 example64) -if(HAVE_OFF64_T) - add_executable(example64 test/example.c) - target_link_libraries(example64 zlib) - set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") - add_test(example64 example64) - - add_executable(minigzip64 test/minigzip.c) - target_link_libraries(minigzip64 zlib) - set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + add_executable(minigzip64 test/minigzip.c) + target_link_libraries(minigzip64 zlib) + set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + endif() endif() diff --git a/zlib/ChangeLog b/zlib/ChangeLog index 8707988ac18..b801a1031ec 100644 --- a/zlib/ChangeLog +++ b/zlib/ChangeLog @@ -1,6 +1,16 @@ ChangeLog file for zlib +Changes in 1.3.1 (22 Jan 2024) +- Reject overflows of zip header fields in minizip +- Fix bug in inflateSync() for data held in bit buffer +- Add LIT_MEM define to use more memory for a small deflate speedup +- Fix decision on the emission of Zip64 end records in minizip +- Add bounds checking to ERR_MSG() macro, used by zError() +- Neutralize zip file traversal attacks in miniunz +- Fix a bug in ZLIB_DEBUG compiles in check_match() +- Various portability and appearance improvements + Changes in 1.3 (18 Aug 2023) - Remove K&R function definitions and zlib2ansi - Fix bug in deflateBound() for level 0 and memLevel 9 diff --git a/zlib/FAQ b/zlib/FAQ index 55f1cdc22f6..92f5d3e29fa 100644 --- a/zlib/FAQ +++ b/zlib/FAQ @@ -14,8 +14,7 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html 2. Where can I get a Windows DLL version? The zlib sources can be compiled without change to produce a DLL. See the - file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the - precompiled DLL are found in the zlib web site at http://zlib.net/ . + file win32/DLL_FAQ.txt in the zlib distribution. 3. Where can I get a Visual Basic interface to zlib? diff --git a/zlib/Makefile.in b/zlib/Makefile.in index 34d3cd722f8..cb8b00a9b07 100644 --- a/zlib/Makefile.in +++ b/zlib/Makefile.in @@ -1,5 +1,5 @@ # Makefile for zlib -# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler +# Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler # For conditions of distribution and use, see copyright notice in zlib.h # To compile and test, type: @@ -22,13 +22,13 @@ CFLAGS=-O SFLAGS=-O LDFLAGS= -TEST_LDFLAGS=$(LDFLAGS) -L. libz.a +TEST_LIBS=-L. libz.a LDSHARED=$(CC) CPP=$(CC) -E STATICLIB=libz.a SHAREDLIB=libz.so -SHAREDLIBV=libz.so.1.3 +SHAREDLIBV=libz.so.1.3.1 SHAREDLIBM=libz.so.1 LIBS=$(STATICLIB) $(SHAREDLIBV) @@ -282,10 +282,10 @@ placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a -@rmdir objs example$(EXE): example.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(TEST_LIBS) minigzip$(EXE): minigzip.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(TEST_LIBS) examplesh$(EXE): example.o $(SHAREDLIBV) $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV) @@ -294,10 +294,10 @@ minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV) example64$(EXE): example64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ example64.o $(TEST_LIBS) minigzip64$(EXE): minigzip64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip64.o $(TEST_LIBS) install-libs: $(LIBS) -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi @@ -360,7 +360,7 @@ zconf: $(SRCDIR)zconf.h.in cp -p $(SRCDIR)zconf.h.in zconf.h minizip-test: static - cd contrib/minizip && { CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; } + cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; } minizip-clean: cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; } diff --git a/zlib/README b/zlib/README index e02fc5aa206..c5f917540b6 100644 --- a/zlib/README +++ b/zlib/README @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.3 is a general purpose data compression library. All the code is +zlib 1.3.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and @@ -31,7 +31,7 @@ Mark Nelson wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at https://marknelson.us/posts/1997/01/01/zlib-engine.html . -The changes made in version 1.3 are documented in the file ChangeLog. +The changes made in version 1.3.1 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . @@ -83,7 +83,7 @@ Acknowledgments: Copyright notice: - (C) 1995-2023 Jean-loup Gailly and Mark Adler + (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/zlib/configure b/zlib/configure index cc867c94474..c55098afc4a 100755 --- a/zlib/configure +++ b/zlib/configure @@ -25,7 +25,7 @@ if test $SRCDIR = "."; then ZINCOUT="-I." SRCDIR="" else - ZINC='-include zconf.h' + ZINC='-I. -include zconf.h' ZINCOUT='-I. -I$(SRCDIR)' SRCDIR="$SRCDIR/" fi @@ -44,7 +44,8 @@ STATICLIB=libz.a # extract zlib version numbers from zlib.h VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h` -VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` +VER3=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\(\\.[0-9]\{1,\}\)\{1,2\}\).*/\1/p'` +VER1=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\)\\..*/\1/p'` # establish commands for library building if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then @@ -263,7 +264,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then SHAREDLIB=libz$shared_ext SHAREDLIBV=libz.$VER$shared_ext SHAREDLIBM=libz.$VER1$shared_ext - LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"} + LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then AR="${CROSS_PREFIX}libtool" elif libtool -V 2>&1 | grep Apple > /dev/null; then @@ -441,7 +442,7 @@ EOF if test $shared -eq 1; then echo Checking for shared library support... | tee -a configure.log # we must test in two steps (cc then ld), required at least on SunOS 4.x - if try $CC -w -c $SFLAGS $test.c && + if try $CC -c $SFLAGS $test.c && try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log elif test -z "$old_cc" -a -z "$old_cflags"; then diff --git a/zlib/contrib/delphi/ZLib.pas b/zlib/contrib/delphi/ZLib.pas index 814ffa6706a..93fa4c9edb0 100644 --- a/zlib/contrib/delphi/ZLib.pas +++ b/zlib/contrib/delphi/ZLib.pas @@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; const OutBuf: Pointer; BufSize: Integer); const - zlib_version = '1.3.0'; + zlib_version = '1.3.1'; type EZlibError = class(Exception); diff --git a/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs b/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs index c1230bf031f..de88dcf1162 100644 --- a/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +++ b/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs @@ -34,7 +34,7 @@ namespace DotZLib } /// - /// Initializes a new instance of the checksum generator basewith a specified value + /// Initializes a new instance of the checksum generator base with a specified value /// /// The value to set the current checksum to public ChecksumGeneratorBase(uint initialValue) diff --git a/zlib/contrib/dotzlib/DotZLib/UnitTests.cs b/zlib/contrib/dotzlib/DotZLib/UnitTests.cs index c5fce221a36..d4f0980237c 100644 --- a/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +++ b/zlib/contrib/dotzlib/DotZLib/UnitTests.cs @@ -156,7 +156,7 @@ namespace DotZLibTests public void Info_Version() { Info info = new Info(); - Assert.AreEqual("1.3.0", Info.Version); + Assert.AreEqual("1.3.1", Info.Version); Assert.AreEqual(32, info.SizeOfUInt); Assert.AreEqual(32, info.SizeOfULong); Assert.AreEqual(32, info.SizeOfPointer); diff --git a/zlib/contrib/infback9/inftree9.c b/zlib/contrib/infback9/inftree9.c index dc38f24de96..ac707ed3fbd 100644 --- a/zlib/contrib/infback9/inftree9.c +++ b/zlib/contrib/infback9/inftree9.c @@ -1,5 +1,5 @@ /* inftree9.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2023 Mark Adler + * Copyright (C) 1995-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate9_copyright[] = - " inflate9 1.3 Copyright 1995-2023 Mark Adler "; + " inflate9 1.3.1 Copyright 1995-2024 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -59,7 +59,7 @@ int inflate_table9(codetype type, unsigned short FAR *lens, unsigned codes, static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, - 133, 133, 133, 133, 144, 198, 203}; + 133, 133, 133, 133, 144, 203, 77}; static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, diff --git a/zlib/contrib/infback9/inftree9.h b/zlib/contrib/infback9/inftree9.h index 2c1252f57de..ab2ea28b2ba 100644 --- a/zlib/contrib/infback9/inftree9.h +++ b/zlib/contrib/infback9/inftree9.h @@ -41,8 +41,8 @@ typedef struct { examples/enough.c found in the zlib distribution. The arguments to that program are the number of symbols, the initial root table size, and the maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 32 6 15" for distance codes returns 594. - The initial root table size (9 or 6) is found in the fifth argument of the + returns 852, and "enough 32 6 15" for distance codes returns 594. The + initial root table size (9 or 6) is found in the fifth argument of the inflate_table() calls in infback9.c. If the root table size is changed, then these maximum sizes would be need to be recalculated and updated. */ #define ENOUGH_LENS 852 diff --git a/zlib/contrib/iostream3/zfstream.h b/zlib/contrib/iostream3/zfstream.h index 8574479ae1e..3dabc0f97d5 100644 --- a/zlib/contrib/iostream3/zfstream.h +++ b/zlib/contrib/iostream3/zfstream.h @@ -413,7 +413,7 @@ template class gzomanip2 { public: - // Allows insertor to peek at internals + // Allows inserter to peek at internals template friend gzofstream& operator<<(gzofstream&, @@ -452,7 +452,7 @@ template : func(f), val1(v1), val2(v2) { } -// Insertor applies underlying manipulator function to stream +// Inserter applies underlying manipulator function to stream template inline gzofstream& operator<<(gzofstream& s, const gzomanip2& m) diff --git a/zlib/contrib/minizip/Makefile b/zlib/contrib/minizip/Makefile index aac76e07f6b..3d927ec149e 100644 --- a/zlib/contrib/minizip/Makefile +++ b/zlib/contrib/minizip/Makefile @@ -1,4 +1,4 @@ -CC=cc +CC?=cc CFLAGS := $(CFLAGS) -O -I../.. UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a diff --git a/zlib/contrib/minizip/configure.ac b/zlib/contrib/minizip/configure.ac index df80e5b7e13..15ec917189c 100644 --- a/zlib/contrib/minizip/configure.ac +++ b/zlib/contrib/minizip/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([minizip], [1.3.0], [bugzilla.redhat.com]) +AC_INIT([minizip], [1.3.1], [bugzilla.redhat.com]) AC_CONFIG_SRCDIR([minizip.c]) AM_INIT_AUTOMAKE([foreign]) LT_INIT diff --git a/zlib/contrib/minizip/ioapi.h b/zlib/contrib/minizip/ioapi.h index c588a18d034..a2d2e6e60d9 100644 --- a/zlib/contrib/minizip/ioapi.h +++ b/zlib/contrib/minizip/ioapi.h @@ -144,7 +144,7 @@ typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream) typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin); -/* here is the "old" 32 bits structure structure */ +/* here is the "old" 32 bits structure */ typedef struct zlib_filefunc_def_s { open_file_func zopen_file; diff --git a/zlib/contrib/minizip/miniunz.c b/zlib/contrib/minizip/miniunz.c index a12aec8bea2..d627c4226bc 100644 --- a/zlib/contrib/minizip/miniunz.c +++ b/zlib/contrib/minizip/miniunz.c @@ -79,7 +79,7 @@ /* change_file_date : change the date/time of a file filename : the filename of the file where date/time must be modified - dosdate : the new date at the MSDos format (4 bytes) + dosdate : the new date at the MSDOS format (4 bytes) tmu_date : the SAME new date at the tm_unz format */ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) { #ifdef _WIN32 @@ -186,7 +186,7 @@ static int makedir(const char *newdir) { } static void do_banner(void) { - printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); + printf("MiniUnz 1.1, demo of zLib + Unz package written by Gilles Vollant\n"); printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); } @@ -356,6 +356,20 @@ static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_pa else write_filename = filename_withoutpath; + if (write_filename[0]!='\0') + { + const char* relative_check = write_filename; + while (relative_check[1]!='\0') + { + if (relative_check[0]=='.' && relative_check[1]=='.') + write_filename = relative_check; + relative_check++; + } + } + + while (write_filename[0]=='/' || write_filename[0]=='.') + write_filename++; + err = unzOpenCurrentFilePassword(uf,password); if (err!=UNZ_OK) { diff --git a/zlib/contrib/minizip/unzip.c b/zlib/contrib/minizip/unzip.c index ed763f89f1f..ea05b7d62a0 100644 --- a/zlib/contrib/minizip/unzip.c +++ b/zlib/contrib/minizip/unzip.c @@ -117,7 +117,7 @@ const char unz_copyright[] = " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; -/* unz_file_info_interntal contain internal info about a file in zipfile*/ +/* unz_file_info64_internal contain internal info about a file in zipfile*/ typedef struct unz_file_info64_internal_s { ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */ @@ -450,7 +450,7 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) return CENTRALDIRINVALID; - /* number of the disk with the start of the zip64 end of central directory */ + /* number of the disk with the start of the zip64 end of central directory */ if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) return CENTRALDIRINVALID; if (uL != 0) @@ -497,9 +497,9 @@ local unzFile unzOpenInternal(const void *path, ZPOS64_T central_pos; uLong uL; - uLong number_disk; /* number of the current dist, used for + uLong number_disk; /* number of the current disk, used for spanning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used + uLong number_disk_with_CD; /* number the disk with central dir, used for spanning ZIP, unsupported, always 0*/ ZPOS64_T number_entry_CD; /* total number of entries in the central dir diff --git a/zlib/contrib/minizip/unzip.h b/zlib/contrib/minizip/unzip.h index 14105840f6d..5cfc9c6274e 100644 --- a/zlib/contrib/minizip/unzip.h +++ b/zlib/contrib/minizip/unzip.h @@ -306,7 +306,7 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain some info about the current file - if szFileName!=NULL, the filemane string will be copied in szFileName + if szFileName!=NULL, the filename string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). diff --git a/zlib/contrib/minizip/zip.c b/zlib/contrib/minizip/zip.c index 3d3d4caddef..60bdffac348 100644 --- a/zlib/contrib/minizip/zip.c +++ b/zlib/contrib/minizip/zip.c @@ -575,7 +575,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) return 0; - /* number of the disk with the start of the zip64 end of central directory */ + /* number of the disk with the start of the zip64 end of central directory */ if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) return 0; if (uL != 0) @@ -614,9 +614,9 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { ZPOS64_T central_pos; uLong uL; - uLong number_disk; /* number of the current dist, used for + uLong number_disk; /* number of the current disk, used for spanning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used + uLong number_disk_with_CD; /* number of the disk with central dir, used for spanning ZIP, unsupported, always 0*/ ZPOS64_T number_entry; ZPOS64_T number_entry_CD; /* total number of entries in @@ -1043,6 +1043,17 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c return ZIP_PARAMERROR; #endif + // The filename and comment length must fit in 16 bits. + if ((filename!=NULL) && (strlen(filename)>0xffff)) + return ZIP_PARAMERROR; + if ((comment!=NULL) && (strlen(comment)>0xffff)) + return ZIP_PARAMERROR; + // The extra field length must fit in 16 bits. If the member also requires + // a Zip64 extra block, that will also need to fit within that 16-bit + // length, but that will be checked for later. + if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff)) + return ZIP_PARAMERROR; + zi = (zip64_internal*)file; if (zi->in_opened_file_inzip == 1) @@ -1597,7 +1608,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree) { - // we can not write more data to the buffer that we have room for. + // we cannot write more data to the buffer that we have room for. return ZIP_BADZIPFILE; } @@ -1861,7 +1872,7 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) { free_linkedlist(&(zi->central_dir)); pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; - if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) + if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF) { ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); diff --git a/zlib/contrib/minizip/zip.h b/zlib/contrib/minizip/zip.h index 5fc08413241..3e230d3405f 100644 --- a/zlib/contrib/minizip/zip.h +++ b/zlib/contrib/minizip/zip.h @@ -177,9 +177,9 @@ extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, filename : the filename in zip (if NULL, '-' without quote will be used *zipfi contain supplemental information if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local - contains the extrafield data the the local header + contains the extrafield data for the local header if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global - contains the extrafield data the the local header + contains the extrafield data for the global header if comment != NULL, comment contain the comment string method contain the compression method (0 for store, Z_DEFLATED for deflate) level contain the level of compression (can be Z_DEFAULT_COMPRESSION) diff --git a/zlib/contrib/nuget/nuget.csproj b/zlib/contrib/nuget/nuget.csproj new file mode 100644 index 00000000000..68627f034aa --- /dev/null +++ b/zlib/contrib/nuget/nuget.csproj @@ -0,0 +1,43 @@ + + + + net6.0 + madler.zlib.redist + $(PackageId).win + $(PackageId).linux + $(PackageId).osx + (C) 1995-2024 Jean-loup Gailly and Mark Adler + 1.3.1 + NuGet Package for consuming native builds of zlib into .NET without complexity. + + NU5128 + $(MSBuildProjectDirectory) + Jean-loup Gailly and Mark Adler + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zlib/contrib/nuget/nuget.sln b/zlib/contrib/nuget/nuget.sln new file mode 100644 index 00000000000..46ee8deab8f --- /dev/null +++ b/zlib/contrib/nuget/nuget.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nuget", "nuget.csproj", "{B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1BD3984-EF8F-4E9D-9A94-EB784E5EB1E8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/zlib/contrib/pascal/zlibpas.pas b/zlib/contrib/pascal/zlibpas.pas index a2b24a593fa..0cf0e7b82dc 100644 --- a/zlib/contrib/pascal/zlibpas.pas +++ b/zlib/contrib/pascal/zlibpas.pas @@ -10,7 +10,7 @@ unit zlibpas; interface const - ZLIB_VERSION = '1.3.0'; + ZLIB_VERSION = '1.3.1'; ZLIB_VERNUM = $12a0; type diff --git a/zlib/contrib/puff/puff.c b/zlib/contrib/puff/puff.c index 6737ff6153f..d759825ab1d 100644 --- a/zlib/contrib/puff/puff.c +++ b/zlib/contrib/puff/puff.c @@ -593,10 +593,10 @@ local int fixed(struct state *s) * provided for each of the literal/length symbols, and for each of the * distance symbols. * - * - If a symbol is not used in the block, this is represented by a zero as - * as the code length. This does not mean a zero-length code, but rather - * that no code should be created for this symbol. There is no way in the - * deflate format to represent a zero-length code. + * - If a symbol is not used in the block, this is represented by a zero as the + * code length. This does not mean a zero-length code, but rather that no + * code should be created for this symbol. There is no way in the deflate + * format to represent a zero-length code. * * - The maximum number of bits in a code is 15, so the possible lengths for * any code are 1..15. diff --git a/zlib/contrib/vstudio/readme.txt b/zlib/contrib/vstudio/readme.txt index 05ba487c941..061bbc0e2d7 100644 --- a/zlib/contrib/vstudio/readme.txt +++ b/zlib/contrib/vstudio/readme.txt @@ -1,75 +1,81 @@ -Building instructions for the DLL versions of Zlib 1.3.0 -======================================================== - -This directory contains projects that build zlib and minizip using -Microsoft Visual C++ 9.0/10.0. - -You don't need to build these projects yourself. You can download the -binaries from: - http://www.winimage.com/zLibDll - -More information can be found at this site. - - - - - -Build instructions for Visual Studio 2008 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008 -- Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32" - -Build instructions for Visual Studio 2010 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc10\zlibvc.sln with Microsoft Visual C++ 2010 - -Build instructions for Visual Studio 2012 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc11\zlibvc.sln with Microsoft Visual C++ 2012 - -Build instructions for Visual Studio 2013 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc12\zlibvc.sln with Microsoft Visual C++ 2013 - -Build instructions for Visual Studio 2015 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc14\zlibvc.sln with Microsoft Visual C++ 2015 - - -Important ---------- -- To use zlibwapi.dll in your application, you must define the - macro ZLIB_WINAPI when compiling your application's source files. - - -Additional notes ----------------- -- This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built - by Gilles Vollant from the zlib 1.1.x sources, and distributed at - http://www.winimage.com/zLibDll - It uses the WINAPI calling convention for the exported functions, and - includes the minizip functionality. If your application needs that - particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll. - -- The new DLL was renamed because there exist several incompatible - versions of zlib.dll on the Internet. - -- There is also an official DLL build of zlib, named zlib1.dll. This one - is exporting the functions using the CDECL convention. See the file - win32\DLL_FAQ.txt found in this zlib distribution. - -- There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol - has a slightly different effect. To avoid compatibility problems, do - not define it here. - - -Gilles Vollant -info@winimage.com - -Visual Studio 2013 and 2015 Projects from Sean Hunt -seandhunt_7@yahoo.com +Building instructions for the DLL versions of Zlib 1.3.1 +======================================================== + +This directory contains projects that build zlib and minizip using +Microsoft Visual C++ 9.0/10.0. + +You don't need to build these projects yourself. You can download the +binaries from: + http://www.winimage.com/zLibDll + +More information can be found at this site. + + + + + +Build instructions for Visual Studio 2008 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008 +- Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32" + +Build instructions for Visual Studio 2010 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc10\zlibvc.sln with Microsoft Visual C++ 2010 + +Build instructions for Visual Studio 2012 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc11\zlibvc.sln with Microsoft Visual C++ 2012 + +Build instructions for Visual Studio 2013 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc12\zlibvc.sln with Microsoft Visual C++ 2013 + +Build instructions for Visual Studio 2015 (32 bits or 64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc14\zlibvc.sln with Microsoft Visual C++ 2015 + +Build instructions for Visual Studio 2022 (64 bits) +-------------------------------------------------------------- +- Decompress current zlib, including all contrib/* files +- Open contrib\vstudio\vc143\zlibvc.sln with Microsoft Visual C++ 2022 + + + +Important +--------- +- To use zlibwapi.dll in your application, you must define the + macro ZLIB_WINAPI when compiling your application's source files. + + +Additional notes +---------------- +- This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built + by Gilles Vollant from the zlib 1.1.x sources, and distributed at + http://www.winimage.com/zLibDll + It uses the WINAPI calling convention for the exported functions, and + includes the minizip functionality. If your application needs that + particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll. + +- The new DLL was renamed because there exist several incompatible + versions of zlib.dll on the Internet. + +- There is also an official DLL build of zlib, named zlib1.dll. This one + is exporting the functions using the CDECL convention. See the file + win32\DLL_FAQ.txt found in this zlib distribution. + +- There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol + has a slightly different effect. To avoid compatibility problems, do + not define it here. + + +Gilles Vollant +info@winimage.com + +Visual Studio 2013, 2015, and 2022 Projects from Sean Hunt +seandhunt_7@yahoo.com diff --git a/zlib/contrib/vstudio/vc10/zlib.rc b/zlib/contrib/vstudio/vc10/zlib.rc index 29af8e11acc..856bd11f08d 100644 --- a/zlib/contrib/vstudio/vc10/zlib.rc +++ b/zlib/contrib/vstudio/vc10/zlib.rc @@ -2,8 +2,8 @@ #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 3, 0, 0 - PRODUCTVERSION 1, 3, 0, 0 + FILEVERSION 1, 3, 1, 0 + PRODUCTVERSION 1, 3, 1, 0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 @@ -17,12 +17,12 @@ BEGIN BEGIN VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.3.0\0" + VALUE "FileVersion", "1.3.1\0" VALUE "InternalName", "zlib\0" VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" + VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" END END BLOCK "VarFileInfo" diff --git a/zlib/contrib/vstudio/vc10/zlibvc.def b/zlib/contrib/vstudio/vc10/zlibvc.def index f28aa6c73bc..3234a02d953 100644 --- a/zlib/contrib/vstudio/vc10/zlibvc.def +++ b/zlib/contrib/vstudio/vc10/zlibvc.def @@ -1,7 +1,7 @@ LIBRARY ; zlib data compression and ZIP file I/O library -VERSION 1.3 +VERSION 1.3.1 EXPORTS adler32 @1 diff --git a/zlib/contrib/vstudio/vc11/zlib.rc b/zlib/contrib/vstudio/vc11/zlib.rc index 29af8e11acc..856bd11f08d 100644 --- a/zlib/contrib/vstudio/vc11/zlib.rc +++ b/zlib/contrib/vstudio/vc11/zlib.rc @@ -2,8 +2,8 @@ #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 3, 0, 0 - PRODUCTVERSION 1, 3, 0, 0 + FILEVERSION 1, 3, 1, 0 + PRODUCTVERSION 1, 3, 1, 0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 @@ -17,12 +17,12 @@ BEGIN BEGIN VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.3.0\0" + VALUE "FileVersion", "1.3.1\0" VALUE "InternalName", "zlib\0" VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" + VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" END END BLOCK "VarFileInfo" diff --git a/zlib/contrib/vstudio/vc11/zlibvc.def b/zlib/contrib/vstudio/vc11/zlibvc.def index f28aa6c73bc..3234a02d953 100644 --- a/zlib/contrib/vstudio/vc11/zlibvc.def +++ b/zlib/contrib/vstudio/vc11/zlibvc.def @@ -1,7 +1,7 @@ LIBRARY ; zlib data compression and ZIP file I/O library -VERSION 1.3 +VERSION 1.3.1 EXPORTS adler32 @1 diff --git a/zlib/contrib/vstudio/vc12/zlib.rc b/zlib/contrib/vstudio/vc12/zlib.rc index 57fb31a3216..a55f341c74c 100644 --- a/zlib/contrib/vstudio/vc12/zlib.rc +++ b/zlib/contrib/vstudio/vc12/zlib.rc @@ -2,8 +2,8 @@ #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 3, 0, 0 - PRODUCTVERSION 1, 3, 0, 0 + FILEVERSION 1, 3, 1, 0 + PRODUCTVERSION 1, 3, 1, 0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 @@ -17,12 +17,12 @@ BEGIN BEGIN VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.3.0\0" + VALUE "FileVersion", "1.3.1\0" VALUE "InternalName", "zlib\0" VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" + VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" END END BLOCK "VarFileInfo" diff --git a/zlib/contrib/vstudio/vc12/zlibvc.def b/zlib/contrib/vstudio/vc12/zlibvc.def index f28aa6c73bc..3234a02d953 100644 --- a/zlib/contrib/vstudio/vc12/zlibvc.def +++ b/zlib/contrib/vstudio/vc12/zlibvc.def @@ -1,7 +1,7 @@ LIBRARY ; zlib data compression and ZIP file I/O library -VERSION 1.3 +VERSION 1.3.1 EXPORTS adler32 @1 diff --git a/zlib/contrib/vstudio/vc14/zlib.rc b/zlib/contrib/vstudio/vc14/zlib.rc index 57fb31a3216..a55f341c74c 100644 --- a/zlib/contrib/vstudio/vc14/zlib.rc +++ b/zlib/contrib/vstudio/vc14/zlib.rc @@ -2,8 +2,8 @@ #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 3, 0, 0 - PRODUCTVERSION 1, 3, 0, 0 + FILEVERSION 1, 3, 1, 0 + PRODUCTVERSION 1, 3, 1, 0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 @@ -17,12 +17,12 @@ BEGIN BEGIN VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.3.0\0" + VALUE "FileVersion", "1.3.1\0" VALUE "InternalName", "zlib\0" VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" + VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" END END BLOCK "VarFileInfo" diff --git a/zlib/contrib/vstudio/vc14/zlibvc.def b/zlib/contrib/vstudio/vc14/zlibvc.def index f28aa6c73bc..3234a02d953 100644 --- a/zlib/contrib/vstudio/vc14/zlibvc.def +++ b/zlib/contrib/vstudio/vc14/zlibvc.def @@ -1,7 +1,7 @@ LIBRARY ; zlib data compression and ZIP file I/O library -VERSION 1.3 +VERSION 1.3.1 EXPORTS adler32 @1 diff --git a/zlib/contrib/vstudio/vc17/miniunz.vcxproj b/zlib/contrib/vstudio/vc17/miniunz.vcxproj new file mode 100644 index 00000000000..68ef16588b2 --- /dev/null +++ b/zlib/contrib/vstudio/vc17/miniunz.vcxproj @@ -0,0 +1,409 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694382A} + Win32Proj + 10.0 + + + + Application + MultiByte + v143 + + + Application + Unicode + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + true + false + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + true + true + true + false + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + false + false + false + false + false + false + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + + + arm64\MiniUnzip$(Configuration)\ + arm64\MiniUnzip$(Configuration)\Tmp\ + + + arm64\MiniUnzip$(Configuration)\ + arm64\MiniUnzip$(Configuration)\Tmp\ + + + arm\MiniUnzip$(Configuration)\ + arm\MiniUnzip$(Configuration)\Tmp\ + + + arm\MiniUnzip$(Configuration)\ + arm\MiniUnzip$(Configuration)\Tmp\ + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineX64 + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineX64 + + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/zlib/contrib/vstudio/vc17/minizip.vcxproj b/zlib/contrib/vstudio/vc17/minizip.vcxproj new file mode 100644 index 00000000000..dd3c52e70c9 --- /dev/null +++ b/zlib/contrib/vstudio/vc17/minizip.vcxproj @@ -0,0 +1,405 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} + Win32Proj + 10.0 + + + + Application + MultiByte + v143 + + + Application + Unicode + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + true + false + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + false + x64\$(Configuration)\ + x64\$(Configuration)\ + true + true + true + false + false + false + x64\$(Configuration)\ + x64\$(Configuration)\ + false + false + false + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + + + arm64\MiniZip$(Configuration)\ + arm64\MiniZip$(Configuration)\Tmp\ + + + arm64\MiniZip$(Configuration)\ + arm64\MiniZip$(Configuration)\Tmp\ + + + arm\MiniZip$(Configuration)\ + arm\MiniZip$(Configuration)\Tmp\ + + + arm\MiniZip$(Configuration)\ + arm\MiniZip$(Configuration)\Tmp\ + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineX64 + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineX64 + + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/zlib/contrib/vstudio/vc17/testzlib.vcxproj b/zlib/contrib/vstudio/vc17/testzlib.vcxproj new file mode 100644 index 00000000000..4cc99b3ffe1 --- /dev/null +++ b/zlib/contrib/vstudio/vc17/testzlib.vcxproj @@ -0,0 +1,473 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + ARM + + + ReleaseWithoutAsm + ARM64 + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} + testzlib + Win32Proj + 10.0 + + + + Application + MultiByte + true + v143 + + + Application + MultiByte + true + v143 + + + Application + Unicode + v143 + + + Application + true + v143 + + + Application + true + v143 + + + Application + true + v143 + + + Application + true + v143 + + + Application + true + v143 + + + Application + true + v143 + + + Application + v143 + + + Application + v143 + + + Application + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + true + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + false + false + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + + + arm64\TestZlib$(Configuration)\ + arm64\TestZlib$(Configuration)\Tmp\ + + + arm64\TestZlib$(Configuration)\ + arm64\TestZlib$(Configuration)\Tmp\ + + + arm64\TestZlib$(Configuration)\ + arm64\TestZlib$(Configuration)\Tmp\ + + + arm\TestZlib$(Configuration)\ + arm\TestZlib$(Configuration)\Tmp\ + + + arm\TestZlib$(Configuration)\ + arm\TestZlib$(Configuration)\Tmp\ + + + arm\TestZlib$(Configuration)\ + arm\TestZlib$(Configuration)\Tmp\ + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + %(AdditionalDependencies) + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + %(AdditionalDependencies) + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + false + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zlib/contrib/vstudio/vc17/testzlibdll.vcxproj b/zlib/contrib/vstudio/vc17/testzlibdll.vcxproj new file mode 100644 index 00000000000..73bba55da80 --- /dev/null +++ b/zlib/contrib/vstudio/vc17/testzlibdll.vcxproj @@ -0,0 +1,409 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694366A} + Win32Proj + 10.0 + + + + Application + MultiByte + v143 + + + Application + Unicode + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + Application + MultiByte + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + true + false + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + true + true + true + false + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + false + false + false + false + false + false + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + + + arm64\TestZlibDll$(Configuration)\ + arm64\TestZlibDll$(Configuration)\Tmp\ + + + arm64\TestZlibDll$(Configuration)\ + arm64\TestZlibDll$(Configuration)\Tmp\ + + + arm\TestZlibDll$(Configuration)\ + arm\TestZlibDll$(Configuration)\Tmp\ + + + arm\TestZlibDll$(Configuration)\ + arm\TestZlibDll$(Configuration)\Tmp\ + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineX64 + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineX64 + + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/zlib/contrib/vstudio/vc17/zlib.rc b/zlib/contrib/vstudio/vc17/zlib.rc new file mode 100644 index 00000000000..a55f341c74c --- /dev/null +++ b/zlib/contrib/vstudio/vc17/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 3, 1, 0 + PRODUCTVERSION 1, 3, 1, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.3.1\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/zlib/contrib/vstudio/vc17/zlibstat.vcxproj b/zlib/contrib/vstudio/vc17/zlibstat.vcxproj new file mode 100644 index 00000000000..b946ac2a90f --- /dev/null +++ b/zlib/contrib/vstudio/vc17/zlibstat.vcxproj @@ -0,0 +1,602 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + ARM + + + ReleaseWithoutAsm + ARM64 + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + 10.0 + + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + Unicode + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + StaticLibrary + false + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + + + arm64\ZlibStat$(Configuration)\ + arm64\ZlibStat$(Configuration)\Tmp\ + + + arm64\ZlibStat$(Configuration)\ + arm64\ZlibStat$(Configuration)\Tmp\ + + + arm64\ZlibStat$(Configuration)\ + arm64\ZlibStat$(Configuration)\Tmp\ + + + arm\ZlibStat$(Configuration)\ + arm\ZlibStat$(Configuration)\Tmp\ + + + arm\ZlibStat$(Configuration)\ + arm\ZlibStat$(Configuration)\Tmp\ + + + arm\ZlibStat$(Configuration)\ + arm\ZlibStat$(Configuration)\Tmp\ + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + %(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:ARM64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:ARM /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + %(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:ARM64 /NODEFAULTLIB %(AdditionalOptions) + %(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:ARM /NODEFAULTLIB %(AdditionalOptions) + %(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:ARM64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:ARM /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zlib/contrib/vstudio/vc17/zlibvc.def b/zlib/contrib/vstudio/vc17/zlibvc.def new file mode 100644 index 00000000000..53947cc31b7 --- /dev/null +++ b/zlib/contrib/vstudio/vc17/zlibvc.def @@ -0,0 +1,158 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.3.1 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 + +; zlib1 v1.2.12 added: + crc32_combine_gen @176 + crc32_combine_gen64 @177 + crc32_combine_op @178 diff --git a/zlib/contrib/vstudio/vc17/zlibvc.sln b/zlib/contrib/vstudio/vc17/zlibvc.sln new file mode 100644 index 00000000000..67896b7470d --- /dev/null +++ b/zlib/contrib/vstudio/vc17/zlibvc.sln @@ -0,0 +1,179 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33015.44 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|ARM = ReleaseWithoutAsm|ARM + ReleaseWithoutAsm|ARM64 = ReleaseWithoutAsm|ARM64 + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|ARM.ActiveCfg = Debug|ARM + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|ARM.Build.0 = Debug|ARM + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|ARM64.Build.0 = Debug|ARM64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|ARM.ActiveCfg = Release|ARM + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|ARM.Build.0 = Release|ARM + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|ARM64.ActiveCfg = Release|ARM64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|ARM64.Build.0 = Release|ARM64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|ARM.ActiveCfg = ReleaseWithoutAsm|ARM + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|ARM.Build.0 = ReleaseWithoutAsm|ARM + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|ARM64.ActiveCfg = ReleaseWithoutAsm|ARM64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|ARM64.Build.0 = ReleaseWithoutAsm|ARM64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|ARM.ActiveCfg = Debug|ARM + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|ARM.Build.0 = Debug|ARM + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|ARM64.Build.0 = Debug|ARM64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|ARM.ActiveCfg = Release|ARM + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|ARM.Build.0 = Release|ARM + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|ARM64.ActiveCfg = Release|ARM64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|ARM64.Build.0 = Release|ARM64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|ARM.ActiveCfg = ReleaseWithoutAsm|ARM + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|ARM.Build.0 = ReleaseWithoutAsm|ARM + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|ARM64.ActiveCfg = ReleaseWithoutAsm|ARM64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|ARM64.Build.0 = ReleaseWithoutAsm|ARM64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|ARM.ActiveCfg = Debug|ARM + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|ARM.Build.0 = Debug|ARM + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|ARM64.Build.0 = Debug|ARM64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|ARM.ActiveCfg = Release|ARM + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|ARM.Build.0 = Release|ARM + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|ARM64.ActiveCfg = Release|ARM64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|ARM64.Build.0 = Release|ARM64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|ARM.ActiveCfg = ReleaseWithoutAsm|ARM + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|ARM.Build.0 = ReleaseWithoutAsm|ARM + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|ARM64.ActiveCfg = ReleaseWithoutAsm|ARM64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|ARM64.Build.0 = ReleaseWithoutAsm|ARM64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|ARM.ActiveCfg = Debug|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|ARM.Build.0 = Debug|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|ARM64.Build.0 = Debug|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|ARM.ActiveCfg = Release|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|ARM.Build.0 = Release|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|ARM64.ActiveCfg = Release|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|ARM64.Build.0 = Release|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|ARM.ActiveCfg = Release|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|ARM.Build.0 = Release|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|ARM64.ActiveCfg = Release|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|ARM64.Build.0 = Release|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|ARM.ActiveCfg = Debug|ARM + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|ARM.Build.0 = Debug|ARM + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|ARM64.Build.0 = Debug|ARM64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|ARM.ActiveCfg = Release|ARM + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|ARM.Build.0 = Release|ARM + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|ARM64.ActiveCfg = Release|ARM64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|ARM64.Build.0 = Release|ARM64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|ARM.ActiveCfg = Release|ARM + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|ARM.Build.0 = Release|ARM + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|ARM64.ActiveCfg = Release|ARM64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|ARM64.Build.0 = Release|ARM64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|ARM.ActiveCfg = Debug|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|ARM.Build.0 = Debug|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|ARM64.Build.0 = Debug|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|ARM.ActiveCfg = Release|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|ARM.Build.0 = Release|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|ARM64.ActiveCfg = Release|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|ARM64.Build.0 = Release|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|ARM.ActiveCfg = Release|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|ARM.Build.0 = Release|ARM + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|ARM64.ActiveCfg = Release|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|ARM64.Build.0 = Release|ARM64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EAA58685-56D9-43F2-8703-FD2CB020745E} + EndGlobalSection +EndGlobal diff --git a/zlib/contrib/vstudio/vc17/zlibvc.vcxproj b/zlib/contrib/vstudio/vc17/zlibvc.vcxproj new file mode 100644 index 00000000000..10a7a901efe --- /dev/null +++ b/zlib/contrib/vstudio/vc17/zlibvc.vcxproj @@ -0,0 +1,875 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + ARM + + + ReleaseWithoutAsm + ARM64 + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {8FD826F8-3739-44E6-8CC8-997122E53B8D} + 10.0 + + + + DynamicLibrary + false + true + v143 + + + DynamicLibrary + false + true + v143 + + + DynamicLibrary + false + v143 + Unicode + + + DynamicLibrary + false + true + v143 + + + DynamicLibrary + false + true + v143 + + + DynamicLibrary + false + true + v143 + + + DynamicLibrary + false + true + v143 + + + DynamicLibrary + false + true + v143 + + + DynamicLibrary + false + true + v143 + + + DynamicLibrary + false + v143 + + + DynamicLibrary + false + v143 + + + DynamicLibrary + false + v143 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + true + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + true + true + true + false + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + false + false + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + false + false + false + false + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + AllRules.ruleset + + + AllRules.ruleset + AllRules.ruleset + AllRules.ruleset + + + + + + + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + + + arm64\ZlibDll$(Configuration)\ + arm64\ZlibDll$(Configuration)\Tmp\ + + + arm\ZlibDll$(Configuration)\ + arm\ZlibDll$(Configuration)\Tmp\ + + + arm64\ZlibDll$(Configuration)\ + arm64\ZlibDll$(Configuration)\Tmp\ + + + arm64\ZlibDll$(Configuration)\ + arm64\ZlibDll$(Configuration)\Tmp\ + + + arm\ZlibDll$(Configuration)\ + arm\ZlibDll$(Configuration)\Tmp\ + + + arm\ZlibDll$(Configuration)\ + arm\ZlibDll$(Configuration)\Tmp\ + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + %(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + %(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + false + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + %(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + %(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + %(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + %(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + %(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN32;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + %(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + + + + + + + + + + + + + + + + + + + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zlib/contrib/vstudio/vc9/zlib.rc b/zlib/contrib/vstudio/vc9/zlib.rc index 29af8e11acc..856bd11f08d 100644 --- a/zlib/contrib/vstudio/vc9/zlib.rc +++ b/zlib/contrib/vstudio/vc9/zlib.rc @@ -2,8 +2,8 @@ #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 3, 0, 0 - PRODUCTVERSION 1, 3, 0, 0 + FILEVERSION 1, 3, 1, 0 + PRODUCTVERSION 1, 3, 1, 0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 @@ -17,12 +17,12 @@ BEGIN BEGIN VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.3.0\0" + VALUE "FileVersion", "1.3.1\0" VALUE "InternalName", "zlib\0" VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" + VALUE "LegalCopyright", "(C) 1995-2024 Jean-loup Gailly & Mark Adler\0" END END BLOCK "VarFileInfo" diff --git a/zlib/contrib/vstudio/vc9/zlibvc.def b/zlib/contrib/vstudio/vc9/zlibvc.def index f28aa6c73bc..3234a02d953 100644 --- a/zlib/contrib/vstudio/vc9/zlibvc.def +++ b/zlib/contrib/vstudio/vc9/zlibvc.def @@ -1,7 +1,7 @@ LIBRARY ; zlib data compression and ZIP file I/O library -VERSION 1.3 +VERSION 1.3.1 EXPORTS adler32 @1 diff --git a/zlib/deflate.c b/zlib/deflate.c index bd011751920..012ea8148e8 100644 --- a/zlib/deflate.c +++ b/zlib/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.3 Copyright 1995-2023 Jean-loup Gailly and Mark Adler "; + " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -493,7 +493,7 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, * symbols from which it is being constructed. */ - s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4); + s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS); s->pending_buf_size = (ulg)s->lit_bufsize * 4; if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || @@ -503,8 +503,14 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, deflateEnd (strm); return Z_MEM_ERROR; } +#ifdef LIT_MEM + s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1)); + s->l_buf = s->pending_buf + (s->lit_bufsize << 2); + s->sym_end = s->lit_bufsize - 1; +#else s->sym_buf = s->pending_buf + s->lit_bufsize; s->sym_end = (s->lit_bufsize - 1) * 3; +#endif /* We avoid equality with lit_bufsize*3 because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. @@ -720,9 +726,15 @@ int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; +#ifdef LIT_MEM + if (bits < 0 || bits > 16 || + (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3)) + return Z_BUF_ERROR; +#else if (bits < 0 || bits > 16 || s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; +#endif do { put = Buf_size - s->bi_valid; if (put > bits) @@ -1294,7 +1306,7 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4); + ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS); if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { @@ -1305,10 +1317,15 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); +#ifdef LIT_MEM + ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1)); + ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2); +#else ds->sym_buf = ds->pending_buf + ds->lit_bufsize; +#endif ds->l_desc.dyn_tree = ds->dyn_ltree; ds->d_desc.dyn_tree = ds->dyn_dtree; @@ -1539,13 +1556,21 @@ local uInt longest_match(deflate_state *s, IPos cur_match) { */ local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); + Bytef *back = s->window + (int)match, *here = s->window + start; + IPos len = length; + if (match == (IPos)-1) { + /* match starts one byte before the current window -- just compare the + subsequent length-1 bytes */ + back++; + here++; + len--; + } + if (zmemcmp(back, here, len) != EQUAL) { + fprintf(stderr, " start %u, match %d, length %d\n", + start, (int)match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); + fprintf(stderr, "(%02x %02x)", *back++, *here++); + } while (--len != 0); z_error("invalid match"); } if (z_verbose > 1) { diff --git a/zlib/deflate.h b/zlib/deflate.h index 8696791429f..300c6ada62b 100644 --- a/zlib/deflate.h +++ b/zlib/deflate.h @@ -1,5 +1,5 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2018 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -23,6 +23,10 @@ # define GZIP #endif +/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at + the cost of a larger memory footprint */ +/* #define LIT_MEM */ + /* =========================================================================== * Internal compression state. */ @@ -217,7 +221,14 @@ typedef struct internal_state { /* Depth of each subtree used as tie breaker for trees of equal frequency */ +#ifdef LIT_MEM +# define LIT_BUFS 5 + ushf *d_buf; /* buffer for distances */ + uchf *l_buf; /* buffer for literals/lengths */ +#else +# define LIT_BUFS 4 uchf *sym_buf; /* buffer for distances and literals/lengths */ +#endif uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for @@ -239,7 +250,7 @@ typedef struct internal_state { * - I can't count above 4 */ - uInt sym_next; /* running index in sym_buf */ + uInt sym_next; /* running index in symbol buffer */ uInt sym_end; /* symbol table full when sym_next reaches this */ ulg opt_len; /* bit length of current block with optimal trees */ @@ -318,6 +329,25 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, extern const uch ZLIB_INTERNAL _dist_code[]; #endif +#ifdef LIT_MEM +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->sym_next] = 0; \ + s->l_buf[s->sym_next++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ + s->d_buf[s->sym_next] = dist; \ + s->l_buf[s->sym_next++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +#else # define _tr_tally_lit(s, c, flush) \ { uch cc = (c); \ s->sym_buf[s->sym_next++] = 0; \ @@ -337,6 +367,7 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, s->dyn_dtree[d_code(dist)].Freq++; \ flush = (s->sym_next == s->sym_end); \ } +#endif #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) # define _tr_tally_dist(s, distance, length, flush) \ diff --git a/zlib/doc/algorithm.txt b/zlib/doc/algorithm.txt index c97f495020b..029e5a31349 100644 --- a/zlib/doc/algorithm.txt +++ b/zlib/doc/algorithm.txt @@ -77,7 +77,7 @@ table took no time (and if you had infinite memory), then there would only be a first level table to cover all the way to the longest code. However, building the table ends up taking a lot longer for more bits since short codes are replicated many times in such a table. What inflate() does is -simply to make the number of bits in the first table a variable, and then +simply to make the number of bits in the first table a variable, and then to set that variable for the maximum speed. For inflate, which has 286 possible codes for the literal/length tree, the size diff --git a/zlib/examples/gzlog.c b/zlib/examples/gzlog.c index b977802dd6e..da1b02e7337 100644 --- a/zlib/examples/gzlog.c +++ b/zlib/examples/gzlog.c @@ -212,8 +212,8 @@ to the appropriate recovery below. If there is no foo.add file, provide a zero data length to the recovery. In that case, the append recovery restores the foo.gz to the previous compressed + uncompressed data state. - For the the compress recovery, a missing foo.add file results in foo.gz - being restored to the previous compressed-only data state. + For the compress recovery, a missing foo.add file results in foo.gz being + restored to the previous compressed-only data state. - Append recovery: - Pick up append at + step above - Compress recovery: diff --git a/zlib/examples/zran.c b/zlib/examples/zran.c index 32c93686c60..d3135955b02 100644 --- a/zlib/examples/zran.c +++ b/zlib/examples/zran.c @@ -267,7 +267,7 @@ static inline void append_bits(unsigned value, int bits, } } -// Insert enough bits in the form of empty deflate blocks in front of the the +// Insert enough bits in the form of empty deflate blocks in front of the // low bits bits of value, in order to bring the sequence to a byte boundary. // Then feed that to inflate(). This does what inflatePrime() does, except that // a negative value of bits is not supported. bits must be in 0..16. If the diff --git a/zlib/gzguts.h b/zlib/gzguts.h index f9375047e8c..eba72085bb7 100644 --- a/zlib/gzguts.h +++ b/zlib/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -210,9 +210,5 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error); /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t value -- needed when comparing unsigned to z_off64_t, which is signed (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else unsigned ZLIB_INTERNAL gz_intmax(void); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) diff --git a/zlib/gzlib.c b/zlib/gzlib.c index 29fc4486fba..983153cc8e4 100644 --- a/zlib/gzlib.c +++ b/zlib/gzlib.c @@ -1,5 +1,5 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -563,20 +563,20 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { #endif } -#ifndef INT_MAX /* portably return maximum value for an int (when limits.h presumed not available) -- we need to do this to cover cases where 2's complement not used, since C standard permits 1's complement and sign-bit representations, otherwise we could just use ((unsigned)-1) >> 1 */ unsigned ZLIB_INTERNAL gz_intmax(void) { - unsigned p, q; - - p = 1; +#ifdef INT_MAX + return INT_MAX; +#else + unsigned p = 1, q; do { q = p; p <<= 1; p++; } while (p > q); return q >> 1; -} #endif +} diff --git a/zlib/inflate.c b/zlib/inflate.c index b0757a9b249..94ecff015a9 100644 --- a/zlib/inflate.c +++ b/zlib/inflate.c @@ -1387,7 +1387,7 @@ int ZEXPORT inflateSync(z_streamp strm) { /* if first time, start search in bit buffer */ if (state->mode != SYNC) { state->mode = SYNC; - state->hold <<= state->bits & 7; + state->hold >>= state->bits & 7; state->bits -= state->bits & 7; len = 0; while (state->bits >= 8) { diff --git a/zlib/inftrees.c b/zlib/inftrees.c index 8a208c2daa8..98cfe164458 100644 --- a/zlib/inftrees.c +++ b/zlib/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2023 Mark Adler + * Copyright (C) 1995-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.3 Copyright 1995-2023 Mark Adler "; + " inflate 1.3.1 Copyright 1995-2024 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -57,7 +57,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, diff --git a/zlib/inftrees.h b/zlib/inftrees.h index a10712d8cb5..396f74b5da7 100644 --- a/zlib/inftrees.h +++ b/zlib/inftrees.h @@ -41,8 +41,8 @@ typedef struct { examples/enough.c found in the zlib distribution. The arguments to that program are the number of symbols, the initial root table size, and the maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the + returns 852, and "enough 30 6 15" for distance codes returns 592. The + initial root table size (9 or 6) is found in the fifth argument of the inflate_table() calls in inflate.c and infback.c. If the root table size is changed, then these maximum sizes would be need to be recalculated and updated. */ diff --git a/zlib/old/visual-basic.txt b/zlib/old/visual-basic.txt index 57efe58124e..3c8d2a42dfc 100644 --- a/zlib/old/visual-basic.txt +++ b/zlib/old/visual-basic.txt @@ -115,7 +115,7 @@ SUCCESS Then ReDim Preserve bytaryCpr(lngCprSiz - 1) Open strCprPth For Binary Access Write As #1 Put #1, , bytaryCpr() - Put #1, , lngOriSiz 'Add the the original size value to the end + Put #1, , lngOriSiz 'Add the original size value to the end (last 4 bytes) Close #1 Else diff --git a/zlib/os400/README400 b/zlib/os400/README400 index 6dd41aa6510..30ed5a12c68 100644 --- a/zlib/os400/README400 +++ b/zlib/os400/README400 @@ -1,4 +1,4 @@ - ZLIB version 1.3.0 for OS/400 installation instructions + ZLIB version 1.3.1 for OS/400 installation instructions 1) Download and unpack the zlib tarball to some IFS directory. (i.e.: /path/to/the/zlib/ifs/source/directory) diff --git a/zlib/os400/zlib.inc b/zlib/os400/zlib.inc index 0d9e2f2090b..744729ab9dd 100644 --- a/zlib/os400/zlib.inc +++ b/zlib/os400/zlib.inc @@ -1,7 +1,7 @@ * ZLIB.INC - Interface to the general purpose compression library * * ILE RPG400 version by Patrick Monnerat, DATASPHERE. - * Version 1.3.0 + * Version 1.3.1 * * * WARNING: @@ -22,12 +22,12 @@ * * Versioning information. * - D ZLIB_VERSION C '1.3.0' + D ZLIB_VERSION C '1.3.1' D ZLIB_VERNUM C X'12a0' D ZLIB_VER_MAJOR C 1 D ZLIB_VER_MINOR C 3 D ZLIB_VER_REVISION... - D C 0 + D C 1 D ZLIB_VER_SUBREVISION... D C 0 * diff --git a/zlib/qnx/package.qpg b/zlib/qnx/package.qpg index d882af2bfb3..4877e0ef013 100644 --- a/zlib/qnx/package.qpg +++ b/zlib/qnx/package.qpg @@ -25,10 +25,10 @@ - - - - + + + + @@ -63,7 +63,7 @@ - 1.3.0 + 1.3.1 Medium Stable diff --git a/zlib/test/example.c b/zlib/test/example.c index 582a17a3ce9..c3521dd5934 100644 --- a/zlib/test/example.c +++ b/zlib/test/example.c @@ -36,12 +36,12 @@ static uLong dictId; /* Adler32 value of the dictionary */ #ifdef Z_SOLO -void *myalloc(void *q, unsigned n, unsigned m) { +static void *myalloc(void *q, unsigned n, unsigned m) { (void)q; return calloc(n, m); } -void myfree(void *q, void *p) { +static void myfree(void *q, void *p) { (void)q; free(p); } @@ -57,7 +57,7 @@ static free_func zfree = (free_func)0; /* =========================================================================== * Test compress() and uncompress() */ -void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, +static void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { int err; uLong len = (uLong)strlen(hello)+1; @@ -81,7 +81,7 @@ void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, /* =========================================================================== * Test read/write of .gz files */ -void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { +static void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { #ifdef NO_GZCOMPRESS fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); #else @@ -163,7 +163,7 @@ void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { /* =========================================================================== * Test deflate() with small buffers */ -void test_deflate(Byte *compr, uLong comprLen) { +static void test_deflate(Byte *compr, uLong comprLen) { z_stream c_stream; /* compression stream */ int err; uLong len = (uLong)strlen(hello)+1; @@ -198,7 +198,7 @@ void test_deflate(Byte *compr, uLong comprLen) { /* =========================================================================== * Test inflate() with small buffers */ -void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, +static void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -237,7 +237,7 @@ void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, /* =========================================================================== * Test deflate() with large buffers and dynamic change of compression level */ -void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, +static void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { z_stream c_stream; /* compression stream */ int err; @@ -290,7 +290,7 @@ void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, /* =========================================================================== * Test inflate() with large buffers */ -void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, +static void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -329,7 +329,7 @@ void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, /* =========================================================================== * Test deflate() with full flush */ -void test_flush(Byte *compr, uLong *comprLen) { +static void test_flush(Byte *compr, uLong *comprLen) { z_stream c_stream; /* compression stream */ int err; uInt len = (uInt)strlen(hello)+1; @@ -364,7 +364,8 @@ void test_flush(Byte *compr, uLong *comprLen) { /* =========================================================================== * Test inflateSync() */ -void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { +static void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, + uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ @@ -404,7 +405,7 @@ void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { /* =========================================================================== * Test deflate() with preset dictionary */ -void test_dict_deflate(Byte *compr, uLong comprLen) { +static void test_dict_deflate(Byte *compr, uLong comprLen) { z_stream c_stream; /* compression stream */ int err; @@ -438,7 +439,7 @@ void test_dict_deflate(Byte *compr, uLong comprLen) { /* =========================================================================== * Test inflate() with a preset dictionary */ -void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, +static void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { int err; z_stream d_stream; /* decompression stream */ diff --git a/zlib/test/minigzip.c b/zlib/test/minigzip.c index 8a21ddfb57e..134e10e6c3e 100644 --- a/zlib/test/minigzip.c +++ b/zlib/test/minigzip.c @@ -149,12 +149,12 @@ static void pwinerror (s) # include /* for unlink() */ #endif -void *myalloc(void *q, unsigned n, unsigned m) { +static void *myalloc(void *q, unsigned n, unsigned m) { (void)q; return calloc(n, m); } -void myfree(void *q, void *p) { +static void myfree(void *q, void *p) { (void)q; free(p); } @@ -167,7 +167,7 @@ typedef struct gzFile_s { z_stream strm; } *gzFile; -gzFile gz_open(const char *path, int fd, const char *mode) { +static gzFile gz_open(const char *path, int fd, const char *mode) { gzFile gz; int ret; @@ -201,15 +201,15 @@ gzFile gz_open(const char *path, int fd, const char *mode) { return gz; } -gzFile gzopen(const char *path, const char *mode) { +static gzFile gzopen(const char *path, const char *mode) { return gz_open(path, -1, mode); } -gzFile gzdopen(int fd, const char *mode) { +static gzFile gzdopen(int fd, const char *mode) { return gz_open(NULL, fd, mode); } -int gzwrite(gzFile gz, const void *buf, unsigned len) { +static int gzwrite(gzFile gz, const void *buf, unsigned len) { z_stream *strm; unsigned char out[BUFLEN]; @@ -227,7 +227,7 @@ int gzwrite(gzFile gz, const void *buf, unsigned len) { return len; } -int gzread(gzFile gz, void *buf, unsigned len) { +static int gzread(gzFile gz, void *buf, unsigned len) { int ret; unsigned got; unsigned char in[1]; @@ -258,7 +258,7 @@ int gzread(gzFile gz, void *buf, unsigned len) { return len - strm->avail_out; } -int gzclose(gzFile gz) { +static int gzclose(gzFile gz) { z_stream *strm; unsigned char out[BUFLEN]; @@ -283,7 +283,7 @@ int gzclose(gzFile gz) { return Z_OK; } -const char *gzerror(gzFile gz, int *err) { +static const char *gzerror(gzFile gz, int *err) { *err = gz->err; return gz->msg; } @@ -295,7 +295,7 @@ static char *prog; /* =========================================================================== * Display error message and exit */ -void error(const char *msg) { +static void error(const char *msg) { fprintf(stderr, "%s: %s\n", prog, msg); exit(1); } @@ -303,9 +303,9 @@ void error(const char *msg) { #ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ /* Try compressing the input file at once using mmap. Return Z_OK if - * if success, Z_ERRNO otherwise. + * success, Z_ERRNO otherwise. */ -int gz_compress_mmap(FILE *in, gzFile out) { +static int gz_compress_mmap(FILE *in, gzFile out) { int len; int err; int ifd = fileno(in); @@ -338,7 +338,7 @@ int gz_compress_mmap(FILE *in, gzFile out) { * Compress input to output then close both files. */ -void gz_compress(FILE *in, gzFile out) { +static void gz_compress(FILE *in, gzFile out) { local char buf[BUFLEN]; int len; int err; @@ -366,7 +366,7 @@ void gz_compress(FILE *in, gzFile out) { /* =========================================================================== * Uncompress input to output then close both files. */ -void gz_uncompress(gzFile in, FILE *out) { +static void gz_uncompress(gzFile in, FILE *out) { local char buf[BUFLEN]; int len; int err; @@ -390,7 +390,7 @@ void gz_uncompress(gzFile in, FILE *out) { * Compress the given file: create a corresponding .gz file and remove the * original. */ -void file_compress(char *file, char *mode) { +static void file_compress(char *file, char *mode) { local char outfile[MAX_NAME_LEN]; FILE *in; gzFile out; @@ -426,7 +426,7 @@ void file_compress(char *file, char *mode) { /* =========================================================================== * Uncompress the given file and remove the original. */ -void file_uncompress(char *file) { +static void file_uncompress(char *file) { local char buf[MAX_NAME_LEN]; char *infile, *outfile; FILE *out; diff --git a/zlib/treebuild.xml b/zlib/treebuild.xml index 1d1b007707c..930b00be4a8 100644 --- a/zlib/treebuild.xml +++ b/zlib/treebuild.xml @@ -1,6 +1,6 @@ - - + + zip compression library diff --git a/zlib/trees.c b/zlib/trees.c index 8dbdc40bacc..6a523ef34e3 100644 --- a/zlib/trees.c +++ b/zlib/trees.c @@ -1,5 +1,5 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2021 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -899,14 +899,19 @@ local void compress_block(deflate_state *s, const ct_data *ltree, const ct_data *dtree) { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ - unsigned sx = 0; /* running index in sym_buf */ + unsigned sx = 0; /* running index in symbol buffers */ unsigned code; /* the code to send */ int extra; /* number of extra bits to send */ if (s->sym_next != 0) do { +#ifdef LIT_MEM + dist = s->d_buf[sx]; + lc = s->l_buf[sx++]; +#else dist = s->sym_buf[sx++] & 0xff; dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; lc = s->sym_buf[sx++]; +#endif if (dist == 0) { send_code(s, lc, ltree); /* send a literal byte */ Tracecv(isgraph(lc), (stderr," '%c' ", lc)); @@ -931,8 +936,12 @@ local void compress_block(deflate_state *s, const ct_data *ltree, } } /* literal or match pair ? */ - /* Check that the overlay between pending_buf and sym_buf is ok: */ + /* Check for no overlay of pending_buf on needed symbols */ +#ifdef LIT_MEM + Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow"); +#else Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); +#endif } while (sx < s->sym_next); @@ -1082,9 +1091,14 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, * the current block must be flushed. */ int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { +#ifdef LIT_MEM + s->d_buf[s->sym_next] = (ush)dist; + s->l_buf[s->sym_next++] = (uch)lc; +#else s->sym_buf[s->sym_next++] = (uch)dist; s->sym_buf[s->sym_next++] = (uch)(dist >> 8); s->sym_buf[s->sym_next++] = (uch)lc; +#endif if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; diff --git a/zlib/win32/DLL_FAQ.txt b/zlib/win32/DLL_FAQ.txt index 12c009018c3..d8cf5f31e3d 100644 --- a/zlib/win32/DLL_FAQ.txt +++ b/zlib/win32/DLL_FAQ.txt @@ -3,7 +3,7 @@ This document describes the design, the rationale, and the usage -of the official DLL build of zlib, named ZLIB1.DLL. If you have +of the common DLL build of zlib, named ZLIB1.DLL. If you have general questions about zlib, you should see the file "FAQ" found in the zlib distribution, or at the following location: http://www.gzip.org/zlib/zlib_faq.html @@ -11,13 +11,9 @@ in the zlib distribution, or at the following location: 1. What is ZLIB1.DLL, and how can I get it? - - ZLIB1.DLL is the official build of zlib as a DLL. + - ZLIB1.DLL is the common build of zlib as a DLL. (Please remark the character '1' in the name.) - Pointers to a precompiled ZLIB1.DLL can be found in the zlib - web site at: - http://www.zlib.net/ - Applications that link to ZLIB1.DLL can rely on the following specification: @@ -379,18 +375,6 @@ in the zlib distribution, or at the following location: code. But you can make your own private DLL build, under a different file name, as suggested in the previous answer. - -17. I made my own ZLIB1.DLL build. Can I test it for compliance? - - - We prefer that you download the official DLL from the zlib - web site. If you need something peculiar from this DLL, you - can send your suggestion to the zlib mailing list. - - However, in case you do rebuild the DLL yourself, you can run - it with the test programs found in the DLL distribution. - Running these test programs is not a guarantee of compliance, - but a failure can imply a detected problem. - ** This document is written and maintained by diff --git a/zlib/win32/README-WIN32.txt b/zlib/win32/README-WIN32.txt index 384c988fa84..14e6398ef3a 100644 --- a/zlib/win32/README-WIN32.txt +++ b/zlib/win32/README-WIN32.txt @@ -1,6 +1,6 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.3.0 is a general purpose data compression library. All the code is +zlib 1.3.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) @@ -16,13 +16,13 @@ is http://zlib.net/ . Before reporting a problem, please check this site to verify that you have the latest version of zlib; otherwise get the latest version and check whether the problem still exists or not. -PLEASE read DLL_FAQ.txt, and the the zlib FAQ http://zlib.net/zlib_faq.html -before asking for help. +PLEASE read DLL_FAQ.txt, and the zlib FAQ http://zlib.net/zlib_faq.html before +asking for help. Manifest: -The package zlib-1.3.0-win32-x86.zip will contain the following files: +The package zlib-1.3.1-win32-x86.zip will contain the following files: README-WIN32.txt This document ChangeLog Changes since previous zlib packages diff --git a/zlib/zconf.h b/zlib/zconf.h index fb76ffe312a..62adc8d8431 100644 --- a/zlib/zconf.h +++ b/zlib/zconf.h @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -300,14 +300,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have diff --git a/zlib/zconf.h.cmakein b/zlib/zconf.h.cmakein index 310c43928a2..0abe3bc9d8f 100644 --- a/zlib/zconf.h.cmakein +++ b/zlib/zconf.h.cmakein @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -302,14 +302,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have diff --git a/zlib/zconf.h.in b/zlib/zconf.h.in index fb76ffe312a..62adc8d8431 100644 --- a/zlib/zconf.h.in +++ b/zlib/zconf.h.in @@ -1,5 +1,5 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -300,14 +300,6 @@ # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have diff --git a/zlib/zlib.3 b/zlib/zlib.3 index 4dd28967534..c716020ea9c 100644 --- a/zlib/zlib.3 +++ b/zlib/zlib.3 @@ -1,4 +1,4 @@ -.TH ZLIB 3 "18 Aug 2023" +.TH ZLIB 3 "22 Jan 2024" .SH NAME zlib \- compression/decompression library .SH SYNOPSIS @@ -105,9 +105,9 @@ before asking for help. Send questions and/or comments to zlib@gzip.org, or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). .SH AUTHORS AND LICENSE -Version 1.3 +Version 1.3.1 .LP -Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler +Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler .LP This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/zlib/zlib.3.pdf b/zlib/zlib.3.pdf index da12d37183a7371513c0991fd14a7d932fd42e84..b224532bdd8eed1939b7dd04a7a0dd46be649c00 100644 GIT binary patch literal 25523 zcmcG01yoh*_Af0dQi8My(rh{eq`SMDO?P*9cejL;N=i4<-6JNhxU_1vvpwOI{v%K4C&? zTYdpW5k3J4roIN5H!=V1M&m)EcJo!-^1J5*#LFS;hoarRpxBwx>4Mx zl=|m<$gTZa@#+CPp}W&0bE?7d^19}E+*ZOwFyPpjeWxtMnK7RITeV<>Br|IXMK)({WgquWOfxbG8iHLJ`Y2SUeovx1a5$&c!Z_V>gaYC3?o&9`6pVy~58Ml#nxevW>}MPN-U>HI>{&CS{Q zW@UZgY-J$uLaM%Y`u$2C=3ECkL8R78I;ogphO8yJCB7s&Z#{uN`s(O-v+|g|8w0Jc zF{R}+dQyID<8O}{q@Xy^9SobW7{aVzxoxNEq}eS<#6J=5O`GE+mnx^0uCevaR)5Es zfXOt#Ybt~sY$StH+^Yqzkk)J5D>sQ}qTE5{H3wh(YSURRh@WbC;}*&}ExB((HPl-^ z$l&75Wd9u_-i*zB^O=v3hgtf0oBY&JYQ$cu3(R;O5mGt;y1X~U};mY3|1G< zZ`>E`ta2!jFW*LjRm3h-YnHJak~|dWAfd{2pUOrCetR}csEBilSFF>(=?ZUoP3?NL_uj(iRxWE3iB8_ z6n=~MogF6}#YS@&=^wdgl|w7z^yT+evh}{C-TBmo@&v=&-KB7d*QC~1=t4FmNE9C` z8w`jqWm~x$zDX|G_NV}61#fBgL7M*1Tw$ej(@codNPjtmR0}I;*I70w`js=HwllV^ zf-vXk8&Q~^?}n%$-42_%lSOf}q`KO6@D3`DYF{ z>GDj)9960K1+YLtzye!!)ciDQER-W~oXY4z7-gCN)0SLvwiP+*JJarjokCl{TeAM% zYW!?rpp;_ajzI!g)iOHevF*UAKr=Er44-5_3TY)5&q%A*Nk?!Gq{{;c?oym zpiSY=Mm*di-pR3C_T_bfsO$pUGp7&@aP%*qCaIK)&j=&pZhBq-qUMS|DqMTbFnU^PXc%Q)kh4O<23t%lOk8R3k@zj z7S`95ws@aj9EwIRuT`GWQJe2Hsh5djI}^!&7IlAdI-K1syqe?E(MT)-aq_XJi=ke% zBKet0J+MoV(^FntD)n|#zOx@e*!fD5iL(NM8HZ5NP>>F_Z{2?E)O7`1!5khr3J&FB zOopZgHfcX-$ji434m-gk*O`(+b%Kqedi2|b=y+Ff&Y>;=t#HOLXZ9j17b>?8sh(4$ zb!p2xT zbw_rhBvI%y>N(?OWwIz*Yvy{Y>!TQ8OBmrGH;T*OSrH9M0kxr8E)|X0$Ue)R(D~@t zM^`^zkb7}+czf&TMZ`ad)ag_%9ZMe9-UAt)goYnJ(9eImBA=8)_xhe$yErG>S*V;09&cdwgmzgc$7B*hDRUM2(hxEd z;|)cyE<0ph{-~H#&V--4SFxCA&vn*rQO0L8jqKH$!F5IjvaS(pAsL$lxdDBJ*G!ql z;>WSLgN;!!bkTcK!uzacwpgU7GKSyi5+T#Bb9ToIO~~-lnKMJ>;}yk)Lw2L=$O_Wp zz6E1Z<0u3%T)gs+eW%qJn55MBnbRxEQRv!cg}XpiBzTe^Jb=KGLCrbiEvxQ!H^jAA zzFqm5jL`7$`qf$GjFXO;o~zgMlEGJ=o`uTb-jM;2tSOU_fVE{Z_Vk@*O{s45)>A=? zX_ zjNh7w=ApCWU_Mek_;E}t@%jme!)-3EwZ*qXh z>8K4j0YYD_2zViU4B-~i?3;@c(IUI<<6zUwr}jJ>YigRCl`@Ft+w%Fm7%Qh&+5JFH=8+^T8NANpj$bvus1 zOHUn5;JiKGM*?L|x_4Rr$+g#Ou%fMdX;3Kj2M@n|c|9#BMM{FAmuQ8Jk_H!6d})A- z*R_r=T?3CN$@jB&xK%vbpI*PkB)Il5C}gQ|K7)XN5cJp|Niuc}D2(c@^ZyYjZ(aED zXe_nGjK(d?Vbrj&R{<;Hd4ZfM(a41T%rUQnsiq!PmH=OuW2Z5%L-Kpz8hc&IlR6Psou+b zHLMN0-Hq)!vssNAZCTrNrQmY0HZ5l~UAD8ccAU7%qPsbr9X9)QOc6coy*C7H*4?*F zcneQ`uoD#{a@iqSlq6P8yu7w8c^#iT5lW;iaUZ=&PvL|2&zD`ex(-f9`7FM_c8~AH zKbS)ZIq;|4Bp@-MDVC5Cp`?i17i=UCoLATMtVzCNC2Wh*X8=^UBGrVfa5Xf*YG!b)XlM~Fo-ZGdfoJ!1aWk<*DEAAha_ zW1?u%(`;q=W5a>k`SCWq3Q1|e3jxU4%o^eMt)j&M@8#(%DgQ)lkzV}x48_A-z7#TE zGkoNc03Y|z0lEj;Fz;5g{o3y6H{+p+p%q+*XPyh?E}K9L{a-3IDD|j@KPumkPkL5X zHuzs!IJF zjoq+s0rkbB!xjJJi-Hlvmy zYRvHDNo4dYegYE1&-BMXBxpyr*P0Tq5mCHBIHfhYHg38e%}` z54F7F947ttE>jcox&@{aqK9=RYa?wGEH+US zm?4k)$S^)d0hpDNR~MwM z%mke2&y!k2XJhZhW&GwpS>sV@6a==8f!|^U#gc(3PT|W@^1_=UPGg*OiRc|%El&N) zp$O|)L4y-!;AyFF><-UM)X0^Jv>Y7I}=fG zNs12rQP`MR7AuEZdczD_13Pm)0w%E@?&J46gJ8&F6_HhYnz)yPpX9IVcxTatMUb+o zEXy-8aNueCcmW}o-9`BT+u~Lzn|RVnZmAZ+(iW1Ht9Etbm(zsQE43CL-wS_Nal{8%h{p@*ufFd#SO zS9MJ2rkmoMlrg=Y9t#P?Es;BEjK-)z$8&Qv$}js$`W7xvDt0wX$yOynEi8o!PpqkxIbwE<+k3x_SI9^tppv-0oE64Pvi$XxlJs z1R9KIAl_b-fmb@hs_3b@06>RXM?Kx$*PNFQp4T*x?R zDicQBf!&^DoWfCTmtn&2*3^e4oFlV=9-D_Pv5M?iX=tv!MU#})J2Oz*ebeEkW_Lw~ zxBM1MsO0%VCDQoSt1X;jP%1!w;CUjRoMBFk|eLUxMe^ zXJMK@_JvG!27FF6R&s90Jn=SP?Ttj$1*fNW1LK0l_g#ix^kVWJDH3-P3VJh8@Hw&K z`_T!3T|)4i{~?>6gwCUIqGP6|{Vkjr|CUYi&Q?Hxw2mPVAOX}j*5S2uB2;^nQ_OVq zge+|I8t?#FOFNJ^iI5i5$_8j*N67Ff#X!YCTT6QzJ)kYf2_RK}EksB`c`lmpkkK^K$6ve$V~)a-Jmh zpX+(t;LqiN_5y;3@ChGVLV%dDzAd2|{3Cj@@N|!>mW9_K1dU`5+9~~?JNj#cUjy*z z*y)&A8vY*X7laZ(I~{#c4I%x{vHpPM5w>5D$g;pcfe4VLV}hr90uPjAfTw#J1(c+N zr+eBKK$Z>uQR|TXdz`2J{y!M!kLB>{*a9Dq79g$2ry$5fDGW4o0NNSr=}=4Qni*T$ z1D_6_A84y*V{Bz-X+!w5w)RRGs)33h z=llDQp5<{2T0$nKM@ofQ%h~JNJ<|H) ziPHUz&=a7)5c+Ft0%E+10y32H#^yj{T z|JoNl)8lF%@1Pz1$36VLo8NoH6L3cW+Sn{|(N6a~0q(oF!z0B_t$%;Vf%uu4C~(V18n@|4cm$ z^nbw2!tfhr_@6NU4FdxM1L(#6^Li|Otbfe^K8W9N{QL7Ka6j*lAp8vkEj$~DvmPOP zJf6qvDGg%7$D?^nKVDCBfK^dCeV^WQ-Fvj1n2Wo7%X6#EOeM{Ixo{R4!bsO%Rd{!Y_Ao&O^ZJTmj+SdSF< zo5Dcl@Q;)SYV~;fk97E}|Ib-LrGK2wKYgM8VfX&U=L&LCV#*4Ci;DjN+2e%&05Upy zy1y|4?dlggzn)KY{lqbUl|OOXZ%Y0B{HylQ{{MpTPgEY;J@N$T4#I}@=g9xk?mvtK zs{cLD&%VFg(EsA;pU+=yo<{r4zfb)5lcRpl{C|P|BPM@x$fIcbTNXdzE~#S<()j*& z!kZVQ1wJW(EFj&8g`Q30F`x*FgEE6w%?c0TvDJIj13?uarB26682HFaKeLZhJ=W2} z1AdB49t%S=knRW%kh24tD-zPtvcLl*jBRZ}68cHnKS@HsqcQ-}AISi`01<#VK$ZMy zp^q_9&|CV6o&ILZr~I!i{)~728SVs4^rxKX`yC%;WTbun{;xo&p1!t@uC~5D`myi; zxfpeixa9bmRBsOzl>~IK$!(Ou?d$eazJ%KP8^hxv^+^I74#WkH{sj)I6AyV6-lN>Ihp89-xeYi(s%%w0CweuWTNKykILy6)OX$6c182 znb<%Npj%>q@~E$0f`VERRO>@rgJUD0uMu*k~tYRgzYWOlr<}B3|30BDBE{Nu8KQ9t2F?*?&!BDACJ;oaq; z`$bnzeHfRR=X%J!O1C1g=bA5cZ|I(@i*i846IVOcHt{SHb1o8+E284qU2B5#pMiT#Yn&cguEz31D-D)+@g<}UYgJ?t`p3}Jfn!`oCx$ zRQe~aGcz;81Af!`W7q#m?o9tq?o1$FQ2xa-jEtZe{-S*ltpaoax&S?Zo~60D4gd%+ z1Q-E~0cHSmfCa!3UZ#RM?&sJyn$0Cw4^AH}Sv#H&@Ascy3??(23^)!t zH($7CUN~p)@vQs5Mu!LL$kHTItGi}xB9gM`S*%jKu|aF01Uw{Ti{%cz9oWxWE`f$s z=7vUCzfx>)vx93mhPR{gS?TQNfL}|mS&c7_#A7=$5bsY}fWFn`v2c)-IsNvP#VkS+ z5OIGHyUA&$W5En?!Ki&v!3OO{ld6QC*(ZSs_aPG9YUnV>lj}ZG?E&HZ!C&ZwKKW;D z7A-=mcW)%Pl3wc>Zv3#RF`XRrEdsSu(r&n7zr-y)oStud!#!JYlYn0XAzmD zZinVOwkHSUG~6)7*E(fj_n7q;d0k5C(L4?vMH5Y+>zaAv#;ue^MYrELxSNL8C@Z8d zgFI_Efo`t1xP6@waK(ZMw;{j+pY48g-B3bLuOv0oallLD^dR_ynlc652huoueZ%|h z$dxZ8t7bgd+;XgV?T#tUL$(b9mWJ$YiZqM9|+MUcD&!;`ZFF*29#H@#B zAP`<51tY$lL1CG^{P^8x%Tcc2bh*i-ZE$#{R(mVOk9PgA1F(~1G0Em(`4 z@~%NbykrU5h&Gc-bzb!gT<{wwwbAG4BEst#U`F1#MW60C)Mq)onHI5euoz?6=)4I$ z7o@xq5;gtV-4@*C_TGe3zn6wddz+ZAu4r)zSy@|`U!{UgMz)f8h){M~8OHA%K*YX{ z{Uc?sK2Eid21D+p=7!yDFSzQ)2s$NL)IobSN+TnE)2J41%hb5oofzTTPE!vM6d$e$ zdHtGsq-e_`b4&$}f+xI3>N$*%mKN}wI`dWYduN&XSo(mnn>A`eziQ~)jnB-6cU3+L z5|Qf5fmjkeQxu5#s9BJz_2U8_Dm2p5z&^+P+`S>>T#a`D8XQ}F;2fuXG^A%_UvFI5 zC?TppK3h6bgvV{sdo{O}UBJvv2rww@)S*o(eFsT-GM*iKrRptd31*@V{WA4cBj0xk zKPuJYo)SHi<5S!$o=$LQJuS7(9;Afw-BX@g_2)^de92ufUIW3LUKhp;r)*izV(uqwejIUVl+qZ^&xBI==||JW$5Qf(Q3CE9nJsBOkI@6ASG=1{M85EL?%I?3qqrF z?~DZY$G2G6!+OYEco!{hop3T`q1Oyptg5&tcOpqQf2EKnEk?~Z016#+j<<)XnQ#%% zhH^LUM@?&kw-{L`@N1NiRVaAbX36hJ7!kb`Feh0LtsT{6(#H1smQAjZV2rEkC5lcG z)28Yy)~9lDNjN#JI5p2XFHRM7oOT#j>4QKxO?!UGQa8RD`i#tJoRb1ERpT4h*P4EA zsLGdBP2IX*HcNlt36wbLWGAo(@v0-?21c-q=nc zef&7AzLKn;7$U5%wPE#{qyQ;yTluuHt}H4mN&MOB0GE173ysv7W(}_>ga?w{(!;6T zA&Y^Q-U}YKyMWeWNDgV;gw4y29Lyt`&R~~z86=7>vG%T|_aerF79Ji&LCJ5#Sj-@d zO0qbV_Yvb@Xlr1lK4Qa9MzAN_651^(dyTpgm^9_I6%1jC1TqK|fV&W1j4E9Wa^b#e zPf4jasRL6zm?#W;`9UOfEB&GvmBQK7pn9mEUyU;9AMmi`~_L!z(GsM+RGp_x{ zh1RRV@YyB3GZEzu+N56Hdl&V-r!2&@Tlt1CURrwYq(0&G3aYf%W09~xVg_oswGU6j z9{#g(j>n}G6UAC3%;!VRVOMTRIiOfsjfY4?fnb) zhjk&Yb`k~xPscZTq;I=LOQ}j=6pR$yhxNWf7W=MM%d1j?V_)^Hk~$W+8)Rlb$H^6X zPnsVjgox7v7lSbgZ(DUVHUIqmt9@nNZ?1E4G;Wj9+r^)N&Zc#0A|s)0FiNX^uhOg9 z;>;9M7%|cEZ24=!fT6s1kwVRPxHlg%9XwZ)GGd|5(=zv!3O!E7jzfC4rQDUu@=2@E zmT+e~E&Idf(1c1mi_$7*6%PRyB%XZgXQ3uY%6Rwbbe(iOsY9AjFH zD%3B%lX9IRRcfw1+j1UN;H1dwDPim>BPQZ=PC=)|U>KF#j17btV)0fXh&z-{5XiYj%Rw07|*!MgeKFlpl0KV|&)iJu;K-@b9i(PVSthh~)$4 zdM0JYee(c`OboEEBS7nIZ~TvbJGMbe!Y}yQ#ckF^?0h_+ElTQ!J?u~KyW01_&f<*M zL}`v>VUDo#SCi3u$2M_gEpGw?ERg518^mSHMoUSyKGBJO;pffoVeIn?;1Ah}e|7`- zx={PgCVqq{t6hK=>*Cr~s0DVG#HeRAnAm?*R-!aaAtANl%vnevr~2)y37eLWz>BStlM#s z8}IYB5_c#uskoyaz+gw6TK=S-_|au&7T$k9Vqvo4PFM2k^HX)@1q6qm(tGzGI{v``~U%fAV3Hp3^IR30b(FS zKms5MkOs&AK)x`5JU{`U2v7njgUkaRJCKE-YonuQ3bZo=8h~;?(@*ZKC)2^q(&Co^ zp${@444&Lu#txvA8NdJ(uz4~njGV2EfEFOz!USOYWM4dazCc!ng|P(?WNKJ~?jUpH zG2Zhu$y4g*6u)c`>p#3`KMfL~xv`$*kWeQ|7(8Ye4hk1`qEfpB+OY+C-ZhcBC&o;qx{_EW0XUOjUVEYWg|6`e zm6sGMFbzG%D&~@y#q@?M^P-WY-M#i;@uZR9pu%%{)^(_HGEFanZXGogiz`CAOgZ*k z=v%;Bz)?^nQbfhW!|T-!-SsfN_42RTHJ+dFte0thM4*y7U}C>14WJ~j(Y_yBzAB_O z$EM5ZRIQjRxO4{~XCl9(R&8K<|N0F%JqHnRv3HG9aR8ww>0-T?BXRgg_hF4Q!Xbfi zHr)|iS++H~>l-~j+1QQnM#l^xBPSDat5MIp-Ool3o=0##mu9wU2ML#@a5TYlG1a68 z!ZXQrlzSDYOA9$Kro!4?=_7ZMkZchgBM*a4!)6KgFjnz)R&RUi{13i*ej(@ns_bdi zGui^|Q!2SNn%H(Wgcw0Tu){(3S((qYNC~k63IR$cN^#Iahe=!fWzsZX$?J1e z)8H9DG`hg7U^sqAx@f0VWvLF-*kD#&NIL%{Q8S`^lrgwxZP7_QR>8?op-U+B*3iL6 z{A5Q_7+iza>Pt2CX2|EYN0i@KtiIXmvU$ePAHS`NE-DDv+^e*1^MO+$t&?&)nymgB z7Mm{>l6Go$+~2d_<0*NRGRknaQ0OTxCxMerlX73nSKj^|FCFi5zg0#w{pwpKj@Yzh zjtcWhKNU5DwLyyHGmOu%7h#$G2kCoE?5@>7hlgFticEHMJ5=_C^i`Guqy6#P=e8`| z?Qzkx(s1rKNna^d-YhcjzxK@`TLB+sU~%3een(F+7yh!l101^v_ImE4*Xc^WE?;38 zKPxP$RaX42ntYnJD3t7b;oknE$x$L@;c$aiBAQ(7H@Pxz4B=y+QM}rBo=oH$1_o)+ zp$RIBaQW6i*^Pcle`j4%SA#T6YO3b|CqtHZCI0q&=mW`NQ2a4VZ)g>%aT3oRmXpp& zYf}FLJCqc8-l7mX`9<_019@y~Nd;Kl2-OiL5ni5stl`z#h#ouktH7_T?~Y$%0zElJ=C;+O@q0eJyup?A z;yB?h$N;utrIs%dGrKm3qtbRP`pfJhqt5NCBaK7oyRoGzSBM6!EwGbF&6h9`u728X zH8ZsFv4TaT9p!dWNW?I~BhB-l55cTpO!dxpzgLsmz2aUqLWjCCdXDIoru8gS14Uon z%zEZk{mVlQZ$qH;#eFQ@cW~B>fO<_{?7?QIw|l~$vzTVFEpPgpT+k8pFiQL5D4!z- zYHx?CM34xg_xW$b+r&yL<~H)QW5j(RE2}Z#-9x{wa-;?}4vS%cp@1I+$?AheC5z2rK|ccLYuEgOv=YjPFNmy7oD>UV=tkgo_BRy>SaGiM%JBlrtxS_bw_$J+KT37}(s^NzNfi+3z zCK|wemU0sK7RB_vmsX3X_R`6<{e?0Q+jpdbE4@`EwQj9;&zw z;oDG3_u=`0YhcpAEiBjCw^(pX0#V)rlP#!Y4PV7)E=I6RvL?cEM3mO~rdh=PaqdL% zr6a>eV8PU3ke%}KdK^%b}?)KIR9>tt!DWxi-rL~noTRHhH zm`U7|iskr7W#J6jqoVucp<+yl#z~@8_?#2U+KQA^5XHI58W5YRrp|h5sz7}!w{1nP zW#l;3gJf))v;LMfs!lT*#LagVtkOYdUY~uC0)9#w9;}AR58}vn+-pg%=C31M0 z^}z6bhzPK~ClFf{H0Dz5W+}2hsGj*44r5$+{vK&{$!(j`Jh}1`?Utx1M^&+>Hgk!&lcC$+iG#y3I}C23ccXTPHpr=bwcP~4exNeRl8K<-@oH_A}@N=$nmP< z5c0#S`&S`5ro}7AC*$xd z!}MAdK#&=JhLlQE17~UOi2>i`Z3&h(IWou7&MoRWA?rq$nE|1OZkQxeT2hZy=O4!6 z2%g(R6wX6!rG5W5__nHM8N}s?u%Ne7l{|%%aCmel#I>;9jm&Geke9-Rt0}UDG+u&&CUyV>WehTri&XX*?#=pE3%}aw{}di=4H!YVUPKj%*<{zmub!ooP{& z%e>W!HPp(ij8W0*(M7ekiI(QAURS~3hC;^{__X3K-=B&+P&C>gtG(_EA6nSXtrq>+ zZ+kKc-S?nXTQ};4)Gea;U+#&$@+*B%8>M-DP|EbVkgD0!Ge)3`_kd>h;KNE zp2sdyN(K846}DckN#@mjND+Y@7JrE`j{Z%;dSn%~z1Y6y5Vz?8k%gw>;w6h5g`5~z zdJYxd3tj^FG#M5V6FGKYGYc=x@|o{Uoe7$1Y6>dppP5V~c*9lHV8!kDOzjVP0$2g9 zn()*!snK}oDJeAJP%<@v8qXj;KR;DSucfe}I$~DLyU;Xz{`h_c%CWO!Q_Sa*= zk4Hp86PkHtjh1+jHyt(%RF?7Hd=JzOMfKr2rPlB8O{cb;rOIk1}E zQp3>wJ=EC4w*WE0_iIIGuSflMy{J6Yp9_g&Y$9g87;aqO)m}Dwg~5P+hIkyX%z8nba7K4Smp;0g0sw)8) zYFkyrk$1>9?nkDaMKM5K#aG{EvOTqW>L*-yJ#XWz^OiU|K`AY33>zcd1E|9d(LwIY zphqlXOhj%lVn#*vDnHDPE-O|bC--AQ?mfHj#`5h6ubJV?#7fl=6C^kG@dLWFw~7mT z%qP#)2a%>qz+DUQ|&Khfxm7KiLulqhgaz5-fj6`-OhvPkJ)R&YiFFk=~S!W}n0w1c|oN*Tk zDL(LEvkwGT#Qpm0L1k0}7WzyLURz0%z{DCARgCUV^F;Gk==3aK3RyuvTRSLs?chyE zNdjL0D*C~W*ick5wd%5HjmvTvHuxHFC_~R+)=@@&MR1h6a<*E2^<34?A0bXOnKvUj z<6{uyDfVZ;G9&B#4_~1TN!-JiE1C&P26M4%+ESB3kQKNBZ{DBV_3-~l+>Q}%pJTj^ zz+R&#dOk}=bi-pTc>wNWH`F{Zi`y%y$ZEMJj%0k55qM-Pg}vo|`%lOLg{o%uLQ}XygPHzlbAw zN!eSbRQ&Pd7GlZwjqO+~GMOYNGE(*W2#1J!koL@!if)5>gQcvSmxg46;3V8WX9a&Y zTdHu@CZ|!N6_`D3QAW4G*-dA-vpAeg@A~1GiDFVOxpHjAP`)u=T@5+Ir$XSaN=cRd zvya-+$4d6>t;3e0ZzMJ9Ytx%GRygAMFq?LJpx0{M)oTikqOk(lZ>q;c4VuqBxP*n5 ze5;qft;voa;HTrT7=ocd5=Pp}ALrH7m1#f`n;RXV=~Lg~vlN0uiya#U9yh3as1}Jv z2vAKBaiug(kkY~XjVwk&dU{;u-fzC*aTIf=+=Q8Weri4_G!K!H_s`$ngY=)5|$neWW6zP4k?;@W!0VBKCBK0Pmg~S8V)uqQ`y1kVRtvWPS z78Lr{CIqTGi%swxGK>Ho-3EjzCU^(6ZED4Kp&7!}|=2HZfjPsk(-a;y!+fsSgva;DpV!K{A^0h=7U}D{E3#g1W5I zV+i#dH5*ji?f!t*9Iz^sV2dUzyRup&hm%@doSGtAw0g+uq&S!hm4hRXzIUOB-2%_KT!f7?>!rD2Q$?b>LF0i+hXF z41qhm11jGbqxcVw*=vBE87EdDnS}mkf+%Swqazdflr&ZERJff#Nd&(Usk^apNh7@b zTF~rS^#HT7fYxM7=LD8kFhsCd=dk;ctbuPBRU<`tJ)rAtgFX7xbB(U*hxX}nEndJn zp_2J@EN;r0@rL||!J@CTUp4dwJF3z}y~CYFj_u-kQ{Hrz=hFfef#bph%0065^l~3u zWe1T@6DFBp+0}{-BkS7UO2FzHwWkD~>F_%myE6uaGPl%`q^Q(n~jI7KF(=b~O^TAY$46WT=~e!7=&_e2ZsbkgaH9Lr+!rmB~SjBiF>b?yJqRMau{}YNm18Jz?O}$^UenQ zY@;J**1-b`_3z#zJ}|Z5AC(vT^Ygz~R2w@x82K0g!7iVjTm}bTug46Ixulh9#qmL5 z2Kv+3;r(>bNuGPh7P^eocSJ50^2)1ZhIud*WcK}2Sd++dr2<*|Y!ayJk{iGaNs$d#@>Se_kJ?bKo=W4S>=Z=%C z-h(}(r)BUZh$B-i8|;X?L_Df9$Nz&FzA996q)U_>Qi+?iiiyPpj<*#lyI?0V&+oR324)GVbfM3PKL^WfUM%XDUb6QeG+$j-O%d906g?z%$LdH z_DpwccwYD)BU-{|2(yKHm(*fHUX(T z-R@GvBQcnpON_9&Vp9l=3z*9|+|)4}E^>@}FY3J|r?lzwh8_~ggDyBZqQ*wCS2Z8l zRE201oZCxQ?Je;w7M!v!`GH`>q`Val#Ymq}fYMk{~Hu!^HH!1V=CV6%J~b5hMt z>gj2RAqhDg95C3o48@4nSY-ol!z;J%4iS7J)OS4y&pV9WkrDWkbo7uOciHE3-ptv7 zSM(zz?l2A{e%n`?1dYNX%mk%Ll@zeMfwBps#usmdBEFaUnoTlv8?>{D6S6RqlfU~! zQ&^bSR9#C__Fge)`10ZCm4~zf`8}S=>p5^P@}1FwM%riSlf9RsL%}d(Pv^p#&emhBrN{4m%EUj9!nGb_L>@L#} zt!Ar>7VHifT^txAwq!(XB=mKvgnj>cu!!pmY`4!(G&gF+6&g~Q5Ob600 zXqF+={o%eUizA3HEn-jXoSMz7n6C||3ok;uGbS&F4lD?GgW9f+Ha$4!C*>RcSd)cbt5^_S3dbW!1 zr?0UxuGnPW82edHN|u=5jOepsSh&wzjdhB(#gbYwaey&`K1j(a-1LS16zV`?prR&T z2azu0gqFfOCn8{ElG%X@e#t|~i;J?g8ZH84*sB??>U#LmaulGq2ho+?;`6BnO|sc7 zTx`I9a8rX7a*xM*Q?C;7D(lV)!-W99*0o%JDgK3fFRLvM(nQlFwS<$4 zx`~gRvgpo?Ek?m?y?=NqUVN3qjGK4DRCv;kvZrfDfT3W%?T++iGfn$p-GqFuq)BJR zcsGUUlu23TmS*M-o#ofoH})l30ZUD<9S|x~T%U0gG1a4&->J?Iz}2iBEqVFFdz|^W zKqF$OW1joOIn+}aMqYDSO2-*ljt+}@>uOKT*cm$22DJBXHoRyNqP!L{SMrD~E6HvC zdWB^Kg;8DytHv9=Ft4c6XL5aq&1_~Tb&8DnEugzyerIz}`2o=Zi@jwHtA%HX&g%hZ z8Y)6z#1ou#vl;U8toloR#vS+A(&5|-yLR~NlK88n8@4(D6J|1uoBP;-uuoo@W}Kt*a8{iosQ~h)G;4z)5f`VqOgp+AQLWYe25Et zm$Yqeqo)Zwqvs=yFj4PW(Q2b-8D_tm3_b_*U?LkV6wboaTQMh@VUqN3$zphUn@G_r zMNl?3LS=!9NKhNr7ON?}H!B-VlXgEvA&NttC}h0H!gsJ!g8vbC(L(fza$K`(lSMm3 zd!cHq{Z#9Llzp0-?EpQrM}T9$P$r(hBTGP)ji?1_EY#JCG?@OrD&01)lE8B!l6Abo z#4~_|t0EgtYaZFBQ)hWUBRdFtXV}_2=>7f-hSR$%R92+xK6ZAR^n(CKuUKQO2Hd7_ z1Gr<yh~CJh&Pd~)&M^}8f|@S4@=_xhhPSs*!X!cdg@uU^ZE77 zk-;_GlI=-Vw2T+U{V_(b@zt0e`b!o5+ZGc zYw+vbZpt@MoZ24FV!ICZFGM(T-v&j*@f+637dkh39vC$uY<>nfm8f`H&7{QhR^rv# z>i3(~1EL-1ziU~0X>lMm2Bwp!LuA?le6b}Y&d=g3q`suzPupIsU)sr;CxJyC=8NxU z6OUE~-H+EtW=vkBzra5zu7|SlWmsvwOsF)Gv5rEjA7Jm=sT&-)?>)PfZEoq`wBj*q zASO4@WJ;X6SyJAy=l+fjJBvpXEG&xtZAFYdM$6Tu<`CwDJVQ5!r2pG)We4gS1E0i_`pdS@Z7e+U1)?Yfg9#hDa_O&J?N3D z!gX}+E-|1;wr@{l#&=UzcU7ldr8mu!;d^@#k5#RmuqbC{ddo(zFFi5 zii{#rQw?p^n^V?it+p$pUPU(jm?zfh=w?qNAC>)94~tJhQcwEcvv`iycy#PmBo=PP z6EbnvIPyP)i61{B{wHDL|NMRbQ?Gme2UbQs7O{B36AA1ljG!M<{%<6jAW3TA|;FO^Xo15-0fyRR2H) zSAj&7ajHQb&*9bxvCW^TQ=k^!OB)QUDwt$j#VxHqX>>a2YS1=(=Q)^sa_`jVesJUd z-Lf_k*wBcT0CZfcWQfshxBZHH} zVi6L&&_EKTlh4qspFq!$l-y7CHYvHiVZe{JS$CZQA;~exG1lkH6u>`%uC}Hg?XXo7Zoia8BXAkw#r)(B!ItpJ%k5A|;Ufsxk6VE3xdioS{ zJDQ+13!HhCyb?aVyNG(1J6%~p^}kxX@_4A)_TM68SGG`1wh?AIGh-QM>|6Goio%R# zvNi^jHA)EC)gwZRvXhW4p+}_bNhM1{S*u63=yyiTQ|f)6=lA)%=dUyOxt9A}_jS)) z=X|d3cZ?V$_PG^2@({ycTd-XmQ7T_xP*$7>C>D(wOAPQjoO-?cL`7ZPa-FvmsfGqjh}hM;r^8CN1nF{@kjtifKFZofpLsour|)K8SR+A`NG(0jg`Ss8 z@3Ea|7(nFUGCl)=hAPExsygx%Vk!!s7HXxqX?m&eILE(a9h8=c4+XZkh3m0l^2I@1MwX?8j zU-slq)~&s~(S6<)m#@P+d(Hb)kIau$oV&$Tui4h)L3u!W)1}aDhY#dXb`pNrmeB3+ zdbGgsRQa?mDbayNjVsius_RMLz;ppKm+=Cxb@4(O?*Wt1)SVy3F3S+dXF6TZqb176 z0(bT0?s;M@6KHV7PP=;Rv0?x9G!^^}J|o{;tfl?Fc5E7OyP*7Z5~rzKkg49{h4FN{ z9vcc9Yt~N8PRFi4;#ekq_G@2>VIP3jdX^d5a$;1fn%Bi%j6j$jPj5?r#7k%x$LOp? zUZ^=XKq?pr8@#TaoVY)KOVm8{)Wz)AXX17D3hgqfLVEf7eR^Cs#rV?A zeXoh18ScR8#J~dyPiIZqH1t0XRK&QH^_kV?ZJRo)lpUmsfun(Nz-@F;#+LUwtlRAXUwdv*A{sdT^Q3;vScsMI>wD_u9-U-RAdlXESY%` z&l-hXW>iF+@2X%;P;3{k7-8c*puV>PYZen0txXWPAXag!q>rEDXw<5@KdpXge3 zW~auodB2c9eQL!j+}%n4mr>DI^0Z!(H|*5V2(I^FAVY}94X)d+p5RqOCsi~TFI z%O~jx)ay&{yfE;1-M6;E^O!02Ff!}K(psb>3=N1rDM=f4j^$G2DI2V;RGc?kITr37 ziFy)kS>}#TR*zt1B0QLLXwH`jl7k9{Ehk(&P>U-!1_9bUSL0`{3@VyP1|18Zg!}Rg ziV_cz>MjV}oJMk%Ch;83eso_FxBHJ%<>dx*B`=#)=|klgh2LG`k z?&!_xB5Q4pZ1`)p`d!|}YZ&tutakW2RTdwYIPV_CTXJ2&FM6TXZ!+u!!z!&^#xP;@ zJp*PiF_KI=%uyW|rG=W#x`(_tYjFfUHtc=IAhQ(%q?U1+mT$E(QhDOtFrV6OxFues zA~sNBg>bMSDFUW6cIS1>ssL;esV;o!$g6_A(@Srght1!M(&OfMY;rOQR|;F)%L^N4 zor#0CZ9_KZ`Z_RC9u|uc-BXrYx^u_<%#$J|EGA~n$G9Dnv^YMUVE;faYlyU+I$$TazRoWc5BtIJ@CG`iP6xpMMGyhKea&v;1L+2rJ+`K39|SasNC zm@wby1&H?5%4=~AclwzP$F9{^%qRy2n)>fGocGOL)I08>_gKnkoag$*@FS%eo`=Uy zw(YEI3N{kCx-CHLVG5(4ie&h-Yq?VH)fbSQf+gj9DpEB=oEe8RaLEQo%R<|D*t9|n zqu<|Z_t;hK)%v8NPr*!5W@Z?X$BoU^uhRhEXeAJ=0}a*G6iARqec=xgJn8WLB7C74 zid#OH4icseB;HJSU0++q-Ql3ly!hj}+QeT6bGaUu`@|6Te&qXXe&Q|uCTa9_)Ct{G z*kWmCjIDj2X8^;(y%ssM62_Z32<@V(i<=H>uabI|iKNH1q0v8C1u)8X0^%FgLDqTb@kOB5&sWo5BwZ zJ2VpK=*}(kzUjf*{iZCU!PEXtS@c^7-?yrW);T9DL&LCQzm-KlfM@<2P>j}e_n(R) z0PMc|xhMhwi{HUB(zMRH?|pQdVBZ|AD*6JT*=Tg5A!lf~nT=+)-?g%B;Ano+pa%A% zZSF?f0DJ#XO3^-ljoSaCl#)fs{#Z(xeSy`qB&K=k0Lr7luxP6?FQ+&;-$=6HwTUYo z*I9`OcaIV>2{F%FEDdgCy7G(ADnl0%Gz5q z*BW5w%RV{1J`_AO6L@#x)XRy$L#pMWkVD<>{+h>5o`X-=zU_XTcwG1Wl*Rm%_}SY} zbn-RZiz}gV_^@e>n5j$72VZ!GX0v%V#Aj-w#0z?bfuIge1Y&OfQ`1UlT7heN+fYBk zC^^TnuGUzC$TdzRna?&}l@msME)i49k9yQ~jhj2qC-(&NXWpgH*M%4x4_`h$Z;(}_ zou0~5sKl3;I8oZw-=PFC(%?{tv}p!u72}mfcFl1fQ|IF}s5KDT&3TqROUypPl2M^C zGHw^jp8FoB$cT`$YQ)*8Tk42+XQQE<%eFgijrMReC++3dvdId{R4zB+Iv_8`&#@+D zz_A$hStGGiXrv}SK6Zbbj1GgADs<%2S!*A!xZ(-dg~ZOs4_4L(6yyenf{;f-KI8A@ zU)tkcT%$TJ5SoBlZL(q(Zl2Pl&T*D`(^or*SG84=p9(i{YYl5h3Aob5wshDD+!$Kg z;V&tvdMCFoiz@9C%{(}^TWK3AE)b2%O=>9LGJ4}(w6Q$oblk&w0czy1gz47qn!1Lh zTc*+NmEE3sqhrt1lTvCBXOn0A!~)nKFb2M|<%2p+h(FzGDkv5GY6o&Y@8o4WW3-m; z(tBPG1*c5PxzWDbvkHs4y_Hl^`%N!@;o`Ojhv^)*}5uE@e?_2(p$?|PW9p!O$c$XSLyElBKh(`o2=h+-3k zksvddPv=FtHIWC5>#5Sm_ea<84eU3o5#BzezxFmH)G5?$pPuc|YzB8(1ShfDo!_?U zlIVHI{QUR=e|jytJvoK^k1ZZ$R`rDIF#WZR75yV3MsF_7#K&*Wwj}+OfLw?xh3gtq z{j2*!wR4OEirX)WiLW#7w)CrDNmnWOXf-1(8qm_N;cW-UREXnsjj2o5#;5oBB-GDO z9DU^2yuL8?NyLHE3$7cC%j0?;cmweezt3O9L+QMI-Ky{Uv!TJKAE5VJBKs-$Nv3M6 z0ZPdIS&sWzpG-w}RHxOJ6Ivt8oysXgE^euH*8;3fE&C{uHmXDe zI;C4U?np07aK{6^(&OGP;ZH*Cd73%svo2>49F|@-)pRF!wx3ogni!w;xM#4`cL`R% z{*Exbg>5JrZvj6Q_@a%k6;Qca8Rn`O#ji*be4Zi|di&KAbIk-_p1gCxgb#nZP(4bO zSmP`Hd||7W^D-{Rnq@LuCy=`)=B8w!q>FOD@dqgD#o|DV=bm@=vRFiZ2u^<@^i+zM zr>aZ=>K@dY=5XGfZFlYX+b9h=mhkqx2JSS?a69wcs0bOlx(xo1r}{gah8f@Q`!GbW z(A}7qylX1))O-?eq(@ZM&t&gRDLtPF0D6y{Nr6}>Q_u1Fm*`WvLd5DZhdZp40jwVKrbqX^X zFggj8;P~@7KdL?byw#$Efc1}M+fqq__5I8H z7iT|3?8{yatGjtT=jAgm2Zi@)&%JsGOeh0EImu}GmD)G2##1{46xOMA0;Pn-SE{3I zq8d&IWku~{AI)i{H?G42_SL!CyhI7TPQEqQ-sZ5~lP>2@6h&ZdQGsDw;O<=kcvHQ* zS1g!>MT_LK;gv8lWEE;xP^EOcVFfy1bJ;`O!E~+P!-utSYYVK23iDZ=Il8n!4ht)q zyix5}dT+_QWnz)TWma$JKz@fV!kFhuJ1h#{0#6Lr&lZW^`Kbkx)-=My7_9iVZQ{lr zoa=MwN4w!!@o;8mu#JWB7%6^|e|hCdL~-j{QV>ygF>krHZcY96noj5v`$wC&!e1+i z4Gx;iid8f$b;v!VFVPiAwqG%L#_0UAQTS|R~HgU;LyaxVh0%izX+p?m_T&11S*>spFyE-Xx+tfRrW@0KgvR2*`p- z1~_72NbrE6?6D{Z85tDT!R}wL2$Ar89-iK0*Nx;O5)clq4m6iu;GzKFM2G}=M-Q@_ z9R*B(Pfw7`XoKD!0p? zDw?}*NE5%r&XuJ28ieD}j_@q*gNn>b?TR)G4k-tqewm*%O7<5Y7%cV| zIWz!17jLqM+2E4-*@rY5^NU|unP2B8_iOwB07Rp0@&RB0S&)h6Cm$$4T6(h_Qbt;K zvtJY%E&IcoQ^0a3{FC1PQ@{li(WMCBfy9?0xS!XW#qY zn~$}oS9NvQ-_^6|>gvC72(mr{GVugdqQC6EJd7DMuk&>|RBOwYwe7U0icNorb@97= zl@jfYHWCdbCJ4i-{13k)1MqcF! zA$5XH-elW73s6Mc;L_dA+YP+IhKFu*Z>5YSmJFbYJt0KrQyShnV7@*2www;S3F*p9 zs&sG9V|fn#(wI1kBCK0Axf>c$?$5Rk4)Z6PWuEwIQA+kSGhbQbc$n5T=@3Z&euL@D zFM$E=AY;r{(jFf-aL7B(*s0-mS@X;YOIC|V=G*hFr;^|iGH9}|?F83P+NlbcYz_7; zok7zrrhS7Q=g-oN0foFpZkH>dXgcjWg!P;OJ`Jm(6BFUUuAZQPhisNUBLkd!%Dvt4 z4NfoR4vmNjalEPVU13EvB52%UK>Rb zS&bV}zirn2%9yHH@8-O5KS@FbOVv{V_ovF7A(@>xja=(BJrk3)o(?}yK)3J1#X#eb zk>h*iv5$!p{$2~yLxLqhn|?tbv83}<*b&5R+LZPL0;>Xl{T3Sf1SzABwBqH48*7kr zjBF4S-a>7nmYfPwc*mJ76h~cSBbfYCOoAwOM1zxhSknmNh-mP!cNnxCu1On|f#8d1 z(!SESPv2o7i#o@9hUbex<65^65Q6>a9AZB>8%88c?&^5y@9KONixybPnw&nd9LY4t zgi9)6rDJELA6_|wed;X4mRM`&?}AUTD8c9IR6Reg6w&tTj)dACPnXS=E`u&s{Mv9h zlfQtoV-|ACeocDVgM*tX{S;aTThvPBGe6RXC=_x6S&`7%&pZ!6kTkO-8d~FwG8Q8} z2b~S9b6+;ZQ{CiXLRu~Y1ej?Vh@qCtsoz16^>M&ItQuR!AYH*4u?;F;;+Q>mIObvB z6xbjcqPjqp%fosxvIq|=D#TIeM%ci;L(a4nJ^+ZWsuR6VK6#5>tYBRO5;JA{qW5V?S2i z9WFg6mqG`55CokaqztaJ#<6VqKv9NqRFr(!hkTG~3WOG&SKpTm#-)#!PZnY^9S7t* zFk4$L^>gQF^^ai|6k6>&+Z%P{SnzX_jv$k-N;Oa%5}G8~{q5h}ykXnyP?t4RrC9k= z^))3JLgM5dy{}X|x1Fj(GJN(gwAS!C_$3r^OTsk~K+d!KU00U?MeK(Sv{|$nhNAb5ZQwJWTY)PU{2t|mO-fuZgW08MS*GYV0NhuHwxZO4e z;^`cjJy+t6H+sY8i%#L8b5tcEs012ri}vp`$77==Fr7=`9C+$4#64~*LWvnD=2p>Q z?xtUqfbPhcJeDzXQX2iD$PgOy9T2s#o3IwoMrcrz#TGYRUew+Mb76fsK+A=a#)^G6 zM#i$+KYo5QGZY=|i38=SeO-4kqC>^FHesOHafoosP$ zeG0!SKvp?AC{i0}HAGoxO-Jjs(k3c&^ZT~jYd{#k*JXExc*KInDk5ZzFsEQhoK(p9 z!3`>1Ih*eNw-jAyM~Dr05H_YEImIb1F0@WGoA}h?bRn5zLVG za%Jr!W+Yw>(VaG$f7+$rC#J@p=apDLl~-x)f{o1R_esK>*&!cV14lALbr4v?5MGYA z$_Bw71}7+1G_j*5otHXIlAf-7v@}@HTm{O)t<$MyQLmKvqLPV%_KOQ8&!ODh7Nb-s z^=Ie%di}{_S$K(Jts{rGdEZ@BBg3ctLY!?V2GzefHvEkFyj;3o>v>D_8LG{ZLClWi zz>_T%CQOkTXTFpYy=QlsRGp};VZM)0AxC#)aqlUEe`o(15pJj%d-5Hj5_njyqwoa8 z8u#WcwA1L<7@Q7v8i#HIXu}UmMG)#BB0Sv{1-E8?PKFY53p=YJd6!;ES79S^&6Xll zK_y2dDTQ2XTWVx*zUZkvYFX$h>JP{Ma(y@4noK=(hg!uBXB$BV_1$Dzh8{GG5J!?^ z<61A^K@@iC&@4msSWx{T5jInFjQKu@09W0Y(QDrNN-=K(_xzArx2j@*A_|g48bc(H z0o=f_Az?P6%NFoW@O^bceq}PW(ntT4T0q%V2Qw!*u_tw;g;&vRkZ77{hk{F>YsW8} z==p*yBqVr4{^zr?3XMIx{L}B!4TX{$Z~d0mrz z@I1wj0<$|7oLOGB@&=f&RR?R(r+nx3GBwqYQ%jD-4kE|inP9y=E`t2DHy$2MQcPXWL;E}u_FSH;(cTXk9yLmM{+=lknRIa3rJj}K#DMb zDwT(mk-htkZc`W%aK{tzq;d>7%LmVi8u6<#PV7!dms=ks&WKrc13NAZo`&y-NRlDN z0h;aBFOiD8@eW!$TrK2QPa8giByY*|^Eo+T0tDGGZG0&2&tw-&33PAa3BZl7nM z#;~{mm+1#@%2m&0`98^CoTXE7MJXY+rfUqVpGm`=;R{SUjHFYdanmDZJf_{u5FxEk zOGF2t_n}6Wn7`81=Mk_|-#!su zo$S#1xp_TYd?EpmOXR5JpBj(|;$lw_Yr55u`0%gU!ZxmarSUX~EOYcnX^={vx_^S{ zilgD`HZ=0Y_m=1GLb;W*m|rPRYC4q+*V)ZEZULR!P35XKnk54KHlT_8MobDVn4| z{S=>p#xUZ(z*x%(GBw{yVeO5#Ol8li(C86nR)=(>UI*shB|LcH`mlek0Oq7qgFK+` z;HG$@GVgJmHqA%o=iRQ_c{QlTd@Z?8uwZ7IE(@2RfMf?K<&*l zl)=L{U`%N&{5=x1!ZtoNFBZL0AG=2q6q(%2rf>oXF-XeVd7I8TLK4Nu;CKZ^Dog2! z#IG@VgP!d!T*jWa-;Z(GyeUfY5p(?RK;yCrlO;ttn%H%HcZ-Jv(} z*hhUJx0|=^MC5Xw%V|Q?fqN_VbtcA%CXr++w=a^=AEduoB!+iNpFRl&u<%;fksJ79W3evKz z>^)IqDh@9i0&c~M-d0Ys;@f=c&jUffS^dav277_g!Ec+F}FwJrT|d<{-)&M z<_7$i5XkknR8Wvj(aPDz)0P6r4R%JM0eR^zCoi}C-lcAgTc*CFg)nYp%l*Y4?PEh~ zQ>9eGJ^?M$Z)>Yj{B?}slE?9xuM85Zc)M*^j0nrtGfz0EqkxThD^%(yPmnWuWz>m| ziFUuB)$Gu9Z}3u8aNF2^->#b#K608|+8}V5M4Jjv&?0M=@pk@XIZqhw&|=sbR2j*- z5~v?dwOi2}G49-)CO9$P(O_Y7#l0h?uUJccbvS9!NLtZyu;^kX;V=W!No6+wRVLnQ z{L!t+ne-z3tIMVXq={crVyDB062XK;{Sr%xw!0iWnI>f#!%{|r+@8Cm^;6-xEFY1^ z<<{Euu7`8$2Ej!yg5f9|MlDAcP%-cxU5FT0PehUDhBV)IY?4SMq@zLuajl^w#34U3SH zV7L(u?9gHNTpF-Po{M#@1zG1%r+$`@L%BQI*y1t*>(t0i-){M#-nuXvs0@Qbn(9rW z`uO?zLi6*qNAs+}b>Z>6*2@;HfYyM90Gcb)Xxp>1S`xWJsQj&Y;w$yFVDNL zTG|y3B|B=5c6VJkP$s$edpj0O14zRMTI!Sz$+9$3uII2Zqbjk|^*)A{yO z$y1|%ta{Skg!*ha5+tq~8K`L~1CrEIoXP4v+hP;Dudy$hixf>6{`lLeqfAtl%+w!C zqLu8B!TwNEc-kAYzmCNk>5a~GjZ)DI;zIQsho;(46fv*E^HkoDz?sn9dMn(f?BQVW zr39>UOqs=7;`?F2YngBbTrV`k|5#pd_%6J4MAe$2eZRr#j?LQ@5e;(e`*Fj4i%8&` z!eYNs$Nat@I_%qwWz(Tj>c+y8rgJFX5HMZ%Z9Y?XDoGMPgB?5@1EA?^1uU)2QnsHJ z;>3xRv-%#?Or;&$yPi1WX|hitvzM#_oi7-<$mu_>+@b@v&@*UVju+}rP!;XB zOu0SIt+-@--YGX$50Qds?U%{WI+nFDdM*)mRTTUEW{{^_IG5U){b+sJ>3>+YD@I`8 zZz1zCr~JxSGY(TrR6eT+&ajo>)kH7Ipdf@-8Y2^^KDwf10>|M$PX!}_8s35eZ;M-@ zbL3F6ZOO{S4CbBoef`d)x2%=LGmMn;seG#@JN zBF?XU7!3`xZr$2_0C367WRm+h}flG}Fl$ZTi31Gc|4V~sL_R(PqZQHhQr?GO1wPb>-X zM-gXj42}(_Q+~#uACIcO$&63VKihlEpWIVpwW0q8Gj@GY@nd3^C2{SjKS+=hcRjh+C9iEQ{!7*Jfe{>| zpE*6XFn_lD$N`vGl3nOrlYBYoXTPZ`*|F2I@S1Ug`G>k;q#tQckqan%_o?3Y#96$- zV*6_(*!YsiXg|<$#FbohMx`dc(7M8G3Kih0vTetI{}|JDAE3#6D>{9h$w-L_kneAzMo0>ftFg^WNsiSk;DJC1sT|pv>~H z+5=hZ=Sx05pPq=QHGRkMg6L2qcazK57nKO4InGB2Iu9GXW5uBw$PL}6z?nnyp?>Da zVQ(-wvrgX7E^XlT692SZRF=to952DPHAo`3K2f5ZqSY&6=*-ksYw_&dPJb1^plJqj z&L0)?Je5KGTH2Nuc%y>|5b$X{a)beIxhN65Yt<^+V=_FBJtMohn1H*jC`a!q&%F)K zG_$}I1fe*IOU9Jy=7Yb;I``O)C591mykr)i60ROdtQ=qTfkiXNUAQYh{Wt@u#rZ~p ztI3IAfPB21;8QFQNDi<$HZ}MfD;NsM1%}1phU5eb;wZqezlH+pNMI9uJa9h_HX@rk z4-(IB5jY+PA3T7A#roe8Vd4LdAAtXgAH>Z(tfXC>J=vsnR8_?Ez+$*mU=1P$XdpW~ zxSp68oKFOgM#0X*``Y67{q+I^NvPogug^TMD#duhnq1rzT)!{CZ{hFKU-#c7cJ|-+ zUYovt^Kx+frN_mM^p_ULZ^>(`zqUlIL5HBE%W|62U7ez}3bKi2sDDj>JS@3tVEb%d6F4eAHLV=%C*N z`VIg0^=E*uzWH7L+ed!}_{S-KJLjK{`Qx0w{Q0+G01^=J8rc0o^or{5q5KQstMYHz zZv$Ka&>x_G-1*zBf8hTa7SG>m|30waWj;>MKV7}HdmZjyj`{2UiUjFj6ZU&L{tNdX zQ-9K8fpXp*}=lLJA`Mc4-&*z^`UOW2@?N6t_I|hKCi3z~0gs8B8J=Nn9{XK^; zf6pNrCKoTK5fYn}vxSSL-D?Vq9SBY$B!vWmYYAPzhjI*X|NT3~#}yZM@ikxpvQx0I z19>TUxn3uq69`t*z`^7MBC$!BxyoAE+1PsikqR)=L9&D0NO8dp8hGGX3XV4(u4Wci zY@TesZ2oW9e!l|Jc8*pY6t6wKzCQo>MpSRSiA7;Dp2> z4LeW8GL(4ga>7oVm3bmZpFwX?D>XK#aC}za)#B2fz@qQ{8EEq8iLtRNz zLjy+^9L#sx3QkSUl{u_gA8H;xMrwJ0zc+wXy8X3UPlaw)&Vu(k_oxwV=tF5n4unC4 zZJJ4nB!oQ_6jaLDDO3%U6IOz<)}`22Hp+NRgdh&qJ@!UJMAx0Sl^)-|${Ed0r;1Si z(4@(e<^>n0yQp5Qzy34N*CZjO#%49@vTO&4vp&{QtHJd zuu=kzX_D?@e^9F@zY`ds9T7Lt^UVhFUZQj4sXu{65JNL4<<6B;=*IeIsam8;V+$=l zyImmTBko~KLSV{%rE9?!h^C;*SdcxY?23l{OlMAB|KXf6Fq$Qtd{ae{wiJ`*f{?P; z5Od~AYJn&kFBE>9`xmwQ)r$b_na58swhlsfj{u64R@ zGu*gR4#!mw(Rj=|yi-Y8R7t=C{O3w5xZ+oM>1&%?D-CAW&wx8$93g@oKpqE6pf_0{ z7fw9#JU(KAsX3ZjJ(p514H z<&4!rVfdde=l3f)4|_{0CQiZPlLf^BI2Z1Az8f7MzhOXxD9No}TJON_!)*T|s+I=( zE2nbf=Y;r7HQw+lOp(8-o6U+m=(e#Oe6*QUnsZz=$XZD|38p#=Z$XmYFjF|IW_lX8 zI7f~*3?f6Cui|gxaKm!}x$SVA$|KFc9%XzY*4JR9RDWjfR zo@trSL$dD|_wgvoe__k+O+C&60CFFe)j5-Pl0C1vHYOG-w|L^MskVpN?ZT1RrvdfR57 z9pDAj8r7~=vw@+;If(s5`%|4!rF0Am7RC^PSaspj{z?TZez%KMTI1eag{|_!PzTpu z`QvbX+ZEY9N=Ilv8>rX3rdrUfkvqjx6hC_uKuSnVels4qmrJXT0I?A-X}_sQXt)Fl*dj<6}1dy2No9{rk+oK zIGl5s-Co`cZYm5C?1ur%!D?(3L4X~$Fb=U}jtrK@ohKd}9ks7=vO3XKv`NsGMfOP8 z+32+OZ12bpY^S(Um5*q>cd4jb*^gtHIj<{PzT#*mBv^faAGUgsW?16A3i zeGKZ(^EQPw??V4AdQr3P?VavzXOgX8?j)-}`DBo64v1j$lD}J}RW3sCelu8NujKiG zG%6J6O9HH`7PFRTRSZQy7>h|SW8!GsGIz=M?_>Jj{|SaA&luvUDTj7ma`9Up%mZbI zw41S3yj&erVeKRLOvJhpAe}}-)){b1Tq6Wj5XW4U*pQEt~jWo=mTBO9za@7_0U2wigH_Ap`?hOTn z?OQ}AQiC8;oL$sS45QRw{z~Z}tiw(3Uqz*$oTrw~0(AcZzHfoUi9w2pi@GK4{HbB< zV%D#zRl`24oD4bAU%Q2@_Wd6HNq4MM8vm$sN#mOXrxx5E+f$Yn$yQq@qwgnY_PUIZWK%$l0#tI4;Y1)Nf3)`L+4(gAt9zYcgD>L|1I(YGr9hCP58*x{r*95wdbaI4zfY|=SF<$Ze193%&jDcWZl&`Gzyt_Zcxs0X*=1-A5^w>uM0G z3$s~Ih-c5aA1nccnZ4U+UV6V|?A0CRXbU!w1;9`~3AMnKE7zy;RX z&LQ05Z2_N6PU>F5%y`J^TgBluJVK2;Ym`)6Ry zBJSd7`6mYY6H)LBahR(eWa&iFsI9IsXZ%{t;mzu}NC} zRrlH$>>^Kq1LQ_xQ?m2$cn#xp>?~iCl&=9LI7?m>0m%1Phy_+d!2uspFoJ*_JRJWX zU1>NdYUq%Nq+hRb*Wf9%^AAo}2*zrPV*0h+il0Lw?Q>hug)*rYXy#LSIWhtPLUjC* z@`1Q3Qz$w4Z*5J%N|wX}H=3#hAKK6x2rimm?3CraS-ITuZZ=C>_a2`U)_=Imo`&$g zzf$Df!Oe2q1)&laAXoY2$;$M7j-&<)4F|A0dXRZ7`E6B->(UM|-i?g(v$K7i@5Rqm zQX$0poA`xnJVr z6x?we4v3RV2{&Scgbg^>Yaa7R`_LSdlX#Ff6s z;xJ>jVlG)AU772JAMr)im#;B6Xh240*PQkQw^x*lN)oa4u)0#m%HW3=r+hvU9}U8i z&ZoRFqg=~Tqx>So&?P=-f$R&k_v7rtvN+ion;?zkiCNx|!+jwllp9|nCeilToE(U- zP$xTRwg&R9c0BFPz`WPvMWZ~PU9OTM#cE++M|~t|y*2zqvHb&8hYgFx8Z+P@FHk!zu^a1R}*itNo|5<2JP$oUpec zlc0c1e-EX-Etikk&1N@n^L4|cfjGS;(M3s~+WI6rURc$w`tInu0(Apkn7LsQ!jZP@ zc$_u0GR(yvo(?mRhMYD~8wtDKVmhQnRnvl{{FCe{q(2U?sI|3I2nbbEq@rrc^jH%| ztdm2Xjj@#6*?4}t4l}4!l+U1ApbW3bn*vFpq)L@d6M7=EnBqzIXO_)RT$@ajB5%H6 ztw7$zkKfO1dWALHn`^-V6sLsg0?b5$cOx`q9T$5$Pa7OeDWnk-WjdrXHV$|7SfYxve7q9Sm_gdA zE;{Hz=|9isc2AjEn7+x!8Yfd-e!Ers*w?I)KW<5{5|5R5>_<(tI0WNp2@i?on>@>U z|AWCpeQV~H8T55atR3#t>7Wtf6S2uwdfSWQe0lZ!9N#zlc9Q+{$8UcLc7?Qf-5(POt`H z1Dm#d59((|#T~!!S!o9xe4msbowuN+HigD5hr{*3EbU9!pr>XVF?Qn#hj|oBZ~V!O z5>=}4X1yLMw5nszAUBm$_hK}9#7@ubxg6hrENHPzQ*Pk-1L}w_B9quPLa12MCC9Jw zZ)ye7COJCs%kJgrhJ+TSPei`PYiT`TtlAz_0sl98UKCWdZPF=7ZD+S2J^9{n?zeS+iN&z5aPy zu~|EUFPJ}K{!XX-+y0v!@Vfuz1aWe6@%;M|p@XQ2qw~F{<)8vfFI+h~%A1;jssWLK zLIGyc(nJeG(^AV$R1$+q&M=t)-OF4u9vIq|{{=Q$x+uR5CK-VWGilJ8-Yzv-dVJ-u zYd6miR@r)2WKYCq0<_UvS)tQ<`f%F4{!|k+LnIR|NpFw&^cJF;7qi4o}Xo9D$N=3Er$b$dv)&X%&BPcqO-eO^}k56<_Oum|5aFZ z9GcB#chFvncI}a)sDq!;6J&k}ZZK2QFD-}F+b*%Rv|>_c_mG%p&~{ldB}&a`-!x%+ zeo<7z!QD=62YnTAQ1i~7^j|0Wg!roaHQVO!c&nq=DQ%~H5jj0wS0jZGSGrw&SCf}3EGB>D;|EO| zD={gx#*en6$uR}i8VU?d_HVc%^`-qZzH2f!M>P~|F@VTN)AW_^)V)*4cT~nppcvro zfjhFW>dKlJTnR{}yBd@!9JuoBsvlD5OJoi-kjtY}AgyHO%6&e{r9@>a5^88LVB0ee zs{belr*L!SxR>Fiu;MC)O4+F)e-uAVwyj}M`DvMb)Q0;5E#X1Qk@-E=UhG42Xj6+r z&is9)Br~W!kw)%%Hq8_2iSQ|I+B`G^T9NvSn7H5BJZmU{oSgre-ihbrrs;tmfPJlK zn*k`csKTxUmo)0^m7F@R3a$oq*m%|+aUVPv?$xB{>y({Ud{TLN`^Qa?)%E;QEyZ(`-ybY=mm18KEtrr%t z(b&B%vDAP#{b7o}%`w9>n(6D4(B`Yd$L9@l7I0Z*?U+LMdNSvoFxjXpDI&b?>w(?{ z5HrKC_lhHA-yj)`DG0Wg`3PRn2m(o7sXtfP4qQ+q8 zJJF8At*LL~GU^6nXTD;7m)0$_mu{R~jfz~H#JDZMpG*)(5r|yF>$Do*Rg}^lCPD{o zZ7T|xQeyPqhd?&oFTeXxwnOiM_U2lqF|?AjOA9`FiiJ{~=RUqTzSWg(9-4li3CKm9 ziHWQMFAC$l!GZq8tliN5ER1TNHnJ`!Zf*&j#w~6JxKS8@a(qi4&RXXabqp0W^=X+) z))k_78>AX@i`E=EOX9WTWT%wB3m*+)0%?>ZTHZqRh>1_|wb-c+s%S;S)A#Wag^EG3 z4@U}C!LpN34ei-}i$WZFfj}nAxL81n+)DJRK1aFxbO$OVcTRqE-)zOa`S#AZC$8zq z+x^x~1e-Z4mUe+S;5sv;tNHr#sy(0ZfGKh_F^}&&sY1PScvg|oKK2xJ_gNn3k&0X) zcU7K2Jtjia93j;BeO}F+VkFg?arq)w;l@}Bk&8b1y{x|r<3romb4bWZ+56XXsrI1k zH;@BaK5rNMuG!TejHH(3TQWZ9e>+MGsGB*riF>O^$oV{kzfpqqiN*w=WgjDr!>FII z4os7pzc+LEl!3net8Gi?dELwigrz2QW6Cr?HUdziJX`o_q$Wis&-Fgu;HaBwXJcA$ z@gY)}|EC-7k?h$kj|vkI|Jl`D<;U3j)b$MV^iI-?7pg0U3ig`2UC*m0=FVx_X`75r<04F&FFWB1*hR5VTVr2-Z!fSn0zt zVK*6by*8V-1e&dyv*lypx-YZXLeyY80Cid7xRz8a2i*!+JJ~;U;lqmdT7}-+GD}1^ zOqCyC0Cw{H;ziCve#mgxQSg4J=9A{Aeg?XCpsr!mLK91gmV0kdTq14JTO&4XugY6Q zMj$B1G$KID{vC_+cg45XAOk3(pX}n&O<$1AfR4uzLaWHjam87;U2=i#$Te2QI!Z-> zIe7HJPepMyhMZ|}8WwXd?Byx~6?}SEZ+}@wMOvg>ZIu(GB{nq^stMwn1BvV~4YOeo z1KU4Gd`TlhcN`5!q=j)9r4?`EpR=|q9GEl}LbS_EyevV9xwUmN11XDr&+OOyd{1X` zlxot5W?tt#Bo2VEv!N##y=Af(!aly@p$j?r7~~QE3uR589h_TI&rORgKvXqilRLxa z*SXH+ojmPvd3{ni_T*Y;@D-#r;Iw*&cu!FO;f$1@GV+Wt6~wYDD8WNlHo|S`qIPUJ zdOa0zW+eD6WML@10c5^I{9&sp^yaD6{A3(9uPQ*qGe{ch(xy7AKiH+BvQ3Nafpb^# zl;tPw(x*yywpfgppiuY!KC>WAWYd?*n-xQuNd1K{B6s-L|Ku z*;pl#^j$9VxPl^Ze)9W{1iAkhXuK<%u@6=816Oc24(W%N2}UUPp`h?DZ{(=Aa~N%R zF;2tRdrvz7FyoxP9#`D0ntk4wmCIPTwxXT~z<&W4cNtekp<{m>{Y+dl(mB6-77`~7?wfr9mx zAjcSA>&?%hax~rW)jAh)ypY9#C2+jX&dhjl0)gQ$y}LxXF6z!qqwdXm`!AbC+frm> z5wZ;{X!Bnn9P>G~qCzgXE_riGUw+Z6j!ejrtZ9l?2~iH-=Ga?x-#iH;a-(&_?$XJV zUB^p5WMbwo#tRO^D9mDIorL@DP}(&nf%*{oq1q&49myd7hl8!G;~Hz{GuNjCp{SE; z6Gv+DYS-KhE<0RQ45B5Kx320ldkKMh-99{w!c+mEUdN>?Gek4;$?#O<9kiZjmdsmc z;U19U`(7*BV~v<#?Y@n=49*I2UWWX$!pg|XNt3(#VJ^?ScXr527bt{1v~|2Lg|H8% zh#b1DE8|Wh?(mdDuGYu|2zH_!-|vEX*PUr{Mh&od)~t#LMCj-=S-JbvWvb#=Nyox! zSd(->^mDr_;v$8WsXCbpj&NCYY+N^T)s72vSt=mwZ)8ZE_A)o`^Ew~B#tWoj?wNu3 z!?GOb5g5+--;s$e4%pes{OX;0`vjU39=3}D*=%ED8J{sWAASvHD?Nk_?P((DS_}_a zn}%t)5#_#ja)n%jnXP9jZvGB(>oLCmA{UAc+61Iy{9>@wT3b3{N&>cIiOm^9z;sc) z9QU1aeeZkz&KGMgzVm|fmL@@xWmWPe+CbW&DeI$%*n?K?LQA`%cU3+od`W`^kt@aR zwPG!9yO`E)NOed2pQ86Jud8A1U83F^CYJT-gb=nR4GYN{9CwZ3Ls+@mJ;MfFm6z9O2R zTk&QZ3CMEZxVlNMZMLJGb_WX0;$w?dGKncLP3feCc(`m-Pcnn#8>%PoC)Wki=Qv)F zzSF-susn#N7ch+V&!vtW9Md9ZEh&_>0HtK7r_=*E*vu4o-6a&>7n@8xABJ7g>c|DK zBJ#FfYN}V8sPIRriQJbTFTKk=v|v~pgI!CPG0J{XA*->b#15gO`=^tJw%cPztP!W6Xfxc zumnMv{`i`w84-RtB@@1;F6gu5FPq4)MD}T)V#ZSBK~@-h+^1sXK)2Lw-1zx^4=QSW z1x35;Fb|p{EG-r$>|YhWPNA~#QIT7Mk4OMxIH!*oVSUpJ98W;VQ>%_sx%*gVkfz8e~0 zKcykNlBt?o!yl|QA^a+A{`2{q&_lG_4=Wr4{;Qp!6h{>PdDv%2!93=&q!JJxs@doC zbz9fnys*yQc1x52HR}-;j^i^plVte;)q4}{xSxQ&z0VA%p_=^%=-=?kV|wch3`1u5 z5S|8*BU$~q+}$E5gv=f!rd#W@P_(9oH>+b!E6>sVSq?!g5g+HX+wUAg#Oqb6qg)0e zXynZA%*+&mKk%phT!w<;U1J9|NV#W4upF|uzz(vJ7P>^_+smS)9&$PZku-|G(8BCY zi1{ML`goe5RrSfsMOiXsI0q7~(m#@?twx zeExMEFJp_r<=6(+&GB_RNQbm#MWQH@Q67zC@=k_KS~I#jD2ERvJ8Td30MCa&;Lf-|k8HeF!EC~;3Sb*1b zs?v1CvteqG%}9QHH;FzN2wha9H&Rl?TJTBaP6K z2$4`#d`?`U@o0v;*|#5ro%;%PGA9?F9#SNbcB@s~N;h0wi&v$LOZRfj|%*p!{iKKPma5(@g| z13whO8Fluy)O&i6vhCK;5WZ%`tmr!J80*V^OANC~rCizHW0wJt2 zIu(|C@QVcZ`NY$bMQiP7tea>`2`rLWWe=;p*(PZ)b=f1RZ}K}O^Jlx~CcXv+d4*NRBEz{+Te68zE# z!4pCV!Y-97LPW2g>1XL#=!Gu0PU_?EIt!9(*Uz7)$Pu!d!;BR+g!a4PtxqEM{LOYT zKBe25+ccwo0x!4m?sb0Fm@d{*>AUx3&$V0Is;PL`1=*goy4y`Q1Zf?eeP}9((BL6* zUKf~s$FHaR&Z3tTe-m*5Ffp#iy-bOsLP&bxZVG!Hrb6yT#=poo)^V0h+|3n}p)@c7 zKrW=vvPDmXo8FMz+I_Ew&-@`T$H3chJ(o?SG7-H`50O=Wa8)c_`z&gWFzX~6JSv}~ zV^iWR3*w44_G?6JS^^y3D9c_W zKJI*?(?f6$US5o0RpZ0SOBjd7V}q*38xu=o0r>~ z?~fU}#vbEBNZD7bZ(a{uUTNW;b}r76W}a3IlKkudb`Ah9kQV^t1pYBi4*<}=swufx z{@*mfA5AInUO~JO7XEvHzV24mujHTC^O`kNVo`1m?pI>i?+=AD1=61ake7#p^B*z* zH#^@e0sTMp0NeloADGXK7R2{T$N5LyD+TEFz~?{oU)g1^grxtJ0l4{que_}P)B|v_ z|4%(G_E(PCf9L^t_}E|bhJaUM)W5(3xH{2 diff --git a/zlib/zlib.h b/zlib/zlib.h index 6b7244f9943..8d4b932eaf6 100644 --- a/zlib/zlib.h +++ b/zlib/zlib.h @@ -1,7 +1,7 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.3, August 18th, 2023 + version 1.3.1, January 22nd, 2024 - Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,11 +37,11 @@ extern "C" { #endif -#define ZLIB_VERSION "1.3" -#define ZLIB_VERNUM 0x1300 +#define ZLIB_VERSION "1.3.1" +#define ZLIB_VERNUM 0x1310 #define ZLIB_VER_MAJOR 1 #define ZLIB_VER_MINOR 3 -#define ZLIB_VER_REVISION 0 +#define ZLIB_VER_REVISION 1 #define ZLIB_VER_SUBREVISION 0 /* @@ -936,10 +936,10 @@ ZEXTERN int ZEXPORT inflateSync(z_streamp strm); inflateSync returns Z_OK if a possible full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. + In the success case, the application may save the current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. */ ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, @@ -1758,14 +1758,14 @@ ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. + len2. len2 must be non-negative. */ /* ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); Return the operator corresponding to length len2, to be used with - crc32_combine_op(). + crc32_combine_op(). len2 must be non-negative. */ ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); diff --git a/zlib/zlib.map b/zlib/zlib.map index b330b606feb..31544f2e93d 100644 --- a/zlib/zlib.map +++ b/zlib/zlib.map @@ -1,100 +1,100 @@ -ZLIB_1.2.0 { - global: - compressBound; - deflateBound; - inflateBack; - inflateBackEnd; - inflateBackInit_; - inflateCopy; - local: - deflate_copyright; - inflate_copyright; - inflate_fast; - inflate_table; - zcalloc; - zcfree; - z_errmsg; - gz_error; - gz_intmax; - _*; -}; - -ZLIB_1.2.0.2 { - gzclearerr; - gzungetc; - zlibCompileFlags; -} ZLIB_1.2.0; - -ZLIB_1.2.0.8 { - deflatePrime; -} ZLIB_1.2.0.2; - -ZLIB_1.2.2 { - adler32_combine; - crc32_combine; - deflateSetHeader; - inflateGetHeader; -} ZLIB_1.2.0.8; - -ZLIB_1.2.2.3 { - deflateTune; - gzdirect; -} ZLIB_1.2.2; - -ZLIB_1.2.2.4 { - inflatePrime; -} ZLIB_1.2.2.3; - -ZLIB_1.2.3.3 { - adler32_combine64; - crc32_combine64; - gzopen64; - gzseek64; - gztell64; - inflateUndermine; -} ZLIB_1.2.2.4; - -ZLIB_1.2.3.4 { - inflateReset2; - inflateMark; -} ZLIB_1.2.3.3; - -ZLIB_1.2.3.5 { - gzbuffer; - gzoffset; - gzoffset64; - gzclose_r; - gzclose_w; -} ZLIB_1.2.3.4; - -ZLIB_1.2.5.1 { - deflatePending; -} ZLIB_1.2.3.5; - -ZLIB_1.2.5.2 { - deflateResetKeep; - gzgetc_; - inflateResetKeep; -} ZLIB_1.2.5.1; - -ZLIB_1.2.7.1 { - inflateGetDictionary; - gzvprintf; -} ZLIB_1.2.5.2; - -ZLIB_1.2.9 { - inflateCodesUsed; - inflateValidate; - uncompress2; - gzfread; - gzfwrite; - deflateGetDictionary; - adler32_z; - crc32_z; -} ZLIB_1.2.7.1; - -ZLIB_1.2.12 { - crc32_combine_gen; - crc32_combine_gen64; - crc32_combine_op; -} ZLIB_1.2.9; +ZLIB_1.2.0 { + global: + compressBound; + deflateBound; + inflateBack; + inflateBackEnd; + inflateBackInit_; + inflateCopy; + local: + deflate_copyright; + inflate_copyright; + inflate_fast; + inflate_table; + zcalloc; + zcfree; + z_errmsg; + gz_error; + gz_intmax; + _*; +}; + +ZLIB_1.2.0.2 { + gzclearerr; + gzungetc; + zlibCompileFlags; +} ZLIB_1.2.0; + +ZLIB_1.2.0.8 { + deflatePrime; +} ZLIB_1.2.0.2; + +ZLIB_1.2.2 { + adler32_combine; + crc32_combine; + deflateSetHeader; + inflateGetHeader; +} ZLIB_1.2.0.8; + +ZLIB_1.2.2.3 { + deflateTune; + gzdirect; +} ZLIB_1.2.2; + +ZLIB_1.2.2.4 { + inflatePrime; +} ZLIB_1.2.2.3; + +ZLIB_1.2.3.3 { + adler32_combine64; + crc32_combine64; + gzopen64; + gzseek64; + gztell64; + inflateUndermine; +} ZLIB_1.2.2.4; + +ZLIB_1.2.3.4 { + inflateReset2; + inflateMark; +} ZLIB_1.2.3.3; + +ZLIB_1.2.3.5 { + gzbuffer; + gzoffset; + gzoffset64; + gzclose_r; + gzclose_w; +} ZLIB_1.2.3.4; + +ZLIB_1.2.5.1 { + deflatePending; +} ZLIB_1.2.3.5; + +ZLIB_1.2.5.2 { + deflateResetKeep; + gzgetc_; + inflateResetKeep; +} ZLIB_1.2.5.1; + +ZLIB_1.2.7.1 { + inflateGetDictionary; + gzvprintf; +} ZLIB_1.2.5.2; + +ZLIB_1.2.9 { + inflateCodesUsed; + inflateValidate; + uncompress2; + gzfread; + gzfwrite; + deflateGetDictionary; + adler32_z; + crc32_z; +} ZLIB_1.2.7.1; + +ZLIB_1.2.12 { + crc32_combine_gen; + crc32_combine_gen64; + crc32_combine_op; +} ZLIB_1.2.9; diff --git a/zlib/zutil.h b/zlib/zutil.h index 902a304cc2d..48dd7febae6 100644 --- a/zlib/zutil.h +++ b/zlib/zutil.h @@ -1,5 +1,5 @@ /* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -56,7 +56,7 @@ typedef unsigned long ulg; extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] +#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)] #define ERR_RETURN(strm,err) \ return (strm->msg = ERR_MSG(err), (err)) @@ -137,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # endif #endif -#if defined(MACOS) || defined(TARGET_OS_MAC) +#if defined(MACOS) # define OS_CODE 7 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif #endif #ifdef __acorn @@ -170,18 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define OS_CODE 19 #endif -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - #if defined(__BORLANDC__) && !defined(MSDOS) #pragma warn -8004 #pragma warn -8008 From 3d4174762563afcc2532e86c5a6c5686daa52fad Mon Sep 17 00:00:00 2001 From: Hugo Wen Date: Wed, 20 Mar 2024 12:46:39 -0700 Subject: [PATCH 221/313] MDEV-33574 Improve mysqlbinlog error message Previously, when running mysqlbinlog without providing a binlog file, it would print the entire help text, which was very verbose and made it difficult to identify the actual issue. Now change the behavior to print a more concise error message instead: "ERROR: Please provide the log file(s). Run with '--help' for usage instructions." This makes the error output more user-friendly and easier to understand, especially when running the tool in scripts or automated processes. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- client/mysqlbinlog.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index d7f3a39aff2..6abfd32208d 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -2997,7 +2997,8 @@ int main(int argc, char** argv) { if (!opt_version) { - usage(); + error("Please provide the log file(s). Run with '--help' for usage " + "instructions."); retval= ERROR_STOP; } goto err; From 7ff649315ec63cc972c542354c6e839617cc28c1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 26 Apr 2024 14:12:47 +0200 Subject: [PATCH 222/313] sporadic failures of rpl.rpl_parallel_multi_domain_xa it's a slow test, the slave needs to catch up, reading >1500 transactions. A default MASTER_GTID_WAIT() timeout in sync_with_master_gtid.inc is 120 seconds, which might be not enough for a slow/overloaded slave. Let's wait forever or until ./mtr --testcase-timeout, whatever comes first. --- mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test b/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test index da1aaea130f..c85e8edf1a8 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test @@ -9,6 +9,7 @@ # Tests' global declarations --let $trx = _trx_ +--let $slave_timeout= -1 call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); call mtr.add_suppression("WSREP: handlerton rollback failed"); From 288ea9e146a238872998d7089070e82f39272728 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Thu, 25 Apr 2024 00:13:02 +0200 Subject: [PATCH 223/313] galera SST scripts: parsing CN in certificates This commit contains a fix for the code that extracts and parses the CN (common name, domain name) record from certificates using the openssl utility. This code is also made common to the rsync and mariabackup scripts. There is also some systematization of the use of 'printf' and 'echo' builtins/utilities. --- mysql-test/suite/galera/disabled.def | 1 - scripts/wsrep_sst_common.sh | 220 ++++++++++++++++++++++----- scripts/wsrep_sst_mariabackup.sh | 17 +-- scripts/wsrep_sst_rsync.sh | 23 +-- 4 files changed, 192 insertions(+), 69 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 1f41e521bd3..a5a1a6f18b1 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -18,7 +18,6 @@ galera_concurrent_ctas : MDEV-32779 galera_concurrent_ctas: assertion in the gal galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() galera_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() galera_sst_mysqldump_with_key : MDEV-32782 galera_sst_mysqldump_with_key test failed -mdev-31285 : MDEV-25089 Assertion `error.len > 0' failed in galera::ReplicatorSMM::handle_apply_error() galera_var_ignore_apply_errors : MENT-1997 galera_var_ignore_apply_errors test freezes MDEV-22232 : temporarily disabled at the request of Codership MW-402 : temporarily disabled at the request of Codership diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 63d2d4ef6d1..14e058cecee 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -23,6 +23,22 @@ trap 'exit 3' INT QUIT TERM # Setting the path for some utilities on CentOS export PATH="$PATH:/usr/sbin:/usr/bin:/sbin:/bin" +commandex() +{ + if [ -n "$BASH_VERSION" ]; then + command -v "$1" || : + elif [ -x "$1" ]; then + echo "$1" + else + which "$1" || : + fi +} + +with_printf=1 +if [ -z "$BASH_VERSION" ]; then + [ -z "$(commandex printf)" ] && with_printf=0 +fi + trim_string() { if [ -n "$BASH_VERSION" ]; then @@ -35,9 +51,9 @@ trim_string() y=${#y} x=$(( z-x-1 )) y=$(( y-x+1 )) - printf '%s' "${1:$x:$y}" + echo "${1:$x:$y}" else - printf '' + echo '' fi else local pattern="[[:space:]${2:-}]" @@ -59,9 +75,9 @@ trim_dir() y=$(( y-x+1 )) x="${1:$x:$y}" [ -z "$x" ] && x='.' - printf '%s' "$x" + echo "$x" else - printf '' + echo '' fi else local pattern="[:space:]${2:-}" @@ -85,9 +101,9 @@ trim_right() y=${#y} if [ $y -ne $z ]; then y=$(( y+1 )) - printf '%s' "${1:0:$y}" + echo "${1:0:$y}" else - printf '' + echo '' fi else local pattern="[[:space:]${2:-}]" @@ -95,6 +111,25 @@ trim_right() fi } +trim_left() +{ + if [ -n "$BASH_VERSION" ]; then + local pattern="[![:space:]${2:-}]" + local x="${1#*$pattern}" + local z=${#1} + x=${#x} + if [ $x -ne $z ]; then + x=$(( z-x-1 )) + echo "${1:$x:$z}" + else + echo '' + fi + else + local pattern="[[:space:]${2:-}]" + echo "$1" | sed -E "s/^$pattern+//g" + fi +} + to_minuses() { local x="$1" @@ -105,11 +140,7 @@ to_minuses() x="$t" t="${t#*_}" done - if [ -n "$BASH_VERSION" ]; then - printf '%s' "$r$x" - else - echo "$r$x" - fi + echo "$r$x" } WSREP_SST_OPT_BYPASS=0 @@ -383,9 +414,11 @@ case "$1" in # option name: if [ -n "$BASH_VERSION" ]; then option="${options:0:1}" + elif [ $with_printf -ne 0 ]; then + option=$(printf '%.1s' "$options") else - # If it's not bash, then we need to use slow - # external utilities: + # If it's not bash and without printf, + # then we need to use slow external utilities: option=$(echo "$options" | cut -c1) fi # And the subsequent characters consider option value: @@ -788,17 +821,6 @@ WSREP_SST_OPT_ADDR="$WSREP_SST_OPT_HOST:$WSREP_SST_OPT_PORT$sst_path" readonly WSREP_SST_OPT_ADDR readonly WSREP_SST_OPT_ADDR_PORT -commandex() -{ - if [ -n "$BASH_VERSION" ]; then - command -v "$1" || : - elif [ -x "$1" ]; then - echo "$1" - else - which "$1" || : - fi -} - # try to use my_print_defaults, mysql and mysqldump that come # with the sources (for MTR suite): script_binary=$(dirname "$0") @@ -929,11 +951,7 @@ parse_cnf() # Truncate spaces: [ -n "$reval" ] && reval=$(trim_string "$reval") - if [ -n "$BASH_VERSION" ]; then - printf '%s' "$reval" - else - echo "$reval" - fi + echo "$reval" } # @@ -986,11 +1004,8 @@ in_config() break fi done - if [ -n "$BASH_VERSION" ]; then - printf '%s' $found - else - echo $found - fi + + echo $found } wsrep_auth_not_set() @@ -1128,9 +1143,7 @@ wsrep_gen_secret() printf '%04x%04x%04x%04x%04x%04x%04x%04x' \ $RANDOM $RANDOM $RANDOM $RANDOM \ $RANDOM $RANDOM $RANDOM $RANDOM - elif [ -n "$(commandex cksum)" -a \ - -n "$(commandex printf)" ] - then + elif [ $with_printf -ne 0 -a -n "$(commandex cksum)" ]; then printf '%08x%08x%08x%08x' \ $(head -8 /dev/urandom | cksum | cut -d ' ' -f1) \ $(head -8 /dev/urandom | cksum | cut -d ' ' -f1) \ @@ -1569,6 +1582,139 @@ check_server_ssl_config() fi } +# Get Common Name (CN) from the certificate: +openssl_getCN() +{ + get_openssl + if [ -z "$OPENSSL_BINARY" ]; then + wsrep_log_error \ + 'openssl not found but it is required for authentication' + exit 42 + fi + + local bug=0 + local CN=$("$OPENSSL_BINARY" x509 -noout -subject -in "$1" 2>&1) || bug=1 + + if [ $bug -ne 0 ]; then + wsrep_log_info "run: \"$OPENSSL_BINARY\" x509 -noout -subject -in \"$1\"" + wsrep_log_info "output: $CN" + wsrep_log_error "******** FATAL ERROR **********************************************" + wsrep_log_error "* Unable to parse the certificate file to obtain the common name. *" + wsrep_log_error "*******************************************************************" + exit 22 + fi + + CN=$(trim_string "$CN") + + if [ -n "$CN" ]; then + # If the string begins with the "subject" prefix + # then we need to remove it: + local saved="$CN" + local remain="${CN#subject}" + if [ "$remain" != "$saved" ]; then + remain=$(trim_left "$remain") + # Now let's check for the presence of "=" character + # after the "subject": + saved="$remain" + remain="${remain#=}" + if [ "$remain" != "$saved" ]; then + remain=$(trim_left "$remain") + else + remain="" + bug=1 + fi + fi + while [ -n "$remain" ]; do + local value="" + # Let's extract the option name - all characters + # up to the first '=' or ',' character (if present): + local option="${remain%%[=,]*}" + if [ "$option" != "$remain" ]; then + option=$(trim_right "$option") + # These variables will be needed to determine + # which separator comes first: + local x="${remain#*=}" + local y="${remain#*,}" + local z=${#remain} + x=${#x}; [ $x -eq $z ] && x=0 + y=${#y}; [ $y -eq $z ] && y=0 + # The remaining string is everything that follows + # the separator character: + remain=$(trim_left "${remain#*[=,]}") + # Let's check what we are dealing with - an equal + # sign or a comma? + if [ $x -gt $y ]; then + # If the remainder begins with a double quote, + # then there is a string containing commas and + # we need to parse it: + saved="$remain" + remain="${remain#\"}" + if [ "$remain" != "$saved" ]; then + while :; do + # We need to find the closing quote: + local prefix="$remain" + remain="${remain#*\"}" + # Let's check if there is a closing quote? + if [ "$remain" = "$prefix" ]; then + bug=1 + break + fi + # Everything up to the closing quote is + # the next part of the value: + value="$value${prefix%%\"*}" + # But if the last character of the value + # is a backslash, then it is a quoted quotation + # mark and we need to add it to the value: + if [ "${value%\\}" != "$value" ]; then + value="$value\"" + else + break + fi + done + [ $bug -ne 0 ] && break + # Now we have to remove "," if it is present + # in the string after the value: + saved=$(trim_left "$remain") + remain="${saved#,}" + if [ "$remain" != "$saved" ]; then + remain=$(trim_left "$remain") + elif [ -n "$remain" ]; then + bug=1 + break + fi + else + # We are dealing with a simple unquoted string value, + # therefore we need to take everything up to the end + # of the string, or up to the next comma character: + value="${remain%%,*}" + if [ "$value" != "$remain" ]; then + remain=$(trim_left "${remain#*,}") + else + remain="" + fi + value=$(trim_right "$value") + fi + if [ "$option" = 'CN' -a -n "$value" ]; then + echo "$value" + return + fi + fi + else + remain="" + fi + done + fi + + if [ $bug -ne 0 ]; then + wsrep_log_error "******** FATAL ERROR **********************************************" + wsrep_log_error "* Unable to parse the certificate options: '$CN'" + wsrep_log_error "*******************************************************************" + exit 22 + fi + + echo '' +} + simple_cleanup() { # Since this is invoked just after exit NNN diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 4e21270feb2..118fd6964c5 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -1205,11 +1205,11 @@ if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then else # BYPASS FOR IST wsrep_log_info "Bypassing the SST for IST" - echo "continue" # now server can resume updating data + echo 'continue' # now server can resume updating data send_magic - echo "1" > "$DATA/$IST_FILE" + echo '1' > "$DATA/$IST_FILE" if [ -n "$scomp" ]; then tcmd="$scomp | $tcmd" @@ -1320,7 +1320,7 @@ else # joiner check_round=0 while check_pid "$SST_PID" 0; do wsrep_log_info "previous SST is not completed, waiting for it to exit" - check_round=$(( check_round + 1 )) + check_round=$(( check_round+1 )) if [ $check_round -eq 10 ]; then wsrep_log_error "previous SST script still running." exit 114 # EALREADY @@ -1347,16 +1347,7 @@ else # joiner # backward-incompatible behavior: CN="" if [ -n "$tpem" ]; then - # find out my Common Name - get_openssl - if [ -z "$OPENSSL_BINARY" ]; then - wsrep_log_error \ - 'openssl not found but it is required for authentication' - exit 42 - fi - CN=$("$OPENSSL_BINARY" x509 -noout -subject -in "$tpem" | \ - tr ',' '\n' | grep -F 'CN =' | cut -d '=' -f2 | sed s/^\ // | \ - sed s/\ %//) + CN=$(openssl_getCN "$tpem") fi MY_SECRET="$(wsrep_gen_secret)" # Add authentication data to address diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 3dc5da7a48e..e386930c5b7 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -354,7 +354,7 @@ SST_PID="$DATA/wsrep_sst.pid" check_round=0 while check_pid "$SST_PID" 0; do wsrep_log_info "Previous SST is not completed, waiting for it to exit" - check_round=$(( check_round + 1 )) + check_round=$(( check_round+1 )) if [ $check_round -eq 20 ]; then wsrep_log_error "previous SST script still running." exit 114 # EALREADY @@ -370,7 +370,7 @@ check_round=0 while check_pid "$STUNNEL_PID" 1 "$STUNNEL_CONF"; do wsrep_log_info "Lingering stunnel daemon found at startup," \ "waiting for it to exit" - check_round=$(( check_round + 1 )) + check_round=$(( check_round+1 )) if [ $check_round -eq 10 ]; then wsrep_log_error "stunnel daemon still running." exit 114 # EALREADY @@ -388,7 +388,7 @@ check_round=0 while check_pid "$RSYNC_PID" 1 "$RSYNC_CONF"; do wsrep_log_info "Lingering rsync daemon found at startup," \ "waiting for it to exit" - check_round=$(( check_round + 1 )) + check_round=$(( check_round+1 )) if [ $check_round -eq 10 ]; then wsrep_log_error "rsync daemon still running." exit 114 # EALREADY @@ -481,11 +481,7 @@ EOF tar_type=2 fi if [ $tar_type -eq 2 ]; then - if [ -n "$BASH_VERSION" ]; then - printf '%s' "$binlog_files" >&2 - else - echo "$binlog_files" >&2 - fi + echo "$binlog_files" >&2 fi if [ $tar_type -ne 0 ]; then # Preparing list of the binlog file names: @@ -854,16 +850,7 @@ EOF # backward-incompatible behavior: CN="" if [ -n "$SSTCERT" ]; then - # find out my Common Name - get_openssl - if [ -z "$OPENSSL_BINARY" ]; then - wsrep_log_error \ - 'openssl not found but it is required for authentication' - exit 42 - fi - CN=$("$OPENSSL_BINARY" x509 -noout -subject -in "$SSTCERT" | \ - tr ',' '\n' | grep -F 'CN =' | cut -d '=' -f2 | sed s/^\ // | \ - sed s/\ %//) + CN=$(openssl_getCN "$SSTCERT") fi MY_SECRET="$(wsrep_gen_secret)" # Add authentication data to address From 1532f1205832c8a7278cea695f074aae0fc61eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 12 Apr 2024 15:40:11 +0300 Subject: [PATCH 224/313] MDEV-33898 : Galera test failure on galera.MW-369 Tests using MW-369.inc sometimes hanged after signaling two debug sync points inside a Galera library. Replaced Galera library sync point with server code sync point when possible and added more wait_conditions to make sure we are in correct state. Tests effected: MW-369, MW-402, MDEV-27276, and mysql-wsrep#332. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/disabled.def | 2 - mysql-test/suite/galera/galera_4nodes.cnf | 4 + mysql-test/suite/galera/r/MDEV-27276.result | 6 +- mysql-test/suite/galera/r/MW-369.result | 126 ++++++++---------- mysql-test/suite/galera/r/MW-402.result | 108 +++++++-------- .../suite/galera/r/mysql-wsrep#332.result | 12 -- mysql-test/suite/galera/t/MDEV-27276.test | 43 +++++- mysql-test/suite/galera/t/MW-369.inc | 40 +++--- mysql-test/suite/galera/t/MW-369.test | 1 - .../suite/galera/t/mysql-wsrep#332.test | 113 +++++++++++++++- 10 files changed, 283 insertions(+), 172 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index a5a1a6f18b1..d6d70c7c43e 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -19,6 +19,4 @@ galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsr galera_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() galera_sst_mysqldump_with_key : MDEV-32782 galera_sst_mysqldump_with_key test failed galera_var_ignore_apply_errors : MENT-1997 galera_var_ignore_apply_errors test freezes -MDEV-22232 : temporarily disabled at the request of Codership -MW-402 : temporarily disabled at the request of Codership galera_desync_overlapped : MDEV-21538 galera_desync_overlapped MTR failed: Result content mismatch diff --git a/mysql-test/suite/galera/galera_4nodes.cnf b/mysql-test/suite/galera/galera_4nodes.cnf index 66238a8e4c2..3ad1a66b9e6 100644 --- a/mysql-test/suite/galera/galera_4nodes.cnf +++ b/mysql-test/suite/galera/galera_4nodes.cnf @@ -21,6 +21,7 @@ wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#gale wsrep_node_address='127.0.0.1:@mysqld.1.#galera_port' wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' +auto-increment-offset=1 [mysqld.2] wsrep-on=1 @@ -32,6 +33,7 @@ wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#gale wsrep_node_address='127.0.0.1:@mysqld.2.#galera_port' wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' +auto-increment-offset=2 [mysqld.3] wsrep-on=1 @@ -43,6 +45,7 @@ wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.3.#gale wsrep_node_address='127.0.0.1:@mysqld.3.#galera_port' wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' +auto-increment-offset=3 [mysqld.4] wsrep-on=1 @@ -54,6 +57,7 @@ wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.4.#gale wsrep_node_address='127.0.0.1:@mysqld.4.#galera_port' wsrep_node_incoming_address=127.0.0.1:@mysqld.4.port wsrep_sst_receive_address='127.0.0.1:@mysqld.4.#sst_port' +auto-increment-offset=4 [ENV] NODE_MYPORT_1= @mysqld.1.port diff --git a/mysql-test/suite/galera/r/MDEV-27276.result b/mysql-test/suite/galera/r/MDEV-27276.result index 7e5b29fad7e..38e217a9ea8 100644 --- a/mysql-test/suite/galera/r/MDEV-27276.result +++ b/mysql-test/suite/galera/r/MDEV-27276.result @@ -16,17 +16,15 @@ connection node_1a; SET SESSION wsrep_on = 0; SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; connection node_1; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; SET GLOBAL wsrep_provider_options = 'dbug='; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +connection node_1a; +SET SESSION DEBUG_SYNC = "RESET"; connection node_2; SELECT * FROM p; id f2 diff --git a/mysql-test/suite/galera/r/MW-369.result b/mysql-test/suite/galera/r/MW-369.result index 9f0a77edbbc..b4fb8668e74 100644 --- a/mysql-test/suite/galera/r/MW-369.result +++ b/mysql-test/suite/galera/r/MW-369.result @@ -12,22 +12,20 @@ START TRANSACTION; DELETE FROM p WHERE f1 = 1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; INSERT INTO c VALUES (1, 1); connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_2; @@ -54,22 +52,20 @@ START TRANSACTION; UPDATE p SET f2 = 1 WHERE f1 = 1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; UPDATE c SET f2 = 1 WHERE f1 = 1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; connection node_2; SELECT * FROM p; @@ -94,22 +90,20 @@ START TRANSACTION; UPDATE p SET f2 = 1 WHERE f1 = 1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; DELETE FROM c WHERE f1 = 1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; connection node_2; SELECT * FROM p; @@ -130,22 +124,20 @@ START TRANSACTION; UPDATE p SET f2 = 1 WHERE f1 = 1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; INSERT INTO c VALUES (1, 0);; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_2; @@ -170,22 +162,20 @@ START TRANSACTION; DELETE FROM p WHERE f1 = 1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; UPDATE c SET f2 = 1 WHERE f1 = 1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_2; @@ -215,22 +205,20 @@ START TRANSACTION; INSERT INTO cf (f1, p_id) VALUES (10, 1); connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; INSERT INTO cf (f1, p_id) VALUES (20, 1); connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; connection node_2; SELECT * FROM pf; @@ -255,22 +243,20 @@ START TRANSACTION; UPDATE pg SET f2 = 1 WHERE f1 = 1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; INSERT INTO cg VALUES (1, 1, 0); connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; connection node_2; SELECT * FROM pg; diff --git a/mysql-test/suite/galera/r/MW-402.result b/mysql-test/suite/galera/r/MW-402.result index f692c90d611..e936b83553d 100644 --- a/mysql-test/suite/galera/r/MW-402.result +++ b/mysql-test/suite/galera/r/MW-402.result @@ -15,22 +15,20 @@ START TRANSACTION; UPDATE c SET f2=1 where f1=1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; DELETE FROM p WHERE f1 = 1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_2; @@ -55,22 +53,20 @@ START TRANSACTION; UPDATE c SET f2=2 where f1=1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; UPDATE p set f1=11 WHERE f1 = 1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_2; @@ -97,22 +93,20 @@ START TRANSACTION; UPDATE c SET p_id=2 where f1=1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; UPDATE p set f1=11 WHERE f1 = 1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_2; @@ -130,22 +124,20 @@ START TRANSACTION; UPDATE p set f1=21 WHERE f1 = 11; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; UPDATE c SET p_id=2 where f1=1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_2; @@ -176,22 +168,20 @@ START TRANSACTION; UPDATE p2 SET f2=2 where f1=1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; DELETE FROM p1 WHERE f1 = 1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; connection node_2; SELECT * FROM p1; @@ -223,22 +213,20 @@ START TRANSACTION; DELETE FROM p2 WHERE f1=1; connection node_1a; SET SESSION wsrep_sync_wait = 0; -SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync'; +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; connection node_2; DELETE FROM p1 WHERE f1=1; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; connection node_1; +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; -SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; -SET GLOBAL wsrep_provider_options = 'dbug='; +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction connection node_2; diff --git a/mysql-test/suite/galera/r/mysql-wsrep#332.result b/mysql-test/suite/galera/r/mysql-wsrep#332.result index 565979a93ae..16b078175bb 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#332.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#332.result @@ -21,14 +21,10 @@ connection node_1a; SET SESSION wsrep_on = 0; SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; connection node_1; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; SET GLOBAL wsrep_provider_options = 'dbug='; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction @@ -64,14 +60,10 @@ connection node_1a; SET SESSION wsrep_on = 0; SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; connection node_1; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; SET GLOBAL wsrep_provider_options = 'dbug='; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction @@ -112,14 +104,10 @@ connection node_1a; SET SESSION wsrep_on = 0; SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'dbug='; -SET GLOBAL wsrep_provider_options = 'dbug=d,local_monitor_master_enter_sync'; connection node_1; COMMIT; connection node_1a; -SET SESSION wsrep_on = 0; -SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync'; -SET GLOBAL wsrep_provider_options = 'signal=local_monitor_master_enter_sync'; SET GLOBAL wsrep_provider_options = 'dbug='; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction diff --git a/mysql-test/suite/galera/t/MDEV-27276.test b/mysql-test/suite/galera/t/MDEV-27276.test index 1c589c9e85b..bdce0d91373 100644 --- a/mysql-test/suite/galera/t/MDEV-27276.test +++ b/mysql-test/suite/galera/t/MDEV-27276.test @@ -17,7 +17,7 @@ # We use concurrency facility of test MW-369 to setup the conflict between DDL and DML # -# Open connection node_1a here, MW-369.inc will use it later +# Open connection node_1a here, we will use it later --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 # create FK parent table @@ -28,14 +28,51 @@ CREATE TABLE p (id INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; --let $mw_369_parent_query = INSERT INTO p VALUES(1,0) --let $mw_369_child_query = CREATE TABLE c(id INT NOT NULL PRIMARY KEY, p_id INT, FOREIGN KEY (p_id) REFERENCES p(id) ON DELETE CASCADE) ENGINE=InnoDB -# execute above queries through separate nodes ---source MW-369.inc +--connection node_1 +SET AUTOCOMMIT=ON; +START TRANSACTION; +--eval $mw_369_parent_query + +# +# Block the $mw_369_child_query from node_2 +# +# --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_set_sync_point.inc + +# +# insert client row, which will make it impossible to replay the +# delete on parent +# +--connection node_2 +--eval $mw_369_child_query + +# +# Wait until $mw_369_child_query from node_2 reaches the sync point and +# block the 'COMMIT' from node_1 before it certifies. +# +--connection node_1a +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc + +--connection node_1 +--send COMMIT + +--connection node_1a +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_signal_sync_point.inc +--source include/galera_clear_sync_point.inc # Expect certification failure --connection node_1 --error ER_LOCK_DEADLOCK --reap +--connection node_1a +SET SESSION DEBUG_SYNC = "RESET"; + --connection node_2 SELECT * FROM p; SELECT * FROM c; diff --git a/mysql-test/suite/galera/t/MW-369.inc b/mysql-test/suite/galera/t/MW-369.inc index 71df979d6ba..f080d99fe7e 100644 --- a/mysql-test/suite/galera/t/MW-369.inc +++ b/mysql-test/suite/galera/t/MW-369.inc @@ -12,9 +12,9 @@ # START TRANSACTION; # $mw_369_parent_query # node_2 -# $mw_369_child_query - will be blocked on node_1 in apply monitor +# $mw_369_child_query - will be blocked on node_1 in wsrep_apply_cb # node_1: -# COMMIT; - will be blocked on node_1 in local monitor +# COMMIT; - will be blocked on node_1 in wsrep_after_certification # # The $mw_369_child_query is always expected to succeed. The caller is # responsible for checking if the final COMMIT on connection node_1 @@ -32,8 +32,7 @@ START TRANSACTION; # --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 --connection node_1a SET SESSION wsrep_sync_wait = 0; ---let $galera_sync_point = apply_monitor_slave_enter_sync ---source include/galera_set_sync_point.inc +SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_cb"; # # insert client row, which will make it impossible to replay the @@ -47,28 +46,37 @@ SET SESSION wsrep_sync_wait = 0; # block the 'COMMIT' from node_1 before it certifies. # --connection node_1a ---source include/galera_wait_sync_point.inc ---source include/galera_clear_sync_point.inc - ---let $galera_sync_point = local_monitor_master_enter_sync ---source include/galera_set_sync_point.inc +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; --connection node_1 +SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification"; --send COMMIT # # Wait until both sync points have been reached # --connection node_1a ---let $galera_sync_point = apply_monitor_slave_enter_sync local_monitor_master_enter_sync ---source include/galera_wait_sync_point.inc +SET SESSION DEBUG_SYNC = "now WAIT_FOR after_certification_reached"; # # both threads are now parked in sync points, signal them to continue # ---let $galera_sync_point = apply_monitor_slave_enter_sync ---source include/galera_signal_sync_point.inc ---let $galera_sync_point = local_monitor_master_enter_sync ---source include/galera_signal_sync_point.inc ---source include/galera_clear_sync_point.inc +--let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'debug sync point:%' +--let $wait_condition_on_error_output = SELECT STATE FROM INFORMATION_SCHEMA.PROCESSLIST +--source include/wait_condition_with_debug.inc + +SET DEBUG_SYNC = 'now SIGNAL continue_after_certification'; + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'debug sync point:%' +--let $wait_condition_on_error_output = SELECT STATE FROM INFORMATION_SCHEMA.PROCESSLIST +--source include/wait_condition_with_debug.inc + +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; + +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'debug sync point:%' +--let $wait_condition_on_error_output = SELECT STATE FROM INFORMATION_SCHEMA.PROCESSLIST +--source include/wait_condition_with_debug.inc + +SET GLOBAL DEBUG_DBUG = ""; +SET DEBUG_SYNC = 'RESET'; diff --git a/mysql-test/suite/galera/t/MW-369.test b/mysql-test/suite/galera/t/MW-369.test index c8f8c974019..0efac20dbe0 100644 --- a/mysql-test/suite/galera/t/MW-369.test +++ b/mysql-test/suite/galera/t/MW-369.test @@ -24,7 +24,6 @@ --source include/galera_cluster.inc --source include/have_innodb.inc --source include/have_debug_sync.inc ---source include/galera_have_debug_sync.inc CREATE TABLE p (f1 INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; CREATE TABLE c (f1 INTEGER PRIMARY KEY, p_id INTEGER, diff --git a/mysql-test/suite/galera/t/mysql-wsrep#332.test b/mysql-test/suite/galera/t/mysql-wsrep#332.test index e216dfe79d4..464156e832e 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#332.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#332.test @@ -3,7 +3,7 @@ --source include/have_debug_sync.inc --source include/galera_have_debug_sync.inc -# Open connection node_1a here, MW-369.inc will use it later +# Open connection node_1a here, will use it later --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 # @@ -27,7 +27,42 @@ INSERT INTO c VALUES (2, 2); --let $mw_369_parent_query = UPDATE p SET f1 = f1 + 100 --let $mw_369_child_query = ALTER TABLE c ADD FOREIGN KEY (p_id) REFERENCES p(f1) ---source MW-369.inc +--connection node_1 +SET AUTOCOMMIT=ON; +START TRANSACTION; +--eval $mw_369_parent_query + +# +# Block the $mw_369_child_query from node_2 +# +# --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_set_sync_point.inc + +# +# insert client row, which will make it impossible to replay the +# delete on parent +# +--connection node_2 +--eval $mw_369_child_query + +# +# Wait until $mw_369_child_query from node_2 reaches the sync point and +# block the 'COMMIT' from node_1 before it certifies. +# +--connection node_1a +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc + +--connection node_1 +--send COMMIT + +--connection node_1a +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_signal_sync_point.inc +--source include/galera_clear_sync_point.inc # Expect certification failure --connection node_1 @@ -62,7 +97,42 @@ INSERT INTO c VALUES (2, 2, 2); --let $mw_369_parent_query = UPDATE p1 SET f1 = f1 + 100 --let $mw_369_child_query = ALTER TABLE c ADD FOREIGN KEY (p_id1) REFERENCES p1(f1), ADD FOREIGN KEY (p_id2) REFERENCES p2(f1) ---source MW-369.inc +--connection node_1 +SET AUTOCOMMIT=ON; +START TRANSACTION; +--eval $mw_369_parent_query + +# +# Block the $mw_369_child_query from node_2 +# +# --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_set_sync_point.inc + +# +# insert client row, which will make it impossible to replay the +# delete on parent +# +--connection node_2 +--eval $mw_369_child_query + +# +# Wait until $mw_369_child_query from node_2 reaches the sync point and +# block the 'COMMIT' from node_1 before it certifies. +# +--connection node_1a +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc + +--connection node_1 +--send COMMIT + +--connection node_1a +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_signal_sync_point.inc +--source include/galera_clear_sync_point.inc # Expect certification failure --connection node_1 @@ -96,7 +166,42 @@ INSERT INTO c VALUES (2, 2, 2); --let $mw_369_parent_query = UPDATE p2 SET f1 = f1 + 100 --let $mw_369_child_query = ALTER TABLE c ADD FOREIGN KEY (p_id1) REFERENCES p1(f1), ADD FOREIGN KEY (p_id2) REFERENCES p2(f1) ---source MW-369.inc +--connection node_1 +SET AUTOCOMMIT=ON; +START TRANSACTION; +--eval $mw_369_parent_query + +# +# Block the $mw_369_child_query from node_2 +# +# --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_set_sync_point.inc + +# +# insert client row, which will make it impossible to replay the +# delete on parent +# +--connection node_2 +--eval $mw_369_child_query + +# +# Wait until $mw_369_child_query from node_2 reaches the sync point and +# block the 'COMMIT' from node_1 before it certifies. +# +--connection node_1a +--source include/galera_wait_sync_point.inc +--source include/galera_clear_sync_point.inc + +--connection node_1 +--send COMMIT + +--connection node_1a +--let $galera_sync_point = apply_monitor_slave_enter_sync +--source include/galera_signal_sync_point.inc +--source include/galera_clear_sync_point.inc # Expect certification failure --connection node_1 From 136358036dfe2637b2db428b848148475ac21154 Mon Sep 17 00:00:00 2001 From: mkaruza Date: Sat, 27 Apr 2024 18:40:58 +0200 Subject: [PATCH 225/313] MDEV-18590: galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replicated events have time associated with them from originating node which will be used for commit timestamp. Associated time can be set in past before event is even applied. For WSREP replication we don't need to use time information from event. Addressed review comments: Jan Lindström Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/disabled.def | 1 - .../suite/galera/r/versioning_trx_id.result | 6 +++--- mysql-test/suite/galera/t/versioning_trx_id.test | 12 ++++++------ sql/log_event.cc | 15 ++++++++++++--- sql/log_event_old.cc | 13 +++++++++++-- sql/wsrep_applier.cc | 9 --------- sql/wsrep_high_priority_service.cc | 2 ++ 7 files changed, 34 insertions(+), 24 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index d6d70c7c43e..45c04bdfd4b 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -13,7 +13,6 @@ galera_as_slave_ctas : MDEV-28378 timeout galera_pc_recovery : MDEV-25199 cluster fails to start up galera_sequences : MDEV-32561 WSREP FSM failure: no such a transition REPLICATING -> COMMITTED -versioning_trx_id : MDEV-18590 : galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch galera_concurrent_ctas : MDEV-32779 galera_concurrent_ctas: assertion in the galera::ReplicatorSMM::finish_cert() galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() galera_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() diff --git a/mysql-test/suite/galera/r/versioning_trx_id.result b/mysql-test/suite/galera/r/versioning_trx_id.result index df92d088834..c28662dcfe6 100644 --- a/mysql-test/suite/galera/r/versioning_trx_id.result +++ b/mysql-test/suite/galera/r/versioning_trx_id.result @@ -17,7 +17,7 @@ a select count(*) from mysql.transaction_registry where begin_timestamp='0-0-0'; count(*) 0 -select count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp; +select count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp; count(*) 0 connection node_3; @@ -34,7 +34,7 @@ a select count(*) from mysql.transaction_registry where begin_timestamp='0-0-0'; count(*) 0 -select count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp; +select count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp; count(*) 0 connection node_1; @@ -50,7 +50,7 @@ a select count(*) from mysql.transaction_registry where begin_timestamp='0-0-0'; count(*) 0 -select count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp; +select count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp; count(*) 0 drop table t1; diff --git a/mysql-test/suite/galera/t/versioning_trx_id.test b/mysql-test/suite/galera/t/versioning_trx_id.test index 017379c32c4..fc9ea18eeb4 100644 --- a/mysql-test/suite/galera/t/versioning_trx_id.test +++ b/mysql-test/suite/galera/t/versioning_trx_id.test @@ -13,29 +13,29 @@ set session wsrep_sync_wait=15; insert into t1 (a) values (3),(4); select a from t1; select count(*) from mysql.transaction_registry where begin_timestamp='0-0-0'; -if (`SELECT count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp`) { +if (`SELECT count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp`) { select * from mysql.transaction_registry; } -select count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp; +select count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp; --connection node_3 set session wsrep_sync_wait=15; insert into t1 (a) values (5),(6); select a from t1; select count(*) from mysql.transaction_registry where begin_timestamp='0-0-0'; -if (`SELECT count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp`) { +if (`SELECT count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp`) { select * from mysql.transaction_registry; } -select count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp; +select count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp; --connection node_1 set session wsrep_sync_wait=15; select a from t1; select count(*) from mysql.transaction_registry where begin_timestamp='0-0-0'; -if (`SELECT count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp`) { +if (`SELECT count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp`) { select * from mysql.transaction_registry; } -select count(*) from mysql.transaction_registry where begin_timestamp>=commit_timestamp; +select count(*) from mysql.transaction_registry where begin_timestamp>commit_timestamp; drop table t1; diff --git a/sql/log_event.cc b/sql/log_event.cc index 6a59a021efc..1638a7d029b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5554,7 +5554,10 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, */ if (is_trans_keyword() || rpl_filter->db_ok(thd->db.str)) { - thd->set_time(when, when_sec_part); +#ifdef WITH_WSREP + if (!wsrep_thd_is_applying(thd)) +#endif + thd->set_time(when, when_sec_part); thd->set_query_and_id((char*)query_arg, q_len_arg, thd->charset(), next_query_id()); thd->variables.pseudo_thread_id= thread_id; // for temp tables @@ -7433,7 +7436,10 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi, */ if (rpl_filter->db_ok(thd->db.str)) { - thd->set_time(when, when_sec_part); +#ifdef WITH_WSREP + if (!wsrep_thd_is_applying(thd)) +#endif + thd->set_time(when, when_sec_part); thd->set_query_id(next_query_id()); thd->get_stmt_da()->opt_clear_warning_info(thd->query_id); @@ -11629,7 +11635,10 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) TIMESTAMP column to a table with one. So we call set_time(), like in SBR. Presently it changes nothing. */ - thd->set_time(when, when_sec_part); +#ifdef WITH_WSREP + if (!wsrep_thd_is_applying(thd)) +#endif + thd->set_time(when, when_sec_part); if (m_width == table->s->fields && bitmap_is_set_all(&m_cols)) set_flags(COMPLETE_ROWS_F); diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index c71a1f39e28..8adf5276577 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -31,6 +31,9 @@ #include "log_event_old.h" #include "rpl_record_old.h" #include "transaction.h" +#ifdef WITH_WSREP +#include "wsrep_mysqld.h" +#endif /* WITH_WSREP */ #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) @@ -203,7 +206,10 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi) TIMESTAMP column to a table with one. So we call set_time(), like in SBR. Presently it changes nothing. */ - ev_thd->set_time(ev->when, ev->when_sec_part); +#ifdef WITH_WSREP + if (!wsrep_thd_is_applying(thd)) +#endif + ev_thd->set_time(ev->when, ev->when_sec_part); /* There are a few flags that are replicated with each row event. Make sure to set/clear them before executing the main body of @@ -1507,7 +1513,10 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi) TIMESTAMP column to a table with one. So we call set_time(), like in SBR. Presently it changes nothing. */ - thd->set_time(when, when_sec_part); +#ifdef WITH_WSREP + if (!wsrep_thd_is_applying(thd)) +#endif + thd->set_time(when, when_sec_part); /* There are a few flags that are replicated with each row event. Make sure to set/clear them before executing the main body of diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index ff6a0a7f60e..32476d05227 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -182,16 +182,7 @@ int wsrep_apply_events(THD* thd, /* Use the original server id for logging. */ thd->set_server_id(ev->server_id); - thd->set_time(); // time the query - thd->transaction.start_time.reset(thd); thd->lex->current_select= 0; - if (!ev->when) - { - my_hrtime_t hrtime= my_hrtime(); - ev->when= hrtime_to_my_time(hrtime); - ev->when_sec_part= hrtime_sec_part(hrtime); - } - thd->variables.option_bits= (thd->variables.option_bits & ~OPTION_SKIP_REPLICATION) | (ev->flags & LOG_EVENT_SKIP_REPLICATION_F ? OPTION_SKIP_REPLICATION : 0); diff --git a/sql/wsrep_high_priority_service.cc b/sql/wsrep_high_priority_service.cc index 1988088d0a8..c63e70d316d 100644 --- a/sql/wsrep_high_priority_service.cc +++ b/sql/wsrep_high_priority_service.cc @@ -197,6 +197,7 @@ int Wsrep_high_priority_service::start_transaction( const wsrep::ws_handle& ws_handle, const wsrep::ws_meta& ws_meta) { DBUG_ENTER(" Wsrep_high_priority_service::start_transaction"); + m_thd->set_time(); DBUG_RETURN(m_thd->wsrep_cs().start_transaction(ws_handle, ws_meta) || trans_begin(m_thd)); } @@ -391,6 +392,7 @@ int Wsrep_high_priority_service::apply_toi(const wsrep::ws_meta& ws_meta, };); #endif + thd->set_time(); int ret= wsrep_apply_events(thd, m_rli, data.data(), data.size()); if (ret != 0 || thd->wsrep_has_ignored_error) { From 3141a68b7ce00852b54d9ce363907897c060a640 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 26 Apr 2024 11:57:25 +0400 Subject: [PATCH 226/313] MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc| The negation in this line: ulonglong abs_dec= dec_negative ? -dec : dec; did not take into account that 'dec' can be the smallest possible signed negative value -9223372036854775808. Its negation is an operation with an undefined behavior. Fixing the code to use Longlong_hybrid, which implements a safe method to get an absolute value. --- mysql-test/main/func_math.result | 15 +++++++++++++++ mysql-test/main/func_math.test | 10 ++++++++++ sql/item_func.cc | 22 ++++++++++++---------- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result index 98d5fdcf3d0..4296a983d71 100644 --- a/mysql-test/main/func_math.result +++ b/mysql-test/main/func_math.result @@ -3617,5 +3617,20 @@ SELECT CRC32(ExtractValue('', '/a/b')) AS f; f 0 # +# MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc| +# +SELECT TRUNCATE(EXP(-1.e-2),-1.e+30) AS c1; +c1 +0 +SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) AS c1; +c1 +0 +SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1; +c1 +0 +SELECT(ASIN(-1)+ LN(-1)) % (ATAN(-1) MOD FLOOR(1)) * (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1; +c1 +NULL +# # End of 10.5 tests # diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test index 171975859e3..dbeefa94d59 100644 --- a/mysql-test/main/func_math.test +++ b/mysql-test/main/func_math.test @@ -1929,6 +1929,16 @@ DROP TABLE t2, t1; SELECT CRC32(ExtractValue('', '/a/b')) AS f; +--echo # +--echo # MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc| +--echo # + +SELECT TRUNCATE(EXP(-1.e-2),-1.e+30) AS c1; +SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) AS c1; +SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1; +SELECT(ASIN(-1)+ LN(-1)) % (ATAN(-1) MOD FLOOR(1)) * (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1; + + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_func.cc b/sql/item_func.cc index b6f601ec82b..1e6fa039059 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2638,12 +2638,12 @@ void Item_func_round::fix_arg_hex_hybrid() } -double my_double_round(double value, longlong dec, bool dec_unsigned, +double my_double_round(double value, longlong dec_value, bool dec_unsigned, bool truncate) { double tmp; - bool dec_negative= (dec < 0) && !dec_unsigned; - ulonglong abs_dec= dec_negative ? -dec : dec; + const Longlong_hybrid dec(dec_value, dec_unsigned); + const ulonglong abs_dec= dec.abs(); /* tmp2 is here to avoid return the value with 80 bit precision This will fix that the test round(0.1,1) = round(0.1,1) is true @@ -2658,22 +2658,24 @@ double my_double_round(double value, longlong dec, bool dec_unsigned, volatile double value_div_tmp= value / tmp; volatile double value_mul_tmp= value * tmp; - if (!dec_negative && std::isinf(tmp)) // "dec" is too large positive number + if (!dec.neg() && std::isinf(tmp)) // "dec" is a too large positive number return value; - if (dec_negative && std::isinf(tmp)) - tmp2= 0.0; - else if (!dec_negative && std::isinf(value_mul_tmp)) + if (dec.neg() && std::isinf(tmp)) // "dec" is a too small negative number + return 0.0; + + // Handle "dec" with a reasonably small absolute value + if (!dec.neg() && std::isinf(value_mul_tmp)) tmp2= value; else if (truncate) { if (value >= 0.0) - tmp2= dec < 0 ? floor(value_div_tmp) * tmp : floor(value_mul_tmp) / tmp; + tmp2= dec.neg() ? floor(value_div_tmp) * tmp : floor(value_mul_tmp) / tmp; else - tmp2= dec < 0 ? ceil(value_div_tmp) * tmp : ceil(value_mul_tmp) / tmp; + tmp2= dec.neg() ? ceil(value_div_tmp) * tmp : ceil(value_mul_tmp) / tmp; } else - tmp2=dec < 0 ? rint(value_div_tmp) * tmp : rint(value_mul_tmp) / tmp; + tmp2=dec.neg() ? rint(value_div_tmp) * tmp : rint(value_mul_tmp) / tmp; return tmp2; } From a09ebe5567694f13dd77876bf61ce3560dfed0e6 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 26 Apr 2024 14:44:38 +0200 Subject: [PATCH 227/313] PCRE2-10.43 pcre2 - fix CMAKE_C_FLAGS for MSVC for external project by Vladislav Vaintroub --- cmake/pcre.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index 65dc2ae28f6..5ef089aa686 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -46,16 +46,16 @@ MACRO(BUNDLE_PCRE2) SET(pcre2_flags${v} "${pcre2_flags${v}} -std=c99 ") IF(MSVC) # Suppress a warning - STRING(APPEND pcre2_flags${v} " /wd4244 " ) + STRING(APPEND pcre2_flags${v} " /wd4244 /wd4267 " ) # Disable asan support - STRING(REPLACE "-fsanitize=address" "" pcre2_flags${v} "${CMAKE_C_FLAGS${v}}") + STRING(REPLACE "-fsanitize=address" "" pcre2_flags${v} "${pcre2_flags${v}}") ENDIF() ENDFOREACH() ExternalProject_Add( pcre2 PREFIX "${dir}" - URL "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.zip" - URL_MD5 fe90992fbfb03f854bd9f344074f49eb + URL "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.43/pcre2-10.43.zip" + URL_MD5 b58f050f2fdd6f2ca5774a2975377a85 INSTALL_COMMAND "" CMAKE_ARGS "-DCMAKE_WARN_DEPRECATED=FALSE" From bda8d4fdf7d363b761d94a6dedf13ad58df54bf6 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 26 Apr 2024 18:34:27 +0200 Subject: [PATCH 228/313] require boost 1.53 for columnstore --- storage/columnstore/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/columnstore/CMakeLists.txt b/storage/columnstore/CMakeLists.txt index 1b3b739b706..7c875251214 100644 --- a/storage/columnstore/CMakeLists.txt +++ b/storage/columnstore/CMakeLists.txt @@ -15,7 +15,7 @@ IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") # https://jira.mariadb.org/browse/MCOL-5611 - FIND_PACKAGE(Boost COMPONENTS system filesystem thread regex date_time chrono atomic) + FIND_PACKAGE(Boost 1.53 COMPONENTS system filesystem thread regex date_time chrono atomic) IF (${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_GREATER "1.79") MESSAGE_ONCE(CS_NO_BOOST "Boost Libraries >= 1.80.0 not supported!") return() From 52f6df99ed7179a6467a8c9078d21eb5add85870 Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Wed, 24 Apr 2024 19:53:13 +0530 Subject: [PATCH 229/313] MDEV-33669 mariabackup --backup hangs This is a server hang and not an issue with backup. While concurrent DDLs in server gets in hanged state, mariabackup waits for DDLs to finish trying to acquire MDL_BACKUP_BLOCK_DDL. The server hang is serious in nature and caused by thread pool state being incorrectly set to thread creation pending state while no creation is actually pending. Once a thread pool reaches such state no new thread gets created in the pool. While it could possibly affect all thread pools in server, the innodb thread pool is the victim in current bug where IO job gets blocked when the pool is stuck with much less number of threads than intended. Available workers are blocked in purge waiting for page lock to be released by IO write (SX lock) causing a complete deadlock. The issue is caused by the state variable m_thread_creation_pending introduced by MDEV-31095: 9e62ab7aafbf. We check and set the variable early while attempting to create a new thread in pool but fail to reset it if we exit the flow for other reasons like maximum threads reached or get into thread creation throttling path. Fix: The simple fix is to make sure that the state is reset back in case we don't actually attempt to create the thread. --- tpool/tpool_generic.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc index f0637044639..a4d6c405bdf 100644 --- a/tpool/tpool_generic.cc +++ b/tpool/tpool_generic.cc @@ -722,9 +722,6 @@ static int throttling_interval_ms(size_t n_threads,size_t concurrency) /* Create a new worker.*/ bool thread_pool_generic::add_thread() { - if (m_thread_creation_pending.test_and_set()) - return false; - size_t n_threads = thread_count(); if (n_threads >= m_max_threads) @@ -750,6 +747,14 @@ bool thread_pool_generic::add_thread() } } + /* Check and set "thread creation pending" flag before creating the thread. We + reset the flag in thread_pool_generic::worker_main in new thread created. The + flag must be reset back in case we fail to create the thread. If this flag is + not reset all future attempt to create thread for this pool would not work as + we would return from here. */ + if (m_thread_creation_pending.test_and_set()) + return false; + worker_data *thread_data = m_thread_data_cache.get(); m_active_threads.push_back(thread_data); try @@ -769,6 +774,7 @@ bool thread_pool_generic::add_thread() "current number of threads in pool %zu\n", e.what(), thread_count()); warning_written = true; } + m_thread_creation_pending.clear(); return false; } return true; From 267dd5a993d5432132c6479d766a6028b85f77fb Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 29 Apr 2024 16:17:22 +1000 Subject: [PATCH 230/313] MDEV-30727 Check spider_hton_ptr in spider udfs We have to #undef my_error and find it from udfs when spider is not installed. --- .../spider/bugfix/r/mdev_30727.result | 24 +++++++++++++++ .../spider/bugfix/t/mdev_30727.test | 30 +++++++++++++++++++ storage/spider/spd_copy_tables.cc | 8 +++++ storage/spider/spd_direct_sql.cc | 8 +++++ 4 files changed, 70 insertions(+) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result new file mode 100644 index 00000000000..ce8ebdc3966 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result @@ -0,0 +1,24 @@ +CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); +ERROR HY000: Plugin 'SPIDER' is not loaded +CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); +ERROR HY000: Plugin 'SPIDER' is not loaded +CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_copy_tables ('t', '0', '0'); +ERROR HY000: Plugin 'SPIDER' is not loaded +CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_flush_table_mon_cache (); +spider_flush_table_mon_cache () +1 +install soname 'ha_spider'; +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); +ERROR HY000: The foreign server name you are trying to reference does not exist. Data source error: b +call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'"); +SELECT spider_copy_tables ('t', '0', '0'); +ERROR HY000: Can't find record in 'spider_tables' +SELECT spider_flush_table_mon_cache (); +spider_flush_table_mon_cache () +1 +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test new file mode 100644 index 00000000000..e1d917e7147 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test @@ -0,0 +1,30 @@ +CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; +--error ER_PLUGIN_IS_NOT_LOADED +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); + +CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; +--error ER_PLUGIN_IS_NOT_LOADED +SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); + +CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; +--error ER_PLUGIN_IS_NOT_LOADED +SELECT spider_copy_tables ('t', '0', '0'); + +# spider_flush_table_mon_cache does not require spider init to function +CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; +SELECT spider_flush_table_mon_cache (); + +# The function functions properly after the plugin is installed +install soname 'ha_spider'; + +--error ER_FOREIGN_SERVER_DOESNT_EXIST +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); + +call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'"); +--error ER_KEY_NOT_FOUND +SELECT spider_copy_tables ('t', '0', '0'); + +SELECT spider_flush_table_mon_cache (); + +--disable_query_log +--source ../../include/clean_up_spider.inc diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index c2463ce30df..1783fe7374b 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -1154,12 +1154,20 @@ error: DBUG_RETURN(0); } +#undef my_error +extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...); + my_bool spider_copy_tables_init_body( UDF_INIT *initid, UDF_ARGS *args, char *message ) { DBUG_ENTER("spider_copy_tables_init_body"); + if (!spider_hton_ptr) + { + my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER"); + goto error; + } if (args->arg_count != 3 && args->arg_count != 4) { strcpy(message, "spider_copy_tables() requires 3 or 4 arguments"); diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index fc8ba264b19..4f6bc0a4405 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -1789,6 +1789,9 @@ error: DBUG_RETURN(0); } +#undef my_error +extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...); + my_bool spider_direct_sql_init_body( UDF_INIT *initid, UDF_ARGS *args, @@ -1797,6 +1800,11 @@ my_bool spider_direct_sql_init_body( ) { SPIDER_BG_DIRECT_SQL *bg_direct_sql; DBUG_ENTER("spider_direct_sql_init_body"); + if (!spider_hton_ptr) + { + my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER"); + goto error; + } if (args->arg_count != 3) { strcpy(message, "spider_(bg)_direct_sql() requires 3 arguments"); From 3f2a5b28c6c7044a05bcef173619b5aeb7b4c34f Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 29 Apr 2024 16:42:46 +1000 Subject: [PATCH 231/313] MDEV-34003 Add testcase spider/bugfix.mdev_34003 MDEV-34003 appears to be a duplicate of MDEV-33742, and no code change is needed. Nevertheless we add the testcase reported in the former. --- .../spider/bugfix/r/mdev_34003.result | 18 +++++++++++++++++ .../spider/bugfix/t/mdev_34003.test | 20 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_34003.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_34003.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_34003.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_34003.result new file mode 100644 index 00000000000..b78f18d19dd --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_34003.result @@ -0,0 +1,18 @@ +for master_1 +for child2 +for child3 +set spider_same_server_link= 1; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +create table t2 (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (0,1,0),(1,0,0),(2,0,0); +create table t1 (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=Spider +COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; +SELECT * FROM t1 WHERE c=0; +c c1 c2 +0 1 0 +drop table t1, t2; +drop server srv; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_34003.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_34003.test new file mode 100644 index 00000000000..f81259b99a9 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_34003.test @@ -0,0 +1,20 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log +set spider_same_server_link= 1; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +create table t2 (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (0,1,0),(1,0,0),(2,0,0); +create table t1 (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=Spider +COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; +SELECT * FROM t1 WHERE c=0; +drop table t1, t2; +drop server srv; +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log From dc25d600eed6ff4cee6340bd22302b7cbc0f2f25 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 24 Apr 2024 16:54:00 +0400 Subject: [PATCH 232/313] MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt Regexp_processor_pcre::fix_owner() called Regexp_processor_pcre::compile(), which could fail on the regex syntax error in the pattern and put an error into the diagnostics area. However, the callers: - Item_func_regex::fix_length_and_dec() - Item_func_regexp_instr::fix_length_and_dec() still returned "false" in such cases, which made the code crash later inside Diagnostics_area::set_ok_status(). Fix: - Change the return type of fix_onwer() from "void" to "bool" and return "true" whenever an error is put to the DA (e.g. on the syntax error in the pattern). - Fixing fix_length_and_dec() of the mentioned Item_func_xxx classes to return "true" if fix_onwer() returned "true". --- mysql-test/main/func_regexp.result | 16 +++++++++ mysql-test/main/func_regexp.test | 17 ++++++++++ mysql-test/suite/vcol/r/func_regexp.result | 24 ++++++++++++++ mysql-test/suite/vcol/t/func_regexp.test | 30 +++++++++++++++++ sql/item_cmpfunc.cc | 38 +++++++++++++++++----- sql/item_cmpfunc.h | 2 +- 6 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 mysql-test/suite/vcol/r/func_regexp.result create mode 100644 mysql-test/suite/vcol/t/func_regexp.test diff --git a/mysql-test/main/func_regexp.result b/mysql-test/main/func_regexp.result index 8e32732e12d..7a9e24f8262 100644 --- a/mysql-test/main/func_regexp.result +++ b/mysql-test/main/func_regexp.result @@ -192,4 +192,20 @@ SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a; SUM(a.t) 0 DROP TABLE t0; +# +# MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt +# +CREATE TABLE t1 (c0 INT); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT ('' RLIKE '[') AS c1 FROM t1; +ERROR 42000: Regex error 'missing terminating ] for character class at offset 1' +SELECT REGEXP_INSTR('','[') AS c1 FROM t1; +ERROR 42000: Regex error 'missing terminating ] for character class at offset 1' +SELECT c0, '' RLIKE NULL AS c1, REGEXP_INSTR('', NULL) AS c2 +FROM t1 ORDER BY c0; +c0 c1 c2 +1 NULL NULL +2 NULL NULL +3 NULL NULL +DROP TABLE t1; # End of 10.5 tests diff --git a/mysql-test/main/func_regexp.test b/mysql-test/main/func_regexp.test index 48a273f6979..fb441bde4d2 100644 --- a/mysql-test/main/func_regexp.test +++ b/mysql-test/main/func_regexp.test @@ -132,5 +132,22 @@ SELECT (c1 RLIKE c1), (c0 IS NULL) FROM t0; SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a; DROP TABLE t0; +--echo # +--echo # MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt +--echo # + +CREATE TABLE t1 (c0 INT); +INSERT INTO t1 VALUES (1),(2),(3); + +--error ER_REGEXP_ERROR +SELECT ('' RLIKE '[') AS c1 FROM t1; + +--error ER_REGEXP_ERROR +SELECT REGEXP_INSTR('','[') AS c1 FROM t1; + +SELECT c0, '' RLIKE NULL AS c1, REGEXP_INSTR('', NULL) AS c2 +FROM t1 ORDER BY c0; + +DROP TABLE t1; --echo # End of 10.5 tests diff --git a/mysql-test/suite/vcol/r/func_regexp.result b/mysql-test/suite/vcol/r/func_regexp.result new file mode 100644 index 00000000000..f7ae11f79b1 --- /dev/null +++ b/mysql-test/suite/vcol/r/func_regexp.result @@ -0,0 +1,24 @@ +# +# Start of 10.5 tests +# +# +# MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt +# +CREATE TABLE t1 (c0 INT AS(('' RLIKE '['))); +ERROR 42000: Regex error 'missing terminating ] for character class at offset 1' +CREATE TABLE t1 (c0 INT AS(REGEXP_INSTR('','['))); +ERROR 42000: Regex error 'missing terminating ] for character class at offset 1' +CREATE TABLE t1 +( +c0 INT, +c1 INT AS(('' RLIKE NULL)), +c2 INT AS(REGEXP_INSTR('',NULL)) +); +INSERT INTO t1 (c0) VALUES (0); +SELECT * FROM t1; +c0 c1 c2 +0 NULL NULL +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/suite/vcol/t/func_regexp.test b/mysql-test/suite/vcol/t/func_regexp.test new file mode 100644 index 00000000000..5e97009ab7b --- /dev/null +++ b/mysql-test/suite/vcol/t/func_regexp.test @@ -0,0 +1,30 @@ +--source inc/vcol_init_vars.pre +--source inc/vcol_cleanup.inc + +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt +--echo # + +--error ER_REGEXP_ERROR +CREATE TABLE t1 (c0 INT AS(('' RLIKE '['))); + +--error ER_REGEXP_ERROR +CREATE TABLE t1 (c0 INT AS(REGEXP_INSTR('','['))); + +CREATE TABLE t1 +( + c0 INT, + c1 INT AS(('' RLIKE NULL)), + c2 INT AS(REGEXP_INSTR('',NULL)) +); +INSERT INTO t1 (c0) VALUES (0); +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f8959cfd2bf..a755cac49ad 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -6215,7 +6215,17 @@ bool Regexp_processor_pcre::exec(Item *item, int offset, } -void Regexp_processor_pcre::fix_owner(Item_func *owner, +/* + This method determines the owner's maybe_null flag. + Generally, the result is NULL-able. However, in case + of a constant pattern and a NOT NULL subject, the + result can also be NOT NULL. + @return true - in case if the constant regex compilation failed + (e.g. due to a wrong regex syntax in the pattern). + The compilation error message is put to the DA in this case. + false - otherwise. +*/ +bool Regexp_processor_pcre::fix_owner(Item_func *owner, Item *subject_arg, Item *pattern_arg) { @@ -6223,16 +6233,30 @@ void Regexp_processor_pcre::fix_owner(Item_func *owner, pattern_arg->const_item() && !pattern_arg->is_expensive()) { - if (compile(pattern_arg, true)) + if (compile(pattern_arg, true/* raise errors to DA, e.g. on bad syntax */)) { - owner->maybe_null= 1; // Will always return NULL - return; + owner->maybe_null= 1; + if (pattern_arg->null_value) + { + /* + The pattern evaluated to NULL. Regex compilation did not happen. + No errors were put to DA. Continue with maybe_null==true. + The function will return NULL per row. + */ + return false; + } + /* + A syntax error in the pattern, an error was raised to the DA. + Let's abort the query. The caller will send the error to the client. + */ + return true; } set_const(true); owner->maybe_null= subject_arg->maybe_null; } else owner->maybe_null= 1; + return false; } @@ -6244,8 +6268,7 @@ Item_func_regex::fix_length_and_dec() return TRUE; re.init(cmp_collation.collation, 0); - re.fix_owner(this, args[0], args[1]); - return FALSE; + return re.fix_owner(this, args[0], args[1]); } @@ -6269,9 +6292,8 @@ Item_func_regexp_instr::fix_length_and_dec() return TRUE; re.init(cmp_collation.collation, 0); - re.fix_owner(this, args[0], args[1]); max_length= MY_INT32_NUM_DECIMAL_DIGITS; // See also Item_func_locate - return FALSE; + return re.fix_owner(this, args[0], args[1]); } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 465625f69bf..4674f935aed 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -2893,7 +2893,7 @@ public: {} int default_regex_flags(); void init(CHARSET_INFO *data_charset, int extra_flags); - void fix_owner(Item_func *owner, Item *subject_arg, Item *pattern_arg); + bool fix_owner(Item_func *owner, Item *subject_arg, Item *pattern_arg); bool compile(String *pattern, bool send_error); bool compile(Item *item, bool send_error); bool recompile(Item *item) From c6e3fe29d41f38bdb98334daff78d9cbd6d40998 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 27 Apr 2024 08:54:38 +0400 Subject: [PATCH 233/313] MDEV-30646 View created via JSON_ARRAYAGG returns incorrect json object Backporting add782a13e58 from 10.6, this fixes the problem. --- mysql-test/main/func_json.result | 6 +++--- mysql-test/suite/json/r/type_json.result | 8 ++++++++ mysql-test/suite/json/t/type_json.test | 9 +++++++++ sql/item_jsonfunc.cc | 2 +- sql/item_jsonfunc.h | 1 + sql/sql_select.cc | 22 ++++++++++++++++++++++ sql/table.cc | 21 +++++++++++++-------- sql/table.h | 2 ++ 8 files changed, 59 insertions(+), 12 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index e40951a0b1f..bf8c85a59f1 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1640,9 +1640,9 @@ SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials from t1 LEFT JOIN t2 on t1.id = t2.owner_id GROUP BY t1.id ORDER BY id; id materials -1 ["{\"id\": 1}","{\"id\": 2}"] -2 ["{\"id\": 3}"] -3 ["{\"id\": 4}"] +1 [{"id": 1},{"id": 2}] +2 [{"id": 3}] +3 [{"id": 4}] DROP TABLE t1; DROP TABLE t2; # diff --git a/mysql-test/suite/json/r/type_json.result b/mysql-test/suite/json/r/type_json.result index b9b70f24190..fc9bea9dc91 100644 --- a/mysql-test/suite/json/r/type_json.result +++ b/mysql-test/suite/json/r/type_json.result @@ -2880,5 +2880,13 @@ DROP PROCEDURE p1; DROP PROCEDURE p2; DROP TABLE t1, t1c, t2; # +# MDEV-30646 View created via JSON_ARRAYAGG returns incorrect json object +# +CREATE VIEW v1 AS SELECT JSON_OBJECT('plugin','unix_socket') as v1_json; +SELECT JSON_ARRAYAGG(v1_json) FROM v1; +JSON_ARRAYAGG(v1_json) +[{"plugin": "unix_socket"}] +DROP VIEW v1; +# # End of 10.5 tests # diff --git a/mysql-test/suite/json/t/type_json.test b/mysql-test/suite/json/t/type_json.test index f84bef780c3..03236070c8e 100644 --- a/mysql-test/suite/json/t/type_json.test +++ b/mysql-test/suite/json/t/type_json.test @@ -138,6 +138,15 @@ DROP PROCEDURE p2; DROP TABLE t1, t1c, t2; +--echo # +--echo # MDEV-30646 View created via JSON_ARRAYAGG returns incorrect json object +--echo # + +CREATE VIEW v1 AS SELECT JSON_OBJECT('plugin','unix_socket') as v1_json; +SELECT JSON_ARRAYAGG(v1_json) FROM v1; +DROP VIEW v1; + + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 25b74f8d0aa..fb2e995cd52 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -1633,7 +1633,7 @@ null_return: `CONVERT(arg USING charset)` is actually a general purpose string expression, not a JSON expression. */ -static bool is_json_type(const Item *item) +bool is_json_type(const Item *item) { for ( ; ; ) { diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h index eea7605d8e8..c8e920dc083 100644 --- a/sql/item_jsonfunc.h +++ b/sql/item_jsonfunc.h @@ -640,5 +640,6 @@ public: { return get_item_copy(thd, this); } }; +extern bool is_json_type(const Item *item); #endif /* ITEM_JSONFUNC_INCLUDED */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a7b84bbfe3b..3b30c2f1789 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -18569,6 +18569,25 @@ Field *Item_func_sp::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, return result; } + +static bool make_json_valid_expr(TABLE *table, Field *field) +{ + THD *thd= table->in_use; + Query_arena backup_arena; + Item *expr, *item_field; + + if (!table->expr_arena && table->init_expr_arena(thd->mem_root)) + return 1; + + thd->set_n_backup_active_arena(table->expr_arena, &backup_arena); + if ((item_field= new (thd->mem_root) Item_field(thd, field)) && + (expr= new (thd->mem_root) Item_func_json_valid(thd, item_field))) + field->check_constraint= add_virtual_expression(thd, expr); + thd->restore_active_arena(table->expr_arena, &backup_arena); + return field->check_constraint == NULL; +} + + /** Create field for temporary table. @@ -18614,6 +18633,9 @@ Field *create_tmp_field(TABLE *table, Item *item, make_copy_field); Field *result= item->create_tmp_field_ex(table->in_use->mem_root, table, &src, &prm); + if (is_json_type(item) && make_json_valid_expr(table, result)) + result= NULL; + *from_field= src.field(); *default_field= src.default_field(); if (src.item_result_field()) diff --git a/sql/table.cc b/sql/table.cc index 6633aa1ee04..610d94d413c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -53,6 +53,17 @@ #define MYSQL57_GENERATED_FIELD 128 #define MYSQL57_GCOL_HEADER_SIZE 4 +bool TABLE::init_expr_arena(MEM_ROOT *mem_root) +{ + /* + We need to use CONVENTIONAL_EXECUTION here to ensure that + any new items created by fix_fields() are not reverted. + */ + expr_arena= new (alloc_root(mem_root, sizeof(Query_arena))) + Query_arena(mem_root, Query_arena::STMT_CONVENTIONAL_EXECUTION); + return expr_arena == NULL; +} + struct extra2_fields { LEX_CUSTRING version; @@ -1145,14 +1156,8 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, table->s->table_check_constraints * sizeof(Virtual_column_info*)); DBUG_ASSERT(table->expr_arena == NULL); - /* - We need to use CONVENTIONAL_EXECUTION here to ensure that - any new items created by fix_fields() are not reverted. - */ - table->expr_arena= new (alloc_root(mem_root, sizeof(Query_arena))) - Query_arena(mem_root, - Query_arena::STMT_CONVENTIONAL_EXECUTION); - if (!table->expr_arena) + + if (table->init_expr_arena(mem_root)) DBUG_RETURN(1); thd->set_n_backup_active_arena(table->expr_arena, &backup_arena); diff --git a/sql/table.h b/sql/table.h index a63eae88cb6..97e595979b9 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1645,6 +1645,8 @@ public: m_needs_reopen= value; } + bool init_expr_arena(MEM_ROOT *mem_root); + bool alloc_keys(uint key_count); bool check_tmp_key(uint key, uint key_parts, uint (*next_field_no) (uchar *), uchar *arg); From a586b6dbc81b788106cee0f88416c389ae79d26c Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 29 Apr 2024 16:42:26 +0530 Subject: [PATCH 234/313] MDEV-22855 Assertion `!field->prefix_len || field->fixed_len == field->prefix_len' failed in btr_node_ptr_max_size Problem: ======== - InnoDB wrongly calulates the record size in btr_node_ptr_max_size() when prefix index of the column has to be stored externally. Fix: ==== - InnoDB should add the maximum field size to record size when the field is a fixed length one. --- mysql-test/suite/innodb/r/index_length.result | 8 ++++++++ mysql-test/suite/innodb/t/index_length.test | 8 ++++++++ storage/innobase/btr/btr0cur.cc | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/index_length.result b/mysql-test/suite/innodb/r/index_length.result index cc92780ac32..e0d6a735bb4 100644 --- a/mysql-test/suite/innodb/r/index_length.result +++ b/mysql-test/suite/innodb/r/index_length.result @@ -20,4 +20,12 @@ FLOOR(index_length/@@innodb_page_size) 2 disconnect stop_purge; DROP TABLE t1; +# +# MDEV-22855 Assertion (!field->prefix_len || +# field->fixed_len == field->prefix_len) +# failed in btr_node_ptr_max_size +# +CREATE TABLE t1(c CHAR(194) CHARACTER SET UTF32, KEY k1(c(193)))ENGINE=InnoDB; +INSERT INTO t1 SET c=''; +DROP TABLE t1; # End of 10.4 tests diff --git a/mysql-test/suite/innodb/t/index_length.test b/mysql-test/suite/innodb/t/index_length.test index bf4940d4b39..03e61a5a8f9 100644 --- a/mysql-test/suite/innodb/t/index_length.test +++ b/mysql-test/suite/innodb/t/index_length.test @@ -20,4 +20,12 @@ WHERE table_schema = 'test' AND table_name = 't1'; disconnect stop_purge; DROP TABLE t1; +--echo # +--echo # MDEV-22855 Assertion (!field->prefix_len || +--echo # field->fixed_len == field->prefix_len) +--echo # failed in btr_node_ptr_max_size +--echo # +CREATE TABLE t1(c CHAR(194) CHARACTER SET UTF32, KEY k1(c(193)))ENGINE=InnoDB; +INSERT INTO t1 SET c=''; +DROP TABLE t1; --echo # End of 10.4 tests diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index bd88582d4f4..bc9abd77a81 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1126,7 +1126,7 @@ static ulint btr_node_ptr_max_size(const dict_index_t* index) /* Determine the maximum length of the index field. */ field_max_size = dict_col_get_fixed_size(col, comp); - if (field_max_size) { + if (field_max_size && field->fixed_len) { /* dict_index_add_col() should guarantee this */ ut_ad(!field->prefix_len || field->fixed_len == field->prefix_len); From d7df63e1c922efcbbf9836f993754ad509823c19 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Tue, 19 Mar 2024 01:30:13 +0530 Subject: [PATCH 235/313] MDEV-19487: JSON_TYPE doesnt detect the type of String Values (returns NULL) and for Date/DateTime returns "INTEGER" Analysis: When the first character of json is scanned it is number. Based on that integer is returned. Fix: Scan rest of the json before returning the final result to ensure json is valid in the first place in order to have a valid type. --- mysql-test/main/func_json.result | 8 ++++++++ mysql-test/main/func_json.test | 7 +++++++ mysql-test/suite/json/r/json_no_table.result | 20 +++++++++++++++----- sql/item_jsonfunc.cc | 6 ++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index bf8c85a59f1..b7710aaaa89 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1697,5 +1697,13 @@ INSERT INTO t (doc) VALUES ('{ "_id" : { "$oid" : "0ca0b0f0" },"a" : [ { "a" : [ ERROR 22001: Data too long for column 'id' at row 1 DROP TABLE t; # +# MDEV-19487: JSON_TYPE doesnt detect the type of String Values (returns NULL) and for Date/DateTime returns "INTEGER" +# +SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')); +JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')) +NULL +Warnings: +Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 5 +# # End of 10.5 tests # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index c881ede45ce..35b9d9bffb9 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1125,6 +1125,13 @@ INSERT INTO t (doc) VALUES ('{ "_id" : { "$oid" : "0ca0b0f0" },"a" : [ { "a" : [ DROP TABLE t; +--echo # +--echo # MDEV-19487: JSON_TYPE doesnt detect the type of String Values (returns NULL) and for Date/DateTime returns "INTEGER" +--echo # + +SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')); + + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/suite/json/r/json_no_table.result b/mysql-test/suite/json/r/json_no_table.result index bb3b9d2ab1e..bd29ef99edd 100644 --- a/mysql-test/suite/json/r/json_no_table.result +++ b/mysql-test/suite/json/r/json_no_table.result @@ -1002,19 +1002,27 @@ DOUBLE error ER_INVALID_JSON_TEXT_IN_PARAM select json_type(CAST(CAST('2015-01-15' AS DATE) as CHAR CHARACTER SET 'utf8')); json_type(CAST(CAST('2015-01-15' AS DATE) as CHAR CHARACTER SET 'utf8')) -INTEGER +NULL +Warnings: +Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 5 # ---------------------------------------------------------------------- # Test of json_compact(literal) # ---------------------------------------------------------------------- select json_type(json_compact(cast('2014-11-25 18:00' as datetime))); json_type(json_compact(cast('2014-11-25 18:00' as datetime))) -INTEGER +NULL +Warnings: +Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 5 select json_type(json_compact(cast('2014-11-25' as date))); json_type(json_compact(cast('2014-11-25' as date))) -INTEGER +NULL +Warnings: +Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 5 select json_type(json_compact(cast('18:00:59' as time))); json_type(json_compact(cast('18:00:59' as time))) -INTEGER +NULL +Warnings: +Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 3 select json_type(json_compact(127)); json_type(json_compact(127)) INTEGER @@ -1064,7 +1072,9 @@ json_type(json_compact(3.14E30)) DOUBLE select json_type(json_compact(cast('10101abcde' as binary))); json_type(json_compact(cast('10101abcde' as binary))) -INTEGER +NULL +Warnings: +Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 6 select json_type(json_compact(ST_GeomFromText('POINT(1 1)'))); json_type(json_compact(ST_GeomFromText('POINT(1 1)'))) NULL diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index fb2e995cd52..95f8bfde7ce 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -2971,6 +2971,12 @@ String *Item_func_json_type::val_str(String *str) break; } + /* ensure the json is at least valid. */ + while(json_scan_next(&je) == 0) {} + + if (je.s.error) + goto error; + str->set(type, strlen(type), &my_charset_utf8mb3_general_ci); return str; From 5ca64e65d099ecd5aff616325ce4f7ed33baf633 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Tue, 19 Mar 2024 00:04:47 +0530 Subject: [PATCH 236/313] MDEV-32287: JSON_EXTRACT not returning multiple values for same path Analysis: When scanning json and getting the exact path at each step, if a path is reached, we end up adding the item in the result and immediately get the next item which results in current path changing. Fix: Instead of immediately returning the item, count the occurences of the path in argument and append in the result as needed. --- mysql-test/main/func_json.result | 6 ++++++ mysql-test/main/func_json.test | 8 ++++++++ sql/item_jsonfunc.cc | 25 +++++++++++++++++-------- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index b7710aaaa89..2991eb4e6fb 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1690,6 +1690,12 @@ select json_arrayagg('ä'), json_objectagg(1, 'ä'); json_arrayagg('ä') json_objectagg(1, 'ä') ["ä"] {"1":"ä"} # +# MDEV-32287: JSON_EXTRACT not returning multiple values for same path +# +select JSON_EXTRACT("[1, 2, [30, 40]]", '$[2][1]', '$[2][1]'); +JSON_EXTRACT("[1, 2, [30, 40]]", '$[2][1]', '$[2][1]') +[40, 40] +# # MDEV-31402: SIGSEGV in json_get_path_next | Item_func_json_extract::read_json # CREATE TABLE t (id CHAR AS (JSON_COMPACT (JSON_EXTRACT(doc,"$._id"))) UNIQUE KEY,doc JSON,CONSTRAINT notnu CHECK (id IS NOT NULL)); diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 35b9d9bffb9..5787ee88960 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1115,6 +1115,14 @@ set names latin1; select json_arrayagg('ä'), json_objectagg(1, 'ä'); --enable_service_connection + +--echo # +--echo # MDEV-32287: JSON_EXTRACT not returning multiple values for same path +--echo # + +select JSON_EXTRACT("[1, 2, [30, 40]]", '$[2][1]', '$[2][1]'); + + --echo # --echo # MDEV-31402: SIGSEGV in json_get_path_next | Item_func_json_extract::read_json --echo # diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 95f8bfde7ce..5622bf3e803 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -893,15 +893,16 @@ bool Item_func_json_extract::fix_length_and_dec() } -static bool path_exact(const json_path_with_flags *paths_list, int n_paths, +static int path_exact(const json_path_with_flags *paths_list, int n_paths, const json_path_t *p, json_value_types vt) { + int count_path= 0; for (; n_paths > 0; n_paths--, paths_list++) { if (json_path_compare(&paths_list->p, p, vt) == 0) - return TRUE; + count_path++; } - return FALSE; + return count_path; } @@ -925,7 +926,7 @@ String *Item_func_json_extract::read_json(String *str, json_engine_t je, sav_je; json_path_t p; const uchar *value; - int not_first_value= 0; + int not_first_value= 0, count_path= 0; uint n_arg; size_t v_len; int possible_multiple_values; @@ -972,7 +973,7 @@ String *Item_func_json_extract::read_json(String *str, while (json_get_path_next(&je, &p) == 0) { - if (!path_exact(paths, arg_count-1, &p, je.value_type)) + if (!(count_path= path_exact(paths, arg_count-1, &p, je.value_type))) continue; value= je.value_begin; @@ -1002,9 +1003,12 @@ String *Item_func_json_extract::read_json(String *str, je= sav_je; } - if ((not_first_value && str->append(", ", 2)) || - str->append((const char *) value, v_len)) - goto error; /* Out of memory. */ + for (int count= 0; count < count_path; count++) + { + if (str->append((const char *) value, v_len) || + str->append(", ", 2)) + goto error; /* Out of memory. */ + } not_first_value= 1; @@ -1025,6 +1029,11 @@ String *Item_func_json_extract::read_json(String *str, goto return_null; } + if (str->length()>2) + { + str->chop(); + str->chop(); + } if (possible_multiple_values && str->append("]", 1)) goto error; /* Out of memory. */ From 9e6858a42653c4684bbafa4b2c2c62f9ea8186c4 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Sat, 16 Mar 2024 00:28:48 +0530 Subject: [PATCH 237/313] MDEV-22141: JSON_REMOVE returns NULL on valid arguments Analysis: When we scan json to get to a beginning according to the path, we end up scanning json even if we have exhausted it. When eventually returns error. Fix: Continue scanning json only if we have not exhausted it and return result accordingly. --- mysql-test/main/func_json.result | 6 ++++++ mysql-test/main/func_json.test | 7 +++++++ sql/item_jsonfunc.cc | 1 + 3 files changed, 14 insertions(+) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 2991eb4e6fb..8d90a6ec726 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1711,5 +1711,11 @@ NULL Warnings: Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 5 # +# MDEV-22141: JSON_REMOVE returns NULL on valid arguments +# +SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D'); +JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D') +{"A": {"B": 1}} +# # End of 10.5 tests # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 5787ee88960..1b55dcb149e 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1140,6 +1140,13 @@ DROP TABLE t; SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')); +--echo # +--echo # MDEV-22141: JSON_REMOVE returns NULL on valid arguments +--echo # + +SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D'); + + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 5622bf3e803..442c4cbed90 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -3332,6 +3332,7 @@ String *Item_func_json_remove::val_str(String *str) { if (je.s.error) goto js_error; + continue; } if (json_read_value(&je)) From ec09c034d84fac703b42156db88faa89176a3f8c Mon Sep 17 00:00:00 2001 From: Tuukka Pasanen Date: Wed, 17 Apr 2024 12:14:14 +0300 Subject: [PATCH 238/313] MDEV-33852: Rework systemd installation on Debian Let dh_systemd handle most of the systemd side and get rid of custom scripts Rework installation of systemd service and socket files base on Michael Biebl merge request: https://salsa.debian.org/mariadb-team/mariadb-server/-/merge_requests/63 https://salsa.debian.org/mariadb-team/mariadb-server/-/merge_requests/75 --- debian/control | 2 +- debian/mariadb-server.install | 4 +++ debian/mariadb-server.postinst | 23 ----------------- debian/mariadb-server.postrm | 45 +--------------------------------- debian/mariadb-server.prerm | 14 ----------- debian/not-installed | 4 --- debian/rules | 14 ++--------- 7 files changed, 8 insertions(+), 98 deletions(-) delete mode 100644 debian/mariadb-server.prerm diff --git a/debian/control b/debian/control index 4290b6960d2..462ecd93666 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: MariaDB Developers Build-Depends: bison, cmake, cracklib-runtime , - debhelper (>= 10), + debhelper (>= 11), dh-exec, flex [amd64], gdb , diff --git a/debian/mariadb-server.install b/debian/mariadb-server.install index 602613a2d41..ba4d77ee0ec 100644 --- a/debian/mariadb-server.install +++ b/debian/mariadb-server.install @@ -11,6 +11,10 @@ lib/*/security/pam_user_map.so lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf lib/systemd/system/mysql.service lib/systemd/system/mysqld.service +usr/share/mysql/systemd/mariadb-extra@.socket +usr/share/mysql/systemd/mariadb.service +usr/share/mysql/systemd/mariadb@.service +usr/share/mysql/systemd/mariadb@.socket support-files/rpm/enable_encryption.preset etc/mysql/mariadb.conf.d/99-enable-encryption.cnf.preset usr/bin/aria_chk usr/bin/aria_dump_log diff --git a/debian/mariadb-server.postinst b/debian/mariadb-server.postinst index 8486a5be46d..bf7918de81f 100644 --- a/debian/mariadb-server.postinst +++ b/debian/mariadb-server.postinst @@ -285,28 +285,5 @@ esac db_stop # in case invoke fails -# dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mariadb. -# Thus MariaDB server is started via init.d script, which in turn redirects to -# systemctl. If we upgrade from MySQL mysql.service may be masked, which also -# means init.d script is disabled. Unmask mysql service explicitly. -# Check first that the command exists, to avoid emitting any warning messages. -if [ -x "$(command -v deb-systemd-helper)" ] -then - deb-systemd-helper unmask mysql.service > /dev/null -fi - #DEBHELPER# -# Modified dh_systemd_start snippet that's not added automatically -if [ -d /run/systemd/system ] -then - systemctl --system daemon-reload >/dev/null || true - deb-systemd-invoke start mariadb.service >/dev/null || true - # Modified dh_installinit snippet to only run with sysvinit -elif [ -x "/etc/init.d/mariadb" ] -then - if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] - then - invoke-rc.d mariadb start || exit $? - fi -fi diff --git a/debian/mariadb-server.postrm b/debian/mariadb-server.postrm index 4b62a8910fa..841be00b6c6 100644 --- a/debian/mariadb-server.postrm +++ b/debian/mariadb-server.postrm @@ -12,50 +12,7 @@ fi ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } -MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" - -# Try to stop the server in a sane way. If it does not success let the admin -# do it himself. No database directories should be removed while the server -# is running! Another mariadbd in e.g. a different chroot is fine for us. -stop_server() { - # Return immediately if there are no mysqld processes running - # as there is no point in trying to shutdown in that case. - if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null - then - return - fi - - set +e - invoke-rc.d mariadb stop - invoke-rc.d mysql stop # Backwards compatibility - errno=$? - set -e - - # systemctl could emit exit code 100=no init script (fresh install) - if [ "$errno" != 0 ] && [ "$errno" != 100 ] - then - echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2 - echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2 - echo "Stop it yourself and try again!" 1>&2 - db_stop - exit 1 - fi -} - - -case "$1" in - purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - if [ -n "$($MYADMIN ping 2>/dev/null)" ] - then - stop_server - sleep 2 - fi - ;; - *) - echo "postrm called with unknown argument '$1'" 1>&2 - exit 1 - ;; -esac +#DEBHELPER# # # - Purge logs and data only if they are ours (#307473) diff --git a/debian/mariadb-server.prerm b/debian/mariadb-server.prerm deleted file mode 100644 index 2701fa5fc36..00000000000 --- a/debian/mariadb-server.prerm +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -set -e - -#DEBHELPER# - -# Modified dh_systemd_start snippet that's not added automatically -if [ -d /run/systemd/system ] -then - deb-systemd-invoke stop mariadb.service >/dev/null - # Modified dh_installinit snippet to only run with sysvinit -elif [ -x "/etc/init.d/mariadb" ] -then - invoke-rc.d mariadb stop || exit $? -fi diff --git a/debian/not-installed b/debian/not-installed index c0d08565616..a7dada6a434 100644 --- a/debian/not-installed +++ b/debian/not-installed @@ -64,10 +64,6 @@ usr/share/mysql/policy/selinux/README # In MariaDB we don't want to use SELinux usr/share/mysql/policy/selinux/mariadb-server.fc # In MariaDB we don't want to use SELinux at the moment usr/share/mysql/policy/selinux/mariadb-server.te # In MariaDB we don't want to use SELinux at the moment usr/share/mysql/policy/selinux/mariadb.te # In MariaDB we don't want to use SELinux at the moment -usr/share/mysql/systemd/mariadb-extra@.socket # Installed by rules file -usr/share/mysql/systemd/mariadb.service # Installed by rules file -usr/share/mysql/systemd/mariadb@.service # Installed by rules file -usr/share/mysql/systemd/mariadb@.socket # Installed by rules file usr/share/mysql/systemd/mysql.service # Installed by rules file usr/share/mysql/systemd/mysqld.service # Installed by rules file usr/share/mysql/systemd/use_galera_new_cluster.conf diff --git a/debian/rules b/debian/rules index 47586c462f9..a8478757706 100755 --- a/debian/rules +++ b/debian/rules @@ -126,16 +126,6 @@ override_dh_auto_install: dh_testdir dh_testroot -ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS))) - # Copy systemd files to a location available for dh_installinit - cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server.mariadb.service - cp $(BUILDDIR)/support-files/mariadb.socket debian/mariadb-server.mariadb.socket - cp $(BUILDDIR)/support-files/mariadb-extra.socket debian/mariadb-server.mariadb-extra.socket - cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server.mariadb@.service - cp $(BUILDDIR)/support-files/mariadb@.socket debian/mariadb-server.mariadb@.socket - cp $(BUILDDIR)/support-files/mariadb-extra@.socket debian/mariadb-server.mariadb-extra@.socket -endif - # Run 'make install' without output since it is uninteresting and # silencing it helps to make overall build log shorter and more readable @echo "Running $(MAKE) install DESTDIR=$(TMP) ..." @@ -178,8 +168,8 @@ endif # Move test plugins that are only needed by the client to the libmariadb path mv -v $(TMP)/usr/lib/mysql/plugin/qa_auth_client.so $(TMP)/usr/lib/$(DEB_HOST_MULTIARCH)/libmariadb3/plugin/ -override_dh_systemd_enable: - dh_systemd_enable --name=mariadb +override_dh_installsystemd: + dh_systemd_enable --name=mariadb mariadb.service dh_systemd_enable --no-enable --name=mariadb mariadb.socket dh_systemd_enable --no-enable --name=mariadb-extra mariadb-extra.socket dh_systemd_enable --no-enable --name=mariadb@ mariadb.socket From 814dc46748d8c276f18c7664d8d14a543cff954c Mon Sep 17 00:00:00 2001 From: Monty Date: Sat, 27 Apr 2024 13:35:48 +0300 Subject: [PATCH 239/313] Fixed slow bootstrap introduced in 10.6 The problem was that the signal thread was not killed when using unireg_abort(). The bug was introduced by: MDEV-30260: Slave crashed:reload_acl_and_cache during shutdown Other things fixed: - Don't produce memory leaks with safemalloc if all threads was not ended properly (not useful) --- include/my_sys.h | 2 +- mysys/my_thr_init.c | 8 +++++--- sql/mysqld.cc | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 84a1e6a4752..d58e53d0bf3 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -153,7 +153,7 @@ char *guess_malloc_library(); void sf_report_leaked_memory(my_thread_id id); int sf_sanity(); extern my_thread_id (*sf_malloc_dbug_id)(void); -#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X) +#define SAFEMALLOC_REPORT_MEMORY(X) if (!sf_leaking_memory) sf_report_leaked_memory(X) #else #define SAFEMALLOC_REPORT_MEMORY(X) do {} while(0) #endif diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 2e8decd7d06..b2436d2be27 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -220,7 +220,11 @@ void my_thread_global_end(void) fprintf(stderr, "Error in my_thread_global_end(): %d threads didn't exit\n", THR_thread_count); -#endif +#endif /* HAVE_PTHREAD_KILL */ +#ifdef SAFEMALLOC + /* We know we will have memoryleaks, suppress the leak report */ + sf_leaking_memory= 1; +#endif /* SAFEMALLOC */ all_threads_killed= 0; break; } @@ -234,9 +238,7 @@ void my_thread_global_end(void) that could use them. */ if (all_threads_killed) - { my_thread_destroy_internal_mutex(); - } my_thread_global_init_done= 0; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0d2f1bd0309..6d7b09adc4c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1889,6 +1889,7 @@ extern "C" void unireg_abort(int exit_code) wsrep_sst_auth_free(); #endif // WITH_WSREP + wait_for_signal_thread_to_end(); clean_up(!opt_abort && (exit_code || !opt_bootstrap)); /* purecov: inspected */ DBUG_PRINT("quit",("done with cleanup in unireg_abort")); mysqld_exit(exit_code); From 6a63204c362ad8c3f644226ea9032bbad8250d81 Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 29 Apr 2024 20:10:21 +0300 Subject: [PATCH 240/313] MDEV-34029 rpl.rpl_heartbeat can fail when (BB) mtr reorders tests rpl.rpl_heartbeat turns out to miss a standard include/master-slave header which made it potentially in BB and actually with manual mtr failing as it may have used a previous slave GTID state. Fixed with installing the standard rpl suite header/footer in the test file. --- mysql-test/suite/rpl/r/rpl_heartbeat.result | 7 ++++--- mysql-test/suite/rpl/t/rpl_heartbeat.test | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_heartbeat.result b/mysql-test/suite/rpl/r/rpl_heartbeat.result index 2a578245400..c9baf960d9a 100644 --- a/mysql-test/suite/rpl/r/rpl_heartbeat.result +++ b/mysql-test/suite/rpl/r/rpl_heartbeat.result @@ -1,8 +1,9 @@ -connect master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK; -connect slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK; +include/master-slave.inc +[connection master] connection master; reset master; connection slave; +include/stop_slave.inc set @restore_slave_net_timeout= @@global.slave_net_timeout; set @@global.slave_net_timeout= 10; change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root'; @@ -68,5 +69,5 @@ connection master; drop table t1; connection slave; set @@global.slave_net_timeout= @restore_slave_net_timeout; -include/stop_slave.inc +include/rpl_end.inc End of tests diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat.test b/mysql-test/suite/rpl/t/rpl_heartbeat.test index e4753b7be07..8a852fd3abf 100644 --- a/mysql-test/suite/rpl/t/rpl_heartbeat.test +++ b/mysql-test/suite/rpl/t/rpl_heartbeat.test @@ -8,14 +8,13 @@ # - SHOW STATUS like 'Slave_heartbeat_period' report -- source include/have_log_bin.inc - -connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); -connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK); +-- source include/master-slave.inc connection master; reset master; connection slave; +-- source include/stop_slave.inc set @restore_slave_net_timeout= @@global.slave_net_timeout; --disable_warnings set @@global.slave_net_timeout= 10; @@ -170,6 +169,5 @@ set @@global.slave_net_timeout= @restore_slave_net_timeout; --disable_prepare_warnings ---source include/stop_slave.inc - +--source include/rpl_end.inc --echo End of tests From ae03374f29944f4ae5cbc4df80d7273f2476dcff Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 29 Apr 2024 20:32:55 +0300 Subject: [PATCH 241/313] MDEV-34030 rpl.rpl_using_gtid_default can fail in (BB) mtr The test's header is not written to follow strictly a correct order of checks by mtr at test start which may lead to an error. E.g ./mtr --mysqld=--binlog-format=row rpl.rpl_using_gtid_default to At line 175: query 'SET GLOBAL gtid_slave_pos= ""' failed: ER_SLAVE_MUST_STOP (1198): This operation cannot be performed as you have a running slave ''; run STOP SLAVE '' first Fixed to require the binlog format first in the test header. --- mysql-test/suite/rpl/t/rpl_using_gtid_default.test | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mysql-test/suite/rpl/t/rpl_using_gtid_default.test b/mysql-test/suite/rpl/t/rpl_using_gtid_default.test index c14695f98cb..1557fcdcef8 100644 --- a/mysql-test/suite/rpl/t/rpl_using_gtid_default.test +++ b/mysql-test/suite/rpl/t/rpl_using_gtid_default.test @@ -42,10 +42,9 @@ # replication is used by default if master supports it # --source include/have_debug.inc ---source include/master-slave.inc - # Format independent test so just use one --source include/have_binlog_format_mixed.inc +--source include/master-slave.inc --echo # --echo # Slave default configuration should be Slave_Pos From f9575495ceef8a262a977cf07a9d6a9c0551ba11 Mon Sep 17 00:00:00 2001 From: Bernard Spil Date: Sun, 28 Apr 2024 16:51:04 +0000 Subject: [PATCH 242/313] Fix typo There is no component `SuportFiles` in MariaDB server, yet a `SupportFiles` component exists. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a01ebcf57eb..05bd751be21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,7 +198,7 @@ ENDIF() OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON) IF (WITHOUT_SERVER) - SET (SKIP_COMPONENTS "Server|IniFiles|SuportFiles|Readme") + SET (SKIP_COMPONENTS "Server|IniFiles|SupportFiles|Readme") ELSE() SET (SKIP_COMPONENTS "N-O-N-E") ENDIF() From f378e7643459f0baa6c4149a795463f2f46b6871 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 30 Apr 2024 14:16:08 +0530 Subject: [PATCH 243/313] MDEV-33980 mariadb-backup --backup is missing retry logic for undo tablespaces Problem: ======== - Currently mariabackup have to reread the pages in case they are modified by server concurrently. But while reading the undo tablespace, mariabackup failed to do reread the page in case of error. Fix: === Mariabackup --backup functionality should have retry logic while reading the undo tablespaces. --- .../suite/mariabackup/undo_space_id.result | 7 +++++++ .../suite/mariabackup/undo_space_id.test | 19 +++++++++++++++++++ storage/innobase/os/os0file.cc | 8 ++++++++ storage/innobase/srv/srv0start.cc | 13 ++++++++++++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/mariabackup/undo_space_id.result b/mysql-test/suite/mariabackup/undo_space_id.result index 96d3e2a58f4..8ca52da7e0d 100644 --- a/mysql-test/suite/mariabackup/undo_space_id.result +++ b/mysql-test/suite/mariabackup/undo_space_id.result @@ -11,3 +11,10 @@ undo004 undo003 undo004 DROP TABLE t1; +# +# MDEV-33980 mariadb-backup --backup is missing +# retry logic for undo tablespaces +# +# xtrabackup backup +# Display undo log files from target directory +FOUND 5 /Retrying to read undo tablespace*/ in backup.log diff --git a/mysql-test/suite/mariabackup/undo_space_id.test b/mysql-test/suite/mariabackup/undo_space_id.test index e903a0ad4c5..f9859cb999d 100644 --- a/mysql-test/suite/mariabackup/undo_space_id.test +++ b/mysql-test/suite/mariabackup/undo_space_id.test @@ -23,3 +23,22 @@ list_files $basedir undo*; DROP TABLE t1; rmdir $basedir; + +--echo # +--echo # MDEV-33980 mariadb-backup --backup is missing +--echo # retry logic for undo tablespaces +--echo # +let $backuplog= $MYSQLTEST_VARDIR/tmp/backup.log; +--echo # xtrabackup backup +--disable_result_log +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir --dbug=+d,undo_space_read_fail > $backuplog; +--enable_result_log +--echo # Display undo log files from target directory +list_files $basedir undo*; + +--let SEARCH_PATTERN=Retrying to read undo tablespace* +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +rmdir $basedir; +remove_file $backuplog; diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 075f838ebb1..6c5203b0739 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -7560,7 +7560,15 @@ invalid: } ut_free(buf2); + DBUG_EXECUTE_IF("undo_space_read_fail", + if (space_id == srv_undo_space_id_start) { + goto wrong_space_id; + }); + if (UNIV_UNLIKELY(space_id != space->id)) { +#ifndef DBUG_OFF +wrong_space_id: +#endif ib::error() << "Expected tablespace id " << space->id << " but found " << space_id << " in the file " << name; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index b8b74263eba..d1b682d9200 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -100,6 +100,7 @@ Created 2/16/1996 Heikki Tuuri #include "zlib.h" #include "ut0crc32.h" #include "btr0scrub.h" +#include "log.h" /** Log sequence number immediately after startup */ lsn_t srv_start_lsn; @@ -656,10 +657,11 @@ static bool srv_undo_tablespace_open(const char* name, ulint space_id, pfs_os_file_t fh; bool success; char undo_name[sizeof "innodb_undo000"]; + ulint n_retries = 5; snprintf(undo_name, sizeof(undo_name), "innodb_undo%03u", static_cast(space_id)); - +undo_retry: fh = os_file_create( innodb_data_file_key, name, OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT | OS_FILE_ON_ERROR_SILENT, @@ -716,6 +718,15 @@ static bool srv_undo_tablespace_open(const char* name, ulint space_id, mutex_exit(&fil_system.mutex); + if (!success && n_retries && + srv_operation == SRV_OPERATION_BACKUP) { + sql_print_information("InnoDB: Retrying to read undo " + "tablespace %s", undo_name); + fil_space_free(space_id, false); + n_retries--; + goto undo_retry; + } + return success; } From bf77f9793dd13630ea2302f5cbdfe5b741e1817a Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Sat, 13 Apr 2024 23:29:11 +0100 Subject: [PATCH 244/313] openssl: add a more specific DES support detection Improve detection for DES support in OpenSSL, to allow compilation against system OpenSSL without DES. Note that MariaDB needs to be compiled against OpenSSL-like library that itself has DES support which cmake detected. Positive detection is indicated with CMake variable HAVE_des 1. Signed-off-by: Dimitri John Ledkov --- cmake/ssl.cmake | 3 ++ config.h.cmake | 1 + mysql-test/main/func_encrypt_nossl.result | 42 +++++++++++------------ mysql-test/main/ssl_and_innodb.test | 2 +- sql/des_key_file.cc | 4 +-- sql/des_key_file.h | 4 +-- sql/item_strfunc.cc | 12 +++---- sql/mysqld.cc | 35 ++++++++++++------- sql/mysqld.h | 17 +++++---- sql/sql_reload.cc | 2 +- 10 files changed, 67 insertions(+), 55 deletions(-) diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index 51176a84c51..8be48e2a597 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -60,6 +60,7 @@ MACRO (MYSQL_USE_BUNDLED_SSL) SET(HAVE_EncryptAes128Ctr OFF CACHE INTERNAL "wolfssl does support AES-CTR, but differently from openssl") SET(HAVE_EncryptAes128Gcm OFF CACHE INTERNAL "wolfssl does not support AES-GCM") SET(HAVE_X509_check_host ON CACHE INTERNAL "wolfssl does support X509_check_host") + SET(HAVE_des ON CACHE INTERNAL "wolfssl does support DES API") CHANGE_SSL_SETTINGS("bundled") ADD_SUBDIRECTORY(extra/wolfssl) MESSAGE_ONCE(SSL_LIBRARIES "SSL_LIBRARIES = ${SSL_LIBRARIES}") @@ -158,6 +159,8 @@ MACRO (MYSQL_CHECK_SSL) HAVE_EncryptAes128Gcm) CHECK_SYMBOL_EXISTS(X509_check_host "openssl/x509v3.h" HAVE_X509_check_host) + CHECK_SYMBOL_EXISTS(DES_set_key_unchecked "openssl/des.h" + HAVE_des) SET(CMAKE_REQUIRED_INCLUDES) SET(CMAKE_REQUIRED_LIBRARIES) SET(CMAKE_REQUIRED_DEFINITIONS) diff --git a/config.h.cmake b/config.h.cmake index cc35690f708..2c421798c33 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -498,6 +498,7 @@ #cmakedefine HAVE_COMPRESS 1 #cmakedefine HAVE_EncryptAes128Ctr 1 #cmakedefine HAVE_EncryptAes128Gcm 1 +#cmakedefine HAVE_des 1 /* Stuff that always need to be defined (compile breaks without it) diff --git a/mysql-test/main/func_encrypt_nossl.result b/mysql-test/main/func_encrypt_nossl.result index dd45717a22f..73bb5c591b9 100644 --- a/mysql-test/main/func_encrypt_nossl.result +++ b/mysql-test/main/func_encrypt_nossl.result @@ -2,83 +2,83 @@ select des_encrypt("test", 'akeystr'); des_encrypt("test", 'akeystr') NULL Warnings: -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_encrypt("test", 1); des_encrypt("test", 1) NULL Warnings: -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_encrypt("test", 9); des_encrypt("test", 9) NULL Warnings: -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_encrypt("test", 100); des_encrypt("test", 100) NULL Warnings: -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_encrypt("test", NULL); des_encrypt("test", NULL) NULL Warnings: -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_encrypt(NULL, NULL); des_encrypt(NULL, NULL) NULL Warnings: -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_decrypt("test", 'anotherkeystr'); des_decrypt("test", 'anotherkeystr') NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_decrypt(1, 1); des_decrypt(1, 1) NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_decrypt(des_encrypt("test", 'thekey')); des_decrypt(des_encrypt("test", 'thekey')) NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select hex(des_encrypt("hello")),des_decrypt(des_encrypt("hello")); hex(des_encrypt("hello")) des_decrypt(des_encrypt("hello")) NULL NULL Warnings: -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_decrypt(des_encrypt("hello",4)); des_decrypt(des_encrypt("hello",4)) NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_decrypt(des_encrypt("hello",'test'),'test'); des_decrypt(des_encrypt("hello",'test'),'test') NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select hex(des_encrypt("hello")),hex(des_encrypt("hello",5)),hex(des_encrypt("hello",'default_password')); hex(des_encrypt("hello")) hex(des_encrypt("hello",5)) hex(des_encrypt("hello",'default_password')) NULL NULL NULL Warnings: -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working -Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working +Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_decrypt(des_encrypt("hello"),'default_password'); des_decrypt(des_encrypt("hello"),'default_password') NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select des_decrypt(des_encrypt("hello",4),'password4'); des_decrypt(des_encrypt("hello",4),'password4') NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working SET @a=des_decrypt(des_encrypt("hello")); Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working flush des_key_file; select @a = des_decrypt(des_encrypt("hello")); @a = des_decrypt(des_encrypt("hello")) @@ -90,9 +90,9 @@ select hex(des_decrypt(des_encrypt("hello",4),'password2')); hex(des_decrypt(des_encrypt("hello",4),'password2')) NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working select hex(des_decrypt(des_encrypt("hello","hidden"))); hex(des_decrypt(des_encrypt("hello","hidden"))) NULL Warnings: -Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working +Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working diff --git a/mysql-test/main/ssl_and_innodb.test b/mysql-test/main/ssl_and_innodb.test index 4966f05b37b..2104eb5c8bf 100644 --- a/mysql-test/main/ssl_and_innodb.test +++ b/mysql-test/main/ssl_and_innodb.test @@ -1,5 +1,5 @@ -- source include/have_innodb.inc --- source include/have_ssl_crypto_functs.inc +-- source include/have_des.inc CREATE TABLE t1(a int) engine=innodb; INSERT INTO t1 VALUES (1); diff --git a/sql/des_key_file.cc b/sql/des_key_file.cc index bfbe04f6015..776be8a5a2f 100644 --- a/sql/des_key_file.cc +++ b/sql/des_key_file.cc @@ -19,7 +19,7 @@ #include "log.h" // sql_print_error #include -#ifdef HAVE_OPENSSL +#ifdef HAVE_des struct st_des_keyschedule des_keyschedule[10]; uint des_default_key; @@ -103,4 +103,4 @@ error: mysql_mutex_unlock(&LOCK_des_key_file); DBUG_RETURN(result); } -#endif /* HAVE_OPENSSL */ +#endif /* HAVE_des */ diff --git a/sql/des_key_file.h b/sql/des_key_file.h index 847cd767b4b..58ed2f87b8e 100644 --- a/sql/des_key_file.h +++ b/sql/des_key_file.h @@ -16,7 +16,7 @@ #ifndef DES_KEY_FILE_INCLUDED #define DES_KEY_FILE_INCLUDED -#ifdef HAVE_OPENSSL +#ifdef HAVE_des #include #include "violite.h" /* DES_cblock, DES_key_schedule */ @@ -35,6 +35,6 @@ extern struct st_des_keyschedule des_keyschedule[10]; extern uint des_default_key; bool load_des_key_file(const char *file_name); -#endif /* HAVE_OPENSSL */ +#endif /* HAVE_des */ #endif /* DES_KEY_FILE_INCLUDED */ diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index ad7ed6e2c9e..c36a2a5c072 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -722,7 +722,7 @@ bool Item_func_concat::fix_length_and_dec() String *Item_func_des_encrypt::val_str(String *str) { DBUG_ASSERT(fixed == 1); -#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) +#if defined(HAVE_des) && !defined(EMBEDDED_LIBRARY) uint code= ER_WRONG_PARAMETERS_TO_PROCEDURE; DES_cblock ivec; struct st_des_keyblock keyblock; @@ -811,8 +811,8 @@ error: THD *thd= current_thd; push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_FEATURE_DISABLED, ER_THD(thd, ER_FEATURE_DISABLED), - "des_encrypt", "--with-ssl"); -#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */ + "des_encrypt", "openssl des cipher (HAVE_des)"); +#endif /* defined(HAVE_des) && !defined(EMBEDDED_LIBRARY) */ null_value=1; return 0; } @@ -821,7 +821,7 @@ error: String *Item_func_des_decrypt::val_str(String *str) { DBUG_ASSERT(fixed == 1); -#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) +#if defined(HAVE_des) && !defined(EMBEDDED_LIBRARY) uint code= ER_WRONG_PARAMETERS_TO_PROCEDURE; DES_cblock ivec; struct st_des_keyblock keyblock; @@ -896,9 +896,9 @@ wrong_key: THD *thd= current_thd; push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_FEATURE_DISABLED, ER_THD(thd, ER_FEATURE_DISABLED), - "des_decrypt", "--with-ssl"); + "des_decrypt", "openssl des cipher (HAVE_des)"); } -#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */ +#endif /* defined(HAVE_des) && !defined(EMBEDDED_LIBRARY) */ null_value=1; return 0; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 128899cb347..be75dd9fc66 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -706,9 +706,6 @@ mysql_mutex_t LOCK_thread_id; server may be fairly high, we need a dedicated lock. */ mysql_mutex_t LOCK_prepared_stmt_count; -#ifdef HAVE_OPENSSL -mysql_mutex_t LOCK_des_key_file; -#endif mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; mysql_rwlock_t LOCK_ssl_refresh; mysql_rwlock_t LOCK_all_status_vars; @@ -849,7 +846,7 @@ static struct my_option pfs_early_options[]= PSI_file_key key_file_binlog, key_file_binlog_cache, key_file_binlog_index, key_file_binlog_index_cache, key_file_casetest, - key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file, + key_file_dbopt, key_file_ERRMSG, key_select_to_file, key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load, key_file_loadfile, key_file_log_event_data, key_file_log_event_info, key_file_master_info, key_file_misc, key_file_partition_ddl_log, @@ -860,16 +857,19 @@ PSI_file_key key_file_relaylog, key_file_relaylog_index, key_file_relaylog_cache, key_file_relaylog_index_cache; PSI_file_key key_file_binlog_state; +#ifdef HAVE_des +char *des_key_file; +PSI_file_key key_file_des_key_file; +PSI_mutex_key key_LOCK_des_key_file; +mysql_mutex_t LOCK_des_key_file; +#endif /* HAVE_des */ + #ifdef HAVE_PSI_INTERFACE #ifdef HAVE_MMAP PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active, key_LOCK_pool, key_LOCK_pending_checkpoint; #endif /* HAVE_MMAP */ -#ifdef HAVE_OPENSSL -PSI_mutex_key key_LOCK_des_key_file; -#endif /* HAVE_OPENSSL */ - PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, key_BINLOG_LOCK_binlog_background_thread, key_LOCK_binlog_end_pos, @@ -924,9 +924,9 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_pool, "TC_LOG_MMAP::LOCK_pending_checkpoint", 0}, #endif /* HAVE_MMAP */ -#ifdef HAVE_OPENSSL +#ifdef HAVE_des { &key_LOCK_des_key_file, "LOCK_des_key_file", PSI_FLAG_GLOBAL}, -#endif /* HAVE_OPENSSL */ +#endif /* HAVE_des */ { &key_BINLOG_LOCK_index, "MYSQL_BIN_LOG::LOCK_index", 0}, { &key_BINLOG_LOCK_xid_list, "MYSQL_BIN_LOG::LOCK_xid_list", 0}, @@ -1454,7 +1454,6 @@ static void openssl_dynlock_destroy(openssl_lock_t *, const char *, int); static void openssl_lock_function(int, int, const char *, int); static void openssl_lock(int, openssl_lock_t *, const char *, int); #endif /* HAVE_OPENSSL10 */ -char *des_key_file; #ifndef EMBEDDED_LIBRARY struct st_VioSSLFd *ssl_acceptor_fd; #endif @@ -2137,7 +2136,9 @@ static void clean_up_mutexes() mysql_mutex_destroy(&LOCK_global_table_stats); mysql_mutex_destroy(&LOCK_global_index_stats); #ifdef HAVE_OPENSSL +#ifdef HAVE_des mysql_mutex_destroy(&LOCK_des_key_file); +#endif /* HAVE_des */ #if defined(HAVE_OPENSSL10) && !defined(HAVE_WOLFSSL) for (int i= 0; i < CRYPTO_num_locks(); ++i) mysql_rwlock_destroy(&openssl_stdlocks[i].lock); @@ -4260,8 +4261,10 @@ static int init_thread_environment() MY_MUTEX_INIT_SLOW); #ifdef HAVE_OPENSSL +#ifdef HAVE_des mysql_mutex_init(key_LOCK_des_key_file, &LOCK_des_key_file, MY_MUTEX_INIT_FAST); +#endif /* HAVE_des */ #if defined(HAVE_OPENSSL10) && !defined(HAVE_WOLFSSL) openssl_stdlocks= (openssl_lock_t*) OPENSSL_malloc(CRYPTO_num_locks() * sizeof(openssl_lock_t)); @@ -4479,8 +4482,10 @@ static void init_ssl() { have_ssl= SHOW_OPTION_DISABLED; } +#ifdef HAVE_des if (des_key_file) load_des_key_file(des_key_file); +#endif /* HAVE_des */ #endif /* HAVE_OPENSSL && ! EMBEDDED_LIBRARY */ } @@ -6566,12 +6571,12 @@ struct my_option my_long_options[]= &opt_debug_sync_timeout, 0, 0, GET_UINT, OPT_ARG, 0, 0, UINT_MAX, 0, 0, 0}, #endif /* defined(ENABLED_DEBUG_SYNC) */ -#ifdef HAVE_OPENSSL +#ifdef HAVE_des {"des-key-file", 0, "Load keys for des_encrypt() and des_encrypt from given file.", &des_key_file, &des_key_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, -#endif /* HAVE_OPENSSL */ +#endif /* HAVE_des */ #ifdef HAVE_STACKTRACE {"stack-trace", 0 , "Print a symbolic stack trace on failure", &opt_stack_trace, &opt_stack_trace, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, @@ -7917,7 +7922,9 @@ static int mysql_init_variables(void) libwrapName= NullS; #endif #ifdef HAVE_OPENSSL +#ifdef HAVE_des des_key_file = 0; +#endif /* HAVE_des */ #ifndef EMBEDDED_LIBRARY ssl_acceptor_fd= 0; #endif /* ! EMBEDDED_LIBRARY */ @@ -9112,7 +9119,9 @@ static PSI_file_info all_server_files[]= { &key_file_io_cache, "io_cache", 0}, { &key_file_casetest, "casetest", 0}, { &key_file_dbopt, "dbopt", 0}, +#ifdef HAVE_des { &key_file_des_key_file, "des_key_file", 0}, +#endif { &key_file_ERRMSG, "ERRMSG", 0}, { &key_select_to_file, "select_to_file", 0}, { &key_file_fileparser, "file_parser", 0}, diff --git a/sql/mysqld.h b/sql/mysqld.h index 5fa8e22c2ab..15febb1e15d 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -310,10 +310,6 @@ extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active, key_LOCK_pool, key_LOCK_pending_checkpoint; #endif /* HAVE_MMAP */ -#ifdef HAVE_OPENSSL -extern PSI_mutex_key key_LOCK_des_key_file; -#endif - extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, key_BINLOG_LOCK_binlog_background_thread, key_LOCK_binlog_end_pos, @@ -390,7 +386,7 @@ extern PSI_thread_key key_thread_delayed_insert, extern PSI_file_key key_file_binlog, key_file_binlog_cache, key_file_binlog_index, key_file_binlog_index_cache, key_file_casetest, - key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file, + key_file_dbopt, key_file_ERRMSG, key_select_to_file, key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load, key_file_loadfile, key_file_log_event_data, key_file_log_event_info, key_file_master_info, key_file_misc, key_file_partition_ddl_log, @@ -403,6 +399,13 @@ extern PSI_socket_key key_socket_tcpip, key_socket_unix, key_socket_client_connection; extern PSI_file_key key_file_binlog_state; +#ifdef HAVE_des +extern char* des_key_file; +extern PSI_file_key key_file_des_key_file; +extern PSI_mutex_key key_LOCK_des_key_file; +extern mysql_mutex_t LOCK_des_key_file; +#endif + #ifdef HAVE_PSI_INTERFACE void init_server_psi_keys(); #endif /* HAVE_PSI_INTERFACE */ @@ -746,10 +749,6 @@ extern mysql_mutex_t extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_global_system_variables; extern mysql_rwlock_t LOCK_all_status_vars; extern mysql_mutex_t LOCK_start_thread; -#ifdef HAVE_OPENSSL -extern char* des_key_file; -extern mysql_mutex_t LOCK_des_key_file; -#endif extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_server_started; extern MYSQL_PLUGIN_IMPORT mysql_cond_t COND_server_started; extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 4f6356cff54..3a9b8e4641d 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -392,7 +392,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, } } #endif -#ifdef HAVE_OPENSSL +#ifdef HAVE_des if (options & REFRESH_DES_KEY_FILE) { if (des_key_file && load_des_key_file(des_key_file)) From b663c935a423ca582c28f1840fcbf23574affbe8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 30 Apr 2024 12:30:48 +0200 Subject: [PATCH 245/313] don't use normal diffs in *.rdiff files they aren't robust enough and can easily apply incorrectly (this fixes the failure of innodb.insert_into_empty,4k after the merge) --- .../r/alter_not_null,COPY,NON-STRICT.rdiff | 121 ++++++++---- .../innodb/r/alter_not_null,COPY,STRICT.rdiff | 181 +++++++++++------- .../r/alter_not_null,INPLACE,STRICT.rdiff | 164 +++++++++------- .../suite/innodb/r/innodb-wl5522,crc32.rdiff | 5 - .../innodb/r/innodb-wl5522,strict_crc32.rdiff | 17 +- .../suite/innodb/r/insert_into_empty,4k.rdiff | 12 +- 6 files changed, 308 insertions(+), 192 deletions(-) delete mode 100644 mysql-test/suite/innodb/r/innodb-wl5522,crc32.rdiff diff --git a/mysql-test/suite/innodb/r/alter_not_null,COPY,NON-STRICT.rdiff b/mysql-test/suite/innodb/r/alter_not_null,COPY,NON-STRICT.rdiff index 01db97e59f8..7c32d38a1d9 100644 --- a/mysql-test/suite/innodb/r/alter_not_null,COPY,NON-STRICT.rdiff +++ b/mysql-test/suite/innodb/r/alter_not_null,COPY,NON-STRICT.rdiff @@ -1,42 +1,79 @@ -7,8c7,8 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 ---- -> affected rows: 1 -> info: Records: 1 Duplicates: 0 Warnings: 1 -21,22c21,22 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 ---- -> affected rows: 1 -> info: Records: 1 Duplicates: 0 Warnings: 1 -35,36c35,36 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 ---- -> affected rows: 1 -> info: Records: 1 Duplicates: 0 Warnings: 1 -49,50c49,50 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 ---- -> affected rows: 1 -> info: Records: 1 Duplicates: 0 Warnings: 1 -63,64c63,64 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 ---- -> affected rows: 1 -> info: Records: 1 Duplicates: 0 Warnings: 1 -77,78c77,78 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 ---- -> affected rows: 1 -> info: Records: 1 Duplicates: 0 Warnings: 1 -98,99c98,99 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 ---- -> affected rows: 1 -> info: Records: 1 Duplicates: 0 Warnings: 1 +--- alter_not_null.result ++++ alter_not_null,COPY,NON-STRICT.result~ +@@ -4,8 +4,8 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 INT NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 1 + Warnings: + Warning 1265 Data truncated for column 'f1' at row 1 + SELECT * FROM t1; +@@ -18,8 +18,8 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 CHAR(10) NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 1 + Warnings: + Warning 1265 Data truncated for column 'f1' at row 1 + SELECT * FROM t1; +@@ -32,8 +32,8 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 VARCHAR(20) NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 1 + Warnings: + Warning 1265 Data truncated for column 'f1' at row 1 + SELECT * FROM t1; +@@ -46,8 +46,8 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 TEXT NOT NULL DEFAULT 'abc'; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 1 + Warnings: + Warning 1265 Data truncated for column 'f1' at row 1 + SELECT * FROM t1; +@@ -60,8 +60,8 @@ + f1 f2 f3 + 2 2 NULL + ALTER TABLE t1 CHANGE f3 f3 INT NOT NULL DEFAULT (f1 + f2); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 1 + Warnings: + Warning 1265 Data truncated for column 'f3' at row 1 + SELECT * FROM t1; +@@ -74,8 +74,8 @@ + f1 b + 10 NULL + ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 1 + Warnings: + Warning 1265 Data truncated for column 'b' at row 1 + SELECT * FROM t1; +@@ -95,8 +95,8 @@ + CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1))ENGINE=INNODB; + INSERT INTO t1 VALUES(1, NULL); + ALTER IGNORE TABLE t1 CHANGE c2 c2 INT NOT NULL DEFAULT 2; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 1 + Warnings: + Warning 1265 Data truncated for column 'c2' at row 1 + SELECT * FROM t1; diff --git a/mysql-test/suite/innodb/r/alter_not_null,COPY,STRICT.rdiff b/mysql-test/suite/innodb/r/alter_not_null,COPY,STRICT.rdiff index e02d235cb72..37e97169a11 100644 --- a/mysql-test/suite/innodb/r/alter_not_null,COPY,STRICT.rdiff +++ b/mysql-test/suite/innodb/r/alter_not_null,COPY,STRICT.rdiff @@ -1,72 +1,109 @@ -7,10c7 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f1' at row 1 ---- -> ERROR 01000: Data truncated for column 'f1' at row 1 -13c10 -< 0 ---- -> NULL -21,24c18 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f1' at row 1 ---- -> ERROR 01000: Data truncated for column 'f1' at row 1 -27c21 -< ---- -> NULL -35,38c29 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f1' at row 1 ---- -> ERROR 01000: Data truncated for column 'f1' at row 1 -41c32 -< ---- -> NULL -49,52c40 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f1' at row 1 ---- -> ERROR 01000: Data truncated for column 'f1' at row 1 -55c43 -< ---- -> NULL -63,66c51 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f3' at row 1 ---- -> ERROR 01000: Data truncated for column 'f3' at row 1 -69c54 -< 2 2 0 ---- -> 2 2 NULL -77,80c62 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'b' at row 1 ---- -> ERROR 01000: Data truncated for column 'b' at row 1 -83c65 -< 10 0 ---- -> 10 NULL -98,99c80,81 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 ---- -> affected rows: 1 -> info: Records: 1 Duplicates: 0 Warnings: 1 +--- alter_not_null.result ++++ alter_not_null,COPY,STRICT.result~ +@@ -4,13 +4,10 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 INT NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f1' at row 1 ++ERROR 01000: Data truncated for column 'f1' at row 1 + SELECT * FROM t1; + f1 +-0 ++NULL + DROP TABLE t1; + CREATE TABLE t1(f1 CHAR(10))ENGINE=INNODB; + INSERT INTO t1 VALUES(NULL); +@@ -18,13 +15,10 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 CHAR(10) NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f1' at row 1 ++ERROR 01000: Data truncated for column 'f1' at row 1 + SELECT * FROM t1; + f1 +- ++NULL + DROP TABLE t1; + CREATE TABLE t1(f1 VARCHAR(10))ENGINE=INNODB; + INSERT INTO t1 VALUES(NULL); +@@ -32,13 +26,10 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 VARCHAR(20) NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f1' at row 1 ++ERROR 01000: Data truncated for column 'f1' at row 1 + SELECT * FROM t1; + f1 +- ++NULL + DROP TABLE t1; + CREATE TABLE t1(f1 TEXT)ENGINE=INNODB; + INSERT INTO t1 VALUES(NULL); +@@ -46,13 +37,10 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 TEXT NOT NULL DEFAULT 'abc'; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f1' at row 1 ++ERROR 01000: Data truncated for column 'f1' at row 1 + SELECT * FROM t1; + f1 +- ++NULL + DROP TABLE t1; + CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, f3 INT)ENGINE=INNODB; + INSERT INTO t1 VALUES(2, 2, NULL); +@@ -60,13 +48,10 @@ + f1 f2 f3 + 2 2 NULL + ALTER TABLE t1 CHANGE f3 f3 INT NOT NULL DEFAULT (f1 + f2); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f3' at row 1 ++ERROR 01000: Data truncated for column 'f3' at row 1 + SELECT * FROM t1; + f1 f2 f3 +-2 2 0 ++2 2 NULL + DROP TABLE t1; + CREATE TABLE t1(f1 INT NOT NULL DEFAULT 0, b TINYINT)ENGINE=InnoDB; + INSERT INTO t1 VALUES(10, NULL); +@@ -74,13 +59,10 @@ + f1 b + 10 NULL + ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'b' at row 1 ++ERROR 01000: Data truncated for column 'b' at row 1 + SELECT * FROM t1; + f1 b +-10 0 ++10 NULL + DROP TABLE t1; + CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB; + ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL; +@@ -95,8 +77,8 @@ + CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1))ENGINE=INNODB; + INSERT INTO t1 VALUES(1, NULL); + ALTER IGNORE TABLE t1 CHANGE c2 c2 INT NOT NULL DEFAULT 2; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 1 + Warnings: + Warning 1265 Data truncated for column 'c2' at row 1 + SELECT * FROM t1; diff --git a/mysql-test/suite/innodb/r/alter_not_null,INPLACE,STRICT.rdiff b/mysql-test/suite/innodb/r/alter_not_null,INPLACE,STRICT.rdiff index ec97b174bdf..555f4cdb1df 100644 --- a/mysql-test/suite/innodb/r/alter_not_null,INPLACE,STRICT.rdiff +++ b/mysql-test/suite/innodb/r/alter_not_null,INPLACE,STRICT.rdiff @@ -1,66 +1,98 @@ -7,10c7 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f1' at row 1 ---- -> ERROR 01000: Data truncated for column 'f1' at row 1 -13c10 -< 0 ---- -> NULL -21,24c18 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f1' at row 1 ---- -> ERROR 01000: Data truncated for column 'f1' at row 1 -27c21 -< ---- -> NULL -35,38c29 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f1' at row 1 ---- -> ERROR 01000: Data truncated for column 'f1' at row 1 -41c32 -< ---- -> NULL -49,52c40 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f1' at row 1 ---- -> ERROR 01000: Data truncated for column 'f1' at row 1 -55c43 -< ---- -> NULL -63,66c51 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'f3' at row 1 ---- -> ERROR 01000: Data truncated for column 'f3' at row 1 -69c54 -< 2 2 0 ---- -> 2 2 NULL -77,80c62 -< affected rows: 0 -< info: Records: 0 Duplicates: 0 Warnings: 1 -< Warnings: -< Warning 1265 Data truncated for column 'b' at row 1 ---- -> ERROR 01000: Data truncated for column 'b' at row 1 -83c65 -< 10 0 ---- -> 10 NULL +--- alter_not_null.result ++++ alter_not_null,INPLACE,STRICT.result~ +@@ -4,13 +4,10 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 INT NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f1' at row 1 ++ERROR 01000: Data truncated for column 'f1' at row 1 + SELECT * FROM t1; + f1 +-0 ++NULL + DROP TABLE t1; + CREATE TABLE t1(f1 CHAR(10))ENGINE=INNODB; + INSERT INTO t1 VALUES(NULL); +@@ -18,13 +15,10 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 CHAR(10) NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f1' at row 1 ++ERROR 01000: Data truncated for column 'f1' at row 1 + SELECT * FROM t1; + f1 +- ++NULL + DROP TABLE t1; + CREATE TABLE t1(f1 VARCHAR(10))ENGINE=INNODB; + INSERT INTO t1 VALUES(NULL); +@@ -32,13 +26,10 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 VARCHAR(20) NOT NULL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f1' at row 1 ++ERROR 01000: Data truncated for column 'f1' at row 1 + SELECT * FROM t1; + f1 +- ++NULL + DROP TABLE t1; + CREATE TABLE t1(f1 TEXT)ENGINE=INNODB; + INSERT INTO t1 VALUES(NULL); +@@ -46,13 +37,10 @@ + f1 + NULL + ALTER TABLE t1 CHANGE f1 f1 TEXT NOT NULL DEFAULT 'abc'; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f1' at row 1 ++ERROR 01000: Data truncated for column 'f1' at row 1 + SELECT * FROM t1; + f1 +- ++NULL + DROP TABLE t1; + CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, f3 INT)ENGINE=INNODB; + INSERT INTO t1 VALUES(2, 2, NULL); +@@ -60,13 +48,10 @@ + f1 f2 f3 + 2 2 NULL + ALTER TABLE t1 CHANGE f3 f3 INT NOT NULL DEFAULT (f1 + f2); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'f3' at row 1 ++ERROR 01000: Data truncated for column 'f3' at row 1 + SELECT * FROM t1; + f1 f2 f3 +-2 2 0 ++2 2 NULL + DROP TABLE t1; + CREATE TABLE t1(f1 INT NOT NULL DEFAULT 0, b TINYINT)ENGINE=InnoDB; + INSERT INTO t1 VALUES(10, NULL); +@@ -74,13 +59,10 @@ + f1 b + 10 NULL + ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 1 +-Warnings: +-Warning 1265 Data truncated for column 'b' at row 1 ++ERROR 01000: Data truncated for column 'b' at row 1 + SELECT * FROM t1; + f1 b +-10 0 ++10 NULL + DROP TABLE t1; + CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB; + ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL; diff --git a/mysql-test/suite/innodb/r/innodb-wl5522,crc32.rdiff b/mysql-test/suite/innodb/r/innodb-wl5522,crc32.rdiff deleted file mode 100644 index bb902e18931..00000000000 --- a/mysql-test/suite/innodb/r/innodb-wl5522,crc32.rdiff +++ /dev/null @@ -1,5 +0,0 @@ -120,121c120 -< Warnings: -< Warning 1810 IO Read error: (2, No such file or directory) Error opening './test/t2.cfg', will attempt to import without schema verification ---- -> ERROR HY000: Schema mismatch (Expected FSP_SPACE_FLAGS=0x*, .ibd file contains 0x*.) diff --git a/mysql-test/suite/innodb/r/innodb-wl5522,strict_crc32.rdiff b/mysql-test/suite/innodb/r/innodb-wl5522,strict_crc32.rdiff index bb902e18931..283bbe96aae 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522,strict_crc32.rdiff +++ b/mysql-test/suite/innodb/r/innodb-wl5522,strict_crc32.rdiff @@ -1,5 +1,12 @@ -120,121c120 -< Warnings: -< Warning 1810 IO Read error: (2, No such file or directory) Error opening './test/t2.cfg', will attempt to import without schema verification ---- -> ERROR HY000: Schema mismatch (Expected FSP_SPACE_FLAGS=0x*, .ibd file contains 0x*.) +--- innodb-wl5522.result ++++ innodb-wl5522,strict_crc32.result~ +@@ -131,8 +131,7 @@ + ALTER TABLE t2 IMPORT TABLESPACE; + ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1; .cfg file uses ROW_FORMAT=COMPACT) + ALTER TABLE t2 IMPORT TABLESPACE; +-Warnings: +-Warning 1810 IO Read error: (2, No such file or directory) Error opening './test/t2.cfg', will attempt to import without schema verification ++ERROR HY000: Schema mismatch (Expected FSP_SPACE_FLAGS=0x*, .ibd file contains 0x*.) + DROP TABLE t2; + SET GLOBAL innodb_file_per_table = 1; + SELECT @@innodb_file_per_table; diff --git a/mysql-test/suite/innodb/r/insert_into_empty,4k.rdiff b/mysql-test/suite/innodb/r/insert_into_empty,4k.rdiff index baa017ecf86..ad3d03a7eae 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty,4k.rdiff +++ b/mysql-test/suite/innodb/r/insert_into_empty,4k.rdiff @@ -1,2 +1,10 @@ -423a424 -> ERROR 42000: Row size too large (> 1982). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. +--- a/mysql-test/suite/innodb/r/insert_into_empty.result ++++ b/mysql-test/suite/innodb/r/insert_into_empty.result +@@ -430,6 +430,7 @@ + INSERT IGNORE INTO t1 VALUES + (1, REPEAT('x',4805), REPEAT('t',2211), REPEAT('u',974), REPEAT('e',871), REPEAT('z',224), REPEAT('j',978), REPEAT('n',190), REPEAT('t',888), REPEAT('x',32768), REPEAT('e',968), REPEAT('b',913), REPEAT('x',12107)), + (2, REPEAT('x',4805), REPEAT('t',2211), REPEAT('u',974), REPEAT('e',871), REPEAT('z',224), REPEAT('j',978), REPEAT('n',190), REPEAT('t',888), REPEAT('x',32768), REPEAT('e',968), REPEAT('b',913), REPEAT('x',12107)); ++ERROR 42000: Row size too large (> 1982). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. + CHECK TABLE t1; + Table Op Msg_type Msg_text + test.t1 check status OK From e63ed4e0047b0169dca1dc06e592096bd3ae4724 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 8 Mar 2024 16:27:23 +1100 Subject: [PATCH 246/313] MDEV-33631 Ubuntu/Debian MYSQL_SERVER_SUFFIX is version+suffix on MariaDB packaged versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The debian/rules removed sufficient version information from the downstream version, however the mariadb upstream has a + separator from the suffix. While we are at it, remove the Debian/Ubuntu revision -1. Other revisions used: * Debian unstable (inherited to both Debian and Ubuntu if package unchanged): 1:10.11.6-2 * Ubuntu stable updates example: 1:10.11.6-0ubuntu0.23.10.2 * Debian stable updates example: 1:10.11.4-1~deb12u1 The result is compulation with: -DMYSQL_SERVER_SUFFIX="-1:10.4.34+maria~deb10" \ Compared to Debian: -DMYSQL_SERVER_SUFFIX="-1~deb12u1" \ The impact comes into play with SELECT VERSION(): 10.4.34-MariaDB-1:10.4.34+maria~deb10 A more abbreviated form of the following is much more human/machine parsable: 10.6.16-MariaDB~ubu2004 Reviewer: Otto Kekäläinen --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 052bf865e52..d88d4a4f869 100755 --- a/debian/rules +++ b/debian/rules @@ -21,7 +21,7 @@ ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS))) endif BUILDDIR := builddir -DEB_VERSION_REVISION := $(shell echo $(DEB_VERSION) | sed -e 's/^.*-//') +DEB_VERSION_REVISION := $(shell echo $(DEB_VERSION) | sed -e 's/.*[~-]\(.*\)/\1/') RELEASE := $(shell lsb_release -r -s) # Use changelog based DEB_DISTRIBUTION instead? TMP:=$(CURDIR)/debian/tmp From 156761db3bd15a326c81d5095ef22fcbd3d87730 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 30 Apr 2024 20:39:29 +0530 Subject: [PATCH 247/313] MDEV-31161 Assertion failures upon adding a too long key to table with COMPRESSED row Problem: ======= During InnoDB non-rebuild online alter operation, InnoDB set the dummy log to clustered index online log. This can be used by concurrent DML to identify whether the table undergoes online DDL. InnoDB fails to reset the dummy log of clustered index in case of error happened during prepare phase. Solution: ======== Reset the InnoDB clustered index online log in case of error during prepare phase. --- .../r/row_size_error_log_warnings_3,4k.rdiff | 2 ++ .../r/row_size_error_log_warnings_3.result | 8 ++++++++ .../innodb/t/row_size_error_log_warnings_3.test | 16 ++++++++++++++++ storage/innobase/handler/handler0alter.cc | 1 + 4 files changed, 27 insertions(+) create mode 100644 mysql-test/suite/innodb/r/row_size_error_log_warnings_3,4k.rdiff diff --git a/mysql-test/suite/innodb/r/row_size_error_log_warnings_3,4k.rdiff b/mysql-test/suite/innodb/r/row_size_error_log_warnings_3,4k.rdiff new file mode 100644 index 00000000000..812632aceae --- /dev/null +++ b/mysql-test/suite/innodb/r/row_size_error_log_warnings_3,4k.rdiff @@ -0,0 +1,2 @@ +91a92 +> ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 1982. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs diff --git a/mysql-test/suite/innodb/r/row_size_error_log_warnings_3.result b/mysql-test/suite/innodb/r/row_size_error_log_warnings_3.result index 21085e4cd7e..1fde89ac3b5 100644 --- a/mysql-test/suite/innodb/r/row_size_error_log_warnings_3.result +++ b/mysql-test/suite/innodb/r/row_size_error_log_warnings_3.result @@ -82,3 +82,11 @@ f29(10), f30(10), f31(10), f32(10), f33(10))) ENGINE=InnoDB; ERROR 42000: Too many key parts specified; max 32 parts allowed +# +# MDEV-31161 Assertion failures upon adding a too long key +# to table with COMPRESSED row format +# +CREATE TABLE t1(pk INT PRIMARY KEY, f1 INT, f2 TEXT)ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +INSERT INTO t1 (pk) VALUES (1); +ALTER TABLE t1 ADD KEY (f1), ADD KEY (f2(1000)); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test b/mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test index 24029a48aa4..47fedc52725 100644 --- a/mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test +++ b/mysql-test/suite/innodb/t/row_size_error_log_warnings_3.test @@ -85,3 +85,19 @@ CREATE TABLE t1(f1 char(200), f2 char(200), f3 char(200), f29(10), f30(10), f31(10), f32(10), f33(10))) ENGINE=InnoDB; + +--echo # +--echo # MDEV-31161 Assertion failures upon adding a too long key +--echo # to table with COMPRESSED row format +--echo # +--let $page_size= `SELECT @@GLOBAL.innodb_page_size` +CREATE TABLE t1(pk INT PRIMARY KEY, f1 INT, f2 TEXT)ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +INSERT INTO t1 (pk) VALUES (1); +let $error_code = 0; +if ($page_size == 4096) { +let $error_code = ER_TOO_BIG_ROWSIZE; +} + +--error $error_code +ALTER TABLE t1 ADD KEY (f1), ADD KEY (f2(1000)); +DROP TABLE t1; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 63a5e56e666..d7ae355d716 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -7436,6 +7436,7 @@ error_handled: row_mysql_lock_data_dictionary(ctx->trx); } else { row_merge_drop_indexes(ctx->trx, user_table, true); + user_table->indexes.start->online_log = nullptr; ctx->trx->commit(); } From dba9d192498bc569c4222d897f5205c63a3252f6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 30 Apr 2024 21:59:38 +0200 Subject: [PATCH 248/313] atomic.alter_table test is too slow for MSAN --- mysql-test/suite/atomic/alter_table.test | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/atomic/alter_table.test b/mysql-test/suite/atomic/alter_table.test index 1f87b7e71b8..aa265c92b7e 100644 --- a/mysql-test/suite/atomic/alter_table.test +++ b/mysql-test/suite/atomic/alter_table.test @@ -1,7 +1,12 @@ --source include/have_debug.inc --source include/have_innodb.inc --source include/have_log_bin.inc ---source include/not_valgrind.inc + +if (!$BIG_TEST) +{ + --source include/not_valgrind.inc + --source include/not_msan.inc +} # # Testing of atomic create table with crashes in a lot of different places From 9dfef3fb4178e44b3f3da029995ef11df8360235 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 22 Dec 2023 09:51:17 +0100 Subject: [PATCH 249/313] fix sporadic failures of main.lock_sync wait for all connections to disconnect before the cleanup --- mysql-test/main/lock_sync.result | 22 ---------------------- mysql-test/main/lock_sync.test | 25 +------------------------ 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/mysql-test/main/lock_sync.result b/mysql-test/main/lock_sync.result index 299a7bb4eb1..6e665b35383 100644 --- a/mysql-test/main/lock_sync.result +++ b/mysql-test/main/lock_sync.result @@ -26,28 +26,6 @@ ALWAYS connect con1, localhost, root,,; connect con2, localhost, root,,; connection default; -drop table if exists t0, t1, t2, t3, t4, t5; -drop view if exists v1, v2; -drop procedure if exists p1; -drop procedure if exists p2; -drop procedure if exists p3; -drop function if exists f1; -drop function if exists f2; -drop function if exists f3; -drop function if exists f4; -drop function if exists f5; -drop function if exists f6; -drop function if exists f7; -drop function if exists f8; -drop function if exists f9; -drop function if exists f10; -drop function if exists f11; -drop function if exists f12; -drop function if exists f13; -drop function if exists f14; -drop function if exists f15; -drop function if exists f16; -drop function if exists f17; create table t1 (i int primary key); insert into t1 values (1), (2), (3), (4), (5); create table t2 (j int primary key); diff --git a/mysql-test/main/lock_sync.test b/mysql-test/main/lock_sync.test index 51247a51067..998c6529462 100644 --- a/mysql-test/main/lock_sync.test +++ b/mysql-test/main/lock_sync.test @@ -44,30 +44,6 @@ select @@global.concurrent_insert; connect (con1, localhost, root,,); connect (con2, localhost, root,,); connection default; ---disable_warnings -drop table if exists t0, t1, t2, t3, t4, t5; -drop view if exists v1, v2; -drop procedure if exists p1; -drop procedure if exists p2; -drop procedure if exists p3; -drop function if exists f1; -drop function if exists f2; -drop function if exists f3; -drop function if exists f4; -drop function if exists f5; -drop function if exists f6; -drop function if exists f7; -drop function if exists f8; -drop function if exists f9; -drop function if exists f10; -drop function if exists f11; -drop function if exists f12; -drop function if exists f13; -drop function if exists f14; -drop function if exists f15; -drop function if exists f16; -drop function if exists f17; ---enable_warnings create table t1 (i int primary key); insert into t1 values (1), (2), (3), (4), (5); create table t2 (j int primary key); @@ -1218,6 +1194,7 @@ COMMIT; --disconnect con1 --disconnect con2 --connection default +--source include/wait_until_count_sessions.inc DROP VIEW v1; DROP FUNCTION IF EXISTS f; DROP TABLE t1, t2; From 90b95c6149c72f43aa2324353a76f370d018a5ac Mon Sep 17 00:00:00 2001 From: mariadb-DebarunBanerjee Date: Tue, 30 Apr 2024 16:55:27 +0530 Subject: [PATCH 250/313] MDEV-33543 Server hang caused by InnoDB change buffer Issue: When getting a page (buf_page_get_gen) with no latch option (RW_NO_LATCH), the caller is not expected to follow the B-tree latching order. However in buf_page_get_low we try to acquire shared page latch unconditionally to wait for a page that is being loaded by another thread concurrently. In general it could lead to latch order violation and deadlock. Currently it affects the change buffer insert path btr_latch_prev() which tries to load the previous page out of order with RW_NO_LATCH and two concurrent inserts into IBUF tree cause deadlock. This problem is introduced in 10.6 by following commit. commit 9436c778c3adba7c29dab5649668433d71e086f2 (MDEV-27058) Fix: While trying to latch a page with RW_NO_LATCH, always use the "*lock_try" interface and retry operation on failure after unfixing the page. --- storage/innobase/buf/buf0buf.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index dc90160a668..16592c05405 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2579,7 +2579,15 @@ ignore_unfixed: in buf_page_t::read_complete() or buf_pool_t::corrupted_evict(), or after buf_zip_decompress() in this function. */ - block->page.lock.s_lock(); + if (rw_latch != RW_NO_LATCH) { + block->page.lock.s_lock(); + } else if (!block->page.lock.s_lock_try()) { + /* For RW_NO_LATCH, we should not try to acquire S or X + latch directly as we could be violating the latching + order resulting in deadlock. Instead we try latching the + page and retry in case of a failure. */ + goto wait_for_read; + } state = block->page.state(); ut_ad(state < buf_page_t::READ_FIX || state >= buf_page_t::WRITE_FIX); @@ -2587,15 +2595,15 @@ ignore_unfixed: block->page.lock.s_unlock(); if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) { - block->page.unfix(); if (UNIV_UNLIKELY(id == page_id)) { /* The page read was completed, and another thread marked the page as free while we were waiting. */ - goto ignore_unfixed; + goto ignore_block; } ut_ad(id == page_id_t{~0ULL}); + block->page.unfix(); if (++retries < BUF_PAGE_READ_MAX_RETRIES) { goto loop; @@ -2634,6 +2642,7 @@ free_unfixed_block: if (UNIV_UNLIKELY(!block->page.frame)) { if (!block->page.lock.x_lock_try()) { wait_for_unzip: +wait_for_read: /* The page is being read or written, or another thread is executing buf_zip_decompress() in buf_page_get_low() on it. */ From e365877bae0f64dad4b9e6d57e931c422f8a693a Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Tue, 30 Apr 2024 14:51:50 +0200 Subject: [PATCH 251/313] MDEV-33798: ROW base optimistic deadlock with concurrent writes on same table One case is conflicting transactions T1 and T2 with different domain id, in optimistic parallel replication in non-GTID mode. Then T2 will wait_for_prior_commit on T1; and if T1 got a row lock wait on T2 it would hang, as different domains caused the deadlock kill to be skipped in thd_rpl_deadlock_check(). More generally, if we have transactions T1 and T2 in one domain/master connection, and independent transactions U in another, then we can still deadlock like this: T1 row low wait on U U row lock wait on T2 T2 wait_for_prior_commit on T1 This commit enforces the deadlock kill in these cases. If the waited-for transaction is speculatively applied, then it will be deadlock killed in case of a conflict, even if the two transactions are in different domains or master connections. Reviewed-by: Andrei Elkin Signed-off-by: Kristian Nielsen --- mysql-test/suite/rpl/r/rpl_mdev33798.result | 143 +++++++++++++++ mysql-test/suite/rpl/t/rpl_mdev33798.cnf | 17 ++ mysql-test/suite/rpl/t/rpl_mdev33798.test | 182 ++++++++++++++++++++ sql/sql_class.cc | 39 ++++- 4 files changed, 373 insertions(+), 8 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_mdev33798.result create mode 100644 mysql-test/suite/rpl/t/rpl_mdev33798.cnf create mode 100644 mysql-test/suite/rpl/t/rpl_mdev33798.test diff --git a/mysql-test/suite/rpl/r/rpl_mdev33798.result b/mysql-test/suite/rpl/r/rpl_mdev33798.result new file mode 100644 index 00000000000..8796e948546 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_mdev33798.result @@ -0,0 +1,143 @@ +include/rpl_init.inc [topology=1->2,1->3] +connect server_2b,127.0.0.1,root,,,$SERVER_MYPORT_2; +connection server_2; +SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; +SET @old_parallel_mode= @@GLOBAL.slave_parallel_mode; +SET @old_timeout= @@GLOBAL.lock_wait_timeout; +SET @old_innodb_timeout= @@GLOBAL.innodb_lock_wait_timeout; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=5; +set global slave_parallel_mode= aggressive; +SET GLOBAL lock_wait_timeout= 86400; +SET GLOBAL innodb_lock_wait_timeout= 86400; +SET STATEMENT sql_log_bin=0 FOR ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +include/start_slave.inc +connection server_1; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0); +connection server_2; +include/stop_slave.inc +connection server_2b; +BEGIN; +SELECT * FROM t1 WHERE a=1 FOR UPDATE; +a b +1 0 +SELECT * FROM t1 WHERE a=5 FOR UPDATE; +a b +5 0 +connection server_1; +SET SESSION gtid_domain_id= 1; +BEGIN; +UPDATE t1 SET b=1 WHERE a=1; +UPDATE t1 SET b=1 WHERE a=7; +COMMIT; +UPDATE t1 SET b=2 WHERE a=3; +SET SESSION gtid_domain_id=2; +BEGIN; +UPDATE t1 SET b=3 WHERE a=5; +UPDATE t1 SET b=3 WHERE a=3; +COMMIT; +UPDATE t1 SET b=4 WHERE a=7; +SET SESSION gtid_domain_id= 0; +include/save_master_gtid.inc +connection server_2; +include/start_slave.inc +connection server_2b; +ROLLBACK; +connection server_2; +include/sync_with_master_gtid.inc +SELECT a, ( +(a=1 AND b=1) OR +(a=3 AND (b=2 OR b=3)) OR +(a=5 AND b=3) OR +(a=7 AND (b=1 OR b=4)) OR +((a MOD 2)=0 AND b=0)) AS `ok` + FROM t1 +ORDER BY a; +a ok +1 1 +2 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +connection server_3; +include/sync_with_master_gtid.inc +include/stop_slave.inc +connection server_2; +include/stop_slave.inc +CHANGE MASTER 'm2' to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +connection server_1; +SET SESSION gtid_domain_id= 1; +BEGIN; +UPDATE t1 SET b=11 WHERE a=1; +UPDATE t1 SET b=11 WHERE a=7; +COMMIT; +UPDATE t1 SET b=12 WHERE a=3; +SET SESSION gtid_domain_id= 1; +connection server_3; +SET SESSION gtid_domain_id=3; +BEGIN; +UPDATE t1 SET b=13 WHERE a=5; +UPDATE t1 SET b=13 WHERE a=3; +COMMIT; +UPDATE t1 SET b=14 WHERE a=7; +include/save_master_gtid.inc +connection server_2b; +BEGIN; +SELECT * FROM t1 WHERE a=1 FOR UPDATE; +a b +1 1 +SELECT * FROM t1 WHERE a=5 FOR UPDATE; +a b +5 3 +START ALL SLAVES; +Warnings: +Note 1937 SLAVE 'm2' started +Note 1937 SLAVE '' started +connection server_2b; +ROLLBACK; +connection server_1; +include/save_master_gtid.inc +connection server_2; +include/sync_with_master_gtid.inc +connection server_3; +include/save_master_gtid.inc +connection server_2; +include/sync_with_master_gtid.inc +SELECT a, ( +(a=1 AND b=11) OR +(a=3 AND (b=12 OR b=13)) OR +(a=5 AND b=13) OR +(a=7 AND (b=11 OR b=14)) OR +((a MOD 2)=0 AND b=0)) AS `ok` + FROM t1 +ORDER BY a; +a ok +1 1 +2 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +SET default_master_connection = 'm2'; +include/stop_slave.inc +RESET SLAVE 'm2' ALL; +SET default_master_connection = ''; +connection server_3; +include/start_slave.inc +disconnect server_2b; +connection server_1; +DROP TABLE t1; +connection server_2; +include/stop_slave.inc +SET GLOBAL slave_parallel_threads=@old_parallel_threads; +set global slave_parallel_mode= @old_parallel_mode; +SET GLOBAL lock_wait_timeout= @old_timeout; +SET GLOBAL innodb_lock_wait_timeout= @old_innodb_timeout; +include/start_slave.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_mdev33798.cnf b/mysql-test/suite/rpl/t/rpl_mdev33798.cnf new file mode 100644 index 00000000000..8e5125ea6ca --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_mdev33798.cnf @@ -0,0 +1,17 @@ +!include suite/rpl/my.cnf + +[mysqld.1] +log-slave-updates +loose-innodb + +[mysqld.2] +log-slave-updates +loose-innodb + +[mysqld.3] +log-slave-updates +loose-innodb + +[ENV] +SERVER_MYPORT_3= @mysqld.3.port +SERVER_MYSOCK_3= @mysqld.3.socket diff --git a/mysql-test/suite/rpl/t/rpl_mdev33798.test b/mysql-test/suite/rpl/t/rpl_mdev33798.test new file mode 100644 index 00000000000..1448ed91133 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_mdev33798.test @@ -0,0 +1,182 @@ +--source include/have_innodb.inc +--source include/have_log_bin.inc +--let $rpl_topology=1->2,1->3 +--source include/rpl_init.inc +--connect (server_2b,127.0.0.1,root,,,$SERVER_MYPORT_2) + +--connection server_2 +SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; +SET @old_parallel_mode= @@GLOBAL.slave_parallel_mode; +SET @old_timeout= @@GLOBAL.lock_wait_timeout; +SET @old_innodb_timeout= @@GLOBAL.innodb_lock_wait_timeout; +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads=5; +set global slave_parallel_mode= aggressive; +# High timeout so we get replication sync error and test failure if the +# conflict handling is insufficient and lock wait timeout occurs. +SET GLOBAL lock_wait_timeout= 86400; +SET GLOBAL innodb_lock_wait_timeout= 86400; +SET STATEMENT sql_log_bin=0 FOR ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +--source include/start_slave.inc + +--connection server_1 +CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0); +--save_master_pos + +--connection server_2 +--sync_with_master +--source include/stop_slave.inc + +# Test the following scenario: +# +# Transactions T1, T2 in domain 1, U1, U2 in domain 2. +# Wait cycle T1->U2->U1->T2->T1 as follows: +# T1 row lock wait on U2 +# U2 wait_for_prior_commit on U1 +# U1 row lock wait on T2 +# T2 wait_for_prior_commit on T1 +# +# Test that the wait cycle is broken correctly with deadlock kill. + +--connection server_2b +# Temporarily block T1 and U1. +BEGIN; +SELECT * FROM t1 WHERE a=1 FOR UPDATE; +SELECT * FROM t1 WHERE a=5 FOR UPDATE; + +--connection server_1 + +SET SESSION gtid_domain_id= 1; +# T1 in domain 1 +BEGIN; +UPDATE t1 SET b=1 WHERE a=1; +UPDATE t1 SET b=1 WHERE a=7; +COMMIT; +# T2 in domain 1 +UPDATE t1 SET b=2 WHERE a=3; + +SET SESSION gtid_domain_id=2; +# U1 in domain 2 +BEGIN; +UPDATE t1 SET b=3 WHERE a=5; +UPDATE t1 SET b=3 WHERE a=3; +COMMIT; +# U2 in domain 2 +UPDATE t1 SET b=4 WHERE a=7; +SET SESSION gtid_domain_id= 0; +--source include/save_master_gtid.inc + +--connection server_2 +--source include/start_slave.inc +# Wait until T2, U2 are holding the row locks. +--let $wait_condition= SELECT COUNT(*)=2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state LIKE '%Waiting for prior transaction to commit%' +--source include/wait_condition.inc + +# Then let T1, U1 continue to conflict on the row locks, and check that +# replication correctly handles the conflict. +--connection server_2b +ROLLBACK; + +--connection server_2 +--source include/sync_with_master_gtid.inc + +# Allow either domain to "win" on the conflicting updates. +SELECT a, ( + (a=1 AND b=1) OR + (a=3 AND (b=2 OR b=3)) OR + (a=5 AND b=3) OR + (a=7 AND (b=1 OR b=4)) OR + ((a MOD 2)=0 AND b=0)) AS `ok` + FROM t1 + ORDER BY a; + +# Now try the same thing with multi-source replication. + +# Make server_3 a second master +--connection server_3 +--source include/sync_with_master_gtid.inc +--source include/stop_slave.inc + +--connection server_2 +--source include/stop_slave.inc +--replace_result $SERVER_MYPORT_3 MYPORT_3 +eval CHANGE MASTER 'm2' to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; + +--connection server_1 + +SET SESSION gtid_domain_id= 1; +# T1 in domain 1 +BEGIN; +UPDATE t1 SET b=11 WHERE a=1; +UPDATE t1 SET b=11 WHERE a=7; +COMMIT; +# T2 in domain 1 +UPDATE t1 SET b=12 WHERE a=3; +SET SESSION gtid_domain_id= 1; + +--connection server_3 +SET SESSION gtid_domain_id=3; +# U1 in domain 3 +BEGIN; +UPDATE t1 SET b=13 WHERE a=5; +UPDATE t1 SET b=13 WHERE a=3; +COMMIT; +# U2 in domain 3 +UPDATE t1 SET b=14 WHERE a=7; +--source include/save_master_gtid.inc + +--connection server_2b +# Temporarily block T1 and U1. +BEGIN; +SELECT * FROM t1 WHERE a=1 FOR UPDATE; +SELECT * FROM t1 WHERE a=5 FOR UPDATE; + +START ALL SLAVES; +# Wait until T2, U2 are holding the row locks. +--let $wait_condition= SELECT COUNT(*)=2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state LIKE '%Waiting for prior transaction to commit%' +--source include/wait_condition.inc + +--connection server_2b +ROLLBACK; + +--connection server_1 +--source include/save_master_gtid.inc +--connection server_2 +--source include/sync_with_master_gtid.inc +--connection server_3 +--source include/save_master_gtid.inc +--connection server_2 +--source include/sync_with_master_gtid.inc + +SELECT a, ( + (a=1 AND b=11) OR + (a=3 AND (b=12 OR b=13)) OR + (a=5 AND b=13) OR + (a=7 AND (b=11 OR b=14)) OR + ((a MOD 2)=0 AND b=0)) AS `ok` + FROM t1 + ORDER BY a; + +SET default_master_connection = 'm2'; +--source include/stop_slave.inc +RESET SLAVE 'm2' ALL; +SET default_master_connection = ''; + +--connection server_3 +--source include/start_slave.inc + +# Cleanup + +--disconnect server_2b +--connection server_1 +DROP TABLE t1; +--connection server_2 +--source include/stop_slave.inc +SET GLOBAL slave_parallel_threads=@old_parallel_threads; +set global slave_parallel_mode= @old_parallel_mode; +SET GLOBAL lock_wait_timeout= @old_timeout; +SET GLOBAL innodb_lock_wait_timeout= @old_innodb_timeout; +--source include/start_slave.inc + +--source include/rpl_end.inc diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9536d4b16aa..a9203a80c10 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -5400,14 +5400,37 @@ thd_rpl_deadlock_check(MYSQL_THD thd, MYSQL_THD other_thd) return 0; if (!rgi->is_parallel_exec) return 0; - if (rgi->rli != other_rgi->rli) - return 0; - if (!rgi->gtid_sub_id || !other_rgi->gtid_sub_id) - return 0; - if (rgi->current_gtid.domain_id != other_rgi->current_gtid.domain_id) - return 0; - if (rgi->gtid_sub_id > other_rgi->gtid_sub_id) - return 0; + if (rgi->rli == other_rgi->rli) + { + /* + Within the same master connection, we can compare transaction order on + the GTID sub_id, and rollback the later transaction to allow the earlier + transaction to commit first. + */ + if (!rgi->gtid_sub_id || !other_rgi->gtid_sub_id) + return 0; + if (rgi->gtid_sub_id > other_rgi->gtid_sub_id) + return 0; + } + else + { + /* + Lock conflicts between different master connection should usually not + occur, but could still happen if user is running some special setup that + tolerates conflicting updates (or in case of user error). We do not have a + pre-defined ordering of transactions in this case, but we still need to + handle conflicts in _some_ way to avoid undetected deadlocks and hangs. + + We do this by rolling back and retrying any transaction that is being + _optimistically_ applied. This can be overly conservative in some cases, + but should be fine as conflicts between different master connections are + not expected to be common. And it ensures that we won't end up in a + deadlock and hang due to a transaction doing wait_for_prior_commit while + holding locks that block something in another master connection. + */ + if (other_rgi->speculation != rpl_group_info::SPECULATE_OPTIMISTIC) + return 0; + } /* This transaction is about to wait for another transaction that is required by replication binlog order to commit after. This would cause a deadlock. From 596921dab8e53c56dc72d0e0f6cb4f03d59e4825 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Tue, 30 Apr 2024 19:21:24 +0200 Subject: [PATCH 252/313] MDEV-34042: Deadlock kill of XA PREPARE can break replication / rpl.rpl_parallel_multi_domain_xa sporadic failure Clear any pending deadlock kill after completing XA PREPARE, and before updating the mysql.gtid_slave_pos table in a separate transaction. Reviewed-by: Andrei Elkin Signed-off-by: Kristian Nielsen --- sql/log_event_server.cc | 13 +++++++++++++ sql/rpl_parallel.cc | 2 +- sql/rpl_parallel.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index ebbd52fcd74..5b0fbf8ced0 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -4209,6 +4209,19 @@ int XA_prepare_log_event::do_commit() else res= trans_xa_commit(thd); + if (thd->rgi_slave->is_parallel_exec) + { + /* + Since the transaction is prepared/committed without updating the GTID pos + (MDEV-32020...), we need here to clear any pending deadlock kill. + Otherwise if the kill happened after the prepare/commit completed, it + might end up killing the subsequent GTID position update, causing the + slave to fail with error. + */ + wait_for_pending_deadlock_kill(thd, thd->rgi_slave); + thd->reset_killed(); + } + return res; } #endif // HAVE_REPLICATION diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 3dff9bf8ade..64819dff2c4 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -131,7 +131,7 @@ handle_queued_pos_update(THD *thd, rpl_parallel_thread::queued_event *qev) asynchronously, we need to be sure they will be completed before starting a new transaction. Otherwise the new transaction might suffer a spurious kill. */ -static void +void wait_for_pending_deadlock_kill(THD *thd, rpl_group_info *rgi) { PSI_stage_info old_stage; diff --git a/sql/rpl_parallel.h b/sql/rpl_parallel.h index a605b977473..9ef5405f39b 100644 --- a/sql/rpl_parallel.h +++ b/sql/rpl_parallel.h @@ -494,6 +494,7 @@ struct rpl_parallel { extern struct rpl_parallel_thread_pool global_rpl_thread_pool; +extern void wait_for_pending_deadlock_kill(THD *thd, rpl_group_info *rgi); extern int rpl_parallel_resize_pool_if_no_slaves(void); extern int rpl_parallel_activate_pool(rpl_parallel_thread_pool *pool); extern int rpl_parallel_inactivate_pool(rpl_parallel_thread_pool *pool); From 20f60fe70f5e3764cd437b2d1dcc80d3e0ce1f00 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 2 May 2024 21:41:13 +0200 Subject: [PATCH 253/313] postfix a09ebe5567694f13dd77876bf61ce3560dfed0e6 (PCRE-10.43) - no need to switch off -fsanitize-address for MSVC anymore - option /WX is MSVC only - CMAKE_C_STANDARD C99 is already in pcre's own CMakeLists.txt --- cmake/pcre.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index 5ef089aa686..70ea92f1746 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -41,16 +41,16 @@ MACRO(BUNDLE_PCRE2) SET(byproducts ${byproducts} BUILD_BYPRODUCTS ${file} ${file_d}) SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${file}) ENDFOREACH() + FOREACH(v "" "_DEBUG" "_RELWITHDEBINFO" "_RELEASE" "_MINSIZEREL") - STRING(REPLACE "/WX" "" pcre2_flags${v} "${CMAKE_C_FLAGS${v}}") - SET(pcre2_flags${v} "${pcre2_flags${v}} -std=c99 ") + SET(pcre2_flags${v} "${CMAKE_C_FLAGS${v}}") IF(MSVC) + STRING(REPLACE "/WX" "" pcre2_flags${v} "${pcre2_flags${v}}") # Suppress a warning STRING(APPEND pcre2_flags${v} " /wd4244 /wd4267 " ) - # Disable asan support - STRING(REPLACE "-fsanitize=address" "" pcre2_flags${v} "${pcre2_flags${v}}") ENDIF() ENDFOREACH() + ExternalProject_Add( pcre2 PREFIX "${dir}" From 3ee6f69d49a58422f994f51a0bd7a0cb1242a3dd Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 2 May 2024 22:14:19 +0200 Subject: [PATCH 254/313] sporadic failures of binlog_encryption.rpl_parallel_gco_wait_kill CURRENT_TEST: binlog_encryption.rpl_parallel_gco_wait_kill mysqltest: In included file "./suite/rpl/t/rpl_parallel_gco_wait_kill.test": included from /home/buildbot/amd64-ubuntu-2004-debug/build/mysql-test/suite/binlog_encryption/rpl_parallel_gco_wait_kill.test at line 2: At line 334: Can't initialize replace from 'replace_result $thd_id THD_ID' An sql thread can reach the "Slave has read all relay log" state and then start reading relay log again. Let's use a more generic pattern to retrieve the sql thread ID even if it's not in the "read all relay log" state. --- mysql-test/suite/rpl/t/rpl_parallel_gco_wait_kill.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/t/rpl_parallel_gco_wait_kill.test b/mysql-test/suite/rpl/t/rpl_parallel_gco_wait_kill.test index c5d2b85cf34..c34c4f20dc0 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_gco_wait_kill.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_gco_wait_kill.test @@ -300,7 +300,7 @@ SET GLOBAL slave_parallel_threads=10; # Find the thread id of the driver SQL thread that we want to kill. --let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE '%Slave has read all relay log%' --source include/wait_condition.inc ---let $thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE '%Slave has read all relay log%'` +--let $thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE '%relay log%'` SET @old_max_queued= @@GLOBAL.slave_parallel_max_queued; SET GLOBAL slave_parallel_max_queued=9000; From b84d335d9df076be0cbf4b02ab21c91e905c077b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 4 Mar 2024 10:25:34 +1100 Subject: [PATCH 255/313] MDEV-33538 make auxiliary spider plugins init depend on actual spider The two I_S plugins SPIDER_ALLOC_MEM and SPIDER_WRAPPER_PROTOCOL only makes sense if the main SPIDER plugin is installed. Further, SPIDER_ALLOC_MEM requires a mutex that requires SPIDER init to fill the table. We also update the spider init query to override --transaction_read_only=on so that it does not affect the spider init. Also fixed error handling in spider_db_init() so that failure in spider table init does not result in memory leak --- sql/handler.cc | 7 ------- sql/sql_show.cc | 10 +++++++--- .../spider/bugfix/r/mdev_33538.result | 12 ++++++++++++ .../spider/bugfix/r/mdev_33538_fail_init.result | 8 ++++++++ .../spider/bugfix/r/plugin_load_add_all.result | 4 ++++ .../mysql-test/spider/bugfix/t/mdev_33538.opt | 2 ++ .../mysql-test/spider/bugfix/t/mdev_33538.test | 2 ++ .../spider/bugfix/t/mdev_33538_fail_init.test | 17 +++++++++++++++++ .../spider/bugfix/t/plugin_load_add_all.test | 1 + storage/spider/spd_i_s.cc | 6 ++++++ storage/spider/spd_init_query.h | 3 +++ storage/spider/spd_table.cc | 7 ++++--- 12 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_33538_fail_init.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_33538.test create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_33538_fail_init.test diff --git a/sql/handler.cc b/sql/handler.cc index 8b299ae1b9e..7f5cb343824 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -641,13 +641,6 @@ int ha_initialize_handlerton(st_plugin_int *plugin) hton->slot= HA_SLOT_UNDEF; /* Historical Requirement */ plugin->data= hton; // shortcut for the future - /* [remove after merge] notes on merge conflict (MDEV-31400): - 10.6-10.11: 13ba00ff4933cfc1712676f323587504e453d1b5 - 11.0-11.2: 42f8be10f18163c4025710cf6a212e82bddb2f62 - The 10.11->11.0 conflict is trivial, but the reference commit also - contains different non-conflict changes needs to be applied to 11.0 - (and beyond). - */ if (plugin->plugin->init && (ret= plugin->plugin->init(hton))) goto err; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 63c00f8614e..a6b307ac8a4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -9942,6 +9942,7 @@ ST_SCHEMA_TABLE schema_tables[]= int initialize_schema_table(st_plugin_int *plugin) { ST_SCHEMA_TABLE *schema_table; + int err; DBUG_ENTER("initialize_schema_table"); if (!(schema_table= (ST_SCHEMA_TABLE *)my_malloc(key_memory_ST_SCHEMA_TABLE, @@ -9958,12 +9959,15 @@ int initialize_schema_table(st_plugin_int *plugin) /* Make the name available to the init() function. */ schema_table->table_name= plugin->name.str; - if (plugin->plugin->init(schema_table)) + if ((err= plugin->plugin->init(schema_table))) { - sql_print_error("Plugin '%s' init function returned error.", - plugin->name.str); + if (err != HA_ERR_RETRY_INIT) + sql_print_error("Plugin '%s' init function returned error.", + plugin->name.str); plugin->data= NULL; my_free(schema_table); + if (err == HA_ERR_RETRY_INIT) + DBUG_RETURN(err); DBUG_RETURN(1); } diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result new file mode 100644 index 00000000000..6597e457101 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33538.result @@ -0,0 +1,12 @@ +show create table information_schema.SPIDER_ALLOC_MEM; +Table Create Table +SPIDER_ALLOC_MEM CREATE TEMPORARY TABLE `SPIDER_ALLOC_MEM` ( + `ID` int(10) unsigned NOT NULL, + `FUNC_NAME` varchar(64), + `FILE_NAME` varchar(64), + `LINE_NO` int(10) unsigned, + `TOTAL_ALLOC_MEM` bigint(20) unsigned, + `CURRENT_ALLOC_MEM` bigint(20), + `ALLOC_MEM_COUNT` bigint(20) unsigned, + `FREE_MEM_COUNT` bigint(20) unsigned +) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_33538_fail_init.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_33538_fail_init.result new file mode 100644 index 00000000000..4b914710f18 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_33538_fail_init.result @@ -0,0 +1,8 @@ +call mtr.add_suppression("\\[ERROR\\] SPIDER plugin initialization failed"); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER' registration as a STORAGE ENGINE failed."); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_WRAPPER_PROTOCOLS' registration as a INFORMATION SCHEMA failed."); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_ALLOC_MEM' registration as a INFORMATION SCHEMA failed."); +create table mysql.spider_tables (c int); +# restart: --plugin-load-add=ha_spider +SELECT * FROM information_schema.SPIDER_ALLOC_MEM; +ERROR 42S02: Unknown table 'SPIDER_ALLOC_MEM' in information_schema diff --git a/storage/spider/mysql-test/spider/bugfix/r/plugin_load_add_all.result b/storage/spider/mysql-test/spider/bugfix/r/plugin_load_add_all.result index 04e5ed6da68..4d161a2f7fb 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/plugin_load_add_all.result +++ b/storage/spider/mysql-test/spider/bugfix/r/plugin_load_add_all.result @@ -3,5 +3,9 @@ # select * from mysql.plugin; name dl +select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA = "information_schema" and TABLE_NAME like "SPIDER_%"; +TABLE_NAME +SPIDER_ALLOC_MEM +SPIDER_WRAPPER_PROTOCOLS create table t (c int) Engine=SPIDER; drop table t; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt new file mode 100644 index 00000000000..a90c3a39413 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.opt @@ -0,0 +1,2 @@ +--plugin-load-add=ha_spider +--transaction-read-only=on diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.test new file mode 100644 index 00000000000..e2d4d8b46e4 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538.test @@ -0,0 +1,2 @@ +# we check that information_schema.SPIDER_ALLOC_MEM exists +show create table information_schema.SPIDER_ALLOC_MEM; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_33538_fail_init.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538_fail_init.test new file mode 100644 index 00000000000..1218e1db719 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_33538_fail_init.test @@ -0,0 +1,17 @@ +call mtr.add_suppression("\\[ERROR\\] SPIDER plugin initialization failed"); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER' registration as a STORAGE ENGINE failed."); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_WRAPPER_PROTOCOLS' registration as a INFORMATION SCHEMA failed."); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER_ALLOC_MEM' registration as a INFORMATION SCHEMA failed."); +# We create a table with identical name of the spider system table, to +# fail the spider init query ([ERROR] SPIDER plugin initialization +# failed at 'alter table mysql.spider_tables add column if not exists +# link_id int not null default 0 after table_name, drop primary key, +# add primary key (db_name, table_name, link_id), algorithm=copy, +# lock=shared;' by 'Unknown column 'table_name' in 'spider_tables'') +# This will cause the init of spider_alloc_mem to fail because it +# depends on the main spider plugin. +create table mysql.spider_tables (c int); +--let $restart_parameters= --plugin-load-add=ha_spider +--source include/restart_mysqld.inc +--error ER_UNKNOWN_TABLE +SELECT * FROM information_schema.SPIDER_ALLOC_MEM; diff --git a/storage/spider/mysql-test/spider/bugfix/t/plugin_load_add_all.test b/storage/spider/mysql-test/spider/bugfix/t/plugin_load_add_all.test index 396145fba2e..35242b2092b 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/plugin_load_add_all.test +++ b/storage/spider/mysql-test/spider/bugfix/t/plugin_load_add_all.test @@ -3,5 +3,6 @@ --echo # # A simple test that tests plugin-load-add=ha_spider select * from mysql.plugin; +select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA = "information_schema" and TABLE_NAME like "SPIDER_%"; create table t (c int) Engine=SPIDER; drop table t; diff --git a/storage/spider/spd_i_s.cc b/storage/spider/spd_i_s.cc index 22cd8eb0f15..8f828939aeb 100644 --- a/storage/spider/spd_i_s.cc +++ b/storage/spider/spd_i_s.cc @@ -129,7 +129,10 @@ static int spider_i_s_alloc_mem_init( void *p ) { ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; + const LEX_CSTRING spider_name={STRING_WITH_LEN("SPIDER")}; DBUG_ENTER("spider_i_s_alloc_mem_init"); + if (!plugin_is_ready(&spider_name, MYSQL_STORAGE_ENGINE_PLUGIN)) + DBUG_RETURN(HA_ERR_RETRY_INIT); schema->fields_info = Show::spider_i_s_alloc_mem_fields_info; schema->fill_table = spider_i_s_alloc_mem_fill_table; schema->idx_field1 = 0; @@ -249,7 +252,10 @@ static int spider_i_s_wrapper_protocols_init( void *p ) { ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *) p; + const LEX_CSTRING spider_name={STRING_WITH_LEN("SPIDER")}; DBUG_ENTER("spider_i_s_wrapper_protocols_init"); + if (!plugin_is_ready(&spider_name, MYSQL_STORAGE_ENGINE_PLUGIN)) + DBUG_RETURN(HA_ERR_RETRY_INIT); schema->fields_info = Show::spider_i_s_wrapper_protocols_fields_info; schema->fill_table = spider_i_s_wrapper_protocols_fill_table; schema->idx_field1 = 0; diff --git a/storage/spider/spd_init_query.h b/storage/spider/spd_init_query.h index b493104f095..bdf42ddc3ef 100644 --- a/storage/spider/spd_init_query.h +++ b/storage/spider/spd_init_query.h @@ -25,6 +25,9 @@ static LEX_STRING spider_init_queries[] = { "SET @@SQL_MODE = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO," "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';" )}, + {C_STRING_WITH_LEN( + "SET tx_read_only = off;" + )}, {C_STRING_WITH_LEN( "create table if not exists mysql.spider_xa(" " format_id int not null default 0," diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 3485ce07eea..5eedda46523 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -7230,7 +7230,7 @@ int spider_db_init( spider_param_table_crd_thread_count()), NullS)) ) - goto error_alloc_mon_mutxes; + goto error_alloc_table_sts_crd_threads; for (roop_count = 0; roop_count < (int) spider_param_table_sts_thread_count(); @@ -7305,9 +7305,11 @@ error_init_table_sts_threads: { spider_free_sts_threads(&spider_table_sts_threads[roop_count]); } +error_alloc_table_sts_crd_threads: spider_free(NULL, spider_table_sts_threads, MYF(0)); - roop_count = spider_param_udf_table_mon_mutex_count() - 1; #endif +error_system_table_creation: + roop_count = spider_param_udf_table_mon_mutex_count() - 1; error_init_udf_table_mon_list_hash: for (; roop_count >= 0; roop_count--) { @@ -7321,7 +7323,6 @@ error_init_udf_table_mon_list_hash: error_init_udf_table_mon_cond: for (; roop_count >= 0; roop_count--) pthread_cond_destroy(&spider_udf_table_mon_conds[roop_count]); -error_system_table_creation: roop_count = spider_param_udf_table_mon_mutex_count() - 1; error_init_udf_table_mon_mutex: for (; roop_count >= 0; roop_count--) From 611cd6b9817e3649441533a332d8d8cc0665d1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 3 May 2024 13:06:13 +0300 Subject: [PATCH 256/313] MDEV-33817 preparation: Restructuring and unit tests In our unit test, let us rely on our own reference implementation using the reflected CRC-32 ISO 3309 and CRC-32C polynomials. Let us also test with various lengths. Let us refactor the CRC-32 and CRC-32C implementations so that no special compilation flags will be needed and that some function call indirection will be avoided. pmull_supported: Remove. We will have pointers to two separate functions crc32c_aarch64_pmull() and crc32c_aarch64(). --- mysys/CMakeLists.txt | 30 ++-- mysys/crc32/crc32_arm64.c | 342 ++++++++++++++++++++---------------- mysys/crc32/crc32_x86.c | 16 +- mysys/crc32/crc32c.cc | 261 +++++++++++---------------- mysys/crc32/crc32c_amd64.cc | 8 + mysys/crc32/crc32c_ppc.h | 3 +- mysys/crc32/crc32c_x86.cc | 67 +++++++ mysys/crc32/crc_ppc64.h | 7 +- mysys/crc32ieee.cc | 19 +- unittest/mysys/crc32-t.c | 138 +++++++++++---- 10 files changed, 509 insertions(+), 382 deletions(-) create mode 100644 mysys/crc32/crc32c_x86.cc diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index ec72fb2601d..8b007f7f8da 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -60,29 +60,21 @@ IF (WIN32) ENDIF() IF(MSVC) - SET(MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32_x86.c) + SET(MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32_x86.c crc32/crc32c_x86.cc) IF(CMAKE_SIZEOF_VOID_P EQUAL 8) SET (MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32c_amd64.cc) ENDIF() - ADD_DEFINITIONS(-DHAVE_SSE42 -DHAVE_PCLMUL) - IF(CLANG_CL) - SET_SOURCE_FILES_PROPERTIES(crc32/crc32_x86.c PROPERTIES COMPILE_FLAGS "-msse4.2 -mpclmul") - ENDIF() ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|i386|i686") - MY_CHECK_CXX_COMPILER_FLAG(-msse4.2) - MY_CHECK_CXX_COMPILER_FLAG(-mpclmul) - CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H) - CHECK_INCLUDE_FILE(x86intrin.h HAVE_X86INTRIN_H) - IF(have_CXX__msse4.2 AND HAVE_CPUID_H) - ADD_DEFINITIONS(-DHAVE_SSE42) - IF (have_CXX__mpclmul AND HAVE_X86INTRIN_H) - ADD_DEFINITIONS(-DHAVE_PCLMUL) - SET(MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32_x86.c) - SET_SOURCE_FILES_PROPERTIES(crc32/crc32_x86.c PROPERTIES COMPILE_FLAGS "-msse4.2 -mpclmul") - IF(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET(MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32c_amd64.cc) - SET_SOURCE_FILES_PROPERTIES(crc32/crc32c_amd64.cc PROPERTIES COMPILE_FLAGS "-msse4.2 -mpclmul") - ENDIF() + SET(MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32_x86.c crc32/crc32c_x86.cc) + IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5") + SET_SOURCE_FILES_PROPERTIES(crc32/crc32_x86.c PROPERTIES + COMPILE_FLAGS "-msse4.2 -mpclmul") + ENDIF() + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32c_amd64.cc) + IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5") + SET_SOURCE_FILES_PROPERTIES(crc32/crc32c_amd64.cc PROPERTIES + COMPILE_FLAGS "-msse4.2 -mpclmul") ENDIF() ENDIF() ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64") diff --git a/mysys/crc32/crc32_arm64.c b/mysys/crc32/crc32_arm64.c index 0e70c21812a..6588606a015 100644 --- a/mysys/crc32/crc32_arm64.c +++ b/mysys/crc32/crc32_arm64.c @@ -1,13 +1,18 @@ #include #include #include +#include -static int pmull_supported; +typedef unsigned (*my_crc32_t)(unsigned, const void *, size_t); -#if defined(HAVE_ARMV8_CRC) +#ifdef HAVE_ARMV8_CRC -#if defined(__APPLE__) -#include +# ifdef HAVE_ARMV8_CRYPTO +static unsigned crc32c_aarch64_pmull(unsigned, const void *, size_t); +# endif + +# ifdef __APPLE__ +# include int crc32_aarch64_available(void) { @@ -18,17 +23,17 @@ int crc32_aarch64_available(void) return ret; } -const char *crc32c_aarch64_available(void) +my_crc32_t crc32c_aarch64_available(void) { - if (crc32_aarch64_available() == 0) - return NULL; - pmull_supported = 1; - return "Using ARMv8 crc32 + pmull instructions"; +# ifdef HAVE_ARMV8_CRYPTO + if (crc32_aarch64_available()) + return crc32c_aarch64_pmull; +# endif + return NULL; } - -#else -#include -#if defined(__FreeBSD__) +# else +# include +# ifdef __FreeBSD__ static unsigned long getauxval(unsigned int key) { unsigned long val; @@ -36,17 +41,17 @@ static unsigned long getauxval(unsigned int key) return 0ul; return val; } -#else -# include -#endif +# else +# include +# endif -#ifndef HWCAP_CRC32 -# define HWCAP_CRC32 (1 << 7) -#endif +# ifndef HWCAP_CRC32 +# define HWCAP_CRC32 (1 << 7) +# endif -#ifndef HWCAP_PMULL -# define HWCAP_PMULL (1 << 4) -#endif +# ifndef HWCAP_PMULL +# define HWCAP_PMULL (1 << 4) +# endif /* ARM made crc32 default from ARMv8.1 but optional in ARMv8A * Runtime check API. @@ -56,22 +61,37 @@ int crc32_aarch64_available(void) unsigned long auxv= getauxval(AT_HWCAP); return (auxv & HWCAP_CRC32) != 0; } +# endif -const char *crc32c_aarch64_available(void) +# ifndef __APPLE__ +static unsigned crc32c_aarch64(unsigned, const void *, size_t); + +my_crc32_t crc32c_aarch64_available(void) { unsigned long auxv= getauxval(AT_HWCAP); - if (!(auxv & HWCAP_CRC32)) return NULL; - - pmull_supported= (auxv & HWCAP_PMULL) != 0; - if (pmull_supported) - return "Using ARMv8 crc32 + pmull instructions"; - else - return "Using ARMv8 crc32 instructions"; +# ifdef HAVE_ARMV8_CRYPTO + /* Raspberry Pi 4 supports crc32 but doesn't support pmull (MDEV-23030). */ + if (auxv & HWCAP_PMULL) + return crc32c_aarch64_pmull; +# endif + return crc32c_aarch64; } +# endif -#endif /* __APPLE__ */ +const char *crc32c_aarch64_impl(my_crc32_t c) +{ +# ifdef HAVE_ARMV8_CRYPTO + if (c == crc32c_aarch64_pmull) + return "Using ARMv8 crc32 + pmull instructions"; +# endif +# ifndef __APPLE__ + if (c == crc32c_aarch64) + return "Using ARMv8 crc32 instructions"; +# endif + return NULL; +} #endif /* HAVE_ARMV8_CRC */ #ifndef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS @@ -157,131 +177,14 @@ asm(".arch_extension crypto"); PREF4X64L2(buffer,(PREF_OFFSET), 8) \ PREF4X64L2(buffer,(PREF_OFFSET), 12) -uint32_t crc32c_aarch64(uint32_t crc, const unsigned char *buffer, uint64_t len) +#ifndef __APPLE__ +static unsigned crc32c_aarch64(unsigned crc, const void *buf, size_t len) { - uint32_t crc0, crc1, crc2; int64_t length= (int64_t)len; + const unsigned char *buffer= buf; crc^= 0xffffffff; - /* Pmull runtime check here. - * Raspberry Pi 4 supports crc32 but doesn't support pmull (MDEV-23030). - * - * Consider the condition that the target platform does support hardware crc32 - * but not support PMULL. In this condition, it should leverage the aarch64 - * crc32 instruction (__crc32c) and just only skip parallel computation (pmull/vmull) - * rather than skip all hardware crc32 instruction of computation. - */ - if (pmull_supported) - { -/* The following Macro (HAVE_ARMV8_CRYPTO) is used for compiling check */ -#ifdef HAVE_ARMV8_CRYPTO - -/* Crypto extension Support - * Parallel computation with 1024 Bytes (per block) - * Intrinsics Support - */ -# ifdef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS - const poly64_t k1= 0xe417f38a, k2= 0x8f158014; - uint64_t t0, t1; - - /* Process per block size of 1024 Bytes - * A block size = 8 + 42*3*sizeof(uint64_t) + 8 - */ - while ((length-= 1024) >= 0) - { - /* Prefetch 3*1024 data for avoiding L2 cache miss */ - PREF1KL2(buffer, 1024*3); - /* Do first 8 bytes here for better pipelining */ - crc0= __crc32cd(crc, *(const uint64_t *)buffer); - crc1= 0; - crc2= 0; - buffer+= sizeof(uint64_t); - - /* Process block inline - * Process crc0 last to avoid dependency with above - */ - CRC32C7X3X8(buffer, 0); - CRC32C7X3X8(buffer, 1); - CRC32C7X3X8(buffer, 2); - CRC32C7X3X8(buffer, 3); - CRC32C7X3X8(buffer, 4); - CRC32C7X3X8(buffer, 5); - - buffer+= 42*3*sizeof(uint64_t); - /* Prefetch data for following block to avoid L1 cache miss */ - PREF1KL1(buffer, 1024); - - /* Last 8 bytes - * Merge crc0 and crc1 into crc2 - * crc1 multiply by K2 - * crc0 multiply by K1 - */ - t1= (uint64_t)vmull_p64(crc1, k2); - t0= (uint64_t)vmull_p64(crc0, k1); - crc= __crc32cd(crc2, *(const uint64_t *)buffer); - crc1= __crc32cd(0, t1); - crc^= crc1; - crc0= __crc32cd(0, t0); - crc^= crc0; - - buffer+= sizeof(uint64_t); - } - -# else /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ - - /*No intrinsics*/ - __asm__("mov x16, #0xf38a \n\t" - "movk x16, #0xe417, lsl 16 \n\t" - "mov v1.2d[0], x16 \n\t" - "mov x16, #0x8014 \n\t" - "movk x16, #0x8f15, lsl 16 \n\t" - "mov v0.2d[0], x16 \n\t" - :::"x16"); - - while ((length-= 1024) >= 0) - { - PREF1KL2(buffer, 1024*3); - __asm__("crc32cx %w[c0], %w[c], %x[v]\n\t" - :[c0]"=r"(crc0):[c]"r"(crc), [v]"r"(*(const uint64_t *)buffer):); - crc1= 0; - crc2= 0; - buffer+= sizeof(uint64_t); - - CRC32C7X3X8(buffer, 0); - CRC32C7X3X8(buffer, 1); - CRC32C7X3X8(buffer, 2); - CRC32C7X3X8(buffer, 3); - CRC32C7X3X8(buffer, 4); - CRC32C7X3X8(buffer, 5); - - buffer+= 42*3*sizeof(uint64_t); - PREF1KL1(buffer, 1024); - __asm__("mov v2.2d[0], %x[c1] \n\t" - "pmull v2.1q, v2.1d, v0.1d \n\t" - "mov v3.2d[0], %x[c0] \n\t" - "pmull v3.1q, v3.1d, v1.1d \n\t" - "crc32cx %w[c], %w[c2], %x[v] \n\t" - "mov %x[c1], v2.2d[0] \n\t" - "crc32cx %w[c1], wzr, %x[c1] \n\t" - "eor %w[c], %w[c], %w[c1] \n\t" - "mov %x[c0], v3.2d[0] \n\t" - "crc32cx %w[c0], wzr, %x[c0] \n\t" - "eor %w[c], %w[c], %w[c0] \n\t" - :[c1]"+r"(crc1), [c0]"+r"(crc0), [c2]"+r"(crc2), [c]"+r"(crc) - :[v]"r"(*((const uint64_t *)buffer))); - buffer+= sizeof(uint64_t); - } -# endif /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ - - /* Done if Input data size is aligned with 1024 */ - if (!(length+= 1024)) - return ~crc; - -#endif /* HAVE_ARMV8_CRYPTO */ - - } // end if pmull_supported - while ((length-= sizeof(uint64_t)) >= 0) { CRC32CX(crc, *(uint64_t *)buffer); @@ -306,6 +209,143 @@ uint32_t crc32c_aarch64(uint32_t crc, const unsigned char *buffer, uint64_t len) return ~crc; } +#endif + +#ifdef HAVE_ARMV8_CRYPTO +static unsigned crc32c_aarch64_pmull(unsigned crc, const void *buf, size_t len) +{ + int64_t length= (int64_t)len; + const unsigned char *buffer= buf; + + crc^= 0xffffffff; + + /* Crypto extension Support + * Parallel computation with 1024 Bytes (per block) + * Intrinsics Support + */ +# ifdef HAVE_ARMV8_CRC_CRYPTO_INTRINSICS + /* Process per block size of 1024 Bytes + * A block size = 8 + 42*3*sizeof(uint64_t) + 8 + */ + for (const poly64_t k1= 0xe417f38a, k2= 0x8f158014; (length-= 1024) >= 0; ) + { + uint32_t crc0, crc1, crc2; + uint64_t t0, t1; + /* Prefetch 3*1024 data for avoiding L2 cache miss */ + PREF1KL2(buffer, 1024*3); + /* Do first 8 bytes here for better pipelining */ + crc0= __crc32cd(crc, *(const uint64_t *)buffer); + crc1= 0; + crc2= 0; + buffer+= sizeof(uint64_t); + + /* Process block inline + * Process crc0 last to avoid dependency with above + */ + CRC32C7X3X8(buffer, 0); + CRC32C7X3X8(buffer, 1); + CRC32C7X3X8(buffer, 2); + CRC32C7X3X8(buffer, 3); + CRC32C7X3X8(buffer, 4); + CRC32C7X3X8(buffer, 5); + + buffer+= 42*3*sizeof(uint64_t); + /* Prefetch data for following block to avoid L1 cache miss */ + PREF1KL1(buffer, 1024); + + /* Last 8 bytes + * Merge crc0 and crc1 into crc2 + * crc1 multiply by K2 + * crc0 multiply by K1 + */ + t1= (uint64_t)vmull_p64(crc1, k2); + t0= (uint64_t)vmull_p64(crc0, k1); + crc= __crc32cd(crc2, *(const uint64_t *)buffer); + crc1= __crc32cd(0, t1); + crc^= crc1; + crc0= __crc32cd(0, t0); + crc^= crc0; + + buffer+= sizeof(uint64_t); + } + +# else /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ + /*No intrinsics*/ + __asm__("mov x16, #0xf38a \n\t" + "movk x16, #0xe417, lsl 16 \n\t" + "mov v1.2d[0], x16 \n\t" + "mov x16, #0x8014 \n\t" + "movk x16, #0x8f15, lsl 16 \n\t" + "mov v0.2d[0], x16 \n\t" + :::"x16"); + + while ((length-= 1024) >= 0) + { + uint32_t crc0, crc1, crc2; + + PREF1KL2(buffer, 1024*3); + __asm__("crc32cx %w[c0], %w[c], %x[v]\n\t" + :[c0]"=r"(crc0):[c]"r"(crc), [v]"r"(*(const uint64_t *)buffer):); + crc1= 0; + crc2= 0; + buffer+= sizeof(uint64_t); + + CRC32C7X3X8(buffer, 0); + CRC32C7X3X8(buffer, 1); + CRC32C7X3X8(buffer, 2); + CRC32C7X3X8(buffer, 3); + CRC32C7X3X8(buffer, 4); + CRC32C7X3X8(buffer, 5); + + buffer+= 42*3*sizeof(uint64_t); + PREF1KL1(buffer, 1024); + __asm__("mov v2.2d[0], %x[c1] \n\t" + "pmull v2.1q, v2.1d, v0.1d \n\t" + "mov v3.2d[0], %x[c0] \n\t" + "pmull v3.1q, v3.1d, v1.1d \n\t" + "crc32cx %w[c], %w[c2], %x[v] \n\t" + "mov %x[c1], v2.2d[0] \n\t" + "crc32cx %w[c1], wzr, %x[c1] \n\t" + "eor %w[c], %w[c], %w[c1] \n\t" + "mov %x[c0], v3.2d[0] \n\t" + "crc32cx %w[c0], wzr, %x[c0] \n\t" + "eor %w[c], %w[c], %w[c0] \n\t" + :[c1]"+r"(crc1), [c0]"+r"(crc0), [c2]"+r"(crc2), [c]"+r"(crc) + :[v]"r"(*((const uint64_t *)buffer))); + buffer+= sizeof(uint64_t); + } +# endif /* HAVE_ARMV8_CRC_CRYPTO_INTRINSICS */ + + /* Done if Input data size is aligned with 1024 */ + length+= 1024; + if (length) + { + while ((length-= sizeof(uint64_t)) >= 0) + { + CRC32CX(crc, *(uint64_t *)buffer); + buffer+= sizeof(uint64_t); + } + + /* The following is more efficient than the straight loop */ + if (length & sizeof(uint32_t)) + { + CRC32CW(crc, *(uint32_t *)buffer); + buffer+= sizeof(uint32_t); + } + + if (length & sizeof(uint16_t)) + { + CRC32CH(crc, *(uint16_t *)buffer); + buffer+= sizeof(uint16_t); + } + + if (length & sizeof(uint8_t)) + CRC32CB(crc, *buffer); + } + + return ~crc; +} +#endif /* HAVE_ARMV8_CRYPTO */ /* There are multiple approaches to calculate crc. Approach-1: Process 8 bytes then 4 bytes then 2 bytes and then 1 bytes diff --git a/mysys/crc32/crc32_x86.c b/mysys/crc32/crc32_x86.c index f077399caca..ab2522d61cf 100644 --- a/mysys/crc32/crc32_x86.c +++ b/mysys/crc32/crc32_x86.c @@ -56,11 +56,16 @@ #include #ifdef __GNUC__ -#include +# include +# include +# include +# include +# define USE_PCLMUL __attribute__((target("sse4.2,pclmul"))) #elif defined(_MSC_VER) -#include +# include +# define USE_PCLMUL /* nothing */ #else -#error "unknown compiler" +# error "unknown compiler" #endif /** @@ -71,6 +76,7 @@ * * @return \a reg << (\a num * 8) */ +USE_PCLMUL static inline __m128i xmm_shift_left(__m128i reg, const unsigned int num) { static const MY_ALIGNED(16) uint8_t crc_xmm_shift_tab[48]= { @@ -111,6 +117,7 @@ struct crcr_pclmulqdq_ctx * * @return New 16 byte folded data */ +USE_PCLMUL static inline __m128i crcr32_folding_round(const __m128i data_block, const __m128i precomp, const __m128i fold) { @@ -128,6 +135,7 @@ static inline __m128i crcr32_folding_round(const __m128i data_block, * * @return data reduced to 64 bits */ +USE_PCLMUL static inline __m128i crcr32_reduce_128_to_64(__m128i data128, const __m128i precomp) { __m128i tmp0, tmp1, tmp2; @@ -152,6 +160,7 @@ static inline __m128i crcr32_reduce_128_to_64(__m128i data128, const __m128i pre * * @return data reduced to 32 bits */ +USE_PCLMUL static inline uint32_t crcr32_reduce_64_to_32(__m128i data64, const __m128i precomp) { static const MY_ALIGNED(16) uint32_t mask1[4]= { @@ -188,6 +197,7 @@ static inline uint32_t crcr32_reduce_64_to_32(__m128i data64, const __m128i prec * * @return CRC for given \a data block (32 bits wide). */ +USE_PCLMUL static inline uint32_t crcr32_calc_pclmulqdq(const uint8_t *data, uint32_t data_len, uint32_t crc, const struct crcr_pclmulqdq_ctx *params) diff --git a/mysys/crc32/crc32c.cc b/mysys/crc32/crc32c.cc index 2bec041e278..32a45478e94 100644 --- a/mysys/crc32/crc32c.cc +++ b/mysys/crc32/crc32c.cc @@ -19,52 +19,23 @@ #include #include #include -#include -static inline uint32_t DecodeFixed32(const char *ptr) -{ - return uint4korr(ptr); -} -#include -#ifdef _MSC_VER -#include -#endif +#ifdef __powerpc64__ +# include "crc32c_ppc.h" +# ifdef __linux__ +# include -#ifdef HAVE_SSE42 -# ifdef __GNUC__ -# include -# if __GNUC__ < 5 && !defined __clang__ -/* the headers do not really work in GCC before version 5 */ -# define _mm_crc32_u8(crc,data) __builtin_ia32_crc32qi(crc,data) -# define _mm_crc32_u32(crc,data) __builtin_ia32_crc32si(crc,data) -# define _mm_crc32_u64(crc,data) __builtin_ia32_crc32di(crc,data) -# else -# include +# ifndef PPC_FEATURE2_VEC_CRYPTO +# define PPC_FEATURE2_VEC_CRYPTO 0x02000000 +# endif + +# ifndef AT_HWCAP2 +# define AT_HWCAP2 26 # endif -# define USE_SSE42 __attribute__((target("sse4.2"))) -# else -# define USE_SSE42 /* nothing */ # endif #endif - -#ifdef __powerpc64__ -#include "crc32c_ppc.h" - -#if __linux__ -#include - -#ifndef PPC_FEATURE2_VEC_CRYPTO -#define PPC_FEATURE2_VEC_CRYPTO 0x02000000 -#endif - -#ifndef AT_HWCAP2 -#define AT_HWCAP2 26 -#endif - -#endif /* __linux__ */ - -#endif +typedef unsigned (*my_crc32_t)(unsigned, const void *, size_t); namespace mysys_namespace { namespace crc32c { @@ -75,6 +46,7 @@ static int arch_ppc_crc32 = 0; #endif /* __powerpc64__ */ #endif +alignas(CPU_LEVEL1_DCACHE_LINESIZE) static const uint32_t table0_[256] = { 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb, @@ -341,8 +313,9 @@ static const uint32_t table3_[256] = { }; // Used to fetch a naturally-aligned 32-bit word in little endian byte-order -static inline uint32_t LE_LOAD32(const uint8_t *p) { - return DecodeFixed32(reinterpret_cast(p)); +static inline uint32_t LE_LOAD32(const uint8_t *p) +{ + return uint4korr(reinterpret_cast(p)); } static inline void Slow_CRC32(uint64_t* l, uint8_t const **p) @@ -362,10 +335,7 @@ static inline void Slow_CRC32(uint64_t* l, uint8_t const **p) table0_[c >> 24]; } -#ifdef ALIGN #undef ALIGN -#endif - // Align n to (1 << m) byte boundary #define ALIGN(n, m) ((n + ((1 << m) - 1)) & ~((1 << m) - 1)) @@ -374,70 +344,30 @@ static inline void Slow_CRC32(uint64_t* l, uint8_t const **p) l = table0_[c] ^ (l >> 8); \ } while (0) -static uint32_t crc32c_slow(uint32_t crc, const char* buf, size_t size) -{ - const uint8_t *p = reinterpret_cast(buf); - const uint8_t *e = p + size; - uint64_t l = crc ^ 0xffffffffu; - - // Point x at first 16-byte aligned byte in string. This might be - // just past the end of the string. - const uintptr_t pval = reinterpret_cast(p); - const uint8_t* x = reinterpret_cast(ALIGN(pval, 4)); - if (x <= e) - // Process bytes until finished or p is 16-byte aligned - while (p != x) - STEP1; - // Process bytes 16 at a time - while ((e-p) >= 16) - { - Slow_CRC32(&l, &p); - Slow_CRC32(&l, &p); - } - // Process bytes 8 at a time - while ((e-p) >= 8) - Slow_CRC32(&l, &p); - // Process the last few bytes - while (p != e) - STEP1; - return static_cast(l ^ 0xffffffffu); -} - -#if defined HAVE_POWER8 -#elif defined HAVE_ARMV8_CRC -#elif defined HAVE_SSE42 -constexpr uint32_t cpuid_ecx_SSE42= 1U << 20; -constexpr uint32_t cpuid_ecx_SSE42_AND_PCLMUL= cpuid_ecx_SSE42 | 1U<<1; - -static uint32_t cpuid_ecx() -{ -#ifdef __GNUC__ - uint32_t reax= 0, rebx= 0, recx= 0, redx= 0; - __cpuid(1, reax, rebx, recx, redx); - return recx; -#elif defined _MSC_VER - int regs[4]; - __cpuid(regs, 1); - return regs[2]; -#else -# error "unknown compiler" +#undef USE_SSE42 +#if defined _MSC_VER && (defined _M_X64 || defined _M_IX86) +# include +# include +# define USE_SSE42 /* nothing */ +#elif defined __GNUC__ && (defined __i386__||defined __x86_64__) +# if __GNUC__ < 5 && !defined __clang_major__ +/* the headers do not really work in GCC before version 5 */ +# define _mm_crc32_u8(crc,data) __builtin_ia32_crc32qi(crc,data) +# define _mm_crc32_u32(crc,data) __builtin_ia32_crc32si(crc,data) +# define _mm_crc32_u64(crc,data) __builtin_ia32_crc32di(crc,data) +# else +# include +# endif +# define USE_SSE42 __attribute__((target("sse4.2"))) #endif -} -extern "C" int crc32_pclmul_enabled(void) -{ - return !(~cpuid_ecx() & cpuid_ecx_SSE42_AND_PCLMUL); -} - -#if SIZEOF_SIZE_T == 8 -extern "C" uint32_t crc32c_3way(uint32_t crc, const char *buf, size_t len); - -USE_SSE42 +#ifdef USE_SSE42 +# if SIZEOF_SIZE_T == 8 static inline uint64_t LE_LOAD64(const uint8_t *ptr) { return uint8korr(reinterpret_cast(ptr)); } -#endif +# endif USE_SSE42 static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) @@ -453,10 +383,11 @@ static inline void Fast_CRC32(uint64_t* l, uint8_t const **p) # endif } +extern "C" USE_SSE42 -static uint32_t crc32c_sse42(uint32_t crc, const char* buf, size_t size) +unsigned crc32c_sse42(unsigned crc, const void* buf, size_t size) { - const uint8_t *p = reinterpret_cast(buf); + const uint8_t *p = static_cast(buf); const uint8_t *e = p + size; uint64_t l = crc ^ 0xffffffffu; @@ -484,107 +415,111 @@ static uint32_t crc32c_sse42(uint32_t crc, const char* buf, size_t size) } #endif -typedef uint32_t (*Function)(uint32_t, const char*, size_t); +static unsigned crc32c_slow(unsigned crc, const void* buf, size_t size) +{ + const uint8_t *p = static_cast(buf); + const uint8_t *e = p + size; + uint64_t l = crc ^ 0xffffffffu; -#if defined(HAVE_POWER8) && defined(HAS_ALTIVEC) -uint32_t ExtendPPCImpl(uint32_t crc, const char *buf, size_t size) { - return crc32c_ppc(crc, (const unsigned char *)buf, size); + // Point x at first 16-byte aligned byte in string. This might be + // just past the end of the string. + const uintptr_t pval = reinterpret_cast(p); + const uint8_t* x = reinterpret_cast(ALIGN(pval, 4)); + if (x <= e) + // Process bytes until finished or p is 16-byte aligned + while (p != x) + STEP1; + // Process bytes 16 at a time + while ((e-p) >= 16) + { + Slow_CRC32(&l, &p); + Slow_CRC32(&l, &p); + } + // Process bytes 8 at a time + while ((e-p) >= 8) + Slow_CRC32(&l, &p); + // Process the last few bytes + while (p != e) + STEP1; + return static_cast(l ^ 0xffffffffu); } -#if __linux__ +#if defined(HAVE_POWER8) && defined(HAS_ALTIVEC) +# ifdef __linux__ static int arch_ppc_probe(void) { arch_ppc_crc32 = 0; -#if defined(__powerpc64__) +# if defined(__powerpc64__) if (getauxval(AT_HWCAP2) & PPC_FEATURE2_VEC_CRYPTO) arch_ppc_crc32 = 1; -#endif /* __powerpc64__ */ +# endif /* __powerpc64__ */ return arch_ppc_crc32; } -#elif __FreeBSD_version >= 1200000 -#include -#include -#include +# elif defined __FreeBSD_version && __FreeBSD_version >= 1200000 +# include +# include +# include static int arch_ppc_probe(void) { unsigned long cpufeatures; arch_ppc_crc32 = 0; -#if defined(__powerpc64__) +# if defined(__powerpc64__) elf_aux_info(AT_HWCAP2, &cpufeatures, sizeof(cpufeatures)); if (cpufeatures & PPC_FEATURE2_HAS_VEC_CRYPTO) arch_ppc_crc32 = 1; -#endif /* __powerpc64__ */ +# endif /* __powerpc64__ */ return arch_ppc_crc32; } -#elif defined(_AIX) || defined(__OpenBSD__) +# elif defined(_AIX) || defined(__OpenBSD__) static int arch_ppc_probe(void) { arch_ppc_crc32 = 0; -#if defined(__powerpc64__) +# if defined(__powerpc64__) // AIX 7.1+/OpenBSD has vector crypto features on all POWER 8+ arch_ppc_crc32 = 1; -#endif /* __powerpc64__ */ +# endif /* __powerpc64__ */ return arch_ppc_crc32; } -#endif // __linux__ +# endif #endif #if defined(HAVE_ARMV8_CRC) -extern "C" const char *crc32c_aarch64_available(void); -extern "C" uint32_t crc32c_aarch64(uint32_t crc, const unsigned char *buffer, uint64_t len); - -static uint32_t ExtendARMImpl(uint32_t crc, const char *buf, size_t size) { - return crc32c_aarch64(crc, (const unsigned char *)buf, (size_t) size); -} +extern "C" my_crc32_t crc32c_aarch64_available(void); +extern "C" const char *crc32c_aarch64_impl(my_crc32_t); +#elif defined __i386__||defined __x86_64__||defined _M_X64||defined _M_IX86 +extern "C" my_crc32_t crc32c_x86_available(void); +extern "C" const char *crc32c_x86_impl(my_crc32_t); #endif -static inline Function Choose_Extend() +static inline my_crc32_t Choose_Extend() { #if defined HAVE_POWER8 && defined HAS_ALTIVEC if (arch_ppc_probe()) - return ExtendPPCImpl; -#elif defined(HAVE_ARMV8_CRC) - if (crc32c_aarch64_available()) - return ExtendARMImpl; -#elif HAVE_SSE42 -# if defined HAVE_PCLMUL && SIZEOF_SIZE_T == 8 - switch (cpuid_ecx() & cpuid_ecx_SSE42_AND_PCLMUL) { - case cpuid_ecx_SSE42_AND_PCLMUL: - return crc32c_3way; - case cpuid_ecx_SSE42: - return crc32c_sse42; - } -# else - if (cpuid_ecx() & cpuid_ecx_SSE42) - return crc32c_sse42; -# endif + return crc32c_ppc; +#elif defined HAVE_ARMV8_CRC + if (my_crc32_t crc= crc32c_aarch64_available()) + return crc; +#elif defined __i386__||defined __x86_64__||defined _M_X64||defined _M_IX86 + if (my_crc32_t crc= crc32c_x86_available()) + return crc; #endif return crc32c_slow; } -static const Function ChosenExtend= Choose_Extend(); - -static inline uint32_t Extend(uint32_t crc, const char* buf, size_t size) -{ - return ChosenExtend(crc, buf, size); -} +static const my_crc32_t ChosenExtend= Choose_Extend(); extern "C" const char *my_crc32c_implementation() { -#if defined(HAVE_POWER8) && defined(HAS_ALTIVEC) - if (ChosenExtend == ExtendPPCImpl) +#if defined HAVE_POWER8 && defined HAS_ALTIVEC + if (ChosenExtend == crc32c_ppc) return "Using POWER8 crc32 instructions"; -#elif defined(HAVE_ARMV8_CRC) - if (const char *ret= crc32c_aarch64_available()) +#elif defined HAVE_ARMV8_CRC + if (const char *ret= crc32c_aarch64_impl(ChosenExtend)) + return ret; +#elif defined __i386__||defined __x86_64__||defined _M_X64||defined _M_IX86 + if (const char *ret= crc32c_x86_impl(ChosenExtend)) return ret; -#elif HAVE_SSE42 -# if defined HAVE_PCLMUL && SIZEOF_SIZE_T == 8 - if (ChosenExtend == crc32c_3way) - return "Using crc32 + pclmulqdq instructions"; -# endif - if (ChosenExtend == crc32c_sse42) - return "Using SSE4.2 crc32 instructions"; #endif return "Using generic crc32 instructions"; } @@ -593,5 +528,5 @@ extern "C" const char *my_crc32c_implementation() extern "C" unsigned my_crc32c(unsigned int crc, const char *buf, size_t size) { - return mysys_namespace::crc32c::Extend(crc,buf, size); + return mysys_namespace::crc32c::ChosenExtend(crc,buf, size); } diff --git a/mysys/crc32/crc32c_amd64.cc b/mysys/crc32/crc32c_amd64.cc index 22c492b457f..147c0ccaba6 100644 --- a/mysys/crc32/crc32c_amd64.cc +++ b/mysys/crc32/crc32c_amd64.cc @@ -47,6 +47,11 @@ #include #include +#ifdef _MSC_VER +# define USE_PCLMUL /* nothing */ +#else +# define USE_PCLMUL __attribute__((target("sse4.2,pclmul"))) +#endif #define CRCtriplet(crc, buf, offset) \ crc##0 = _mm_crc32_u64(crc##0, *(buf##0 + offset)); \ @@ -131,6 +136,7 @@ static const uint64_t clmul_constants alignas(16) [] = { }; // Compute the crc32c value for buffer smaller than 8 +USE_PCLMUL static inline void align_to_8( size_t len, uint64_t& crc0, // crc so far, updated on return @@ -155,6 +161,7 @@ static inline void align_to_8( // CombineCRC performs pclmulqdq multiplication of 2 partial CRC's and a well // chosen constant and xor's these with the remaining CRC. // +USE_PCLMUL static inline uint64_t CombineCRC( size_t block_size, uint64_t crc0, @@ -176,6 +183,7 @@ static inline uint64_t CombineCRC( // Compute CRC-32C using the Intel hardware instruction. extern "C" +USE_PCLMUL uint32_t crc32c_3way(uint32_t crc, const char *buf, size_t len) { const unsigned char* next = (const unsigned char*)buf; diff --git a/mysys/crc32/crc32c_ppc.h b/mysys/crc32/crc32c_ppc.h index c359061c610..797e849b685 100644 --- a/mysys/crc32/crc32c_ppc.h +++ b/mysys/crc32/crc32c_ppc.h @@ -11,8 +11,7 @@ extern "C" { #endif -extern uint32_t crc32c_ppc(uint32_t crc, unsigned char const *buffer, - unsigned len); +extern unsigned crc32c_ppc(unsigned crc, const void *buffer, size_t len); #ifdef __cplusplus } diff --git a/mysys/crc32/crc32c_x86.cc b/mysys/crc32/crc32c_x86.cc new file mode 100644 index 00000000000..d191d16c2cf --- /dev/null +++ b/mysys/crc32/crc32c_x86.cc @@ -0,0 +1,67 @@ +#include +#include +#include + +#ifdef _MSC_VER +# include +#else +# include +#endif + +extern "C" unsigned crc32c_sse42(unsigned crc, const void* buf, size_t size); + +constexpr uint32_t cpuid_ecx_SSE42= 1U << 20; +constexpr uint32_t cpuid_ecx_SSE42_AND_PCLMUL= cpuid_ecx_SSE42 | 1U << 1; + +static uint32_t cpuid_ecx() +{ +#ifdef __GNUC__ + uint32_t reax= 0, rebx= 0, recx= 0, redx= 0; + __cpuid(1, reax, rebx, recx, redx); + return recx; +#elif defined _MSC_VER + int regs[4]; + __cpuid(regs, 1); + return regs[2]; +#else +# error "unknown compiler" +#endif +} + +typedef unsigned (*my_crc32_t)(unsigned, const void *, size_t); +extern "C" unsigned int crc32_pclmul(unsigned int, const void *, size_t); +extern "C" unsigned int crc32c_3way(unsigned int, const void *, size_t); + +extern "C" my_crc32_t crc32_pclmul_enabled(void) +{ + if (~cpuid_ecx() & cpuid_ecx_SSE42_AND_PCLMUL) + return nullptr; + return crc32_pclmul; +} + +extern "C" my_crc32_t crc32c_x86_available(void) +{ +#if SIZEOF_SIZE_T == 8 + switch (cpuid_ecx() & cpuid_ecx_SSE42_AND_PCLMUL) { + case cpuid_ecx_SSE42_AND_PCLMUL: + return crc32c_3way; + case cpuid_ecx_SSE42: + return crc32c_sse42; + } +#else + if (cpuid_ecx() & cpuid_ecx_SSE42) + return crc32c_sse42; +#endif + return nullptr; +} + +extern "C" const char *crc32c_x86_impl(my_crc32_t c) +{ +#if SIZEOF_SIZE_T == 8 + if (c == crc32c_3way) + return "Using crc32 + pclmulqdq instructions"; +#endif + if (c == crc32c_sse42) + return "Using SSE4.2 crc32 instructions"; + return nullptr; +} diff --git a/mysys/crc32/crc_ppc64.h b/mysys/crc32/crc_ppc64.h index eb9379abc6c..81bbc16dfed 100644 --- a/mysys/crc32/crc_ppc64.h +++ b/mysys/crc32/crc_ppc64.h @@ -28,7 +28,7 @@ * any later version, or * b) the Apache License, Version 2.0 */ - +#include #include @@ -57,12 +57,13 @@ static unsigned int __attribute__ ((aligned (32))) __crc32_vpmsum(unsigned int crc, const void* p, unsigned long len); -unsigned int CRC32_FUNCTION(unsigned int crc, const unsigned char *p, - unsigned long len) +unsigned CRC32_FUNCTION(unsigned crc, const void *buffer, size_t len) { unsigned int prealign; unsigned int tail; + const unsigned char *p = buffer; + #ifdef CRC_XOR crc ^= 0xffffffff; #endif diff --git a/mysys/crc32ieee.cc b/mysys/crc32ieee.cc index bbafa1230f8..a9bbf690272 100644 --- a/mysys/crc32ieee.cc +++ b/mysys/crc32ieee.cc @@ -26,23 +26,22 @@ static unsigned int my_crc32_zlib(unsigned int crc, const void *data, return (unsigned int) crc32(crc, (const Bytef *)data, (unsigned int) len); } -#ifdef HAVE_PCLMUL -extern "C" int crc32_pclmul_enabled(); -extern "C" unsigned int crc32_pclmul(unsigned int, const void *, size_t); -#elif defined(__GNUC__) && defined(HAVE_ARMV8_CRC) +typedef unsigned int (*my_crc32_t)(unsigned int, const void *, size_t); + +#if defined _M_IX86 || defined _M_X64 || defined __i386__ || defined __x86_64__ +extern "C" my_crc32_t crc32_pclmul_enabled(); +#elif defined HAVE_ARMV8_CRC extern "C" int crc32_aarch64_available(); extern "C" unsigned int crc32_aarch64(unsigned int, const void *, size_t); #endif -typedef unsigned int (*my_crc32_t)(unsigned int, const void *, size_t); - static my_crc32_t init_crc32() { -#ifdef HAVE_PCLMUL - if (crc32_pclmul_enabled()) - return crc32_pclmul; -#elif defined(__GNUC__) && defined(HAVE_ARMV8_CRC) +#if defined _M_IX86 || defined _M_X64 || defined __i386__ || defined __x86_64__ + if (my_crc32_t crc= crc32_pclmul_enabled()) + return crc; +#elif defined HAVE_ARMV8_CRC if (crc32_aarch64_available()) return crc32_aarch64; #endif diff --git a/unittest/mysys/crc32-t.c b/unittest/mysys/crc32-t.c index 9834d21769b..7079aeb614a 100644 --- a/unittest/mysys/crc32-t.c +++ b/unittest/mysys/crc32-t.c @@ -1,4 +1,4 @@ -/* Copyright (c) MariaDB 2020 +/* Copyright (c) MariaDB 2020, 2024 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -19,51 +19,127 @@ #include #include #include -#include /* - Check that optimized crc32 (ieee, or ethernet polynomical) returns the same - result as zlib (not so well optimized, yet, but trustworthy) + The following lookup table oriented computation of CRC-32 + is based on the Public Domain / Creative Commons CC0 Perl code from + http://billauer.co.il/blog/2011/05/perl-crc32-crc-xs-module/ */ -#define DO_TEST_CRC32(crc,str) \ - ok(crc32(crc,(const Bytef *)str,(uint)(sizeof(str)-1)) == my_checksum(crc, str, sizeof(str)-1), "crc32 '%s'",str) -/* Check that CRC32-C calculation returns correct result*/ -#define DO_TEST_CRC32C(crc,str,expected) \ - do { \ - unsigned int v = my_crc32c(crc, str, sizeof(str)-1); \ - printf("crc32(%u,'%s',%zu)=%u\n",crc,str,sizeof(str)-1,v); \ - ok(expected == my_crc32c(crc, str, sizeof(str)-1),"crc32c '%s'",str); \ - }while(0) +/** Lookup tables */ +static uint32 tab_3309[256], tab_castagnoli[256]; +/** Initialize a lookup table for a CRC-32 polynomial */ +static void init_lookup(uint32 *tab, uint32 polynomial) +{ + unsigned i; + for (i= 0; i < 256; i++) + { + uint32 x= i; + unsigned j; + for (j= 0; j < 8; j++) + if (x & 1) + x= (x >> 1) ^ polynomial; + else + x>>= 1; + tab[i]= x; + } +} -#define LONG_STR "1234567890234568900212345678901231213123321212123123123123123"\ - "............................................................................." \ - "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \ - "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" \ - "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" +/** Compute a CRC-32 one octet at a time based on a lookup table */ +static uint crc_(uint32 crc, const void *buf, size_t len, const uint32 *tab) +{ + const unsigned char *b= buf; + const unsigned char *const end = b + len; + crc^= 0xffffffff; + while (b != end) + crc= ((crc >> 8) & 0xffffff) ^ tab[(crc ^ *b++) & 0xff]; + crc^= 0xffffffff; + return crc; +} + +static uint crc32(uint32 crc, const void *buf, size_t len) +{ return crc_(crc, buf, len, tab_3309); } +static uint crc32c(uint32 crc, const void *buf, size_t len) +{ return crc_(crc, buf, len, tab_castagnoli); } + +static char buf[16384]; + +typedef uint (*check)(uint32, const void*, size_t); + +static size_t test_buf(check c1, check c2) +{ + size_t s; + for (s= sizeof buf; s; s--) + if (c1(0, buf, s) != c2(0, buf, s)) + break; + return s; +} + +#define DO_TEST_CRC32(crc,str,len) \ + ok(crc32(crc,str,len) == my_checksum(crc, str, len), \ + "crc32(%u,'%.*s')", crc, (int) len, str) + +/* Check that CRC-32C calculation returns correct result*/ +#define DO_TEST_CRC32C(crc,str,len) \ + ok(crc32c(crc,str,len) == my_crc32c(crc, str, len), \ + "crc32c(%u,'%.*s')", crc, (int) len, str) + +static const char STR[]= + "123456789012345678900212345678901231213123321212123123123123123" + "..........................................................................." + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" + "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"; int main(int argc __attribute__((unused)),char *argv[]) { MY_INIT(argv[0]); - plan(14); + init_lookup(tab_3309, 0xedb88320); + init_lookup(tab_castagnoli, 0x82f63b78); + + plan(36); printf("%s\n",my_crc32c_implementation()); - DO_TEST_CRC32(0,""); - DO_TEST_CRC32(1,""); - DO_TEST_CRC32(0,"12345"); - DO_TEST_CRC32(1,"12345"); - DO_TEST_CRC32(0,"1234567890123456789"); - DO_TEST_CRC32(0, LONG_STR); + DO_TEST_CRC32(0,STR,0); + DO_TEST_CRC32(1,STR,0); + DO_TEST_CRC32(0,STR,3); + DO_TEST_CRC32(0,STR,5); + DO_TEST_CRC32(1,STR,5); + DO_TEST_CRC32(0,STR,15); + DO_TEST_CRC32(0,STR,16); + DO_TEST_CRC32(0,STR,19); + DO_TEST_CRC32(0,STR,32); + DO_TEST_CRC32(0,STR,63); + DO_TEST_CRC32(0,STR,64); + DO_TEST_CRC32(0,STR,65); + DO_TEST_CRC32(0,STR,255); + DO_TEST_CRC32(0,STR,256); + DO_TEST_CRC32(0,STR,257); + DO_TEST_CRC32(0,STR,(sizeof(STR)-1)); ok(0 == my_checksum(0, NULL, 0) , "crc32 data = NULL, length = 0"); - DO_TEST_CRC32C(0,"", 0); - DO_TEST_CRC32C(1,"", 1); - DO_TEST_CRC32C(0, "12345", 416359221); - DO_TEST_CRC32C(1, "12345", 549473433); - DO_TEST_CRC32C(0, "1234567890123456789", 2366987449U); - DO_TEST_CRC32C(0, LONG_STR, 3009234172U); + DO_TEST_CRC32C(0,STR,0); + DO_TEST_CRC32C(1,STR,0); + DO_TEST_CRC32C(0,STR,3); + DO_TEST_CRC32C(0,STR,5); + DO_TEST_CRC32C(1,STR,5); + DO_TEST_CRC32C(0,STR,15); + DO_TEST_CRC32C(0,STR,16); + DO_TEST_CRC32C(0,STR,19); + DO_TEST_CRC32C(0,STR,32); + DO_TEST_CRC32C(0,STR,63); + DO_TEST_CRC32C(0,STR,64); + DO_TEST_CRC32C(0,STR,65); + DO_TEST_CRC32C(0,STR,255); + DO_TEST_CRC32C(0,STR,256); + DO_TEST_CRC32C(0,STR,257); + DO_TEST_CRC32C(0,STR,(sizeof(STR)-1)); ok(0 == my_crc32c(0, NULL, 0), "crc32c data = NULL, length = 0"); + memset(buf, 0x5a, sizeof buf); + ok(0 == test_buf(my_checksum, crc32), "crc32 with various lengths"); + ok(0 == test_buf(my_crc32c, crc32c), "crc32c with various lengths"); + my_end(0); return exit_status(); } From 9ec7819c585d139c8fe64d0f7f0f0f51dcafa01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 3 May 2024 15:55:20 +0300 Subject: [PATCH 257/313] MDEV-33817: AVX512BW and VPCLMULQDQ based CRC-32 This is based on https://github.com/intel/intel-ipsec-mb/ and has been tested both on x86 and x86-64, with code that was generated by several versions of GCC and clang. GCC 11 or clang 8 or later should be able to compile this, and so should recent versions of MSVC. Thanks to Intel Corporation for providing access to hardware, for answering my questions regarding the code, and for providing the coefficients for the CRC-32C computation. crc32_avx512(): Compute a reverse polynomial CRC-32 using precomputed tables and carry-less product, for up to 256 bytes of unaligned input per loop iteration. Reviewed by: Vladislav Vaintroub --- mysys/crc32/crc32c_x86.cc | 390 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 390 insertions(+) diff --git a/mysys/crc32/crc32c_x86.cc b/mysys/crc32/crc32c_x86.cc index d191d16c2cf..02dbf2920eb 100644 --- a/mysys/crc32/crc32c_x86.cc +++ b/mysys/crc32/crc32c_x86.cc @@ -1,11 +1,33 @@ +/* Copyright (c) 2024, MariaDB plc + + 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 Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + #include #include #include #ifdef _MSC_VER # include +# if 0 /* So far, we have no environment where this could be tested. */ +# define USE_VPCLMULQDQ /* nothing */ +# endif #else # include +# if __GNUC__ >= 11 || (defined __clang_major__ && __clang_major__ >= 8) +# define TARGET "pclmul,avx512f,avx512dq,avx512bw,avx512vl,vpclmulqdq" +# define USE_VPCLMULQDQ __attribute__((target(TARGET))) +# endif #endif extern "C" unsigned crc32c_sse42(unsigned crc, const void* buf, size_t size); @@ -32,15 +54,379 @@ typedef unsigned (*my_crc32_t)(unsigned, const void *, size_t); extern "C" unsigned int crc32_pclmul(unsigned int, const void *, size_t); extern "C" unsigned int crc32c_3way(unsigned int, const void *, size_t); +#ifdef USE_VPCLMULQDQ +# include + +# ifdef _MSC_VER +/* MSVC does not seem to define this intrinsic for vmovdqa */ +# define _mm_load_epi32(x) *reinterpret_cast(x) +# endif + +/* + This implementation is based on + crc32_by16_vclmul_avx512 and crc32_refl_by16_vclmul_avx512 + in https://github.com/intel/intel-ipsec-mb/ with some optimizations. + The // comments in crc32_avx512() correspond to assembler labels. +*/ + +/** table of constants corresponding to a CRC polynomial up to degree 32 */ +struct alignas(64) crc32_tab +{ + const uint64_t b2048[2], b1024[2]; + alignas(64) const uint64_t b896[6]; /* includes b786, b640 */ + const uint64_t b512[2]; + const uint64_t b384[2], b256[2], b128[2], zeropad_for_b384[2]; + const uint64_t b64[2], b32[2]; +}; + +/** ISO 3309 CRC-32 (reflected polynomial 0x04C11DB7); zlib crc32() */ +static const crc32_tab refl32 = { + { 0x00000000e95c1271, 0x00000000ce3371cb }, + { 0x00000000910eeec1, 0x0000000033fff533 }, + { 0x000000000cbec0ed, 0x0000000031f8303f, + 0x0000000057c54819, 0x00000000df068dc2, + 0x00000000ae0b5394, 0x000000001c279815 }, + { 0x000000001d9513d7, 0x000000008f352d95 }, + { 0x00000000af449247, 0x000000003db1ecdc }, + { 0x0000000081256527, 0x00000000f1da05aa }, + { 0x00000000ccaa009e, 0x00000000ae689191 }, + { 0, 0 }, + { 0x00000000ccaa009e, 0x00000000b8bc6765 }, + { 0x00000001f7011640, 0x00000001db710640 } +}; + +/** Castagnoli CRC-32C (reflected polynomial 0x1EDC6F41) */ +static const crc32_tab refl32c = { + { 0x00000000b9e02b86, 0x00000000dcb17aa4 }, + { 0x000000000d3b6092, 0x000000006992cea2 }, + { 0x0000000047db8317, 0x000000002ad91c30, + 0x000000000715ce53, 0x00000000c49f4f67, + 0x0000000039d3b296, 0x00000000083a6eec }, + { 0x000000009e4addf8, 0x00000000740eef02 }, + { 0x00000000ddc0152b, 0x000000001c291d04 }, + { 0x00000000ba4fc28e, 0x000000003da6d0cb }, + { 0x00000000493c7d27, 0x00000000f20c0dfe }, + { 0, 0 }, + { 0x00000000493c7d27, 0x00000000dd45aab8 }, + { 0x00000000dea713f0, 0x0000000105ec76f0 } +}; + +/** Some ternary functions */ +class ternary +{ + static constexpr uint8_t A = 0b11110000; + static constexpr uint8_t B = 0b11001100; + static constexpr uint8_t C = 0b10101010; +public: + static constexpr uint8_t XOR3 = A ^ B ^ C; + static constexpr uint8_t XNOR3 = uint8_t(~(A ^ B ^ C)); + static constexpr uint8_t XOR2_AND = (A ^ B) & C; +}; + +USE_VPCLMULQDQ +/** @return a^b^c */ +static inline __m128i xor3_128(__m128i a, __m128i b, __m128i c) +{ + return _mm_ternarylogic_epi64(a, b, c, ternary::XOR3); +} + +USE_VPCLMULQDQ +/** @return ~(a^b^c) */ +static inline __m128i xnor3_128(__m128i a, __m128i b, __m128i c) +{ + return _mm_ternarylogic_epi64(a, b, c, ternary::XNOR3); +} + +USE_VPCLMULQDQ +/** @return a^b^c */ +static inline __m512i xor3_512(__m512i a, __m512i b, __m512i c) +{ + return _mm512_ternarylogic_epi64(a, b, c, ternary::XOR3); +} + +USE_VPCLMULQDQ +/** @return (a^b)&c */ +static inline __m128i xor2_and_128(__m128i a, __m128i b, __m128i c) +{ + return _mm_ternarylogic_epi64(a, b, c, ternary::XOR2_AND); +} + +USE_VPCLMULQDQ +/** Load 64 bytes */ +static inline __m512i load512(const char *b) { return _mm512_loadu_epi8(b); } + +USE_VPCLMULQDQ +/** Load 16 bytes */ +static inline __m128i load128(const char *b) { return _mm_loadu_epi64(b); } + +/** Combine 512 data bits with CRC */ +USE_VPCLMULQDQ +static inline __m512i combine512(__m512i a, __m512i tab, __m512i b) +{ + return xor3_512(b, _mm512_clmulepi64_epi128(a, tab, 0x01), + _mm512_clmulepi64_epi128(a, tab, 0x10)); +} + +# define xor512(a, b) _mm512_xor_epi64(a, b) +# define xor256(a, b) _mm256_xor_epi64(a, b) +# define xor128(a, b) _mm_xor_epi64(a, b) +# define and128(a, b) _mm_and_si128(a, b) + +template USE_VPCLMULQDQ +/** Pick a 128-bit component of a 512-bit vector */ +static inline __m512i extract512_128(__m512i a) +{ + static_assert(bits <= 3, "usage"); +# if defined __GNUC__ && __GNUC__ >= 11 + /* While technically incorrect, this would seem to translate into a + vextracti32x4 instruction, which actually outputs a ZMM register + (anything above the XMM range is cleared). */ + return _mm512_castsi128_si512(_mm512_extracti64x2_epi64(a, bits)); +# else + /* On clang, this is needed in order to get a correct result. */ + return _mm512_maskz_shuffle_i64x2(3, a, a, bits); +# endif +} + +alignas(16) static const uint64_t shuffle128[4] = { + 0x8786858483828100, 0x8f8e8d8c8b8a8988, + 0x0706050403020100, 0x000e0d0c0b0a0908 +}; + +static const __mmask16 size_mask[16] = { + 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; + +alignas(16) static const uint64_t shift128[4] = { + 0x8786858483828100, 0x8f8e8d8c8b8a8988, + 0x0706050403020100, 0x000e0d0c0b0a0908 +}; + +static const char shift_1_to_3_reflect[7 + 11] = { + -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 +}; + +USE_VPCLMULQDQ +static unsigned crc32_avx512(unsigned crc, const char *buf, size_t size, + const crc32_tab &tab) +{ + const __m512i crc_in = _mm512_castsi128_si512(_mm_cvtsi32_si128(~crc)), + b512 = _mm512_broadcast_i32x4(_mm_load_epi32(tab.b512)); + __m128i crc_out; + __m512i lo; + + if (size >= 256) { + lo = xor512(load512(buf), crc_in); + __m512i l1 = load512(buf + 64); + + const __m512i b1024 = _mm512_broadcast_i32x4(_mm_load_epi32(&tab.b1024)); + size -= 256; + if (size >= 256) { + __m512i h0 = load512(buf + 128), + hi = load512(buf + 192); + const __m512i b2048 = _mm512_broadcast_i32x4(_mm_load_epi32(&tab.b2048)); + size -= 256; + do { + buf += 256; + lo = combine512(lo, b2048, load512(buf)); + l1 = combine512(l1, b2048, load512(buf + 64)); + h0 = combine512(h0, b2048, load512(buf + 128)); + hi = combine512(hi, b2048, load512(buf + 192)); + size -= 256; + } while (ssize_t(size) >= 0); + + buf += 256; + lo = combine512(lo, b1024, h0); + l1 = combine512(l1, b1024, hi); + size += 128; + } else { + do { + buf += 128; + lo = combine512(lo, b1024, load512(buf)); + l1 = combine512(l1, b1024, load512(buf + 64)); + size -= 128; + } while (ssize_t(size) >= 0); + + buf += 128; + } + + if (ssize_t(size) >= -64) { + size += 128; + lo = combine512(lo, b512, l1); + goto fold_64_B_loop; + } + + const __m512i + b896 = _mm512_load_epi32(&tab.b896), + b384 = _mm512_load_epi32(&tab.b384); + + __m512i c4 = xor3_512(_mm512_clmulepi64_epi128(lo, b896, 1), + _mm512_clmulepi64_epi128(lo, b896, 0x10), + _mm512_clmulepi64_epi128(l1, b384, 1)); + c4 = xor3_512(c4, _mm512_clmulepi64_epi128(l1, b384, 0x10), + extract512_128<3>(l1)); + + __m256i c2 = _mm512_castsi512_si256(_mm512_shuffle_i64x2(c4, c4, 0b01001110)); + c2 = xor256(c2, _mm512_castsi512_si256(c4)); + crc_out = xor128(_mm256_extracti64x2_epi64(c2, 1), + _mm256_castsi256_si128(c2)); + size += 128 - 16; + goto final_reduction; + } + + __m128i b; + + // less_than_256 + if (size >= 32) { + if (size >= 64) { + lo = xor512(load512(buf), crc_in); + + while (buf += 64, (size -= 64) >= 64) + fold_64_B_loop: + lo = combine512(lo, b512, load512(buf)); + + // reduce_64B + const __m512i b384 = _mm512_load_epi32(&tab.b384); + __m512i crc512 = + xor3_512(_mm512_clmulepi64_epi128(lo, b384, 1), + _mm512_clmulepi64_epi128(lo, b384, 0x10), + extract512_128<3>(lo)); + crc512 = xor512(crc512, _mm512_shuffle_i64x2(crc512, crc512, 0b01001110)); + const __m256i crc256 = _mm512_castsi512_si256(crc512); + crc_out = xor128(_mm256_extracti64x2_epi64(crc256, 1), + _mm256_castsi256_si128(crc256)); + size -= 16; + } else { + // less_than_64 + crc_out = xor128(load128(buf), + _mm512_castsi512_si128(crc_in)); + buf += 16; + size -= 32; + } + + final_reduction: + b = _mm_load_epi32(&tab.b128); + + while (ssize_t(size) >= 0) { + // reduction_loop_16B + crc_out = xor3_128(load128(buf), + _mm_clmulepi64_si128(crc_out, b, 1), + _mm_clmulepi64_si128(crc_out, b, 0x10)); + buf += 16; + size -= 16; + } + // final_reduction_for_128 + + size += 16; + if (size) { + get_last_two_xmms: + const __m128i crc2 = crc_out, d = load128(buf + (size - 16)); + __m128i S = load128(reinterpret_cast(shuffle128) + size); + crc_out = _mm_shuffle_epi8(crc_out, S); + S = xor128(S, _mm_set1_epi32(0x80808080)); + crc_out = xor3_128(_mm_blendv_epi8(_mm_shuffle_epi8(crc2, S), d, S), + _mm_clmulepi64_si128(crc_out, b, 1), + _mm_clmulepi64_si128(crc_out, b, 0x10)); + } + + done_128: + __m128i crc_tmp; + b = _mm_load_epi32(&tab.b64); + crc_tmp = xor128(_mm_clmulepi64_si128(crc_out, b, 0x00), + _mm_srli_si128(crc_out, 8)); + crc_out = _mm_slli_si128(crc_tmp, 4); + crc_out = _mm_clmulepi64_si128(crc_out, b, 0x10); + crc_out = xor128(crc_out, crc_tmp); + + barrett: + b = _mm_load_epi32(&tab.b32); + crc_tmp = crc_out; + crc_out = and128(crc_out, _mm_set_epi64x(~0ULL, ~0xFFFFFFFFULL)); + crc_out = _mm_clmulepi64_si128(crc_out, b, 0); + crc_out = xor2_and_128(crc_out, crc_tmp, _mm_set_epi64x(0, ~0ULL)); + crc_out = xnor3_128(crc_out, crc_tmp, + _mm_clmulepi64_si128(crc_out, b, 0x10)); + return _mm_extract_epi32(crc_out, 2); + } else { + // less_than_32 + if (size > 0) { + if (size > 16) { + crc_out = xor128(load128(buf), + _mm512_castsi512_si128(crc_in)); + buf += 16; + size -= 16; + b = _mm_load_epi32(&tab.b128); + goto get_last_two_xmms; + } else if (size < 16) { + crc_out = _mm_maskz_loadu_epi8(size_mask[size - 1], buf); + crc_out = xor128(crc_out, _mm512_castsi512_si128(crc_in)); + + if (size >= 4) { + crc_out = _mm_shuffle_epi8 + (crc_out, + load128(reinterpret_cast(shift128) + size)); + goto done_128; + } else { + // only_less_than_4 + /* Shift, zero-filling 5 to 7 of the 8-byte crc_out */ + crc_out = _mm_shuffle_epi8(crc_out, + load128(shift_1_to_3_reflect + size - 1)); + goto barrett; + } + } else { + crc_out = xor128(load128(buf), _mm512_castsi512_si128(crc_in)); + goto done_128; + } + } else + return crc; + } +} + +static ATTRIBUTE_NOINLINE int have_vpclmulqdq() +{ +# ifdef _MSC_VER + int regs[4]; + __cpuidex(regs, 7, 0); + uint32_t ebx = regs[1], ecx = regs[2]; +# else + uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; + __cpuid_count(7, 0, eax, ebx, ecx, edx); +# endif + return ecx & 1U<<10/*VPCLMULQDQ*/ && + !(~ebx & ((1U<<16/*AVX512F*/ | 1U<<17/*AVX512DQ*/ | + 1U<<30/*AVX512BW*/ | 1U<<31/*AVX512VL*/))); +} + +static unsigned crc32_vpclmulqdq(unsigned crc, const void *buf, size_t size) +{ + return crc32_avx512(crc, static_cast(buf), size, refl32); +} + +static unsigned crc32c_vpclmulqdq(unsigned crc, const void *buf, size_t size) +{ + return crc32_avx512(crc, static_cast(buf), size, refl32c); +} +#endif + extern "C" my_crc32_t crc32_pclmul_enabled(void) { if (~cpuid_ecx() & cpuid_ecx_SSE42_AND_PCLMUL) return nullptr; +#ifdef USE_VPCLMULQDQ + if (have_vpclmulqdq()) + return crc32_vpclmulqdq; +#endif return crc32_pclmul; } extern "C" my_crc32_t crc32c_x86_available(void) { +#ifdef USE_VPCLMULQDQ + if (have_vpclmulqdq()) + return crc32c_vpclmulqdq; +#endif #if SIZEOF_SIZE_T == 8 switch (cpuid_ecx() & cpuid_ecx_SSE42_AND_PCLMUL) { case cpuid_ecx_SSE42_AND_PCLMUL: @@ -57,6 +443,10 @@ extern "C" my_crc32_t crc32c_x86_available(void) extern "C" const char *crc32c_x86_impl(my_crc32_t c) { +#ifdef USE_VPCLMULQDQ + if (c == crc32c_vpclmulqdq) + return "Using AVX512 instructions"; +#endif #if SIZEOF_SIZE_T == 8 if (c == crc32c_3way) return "Using crc32 + pclmulqdq instructions"; From 029e2a5fd9017d0ed12de6a0a1549f39bece7fbe Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 2 May 2024 23:11:38 +0200 Subject: [PATCH 258/313] MDEV-33876 CMake, zlib - use names compatible with official FindZLIB.cmake - ZLIB_LIBRARIES, not ZLIB_LIBRARY - ZLIB_INCLUDE_DIRS, not ZLIB_INCLUDE_DIR For building libmariadb, ZLIB_LIBRARY/ZLIB_INCLUDE_DIR are still defined This workaround will be removed later. --- client/CMakeLists.txt | 2 +- cmake/plugin.cmake | 2 +- cmake/zlib.cmake | 10 ++++++---- extra/CMakeLists.txt | 2 +- libmysqld/CMakeLists.txt | 4 ++-- mysys/CMakeLists.txt | 4 ++-- sql/CMakeLists.txt | 2 +- storage/archive/CMakeLists.txt | 2 +- storage/connect/CMakeLists.txt | 2 +- storage/innobase/CMakeLists.txt | 2 +- storage/maria/CMakeLists.txt | 4 ++-- storage/maria/unittest/CMakeLists.txt | 2 +- storage/rocksdb/CMakeLists.txt | 2 +- storage/rocksdb/build_rocksdb.cmake | 2 +- storage/tokudb/CMakeLists.txt | 2 +- storage/tokudb/PerconaFT/src/CMakeLists.txt | 2 +- unittest/mysys/CMakeLists.txt | 2 +- 17 files changed, 25 insertions(+), 23 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 55fd02b23c3..3ad788f8023 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -18,7 +18,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include ${PCRE_INCLUDES} ${CMAKE_SOURCE_DIR}/mysys_ssl - ${ZLIB_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/strings diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 813d8ef6e42..7fd3b6294b9 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -46,7 +46,7 @@ MACRO(MYSQL_ADD_PLUGIN) ${CMAKE_SOURCE_DIR}/sql ${PCRE_INCLUDES} ${SSL_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIR}) + ${ZLIB_INCLUDE_DIRS}) LIST(GET ARG_UNPARSED_ARGUMENTS 0 plugin) SET(SOURCES ${ARG_UNPARSED_ARGUMENTS}) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index ee47eb427d9..a933194cd33 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -14,9 +14,12 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA MACRO (MYSQL_USE_BUNDLED_ZLIB) - SET(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_BINARY_DIR}/zlib) + SET(ZLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_BINARY_DIR}/zlib) SET(BUILD_BUNDLED_ZLIB 1) - SET(ZLIB_LIBRARY zlib CACHE INTERNAL "Bundled zlib library") + SET(ZLIB_LIBRARIES zlib CACHE INTERNAL "Bundled zlib library") + # temporarily define ZLIB_LIBRARY and ZLIB_INCLUDE_DIR for libmariadb + SET(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) + SET(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS}) SET(ZLIB_FOUND TRUE) SET(WITH_ZLIB "bundled" CACHE STRING "Use bundled zlib") ADD_SUBDIRECTORY(zlib) @@ -29,7 +32,7 @@ ENDMACRO() # If this is set,we use bundled zlib # If this is not set,search for system zlib. # if system zlib is not found, use bundled copy -# ZLIB_LIBRARIES, ZLIB_INCLUDE_DIR and ZLIB_SOURCES +# ZLIB_LIBRARIES, ZLIB_INCLUDE_DIRS # are set after this macro has run MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) @@ -52,7 +55,6 @@ MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) IF(HAVE_CRC32 AND HAVE_COMPRESSBOUND AND HAVE_DEFLATEBOUND) SET(WITH_ZLIB "system" CACHE STRING "Which zlib to use (possible values are 'bundled' or 'system')") - SET(ZLIB_SOURCES "") ELSE() SET(ZLIB_FOUND FALSE CACHE INTERNAL "Zlib found but not usable") MESSAGE(STATUS "system zlib found but not usable") diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index f53e9fdf8d8..00ef14c1b21 100644 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -13,7 +13,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${ZLIB_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${ZLIB_INCLUDE_DIRS}) # Default install component for the files is Server here SET(MYSQL_INSTALL_COMPONENT Server) diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index b9eff10bc18..44115b5c1fc 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -24,7 +24,7 @@ ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/tpool ${CMAKE_BINARY_DIR}/sql ${PCRE_INCLUDES} -${ZLIB_INCLUDE_DIR} +${ZLIB_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} ${SSL_INTERNAL_INCLUDE_DIRS} ) @@ -169,7 +169,7 @@ ENDIF() SET(LIBS dbug strings mysys mysys_ssl pcre2-8 vio - ${ZLIB_LIBRARY} ${SSL_LIBRARIES} + ${ZLIB_LIBRARIES} ${SSL_LIBRARIES} ${LIBWRAP} ${LIBCRYPT} ${CMAKE_DL_LIBS} ${EMBEDDED_PLUGIN_LIBS} sql_embedded diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 8b007f7f8da..bf3984a1ffc 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA -INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys) +INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys) SET(MYSYS_SOURCES array.c charset-def.c charset.c my_default.c get_password.c @@ -157,7 +157,7 @@ ENDIF() ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES}) MAYBE_DISABLE_IPO(mysys) -TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY} +TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARIES} ${LIBNSL} ${LIBM} ${LIBRT} ${CMAKE_DL_LIBS} ${LIBSOCKET} ${LIBEXECINFO}) DTRACE_INSTRUMENT(mysys) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index bb86d5cac66..8d24a140865 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -53,7 +53,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${PCRE_INCLUDES} -${ZLIB_INCLUDE_DIR} +${ZLIB_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/sql ${CMAKE_SOURCE_DIR}/tpool diff --git a/storage/archive/CMakeLists.txt b/storage/archive/CMakeLists.txt index 5b6818fc921..5c7b6aa4aab 100644 --- a/storage/archive/CMakeLists.txt +++ b/storage/archive/CMakeLists.txt @@ -14,5 +14,5 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA SET(ARCHIVE_SOURCES azio.c ha_archive.cc ha_archive.h) -MYSQL_ADD_PLUGIN(archive ${ARCHIVE_SOURCES} STORAGE_ENGINE LINK_LIBRARIES ${ZLIB_LIBRARY}) +MYSQL_ADD_PLUGIN(archive ${ARCHIVE_SOURCES} STORAGE_ENGINE LINK_LIBRARIES ${ZLIB_LIBRARIES}) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 6dd6832dc7e..1a1e8df080a 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -406,7 +406,7 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES} STORAGE_ENGINE COMPONENT connect-engine RECOMPILE_FOR_EMBEDDED - LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} + LINK_LIBRARIES ${ZLIB_LIBRARIES} ${XML_LIBRARY} ${ICONV_LIBRARY} ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${MONGOC_LIBRARY} ${IPHLPAPI_LIBRARY} ${REST_LIBRARY}) IF(NOT TARGET connect) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 8e26eec0f0a..8289da05fc4 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -492,7 +492,7 @@ MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE MODULE_OUTPUT_NAME ha_innodb DEFAULT RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES - ${ZLIB_LIBRARY} + ${ZLIB_LIBRARIES} ${NUMA_LIBRARY} ${LIBSYSTEMD} ${LINKER_SCRIPT} diff --git a/storage/maria/CMakeLists.txt b/storage/maria/CMakeLists.txt index a566580dca3..426a19f0447 100644 --- a/storage/maria/CMakeLists.txt +++ b/storage/maria/CMakeLists.txt @@ -124,7 +124,7 @@ ENDIF() IF (CURL_FOUND) INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) MYSQL_ADD_PLUGIN(s3 ha_s3.cc ${S3_SOURCES} COMPONENT s3-engine - LINK_LIBRARIES ${CURL_LIBRARIES} ${ZLIB_LIBRARY} STORAGE_ENGINE NOT_EMBEDDED CONFIG s3.cnf) + LINK_LIBRARIES ${CURL_LIBRARIES} ${ZLIB_LIBRARIES} STORAGE_ENGINE NOT_EMBEDDED CONFIG s3.cnf) ENDIF() SET(CPACK_RPM_s3-engine_PACKAGE_SUMMARY "Amazon S3 archival storage engine for MariaDB" PARENT_SCOPE) @@ -132,7 +132,7 @@ SET(CPACK_RPM_s3-engine_PACKAGE_DESCRIPTION "The S3 storage engine allows one to IF(TARGET s3) MYSQL_ADD_EXECUTABLE(aria_s3_copy aria_s3_copy.cc ${S3_SOURCES} COMPONENT s3-engine) - TARGET_LINK_LIBRARIES(aria_s3_copy aria myisam mysys mysys_ssl ${CURL_LIBRARIES} ${ZLIB_LIBRARY}) + TARGET_LINK_LIBRARIES(aria_s3_copy aria myisam mysys mysys_ssl ${CURL_LIBRARIES} ${ZLIB_LIBRARIES}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/libmarias3) ADD_DEFINITIONS(-DWITH_S3_STORAGE_ENGINE) ENDIF() diff --git a/storage/maria/unittest/CMakeLists.txt b/storage/maria/unittest/CMakeLists.txt index a2da1507c97..a7b3441044d 100644 --- a/storage/maria/unittest/CMakeLists.txt +++ b/storage/maria/unittest/CMakeLists.txt @@ -15,7 +15,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/unittest/mytap) -LINK_LIBRARIES(aria myisam mytap mysys dbug strings ${ZLIB_LIBRARY}) +LINK_LIBRARIES(aria myisam mytap mysys dbug strings ${ZLIB_LIBRARIES}) MY_ADD_TESTS(ma_control_file trnman) diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index b6671c458f9..976b7fb2f51 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -197,7 +197,7 @@ ADD_CONVENIENCE_LIBRARY(rocksdb_aux_lib ADD_DEPENDENCIES(rocksdb_aux_lib GenError) # MARIAROCKS-TODO: how to properly depend on -lrt ? -TARGET_LINK_LIBRARIES(rocksdb_aux_lib rocksdblib ${ZLIB_LIBRARY}) +TARGET_LINK_LIBRARIES(rocksdb_aux_lib rocksdblib ${ZLIB_LIBRARIES}) if (UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") TARGET_LINK_LIBRARIES(rocksdb_aux_lib -lrt) endif() diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake index cfcb0e351b7..eda58421da0 100644 --- a/storage/rocksdb/build_rocksdb.cmake +++ b/storage/rocksdb/build_rocksdb.cmake @@ -79,7 +79,7 @@ check_lib(snappy snappy) # rocksdb/cmake/modules/Findsnappy.cmake violates the c check_lib(ZSTD ZSTD ZDICT_trainFromBuffer) add_definitions(-DZLIB) -list(APPEND THIRDPARTY_LIBS ${ZLIB_LIBRARY}) +list(APPEND THIRDPARTY_LIBS ${ZLIB_LIBRARIES}) ADD_FEATURE_INFO(ROCKSDB_ZLIB "ON" "zlib Compression in the RocksDB storage engine") if(CMAKE_SYSTEM_NAME MATCHES "Cygwin") diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index b88fad4c244..90d7237344d 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -175,7 +175,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/${TOKU_FT_DIR_NAME}/buildheader) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/${TOKU_FT_DIR_NAME}/portability) TARGET_LINK_LIBRARIES(tokudb tokufractaltree_static tokuportability_static - ${ZLIB_LIBRARY} ${LIBJEMALLOC} stdc++) + ${ZLIB_LIBRARIES} ${LIBJEMALLOC} stdc++) SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto -fuse-linker-plugin") SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} -flto -fuse-linker-plugin") diff --git a/storage/tokudb/PerconaFT/src/CMakeLists.txt b/storage/tokudb/PerconaFT/src/CMakeLists.txt index bae37389004..ae5611044a8 100644 --- a/storage/tokudb/PerconaFT/src/CMakeLists.txt +++ b/storage/tokudb/PerconaFT/src/CMakeLists.txt @@ -19,7 +19,7 @@ set(tokudb_srcs add_library(${LIBTOKUDB} SHARED ${tokudb_srcs}) add_dependencies(${LIBTOKUDB} install_tdb_h generate_log_code) target_link_libraries(${LIBTOKUDB} LINK_PRIVATE locktree_static ft_static util_static lzma snappy dbug ${LIBTOKUPORTABILITY}) -target_link_libraries(${LIBTOKUDB} LINK_PUBLIC ${ZLIB_LIBRARY} ) +target_link_libraries(${LIBTOKUDB} LINK_PUBLIC ${ZLIB_LIBRARIES} ) ## make the static library add_library(tokudb_static_conv STATIC ${tokudb_srcs}) diff --git a/unittest/mysys/CMakeLists.txt b/unittest/mysys/CMakeLists.txt index 4b947ab780f..9dd5e5dbd9c 100644 --- a/unittest/mysys/CMakeLists.txt +++ b/unittest/mysys/CMakeLists.txt @@ -19,7 +19,7 @@ MY_ADD_TESTS(bitmap base64 my_atomic my_rdtsc lf my_malloc my_getopt dynstring MY_ADD_TESTS(my_vsnprintf LINK_LIBRARIES strings mysys) MY_ADD_TESTS(aes LINK_LIBRARIES mysys mysys_ssl) ADD_DEFINITIONS(${SSL_DEFINES}) -INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) MY_ADD_TESTS(ma_dyncol LINK_LIBRARIES mysys) IF(WIN32) From b18259ecf5e7a730c528382f86a1310fcdcab8c5 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 3 May 2024 13:24:06 +0200 Subject: [PATCH 259/313] Compiling - Fix MSVC compile warnings, on x86 --- sql/ha_partition.cc | 8 +++++--- storage/innobase/buf/buf0flu.cc | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 8606c28d046..8ab9c346ca6 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3282,10 +3282,12 @@ handlerton *ha_partition::get_def_part_engine(const char *name) goto err; if (state.st_size <= 64) goto err; - if (!(frm_image= (uchar*)my_malloc(key_memory_Partition_share, - state.st_size, MYF(MY_WME)))) + if ((ulonglong)state.st_size >= SIZE_T_MAX) /* Whole file need to fit into memory*/ goto err; - if (mysql_file_read(file, frm_image, state.st_size, MYF(MY_NABP))) + if (!(frm_image= (uchar*)my_malloc(key_memory_Partition_share, + (size_t)state.st_size, MYF(MY_WME)))) + goto err; + if (mysql_file_read(file, frm_image, (size_t)state.st_size, MYF(MY_NABP))) goto err; if (frm_image[64] != '/') diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index d74ccd75521..a554309915d 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -2168,7 +2168,7 @@ func_exit: sum_pages += last_pages_in; - const ulint time_elapsed = std::max(curr_time - prev_time, 1); + const ulint time_elapsed = std::max(ulint(curr_time - prev_time), 1); /* We update our variables every innodb_flushing_avg_loops iterations to smooth out transition in workload. */ From 88f49da8e08bb5027b6031fed04f82f2d9f552b7 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 3 May 2024 21:48:26 +0200 Subject: [PATCH 260/313] MDEV-34063 tpool - integer overflow in multiplication. When calculating next wakeup timepoint for the timer thread, with large thread_pool_stall_limit values, 32bit int overflow can happen. Fixed by making one operand 8 byte large. Also fixed the type of tick_interval to be unsigned, so it does not go negative for very thread_pool_stall_limit. --- sql/threadpool_generic.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc index d80cf0e08df..0bab82fba79 100644 --- a/sql/threadpool_generic.cc +++ b/sql/threadpool_generic.cc @@ -107,7 +107,7 @@ struct pool_timer_t mysql_cond_t cond; volatile uint64 current_microtime; std::atomic next_timeout_check; - int tick_interval; + uint tick_interval; bool shutdown; pthread_t timer_thread_id; }; @@ -577,7 +577,7 @@ static void* timer_thread(void *param) struct timespec ts; int err; - set_timespec_nsec(ts,timer->tick_interval*1000000); + set_timespec_nsec(ts, timer->tick_interval*1000000LL); mysql_mutex_lock(&timer->mutex); err= mysql_cond_timedwait(&timer->cond, &timer->mutex, &ts); if (timer->shutdown) From 1cdf22374be6a23f026cfedd4d099b06f84a301c Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 4 May 2024 22:34:14 +0400 Subject: [PATCH 261/313] MDEV-34069 Zero datetime reinterprets as '1970-01-01 00:00:00' on field_datetime=field_timestamp The code in Field_timestamp::save_in_field() did not catch zero datetime and stored it to the other field like a usual value using store_timestamp_dec(), which knows nothing about zero date and treats {tv_sec=0, tv_usec=0} as a normal timeval value corresponding to '1970-01-01 00:00:00 +00:00'. Fixing the code to catch the special combination (ts==0 && sec_pat==0) and store it using store_time_dec() with a zero datetime passed as an argument. --- mysql-test/main/type_timestamp.result | 30 +++++++++++++++++++++++++++ mysql-test/main/type_timestamp.test | 20 ++++++++++++++++++ sql/field.cc | 2 ++ 3 files changed, 52 insertions(+) diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index f95a1d6ae39..2763b25f58c 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -1368,5 +1368,35 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci drop table t1; # +# MDEV-34069 Zero datetime reinterprets as '1970-01-01 00:00:00' on field_datetime=field_timestamp +# +SET sql_mode=''; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00'); +SELECT * FROM t1; +a +0000-00-00 00:00:00 +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 SELECT a FROM t1; +SELECT * FROM t2; +a +0000-00-00 00:00:00 +SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE'; +INSERT INTO t2 VALUES ('0000-00-00 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t2 SELECT a FROM t1; +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +SELECT * FROM t2; +a +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +DROP TABLE t2, t1; +SET time_zone=DEFAULT; +SET sql_mode=DEFAULT; +# # End of 10.5 tests # diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index 526a0e69857..076ecbd41ed 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -920,6 +920,26 @@ create table t1 (f1 timestamp, f2 timestamp); show create table t1; drop table t1; +--echo # +--echo # MDEV-34069 Zero datetime reinterprets as '1970-01-01 00:00:00' on field_datetime=field_timestamp +--echo # + +SET sql_mode=''; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('0000-00-00 00:00:00'); +SELECT * FROM t1; +CREATE TABLE t2 (a DATETIME); +INSERT INTO t2 SELECT a FROM t1; +SELECT * FROM t2; +SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE'; +INSERT INTO t2 VALUES ('0000-00-00 00:00:00'); +INSERT INTO t2 SELECT a FROM t1; +SELECT * FROM t2; +DROP TABLE t2, t1; +SET time_zone=DEFAULT; +SET sql_mode=DEFAULT; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/field.cc b/sql/field.cc index 828687aeaf3..e428f38b896 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5184,6 +5184,8 @@ int Field_timestamp::save_in_field(Field *to) { ulong sec_part; my_time_t ts= get_timestamp(&sec_part); + if (!ts && !sec_part) + return to->store_time_dec(Datetime::zero().get_mysql_time(), decimals()); return to->store_timestamp_dec(Timeval(ts, sec_part), decimals()); } From 2c19877015bd318f5f1871b1ce5c4aa7e9e8e559 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 4 May 2024 23:41:55 +0400 Subject: [PATCH 262/313] MDEV-34061 unix_timestamp(coalesce(timestamp_column)) returns NULL on '1970-01-01 00:00:00.000001' Field_timestampf::val_native() checked only the first four bytes to detect zero dates. That was not enough. Fixing the code to check all packed_length() bytes to detect zero dates. --- mysql-test/main/type_timestamp.result | 11 +++++++++++ mysql-test/main/type_timestamp.test | 11 +++++++++++ sql/field.cc | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index 2763b25f58c..a87db3ae898 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -1398,5 +1398,16 @@ DROP TABLE t2, t1; SET time_zone=DEFAULT; SET sql_mode=DEFAULT; # +# MDEV-34061 unix_timestamp(coalesce(timestamp_column)) returns NULL on '1970-01-01 00:00:00.000001' +# +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP(6) NULL); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.000001'); +SELECT unix_timestamp(a) AS c1, unix_timestamp(coalesce(a)) AS c2 FROM t1; +c1 c2 +0.000001 0.000001 +DROP TABLE t1; +SET time_zone=DEFAULT; +# # End of 10.5 tests # diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index 076ecbd41ed..4093afe4e0d 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -940,6 +940,17 @@ DROP TABLE t2, t1; SET time_zone=DEFAULT; SET sql_mode=DEFAULT; +--echo # +--echo # MDEV-34061 unix_timestamp(coalesce(timestamp_column)) returns NULL on '1970-01-01 00:00:00.000001' +--echo # + +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP(6) NULL); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.000001'); +SELECT unix_timestamp(a) AS c1, unix_timestamp(coalesce(a)) AS c2 FROM t1; +DROP TABLE t1; +SET time_zone=DEFAULT; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/field.cc b/sql/field.cc index e428f38b896..86b11f6c6bf 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5698,8 +5698,10 @@ my_time_t Field_timestampf::get_timestamp(const uchar *pos, bool Field_timestampf::val_native(Native *to) { DBUG_ASSERT(marked_for_read()); + char zero[8]= "\0\0\0\0\0\0\0"; + DBUG_ASSERT(pack_length () <= sizeof(zero)); // Check if it's '0000-00-00 00:00:00' rather than a real timestamp - if (ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) + if (!memcmp(ptr, zero, pack_length())) { to->length(0); return false; From 7f161a5c588495ed59d880a98fcd7cdfa74174c9 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sun, 5 May 2024 15:28:37 +0400 Subject: [PATCH 263/313] MDEV-34088 The TIMESTAMP value of '1970-01-01 00:00:00' can be indirectly inserted in strict mode In strict mode a timestamp(0) column could be directly assigned from another timestamp(N>0) column with the value '1970-01-01 00:00:00.1' (at time zone '+00:00'), or with any other value '1970-01-01 00:00:00.XXXXXX' with non-zero microsecond value XXXXXX. This assignment happened silently without warnings or errors. It worked as follows: - The value {tv_sec=0, tv_usec=100000}, which is '1970-01-01 00:00:00.1' was rounded to {tv_sec=0, tv_usec=0}, which is '1970-01-01 00:00:00.0' - Then {tv_sec=0, tv_usec=0} was silently re-interpreted as zero datetime. After the fix this assignment always raises a warning, which in case of the strict mode is escalated to an error. The problem in this scenario is that '1970-01-01 00:00:00' cannot be stored, because its timeval value {tv_sec=0, tv_usec=0} is reserved for zero datetimes. Thus the warning should be raised no matter if sql_mode allows or disallows zero dates. --- mysql-test/main/type_timestamp.result | 75 +++++++++++++++++++++++++++ mysql-test/main/type_timestamp.test | 61 ++++++++++++++++++++++ sql/field.cc | 29 +++++++++-- 3 files changed, 160 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index a87db3ae898..2516f8ea312 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -1409,5 +1409,80 @@ c1 c2 DROP TABLE t1; SET time_zone=DEFAULT; # +# MDEV-34088 The TIMESTAMP value of '1970-01-01 00:00:00' can be indirectly inserted in strict mode +# +SET sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES'; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00' for column `test`.`t1`.`a` at row 1 +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1'); +ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00.1' for column `test`.`t1`.`a` at row 1 +CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1'); +INSERT INTO t1 SELECT a FROM t2; +ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00 +00:00' for column `test`.`t1`.`a` at row 1 +DROP TABLE t2; +DROP TABLE t1; +SET sql_mode=DEFAULT; +SET sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE'; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00' for column `test`.`t1`.`a` at row 1 +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1'); +ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00.1' for column `test`.`t1`.`a` at row 1 +CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1'); +INSERT INTO t1 SELECT a FROM t2; +ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00 +00:00' for column `test`.`t1`.`a` at row 1 +DROP TABLE t2; +DROP TABLE t1; +SET sql_mode=DEFAULT; +SET sql_mode=''; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1'); +INSERT INTO t1 SELECT a FROM t2; +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +DROP TABLE t2; +SELECT * FROM t1; +a +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +DROP TABLE t1; +SET sql_mode=DEFAULT; +SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE'; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1'); +INSERT INTO t1 SELECT a FROM t2; +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +DROP TABLE t2; +SELECT * FROM t1; +a +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +DROP TABLE t1; +SET sql_mode=DEFAULT; +# # End of 10.5 tests # diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index 4093afe4e0d..3f17f347a22 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -951,6 +951,67 @@ SELECT unix_timestamp(a) AS c1, unix_timestamp(coalesce(a)) AS c2 FROM t1; DROP TABLE t1; SET time_zone=DEFAULT; +--echo # +--echo # MDEV-34088 The TIMESTAMP value of '1970-01-01 00:00:00' can be indirectly inserted in strict mode +--echo # + +SET sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES'; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1'); +CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1'); +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 SELECT a FROM t2; +DROP TABLE t2; +DROP TABLE t1; +SET sql_mode=DEFAULT; + + +SET sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE'; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1'); +CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1'); +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 SELECT a FROM t2; +DROP TABLE t2; +DROP TABLE t1; +SET sql_mode=DEFAULT; + +SET sql_mode=''; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1'); +CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1'); +INSERT INTO t1 SELECT a FROM t2; +DROP TABLE t2; +SELECT * FROM t1; +DROP TABLE t1; +SET sql_mode=DEFAULT; + +SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE'; +SET time_zone='+00:00'; +CREATE TABLE t1 (a TIMESTAMP); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00'); +INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1'); +CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1'); +INSERT INTO t1 SELECT a FROM t2; +DROP TABLE t2; +SELECT * FROM t1; +DROP TABLE t1; +SET sql_mode=DEFAULT; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/field.cc b/sql/field.cc index 86b11f6c6bf..f03135a63bc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5307,11 +5307,33 @@ int Field_timestamp::store(longlong nr, bool unsigned_val) } -int Field_timestamp::store_timestamp_dec(const timeval &ts, uint dec) +int Field_timestamp::store_timestamp_dec(const timeval &tv, uint dec) { int warn= 0; time_round_mode_t mode= Datetime::default_round_mode(get_thd()); - store_TIMESTAMP(Timestamp(ts).round(decimals(), mode, &warn)); + const Timestamp ts= Timestamp(tv).round(decimals(), mode, &warn); + store_TIMESTAMP(ts); + if (ts.tv().tv_sec == 0 && ts.tv().tv_usec == 0) + { + /* + The value {tv_sec==0, tv_usec==0} here means '1970-01-01 00:00:00 +00'. + It does not mean zero datetime! because store_timestamp_dec() knows + nothing about zero dates. It inserts only real timeval values. + Zero ts={0,0} here is possible in two scenarios: + - the passed tv was already {0,0} meaning '1970-01-01 00:00:00 +00' + - the passed tv had some microseconds but they were rounded/truncated + to zero: '1970-01-01 00:00:00.1 +00' -> '1970-01-01 00:00:00 +00'. + It does not matter whether rounding/truncation really happened. + In both cases the call for store_TIMESTAMP(ts) above re-interpreted + '1970-01-01 00:00:00 +00:00' to zero date. Return 1 no matter what + sql_mode is. Even if sql_mode allows zero dates, there is still a problem + here: '1970-01-01 00:00:00 +00' could not be stored as-is! + */ + ErrConvString str(STRING_WITH_LEN("1970-01-01 00:00:00 +00:00"), + system_charset_info); + set_datetime_warning(ER_WARN_DATA_OUT_OF_RANGE, &str, "datetime", 1); + return 1; // '1970-01-01 00:00:00 +00' was converted to a zero date + } if (warn) { /* @@ -5325,9 +5347,6 @@ int Field_timestamp::store_timestamp_dec(const timeval &ts, uint dec) */ set_warning(Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); } - if (ts.tv_sec == 0 && ts.tv_usec == 0 && - get_thd()->variables.sql_mode & (ulonglong) TIME_NO_ZERO_DATE) - return zero_time_stored_return_code_with_warning(); return 0; } From 72429cad7f5448ad680d8df7b55aa055462d5964 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Wed, 28 Dec 2022 23:05:46 +0300 Subject: [PATCH 264/313] MDEV-30046 wrong row targeted with "insert ... on duplicate" and "replace" When HA_DUPLICATE_POS is not supported, the row to replace was navigated by ha_index_read_idx_map, which uses only hash to navigate. Suchwise, given a hash collision it may choose an incorrect row. handler::position would be correct and very convenient to use here. dup_ref is already set by handler independently of the engine capabilities, when an extra lookup is made (for long unique or something else, for example WITHOUT OVERLAPS) such error will be indicated by file->lookup_errkey != -1. --- mysql-test/main/long_unique_bugs.result | 19 +++++++++++++++++++ mysql-test/main/long_unique_bugs.test | 15 +++++++++++++++ sql/handler.cc | 13 ++++++++----- sql/handler.h | 1 + sql/sql_insert.cc | 23 ++++++++++++++++++++--- 5 files changed, 63 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 81482e68417..b01a0dd2256 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -674,6 +674,25 @@ SELECT * FROM t1; a b c 3 2 2 DROP TABLE t1; +# MDEV-30046 wrong row targeted with "insert ... on duplicate" and +# "replace", leading to data corruption +create table t (s blob, n int, unique (s)) engine=innodb; +insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1); +replace into t values ('Hrecvx_0004mm-00',2); +select * from t; +s n +Hrecvx_0004ln-00 1 +Hrecvx_0004mm-00 2 +drop table t; +create table t (s blob, n int, unique (s)) engine=innodb; +insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1); +insert into t values ('Hrecvx_0004mm-00',2) +on duplicate key update n = values (n); +select * from t; +s n +Hrecvx_0004ln-00 1 +Hrecvx_0004mm-00 2 +drop table t; # # End of 10.5 tests # diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 2441dfa59e8..3c2ab4d70f5 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -655,6 +655,21 @@ REPLACE INTO t1 VALUES (3,2,2); SELECT * FROM t1; DROP TABLE t1; +--echo # MDEV-30046 wrong row targeted with "insert ... on duplicate" and +--echo # "replace", leading to data corruption +--source include/have_innodb.inc +create table t (s blob, n int, unique (s)) engine=innodb; +insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1); +replace into t values ('Hrecvx_0004mm-00',2); +select * from t; +drop table t; + +create table t (s blob, n int, unique (s)) engine=innodb; +insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1); +insert into t values ('Hrecvx_0004mm-00',2) + on duplicate key update n = values (n); +select * from t; +drop table t; --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/handler.cc b/sql/handler.cc index 7f5cb343824..e2fe80a260d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4569,6 +4569,12 @@ uint handler::get_dup_key(int error) DBUG_RETURN(errkey); } +bool handler::has_dup_ref() const +{ + DBUG_ASSERT(lookup_errkey != (uint)-1 || errkey != (uint)-1); + return ha_table_flags() & HA_DUPLICATE_POS || lookup_errkey != (uint)-1; +} + /** Delete all files with extension from bas_ext(). @@ -6996,11 +7002,8 @@ exit: if (error == HA_ERR_FOUND_DUPP_KEY) { table->file->lookup_errkey= key_no; - if (ha_table_flags() & HA_DUPLICATE_POS) - { - lookup_handler->position(table->record[0]); - memcpy(table->file->dup_ref, lookup_handler->ref, ref_length); - } + lookup_handler->position(table->record[0]); + memcpy(table->file->dup_ref, lookup_handler->ref, ref_length); } restore_record(table, file->lookup_buffer); table->restore_blob_values(blob_storage); diff --git a/sql/handler.h b/sql/handler.h index 0b0ffe6be27..f858553c7b7 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3464,6 +3464,7 @@ public: virtual void print_error(int error, myf errflag); virtual bool get_error_message(int error, String *buf); uint get_dup_key(int error); + bool has_dup_ref() const; /** Retrieves the names of the table and the key for which there was a duplicate entry in the case of HA_ERR_FOREIGN_DUPLICATE_KEY. diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index b3314e075f0..1e0a6a75338 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1884,11 +1884,28 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, select_result *sink) if (info->handle_duplicates == DUP_REPLACE && table->next_number_field && key_nr == table->s->next_number_index && insert_id_for_cur_row > 0) goto err; - if (table->file->ha_table_flags() & HA_DUPLICATE_POS) + if (table->file->has_dup_ref()) { + /* + If engine doesn't support HA_DUPLICATE_POS, the handler may init to + INDEX, but dup_ref could also be set by lookup_handled (and then, + lookup_errkey is set, f.ex. long unique duplicate). + + In such case, handler would stay uninitialized, so do it here. + */ + bool init_lookup_handler= table->file->lookup_errkey != (uint)-1 && + table->file->inited == handler::NONE; + if (init_lookup_handler && table->file->ha_rnd_init_with_error(false)) + goto err; + DBUG_ASSERT(table->file->inited == handler::RND); - if (table->file->ha_rnd_pos(table->record[1],table->file->dup_ref)) - goto err; + int rnd_pos_err= table->file->ha_rnd_pos(table->record[1], + table->file->dup_ref); + + if (init_lookup_handler) + table->file->ha_rnd_end(); + if (rnd_pos_err) + goto err; } else { From 2a2019e199c5bd9575e1a65369654c39453cdb35 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Sun, 5 May 2024 19:01:22 +0200 Subject: [PATCH 265/313] MDEV-33798: Follow-up patch Don't deadlock kill event groups in other domains if they are not SPECULATE_OPTIMISTIC. Such event groups may not be able to safely roll back and retry (eg. DDL). But do deadlock kill a transaction T2 from a blocked transaction U in another domain, even if T2 has lower sub_id than U. Otherwise, in case of a cycle T2->T1->U->T2, we might not break the cycle if U is not SPECULATE_OPTIMISTIC Signed-off-by: Kristian Nielsen --- sql/sql_class.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index a9203a80c10..7b3c81a381d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -5400,31 +5400,32 @@ thd_rpl_deadlock_check(MYSQL_THD thd, MYSQL_THD other_thd) return 0; if (!rgi->is_parallel_exec) return 0; - if (rgi->rli == other_rgi->rli) + if (rgi->rli == other_rgi->rli && + rgi->current_gtid.domain_id == other_rgi->current_gtid.domain_id) { /* - Within the same master connection, we can compare transaction order on - the GTID sub_id, and rollback the later transaction to allow the earlier - transaction to commit first. + Within the same master connection and domain, we can compare transaction + order on the GTID sub_id, and rollback the later transaction to allow the + earlier transaction to commit first. */ - if (!rgi->gtid_sub_id || !other_rgi->gtid_sub_id) - return 0; - if (rgi->gtid_sub_id > other_rgi->gtid_sub_id) + if (!rgi->gtid_sub_id || !other_rgi->gtid_sub_id || + rgi->gtid_sub_id > other_rgi->gtid_sub_id) return 0; } else { /* - Lock conflicts between different master connection should usually not - occur, but could still happen if user is running some special setup that - tolerates conflicting updates (or in case of user error). We do not have a - pre-defined ordering of transactions in this case, but we still need to - handle conflicts in _some_ way to avoid undetected deadlocks and hangs. + Lock conflicts between different master connections or domains should + usually not occur, but could still happen if user is running some + special setup that tolerates conflicting updates (or in case of user + error). We do not have a pre-defined ordering of transactions in this + case, but we still need to handle conflicts in _some_ way to avoid + undetected deadlocks and hangs. We do this by rolling back and retrying any transaction that is being _optimistically_ applied. This can be overly conservative in some cases, - but should be fine as conflicts between different master connections are - not expected to be common. And it ensures that we won't end up in a + but should be fine as conflicts between different master connections / + domains are not common. And it ensures that we won't end up in a deadlock and hang due to a transaction doing wait_for_prior_commit while holding locks that block something in another master connection. */ From 4b4db4a8e54480eccfed99fd7e3a8223ec03d1d7 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Sat, 4 May 2024 11:02:41 +0200 Subject: [PATCH 266/313] MDEV-34042: Deadlock kill of XA PREPARE can break replication / rpl.rpl_parallel_multi_domain_xa sporadic failure Refinement of the original patch. Move the code to reset the kill up into the parent class Xid_apply_log_event, to also fix the similar issue for XA COMMIT. Increase the number of slave retries in the test case rpl.rpl_parallel_multi_domain_xa to fix some sporadic failures. The test generates massive amounts of conflicting transactions in multiple independent domains, which can cause multiple rollback+retry for a transaction as it conflicts with transactions in other domains one-by-one. Signed-off-by: Kristian Nielsen --- .../rpl/r/rpl_parallel_multi_domain_xa.result | 3 ++ .../rpl/t/rpl_parallel_multi_domain_xa.test | 7 ++++ sql/log_event_server.cc | 36 ++++++++++++------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_parallel_multi_domain_xa.result b/mysql-test/suite/rpl/r/rpl_parallel_multi_domain_xa.result index defab6aef52..1993d09895a 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_multi_domain_xa.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_multi_domain_xa.result @@ -6,6 +6,8 @@ connection master; ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; connection slave; include/stop_slave.inc +SET @old_transaction_retries = @@GLOBAL.slave_transaction_retries; +SET @@global.slave_transaction_retries = 1000; SET @old_parallel_threads = @@GLOBAL.slave_parallel_threads; SET @old_slave_domain_parallel_threads = @@GLOBAL.slave_domain_parallel_threads; SET @@global.slave_parallel_threads = 5; @@ -45,6 +47,7 @@ include/stop_slave.inc SET @@global.slave_parallel_mode = @old_parallel_mode; SET @@global.slave_parallel_threads = @old_parallel_threads; SET @@global.slave_domain_parallel_threads = @old_slave_domain_parallel_threads; +SET @@global.slave_transaction_retries = @old_transaction_retries; include/start_slave.inc connection master; DROP TABLE t1; diff --git a/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test b/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test index da1aaea130f..44b303c77d8 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_multi_domain_xa.test @@ -21,6 +21,12 @@ ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; --connection slave --sync_with_master --source include/stop_slave.inc +# This test runs huge number of transactions independently in parallel that +# all conflict on a single row. This requires a large number of retries, as a +# transaction can repeatedly conflict/deadlock with a large number of other +# transactions (in a different domain) one by one. +SET @old_transaction_retries = @@GLOBAL.slave_transaction_retries; +SET @@global.slave_transaction_retries = 1000; SET @old_parallel_threads = @@GLOBAL.slave_parallel_threads; SET @old_slave_domain_parallel_threads = @@GLOBAL.slave_domain_parallel_threads; SET @@global.slave_parallel_threads = 5; @@ -160,6 +166,7 @@ SET @@global.slave_parallel_mode = 'optimistic'; SET @@global.slave_parallel_mode = @old_parallel_mode; SET @@global.slave_parallel_threads = @old_parallel_threads; SET @@global.slave_domain_parallel_threads = @old_slave_domain_parallel_threads; +SET @@global.slave_transaction_retries = @old_transaction_retries; --source include/start_slave.inc --connection master diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 5b0fbf8ced0..fb5f8bc7cb1 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -4066,6 +4066,9 @@ int Xid_apply_log_event::do_apply_event(rpl_group_info *rgi) thd->wsrep_affected_rows= 0; #endif +#ifndef DBUG_OFF + bool record_gtid_delayed_for_xa= false; +#endif if (rgi->gtid_pending) { sub_id= rgi->gtid_sub_id; @@ -4084,6 +4087,10 @@ int Xid_apply_log_event::do_apply_event(rpl_group_info *rgi) return 1; }); } +#ifndef DBUG_OFF + else + record_gtid_delayed_for_xa= true; +#endif } general_log_print(thd, COM_QUERY, get_query()); @@ -4093,6 +4100,22 @@ int Xid_apply_log_event::do_apply_event(rpl_group_info *rgi) { DBUG_ASSERT(!thd->transaction->xid_state.is_explicit_XA()); + DBUG_ASSERT(record_gtid_delayed_for_xa); + if (thd->rgi_slave->is_parallel_exec) + { + /* + With XA, since the transaction is prepared/committed without updating + the GTID pos (MDEV-32020...), we need here to clear any pending + deadlock kill. + + Otherwise if the kill happened after the prepare/commit completed, it + might end up killing the subsequent GTID position update, causing the + slave to fail with error. + */ + wait_for_pending_deadlock_kill(thd, thd->rgi_slave); + thd->reset_killed(); + } + if ((err= do_record_gtid(thd, rgi, false, &hton, true))) return err; } @@ -4209,19 +4232,6 @@ int XA_prepare_log_event::do_commit() else res= trans_xa_commit(thd); - if (thd->rgi_slave->is_parallel_exec) - { - /* - Since the transaction is prepared/committed without updating the GTID pos - (MDEV-32020...), we need here to clear any pending deadlock kill. - Otherwise if the kill happened after the prepare/commit completed, it - might end up killing the subsequent GTID position update, causing the - slave to fail with error. - */ - wait_for_pending_deadlock_kill(thd, thd->rgi_slave); - thd->reset_killed(); - } - return res; } #endif // HAVE_REPLICATION From cb7c99674ea861b8e4003a8a593fa6f5c6a1dd88 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 5 May 2024 16:54:50 +0200 Subject: [PATCH 267/313] sporadic failure of perfschema.func_file_io --- func_file_io.result +++ func_file_io.reject @@ -134,7 +134,7 @@ Variable_name Value Performance_schema_accounts_lost 0 Performance_schema_cond_classes_lost 0 -Performance_schema_cond_instances_lost 0 +Performance_schema_cond_instances_lost 5 Performance_schema_digest_lost 0 Performance_schema_file_classes_lost 0 Performance_schema_file_handles_lost 0 --- mysql-test/include/default_mysqld.cnf | 2 +- mysql-test/suite/perfschema/r/max_program_zero.result | 2 +- mysql-test/suite/perfschema/r/ortho_iter.result | 2 +- mysql-test/suite/perfschema/r/privilege_table_io.result | 2 +- .../suite/perfschema/r/start_server_disable_idle.result | 2 +- .../suite/perfschema/r/start_server_disable_stages.result | 2 +- .../suite/perfschema/r/start_server_disable_statements.result | 2 +- .../perfschema/r/start_server_disable_transactions.result | 2 +- .../suite/perfschema/r/start_server_disable_waits.result | 2 +- mysql-test/suite/perfschema/r/start_server_innodb.result | 2 +- mysql-test/suite/perfschema/r/start_server_low_index.result | 2 +- .../suite/perfschema/r/start_server_low_table_lock.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_account.result | 2 +- .../suite/perfschema/r/start_server_no_cond_class.result | 2 +- .../suite/perfschema/r/start_server_no_file_class.result | 2 +- .../suite/perfschema/r/start_server_no_file_inst.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_host.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_index.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_mdl.result | 2 +- .../suite/perfschema/r/start_server_no_memory_class.result | 2 +- .../suite/perfschema/r/start_server_no_mutex_class.result | 2 +- .../suite/perfschema/r/start_server_no_mutex_inst.result | 2 +- .../r/start_server_no_prepared_stmts_instances.result | 2 +- .../suite/perfschema/r/start_server_no_rwlock_class.result | 2 +- .../suite/perfschema/r/start_server_no_rwlock_inst.result | 2 +- .../suite/perfschema/r/start_server_no_setup_actors.result | 2 +- .../suite/perfschema/r/start_server_no_setup_objects.result | 2 +- .../suite/perfschema/r/start_server_no_socket_class.result | 2 +- .../suite/perfschema/r/start_server_no_socket_inst.result | 2 +- .../suite/perfschema/r/start_server_no_stage_class.result | 2 +- .../suite/perfschema/r/start_server_no_stages_history.result | 2 +- .../perfschema/r/start_server_no_stages_history_long.result | 2 +- .../suite/perfschema/r/start_server_no_statement_class.result | 2 +- .../perfschema/r/start_server_no_statements_history.result | 2 +- .../r/start_server_no_statements_history_long.result | 2 +- .../suite/perfschema/r/start_server_no_table_hdl.result | 2 +- .../suite/perfschema/r/start_server_no_table_inst.result | 2 +- .../suite/perfschema/r/start_server_no_table_lock.result | 2 +- .../suite/perfschema/r/start_server_no_thread_class.result | 2 +- .../suite/perfschema/r/start_server_no_thread_inst.result | 2 +- .../perfschema/r/start_server_no_transactions_history.result | 2 +- .../r/start_server_no_transactions_history_long.result | 2 +- mysql-test/suite/perfschema/r/start_server_no_user.result | 2 +- .../suite/perfschema/r/start_server_no_waits_history.result | 2 +- .../perfschema/r/start_server_no_waits_history_long.result | 2 +- mysql-test/suite/perfschema/r/start_server_off.result | 2 +- mysql-test/suite/perfschema/r/start_server_on.result | 2 +- mysql-test/suite/perfschema/r/start_server_variables.result | 4 ++-- .../suite/perfschema/r/statement_program_lost_inst.result | 2 +- 49 files changed, 50 insertions(+), 50 deletions(-) diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index 40bf19ac922..1f80cb3910c 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -72,7 +72,7 @@ loose-performance-schema-hosts-size=100 loose-performance-schema-users-size=100 loose-performance-schema-max-mutex-instances=5000 loose-performance-schema-max-rwlock-instances=5000 -loose-performance-schema-max-cond-instances=1000 +loose-performance-schema-max-cond-instances=1500 loose-performance-schema-max-file-instances=10000 loose-performance-schema-max-socket-instances=1000 loose-performance-schema-max-table-instances=500 diff --git a/mysql-test/suite/perfschema/r/max_program_zero.result b/mysql-test/suite/perfschema/r/max_program_zero.result index d2e4526d307..99a63b5f848 100644 --- a/mysql-test/suite/perfschema/r/max_program_zero.result +++ b/mysql-test/suite/perfschema/r/max_program_zero.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/ortho_iter.result b/mysql-test/suite/perfschema/r/ortho_iter.result index 2dacee0ac27..4eee062244a 100644 --- a/mysql-test/suite/perfschema/r/ortho_iter.result +++ b/mysql-test/suite/perfschema/r/ortho_iter.result @@ -237,7 +237,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/privilege_table_io.result b/mysql-test/suite/perfschema/r/privilege_table_io.result index 2b40cdec14b..de9a118f726 100644 --- a/mysql-test/suite/perfschema/r/privilege_table_io.result +++ b/mysql-test/suite/perfschema/r/privilege_table_io.result @@ -39,7 +39,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_idle.result b/mysql-test/suite/perfschema/r/start_server_disable_idle.result index 8b609de4534..acebfc567af 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_idle.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_idle.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_stages.result b/mysql-test/suite/perfschema/r/start_server_disable_stages.result index b31430eada3..a5f3032c58b 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_stages.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_stages.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_statements.result b/mysql-test/suite/perfschema/r/start_server_disable_statements.result index c37509c98ab..c4a21b3e69d 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_statements.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_statements.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_transactions.result b/mysql-test/suite/perfschema/r/start_server_disable_transactions.result index 7fa2125b20e..4e5979f7b37 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_transactions.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_transactions.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_disable_waits.result b/mysql-test/suite/perfschema/r/start_server_disable_waits.result index b6bb1a989ac..7512fc823ff 100644 --- a/mysql-test/suite/perfschema/r/start_server_disable_waits.result +++ b/mysql-test/suite/perfschema/r/start_server_disable_waits.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_innodb.result b/mysql-test/suite/perfschema/r/start_server_innodb.result index 8cad1f4d414..07f11f49e8d 100644 --- a/mysql-test/suite/perfschema/r/start_server_innodb.result +++ b/mysql-test/suite/perfschema/r/start_server_innodb.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_low_index.result b/mysql-test/suite/perfschema/r/start_server_low_index.result index 54441252db2..8bb591704cc 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_index.result +++ b/mysql-test/suite/perfschema/r/start_server_low_index.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_low_table_lock.result b/mysql-test/suite/perfschema/r/start_server_low_table_lock.result index 9164fe18775..65375d3e03f 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_table_lock.result +++ b/mysql-test/suite/perfschema/r/start_server_low_table_lock.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_account.result b/mysql-test/suite/perfschema/r/start_server_no_account.result index 9ec22e633d1..e963ec11355 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_account.result +++ b/mysql-test/suite/perfschema/r/start_server_no_account.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result index e554b1e9aa4..e12c4fa066c 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 0 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_file_class.result b/mysql-test/suite/perfschema/r/start_server_no_file_class.result index f5367f17973..18e88b131c8 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 0 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result index e9db05a1364..1fa0ac8cb1e 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_host.result b/mysql-test/suite/perfschema/r/start_server_no_host.result index 8298ca3a828..c524120d846 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_host.result +++ b/mysql-test/suite/perfschema/r/start_server_no_host.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 0 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_index.result b/mysql-test/suite/perfschema/r/start_server_no_index.result index 50c693e4489..e8fe0ceb637 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_index.result +++ b/mysql-test/suite/perfschema/r/start_server_no_index.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_mdl.result b/mysql-test/suite/perfschema/r/start_server_no_mdl.result index a495471f994..4b2298a94df 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_mdl.result +++ b/mysql-test/suite/perfschema/r/start_server_no_mdl.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_memory_class.result b/mysql-test/suite/perfschema/r/start_server_no_memory_class.result index a598db77dc9..69b8f0d9325 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_memory_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_memory_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result index cc72db98662..20dde61d564 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result index ee1507c8c59..c07e305aad9 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_prepared_stmts_instances.result b/mysql-test/suite/perfschema/r/start_server_no_prepared_stmts_instances.result index 4b779b919df..c9944f81c99 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_prepared_stmts_instances.result +++ b/mysql-test/suite/perfschema/r/start_server_no_prepared_stmts_instances.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result index 4c480f75b3b..048b34b9c41 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result index d0f76f6a8a3..8093234616f 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result index 43e98074842..04f90453d0f 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result +++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result index b8c5e26d6cc..12aa77ff460 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result +++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result index de55a7ff938..55853d6ea39 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result index 57f7a5a3647..d5f8457561a 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_stage_class.result b/mysql-test/suite/perfschema/r/start_server_no_stage_class.result index fdefd3ad1f7..51c8b9a1991 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_stage_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_stage_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result index ac0355c51c6..a99f89671d6 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result +++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result index dd8fc35984e..da165c2b7fe 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result +++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_statement_class.result b/mysql-test/suite/perfschema/r/start_server_no_statement_class.result index 49fdd561ad9..0297ba27546 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_statement_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_statement_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result index 612b305f6e6..b4eb2041253 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result +++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result index 92a654bdab4..f732163b8e2 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result +++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result index b7204361047..8db0883d5b2 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result +++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result index 943e1e92dc2..da235f9bccb 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_lock.result b/mysql-test/suite/perfschema/r/start_server_no_table_lock.result index 4996016b4af..6b83569ee94 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_table_lock.result +++ b/mysql-test/suite/perfschema/r/start_server_no_table_lock.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result index 374d3bb400b..357478b3d6a 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result +++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result index abedd06c0d9..f4ceb286254 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result +++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_transactions_history.result b/mysql-test/suite/perfschema/r/start_server_no_transactions_history.result index 0ce961296bb..3e37684e906 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_transactions_history.result +++ b/mysql-test/suite/perfschema/r/start_server_no_transactions_history.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_transactions_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_transactions_history_long.result index 4b92d21150d..ef8f9402a73 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_transactions_history_long.result +++ b/mysql-test/suite/perfschema/r/start_server_no_transactions_history_long.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_user.result b/mysql-test/suite/perfschema/r/start_server_no_user.result index 2ac41042d03..76dd9bf1379 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_user.result +++ b/mysql-test/suite/perfschema/r/start_server_no_user.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_waits_history.result b/mysql-test/suite/perfschema/r/start_server_no_waits_history.result index 570900fca79..1f66e481be2 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_waits_history.result +++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 0 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result index dbcd2100141..d7df9216869 100644 --- a/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result +++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 0 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_off.result b/mysql-test/suite/perfschema/r/start_server_off.result index f9de9146a13..74fd53fcf4a 100644 --- a/mysql-test/suite/perfschema/r/start_server_off.result +++ b/mysql-test/suite/perfschema/r/start_server_off.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_on.result b/mysql-test/suite/perfschema/r/start_server_on.result index 8cad1f4d414..07f11f49e8d 100644 --- a/mysql-test/suite/perfschema/r/start_server_on.result +++ b/mysql-test/suite/perfschema/r/start_server_on.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/start_server_variables.result b/mysql-test/suite/perfschema/r/start_server_variables.result index f7f44904660..160b648022e 100644 --- a/mysql-test/suite/perfschema/r/start_server_variables.result +++ b/mysql-test/suite/perfschema/r/start_server_variables.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 @@ -164,7 +164,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 diff --git a/mysql-test/suite/perfschema/r/statement_program_lost_inst.result b/mysql-test/suite/perfschema/r/statement_program_lost_inst.result index 264be0ede45..0c599c95516 100644 --- a/mysql-test/suite/perfschema/r/statement_program_lost_inst.result +++ b/mysql-test/suite/perfschema/r/statement_program_lost_inst.result @@ -116,7 +116,7 @@ performance_schema_events_waits_history_long_size 10000 performance_schema_events_waits_history_size 10 performance_schema_hosts_size 100 performance_schema_max_cond_classes 90 -performance_schema_max_cond_instances 1000 +performance_schema_max_cond_instances 1500 performance_schema_max_digest_length 1024 performance_schema_max_file_classes 80 performance_schema_max_file_handles 32768 From cea083af9fc099551a34207dac9206181a1ca899 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 24 Apr 2024 22:08:52 +0200 Subject: [PATCH 268/313] cleanup: use THD_STAGE_INFO, not thd_proc_info and put master-slave.inc *last* in the series of includes --- mysql-test/suite/rpl/t/rpl_parallel_sbm.test | 2 +- sql/rpl_rli.cc | 2 -- sql/rpl_rli.h | 7 +------ sql/slave.cc | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test index 9c502ff6cb9..3bf39b47f69 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test @@ -1,9 +1,9 @@ # # Ensure that Seconds_Behind_Master works correctly on the parallel replica. # ---source include/master-slave.inc --source include/have_log_bin.inc --source include/have_debug.inc +--source include/master-slave.inc --echo # --echo # MDEV-29639: Seconds_Behind_Master is incorrect for Delayed, Parallel Replicas diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 4352cdcf494..efcbd29ef39 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -44,8 +44,6 @@ rpl_slave_state *rpl_global_gtid_slave_state; /* Object used for MASTER_GTID_WAIT(). */ gtid_waiting rpl_global_gtid_waiting; -const char *const Relay_log_info::state_delaying_string = "Waiting until MASTER_DELAY seconds after master executed event"; - Relay_log_info::Relay_log_info(bool is_slave_recovery, const char* thread_name) :Slave_reporting_capability(thread_name), replicate_same_server_id(::replicate_same_server_id), diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 46eacf3411a..ec93f76432b 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -506,11 +506,6 @@ public: m_flags&= ~flag; } - /** - Text used in THD::proc_info when the slave SQL thread is delaying. - */ - static const char *const state_delaying_string; - bool flush(); /** @@ -533,7 +528,7 @@ public: { mysql_mutex_assert_owner(&data_lock); sql_delay_end= delay_end; - thd_proc_info(sql_driver_thd, state_delaying_string); + THD_STAGE_INFO(sql_driver_thd, stage_sql_thd_waiting_until_delay); } int32 get_sql_delay() { return sql_delay; } diff --git a/sql/slave.cc b/sql/slave.cc index 5948d11825d..66b42cabcd4 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3324,7 +3324,7 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, // to ensure that we use the same value throughout this function. const char *slave_sql_running_state= mi->rli.sql_driver_thd ? mi->rli.sql_driver_thd->proc_info : ""; - if (slave_sql_running_state == Relay_log_info::state_delaying_string) + if (slave_sql_running_state == stage_sql_thd_waiting_until_delay.m_name) { time_t t= my_time(0), sql_delay_end= mi->rli.get_sql_delay_end(); protocol->store((uint32)(t < sql_delay_end ? sql_delay_end - t : 0)); From 7a789e2027778ef1a5f0657b29181aa1f6cfdc87 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 25 Apr 2024 12:47:23 +0200 Subject: [PATCH 269/313] sporadic failures of rpl.rpl_parallel_sbm the test waits for the event to get stuck on MASTER_DELAY, but on a slow/overloaded slave the event might pass MASTER_DELAY before the test starts waiting. Wait for the event to get stuck on the LOCK TABLES (after MASTER_DELAY), the event cannot avoid that, --- mysql-test/suite/rpl/r/rpl_parallel_sbm.result | 2 +- mysql-test/suite/rpl/t/rpl_parallel_sbm.test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_parallel_sbm.result b/mysql-test/suite/rpl/r/rpl_parallel_sbm.result index e349353ac59..75012c93f3b 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_sbm.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_sbm.result @@ -34,7 +34,7 @@ connection server_2; LOCK TABLES t1 WRITE; include/start_slave.inc connection slave; -# Waiting for replica to resume the delay for the transaction +# Waiting for replica to get blocked by the table lock # Sleeping 1s to increment SBM # Ensuring Seconds_Behind_Master increases after sleeping.. # ..done diff --git a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test index 3bf39b47f69..90753caf143 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test @@ -77,8 +77,8 @@ LOCK TABLES t1 WRITE; --source include/start_slave.inc --connection slave ---echo # Waiting for replica to resume the delay for the transaction ---let $wait_condition= SELECT count(*) FROM information_schema.processlist WHERE state LIKE 'Waiting until MASTER_DELAY seconds after master executed event'; +--echo # Waiting for replica to get blocked by the table lock +--let $wait_condition= SELECT count(*) FROM information_schema.processlist WHERE state LIKE 'Waiting for table metadata lock'; --source include/wait_condition.inc --echo # Sleeping 1s to increment SBM From 03295f0c20ddf49c655ebe4684f8db4b448896e8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 5 May 2024 17:13:20 +0200 Subject: [PATCH 270/313] MDEV-30727 Check spider_hton_ptr in spider udfs UDF isn't supposed to use my_error(), it should return the error message in the provided error message buffer Fixes valgrind: ==93993== Conditional jump or move depends on uninitialised value(s) ==93993== at 0x484ECCD: strnlen (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==93993== by 0x1AD2B2C: process_str_arg (my_vsnprintf.c:259) ==93993== by 0x1AD47E0: my_vsnprintf_ex (my_vsnprintf.c:696) ==93993== by 0x1A3B91E: my_error (my_error.c:120) ==93993== by 0xF87BE8: udf_handler::fix_fields(THD*, Item_func_or_sum*, unsigned int, Item**) (item_func.cc:3638) followup for 267dd5a993d5 --- storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result | 6 +++--- storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test | 6 +++--- storage/spider/spd_copy_tables.cc | 5 +---- storage/spider/spd_direct_sql.cc | 5 +---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result index ce8ebdc3966..79a383feb83 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_30727.result @@ -1,12 +1,12 @@ CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); -ERROR HY000: Plugin 'SPIDER' is not loaded +ERROR HY000: Can't initialize function 'spider_direct_sql'; Plugin 'SPIDER' is not loaded CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); -ERROR HY000: Plugin 'SPIDER' is not loaded +ERROR HY000: Can't initialize function 'spider_bg_direct_sql'; Plugin 'SPIDER' is not loaded CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; SELECT spider_copy_tables ('t', '0', '0'); -ERROR HY000: Plugin 'SPIDER' is not loaded +ERROR HY000: Can't initialize function 'spider_copy_tables'; Plugin 'SPIDER' is not loaded CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; SELECT spider_flush_table_mon_cache (); spider_flush_table_mon_cache () diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test index e1d917e7147..ebd08edce24 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test @@ -1,13 +1,13 @@ CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; ---error ER_PLUGIN_IS_NOT_LOADED +--error ER_CANT_INITIALIZE_UDF SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; ---error ER_PLUGIN_IS_NOT_LOADED +--error ER_CANT_INITIALIZE_UDF SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; ---error ER_PLUGIN_IS_NOT_LOADED +--error ER_CANT_INITIALIZE_UDF SELECT spider_copy_tables ('t', '0', '0'); # spider_flush_table_mon_cache does not require spider init to function diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index 1783fe7374b..524ad7dd9e9 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -1154,9 +1154,6 @@ error: DBUG_RETURN(0); } -#undef my_error -extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...); - my_bool spider_copy_tables_init_body( UDF_INIT *initid, UDF_ARGS *args, @@ -1165,7 +1162,7 @@ my_bool spider_copy_tables_init_body( DBUG_ENTER("spider_copy_tables_init_body"); if (!spider_hton_ptr) { - my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER"); + strcpy(message, "Plugin 'SPIDER' is not loaded"); goto error; } if (args->arg_count != 3 && args->arg_count != 4) diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 4f6bc0a4405..524e8b7443a 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -1789,9 +1789,6 @@ error: DBUG_RETURN(0); } -#undef my_error -extern "C" void my_error(unsigned int nr, unsigned long MyFlags, ...); - my_bool spider_direct_sql_init_body( UDF_INIT *initid, UDF_ARGS *args, @@ -1802,7 +1799,7 @@ my_bool spider_direct_sql_init_body( DBUG_ENTER("spider_direct_sql_init_body"); if (!spider_hton_ptr) { - my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "SPIDER"); + strcpy(message, "Plugin 'SPIDER' is not loaded"); goto error; } if (args->arg_count != 3) From d74fee9e8c9542ee884bb14e5bee98a75c226bbb Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 5 May 2024 17:02:09 +0200 Subject: [PATCH 271/313] MDEV-19487 fix for --view followup for d7df63e1c922 --- mysql-test/main/func_json.result | 4 ++-- mysql-test/main/func_json.test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 8d90a6ec726..591e8813a0f 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1705,8 +1705,8 @@ DROP TABLE t; # # MDEV-19487: JSON_TYPE doesnt detect the type of String Values (returns NULL) and for Date/DateTime returns "INTEGER" # -SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')); -JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')) +SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')) as x; +x NULL Warnings: Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 5 diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 1b55dcb149e..9f08c30f7cf 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1137,7 +1137,7 @@ DROP TABLE t; --echo # MDEV-19487: JSON_TYPE doesnt detect the type of String Values (returns NULL) and for Date/DateTime returns "INTEGER" --echo # -SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')); +SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')) as x; --echo # From df6899b30bc12d5b3c1e0a11cef64c57fc196eda Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 3 May 2024 16:21:41 +0200 Subject: [PATCH 272/313] bugfix: mysqld --safe-mode crashes --- mysql-test/suite/parts/t/partition_recover_myisam-master.opt | 2 +- sql/mysqld.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/parts/t/partition_recover_myisam-master.opt b/mysql-test/suite/parts/t/partition_recover_myisam-master.opt index ddbd7a0a8c5..ca3d0cddc18 100644 --- a/mysql-test/suite/parts/t/partition_recover_myisam-master.opt +++ b/mysql-test/suite/parts/t/partition_recover_myisam-master.opt @@ -1 +1 @@ ---myisam-recover-options +--safe-mode diff --git a/sql/mysqld.cc b/sql/mysqld.cc index be75dd9fc66..9a17a002cc8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8241,7 +8241,7 @@ mysqld_get_one_option(const struct my_option *opt, const char *argument, case (int) OPT_SAFE: opt_specialflag|= SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC; SYSVAR_AUTOSIZE(delay_key_write_options, (uint) DELAY_KEY_WRITE_NONE); - SYSVAR_AUTOSIZE(myisam_recover_options, HA_RECOVER_DEFAULT); + myisam_recover_options= HA_RECOVER_DEFAULT; ha_open_options&= ~(HA_OPEN_DELAY_KEY_WRITE); #ifdef HAVE_QUERY_CACHE SYSVAR_AUTOSIZE(query_cache_size, 0); From 349ca2be7437ccc45a565edd954d7b2f78f519d8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 29 Apr 2024 15:59:13 +0200 Subject: [PATCH 273/313] mtr: remove innodb combinations dead code for about 10 years --- mysql-test/include/have_innodb.combinations | 39 ------------------- mysql-test/include/have_innodb.opt | 17 ++++++++ ...rdiff => innodb_ext_key,covering,on.rdiff} | 0 ...ff => innodb_ext_key,on,unoptimized.rdiff} | 0 mysql-test/suite.pm | 9 +---- .../include/innodb_merge_threshold_delete.inc | 3 -- .../innodb_merge_threshold_secondary.inc | 3 -- .../include/innodb_merge_threshold_update.inc | 3 -- ...diff => max_record_size,16k,compact.rdiff} | 0 ...diff => max_record_size,16k,dynamic.rdiff} | 0 ...ff => max_record_size,16k,redundant.rdiff} | 0 ...diff => max_record_size,32k,compact.rdiff} | 0 ...diff => max_record_size,32k,dynamic.rdiff} | 0 ...ff => max_record_size,32k,redundant.rdiff} | 0 ...rdiff => max_record_size,4k,compact.rdiff} | 0 ...rdiff => max_record_size,4k,dynamic.rdiff} | 0 ...iff => max_record_size,4k,redundant.rdiff} | 0 ...diff => max_record_size,64k,compact.rdiff} | 0 ...diff => max_record_size,64k,dynamic.rdiff} | 0 ...ff => max_record_size,64k,redundant.rdiff} | 0 ...rdiff => max_record_size,8k,compact.rdiff} | 0 ...rdiff => max_record_size,8k,dynamic.rdiff} | 0 ...art,16k,innodb.rdiff => restart,16k.rdiff} | 0 ...art,32k,innodb.rdiff => restart,32k.rdiff} | 0 ...start,4k,innodb.rdiff => restart,4k.rdiff} | 0 ...art,64k,innodb.rdiff => restart,64k.rdiff} | 0 ...start,8k,innodb.rdiff => restart,8k.rdiff} | 0 .../suite/innodb/t/index_merge_threshold.test | 1 + 28 files changed, 19 insertions(+), 56 deletions(-) delete mode 100644 mysql-test/include/have_innodb.combinations create mode 100644 mysql-test/include/have_innodb.opt rename mysql-test/main/{innodb_ext_key,covering,innodb,on.rdiff => innodb_ext_key,covering,on.rdiff} (100%) rename mysql-test/main/{innodb_ext_key,innodb,on,unoptimized.rdiff => innodb_ext_key,on,unoptimized.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,16k,compact,innodb.rdiff => max_record_size,16k,compact.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,16k,dynamic,innodb.rdiff => max_record_size,16k,dynamic.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,16k,innodb,redundant.rdiff => max_record_size,16k,redundant.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,32k,compact,innodb.rdiff => max_record_size,32k,compact.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,32k,dynamic,innodb.rdiff => max_record_size,32k,dynamic.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,32k,innodb,redundant.rdiff => max_record_size,32k,redundant.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,4k,compact,innodb.rdiff => max_record_size,4k,compact.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,4k,dynamic,innodb.rdiff => max_record_size,4k,dynamic.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,4k,innodb,redundant.rdiff => max_record_size,4k,redundant.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,64k,compact,innodb.rdiff => max_record_size,64k,compact.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,64k,dynamic,innodb.rdiff => max_record_size,64k,dynamic.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,64k,innodb,redundant.rdiff => max_record_size,64k,redundant.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,8k,compact,innodb.rdiff => max_record_size,8k,compact.rdiff} (100%) rename mysql-test/suite/innodb/r/{max_record_size,8k,dynamic,innodb.rdiff => max_record_size,8k,dynamic.rdiff} (100%) rename mysql-test/suite/innodb/r/{restart,16k,innodb.rdiff => restart,16k.rdiff} (100%) rename mysql-test/suite/innodb/r/{restart,32k,innodb.rdiff => restart,32k.rdiff} (100%) rename mysql-test/suite/innodb/r/{restart,4k,innodb.rdiff => restart,4k.rdiff} (100%) rename mysql-test/suite/innodb/r/{restart,64k,innodb.rdiff => restart,64k.rdiff} (100%) rename mysql-test/suite/innodb/r/{restart,8k,innodb.rdiff => restart,8k.rdiff} (100%) diff --git a/mysql-test/include/have_innodb.combinations b/mysql-test/include/have_innodb.combinations deleted file mode 100644 index f1131c448f3..00000000000 --- a/mysql-test/include/have_innodb.combinations +++ /dev/null @@ -1,39 +0,0 @@ -[innodb_plugin] -ignore-builtin-innodb -plugin-load-add=$HA_INNODB_SO -innodb -innodb-cmpmem -innodb-cmp-per-index -innodb-trx -innodb-locks -innodb-lock-waits -innodb-buffer-pool-stats -innodb-buffer-page -innodb-buffer-page-lru -innodb-sys-columns -innodb-sys-fields -innodb-sys-foreign -innodb-sys-foreign-cols -innodb-sys-indexes -innodb-sys-tables -innodb-sys-virtual -innodb-metrics - -[innodb] -innodb -innodb-cmpmem -innodb-cmp-per-index -innodb-trx -innodb-locks -innodb-lock-waits -innodb-metrics -innodb-buffer-pool-stats -innodb-buffer-page -innodb-buffer-page-lru -innodb-sys-columns -innodb-sys-fields -innodb-sys-foreign -innodb-sys-foreign-cols -innodb-sys-indexes -innodb-sys-tables -innodb-sys-virtual diff --git a/mysql-test/include/have_innodb.opt b/mysql-test/include/have_innodb.opt new file mode 100644 index 00000000000..0a6d4d9c819 --- /dev/null +++ b/mysql-test/include/have_innodb.opt @@ -0,0 +1,17 @@ +--innodb +--innodb-cmpmem +--innodb-cmp-per-index +--innodb-trx +--innodb-locks +--innodb-lock-waits +--innodb-metrics +--innodb-buffer-pool-stats +--innodb-buffer-page +--innodb-buffer-page-lru +--innodb-sys-columns +--innodb-sys-fields +--innodb-sys-foreign +--innodb-sys-foreign-cols +--innodb-sys-indexes +--innodb-sys-tables +--innodb-sys-virtual diff --git a/mysql-test/main/innodb_ext_key,covering,innodb,on.rdiff b/mysql-test/main/innodb_ext_key,covering,on.rdiff similarity index 100% rename from mysql-test/main/innodb_ext_key,covering,innodb,on.rdiff rename to mysql-test/main/innodb_ext_key,covering,on.rdiff diff --git a/mysql-test/main/innodb_ext_key,innodb,on,unoptimized.rdiff b/mysql-test/main/innodb_ext_key,on,unoptimized.rdiff similarity index 100% rename from mysql-test/main/innodb_ext_key,innodb,on,unoptimized.rdiff rename to mysql-test/main/innodb_ext_key,on,unoptimized.rdiff diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index 5100b4137a2..d5c4855ce6e 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -4,14 +4,7 @@ use My::Platform; @ISA = qw(My::Suite); sub skip_combinations { - my @combinations; - - # disable innodb combinations for configurations that were not built - push @combinations, 'innodb_plugin' unless $ENV{HA_INNODB_SO}; - - push @combinations, 'innodb' unless $::mysqld_variables{'innodb'} eq "ON"; - - my %skip = ( 'include/have_innodb.combinations' => [ @combinations ]); + my %skip; $skip{'include/innodb_encrypt_log.combinations'} = [ 'crypt' ] unless $ENV{DEBUG_KEY_MANAGEMENT_SO}; diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc index 8c60cd6e230..7d7188aa463 100644 --- a/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc +++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_delete.inc @@ -5,9 +5,6 @@ # "create table tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;" # ---source include/have_innodb.inc ---source include/have_innodb_16k.inc - # turn on flags --disable_query_log SET GLOBAL innodb_monitor_enable=index_page_merge_attempts; diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc index 8e821365e3f..1d3aca87af6 100644 --- a/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc +++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_secondary.inc @@ -6,9 +6,6 @@ # "create index index1 on tab1(b(750));" # ---source include/have_innodb.inc ---source include/have_innodb_16k.inc - # turn on flags --disable_query_log SET GLOBAL innodb_monitor_enable=index_page_merge_attempts; diff --git a/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc b/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc index 61e961ac6ae..f91a796d161 100644 --- a/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc +++ b/mysql-test/suite/innodb/include/innodb_merge_threshold_update.inc @@ -5,9 +5,6 @@ # "create table tab1 (a bigint primary key, b varchar(2048)) engine=InnoDB;" # ---source include/have_innodb.inc ---source include/have_innodb_16k.inc - # turn on flags --disable_query_log SET GLOBAL innodb_monitor_enable=index_page_merge_attempts; diff --git a/mysql-test/suite/innodb/r/max_record_size,16k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,16k,compact.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,16k,compact,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,16k,compact.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,16k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,16k,dynamic.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,16k,dynamic,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,16k,dynamic.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,16k,innodb,redundant.rdiff b/mysql-test/suite/innodb/r/max_record_size,16k,redundant.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,16k,innodb,redundant.rdiff rename to mysql-test/suite/innodb/r/max_record_size,16k,redundant.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,32k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,32k,compact.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,32k,compact,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,32k,compact.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,32k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,32k,dynamic.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,32k,dynamic,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,32k,dynamic.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,32k,innodb,redundant.rdiff b/mysql-test/suite/innodb/r/max_record_size,32k,redundant.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,32k,innodb,redundant.rdiff rename to mysql-test/suite/innodb/r/max_record_size,32k,redundant.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,4k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,4k,compact.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,4k,compact,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,4k,compact.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,4k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,4k,dynamic.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,4k,dynamic,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,4k,dynamic.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,4k,innodb,redundant.rdiff b/mysql-test/suite/innodb/r/max_record_size,4k,redundant.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,4k,innodb,redundant.rdiff rename to mysql-test/suite/innodb/r/max_record_size,4k,redundant.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,64k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,64k,compact.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,64k,compact,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,64k,compact.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,64k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,64k,dynamic.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,64k,dynamic,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,64k,dynamic.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,64k,innodb,redundant.rdiff b/mysql-test/suite/innodb/r/max_record_size,64k,redundant.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,64k,innodb,redundant.rdiff rename to mysql-test/suite/innodb/r/max_record_size,64k,redundant.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,8k,compact,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,8k,compact.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,8k,compact,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,8k,compact.rdiff diff --git a/mysql-test/suite/innodb/r/max_record_size,8k,dynamic,innodb.rdiff b/mysql-test/suite/innodb/r/max_record_size,8k,dynamic.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/max_record_size,8k,dynamic,innodb.rdiff rename to mysql-test/suite/innodb/r/max_record_size,8k,dynamic.rdiff diff --git a/mysql-test/suite/innodb/r/restart,16k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,16k.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/restart,16k,innodb.rdiff rename to mysql-test/suite/innodb/r/restart,16k.rdiff diff --git a/mysql-test/suite/innodb/r/restart,32k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,32k.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/restart,32k,innodb.rdiff rename to mysql-test/suite/innodb/r/restart,32k.rdiff diff --git a/mysql-test/suite/innodb/r/restart,4k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,4k.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/restart,4k,innodb.rdiff rename to mysql-test/suite/innodb/r/restart,4k.rdiff diff --git a/mysql-test/suite/innodb/r/restart,64k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,64k.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/restart,64k,innodb.rdiff rename to mysql-test/suite/innodb/r/restart,64k.rdiff diff --git a/mysql-test/suite/innodb/r/restart,8k,innodb.rdiff b/mysql-test/suite/innodb/r/restart,8k.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/restart,8k,innodb.rdiff rename to mysql-test/suite/innodb/r/restart,8k.rdiff diff --git a/mysql-test/suite/innodb/t/index_merge_threshold.test b/mysql-test/suite/innodb/t/index_merge_threshold.test index a587e10db6c..23ad81f79a9 100644 --- a/mysql-test/suite/innodb/t/index_merge_threshold.test +++ b/mysql-test/suite/innodb/t/index_merge_threshold.test @@ -10,6 +10,7 @@ # # Check actual behavior for table, partitioned table and temporary table # ############################################################# +--source include/have_innodb.inc --source include/have_innodb_16k.inc --source include/have_partition.inc From 983e6ca0974805ba655fe4305dcfb4512d738494 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 4 May 2024 21:02:53 +0200 Subject: [PATCH 274/313] bugfix: buffer overwrite in mariadb-backup this fixes galera.galera_sst_mariabackup_table_options Note that `man snprintf` says The functions snprintf() and vsnprintf() do not write more than size bytes (including the terminating null byte ('\0')). If the output was truncated due to this limit, then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available. --- extra/mariabackup/backup_mysql.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 862f8b46a3a..1c425626f8f 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -66,7 +66,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA #include "page0zip.h" char *tool_name; -char tool_args[2048]; +char tool_args[8192]; /* mysql flavor and version */ mysql_flavor_t server_flavor = FLAVOR_UNKNOWN; @@ -1937,9 +1937,11 @@ char *make_argv(char *buf, size_t len, int argc, char **argv) if (strncmp(*argv, "--password", strlen("--password")) == 0) { arg = "--password=..."; } - left-= snprintf(buf + len - left, left, + uint l= snprintf(buf + len - left, left, "%s%c", arg, argc > 1 ? ' ' : 0); ++argv; --argc; + if (l < left) + left-= l; } return buf; From cd0356a764d5cad5bb64479adb1a646283314f3c Mon Sep 17 00:00:00 2001 From: Monty Date: Sat, 27 Apr 2024 13:35:48 +0300 Subject: [PATCH 275/313] MDEV-34077 scripts/mariadb-install-db: Error in my_thread_global_end(): 1 threads didn't exit followup for 952ab9a5965 chery-pick of 814dc46748d8 into 10.5 --- include/my_sys.h | 2 +- mysys/my_thr_init.c | 8 +++++--- sql/mysqld.cc | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 170794522e7..74231be6746 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -147,7 +147,7 @@ char *guess_malloc_library(); void sf_report_leaked_memory(my_thread_id id); int sf_sanity(); extern my_thread_id (*sf_malloc_dbug_id)(void); -#define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X) +#define SAFEMALLOC_REPORT_MEMORY(X) if (!sf_leaking_memory) sf_report_leaked_memory(X) #else #define SAFEMALLOC_REPORT_MEMORY(X) do {} while(0) #endif diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index d9f0e41de8d..a10957bdbb0 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -220,7 +220,11 @@ void my_thread_global_end(void) fprintf(stderr, "Error in my_thread_global_end(): %d threads didn't exit\n", THR_thread_count); -#endif +#endif /* HAVE_PTHREAD_KILL */ +#ifdef SAFEMALLOC + /* We know we will have memoryleaks, suppress the leak report */ + sf_leaking_memory= 1; +#endif /* SAFEMALLOC */ all_threads_killed= 0; break; } @@ -234,9 +238,7 @@ void my_thread_global_end(void) that could use them. */ if (all_threads_killed) - { my_thread_destroy_internal_mutex(); - } my_thread_global_init_done= 0; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9a17a002cc8..93afee25dcf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1927,6 +1927,7 @@ extern "C" void unireg_abort(int exit_code) wsrep_sst_auth_free(); #endif // WITH_WSREP + wait_for_signal_thread_to_end(); clean_up(!opt_abort && (exit_code || !opt_bootstrap)); /* purecov: inspected */ DBUG_PRINT("quit",("done with cleanup in unireg_abort")); mysqld_exit(exit_code); From 91fb8b7fd3224767fe7eb81e82f5ec0926751420 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 29 Apr 2024 22:41:07 +0200 Subject: [PATCH 276/313] MDEV-19949 mariabackup option of '--password' or '-p' without specifying password in commandline password handling as in other command-line tools --- extra/mariabackup/xtrabackup.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index fcea942cd3e..90ccd693347 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -370,6 +370,7 @@ my_bool opt_no_backup_locks = FALSE; my_bool opt_decompress = FALSE; my_bool opt_remove_original; my_bool opt_log_innodb_page_corruption; +my_bool tty_password= FALSE; my_bool opt_lock_ddl_per_table = FALSE; static my_bool opt_check_privileges; @@ -1367,7 +1368,7 @@ struct my_option xb_client_options[]= { "This option specifies the password to use " "when connecting to the database. It accepts a string argument. " "See mysql --help for details.", - 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, @@ -2043,6 +2044,7 @@ xb_get_one_option(const struct my_option *opt, break; case 'p': opt_password = argument; + tty_password = argument == NULL; break; case OPT_PROTOCOL: if (argument) @@ -6749,6 +6751,8 @@ void handle_options(int argc, char **argv, char ***argv_server, if (*start) start[1]= 0; } + else if (tty_password) + opt_password= my_get_tty_password(NullS); /* 4) Process --mysqld-args options, ignore unknown options */ From 947eeaa6dc780c55e5cb731a83a02f2e34107499 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 2 May 2024 09:55:59 +0200 Subject: [PATCH 277/313] MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key use collation-sensitive comparison when comparing fields --- mysql-test/main/long_unique_bugs.result | 24 +++++++++++++++++++++++- mysql-test/main/long_unique_bugs.test | 17 ++++++++++++++++- sql/handler.cc | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index b01a0dd2256..afa14310153 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -694,5 +694,27 @@ Hrecvx_0004ln-00 1 Hrecvx_0004mm-00 2 drop table t; # -# End of 10.5 tests +# MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key # +create table t1 (a int, b text, unique (b)); +insert ignore t1 values (1, 'a'), (2, 'A'); +Warnings: +Warning 1062 Duplicate entry 'A' for key 'b' +select * from t1; +a b +1 a +update t1 set b='A' where a=1; +select * from t1; +a b +1 A +drop table t1; +create table t1 (a int, b blob, unique (b)); +insert t1 values (1, 'a'), (2, 'A'); +select * from t1; +a b +1 a +2 A +update t1 set b='A' where a=1; +ERROR 23000: Duplicate entry 'A' for key 'b' +drop table t1; +# End of 10.5 tests diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 3c2ab4d70f5..e7f8825ab97 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -671,5 +671,20 @@ insert into t values ('Hrecvx_0004mm-00',2) select * from t; drop table t; --echo # ---echo # End of 10.5 tests +--echo # MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key --echo # +create table t1 (a int, b text, unique (b)); +insert ignore t1 values (1, 'a'), (2, 'A'); +select * from t1; +update t1 set b='A' where a=1; +select * from t1; +drop table t1; + +create table t1 (a int, b blob, unique (b)); +insert t1 values (1, 'a'), (2, 'A'); +select * from t1; +--error ER_DUP_ENTRY +update t1 set b='A' where a=1; +drop table t1; + +--echo # End of 10.5 tests diff --git a/sql/handler.cc b/sql/handler.cc index e2fe80a260d..93baef92267 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7082,7 +7082,7 @@ int handler::check_duplicate_long_entries_update(const uchar *new_rec) So also check for that too */ if((field->is_null(0) != field->is_null(reclength)) || - field->cmp_binary_offset(reclength)) + field->cmp_offset(reclength)) { if((error= check_duplicate_long_entry_key(new_rec, i))) return error; From 4f5dea43df22dbf6dffb6694aa0fe23a6da98983 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 26 Apr 2024 16:27:29 +0200 Subject: [PATCH 278/313] cleanup * remove dead code * simplify the check for table->s->next_number_index * misc --- mysql-test/main/information_schema2.result | 7 + mysql-test/main/information_schema2.test | 14 +- mysql-test/main/innodb_ext_key,off.rdiff | 6 +- mysql-test/main/innodb_ext_key.result | 28 +- mysql-test/main/innodb_ext_key.test | 28 +- mysql-test/main/long_unique_bugs.test | 2 - mysql-test/main/myisam.result | 2 - mysql-test/main/myisam.test | 6 - mysql-test/main/trigger.result | 6 - mysql-test/main/trigger.test | 9 - .../suite/galera/r/galera_load_data.result | 303 ++++++++++++++++- .../suite/galera/t/galera_load_data.test | 304 +++++++++++++++++- mysql-test/suite/parts/r/alter_table.result | 11 + .../parts/r/partition_recover_myisam.result | 3 + mysql-test/suite/parts/t/alter_table.test | 24 +- ...aster.opt => partition_recover_myisam.opt} | 0 .../parts/t/partition_recover_myisam.test | 8 - sql/handler.cc | 6 +- sql/sql_insert.cc | 2 +- sql/table.cc | 4 +- storage/myisam/mi_extra.c | 45 --- 21 files changed, 683 insertions(+), 135 deletions(-) rename mysql-test/suite/parts/t/{partition_recover_myisam-master.opt => partition_recover_myisam.opt} (100%) diff --git a/mysql-test/main/information_schema2.result b/mysql-test/main/information_schema2.result index e23e81b885c..75217cf58bd 100644 --- a/mysql-test/main/information_schema2.result +++ b/mysql-test/main/information_schema2.result @@ -1,3 +1,6 @@ +# +# MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling +# select variable_name from information_schema.session_status where variable_name = (select variable_name from information_schema.session_status where variable_name = 'uptime'); variable_name @@ -6,6 +9,9 @@ select variable_name from information_schema.session_variables where variable_na (select variable_name from information_schema.session_variables where variable_name = 'basedir'); variable_name BASEDIR +# +# MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows +# create table t1 (x int); create table t2 (x int); create table t3 (x int); @@ -18,3 +24,4 @@ t2 t3 t4 drop table t1, t2, t3, t4; +# End of 5.5 tests diff --git a/mysql-test/main/information_schema2.test b/mysql-test/main/information_schema2.test index d2fa3da2b5f..bd9350a3031 100644 --- a/mysql-test/main/information_schema2.test +++ b/mysql-test/main/information_schema2.test @@ -1,15 +1,15 @@ -# -# MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling -# +--echo # +--echo # MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling +--echo # select variable_name from information_schema.session_status where variable_name = (select variable_name from information_schema.session_status where variable_name = 'uptime'); select variable_name from information_schema.session_variables where variable_name = (select variable_name from information_schema.session_variables where variable_name = 'basedir'); -# -# MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows -# +--echo # +--echo # MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows +--echo # create table t1 (x int); create table t2 (x int); create table t3 (x int); @@ -17,3 +17,5 @@ create table t4 AS select table_name from information_schema.TABLES where table_ delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE'); select * from t4 order by table_name; drop table t1, t2, t3, t4; + +--echo # End of 5.5 tests diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff index 8061d87990b..0eb123fcfcf 100644 --- a/mysql-test/main/innodb_ext_key,off.rdiff +++ b/mysql-test/main/innodb_ext_key,off.rdiff @@ -163,7 +163,7 @@ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000 @@ -220,12 +220,12 @@ 5959 3 - show status like 'handler_read_next'; + show /*a*/ status like 'handler_read_next'; Variable_name Value -Handler_read_next 3 +Handler_read_next 9 @@ -177,7 +177,7 @@ select max(l_orderkey) from lineitem where l_partkey between 1 and 10 group by l_partkey; @@ -243,9 +243,9 @@ - show status like 'handler_read%'; + show /*b*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 -Handler_read_key 21 @@ -199,7 +199,7 @@ select max(l_orderkey) from lineitem where l_suppkey in (1,4) group by l_suppkey; @@ -265,9 +265,9 @@ - show status like 'handler_read%'; + show /*c*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 -Handler_read_key 6 diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index 6d5c1885110..f436b554fb8 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -14,7 +14,7 @@ flush status; select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01'; count(*) 1 -show status like 'handler_read%'; +show /*1*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 1 @@ -35,7 +35,7 @@ select count(*) from lineitem use index(primary) where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01'; count(*) 1 -show status like 'handler_read%'; +show /*2*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 1 @@ -56,7 +56,7 @@ select count(*) from lineitem where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000; count(*) 1 -show status like 'handler_read%'; +show /*3*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 1 @@ -79,7 +79,7 @@ l_orderkey l_linenumber 1088 3 1217 1 1221 3 -show status like 'handler_read%'; +show /*4*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 1 @@ -98,7 +98,7 @@ flush status; select min(l_orderkey) from lineitem where l_shipdate='1992-07-01'; min(l_orderkey) 130 -show status like 'handler_read%'; +show /*5*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 1 @@ -119,7 +119,7 @@ select min(l_orderkey) from lineitem where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000; min(l_orderkey) 1088 -show status like 'handler_read%'; +show /*6*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 1 @@ -140,7 +140,7 @@ select max(l_linenumber) from lineitem where l_shipdate='1992-07-01' and l_orderkey=130; max(l_linenumber) 2 -show status like 'handler_read%'; +show /*7*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 1 @@ -166,7 +166,7 @@ or l_receiptdate='1992-07-01' and l_orderkey=5603; l_orderkey l_linenumber 130 2 5603 2 -show status like 'handler_read%'; +show /*8*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 2 @@ -193,7 +193,7 @@ l_orderkey l_linenumber 130 2 5603 2 5959 3 -show status like 'handler_read%'; +show /*9*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 2 @@ -218,7 +218,7 @@ l_orderkey l_linenumber 130 2 5603 2 5959 3 -show status like 'handler_read_next'; +show /*a*/ status like 'handler_read_next'; Variable_name Value Handler_read_next 3 explain @@ -240,7 +240,7 @@ max(l_orderkey) 5894 5859 5632 -show status like 'handler_read%'; +show /*b*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 21 @@ -262,7 +262,7 @@ where l_suppkey in (1,4) group by l_suppkey; max(l_orderkey) 5988 5984 -show status like 'handler_read%'; +show /*c*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 6 @@ -292,7 +292,7 @@ where p_retailprice > 1100 and o_orderdate='1997-01-01' and o_orderkey=l_orderkey and p_partkey=l_partkey; o_orderkey p_partkey 5895 200 -show status like 'handler_read%'; +show /*d*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 3 @@ -457,7 +457,7 @@ select * from t1, t2 where t2.a=t1.a and t2.b < 2; a pk a b 0 0 0 0 1 1 1 1 -show status like 'handler_read%'; +show /*e*/ status like 'handler_read%'; Variable_name Value Handler_read_first 0 Handler_read_key 10 diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test index 48acf2e747f..a37677411ad 100644 --- a/mysql-test/main/innodb_ext_key.test +++ b/mysql-test/main/innodb_ext_key.test @@ -34,7 +34,7 @@ explain select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01'; flush status; select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01'; -show status like 'handler_read%'; +show /*1*/ status like 'handler_read%'; explain select count(*) from lineitem use index(primary) @@ -42,7 +42,7 @@ select count(*) from lineitem use index(primary) flush status; select count(*) from lineitem use index(primary) where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01'; -show status like 'handler_read%'; +show /*2*/ status like 'handler_read%'; explain select count(*) from lineitem @@ -50,7 +50,7 @@ select count(*) from lineitem flush status; select count(*) from lineitem where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000; -show status like 'handler_read%'; +show /*3*/ status like 'handler_read%'; explain select l_orderkey, l_linenumber from lineitem @@ -58,13 +58,13 @@ select l_orderkey, l_linenumber from lineitem flush status; select l_orderkey, l_linenumber from lineitem where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000; -show status like 'handler_read%'; +show /*4*/ status like 'handler_read%'; explain select min(l_orderkey) from lineitem where l_shipdate='1992-07-01'; flush status; select min(l_orderkey) from lineitem where l_shipdate='1992-07-01'; -show status like 'handler_read%'; +show /*5*/ status like 'handler_read%'; explain select min(l_orderkey) from lineitem @@ -72,7 +72,7 @@ select min(l_orderkey) from lineitem flush status; select min(l_orderkey) from lineitem where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000; -show status like 'handler_read%'; +show /*6*/ status like 'handler_read%'; explain select max(l_linenumber) from lineitem @@ -80,7 +80,7 @@ select max(l_linenumber) from lineitem flush status; select max(l_linenumber) from lineitem where l_shipdate='1992-07-01' and l_orderkey=130; -show status like 'handler_read%'; +show /*7*/ status like 'handler_read%'; explain select l_orderkey, l_linenumber @@ -92,7 +92,7 @@ select l_orderkey, l_linenumber from lineitem use index (i_l_shipdate, i_l_receiptdate) where l_shipdate='1992-07-01' and l_orderkey=130 or l_receiptdate='1992-07-01' and l_orderkey=5603; -show status like 'handler_read%'; +show /*8*/ status like 'handler_read%'; --replace_column 7 # explain @@ -105,7 +105,7 @@ select l_orderkey, l_linenumber from lineitem use index (i_l_shipdate, i_l_receiptdate) where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000 or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000; -show status like 'handler_read%'; +show /*9*/ status like 'handler_read%'; --replace_column 7 # 9 # 10 Using explain @@ -116,7 +116,7 @@ flush status; select l_orderkey, l_linenumber from lineitem where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000 or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000; -show status like 'handler_read_next'; +show /*a*/ status like 'handler_read_next'; --replace_column 9 # explain @@ -125,7 +125,7 @@ select max(l_orderkey) from lineitem flush status; select max(l_orderkey) from lineitem where l_partkey between 1 and 10 group by l_partkey; -show status like 'handler_read%'; +show /*b*/ status like 'handler_read%'; --replace_column 9 # explain @@ -134,7 +134,7 @@ select max(l_orderkey) from lineitem flush status; select max(l_orderkey) from lineitem where l_suppkey in (1,4) group by l_suppkey; -show status like 'handler_read%'; +show /*c*/ status like 'handler_read%'; create index i_p_retailprice on part(p_retailprice); @@ -151,7 +151,7 @@ select o_orderkey, p_partkey lineitem use index (i_l_partkey), orders where p_retailprice > 1100 and o_orderdate='1997-01-01' and o_orderkey=l_orderkey and p_partkey=l_partkey; -show status like 'handler_read%'; +show /*d*/ status like 'handler_read%'; --enable_ps2_protocol --echo # @@ -327,7 +327,7 @@ explain select * from t1, t2 where t2.a=t1.a and t2.b < 2; flush status; select * from t1, t2 where t2.a=t1.a and t2.b < 2; -show status like 'handler_read%'; +show /*e*/ status like 'handler_read%'; --enable_ps2_protocol drop table t1,t2; diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index e7f8825ab97..a0da2cd1873 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -503,7 +503,6 @@ start transaction; alter table tmp alter column a set default 8; unlock tables; drop table t2; ---source include/have_innodb.inc --echo # --echo # MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table @@ -642,7 +641,6 @@ insert into t1 values (0); check table t1 extended; drop table t1; - --echo # --echo # MDEV-32837 long unique does not work like unique key when using replace --echo # diff --git a/mysql-test/main/myisam.result b/mysql-test/main/myisam.result index 9f907e6df1e..abff4c46137 100644 --- a/mysql-test/main/myisam.result +++ b/mysql-test/main/myisam.result @@ -1,7 +1,5 @@ call mtr.add_suppression("Can't find record in '.*'"); call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); -drop table if exists t1,t2,t3; -SET SQL_WARNINGS=1; CREATE TABLE t1 ( STRING_DATA char(255) default NULL, KEY string_data (STRING_DATA) diff --git a/mysql-test/main/myisam.test b/mysql-test/main/myisam.test index 4dc02c35a18..36780ef09ab 100644 --- a/mysql-test/main/myisam.test +++ b/mysql-test/main/myisam.test @@ -7,12 +7,6 @@ call mtr.add_suppression("Can't find record in '.*'"); call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); -# Initialise ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings -SET SQL_WARNINGS=1; - # # Test problem with CHECK TABLE; # diff --git a/mysql-test/main/trigger.result b/mysql-test/main/trigger.result index 40f310a43e9..cae8faf90b1 100644 --- a/mysql-test/main/trigger.result +++ b/mysql-test/main/trigger.result @@ -1,9 +1,3 @@ -drop table if exists t1, t2, t3, t4; -drop view if exists v1; -drop database if exists mysqltest; -drop function if exists f1; -drop function if exists f2; -drop procedure if exists p1; connect addconroot1, localhost, root,,; connect addconroot2, localhost, root,,; connect addconwithoutdb, localhost, root,,*NO-ONE*; diff --git a/mysql-test/main/trigger.test b/mysql-test/main/trigger.test index ddbb8555b90..ae4ee2e04bc 100644 --- a/mysql-test/main/trigger.test +++ b/mysql-test/main/trigger.test @@ -7,15 +7,6 @@ # Basic triggers test # ---disable_warnings -drop table if exists t1, t2, t3, t4; -drop view if exists v1; -drop database if exists mysqltest; -drop function if exists f1; -drop function if exists f2; -drop procedure if exists p1; ---enable_warnings - # Create additional connections used through test connect (addconroot1, localhost, root,,); connect (addconroot2, localhost, root,,); diff --git a/mysql-test/suite/galera/r/galera_load_data.result b/mysql-test/suite/galera/r/galera_load_data.result index 84e96f8a36c..80bea22480f 100644 --- a/mysql-test/suite/galera/r/galera_load_data.result +++ b/mysql-test/suite/galera/r/galera_load_data.result @@ -28,7 +28,308 @@ LOCK TABLES cardtest_tbl WRITE; ALTER TABLE cardtest_tbl DISABLE KEYS; Warnings: Note 1031 Storage engine InnoDB of the table `cardtest02`.`cardtest_tbl` doesn't have this option -INSERT INTO cardtest_tbl VALUES (1,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(2,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(3,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(4,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(5,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(6,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(7,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(8,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(9,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(10,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(11,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(12,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(13,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(14,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(15,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(16,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(17,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(18,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(19,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(20,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(21,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(22,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(23,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(24,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(25,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(26,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(27,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(28,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(29,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(30,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(31,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(32,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(33,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(34,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(35,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(36,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(37,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(38,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(39,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(40,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(41,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(42,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(43,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(44,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(45,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(46,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(47,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(48,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(49,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(50,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(51,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(52,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(53,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(54,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(55,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(56,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(57,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(58,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(59,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(60,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(61,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(62,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(63,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(64,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(65,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(66,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(67,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(68,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(69,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(70,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(71,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(72,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(73,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(74,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(75,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(76,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(77,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(78,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(79,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(80,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(81,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(82,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(83,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(84,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(85,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(86,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(87,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(88,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(89,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(90,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(91,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(92,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(93,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(94,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(95,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(96,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(97,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(98,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(99,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(100,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(101,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(102,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(103,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(104,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(105,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(106,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(107,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(108,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(109,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(110,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(111,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(112,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(113,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(114,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(115,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(116,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(117,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(118,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(119,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(120,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(121,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(122,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(123,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(124,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(125,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(126,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(127,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(128,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(129,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(130,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(131,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(132,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(133,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(134,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(135,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(136,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(137,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(138,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(139,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(140,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(141,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(142,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(143,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(144,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(145,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(146,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(147,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(148,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(149,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(150,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(151,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(152,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(153,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(154,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(155,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(156,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(157,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(158,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(159,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(160,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(161,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(162,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(163,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(164,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(165,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(166,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(167,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(168,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(169,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(170,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(171,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(172,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(173,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(174,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(175,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(176,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(177,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(178,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(179,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(180,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(181,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(182,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(183,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(184,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(185,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(186,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(187,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(188,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(189,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(190,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(191,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(192,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(193,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(194,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(195,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(196,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(197,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(198,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(199,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(200,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(201,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(202,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(203,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(204,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(205,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(206,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(207,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(208,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(209,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(210,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(211,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(212,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(213,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(214,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(215,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(216,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(217,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(218,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(219,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(220,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(221,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(222,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(223,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(224,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(225,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(226,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(227,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(228,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(229,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(230,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(231,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(232,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(233,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(234,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(235,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(236,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(237,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(238,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(239,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(240,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(241,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(242,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(243,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(244,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(245,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(246,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(247,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(248,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(249,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(250,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(251,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(252,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(253,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(254,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(255,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(256,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(257,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(258,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(259,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(260,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(261,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(262,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(263,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(264,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(265,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(266,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(267,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(268,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(269,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(270,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(271,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(272,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(273,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(274,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(275,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(276,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(277,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(278,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(279,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(280,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(281,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(282,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(283,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(284,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(285,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(286,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(287,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(288,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(289,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(290,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(291,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(292,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(293,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(294,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(295,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(296,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(297,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(298,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(299,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(300,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(301,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL); +INSERT INTO cardtest_tbl VALUES +(1,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(2,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(3,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(4,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(5,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(6,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(7,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(8,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(9,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(10,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(11,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(12,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(13,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(14,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(15,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(16,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(17,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(18,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(19,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(20,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(21,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(22,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(23,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(24,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(25,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(26,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(27,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(28,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(29,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(30,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(31,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(32,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(33,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(34,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(35,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(36,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(37,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(38,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(39,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(40,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(41,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(42,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(43,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(44,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(45,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(46,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(47,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(48,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(49,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(50,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(51,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(52,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(53,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(54,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(55,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(56,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(57,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(58,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(59,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(60,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(61,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(62,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(63,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(64,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(65,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(66,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(67,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(68,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(69,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(70,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(71,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(72,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(73,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(74,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(75,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(76,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(77,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(78,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(79,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(80,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(81,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(82,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(83,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(84,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(85,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(86,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(87,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(88,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(89,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(90,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(91,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(92,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(93,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(94,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(95,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(96,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(97,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(98,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(99,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(100,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(101,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(102,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(103,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(104,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(105,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(106,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(107,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(108,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(109,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(110,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(111,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(112,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(113,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(114,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(115,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(116,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(117,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(118,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(119,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(120,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(121,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(122,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(123,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(124,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(125,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(126,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(127,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(128,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(129,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(130,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(131,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(132,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(133,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(134,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(135,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(136,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(137,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(138,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(139,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(140,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(141,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(142,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(143,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(144,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(145,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(146,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(147,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(148,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(149,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(150,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(151,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(152,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(153,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(154,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(155,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(156,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(157,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(158,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(159,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(160,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(161,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(162,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(163,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(164,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(165,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(166,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(167,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(168,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(169,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(170,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(171,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(172,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(173,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(174,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(175,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(176,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(177,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(178,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(179,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(180,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(181,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(182,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(183,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(184,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(185,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(186,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(187,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(188,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(189,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(190,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(191,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(192,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(193,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(194,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(195,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(196,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(197,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(198,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(199,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(200,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(201,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(202,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(203,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(204,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(205,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(206,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(207,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(208,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(209,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(210,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(211,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(212,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(213,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(214,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(215,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(216,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(217,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(218,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(219,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(220,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(221,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(222,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(223,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(224,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(225,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(226,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(227,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(228,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(229,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(230,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(231,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(232,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(233,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(234,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(235,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(236,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(237,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(238,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(239,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(240,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(241,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(242,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(243,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(244,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(245,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(246,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(247,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(248,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(249,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(250,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(251,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(252,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(253,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(254,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(255,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(256,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(257,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(258,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(259,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(260,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(261,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(262,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(263,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(264,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(265,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(266,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(267,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(268,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(269,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(270,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(271,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(272,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(273,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(274,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(275,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(276,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(277,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(278,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(279,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(280,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(281,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(282,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(283,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(284,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(285,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(286,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(287,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(288,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(289,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(290,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(291,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(292,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(293,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(294,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(295,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(296,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(297,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(298,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(299,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(300,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), +(301,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL); ALTER TABLE cardtest_tbl ENABLE KEYS; Warnings: Note 1031 Storage engine InnoDB of the table `cardtest02`.`cardtest_tbl` doesn't have this option diff --git a/mysql-test/suite/galera/t/galera_load_data.test b/mysql-test/suite/galera/t/galera_load_data.test index c37920a43c4..252580f9426 100644 --- a/mysql-test/suite/galera/t/galera_load_data.test +++ b/mysql-test/suite/galera/t/galera_load_data.test @@ -30,8 +30,308 @@ CREATE TABLE cardtest_tbl ( LOCK TABLES cardtest_tbl WRITE; ALTER TABLE cardtest_tbl DISABLE KEYS; -INSERT INTO cardtest_tbl VALUES (1,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(2,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(3,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(4,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(5,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(6,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(7,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(8,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(9,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(10,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(11,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(12,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(13,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(14,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(15,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(16,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(17,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(18,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(19,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(20,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(21,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(22,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(23,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(24,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(25,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(26,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(27,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(28,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(29,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(30,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(31,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(32,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(33,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(34,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(35,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(36,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(37,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(38,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(39,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(40,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(41,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(42,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(43,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(44,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(45,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(46,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(47,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(48,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(49,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(50,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(51,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(52,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(53,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(54,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(55,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(56,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(57,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(58,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(59,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(60,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(61,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(62,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(63,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(64,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(65,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(66,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(67,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(68,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(69,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(70,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(71,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(72,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(73,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(74,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(75,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(76,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(77,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(78,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(79,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(80,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(81,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(82,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(83,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(84,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(85,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(86,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(87,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(88,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(89,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(90,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(91,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(92,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(93,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(94,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(95,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(96,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(97,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(98,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(99,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(100,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(101,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(102,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(103,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(104,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(105,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(106,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(107,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(108,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(109,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(110,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(111,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(112,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(113,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(114,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(115,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(116,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(117,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(118,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(119,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(120,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(121,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(122,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(123,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(124,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(125,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(126,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(127,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(128,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(129,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(130,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(131,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(132,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(133,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(134,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(135,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(136,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(137,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(138,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(139,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(140,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(141,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(142,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(143,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(144,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(145,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(146,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(147,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(148,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(149,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(150,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(151,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(152,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(153,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(154,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(155,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(156,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(157,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(158,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(159,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(160,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(161,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(162,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(163,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(164,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(165,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(166,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(167,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(168,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(169,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(170,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(171,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(172,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(173,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(174,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(175,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(176,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(177,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(178,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(179,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(180,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(181,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(182,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(183,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(184,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(185,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(186,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(187,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(188,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(189,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(190,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(191,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(192,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(193,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(194,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(195,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(196,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(197,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(198,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(199,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(200,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(201,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(202,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(203,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(204,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(205,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(206,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(207,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(208,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(209,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(210,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(211,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(212,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(213,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(214,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(215,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(216,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(217,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(218,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(219,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(220,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(221,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(222,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(223,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(224,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(225,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(226,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(227,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(228,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(229,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(230,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(231,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(232,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(233,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(234,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(235,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(236,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(237,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(238,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(239,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(240,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(241,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(242,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(243,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(244,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(245,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(246,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(247,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(248,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(249,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(250,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(251,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(252,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(253,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(254,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(255,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(256,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(257,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(258,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(259,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(260,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(261,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(262,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(263,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(264,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(265,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(266,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(267,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(268,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(269,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(270,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(271,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(272,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(273,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(274,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(275,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(276,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(277,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(278,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(279,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(280,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(281,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(282,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(283,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(284,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(285,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(286,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(287,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(288,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(289,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(290,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(291,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(292,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(293,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(294,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(295,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(296,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(297,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(298,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(299,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(300,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL),(301,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL); - +INSERT INTO cardtest_tbl VALUES + (1,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (2,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (3,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (4,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (5,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (6,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (7,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (8,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (9,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (10,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (11,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (12,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (13,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (14,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (15,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (16,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (17,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (18,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (19,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (20,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (21,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (22,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (23,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (24,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (25,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (26,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (27,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (28,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (29,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (30,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (31,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (32,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (33,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (34,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (35,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (36,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (37,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (38,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (39,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (40,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (41,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (42,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (43,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (44,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (45,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (46,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (47,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (48,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (49,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (50,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (51,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (52,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (53,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (54,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (55,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (56,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (57,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (58,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (59,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (60,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (61,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (62,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (63,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (64,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (65,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (66,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (67,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (68,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (69,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (70,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (71,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (72,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (73,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (74,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (75,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (76,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (77,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (78,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (79,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (80,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (81,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (82,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (83,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (84,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (85,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (86,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (87,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (88,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (89,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (90,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (91,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (92,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (93,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (94,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (95,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (96,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (97,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (98,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (99,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (100,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (101,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (102,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (103,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (104,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (105,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (106,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (107,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (108,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (109,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (110,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (111,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (112,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (113,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (114,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (115,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (116,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (117,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (118,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (119,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (120,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (121,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (122,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (123,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (124,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (125,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (126,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (127,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (128,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (129,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (130,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (131,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (132,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (133,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (134,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (135,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (136,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (137,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (138,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (139,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (140,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (141,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (142,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (143,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (144,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (145,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (146,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (147,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (148,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (149,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (150,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (151,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (152,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (153,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (154,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (155,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (156,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (157,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (158,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (159,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (160,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (161,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (162,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (163,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (164,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (165,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (166,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (167,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (168,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (169,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (170,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (171,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (172,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (173,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (174,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (175,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (176,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (177,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (178,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (179,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (180,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (181,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (182,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (183,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (184,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (185,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (186,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (187,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (188,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (189,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (190,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (191,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (192,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (193,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (194,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (195,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (196,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (197,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (198,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (199,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (200,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (201,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (202,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (203,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (204,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (205,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (206,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (207,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (208,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (209,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (210,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (211,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (212,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (213,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (214,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (215,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (216,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (217,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (218,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (219,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (220,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (221,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (222,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (223,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (224,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (225,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (226,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (227,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (228,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (229,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (230,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (231,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (232,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (233,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (234,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (235,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (236,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (237,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (238,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (239,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (240,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (241,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (242,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (243,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (244,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (245,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (246,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (247,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (248,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (249,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (250,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (251,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (252,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (253,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (254,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (255,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (256,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (257,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (258,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (259,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (260,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (261,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (262,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (263,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (264,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (265,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (266,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (267,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (268,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (269,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (270,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (271,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (272,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (273,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (274,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (275,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (276,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (277,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (278,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (279,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (280,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (281,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (282,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (283,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (284,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (285,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (286,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (287,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (288,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (289,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (290,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (291,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (292,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (293,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (294,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (295,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (296,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (297,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (298,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (299,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (300,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), + (301,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL); ALTER TABLE cardtest_tbl ENABLE KEYS; UNLOCK TABLES; diff --git a/mysql-test/suite/parts/r/alter_table.result b/mysql-test/suite/parts/r/alter_table.result index 0901584c6f8..a16959d04aa 100644 --- a/mysql-test/suite/parts/r/alter_table.result +++ b/mysql-test/suite/parts/r/alter_table.result @@ -1,3 +1,6 @@ +# +# MDEV-22649 SIGSEGV in ha_partition::create_partitioning_metadata on ALTER +# set @save_alter_algorithm= @@session.alter_algorithm; SET SESSION alter_algorithm=4; CREATE TABLE t1(a INT) engine=myisam PARTITION BY RANGE(a) SUBPARTITION BY KEY(a) (PARTITION p0 VALUES LESS THAN (10) (SUBPARTITION s0,SUBPARTITION s1), PARTITION p1 VALUES LESS THAN (20) (SUBPARTITION s2,SUBPARTITION s3)); @@ -18,9 +21,16 @@ ALTER TABLE t1 ADD COLUMN c INT; ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY DROP table if exists t1; set @@session.alter_algorithm= @save_alter_algorithm; +# +# MDEV-22804 SIGSEGV in ha_partition::create_partitioning_metadata | +# ERROR 1507 (HY000): Error in list of partitions to DROP +# CREATE TABLE t1 (a INT) PARTITION BY RANGE(a) SUBPARTITION BY HASH(a) (PARTITION p VALUES LESS THAN (5) (SUBPARTITION sp, SUBPARTITION sp1), PARTITION p1 VALUES LESS THAN MAXVALUE (SUBPARTITION sp2, SUBPARTITION sp3)); ALTER TABLE t1 DROP PARTITION p; DROP TABLE if exists t1; +# +# MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition +# CREATE TABLE t1 (i INT); CREATE VIEW v1 as SELECT * FROM t1; CREATE TABLE t2 (i INT); @@ -28,3 +38,4 @@ ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ; ERROR 42000: Can't open table DROP VIEW v1; DROP TABLE t1, t2; +# End of 10.5 tests diff --git a/mysql-test/suite/parts/r/partition_recover_myisam.result b/mysql-test/suite/parts/r/partition_recover_myisam.result index 151ff802a82..840b8da771b 100644 --- a/mysql-test/suite/parts/r/partition_recover_myisam.result +++ b/mysql-test/suite/parts/r/partition_recover_myisam.result @@ -1,3 +1,6 @@ +call mtr.add_suppression("..test.t1_will_crash"); +call mtr.add_suppression("Got an error from unknown thread"); +call mtr.add_suppression("Table 't1_will_crash' is marked as crashed and should be repaired"); CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM; INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); FLUSH TABLES; diff --git a/mysql-test/suite/parts/t/alter_table.test b/mysql-test/suite/parts/t/alter_table.test index 53b61806acb..61b2539dac1 100644 --- a/mysql-test/suite/parts/t/alter_table.test +++ b/mysql-test/suite/parts/t/alter_table.test @@ -1,13 +1,13 @@ # -# General errors with ALTER TABLE and partitions that doesn't have to be run +# General bugs with ALTER TABLE and partitions that doesn't have to be run # on all engines # --source include/have_partition.inc -# -# MDEV-22649 SIGSEGV in ha_partition::create_partitioning_metadata on ALTER -# +--echo # +--echo # MDEV-22649 SIGSEGV in ha_partition::create_partitioning_metadata on ALTER +--echo # set @save_alter_algorithm= @@session.alter_algorithm; SET SESSION alter_algorithm=4; @@ -19,18 +19,18 @@ DROP table if exists t1; set @@session.alter_algorithm= @save_alter_algorithm; -# -# MDEV-22804 SIGSEGV in ha_partition::create_partitioning_metadata | -# ERROR 1507 (HY000): Error in list of partitions to DROP -# +--echo # +--echo # MDEV-22804 SIGSEGV in ha_partition::create_partitioning_metadata | +--echo # ERROR 1507 (HY000): Error in list of partitions to DROP +--echo # CREATE TABLE t1 (a INT) PARTITION BY RANGE(a) SUBPARTITION BY HASH(a) (PARTITION p VALUES LESS THAN (5) (SUBPARTITION sp, SUBPARTITION sp1), PARTITION p1 VALUES LESS THAN MAXVALUE (SUBPARTITION sp2, SUBPARTITION sp3)); ALTER TABLE t1 DROP PARTITION p; DROP TABLE if exists t1; -# -# MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition -# +--echo # +--echo # MDEV-23357 Server crashes in Sql_cmd_alter_table_exchange_partition::exchange_partition +--echo # CREATE TABLE t1 (i INT); CREATE VIEW v1 as SELECT * FROM t1; CREATE TABLE t2 (i INT); @@ -38,3 +38,5 @@ CREATE TABLE t2 (i INT); ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ; DROP VIEW v1; DROP TABLE t1, t2; + +--echo # End of 10.5 tests diff --git a/mysql-test/suite/parts/t/partition_recover_myisam-master.opt b/mysql-test/suite/parts/t/partition_recover_myisam.opt similarity index 100% rename from mysql-test/suite/parts/t/partition_recover_myisam-master.opt rename to mysql-test/suite/parts/t/partition_recover_myisam.opt diff --git a/mysql-test/suite/parts/t/partition_recover_myisam.test b/mysql-test/suite/parts/t/partition_recover_myisam.test index 91a14a51b3c..3106407bea9 100644 --- a/mysql-test/suite/parts/t/partition_recover_myisam.test +++ b/mysql-test/suite/parts/t/partition_recover_myisam.test @@ -1,18 +1,10 @@ # test the auto-recover (--myisam-recover) of partitioned myisam tables ---disable_query_log call mtr.add_suppression("..test.t1_will_crash"); call mtr.add_suppression("Got an error from unknown thread"); call mtr.add_suppression("Table 't1_will_crash' is marked as crashed and should be repaired"); ---enable_query_log --source include/have_partition.inc ---disable_warnings ---disable_query_log -drop table if exists t1_will_crash; ---enable_query_log ---enable_warnings - CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM; INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11); diff --git a/sql/handler.cc b/sql/handler.cc index 93baef92267..4d03fcce8cd 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4915,8 +4915,7 @@ handler::ha_check_and_repair(THD *thd) int handler::ha_disable_indexes(uint mode) { - DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + DBUG_ASSERT(table->s->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); mark_trx_read_write(); return disable_indexes(mode); @@ -4932,8 +4931,7 @@ handler::ha_disable_indexes(uint mode) int handler::ha_enable_indexes(uint mode) { - DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE || - m_lock_type != F_UNLCK); + DBUG_ASSERT(table->s->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); mark_trx_read_write(); return enable_indexes(mode); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 1e0a6a75338..a6b12ed7cff 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1881,7 +1881,7 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, select_result *sink) was used. This ensures that we don't get a problem when the whole range of the key has been used. */ - if (info->handle_duplicates == DUP_REPLACE && table->next_number_field && + if (info->handle_duplicates == DUP_REPLACE && key_nr == table->s->next_number_index && insert_id_for_cur_row > 0) goto err; if (table->file->has_dup_ref()) diff --git a/sql/table.cc b/sql/table.cc index 610d94d413c..72bc7835a3c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3209,6 +3209,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, goto err; // Wrong field definition reg_field->flags |= AUTO_INCREMENT_FLAG; } + else + share->next_number_index= MAX_KEY; if (share->blob_fields) { @@ -8926,7 +8928,7 @@ void TABLE::period_prepare_autoinc() if (!found_next_number_field) return; /* Don't generate a new value if the autoinc index is WITHOUT OVERLAPS */ - DBUG_ASSERT(s->next_number_index != (uint)-1); + DBUG_ASSERT(s->next_number_index < MAX_KEY); if (key_info[s->next_number_index].without_overlaps) return; diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 67cb714e7bf..4f3326098f6 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -279,51 +279,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* Fatal error found */ } -#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND - /* Close the isam and data files as Win32 can't drop an open table */ - if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) - { - info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); - error=end_io_cache(&info->rec_cache); - } - if (info->lock_type != F_UNLCK && ! info->was_locked) - { - info->was_locked=info->lock_type; - if (mi_lock_database(info,F_UNLCK)) - error=my_errno; - info->lock_type = F_UNLCK; - } - if (share->kfile >= 0) - { - /* - We don't need to call _mi_decrement_open_count() if we are - dropping the table, as the files will be removed anyway. If we - are aborted before the files is removed, it's better to not - call it as in that case the automatic repair on open will add - the missing index entries - */ - if (function != HA_EXTRA_PREPARE_FOR_DROP) - _mi_decrement_open_count(info); - if (mysql_file_close(share->kfile,MYF(0))) - error=my_errno; - } - { - LIST *list_element ; - for (list_element=myisam_open_list ; - list_element ; - list_element=list_element->next) - { - MI_INFO *tmpinfo=(MI_INFO*) list_element->data; - if (tmpinfo->s == info->s) - { - if (tmpinfo->dfile >= 0 && mysql_file_close(tmpinfo->dfile, MYF(0))) - error = my_errno; - tmpinfo->dfile= -1; - } - } - } - share->kfile= -1; /* Files aren't open anymore */ -#endif mysql_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&THR_LOCK_myisam); break; From 179515a68cc305f4bb3880de911df0b3f8325b90 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 28 Apr 2024 09:45:16 +0200 Subject: [PATCH 279/313] bugfix: dgcov.pl shows wrong line numbers dgcov.pl was putting gcov execution counters on wrong lines in the report (*.dgcov files were correct), because it was incrementing the new line number for diff lines starting from '-' (lines from the old file, not present in the new) --- mysql-test/dgcov.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl index 94fe48805d1..1da0d6c23b0 100755 --- a/mysql-test/dgcov.pl +++ b/mysql-test/dgcov.pl @@ -112,8 +112,7 @@ sub print_gcov_for_diff { $acc.=sprintf '%9s:%5s:%s', '', $lnum, $' if /^ /; ++$printme, $acc.=sprintf '%9s:%5s:%s', gcov_prefix($fcov->{$lnum}), $lnum, $' if /^\+/; die "$_^^^ dying", unless /^[- +]/; - ++$lnum; - --$cnt; + ++$lnum, --$cnt unless /^-/; } print $acc if $printme; close PIPE or die "command '$cmd' failed: $!: $?"; From 3d75cffa9144606e4cbca1fe4a9bc8059e90c83b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 28 Apr 2024 10:38:32 +0200 Subject: [PATCH 280/313] bugfix: INFORMATION_SCHEMA.STATISTICS doesn't show whether the index is disabled --- mysql-test/main/information_schema2.result | 11 +++++++++++ mysql-test/main/information_schema2.test | 9 +++++++++ sql/sql_show.cc | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/information_schema2.result b/mysql-test/main/information_schema2.result index 75217cf58bd..fa4d71bf227 100644 --- a/mysql-test/main/information_schema2.result +++ b/mysql-test/main/information_schema2.result @@ -25,3 +25,14 @@ t3 t4 drop table t1, t2, t3, t4; # End of 5.5 tests +# INFORMATION_SCHEMA.STATISTICS doesn't show if the index is disabled +create table t1 (a int, key(a)); +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +index_name comment +a +alter table t1 disable keys; +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +index_name comment +a disabled +drop table t1; +# End of 10.5 tests diff --git a/mysql-test/main/information_schema2.test b/mysql-test/main/information_schema2.test index bd9350a3031..50ceec2c5d3 100644 --- a/mysql-test/main/information_schema2.test +++ b/mysql-test/main/information_schema2.test @@ -19,3 +19,12 @@ select * from t4 order by table_name; drop table t1, t2, t3, t4; --echo # End of 5.5 tests + +--echo # INFORMATION_SCHEMA.STATISTICS doesn't show if the index is disabled +create table t1 (a int, key(a)); +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +alter table t1 disable keys; +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +drop table t1; + +--echo # End of 10.5 tests diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a6b307ac8a4..3ed8e108f8d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -9400,7 +9400,7 @@ ST_FIELD_INFO stat_fields_info[]= Column("PACKED", Varchar(10), NULLABLE, "Packed", OPEN_FRM_ONLY), Column("NULLABLE", Varchar(3), NOT_NULL, "Null", OPEN_FRM_ONLY), Column("INDEX_TYPE", Varchar(16), NOT_NULL, "Index_type", OPEN_FULL_TABLE), - Column("COMMENT", Varchar(16), NULLABLE, "Comment", OPEN_FRM_ONLY), + Column("COMMENT", Varchar(16), NULLABLE, "Comment", OPEN_FULL_TABLE), Column("INDEX_COMMENT", Varchar(INDEX_COMMENT_MAXLEN), NOT_NULL, "Index_comment",OPEN_FRM_ONLY), CEnd() From 4045a87bcb37763670cec4aad7f5b7afaf42717a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 28 Apr 2024 10:39:37 +0200 Subject: [PATCH 281/313] test for Bug #16051817 GOT ERROR 124 FROM STORAGE ENGINE ON DELETE FROM A PARTITIONED TABLE followup for c5896384bda5 --- mysql-test/suite/parts/r/alter_table.result | 21 +++++++++++++++++++++ mysql-test/suite/parts/t/alter_table.test | 13 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/mysql-test/suite/parts/r/alter_table.result b/mysql-test/suite/parts/r/alter_table.result index a16959d04aa..ac8eba12f1b 100644 --- a/mysql-test/suite/parts/r/alter_table.result +++ b/mysql-test/suite/parts/r/alter_table.result @@ -38,4 +38,25 @@ ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ; ERROR 42000: Can't open table DROP VIEW v1; DROP TABLE t1, t2; +# +# MDEV-25102 UNIQUE USING HASH error after ALTER ... DISABLE KEYS +# +create table t1 (i1 int primary key, i2 int, d1 date, key(i2)) +partition by hash(i1) partitions 3; +insert into t1 values(0, 1, '2010-10-10'); +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +index_name comment +PRIMARY +i2 +alter table t1 disable keys; +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +index_name comment +PRIMARY +i2 disabled +alter table t1 add partition (partition p4); +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +index_name comment +PRIMARY +i2 disabled +drop table t1; # End of 10.5 tests diff --git a/mysql-test/suite/parts/t/alter_table.test b/mysql-test/suite/parts/t/alter_table.test index 61b2539dac1..37adb424d75 100644 --- a/mysql-test/suite/parts/t/alter_table.test +++ b/mysql-test/suite/parts/t/alter_table.test @@ -39,4 +39,17 @@ ALTER TABLE v1 EXCHANGE PARTITION p2 WITH TABLE t2 ; DROP VIEW v1; DROP TABLE t1, t2; +--echo # +--echo # MDEV-25102 UNIQUE USING HASH error after ALTER ... DISABLE KEYS +--echo # +create table t1 (i1 int primary key, i2 int, d1 date, key(i2)) +partition by hash(i1) partitions 3; +insert into t1 values(0, 1, '2010-10-10'); +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +alter table t1 disable keys; +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +alter table t1 add partition (partition p4); +select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; +drop table t1; + --echo # End of 10.5 tests From 52c45332a8424bfe2e767202ff1c821c8c1951da Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 3 May 2024 15:16:25 +0200 Subject: [PATCH 282/313] MDEV-34071: Failure during the galera_3nodes_sr.GCF-336 test This commit fixes sporadic failures in galera_3nodes_sr.GCF-336 test. The following changes have been made here: 1) A small addition to the test itself which should make it more deterministic by waiting for non-primary state before COMMIT; 2) More careful handling of the wsrep_ready variable in the server code (it should always be protected with mutex). No additional tests are required. --- mysql-test/suite/galera_3nodes_sr/r/GCF-336.result | 2 ++ mysql-test/suite/galera_3nodes_sr/t/GCF-336.test | 6 ++++++ sql/slave.cc | 2 +- sql/wsrep_mysqld.cc | 2 +- sql/wsrep_notify.cc | 2 +- sql/wsrep_server_service.cc | 1 - 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result b/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result index eeccfa3b5a3..8fc853f8425 100644 --- a/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result +++ b/mysql-test/suite/galera_3nodes_sr/r/GCF-336.result @@ -25,6 +25,8 @@ SET SESSION wsrep_sync_wait=0; connection node_2; INSERT INTO t1 VALUES (2); ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +connection node_2a; +connection node_2; COMMIT; ERROR 08S01: WSREP has not yet prepared node for application use connection node_2a; diff --git a/mysql-test/suite/galera_3nodes_sr/t/GCF-336.test b/mysql-test/suite/galera_3nodes_sr/t/GCF-336.test index ba85aa5291c..20d5955e4fc 100644 --- a/mysql-test/suite/galera_3nodes_sr/t/GCF-336.test +++ b/mysql-test/suite/galera_3nodes_sr/t/GCF-336.test @@ -27,6 +27,12 @@ SET SESSION wsrep_sync_wait=0; --connection node_2 --error ER_LOCK_DEADLOCK INSERT INTO t1 VALUES (2); + +--connection node_2a +--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc + +--connection node_2 --error ER_UNKNOWN_COM_ERROR COMMIT; diff --git a/sql/slave.cc b/sql/slave.cc index 66b42cabcd4..6032256c60c 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3895,7 +3895,7 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi, if (thd->system_thread == SYSTEM_THREAD_SLAVE_SQL && ((rli->mi->using_parallel() && rli->mi->parallel_mode <= SLAVE_PARALLEL_CONSERVATIVE) || - wsrep_ready == 0)) { + !wsrep_ready_get())) { rli->abort_slave= 1; rli->report(ERROR_LEVEL, ER_UNKNOWN_COM_ERROR, rgi->gtid_info(), "Node has dropped from cluster"); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 8bd953e98b2..e584c2cc144 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -3456,7 +3456,7 @@ void wsrep_ready_set(bool ready_value) mysql_mutex_lock(&LOCK_wsrep_ready); wsrep_ready= ready_value; // Signal if we have reached ready state - if (wsrep_ready) + if (ready_value) mysql_cond_signal(&COND_wsrep_ready); mysql_mutex_unlock(&LOCK_wsrep_ready); } diff --git a/sql/wsrep_notify.cc b/sql/wsrep_notify.cc index 1c8b2b47bfe..bd2919a223e 100644 --- a/sql/wsrep_notify.cc +++ b/sql/wsrep_notify.cc @@ -24,7 +24,7 @@ void wsrep_notify_status(enum wsrep::server_state::state status, if (!view) { WSREP_DEBUG("wsrep_notify_status server not yet ready : wsrep_ready=%d status %d", - wsrep_ready, (int)status); + (int) wsrep_ready_get(), (int)status); return; } diff --git a/sql/wsrep_server_service.cc b/sql/wsrep_server_service.cc index e6cfb7948b9..af2c3efd214 100644 --- a/sql/wsrep_server_service.cc +++ b/sql/wsrep_server_service.cc @@ -340,7 +340,6 @@ void Wsrep_server_service::log_state_change( switch (current_state) { case Wsrep_server_state::s_synced: - wsrep_ready= TRUE; WSREP_INFO("Synchronized with group, ready for connections"); wsrep_ready_set(true); /* fall through */ From be607821037a7b071575f5a5915ae45599cbd2e4 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 6 May 2024 13:06:14 +0300 Subject: [PATCH 283/313] MDEV-33789: rocksdb.bloomfilter2 failed on ... : Disable it. --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 627d7da4171..681e6ffa450 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -87,6 +87,7 @@ compact_deletes: MDEV-12663 : rocksdb.compact_deletes times out and causes other blind_delete_without_tx_api: MDEV-12286: rocksdb.blind_delete_without_tx_api test fails information_schema: MDEV-14372: unstable testcase +bloomfilter2: MDEV-33789: rocksdb.bloomfilter2 failed on amd64-debian-12-rocksdb ## ## Tests that fail for some other reason ## From f90fcefdb2eada4e8c507eefc5d5e620b34c94d2 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 6 May 2024 13:31:31 +0300 Subject: [PATCH 284/313] MDEV-33866: rocksdb.write_sync fails on windows ... : Disable it --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 681e6ffa450..824d07935b7 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -88,6 +88,8 @@ blind_delete_without_tx_api: MDEV-12286: rocksdb.blind_delete_without_tx_api tes information_schema: MDEV-14372: unstable testcase bloomfilter2: MDEV-33789: rocksdb.bloomfilter2 failed on amd64-debian-12-rocksdb +write_sync: MDEV-33866: rocksdb.write_sync fails on amd64-windows-packages + ## ## Tests that fail for some other reason ## From 55754be20ca2807a54bbfd5a23eb690617f57d53 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 6 May 2024 13:34:39 +0300 Subject: [PATCH 285/313] MDEV-33781: rocksdb.locking_issues_case5_rc fails windows ... : Disable it --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 824d07935b7..c16c1021141 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -89,6 +89,7 @@ information_schema: MDEV-14372: unstable testcase bloomfilter2: MDEV-33789: rocksdb.bloomfilter2 failed on amd64-debian-12-rocksdb write_sync: MDEV-33866: rocksdb.write_sync fails on amd64-windows-packages +locking_issues_case5_rc: MDEV-33781: rocksdb.locking_issues_case5_rc fails on amd64-windows-packages ## ## Tests that fail for some other reason From 16394f1aa1b4097f897b8ab01ea2064726cca059 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 6 May 2024 16:14:11 +0200 Subject: [PATCH 286/313] update C/C 3.1 --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 9155b19b462..51b2a621b3d 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 9155b19b462ac15fc69d0b58ae51370b7523ced5 +Subproject commit 51b2a621b3d5ef949098dcb7912048caaf878793 From 9b2bf09b9513222ec959c7df92926c8ef4b6ebe5 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 6 May 2024 19:49:11 +0530 Subject: [PATCH 287/313] MDEV-33980 mariadb-backup --backup is missing retry logic for undo tablespaces - This is a merge of commit f378e7643459f0baa6c4149a795463f2f46b6871 from 10.4 to 10.5. --- storage/innobase/os/os0file.cc | 8 -------- storage/innobase/srv/srv0start.cc | 28 +++++++++++++--------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 14c2f865aa3..4ef6799e9a6 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -4264,15 +4264,7 @@ invalid: } aligned_free(page); - DBUG_EXECUTE_IF("undo_space_read_fail", - if (space_id == srv_undo_space_id_start) { - goto wrong_space_id; - }); - if (UNIV_UNLIKELY(space_id != space->id)) { -#ifndef DBUG_OFF -wrong_space_id: -#endif ib::error() << "Expected tablespace id " << space->id << " but found " << space_id << " in the file " << name; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 5af1ccb2ebb..9d64d4ce57f 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -489,7 +489,6 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i) char undo_name[sizeof "innodb_undo000"]; ulint space_id= 0; ulint fsp_flags= 0; - ulint n_retries= 5; if (create) { @@ -506,7 +505,6 @@ static ulint srv_undo_tablespace_open(bool create, const char* name, ulint i) } } -undo_retry: pfs_os_file_t fh= os_file_create(innodb_data_file_key, name, OS_FILE_OPEN | OS_FILE_ON_ERROR_NO_EXIT | OS_FILE_ON_ERROR_SILENT, @@ -516,6 +514,7 @@ undo_retry: if (!success) return 0; + ulint n_retries = 5; os_offset_t size= os_file_get_size(fh); ut_a(size != os_offset_t(-1)); @@ -523,15 +522,25 @@ undo_retry: { page_t *page= static_cast(aligned_malloc(srv_page_size, srv_page_size)); +undo_retry: if (os_file_read(IORequestRead, fh, page, 0, srv_page_size) != DB_SUCCESS) { err_exit: + if (n_retries && srv_operation == SRV_OPERATION_BACKUP) + { + sql_print_information("InnoDB: Retrying to read undo " + "tablespace %s", name); + n_retries--; + goto undo_retry; + } ib::error() << "Unable to read first page of file " << name; aligned_free(page); return ULINT_UNDEFINED; } + DBUG_EXECUTE_IF("undo_space_read_fail", goto err_exit;); + uint32_t id= mach_read_from_4(FIL_PAGE_SPACE_ID + page); if (id == 0 || id >= SRV_SPACE_ID_UPPER_BOUND || memcmp_aligned<2>(FIL_PAGE_SPACE_ID + page, @@ -576,7 +585,7 @@ err_exit: space->set_sizes(SRV_UNDO_TABLESPACE_SIZE_IN_PAGES); space->size= file->size= uint32_t(size >> srv_page_size_shift); } - else if (!(success = file->read_page0())) + else if (!file->read_page0()) { os_file_close(file->handle); file->handle= OS_FILE_CLOSED; @@ -585,18 +594,7 @@ err_exit: } mutex_exit(&fil_system.mutex); - - if (!success && n_retries && - srv_operation == SRV_OPERATION_BACKUP) - { - sql_print_information("InnoDB: Retrying to read undo " - "tablespace %s", undo_name); - fil_space_free(space_id, false); - n_retries--; - goto undo_retry; - } - - return success ? space_id : ULINT_UNDEFINED; + return space_id; } /** Check if undo tablespaces and redo log files exist before creating a From 22b3ba93121581db1cca4d2f9bfaf8d889cb2b32 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 27 Apr 2024 15:15:37 +0200 Subject: [PATCH 288/313] MDEV-25102 UNIQUE USING HASH error after ALTER ... DISABLE KEYS on disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE) the engine does not know that the long unique is logically unique, because on the engine level it is not. And the engine disables it, Change the disable_indexes/enable_indexes API. Instead of the enum mode, send a key_map of indexes that should be enabled. This way the server will decide what is unique, not the engine. --- mysql-test/main/long_unique_bugs.result | 12 + mysql-test/main/long_unique_bugs.test | 13 + .../suite/galera/r/galera_load_data.result | 2 - sql/ha_partition.cc | 29 +- sql/ha_partition.h | 7 +- sql/handler.cc | 24 +- sql/handler.h | 14 +- sql/sql_select.cc | 2 +- sql/sql_table.cc | 18 +- sql/sql_union.cc | 8 +- sql/table.cc | 3 +- storage/heap/ha_heap.cc | 32 +- storage/heap/ha_heap.h | 4 +- storage/maria/ha_maria.cc | 70 ++-- storage/maria/ha_maria.h | 4 +- storage/maria/ma_extra.c | 16 +- storage/mroonga/ha_mroonga.cpp | 358 ++++++++---------- storage/mroonga/ha_mroonga.hpp | 16 +- storage/myisam/ha_myisam.cc | 58 ++- storage/myisam/ha_myisam.h | 4 +- storage/myisam/mi_extra.c | 13 +- storage/spider/ha_spider.cc | 24 +- storage/spider/ha_spider.h | 4 +- 23 files changed, 354 insertions(+), 381 deletions(-) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index afa14310153..c85f5d5b21e 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -717,4 +717,16 @@ a b update t1 set b='A' where a=1; ERROR 23000: Duplicate entry 'A' for key 'b' drop table t1; +# +# MDEV-25102 UNIQUE USING HASH error after ALTER ... DISABLE KEYS +# +create table t1 (i int, unique key (i) using hash); +alter table t1 disable keys; +insert into t1 values (1),(2); +insert into t1 values (1); +ERROR 23000: Duplicate entry '1' for key 'i' +alter table t1 enable keys; +insert into t1 values (2); +ERROR 23000: Duplicate entry '2' for key 'i' +drop table t1; # End of 10.5 tests diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index a0da2cd1873..aa89a78e0bd 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -685,4 +685,17 @@ select * from t1; update t1 set b='A' where a=1; drop table t1; +--echo # +--echo # MDEV-25102 UNIQUE USING HASH error after ALTER ... DISABLE KEYS +--echo # +create table t1 (i int, unique key (i) using hash); +alter table t1 disable keys; +insert into t1 values (1),(2); +--error ER_DUP_ENTRY +insert into t1 values (1); +alter table t1 enable keys; +--error ER_DUP_ENTRY +insert into t1 values (2); +drop table t1; + --echo # End of 10.5 tests diff --git a/mysql-test/suite/galera/r/galera_load_data.result b/mysql-test/suite/galera/r/galera_load_data.result index 80bea22480f..c275eb02ca5 100644 --- a/mysql-test/suite/galera/r/galera_load_data.result +++ b/mysql-test/suite/galera/r/galera_load_data.result @@ -26,8 +26,6 @@ PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1324 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED; LOCK TABLES cardtest_tbl WRITE; ALTER TABLE cardtest_tbl DISABLE KEYS; -Warnings: -Note 1031 Storage engine InnoDB of the table `cardtest02`.`cardtest_tbl` doesn't have this option INSERT INTO cardtest_tbl VALUES (1,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), (2,1,'','',1,1466430455,1471454450,NULL,10.00000,1,NULL,'','',NULL,NULL,1,NULL,NULL), diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 8ab9c346ca6..735d5c4442d 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1664,10 +1664,10 @@ bool ha_partition::is_crashed() const int ha_partition::prepare_new_partition(TABLE *tbl, HA_CREATE_INFO *create_info, handler *file, const char *part_name, - partition_element *p_elem, - uint disable_non_uniq_indexes) + partition_element *p_elem) { int error; + key_map keys_in_use= table->s->keys_in_use; DBUG_ENTER("prepare_new_partition"); /* @@ -1723,8 +1723,8 @@ int ha_partition::prepare_new_partition(TABLE *tbl, goto error_external_lock; DBUG_PRINT("info", ("partition %s external locked", part_name)); - if (disable_non_uniq_indexes) - file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + if (!keys_in_use.is_prefix(table->s->keys)) + file->ha_disable_indexes(keys_in_use, true); DBUG_RETURN(0); error_external_lock: @@ -2020,13 +2020,6 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, calls */ - /* - Before creating new partitions check whether indexes are disabled - in the partitions. - */ - - uint disable_non_uniq_indexes= indexes_are_disabled(); - i= 0; part_count= 0; part_it.rewind(); @@ -2068,8 +2061,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, prepare_new_partition(table, create_info, new_file_array[part], (const char *)part_name_buff, - sub_elem, - disable_non_uniq_indexes)))) + sub_elem)))) { cleanup_new_partition(part_count); DBUG_RETURN(error); @@ -2095,8 +2087,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, prepare_new_partition(table, create_info, new_file_array[i], (const char *)part_name_buff, - part_elem, - disable_non_uniq_indexes)))) + part_elem)))) { cleanup_new_partition(part_count); DBUG_RETURN(error); @@ -11054,7 +11045,7 @@ int ha_partition::calculate_checksum() != 0 Error */ -int ha_partition::disable_indexes(uint mode) +int ha_partition::disable_indexes(key_map map, bool persist) { handler **file; int error= 0; @@ -11062,7 +11053,7 @@ int ha_partition::disable_indexes(uint mode) DBUG_ASSERT(bitmap_is_set_all(&(m_part_info->lock_partitions))); for (file= m_file; *file; file++) { - if (unlikely((error= (*file)->ha_disable_indexes(mode)))) + if (unlikely((error= (*file)->ha_disable_indexes(map, persist)))) break; } return error; @@ -11079,7 +11070,7 @@ int ha_partition::disable_indexes(uint mode) != 0 Error */ -int ha_partition::enable_indexes(uint mode) +int ha_partition::enable_indexes(key_map map, bool persist) { handler **file; int error= 0; @@ -11087,7 +11078,7 @@ int ha_partition::enable_indexes(uint mode) DBUG_ASSERT(bitmap_is_set_all(&(m_part_info->lock_partitions))); for (file= m_file; *file; file++) { - if (unlikely((error= (*file)->ha_enable_indexes(mode)))) + if (unlikely((error= (*file)->ha_enable_indexes(map, persist)))) break; } return error; diff --git a/sql/ha_partition.h b/sql/ha_partition.h index a38aca2691b..e86928ce2d9 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -575,8 +575,7 @@ private: void cleanup_new_partition(uint part_count); int prepare_new_partition(TABLE *table, HA_CREATE_INFO *create_info, handler *file, const char *part_name, - partition_element *p_elem, - uint disable_non_uniq_indexes); + partition_element *p_elem); /* delete_table and rename_table uses very similar logic which is packed into this routine. @@ -1578,8 +1577,8 @@ public: Enable/Disable Indexes are only supported by HEAP and MyISAM. ------------------------------------------------------------------------- */ - int disable_indexes(uint mode) override; - int enable_indexes(uint mode) override; + int disable_indexes(key_map map, bool persist) override; + int enable_indexes(key_map map, bool persist) override; int indexes_are_disabled() override; /* diff --git a/sql/handler.cc b/sql/handler.cc index 4d03fcce8cd..b12014b55ec 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4909,32 +4909,48 @@ handler::ha_check_and_repair(THD *thd) /** Disable indexes: public interface. + @param map has 0 for all indexes that should be disabled + @param persist indexes should stay disabled after server restart + + Currently engines don't support disabling an arbitrary subset of indexes. + + In particular, if the change is persistent: + * auto-increment index should not be disabled + * unique indexes should not be disabled + + if unique or auto-increment indexes are disabled (non-persistently), + the caller should only insert data that does not require + auto-inc generation and does not violate uniqueness + @sa handler::disable_indexes() */ int -handler::ha_disable_indexes(uint mode) +handler::ha_disable_indexes(key_map map, bool persist) { DBUG_ASSERT(table->s->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); mark_trx_read_write(); - return disable_indexes(mode); + return disable_indexes(map, persist); } /** Enable indexes: public interface. + @param map has 1 for all indexes that should be enabled + @param persist indexes should stay enabled after server restart + @sa handler::enable_indexes() */ int -handler::ha_enable_indexes(uint mode) +handler::ha_enable_indexes(key_map map, bool persist) { DBUG_ASSERT(table->s->tmp_table != NO_TMP_TABLE || m_lock_type != F_UNLCK); mark_trx_read_write(); - return enable_indexes(mode); + return enable_indexes(map, persist); } diff --git a/sql/handler.h b/sql/handler.h index f858553c7b7..2be0b3372f3 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -445,12 +445,6 @@ enum chf_create_flags { #define HA_FAST_CHANGE_PARTITION (1UL << 13) #define HA_PARTITION_ONE_PHASE (1UL << 14) -/* operations for disable/enable indexes */ -#define HA_KEY_SWITCH_NONUNIQ 0 -#define HA_KEY_SWITCH_ALL 1 -#define HA_KEY_SWITCH_NONUNIQ_SAVE 2 -#define HA_KEY_SWITCH_ALL_SAVE 3 - /* Note: the following includes binlog and closing 0. TODO remove the limit, use dynarrays @@ -3439,8 +3433,8 @@ public: int ha_optimize(THD* thd, HA_CHECK_OPT* check_opt); int ha_analyze(THD* thd, HA_CHECK_OPT* check_opt); bool ha_check_and_repair(THD *thd); - int ha_disable_indexes(uint mode); - int ha_enable_indexes(uint mode); + int ha_disable_indexes(key_map map, bool persist); + int ha_enable_indexes(key_map map, bool persist); int ha_discard_or_import_tablespace(my_bool discard); int ha_rename_table(const char *from, const char *to); void ha_drop_table(const char *name); @@ -4950,8 +4944,8 @@ public: virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt) { return HA_ADMIN_NOT_IMPLEMENTED; } virtual bool check_and_repair(THD *thd) { return TRUE; } - virtual int disable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; } - virtual int enable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; } + virtual int disable_indexes(key_map map, bool persist) { return HA_ERR_WRONG_COMMAND; } + virtual int enable_indexes(key_map map, bool persist) { return HA_ERR_WRONG_COMMAND; } virtual int discard_or_import_tablespace(my_bool discard) { return (my_errno=HA_ERR_WRONG_COMMAND); } virtual void drop_table(const char *name); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3b30c2f1789..54251e2d3ad 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -20401,7 +20401,7 @@ create_internal_tmp_table_from_heap(THD *thd, TABLE *table, if (open_tmp_table(&new_table)) goto err1; if (table->file->indexes_are_disabled()) - new_table.file->ha_disable_indexes(HA_KEY_SWITCH_ALL); + new_table.file->ha_disable_indexes(key_map(0), false); table->file->ha_index_or_rnd_end(); if (table->file->ha_rnd_init_with_error(1)) DBUG_RETURN(1); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2af1194074a..7941f1de78c 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7955,14 +7955,28 @@ bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled, switch (keys_onoff) { case Alter_info::ENABLE: DEBUG_SYNC(table->in_use, "alter_table_enable_indexes"); - error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + error= table->file->ha_enable_indexes(key_map(table->s->keys), true); break; case Alter_info::LEAVE_AS_IS: if (!indexes_were_disabled) break; /* fall through */ case Alter_info::DISABLE: - error= table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + { + key_map map= table->s->keys_in_use; + bool do_clear= false; + for (uint i=0; i < table->s->keys; i++) + { + if (!(table->s->key_info[i].flags & HA_NOSAME) && + i != table->s->next_number_index) + { + map.clear_bit(i); + do_clear= true; + } + } + if (do_clear) + error= table->file->ha_disable_indexes(map, true); + } } if (unlikely(error)) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index c3c4198439a..8cbb35fc9a4 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -485,7 +485,7 @@ bool select_unit_ext::disable_index_if_needed(SELECT_LEX *curr_sl) !curr_sl->next_select()) ) { is_index_enabled= false; - if (table->file->ha_disable_indexes(HA_KEY_SWITCH_ALL)) + if (table->file->ha_disable_indexes(key_map(0), false)) return false; table->no_keyread=1; return true; @@ -2086,7 +2086,7 @@ bool st_select_lex_unit::optimize() /* re-enabling indexes for next subselect iteration */ if ((union_result->force_enable_index_if_needed() || union_distinct)) { - if(table->file->ha_enable_indexes(HA_KEY_SWITCH_ALL)) + if(table->file->ha_enable_indexes(key_map(table->s->keys), false)) DBUG_ASSERT(0); else table->no_keyread= 0; @@ -2186,7 +2186,7 @@ bool st_select_lex_unit::exec() union_result->table && union_result->table->is_created()) { union_result->table->file->ha_delete_all_rows(); - union_result->table->file->ha_enable_indexes(HA_KEY_SWITCH_ALL); + union_result->table->file->ha_enable_indexes(key_map(table->s->keys), false); } } @@ -2253,7 +2253,7 @@ bool st_select_lex_unit::exec() { // This is UNION DISTINCT, so there should be a fake_select_lex DBUG_ASSERT(fake_select_lex != NULL); - if (unlikely(table->file->ha_disable_indexes(HA_KEY_SWITCH_ALL))) + if (table->file->ha_disable_indexes(key_map(0), false)) DBUG_RETURN(TRUE); table->no_keyread=1; } diff --git a/sql/table.cc b/sql/table.cc index 72bc7835a3c..cc8fb094e36 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -9226,7 +9226,8 @@ bool TABLE::insert_all_rows_into_tmp_table(THD *thd, } if (file->indexes_are_disabled()) - tmp_table->file->ha_disable_indexes(HA_KEY_SWITCH_ALL); + tmp_table->file->ha_disable_indexes(key_map(0), false); + file->ha_index_or_rnd_end(); if (unlikely(file->ha_rnd_init_with_error(1))) diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 5f7f0c1efa0..404ad22a88a 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -440,31 +440,22 @@ int ha_heap::external_lock(THD *thd, int lock_type) SYNOPSIS disable_indexes() - mode mode of operation: - HA_KEY_SWITCH_NONUNIQ disable all non-unique keys - HA_KEY_SWITCH_ALL disable all keys - HA_KEY_SWITCH_NONUNIQ_SAVE dis. non-uni. and make persistent - HA_KEY_SWITCH_ALL_SAVE dis. all keys and make persistent DESCRIPTION - Disable indexes and clear keys to use for scanning. - - IMPLEMENTATION - HA_KEY_SWITCH_NONUNIQ is not implemented. - HA_KEY_SWITCH_NONUNIQ_SAVE is not implemented with HEAP. - HA_KEY_SWITCH_ALL_SAVE is not implemented with HEAP. + See handler::ha_disable_indexes() RETURN 0 ok HA_ERR_WRONG_COMMAND mode not implemented. */ -int ha_heap::disable_indexes(uint mode) +int ha_heap::disable_indexes(key_map map, bool persist) { int error; - if (mode == HA_KEY_SWITCH_ALL) + if (!persist) { + DBUG_ASSERT(map.is_clear_all()); if (!(error= heap_disable_indexes(file))) set_keys_for_scanning(); } @@ -482,11 +473,6 @@ int ha_heap::disable_indexes(uint mode) SYNOPSIS enable_indexes() - mode mode of operation: - HA_KEY_SWITCH_NONUNIQ enable all non-unique keys - HA_KEY_SWITCH_ALL enable all keys - HA_KEY_SWITCH_NONUNIQ_SAVE en. non-uni. and make persistent - HA_KEY_SWITCH_ALL_SAVE en. all keys and make persistent DESCRIPTION Enable indexes and set keys to use for scanning. @@ -495,10 +481,7 @@ int ha_heap::disable_indexes(uint mode) since the heap storage engine cannot repair the indexes. To be sure, call handler::delete_all_rows() before. - IMPLEMENTATION - HA_KEY_SWITCH_NONUNIQ is not implemented. - HA_KEY_SWITCH_NONUNIQ_SAVE is not implemented with HEAP. - HA_KEY_SWITCH_ALL_SAVE is not implemented with HEAP. + See also handler::ha_enable_indexes() RETURN 0 ok @@ -506,12 +489,13 @@ int ha_heap::disable_indexes(uint mode) HA_ERR_WRONG_COMMAND mode not implemented. */ -int ha_heap::enable_indexes(uint mode) +int ha_heap::enable_indexes(key_map map, bool persist) { int error; - if (mode == HA_KEY_SWITCH_ALL) + if (!persist) { + DBUG_ASSERT(map.is_prefix(table->s->keys)); if (!(error= heap_enable_indexes(file))) set_keys_for_scanning(); } diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h index 18e0d1a92d5..d8636f7fc7e 100644 --- a/storage/heap/ha_heap.h +++ b/storage/heap/ha_heap.h @@ -101,8 +101,8 @@ public: int external_lock(THD *thd, int lock_type); int delete_all_rows(void); int reset_auto_increment(ulonglong value); - int disable_indexes(uint mode); - int enable_indexes(uint mode); + int disable_indexes(key_map map, bool persist); + int enable_indexes(key_map map, bool persist); int indexes_are_disabled(void); ha_rows records_in_range(uint inx, const key_range *start_key, const key_range *end_key, page_range *pages); diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 998255e21e0..fae1cdcd816 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -1924,40 +1924,45 @@ int ha_maria::preload_keys(THD * thd, HA_CHECK_OPT *check_opt) SYNOPSIS disable_indexes() - mode mode of operation: - HA_KEY_SWITCH_NONUNIQ disable all non-unique keys - HA_KEY_SWITCH_ALL disable all keys - HA_KEY_SWITCH_NONUNIQ_SAVE dis. non-uni. and make persistent - HA_KEY_SWITCH_ALL_SAVE dis. all keys and make persistent - IMPLEMENTATION - HA_KEY_SWITCH_NONUNIQ is not implemented. - HA_KEY_SWITCH_ALL_SAVE is not implemented. + DESCRIPTION + See handler::ha_disable_indexes() RETURN 0 ok HA_ERR_WRONG_COMMAND mode not implemented. */ -int ha_maria::disable_indexes(uint mode) +int ha_maria::disable_indexes(key_map map, bool persist) { int error; - if (mode == HA_KEY_SWITCH_ALL) + if (!persist) { /* call a storage engine function to switch the key map */ + DBUG_ASSERT(map.is_clear_all()); error= maria_disable_indexes(file); } - else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) - { - maria_extra(file, HA_EXTRA_NO_KEYS, 0); - info(HA_STATUS_CONST); // Read new key info - error= 0; - } else { - /* mode not implemented */ - error= HA_ERR_WRONG_COMMAND; + /* auto-inc key cannot be disabled */ + if (table->s->next_number_index < MAX_KEY) + DBUG_ASSERT(map.is_set(table->s->next_number_index)); + + /* unique keys cannot be disabled either */ + for (uint i=0; i < table->s->keys; i++) + DBUG_ASSERT(!(table->key_info[i].flags & HA_NOSAME) || map.is_set(i)); + + ulonglong ullmap= map.to_ulonglong(); + + /* make sure auto-inc key is enabled even if it's > 64 */ + if (map.length() > MARIA_KEYMAP_BITS && + table->s->next_number_index < MAX_KEY) + maria_set_key_active(ullmap, table->s->next_number_index); + + maria_extra(file, HA_EXTRA_NO_KEYS, &ullmap); + info(HA_STATUS_CONST); // Read new key info + error= 0; } return error; } @@ -1968,21 +1973,14 @@ int ha_maria::disable_indexes(uint mode) SYNOPSIS enable_indexes() - mode mode of operation: - HA_KEY_SWITCH_NONUNIQ enable all non-unique keys - HA_KEY_SWITCH_ALL enable all keys - HA_KEY_SWITCH_NONUNIQ_SAVE en. non-uni. and make persistent - HA_KEY_SWITCH_ALL_SAVE en. all keys and make persistent DESCRIPTION Enable indexes, which might have been disabled by disable_index() before. - The modes without _SAVE work only if both data and indexes are empty, - since the MARIA repair would enable them persistently. + If persist=false, it works only if both data and indexes are empty, + since the Aria repair would enable them persistently. To be sure in these cases, call handler::delete_all_rows() before. - IMPLEMENTATION - HA_KEY_SWITCH_NONUNIQ is not implemented. - HA_KEY_SWITCH_ALL_SAVE is not implemented. + See also handler::ha_enable_indexes() RETURN 0 ok @@ -1991,18 +1989,19 @@ int ha_maria::disable_indexes(uint mode) HA_ERR_WRONG_COMMAND mode not implemented. */ -int ha_maria::enable_indexes(uint mode) +int ha_maria::enable_indexes(key_map map, bool persist) { int error; ha_rows start_rows= file->state->records; - DBUG_PRINT("info", ("ha_maria::enable_indexes mode: %d", mode)); + DBUG_PRINT("info", ("ha_maria::enable_indexes mode: %d", persist)); if (maria_is_all_keys_active(file->s->state.key_map, file->s->base.keys)) { /* All indexes are enabled already. */ return 0; } - if (mode == HA_KEY_SWITCH_ALL) + DBUG_ASSERT(map.is_prefix(table->s->keys)); + if (!persist) { error= maria_enable_indexes(file); /* @@ -2011,7 +2010,7 @@ int ha_maria::enable_indexes(uint mode) but mode==HA_KEY_SWITCH_ALL forbids it. */ } - else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) + else { THD *thd= table->in_use; HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param); @@ -2076,11 +2075,6 @@ int ha_maria::enable_indexes(uint mode) info(HA_STATUS_CONST); thd_proc_info(thd, save_proc_info); } - else - { - /* mode not implemented */ - error= HA_ERR_WRONG_COMMAND; - } DBUG_EXECUTE_IF("maria_flush_whole_log", { DBUG_PRINT("maria_flush_whole_log", ("now")); @@ -2292,7 +2286,7 @@ int ha_maria::end_bulk_insert() } if (!abort && can_enable_indexes) - if ((error= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE))) + if ((error= enable_indexes(key_map(table->s->keys), true))) first_error= first_error ? first_error : error; if (bulk_insert_single_undo != BULK_INSERT_NONE) diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index 2b8b5dc9742..41f644364bd 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -122,8 +122,8 @@ public: int external_lock(THD * thd, int lock_type) override; int start_stmt(THD *thd, thr_lock_type lock_type) override final; int delete_all_rows(void) override final; - int disable_indexes(uint mode) override final; - int enable_indexes(uint mode) override final; + int disable_indexes(key_map map, bool persist) override final; + int enable_indexes(key_map map, bool persist) override final; int indexes_are_disabled(void) override final; void start_bulk_insert(ha_rows rows, uint flags) override final; int end_bulk_insert() override final; diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 3ab150862a2..6be1edbc5ce 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -239,25 +239,17 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, break; /* we're going to modify pieces of the state, stall Checkpoint */ - mysql_mutex_lock(&share->intern_lock); if (info->lock_type == F_UNLCK) { - mysql_mutex_unlock(&share->intern_lock); error= 1; /* Not possibly if not lock */ break; } + mysql_mutex_lock(&share->intern_lock); if (maria_is_any_key_active(share->state.key_map)) { - MARIA_KEYDEF *key= share->keyinfo; - uint i; - for (i =0 ; i < share->base.keys ; i++,key++) - { - if (!(key->flag & HA_NOSAME) && info->s->base.auto_key != i+1) - { - maria_clear_key_active(share->state.key_map, i); - info->update|= HA_STATE_CHANGED; - } - } + if (share->state.key_map != *(ulonglong*)extra_arg) + info->update|= HA_STATE_CHANGED; + share->state.key_map= *(ulonglong*)extra_arg; if (!share->changed) { diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 5c04add0dab..2077b0b8863 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -4337,9 +4337,9 @@ int ha_mroonga::wrapper_open(const char *name, int mode, uint open_options) // TODO: implemented by "reindex" instead of "remove and recreate". // Because "remove and recreate" invalidates opened indexes by // other threads. - error = wrapper_disable_indexes_mroonga(HA_KEY_SWITCH_ALL); + error = wrapper_disable_indexes_mroonga(key_map(table->s->keys), false); if (!error) { - error = wrapper_enable_indexes_mroonga(HA_KEY_SWITCH_ALL); + error = wrapper_enable_indexes_mroonga(key_map(table->s->keys), false); } } } @@ -13625,197 +13625,184 @@ int ha_mroonga::generic_disable_index(int i, KEY *key_info) DBUG_RETURN(error); } -int ha_mroonga::wrapper_disable_indexes_mroonga(uint mode) +int ha_mroonga::wrapper_disable_indexes_mroonga(key_map map, bool persist) { int error = 0; MRN_DBUG_ENTER_METHOD(); - if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE || mode == HA_KEY_SWITCH_ALL) { - uint i; - for (i = 0; i < table_share->keys; i++) { - if (i == table->s->primary_key) { - continue; - } - if (share->wrap_key_nr[i] < MAX_KEY) { - continue; - } - if (!grn_index_tables[i]) { - DBUG_PRINT("info", ("mroonga: keys are disabled already %u", i)); - DBUG_RETURN(0); - } + uint i; + for (i = 0; i < table_share->keys; i++) { + if (i == table->s->primary_key) { + continue; + } + if (share->wrap_key_nr[i] < MAX_KEY) { + continue; + } + if (!grn_index_tables[i]) { + DBUG_PRINT("info", ("mroonga: keys are disabled already %u", i)); + DBUG_RETURN(0); + } + } + KEY *key_info = table_share->key_info; + for (i = 0; i < table_share->keys; i++) { + if (!(key_info[i].flags & HA_FULLTEXT) && + !mrn_is_geo_key(&key_info[i])) { + continue; } - KEY *key_info = table_share->key_info; - for (i = 0; i < table_share->keys; i++) { - if (!(key_info[i].flags & HA_FULLTEXT) && - !mrn_is_geo_key(&key_info[i])) { - continue; - } - int sub_error = generic_disable_index(i, key_info); - if (error != 0 && sub_error != 0) { - error = sub_error; - } + int sub_error = generic_disable_index(i, key_info); + if (error != 0 && sub_error != 0) { + error = sub_error; } - } else { - error = HA_ERR_WRONG_COMMAND; } DBUG_RETURN(error); } -int ha_mroonga::wrapper_disable_indexes(uint mode) +int ha_mroonga::wrapper_disable_indexes(key_map map, bool persist) { int error = 0; MRN_DBUG_ENTER_METHOD(); MRN_SET_WRAP_SHARE_KEY(share, table->s); MRN_SET_WRAP_TABLE_KEY(this, table); - error = wrap_handler->ha_disable_indexes(mode); + error = wrap_handler->ha_disable_indexes(map, persist); MRN_SET_BASE_SHARE_KEY(share, table->s); MRN_SET_BASE_TABLE_KEY(this, table); if (error == HA_ERR_WRONG_COMMAND) { error = 0; } if (!error) { - error = wrapper_disable_indexes_mroonga(mode); + error = wrapper_disable_indexes_mroonga(map, persist); } DBUG_RETURN(error); } -int ha_mroonga::storage_disable_indexes(uint mode) +int ha_mroonga::storage_disable_indexes(key_map map, bool persist) { int error = 0; MRN_DBUG_ENTER_METHOD(); - if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE || mode == HA_KEY_SWITCH_ALL) { - uint i; - for (i = 0; i < table_share->keys; i++) { - if (i == table->s->primary_key) { - continue; - } - if (!grn_index_tables[i]) { - DBUG_PRINT("info", ("mroonga: keys are disabled already %u", i)); - DBUG_RETURN(0); - } + uint i; + for (i = 0; i < table_share->keys; i++) { + if (i == table->s->primary_key) { + continue; + } + if (!grn_index_tables[i]) { + DBUG_PRINT("info", ("mroonga: keys are disabled already %u", i)); + DBUG_RETURN(0); + } + } + KEY *key_info = table_share->key_info; + for (i = 0; i < table_share->keys; i++) { + if (i == table->s->primary_key) { + continue; + } + if (map.is_set(i)) { + continue; } - KEY *key_info = table_share->key_info; - for (i = 0; i < table_share->keys; i++) { - if (i == table->s->primary_key) { - continue; - } - if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE && - (key_info[i].flags & HA_NOSAME)) { - continue; - } - int sub_error = generic_disable_index(i, key_info); - if (error != 0 && sub_error != 0) { - error = sub_error; - } + int sub_error = generic_disable_index(i, key_info); + if (error != 0 && sub_error != 0) { + error = sub_error; } - } else { - DBUG_RETURN(HA_ERR_WRONG_COMMAND); } DBUG_RETURN(error); } -int ha_mroonga::disable_indexes(uint mode) +int ha_mroonga::disable_indexes(key_map map, bool persist) { int error = 0; MRN_DBUG_ENTER_METHOD(); if (share->wrapper_mode) { - error = wrapper_disable_indexes(mode); + error = wrapper_disable_indexes(map, persist); } else { - error = storage_disable_indexes(mode); + error = storage_disable_indexes(map, persist); } DBUG_RETURN(error); } -int ha_mroonga::wrapper_enable_indexes_mroonga(uint mode) +int ha_mroonga::wrapper_enable_indexes_mroonga(key_map map, bool persist) { int error = 0; MRN_DBUG_ENTER_METHOD(); - if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE || mode == HA_KEY_SWITCH_ALL) { - uint i, j; - for (i = 0; i < table_share->keys; i++) { - if (i == table->s->primary_key) { - continue; - } - if (share->wrap_key_nr[i] < MAX_KEY) { - continue; - } - if (!grn_index_columns[i]) { - break; - } + uint i, j; + for (i = 0; i < table_share->keys; i++) { + if (i == table->s->primary_key) { + continue; } - if (i == table_share->keys) { - DBUG_PRINT("info", ("mroonga: keys are enabled already")); - DBUG_RETURN(0); + if (share->wrap_key_nr[i] < MAX_KEY) { + continue; + } + if (!grn_index_columns[i]) { + break; + } + } + if (i == table_share->keys) { + DBUG_PRINT("info", ("mroonga: keys are enabled already")); + DBUG_RETURN(0); + } + KEY *p_key_info = &table->key_info[table_share->primary_key]; + KEY *key_info = table_share->key_info; + uint n_keys = table_share->keys; + MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(grn_obj *, index_tables, n_keys); + MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(grn_obj *, index_columns, n_keys); + bitmap_clear_all(table->read_set); + mrn_set_bitmap_by_key(table->read_set, p_key_info); + mrn::PathMapper mapper(share->table_name); + for (i = 0, j = 0; i < n_keys; i++) { + if (!(key_info[i].flags & HA_FULLTEXT) && + !mrn_is_geo_key(&key_info[i])) { + j++; + continue; } - KEY *p_key_info = &table->key_info[table_share->primary_key]; - KEY *key_info = table_share->key_info; - uint n_keys = table_share->keys; - MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(grn_obj *, index_tables, n_keys); - MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(grn_obj *, index_columns, n_keys); - bitmap_clear_all(table->read_set); - mrn_set_bitmap_by_key(table->read_set, p_key_info); - mrn::PathMapper mapper(share->table_name); - for (i = 0, j = 0; i < n_keys; i++) { - if (!(key_info[i].flags & HA_FULLTEXT) && - !mrn_is_geo_key(&key_info[i])) { - j++; - continue; - } - if ((error = mrn_add_index_param(share, &key_info[i], i))) - { - break; - } - index_tables[i] = NULL; - index_columns[i] = NULL; - if (!grn_index_columns[i]) { - if ( - (key_info[i].flags & HA_FULLTEXT) && - (error = wrapper_create_index_fulltext(mapper.table_name(), - i, &key_info[i], - index_tables, index_columns, - share)) - ) { - break; - } else if ( - mrn_is_geo_key(&key_info[i]) && - (error = wrapper_create_index_geo(mapper.table_name(), - i, &key_info[i], - index_tables, index_columns, - share)) - ) { - break; - } - grn_index_columns[i] = index_columns[i]; - } - mrn_set_bitmap_by_key(table->read_set, &key_info[i]); - } - if (!error && i > j) + if ((error = mrn_add_index_param(share, &key_info[i], i))) { - error = wrapper_fill_indexes(ha_thd(), table->key_info, index_columns, - n_keys); + break; } - bitmap_set_all(table->read_set); - MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_tables); - MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_columns); - } else { - error = HA_ERR_WRONG_COMMAND; + index_tables[i] = NULL; + index_columns[i] = NULL; + if (!grn_index_columns[i]) { + if ( + (key_info[i].flags & HA_FULLTEXT) && + (error = wrapper_create_index_fulltext(mapper.table_name(), + i, &key_info[i], + index_tables, index_columns, + share)) + ) { + break; + } else if ( + mrn_is_geo_key(&key_info[i]) && + (error = wrapper_create_index_geo(mapper.table_name(), + i, &key_info[i], + index_tables, index_columns, + share)) + ) { + break; + } + grn_index_columns[i] = index_columns[i]; + } + mrn_set_bitmap_by_key(table->read_set, &key_info[i]); } + if (!error && i > j) + { + error = wrapper_fill_indexes(ha_thd(), table->key_info, index_columns, + n_keys); + } + bitmap_set_all(table->read_set); + MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_tables); + MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_columns); DBUG_RETURN(error); } -int ha_mroonga::wrapper_enable_indexes(uint mode) +int ha_mroonga::wrapper_enable_indexes(key_map map, bool persist) { int error = 0; MRN_DBUG_ENTER_METHOD(); - int mroonga_error = wrapper_enable_indexes_mroonga(mode); + int mroonga_error = wrapper_enable_indexes_mroonga(map, persist); MRN_SET_WRAP_SHARE_KEY(share, table->s); MRN_SET_WRAP_TABLE_KEY(this, table); - error = wrap_handler->ha_enable_indexes(mode); + error = wrap_handler->ha_enable_indexes(map, persist); MRN_SET_BASE_SHARE_KEY(share, table->s); MRN_SET_BASE_TABLE_KEY(this, table); if (error == HA_ERR_WRONG_COMMAND) { @@ -13824,95 +13811,86 @@ int ha_mroonga::wrapper_enable_indexes(uint mode) DBUG_RETURN(error); } -int ha_mroonga::storage_enable_indexes(uint mode) +int ha_mroonga::storage_enable_indexes(key_map map, bool persist) { int error = 0; uint n_keys = table_share->keys; MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(grn_obj *, index_tables, n_keys); MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(grn_obj *, index_columns, n_keys); bool have_multiple_column_index = false; - bool skip_unique_key = (mode == HA_KEY_SWITCH_NONUNIQ_SAVE); MRN_DBUG_ENTER_METHOD(); - if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE || mode == HA_KEY_SWITCH_ALL) { - uint i; - for (i = 0; i < table_share->keys; i++) { - if (i == table->s->primary_key) { - continue; - } - if (!grn_index_columns[i]) { - break; - } + uint i; + for (i = 0; i < n_keys; i++) { + if (i == table->s->primary_key) { + continue; } - if (i == table_share->keys) { - DBUG_PRINT("info", ("mroonga: keys are enabled already")); - MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_tables); - MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_columns); - DBUG_RETURN(0); + if (!grn_index_columns[i]) { + break; + } + } + if (i == n_keys) { + DBUG_PRINT("info", ("mroonga: keys are enabled already")); + MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_tables); + MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_columns); + DBUG_RETURN(0); + } + KEY *key_info = table->key_info; + bitmap_clear_all(table->read_set); + mrn::PathMapper mapper(share->table_name); + for (; i < n_keys; i++) { + if (!map.is_set(i)) { + continue; } - KEY *key_info = table->key_info; - bitmap_clear_all(table->read_set); - mrn::PathMapper mapper(share->table_name); - for (i = 0; i < n_keys; i++) { - if (i == table->s->primary_key) { - continue; - } - if (skip_unique_key && (key_info[i].flags & HA_NOSAME)) { - continue; - } - if ((error = mrn_add_index_param(share, &key_info[i], i))) + if ((error = mrn_add_index_param(share, &key_info[i], i))) + { + break; + } + index_tables[i] = NULL; + if (!grn_index_columns[i]) { + if ((error = storage_create_index(table, mapper.table_name(), grn_table, + share, &key_info[i], index_tables, + index_columns, i))) { break; } - index_tables[i] = NULL; - if (!grn_index_columns[i]) { - if ((error = storage_create_index(table, mapper.table_name(), grn_table, - share, &key_info[i], index_tables, - index_columns, i))) - { - break; - } - if ( - KEY_N_KEY_PARTS(&(key_info[i])) != 1 && - !(key_info[i].flags & HA_FULLTEXT) - ) { - mrn_set_bitmap_by_key(table->read_set, &key_info[i]); - have_multiple_column_index = true; - } - grn_index_tables[i] = index_tables[i]; - grn_index_columns[i] = index_columns[i]; - } else { - index_columns[i] = NULL; + if ( + KEY_N_KEY_PARTS(&(key_info[i])) != 1 && + !(key_info[i].flags & HA_FULLTEXT) + ) { + mrn_set_bitmap_by_key(table->read_set, &key_info[i]); + have_multiple_column_index = true; } + grn_index_tables[i] = index_tables[i]; + grn_index_columns[i] = index_columns[i]; + } else { + index_columns[i] = NULL; } - if (!error && have_multiple_column_index) - { - error = storage_add_index_multiple_columns(key_info, n_keys, - index_tables, - index_columns, - skip_unique_key); - } - bitmap_set_all(table->read_set); - } else { - MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_tables); - MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_columns); - DBUG_RETURN(HA_ERR_WRONG_COMMAND); } + if (!error && have_multiple_column_index) + { + bool skip_unique_key= !table->s->keys_in_use.is_clear_all(); + error = storage_add_index_multiple_columns(key_info, n_keys, + index_tables, + index_columns, + skip_unique_key); + } + bitmap_set_all(table->read_set); MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_tables); MRN_FREE_VARIABLE_LENGTH_ARRAYS(index_columns); DBUG_RETURN(error); } -int ha_mroonga::enable_indexes(uint mode) +int ha_mroonga::enable_indexes(key_map map, bool persist) { int error = 0; MRN_DBUG_ENTER_METHOD(); share->disable_keys = false; if (share->wrapper_mode) { - error = wrapper_enable_indexes(mode); + error = wrapper_enable_indexes(map, persist); } else { - error = storage_enable_indexes(mode); + error = storage_enable_indexes(map, persist); } DBUG_RETURN(error); } diff --git a/storage/mroonga/ha_mroonga.hpp b/storage/mroonga/ha_mroonga.hpp index 66767899e21..6bf971aa347 100644 --- a/storage/mroonga/ha_mroonga.hpp +++ b/storage/mroonga/ha_mroonga.hpp @@ -542,8 +542,8 @@ public: bool is_crashed() const mrn_override; bool auto_repair(int error) const mrn_override; bool auto_repair() const; - int disable_indexes(uint mode) mrn_override; - int enable_indexes(uint mode) mrn_override; + int disable_indexes(key_map map, bool persist) mrn_override; + int enable_indexes(key_map map, bool persist) mrn_override; int check(THD* thd, HA_CHECK_OPT* check_opt) mrn_override; int repair(THD* thd, HA_CHECK_OPT* check_opt) mrn_override; bool check_and_repair(THD *thd) mrn_override; @@ -1140,12 +1140,12 @@ private: bool wrapper_auto_repair(int error) const; bool storage_auto_repair(int error) const; int generic_disable_index(int i, KEY *key_info); - int wrapper_disable_indexes_mroonga(uint mode); - int wrapper_disable_indexes(uint mode); - int storage_disable_indexes(uint mode); - int wrapper_enable_indexes_mroonga(uint mode); - int wrapper_enable_indexes(uint mode); - int storage_enable_indexes(uint mode); + int wrapper_disable_indexes_mroonga(key_map map, bool persist); + int wrapper_disable_indexes(key_map map, bool persist); + int storage_disable_indexes(key_map map, bool persist); + int wrapper_enable_indexes_mroonga(key_map map, bool persist); + int wrapper_enable_indexes(key_map map, bool persist); + int storage_enable_indexes(key_map map, bool persist); int wrapper_check(THD* thd, HA_CHECK_OPT* check_opt); int storage_check(THD* thd, HA_CHECK_OPT* check_opt); int wrapper_fill_indexes(THD *thd, KEY *key_info, diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 59171cfcbcd..022a7bb6819 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1569,40 +1569,37 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt) SYNOPSIS disable_indexes() - mode mode of operation: - HA_KEY_SWITCH_NONUNIQ disable all non-unique keys - HA_KEY_SWITCH_ALL disable all keys - HA_KEY_SWITCH_NONUNIQ_SAVE dis. non-uni. and make persistent - HA_KEY_SWITCH_ALL_SAVE dis. all keys and make persistent - IMPLEMENTATION - HA_KEY_SWITCH_NONUNIQ is not implemented. - HA_KEY_SWITCH_ALL_SAVE is not implemented. + DESCRIPTION + See handler::ha_disable_indexes() RETURN 0 ok HA_ERR_WRONG_COMMAND mode not implemented. */ -int ha_myisam::disable_indexes(uint mode) +int ha_myisam::disable_indexes(key_map map, bool persist) { int error; - if (mode == HA_KEY_SWITCH_ALL) + if (!persist) { /* call a storage engine function to switch the key map */ + DBUG_ASSERT(map.is_clear_all()); error= mi_disable_indexes(file); } - else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) - { - mi_extra(file, HA_EXTRA_NO_KEYS, 0); - info(HA_STATUS_CONST); // Read new key info - error= 0; - } else { - /* mode not implemented */ - error= HA_ERR_WRONG_COMMAND; + ulonglong ullmap= map.to_ulonglong(); + + /* make sure auto-inc key is enabled even if it's > 64 */ + if (map.length() > MI_KEYMAP_BITS && + table->s->next_number_index < MAX_KEY) + mi_set_key_active(ullmap, table->s->next_number_index); + + mi_extra(file, HA_EXTRA_NO_KEYS, &ullmap); + info(HA_STATUS_CONST); // Read new key info + error= 0; } return error; } @@ -1613,21 +1610,14 @@ int ha_myisam::disable_indexes(uint mode) SYNOPSIS enable_indexes() - mode mode of operation: - HA_KEY_SWITCH_NONUNIQ enable all non-unique keys - HA_KEY_SWITCH_ALL enable all keys - HA_KEY_SWITCH_NONUNIQ_SAVE en. non-uni. and make persistent - HA_KEY_SWITCH_ALL_SAVE en. all keys and make persistent DESCRIPTION Enable indexes, which might have been disabled by disable_index() before. - The modes without _SAVE work only if both data and indexes are empty, + If persist=false, it works only if both data and indexes are empty, since the MyISAM repair would enable them persistently. To be sure in these cases, call handler::delete_all_rows() before. - IMPLEMENTATION - HA_KEY_SWITCH_NONUNIQ is not implemented. - HA_KEY_SWITCH_ALL_SAVE is not implemented. + See also handler::ha_enable_indexes() RETURN 0 ok @@ -1636,7 +1626,7 @@ int ha_myisam::disable_indexes(uint mode) HA_ERR_WRONG_COMMAND mode not implemented. */ -int ha_myisam::enable_indexes(uint mode) +int ha_myisam::enable_indexes(key_map map, bool persist) { int error; DBUG_ENTER("ha_myisam::enable_indexes"); @@ -1650,7 +1640,8 @@ int ha_myisam::enable_indexes(uint mode) DBUG_RETURN(0); } - if (mode == HA_KEY_SWITCH_ALL) + DBUG_ASSERT(map.is_prefix(table->s->keys)); + if (!persist) { error= mi_enable_indexes(file); /* @@ -1659,7 +1650,7 @@ int ha_myisam::enable_indexes(uint mode) but mode==HA_KEY_SWITCH_ALL forbids it. */ } - else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) + else { THD *thd= table->in_use; int was_error= thd->is_error(); @@ -1719,11 +1710,6 @@ int ha_myisam::enable_indexes(uint mode) restore_vcos_after_repair(); } - else - { - /* mode not implemented */ - error= HA_ERR_WRONG_COMMAND; - } DBUG_RETURN(error); } @@ -1886,7 +1872,7 @@ int ha_myisam::end_bulk_insert() setting the indexes as active and trying to recreate them. */ - if (((first_error= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)) != 0) && + if (((first_error= enable_indexes(key_map(table->s->keys), true))) && table->in_use->killed) { delete_all_rows(); diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index c4c46a63afa..e0121dbeb51 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -109,8 +109,8 @@ class ha_myisam final : public handler int external_lock(THD *thd, int lock_type); int delete_all_rows(void); int reset_auto_increment(ulonglong value); - int disable_indexes(uint mode); - int enable_indexes(uint mode); + int disable_indexes(key_map map, bool persist); + int enable_indexes(key_map map, bool persist); int indexes_are_disabled(void); void start_bulk_insert(ha_rows rows, uint flags); int end_bulk_insert(); diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 4f3326098f6..4ce138e888c 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -225,16 +225,9 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) } if (mi_is_any_key_active(share->state.key_map)) { - MI_KEYDEF *key=share->keyinfo; - uint i; - for (i=0 ; i < share->base.keys ; i++,key++) - { - if (!(key->flag & HA_NOSAME) && info->s->base.auto_key != i+1) - { - mi_clear_key_active(share->state.key_map, i); - info->update|= HA_STATE_CHANGED; - } - } + if (share->state.key_map != *(ulonglong*)extra_arg) + info->update|= HA_STATE_CHANGED; + share->state.key_map= *(ulonglong*)extra_arg; if (!share->changed) { diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index ba0fd150dcf..997f57ab6c8 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -11774,27 +11774,35 @@ bool ha_spider::auto_repair() const } int ha_spider::disable_indexes( - uint mode + key_map map, bool persist ) { int error_num; backup_error_status(); DBUG_ENTER("ha_spider::disable_indexes"); DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = spider_db_disable_keys(this))) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); + if (persist) + { + if ((error_num = spider_db_disable_keys(this))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); + } + DBUG_RETURN(HA_ERR_WRONG_COMMAND); } int ha_spider::enable_indexes( - uint mode + key_map map, bool persist ) { int error_num; backup_error_status(); DBUG_ENTER("ha_spider::enable_indexes"); DBUG_PRINT("info",("spider this=%p", this)); - if ((error_num = spider_db_enable_keys(this))) - DBUG_RETURN(check_error_mode(error_num)); - DBUG_RETURN(0); + if (persist) + { + if ((error_num = spider_db_enable_keys(this))) + DBUG_RETURN(check_error_mode(error_num)); + DBUG_RETURN(0); + } + DBUG_RETURN(HA_ERR_WRONG_COMMAND); } diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h index b1301d91cab..89b39d585fa 100644 --- a/storage/spider/ha_spider.h +++ b/storage/spider/ha_spider.h @@ -791,10 +791,10 @@ public: bool auto_repair() const; #endif int disable_indexes( - uint mode + key_map map, bool persist ); int enable_indexes( - uint mode + key_map map, bool persist ); int check( THD* thd, From 98b157fdee40f74f935f24efff65e66dbe421b5a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 4 May 2024 17:05:29 +0200 Subject: [PATCH 289/313] cleanup: unused OPT_xxx and client_priv.h --- client/client_priv.h | 74 +++++++-------------------------- client/mysql.cc | 47 ++++++++++----------- client/mysql_upgrade.c | 10 ++--- client/mysqladmin.cc | 18 ++++---- client/mysqlbinlog.cc | 33 +++++++-------- client/mysqlcheck.c | 24 +++++------ client/mysqldump.c | 73 ++++++++++++++++---------------- client/mysqlimport.c | 30 ++++++------- client/mysqlshow.c | 14 +++---- client/mysqlslap.c | 57 ++++++++++++------------- extra/mariabackup/xtrabackup.cc | 4 +- include/sslopt-longopts.h | 10 ++--- 12 files changed, 169 insertions(+), 225 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index 16547494d03..ae5701d28b3 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2022, MariaDB + Copyright (c) 2009, 2024, 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 @@ -38,74 +38,32 @@ enum options_client { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET, OPT_PAGER, OPT_TEE, - OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS, - OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE, - OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES, - OPT_MASTER_DATA, OPT_AUTOCOMMIT, OPT_AUTO_REHASH, - OPT_LINE_NUMBERS, OPT_COLUMN_NAMES, OPT_CONNECT_TIMEOUT, - OPT_MAX_ALLOWED_PACKET, OPT_NET_BUFFER_LENGTH, - OPT_SELECT_LIMIT, OPT_MAX_JOIN_SIZE, OPT_SSL_SSL, + OPT_OPTIMIZE, + OPT_TABLES, + OPT_MASTER_DATA, OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH, - OPT_SSL_CIPHER, OPT_TLS_VERSION, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE, - OPT_DELETE_MASTER_LOGS, OPT_COMPACT, - OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL, - OPT_FRM, OPT_SKIP_OPTIMIZATION, - OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH, - OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_SERVER_ARG, - OPT_STOP_POSITION, OPT_START_DATETIME, OPT_STOP_DATETIME, - OPT_SIGINT_IGNORE, OPT_HEXBLOB, OPT_ORDER_BY_PRIMARY, OPT_COUNT, - OPT_FLUSH_TABLES, - OPT_TRIGGERS, - OPT_MYSQL_ONLY_PRINT, - OPT_MYSQL_LOCK_DIRECTORY, - OPT_USE_THREADS, - OPT_IMPORT_USE_THREADS, - OPT_MYSQL_NUMBER_OF_QUERY, + OPT_SSL_CIPHER, OPT_LOCAL_INFILE, + OPT_COMPACT, + OPT_MYSQL_PROTOCOL, + OPT_SKIP_OPTIMIZATION, + OPT_COMPATIBLE, OPT_DELIMITER, + OPT_SERVER_ARG, + OPT_START_DATETIME, OPT_STOP_DATETIME, OPT_IGNORE_DATABASE, - OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, - OPT_TZ_UTC, OPT_CREATE_SLAP_SCHEMA, - OPT_MYSQLDUMP_SLAVE_APPLY, + OPT_IGNORE_TABLE, OPT_MYSQLDUMP_SLAVE_DATA, - OPT_MYSQLDUMP_INCLUDE_MASTER_HOST_PORT, -#ifdef WHEN_FLASHBACK_REVIEW_READY - OPT_REVIEW, - OPT_REVIEW_DBNAME, OPT_REVIEW_TABLENAME, -#endif - OPT_SLAP_CSV, OPT_SLAP_CREATE_STRING, - OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, OPT_SLAP_AUTO_GENERATE_WRITE_NUM, - OPT_SLAP_AUTO_GENERATE_ADD_AUTO, - OPT_SLAP_AUTO_GENERATE_GUID_PRIMARY, - OPT_SLAP_AUTO_GENERATE_EXECUTE_QUERIES, - OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES, - OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM, - OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM, - OPT_SLAP_PRE_QUERY, - OPT_SLAP_POST_QUERY, - OPT_SLAP_PRE_SYSTEM, - OPT_SLAP_POST_SYSTEM, - OPT_SLAP_COMMIT, - OPT_SLAP_DETACH, - OPT_SLAP_NO_DROP, - OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID, - OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, - OPT_AUTO_VERTICAL_OUTPUT, - OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE, - OPT_WRITE_BINLOG, OPT_DUMP_DATE, - OPT_INIT_COMMAND, + OPT_SLAP_CSV, + OPT_BASE64_OUTPUT_MODE, + OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, + OPT_WRITE_BINLOG, OPT_PLUGIN_DIR, OPT_DEFAULT_AUTH, - OPT_ABORT_SOURCE_ON_ERROR, OPT_REWRITE_DB, - OPT_REPORT_PROGRESS, - OPT_SKIP_ANNOTATE_ROWS_EVENTS, OPT_SSL_CRL, OPT_SSL_CRLPATH, OPT_IGNORE_DATA, OPT_PRINT_ROW_COUNT, OPT_PRINT_ROW_EVENT_POSITIONS, OPT_CHECK_IF_UPGRADE_NEEDED, OPT_COMPATIBILTY_CLEARTEXT_PLUGIN, - OPT_SHUTDOWN_WAIT_FOR_SLAVES, - OPT_COPY_S3_TABLES, - OPT_PRINT_TABLE_METADATA, OPT_MAX_CLIENT_OPTION /* should be always the last */ }; diff --git a/client/mysql.cc b/client/mysql.cc index a598ab7e5ff..c6f1a4662cf 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2022, MariaDB Corporation. + Copyright (c) 2009, 2024, 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 @@ -1500,11 +1500,11 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0}, {"help", 'I', "Synonym for -?", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"abort-source-on-error", OPT_ABORT_SOURCE_ON_ERROR, + {"abort-source-on-error", 0, "Abort 'source filename' operations in case of errors", &batch_abort_on_error, &batch_abort_on_error, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-rehash", OPT_AUTO_REHASH, + {"auto-rehash", 0, "Enable automatic rehashing. One doesn't need to use 'rehash' to get table " "and field completion, but startup and reconnecting may take a longer time. " "Disable with --disable-auto-rehash.", @@ -1515,7 +1515,7 @@ static struct my_option my_long_options[] = "completion. This gives a quicker start of mysql and disables rehashing " "on reconnect.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT, + {"auto-vertical-output", 0, "Automatically switch to vertical output mode if the result is wider " "than the terminal width.", &auto_vertical_output, &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, @@ -1528,7 +1528,7 @@ static struct my_option my_long_options[] = {"character-sets-dir", OPT_CHARSETS_DIR, "Directory for character set files.", &charsets_dir, &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"column-type-info", OPT_COLUMN_TYPES, "Display column type information.", + {"column-type-info", 0, "Display column type information.", &column_types_flag, &column_types_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"comments", 'c', "Preserve comments. Send comments to the server." @@ -1545,14 +1545,14 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log.", &default_dbug_option, &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", + {"debug-check", 0, "Check memory and open file usage at exit.", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"database", 'D', "Database to use.", ¤t_db, ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default-character-set", OPT_DEFAULT_CHARSET, + {"default-character-set", 0, "Set the default character set.", &default_charset, &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"delimiter", OPT_DELIMITER, "Delimiter to be used.", &delimiter_str, @@ -1578,7 +1578,7 @@ static struct my_option my_long_options[] = {"ignore-spaces", 'i', "Ignore space after function names.", &ignore_spaces, &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"init-command", OPT_INIT_COMMAND, + {"init-command", 0, "SQL Command to execute when connecting to MariaDB server. Will " "automatically be re-executed when reconnecting.", &opt_init_command, &opt_init_command, 0, @@ -1593,20 +1593,20 @@ static struct my_option my_long_options[] = 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"xml", 'X', "Produce XML output.", &opt_xml, &opt_xml, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.", + {"line-numbers", 0, "Write line numbers for errors.", &line_numbers, &line_numbers, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-line-numbers", 'L', "Don't write line number for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"unbuffered", 'n', "Flush buffer after each query.", &unbuffered, &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"column-names", OPT_COLUMN_NAMES, "Write column names in results.", + {"column-names", 0, "Write column names in results.", &column_names, &column_names, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-column-names", 'N', "Don't write column names in results.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C).", + {"sigint-ignore", 0, "Ignore SIGINT (CTRL-C).", &opt_sigint_ignore, &opt_sigint_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"one-database", 'o', @@ -1637,11 +1637,11 @@ static struct my_option my_long_options[] = "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", &opt_mysql_port, &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"progress-reports", OPT_REPORT_PROGRESS, + {"progress-reports", 0, "Get progress reports for long running commands (like ALTER TABLE)", &opt_progress_reports, &opt_progress_reports, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"prompt", OPT_PROMPT, "Set the command line prompt to this value.", + {"prompt", 0, "Set the command line prompt to this value.", ¤t_prompt, ¤t_prompt, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe).", @@ -1654,7 +1654,7 @@ static struct my_option my_long_options[] = {"raw", 'r', "Write fields without conversion. Used with --batch.", &opt_raw_data, &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable " + {"reconnect", 0, "Reconnect if the connection is lost. Disable " "with --disable-reconnect. This option is enabled by default.", &opt_reconnect, &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"silent", 's', "Be more silent. Print results with a tab as separator, " @@ -1686,39 +1686,38 @@ static struct my_option my_long_options[] = GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"connect_timeout", OPT_CONNECT_TIMEOUT, - "Number of seconds before connection timeout.", + {"connect_timeout", 0, "Number of seconds before connection timeout.", &opt_connect_timeout, &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0, 0, 0}, - {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, + {"max_allowed_packet", 0, "The maximum packet length to send to or receive from server.", &opt_max_allowed_packet, &opt_max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, - {"net_buffer_length", OPT_NET_BUFFER_LENGTH, + {"net_buffer_length", 0, "The buffer size for TCP/IP and socket communication.", &opt_net_buffer_length, &opt_net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0}, - {"select_limit", OPT_SELECT_LIMIT, + {"select_limit", 0, "Automatic limit for SELECT when using --safe-updates.", &select_limit, &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX, 0, 1, 0}, - {"max_join_size", OPT_MAX_JOIN_SIZE, + {"max_join_size", 0, "Automatic limit for rows in a join when using --safe-updates.", &max_join_size, &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX, 0, 1, 0}, - {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" + {"secure-auth", 0, "Refuse client connecting to server if it" " uses old (pre-4.1.1) protocol.", &opt_secure_auth, &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.", + {"show-warnings", 0, "Show warnings after every statement.", &show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", OPT_DEFAULT_AUTH, + {"default_auth", 0, "Default authentication client-side plugin to use.", &opt_default_auth, &opt_default_auth, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 36c73f69716..b303ffd099a 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1,6 +1,6 @@ /* Copyright (c) 2006, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2017, MariaDB + Copyright (c) 2010, 2024, 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 @@ -87,10 +87,10 @@ static struct my_option my_long_options[]= {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibility.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"character-sets-dir", OPT_CHARSETS_DIR, + {"character-sets-dir", 0, "Not used by mysql_upgrade. Only for backward compatibility.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - {"compress", OPT_COMPRESS, + {"compress", 0, "Not used by mysql_upgrade. Only for backward compatibility.", ¬_used, ¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"datadir", 'd', @@ -103,12 +103,12 @@ static struct my_option my_long_options[]= {"debug", '#', "Output debug log.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", + {"debug-check", 0, "Check memory and open file usage at exit.", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"default-character-set", OPT_DEFAULT_CHARSET, + {"default-character-set", 0, "Not used by mysql_upgrade. Only for backward compatibility.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default_auth", OPT_DEFAULT_AUTH, diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 3f73d7c38fd..098e7ef7c83 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB + Copyright (c) 2010, 2024, 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 @@ -141,10 +141,10 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", + {"debug-check", 0, "Check memory and open file usage at exit.", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + {"debug-info", 0, "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', @@ -158,7 +158,7 @@ static struct my_option my_long_options[] = {"character-sets-dir", OPT_CHARSETS_DIR, "Directory for character set files.", &charsets_dir, &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default-character-set", OPT_DEFAULT_CHARSET, + {"default-character-set", 0, "Set the default character set.", &default_charset, &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, @@ -214,21 +214,21 @@ static struct my_option my_long_options[] = 0, 0, 0}, {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_UINT, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"connect_timeout", OPT_CONNECT_TIMEOUT, "", &opt_connect_timeout, + {"connect_timeout", 0, "", &opt_connect_timeout, &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0, 3600*12, 0, 1, 0}, - {"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", &opt_shutdown_timeout, + {"shutdown_timeout", 0, "", &opt_shutdown_timeout, &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG, SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0}, - {"wait_for_all_slaves", OPT_SHUTDOWN_WAIT_FOR_SLAVES, + {"wait_for_all_slaves", 0, "Defers shutdown until after all binlogged events have been sent to " "all connected slaves", &opt_shutdown_wait_for_slaves, &opt_shutdown_wait_for_slaves, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", OPT_DEFAULT_AUTH, + {"default_auth", 0, "Default authentication client-side plugin to use.", &opt_default_auth, &opt_default_auth, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 6abfd32208d..6324e5a7242 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2020, MariaDB + Copyright (c) 2009, 2024, 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 @@ -1530,7 +1530,7 @@ static struct my_option my_options[] = like this: SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`; */ - {"character-sets-dir", OPT_CHARSETS_DIR, + {"character-sets-dir", 0, "Directory for character set files.", &charsets_dir, &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"database", 'd', "List entries for just this database (local log only).", @@ -1540,13 +1540,13 @@ static struct my_option my_options[] = {"debug", '#', "Output debug log.", ¤t_dbug_option, ¤t_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + {"debug-check", 0, "Check memory and open file usage at exit .", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + {"debug-info", 0, "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", OPT_DEFAULT_AUTH, + {"default_auth", 0, "Default authentication client-side plugin to use.", &opt_default_auth, &opt_default_auth, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -1582,7 +1582,7 @@ static struct my_option my_options[] = 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to connect to remote server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugindir, &opt_plugindir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection or 0 for default to, in " @@ -1608,14 +1608,14 @@ static struct my_option my_options[] = &result_file_name, &result_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef WHEN_FLASHBACK_REVIEW_READY - {"review", opt_flashback_review, "Print review sql in output file.", + {"review", 0, "Print review sql in output file.", &opt_flashback_review, &opt_flashback_review, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"review-dbname", opt_flashback_flashback_review_dbname, + {"review-dbname", 0, "Writing flashback original row data into this db", &flashback_review_dbname, &flashback_review_dbname, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"review-tablename", opt_flashback_flashback_review_tablename, + {"review-tablename", 0, "Writing flashback original row data into this table", &flashback_review_tablename, &flashback_review_tablename, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -1632,7 +1632,7 @@ static struct my_option my_options[] = "Extract only binlog entries created by the server having the given id.", &server_id, &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"set-charset", OPT_SET_CHARSET, + {"set-charset", 0, "Add 'SET NAMES character_set' to the output.", &charset, &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"short-form", 's', "Just show regular queries: no extra info, no " @@ -1680,7 +1680,7 @@ static struct my_option my_options[] = "The slave server_id used for --read-from-remote-server --stop-never.", &opt_stop_never_slave_server_id, &opt_stop_never_slave_server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"stop-position", OPT_STOP_POSITION, + {"stop-position", 0, "Stop reading the binlog at position N. Applies to the last binlog " "passed on the command line.", &stop_position, &stop_position, 0, GET_ULL, @@ -1703,7 +1703,7 @@ that may lead to an endless loop.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"open_files_limit", OPT_OPEN_FILES_LIMIT, + {"open_files_limit", 0, "Used to reserve file descriptors for use by this program.", &open_files_limit, &open_files_limit, 0, GET_ULONG, REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0}, @@ -1729,12 +1729,12 @@ that may lead to an endless loop.", "Updates to a database with a different name than the original. \ Example: rewrite-db='from->to'.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-annotate-row-events", OPT_SKIP_ANNOTATE_ROWS_EVENTS, + {"skip-annotate-row-events", 0, "Don't print Annotate_rows events stored in the binary log.", (uchar**) &opt_skip_annotate_row_events, (uchar**) &opt_skip_annotate_row_events, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"print-table-metadata", OPT_PRINT_TABLE_METADATA, + {"print-table-metadata", 0, "Print metadata stored in Table_map_log_event", &opt_print_table_metadata, &opt_print_table_metadata, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -1948,11 +1948,6 @@ get_one_option(const struct my_option *opt, const char *argument, const char *) die(1); } break; -#ifdef WHEN_FLASHBACK_REVIEW_READY - case opt_flashback_review: - opt_flashback_review= 1; - break; -#endif case OPT_START_DATETIME: start_datetime= convert_str_to_timestamp(start_datetime_str); break; diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 34cbcadbdf5..da71656c9e4 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2012, MariaDB + Copyright (c) 2010, 2024, 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 @@ -81,11 +81,11 @@ static struct my_option my_long_options[] = "Instead of issuing one query for each table, use one query per database, naming all tables in the database in a comma-separated list.", &opt_all_in_1, &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-repair", OPT_AUTO_REPAIR, + {"auto-repair", 0, "If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found.", &opt_auto_repair, &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"character-sets-dir", OPT_CHARSETS_DIR, + {"character-sets-dir", 0, "Directory for character set files.", (char**) &charsets_dir, (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, @@ -96,7 +96,7 @@ static struct my_option my_long_options[] = {"check-upgrade", 'g', "Check tables for version-dependent changes. May be used with --auto-repair to correct tables requiring version-dependent updates.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", + {"compress", 0, "Use compression in server/client protocol.", &opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"databases", 'B', @@ -110,16 +110,16 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", + {"debug-check", 0, "Check memory and open file usage at exit.", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + {"debug-info", 0, "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"default-character-set", OPT_DEFAULT_CHARSET, + {"default-character-set", 0, "Set the default character set.", &default_charset, &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", OPT_DEFAULT_AUTH, + {"default_auth", 0, "Default authentication client-side plugin to use.", &opt_default_auth, &opt_default_auth, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -139,7 +139,7 @@ static struct my_option my_long_options[] = "If you are using this option with CHECK TABLE, it will ensure that the table is 100 percent consistent, but will take a long time. If you are using this option with REPAIR TABLE, it will force using old slow repair with keycache method, instead of much faster repair by sorting.", &opt_extended, &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"flush", OPT_FLUSH_TABLES, "Flush each table after check. This is useful if you don't want to have the checked tables take up space in the caches after the check", + {"flush", 0, "Flush each table after check. This is useful if you don't want to have the checked tables take up space in the caches after the check", &opt_flush_tables, &opt_flush_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, @@ -149,7 +149,7 @@ static struct my_option my_long_options[] = {"medium-check", 'm', "Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"write-binlog", OPT_WRITE_BINLOG, + {"write-binlog", 0, "Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Use --skip-write-binlog " "when commands should not be sent to replication slaves.", &opt_write_binlog, &opt_write_binlog, 0, GET_BOOL, NO_ARG, @@ -167,7 +167,7 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection or 0 for default to, in " @@ -198,7 +198,7 @@ static struct my_option my_long_options[] = #include {"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"use-frm", OPT_FRM, + {"use-frm", 0, "When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.", &opt_frm, &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqldump.c b/client/mysqldump.c index 79339fc59b8..06ecc67cc97 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2020, MariaDB Corporation. + Copyright (c) 2010, 2024, 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 @@ -165,7 +165,6 @@ static my_bool server_supports_switching_charsets= TRUE; static ulong opt_compatible_mode= 0; #define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1 #define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2 -#define MYSQL_OPT_MAX_STATEMENT_TIME 0 #define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1 #define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL 2 static uint opt_mysql_port= 0, opt_master_data; @@ -259,26 +258,26 @@ static struct my_option my_long_options[] = "Do not dump any tablespace information.", &opt_notspcs, &opt_notspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"add-drop-database", OPT_DROP_DATABASE, "Add a DROP DATABASE before each create.", + {"add-drop-database", 0, "Add a DROP DATABASE before each create.", &opt_drop_database, &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"add-drop-table", OPT_DROP, "Add a DROP TABLE before each create.", + {"add-drop-table", 0, "Add a DROP TABLE before each create.", &opt_drop, &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"add-drop-trigger", 0, "Add a DROP TRIGGER before each create.", &opt_drop_trigger, &opt_drop_trigger, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"add-locks", OPT_LOCKS, "Add locks around INSERT statements.", + {"add-locks", 0, "Add locks around INSERT statements.", &opt_lock, &opt_lock, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"allow-keywords", OPT_KEYWORDS, + {"allow-keywords", 0, "Allow creation of column names that are keywords.", &opt_keywords, &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"apply-slave-statements", OPT_MYSQLDUMP_SLAVE_APPLY, + {"apply-slave-statements", 0, "Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START SLAVE' to bottom of dump.", &opt_slave_apply, &opt_slave_apply, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"character-sets-dir", OPT_CHARSETS_DIR, + {"character-sets-dir", 0, "Directory for character set files.", (char **)&charsets_dir, (char **)&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"comments", 'i', "Write additional information.", @@ -305,7 +304,7 @@ static struct my_option my_long_options[] = {"compress", 'C', "Use compression in server/client protocol.", &opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"copy_s3_tables", OPT_COPY_S3_TABLES, + {"copy_s3_tables", 0, "If 'no' S3 tables will be ignored, otherwise S3 tables will be copied as " " Aria tables and then altered to S3", &opt_copy_s3_tables, &opt_copy_s3_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, @@ -325,19 +324,19 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log.", (char *)&default_dbug_option, (char *)&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", + {"debug-check", 0, "Check memory and open file usage at exit.", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + {"debug-info", 0, "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", &default_charset, &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED.", + {"delayed-insert", 0, "Insert rows with INSERT DELAYED.", &opt_delayed, &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"delete-master-logs", OPT_DELETE_MASTER_LOGS, + {"delete-master-logs", 0, "Delete logs on master after backup. This automatically enables --master-data.", &opt_delete_master_logs, &opt_delete_master_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -365,17 +364,17 @@ static struct my_option my_long_options[] = "Use multiple-row INSERT syntax that include several VALUES lists.", &extended_insert, &extended_insert, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"fields-terminated-by", OPT_FTB, + {"fields-terminated-by", 0, "Fields in the output file are terminated by the given string.", &fields_terminated, &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"fields-enclosed-by", OPT_ENC, + {"fields-enclosed-by", 0, "Fields in the output file are enclosed by the given character.", &enclosed, &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, - {"fields-optionally-enclosed-by", OPT_O_ENC, + {"fields-optionally-enclosed-by", 0, "Fields in the output file are optionally enclosed by the given character.", &opt_enclosed, &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, - {"fields-escaped-by", OPT_ESC, + {"fields-escaped-by", 0, "Fields in the output file are escaped by the given character.", &escaped, &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"flush-logs", 'F', "Flush logs file in server before starting dump. " @@ -389,7 +388,7 @@ static struct my_option my_long_options[] = "--lock-all-tables or --master-data with --flush-logs.", &flush_logs, &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"flush-privileges", OPT_ESC, "Emit a FLUSH PRIVILEGES statement " + {"flush-privileges", 0, "Emit a FLUSH PRIVILEGES statement " "after dumping the mysql database. This option should be used any " "time the dump contains the mysql database and any other database " "that depends on the data in the mysql database for proper restore. ", @@ -407,7 +406,7 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"hex-blob", OPT_HEXBLOB, "Dump binary strings (BINARY, " + {"hex-blob", 0, "Dump binary strings (BINARY, " "VARBINARY, BLOB) in hexadecimal format.", &opt_hex_blob, &opt_hex_blob, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", ¤t_host, @@ -429,15 +428,15 @@ static struct my_option my_long_options[] = "be specified with both database and table names, e.g., " "--ignore-table=database.table.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"include-master-host-port", OPT_MYSQLDUMP_INCLUDE_MASTER_HOST_PORT, + {"include-master-host-port", 0, "Adds 'MASTER_HOST=, MASTER_PORT=' to 'CHANGE MASTER TO..' " "in dump produced with --dump-slave.", &opt_include_master_host_port, &opt_include_master_host_port, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.", + {"insert-ignore", 0, "Insert rows with INSERT IGNORE.", &opt_ignore, &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"lines-terminated-by", OPT_LTB, + {"lines-terminated-by", 0, "Lines in the output file are terminated by the given string.", &lines_terminated, &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -448,7 +447,7 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0, 0}, {"lock-tables", 'l', "Lock all tables for read.", &lock_tables, &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.", + {"log-error", 0, "Append warnings and errors to given file.", &log_error_file, &log_error_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"log-queries", 0, "When restoring the dump, the server will, if logging turned on, log the queries to the general and slow query log.", @@ -465,21 +464,21 @@ static struct my_option my_long_options[] = "Option automatically turns --lock-tables off.", &opt_master_data, &opt_master_data, 0, GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0}, - {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, + {"max_allowed_packet", 0, "The maximum packet length to send to or receive from server.", &opt_max_allowed_packet, &opt_max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, (longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, - {"max-statement-time", MYSQL_OPT_MAX_STATEMENT_TIME, + {"max-statement-time", 0, "Max statement execution time. If unset, overrides server default with 0.", &opt_max_statement_time, &opt_max_statement_time, 0, GET_DOUBLE, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"net_buffer_length", OPT_NET_BUFFER_LENGTH, + {"net_buffer_length", 0, "The buffer size for TCP/IP and socket communication.", &opt_net_buffer_length, &opt_net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L-1025, 4096, 16*1024L*1024L, MALLOC_OVERHEAD-1024, 1024, 0}, - {"no-autocommit", OPT_AUTOCOMMIT, + {"no-autocommit", 0, "Wrap tables with autocommit/commit statements.", &opt_autocommit, &opt_autocommit, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -502,7 +501,7 @@ static struct my_option my_long_options[] = {"opt", OPT_OPTIMIZE, "Same as --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys. Enabled by default, disable with --skip-opt.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"order-by-primary", OPT_ORDER_BY_PRIMARY, + {"order-by-primary", 0, "Sorts each table's rows by primary key, or first unique key, if such a key exists. Useful when dumping a MyISAM table to be loaded into an InnoDB table, but will make the dump itself take considerably longer.", &opt_order_by_primary, &opt_order_by_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', @@ -523,7 +522,7 @@ static struct my_option my_long_options[] = {"quote-names",'Q', "Quote table and column names with backticks (`).", &opt_quoted, &opt_quoted, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"replace", OPT_MYSQL_REPLACE_INTO, "Use REPLACE INTO instead of INSERT INTO.", + {"replace", 0, "Use REPLACE INTO instead of INSERT INTO.", &opt_replace_into, &opt_replace_into, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"result-file", 'r', @@ -534,7 +533,7 @@ static struct my_option my_long_options[] = {"routines", 'R', "Dump stored routines (functions and procedures).", &opt_routines, &opt_routines, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"set-charset", OPT_SET_CHARSET, + {"set-charset", 0, "Add 'SET NAMES default_character_set' to the output.", &opt_set_charset, &opt_set_charset, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, @@ -543,7 +542,7 @@ static struct my_option my_long_options[] = will give bullet-proof binlog position only if server >=4.1.3. That's the old "FLUSH TABLES WITH READ LOCK does not block commit" fixed bug. */ - {"single-transaction", OPT_TRANSACTION, + {"single-transaction", 0, "Creates a consistent snapshot by dumping all tables in a single " "transaction. Works ONLY for tables stored in storage engines which " "support multiversioning (currently only InnoDB does); the dump is NOT " @@ -555,7 +554,7 @@ static struct my_option my_long_options[] = "isolated from them. Option automatically turns off --lock-tables.", &opt_single_transaction, &opt_single_transaction, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"dump-date", OPT_DUMP_DATE, "Put a dump date to the end of the output.", + {"dump-date", 0, "Put a dump date to the end of the output.", &opt_dump_date, &opt_dump_date, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-opt", OPT_SKIP_OPTIMIZATION, @@ -565,7 +564,7 @@ static struct my_option my_long_options[] = &opt_mysql_unix_port, &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include - {"system", 256, "Dump system tables as portable SQL", + {"system", 0, "Dump system tables as portable SQL", &opt_system, &opt_system, &opt_system_types, GET_SET, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tab",'T', "Create tab-separated textfile for each table to given path. (Create .sql " @@ -574,10 +573,10 @@ static struct my_option my_long_options[] = &path, &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"triggers", OPT_TRIGGERS, "Dump triggers for each dumped table.", + {"triggers", 0, "Dump triggers for each dumped table.", &opt_dump_triggers, &opt_dump_triggers, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"tz-utc", OPT_TZ_UTC, + {"tz-utc", 0, "SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones.", &opt_tz_utc, &opt_tz_utc, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE @@ -593,10 +592,10 @@ static struct my_option my_long_options[] = &where, &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", OPT_DEFAULT_AUTH, + {"default_auth", 0, "Default authentication client-side plugin to use.", &opt_default_auth, &opt_default_auth, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqlimport.c b/client/mysqlimport.c index d64e1daac50..b7c507e359d 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2011, 2022, MariaDB + Copyright (c) 2011, 2024, 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 @@ -69,10 +69,10 @@ static char **argv_to_free; static struct my_option my_long_options[] = { - {"character-sets-dir", OPT_CHARSETS_DIR, + {"character-sets-dir", 0, "Directory for character set files.", (char**) &charsets_dir, (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default-character-set", OPT_DEFAULT_CHARSET, + {"default-character-set", 0, "Set the default character set.", &default_charset, &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"columns", 'c', @@ -84,31 +84,31 @@ static struct my_option my_long_options[] = 0, 0, 0}, {"debug",'#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", + {"debug-check", 0, "Check memory and open file usage at exit.", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + {"debug-info", 0, "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", OPT_DEFAULT_AUTH, + {"default_auth", 0, "Default authentication client-side plugin to use.", &opt_default_auth, &opt_default_auth, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"delete", 'd', "First delete all rows from table.", &opt_delete, &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"fields-terminated-by", OPT_FTB, + {"fields-terminated-by", 0, "Fields in the input file are terminated by the given string.", &fields_terminated, &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"fields-enclosed-by", OPT_ENC, + {"fields-enclosed-by", 0, "Fields in the import file are enclosed by the given character.", &enclosed, &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"fields-optionally-enclosed-by", OPT_O_ENC, + {"fields-optionally-enclosed-by", 0, "Fields in the input file are optionally enclosed by the given character.", &opt_enclosed, &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"fields-escaped-by", OPT_ESC, + {"fields-escaped-by", 0, "Fields in the input file are escaped by the given character.", &escaped, &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -125,10 +125,10 @@ static struct my_option my_long_options[] = "Disable foreign key checks while importing the data.", &ignore_foreign_keys, &ignore_foreign_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.", + {"ignore-lines", 0, "Ignore first n lines of data infile.", &opt_ignore_lines, &opt_ignore_lines, 0, GET_LL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"lines-terminated-by", OPT_LTB, + {"lines-terminated-by", 0, "Lines in the input file are terminated by the given string.", &lines_terminated, &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -137,7 +137,7 @@ static struct my_option my_long_options[] = {"lock-tables", 'l', "Lock all tables for write (this disables threads).", &lock_tables, &lock_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"low-priority", OPT_LOW_PRIORITY, + {"low-priority", 0, "Use LOW_PRIORITY when updating the table.", &opt_low_priority, &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', @@ -147,7 +147,7 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection or 0 for default to, in " @@ -169,7 +169,7 @@ static struct my_option my_long_options[] = &opt_mysql_unix_port, &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include - {"use-threads", OPT_USE_THREADS, + {"use-threads", 0, "Load files in parallel. The argument is the number " "of threads to use for loading data.", &opt_use_threads, &opt_use_threads, 0, diff --git a/client/mysqlshow.c b/client/mysqlshow.c index e1dc840cf8f..fdb58b56b30 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB + Copyright (c) 2010, 2024, 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 @@ -186,10 +186,10 @@ static struct my_option my_long_options[] = {"character-sets-dir", 'c', "Directory for character set files.", (char**) &charsets_dir, (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default-character-set", OPT_DEFAULT_CHARSET, + {"default-character-set", 0, "Set the default character set.", &default_charset, &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"count", OPT_COUNT, + {"count", 0, "Show number of rows per table (may be slow for non-MyISAM tables).", &opt_count, &opt_count, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -198,13 +198,13 @@ static struct my_option my_long_options[] = 0, 0, 0}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", + {"debug-check", 0, "Check memory and open file usage at exit.", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", + {"debug-info", 0, "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", OPT_DEFAULT_AUTH, + {"default_auth", 0, "Default authentication client-side plugin to use.", &opt_default_auth, &opt_default_auth, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -221,7 +221,7 @@ static struct my_option my_long_options[] = "Password to use when connecting to server. If password is not given, it's " "solicited on the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection or 0 for default to, in " diff --git a/client/mysqlslap.c b/client/mysqlslap.c index f94bb2ad956..8fc59e41c94 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2015, Oracle and/or its affiliates. - Copyright (c) 2010, 2022, MariaDB + Copyright (c) 2010, 2024, 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 @@ -532,50 +532,45 @@ static struct my_option my_long_options[] = "Generate SQL where not supplied by file or command line.", &auto_generate_sql, &auto_generate_sql, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-generate-sql-add-autoincrement", OPT_SLAP_AUTO_GENERATE_ADD_AUTO, + {"auto-generate-sql-add-autoincrement", 0, "Add an AUTO_INCREMENT column to auto-generated tables.", - &auto_generate_sql_autoincrement, - &auto_generate_sql_autoincrement, + &auto_generate_sql_autoincrement, &auto_generate_sql_autoincrement, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-generate-sql-execute-number", OPT_SLAP_AUTO_GENERATE_EXECUTE_QUERIES, + {"auto-generate-sql-execute-number", 0, "Set this number to generate a set number of queries to run.", &auto_actual_queries, &auto_actual_queries, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-generate-sql-guid-primary", OPT_SLAP_AUTO_GENERATE_GUID_PRIMARY, + {"auto-generate-sql-guid-primary", 0, "Add GUID based primary keys to auto-generated tables.", - &auto_generate_sql_guid_primary, - &auto_generate_sql_guid_primary, + &auto_generate_sql_guid_primary, &auto_generate_sql_guid_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-generate-sql-load-type", OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, + {"auto-generate-sql-load-type", 0, "Specify test load type: mixed, update, write, key, or read; default is mixed.", (char**) &auto_generate_sql_type, (char**) &auto_generate_sql_type, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-generate-sql-secondary-indexes", - OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES, + {"auto-generate-sql-secondary-indexes", 0, "Number of secondary indexes to add to auto-generated tables.", &auto_generate_sql_secondary_indexes, &auto_generate_sql_secondary_indexes, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"auto-generate-sql-unique-query-number", - OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM, + {"auto-generate-sql-unique-query-number", 0, "Number of unique queries to generate for automatic tests.", &auto_generate_sql_unique_query_number, &auto_generate_sql_unique_query_number, 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0}, - {"auto-generate-sql-unique-write-number", - OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM, + {"auto-generate-sql-unique-write-number", 0, "Number of unique queries to generate for auto-generate-sql-write-number.", &auto_generate_sql_unique_write_number, &auto_generate_sql_unique_write_number, 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0}, - {"auto-generate-sql-write-number", OPT_SLAP_AUTO_GENERATE_WRITE_NUM, + {"auto-generate-sql-write-number", 0, "Number of row inserts to perform for each thread (default is 100).", &auto_generate_sql_number, &auto_generate_sql_number, 0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, "Directory for character set files.", (char **)&charsets_dir, (char **)&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"commit", OPT_SLAP_COMMIT, "Commit records every X number of statements.", + {"commit", 0, "Commit records every X number of statements.", &commit_rate, &commit_rate, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", @@ -584,10 +579,10 @@ static struct my_option my_long_options[] = {"concurrency", 'c', "Number of clients to simulate for query to run.", (char**) &concurrency_str, (char**) &concurrency_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"create", OPT_SLAP_CREATE_STRING, "File or string to use create tables.", + {"create", 0, "File or string to use create tables.", &create_string, &create_string, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"create-schema", OPT_CREATE_SLAP_SCHEMA, "Schema to run tests in.", + {"create-schema", 0, "Schema to run tests in.", (char**) &create_schema_string, (char**) &create_schema_string, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"csv", OPT_SLAP_CSV, @@ -601,12 +596,12 @@ static struct my_option my_long_options[] = (char**) &default_dbug_option, (char**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", + {"debug-check", 0, "Check memory and open file usage at exit.", &debug_check_flag, &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", OPT_DEFAULT_AUTH, + {"default_auth", 0, "Default authentication client-side plugin to use.", &opt_default_auth, &opt_default_auth, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -614,7 +609,7 @@ static struct my_option my_long_options[] = "Delimiter to use in SQL statements supplied in file or command line.", (char**) &delimiter, (char**) &delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"detach", OPT_SLAP_DETACH, + {"detach", 0, "Detach (close and reopen) connections after X number of requests.", &detach_rate, &detach_rate, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -626,14 +621,14 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", &host, &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"init-command", OPT_INIT_COMMAND, + {"init-command", 0, "SQL Command to execute when connecting to MariaDB server. Will " "automatically be re-executed when reconnecting.", &opt_init_command, &opt_init_command, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"iterations", 'i', "Number of times to run the tests.", &iterations, &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, - {"no-drop", OPT_SLAP_NO_DROP, "Do not drop the schema after the test.", + {"no-drop", 0, "Do not drop the schema after the test.", &opt_no_drop, &opt_no_drop, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"number-char-cols", 'x', "Number of VARCHAR columns to create in table if specifying --auto-generate-sql.", @@ -643,11 +638,11 @@ static struct my_option my_long_options[] = "Number of INT columns to create in table if specifying --auto-generate-sql.", (char**) &num_int_cols_opt, (char**) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"number-of-queries", OPT_MYSQL_NUMBER_OF_QUERY, + {"number-of-queries", 0, "Limit each client to this number of queries (this is not exact).", &num_of_query, &num_of_query, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"only-print", OPT_MYSQL_ONLY_PRINT, + {"only-print", 0, "Do not connect to the databases, but instead print out what would have " "been done.", &opt_only_print, &opt_only_print, 0, GET_BOOL, NO_ARG, @@ -659,25 +654,25 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection.", &opt_mysql_port, &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"post-query", OPT_SLAP_POST_QUERY, + {"post-query", 0, "Query to run or file containing query to execute after tests have completed.", &user_supplied_post_statements, &user_supplied_post_statements, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"post-system", OPT_SLAP_POST_SYSTEM, + {"post-system", 0, "system() string to execute after tests have completed.", &post_system, &post_system, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"pre-query", OPT_SLAP_PRE_QUERY, + {"pre-query", 0, "Query to run or file containing query to execute before running tests.", &user_supplied_pre_statements, &user_supplied_pre_statements, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"pre-system", OPT_SLAP_PRE_SYSTEM, + {"pre-system", 0, "system() string to execute before running tests.", &pre_system, &pre_system, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 90ccd693347..c464c7937d3 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB Originally Created 3/3/2009 Yasufumi Kinoshita Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko, Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz. -(c) 2017, 2022, MariaDB Corporation. +(c) 2017, 2024, MariaDB Corporation. Portions written by Marko Mäkelä. This program is free software; you can redistribute it and/or modify @@ -1684,7 +1684,7 @@ struct my_option xb_server_options[] = &aria_log_dir_path, &aria_log_dir_path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"open_files_limit", OPT_OPEN_FILES_LIMIT, "the maximum number of file " + {"open_files_limit", 0, "the maximum number of file " "descriptors to reserve with setrlimit().", (G_PTR*) &xb_open_files_limit, (G_PTR*) &xb_open_files_limit, 0, GET_ULONG, REQUIRED_ARG, 0, 0, UINT_MAX, 0, 1, 0}, diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index ee90d17fb64..53cf1d1a597 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -19,13 +19,12 @@ #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) - {"ssl", OPT_SSL_SSL, + {"ssl", 0, "Enable SSL for connection (automatically enabled with other flags).", &opt_use_ssl, &opt_use_ssl, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-ca", OPT_SSL_CA, "CA file in PEM format (check OpenSSL docs, implies --ssl).", - &opt_ssl_ca, &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, - 0, 0, 0, 0, 0, 0}, + &opt_ssl_ca, &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-capath", OPT_SSL_CAPATH, "CA directory (check OpenSSL docs, implies --ssl).", &opt_ssl_capath, &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, @@ -46,13 +45,12 @@ "Certificate revocation list path (implies --ssl).", &opt_ssl_crlpath, &opt_ssl_crlpath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"tls-version", OPT_TLS_VERSION, - "TLS protocol version for secure connection.", + {"tls-version", 0, "TLS protocol version for secure connection.", &opt_tls_version, &opt_tls_version, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef MYSQL_CLIENT - {"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT, + {"ssl-verify-server-cert", 0, "Verify server's \"Common Name\" in its cert against hostname used " "when connecting. This option is disabled by default.", &opt_ssl_verify_server_cert, &opt_ssl_verify_server_cert, From 994a0de96b3a77449a5b4274835a308dd04b4912 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 5 May 2024 09:28:25 +0200 Subject: [PATCH 290/313] cleanup: reorder mysql help output --- client/mysql.cc | 220 ++++++++++++++++++++++-------------------------- 1 file changed, 100 insertions(+), 120 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index c6f1a4662cf..b7aaa278763 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -283,11 +283,12 @@ typedef struct { static COMMANDS commands[] = { { "?", '?', com_help, 1, "Synonym for `help'." }, + { "charset", 'C', com_charset, 1, + "Switch to another charset. Might be needed for processing binlog with multi-byte charsets." }, { "clear", 'c', com_clear, 0, "Clear the current input statement."}, { "connect",'r', com_connect,1, "Reconnect to the server. Optional arguments are db and host." }, - { "delimiter", 'd', com_delimiter, 1, - "Set statement delimiter." }, + { "delimiter", 'd', com_delimiter, 1, "Set statement delimiter." }, #ifdef USE_POPEN { "edit", 'e', com_edit, 0, "Edit command with $EDITOR."}, #endif @@ -300,6 +301,8 @@ static COMMANDS commands[] = { { "nopager",'n', com_nopager,0, "Disable pager, print to stdout." }, #endif { "notee", 't', com_notee, 0, "Don't write into outfile." }, + { "nowarning", 'w', com_nowarnings, 0, + "Don't show warnings after every statement." }, #ifdef USE_POPEN { "pager", 'P', com_pager, 1, "Set PAGER [to_pager]. Print the query results via PAGER." }, @@ -318,12 +321,8 @@ static COMMANDS commands[] = { "Set outfile [to_outfile]. Append everything into given outfile." }, { "use", 'u', com_use, 1, "Use another database. Takes database name as argument." }, - { "charset", 'C', com_charset, 1, - "Switch to another charset. Might be needed for processing binlog with multi-byte charsets." }, { "warnings", 'W', com_warnings, 0, "Show warnings after every statement." }, - { "nowarning", 'w', com_nowarnings, 0, - "Don't show warnings after every statement." }, /* Get bash-like expansion for some commands */ { "create table", 0, 0, 0, ""}, { "create database", 0, 0, 0, ""}, @@ -1506,10 +1505,8 @@ static struct my_option my_long_options[] = GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"auto-rehash", 0, "Enable automatic rehashing. One doesn't need to use 'rehash' to get table " - "and field completion, but startup and reconnecting may take a longer time. " - "Disable with --disable-auto-rehash.", - &opt_rehash, &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, - 0, 0}, + "and field completion, but startup and reconnecting may take a longer time.", + &opt_rehash, &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"no-auto-rehash", 'A', "No automatic rehashing. One has to use 'rehash' to get table and field " "completion. This gives a quicker start of mysql and disables rehashing " @@ -1517,17 +1514,31 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"auto-vertical-output", 0, "Automatically switch to vertical output mode if the result is wider " - "than the terminal width.", - &auto_vertical_output, &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, - 0, 0, 0, 0, 0}, + "than the terminal width.", &auto_vertical_output, &auto_vertical_output, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"batch", 'B', "Don't use history file. Disable interactive behavior. (Enables --silent.)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"binary-as-hex", 0, "Print binary data as hex", &opt_binhex, &opt_binhex, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"binary-mode", 0, + "Binary mode allows certain character sequences to be processed as data " + "that would otherwise be treated with a special meaning by the parser. " + "Specifically, this switch turns off parsing of all client commands except " + "\\C and DELIMITER in non-interactive mode (i.e., when binary mode is " + "combined with either 1) piped input, 2) the --batch mysql option, or 3) " + "the 'source' command). Also, in binary mode, occurrences of '\\r\\n' and " + "ASCII '\\0' are preserved within strings, whereas by default, '\\r\\n' is " + "translated to '\\n' and '\\0' is disallowed in user input.", + &opt_binary_mode, &opt_binary_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, "Directory for character set files.", &charsets_dir, &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"column-names", 0, "Write column names in results.", + &column_names, &column_names, 0, GET_BOOL, + NO_ARG, 1, 0, 0, 0, 0, 0}, + {"skip-column-names", 'N', "Don't write column names in results.", 0, 0, 0, + GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"column-type-info", 0, "Display column type information.", &column_types_flag, &column_types_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -1538,6 +1549,16 @@ static struct my_option my_long_options[] = {"compress", 'C', "Use compression in server/client protocol.", &opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"connect-expired-password", 0, + "Notify the server that this client is prepared to handle expired " + "password sandbox mode even if --batch was specified.", + &opt_connect_expired_password, &opt_connect_expired_password, 0, GET_BOOL, + NO_ARG, 0, 0, 0, 0, 0, 0}, + {"connect_timeout", 0, "Number of seconds before connection timeout.", + &opt_connect_timeout, &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, + 0, 0, 3600*12, 0, 0, 0}, + {"database", 'D', "Database to use.", ¤t_db, + ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit.", 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -1550,65 +1571,59 @@ static struct my_option my_long_options[] = GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use.", ¤t_db, - ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"default-auth", 0, "Default authentication client-side plugin to use.", + &opt_default_auth, &opt_default_auth, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", 0, "Set the default character set.", &default_charset, &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"delimiter", OPT_DELIMITER, "Delimiter to be used.", &delimiter_str, &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"enable-cleartext-plugin", OPT_COMPATIBILTY_CLEARTEXT_PLUGIN, + "Obsolete option. Exists only for MySQL compatibility.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"execute", 'e', "Execute command and quit. (Disables --force and history file.)", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"enable-cleartext-plugin", OPT_COMPATIBILTY_CLEARTEXT_PLUGIN, "Obsolete option. Exists only for MySQL compatibility.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"vertical", 'E', "Print the output of a query (rows) vertically.", - &vertical, &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, - 0}, - {"force", 'f', "Continue even if we get an SQL error. Sets abort-source-on-error to 0", - &ignore_errors, &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, - 0, 0, 0, 0}, + {"force", 'f', + "Continue even if we get an SQL error. Sets abort-source-on-error to 0", + &ignore_errors, &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"host", 'h', "Connect to host.", ¤t_host, + ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"html", 'H', "Produce HTML output.", &opt_html, &opt_html, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"ignore-spaces", 'i', "Ignore space after function names.", + &ignore_spaces, &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"init-command", 0, + "SQL Command to execute when connecting to MariaDB server. Will " + "automatically be re-executed when reconnecting.", &opt_init_command, + &opt_init_command, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"line-numbers", 0, "Write line numbers for errors.", + &line_numbers, &line_numbers, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"skip-line-numbers", 'L', "Don't write line number for errors.", 0, 0, 0, + GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"local-infile", OPT_LOCAL_INFILE, "Enable LOAD DATA LOCAL INFILE.", + &opt_local_infile, &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"max-allowed-packet", 0, + "The maximum packet length to send to or receive from server.", + &opt_max_allowed_packet, &opt_max_allowed_packet, 0, GET_ULONG, + REQUIRED_ARG, 16*1024LL*1024LL, 4096, 2*1024LL*1024LL*1024LL, 0, 1024, 0}, + {"max-join-size", 0, + "Automatic limit for rows in a join when using --safe-updates.", + &max_join_size, &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, + 1, ULONG_MAX, 0, 1, 0}, {"named-commands", 'G', "Enable named commands. Named commands mean this program's internal " "commands; see mysql> help . When enabled, the named commands can be " "used from any line of the query, otherwise only from the first line, " "before an enter. Disable with --disable-named-commands. This option " "is disabled by default.", - &named_cmds, &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, - 0, 0}, - {"ignore-spaces", 'i', "Ignore space after function names.", - &ignore_spaces, &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0, - 0, 0, 0, 0}, - {"init-command", 0, - "SQL Command to execute when connecting to MariaDB server. Will " - "automatically be re-executed when reconnecting.", - &opt_init_command, &opt_init_command, 0, - GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.", - &opt_local_infile, &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, + &named_cmds, &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"net-buffer-length", 0, + "The buffer size for TCP/IP and socket communication.", + &opt_net_buffer_length, &opt_net_buffer_length, 0, GET_ULONG, + REQUIRED_ARG, 16384, 1024, 512*1024ULL*1024ULL, MALLOC_OVERHEAD, 1024, 0}, {"no-beep", 'b', "Turn off beep on error.", &opt_nobeep, &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host.", ¤t_host, - ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"html", 'H', "Produce HTML output.", &opt_html, &opt_html, - 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"xml", 'X', "Produce XML output.", &opt_xml, &opt_xml, 0, - GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"line-numbers", 0, "Write line numbers for errors.", - &line_numbers, &line_numbers, 0, GET_BOOL, - NO_ARG, 1, 0, 0, 0, 0, 0}, - {"skip-line-numbers", 'L', "Don't write line number for errors.", 0, 0, 0, GET_NO_ARG, - NO_ARG, 0, 0, 0, 0, 0, 0}, - {"unbuffered", 'n', "Flush buffer after each query.", &unbuffered, - &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"column-names", 0, "Write column names in results.", - &column_names, &column_names, 0, GET_BOOL, - NO_ARG, 1, 0, 0, 0, 0, 0}, - {"skip-column-names", 'N', - "Don't write column names in results.", - 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"sigint-ignore", 0, "Ignore SIGINT (CTRL-C).", - &opt_sigint_ignore, &opt_sigint_ignore, 0, GET_BOOL, - NO_ARG, 0, 0, 0, 0, 0, 0}, {"one-database", 'o', "Ignore statements except those that occur while the default " "database is the one named at the command line.", @@ -1629,14 +1644,15 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif + {"plugin-dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, + &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection or 0 for default to, in " "order of preference, my.cnf, $MYSQL_TCP_PORT, " #if MYSQL_PORT_DEFAULT == 0 "/etc/services, " #endif - "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", - &opt_mysql_port, - &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", &opt_mysql_port, + &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"progress-reports", 0, "Get progress reports for long running commands (like ALTER TABLE)", &opt_progress_reports, &opt_progress_reports, 0, GET_BOOL, NO_ARG, 1, 0, @@ -1652,11 +1668,25 @@ static struct my_option my_long_options[] = "if the output is suspended. Doesn't use history file.", &quick, &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"raw", 'r', "Write fields without conversion. Used with --batch.", - &opt_raw_data, &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, - 0, 0, 0}, - {"reconnect", 0, "Reconnect if the connection is lost. Disable " - "with --disable-reconnect. This option is enabled by default.", + &opt_raw_data, &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"reconnect", 0, "Reconnect if the connection is lost.", &opt_reconnect, &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.", + &safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.", + &safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"secure-auth", 0, "Refuse client connecting to server if it" + " uses old (pre-4.1.1) protocol.", &opt_secure_auth, + &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"select-limit", 0, + "Automatic limit for SELECT when using --safe-updates.", &select_limit, + &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX, 0, 1, 0}, + {"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"show-warnings", 0, "Show warnings after every statement.", + &show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"sigint-ignore", 0, "Ignore SIGINT (CTRL-C).", &opt_sigint_ignore, + &opt_sigint_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"silent", 's', "Be more silent. Print results with a tab as separator, " "each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "The socket file to use for connection.", @@ -1670,72 +1700,22 @@ static struct my_option my_long_options[] = "Does not work in batch mode. Disable with --disable-tee. " "This option is disabled by default.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"unbuffered", 'n', "Flush buffer after each query.", &unbuffered, + &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE {"user", 'u', "User for login if not current user.", ¤t_user, ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.", - &safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, - 0, 0, 0, 0}, - {"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.", - &safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, - 0, 0, 0, 0}, {"verbose", 'v', "Write more. (-v -v -v gives the table output format).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"vertical", 'E', "Print the output of a query (rows) vertically.", + &vertical, &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"connect_timeout", 0, "Number of seconds before connection timeout.", - &opt_connect_timeout, &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, - 0, 0, 3600*12, 0, 0, 0}, - {"max_allowed_packet", 0, - "The maximum packet length to send to or receive from server.", - &opt_max_allowed_packet, &opt_max_allowed_packet, 0, - GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096, - (longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, - {"net_buffer_length", 0, - "The buffer size for TCP/IP and socket communication.", - &opt_net_buffer_length, &opt_net_buffer_length, 0, GET_ULONG, - REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0}, - {"select_limit", 0, - "Automatic limit for SELECT when using --safe-updates.", - &select_limit, &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, - 1, ULONG_MAX, 0, 1, 0}, - {"max_join_size", 0, - "Automatic limit for rows in a join when using --safe-updates.", - &max_join_size, &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, - 1, ULONG_MAX, 0, 1, 0}, - {"secure-auth", 0, "Refuse client connecting to server if it" - " uses old (pre-4.1.1) protocol.", &opt_secure_auth, - &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.", - 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"show-warnings", 0, "Show warnings after every statement.", - &show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG, - 0, 0, 0, 0, 0, 0}, - {"plugin_dir", 0, "Directory for client-side plugins.", - &opt_plugin_dir, &opt_plugin_dir, 0, - GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"default_auth", 0, - "Default authentication client-side plugin to use.", - &opt_default_auth, &opt_default_auth, 0, - GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"binary-mode", 0, - "Binary mode allows certain character sequences to be processed as data " - "that would otherwise be treated with a special meaning by the parser. " - "Specifically, this switch turns off parsing of all client commands except " - "\\C and DELIMITER in non-interactive mode (i.e., when binary mode is " - "combined with either 1) piped input, 2) the --batch mysql option, or 3) " - "the 'source' command). Also, in binary mode, occurrences of '\\r\\n' and " - "ASCII '\\0' are preserved within strings, whereas by default, '\\r\\n' is " - "translated to '\\n' and '\\0' is disallowed in user input.", - &opt_binary_mode, &opt_binary_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"connect-expired-password", 0, - "Notify the server that this client is prepared to handle expired " - "password sandbox mode even if --batch was specified.", - &opt_connect_expired_password, &opt_connect_expired_password, 0, GET_BOOL, - NO_ARG, 0, 0, 0, 0, 0, 0}, + {"xml", 'X', "Produce XML output.", &opt_xml, &opt_xml, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; From 83aedeacc404f5e1000dc8b46e099b4a2cfb1cd0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 5 May 2024 10:29:41 +0200 Subject: [PATCH 291/313] cleanup: remove __attribute__((unused)) from mysql.cc the client is C++, use a much more concise C++ syntax as a bonus, arguments that are used, are no longer marked "unused" --- client/mysql.cc | 105 +++++++++++++++--------------------------------- 1 file changed, 32 insertions(+), 73 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index b7aaa278763..7ebb46a1a16 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2769,9 +2769,7 @@ static void initialize_readline () array of matches, or NULL if there aren't any. */ -static char **new_mysql_completion(const char *text, - int start __attribute__((unused)), - int end __attribute__((unused))) +static char **new_mysql_completion(const char *text, int, int) { if (!status.batch && !quick) #if defined(USE_NEW_READLINE_INTERFACE) @@ -3094,8 +3092,7 @@ static void print_help_item(MYSQL_ROW *cur, int num_name, int num_cat, char *las } -static int com_server_help(String *buffer __attribute__((unused)), - char *line __attribute__((unused)), char *help_arg) +static int com_server_help(String *buffer, char *, char *help_arg) { MYSQL_ROW cur; const char *server_cmd; @@ -3197,18 +3194,16 @@ err: return error; } -static int -com_help(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_help(String *buffer, char *line) { int i, j; char * help_arg= strchr(line,' '), buff[32], *end; if (help_arg) { - while (my_isspace(charset_info,*help_arg)) + while (my_isspace(charset_info, *help_arg)) help_arg++; if (*help_arg) - return com_server_help(buffer,line,help_arg); + return com_server_help(buffer, line, help_arg); } put_info("\nGeneral information about MariaDB can be found at\n" @@ -3231,9 +3226,7 @@ com_help(String *buffer __attribute__((unused)), } - /* ARGSUSED */ -static int -com_clear(String *buffer,char *line __attribute__((unused))) +static int com_clear(String *buffer,char *) { #ifdef HAVE_READLINE if (status.add_to_history) @@ -3243,9 +3236,7 @@ com_clear(String *buffer,char *line __attribute__((unused))) return 0; } - /* ARGSUSED */ -static int -com_charset(String *buffer __attribute__((unused)), char *line) +static int com_charset(String *, char *line) { char buff[256], *param; CHARSET_INFO * new_cs; @@ -3276,8 +3267,7 @@ com_charset(String *buffer __attribute__((unused)), char *line) */ -static int -com_go(String *buffer,char *line __attribute__((unused))) +static int com_go(String *buffer, char *) { char buff[200]; /* about 110 chars used so far */ char time_buff[53+3+1]; /* time max + space & parens + NUL */ @@ -3856,9 +3846,7 @@ tee_print_sized_data(const char *data, unsigned int data_length, unsigned int to } - -static void -print_table_data_html(MYSQL_RES *result) +static void print_table_data_html(MYSQL_RES *result) { MYSQL_ROW cur; MYSQL_FIELD *field; @@ -4154,15 +4142,13 @@ print_tab_data(MYSQL_RES *result) } } -static int -com_tee(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_tee(String *, char *line) { char file_name[FN_REFLEN], *end, *param; if (status.batch) return 0; - while (my_isspace(charset_info,*line)) + while (my_isspace(charset_info, *line)) line++; if (!(param = strchr(line, ' '))) // if outfile wasn't given, use the default { @@ -4199,9 +4185,7 @@ com_tee(String *buffer __attribute__((unused)), } -static int -com_notee(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_notee(String *, char *) { if (opt_outfile) end_tee(); @@ -4214,9 +4198,7 @@ com_notee(String *buffer __attribute__((unused)), */ #ifdef USE_POPEN -static int -com_pager(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_pager(String *, char *line) { char pager_name[FN_REFLEN], *end, *param; @@ -4258,9 +4240,7 @@ com_pager(String *buffer __attribute__((unused)), } -static int -com_nopager(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_nopager(String *, char *) { strmov(pager, "stdout"); opt_nopager=1; @@ -4272,7 +4252,7 @@ com_nopager(String *buffer __attribute__((unused)), #ifdef USE_POPEN static int -com_edit(String *buffer,char *line __attribute__((unused))) +com_edit(String *buffer,char *) { char filename[FN_REFLEN],buff[160]; int fd,tmp,error; @@ -4319,17 +4299,15 @@ err: /* If arg is given, exit without errors. This happens on command 'quit' */ -static int -com_quit(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_quit(String *, char *) { status.exit_status=0; return 1; } static int -com_rehash(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +com_rehash(String *, + char *) { #ifdef HAVE_READLINE build_completion_hash(1, 0); @@ -4339,9 +4317,7 @@ com_rehash(String *buffer __attribute__((unused)), #ifdef USE_POPEN -static int -com_shell(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_shell(String *, char *line) { char *shell_cmd; @@ -4367,8 +4343,7 @@ com_shell(String *buffer __attribute__((unused)), #endif -static int -com_print(String *buffer,char *line __attribute__((unused))) +static int com_print(String *buffer,char *) { tee_puts("--------------", stdout); (void) tee_fputs(buffer->c_ptr(), stdout); @@ -4378,9 +4353,8 @@ com_print(String *buffer,char *line __attribute__((unused))) return 0; /* If empty buffer */ } - /* ARGSUSED */ -static int -com_connect(String *buffer, char *line) + +static int com_connect(String *buffer, char *line) { char *tmp, buff[256]; my_bool save_rehash= opt_rehash; @@ -4433,8 +4407,7 @@ com_connect(String *buffer, char *line) } -static int com_source(String *buffer __attribute__((unused)), - char *line) +static int com_source(String *, char *line) { char source_name[FN_REFLEN], *end, *param; LINE_BUFFER *line_buff; @@ -4498,9 +4471,7 @@ static int com_source(String *buffer __attribute__((unused)), } - /* ARGSUSED */ -static int -com_delimiter(String *buffer __attribute__((unused)), char *line) +static int com_delimiter(String *, char *line) { char buff[256], *tmp; @@ -4527,9 +4498,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) return 0; } - /* ARGSUSED */ -static int -com_use(String *buffer __attribute__((unused)), char *line) +static int com_use(String *, char *line) { char *tmp, buff[FN_REFLEN + 1]; int select_db; @@ -4602,18 +4571,14 @@ com_use(String *buffer __attribute__((unused)), char *line) return 0; } -static int -com_warnings(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_warnings(String *, char *) { show_warnings = 1; put_info("Show warnings enabled.",INFO_INFO); return 0; } -static int -com_nowarnings(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_nowarnings(String *, char *) { show_warnings = 0; put_info("Show warnings disabled.",INFO_INFO); @@ -4858,10 +4823,7 @@ sql_connect(char *host,char *database,char *user,char *password,uint silent) } - -static int -com_status(String *buffer __attribute__((unused)), - char *line __attribute__((unused))) +static int com_status(String *, char *) { const char *status_str; char buff[40]; @@ -4985,8 +4947,7 @@ select_limit, max_join_size); return 0; } -static const char * -server_version_string(MYSQL *con) +static const char * server_version_string(MYSQL *con) { /* Only one thread calls this, so no synchronization is needed */ if (server_version == NULL) @@ -5111,8 +5072,7 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) } -static int -put_error(MYSQL *con) +static int put_error(MYSQL *con) { return put_info(mysql_error(con), INFO_ERROR, mysql_errno(con), mysql_sqlstate(con)); @@ -5178,7 +5138,7 @@ void tee_putc(int c, FILE *file) len("4294967296 days, 23 hours, 59 minutes, 60.000 seconds") -> 53 */ -static void nice_time(double sec,char *buff,bool part_second) +static void nice_time(double sec, char *buff, bool part_second) { ulong tmp; if (sec >= 3600.0*24) @@ -5429,8 +5389,7 @@ static void init_username() } } -static int com_prompt(String *buffer __attribute__((unused)), - char *line) +static int com_prompt(String *, char *line) { char *ptr=strchr(line, ' '); prompt_counter = 0; From 2025597c0bc4fc1aa076af2476e0f8c4ce056168 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 5 May 2024 09:44:10 +0200 Subject: [PATCH 292/313] MDEV-21778 Disable system commands in mysql/mariadb client mysql --sandbox disables system (\!), tee (\T), pager with an argument(\P foo), source (\.) does *not* disable edit (\e). Use EDITOR=/bin/false to disable or, for example, EDITOR=rnano for something more useful does *not* disable pager (\P) without an argument. Use PAGER=cat or, for example PAGER=less LESSSECURE=1 for something more useful using a disabled command is an error, which can be ignored with --force Also, a "sandbox" command (\-) - enables the sandbox mode until EOF (current file or the session, if interactive) --- client/mysql.cc | 29 +++++++++++++++++++++++--- mysql-test/main/mysql.result | 24 ++++++++++++++++++++++ mysql-test/main/mysql.test | 40 ++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 3 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 7ebb46a1a16..5c79dd7890b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -136,7 +136,7 @@ typedef struct st_status ulong query_start_line; char *file_name; LINE_BUFFER *line_buff; - bool batch,add_to_history; + bool batch, add_to_history, sandbox; } STATUS; @@ -154,7 +154,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0, vertical=0, line_numbers=1, column_names=1,opt_html=0, opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0, tty_password= 0, opt_nobeep=0, opt_reconnect=1, - opt_secure_auth= 0, + opt_secure_auth= 0, default_pager_set= 0, opt_sigint_ignore= 0, auto_vertical_output= 0, show_warnings= 0, executing_query= 0, @@ -235,7 +235,8 @@ static int com_quit(String *str,char*), com_rehash(String *str, char*), com_tee(String *str, char*), com_notee(String *str, char*), com_charset(String *str,char*), com_prompt(String *str, char*), com_delimiter(String *str, char*), - com_warnings(String *str, char*), com_nowarnings(String *str, char*); + com_warnings(String *str, char*), com_nowarnings(String *str, char*), + com_sandbox(String *str, char*); #ifdef USE_POPEN static int com_nopager(String *str, char*), com_pager(String *str, char*), @@ -311,6 +312,8 @@ static COMMANDS commands[] = { { "prompt", 'R', com_prompt, 1, "Change your mysql prompt."}, { "quit", 'q', com_quit, 0, "Quit mysql." }, { "rehash", '#', com_rehash, 0, "Rebuild completion hash." }, + { "sandbox", '-', com_sandbox, 0, + "Disallow commands that access the file system (except \\P without an argument and \\e)." }, { "source", '.', com_source, 1, "Execute an SQL script file. Takes a file name as an argument."}, { "status", 's', com_status, 0, "Get status information from the server."}, @@ -1675,6 +1678,8 @@ static struct my_option my_long_options[] = &safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.", &safe_updates, &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"sandbox", 0, "Disallow commands that access the file system (except \\P without an argument and \\e).", + &status.sandbox, &status.sandbox, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"secure-auth", 0, "Refuse client connecting to server if it" " uses old (pre-4.1.1) protocol.", &opt_secure_auth, &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -4146,6 +4151,8 @@ static int com_tee(String *, char *line) { char file_name[FN_REFLEN], *end, *param; + if (status.sandbox) + return put_info("Not allowed in the sandbox mode", INFO_ERROR, 0); if (status.batch) return 0; while (my_isspace(charset_info, *line)) @@ -4226,6 +4233,8 @@ static int com_pager(String *, char *line) } else { + if (status.sandbox) + return put_info("Not allowed in the sandbox mode", INFO_ERROR, 0); end= strmake_buf(pager_name, param); while (end > pager_name && (my_isspace(charset_info,end[-1]) || my_iscntrl(charset_info,end[-1]))) @@ -4321,6 +4330,9 @@ static int com_shell(String *, char *line) { char *shell_cmd; + if (status.sandbox) + return put_info("Not allowed in the sandbox mode", INFO_ERROR, 0); + /* Skip space from line begin */ while (my_isspace(charset_info, *line)) line++; @@ -4416,6 +4428,9 @@ static int com_source(String *, char *line) FILE *sql_file; my_bool save_ignore_errors; + if (status.sandbox) + return put_info("Not allowed in the sandbox mode", INFO_ERROR, 0); + /* Skip space from file name */ while (my_isspace(charset_info,*line)) line++; @@ -4450,6 +4465,7 @@ static int com_source(String *, char *line) bfill((char*) &status,sizeof(status),(char) 0); status.batch=old_status.batch; // Run in batch mode + status.sandbox=old_status.sandbox; status.line_buff=line_buff; status.file_name=source_name; glob_buffer.length(0); // Empty command buffer @@ -4571,6 +4587,13 @@ static int com_use(String *, char *line) return 0; } +static int com_sandbox(String *, char *) +{ + status.sandbox= 1; + put_info("Sandbox mode.", INFO_INFO); + return 0; +} + static int com_warnings(String *, char *) { show_warnings = 1; diff --git a/mysql-test/main/mysql.result b/mysql-test/main/mysql.result index 48e0a9335ff..b168f1b57d5 100644 --- a/mysql-test/main/mysql.result +++ b/mysql-test/main/mysql.result @@ -633,3 +633,27 @@ drop table t1; WARNING: option '--enable-cleartext-plugin' is obsolete. 1 1 +# End of 10.3 tests +# +# MDEV-21778 Disable system commands in mysql/mariadb client +# +ERROR at line 1: Not allowed in the sandbox mode +1 +ERROR at line 1: Not allowed in the sandbox mode +2 +ERROR at line 1: Not allowed in the sandbox mode +3 +1 +entering sandbox +system +tee +source +^^^ +2 +entering sandbox +system +tee +source +^^^ +3 +# End of 10.5 tests diff --git a/mysql-test/main/mysql.test b/mysql-test/main/mysql.test index 0f41add821a..d71c0b59575 100644 --- a/mysql-test/main/mysql.test +++ b/mysql-test/main/mysql.test @@ -716,3 +716,43 @@ drop table t1; # --echo --exec $MYSQL test --enable-cleartext-plugin -e "select 1" + +--echo # End of 10.3 tests + +--echo # +--echo # MDEV-21778 Disable system commands in mysql/mariadb client +--echo # + +--error 1 +--exec $MYSQL --sandbox -Ne "select 1; \! echo foo; select 0" 2>&1 +--error 1 +--exec $MYSQL --sandbox -Ne "select 2; \T echo foo; select 0" 2>&1 +--error 1 +--exec $MYSQL --sandbox -Ne "select 3; \. echo.foo; select 0" 2>&1 + +--write_file $MYSQL_TMP_DIR/mysql_in +select 'entering sandbox'; +\- +select 'system'; +\! echo foo +select 'tee'; +\T echo foo +select 'source'; +\. echo.foo +select '^^^'; +EOF + +write_line "select 1; +source $MYSQL_TMP_DIR/mysql_in; +select 2; +source $MYSQL_TMP_DIR/mysql_in; +sandbox; +select 3; +source $MYSQL_TMP_DIR/mysql_in;" $MYSQL_TMP_DIR/mysql_in2; + +--exec $MYSQL -fN <$MYSQL_TMP_DIR/mysql_in2 + +--remove_file $MYSQL_TMP_DIR/mysql_in +--remove_file $MYSQL_TMP_DIR/mysql_in2 + +--echo # End of 10.5 tests From 13663cb5c4558383e9dab96e501d72ceb7a0a158 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 5 May 2024 17:37:37 +0200 Subject: [PATCH 293/313] MDEV-33727 mariadb-dump trusts the server and does not validate the data safety first - tell mariadb client not to execute dangerous cli commands, they cannot be present in the dump anyway. wrapping the command in /*!999999 ..... */ guarantees that if a non-mariadb-cli client loads the dump and sends it to the server - the server will ignore the command it doesn't understand --- client/mysqldump.c | 91 +++++++------- mysql-test/main/ddl_i18n_koi8r.result | 6 + mysql-test/main/ddl_i18n_utf8.result | 6 + mysql-test/main/lock_view.result | 2 + mysql-test/main/mysql.result | 8 +- mysql-test/main/mysqldump-compat-102.result | 1 + mysql-test/main/mysqldump-max.result | 2 + mysql-test/main/mysqldump-nl.result | 2 + mysql-test/main/mysqldump-no-binlog.result | 1 + mysql-test/main/mysqldump-system.result | 3 + mysql-test/main/mysqldump-timing.result | 2 + mysql-test/main/mysqldump-utf8mb4.result | 1 + mysql-test/main/mysqldump.result | 118 +++++++++++++++++- mysql-test/main/mysqldump.test | 23 +++- mysql-test/main/openssl_1.result | 3 + mysql-test/main/plugin_auth.result | 1 + mysql-test/main/rpl_mysqldump_slave.result | 17 +++ mysql-test/main/trigger_wl3253.result | 2 + .../suite/archive/archive_bitfield.result | 1 + .../r/mysqldump_restore_func_qualified.result | 1 + .../oracle/r/sp-package-mysqldump.result | 1 + mysql-test/suite/federated/federatedx.result | 1 + mysql-test/suite/roles/definer.result | 1 + .../suite/sql_sequence/mysqldump.result | 5 + .../connect/mysql-test/connect/r/mysql.result | 1 + 25 files changed, 246 insertions(+), 54 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 06ecc67cc97..d3d6851b65a 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -753,56 +753,59 @@ static void write_header(FILE *sql_file, const char *db_name) fputs(">\n", sql_file); check_io(sql_file); } - else if (!opt_compact) + else { - print_comment(sql_file, 0, - "-- MariaDB dump %s Distrib %s, for %s (%s)\n--\n", - DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE, - MACHINE_TYPE); - print_comment(sql_file, 0, "-- Host: %s ", - fix_for_comment(current_host ? current_host : "localhost")); - print_comment(sql_file, 0, "Database: %s\n", - fix_for_comment(db_name ? db_name : "")); - print_comment(sql_file, 0, - "-- ------------------------------------------------------\n" - ); - print_comment(sql_file, 0, "-- Server version\t%s\n", - mysql_get_server_info(&mysql_connection)); - - if (!opt_logging) - fprintf(sql_file, -"\n/*M!100101 SET LOCAL SQL_LOG_OFF=0, LOCAL SLOW_QUERY_LOG=0 */;"); - - if (opt_set_charset) - fprintf(sql_file, -"\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" -"\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" -"\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" -"\n/*!40101 SET NAMES %s */;\n",default_charset); - - if (opt_tz_utc) + fprintf(sql_file, "/*!999999\\- enable the sandbox mode */ \n"); + if (!opt_compact) { - fprintf(sql_file, "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;\n"); - fprintf(sql_file, "/*!40103 SET TIME_ZONE='+00:00' */;\n"); - } + print_comment(sql_file, 0, + "-- MariaDB dump %s Distrib %s, for %s (%s)\n--\n", + DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE, + MACHINE_TYPE); + print_comment(sql_file, 0, "-- Host: %s ", + fix_for_comment(current_host ? current_host : "localhost")); + print_comment(sql_file, 0, "Database: %s\n", + fix_for_comment(db_name ? db_name : "")); + print_comment(sql_file, 0, + "-- ------------------------------------------------------\n" + ); + print_comment(sql_file, 0, "-- Server version\t%s\n", + mysql_get_server_info(&mysql_connection)); - if (!path) - { - if (!opt_no_create_info) + if (!opt_logging) + fprintf(sql_file, + "\n/*M!100101 SET LOCAL SQL_LOG_OFF=0, LOCAL SLOW_QUERY_LOG=0 */;"); + + if (opt_set_charset) + fprintf(sql_file, + "\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" + "\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" + "\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" + "\n/*!40101 SET NAMES %s */;\n",default_charset); + + if (opt_tz_utc) { - /* We don't need unique checks as the table is created just before */ - fprintf(md_result_file,"\ -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n"); + fprintf(sql_file, "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;\n"); + fprintf(sql_file, "/*!40103 SET TIME_ZONE='+00:00' */;\n"); } - fprintf(md_result_file,"\ -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n\ -"); + + if (!path) + { + if (!opt_no_create_info) + { + /* We don't need unique checks as the table is created just before */ + fprintf(md_result_file, + "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n"); + } + fprintf(md_result_file, + "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n"); + } + fprintf(sql_file, + "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n" + "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n", + path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",", + compatible_mode_normal_str); } - fprintf(sql_file, - "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='%s%s%s' */;\n" - "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n", - path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",", - compatible_mode_normal_str); check_io(sql_file); } } /* write_header */ diff --git a/mysql-test/main/ddl_i18n_koi8r.result b/mysql-test/main/ddl_i18n_koi8r.result index 9fd6e2c968f..ab5104123a0 100644 --- a/mysql-test/main/ddl_i18n_koi8r.result +++ b/mysql-test/main/ddl_i18n_koi8r.result @@ -719,6 +719,7 @@ ca cb utf8_general_ci utf8_general_ci ---> Dump of mysqltest1 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -795,6 +796,7 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ; ---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql ---> Dump of mysqltest2 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -1723,6 +1725,7 @@ koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r_general_ci utf8_general_ DELETE FROM mysqltest2.log| ---> Dump of mysqltest1 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -1802,6 +1805,7 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ; ---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql ---> Dump of mysqltest2 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -2485,6 +2489,7 @@ COLLATION( ' END ONE TIME 1970-01-02 00:00:00 NULL NULL NULL NULL DISABLED PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8_unicode_ci ---> Dump of mysqltest1 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -2552,6 +2557,7 @@ DELIMITER ; ---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql ---> Dump of mysqltest2 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; diff --git a/mysql-test/main/ddl_i18n_utf8.result b/mysql-test/main/ddl_i18n_utf8.result index c2bca0cdf78..457f68a33af 100644 --- a/mysql-test/main/ddl_i18n_utf8.result +++ b/mysql-test/main/ddl_i18n_utf8.result @@ -719,6 +719,7 @@ ca cb utf8_general_ci utf8_general_ci ---> Dump of mysqltest1 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -795,6 +796,7 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ; ---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql ---> Dump of mysqltest2 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -1723,6 +1725,7 @@ utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8_general_ci DELETE FROM mysqltest2.log| ---> Dump of mysqltest1 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -1802,6 +1805,7 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ; ---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql ---> Dump of mysqltest2 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -2485,6 +2489,7 @@ COLLATION( 'текÑÑ‚') AS c4, END ONE TIME 1970-01-02 00:00:00 NULL NULL NULL NULL DISABLED PRESERVE CREATED LAST_ALTERED NULL 1 utf8 utf8_general_ci utf8_unicode_ci ---> Dump of mysqltest1 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; @@ -2552,6 +2557,7 @@ DELIMITER ; ---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql ---> Dump of mysqltest2 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */; diff --git a/mysql-test/main/lock_view.result b/mysql-test/main/lock_view.result index 47a7e58ea0d..3d710f38936 100644 --- a/mysql-test/main/lock_view.result +++ b/mysql-test/main/lock_view.result @@ -16,6 +16,7 @@ create definer=definer@localhost view mysqltest3.v3is as select schema_name from create definer=definer@localhost view mysqltest3.v3ps as select user from performance_schema.users where current_connections>0 order by user; create definer=definer@localhost view mysqltest3.v3nt as select 1; create definer=definer@localhost sql security invoker view mysqltest3.v3i as select * from mysqltest1.t1; +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */; @@ -235,6 +236,7 @@ create view v1 as select * from (select * from t1) dt; lock table v1 read; disconnect con1; connection default; +/*!999999\- enable the sandbox mode */ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `v1` AS SELECT diff --git a/mysql-test/main/mysql.result b/mysql-test/main/mysql.result index b168f1b57d5..c6834d0fc20 100644 --- a/mysql-test/main/mysql.result +++ b/mysql-test/main/mysql.result @@ -552,6 +552,7 @@ Table Create Table a1\`b1 CREATE TABLE `a1\``b1` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `a1\``b1` ( @@ -581,6 +582,7 @@ Table Create Table a1\"b1 CREATE TABLE "a1\""b1" ( "a" int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE "a1\""b1" ( @@ -603,11 +605,11 @@ set sql_mode=default; create table t1 (a text); select count(*) from t1; count(*) -41 +42 truncate table t1; select count(*) from t1; count(*) -41 +42 truncate table t1; select count(*) from t1; count(*) @@ -619,7 +621,7 @@ count(*) truncate table t1; select count(*) from t1; count(*) -41 +42 truncate table t1; select count(*) from t1; count(*) diff --git a/mysql-test/main/mysqldump-compat-102.result b/mysql-test/main/mysqldump-compat-102.result index 86a2ebc47e0..d5ed54570e2 100644 --- a/mysql-test/main/mysqldump-compat-102.result +++ b/mysql-test/main/mysqldump-compat-102.result @@ -58,6 +58,7 @@ BEGIN log(0, 'Session ' || connection_id() || ' ' || current_user || ' started'); END; $$ +/*!999999\- enable the sandbox mode */ -- MariaDB dump DUMPVERSION Distrib DISTVERSION, for OS -- -- Host: localhost Database: db1_mdev17429 diff --git a/mysql-test/main/mysqldump-max.result b/mysql-test/main/mysqldump-max.result index 4a53a5f3328..28c111d37b7 100644 --- a/mysql-test/main/mysqldump-max.result +++ b/mysql-test/main/mysqldump-max.result @@ -77,6 +77,7 @@ id name 3 first value 4 first value 5 first value +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -174,6 +175,7 @@ INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first val /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; diff --git a/mysql-test/main/mysqldump-nl.result b/mysql-test/main/mysqldump-nl.result index 66902492934..1e9928308fc 100644 --- a/mysql-test/main/mysqldump-nl.result +++ b/mysql-test/main/mysqldump-nl.result @@ -12,6 +12,7 @@ create procedure sp() select * from `v1 1v`; flush tables; use test; +/*!999999\- enable the sandbox mode */ -- -- Current Database: `mysqltest1 @@ -134,6 +135,7 @@ test\` \! ls # test` +/*!999999\- enable the sandbox mode */ -- -- Current Database: `test``` diff --git a/mysql-test/main/mysqldump-no-binlog.result b/mysql-test/main/mysqldump-no-binlog.result index 223034d8401..669675ff21b 100644 --- a/mysql-test/main/mysqldump-no-binlog.result +++ b/mysql-test/main/mysqldump-no-binlog.result @@ -1 +1,2 @@ mariadb-dump: Error: Binlogging on server not active +/*!999999\- enable the sandbox mode */ diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result index bc8229ff42f..98cdd16abef 100644 --- a/mysql-test/main/mysqldump-system.result +++ b/mysql-test/main/mysqldump-system.result @@ -38,6 +38,7 @@ CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB"; # # mysqldump of system tables with --system=all # +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -162,6 +163,7 @@ UNLOCK TABLES; # # mysqldump of system tables with --system=all --replace # +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -307,6 +309,7 @@ UNLOCK TABLES; # # mysqldump of system tables with --system=all --insert-ignore # +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; diff --git a/mysql-test/main/mysqldump-timing.result b/mysql-test/main/mysqldump-timing.result index fe44a1eadd4..e70aaf3b0f8 100644 --- a/mysql-test/main/mysqldump-timing.result +++ b/mysql-test/main/mysqldump-timing.result @@ -7,6 +7,7 @@ CREATE TABLE t1 (i INT); INSERT INTO t1 VALUES (0); LOCK TABLE t1 WRITE; timeout without t1 contents expected +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -30,6 +31,7 @@ SET @save_max_statement_time=@@max_statement_time; SET GLOBAL max_statement_time=0.1; UNLOCK TABLES;; This would be a race condition otherwise, but default max_statement_time=0 makes it succeed +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; diff --git a/mysql-test/main/mysqldump-utf8mb4.result b/mysql-test/main/mysqldump-utf8mb4.result index 3bafd6da6c9..ce321a59361 100644 --- a/mysql-test/main/mysqldump-utf8mb4.result +++ b/mysql-test/main/mysqldump-utf8mb4.result @@ -32,6 +32,7 @@ Testing XML format output ---- Testing text format output ---- +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index a23bf87833d..1541a4e6f72 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -31,6 +31,7 @@ DROP TABLE t1; CREATE TABLE t1 (a decimal(64, 20)); INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"), ("0987654321098765432109876543210987654321"); +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -46,6 +47,7 @@ CREATE TABLE t1 (a double); INSERT IGNORE INTO t1 VALUES ('-9e999999'); Warnings: Warning 1264 Out of range value for column 'a' at row 1 +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -67,6 +69,7 @@ INSERT INTO t1 VALUES ('1.2345', 2.3456); INSERT INTO t1 VALUES ("1.2345", 2.3456); ERROR 42S22: Unknown column '1.2345' in 'field list' SET SQL_MODE=@OLD_SQL_MODE; +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -75,6 +78,7 @@ CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t1` VALUES (1.23450,2.3456),(1.23450,2.3456),(1.23450,2.3456),(1.23450,2.3456),(1.23450,2.3456); +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -83,6 +87,7 @@ CREATE TABLE `t1` ( ); /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t1` VALUES (1.23450,2.3456),(1.23450,2.3456),(1.23450,2.3456),(1.23450,2.3456),(1.23450,2.3456); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -118,6 +123,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -194,6 +200,7 @@ DROP TABLE t1; # CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r; INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -235,6 +242,7 @@ DROP TABLE t1; # CREATE TABLE t1 (a int) ENGINE=MYISAM; INSERT INTO t1 VALUES (1), (2); +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -258,6 +266,7 @@ UNLOCK TABLES; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -286,6 +295,7 @@ DROP TABLE t1; # Bug#2592 mysqldump doesn't quote "tricky" names correctly # create table ```a` (i int); +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE ```a` ( @@ -297,6 +307,7 @@ drop table ```a`; # Bug#2591 mysqldump quotes names inconsistently # create table t1(a int); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -330,6 +341,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -356,6 +368,7 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; set global sql_mode='ANSI_QUOTES'; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -389,6 +402,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -421,6 +435,7 @@ drop table t1; # create table t1(a int); insert into t1 values (1),(2),(3); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -453,6 +468,7 @@ drop table t1; # # Bug#6101 create database problem # +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -479,6 +495,7 @@ USE `test`; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; create database mysqldump_test_db character set latin2 collate latin2_bin; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -513,6 +530,7 @@ drop database mysqldump_test_db; # if it is explicitly set. CREATE TABLE t1 (a CHAR(10)); INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -554,6 +572,7 @@ UNLOCK TABLES; # If the future we can move this command into a separate test with # checking that "mysqldump" is compiled with "latin1" # +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -577,6 +596,7 @@ UNLOCK TABLES; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -600,6 +620,7 @@ UNLOCK TABLES; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -631,6 +652,7 @@ CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t2 VALUES (4),(5),(6); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -672,6 +694,7 @@ DROP TABLE t2; # CREATE TABLE t1 (`b` blob); INSERT INTO `t1` VALUES (0x602010000280100005E71A); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -713,6 +736,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INT) ENGINE=MyISAM; INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (4),(5),(6); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -747,6 +771,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1116,6 +1141,7 @@ F_cd00692c3bfe59267d5ecfac5310286c int, F_6faa8040da20ef399b63a72d0e4ab575 int, F_fe73f687e5bc5280214e0486b273a5f9 int); insert into t1 (F_8d3bba7425e7c98c50f52ca1b52d3735) values (1); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1485,6 +1511,7 @@ drop table t1; # CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (1),(2),(3); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1535,6 +1562,7 @@ CREATE TABLE t1 ( a INT ); CREATE TABLE t2 ( a INT ); INSERT INTO t1 VALUES (1), (2); INSERT INTO t2 VALUES (1), (2); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1570,6 +1598,7 @@ CREATE TABLE `t2` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1642,21 +1671,35 @@ create table t3(a varchar(30) primary key, b int not null); test_sequence ------ Testing with illegal table names ------ mariadb-dump: Couldn't find table: "\d-2-1.sql" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "\t1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "\t1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "\\t1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "t\1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "t\1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "t/1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "T_1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "T%1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "T'1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "T_1" +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't find table: "T_" +/*!999999\- enable the sandbox mode */ test_sequence ------ Testing with illegal database names ------ mariadb-dump: Got error: 1049: "Unknown database 'mysqldump_test_d'" when selecting the database +/*!999999\- enable the sandbox mode */ mariadb-dump: Got error: 1049: "Unknown database 'mysqld\ump_test_db'" when selecting the database +/*!999999\- enable the sandbox mode */ drop table t1, t2, t3; drop database mysqldump_test_db; use test; @@ -1718,6 +1761,7 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1749,6 +1793,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1867,6 +1912,7 @@ create table t1(a int); create table t2(a int); create table t3(a int); mariadb-dump: Couldn't find table: "non_existing" +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1916,6 +1962,7 @@ drop table t1, t2, t3; create table t1 (a int); mariadb-dump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ `a` FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': 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 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064) mariadb-dump: Got error: 1064: "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 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1" when retrieving data from server +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1957,6 +2004,7 @@ CREATE TABLE `t1` ( PRIMARY KEY (`a b`, `c"d`, `e``f`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; insert into t1 values (0815, 4711, 2006); +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -1986,6 +2034,7 @@ UNLOCK TABLES; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2040,6 +2089,7 @@ INSERT INTO t2 VALUES ('bingo'); INSERT INTO t2 VALUES ('waffle'); INSERT INTO t2 VALUES ('lemon'); create view v2 as select * from t2 where a like 'a%' with check option; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2134,6 +2184,7 @@ drop database db1; use test; create table t1(a int); create view v1 as select * from t1; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2204,6 +2255,7 @@ INSERT INTO t2 VALUES ('bingo'); INSERT INTO t2 VALUES ('waffle'); INSERT INTO t2 VALUES ('lemon'); create view v2 as select * from t2 where a like 'a%' with check option; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2269,6 +2321,7 @@ use test; # CREATE TABLE t1 (a char(10)); INSERT INTO t1 VALUES ('\''); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2315,6 +2368,7 @@ create view v1 as select * from v3 where b in (1, 2, 3, 4, 5, 6, 7); create view v2 as select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2464,6 +2518,7 @@ end if; end AFTER 0000-00-00 00:00:00 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci INSERT INTO t1 (a) VALUES (1),(2),(3),(22); update t1 set a = 4 where a=3; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2593,6 +2648,7 @@ DELIMITER ; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2740,6 +2796,7 @@ Warning 1287 '