mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
14810ff1d3
Cleaned up test; Removed wrong DROP TABLE commands and use standard table and database names. changed store_warning() -> push_warning_print() BitKeeper/deleted/.del-rpl000016-slave.opt~ef76f85ddcc13b87: Delete: mysql-test/t/rpl000016-slave.opt BitKeeper/deleted/.del-sel000001.test~9567c1646058cc: Delete: mysql-test/t/sel000001.test BitKeeper/deleted/.del-sel000002.test~9f500639572e18e1: Delete: mysql-test/t/sel000002.test BitKeeper/deleted/.del-sel000003.test~63a5512d18cd20a2: Delete: mysql-test/t/sel000003.test BitKeeper/deleted/.del-sel000001.result~383913ae4505ec86: Delete: mysql-test/r/sel000001.result BitKeeper/deleted/.del-sel000002.result~d1787e6fd5dbc1cc: Delete: mysql-test/r/sel000002.result BitKeeper/deleted/.del-sel000003.result~d7b657b1e3a286a7: Delete: mysql-test/r/sel000003.result BitKeeper/deleted/.del-sel000031.result~d49aeac63ad7db4d: Delete: mysql-test/r/sel000031.result BitKeeper/deleted/.del-sel000031.test~50a19a8e204e99bc: Delete: mysql-test/t/sel000031.test BitKeeper/deleted/.del-sel000032.result~6cb30e23cbca9fb0: Delete: mysql-test/r/sel000032.result BitKeeper/deleted/.del-sel000032.test~e32da7c3fc4b7ace: Delete: mysql-test/t/sel000032.test BitKeeper/deleted/.del-rpl000003.result~68d6ee00beaa011: Delete: mysql-test/r/rpl000003.result BitKeeper/deleted/.del-rpl000003.test~b7cfc4c5576fbafd: Delete: mysql-test/t/rpl000003.test client/mysql.cc: Don't yet print information about SQL help client/mysqltest.c: Added test options: --enable_warnings --disable_warnings --enable_info --disable_info configure.in: changed version number of shared libraries mysql-test/include/master-slave.inc: Don't write warnings on init mysql-test/r/backup.result: Updated results mysql-test/r/bdb.result: Updated results mysql-test/r/bigint.result: Updated results mysql-test/r/bool.result: Updated results mysql-test/r/create.result: Updated results mysql-test/r/delete.result: Updated results mysql-test/r/derived.result: Updated results mysql-test/r/distinct.result: Updated results mysql-test/r/drop.result: Updated results mysql-test/r/flush.result: Updated results mysql-test/r/fulltext.result: Updated results mysql-test/r/fulltext_multi.result: Updated results mysql-test/r/fulltext_order_by.result: Updated results mysql-test/r/func_equal.result: Updated results mysql-test/r/func_in.result: Updated results mysql-test/r/func_set.result: Updated results mysql-test/r/gcc296.result: Updated results mysql-test/r/group_by.result: Updated results mysql-test/r/innodb-deadlock.result: Updated results mysql-test/r/innodb.result: Updated results mysql-test/r/innodb_cache.result: Updated results mysql-test/r/innodb_handler.result: Updated results mysql-test/r/insert.result: Updated results mysql-test/r/insert_select.result: Updated results mysql-test/r/isam.result: Updated results mysql-test/r/join_outer.result: Updated results mysql-test/r/key.result: Updated results mysql-test/r/merge.result: Updated results mysql-test/r/multi_update.result: Updated results mysql-test/r/myisam.result: Updated results mysql-test/r/null.result: Updated results mysql-test/r/null_key.result: Updated results mysql-test/r/odbc.result: Updated results mysql-test/r/olap.result: Updated results mysql-test/r/order_by.result: Updated results mysql-test/r/query_cache.result: Updated results mysql-test/r/rename.result: Updated results mysql-test/r/row.result: Updated results mysql-test/r/rpl000001.result: Updated results mysql-test/r/rpl000002.result: Updated results mysql-test/r/rpl000004.result: Updated results mysql-test/r/rpl000005.result: Updated results mysql-test/r/rpl000006.result: Updated results mysql-test/r/rpl000008.result: Updated results mysql-test/r/rpl000009.result: Updated results mysql-test/r/rpl000010.result: Updated results mysql-test/r/rpl000011.result: Updated results mysql-test/r/rpl000012.result: Updated results mysql-test/r/rpl000013.result: Updated results mysql-test/r/rpl_alter.result: Updated results mysql-test/r/rpl_empty_master_crash.result: Updated results mysql-test/r/rpl_redirect.result: Updated results mysql-test/r/rpl_replicate_do.result: Updated results mysql-test/r/rpl_rotate_logs.result: Updated results mysql-test/r/rpl_skip_error.result: Updated results mysql-test/r/rpl_temporary.result: Updated results mysql-test/r/select.result: Updated results mysql-test/r/subselect.result: Updated results mysql-test/r/temp_table.result: Updated results mysql-test/r/type_date.result: Updated results mysql-test/r/type_float.result: Updated results mysql-test/r/union.result: Updated results mysql-test/r/update.result: Updated results mysql-test/r/user_var.result: Updated results mysql-test/r/varbinary.result: Updated results mysql-test/r/variables.result: Updated results mysql-test/r/warnings.result: Updated results mysql-test/t/alias.test: Don't write warnings when initializing test mysql-test/t/alter_table.test: Don't write warnings when initializing test mysql-test/t/analyse.test: Don't write warnings when initializing test mysql-test/t/auto_increment.test: Don't write warnings when initializing test mysql-test/t/backup.test: Don't write warnings when initializing test mysql-test/t/bdb-alter-table-1.test: Don't write warnings when initializing test mysql-test/t/bdb-crash.test: Don't write warnings when initializing test mysql-test/t/bdb-deadlock.test: Don't write warnings when initializing test mysql-test/t/bdb.test: Don't write warnings when initializing test cleaned up test mysql-test/t/bdb_cache.test: Don't write warnings when initializing test mysql-test/t/bench_count_distinct.test: Don't write warnings when initializing test mysql-test/t/bigint.test: Don't write warnings when initializing test mysql-test/t/binary.test: Don't write warnings when initializing test mysql-test/t/bool.test: Don't write warnings when initializing test Changed to use standard table names mysql-test/t/bulk_replace.test: Don't write warnings when initializing test mysql-test/t/case.test: Don't write warnings when initializing test mysql-test/t/check.test: Don't write warnings when initializing test mysql-test/t/compare.test: Don't write warnings when initializing test mysql-test/t/connect.test: Removed empty line mysql-test/t/constraints.test: Don't write warnings when initializing test mysql-test/t/count_distinct.test: Don't write warnings when initializing test mysql-test/t/count_distinct2.test: Don't write warnings when initializing test mysql-test/t/create.test: Don't write warnings when initializing test Cleaned up test mysql-test/t/ctype_latin1_de.test: Don't write warnings when initializing test mysql-test/t/ctype_many.test: Don't write warnings when initializing test mysql-test/t/delayed.test: Don't write warnings when initializing test mysql-test/t/delete.test: Don't write warnings when initializing test Cleaned up test mysql-test/t/derived.test: Don't write warnings when initializing test Cleaned up test mysql-test/t/dirty_close.test: Don't write warnings when initializing test mysql-test/t/distinct.test: Don't write warnings when initializing test Cleaned up test mysql-test/t/drop.test: Don't write warnings when initializing test mysql-test/t/empty_table.test: Don't write warnings when initializing test mysql-test/t/err000001.test: Don't write warnings when initializing test Cleaned up test mysql-test/t/explain.test: Don't write warnings when initializing test mysql-test/t/flush.test: Don't write warnings when initializing test mysql-test/t/foreign_key.test: Don't write warnings when initializing test mysql-test/t/fulltext.test: Don't write warnings when initializing test mysql-test/t/fulltext_cache.test: Don't write warnings when initializing test mysql-test/t/fulltext_distinct.test: Don't write warnings when initializing test mysql-test/t/fulltext_left_join.test: Don't write warnings when initializing test mysql-test/t/fulltext_multi.test: Don't write warnings when initializing test mysql-test/t/fulltext_order_by.test: Don't write warnings when initializing test mysql-test/t/fulltext_update.test: Don't write warnings when initializing test mysql-test/t/func_concat.test: Don't write warnings when initializing test mysql-test/t/func_date_add.test: Don't write warnings when initializing test mysql-test/t/func_encrypt.test: Don't write warnings when initializing test mysql-test/t/func_equal.test: Don't write warnings when initializing test mysql-test/t/func_group.test: Don't write warnings when initializing test mysql-test/t/func_if.test: Don't write warnings when initializing test mysql-test/t/func_in.test: Don't write warnings when initializing test mysql-test/t/func_isnull.test: Don't write warnings when initializing test mysql-test/t/func_like.test: Don't write warnings when initializing test mysql-test/t/func_regexp.test: Don't write warnings when initializing test mysql-test/t/func_set.test: Don't write warnings when initializing test Merged test with other tests mysql-test/t/func_str.test: Don't write warnings when initializing test mysql-test/t/func_time.test: Don't write warnings when initializing test mysql-test/t/func_timestamp.test: Don't write warnings when initializing test mysql-test/t/gcc296.test: Don't write warnings when initializing test Cleaned up test mysql-test/t/grant_cache.test: Don't write warnings when initializing test mysql-test/t/group_by.test: Don't write warnings when initializing test Cleaned up test mysql-test/t/handler.test: Don't write warnings when initializing test mysql-test/t/having.test: Don't write warnings when initializing test mysql-test/t/heap.test: Don't write warnings when initializing test mysql-test/t/heap_auto_increment.test: Don't write warnings when initializing test mysql-test/t/heap_btree.test: Don't write warnings when initializing test mysql-test/t/heap_hash.test: Don't write warnings when initializing test mysql-test/t/innodb-deadlock.test: Don't write warnings when initializing test mysql-test/t/innodb.test: Don't write warnings when initializing test mysql-test/t/innodb_cache.test: Don't write warnings when initializing test mysql-test/t/innodb_handler.test: Don't write warnings when initializing test mysql-test/t/ins000001.test: Don't write warnings when initializing test mysql-test/t/insert.test: Don't write warnings when initializing test cleaned up test. Changed to use standard database and table names mysql-test/t/insert_select.test: Don't write warnings when initializing test Changed to use standard table names mysql-test/t/insert_update.test: Don't write warnings when initializing test mysql-test/t/isam.test: Don't write warnings when initializing test cleaned up test mysql-test/t/join.test: Don't write warnings when initializing test mysql-test/t/join_crash.test: Don't write warnings when initializing test mysql-test/t/join_outer.test: Don't write warnings when initializing test mysql-test/t/key.test: Don't write warnings when initializing test mysql-test/t/key_diff.test: Don't write warnings when initializing test mysql-test/t/key_primary.test: Don't write warnings when initializing test mysql-test/t/keywords.test: Don't write warnings when initializing test mysql-test/t/kill.test: Don't write warnings when initializing test mysql-test/t/limit.test: Don't write warnings when initializing test mysql-test/t/lock.test: Don't write warnings when initializing test mysql-test/t/lock_multi.test: Don't write warnings when initializing test mysql-test/t/lowercase_table.test: Don't write warnings when initializing test mysql-test/t/merge.test: Don't write warnings when initializing test cleaned up test mysql-test/t/multi_update.test: Don't write warnings when initializing test mysql-test/t/myisam.test: Don't write warnings when initializing test mysql-test/t/null.test: Don't write warnings when initializing test mysql-test/t/null_key.test: Don't write warnings when initializing test mysql-test/t/odbc.test: Don't write warnings when initializing test mysql-test/t/olap.test: Don't write warnings when initializing test mysql-test/t/order_by.test: Don't write warnings when initializing test mysql-test/t/order_fill_sortbuf.test: Don't write warnings when initializing test mysql-test/t/query_cache.test: Don't write warnings when initializing test mysql-test/t/raid.test: Don't write warnings when initializing test mysql-test/t/range.test: Don't write warnings when initializing test mysql-test/t/rename.test: Don't write warnings when initializing test mysql-test/t/repair.test: Don't write warnings when initializing test mysql-test/t/replace.test: Don't write warnings when initializing test mysql-test/t/rollback.test: Don't write warnings when initializing test mysql-test/t/row.test: Don't write warnings when initializing test mysql-test/t/rpl000001.test: Don't write warnings when initializing test mysql-test/t/rpl000002.test: Don't write warnings when initializing test mysql-test/t/rpl000004.test: Don't write warnings when initializing test mysql-test/t/rpl000005.test: Don't write warnings when initializing test mysql-test/t/rpl000006.test: Don't write warnings when initializing test mysql-test/t/rpl000008-slave.opt: Don't write warnings when initializing test mysql-test/t/rpl000008.test: Don't write warnings when initializing test mysql-test/t/rpl000009-slave.opt: Don't write warnings when initializing test mysql-test/t/rpl000009.test: Don't write warnings when initializing test mysql-test/t/rpl000010.test: Don't write warnings when initializing test mysql-test/t/rpl000011.test: Don't write warnings when initializing test mysql-test/t/rpl000012.test: Don't write warnings when initializing test mysql-test/t/rpl000013.test: Don't write warnings when initializing test mysql-test/t/rpl000015.test: Don't write warnings when initializing test mysql-test/t/rpl000017.test: Don't write warnings when initializing test mysql-test/t/rpl000018.test: Don't write warnings when initializing test mysql-test/t/rpl_alter.test: Don't write warnings when initializing test mysql-test/t/rpl_empty_master_crash.test: Don't write warnings when initializing test mysql-test/t/rpl_redirect.test: Don't write warnings when initializing test mysql-test/t/rpl_replicate_do.test: Don't write warnings when initializing test mysql-test/t/rpl_rotate_logs.test: Don't write warnings when initializing test mysql-test/t/rpl_skip_error.test: Don't write warnings when initializing test mysql-test/t/rpl_temporary.test: Don't write warnings when initializing test mysql-test/t/sel000033.test: Don't write warnings when initializing test mysql-test/t/sel000100.test: Don't write warnings when initializing test mysql-test/t/select.test: Don't write warnings when initializing test mysql-test/t/select_found.test: Don't write warnings when initializing test mysql-test/t/select_safe.test: Don't write warnings when initializing test mysql-test/t/show_check.test: Don't write warnings when initializing test mysql-test/t/status.test: Don't write warnings when initializing test mysql-test/t/subselect.test: Don't write warnings when initializing test mysql-test/t/symlink.test: Don't write warnings when initializing test mysql-test/t/tablelock.test: Don't write warnings when initializing test mysql-test/t/temp_table.test: Don't write warnings when initializing test mysql-test/t/truncate.test: Don't write warnings when initializing test mysql-test/t/type_blob.test: Don't write warnings when initializing test mysql-test/t/type_date.test: Don't write warnings when initializing test mysql-test/t/type_datetime.test: Don't write warnings when initializing test mysql-test/t/type_decimal.test: Don't write warnings when initializing test mysql-test/t/type_enum.test: Don't write warnings when initializing test mysql-test/t/type_float.test: Don't write warnings when initializing test mysql-test/t/type_ranges.test: Don't write warnings when initializing test mysql-test/t/type_set.test: Don't write warnings when initializing test mysql-test/t/type_time.test: Don't write warnings when initializing test mysql-test/t/type_timestamp.test: Don't write warnings when initializing test mysql-test/t/type_uint.test: Don't write warnings when initializing test mysql-test/t/type_year.test: Don't write warnings when initializing test mysql-test/t/union.test: Don't write warnings when initializing test mysql-test/t/update.test: Don't write warnings when initializing test mysql-test/t/user_var.test: Don't write warnings when initializing test mysql-test/t/varbinary.test: Don't write warnings when initializing test mysql-test/t/variables.test: Don't write warnings when initializing test mysql-test/t/warnings.test: Don't write warnings when initializing test mysys/my_vsnprintf.c: Safety fix readline/terminal.c: Removed compiler warnings sql/ha_berkeley.cc: Indentation changes sql/mysql_priv.h: Change store_warning -> push_warning_printf sql/sql_db.cc: Change store_warning -> push_warning_printf sql/sql_error.cc: Change store_warning -> push_warning_printf sql/sql_table.cc: Change store_warning -> push_warning_printf
218 lines
12 KiB
Text
218 lines
12 KiB
Text
#
|
|
# time functions
|
|
#
|
|
--disable_warnings
|
|
drop table if exists t1,t2,t3;
|
|
--enable_warnings
|
|
|
|
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");
|
|
select period_add("9602",-12),period_diff(199505,"9404") ;
|
|
select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
|
|
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
|
|
select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
|
|
sec_to_time(time_to_sec("0:30:47")/6.21);
|
|
select sec_to_time(time_to_sec('-838:59:59'));
|
|
select now()-curdate()*1000000-curtime();
|
|
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
|
|
select strcmp(localtime(),concat(current_date()," ",current_time()));
|
|
select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
|
|
select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
|
|
select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"));
|
|
select dayofmonth("1997-01-02"),dayofmonth(19970323);
|
|
select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
|
|
select month("2001-02-00"),year("2001-00-00");
|
|
select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
|
|
select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
|
|
|
|
# Test of week and yearweek
|
|
select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
|
|
select week(19981231),week(19971231),week(19981231,1),week(19971231,1);
|
|
select week(19950101),week(19950101,1);
|
|
select yearweek('1981-12-31',1),yearweek('1982-01-01',1),yearweek('1982-12-31',1),yearweek('1983-01-01',1);
|
|
select yearweek('1987-01-01',1),yearweek('1987-01-01');
|
|
select week("2000-01-01",0) as '2000', week("2001-01-01",0) as '2001', week("2002-01-01",0) as '2002',week("2003-01-01",0) as '2003', week("2004-01-01",0) as '2004', week("2005-01-01",0) as '2005', week("2006-01-01",0) as '2006';
|
|
select week("2000-01-06",0) as '2000', week("2001-01-06",0) as '2001', week("2002-01-06",0) as '2002',week("2003-01-06",0) as '2003', week("2004-01-06",0) as '2004', week("2005-01-06",0) as '2005', week("2006-01-06",0) as '2006';
|
|
select week("2000-01-01",1) as '2000', week("2001-01-01",1) as '2001', week("2002-01-01",1) as '2002',week("2003-01-01",1) as '2003', week("2004-01-01",1) as '2004', week("2005-01-01",1) as '2005', week("2006-01-01",1) as '2006';
|
|
select week("2000-01-06",1) as '2000', week("2001-01-06",1) as '2001', week("2002-01-06",1) as '2002',week("2003-01-06",1) as '2003', week("2004-01-06",1) as '2004', week("2005-01-06",1) as '2005', week("2006-01-06",1) as '2006';
|
|
select yearweek("2000-01-01",0) as '2000', yearweek("2001-01-01",0) as '2001', yearweek("2002-01-01",0) as '2002',yearweek("2003-01-01",0) as '2003', yearweek("2004-01-01",0) as '2004', yearweek("2005-01-01",0) as '2005', yearweek("2006-01-01",0) as '2006';
|
|
select yearweek("2000-01-06",0) as '2000', yearweek("2001-01-06",0) as '2001', yearweek("2002-01-06",0) as '2002',yearweek("2003-01-06",0) as '2003', yearweek("2004-01-06",0) as '2004', yearweek("2005-01-06",0) as '2005', yearweek("2006-01-06",0) as '2006';
|
|
select yearweek("2000-01-01",1) as '2000', yearweek("2001-01-01",1) as '2001', yearweek("2002-01-01",1) as '2002',yearweek("2003-01-01",1) as '2003', yearweek("2004-01-01",1) as '2004', yearweek("2005-01-01",1) as '2005', yearweek("2006-01-01",1) as '2006';
|
|
select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', yearweek("2002-01-06",1) as '2002',yearweek("2003-01-06",1) as '2003', yearweek("2004-01-06",1) as '2004', yearweek("2005-01-06",1) as '2005', yearweek("2006-01-06",1) as '2006';
|
|
select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3);
|
|
select week(20001231,2),week(20001231,3);
|
|
|
|
select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
|
|
select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
|
|
|
|
select dayname("1962-03-03"),dayname("1962-03-03")+0;
|
|
select monthname("1972-03-04"),monthname("1972-03-04")+0;
|
|
select time_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
|
|
select time_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
|
|
select time_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
|
|
select time_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
|
|
select date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
|
|
select date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 1 DAY);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND);
|
|
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE);
|
|
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND);
|
|
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND);
|
|
select "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
|
|
select INTERVAL 1 DAY + "1997-12-31";
|
|
select "1998-01-01 00:00:00" - INTERVAL 1 SECOND;
|
|
|
|
select date_sub("1998-01-02",INTERVAL 31 DAY);
|
|
select date_add("1997-12-31",INTERVAL 1 SECOND);
|
|
select date_add("1997-12-31",INTERVAL 1 DAY);
|
|
select date_add(NULL,INTERVAL 100000 SECOND);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL NULL SECOND);
|
|
select date_add("1997-12-31 23:59:59",INTERVAL NULL MINUTE_SECOND);
|
|
select date_add("9999-12-31 23:59:59",INTERVAL 1 SECOND);
|
|
select date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND);
|
|
select date_add('1998-01-30',Interval 1 month);
|
|
select date_add('1998-01-30',Interval '2:1' year_month);
|
|
select date_add('1996-02-29',Interval '1' year);
|
|
select extract(YEAR FROM "1999-01-02 10:11:12");
|
|
select extract(YEAR_MONTH FROM "1999-01-02");
|
|
select extract(DAY FROM "1999-01-02");
|
|
select extract(DAY_HOUR FROM "1999-01-02 10:11:12");
|
|
select extract(DAY_MINUTE FROM "02 10:11:12");
|
|
select extract(DAY_SECOND FROM "225 10:11:12");
|
|
select extract(HOUR FROM "1999-01-02 10:11:12");
|
|
select extract(HOUR_MINUTE FROM "10:11:12");
|
|
select extract(HOUR_SECOND FROM "10:11:12");
|
|
select extract(MINUTE FROM "10:11:12");
|
|
select extract(MINUTE_SECOND FROM "10:11:12");
|
|
select extract(SECOND FROM "1999-01-02 10:11:12");
|
|
select extract(MONTH FROM "2001-02-00");
|
|
|
|
create table t1 (ctime varchar(20));
|
|
insert into t1 values ('2001-01-12 12:23:40');
|
|
select ctime, hour(ctime) from t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# Test bug with monthname() and NULL
|
|
#
|
|
|
|
create table t1 (id int);
|
|
create table t2 (id int, date date);
|
|
insert into t1 values (1);
|
|
insert into t2 values (1, "0000-00-00");
|
|
insert into t1 values (2);
|
|
insert into t2 values (2, "2000-01-01");
|
|
select monthname(date) from t1 inner join t2 on t1.id = t2.id;
|
|
select monthname(date) from t1 inner join t2 on t1.id = t2.id order by t1.id;
|
|
drop table t1,t2;
|
|
|
|
#
|
|
# Test bug with month() and year() on text fields with wrong information
|
|
|
|
CREATE TABLE t1 (updated text) TYPE=MyISAM;
|
|
INSERT INTO t1 VALUES ('');
|
|
SELECT month(updated) from t1;
|
|
SELECT year(updated) from t1;
|
|
drop table t1;
|
|
|
|
#
|
|
# Check that functions work identically on 0000-00-00 as a constant and on a
|
|
# column
|
|
#
|
|
|
|
create table t1 (d date, dt datetime, t timestamp, c char(10));
|
|
insert into t1 values ("0000-00-00", "0000-00-00", "0000-00-00", "0000-00-00");
|
|
select dayofyear("0000-00-00"),dayofyear(d),dayofyear(dt),dayofyear(t),dayofyear(c) from t1;
|
|
select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1;
|
|
select month("0000-00-00"),month(d),month(dt),month(t),month(c) from t1;
|
|
select quarter("0000-00-00"),quarter(d),quarter(dt),quarter(t),quarter(c) from t1;
|
|
select week("0000-00-00"),week(d),week(dt),week(t),week(c) from t1;
|
|
select year("0000-00-00"),year(d),year(dt),year(t),year(c) from t1;
|
|
select yearweek("0000-00-00"),yearweek(d),yearweek(dt),yearweek(t),yearweek(c) from t1;
|
|
select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t1;
|
|
select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1;
|
|
drop table t1;
|
|
|
|
|
|
#
|
|
# Test problem with TIMESTAMP and BETWEEN
|
|
#
|
|
|
|
CREATE TABLE t1 ( start datetime default NULL);
|
|
INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
|
|
CREATE TABLE t2 ( ctime1 timestamp(14) NOT NULL, ctime2 timestamp(14) NOT NULL);
|
|
INSERT INTO t2 VALUES (20021029165106,20021105164731);
|
|
CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
|
|
INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
|
|
|
|
# The following statement should be fixed to return a row in 4.1
|
|
select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
|
|
select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
|
|
select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
|
|
drop table t1,t2,t3;
|
|
|
|
#
|
|
# Test types from + INTERVAL
|
|
#
|
|
|
|
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
|
|
INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
|
|
SELECT * from t1;
|
|
select date_add("1997-12-31",INTERVAL 1 SECOND);
|
|
select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
|
|
|
|
select date_add(datetime, INTERVAL 1 SECOND) from t1;
|
|
select date_add(datetime, INTERVAL 1 YEAR) from t1;
|
|
|
|
select date_add(date,INTERVAL 1 SECOND) from t1;
|
|
select date_add(date,INTERVAL 1 MINUTE) from t1;
|
|
select date_add(date,INTERVAL 1 HOUR) from t1;
|
|
select date_add(date,INTERVAL 1 DAY) from t1;
|
|
select date_add(date,INTERVAL 1 MONTH) from t1;
|
|
select date_add(date,INTERVAL 1 YEAR) from t1;
|
|
select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1;
|
|
select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1;
|
|
select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1;
|
|
select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
|
|
select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
|
|
select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
|
|
select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
|
|
|
|
# The following is not as one would expect...
|
|
select date_add(time,INTERVAL 1 SECOND) from t1;
|
|
drop table t1;
|