mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #42760: Select doesn't return desired results when we have null
values We should re-set the access method functions when changing the access method when switching to another index to avoid sorting. Fixed by doing a little re-engineering : encapsulating all the function assignment into a special function and calling it when flipping the indexes.
This commit is contained in:
@ -1092,3 +1092,24 @@ FROM t3;
|
||||
2
|
||||
NULL
|
||||
DROP TABLE t1, t2, t3;
|
||||
#
|
||||
# Bug #42760: Select doesn't return desired results when we have null
|
||||
# values
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
a INT,
|
||||
c INT,
|
||||
UNIQUE KEY a_c (a,c),
|
||||
KEY (a));
|
||||
INSERT INTO t1 VALUES (1, 10), (2, NULL);
|
||||
# Must use ref-or-null on the a_c index
|
||||
EXPLAIN
|
||||
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref_or_null a_c,a a_c 10 const,const 1 Using where
|
||||
# Must return 1 row
|
||||
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
|
||||
col
|
||||
1
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
|
@ -756,3 +756,29 @@ SELECT
|
||||
FROM t3;
|
||||
|
||||
DROP TABLE t1, t2, t3;
|
||||
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug #42760: Select doesn't return desired results when we have null
|
||||
--echo # values
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
a INT,
|
||||
c INT,
|
||||
UNIQUE KEY a_c (a,c),
|
||||
KEY (a));
|
||||
|
||||
INSERT INTO t1 VALUES (1, 10), (2, NULL);
|
||||
|
||||
--echo # Must use ref-or-null on the a_c index
|
||||
EXPLAIN
|
||||
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
|
||||
--echo # Must return 1 row
|
||||
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
Reference in New Issue
Block a user