From 090a84366ad27564ae5e8be01fa1c672508d13ab Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Thu, 6 Jul 2023 11:49:28 +0300 Subject: [PATCH 1/7] MDEV-29311 Server Status Innodb_row_lock_time% is reported in seconds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before MDEV-24671, the wait time was derived from my_interval_timer() / 1000 (nanoseconds converted to microseconds, and not microseconds to milliseconds like I must have assumed). The lock_sys.wait_time and lock_sys.wait_time_max are already in milliseconds; we should not divide them by 1000. In MDEV-24738 the millisecond counts lock_sys.wait_time and lock_sys.wait_time_max were changed to a 32-bit type. That would overflow in 49.7 days. Keep using a 64-bit type for those millisecond counters. Reviewed by: Marko Mäkelä --- .../innodb/r/innodb_row_lock_time_ms.result | 40 ++++++++++++++++++ .../innodb/t/innodb_row_lock_time_ms.test | 42 +++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 4 +- storage/innobase/include/lock0lock.h | 8 ++-- storage/innobase/include/srv0srv.h | 11 ++--- storage/innobase/lock/lock0lock.cc | 4 +- storage/innobase/srv/srv0mon.cc | 7 ++-- storage/innobase/srv/srv0srv.cc | 7 ++-- 8 files changed, 100 insertions(+), 23 deletions(-) create mode 100644 mysql-test/suite/innodb/r/innodb_row_lock_time_ms.result create mode 100644 mysql-test/suite/innodb/t/innodb_row_lock_time_ms.test diff --git a/mysql-test/suite/innodb/r/innodb_row_lock_time_ms.result b/mysql-test/suite/innodb/r/innodb_row_lock_time_ms.result new file mode 100644 index 00000000000..984d789e058 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_row_lock_time_ms.result @@ -0,0 +1,40 @@ +CREATE TABLE `t`(`id` INT, PRIMARY KEY(`id`)) ENGINE=InnoDB STATS_PERSISTENT=0; +INSERT INTO t VALUES (1); +SET GLOBAL innodb_monitor_reset = "module_innodb"; +BEGIN; +SELECT * FROM t FOR UPDATE; +id +1 +connect con1,localhost,root,,; +SET innodb_lock_wait_timeout = 1; +SELECT * FROM t FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +disconnect con1; +connection default; +COMMIT; +SELECT variable_value > 100 FROM information_schema.global_status +WHERE LOWER(variable_name) = 'innodb_row_lock_time'; +variable_value > 100 +1 +SELECT variable_value > 100 FROM information_schema.global_status +WHERE LOWER(variable_name) = 'innodb_row_lock_time_max'; +variable_value > 100 +1 +SELECT variable_value > 100 FROM information_schema.global_status +WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg'; +variable_value > 100 +1 +SELECT count_reset > 100 FROM INFORMATION_SCHEMA.INNODB_METRICS +WHERE NAME="lock_row_lock_time"; +count_reset > 100 +1 +SELECT count_reset > 100 FROM INFORMATION_SCHEMA.INNODB_METRICS +WHERE NAME="lock_row_lock_time_max"; +count_reset > 100 +1 +SELECT count_reset > 100 FROM INFORMATION_SCHEMA.INNODB_METRICS +WHERE NAME="lock_row_lock_time_avg"; +count_reset > 100 +1 +DROP TABLE t; +SET GLOBAL innodb_monitor_reset=default; diff --git a/mysql-test/suite/innodb/t/innodb_row_lock_time_ms.test b/mysql-test/suite/innodb/t/innodb_row_lock_time_ms.test new file mode 100644 index 00000000000..4a100821819 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_row_lock_time_ms.test @@ -0,0 +1,42 @@ +--source include/have_innodb.inc +--source include/count_sessions.inc + +CREATE TABLE `t`(`id` INT, PRIMARY KEY(`id`)) ENGINE=InnoDB STATS_PERSISTENT=0; + +INSERT INTO t VALUES (1); + +SET GLOBAL innodb_monitor_reset = "module_innodb"; + +BEGIN; +SELECT * FROM t FOR UPDATE; + +--connect(con1,localhost,root,,) +SET innodb_lock_wait_timeout = 1; +--error ER_LOCK_WAIT_TIMEOUT +SELECT * FROM t FOR UPDATE; +--disconnect con1 + +--connection default +COMMIT; + +SELECT variable_value > 100 FROM information_schema.global_status + WHERE LOWER(variable_name) = 'innodb_row_lock_time'; +SELECT variable_value > 100 FROM information_schema.global_status + WHERE LOWER(variable_name) = 'innodb_row_lock_time_max'; +SELECT variable_value > 100 FROM information_schema.global_status + WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg'; + +SELECT count_reset > 100 FROM INFORMATION_SCHEMA.INNODB_METRICS + WHERE NAME="lock_row_lock_time"; +SELECT count_reset > 100 FROM INFORMATION_SCHEMA.INNODB_METRICS + WHERE NAME="lock_row_lock_time_max"; +SELECT count_reset > 100 FROM INFORMATION_SCHEMA.INNODB_METRICS + WHERE NAME="lock_row_lock_time_avg"; + +DROP TABLE t; + +--disable_warnings +SET GLOBAL innodb_monitor_reset=default; +--enable_warnings + +--source include/wait_until_count_sessions.inc diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 3d0da6bbf74..c44748d3c5f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1010,8 +1010,8 @@ static SHOW_VAR innodb_status_variables[]= { {"row_lock_current_waits", &export_vars.innodb_row_lock_current_waits, SHOW_SIZE_T}, {"row_lock_time", &export_vars.innodb_row_lock_time, SHOW_LONGLONG}, - {"row_lock_time_avg", &export_vars.innodb_row_lock_time_avg, SHOW_SIZE_T}, - {"row_lock_time_max", &export_vars.innodb_row_lock_time_max, SHOW_SIZE_T}, + {"row_lock_time_avg", &export_vars.innodb_row_lock_time_avg, SHOW_ULONGLONG}, + {"row_lock_time_max", &export_vars.innodb_row_lock_time_max, SHOW_ULONGLONG}, {"row_lock_waits", &export_vars.innodb_row_lock_waits, SHOW_SIZE_T}, {"rows_deleted", &export_vars.innodb_rows_deleted, SHOW_SIZE_T}, {"rows_inserted", &export_vars.innodb_rows_inserted, SHOW_SIZE_T}, diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index e8299bb1189..4c92984f2f6 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -755,9 +755,9 @@ private: /** waits and total number of lock waits; protected by wait_mutex */ uint64_t wait_count; /** Cumulative wait time; protected by wait_mutex */ - uint32_t wait_time; + uint64_t wait_time; /** Longest wait time; protected by wait_mutex */ - uint32_t wait_time_max; + uint64_t wait_time_max; public: /** number of deadlocks detected; protected by wait_mutex */ ulint deadlocks; @@ -916,9 +916,9 @@ public: ulint get_wait_cumulative() const { return static_cast(wait_count / WAIT_COUNT_STEP); } /** Cumulative wait time; protected by wait_mutex */ - ulint get_wait_time_cumulative() const { return wait_time; } + uint64_t get_wait_time_cumulative() const { return wait_time; } /** Longest wait time; protected by wait_mutex */ - ulint get_wait_time_max() const { return wait_time_max; } + uint64_t get_wait_time_max() const { return wait_time_max; } /** Get the lock hash table for a mode */ hash_table &hash_get(ulint mode) diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index c4c854f6b9c..0052f015239 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -708,13 +708,10 @@ struct export_var_t{ ulint innodb_os_log_pending_fsyncs; /*!< n_pending_log_flushes */ ulint innodb_row_lock_waits; /*!< srv_n_lock_wait_count */ ulint innodb_row_lock_current_waits; /*!< srv_n_lock_wait_current_count */ - int64_t innodb_row_lock_time; /*!< srv_n_lock_wait_time - / 1000 */ - ulint innodb_row_lock_time_avg; /*!< srv_n_lock_wait_time - / 1000 - / srv_n_lock_wait_count */ - ulint innodb_row_lock_time_max; /*!< srv_n_lock_max_wait_time - / 1000 */ + int64_t innodb_row_lock_time; /*!< srv_n_lock_wait_time */ + uint64_t innodb_row_lock_time_avg; /*!< srv_n_lock_wait_time + / srv_n_lock_wait_count */ + uint64_t innodb_row_lock_time_max; /*!< srv_n_lock_max_wait_time */ ulint innodb_rows_read; /*!< srv_n_rows_read */ ulint innodb_rows_inserted; /*!< srv_n_rows_inserted */ ulint innodb_rows_updated; /*!< srv_n_rows_updated */ diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 08547f169f3..6a7e4a2843e 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1648,8 +1648,8 @@ void lock_sys_t::wait_resume(THD *thd, my_hrtime_t start, my_hrtime_t now) wait_count--; if (now.val >= start.val) { - const uint32_t diff_time= - static_cast((now.val - start.val) / 1000); + const uint64_t diff_time= + static_cast((now.val - start.val) / 1000); wait_time+= diff_time; if (diff_time > wait_time_max) diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index 3065ab19462..aa14bc00976 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1677,21 +1677,20 @@ srv_mon_process_existing_counter( /* innodb_row_lock_time */ case MONITOR_OVLD_LOCK_WAIT_TIME: // dirty read without lock_sys.wait_mutex - value = lock_sys.get_wait_time_cumulative() / 1000; + value = lock_sys.get_wait_time_cumulative(); break; /* innodb_row_lock_time_max */ case MONITOR_OVLD_LOCK_MAX_WAIT_TIME: // dirty read without lock_sys.wait_mutex - value = lock_sys.get_wait_time_max() / 1000; + value = lock_sys.get_wait_time_max(); break; /* innodb_row_lock_time_avg */ case MONITOR_OVLD_LOCK_AVG_WAIT_TIME: mysql_mutex_lock(&lock_sys.wait_mutex); if (auto count = lock_sys.get_wait_cumulative()) { - value = lock_sys.get_wait_time_cumulative() / 1000 - / count; + value = lock_sys.get_wait_time_cumulative() / count; } else { value = 0; } diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 8a4df1b0d14..38ec7377fa4 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1057,10 +1057,9 @@ srv_export_innodb_status(void) export_vars.innodb_row_lock_current_waits= lock_sys.get_wait_pending(); - export_vars.innodb_row_lock_time = lock_sys.get_wait_time_cumulative() - / 1000; - export_vars.innodb_row_lock_time_max = lock_sys.get_wait_time_max() - / 1000; + export_vars.innodb_row_lock_time = lock_sys.get_wait_time_cumulative(); + export_vars.innodb_row_lock_time_max = lock_sys.get_wait_time_max(); + mysql_mutex_unlock(&lock_sys.wait_mutex); export_vars.innodb_row_lock_time_avg= export_vars.innodb_row_lock_waits From feaeb27b6913e3c1dc67f01bb80b381fec333b56 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 11 Jul 2023 20:24:28 +0300 Subject: [PATCH 2/7] MDEV-29152: Assertion failed ... upon TO_CHAR with wrong argument Item_func_tochar::check_arguments() didn't check if its arguments each had one column. Failing to make this check and proceeding would eventually cause either an assertion failure or the execution would reach "MY_ASSERT_UNREACHABLE();" which would produce a crash with a misleading stack trace. * Fixed Item_func_tochar::check_arguments() to do the required check. * Also fixed MY_ASSERT_UNREACHABLE() to terminate the program. Just "executing" __builtin_unreachable() used to cause "undefined results", which in my experience was a crash with corrupted stack trace. --- include/my_compiler.h | 12 ++++++++++-- mysql-test/suite/compat/oracle/r/func_to_char.result | 7 +++++++ mysql-test/suite/compat/oracle/t/func_to_char.test | 10 ++++++++++ sql/item_timefunc.h | 5 ++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/my_compiler.h b/include/my_compiler.h index ff049f3d8a6..b979b5a5b73 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -40,7 +40,15 @@ /* GNU C/C++ */ #if defined __GNUC__ # define MY_ALIGN_EXT -# define MY_ASSERT_UNREACHABLE() __builtin_unreachable() + +/* + __builtin_unreachable() removes the "statement may fall through" warning-as- + error when MY_ASSERT_UNREACHABLE() is used in "case xxx:" in switch (...) + statements. + abort() is there to prevent the execution from reaching the + __builtin_unreachable() as this may cause misleading stack traces. +*/ +# define MY_ASSERT_UNREACHABLE() { abort(); __builtin_unreachable(); } /* Microsoft Visual C++ */ #elif defined _MSC_VER @@ -88,7 +96,7 @@ #endif #ifndef MY_ASSERT_UNREACHABLE -# define MY_ASSERT_UNREACHABLE() do { assert(0); } while (0) +# define MY_ASSERT_UNREACHABLE() do { abort(); } while (0) #endif /** diff --git a/mysql-test/suite/compat/oracle/r/func_to_char.result b/mysql-test/suite/compat/oracle/r/func_to_char.result index a4978b07579..1f95acece5e 100644 --- a/mysql-test/suite/compat/oracle/r/func_to_char.result +++ b/mysql-test/suite/compat/oracle/r/func_to_char.result @@ -439,3 +439,10 @@ NULL 2021-01-24 drop table t1,t2; set @local.sql_mode=@sql_mode; +# +# MDEV-29152: Assertion failed ... upon TO_CHAR with wrong argument +# +SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10'))); +ERROR HY000: Illegal parameter data type row for operation 'to_char' +SELECT TO_CHAR((STR_TO_DATE('2023-01-01', '%d-%m-%Y'), 'YYYY-MM-DD') ); +ERROR HY000: Illegal parameter data type row for operation 'to_char' diff --git a/mysql-test/suite/compat/oracle/t/func_to_char.test b/mysql-test/suite/compat/oracle/t/func_to_char.test index 9910fe60a84..7a40321538d 100644 --- a/mysql-test/suite/compat/oracle/t/func_to_char.test +++ b/mysql-test/suite/compat/oracle/t/func_to_char.test @@ -224,3 +224,13 @@ select * from t2; drop table t1,t2; set @local.sql_mode=@sql_mode; +--echo # +--echo # MDEV-29152: Assertion failed ... upon TO_CHAR with wrong argument +--echo # + +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT TO_CHAR((VALUES('2022-12-12','2020-10-10'))); + +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION +SELECT TO_CHAR((STR_TO_DATE('2023-01-01', '%d-%m-%Y'), 'YYYY-MM-DD') ); + diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 9b78d6c159e..1cf1a614ece 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -996,7 +996,10 @@ class Item_func_tochar :public Item_str_func bool check_arguments() const override { - return check_argument_types_can_return_text(1, arg_count); + return + (args[0]->check_type_can_return_date(func_name_cstring()) && + args[0]->check_type_can_return_time(func_name_cstring())) || + check_argument_types_can_return_text(1, arg_count); } public: From a4e103ad825f872e0c07a717984ec05357e02837 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 12 Jul 2023 22:55:26 +0300 Subject: [PATCH 3/7] Fixed bug in ddl log This issue could only be noticed in very extraordinary circumstances when trying to rename a temporary table that is not in the file system. The issue was found when I temporarly disabled check_if_frm_exists() while searching for another bug. --- sql/ddl_log.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 8722d88ba95..ec688a8cc86 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -1099,7 +1099,7 @@ static void execute_rename_table(DDL_LOG_ENTRY *ddl_log_entry, handler *file, { fr_length= build_table_filename(from_path, FN_REFLEN, from_db->str, from_table->str, "", - flags & FN_TO_IS_TMP); + flags & FN_FROM_IS_TMP); to_length= build_table_filename(to_path, FN_REFLEN, to_db->str, to_table->str, "", flags & FN_TO_IS_TMP); From a03ce7b99cde33855965a8c2edb5e973d09e7871 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 13 Jul 2023 16:05:02 +0400 Subject: [PATCH 4/7] MDEV-31521 bzero wipes more bytes than necessary in set_global_from_ddl_log_entry. 'defaults' made into 'constexpr' variables. --- sql/ddl_log.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index ec688a8cc86..b65305918e3 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -141,23 +141,23 @@ static st_ddl_recovery recovery_state; mysql_mutex_t LOCK_gdl; /* Positions to different data in a ddl log block */ -#define DDL_LOG_ENTRY_TYPE_POS 0 +static constexpr unsigned DDL_LOG_ENTRY_TYPE_POS= 0; /* Note that ACTION_TYPE and PHASE_POS must be after each other. See update_phase() */ -#define DDL_LOG_ACTION_TYPE_POS 1 -#define DDL_LOG_PHASE_POS 2 -#define DDL_LOG_NEXT_ENTRY_POS 4 +static constexpr unsigned DDL_LOG_ACTION_TYPE_POS= 1; +static constexpr unsigned DDL_LOG_PHASE_POS= 2; +static constexpr unsigned DDL_LOG_NEXT_ENTRY_POS= 4; /* Flags to remember something unique about the query, like if .frm was used */ -#define DDL_LOG_FLAG_POS 8 +static constexpr unsigned DDL_LOG_FLAG_POS= 8; /* Used to store XID entry that was written to binary log */ -#define DDL_LOG_XID_POS 10 +static constexpr unsigned DDL_LOG_XID_POS= 10; /* Used to store unique uuid from the .frm file */ -#define DDL_LOG_UUID_POS 18 +static constexpr unsigned DDL_LOG_UUID_POS= 18; /* ID_POS can be used to store something unique, like file size (4 bytes) */ -#define DDL_LOG_ID_POS DDL_LOG_UUID_POS + MY_UUID_SIZE -#define DDL_LOG_END_POS DDL_LOG_ID_POS + 8 +static constexpr unsigned DDL_LOG_ID_POS= DDL_LOG_UUID_POS + MY_UUID_SIZE; +static constexpr unsigned DDL_LOG_END_POS= DDL_LOG_ID_POS + 8; /* Position to where names are stored in the ddl log blocks. The current @@ -165,19 +165,19 @@ mysql_mutex_t LOCK_gdl; space for constants in the header than what is between DDL_LOG_ID_POS and DDL_LOG_TMP_NAME_POS. */ -#define DDL_LOG_TMP_NAME_POS 56 +static constexpr unsigned DDL_LOG_TMP_NAME_POS= 56; /* Definitions for the ddl log header, the first block in the file */ /* IO_SIZE is stored in the header and can thus be changed */ -#define DDL_LOG_IO_SIZE IO_SIZE +static constexpr unsigned DDL_LOG_IO_SIZE= IO_SIZE; /* Header is stored in positions 0-3 */ -#define DDL_LOG_IO_SIZE_POS 4 -#define DDL_LOG_NAME_OFFSET_POS 6 +static constexpr unsigned DDL_LOG_IO_SIZE_POS= 4; +static constexpr unsigned DDL_LOG_NAME_OFFSET_POS= 6; /* Marks if we have done a backup of the ddl log */ -#define DDL_LOG_BACKUP_OFFSET_POS 8 +static constexpr unsigned DDL_LOG_BACKUP_OFFSET_POS= 8; /* Sum of the above variables */ -#define DDL_LOG_HEADER_SIZE 4+2+2+1 +static constexpr unsigned DDL_LOG_HEADER_SIZE= 4+2+2+1; /** Sync the ddl log file. From 6e484c3bd99a6709e3554f32a99167042ea88496 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 6 Jul 2023 10:41:46 +0300 Subject: [PATCH 5/7] MDEV-31577: Make ANALYZE FORMAT=JSON print innodb stats ANALYZE FORMAT=JSON output now includes table.r_engine_stats which has the engine statistics. Only non-zero members are printed. Internally: EXPLAIN data structures Explain_table_acccess and Explain_update now have handler* handler_for_stats pointer. It is used to read statistics from handler_for_stats->handler_stats. The following applies only to 10.9+, backport doesn't use it: Explain data structures exist after the tables are closed. We avoid walking invalid pointers using this: - SQL layer calls Explain_query::notify_tables_are_closed() before closing tables. - After that call, printing of JSON output is disabled. Non-JSON output can be printed but we don't access handler_for_stats when doing that. --- mysql-test/include/analyze-format.inc | 8 +- .../main/analyze_engine_stats.combinations | 5 + mysql-test/main/analyze_engine_stats.result | 105 ++++++++++++++++++ mysql-test/main/analyze_engine_stats.test | 64 +++++++++++ mysql-test/main/analyze_format_json.result | 37 +++++- .../main/analyze_format_json_timings.result | 4 + mysql-test/main/analyze_stmt_orderby.result | 17 ++- mysql-test/main/cte_recursive.result | 6 + mysql-test/main/derived_cond_pushdown.result | 1 + mysql-test/main/derived_split_innodb.result | 5 + mysql-test/main/except.result | 12 ++ mysql-test/main/except_all.result | 12 ++ mysql-test/main/explain_json.result | 9 ++ .../explain_json_format_partitions.result | 3 + mysql-test/main/intersect.result | 12 ++ mysql-test/main/intersect_all.result | 12 ++ mysql-test/main/order_by.result | 8 ++ mysql-test/main/order_by_pack_big.result | 4 + mysql-test/main/rowid_filter.result | 31 ++++++ mysql-test/main/rowid_filter_innodb.result | 42 +++++++ mysql-test/main/subselect4.result | 3 + mysql-test/main/subselect_cache.result | 5 + mysql-test/main/win.result | 1 + .../encryption/r/tempfiles_encrypted.result | 1 + .../federatedx_create_handlers.result | 1 + sql/sql_class.h | 6 + sql/sql_delete.cc | 2 + sql/sql_explain.cc | 23 ++++ sql/sql_explain.h | 17 ++- sql/sql_lex.cc | 3 +- sql/sql_select.cc | 6 + sql/table.cc | 2 +- 32 files changed, 459 insertions(+), 8 deletions(-) create mode 100644 mysql-test/main/analyze_engine_stats.combinations create mode 100644 mysql-test/main/analyze_engine_stats.result create mode 100644 mysql-test/main/analyze_engine_stats.test diff --git a/mysql-test/include/analyze-format.inc b/mysql-test/include/analyze-format.inc index 330be82ef96..1fbf4e72b76 100644 --- a/mysql-test/include/analyze-format.inc +++ b/mysql-test/include/analyze-format.inc @@ -1,3 +1,7 @@ -# The time on ANALYSE FORMAT=JSON is rather variable +# Remove non-deterministic parts of ANALYZE FORMAT=JSON output: +# - any timings +# - Buffer sizes (depend on pointer size) +# - r_engine_stats depends on buffer pool state and whether old record versions +# were purged. ---replace_regex /("(r_[a-z_]*_time_ms|r_buffer_size)": )[^, \n]*/\1"REPLACED"/ +--replace_regex /("(r_[a-z_]*_time_ms|r_buffer_size)": )[^, \n]*/\1"REPLACED"/ /("r_engine_stats":) {[^}]*}/\1 REPLACED/ diff --git a/mysql-test/main/analyze_engine_stats.combinations b/mysql-test/main/analyze_engine_stats.combinations new file mode 100644 index 00000000000..09620f9f4da --- /dev/null +++ b/mysql-test/main/analyze_engine_stats.combinations @@ -0,0 +1,5 @@ +[slow_query_log_on] +slow_query_log=ON + +[slow_query_log_off] +slow_query_log=OFF diff --git a/mysql-test/main/analyze_engine_stats.result b/mysql-test/main/analyze_engine_stats.result new file mode 100644 index 00000000000..d21a55102da --- /dev/null +++ b/mysql-test/main/analyze_engine_stats.result @@ -0,0 +1,105 @@ +create table t1 ( +pk int not null, +a varchar(64), +b varchar(64), +c varchar(64) +) engine=innodb; +insert into t1 select +seq, seq, seq, seq +from +seq_1_to_10000; +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 +# Note the r_engine_stats below. Only non-zero members are printed +select '$out' as X; +X +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t1", + "access_type": "ALL", + "r_loops": 1, + "rows": 10000, + "r_rows": 10000, + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_engine_stats": { + "pages_accessed": "REPLACED" + }, + "filtered": 99.21875, + "r_filtered": 100, + "attached_condition": "t1.pk < 120000" + } + } +} +set @js='$out'; +set @out=(select json_extract(@js,'$**.r_engine_stats.pages_accessed')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_ACCESSED_MORE_THAN_ZERO; +PAGES_ACCESSED_MORE_THAN_ZERO +1 +# +# Try an UPDATE +# +select '$out' as X; +X +{ + "query_block": { + "select_id": 1, + "r_total_time_ms": "REPLACED", + "table": { + "update": 1, + "table_name": "t1", + "access_type": "ALL", + "rows": 10000, + "r_rows": 10000, + "r_filtered": 100, + "r_total_time_ms": "REPLACED", + "r_engine_stats": { + "pages_accessed": "REPLACED", + "pages_updated": "REPLACED" + }, + "attached_condition": "t1.pk < 120000" + } + } +} +set @js='$out'; +set @out=(select json_extract(@js,'$**.r_engine_stats.pages_updated')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_UPDATED_MORE_THAN_ZERO; +PAGES_UPDATED_MORE_THAN_ZERO +1 +# +# Try a DELETE +# +select '$out' as X; +X +{ + "query_block": { + "select_id": 1, + "r_total_time_ms": "REPLACED", + "table": { + "delete": 1, + "table_name": "t1", + "access_type": "ALL", + "rows": 10000, + "r_rows": 10000, + "r_filtered": 50, + "r_total_time_ms": "REPLACED", + "r_engine_stats": { + "pages_accessed": "REPLACED", + "pages_updated": "REPLACED" + }, + "attached_condition": "t1.pk MOD 2 = 1" + } + } +} +set @js='$out'; +set @out=(select json_extract(@js,'$**.r_engine_stats.pages_updated')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_UPDATED_MORE_THAN_ZERO; +PAGES_UPDATED_MORE_THAN_ZERO +1 +drop table t1; diff --git a/mysql-test/main/analyze_engine_stats.test b/mysql-test/main/analyze_engine_stats.test new file mode 100644 index 00000000000..a26c65a1aa4 --- /dev/null +++ b/mysql-test/main/analyze_engine_stats.test @@ -0,0 +1,64 @@ +# +# Tests for r_engine_stats in ANALYZE FORMAT=JSON output +# +--source include/analyze-format.inc +--source include/have_sequence.inc +--source include/have_innodb.inc + +create table t1 ( + pk int not null, + a varchar(64), + b varchar(64), + c varchar(64) +) engine=innodb; + +insert into t1 select + seq, seq, seq, seq +from + seq_1_to_10000; + +analyze table t1 persistent for all; + +--echo # Note the r_engine_stats below. Only non-zero members are printed +let $out=` +ANALYZE FORMAT=json +select * from t1 where pk < 120000; +`; + +# Don't use "source include/analyze-format.inc" as it replaces r_engine_stats +# Replace the "pages_accessed" value, too, as it is different for some +# platforms... +--replace_regex /("(r_[a-z_]*_time(_in_progress)?_ms|r_buffer_size|pages_accessed)": )[^, \n]*/\1"REPLACED"/ +evalp select '$out' as X; + +evalp set @js='$out'; +set @out=(select json_extract(@js,'$**.r_engine_stats.pages_accessed')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_ACCESSED_MORE_THAN_ZERO; + +--echo # +--echo # Try an UPDATE +--echo # + +let $out=`analyze format=json update t1 set b = b-1 where pk < 120000`; + +--replace_regex /("(r_[a-z_]*_time_ms|pages_accessed|pages_updated)": )[^, \n]*/\1"REPLACED"/ +evalp select '$out' as X; + +evalp set @js='$out'; +set @out=(select json_extract(@js,'$**.r_engine_stats.pages_updated')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_UPDATED_MORE_THAN_ZERO; + +--echo # +--echo # Try a DELETE +--echo # +let $out=`analyze format=json delete from t1 where mod(pk,2)=1`; + +--replace_regex /("(r_[a-z_]*_time_ms|pages_accessed|pages_updated)": )[^, \n]*/\1"REPLACED"/ +evalp select '$out' as X; + +evalp set @js='$out'; +set @out=(select json_extract(@js,'$**.r_engine_stats.pages_updated')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_UPDATED_MORE_THAN_ZERO; + +drop table t1; + diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result index b9f275af742..ca10acc092e 100644 --- a/mysql-test/main/analyze_format_json.result +++ b/mysql-test/main/analyze_format_json.result @@ -17,6 +17,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 30, "attached_condition": "t0.a < 3" @@ -46,6 +47,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 0, "attached_condition": "t0.a > 9 and t0.a is not null" @@ -61,6 +63,7 @@ ANALYZE "r_loops": 0, "rows": 1, "r_rows": null, + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": null } @@ -87,6 +90,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t0.a is not null" @@ -104,6 +108,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 40, "attached_condition": "t1.b < 4" @@ -131,6 +136,7 @@ ANALYZE "r_rows": 100, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 20, "attached_condition": "tbl1.b < 20" @@ -144,6 +150,7 @@ ANALYZE "r_rows": 100, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 60, "attached_condition": "tbl2.b < 60" @@ -175,6 +182,7 @@ ANALYZE "r_rows": 100, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 20, "attached_condition": "tbl1.b < 20" @@ -188,6 +196,7 @@ ANALYZE "r_rows": 100, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 60, "attached_condition": "tbl2.b < 60" @@ -228,6 +237,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t1.a is not null" @@ -245,6 +255,7 @@ ANALYZE "r_rows": 0.2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "using_index": true @@ -280,6 +291,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 50, "attached_condition": "test.t1.a < 5" @@ -314,7 +326,8 @@ ANALYZE "rows": 1000, "r_rows": 1000, "r_filtered": 100, - "r_total_time_ms": "REPLACED" + "r_total_time_ms": "REPLACED", + "r_engine_stats": REPLACED } } } @@ -338,6 +351,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 50, "index_condition": "t1.pk < 10", @@ -364,6 +378,7 @@ ANALYZE "r_rows": 10, "r_filtered": 50, "r_total_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "attached_condition": "t1.pk < 10 and t1.b > 4" } } @@ -404,6 +419,7 @@ ANALYZE "r_rows": 5, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -428,6 +444,7 @@ ANALYZE "r_rows": 203.8, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 98.13542689 } @@ -465,6 +482,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 50, "attached_condition": "tbl1.a < 5" @@ -485,6 +503,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 20, "attached_condition": "tbl2.a in (2,3)" @@ -535,6 +554,7 @@ ANALYZE "r_rows": 256, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -567,6 +587,7 @@ ANALYZE "r_rows": 256, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -610,6 +631,7 @@ ANALYZE "r_rows": 256, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -640,6 +662,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -652,6 +675,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 0, "attached_condition": "(t2.b,t2.b in (subquery#2))" @@ -680,6 +704,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -735,6 +760,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -747,6 +773,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 0, "attached_condition": "t3.f3 in (1,2)" @@ -773,6 +800,7 @@ ANALYZE "r_loops": 0, "rows": 2, "r_rows": null, + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": null }, @@ -783,6 +811,7 @@ ANALYZE "r_loops": 0, "rows": 2, "r_rows": null, + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": null }, @@ -830,6 +859,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 0, "attached_condition": "t1.a < 0" @@ -856,6 +886,7 @@ ANALYZE "r_loops": 0, "rows": 10, "r_rows": null, + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": null, "attached_condition": "t2.a < t1.a" @@ -908,6 +939,7 @@ ANALYZE "r_rows": 1000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 10.15625, "r_filtered": 10, "attached_condition": "t11.a < 100" @@ -921,6 +953,7 @@ ANALYZE "r_rows": 1000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 70.3125, "r_filtered": 70, "attached_condition": "t10.a < 700" @@ -958,6 +991,7 @@ ANALYZE "r_rows": 1000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 10.15625, "r_filtered": 10, "attached_condition": "t11.a < 100 and t11.b is not null" @@ -975,6 +1009,7 @@ ANALYZE "r_rows": 1000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 70.3125, "r_filtered": 70, "attached_condition": "t10.a < 700" diff --git a/mysql-test/main/analyze_format_json_timings.result b/mysql-test/main/analyze_format_json_timings.result index 6cced9ec6b1..8b719eb9dee 100644 --- a/mysql-test/main/analyze_format_json_timings.result +++ b/mysql-test/main/analyze_format_json_timings.result @@ -49,6 +49,7 @@ X "r_rows": 500, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t1.a < 700 and t1.b is not null" @@ -66,6 +67,7 @@ X "r_rows": 500, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 20, "attached_condition": "t2.a < 100" @@ -131,6 +133,7 @@ X "r_rows": 1000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t1.a is not null" @@ -148,6 +151,7 @@ X "r_rows": 2000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, diff --git a/mysql-test/main/analyze_stmt_orderby.result b/mysql-test/main/analyze_stmt_orderby.result index 7f03e2b2673..9e098cb498e 100644 --- a/mysql-test/main/analyze_stmt_orderby.result +++ b/mysql-test/main/analyze_stmt_orderby.result @@ -52,7 +52,8 @@ ANALYZE "rows": 10000, "r_rows": 10000, "r_filtered": 100, - "r_total_time_ms": "REPLACED" + "r_total_time_ms": "REPLACED", + "r_engine_stats": REPLACED } } } @@ -105,6 +106,7 @@ ANALYZE "r_rows": 10, "r_filtered": 100, "r_total_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "attached_condition": "t2.a < 10" } } @@ -154,7 +156,8 @@ ANALYZE "rows": 10000, "r_rows": 10000, "r_filtered": 100, - "r_total_time_ms": "REPLACED" + "r_total_time_ms": "REPLACED", + "r_engine_stats": REPLACED } } } @@ -223,6 +226,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t0.a is not null" @@ -240,6 +244,7 @@ ANALYZE "r_rows": 0.4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -312,6 +317,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t0.a is not null" @@ -331,6 +337,7 @@ ANALYZE "r_rows": 0.4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -373,6 +380,7 @@ ANALYZE "r_rows": 1000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 50, "attached_condition": "t2.a MOD 2 = 0" @@ -422,6 +430,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -434,6 +443,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -500,6 +510,7 @@ ANALYZE "r_rows": 5, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 80, "attached_condition": "t6.b > 0 and t6.a <= 5" @@ -513,6 +524,7 @@ ANALYZE "r_rows": 7, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -612,6 +624,7 @@ ANALYZE "r_rows": 20, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "using_index_for_group_by": true diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index dd82ef46229..91bc452c92c 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -3807,6 +3807,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t1.a1 is not null" @@ -3851,6 +3852,7 @@ ANALYZE "r_loops": 0, "rows": 1, "r_rows": null, + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": null, "using_index": true @@ -3888,6 +3890,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -4086,6 +4089,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -4105,6 +4109,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t1.c is not null" @@ -4201,6 +4206,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 82a8dd89a05..97824dbde62 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -17315,6 +17315,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 50, "attached_condition": "t1.a = 3" diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index e491b631121..29a3261e9b8 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -378,6 +378,7 @@ ANALYZE "r_rows": 5, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -394,6 +395,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "trigcond(trigcond(t1.b is not null))" @@ -411,6 +413,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "trigcond(trigcond(t1.b is not null))" @@ -451,6 +454,7 @@ ANALYZE "r_rows": 100, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -463,6 +467,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result index 5614ab18bf0..677e3ce202e 100644 --- a/mysql-test/main/except.result +++ b/mysql-test/main/except.result @@ -84,6 +84,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -103,6 +104,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -150,6 +152,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -169,6 +172,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -316,6 +320,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -328,6 +333,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -356,6 +362,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -368,6 +375,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -425,6 +433,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -437,6 +446,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -465,6 +475,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -477,6 +488,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, diff --git a/mysql-test/main/except_all.result b/mysql-test/main/except_all.result index 113c161a98b..4f4fed2ffa7 100644 --- a/mysql-test/main/except_all.result +++ b/mysql-test/main/except_all.result @@ -142,6 +142,7 @@ ANALYZE "r_rows": 7, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -161,6 +162,7 @@ ANALYZE "r_rows": 7, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -211,6 +213,7 @@ ANALYZE "r_rows": 7, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -230,6 +233,7 @@ ANALYZE "r_rows": 7, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -435,6 +439,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -447,6 +452,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -475,6 +481,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -487,6 +494,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -543,6 +551,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -555,6 +564,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -583,6 +593,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -595,6 +606,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index c3cff36626d..8fa729c8524 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -977,6 +977,7 @@ ANALYZE "r_rows": 100, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "using_index_for_group_by": true @@ -1281,6 +1282,7 @@ ANALYZE "r_loops": 0, "rows": 1, "r_rows": null, + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": null, "impossible_on_condition": true @@ -1293,6 +1295,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -1348,6 +1351,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -1364,6 +1368,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "trigcond(t2.pk is null) and trigcond(trigcond(t1.a is not null))", @@ -1425,6 +1430,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t1.a is not null" @@ -1442,6 +1448,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "using_index": true, @@ -1518,6 +1525,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t3.a is not null" @@ -1536,6 +1544,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "index_condition_bka": "t4.b + 1 <= t3.b + 1" diff --git a/mysql-test/main/explain_json_format_partitions.result b/mysql-test/main/explain_json_format_partitions.result index 0c7d9e93105..34411d8e121 100644 --- a/mysql-test/main/explain_json_format_partitions.result +++ b/mysql-test/main/explain_json_format_partitions.result @@ -38,6 +38,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 30, "attached_condition": "t1.a in (2,3,4)" @@ -60,6 +61,7 @@ ANALYZE "r_rows": 10, "r_filtered": 30, "r_total_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "attached_condition": "t1.a in (2,3,4)" } } @@ -80,6 +82,7 @@ ANALYZE "r_rows": 10, "r_filtered": 0, "r_total_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "attached_condition": "t1.a in (20,30,40)" } } diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result index 25d81a7fc34..df4ae638c04 100644 --- a/mysql-test/main/intersect.result +++ b/mysql-test/main/intersect.result @@ -110,6 +110,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -129,6 +130,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -148,6 +150,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -195,6 +198,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -214,6 +218,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -233,6 +238,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -358,6 +364,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -377,6 +384,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -389,6 +397,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -445,6 +454,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -464,6 +474,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -476,6 +487,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, diff --git a/mysql-test/main/intersect_all.result b/mysql-test/main/intersect_all.result index da5d778daab..e72209c5f89 100644 --- a/mysql-test/main/intersect_all.result +++ b/mysql-test/main/intersect_all.result @@ -122,6 +122,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -141,6 +142,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -160,6 +162,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -207,6 +210,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -226,6 +230,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -245,6 +250,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -389,6 +395,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -408,6 +415,7 @@ ANALYZE "r_rows": 5, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -420,6 +428,7 @@ ANALYZE "r_rows": 7, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -476,6 +485,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -495,6 +505,7 @@ ANALYZE "r_rows": 5, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -507,6 +518,7 @@ ANALYZE "r_rows": 7, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index 5f56201af9c..a8d779d6dc8 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3420,6 +3420,7 @@ ANALYZE "r_rows": 100, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -3769,6 +3770,7 @@ ANALYZE "r_rows": 100, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -3928,6 +3930,7 @@ ANALYZE "r_rows": 5, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -3970,6 +3973,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -4018,6 +4022,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -4080,6 +4085,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -4245,6 +4251,7 @@ ANALYZE "r_rows": 50, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -4274,6 +4281,7 @@ ANALYZE "r_rows": 50, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 2, "attached_condition": "t1.b = t2.b" diff --git a/mysql-test/main/order_by_pack_big.result b/mysql-test/main/order_by_pack_big.result index a7cf2436bcc..b93a6a66c3b 100644 --- a/mysql-test/main/order_by_pack_big.result +++ b/mysql-test/main/order_by_pack_big.result @@ -111,6 +111,7 @@ ANALYZE "r_rows": 10000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -269,6 +270,7 @@ ANALYZE "r_rows": 10000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -423,6 +425,7 @@ ANALYZE "r_rows": 10000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } @@ -472,6 +475,7 @@ ANALYZE "r_rows": 10000, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index e32b738c4e5..15b738ea940 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -138,6 +138,7 @@ ANALYZE "r_rows": 60, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 11.69025803, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", @@ -261,6 +262,7 @@ ANALYZE "r_rows": 510, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 11.69025803, "r_filtered": 11.76470588, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", @@ -414,6 +416,7 @@ ANALYZE "r_rows": 71, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" @@ -449,6 +452,7 @@ ANALYZE "r_rows": 0.154929577, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 1.631973386, "r_filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" @@ -550,6 +554,7 @@ ANALYZE "r_rows": 98, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'" @@ -567,6 +572,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 4.599999905, "r_filtered": 11.2244898, "attached_condition": "orders.o_totalprice between 200000 and 230000" @@ -704,6 +710,7 @@ ANALYZE "r_rows": 60, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 11.69025803, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", @@ -735,6 +742,7 @@ ANALYZE "r_rows": 0.266666667, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 9.266666412, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 180000 and 230000" @@ -849,6 +857,7 @@ ANALYZE "r_rows": 510, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 11.69025803, "r_filtered": 11.76470588, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", @@ -867,6 +876,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 9.266666412, "r_filtered": 26.66666667, "attached_condition": "orders.o_totalprice between 180000 and 230000" @@ -977,6 +987,7 @@ ANALYZE "r_rows": 71, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" @@ -1012,6 +1023,7 @@ ANALYZE "r_rows": 0.521126761, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 8.476269722, "r_filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" @@ -1134,6 +1146,7 @@ ANALYZE "r_rows": 71, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "index_condition": "orders.o_totalprice between 200000 and 230000" @@ -1156,6 +1169,7 @@ ANALYZE "r_rows": 6.704225352, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 8.476269722, "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" @@ -1301,6 +1315,7 @@ ANALYZE "r_rows": 18, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 0.566194832, "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", @@ -1319,6 +1334,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 7.466666698, "r_filtered": 14.28571429, "attached_condition": "orders.o_totalprice between 200000 and 250000" @@ -1423,6 +1439,7 @@ ANALYZE "r_rows": 18, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 0.566194832, "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", @@ -1441,6 +1458,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 7.466666698, "r_filtered": 14.28571429, "attached_condition": "orders.o_totalprice between 200000 and 250000" @@ -1545,6 +1563,7 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 3.200000048, "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", @@ -1568,6 +1587,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 3.047460556, "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -1668,6 +1688,7 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 3.200000048, "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", @@ -1691,6 +1712,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 3.047460556, "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -1804,6 +1826,7 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": {}, "filtered": "REPLACED", "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", @@ -1827,6 +1850,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": {}, "filtered": "REPLACED", "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -1937,6 +1961,7 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": {}, "filtered": "REPLACED", "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", @@ -1960,6 +1985,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": {}, "filtered": "REPLACED", "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -2329,6 +2355,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 49.20000076, "r_filtered": 100, "index_condition": "t1.nm like '500%'", @@ -2375,6 +2402,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 49.20000076, "r_filtered": 100, "index_condition": "t1.nm like '500%'", @@ -2460,6 +2488,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 1.149999976, "r_filtered": 100, "attached_condition": "t1.nm like '75%'" @@ -2567,6 +2596,7 @@ ANALYZE "r_rows": 0, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 0.439999998, "r_filtered": 100, "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" @@ -2624,6 +2654,7 @@ ANALYZE "r_loops": 1, "rows": 853, "r_rows": 0, + "r_engine_stats": REPLACED, "filtered": 0.439999998, "r_filtered": 100, "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index c5a27f8b60e..d94de99cf2c 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -141,6 +141,7 @@ ANALYZE "r_rows": 60, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 10.07493782, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", @@ -264,6 +265,7 @@ ANALYZE "r_rows": 510, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 10.07493782, "r_filtered": 11.76470588, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", @@ -415,6 +417,7 @@ ANALYZE "r_rows": 98, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", @@ -433,6 +436,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 4.733333111, "r_filtered": 11.2244898, "attached_condition": "orders.o_totalprice between 200000 and 230000" @@ -535,6 +539,7 @@ ANALYZE "r_rows": 98, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'", @@ -553,6 +558,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 4.733333111, "r_filtered": 11.2244898, "attached_condition": "orders.o_totalprice between 200000 and 230000" @@ -682,6 +688,7 @@ ANALYZE "r_rows": 60, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 10.07493782, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", @@ -700,6 +707,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 9.600000381, "r_filtered": 26.66666667, "attached_condition": "orders.o_totalprice between 180000 and 230000" @@ -808,6 +816,7 @@ ANALYZE "r_rows": 144, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 180000 and 230000", @@ -832,6 +841,7 @@ ANALYZE "r_rows": 6.625, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 0.855656624, "r_filtered": 1.677148847, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" @@ -935,6 +945,7 @@ ANALYZE "r_rows": 71, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 200000 and 230000", @@ -958,6 +969,7 @@ ANALYZE "r_rows": 6.704225352, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 8.492922783, "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" @@ -1081,6 +1093,7 @@ ANALYZE "r_rows": 71, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "orders.o_totalprice between 200000 and 230000", @@ -1104,6 +1117,7 @@ ANALYZE "r_rows": 6.704225352, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 8.492922783, "r_filtered": 7.773109244, "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" @@ -1249,6 +1263,7 @@ ANALYZE "r_rows": 18, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 0.566194832, "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", @@ -1267,6 +1282,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 5.666666508, "r_filtered": 14.28571429, "attached_condition": "orders.o_totalprice between 200000 and 250000" @@ -1371,6 +1387,7 @@ ANALYZE "r_rows": 18, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 0.566194832, "r_filtered": 38.88888889, "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'", @@ -1389,6 +1406,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 5.666666508, "r_filtered": 14.28571429, "attached_condition": "orders.o_totalprice between 200000 and 250000" @@ -1493,6 +1511,7 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 3.333333254, "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", @@ -1516,6 +1535,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 3.047460556, "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -1616,6 +1636,7 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 3.333333254, "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", @@ -1639,6 +1660,7 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 3.047460556, "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -1752,6 +1774,9 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": { + "pages_accessed": 84 + }, "filtered": "REPLACED", "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", @@ -1775,6 +1800,9 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": { + "pages_accessed": 3 + }, "filtered": "REPLACED", "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -1885,6 +1913,9 @@ ANALYZE "r_rows": 41, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": { + "pages_accessed": 84 + }, "filtered": "REPLACED", "r_filtered": 2.43902439, "index_condition": "orders.o_totaldiscount between 18000 and 20000", @@ -1908,6 +1939,9 @@ ANALYZE "r_rows": 6, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": { + "pages_accessed": 3 + }, "filtered": "REPLACED", "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" @@ -2277,6 +2311,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 49.20000076, "r_filtered": 100, "index_condition": "t1.nm like '500%'", @@ -2323,6 +2358,7 @@ ANALYZE "r_rows": 1, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 49.20000076, "r_filtered": 100, "index_condition": "t1.nm like '500%'", @@ -2408,6 +2444,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 1.149999976, "r_filtered": 100, "attached_condition": "t1.nm like '75%'" @@ -2515,6 +2552,7 @@ ANALYZE "r_rows": 0, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 0.439999998, "r_filtered": 100, "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" @@ -2572,6 +2610,7 @@ ANALYZE "r_loops": 1, "rows": 853, "r_rows": 0, + "r_engine_stats": REPLACED, "filtered": 0.439999998, "r_filtered": 100, "attached_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'" @@ -3658,6 +3697,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100, "attached_condition": "t.tp = 121 and t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2'", @@ -3677,6 +3717,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -3705,6 +3746,7 @@ ANALYZE "r_rows": 80, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 14.46428585, "r_filtered": 100 }, diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index c32872511b1..353becd2b69 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -2931,6 +2931,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -2951,6 +2952,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 50, "attached_condition": "((t1.b,(subquery#3) >= 4))" @@ -2969,6 +2971,7 @@ ANALYZE "r_rows": 2, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } diff --git a/mysql-test/main/subselect_cache.result b/mysql-test/main/subselect_cache.result index 9722acbd0e6..128071ec723 100644 --- a/mysql-test/main/subselect_cache.result +++ b/mysql-test/main/subselect_cache.result @@ -56,6 +56,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -76,6 +77,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 18.75, "attached_condition": "t1.b = t2.c" @@ -102,6 +104,7 @@ ANALYZE "r_rows": 10, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, @@ -130,6 +133,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 18.75, "attached_condition": "t1.b = t2.c" @@ -166,6 +170,7 @@ ANALYZE "r_rows": 4, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 18.75, "attached_condition": "t1.b = t2.c" diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 48eea7a3add..bcfea2f1419 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -3775,6 +3775,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index 8582d5dc713..9dfca3aadcb 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -3781,6 +3781,7 @@ ANALYZE "r_rows": 3, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 } diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index c0b91a68da7..11b1ee4109c 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -229,6 +229,7 @@ ANALYZE "r_rows": 7, "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", + "r_engine_stats": REPLACED, "filtered": 100, "r_filtered": 100 }, diff --git a/sql/sql_class.h b/sql/sql_class.h index 5648b4a60cb..c220f02a2fd 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5607,6 +5607,12 @@ public: { lex= backup_lex; } + + bool should_collect_handler_stats() const + { + return (variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_ENGINE) || + lex->analyze_stmt; + } }; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f615e287fa9..7236d01e1b3 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -126,6 +126,8 @@ bool Update_plan::save_explain_data_intern(THD *thd, LOG_SLOW_VERBOSITY_ENGINE)) table->file->set_time_tracker(&explain->table_tracker); + explain->handler_for_stats= table->file; + select_lex->set_explain_type(TRUE); explain->select_type= select_lex->type; /* Partitions */ diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index e9bdc4be66f..45ea4a82c7d 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -1709,6 +1709,26 @@ void Explain_rowid_filter::print_explain_json(Explain_query *query, writer->end_object(); // rowid_filter } +static void trace_engine_stats(handler *file, Json_writer *writer) +{ + if (file && file->handler_stats) + { + ha_handler_stats *hs= file->handler_stats; + writer->add_member("r_engine_stats").start_object(); + if (hs->pages_accessed) + writer->add_member("pages_accessed").add_ull(hs->pages_accessed); + if (hs->pages_updated) + writer->add_member("pages_updated").add_ull(hs->pages_updated); + if (hs->pages_read_count) + writer->add_member("pages_read_count").add_ull(hs->pages_read_count); + if (hs->pages_read_time) + writer->add_member("pages_read_time_ms"). + add_double(hs->pages_read_time / 1000.0); + if (hs->undo_records_read) + writer->add_member("old_rows_read").add_ull(hs->undo_records_read); + writer->end_object(); + } +} void Explain_table_access::print_explain_json(Explain_query *query, Json_writer *writer, @@ -1850,6 +1870,7 @@ void Explain_table_access::print_explain_json(Explain_query *query, writer->add_member("r_table_time_ms").add_double(total_time); writer->add_member("r_other_time_ms").add_double(extra_time_tracker.get_time_ms()); } + trace_engine_stats(handler_for_stats, writer); } /* `filtered` */ @@ -2551,6 +2572,8 @@ void Explain_update::print_explain_json(Explain_query *query, } } + trace_engine_stats(handler_for_stats, writer); + if (where_cond) { writer->add_member("attached_condition"); diff --git a/sql/sql_explain.h b/sql/sql_explain.h index af110a25296..7b93ba74a42 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -735,6 +735,7 @@ public: pushed_index_cond(NULL), sjm_nest(NULL), pre_join_sort(NULL), + handler_for_stats(NULL), jbuf_unpack_tracker(timed), rowid_filter(NULL) {} @@ -843,6 +844,16 @@ public: Exec_time_tracker op_tracker; Gap_time_tracker extra_time_tracker; + /* + Note: This pointer is only valid until notify_tables_are_closed() is + called. After that, the tables may be freed or reused, together with their + handler_stats objects. + + notify_tables_are_closed() disables printing of FORMAT=JSON output. + r_engine_stats is only printed in FORMAT=JSON output, so we're fine. + */ + handler *handler_for_stats; + /* When using join buffer: Track the reads from join buffer */ Table_access_tracker jbuf_tracker; @@ -893,7 +904,8 @@ public: Explain_update(MEM_ROOT *root, bool is_analyze) : Explain_node(root), filesort_tracker(NULL), - command_tracker(is_analyze) + command_tracker(is_analyze), + handler_for_stats(NULL) {} virtual enum explain_node_type get_type() { return EXPLAIN_UPDATE; } @@ -953,6 +965,9 @@ public: /* TODO: This tracks time to read rows from the table */ Exec_time_tracker table_tracker; + /* The same as Explain_table_access::handler_for_stats */ + handler *handler_for_stats; + virtual int print_explain(Explain_query *query, select_result_sink *output, uint8 explain_flags, bool is_analyze); virtual void print_explain_json(Explain_query *query, Json_writer *writer, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index d152eb8eeb8..9d765a31fe2 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3969,7 +3969,8 @@ void Query_tables_list::destroy_query_tables_list() LEX::LEX() : explain(NULL), result(0), part_info(NULL), arena_for_set_stmt(0), - mem_root_for_set_stmt(0), json_table(NULL), default_used(0), + mem_root_for_set_stmt(0), json_table(NULL), analyze_stmt(0), + default_used(0), with_rownum(0), is_lex_started(0), option_type(OPT_DEFAULT), context_analysis_only(0), sphead(0), limit_rows_examined_cnt(ULONGLONG_MAX) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 27c51879f4f..5377d245c76 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -27755,6 +27755,12 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, LOG_SLOW_VERBOSITY_ENGINE)) { table->file->set_time_tracker(&eta->op_tracker); + /* + Set handler_for_stats even if we are not running an ANALYZE command. + There's no harm, and in case somebody runs a SHOW ANALYZE command we'll + be able to print the engine statistics. + */ + eta->handler_for_stats= table->file; if (likely(thd->lex->analyze_stmt)) { eta->op_tracker.set_gap_tracker(&eta->extra_time_tracker); diff --git a/sql/table.cc b/sql/table.cc index cd66a3466ce..a9d45b13b35 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5678,7 +5678,7 @@ void TABLE::init(THD *thd, TABLE_LIST *tl) } /* enable and clear or disable engine query statistics */ - if ((thd->variables.log_slow_verbosity & LOG_SLOW_VERBOSITY_ENGINE)) + if (thd->should_collect_handler_stats()) file->ha_handler_stats_reset(); else file->ha_handler_stats_disable(); From 9bb5b253252f44b261fe87142b6468b22bbf915f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 24 Jul 2023 12:29:43 +0300 Subject: [PATCH 6/7] MDEV-31120 Duplicate entry allowed into a UNIQUE column row_ins_sec_index_entry_low(): Correct a condition that was inadvertently inverted in commit 89ec4b53ac4c7568b9c9765fff50d9bec7cf3534 (MDEV-29603). We are not supposed to buffer INSERT operations into unique indexes, because duplicate key values would not be checked for. It is only allowed when using unique_checks=0, and in that case the user is supposed to guarantee that there are no duplicates. --- storage/innobase/row/row0ins.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 3188c8c27ce..d9ba8bca64e 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -3005,8 +3005,8 @@ row_ins_sec_index_entry_low( search_mode = btr_latch_mode( search_mode | (thr_get_trx(thr)->check_unique_secondary - ? BTR_INSERT | BTR_IGNORE_SEC_UNIQUE - : BTR_INSERT)); + ? BTR_INSERT + : BTR_INSERT | BTR_IGNORE_SEC_UNIQUE)); } err = cursor.search_leaf(entry, PAGE_CUR_LE, search_mode, From b102872ad50cce5959ad95369740766d14e9e48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 25 Jul 2023 11:40:58 +0300 Subject: [PATCH 7/7] MDEV-31767 InnoDB tables are being flagged as corrupted on an I/O bound server The main problem is that at ever since commit aaef2e1d8c843d1e40b1ce0c5199c3abb3c5da28 removed the function buf_wait_for_read(), it is not safe to invoke buf_page_get_low() with RW_NO_LATCH, that is, only buffer-fixing the page. If a page read (or decryption or decompression) is in progress, there would be a race condition when executing consistency checks, and a page would wrongly be flagged as corrupted. Furthermore, if the page is actually corrupted and the initial access to it was with RW_NO_LATCH (only buffer-fixing), the page read handler would likely end up in an infinite loop in buf_pool_t::corrupted_evict(). It is not safe to invoke mtr_t::upgrade_buffer_fix() on a block on which a page latch was not initially acquired in buf_page_get_low(). btr_block_reget(): Remove the constant parameter rw_latch=RW_X_LATCH. btr_block_get(): Assert that RW_NO_LATCH is not being used, and change the parameter type of rw_latch. btr_pcur_move_to_next_page(), innobase_table_is_empty(): Adjust for the parameter type change of btr_block_get(). btr_root_block_get(): If mode==RW_NO_LATCH, do not check the integrity of the page, because it is not safe to do so. btr_page_alloc_low(), btr_page_free(): If the root page latch is not previously held by the mini-transaction, invoke btr_root_block_get() again with the proper latching mode. btr_latch_prev(): Helper function to safely acquire a latch on a preceding sibling page while holding a latch on a B-tree page. To avoid deadlocks, we must not wait for the latch while holding a latch on the current page, because another thread may be waiting for our page latch when moving to the next page from our preceding sibling page. If s_lock_try() or x_lock_try() on the preceding page fails, we must release the current page latch, and wait for the latch on the preceding page as well as the current page, in that order. Page splits or merges will be prevented by the parent page latch that we are holding. btr_cur_t::search_leaf(): Make use of btr_latch_prev(). btr_cur_t::open_leaf(): Make use of btr_latch_prev(). Do not invoke mtr_t::upgrade_buffer_fix() (when latch_mode == BTR_MODIFY_TREE), because we will already have acquired all page latches upfront. btr_cur_t::pessimistic_search_leaf(): Do acquire an exclusive index latch before accessing the page. Make use of btr_latch_prev(). --- storage/innobase/btr/btr0btr.cc | 75 ++++---- storage/innobase/btr/btr0cur.cc | 201 ++++++++++++---------- storage/innobase/btr/btr0pcur.cc | 3 +- storage/innobase/handler/handler0alter.cc | 3 +- storage/innobase/include/btr0btr.h | 2 +- 5 files changed, 144 insertions(+), 140 deletions(-) diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 3b03df3f47c..ee2f8d00857 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -218,9 +218,10 @@ ATTRIBUTE_COLD void btr_decryption_failed(const dict_index_t &index) @param[out] err error code @return block */ buf_block_t *btr_block_get(const dict_index_t &index, - uint32_t page, ulint mode, bool merge, + uint32_t page, rw_lock_type_t mode, bool merge, mtr_t *mtr, dberr_t *err) { + ut_ad(mode != RW_NO_LATCH); dberr_t local_err; if (!err) err= &local_err; @@ -281,11 +282,13 @@ btr_root_block_get( if (UNIV_LIKELY(block != nullptr)) { - 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 (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)) { *err= DB_PAGE_CORRUPTED; block= nullptr; @@ -515,18 +518,16 @@ static buf_block_t *btr_get_latched_root(const dict_index_t &index, mtr_t *mtr) mini-transaction. */ static buf_block_t * btr_block_reget(mtr_t *mtr, const dict_index_t &index, - const page_id_t id, rw_lock_type_t rw_latch, - dberr_t *err) + const page_id_t id, dberr_t *err) { - if (buf_block_t *block= - mtr->get_already_latched(id, mtr_memo_type_t(rw_latch))) + if (buf_block_t *block= mtr->get_already_latched(id, MTR_MEMO_PAGE_X_FIX)) { *err= DB_SUCCESS; return block; } ut_ad(mtr->memo_contains_flagged(&index.lock, MTR_MEMO_X_LOCK)); - return btr_block_get(index, id.page_no(), rw_latch, true, mtr, err); + return btr_block_get(index, id.page_no(), RW_X_LATCH, true, mtr, err); } /**************************************************************//** @@ -585,21 +586,15 @@ btr_page_alloc_low( if (UNIV_UNLIKELY(!root)) return root; - if (mtr->have_u_or_x_latch(*root)) - { + const bool have_latch= mtr->have_u_or_x_latch(*root); #ifdef BTR_CUR_HASH_ADAPT - ut_ad(!root->index || !root->index->freed()); + ut_ad(!have_latch || !root->index || !root->index->freed()); #endif - mtr->rollback_to_savepoint(savepoint); - } - else - { - mtr->lock_register(savepoint, MTR_MEMO_PAGE_SX_FIX); - root->page.lock.u_lock(); -#ifdef BTR_CUR_HASH_ADAPT - btr_search_drop_page_hash_index(root, true); -#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); @@ -696,26 +691,18 @@ dberr_t btr_page_free(dict_index_t* index, buf_block_t* block, mtr_t* mtr, const auto savepoint= mtr->get_savepoint(); if (buf_block_t *root= btr_root_block_get(index, RW_NO_LATCH, mtr, &err)) { - if (mtr->have_u_or_x_latch(*root)) - { + const bool have_latch= mtr->have_u_or_x_latch(*root); #ifdef BTR_CUR_HASH_ADAPT - ut_ad(!root->index || !root->index->freed()); + ut_ad(!have_latch || !root->index || !root->index->freed()); #endif - mtr->rollback_to_savepoint(savepoint); - } - else - { - mtr->lock_register(savepoint, MTR_MEMO_PAGE_SX_FIX); - root->page.lock.u_lock(); -#ifdef BTR_CUR_HASH_ADAPT - btr_search_drop_page_hash_index(root, true); -#endif - } - 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); + 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); } if (err == DB_SUCCESS) buf_page_free(space, page, mtr); @@ -4293,7 +4280,7 @@ btr_discard_page( if (left_page_no != FIL_NULL) { merge_page_id.set_page_no(left_page_no); merge_block = btr_block_reget(mtr, *index, merge_page_id, - RW_X_LATCH, &err); + &err); if (UNIV_UNLIKELY(!merge_block)) { return err; } @@ -4319,7 +4306,7 @@ btr_discard_page( } else if (right_page_no != FIL_NULL) { merge_page_id.set_page_no(right_page_no); merge_block = btr_block_reget(mtr, *index, merge_page_id, - RW_X_LATCH, &err); + &err); if (UNIV_UNLIKELY(!merge_block)) { return err; } diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 8b7a5ffc623..6bf093f6d18 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -938,6 +938,76 @@ static inline page_cur_mode_t btr_cur_nonleaf_mode(page_cur_mode_t mode) return PAGE_CUR_LE; } +static MY_ATTRIBUTE((nonnull)) +/** 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 +@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 +@param rw_latch the latch on block (RW_S_LATCH or RW_X_LATCH) +@param mtr mini-transaction +@param err error code +@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) +{ + ut_ad(rw_latch == RW_S_LATCH || rw_latch == RW_X_LATCH); + ut_ad(page_id.space() == block->page.id().space()); + + 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)); + 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)) + { + if (UNIV_LIKELY(prev->page.lock.s_lock_try())) + { + mtr->lock_register(prev_savepoint, MTR_MEMO_PAGE_S_FIX); + goto prev_latched; + } + block->page.lock.s_unlock(); + } + else + { + if (UNIV_LIKELY(prev->page.lock.x_lock_try())) + { + mtr->lock_register(prev_savepoint, MTR_MEMO_PAGE_X_FIX); + goto prev_latched; + } + block->page.lock.x_unlock(); + } + + 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)) + { + ut_ad("corrupted" == 0); // FIXME: remove this + *err= DB_CORRUPTION; + ret= 0; + } + + return ret; +} + dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, btr_latch_mode latch_mode, mtr_t *mtr) { @@ -1192,11 +1262,12 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, page_cur.block= block; ut_ad(block == mtr->at_savepoint(block_savepoint)); + ut_ad(rw_latch != RW_NO_LATCH); #ifdef UNIV_ZIP_DEBUG - if (rw_latch == RW_NO_LATCH); - else if (const page_zip_des_t *page_zip= buf_block_get_page_zip(block)) + if (const page_zip_des_t *page_zip= buf_block_get_page_zip(block)) ut_a(page_zip_validate(page_zip, block->page.frame, index())); #endif /* UNIV_ZIP_DEBUG */ + const uint32_t page_level= btr_page_get_level(block->page.frame); if (height == ULINT_UNDEFINED) @@ -1240,7 +1311,7 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, goto reached_index_root_and_leaf; goto reached_root_and_leaf; case RW_NO_LATCH: - ut_ad(mtr->memo_contains_flagged(&index()->lock, MTR_MEMO_X_LOCK)); + ut_ad(0); } goto reached_leaf; } @@ -1257,14 +1328,8 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, if (tree_height <= height + 2) /* Retain the root page latch. */ break; - goto release_parent_page; + /* fall through */ default: - if (rw_latch == RW_NO_LATCH) - { - ut_ad(!height); - break; - } - release_parent_page: ut_ad(block_savepoint > savepoint); mtr->rollback_to_savepoint(block_savepoint - 1, block_savepoint); block_savepoint--; @@ -1301,29 +1366,20 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode, static_assert(BTR_MODIFY_PREV & BTR_MODIFY_LEAF, ""); static_assert(BTR_SEARCH_PREV & BTR_SEARCH_LEAF, ""); ut_ad(!latch_by_caller); + ut_ad(rw_latch == + rw_lock_type_t(latch_mode & (RW_X_LATCH | RW_S_LATCH))); - if (rw_latch == RW_NO_LATCH) - { - /* latch also siblings from left to right */ - rw_latch= rw_lock_type_t(latch_mode & (RW_X_LATCH | RW_S_LATCH)); - if (page_has_prev(block->page.frame) && - !btr_block_get(*index(), btr_page_get_prev(block->page.frame), - rw_latch, false, mtr, &err)) - goto func_exit; - mtr->upgrade_buffer_fix(block_savepoint, rw_latch); - if (page_has_next(block->page.frame) && - !btr_block_get(*index(), btr_page_get_next(block->page.frame), - rw_latch, false, mtr, &err)) - goto func_exit; - } + /* latch also siblings from left to right */ + if (page_has_prev(block->page.frame) && + !btr_latch_prev(block, page_id, zip_size, rw_latch, mtr, &err)) + goto func_exit; + if (page_has_next(block->page.frame) && + !btr_block_get(*index(), btr_page_get_next(block->page.frame), + rw_latch, false, mtr, &err)) + goto func_exit; goto release_tree; case BTR_SEARCH_LEAF: case BTR_MODIFY_LEAF: - if (rw_latch == RW_NO_LATCH) - { - ut_ad(index()->is_ibuf()); - mtr->upgrade_buffer_fix(block_savepoint, rw_lock_type_t(latch_mode)); - } if (!latch_by_caller) { release_tree: @@ -1337,13 +1393,11 @@ release_tree: break; default: ut_ad(latch_mode == BTR_MODIFY_TREE); - ut_ad(rw_latch == RW_NO_LATCH); + ut_ad(rw_latch == RW_X_LATCH); /* x-latch also siblings from left to right */ if (page_has_prev(block->page.frame) && - !btr_block_get(*index(), btr_page_get_prev(block->page.frame), - RW_X_LATCH, false, mtr, &err)) + !btr_latch_prev(block, page_id, zip_size, rw_latch, mtr, &err)) goto func_exit; - mtr->upgrade_buffer_fix(block_savepoint, RW_X_LATCH); if (page_has_next(block->page.frame) && !btr_block_get(*index(), btr_page_get_next(block->page.frame), RW_X_LATCH, false, mtr, &err)) @@ -1491,25 +1545,15 @@ release_tree: page_rec_is_first(page_cur.rec, block->page.frame)) { ut_ad(block_savepoint + 1 == mtr->get_savepoint()); + /* Latch the previous page if the node pointer is the leftmost of the current page. */ - buf_block_t *left= btr_block_get(*index(), - btr_page_get_prev(block->page.frame), - RW_NO_LATCH, false, mtr, &err); - if (UNIV_UNLIKELY(!left)) + int ret= btr_latch_prev(block, page_id, zip_size, rw_latch, mtr, &err); + if (!ret) goto func_exit; ut_ad(block_savepoint + 2 == mtr->get_savepoint()); - if (UNIV_LIKELY(left->page.lock.s_lock_try())) - mtr->lock_register(block_savepoint + 1, MTR_MEMO_PAGE_S_FIX); - else + if (ret < 0) { - if (rw_latch == RW_S_LATCH) - block->page.lock.s_unlock(); - else - block->page.lock.x_unlock(); - mtr->upgrade_buffer_fix(block_savepoint + 1, RW_S_LATCH); - mtr->lock_register(block_savepoint, MTR_MEMO_BUF_FIX); - mtr->upgrade_buffer_fix(block_savepoint, RW_S_LATCH); /* While our latch on the level-2 page prevents splits or merges of this level-1 block, other threads may have modified it due to splitting or merging some level-0 (leaf) @@ -1524,13 +1568,12 @@ release_tree: offsets)); } } - goto leaf_with_no_latch; + rw_latch= rw_lock_type_t(latch_mode & (RW_X_LATCH | RW_S_LATCH)); + break; case BTR_MODIFY_LEAF: case BTR_SEARCH_LEAF: - if (index()->is_ibuf()) - goto leaf_with_no_latch; rw_latch= rw_lock_type_t(latch_mode); - if (btr_op != BTR_NO_OP && + if (btr_op != BTR_NO_OP && !index()->is_ibuf() && ibuf_should_try(index(), btr_op != BTR_INSERT_OP)) /* Try to buffer the operation if the leaf page is not in the buffer pool. */ @@ -1550,10 +1593,9 @@ release_tree: mtr->rollback_to_savepoint(block_savepoint); goto need_opposite_intention; } - /* fall through */ + break; default: - leaf_with_no_latch: - rw_latch= RW_NO_LATCH; + ut_ad(rw_latch == RW_X_LATCH); } } @@ -1578,8 +1620,8 @@ dberr_t btr_cur_t::pessimistic_search_leaf(const dtuple_t *tuple, ut_ad(index()->is_btree() || index()->is_ibuf()); ut_ad(!index()->is_ibuf() || ibuf_inside(mtr)); - rec_offs offsets_[REC_OFFS_NORMAL_SIZE]; - rec_offs* offsets = offsets_; + rec_offs offsets_[REC_OFFS_NORMAL_SIZE]; + rec_offs* offsets= offsets_; rec_offs_init(offsets_); ut_ad(flag == BTR_CUR_BINARY); @@ -1653,9 +1695,8 @@ dberr_t btr_cur_t::pessimistic_search_leaf(const dtuple_t *tuple, /* Go to the child node */ page_id.set_page_no(btr_node_ptr_get_child_page_no(page_cur.rec, offsets)); - const auto block_savepoint= mtr->get_savepoint(); block= - buf_page_get_gen(page_id, block->zip_size(), RW_NO_LATCH, nullptr, BUF_GET, + buf_page_get_gen(page_id, block->zip_size(), RW_X_LATCH, nullptr, BUF_GET, mtr, &err, !--height && !index()->is_clust()); if (!block) @@ -1674,15 +1715,15 @@ dberr_t btr_cur_t::pessimistic_search_leaf(const dtuple_t *tuple, if (height != btr_page_get_level(block->page.frame)) goto corrupted; - if (page_has_prev(block->page.frame) && - !btr_block_get(*index(), btr_page_get_prev(block->page.frame), - RW_X_LATCH, false, mtr, &err)) - goto func_exit; - mtr->upgrade_buffer_fix(block_savepoint, RW_X_LATCH); #ifdef UNIV_ZIP_DEBUG const page_zip_des_t *page_zip= buf_block_get_page_zip(block); ut_a(!page_zip || page_zip_validate(page_zip, block->page.frame, index())); #endif /* UNIV_ZIP_DEBUG */ + + if (page_has_prev(block->page.frame) && + !btr_latch_prev(block, page_id, block->zip_size(), + RW_X_LATCH, mtr, &err)) + goto func_exit; if (page_has_next(block->page.frame) && !btr_block_get(*index(), btr_page_get_next(block->page.frame), RW_X_LATCH, false, mtr, &err)) @@ -1895,13 +1936,10 @@ index_locked: ut_ad(n_blocks < BTR_MAX_LEVELS); ut_ad(savepoint + n_blocks == mtr->get_savepoint()); - const rw_lock_type_t rw_latch= height && latch_mode != BTR_MODIFY_TREE - ? upper_rw_latch - : RW_NO_LATCH; buf_block_t* block= - btr_block_get(*index, page, rw_latch, !height && !index->is_clust(), mtr, - &err); - + btr_block_get(*index, page, + height ? upper_rw_latch : root_leaf_rw_latch, + !height, mtr, &err); ut_ad(!block == (err != DB_SUCCESS)); if (!block) @@ -1943,13 +1981,11 @@ index_locked: if (latch_mode == BTR_MODIFY_TREE) { - ut_ad(rw_latch == RW_NO_LATCH); /* x-latch also siblings from left to right */ if (page_has_prev(block->page.frame) && - !btr_block_get(*index, btr_page_get_prev(block->page.frame), - RW_X_LATCH, false, mtr, &err)) + !btr_latch_prev(block, block->page.id(), zip_size, RW_X_LATCH, + mtr, &err)) break; - mtr->upgrade_buffer_fix(leaf_savepoint - 1, RW_X_LATCH); if (page_has_next(block->page.frame) && !btr_block_get(*index, btr_page_get_next(block->page.frame), RW_X_LATCH, false, mtr, &err)) @@ -1964,10 +2000,6 @@ index_locked: } else { - if (rw_latch == RW_NO_LATCH) - mtr->upgrade_buffer_fix(leaf_savepoint - 1, - rw_lock_type_t(latch_mode & - (RW_X_LATCH | RW_S_LATCH))); if (latch_mode != BTR_CONT_MODIFY_TREE) { ut_ad(latch_mode == BTR_MODIFY_LEAF || @@ -2037,21 +2069,6 @@ index_locked: n_blocks= 1; } } - - if (!height) - { - if (page == index->page) - mtr->upgrade_buffer_fix(savepoint, RW_X_LATCH); - else - { - /* The U-latch protects BTR_SEG_HEAP, BTR_SEG_TOP. */ - mtr->upgrade_buffer_fix(savepoint, RW_SX_LATCH); - - /* Upgrade buffer-fix to exclusive latches on all remaining pages. */ - for (ulint i= 1; i <= n_blocks; i++) - mtr->upgrade_buffer_fix(savepoint + i, RW_X_LATCH); - } - } } /* Go to the child node */ diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index d48437e4bd0..01f8b2671b0 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -540,7 +540,8 @@ btr_pcur_move_to_next_page( dberr_t err; buf_block_t* next_block = btr_block_get( - *cursor->index(), next_page_no, cursor->latch_mode & ~12, + *cursor->index(), next_page_no, + rw_lock_type_t(cursor->latch_mode & (RW_X_LATCH | RW_S_LATCH)), page_is_leaf(page), mtr, &err); if (UNIV_UNLIKELY(!next_block)) { diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 1a18004533e..2f4de339d02 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -2156,8 +2156,7 @@ next_page: } next_page= false; - block= btr_block_get(*clust_index, next_page_no, BTR_SEARCH_LEAF, false, - &mtr); + block= btr_block_get(*clust_index, next_page_no, RW_S_LATCH, false, &mtr); if (!block) goto non_empty; page_cur_set_before_first(block, cur); diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index a56598d3620..5a0401fad85 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -91,7 +91,7 @@ ATTRIBUTE_COLD void btr_decryption_failed(const dict_index_t &index); @param[out] err error code @return block */ buf_block_t *btr_block_get(const dict_index_t &index, - uint32_t page, ulint mode, bool merge, + uint32_t page, rw_lock_type_t mode, bool merge, mtr_t *mtr, dberr_t *err= nullptr); /**************************************************************//**