~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/func_time.test

  • Committer: Brian Aker
  • Date: 2008-07-06 15:03:34 UTC
  • Revision ID: brian@tangent.org-20080706150334-xv3xa202trvs0712
USE_RAID cleanup, along with ftbench tools.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
drop table if exists t1,t2,t3;
6
6
--enable_warnings
7
7
 
 
8
# Set timezone to GMT-3, to make it possible to use "interval 3 hour"
 
9
set time_zone="+03:00";
 
10
 
8
11
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");
9
12
select period_add("9602",-12),period_diff(199505,"9404") ;
10
13
 
166
169
#
167
170
SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
168
171
SELECT "1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND;
169
 
SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" 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;
 
175
 
 
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;
170
179
SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
171
180
 
172
181
#
288
297
 
289
298
#
290
299
# Check positive shift. (it happens only on
291
 
# platfroms with time_t, such as QNX)
 
300
# platfroms with unsigned time_t, such as QNX)
292
301
#
293
302
select unix_timestamp('1970-01-01 03:00:01');
294
303
 
441
450
       monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
442
451
 
443
452
#
 
453
# Bug #16327: problem with timestamp < 1970
 
454
#
 
455
 
 
456
set time_zone='-6:00';
 
457
create table t1(a timestamp);
 
458
insert into t1 values (19691231190001);
 
459
select * from t1;
 
460
drop table t1;
 
461
 
 
462
#
444
463
# Bug#16377 result of DATE/TIME functions were compared as strings which
445
464
#           can lead to a wrong result.
446
465
# Now wrong dates should be compared only with CAST()
495
514
SELECT MAKETIME(-4294967296, 0, 0);
496
515
SELECT MAKETIME(0, 4294967296, 0);
497
516
SELECT MAKETIME(0, 0, 4294967296);
 
517
SELECT MAKETIME(CAST(-1 AS UNSIGNED), 0, 0);
498
518
 
499
519
# check if EXTRACT() handles out-of-range values correctly
500
520
SELECT EXTRACT(HOUR FROM '100000:02:03');
502
522
# check if we get proper warnings if both input string truncation
503
523
# and out-of-range value occur
504
524
CREATE TABLE t1(f1 TIME);
505
 
--error 1292
506
525
INSERT INTO t1 VALUES('916:00:00 a');
507
526
SELECT * FROM t1;
508
527
DROP TABLE t1;
509
528
 
510
529
#
 
530
# Bug #20927: sec_to_time treats big unsigned as signed
 
531
#
 
532
# check if SEC_TO_TIME() handles BIGINT UNSIGNED values correctly
 
533
SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
 
534
 
 
535
#
511
536
# 21913: DATE_FORMAT() Crashes mysql server if I use it through
512
537
#        mysql-connector-j driver.
513
538
#
514
539
 
 
540
SET NAMES latin1;
 
541
SET character_set_results = NULL;
515
542
SHOW VARIABLES LIKE 'character_set_results';
516
543
 
517
 
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32));
 
544
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
518
545
INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
519
546
 
520
547
SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
521
548
 
522
549
DROP TABLE testBug8868;
523
550
 
 
551
SET NAMES DEFAULT;
 
552
 
524
553
#
525
554
# Bug #31160: MAKETIME() crashes server when returning NULL in ORDER BY using 
526
555
# filesort
574
603
select time_format('100:00:00', '%H %k %h %I %l');
575
604
 
576
605
#
 
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;
 
610
 
 
611
create table t1 (a timestamp default '2005-05-05 01:01:01',
 
612
                 b timestamp default '2005-05-05 01:01:01');
 
613
delimiter //;
 
614
drop function if exists t_slow_sysdate;
 
615
create function t_slow_sysdate() returns timestamp
 
616
begin
 
617
  do sleep(2);
 
618
  return sysdate();
 
619
end;
 
620
//
 
621
 
 
622
insert into t1 set a = sysdate(), b = t_slow_sysdate();//
 
623
 
 
624
create trigger t_before before insert on t1
 
625
for each row begin
 
626
  set new.b = t_slow_sysdate();
 
627
end
 
628
//
 
629
 
 
630
delimiter ;//
 
631
 
 
632
insert into t1 set a = sysdate();
 
633
 
 
634
select a != b from t1;
 
635
 
 
636
drop trigger t_before;
 
637
drop function t_slow_sysdate;
 
638
drop table t1;
 
639
 
 
640
SET GLOBAL log_bin_trust_function_creators = 0;
 
641
 
 
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;
 
645
drop table t1;
 
646
 
 
647
delimiter //;
 
648
create procedure t_sysdate()
 
649
begin
 
650
  select sysdate() into @a;
 
651
  do sleep(2);
 
652
  select sysdate() into @b;
 
653
  select @a != @b;
 
654
end;
 
655
//
 
656
delimiter ;//
 
657
call t_sysdate();
 
658
drop procedure t_sysdate;
 
659
 
 
660
#
577
661
# Bug #13534: timestampdiff() returned incorrect results across leap years
578
662
#
579
663
select timestampdiff(month,'2004-09-11','2004-09-11');
619
703
 
620
704
DROP TABLE t1,t2;
621
705
 
 
706
 
 
707
# Restore timezone to default
 
708
set time_zone= @@global.time_zone;
 
709
 
622
710
#
623
711
# Bug #22229: bug in DATE_ADD()
624
712
#
658
746
SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SELECT 3020398 ) x GROUP BY 1;
659
747
 
660
748
#
 
749
# Bug#28875 Conversion between ASCII and LATIN1 charsets does not function
 
750
#
 
751
set names latin1;
 
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
 
756
--replace_column 1 #
 
757
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
 
758
# Error for swe7: it is not ASCII compatible
 
759
set names swe7;
 
760
--error 1267
 
761
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
 
762
set names latin1;
 
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;
 
767
--error 1267
 
768
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
 
769
set lc_time_names=en_US;
 
770
drop table t1;
 
771
 
 
772
#
661
773
# Bug#32180: DATE_ADD treats datetime numeric argument as DATE
662
774
#            instead of DATETIME
663
775
#
681
793
# TIMESTAMPADD / TIMESTAMPDIFF, is a server error.
682
794
 
683
795
# mysqltest.c discards an expected 'deprecated' warning on prepare stage
 
796
--disable_ps_protocol
684
797
SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
685
798
SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
 
799
--enable_ps_protocol
686
800
 
687
801
--error ER_PARSE_ERROR
688
802
SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND);