mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
Fixed LP bug #874035.
The function Item_direct_view_ref::fix_fields erroneously did not correct the value of the flag maybe_null when the view for which the item was being fixed happened to be an inner table of an outer join.
This commit is contained in:
parent
16942bc5ca
commit
2a3858d9d0
3 changed files with 52 additions and 1 deletions
|
@ -1764,4 +1764,27 @@ x
|
|||
set optimizer_switch= @save_optimizer_switch;
|
||||
DROP VIEW v3;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# Bug #874035: view as an inner table of a materialized derived
|
||||
#
|
||||
CREATE TABLE t2 (a int NOT NULL);
|
||||
INSERT INTO t2 VALUES (7), (4);
|
||||
CREATE TABLE t1 (b int NOT NULL);
|
||||
INSERT INTO t1 VALUES (5), (7);
|
||||
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
SET SESSION optimizer_switch='derived_merge=off';
|
||||
PREPARE st1 FROM
|
||||
'SELECT * FROM (SELECT * FROM t2 LEFT JOIN v1 ON t2.a = v1.b) AS t';
|
||||
EXECUTE st1;
|
||||
a b
|
||||
7 7
|
||||
4 NULL
|
||||
EXECUTE st1;
|
||||
a b
|
||||
7 7
|
||||
4 NULL
|
||||
DEALLOCATE PREPARE st1;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
SET SESSION optimizer_switch='derived_merge=on';
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
|
|
@ -1166,5 +1166,29 @@ set optimizer_switch= @save_optimizer_switch;
|
|||
DROP VIEW v3;
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # Bug #874035: view as an inner table of a materialized derived
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t2 (a int NOT NULL);
|
||||
INSERT INTO t2 VALUES (7), (4);
|
||||
|
||||
CREATE TABLE t1 (b int NOT NULL);
|
||||
INSERT INTO t1 VALUES (5), (7);
|
||||
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
|
||||
SET SESSION optimizer_switch='derived_merge=off';
|
||||
|
||||
PREPARE st1 FROM
|
||||
'SELECT * FROM (SELECT * FROM t2 LEFT JOIN v1 ON t2.a = v1.b) AS t';
|
||||
EXECUTE st1;
|
||||
EXECUTE st1;
|
||||
DEALLOCATE PREPARE st1;
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
SET SESSION optimizer_switch='derived_merge=on';
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
|
|
@ -7321,7 +7321,11 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference)
|
|||
((*ref)->fix_fields(thd, ref)))
|
||||
return TRUE;
|
||||
|
||||
return Item_direct_ref::fix_fields(thd, reference);
|
||||
if (Item_direct_ref::fix_fields(thd, reference))
|
||||
return TRUE;
|
||||
if (view->table && view->table->maybe_null)
|
||||
maybe_null= TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue