1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-22583: Selectivity for BIT columns in filtered column for EXPLAIN is incorrect

For BIT columns when EITS is collected, we store the integral value in
text representation in the min and max fields of the statistical table
When this value is retrieved from the statistical table to original table
field then we try to store the text representation in the original field
which is INCORRECT.

The value that is retrieved should be converted to integral type and that
value should be stored back in the original field. This would get us the
correct estimate for selectivity of the predicate.
This commit is contained in:
Varun Gupta
2021-01-30 22:36:51 +05:30
parent b87c342da5
commit 072b39da66
4 changed files with 88 additions and 8 deletions

View File

@ -1154,16 +1154,30 @@ public:
switch (i) {
case COLUMN_STAT_MIN_VALUE:
table_field->read_stats->min_value->set_notnull();
stat_field->val_str(&val);
table_field->read_stats->min_value->store(val.ptr(), val.length(),
&my_charset_bin);
table_field->read_stats->min_value->set_notnull();
if (table_field->type() == MYSQL_TYPE_BIT)
table_field->read_stats->min_value->store(stat_field->val_int(),
true);
else
{
stat_field->val_str(&val);
table_field->read_stats->min_value->store(val.ptr(),
val.length(),
&my_charset_bin);
}
break;
case COLUMN_STAT_MAX_VALUE:
table_field->read_stats->max_value->set_notnull();
stat_field->val_str(&val);
table_field->read_stats->max_value->store(val.ptr(), val.length(),
&my_charset_bin);
table_field->read_stats->max_value->set_notnull();
if (table_field->type() == MYSQL_TYPE_BIT)
table_field->read_stats->max_value->store(stat_field->val_int(),
true);
else
{
stat_field->val_str(&val);
table_field->read_stats->max_value->store(val.ptr(),
val.length(),
&my_charset_bin);
}
break;
case COLUMN_STAT_NULLS_RATIO:
table_field->read_stats->set_nulls_ratio(stat_field->val_real());