Commit 63777287 authored by Alexander Barkov's avatar Alexander Barkov

Bug#54668 User variable assignments get wrong type

Problem: Item_str_ascii_func::val_str() did not set
charset of the returned value properly.
  
  mysql-test/include/ctype_numconv.inc
  mysql-test/r/ctype_binary.result
  mysql-test/r/ctype_cp1251.result
  mysql-test/r/ctype_latin1.result
  mysql-test/r/ctype_ucs.result
  - Adding tests
  
  sql/item_strfunc.cc
  - Adding initialization of charset
parent dbf76b0d
......@@ -1606,6 +1606,25 @@ drop function f1;
--echo # End of WL#2649 Number-to-string conversions
--echo #
--echo #
--echo # Bug#54668 User variable assignments get wrong type
--echo #
SET @x=md5('a');
SELECT charset(@x), collation(@x);
SET @x=old_password('a');
SELECT charset(@x), collation(@x);
SET @x=password('a');
SELECT charset(@x), collation(@x);
SET @x=sha('a');
SELECT charset(@x), collation(@x);
SET @x=sha1('a');
SELECT charset(@x), collation(@x);
SET @x=astext(point(1,2));
SELECT charset(@x), collation(@x);
SET @x=aswkt(point(1,2));
SELECT charset(@x), collation(@x);
--echo #
--echo # Bug#52159 returning time type from function and empty left join causes debug assertion
--echo #
......
......@@ -2567,6 +2567,37 @@ drop function f1;
# End of WL#2649 Number-to-string conversions
#
#
# Bug#54668 User variable assignments get wrong type
#
SET @x=md5('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
binary binary
SET @x=old_password('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
binary binary
SET @x=password('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
binary binary
SET @x=sha('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
binary binary
SET @x=sha1('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
binary binary
SET @x=astext(point(1,2));
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
binary binary
SET @x=aswkt(point(1,2));
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
binary binary
#
# Bug#52159 returning time type from function and empty left join causes debug assertion
#
CREATE FUNCTION f1() RETURNS TIME RETURN 1;
......
......@@ -2649,6 +2649,37 @@ drop function f1;
# End of WL#2649 Number-to-string conversions
#
#
# Bug#54668 User variable assignments get wrong type
#
SET @x=md5('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
cp1251 cp1251_general_ci
SET @x=old_password('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
cp1251 cp1251_general_ci
SET @x=password('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
cp1251 cp1251_general_ci
SET @x=sha('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
cp1251 cp1251_general_ci
SET @x=sha1('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
cp1251 cp1251_general_ci
SET @x=astext(point(1,2));
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
cp1251 cp1251_general_ci
SET @x=aswkt(point(1,2));
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
cp1251 cp1251_general_ci
#
# Bug#52159 returning time type from function and empty left join causes debug assertion
#
CREATE FUNCTION f1() RETURNS TIME RETURN 1;
......
......@@ -2977,6 +2977,37 @@ drop function f1;
# End of WL#2649 Number-to-string conversions
#
#
# Bug#54668 User variable assignments get wrong type
#
SET @x=md5('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
latin1 latin1_swedish_ci
SET @x=old_password('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
latin1 latin1_swedish_ci
SET @x=password('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
latin1 latin1_swedish_ci
SET @x=sha('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
latin1 latin1_swedish_ci
SET @x=sha1('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
latin1 latin1_swedish_ci
SET @x=astext(point(1,2));
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
latin1 latin1_swedish_ci
SET @x=aswkt(point(1,2));
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
latin1 latin1_swedish_ci
#
# Bug#52159 returning time type from function and empty left join causes debug assertion
#
CREATE FUNCTION f1() RETURNS TIME RETURN 1;
......
......@@ -3809,6 +3809,37 @@ drop function f1;
# End of WL#2649 Number-to-string conversions
#
#
# Bug#54668 User variable assignments get wrong type
#
SET @x=md5('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
ucs2 ucs2_general_ci
SET @x=old_password('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
ucs2 ucs2_general_ci
SET @x=password('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
ucs2 ucs2_general_ci
SET @x=sha('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
ucs2 ucs2_general_ci
SET @x=sha1('a');
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
ucs2 ucs2_general_ci
SET @x=astext(point(1,2));
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
ucs2 ucs2_general_ci
SET @x=aswkt(point(1,2));
SELECT charset(@x), collation(@x);
charset(@x) collation(@x)
ucs2 ucs2_general_ci
#
# Bug#52159 returning time type from function and empty left join causes debug assertion
#
CREATE FUNCTION f1() RETURNS TIME RETURN 1;
......
......@@ -72,7 +72,12 @@ String *Item_str_ascii_func::val_str(String *str)
DBUG_ASSERT(fixed == 1);
if (!(collation.collation->state & MY_CS_NONASCII))
return val_str_ascii(str);
{
String *res= val_str_ascii(str);
if (res)
res->set_charset(collation.collation);
return res;
}
DBUG_ASSERT(str != &ascii_buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment