diff options
| author | Varun Gupta <varun.gupta@mariadb.com> | 2019-03-28 13:14:49 +0530 |
|---|---|---|
| committer | Varun Gupta <varun.gupta@mariadb.com> | 2019-03-28 13:16:28 +0530 |
| commit | 38cad6875f2c85f5190eaae7b9da7c43e591eff2 (patch) | |
| tree | 81db01543b569893249a71c3f60239ef643b7138 /sql | |
| parent | 1e9c2b2305c10ccaad235f3249a0f5084bf9b2c8 (diff) | |
| download | mariadb-git-38cad6875f2c85f5190eaae7b9da7c43e591eff2.tar.gz | |
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.
Diffstat (limited to 'sql')
| -rw-r--r-- | sql/field.cc | 7 | ||||
| -rw-r--r-- | sql/sql_statistics.cc | 10 |
2 files changed, 12 insertions, 5 deletions
diff --git a/sql/field.cc b/sql/field.cc index 080cf34c76d..0621015c0e4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7027,8 +7027,11 @@ Field_longstr::check_string_copy_error(const String_copier *copier, if (!(pos= copier->most_important_error_pos())) return FALSE; - convert_to_printable(tmp, sizeof(tmp), pos, (end - pos), cs, 6); - set_warning_truncated_wrong_value("string", tmp); + if (!is_stat_field) + { + convert_to_printable(tmp, sizeof(tmp), pos, (end - pos), cs, 6); + set_warning_truncated_wrong_value("string", tmp); + } return TRUE; } diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index b5811c683e8..0a51346adb2 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -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); |
