mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#48294 assertion when creating a view based on some row() construct in select query
In case of 'CREATE VIEW' subselect transformation does not happen(see JOIN::prepare). During fix_fields Item_row may call is_null() method for its arugmens which leads to item calculation(wrong subselect in our case as transformation did not happen before). This is_null() call does not make sence for 'CREATE VIEW'. Note: Only Item_row is affected because other items don't call is_null() during fix_fields() for arguments. mysql-test/r/view.result: test case mysql-test/t/view.test: test case sql/item_row.cc: skip is_null() call in case of 'CREATE VIEW' as unnecessary.
This commit is contained in:
@ -3868,6 +3868,12 @@ Note 1599 View `test`.`v2` has no creation context
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1,t2;
|
||||
DROP FUNCTION f1;
|
||||
CREATE TABLE t1(f1 INT);
|
||||
INSERT INTO t1 VALUES ();
|
||||
CREATE VIEW v1 AS SELECT 1 FROM t1 WHERE
|
||||
ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' )));
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
# -----------------------------------------------------------------
|
||||
# -- End of 5.1 tests.
|
||||
# -----------------------------------------------------------------
|
||||
|
@ -3903,6 +3903,19 @@ DROP VIEW v1,v2;
|
||||
DROP TABLE t1,t2;
|
||||
DROP FUNCTION f1;
|
||||
|
||||
|
||||
#
|
||||
# Bug#48294 assertion when creating a view based on some row() construct in select query
|
||||
#
|
||||
CREATE TABLE t1(f1 INT);
|
||||
INSERT INTO t1 VALUES ();
|
||||
|
||||
CREATE VIEW v1 AS SELECT 1 FROM t1 WHERE
|
||||
ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' )));
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # -----------------------------------------------------------------
|
||||
--echo # -- End of 5.1 tests.
|
||||
--echo # -----------------------------------------------------------------
|
||||
|
@ -71,7 +71,12 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
|
||||
Item *item= *arg;
|
||||
used_tables_cache |= item->used_tables();
|
||||
const_item_cache&= item->const_item() && !with_null;
|
||||
if (const_item_cache)
|
||||
/*
|
||||
Some subqueries transformations aren't done in the view_prepare_mode thus
|
||||
is_null() will fail. So we skip is_null() calculation for CREATE VIEW as
|
||||
not necessary.
|
||||
*/
|
||||
if (const_item_cache && !thd->lex->view_prepare_mode)
|
||||
{
|
||||
if (item->cols() > 1)
|
||||
with_null|= item->null_inside();
|
||||
|
Reference in New Issue
Block a user