summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_time_hires.test
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-05-28 05:11:32 +0300
committerMichael Widenius <monty@askmonty.org>2011-05-28 05:11:32 +0300
commitf197991f4102ed8ac66b7b57071f24f1d3b86aea (patch)
treeb4590b80e7d50b664d8e6ff6a62978cb2402f0a6 /mysql-test/t/func_time_hires.test
parentde44b51e151a00a00d0e396dc57ced3682d24d78 (diff)
parent306ed65302e14f303fdc33cfa9d19016fb319440 (diff)
downloadmariadb-git-f197991f4102ed8ac66b7b57071f24f1d3b86aea.tar.gz
Merge with 5.1-microseconds
A lot of small fixes and new test cases. client/mysqlbinlog.cc: Cast removed client/mysqltest.cc: Added missing DBUG_RETURN include/my_pthread.h: set_timespec_time_nsec() now only takes one argument mysql-test/t/date_formats.test: Remove --disable_ps_protocl as now also ps supports microseconds mysys/my_uuid.c: Changed to use my_interval_timer() instead of my_getsystime() mysys/waiting_threads.c: Changed to use my_hrtime() sql/field.h: Added bool special_const_compare() for fields that may convert values before compare (like year) sql/field_conv.cc: Added test to get optimal copying of identical temporal values. sql/item.cc: Return that item_int is equal if it's positive, even if unsigned flag is different. Fixed Item_cache_str::save_in_field() to have identical null check as other similar functions Added proper NULL check to Item_cache_int::save_in_field() sql/item_cmpfunc.cc: Don't call convert_constant_item() if there is nothing that is worth converting. Simplified test when years should be converted sql/item_sum.cc: Mark cache values in Item_sum_hybrid as not constants to ensure they are not replaced by other cache values in compare_datetime() sql/item_timefunc.cc: Changed sec_to_time() to take a my_decimal argument to ensure we don't loose any sub seconds. Added Item_temporal_func::get_time() (This simplifies some things) sql/mysql_priv.h: Added Lazy_string_decimal() sql/mysqld.cc: Added my_decimal constants max_seconds_for_time_type, time_second_part_factor sql/table.cc: Changed expr_arena to be of type CONVENTIONAL_EXECUTION to ensure that we don't loose any items that are created by fix_fields() sql/tztime.cc: TIME_to_gmt_sec() now sets *in_dst_time_gap in case of errors This is needed to be able to detect if timestamp is 0 storage/maria/lockman.c: Changed from my_getsystime() to set_timespec_time_nsec() storage/maria/ma_loghandler.c: Changed from my_getsystime() to my_hrtime() storage/maria/ma_recovery.c: Changed from my_getsystime() to mmicrosecond_interval_timer() storage/maria/unittest/trnman-t.c: Changed from my_getsystime() to mmicrosecond_interval_timer() storage/xtradb/handler/ha_innodb.cc: Added support for new time,datetime and timestamp unittest/mysys/thr_template.c: my_getsystime() -> my_interval_timer() unittest/mysys/waiting_threads-t.c: my_getsystime() -> my_interval_timer()
Diffstat (limited to 'mysql-test/t/func_time_hires.test')
-rw-r--r--mysql-test/t/func_time_hires.test106
1 files changed, 106 insertions, 0 deletions
diff --git a/mysql-test/t/func_time_hires.test b/mysql-test/t/func_time_hires.test
new file mode 100644
index 00000000000..ae185aef0b7
--- /dev/null
+++ b/mysql-test/t/func_time_hires.test
@@ -0,0 +1,106 @@
+#
+# Test of timestamp with hires resolution;
+
+set time_zone='+03:00';
+set timestamp=unix_timestamp('2011-01-01 01:01:01.123456');
+
+--vertical_results
+select sec_to_time(12345), sec_to_time(12345.6789), sec_to_time(1234567e-2);
+select now(), curtime(0), utc_timestamp(1), utc_time(2), current_time(3),
+ current_timestamp(4), localtime(5), localtimestamp(6), time_to_sec('12:34:56'),
+ time_to_sec('12:34:56.789');
+select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890'));
+select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222));
+--horizontal_results
+--error ER_TOO_BIG_PRECISION
+select current_timestamp(7);
+--error ER_TOO_BIG_PRECISION
+select curtime(7);
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 select sec_to_time(12345), sec_to_time(12345.6789),
+ sec_to_time(1234567e-2), now(), curtime(0),
+ utc_timestamp(1), utc_time(2), current_time(3),
+ current_timestamp(4), localtime(5), localtimestamp(6),
+ time_to_sec(123456), time_to_sec('12:34:56.789');
+show create table t1;
+--query_vertical select * from t1
+drop table t1;
+
+--query_vertical select unix_timestamp('2011-01-01 01:01:01'), unix_timestamp('2011-01-01 01:01:01.123456'), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4)));
+--query_vertical select from_unixtime(unix_timestamp('2011/1/1 1:1:1')), from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4))));
+
+select sec_to_time(3020399.99999), sec_to_time(3020399.999999), sec_to_time(3020399.9999999);
+select sec_to_time(-3020399.99999), sec_to_time(-3020399.999999), sec_to_time(-3020399.9999999);
+select 20010101000203.000000004 + interval 1 day;
+select 20010101000203.00004 + interval 1 day;
+#
+# precision of expressions
+#
+set @a=cast('2011-01-02 12:13:14' as datetime);
+select @a + interval 1 minute;
+select @a + interval 10 microsecond;
+select @a + interval 10 microsecond + interval 999990 microsecond;
+
+#
+# CAST
+#
+set @a='2011-01-02 12:13:14.123456';
+create table t1 select CAST(@a AS DATETIME) as dauto,
+ CAST(@a AS DATETIME(0)) as d0,
+ CAST(@a AS DATETIME(1)) as d1,
+ CAST(@a AS DATETIME(2)) as d2,
+ CAST(@a AS DATETIME(3)) as d3,
+ CAST(@a AS DATETIME(4)) as d4,
+ CAST(@a AS DATETIME(5)) as d5,
+ CAST(@a AS DATETIME(6)) as d6,
+ CAST(@a AS TIME) as tauto,
+ CAST(@a AS TIME(0)) as t0,
+ CAST(@a AS TIME(1)) as t1,
+ CAST(@a AS TIME(2)) as t2,
+ CAST(@a AS TIME(3)) as t3,
+ CAST(@a AS TIME(4)) as t4,
+ CAST(@a AS TIME(5)) as t5,
+ CAST(@a AS TIME(6)) as t6;
+show create table t1;
+--query_vertical select * from t1
+drop table t1;
+
+--error ER_TOO_BIG_PRECISION
+select CAST(@a AS DATETIME(7));
+
+#
+# CONVERT_TZ
+#
+SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00');
+SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00');
+SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00');
+SELECT CONVERT_TZ(CAST('2010-10-10 10:10:10.123456' AS DATETIME(4)), '+00:00', '+03:00');
+
+#
+# Field::store_time()
+#
+create table t1 (a varchar(200));
+insert t1 values (now(6));
+select * from t1;
+drop table t1;
+
+#
+# lp:736358 Unexpected increased timestamp resolution with UNION
+#
+# timestamp(6) case is fixed:
+create table t1 (f1 timestamp(6));
+insert into t1 values ('2002-07-15 21:00:00');
+select time(f1) from t1;
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+alter table t1 modify f1 timestamp;
+select time(f1) from t1;
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+# but the effect cannot be eliminated completely:
+alter table t1 modify f1 varchar(100);
+select time(f1) from t1;
+select time(f1) from t1 union all select time(f1 + interval 1 second) from t1;
+drop table t1;