summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2019-09-18 01:59:29 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2019-09-18 15:06:02 +0530
commit273d8eb12c40a6dcd05a8148bdfba3f1fd96e764 (patch)
tree4d67cbf15ce5cc7fac333cac019f70eb4afb3916 /sql
parentc471bfb34e970075d8649247ab088b19a097eaf4 (diff)
downloadmariadb-git-273d8eb12c40a6dcd05a8148bdfba3f1fd96e764.tar.gz
MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value
The flag is_stat_field is not set for the min_value and max_value of field items inside table share. This is a must requirement as we don't want to throw warnings of truncation when we read values from the statistics table to the column statistics of table share fields.
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc14
-rw-r--r--sql/field.h1
-rw-r--r--sql/sql_statistics.cc4
3 files changed, 5 insertions, 14 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 2b1ba0e1372..fd4cd8d5c54 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2436,14 +2436,14 @@ Field *Field::clone(MEM_ROOT *root, TABLE *new_table)
}
-
Field *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff,
bool stat_flag)
{
Field *tmp;
if ((tmp= (Field*) memdup_root(root,(char*) this,size_of())))
{
- tmp->init(new_table);
+ if (new_table)
+ tmp->init(new_table);
tmp->move_field_offset(diff);
}
tmp->is_stat_field= stat_flag;
@@ -2451,16 +2451,6 @@ Field *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff,
}
-Field *Field::clone(MEM_ROOT *root, my_ptrdiff_t diff)
-{
- Field *tmp;
- if ((tmp= (Field*) memdup_root(root,(char*) this,size_of())))
- {
- tmp->move_field_offset(diff);
- }
- return tmp;
-}
-
int Field::set_default()
{
if (default_value)
diff --git a/sql/field.h b/sql/field.h
index 19a716cfd5d..3f027868c3c 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1220,7 +1220,6 @@ public:
Field *clone(MEM_ROOT *mem_root, TABLE *new_table);
Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff,
bool stat_flag= FALSE);
- Field *clone(MEM_ROOT *mem_root, my_ptrdiff_t diff);
inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
{
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 26032d8d535..578d3fac641 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -1153,12 +1153,14 @@ public:
case COLUMN_STAT_MIN_VALUE:
table_field->read_stats->min_value->set_notnull();
stat_field->val_str(&val);
+ DBUG_ASSERT(table_field->read_stats->min_value->is_stat_field);
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);
+ DBUG_ASSERT(table_field->read_stats->min_value->is_stat_field);
table_field->read_stats->max_value->store(val.ptr(), val.length(),
&my_charset_bin);
break;
@@ -2045,7 +2047,7 @@ void create_min_max_statistical_fields_for_table_share(THD *thd,
Field *fld;
Field *table_field= *field_ptr;
my_ptrdiff_t diff= record - table_share->default_values;
- if (!(fld= table_field->clone(&stats_cb->mem_root, diff)))
+ if (!(fld= table_field->clone(&stats_cb->mem_root, NULL, diff, TRUE)))
continue;
if (i == 0)
table_field->read_stats->min_value= fld;