mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 03:47:17 +02:00
Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
We should disable const subselect item evaluation because subselect transformation does not happen in view_prepare_mode and thus val_...() methods can not be called. mysql-test/r/ctype_ucs.result: test case mysql-test/r/view.result: test case mysql-test/t/ctype_ucs.test: test case mysql-test/t/view.test: test case sql/item.cc: disabled const subselect item evaluation in view prepare mode. sql/item_subselect.cc: added Item_subselect::safe_charset_converter which prevents const item evaluation in view prepare mode. sql/item_subselect.h: added Item_subselect::safe_charset_converter which prevents const item evaluation in view prepare mode.
This commit is contained in:
parent
01fb1c8938
commit
ba229d799a
7 changed files with 60 additions and 1 deletions
|
|
@ -1230,4 +1230,12 @@ SELECT HEX(DAYNAME(19700101));
|
||||||
HEX(DAYNAME(19700101))
|
HEX(DAYNAME(19700101))
|
||||||
0427043504420432043504400433
|
0427043504420432043504400433
|
||||||
SET character_set_connection=latin1;
|
SET character_set_connection=latin1;
|
||||||
|
#
|
||||||
|
# Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a CHAR(1) CHARSET ascii, b CHAR(1) CHARSET latin1);
|
||||||
|
CREATE VIEW v1 AS SELECT 1 from t1
|
||||||
|
WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
End of 5.0 tests
|
End of 5.0 tests
|
||||||
|
|
|
||||||
|
|
@ -3874,6 +3874,14 @@ CREATE VIEW v1 AS SELECT 1 FROM t1 WHERE
|
||||||
ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' )));
|
ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' )));
|
||||||
DROP VIEW v1;
|
DROP VIEW v1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a CHAR(1) CHARSET latin1, b CHAR(1) CHARSET utf8);
|
||||||
|
CREATE VIEW v1 AS SELECT 1 from t1
|
||||||
|
WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# -- End of 5.1 tests.
|
# -- End of 5.1 tests.
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -732,4 +732,13 @@ SELECT HEX(MONTHNAME(19700101));
|
||||||
SELECT HEX(DAYNAME(19700101));
|
SELECT HEX(DAYNAME(19700101));
|
||||||
SET character_set_connection=latin1;
|
SET character_set_connection=latin1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1 (a CHAR(1) CHARSET ascii, b CHAR(1) CHARSET latin1);
|
||||||
|
CREATE VIEW v1 AS SELECT 1 from t1
|
||||||
|
WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo End of 5.0 tests
|
--echo End of 5.0 tests
|
||||||
|
|
|
||||||
|
|
@ -3916,6 +3916,15 @@ ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' )));
|
||||||
DROP VIEW v1;
|
DROP VIEW v1;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug#52120 create view cause Assertion failed: 0, file .\item_subselect.cc, line 817
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1 (a CHAR(1) CHARSET latin1, b CHAR(1) CHARSET utf8);
|
||||||
|
CREATE VIEW v1 AS SELECT 1 from t1
|
||||||
|
WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # -----------------------------------------------------------------
|
--echo # -----------------------------------------------------------------
|
||||||
--echo # -- End of 5.1 tests.
|
--echo # -- End of 5.1 tests.
|
||||||
--echo # -----------------------------------------------------------------
|
--echo # -----------------------------------------------------------------
|
||||||
|
|
|
||||||
11
sql/item.cc
11
sql/item.cc
|
|
@ -1713,7 +1713,16 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname,
|
||||||
|
|
||||||
if (!(conv= (*arg)->safe_charset_converter(coll.collation)) &&
|
if (!(conv= (*arg)->safe_charset_converter(coll.collation)) &&
|
||||||
((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII))
|
((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII))
|
||||||
conv= new Item_func_conv_charset(*arg, coll.collation, 1);
|
{
|
||||||
|
/*
|
||||||
|
We should disable const subselect item evaluation because
|
||||||
|
subselect transformation does not happen in view_prepare_mode
|
||||||
|
and thus val_...() methods can not be called for const items.
|
||||||
|
*/
|
||||||
|
bool resolve_const= ((*arg)->type() == Item::SUBSELECT_ITEM &&
|
||||||
|
thd->lex->view_prepare_mode) ? FALSE : TRUE;
|
||||||
|
conv= new Item_func_conv_charset(*arg, coll.collation, resolve_const);
|
||||||
|
}
|
||||||
|
|
||||||
if (!conv)
|
if (!conv)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,21 @@ void Item_subselect::cleanup()
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
We cannot use generic Item::safe_charset_converter() because
|
||||||
|
Subselect transformation does not happen in view_prepare_mode
|
||||||
|
and thus we can not evaluate val_...() for const items.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Item *Item_subselect::safe_charset_converter(CHARSET_INFO *tocs)
|
||||||
|
{
|
||||||
|
Item_func_conv_charset *conv=
|
||||||
|
new Item_func_conv_charset(this, tocs, thd->lex->view_prepare_mode ? 0 : 1);
|
||||||
|
return conv->safe ? conv : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Item_singlerow_subselect::cleanup()
|
void Item_singlerow_subselect::cleanup()
|
||||||
{
|
{
|
||||||
DBUG_ENTER("Item_singlerow_subselect::cleanup");
|
DBUG_ENTER("Item_singlerow_subselect::cleanup");
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ public:
|
||||||
virtual void reset_value_registration() {}
|
virtual void reset_value_registration() {}
|
||||||
enum_parsing_place place() { return parsing_place; }
|
enum_parsing_place place() { return parsing_place; }
|
||||||
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
|
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
|
||||||
|
Item *safe_charset_converter(CHARSET_INFO *tocs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the SELECT_LEX structure associated with this Item.
|
Get the SELECT_LEX structure associated with this Item.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue