summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-09-23 17:35:29 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-09-23 17:35:29 +0300
commit5a92ccbaea1bb3973e23846a741f5694a1e687bd (patch)
treeaafc504552502b48b79cadcb06b2b5c7eba4f374 /sql/field.cc
parentc997af7d1f432dfca922958453f0e2313287f1eb (diff)
parentc016ea660ede8b7ff75f8ca65f73e2958262263a (diff)
downloadmariadb-git-5a92ccbaea1bb3973e23846a741f5694a1e687bd.tar.gz
Merge 10.3 into 10.4
Disable MDEV-20576 assertions until MDEV-20595 has been fixed.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc51
1 files changed, 23 insertions, 28 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 06dac05317c..3379be50494 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -64,7 +64,7 @@ inline bool Field::marked_for_read() const
(!table->read_set ||
bitmap_is_set(table->read_set, field_index) ||
(!(ptr >= table->record[0] &&
- ptr < table->record[0] + table->s->reclength)));
+ ptr < table->record[0] + table->s->reclength)));
}
/*
@@ -75,7 +75,7 @@ inline bool Field::marked_for_read() const
inline bool Field::marked_for_write_or_computed() const
{
- return (is_stat_field || !table ||
+ return (!table ||
(!table->write_set ||
bitmap_is_set(table->write_set, field_index) ||
(!(ptr >= table->record[0] &&
@@ -2441,31 +2441,19 @@ 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 *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff)
{
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;
return tmp;
}
-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)
@@ -2898,7 +2886,7 @@ int Field_decimal::store(const char *from_arg, size_t len, CHARSET_INFO *cs)
/*
Write digits of the frac_% parts ;
- Depending on get_thd()->count_cutted_fields, we may also want
+ Depending on get_thd()->count_cuted_fields, we may also want
to know if some non-zero tail of these parts will
be truncated (for example, 0.002->0.00 will generate a warning,
while 0.000->0.00 will not)
@@ -7026,7 +7014,8 @@ Field_longstr::check_string_copy_error(const String_copier *copier,
if (likely(!(pos= copier->most_important_error_pos())))
return FALSE;
- if (!is_stat_field)
+ /* Ignore errors from internal expressions */
+ if (get_thd()->count_cuted_fields > CHECK_FIELD_EXPRESSION)
{
DBUG_ASSERT(sizeof(tmp) >= convert_to_printable_required_length(6));
convert_to_printable(tmp, sizeof(tmp), pos, (end - pos), cs, 6);
@@ -7060,8 +7049,9 @@ int
Field_longstr::report_if_important_data(const char *pstr, const char *end,
bool count_spaces)
{
- THD *thd= get_thd();
- if ((pstr < end) && thd->count_cuted_fields > CHECK_FIELD_EXPRESSION)
+ THD *thd;
+ if ((pstr < end) &&
+ (thd= get_thd())->count_cuted_fields > CHECK_FIELD_EXPRESSION)
{
if (test_if_important_data(field_charset, pstr, end))
{
@@ -7072,7 +7062,8 @@ Field_longstr::report_if_important_data(const char *pstr, const char *end,
return 2;
}
else if (count_spaces)
- { /* If we lost only spaces then produce a NOTE, not a WARNING */
+ {
+ /* If we lost only spaces then produce a NOTE, not a WARNING */
set_note(WARN_DATA_TRUNCATED, 1);
return 2;
}
@@ -11190,13 +11181,17 @@ void Field::set_warning_truncated_wrong_value(const char *type_arg,
const char *value)
{
THD *thd= get_thd();
- const char *db_name= table->s->db.str;
- const char *table_name= table->s->table_name.str;
+ const char *db_name;
+ const char *table_name;
+ /*
+ table has in the past been 0 in case of wrong calls when processing
+ statistics tables. Let's protect against that.
+ */
+ DBUG_ASSERT(table);
- if (!db_name)
- db_name= "";
- if (!table_name)
- table_name= "";
+ db_name= (table && table->s->db.str) ? table->s->db.str : "";
+ table_name= ((table && table->s->table_name.str) ? table->s->table_name.str :
+ "");
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,