The problem seems to be with "ctype_common.inc" file when included with the following variables set
**************************************
SET @test_character_set= 'ucs2';
SET @test_collation= 'ucs2_general_ci';
-- source include/ctype_common.inc
**************************************
This include, although properly saves and restores all the session variables it uses, has one side effect. By changing the default database via "USE d1"/"USE test" this file implicitly changes "@@character_set_database" session variable.
This variable, in turn, affects how string literals without explicit "_xxx" prefix are interpreted with regards to character set associated with them.
Therefore, "SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'" from "ctype_ucs.test" will generate different files depending on whether "@@character_set_database" is set to "ucs2" or "latin1".
According to the comment from the same file, the author of the original commit expected the select statement to produce two zeros (which means that he wanted 'tmpp.txt' to be written in 'latin1' encoding)
******************************************************
--echo # should return 2 zeroes (as the value is truncated)
SELECT * FROM t1;
******************************************************
However, in the same commit we have different values recorded in "ctype_ucs.result"
******************************************************
# should return 2 zeroes (as the value is truncated)
SELECT * FROM t1;
a
0
1
******************************************************
The problem seems to be with "ctype_common.inc" file when included with the following variables set
******* ******* ******* ******* ******* *** _set= 'ucs2'; ctype_common. inc ******* ******* ******* ******* ***
SET @test_character
SET @test_collation= 'ucs2_general_ci';
-- source include/
*******
This include, although properly saves and restores all the session variables it uses, has one side effect. By changing the default database via "USE d1"/"USE test" this file implicitly changes "@@character_ set_database" session variable.
This variable, in turn, affects how string literals without explicit "_xxx" prefix are interpreted with regards to character set associated with them.
Therefore, "SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'" from "ctype_ucs.test" will generate different files depending on whether "@@character_ set_database" is set to "ucs2" or "latin1".
According to the comment from the same file, the author of the original commit expected the select statement to produce two zeros (which means that he wanted 'tmpp.txt' to be written in 'latin1' encoding) ******* ******* ******* ******* ******* ******* ***** ******* ******* ******* ******* ******* ******* *****
*******
--echo # should return 2 zeroes (as the value is truncated)
SELECT * FROM t1;
*******
However, in the same commit we have different values recorded in "ctype_ucs.result" ******* ******* ******* ******* ******* ******* ***** ******* ******* ******* ******* ******* ******* *****
*******
# should return 2 zeroes (as the value is truncated)
SELECT * FROM t1;
a
0
1
*******