Commit ca948e33 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant

parent dbeffabc
...@@ -4944,5 +4944,23 @@ E05B ...@@ -4944,5 +4944,23 @@ E05B
DROP TABLE t1; DROP TABLE t1;
# Start of ctype_E05C.inc # Start of ctype_E05C.inc
# #
# MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
#
SET NAMES latin1;
CREATE TABLE t1 (a TEXT CHARACTER SET gbk);
INSERT INTO t1 VALUES (0xEE5D);
SELECT a<>0xEE5D AS a FROM t1;
a
0
CREATE VIEW v1 AS SELECT a<>0xEE5D AS a FROM t1;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` <> 0xee5d) AS `a` from `t1` latin1 latin1_swedish_ci
SELECT * FROM v1;
a
0
DROP VIEW v1;
DROP TABLE t1;
#
# End of 10.0 tests # End of 10.0 tests
# #
...@@ -7922,5 +7922,23 @@ SELECT _latin1 0x7E, _latin1 X'7E', _latin1 B'01111110'; ...@@ -7922,5 +7922,23 @@ SELECT _latin1 0x7E, _latin1 X'7E', _latin1 B'01111110';
_latin1 0x7E _latin1 X'7E' _latin1 B'01111110' _latin1 0x7E _latin1 X'7E' _latin1 B'01111110'
~ ~ ~ ~ ~ ~
# #
# MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
#
SET NAMES latin1;
CREATE TABLE t1 (a TEXT CHARACTER SET latin1);
INSERT INTO t1 VALUES (0xC0);
SELECT a<>0xEE5D AS a FROM t1;
a
1
CREATE VIEW v1 AS SELECT a<>0xC0 AS a FROM t1;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (`t1`.`a` <> 0xc0) AS `a` from `t1` latin1 latin1_swedish_ci
SELECT * FROM v1;
a
0
DROP VIEW v1;
DROP TABLE t1;
#
# End of 10.0 tests # End of 10.0 tests
# #
...@@ -199,6 +199,20 @@ let $ctype_unescape_combinations=selected; ...@@ -199,6 +199,20 @@ let $ctype_unescape_combinations=selected;
SET NAMES gbk; SET NAMES gbk;
--source include/ctype_E05C.inc --source include/ctype_E05C.inc
--echo #
--echo # MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
--echo #
SET NAMES latin1;
CREATE TABLE t1 (a TEXT CHARACTER SET gbk);
INSERT INTO t1 VALUES (0xEE5D);
SELECT a<>0xEE5D AS a FROM t1;
CREATE VIEW v1 AS SELECT a<>0xEE5D AS a FROM t1;
SHOW CREATE VIEW v1;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.0 tests --echo # End of 10.0 tests
......
...@@ -245,6 +245,22 @@ DROP TABLE t1; ...@@ -245,6 +245,22 @@ DROP TABLE t1;
--echo # --echo #
SELECT _latin1 0x7E, _latin1 X'7E', _latin1 B'01111110'; SELECT _latin1 0x7E, _latin1 X'7E', _latin1 B'01111110';
--echo #
--echo # MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
--echo #
SET NAMES latin1;
CREATE TABLE t1 (a TEXT CHARACTER SET latin1);
INSERT INTO t1 VALUES (0xC0);
SELECT a<>0xEE5D AS a FROM t1;
CREATE VIEW v1 AS SELECT a<>0xC0 AS a FROM t1;
SHOW CREATE VIEW v1;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.0 tests --echo # End of 10.0 tests
--echo # --echo #
...@@ -2162,6 +2162,9 @@ bool agg_item_collations_for_comparison(DTCollation &c, const char *fname, ...@@ -2162,6 +2162,9 @@ bool agg_item_collations_for_comparison(DTCollation &c, const char *fname,
bool agg_item_set_converter(DTCollation &coll, const char *fname, bool agg_item_set_converter(DTCollation &coll, const char *fname,
Item **args, uint nargs, uint flags, int item_sep) Item **args, uint nargs, uint flags, int item_sep)
{ {
THD *thd= current_thd;
if (thd->lex->is_ps_or_view_context_analysis())
return false;
Item **arg, *safe_args[2]= {NULL, NULL}; Item **arg, *safe_args[2]= {NULL, NULL};
/* /*
...@@ -2177,7 +2180,6 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname, ...@@ -2177,7 +2180,6 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname,
safe_args[1]= args[item_sep]; safe_args[1]= args[item_sep];
} }
THD *thd= current_thd;
bool res= FALSE; bool res= FALSE;
uint i; uint i;
......
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