Skip to content

Commit d161546

Browse files
committed
MDEV-6689: valgrind errors in view.test in 10.1
SHOW COLUMNS and SHOW KEYS commands fill IS_table_read_plan in a special way - they don't set or use lookup_field_vals member. Added a "trivial_show_command" flag that signals that lookup_field_vals has no valid data, made EXPLAIN code honor it.
1 parent e44751b commit d161546

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

sql/sql_select.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23490,16 +23490,19 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, table_map prefix_tab
2349023490
const char *tmp_buff;
2349123491
int f_idx;
2349223492
StringBuffer<64> key_name_buf;
23493-
if (is_table_read_plan->has_db_lookup_value())
23493+
if (is_table_read_plan->trivial_show_command ||
23494+
is_table_read_plan->has_db_lookup_value())
2349423495
{
2349523496
/* The "key" has the name of the column referring to the database */
2349623497
f_idx= table_list->schema_table->idx_field1;
2349723498
tmp_buff= table_list->schema_table->fields_info[f_idx].field_name;
2349823499
key_name_buf.append(tmp_buff, strlen(tmp_buff), cs);
2349923500
}
23500-
if (is_table_read_plan->has_table_lookup_value())
23501+
if (is_table_read_plan->trivial_show_command ||
23502+
is_table_read_plan->has_table_lookup_value())
2350123503
{
23502-
if (is_table_read_plan->has_db_lookup_value())
23504+
if (is_table_read_plan->trivial_show_command ||
23505+
is_table_read_plan->has_db_lookup_value())
2350323506
key_name_buf.append(',');
2350423507

2350523508
f_idx= table_list->schema_table->idx_field2;
@@ -23630,8 +23633,9 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, table_map prefix_tab
2363023633
else
2363123634
eta->push_extra(ET_OPEN_FULL_TABLE);
2363223635
/* psergey-note: the following has a bug.*/
23633-
if (table_list->is_table_read_plan->has_db_lookup_value() &&
23634-
table_list->is_table_read_plan->has_table_lookup_value())
23636+
if (table_list->is_table_read_plan->trivial_show_command ||
23637+
(table_list->is_table_read_plan->has_db_lookup_value() &&
23638+
table_list->is_table_read_plan->has_table_lookup_value()))
2363523639
eta->push_extra(ET_SCANNED_0_DATABASES);
2363623640
else if (table_list->is_table_read_plan->has_db_lookup_value() ||
2363723641
table_list->is_table_read_plan->has_table_lookup_value())

sql/sql_show.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8035,6 +8035,7 @@ static bool optimize_for_get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond
80358035
if (lsel && lsel->table_list.first)
80368036
{
80378037
/* These do not need to have a query plan */
8038+
plan->trivial_show_command= true;
80388039
goto end;
80398040
}
80408041

sql/sql_show.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,17 @@ typedef struct st_lookup_field_values
192192
class IS_table_read_plan : public Sql_alloc
193193
{
194194
public:
195-
IS_table_read_plan() : no_rows(false) {}
195+
IS_table_read_plan() : no_rows(false), trivial_show_command(FALSE) {}
196196

197197
bool no_rows;
198+
/*
199+
For EXPLAIN only: For SHOW KEYS and SHOW COLUMNS, we know which
200+
db_name.table_name will be read, however for some reason we don't
201+
set the fields in this->lookup_field_vals.
202+
In order to not have JOIN::save_explain_data() walking over uninitialized
203+
data, we set trivial_show_command=true.
204+
*/
205+
bool trivial_show_command;
198206

199207
LOOKUP_FIELD_VALUES lookup_field_vals;
200208
Item *partial_cond;

0 commit comments

Comments
 (0)