diff options
author | Andrei Elkin <andrei.elkin@mariadb.com> | 2019-11-11 16:03:43 +0200 |
---|---|---|
committer | Andrei Elkin <andrei.elkin@mariadb.com> | 2019-11-11 16:03:43 +0200 |
commit | 26fd880d5eba5e46e69f88f21cc6ca45cbda0a4f (patch) | |
tree | a02a4bb6992f540cd229776680d381c730d2ea77 /sql | |
parent | 142442d571dd86c630019ece82e36dc73e1e5f1b (diff) | |
parent | 13db50fc03e7312e6c01b06c7e4af69f69ba5382 (diff) | |
download | mariadb-git-26fd880d5eba5e46e69f88f21cc6ca45cbda0a4f.tar.gz |
manual merge 10.1->10.2
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_repl.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/table.cc | 21 | ||||
-rw-r--r-- | sql/table.h | 1 |
4 files changed, 27 insertions, 5 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 8a6bea34fb4..294dcc61713 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -2742,7 +2742,11 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, run hook first when all check has been made that slave seems to be requesting a reasonable position. i.e when transmit actually starts */ - if (RUN_HOOK(binlog_transmit, transmit_start, (thd, flags, log_ident, pos))) + + DBUG_ASSERT(pos == linfo.pos); + + if (RUN_HOOK(binlog_transmit, transmit_start, + (thd, flags, linfo.log_file_name, linfo.pos))) { info->errmsg= "Failed to run hook 'transmit_start'"; info->error= ER_UNKNOWN_ERROR; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c450572c9bd..b8f23cd135b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8003,7 +8003,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, something went wrong. */ sel /= (double)table->quick_rows[key] / (double) table->stat_records(); - DBUG_ASSERT(0 < sel && sel <= 2.0); set_if_smaller(sel, 1.0); used_range_selectivity= true; } @@ -8052,7 +8051,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, if (table->field[fldno]->cond_selectivity > 0) { sel /= table->field[fldno]->cond_selectivity; - DBUG_ASSERT(0 < sel && sel <= 2.0); set_if_smaller(sel, 1.0); } /* @@ -8110,7 +8108,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, if (field->cond_selectivity > 0) { sel/= field->cond_selectivity; - DBUG_ASSERT(0 < sel && sel <= 2.0); set_if_smaller(sel, 1.0); } break; @@ -8122,7 +8119,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, sel*= table_multi_eq_cond_selectivity(join, idx, s, rem_tables, keyparts, ref_keyuse_steps); - DBUG_ASSERT(0.0 < sel && sel <= 1.0); return sel; } diff --git a/sql/table.cc b/sql/table.cc index 57abf6c4c7b..bb6c35fecd2 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4571,6 +4571,8 @@ void TABLE::init(THD *thd, TABLE_LIST *tl) created= TRUE; cond_selectivity= 1.0; cond_selectivity_sampling_explain= NULL; + quick_condition_rows=0; + initialize_quick_structures(); #ifdef HAVE_REPLICATION /* used in RBR Triggers */ master_had_triggers= 0; @@ -8556,3 +8558,22 @@ bool fk_modifies_child(enum_fk_option opt) static bool can_write[]= { false, false, true, true, false, true }; return can_write[opt]; } + + +/* + @brief + Initialize all the quick structures that are used to stored the + estimates when the range optimizer is run. + @details + This is specifically needed when we read the TABLE structure from the + table cache. There can be some garbage data from previous queries + that need to be reset here. +*/ + +void TABLE::initialize_quick_structures() +{ + bzero(quick_rows, sizeof(quick_rows)); + bzero(quick_key_parts, sizeof(quick_key_parts)); + bzero(quick_costs, sizeof(quick_costs)); + bzero(quick_n_ranges, sizeof(quick_n_ranges)); +} diff --git a/sql/table.h b/sql/table.h index f10e00562dc..e0541ef3f2e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1441,6 +1441,7 @@ public: bool is_filled_at_execution(); bool update_const_key_parts(COND *conds); + void initialize_quick_structures(); my_ptrdiff_t default_values_offset() const { return (my_ptrdiff_t) (s->default_values - record[0]); } |