mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol
Item_func_dyncol_create::print_arguments() printed only CHARSET clause without COLLATE. Therefore, HEX(column_create(1,'1212' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) inside a VIEW changed to just: HEX(column_create(1,'1212' AS CHAR CHARACTER SET utf8mb3)) which changed the collation ID seen in the HEX output. Note, the collation ID inside column_create() is not really much important. (It's only important what the character set is). And for COLLATE, the more important thing is what's later written in the AS clause of COLUMN_GET: SELECT COLUMN_GET( column_create(1,'1212' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin) column_nr AS type -- this type is more important ); Still, let's add the COLLATE clause into the COLUMN_CREATE() print output, although it's not important for now for anything else than just the HEX output. At least to make VIEW work in a more predictable way with HEX(COLUMN_CREATE()). Also, in the future we can start using somehow the collation ID written inside COLUMN_CREATE(), for example by making the `AS type` clause optional in COLUMN_GET(): COLUMN_GET(dyncol_blob, column_nr [AS type]); instead of: COLUMN_GET(dyncol_blob, column_nr AS type); SQL Server compatibility layer may need this for the SQL_Variant data type support.
This commit is contained in:
@ -1806,7 +1806,7 @@ show create table t1;
|
|||||||
Table Create Table
|
Table Create Table
|
||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`color` char(32) GENERATED ALWAYS AS (column_get(`dynamic_cols`,1 as char charset latin1)) STORED,
|
`color` char(32) GENERATED ALWAYS AS (column_get(`dynamic_cols`,1 as char charset latin1)) STORED,
|
||||||
`cl` char(32) GENERATED ALWAYS AS (column_get(column_add(column_create(1,'blue' AS char charset latin1 ),2,'ttt'),`i` as char charset latin1)) STORED,
|
`cl` char(32) GENERATED ALWAYS AS (column_get(column_add(column_create(1,'blue' AS char charset latin1 collate latin1_swedish_ci ),2,'ttt'),`i` as char charset latin1)) STORED,
|
||||||
`item_name` varchar(32) NOT NULL,
|
`item_name` varchar(32) NOT NULL,
|
||||||
`i` int(11) DEFAULT NULL,
|
`i` int(11) DEFAULT NULL,
|
||||||
`dynamic_cols` blob DEFAULT NULL,
|
`dynamic_cols` blob DEFAULT NULL,
|
||||||
|
@ -150,7 +150,7 @@ select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select hex(column_create(1,'afaf' AS char charset utf8 ,2,1212 AS unsigned int,3,1212 AS int,4,12.12 AS double,4 + 1,12.12 AS decimal,6,'2011-04-05' AS date,7,'- 0:45:49.000001' AS time,8,'2011-04-05 0:45:49.000001' AS datetime)) AS `ex`
|
Note 1003 select hex(column_create(1,'afaf' AS char charset utf8 collate utf8_general_ci ,2,1212 AS unsigned int,3,1212 AS int,4,12.12 AS double,4 + 1,12.12 AS decimal,6,'2011-04-05' AS date,7,'- 0:45:49.000001' AS time,8,'2011-04-05 0:45:49.000001' AS datetime)) AS `ex`
|
||||||
select hex(column_create(1, 0.0 AS decimal));
|
select hex(column_create(1, 0.0 AS decimal));
|
||||||
hex(column_create(1, 0.0 AS decimal))
|
hex(column_create(1, 0.0 AS decimal))
|
||||||
000100010004
|
000100010004
|
||||||
@ -354,7 +354,7 @@ select column_get(column_create(1, "1212" AS char charset utf8), 1 as char chars
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 ),1 as char charset utf8) AS `ex`
|
Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 collate utf8_general_ci ),1 as char charset utf8) AS `ex`
|
||||||
select column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8) as ex;
|
select column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8) as ex;
|
||||||
ex
|
ex
|
||||||
1212
|
1212
|
||||||
@ -414,7 +414,7 @@ select column_get(column_create(1, "1212" AS char charset utf8), 1 as char chars
|
|||||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||||
Warnings:
|
Warnings:
|
||||||
Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 ),1 as char charset binary) AS `ex`
|
Note 1003 select column_get(column_create(1,'1212' AS char charset utf8 collate utf8_general_ci ),1 as char charset binary) AS `ex`
|
||||||
#
|
#
|
||||||
# column get real
|
# column get real
|
||||||
#
|
#
|
||||||
@ -1882,7 +1882,7 @@ drop table t1;
|
|||||||
create view v1 as select column_get(column_add(column_create(1 , 'blue' as char), 2, 'ttt'), 1 as char);
|
create view v1 as select column_get(column_add(column_create(1 , 'blue' as char), 2, 'ttt'), 1 as char);
|
||||||
show create view v1;
|
show create view v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select column_get(column_add(column_create(1,'blue' AS char charset utf8 ),2,'ttt'),1 as char charset utf8) AS `Name_exp_1` utf8 utf8_general_ci
|
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select column_get(column_add(column_create(1,'blue' AS char charset utf8 collate utf8_general_ci ),2,'ttt'),1 as char charset utf8) AS `Name_exp_1` utf8 utf8_general_ci
|
||||||
select * from v1;
|
select * from v1;
|
||||||
Name_exp_1
|
Name_exp_1
|
||||||
blue
|
blue
|
||||||
@ -1949,3 +1949,23 @@ ex
|
|||||||
#
|
#
|
||||||
# End of 10.4 tests
|
# End of 10.4 tests
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# Start of 10.5 tests
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Start of 10.5 tests
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol
|
||||||
|
#
|
||||||
|
SELECT hex(column_create(1,'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) AS ex;
|
||||||
|
ex
|
||||||
|
0001000100035361
|
||||||
|
SELECT hex(column_add(column_create(
|
||||||
|
1, 'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin),
|
||||||
|
2, 'b' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci)) AS ex;
|
||||||
|
ex
|
||||||
|
00020001000302001353612162
|
||||||
|
#
|
||||||
|
# Start of 10.5 tests
|
||||||
|
#
|
||||||
|
@ -1000,3 +1000,24 @@ SELECT HEX(COLUMN_ADD(COLUMN_CREATE(1,10),2,NULL,1,NULL)) as ex;
|
|||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.4 tests
|
--echo # End of 10.4 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Start of 10.5 tests
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Start of 10.5 tests
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SELECT hex(column_create(1,'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) AS ex;
|
||||||
|
SELECT hex(column_add(column_create(
|
||||||
|
1, 'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin),
|
||||||
|
2, 'b' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci)) AS ex;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Start of 10.5 tests
|
||||||
|
--echo #
|
||||||
|
@ -4670,6 +4670,11 @@ void Item_func_dyncol_create::print_arguments(String *str,
|
|||||||
{
|
{
|
||||||
str->append(STRING_WITH_LEN(" charset "));
|
str->append(STRING_WITH_LEN(" charset "));
|
||||||
str->append(defs[i].cs->csname);
|
str->append(defs[i].cs->csname);
|
||||||
|
if (Charset(defs[i].cs).can_have_collate_clause())
|
||||||
|
{
|
||||||
|
str->append(STRING_WITH_LEN(" collate "));
|
||||||
|
str->append(defs[i].cs->name);
|
||||||
|
}
|
||||||
str->append(' ');
|
str->append(' ');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user