mirror of
https://github.com/MariaDB/server.git
synced 2025-12-23 20:55:45 +01:00
Problem: Cursor protocol uses an intermediate server-side cursor to materialize the SELECT query's result set. If the current sql_mode does not allow INVALID_DATES, ZERO_DATES and ZERO_IN_DATES, such values present in base tables are set to '0000-00-00' in temp table used by cursor. Subsequent fetches from the server-side cursor, produce zero date in the result set. Fix: When creating the temp table used by server-side cursor, allow all values from the base table into temp table. Temporarily set the sql_mode allow all invalid dates and reset it as soon as temp table is created.
35 lines
753 B
Text
35 lines
753 B
Text
--echo #
|
|
--echo # MDEV-31516 : Cursor Protocol gives incorrect result with
|
|
--echo # sql_mode='ALLOW_INVALID_DATES'
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (col1 date);
|
|
|
|
set @@sql_mode='STRICT_ALL_TABLES,ALLOW_INVALID_DATES';
|
|
INSERT INTO t1 VALUES ('2004-2-30');
|
|
|
|
set @@sql_mode='ansi,traditional';
|
|
INSERT IGNORE INTO t1 VALUES('2004-02-29');
|
|
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
#---------------------------
|
|
|
|
CREATE TABLE t1 (col1 date);
|
|
|
|
set @@sql_mode='STRICT_ALL_TABLES';
|
|
INSERT INTO t1 VALUES('2004-0-31');
|
|
|
|
set @@sql_mode='STRICT_ALL_TABLES,NO_ZERO_DATE';
|
|
INSERT INTO t1 VALUES ('2004-0-30');
|
|
|
|
set @@sql_mode='ansi,traditional'; # implies NO_ZERO_DATE & NO_ZERO_IN_DATE
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
#----------------------------
|
|
|
|
--echo # End of 10.6 tests
|