[Commits] e82858fc6b7: MDEV-22910: SIGSEGV in Opt_trace_context::is_started & SIGSEGV in Json_writer::add_table_name (on optimized builds)
revision-id: e82858fc6b73336778992a371d24a11e96e28f83 (mariadb-10.4.11-230-ge82858fc6b7) parent(s): 6404645980db51fdc1e5dae2ac94eca57804284b author: Varun Gupta committer: Varun Gupta timestamp: 2020-06-17 20:54:09 +0530 message: MDEV-22910: SIGSEGV in Opt_trace_context::is_started & SIGSEGV in Json_writer::add_table_name (on optimized builds) Make sure to initialize members of TABLE::reginfo when TABLE::init is called. In this case the problem was that table->reginfo.join_tab was set for the SELECT query and then was reused by the UPDATE query. This case occurred only when the SELECT query had a degenerate join. --- mysql-test/main/opt_trace.result | 31 +++++++++++++++++++++++++++++++ mysql-test/main/opt_trace.test | 11 +++++++++++ sql/opt_range.cc | 6 ++---- sql/table.cc | 2 ++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index be358e69c47..7e6532083da 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -8465,5 +8465,36 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] ] DROP TABLE t1,t2; +# +# MDEV-22910:SIGSEGV in Opt_trace_context::is_started & SIGSEGV in Json_writer::add_table_name +# (on optimized builds) +# +CREATE TABLE t1( a INT, b INT, PRIMARY KEY( a ) ); +SELECT sum(b), row_number() OVER (order by b) FROM t1 WHERE a = 101; +sum(b) row_number() OVER (order by b) +NULL 1 +UPDATE t1 SET b=10 WHERE a=1; +SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) +[ + + [ + + { + "index": "PRIMARY", + "ranges": + [ + "(1) <= (a) <= (1)" + ], + "rowid_ordered": true, + "using_mrr": false, + "index_only": false, + "rows": 0, + "cost": 1.125, + "chosen": true + } + ] +] +DROP TABLE t1; # End of 10.4 tests set optimizer_trace='enabled=off'; diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index d1a8fedc635..a10de9b0e3b 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -594,6 +594,17 @@ EXPLAIN SELECT * FROM t1, t2 WHERE t1.a=t2.a ORDER BY t2.b; select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; DROP TABLE t1,t2; +--echo # +--echo # MDEV-22910:SIGSEGV in Opt_trace_context::is_started & SIGSEGV in Json_writer::add_table_name +--echo # (on optimized builds) +--echo # + +CREATE TABLE t1( a INT, b INT, PRIMARY KEY( a ) ); +SELECT sum(b), row_number() OVER (order by b) FROM t1 WHERE a = 101; +UPDATE t1 SET b=10 WHERE a=1; +SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +DROP TABLE t1; + --echo # End of 10.4 tests set optimizer_trace='enabled=off'; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 66c870dd2ac..1b7f8d1bb9b 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2683,10 +2683,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, DBUG_PRINT("info",("Time to scan table: %g", read_time)); Json_writer_object table_records(thd); - if (head->reginfo.join_tab) - table_records.add_table_name(head->reginfo.join_tab); - else - table_records.add_table_name(head); + table_records.add_table_name(head); + Json_writer_object trace_range(thd, "range_analysis"); { Json_writer_object table_rec(thd, "table_scan"); diff --git a/sql/table.cc b/sql/table.cc index f58f2428129..aacb4eee228 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5160,6 +5160,8 @@ void TABLE::init(THD *thd, TABLE_LIST *tl) fulltext_searched= 0; file->ft_handler= 0; reginfo.impossible_range= 0; + reginfo.join_tab= NULL; + reginfo.not_exists_optimize= FALSE; created= TRUE; cond_selectivity= 1.0; cond_selectivity_sampling_explain= NULL;
participants (1)
-
Varun