diff options
author | timour@mysql.com <> | 2004-12-28 11:57:56 +0200 |
---|---|---|
committer | timour@mysql.com <> | 2004-12-28 11:57:56 +0200 |
commit | 064c73490b7266bc00cb2a6668332414673b4cec (patch) | |
tree | ef1944be254fd19762ac926af21196cbee1448d9 /sql/item_strfunc.cc | |
parent | fbc96c79a1126344b6b48d9ace1e3e59a4650518 (diff) | |
download | mariadb-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.cc | 11 |
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()) |