Skip to content

Commit 351a8ee

Browse files
committed
MDEV-32148 Inefficient WHERE timestamp_column=datetime_const_expr
Changing the way how a the following conditions are evaluated: WHERE timestamp_column=datetime_const_expr (for all comparison operators: =, <=>, <, >, <=, >=, <> and for NULLIF) Before the change it was always performed as DATETIME. That was not efficient, as involved per-row TIMESTAMP->DATETIME conversion for timestamp_column. For example, in case of the SYSTEM time zone it involved a localtime_r() call, which is known to be slow. After the change it's performed as TIMESTAMP in many cases. This allows to avoid per-row conversion, as it works the other way around: datetime_const_expr is converted to TIMESTAMP once before the execution stage. Note, datetime_const_expr must be inside monotone continuous periods of the current time zone, i.e. not near these anomalies: - DST changes (spring forward, fall back) - leap seconds
1 parent af4f9da commit 351a8ee

23 files changed

+1543
-24
lines changed

mysql-test/main/rowid_filter_innodb.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2917,7 +2917,7 @@ ORDER BY timestamp DESC;
29172917
id select_type table type possible_keys key key_len ref rows filtered Extra
29182918
1 SIMPLE t1 ALL ixEventWhoisDomainDomain,ixEventWhoisDomainTimestamp NULL NULL NULL 60 22.22 Using where; Using filesort
29192919
Warnings:
2920-
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`domain` AS `domain`,`test`.`t1`.`registrant_name` AS `registrant_name`,`test`.`t1`.`registrant_organization` AS `registrant_organization`,`test`.`t1`.`registrant_street1` AS `registrant_street1`,`test`.`t1`.`registrant_street2` AS `registrant_street2`,`test`.`t1`.`registrant_street3` AS `registrant_street3`,`test`.`t1`.`registrant_street4` AS `registrant_street4`,`test`.`t1`.`registrant_street5` AS `registrant_street5`,`test`.`t1`.`registrant_city` AS `registrant_city`,`test`.`t1`.`registrant_postal_code` AS `registrant_postal_code`,`test`.`t1`.`registrant_country` AS `registrant_country`,`test`.`t1`.`registrant_email` AS `registrant_email`,`test`.`t1`.`registrant_telephone` AS `registrant_telephone`,`test`.`t1`.`administrative_name` AS `administrative_name`,`test`.`t1`.`administrative_organization` AS `administrative_organization`,`test`.`t1`.`administrative_street1` AS `administrative_street1`,`test`.`t1`.`administrative_street2` AS `administrative_street2`,`test`.`t1`.`administrative_street3` AS `administrative_street3`,`test`.`t1`.`administrative_street4` AS `administrative_street4`,`test`.`t1`.`administrative_street5` AS `administrative_street5`,`test`.`t1`.`administrative_city` AS `administrative_city`,`test`.`t1`.`administrative_postal_code` AS `administrative_postal_code`,`test`.`t1`.`administrative_country` AS `administrative_country`,`test`.`t1`.`administrative_email` AS `administrative_email`,`test`.`t1`.`administrative_telephone` AS `administrative_telephone`,`test`.`t1`.`technical_name` AS `technical_name`,`test`.`t1`.`technical_organization` AS `technical_organization`,`test`.`t1`.`technical_street1` AS `technical_street1`,`test`.`t1`.`technical_street2` AS `technical_street2`,`test`.`t1`.`technical_street3` AS `technical_street3`,`test`.`t1`.`technical_street4` AS `technical_street4`,`test`.`t1`.`technical_street5` AS `technical_street5`,`test`.`t1`.`technical_city` AS `technical_city`,`test`.`t1`.`technical_postal_code` AS `technical_postal_code`,`test`.`t1`.`technical_country` AS `technical_country`,`test`.`t1`.`technical_email` AS `technical_email`,`test`.`t1`.`technical_telephone` AS `technical_telephone`,`test`.`t1`.`json` AS `json`,`test`.`t1`.`timestamp` AS `timestamp` from `test`.`t1` where `test`.`t1`.`domain` = 'www.mailhost.i-dev.fr' and `test`.`t1`.`timestamp` >= <cache>('2017-01-30 08:24:51' + interval -1 month) order by `test`.`t1`.`timestamp` desc
2920+
Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`domain` AS `domain`,`test`.`t1`.`registrant_name` AS `registrant_name`,`test`.`t1`.`registrant_organization` AS `registrant_organization`,`test`.`t1`.`registrant_street1` AS `registrant_street1`,`test`.`t1`.`registrant_street2` AS `registrant_street2`,`test`.`t1`.`registrant_street3` AS `registrant_street3`,`test`.`t1`.`registrant_street4` AS `registrant_street4`,`test`.`t1`.`registrant_street5` AS `registrant_street5`,`test`.`t1`.`registrant_city` AS `registrant_city`,`test`.`t1`.`registrant_postal_code` AS `registrant_postal_code`,`test`.`t1`.`registrant_country` AS `registrant_country`,`test`.`t1`.`registrant_email` AS `registrant_email`,`test`.`t1`.`registrant_telephone` AS `registrant_telephone`,`test`.`t1`.`administrative_name` AS `administrative_name`,`test`.`t1`.`administrative_organization` AS `administrative_organization`,`test`.`t1`.`administrative_street1` AS `administrative_street1`,`test`.`t1`.`administrative_street2` AS `administrative_street2`,`test`.`t1`.`administrative_street3` AS `administrative_street3`,`test`.`t1`.`administrative_street4` AS `administrative_street4`,`test`.`t1`.`administrative_street5` AS `administrative_street5`,`test`.`t1`.`administrative_city` AS `administrative_city`,`test`.`t1`.`administrative_postal_code` AS `administrative_postal_code`,`test`.`t1`.`administrative_country` AS `administrative_country`,`test`.`t1`.`administrative_email` AS `administrative_email`,`test`.`t1`.`administrative_telephone` AS `administrative_telephone`,`test`.`t1`.`technical_name` AS `technical_name`,`test`.`t1`.`technical_organization` AS `technical_organization`,`test`.`t1`.`technical_street1` AS `technical_street1`,`test`.`t1`.`technical_street2` AS `technical_street2`,`test`.`t1`.`technical_street3` AS `technical_street3`,`test`.`t1`.`technical_street4` AS `technical_street4`,`test`.`t1`.`technical_street5` AS `technical_street5`,`test`.`t1`.`technical_city` AS `technical_city`,`test`.`t1`.`technical_postal_code` AS `technical_postal_code`,`test`.`t1`.`technical_country` AS `technical_country`,`test`.`t1`.`technical_email` AS `technical_email`,`test`.`t1`.`technical_telephone` AS `technical_telephone`,`test`.`t1`.`json` AS `json`,`test`.`t1`.`timestamp` AS `timestamp` from `test`.`t1` where `test`.`t1`.`domain` = 'www.mailhost.i-dev.fr' and `test`.`t1`.`timestamp` >= TIMESTAMP/*WITH LOCAL TIME ZONE*/'2016-12-30 08:24:51' order by `test`.`t1`.`timestamp` desc
29212921
SET optimizer_switch=@save_optimizer_switch;
29222922
DROP TABLE t1;
29232923
#

mysql-test/main/timezone2.result

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,3 +678,188 @@ SELECT a, UNIX_TIMESTAMP(a) FROM t1 WHERE a >= ALL (SELECT * FROM t1);
678678
a UNIX_TIMESTAMP(a)
679679
2010-10-31 02:25:25 1288481125
680680
DROP TABLE t1;
681+
#
682+
# MDEV-32148 Inefficient WHERE timestamp_column=datetime_expr
683+
#
684+
#
685+
# Testing a DST change (fall back)
686+
#
687+
SET time_zone='Europe/Moscow';
688+
SET @first_second_after_dst_fall_back=1288479600;
689+
CREATE TABLE t1 (a TIMESTAMP NULL);
690+
INSERT INTO t1 VALUES ('2001-01-01 10:20:30'),('2001-01-01 10:20:31');
691+
#
692+
# Optimized (more than 24 hours before the DST fall back)
693+
#
694+
SET timestamp=@first_second_after_dst_fall_back-24*3600-1;
695+
SELECT UNIX_TIMESTAMP(), NOW();
696+
UNIX_TIMESTAMP() NOW()
697+
1288393199 2010-10-30 02:59:59
698+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
699+
id select_type table type possible_keys key key_len ref rows filtered Extra
700+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
701+
Warnings:
702+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2010-10-30 02:59:59'
703+
#
704+
# Not optimized (24 hours before the DST fall back)
705+
#
706+
SET timestamp=@first_second_after_dst_fall_back-24*3600;
707+
SELECT UNIX_TIMESTAMP(), NOW();
708+
UNIX_TIMESTAMP() NOW()
709+
1288393200 2010-10-30 03:00:00
710+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
711+
id select_type table type possible_keys key key_len ref rows filtered Extra
712+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
713+
Warnings:
714+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = <cache>(current_timestamp())
715+
#
716+
# Not optimized (less than 24 hours after the DST fall back)
717+
#
718+
SET timestamp=@first_second_after_dst_fall_back+24*3600-1;
719+
SELECT UNIX_TIMESTAMP(), NOW();
720+
UNIX_TIMESTAMP() NOW()
721+
1288565999 2010-11-01 01:59:59
722+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
723+
id select_type table type possible_keys key key_len ref rows filtered Extra
724+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
725+
Warnings:
726+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = <cache>(current_timestamp())
727+
#
728+
# Optimized (24 hours after the DST fall back)
729+
#
730+
SET timestamp=@first_second_after_dst_fall_back+24*3600;
731+
SELECT UNIX_TIMESTAMP(), NOW();
732+
UNIX_TIMESTAMP() NOW()
733+
1288566000 2010-11-01 02:00:00
734+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
735+
id select_type table type possible_keys key key_len ref rows filtered Extra
736+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
737+
Warnings:
738+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2010-11-01 02:00:00'
739+
DROP TABLE t1;
740+
SET time_zone=DEFAULT;
741+
#
742+
# Testing a DST change (spring forward)
743+
#
744+
SET time_zone='Europe/Moscow';
745+
SET @first_second_after_dst_spring_forward=1301180400;
746+
CREATE TABLE t1 (a TIMESTAMP NULL);
747+
INSERT INTO t1 VALUES ('2001-01-01 10:20:30'),('2001-01-01 10:20:31');
748+
#
749+
# Optimized (more than 24 hours before the DST sprint forward)
750+
#
751+
SET timestamp=@first_second_after_dst_spring_forward-24*3600-1;
752+
SELECT UNIX_TIMESTAMP(), NOW();
753+
UNIX_TIMESTAMP() NOW()
754+
1301093999 2011-03-26 01:59:59
755+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
756+
id select_type table type possible_keys key key_len ref rows filtered Extra
757+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
758+
Warnings:
759+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2011-03-26 01:59:59'
760+
#
761+
# Not optimized (24 hours before the DST sprint forward)
762+
#
763+
SET timestamp=@first_second_after_dst_spring_forward-24*3600;
764+
SELECT UNIX_TIMESTAMP(), NOW();
765+
UNIX_TIMESTAMP() NOW()
766+
1301094000 2011-03-26 02:00:00
767+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
768+
id select_type table type possible_keys key key_len ref rows filtered Extra
769+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
770+
Warnings:
771+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = <cache>(current_timestamp())
772+
#
773+
# Not optimized (less than 24 hours after the DST sprint forward)
774+
#
775+
SET timestamp=@first_second_after_dst_spring_forward+24*3600-1;
776+
SELECT UNIX_TIMESTAMP(), NOW();
777+
UNIX_TIMESTAMP() NOW()
778+
1301266799 2011-03-28 02:59:59
779+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
780+
id select_type table type possible_keys key key_len ref rows filtered Extra
781+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
782+
Warnings:
783+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = <cache>(current_timestamp())
784+
#
785+
# Optimized (24 hours after the DST sprint forward)
786+
#
787+
SET timestamp=@first_second_after_dst_spring_forward+24*3600;
788+
SELECT UNIX_TIMESTAMP(), NOW();
789+
UNIX_TIMESTAMP() NOW()
790+
1301266800 2011-03-28 03:00:00
791+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
792+
id select_type table type possible_keys key key_len ref rows filtered Extra
793+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
794+
Warnings:
795+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'2011-03-28 03:00:00'
796+
DROP TABLE t1;
797+
#
798+
# Testing a leap second
799+
#
800+
SET time_zone='leap/Europe/Moscow';
801+
SET @leap_second=362793609;
802+
/*The 60th leap second*/
803+
CREATE TABLE t1 (a TIMESTAMP);
804+
SET timestamp=@leap_second-1;
805+
INSERT INTO t1 VALUES (NOW());
806+
SET timestamp=@leap_second;
807+
INSERT INTO t1 VALUES (NOW());
808+
SET timestamp=@leap_second+1;
809+
INSERT INTO t1 VALUES (NOW());
810+
SELECT UNIX_TIMESTAMP(a), a FROM t1 ORDER BY UNIX_TIMESTAMP(a);
811+
UNIX_TIMESTAMP(a) a
812+
362793608 1981-07-01 03:59:59
813+
362793609 1981-07-01 03:59:59
814+
362793610 1981-07-01 04:00:00
815+
INSERT INTO t1 VALUES ('2001-01-01 10:20:30');
816+
#
817+
# Optimized (more than 24 hours before the leap second)
818+
#
819+
SET timestamp=@leap_second-24*3600-1;
820+
SELECT UNIX_TIMESTAMP(), NOW();
821+
UNIX_TIMESTAMP() NOW()
822+
362707208 1981-06-30 03:59:59
823+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
824+
id select_type table type possible_keys key key_len ref rows filtered Extra
825+
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
826+
Warnings:
827+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'1981-06-30 03:59:59'
828+
#
829+
# Not optimized (24 hours before the leap second)
830+
#
831+
SET timestamp=@leap_second-24*3600;
832+
SELECT UNIX_TIMESTAMP(), NOW();
833+
UNIX_TIMESTAMP() NOW()
834+
362707209 1981-06-30 04:00:00
835+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
836+
id select_type table type possible_keys key key_len ref rows filtered Extra
837+
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
838+
Warnings:
839+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = <cache>(current_timestamp())
840+
#
841+
# Not optimized (less than 24 hours after the leap second)
842+
#
843+
SET timestamp=@leap_second+24*3600-1;
844+
SELECT UNIX_TIMESTAMP(), NOW();
845+
UNIX_TIMESTAMP() NOW()
846+
362880008 1981-07-02 03:59:58
847+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
848+
id select_type table type possible_keys key key_len ref rows filtered Extra
849+
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
850+
Warnings:
851+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = <cache>(current_timestamp())
852+
#
853+
# Not optimized (24 hours after the leap second)
854+
#
855+
SET timestamp=@leap_second+24*3600;
856+
SELECT UNIX_TIMESTAMP(), NOW();
857+
UNIX_TIMESTAMP() NOW()
858+
362880009 1981-07-02 03:59:59
859+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
860+
id select_type table type possible_keys key key_len ref rows filtered Extra
861+
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
862+
Warnings:
863+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP/*WITH LOCAL TIME ZONE*/'1981-07-02 03:59:59'
864+
DROP TABLE t1;
865+
SET time_zone=DEFAULT;

mysql-test/main/timezone2.test

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,3 +630,155 @@ SELECT a, UNIX_TIMESTAMP(a) FROM t1 ORDER BY a;
630630
SELECT a, UNIX_TIMESTAMP(a) FROM t1 WHERE a <= ALL (SELECT * FROM t1);
631631
SELECT a, UNIX_TIMESTAMP(a) FROM t1 WHERE a >= ALL (SELECT * FROM t1);
632632
DROP TABLE t1;
633+
634+
635+
--echo #
636+
--echo # MDEV-32148 Inefficient WHERE timestamp_column=datetime_expr
637+
--echo #
638+
639+
--echo #
640+
--echo # Testing a DST change (fall back)
641+
--echo #
642+
643+
SET time_zone='Europe/Moscow';
644+
# '2010-10-31 02:59:59' (1288479599)
645+
# '2010-10-31 02:00:00' (1288479600)
646+
SET @first_second_after_dst_fall_back=1288479600;
647+
648+
CREATE TABLE t1 (a TIMESTAMP NULL);
649+
INSERT INTO t1 VALUES ('2001-01-01 10:20:30'),('2001-01-01 10:20:31');
650+
651+
--echo #
652+
--echo # Optimized (more than 24 hours before the DST fall back)
653+
--echo #
654+
655+
SET timestamp=@first_second_after_dst_fall_back-24*3600-1;
656+
SELECT UNIX_TIMESTAMP(), NOW();
657+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
658+
659+
--echo #
660+
--echo # Not optimized (24 hours before the DST fall back)
661+
--echo #
662+
663+
SET timestamp=@first_second_after_dst_fall_back-24*3600;
664+
SELECT UNIX_TIMESTAMP(), NOW();
665+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
666+
667+
--echo #
668+
--echo # Not optimized (less than 24 hours after the DST fall back)
669+
--echo #
670+
671+
SET timestamp=@first_second_after_dst_fall_back+24*3600-1;
672+
SELECT UNIX_TIMESTAMP(), NOW();
673+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
674+
675+
--echo #
676+
--echo # Optimized (24 hours after the DST fall back)
677+
--echo #
678+
679+
SET timestamp=@first_second_after_dst_fall_back+24*3600;
680+
SELECT UNIX_TIMESTAMP(), NOW();
681+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
682+
683+
DROP TABLE t1;
684+
SET time_zone=DEFAULT;
685+
686+
687+
--echo #
688+
--echo # Testing a DST change (spring forward)
689+
--echo #
690+
691+
SET time_zone='Europe/Moscow';
692+
# '2011-03-27 01:59:59' (1301180399)
693+
# '2011-03-27 03:00:00' (1301180400)
694+
SET @first_second_after_dst_spring_forward=1301180400;
695+
696+
CREATE TABLE t1 (a TIMESTAMP NULL);
697+
INSERT INTO t1 VALUES ('2001-01-01 10:20:30'),('2001-01-01 10:20:31');
698+
699+
--echo #
700+
--echo # Optimized (more than 24 hours before the DST sprint forward)
701+
--echo #
702+
703+
SET timestamp=@first_second_after_dst_spring_forward-24*3600-1;
704+
SELECT UNIX_TIMESTAMP(), NOW();
705+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
706+
707+
--echo #
708+
--echo # Not optimized (24 hours before the DST sprint forward)
709+
--echo #
710+
711+
SET timestamp=@first_second_after_dst_spring_forward-24*3600;
712+
SELECT UNIX_TIMESTAMP(), NOW();
713+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
714+
715+
--echo #
716+
--echo # Not optimized (less than 24 hours after the DST sprint forward)
717+
--echo #
718+
719+
SET timestamp=@first_second_after_dst_spring_forward+24*3600-1;
720+
SELECT UNIX_TIMESTAMP(), NOW();
721+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
722+
723+
--echo #
724+
--echo # Optimized (24 hours after the DST sprint forward)
725+
--echo #
726+
727+
SET timestamp=@first_second_after_dst_spring_forward+24*3600;
728+
SELECT UNIX_TIMESTAMP(), NOW();
729+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
730+
731+
DROP TABLE t1;
732+
733+
--echo #
734+
--echo # Testing a leap second
735+
--echo #
736+
737+
SET time_zone='leap/Europe/Moscow';
738+
SET @leap_second=362793609; /*The 60th leap second*/
739+
740+
CREATE TABLE t1 (a TIMESTAMP);
741+
SET timestamp=@leap_second-1;
742+
INSERT INTO t1 VALUES (NOW());
743+
SET timestamp=@leap_second;
744+
INSERT INTO t1 VALUES (NOW());
745+
SET timestamp=@leap_second+1;
746+
INSERT INTO t1 VALUES (NOW());
747+
SELECT UNIX_TIMESTAMP(a), a FROM t1 ORDER BY UNIX_TIMESTAMP(a);
748+
INSERT INTO t1 VALUES ('2001-01-01 10:20:30');
749+
750+
--echo #
751+
--echo # Optimized (more than 24 hours before the leap second)
752+
--echo #
753+
754+
SET timestamp=@leap_second-24*3600-1;
755+
SELECT UNIX_TIMESTAMP(), NOW();
756+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
757+
758+
--echo #
759+
--echo # Not optimized (24 hours before the leap second)
760+
--echo #
761+
762+
SET timestamp=@leap_second-24*3600;
763+
SELECT UNIX_TIMESTAMP(), NOW();
764+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
765+
766+
--echo #
767+
--echo # Not optimized (less than 24 hours after the leap second)
768+
--echo #
769+
770+
SET timestamp=@leap_second+24*3600-1;
771+
SELECT UNIX_TIMESTAMP(), NOW();
772+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
773+
774+
--echo #
775+
--echo # Not optimized (24 hours after the leap second)
776+
--echo #
777+
778+
SET timestamp=@leap_second+24*3600;
779+
SELECT UNIX_TIMESTAMP(), NOW();
780+
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=now();
781+
782+
DROP TABLE t1;
783+
784+
SET time_zone=DEFAULT;

0 commit comments

Comments
 (0)