Wrong result with double ORDER BY
Bug #793589 reported by
Philip Stoev
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Oleksandr "Sanja" Byelkin |
Bug Description
Reproducible on maria-5.2, maria-5.3.
If a query containing a double ORDER BY is used in a VIEW, selecting from that view returns only some of the rows of the original query.
test case:
CREATE TABLE t1 ( f1 int NOT NULL , f10 int, f11 varchar(32), PRIMARY KEY (f1)) ;
INSERT IGNORE INTO t1 VALUES (6,0,'j'
CREATE TABLE t2 ( f11 int) ;
INSERT IGNORE INTO t2 VALUES (0),(0);
CREATE OR REPLACE VIEW v1 AS
SELECT alias2.f11 AS field1
FROM t2 STRAIGHT_JOIN
( t1 AS alias2
RIGHT JOIN t1 AS alias3 ON alias3.f10 = alias2.f10 )
ON alias3.f1 = alias2.f1
GROUP BY field1
ORDER BY alias3.f1 , alias2.f1 ;
SELECT * FROM v1;
should return 5 rows, returns only 1
Changed in maria: | |
milestone: | none → 5.2 |
Changed in maria: | |
assignee: | nobody → Oleksandr "Sanja" Byelkin (sanja-byelkin) |
Changed in maria: | |
status: | New → In Progress |
Changed in maria: | |
importance: | Undecided → High |
Changed in maria: | |
status: | In Progress → Confirmed |
Changed in maria: | |
status: | Confirmed → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Reproducible without views. Also reproducible with mysql-5.1 . So it is a legacy bug.
CREATE TABLE t1 ( b int) ;
INSERT INTO t1 VALUES (8),(9);
CREATE TABLE t2 ( a int, b int, PRIMARY KEY (a)) ; 7,7),(8, 1),(9,7) ,(10,1) ,(11,5) ,(12,2) ,(13,0) ,(14,1) ,(15,8) ,(16,1) ,(17,1) ,(18,9) ,(19,1) ,(20,5) ;
INSERT INTO t2 VALUES (6,7),(
SELECT t2.b AS field1 FROM t1, t2 WHERE t1.b = t2.a GROUP BY field1 ORDER BY t1.b, field1;
explain:
| 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 4 | Using where |
| 1 | SIMPLE | t2 | eq_ref | PRIMARY | PRIMARY | 4 | test.t1.b | 1 | |