summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2014-03-18 12:06:32 +0400
committerSergey Petrunya <psergey@askmonty.org>2014-03-18 12:06:32 +0400
commit8dae5a8a891d50d71caf59129d637b517e32ae83 (patch)
treef169db5d8f4259bfaffcfe11f27a31364d96fff7 /sql/sql_select.cc
parent5d0c01608c74b09fea8c6110213160b049487a4c (diff)
parent8c04dd33dd7ab1c261bd15ace2009832af7a2f98 (diff)
downloadmariadb-git-8dae5a8a891d50d71caf59129d637b517e32ae83.tar.gz
Merge
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index cd7b15e80b6..15bd6886682 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -14976,7 +14976,20 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
keyinfo->key_length= 0; // Will compute the sum of the parts below.
keyinfo->name= (char*) "distinct_key";
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
- keyinfo->rec_per_key=0;
+ /*
+ Needed by non-merged semi-joins: SJ-Materialized table must have a valid
+ rec_per_key array, because it participates in join optimization. Since
+ the table has no data, the only statistics we can provide is "unknown",
+ i.e. zero values.
+
+ (For table record count, we calculate and set JOIN_TAB::found_records,
+ see get_delayed_table_estimates()).
+ */
+ size_t rpk_size= keyinfo->key_parts* sizeof(keyinfo->rec_per_key[0]);
+ if (!(keyinfo->rec_per_key= (ulong*) alloc_root(&table->mem_root,
+ rpk_size)))
+ goto err;
+ bzero(keyinfo->rec_per_key, rpk_size);
/*
Create an extra field to hold NULL bits so that unique indexes on