mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
MDEV-5369: Wrong result (0 instead of NULL) on 2nd execution of PS with LEFT JOIN, TEMPTABLE view
Set of JOIN_TYPE_OUTER made only once to avoid interference with optimization joins which made only once per query.
This commit is contained in:
@@ -3307,4 +3307,25 @@ c1
|
||||
NULL
|
||||
2
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# MDEV-5369: Wrong result (0 instead of NULL) on 2nd execution of
|
||||
# PS with LEFT JOIN, TEMPTABLE view
|
||||
#
|
||||
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (0),(8);
|
||||
CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=MyISAM;
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
|
||||
SELECT SUM(pk) FROM t1 LEFT JOIN v2 ON a = pk;
|
||||
SUM(pk)
|
||||
NULL
|
||||
PREPARE stmt FROM "SELECT SUM(pk) FROM t1 LEFT JOIN v2 ON a = pk";
|
||||
EXECUTE stmt;
|
||||
SUM(pk)
|
||||
NULL
|
||||
EXECUTE stmt;
|
||||
SUM(pk)
|
||||
NULL
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1, t2;
|
||||
# End of 5.3 tests
|
||||
|
||||
@@ -3330,4 +3330,27 @@ EXECUTE stmt;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-5369: Wrong result (0 instead of NULL) on 2nd execution of
|
||||
--echo # PS with LEFT JOIN, TEMPTABLE view
|
||||
--echo #
|
||||
|
||||
|
||||
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (0),(8);
|
||||
|
||||
CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=MyISAM;
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
|
||||
|
||||
SELECT SUM(pk) FROM t1 LEFT JOIN v2 ON a = pk;
|
||||
|
||||
PREPARE stmt FROM "SELECT SUM(pk) FROM t1 LEFT JOIN v2 ON a = pk";
|
||||
EXECUTE stmt;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo # End of 5.3 tests
|
||||
|
||||
@@ -627,7 +627,7 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
|
||||
if ((res= sl->handle_derived(lex, DT_PREPARE)))
|
||||
goto exit;
|
||||
|
||||
if (derived->outer_join)
|
||||
if (derived->outer_join && sl->first_cond_optimization)
|
||||
{
|
||||
/* Mark that table is part of OUTER JOIN and fields may be NULL */
|
||||
for (TABLE_LIST *cursor= (TABLE_LIST*) sl->table_list.first;
|
||||
|
||||
Reference in New Issue
Block a user