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/sql_lex.cc | |
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/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index dcf0b7ad41b..f012187a88a 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -7702,3 +7702,64 @@ bool SELECT_LEX::vers_push_field(THD *thd, TABLE_LIST *table, const LEX_CSTRING return false; } + +Item *Lex_trim_st::make_item_func_trim_std(THD *thd) const +{ + if (m_remove) + { + switch (m_spec) { + case TRIM_BOTH: + return new (thd->mem_root) Item_func_trim(thd, m_source, m_remove); + case TRIM_LEADING: + return new (thd->mem_root) Item_func_ltrim(thd, m_source, m_remove); + case TRIM_TRAILING: + return new (thd->mem_root) Item_func_rtrim(thd, m_source, m_remove); + } + } + + switch (m_spec) { + case TRIM_BOTH: + return new (thd->mem_root) Item_func_trim(thd, m_source); + case TRIM_LEADING: + return new (thd->mem_root) Item_func_ltrim(thd, m_source); + case TRIM_TRAILING: + return new (thd->mem_root) Item_func_rtrim(thd, m_source); + } + DBUG_ASSERT(0); + return NULL; +} + + +Item *Lex_trim_st::make_item_func_trim_oracle(THD *thd) const +{ + if (m_remove) + { + switch (m_spec) { + case TRIM_BOTH: + return new (thd->mem_root) Item_func_trim_oracle(thd, m_source, m_remove); + case TRIM_LEADING: + return new (thd->mem_root) Item_func_ltrim_oracle(thd, m_source, m_remove); + case TRIM_TRAILING: + return new (thd->mem_root) Item_func_rtrim_oracle(thd, m_source, m_remove); + } + } + + switch (m_spec) { + case TRIM_BOTH: + return new (thd->mem_root) Item_func_trim_oracle(thd, m_source); + case TRIM_LEADING: + return new (thd->mem_root) Item_func_ltrim_oracle(thd, m_source); + case TRIM_TRAILING: + return new (thd->mem_root) Item_func_rtrim_oracle(thd, m_source); + } + DBUG_ASSERT(0); + return NULL; +} + + +Item *Lex_trim_st::make_item_func_trim(THD *thd) const +{ + return (thd->variables.sql_mode & MODE_ORACLE) ? + make_item_func_trim_oracle(thd) : + make_item_func_trim_std(thd); +} |