mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #24778: Innodb: No result when using ORDER BY
This bug was intruduced by the fix for bug#17212 (in 4.1). It is not ok to call test_if_skip_sort_order since this function will alter the execution plan. By contract it is not ok to call test_if_skip_sort_order in this context. This bug appears only in the case when the optimizer has chosen an index for accessing a particular table but finds a covering index that enables it to skip ORDER BY. This happens in test_if_skip_sort_order.
This commit is contained in:
@ -414,3 +414,44 @@ a int(11) NO PRI
|
|||||||
b varchar(20) NO MUL
|
b varchar(20) NO MUL
|
||||||
c varchar(20) NO
|
c varchar(20) NO
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
a INTEGER auto_increment PRIMARY KEY,
|
||||||
|
b INTEGER NOT NULL,
|
||||||
|
c INTEGER NOT NULL,
|
||||||
|
d CHAR(64)
|
||||||
|
);
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
a INTEGER auto_increment PRIMARY KEY,
|
||||||
|
b INTEGER NOT NULL,
|
||||||
|
c SMALLINT NOT NULL,
|
||||||
|
d DATETIME NOT NULL,
|
||||||
|
e SMALLINT NOT NULL,
|
||||||
|
f INTEGER NOT NULL,
|
||||||
|
g INTEGER NOT NULL,
|
||||||
|
h SMALLINT NOT NULL,
|
||||||
|
i INTEGER NOT NULL,
|
||||||
|
j INTEGER NOT NULL,
|
||||||
|
UNIQUE INDEX (b),
|
||||||
|
INDEX (b, d, e, f, g, h, i, j, c),
|
||||||
|
INDEX (c)
|
||||||
|
);
|
||||||
|
INSERT INTO t2 VALUES
|
||||||
|
(NULL, 1, 254, '1000-01-01 00:00:00', 257, 0, 0, 0, 0, 0),
|
||||||
|
(NULL, 2, 1, '2004-11-30 12:00:00', 1, 0, 0, 0, 0, 0),
|
||||||
|
(NULL, 3, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -21600, 0),
|
||||||
|
(NULL, 4, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -10800, 0),
|
||||||
|
(NULL, 5, 1, '2004-11-30 12:00:00', 1, 0, 0, 5, -10800, 0),
|
||||||
|
(NULL, 6, 1, '2004-11-30 12:00:00', 102, 0, 0, 0, 0, 0),
|
||||||
|
(NULL, 7, 1, '2004-11-30 12:00:00', 105, 2, 0, 0, 0, 0),
|
||||||
|
(NULL, 8, 1, '2004-11-30 12:00:00', 105, 10, 0, 0, 0, 0);
|
||||||
|
INSERT INTO t1 (b, c, d) VALUES
|
||||||
|
(3388000, -553000, NULL),
|
||||||
|
(3388000, -553000, NULL);
|
||||||
|
SELECT *
|
||||||
|
FROM t2 c JOIN t1 pa ON c.b = pa.a
|
||||||
|
WHERE c.c = 1
|
||||||
|
ORDER BY c.b, c.d
|
||||||
|
;
|
||||||
|
a b c d e f g h i j a b c d
|
||||||
|
2 2 1 2004-11-30 12:00:00 1 0 0 0 0 0 2 3388000 -553000 NULL
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
@ -384,3 +384,51 @@ desc t1;
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
# End of 4.1 tests
|
# End of 4.1 tests
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #24778: Innodb: No result when using ORDER BY
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
a INTEGER auto_increment PRIMARY KEY,
|
||||||
|
b INTEGER NOT NULL,
|
||||||
|
c INTEGER NOT NULL,
|
||||||
|
d CHAR(64)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
a INTEGER auto_increment PRIMARY KEY,
|
||||||
|
b INTEGER NOT NULL,
|
||||||
|
c SMALLINT NOT NULL,
|
||||||
|
d DATETIME NOT NULL,
|
||||||
|
e SMALLINT NOT NULL,
|
||||||
|
f INTEGER NOT NULL,
|
||||||
|
g INTEGER NOT NULL,
|
||||||
|
h SMALLINT NOT NULL,
|
||||||
|
i INTEGER NOT NULL,
|
||||||
|
j INTEGER NOT NULL,
|
||||||
|
UNIQUE INDEX (b),
|
||||||
|
INDEX (b, d, e, f, g, h, i, j, c),
|
||||||
|
INDEX (c)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO t2 VALUES
|
||||||
|
(NULL, 1, 254, '1000-01-01 00:00:00', 257, 0, 0, 0, 0, 0),
|
||||||
|
(NULL, 2, 1, '2004-11-30 12:00:00', 1, 0, 0, 0, 0, 0),
|
||||||
|
(NULL, 3, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -21600, 0),
|
||||||
|
(NULL, 4, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -10800, 0),
|
||||||
|
(NULL, 5, 1, '2004-11-30 12:00:00', 1, 0, 0, 5, -10800, 0),
|
||||||
|
(NULL, 6, 1, '2004-11-30 12:00:00', 102, 0, 0, 0, 0, 0),
|
||||||
|
(NULL, 7, 1, '2004-11-30 12:00:00', 105, 2, 0, 0, 0, 0),
|
||||||
|
(NULL, 8, 1, '2004-11-30 12:00:00', 105, 10, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
INSERT INTO t1 (b, c, d) VALUES
|
||||||
|
(3388000, -553000, NULL),
|
||||||
|
(3388000, -553000, NULL);
|
||||||
|
|
||||||
|
SELECT *
|
||||||
|
FROM t2 c JOIN t1 pa ON c.b = pa.a
|
||||||
|
WHERE c.c = 1
|
||||||
|
ORDER BY c.b, c.d
|
||||||
|
;
|
||||||
|
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
@ -5982,10 +5982,7 @@ make_join_readinfo(JOIN *join, ulonglong options)
|
|||||||
*/
|
*/
|
||||||
if (!ordered_set &&
|
if (!ordered_set &&
|
||||||
(table == join->sort_by_table &&
|
(table == join->sort_by_table &&
|
||||||
(!join->order || join->skip_sort_order ||
|
(!join->order || join->skip_sort_order)) ||
|
||||||
test_if_skip_sort_order(tab, join->order, join->select_limit,
|
|
||||||
1))
|
|
||||||
) ||
|
|
||||||
(join->sort_by_table == (TABLE *) 1 && i != join->const_tables))
|
(join->sort_by_table == (TABLE *) 1 && i != join->const_tables))
|
||||||
ordered_set= 1;
|
ordered_set= 1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user