mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-31277 Wrong result on 2-nd execution of PS to select from view using derived
As a result of this bug the second execution of the prepared statement created for select from materialized view could return a wrong result set if - the specification of the view used a left join - an inner table the left join was a mergeable derived table - the derived table contained a constant column. The problem appeared because the flag 'maybe-null' of the wrapper Item_direct_view_ref constructed for the constant field of the mergeable derived table was not set to 'true' on the second execution of the prepared statement. The patch always sets this flag properly when calling the function Item_direct_view_ref::set_null_ref-table(). The latter is invoked in Item_direct_view_ref constructor if it is created for some reference of a constant column belonging to a mergeable derived table. Approved by Oleksandr Byelkin <sanja@mariadb.com>
This commit is contained in:
@ -2832,3 +2832,39 @@ SELECT d.*, SUM(p) FROM demo d;
|
||||
DROP VIEW v;
|
||||
|
||||
--echo # End of 10.4 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31277: 2-nd execution of PS to select from materialized view
|
||||
--echo # specified as left join whose inner table is mergeable
|
||||
--echo # derived containing a constant column
|
||||
--echo #
|
||||
|
||||
create table t1 (
|
||||
Election int(10) unsigned NOT NULL
|
||||
) engine=MyISAM;
|
||||
|
||||
insert into t1 (Election) values (1), (4);
|
||||
|
||||
create table t2 (
|
||||
VoteID int(10),
|
||||
ElectionID int(10),
|
||||
UserID int(10)
|
||||
);
|
||||
|
||||
insert into t2 (ElectionID, UserID) values (2, 30), (3, 30);
|
||||
create view v1 as select * from t1
|
||||
left join ( select 'Y' AS Voted, ElectionID from t2 ) AS T
|
||||
on T.ElectionID = t1.Election
|
||||
limit 9;
|
||||
|
||||
prepare stmt1 from "select * from v1";
|
||||
|
||||
execute stmt1;
|
||||
execute stmt1;
|
||||
|
||||
deallocate prepare stmt1;
|
||||
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
|
||||
--echo # End of 10.5 tests
|
||||
|
Reference in New Issue
Block a user