summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2019-09-11 20:22:08 +0300
committerSergei Petrunia <psergey@askmonty.org>2019-09-12 19:29:07 +0300
commit1966b71bfb250d551d53daf7f6606337900bbb0f (patch)
treed2624459c035dae8f1be282d225eb921910c204e /sql/sql_select.h
parent5c5452a5a086a9584efb2255059da671fff6e484 (diff)
downloadmariadb-git-bb-10.4-mdev20371.tar.gz
MDEV-20371: Invalid reads at plan refinement stage: join->positions...bb-10.4-mdev20371
(re-committing in 10.4) 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.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 4ec258f3653..b6359307215 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -854,6 +854,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,
@@ -2071,6 +2072,12 @@ 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);
@@ -2435,7 +2442,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);
double get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size);
double get_tmp_table_write_cost(THD *thd, double row_count, uint row_size);