mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug #31928: Search fails on '1000-00-00' date after sql_mode change
When constructing a key image stricter date checking (from sql_mode) should not be enabled, because it will reject invalid dates that the server would otherwise accept for searching when there's no index. Fixed by disabling strict date checking when constructing a key image. mysql-test/r/type_date.result: Bug #31928: test case mysql-test/t/type_date.test: Bug #31928: test case sql/sql_select.h: Bug #31928: Disable strict date checking when consructing a key image
This commit is contained in:
@ -202,7 +202,6 @@ a
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
SELECT * FROM t2 WHERE a = '0000-00-00';
|
||||
a
|
||||
0000-00-00
|
||||
@ -214,4 +213,42 @@ INSERT INTO t1 VALUES ('0000-00-00');
|
||||
ERROR 22007: Incorrect date value: '0000-00-00' for column 'a' at row 1
|
||||
SET SQL_MODE=DEFAULT;
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a DATE);
|
||||
CREATE TABLE t2 (a DATE);
|
||||
CREATE INDEX i ON t1 (a);
|
||||
INSERT INTO t1 VALUES ('1000-00-00'),('1000-00-00');
|
||||
INSERT INTO t2 VALUES ('1000-00-00'),('1000-00-00');
|
||||
SELECT * FROM t1 WHERE a = '1000-00-00';
|
||||
a
|
||||
1000-00-00
|
||||
1000-00-00
|
||||
SELECT * FROM t2 WHERE a = '1000-00-00';
|
||||
a
|
||||
1000-00-00
|
||||
1000-00-00
|
||||
SET SQL_MODE=TRADITIONAL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref i i 4 const 1 Using where; Using index
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
SELECT * FROM t1 WHERE a = '1000-00-00';
|
||||
a
|
||||
1000-00-00
|
||||
1000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
SELECT * FROM t2 WHERE a = '1000-00-00';
|
||||
a
|
||||
1000-00-00
|
||||
1000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
INSERT INTO t1 VALUES ('1000-00-00');
|
||||
ERROR 22007: Incorrect date value: '1000-00-00' for column 'a' at row 1
|
||||
SET SQL_MODE=DEFAULT;
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.0 tests
|
||||
|
@ -190,4 +190,24 @@ INSERT INTO t1 VALUES ('0000-00-00');
|
||||
SET SQL_MODE=DEFAULT;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug #31928: Search fails on '1000-00-00' date after sql_mode change
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a DATE);
|
||||
CREATE TABLE t2 (a DATE);
|
||||
CREATE INDEX i ON t1 (a);
|
||||
INSERT INTO t1 VALUES ('1000-00-00'),('1000-00-00');
|
||||
INSERT INTO t2 VALUES ('1000-00-00'),('1000-00-00');
|
||||
SELECT * FROM t1 WHERE a = '1000-00-00';
|
||||
SELECT * FROM t2 WHERE a = '1000-00-00';
|
||||
SET SQL_MODE=TRADITIONAL;
|
||||
EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
|
||||
SELECT * FROM t1 WHERE a = '1000-00-00';
|
||||
SELECT * FROM t2 WHERE a = '1000-00-00';
|
||||
--error ER_TRUNCATED_WRONG_VALUE
|
||||
INSERT INTO t1 VALUES ('1000-00-00');
|
||||
SET SQL_MODE=DEFAULT;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
Reference in New Issue
Block a user