diff options
author | halfspawn <j.brauge@qualiac.com> | 2018-03-27 09:08:30 +0200 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-03-29 14:27:57 +0400 |
commit | 209375fdd07d9be79784984f8543be73d1f92a9a (patch) | |
tree | 938c1ab12ab0a4daf616c1a0e43c0f51d4b8873a /sql/item_strfunc.h | |
parent | 4faf34ad639a28a29ddfc84547108fad058d00ca (diff) | |
download | mariadb-git-209375fdd07d9be79784984f8543be73d1f92a9a.tar.gz |
MDEV-15664 : sql_mode=ORACLE: Make TRIM return NULL instead of empty string
Diffstat (limited to 'sql/item_strfunc.h')
-rw-r--r-- | sql/item_strfunc.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index da77f29f108..4e1514c5476 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -539,6 +539,9 @@ protected: String remove; String *trimmed_value(String *res, uint32 offset, uint32 length) { + if (length == 0) + return make_empty_result(); + tmp_value.set(*res, offset, length); /* Make sure to return correct charset and collation: @@ -552,6 +555,7 @@ protected: { return trimmed_value(res, 0, res->length()); } + virtual const char *func_name_ext() const { return ""; } public: Item_func_trim(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} Item_func_trim(THD *thd, Item *a): Item_str_func(thd, a) {} @@ -565,6 +569,27 @@ public: }; +class Item_func_trim_oracle :public Item_func_trim +{ +protected: + String *make_empty_result() + { null_value= 1; return NULL; } + const char *func_name_ext() const { return "_oracle"; } +public: + Item_func_trim_oracle(THD *thd, Item *a, Item *b): + Item_func_trim(thd, a, b) {} + Item_func_trim_oracle(THD *thd, Item *a): Item_func_trim(thd, a) {} + const char *func_name() const { return "trim_oracle"; } + void fix_length_and_dec() + { + Item_func_trim::fix_length_and_dec(); + maybe_null= true; + } + Item *get_copy(THD *thd) + { return get_item_copy<Item_func_trim_oracle>(thd, this); } +}; + + class Item_func_ltrim :public Item_func_trim { public: @@ -578,6 +603,27 @@ public: }; +class Item_func_ltrim_oracle :public Item_func_ltrim +{ +protected: + String *make_empty_result() + { null_value= 1; return NULL; } + const char *func_name_ext() const { return "_oracle"; } +public: + Item_func_ltrim_oracle(THD *thd, Item *a, Item *b): + Item_func_ltrim(thd, a, b) {} + Item_func_ltrim_oracle(THD *thd, Item *a): Item_func_ltrim(thd, a) {} + const char *func_name() const { return "ltrim_oracle"; } + void fix_length_and_dec() + { + Item_func_ltrim::fix_length_and_dec(); + maybe_null= true; + } + Item *get_copy(THD *thd) + { return get_item_copy<Item_func_ltrim_oracle>(thd, this); } +}; + + class Item_func_rtrim :public Item_func_trim { public: @@ -591,6 +637,26 @@ public: }; +class Item_func_rtrim_oracle :public Item_func_rtrim +{ +protected: + String *make_empty_result() + { null_value= 1; return NULL; } + const char *func_name_ext() const { return "_oracle"; } +public: + Item_func_rtrim_oracle(THD *thd, Item *a, Item *b): + Item_func_rtrim(thd, a, b) {} + Item_func_rtrim_oracle(THD *thd, Item *a): Item_func_rtrim(thd, a) {} + const char *func_name() const { return "rtrim_oracle"; } + void fix_length_and_dec() + { + Item_func_rtrim::fix_length_and_dec(); + maybe_null= true; + } + Item *get_copy(THD *thd) + { return get_item_copy<Item_func_rtrim_oracle>(thd, this); } +}; + /* Item_func_password -- new (4.1.1) PASSWORD() function implementation. Returns strcat('*', octet2hex(sha1(sha1(password)))). '*' stands for new |