summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAndrei Elkin <andrei.elkin@mariadb.com>2019-11-11 16:28:21 +0200
committerAndrei Elkin <andrei.elkin@mariadb.com>2019-11-11 16:28:21 +0200
commitd103c5a489d1d96c967c90f25fefc4aa0083ed07 (patch)
tree9e51cb2d10e036b062b74d08d2f90c45fb234558 /sql
parent4fcfdb60e788c6c8cebe35e2e0f8d9595cc9e930 (diff)
parent26fd880d5eba5e46e69f88f21cc6ca45cbda0a4f (diff)
downloadmariadb-git-d103c5a489d1d96c967c90f25fefc4aa0083ed07.tar.gz
merge 10.2->10.3 with conflict resolutions
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_repl.cc5
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/table.cc20
-rw-r--r--sql/table.h1
4 files changed, 25 insertions, 5 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 2f547707ed5..bb25ca69924 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -2777,7 +2777,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
/* Check if the dump thread is created by a slave with semisync enabled. */
thd->semi_sync_slave = is_semi_sync_slave();
- if (repl_semisync_master.dump_start(thd, log_ident, pos))
+
+ DBUG_ASSERT(pos == linfo.pos);
+
+ if (repl_semisync_master.dump_start(thd, 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 fcd4b4336c1..c7501e4fd1d 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8527,7 +8527,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;
}
@@ -8576,7 +8575,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);
}
/*
@@ -8634,7 +8632,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;
@@ -8646,7 +8643,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 0e713f60d21..278423ec0c2 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -4687,6 +4687,8 @@ void TABLE::init(THD *thd, TABLE_LIST *tl)
cond_selectivity= 1.0;
cond_selectivity_sampling_explain= NULL;
vers_write= s->versioned;
+ quick_condition_rows=0;
+ initialize_quick_structures();
#ifdef HAVE_REPLICATION
/* used in RBR Triggers */
master_had_triggers= 0;
@@ -9268,3 +9270,21 @@ bool TABLE::export_structure(THD *thd, Row_definition_list *defs)
}
return false;
}
+
+/*
+ @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 64a49fb2596..bec0fdd10ba 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1481,6 +1481,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]); }