summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-06-10 13:55:55 +0400
committerAlexander Barkov <bar@mariadb.com>2020-06-10 13:55:55 +0400
commitbf2a244406c36cd12bc53f9a30c8a2cab191f235 (patch)
tree50309b72c7365c3db451aba16751e8bee1b3826c /sql
parent86c50a255a8319a4c89399b9c2d4f416b4973815 (diff)
downloadmariadb-git-bf2a244406c36cd12bc53f9a30c8a2cab191f235.tar.gz
MDEV-22854 Garbage returned with SELECT CASE..DEFAULT(timestamp_field_with_now_as_default)
Item_default_value did not override val_native(), so the inherited Item_field::val_native() was called. As a result Item_default_value::calculate() was not called and Item_field::val_native() was called on a Field with a non-initialized ptr. Implementing Item_default_value::val_native() properly.
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc6
-rw-r--r--sql/item.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 84e2c369bac..4b64d76905a 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -9338,6 +9338,12 @@ void Item_default_value::calculate()
DEBUG_SYNC(field->table->in_use, "after_Item_default_value_calculate");
}
+bool Item_default_value::val_native(THD *thd, Native *to)
+{
+ calculate();
+ return Item_field::val_native(thd, to);
+}
+
String *Item_default_value::val_str(String *str)
{
calculate();
diff --git a/sql/item.h b/sql/item.h
index 98b61e15c11..1fa80066f9d 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -6320,6 +6320,7 @@ public:
longlong val_int();
my_decimal *val_decimal(my_decimal *decimal_value);
bool get_date(THD *thd, MYSQL_TIME *ltime,date_mode_t fuzzydate);
+ bool val_native(THD *thd, Native *to);
bool send(Protocol *protocol, st_value *buffer);
int save_in_field(Field *field_arg, bool no_conversions);
bool save_in_param(THD *thd, Item_param *param)