5
5
drop table if exists t1,t2,t3;
8
# Set timezone to GMT-3, to make it possible to use "interval 3 hour"
9
set time_zone="+03:00";
11
8
select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
12
9
select period_add("9602",-12),period_diff(199505,"9404") ;
170
167
SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
171
168
SELECT "1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND;
172
SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND;SELECT "1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND;
173
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE;
174
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR;
176
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND;
177
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE;
178
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR;
169
SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND;
179
170
SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
450
441
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
453
# Bug #16327: problem with timestamp < 1970
456
set time_zone='-6:00';
457
create table t1(a timestamp);
458
insert into t1 values (19691231190001);
463
444
# Bug#16377 result of DATE/TIME functions were compared as strings which
464
445
# can lead to a wrong result.
465
446
# Now wrong dates should be compared only with CAST()
514
495
SELECT MAKETIME(-4294967296, 0, 0);
515
496
SELECT MAKETIME(0, 4294967296, 0);
516
497
SELECT MAKETIME(0, 0, 4294967296);
517
SELECT MAKETIME(CAST(-1 AS UNSIGNED), 0, 0);
519
499
# check if EXTRACT() handles out-of-range values correctly
520
500
SELECT EXTRACT(HOUR FROM '100000:02:03');
522
502
# check if we get proper warnings if both input string truncation
523
503
# and out-of-range value occur
524
504
CREATE TABLE t1(f1 TIME);
525
506
INSERT INTO t1 VALUES('916:00:00 a');
526
507
SELECT * FROM t1;
530
# Bug #20927: sec_to_time treats big as signed
532
# check if SEC_TO_TIME() handles BIGINT values correctly
533
SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
536
511
# 21913: DATE_FORMAT() Crashes mysql server if I use it through
537
512
# mysql-connector-j driver.
541
SET character_set_results = NULL;
542
515
SHOW VARIABLES LIKE 'character_set_results';
544
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
517
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32));
545
518
INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
547
520
SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
549
522
DROP TABLE testBug8868;
554
525
# Bug #31160: MAKETIME() crashes server when returning NULL in ORDER BY using
603
574
select time_format('100:00:00', '%H %k %h %I %l');
606
# Bug #12562: Make SYSDATE behave like it does in Oracle: always the current
607
# time, regardless of magic to make NOW() always the same for the
608
# entirety of a statement.
609
SET GLOBAL log_bin_trust_function_creators = 1;
611
create table t1 (a timestamp default '2005-05-05 01:01:01',
612
b timestamp default '2005-05-05 01:01:01');
614
drop function if exists t_slow_sysdate;
615
create function t_slow_sysdate() returns timestamp
622
insert into t1 set a = sysdate(), b = t_slow_sysdate();//
624
create trigger t_before before insert on t1
626
set new.b = t_slow_sysdate();
632
insert into t1 set a = sysdate();
634
select a != b from t1;
636
drop trigger t_before;
637
drop function t_slow_sysdate;
640
SET GLOBAL log_bin_trust_function_creators = 0;
642
create table t1 (a datetime, i int, b datetime);
643
insert into t1 select sysdate(), sleep(1), sysdate() from dual;
644
select a != b from t1;
648
create procedure t_sysdate()
650
select sysdate() into @a;
652
select sysdate() into @b;
658
drop procedure t_sysdate;
661
577
# Bug #13534: timestampdiff() returned incorrect results across leap years
663
579
select timestampdiff(month,'2004-09-11','2004-09-11');
746
658
SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SELECT 3020398 ) x GROUP BY 1;
749
# Bug#28875 Conversion between ASCII and LATIN1 charsets does not function
752
create table t1 (a varchar(15) character set ascii not null);
753
insert into t1 values ('070514-000000');
754
# Conversion of date_format() result to ASCII
755
# is safe with the default locale en_US
757
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
758
# Error for swe7: it is not ASCII compatible
761
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
763
# Conversion of date_format() result to ASCII
764
# is not safe with the non-default locale fr_FR
765
# because month and day names can have accented characters
766
set lc_time_names=fr_FR;
768
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
769
set lc_time_names=en_US;
773
661
# Bug#32180: DATE_ADD treats datetime numeric argument as DATE
774
662
# instead of DATETIME
793
681
# TIMESTAMPADD / TIMESTAMPDIFF, is a server error.
795
683
# mysqltest.c discards an expected 'deprecated' warning on prepare stage
796
--disable_ps_protocol
797
684
SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
798
685
SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
801
687
--error ER_PARSE_ERROR
802
688
SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND);