1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-18899: Server crashes in Field::set_warning_truncated_wrong_value

To fix the crash there we need to make sure that the
server while storing the statistical values in statistical tables should do it
in a multi-byte safe way.
Also there is no need to throw warnings if there is truncation while storing
values from statistical fields.
This commit is contained in:
Varun Gupta
2019-03-28 13:14:49 +05:30
parent 1e9c2b2305
commit 38cad6875f
5 changed files with 166 additions and 5 deletions

View File

@ -1060,7 +1060,9 @@ public:
else
{
table_field->collected_stats->min_value->val_str(&val);
stat_field->store(val.ptr(), val.length(), &my_charset_bin);
uint32 length= Well_formed_prefix(val.charset(), val.ptr(),
MY_MIN(val.length(), stat_field->field_length)).length();
stat_field->store(val.ptr(), length, &my_charset_bin);
}
break;
case COLUMN_STAT_MAX_VALUE:
@ -1069,7 +1071,9 @@ public:
else
{
table_field->collected_stats->max_value->val_str(&val);
stat_field->store(val.ptr(), val.length(), &my_charset_bin);
uint32 length= Well_formed_prefix(val.charset(), val.ptr(),
MY_MIN(val.length(), stat_field->field_length)).length();
stat_field->store(val.ptr(), length, &my_charset_bin);
}
break;
case COLUMN_STAT_NULLS_RATIO:
@ -3059,7 +3063,7 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
}
}
}
table->stats_is_read= TRUE;
DBUG_RETURN(0);