diff options
author | Michael Widenius <monty@askmonty.org> | 2011-05-28 05:11:32 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-05-28 05:11:32 +0300 |
commit | f197991f4102ed8ac66b7b57071f24f1d3b86aea (patch) | |
tree | b4590b80e7d50b664d8e6ff6a62978cb2402f0a6 /mysql-test/include | |
parent | de44b51e151a00a00d0e396dc57ced3682d24d78 (diff) | |
parent | 306ed65302e14f303fdc33cfa9d19016fb319440 (diff) | |
download | mariadb-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/include')
-rw-r--r-- | mysql-test/include/ps_conv.inc | 49 | ||||
-rw-r--r-- | mysql-test/include/type_hrtime.inc | 98 |
2 files changed, 128 insertions, 19 deletions
diff --git a/mysql-test/include/ps_conv.inc b/mysql-test/include/ps_conv.inc index 9ac943d5bdd..2e42542d19a 100644 --- a/mysql-test/include/ps_conv.inc +++ b/mysql-test/include/ps_conv.inc @@ -106,7 +106,7 @@ drop table t5 ; # c1 tinyint, c2 smallint, c3 mediumint, c4 int, # c5 integer, c6 bigint, c7 float, c8 double, # c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4), -# c13 date, c14 datetime, c15 timestamp(14), c16 time, +# c13 date, c14 datetime, c15 timestamp, c16 time, # c17 year, c18 tinyint, c19 bool, c20 char, # c21 char(10), c22 varchar(30), c23 tinyblob, c24 tinytext, # c25 blob, c26 text, c27 mediumblob, c28 mediumtext, @@ -672,7 +672,6 @@ select '-- insert into string columns --' as test_sequence ; --enable_query_log ######## INSERT into .. string columns values(CHAR(n),LONGTEXT) ######## ---disable_query_log insert into t9 ( c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 ) values @@ -860,8 +859,6 @@ values execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00 ; ---enable_query_log - ######## SELECT of all inserted records ######## select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 from t9 where c1 >= 20 @@ -980,14 +977,13 @@ delete from t9 ; ######################### test of date/time columns ######################## # # -# c13 date, c14 datetime, c15 timestamp(14), c16 time, c17 year # +# c13 date, c14 datetime, c15 timestamp, c16 time, c17 year # # # ############################################################################ --disable_query_log select '-- insert into date/time columns --' as test_sequence ; --enable_query_log ######## INSERT into .. date/time columns values(VARCHAR(19),LONGTEXT) ######## ---disable_query_log set @arg00= '1991-01-01 01:01:01' ; insert into t9 ( c1, c13, c14, c15, c16, c17 ) @@ -1143,12 +1139,9 @@ values ( 83, ?, ?, '1991-01-01 01:01:01', ?, ? )" ; execute stmt2 using @arg00, @arg00, @arg00, @arg00 ; ---enable_query_log - ######## SELECT of all inserted records ######## select c1, c13, c14, c15, c16, c17 from t9 order by c1 ; - --disable_query_log select '-- select .. where date/time column = .. --' as test_sequence ; --enable_query_log @@ -1156,19 +1149,19 @@ select '-- select .. where date/time column = .. --' as test_sequence ; set @arg00= '1991-01-01 01:01:01' ; select 'true' as found from t9 where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and - c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and + c15= '1991-01-01 01:01:01' and c17= '1991-01-01 01:01:01' ; select 'true' as found from t9 -where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00 +where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c17= @arg00 ; prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and - c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and + c15= '1991-01-01 01:01:01' and c17= '1991-01-01 01:01:01'" ; execute stmt1 ; prepare stmt1 from "select 'true' as found from t9 -where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ; -execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ; +where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ; +execute stmt1 using @arg00, @arg00, @arg00, @arg00 ; ######## SELECT .. WHERE column(date/time/..)=value(DATETIME/LONGBLOB) ######## @@ -1177,21 +1170,39 @@ select 'true' as found from t9 where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and c14= CAST('1991-01-01 01:01:01' as datetime) and c15= CAST('1991-01-01 01:01:01' as datetime) and - c16= CAST('1991-01-01 01:01:01' as datetime) and c17= CAST('1991-01-01 01:01:01' as datetime) ; select 'true' as found from t9 -where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00 +where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c17= @arg00 ; prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and c14= CAST('1991-01-01 01:01:01' as datetime) and c15= CAST('1991-01-01 01:01:01' as datetime) and - c16= CAST('1991-01-01 01:01:01' as datetime) and c17= CAST('1991-01-01 01:01:01' as datetime)" ; execute stmt1 ; prepare stmt1 from "select 'true' as found from t9 -where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ; -execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ; +where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c17= ?" ; +execute stmt1 using @arg00, @arg00, @arg00, @arg00 ; + + +######## SELECT .. WHERE column(date/time/..)=value(CHAR(n)/LONGTEXT) ######## +set @arg00= '01:01:01' ; +select 'true' as found from t9 where c1= 20 and c16= '01:01:01' ; +select 'true' as found from t9 where c1= 20 and c16= @arg00 ; +prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= '01:01:01'" ; +execute stmt1 ; +prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ; +execute stmt1 using @arg00 ; + + +######## SELECT .. WHERE column(date/time/..)=value(DATETIME/LONGBLOB) ######## +set @arg00= CAST('01:01:01' as time) ; +select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time) ; +select 'true' as found from t9 where c1= 20 and c16= @arg00 ; +prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= CAST('01:01:01' as time)" ; +execute stmt1 ; +prepare stmt1 from "select 'true' as found from t9 where c1= 20 and c16= ?" ; +execute stmt1 using @arg00 ; ######## SELECT .. WHERE column(year)=value(INT(10)/BIGINT) ######## diff --git a/mysql-test/include/type_hrtime.inc b/mysql-test/include/type_hrtime.inc new file mode 100644 index 00000000000..f9369d51658 --- /dev/null +++ b/mysql-test/include/type_hrtime.inc @@ -0,0 +1,98 @@ + +--source include/have_innodb.inc + +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings + +--error ER_TOO_BIG_PRECISION +eval create table t1 (a $type(7)); + +eval create table t1 (a $type(3), key(a)); +insert t1 values ('2010-12-11 00:20:03.1234'); +insert t1 values ('2010-12-11 15:47:11.1234'); +insert t1 values (20101211010203.45678); +insert t1 values (20101211030405.789e0); +insert t1 values (99991231235959e1); +select * from t1; +select truncate(a, 6) from t1; # Field::val_real() +select a DIV 1 from t1; # Field::val_int() +select group_concat(distinct a) from t1; # Field::cmp() +alter table t1 engine=innodb; +select * from t1 order by a; +select * from t1 order by a+0; +drop table t1; +eval create table t1 (a $type(4)) engine=innodb; +insert t1 values ('2010-12-11 01:02:03.456789'); +select * from t1; +select extract(microsecond from a + interval 100 microsecond) from t1 where a>'2010-11-12 01:02:03.456'; +select a from t1 where a>'2010-11-12 01:02:03.456' group by a; + +# +# metadata +# +show create table t1; +show columns from t1; +--query_vertical select table_name, column_name, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra from information_schema.columns where table_name='t1' + +# +# update/delete +# +select a, a+interval 9876543 microsecond from t1; +update t1 set a=a+interval 9876543 microsecond; +select * from t1; +select a, a + interval 2 year from t1; +insert t1 select a + interval 2 year from t1; +select * from t1; +delete from t1 where a < 20110101; +select * from t1; + +# +# create ... select +# +create table t2 select * from t1; +create table t3 like t1; + +show create table t2; +show create table t3; + +drop table t1, t2, t3; + +# +# SP +# +eval create table t1 (a $type(6), b $type(6)); +eval create procedure foo(x $type, y $type(4)) insert into t1 values (x, y); +call foo('2010-02-03 4:5:6.789123', '2010-02-03 4:5:6.789123'); +select * from t1; +delimiter |; +eval create procedure bar(a int, c $type(5)) +begin + declare b $type(4); + set b = c + interval a microsecond; + insert t1 values (b, c + interval a microsecond); +end| +delimiter ;| +call bar(1111111, '2011-01-02 3:4:5.123456'); +select * from t1; +drop procedure foo; +drop procedure bar; +eval create function xyz(s char(20)) returns $type(4) + return addtime('2010-10-10 10:10:10.101010', s); +select xyz('1:1:1.010101'); +drop function xyz; + +# +# Views +# + +create view v1 as select * from t1 group by a,b; +select * from v1; +show columns from v1; +create table t2 select * from v1; +show create table t2; +select * from t2; + +drop view v1; +drop table t1, t2; + |