1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

fixed substring() length calculation in case of constant negative argument (BUG#10269)

mysql-test/r/func_str.result:
  Correct length reporting from substring()
mysql-test/t/func_str.test:
  Correct length reporting from substring()
sql/item_strfunc.cc:
  fixed substring() length calculation in case of constant negative argument
This commit is contained in:
unknown
2005-06-28 21:45:11 +03:00
parent dadf91f0ff
commit 2637338014
3 changed files with 26 additions and 1 deletions

View File

@@ -1065,7 +1065,8 @@ void Item_func_substr::fix_length_and_dec()
collation.set(args[0]->collation);
if (args[1]->const_item())
{
int32 start=(int32) args[1]->val_int()-1;
int32 start= (int32) args[1]->val_int();
start= (int32)((start < 0) ? max_length + start : start - 1);
if (start < 0 || start >= (int32) max_length)
max_length=0; /* purecov: inspected */
else