Commit 1b5da2ca authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-10316 - main.type_date fails around midnight sporadically

A better fix for MySQL Bug#41776: use hard timestamp rather than unreliable
sleep.
parent 5cf49cdf
...@@ -165,6 +165,7 @@ str_to_date( '', a ) ...@@ -165,6 +165,7 @@ str_to_date( '', a )
NULL NULL
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b));
SET timestamp=UNIX_TIMESTAMP('2016-07-21 14:48:18');
INSERT INTO t1 VALUES (DATE(NOW()), 1); INSERT INTO t1 VALUES (DATE(NOW()), 1);
SELECT COUNT(*) FROM t1 WHERE a = NOW(); SELECT COUNT(*) FROM t1 WHERE a = NOW();
COUNT(*) COUNT(*)
...@@ -192,6 +193,7 @@ COUNT(*) ...@@ -192,6 +193,7 @@ COUNT(*)
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SET timestamp=DEFAULT;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a DATE); CREATE TABLE t1 (a DATE);
CREATE TABLE t2 (a DATE); CREATE TABLE t2 (a DATE);
......
...@@ -169,18 +169,8 @@ DROP TABLE t1; ...@@ -169,18 +169,8 @@ DROP TABLE t1;
# #
CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b)); CREATE TABLE t1 (a DATE, b INT, PRIMARY KEY (a,b));
## The current sub test could fail (difference to expected result) if we
## have just reached midnight. SET timestamp=UNIX_TIMESTAMP('2016-07-21 14:48:18');
## (Bug#41776 type_date.test may fail if run around midnight)
## Therefore we sleep a bit if we are too close to midnight.
## The complete test itself needs in average less than 1 second.
## Therefore a time_distance to midnight of 5 seconds should be sufficient.
if (`SELECT CURTIME() > SEC_TO_TIME(24 * 3600 - 5)`)
{
# We are here when CURTIME() is between '23:59:56' and '23:59:59'.
# So a sleep time of 5 seconds brings us between '00:00:01' and '00:00:04'.
--real_sleep 5
}
INSERT INTO t1 VALUES (DATE(NOW()), 1); INSERT INTO t1 VALUES (DATE(NOW()), 1);
SELECT COUNT(*) FROM t1 WHERE a = NOW(); SELECT COUNT(*) FROM t1 WHERE a = NOW();
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
...@@ -192,6 +182,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; ...@@ -192,6 +182,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1;
ALTER TABLE t1 DROP PRIMARY KEY; ALTER TABLE t1 DROP PRIMARY KEY;
SELECT COUNT(*) FROM t1 WHERE a = NOW(); SELECT COUNT(*) FROM t1 WHERE a = NOW();
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW();
SET timestamp=DEFAULT;
DROP TABLE t1; DROP TABLE t1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment