summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorigor@olga.mysql.com <>2007-06-17 11:23:19 -0700
committerigor@olga.mysql.com <>2007-06-17 11:23:19 -0700
commit63ab91090ddc6ff0588dd4616fb90a77a2036970 (patch)
treea2fb6dabdae243780ae0d3845d1c3d2f008d8826 /sql/item_strfunc.cc
parenta877145db840edb5a54c8a428abbef44f616846b (diff)
downloadmariadb-git-63ab91090ddc6ff0588dd4616fb90a77a2036970.tar.gz
Fixed bug #27130. If the third argument of the function SUBSTR was
represented by an expression of the type UNSIGNED INT and this expression was evaluated to 0 then the function erroneously returned the value of the first argument instead of an empty string. This problem was introduced by the patch for bug 10963. The problem has been resolved by a proper modification of the code of Item_func_substr::val_str.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 33e9b8de823..0c24f14c8fe 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1145,8 +1145,9 @@ String *Item_func_substr::val_str(String *str)
(arg_count == 3 && args[2]->null_value))))
return 0; /* purecov: inspected */
- /* Negative length, will return empty string. */
- if ((arg_count == 3) && (length <= 0) && !args[2]->unsigned_flag)
+ /* Negative or zero length, will return empty string. */
+ if ((arg_count == 3) && (length <= 0) &&
+ (length == 0 || !args[2]->unsigned_flag))
return &my_empty_string;
/* Assumes that the maximum length of a String is < INT_MAX32. */