MDEV-8642: WHERE Clause not applied on View - Empty result set returned
An attempt to mark reference as dependent lead to transfering this property to original view field and through it to other references of this field which can't be dependent.
This commit is contained in:
parent
8e36216a06
commit
57a699b0a0
@ -5907,6 +5907,43 @@ a
|
||||
2
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-8642: WHERE Clause not applied on View - Empty result set returned
|
||||
#
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(20) NOT NULL AUTO_INCREMENT,
|
||||
`use_case` int(11) DEFAULT NULL,
|
||||
`current_deadline` date DEFAULT NULL,
|
||||
`ts_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id_UNIQUE` (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=13976 DEFAULT CHARSET=latin1;
|
||||
INSERT INTO `t1` VALUES (1,10,'2015-12-18','2015-08-18 08:38:16');
|
||||
INSERT INTO `t1` VALUES (2,20,'2015-10-18','2015-08-18 08:43:30');
|
||||
CREATE VIEW v1 AS SELECT
|
||||
use_case as use_case_id,
|
||||
(
|
||||
SELECT
|
||||
deadline_sub.current_deadline
|
||||
FROM
|
||||
t1 deadline_sub
|
||||
WHERE
|
||||
deadline_sub.use_case = use_case_id
|
||||
AND ts_create = (SELECT
|
||||
MIN(ts_create)
|
||||
FROM
|
||||
t1 startdate_sub
|
||||
WHERE
|
||||
startdate_sub.use_case = use_case_id
|
||||
)
|
||||
) AS InitialDeadline
|
||||
FROM
|
||||
t1;
|
||||
SELECT * FROM v1 where use_case_id = 10;
|
||||
use_case_id InitialDeadline
|
||||
10 2015-12-18
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
# -----------------------------------------------------------------
|
||||
# -- End of 10.0 tests.
|
||||
# -----------------------------------------------------------------
|
||||
|
@ -5775,6 +5775,44 @@ DROP VIEW v1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-8642: WHERE Clause not applied on View - Empty result set returned
|
||||
--echo #
|
||||
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(20) NOT NULL AUTO_INCREMENT,
|
||||
`use_case` int(11) DEFAULT NULL,
|
||||
`current_deadline` date DEFAULT NULL,
|
||||
`ts_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id_UNIQUE` (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=13976 DEFAULT CHARSET=latin1;
|
||||
INSERT INTO `t1` VALUES (1,10,'2015-12-18','2015-08-18 08:38:16');
|
||||
INSERT INTO `t1` VALUES (2,20,'2015-10-18','2015-08-18 08:43:30');
|
||||
CREATE VIEW v1 AS SELECT
|
||||
use_case as use_case_id,
|
||||
(
|
||||
SELECT
|
||||
deadline_sub.current_deadline
|
||||
FROM
|
||||
t1 deadline_sub
|
||||
WHERE
|
||||
deadline_sub.use_case = use_case_id
|
||||
AND ts_create = (SELECT
|
||||
MIN(ts_create)
|
||||
FROM
|
||||
t1 startdate_sub
|
||||
WHERE
|
||||
startdate_sub.use_case = use_case_id
|
||||
)
|
||||
) AS InitialDeadline
|
||||
FROM
|
||||
t1;
|
||||
|
||||
SELECT * FROM v1 where use_case_id = 10;
|
||||
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
--echo # -----------------------------------------------------------------
|
||||
--echo # -- End of 10.0 tests.
|
||||
|
13
sql/item.cc
13
sql/item.cc
@ -7141,19 +7141,6 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
|
||||
last_checked_context->select_lex->nest_level);
|
||||
}
|
||||
}
|
||||
else if (ref_type() != VIEW_REF)
|
||||
{
|
||||
/*
|
||||
It could be that we're referring to something that's in ancestor selects.
|
||||
We must make an appropriate mark_as_dependent() call for each such
|
||||
outside reference.
|
||||
*/
|
||||
Dependency_marker dep_marker;
|
||||
dep_marker.current_select= current_sel;
|
||||
dep_marker.thd= thd;
|
||||
(*ref)->walk(&Item::enumerate_field_refs_processor, FALSE,
|
||||
(uchar*)&dep_marker);
|
||||
}
|
||||
|
||||
DBUG_ASSERT(*ref);
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user