Commit 4aca623a authored by unknown's avatar unknown
Browse files

Merge magare.gmz:/home/kgeorge/mysql/work/WL3527-5.0-opt-merge

into  magare.gmz:/home/kgeorge/mysql/work/WL3527-5.0-opt-merge-5.1-opt


mysql-test/r/func_str.result:
  Auto merged
mysql-test/t/func_str.test:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
parents 209802eb 52fb60da
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2293,4 +2293,16 @@ NULL
SELECT UNHEX('G') IS NULL;
UNHEX('G') IS NULL
1
SELECT INSERT('abc', 3, 3, '1234');
INSERT('abc', 3, 3, '1234')
ab1234
SELECT INSERT('abc', 4, 3, '1234');
INSERT('abc', 4, 3, '1234')
abc1234
SELECT INSERT('abc', 5, 3, '1234');
INSERT('abc', 5, 3, '1234')
abc
SELECT INSERT('abc', 6, 3, '1234');
INSERT('abc', 6, 3, '1234')
abc
End of 5.0 tests
+8 −0
Original line number Diff line number Diff line
@@ -1142,4 +1142,12 @@ DROP TABLE t1;
SELECT UNHEX('G');
SELECT UNHEX('G') IS NULL;

#
# Bug #26281: INSERT() function mishandles NUL on boundary condition
#
SELECT INSERT('abc', 3, 3, '1234');
SELECT INSERT('abc', 4, 3, '1234');
SELECT INSERT('abc', 5, 3, '1234');
SELECT INSERT('abc', 6, 3, '1234');

--echo End of 5.0 tests
+5 −5
Original line number Diff line number Diff line
@@ -964,18 +964,18 @@ String *Item_func_insert::val_str(String *str)
      args[3]->null_value)
    goto null; /* purecov: inspected */

  if ((start < 0) || (start > res->length() + 1))
  if ((start < 0) || (start > res->length()))
    return res;                                 // Wrong param; skip insert
  if ((length < 0) || (length > res->length() + 1))
    length= res->length() + 1;
  if ((length < 0) || (length > res->length()))
    length= res->length();

  /* start and length are now sufficiently valid to pass to charpos function */
   start= res->charpos((int) start);
   length= res->charpos((int) length, (uint32) start);

  /* Re-testing with corrected params */
  if (start > res->length() + 1)
    return res;                                 // Wrong param; skip insert
  if (start > res->length())
    return res; /* purecov: inspected */        // Wrong param; skip insert
  if (length > res->length() - start)
    length= res->length() - start;