Skip to content

Commit 02e35ef

Browse files
author
Alexander Barkov
committed
MDEV-12681 Wrong VIEW results for CHAR(0xDF USING latin1)
1 parent ea1739f commit 02e35ef

File tree

6 files changed

+75
-0
lines changed

6 files changed

+75
-0
lines changed

mysql-test/r/ctype_utf8.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10113,5 +10113,20 @@ DROP FUNCTION iswellformed;
1011310113
DROP TABLE allbytes;
1011410114
# End of ctype_backslash.inc
1011510115
#
10116+
# MDEV-12681 Wrong VIEW results for CHAR(0xDF USING latin1)
10117+
#
10118+
SET NAMES utf8;
10119+
SELECT CHAR(0xDF USING latin1);
10120+
CHAR(0xDF USING latin1)
10121+
ß
10122+
CREATE OR REPLACE VIEW v1 AS SELECT CHAR(0xDF USING latin1) AS c;
10123+
SHOW CREATE VIEW v1;
10124+
View Create View character_set_client collation_connection
10125+
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select char(0xdf using latin1) AS `c` utf8 utf8_general_ci
10126+
SELECT * FROM v1;
10127+
c
10128+
ß
10129+
DROP VIEW v1;
10130+
#
1011610131
# End of 10.0 tests
1011710132
#

mysql-test/r/func_str.result

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4530,3 +4530,24 @@ latin2_general_ci
45304530
#
45314531
# End of 5.6 tests
45324532
#
4533+
#
4534+
# Start of 10.0 tests
4535+
#
4536+
#
4537+
# MDEV-12681 Wrong VIEW results for CHAR(0xDF USING latin1)
4538+
#
4539+
EXPLAIN EXTENDED SELECT CHAR(0xDF USING latin1);
4540+
id select_type table type possible_keys key key_len ref rows filtered Extra
4541+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
4542+
Warnings:
4543+
Note 1003 select char(0xdf using latin1) AS `CHAR(0xDF USING latin1)`
4544+
EXPLAIN EXTENDED SELECT CHAR(0xDF USING `binary`);
4545+
id select_type table type possible_keys key key_len ref rows filtered Extra
4546+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
4547+
Warnings:
4548+
Note 1003 select char(0xdf) AS `CHAR(0xDF USING ``binary``)`
4549+
EXPLAIN EXTENDED SELECT CHAR(0xDF);
4550+
id select_type table type possible_keys key key_len ref rows filtered Extra
4551+
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
4552+
Warnings:
4553+
Note 1003 select char(0xdf) AS `CHAR(0xDF)`

mysql-test/t/ctype_utf8.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,18 @@ SELECT _utf8 0x7E, _utf8 X'7E', _utf8 B'01111110';
18681868
let $ctype_unescape_combinations=selected;
18691869
--source include/ctype_unescape.inc
18701870

1871+
--echo #
1872+
--echo # MDEV-12681 Wrong VIEW results for CHAR(0xDF USING latin1)
1873+
--echo #
1874+
1875+
SET NAMES utf8;
1876+
SELECT CHAR(0xDF USING latin1);
1877+
CREATE OR REPLACE VIEW v1 AS SELECT CHAR(0xDF USING latin1) AS c;
1878+
SHOW CREATE VIEW v1;
1879+
SELECT * FROM v1;
1880+
DROP VIEW v1;
1881+
1882+
18711883
--echo #
18721884
--echo # End of 10.0 tests
18731885
--echo #

mysql-test/t/func_str.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,3 +1742,15 @@ EXECUTE stmt;
17421742
--echo #
17431743
--echo # End of 5.6 tests
17441744
--echo #
1745+
1746+
--echo #
1747+
--echo # Start of 10.0 tests
1748+
--echo #
1749+
1750+
--echo #
1751+
--echo # MDEV-12681 Wrong VIEW results for CHAR(0xDF USING latin1)
1752+
--echo #
1753+
1754+
EXPLAIN EXTENDED SELECT CHAR(0xDF USING latin1);
1755+
EXPLAIN EXTENDED SELECT CHAR(0xDF USING `binary`);
1756+
EXPLAIN EXTENDED SELECT CHAR(0xDF);

sql/item_strfunc.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,6 +2905,20 @@ String *Item_func_make_set::val_str(String *str)
29052905
}
29062906

29072907

2908+
void Item_func_char::print(String *str, enum_query_type query_type)
2909+
{
2910+
str->append(Item_func_char::func_name());
2911+
str->append('(');
2912+
print_args(str, 0, query_type);
2913+
if (collation.collation != &my_charset_bin)
2914+
{
2915+
str->append(C_STRING_WITH_LEN(" using "));
2916+
str->append(collation.collation->csname);
2917+
}
2918+
str->append(')');
2919+
}
2920+
2921+
29082922
String *Item_func_char::val_str(String *str)
29092923
{
29102924
DBUG_ASSERT(fixed == 1);

sql/item_strfunc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ class Item_func_char :public Item_str_func
702702
max_length= arg_count * 4;
703703
}
704704
const char *func_name() const { return "char"; }
705+
void print(String *str, enum_query_type query_type);
705706
};
706707

707708

0 commit comments

Comments
 (0)