diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-01-28 09:12:23 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-01-28 09:12:23 +0100 |
commit | b816d5f387cdfa61e065ef33db9246d17958974f (patch) | |
tree | e811e54db5452bbe05647d16fa4991c0332121d7 /sql/item_strfunc.cc | |
parent | e73aceedde2f58ddd1d334cdb19d6adbde7839b3 (diff) | |
parent | f4e7c093726a0143fd734b588c10e2b7780fe9ab (diff) | |
download | mariadb-git-mariadb-5.3.12.tar.gz |
5.2 mergemariadb-5.3.12
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index d0b284a363d..71526c433ed 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1167,7 +1167,7 @@ void Item_str_func::left_right_max_length() if (args[1]->const_item()) { int length=(int) args[1]->val_int()*collation.collation->mbmaxlen; - if (length <= 0) + if (args[1]->null_value || length <= 0) max_length=0; else set_if_smaller(max_length,(uint) length); @@ -1270,7 +1270,9 @@ void Item_func_substr::fix_length_and_dec() if (args[1]->const_item()) { int32 start= (int32) args[1]->val_int(); - if (start < 0) + if (args[1]->null_value) + max_length= 0; + else if (start < 0) max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start); else max_length-= min((uint)(start - 1), max_length); @@ -1278,7 +1280,7 @@ void Item_func_substr::fix_length_and_dec() if (arg_count == 3 && args[2]->const_item()) { int32 length= (int32) args[2]->val_int(); - if (length <= 0) + if (args[2]->null_value || length <= 0) max_length=0; /* purecov: inspected */ else set_if_smaller(max_length,(uint) length); @@ -2412,7 +2414,9 @@ void Item_func_repeat::fix_length_and_dec() /* Assumes that the maximum length of a String is < INT_MAX32. */ /* Set here so that rest of code sees out-of-bound value as such. */ - if (count > INT_MAX32) + if (args[1]->null_value) + count= 0; + else if (count > INT_MAX32) count= INT_MAX32; ulonglong max_result_length= (ulonglong) args[0]->max_length * count; @@ -2500,7 +2504,9 @@ void Item_func_rpad::fix_length_and_dec() /* Assumes that the maximum length of a String is < INT_MAX32. */ /* Set here so that rest of code sees out-of-bound value as such. */ - if (temp > INT_MAX32) + if (args[1]->null_value) + temp= 0; + else if (temp > INT_MAX32) temp = INT_MAX32; length= temp * collation.collation->mbmaxlen; @@ -2617,7 +2623,9 @@ void Item_func_lpad::fix_length_and_dec() /* Assumes that the maximum length of a String is < INT_MAX32. */ /* Set here so that rest of code sees out-of-bound value as such. */ - if (temp > INT_MAX32) + if (args[1]->null_value) + temp= 0; + else if (temp > INT_MAX32) temp= INT_MAX32; length= temp * collation.collation->mbmaxlen; |