From 3e6893e29a4298e9bb11bd91c6f8f88c7c1191d0 Mon Sep 17 00:00:00 2001 From: halfspawn Date: Tue, 13 Mar 2018 10:34:28 +0100 Subject: MDEV-10574 / SUBSTR - sql_mode=Oracle: return null instead of empty string --- sql/item_strfunc.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sql/item_strfunc.h') diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index a357c03bda5..3c8a699fffe 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -35,7 +35,7 @@ protected: character set. No memory is allocated. @retval A pointer to the str_value member. */ - String *make_empty_result() + virtual String *make_empty_result() { /* Reset string length to an empty string. We don't use str_value.set() as @@ -500,11 +500,18 @@ class Item_func_substr_oracle :public Item_func_substr protected: longlong get_position() { longlong pos= args[1]->val_int(); return pos == 0 ? 1 : pos; } + String *make_empty_result() + { null_value= 1; return NULL; } public: Item_func_substr_oracle(THD *thd, Item *a, Item *b): Item_func_substr(thd, a, b) {} Item_func_substr_oracle(THD *thd, Item *a, Item *b, Item *c): Item_func_substr(thd, a, b, c) {} + void fix_length_and_dec() + { + Item_func_substr::fix_length_and_dec(); + maybe_null= true; + } const char *func_name() const { return "substr_oracle"; } Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy(thd, mem_root, this); } -- cgit v1.2.1