summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2014-10-10 17:08:12 +0400
committerSergey Petrunya <psergey@askmonty.org>2014-10-10 17:08:12 +0400
commit41b45a81637be64c5039d4f600ce7eb9dbf03844 (patch)
tree83239aed4de0642d8d2997a9de55c3ef18861253 /sql
parent33f1ac66ad0c995396026881260c27a937da19ec (diff)
downloadmariadb-git-41b45a81637be64c5039d4f600ce7eb9dbf03844.tar.gz
MDEV-6738: use_stat_table + histograms crashing optimizer
- When EITS code calls store_key_image_to_rec(), it should follow its calling convention (which is counter-intuitive)
Diffstat (limited to 'sql')
-rw-r--r--sql/opt_range.cc5
-rw-r--r--sql/sql_statistics.cc6
2 files changed, 8 insertions, 3 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 07a563d8090..ee26f3745b2 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3737,6 +3737,11 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item *cond)
field Field which key image should be stored
ptr Field value in key format
len Length of the value, in bytes
+
+ ATTENTION
+ len is the length of the value not counting the NULL-byte (at the same
+ time, ptr points to the key image, which starts with NULL-byte for
+ nullable columns)
DESCRIPTION
Copy the field value from its key image to the table record. The source
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index e1b197f4a63..a38df24cfb7 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -3531,7 +3531,7 @@ double get_column_range_cardinality(Field *field,
if (hist->is_available())
{
store_key_image_to_rec(field, (uchar *) min_endp->key,
- min_endp->length);
+ field->key_length());
double pos= field->pos_in_interval(col_stats->min_value,
col_stats->max_value);
res= col_non_nulls *
@@ -3555,7 +3555,7 @@ double get_column_range_cardinality(Field *field,
if (min_endp && !(field->null_ptr && min_endp->key[0]))
{
store_key_image_to_rec(field, (uchar *) min_endp->key,
- min_endp->length);
+ field->key_length());
min_mp_pos= field->pos_in_interval(col_stats->min_value,
col_stats->max_value);
}
@@ -3564,7 +3564,7 @@ double get_column_range_cardinality(Field *field,
if (max_endp)
{
store_key_image_to_rec(field, (uchar *) max_endp->key,
- max_endp->length);
+ field->key_length());
max_mp_pos= field->pos_in_interval(col_stats->min_value,
col_stats->max_value);
}