Skip to content

Commit b2f5d98

Browse files
MDEV-40388: sequence.simple fails on replay
sequence table was determined using tbl->table->s->sequence. The intention was to not record sequence table information. However, the check was only partially correct. Instead, we could compare using the engine name like if (!tbl->is_view() && tbl->table) { handlerton *hton= tbl->table->file->partition_ht(); const LEX_CSTRING *engine_name= hton_name(hton); if (strcmp(engine_name->str, "SEQUENCE") == 0 || strcmp(engine_name->str, "SQL_SEQUENCE") == 0) continue; } This makes the sequence.simple succeed
1 parent feb3817 commit b2f5d98

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

mysql-test/main/opt_context_store_stats.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,3 +591,18 @@ table_name file_stat_records index_name rec_per_key
591591
index_name ranges num_rows max_index_blocks max_row_blocks
592592
# == End of optimizer context
593593
drop table s1;
594+
#
595+
# MDEV-40388: sequence.simple fails on replay
596+
# Table context should *not* be recorded for seq
597+
#
598+
set optimizer_record_context=ON;
599+
explain select * from seq_15_to_1_step_12345;
600+
id select_type table type possible_keys key key_len ref rows Extra
601+
1 SIMPLE seq_15_to_1_step_12345 ALL NULL NULL NULL NULL 1
602+
# == Optimizer Context
603+
# === Tables
604+
# Tables in the context
605+
table_name file_stat_records index_name rec_per_key
606+
# === Range accesses
607+
index_name ranges num_rows max_index_blocks max_row_blocks
608+
# == End of optimizer context

mysql-test/main/opt_context_store_stats.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,12 @@ EXPLAIN select * from s1;
432432

433433
--source include/opt_context_list_tables_and_ranges.inc
434434
drop table s1;
435+
436+
--echo #
437+
--echo # MDEV-40388: sequence.simple fails on replay
438+
--echo # Table context should *not* be recorded for seq
439+
--echo #
440+
set optimizer_record_context=ON;
441+
explain select * from seq_15_to_1_step_12345;
442+
443+
--source include/opt_context_list_tables_and_ranges.inc

sql/opt_context_store_replay.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,16 @@ bool Optimizer_context_recorder::dump_sql_script(THD* thd, String &sql_script)
746746
/*
747747
Sequence table doesn't need CREATE TABLE or contain any stats
748748
*/
749-
if (tbl->table && tbl->table->s && tbl->table->s->sequence)
750-
continue;
749+
if (!tbl->is_view() && tbl->table)
750+
{
751+
handlerton *hton= tbl->table->file->partition_ht();
752+
const LEX_CSTRING *engine_name= hton_name(hton);
753+
if (strcmp(engine_name->str, "SEQUENCE") == 0 ||
754+
strcmp(engine_name->str, "SQL_SEQUENCE") == 0)
755+
{
756+
continue;
757+
}
758+
}
751759

752760
/*
753761
A query can use the same table multiple times. Do not dump the

0 commit comments

Comments
 (0)