Commit 8f6ecbca authored by gshchepa/uchum@host.loc's avatar gshchepa/uchum@host.loc
Browse files

Fixed bug#33764: Wrong result with IN(), CONCAT() and implicit

                 type conversion.

Instead of copying of whole character string from a temporary
buffer, the server copied a short-living pointer to that string
into a long-living structure. That has been fixed.
parent 0b0fd39f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4328,4 +4328,10 @@ SELECT * FROM t1 WHERE c1 > NULL + 1;
c1
DROP TABLE t1;

CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY);
INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0');
SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar');
a
foo0
DROP TABLE t1;
End of 5.0 tests
+11 −0
Original line number Diff line number Diff line
@@ -3672,4 +3672,15 @@ DROP TABLE t1;

--echo

###########################################################################

#
# Bug #33764: Wrong result with IN(), CONCAT() and implicit type conversion
#

CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY);
INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0');
SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar');
DROP TABLE t1;

--echo End of 5.0 tests
+4 −1
Original line number Diff line number Diff line
@@ -2995,6 +2995,9 @@ void in_string::set(uint pos,Item *item)
  {
    if (res->uses_buffer_owned_by(str))
      res->copy();
    if (item->type() == Item::FUNC_ITEM)
      str->copy(*res);
    else
      *str= *res;
  }
  if (!str->charset())