summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2019-09-10 23:51:42 +0300
committerSergei Petrunia <psergey@askmonty.org>2019-09-11 17:06:50 +0300
commitc8dc866fdeee551993ef91fb321135f9106ea00e (patch)
treed74301fbc473f28660e57b43bc836fc3b643f628 /sql/sql_select.h
parent863a95173110e1528e7a47fe688fea8784eb67b6 (diff)
downloadmariadb-git-c8dc866fdeee551993ef91fb321135f9106ea00e.tar.gz
MDEV-20371: Invalid reads at plan refinement stage: join->positions...
best_access_path() is called from two optimization phases: 1. Plan choice phase, in choose_plan(). Here, the join prefix being considered is in join->positions[] 2. Plan refinement stage, in fix_semijoin_strategies_for_picked_join_order Here, the join prefix is in join->best_positions[] It used to access join->positions[] from stage #2. This didnt cause any valgrind or asan failures (as join->positions[] has been written-to before) but the effect was similar to that of reading the random data: The join prefix we've picked (in join->best_positions) could have nothing in common with the join prefix that was last to be considered (in join->positions).
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r--sql/sql_select.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 60c2ce55a16..fe44f448446 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -792,6 +792,7 @@ public:
friend void best_access_path(JOIN *join,
JOIN_TAB *s,
table_map remaining_tables,
+ const struct st_position *join_positions,
uint idx,
bool disable_jbuf,
double record_count,
@@ -1960,6 +1961,11 @@ protected:
}
};
+void best_access_path(JOIN *join, JOIN_TAB *s,
+ table_map remaining_tables,
+ const POSITION *join_positions, uint idx,
+ bool disable_jbuf, double record_count,
+ POSITION *pos, POSITION *loose_scan_pos);
bool cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref);
bool error_if_full_join(JOIN *join);
int report_error(TABLE *table, int error);
@@ -2277,7 +2283,7 @@ bool instantiate_tmp_table(TABLE *table, KEY *keyinfo,
ulonglong options);
bool open_tmp_table(TABLE *table);
void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps);
-double prev_record_reads(POSITION *positions, uint idx, table_map found_ref);
+double prev_record_reads(const POSITION *positions, uint idx, table_map found_ref);
void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist);
struct st_cond_statistic