Skip to content

Commit

Permalink
MDEV-6689: valgrind errors in view.test in 10.1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spetrunia committed Sep 3, 2014
1 parent e44751b commit d161546
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
14 changes: 9 additions & 5 deletions sql/sql_select.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23490,16 +23490,19 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, table_map prefix_tab
const char *tmp_buff;
int f_idx;
StringBuffer<64> key_name_buf;
if (is_table_read_plan->has_db_lookup_value())
if (is_table_read_plan->trivial_show_command ||
is_table_read_plan->has_db_lookup_value())
{
/* The "key" has the name of the column referring to the database */
f_idx= table_list->schema_table->idx_field1;
tmp_buff= table_list->schema_table->fields_info[f_idx].field_name;
key_name_buf.append(tmp_buff, strlen(tmp_buff), cs);
}
if (is_table_read_plan->has_table_lookup_value())
if (is_table_read_plan->trivial_show_command ||
is_table_read_plan->has_table_lookup_value())
{
if (is_table_read_plan->has_db_lookup_value())
if (is_table_read_plan->trivial_show_command ||
is_table_read_plan->has_db_lookup_value())
key_name_buf.append(',');

f_idx= table_list->schema_table->idx_field2;
Expand Down Expand Up @@ -23630,8 +23633,9 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, table_map prefix_tab
else
eta->push_extra(ET_OPEN_FULL_TABLE);
/* psergey-note: the following has a bug.*/
if (table_list->is_table_read_plan->has_db_lookup_value() &&
table_list->is_table_read_plan->has_table_lookup_value())
if (table_list->is_table_read_plan->trivial_show_command ||
(table_list->is_table_read_plan->has_db_lookup_value() &&
table_list->is_table_read_plan->has_table_lookup_value()))
eta->push_extra(ET_SCANNED_0_DATABASES);
else if (table_list->is_table_read_plan->has_db_lookup_value() ||
table_list->is_table_read_plan->has_table_lookup_value())
Expand Down
1 change: 1 addition & 0 deletions sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8035,6 +8035,7 @@ static bool optimize_for_get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond
if (lsel && lsel->table_list.first)
{
/* These do not need to have a query plan */
plan->trivial_show_command= true;
goto end;
}

Expand Down
10 changes: 9 additions & 1 deletion sql/sql_show.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,17 @@ typedef struct st_lookup_field_values
class IS_table_read_plan : public Sql_alloc
{
public:
IS_table_read_plan() : no_rows(false) {}
IS_table_read_plan() : no_rows(false), trivial_show_command(FALSE) {}

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

LOOKUP_FIELD_VALUES lookup_field_vals;
Item *partial_cond;
Expand Down

0 comments on commit d161546

Please sign in to comment.