Details
Description
Table Elimination works wrong for the view. Ex:
(EDIT : Table Elimination doesn't have anything to do with this bug)
Test:
CREATE TABLE t1 ( |
PostID int(10) unsigned NOT NULL |
) DEFAULT CHARSET=utf8; |
|
INSERT INTO t1 (PostID) VALUES (1), (2); |
|
CREATE TABLE t2 ( |
VoteID int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
EntityID int(10) unsigned NOT NULL, |
UserID int(10) unsigned NOT NULL, |
UNIQUE KEY EntityID (EntityID,UserID) |
) DEFAULT CHARSET=utf8; |
|
INSERT INTO t2 (EntityID, UserID) VALUES (1, 30), (2, 30); |
|
CREATE VIEW v1 as SELECT t1.*, T.Voted as Voted |
FROM |
t1 LEFT JOIN ( |
SELECT 1 AS Voted, EntityID |
FROM t2 |
WHERE t2.UserID = '20' ) AS T |
ON T.EntityID = t1.PostID |
WHERE t1.PostID='1' |
LIMIT 1;
|
SELECT * FROM v1; |
|
DROP VIEW v1; |
DROP TABLE t1,t2; |
Actual result:
PostID Voted
|
1 1
|
Expected result:
PostID Voted
|
1 NULL |
Attachments
Issue Links
- causes
-
MDEV-31277 Wrong result on 2-nd execution of PS to select from view using derived
-
- Closed
-
- is part of
-
MDEV-27691 make working view-protocol
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Link |
This issue is part of |
Labels | view-protocol |
Assignee | Lena Startseva [ JIRAUSER50478 ] | Oleksandr Byelkin [ sanja ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Assignee | Oleksandr Byelkin [ sanja ] | Sergei Petrunia [ psergey ] |
Assignee | Sergei Petrunia [ psergey ] | Rex Johnston [ JIRAUSER52533 ] |
Fix Version/s | 10.11 [ 27614 ] | |
Fix Version/s | 10.10 [ 27530 ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Summary | Table Elimination works wrong for the view | Wrong result with outer join, merged derived table and view |
Description |
Table Elimination works wrong for the view. Ex:
*Test:* {code:sql} CREATE TABLE t1 ( PostID int(10) unsigned NOT NULL ) DEFAULT CHARSET=utf8; INSERT INTO t1 (PostID) VALUES (1), (2); CREATE TABLE t2 ( VoteID int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, EntityID int(10) unsigned NOT NULL, UserID int(10) unsigned NOT NULL, UNIQUE KEY EntityID (EntityID,UserID) ) DEFAULT CHARSET=utf8; INSERT INTO t2 (EntityID, UserID) VALUES (1, 30), (2, 30); CREATE VIEW v1 as SELECT t1.*, T.Voted as Voted FROM t1 LEFT JOIN ( SELECT 1 AS Voted, EntityID FROM t2 WHERE t2.UserID = '20' ) AS T ON T.EntityID = t1.PostID WHERE t1.PostID='1' LIMIT 1; SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1,t2; {code} *Actual result:* {code:sql} PostID Voted 1 1 {code} *Expected result:* {code:sql} PostID Voted 1 NULL {code} |
Table Elimination works wrong for the view. Ex:
(*EDIT* : Table Elimination doesn't have anything to do with this bug) *Test:* {code:sql} CREATE TABLE t1 ( PostID int(10) unsigned NOT NULL ) DEFAULT CHARSET=utf8; INSERT INTO t1 (PostID) VALUES (1), (2); CREATE TABLE t2 ( VoteID int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, EntityID int(10) unsigned NOT NULL, UserID int(10) unsigned NOT NULL, UNIQUE KEY EntityID (EntityID,UserID) ) DEFAULT CHARSET=utf8; INSERT INTO t2 (EntityID, UserID) VALUES (1, 30), (2, 30); CREATE VIEW v1 as SELECT t1.*, T.Voted as Voted FROM t1 LEFT JOIN ( SELECT 1 AS Voted, EntityID FROM t2 WHERE t2.UserID = '20' ) AS T ON T.EntityID = t1.PostID WHERE t1.PostID='1' LIMIT 1; SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1,t2; {code} *Actual result:* {code:sql} PostID Voted 1 1 {code} *Expected result:* {code:sql} PostID Voted 1 NULL {code} |
Assignee | Rex Johnston [ JIRAUSER52533 ] | Sergei Petrunia [ psergey ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Assignee | Sergei Petrunia [ psergey ] | Oleksandr Byelkin [ sanja ] |
Status | Stalled [ 10000 ] | In Review [ 10002 ] |
Assignee | Oleksandr Byelkin [ sanja ] | Igor Babaev [ igor ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Assignee | Igor Babaev [ igor ] | Sergei Petrunia [ psergey ] |
Component/s | Optimizer [ 10200 ] | |
Fix Version/s | 10.3.38 [ 28507 ] | |
Fix Version/s | 10.4.28 [ 28509 ] | |
Fix Version/s | 10.5.19 [ 28511 ] | |
Fix Version/s | 10.6.12 [ 28513 ] | |
Fix Version/s | 10.7.8 [ 28515 ] | |
Fix Version/s | 10.8.7 [ 28517 ] | |
Fix Version/s | 10.9.5 [ 28519 ] | |
Fix Version/s | 10.10.3 [ 28521 ] | |
Fix Version/s | 10.11.2 [ 28523 ] | |
Fix Version/s | 10.11 [ 27614 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Link |
This issue relates to |
Link |
This issue relates to |
Link |
This issue causes |
Simplest egregious activation so far...
CREATE TABLE t1 (
Election int(10) unsigned NOT NULL
);
INSERT INTO t1 (Election) VALUES (1);
CREATE TABLE t2 (
VoteID int(10),
ElectionID int(10),
UserID int(10)
);
INSERT INTO t2 (ElectionID, UserID) VALUES (2, 30), (3, 30);
-- INSERT INTO t2 (ElectionID, UserID) VALUES (1, 30);
set @foo = "select * FROM t1
LEFT JOIN ( SELECT 'Y' AS Voted, ElectionID FROM t2 ) AS T
ON T.ElectionID = t1.Election
LIMIT 9";
-- limit needed for bug
prepare mq from @foo;
execute mq;
prepare mq from concat( "CREATE VIEW v1 as ", @foo );
execute mq;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1,t2;
Election Voted ElectionID
1 NULL NULL
Election Voted ElectionID
1 Y NULL