summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authortimour@mysql.com <>2004-12-28 11:57:56 +0200
committertimour@mysql.com <>2004-12-28 11:57:56 +0200
commit064c73490b7266bc00cb2a6668332414673b4cec (patch)
treeef1944be254fd19762ac926af21196cbee1448d9 /sql/item_strfunc.cc
parentfbc96c79a1126344b6b48d9ace1e3e59a4650518 (diff)
downloadmariadb-git-064c73490b7266bc00cb2a6668332414673b4cec.tar.gz
Fix for BUG#7455.
The fix checks if the trim string argument is NULL. If so, the standard mandates that the function result must be also NULL.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 068878652e4..2a63c5355a4 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1302,9 +1302,18 @@ String *Item_func_trim::val_str(String *str)
return 0; /* purecov: inspected */
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),res->charset());
- String *remove_str= (arg_count==2) ? args[1]->val_str(&tmp) : &remove;
uint remove_length;
LINT_INIT(remove_length);
+ String *remove_str; /* The string to remove from res. */
+
+ if (arg_count == 2)
+ {
+ remove_str= args[1]->val_str(&tmp);
+ if ((null_value= args[1]->null_value))
+ return 0;
+ }
+ else
+ remove_str= &remove; /* Default value. */
if (!remove_str || (remove_length=remove_str->length()) == 0 ||
remove_length > res->length())