From: Alexander Barkov Date: November 21 2011 3:18pm Subject: bzr push into mysql-trunk branch (alexander.barkov:3605 to 3606) List-Archive: http://lists.mysql.com/commits/142115 Message-Id: <201111211518.pALFIgSp007764@bar.myoffice.izhnet.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3606 Alexander Barkov 2011-11-21 Improving coverage according to gcov results. modified: mysql-test/r/type_temporal_fractional.result mysql-test/t/type_temporal_fractional.test sql/field.cc sql/field.h 3605 Alexander Barkov 2011-11-21 Removing debug code. modified: sql/sql_time.cc === modified file 'mysql-test/r/type_temporal_fractional.result' --- a/mysql-test/r/type_temporal_fractional.result 2011-11-21 11:05:05 +0000 +++ b/mysql-test/r/type_temporal_fractional.result 2011-11-21 15:17:51 +0000 @@ -268,6 +268,23 @@ a b -101011 -10:10:10.500000 -101010 -10:10:10.499999 DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (TIME'01:59:59.499999'); +INSERT INTO t1 VALUES (TIME'01:59:59.500000'); +SELECT * FROM t1; +a +15959 +20000 +DROP TABLE t1; +# +# Inserting TIME into a REAL column +# +CREATE TABLE t1 (a REAL); +INSERT INTO t1 VALUES (TIME'01:02:03.123'); +SELECT * FROM t1; +a +10203.123 +DROP TABLE t1; # # Testing rounding when altering TIME(N) to a smaller size # @@ -13734,6 +13751,53 @@ a LENGTH(a) DROP TABLE t2; DROP TABLE t1; # +# Testing that default precision in "DEFAULT CURRENT_TIMESTAMP(N)" +# and "ON UPDATE CURRENT_TIMESTAMP(N)" is the same to the precision +# of the field itself. +# +CREATE TABLE t1 (a TIMESTAMP(1) NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(1) NOT NULL DEFAULT CURRENT_TIMESTAMP(1) ON UPDATE CURRENT_TIMESTAMP(1) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(2) NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(3) NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(4) NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(4) NOT NULL DEFAULT CURRENT_TIMESTAMP(4) ON UPDATE CURRENT_TIMESTAMP(4) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(5) NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(5) NOT NULL DEFAULT CURRENT_TIMESTAMP(5) ON UPDATE CURRENT_TIMESTAMP(5) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# # Testing DEFAULT value # CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT '2000-01-01 11:22:33.123456'); === modified file 'mysql-test/t/type_temporal_fractional.test' --- a/mysql-test/t/type_temporal_fractional.test 2011-11-21 11:05:05 +0000 +++ b/mysql-test/t/type_temporal_fractional.test 2011-11-21 15:17:51 +0000 @@ -90,6 +90,19 @@ INSERT INTO t1 (b) VALUES ('-10:10:10.49 UPDATE t1 SET a=b; SELECT * FROM t1; DROP TABLE t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (TIME'01:59:59.499999'); +INSERT INTO t1 VALUES (TIME'01:59:59.500000'); +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # Inserting TIME into a REAL column +--echo # +CREATE TABLE t1 (a REAL); +INSERT INTO t1 VALUES (TIME'01:02:03.123'); +SELECT * FROM t1; +DROP TABLE t1; --echo # @@ -4058,6 +4071,7 @@ CREATE TABLE t1 (a TIMESTAMP(0) NOT NULL SHOW CREATE TABLE t1; DROP TABLE t1; + --echo # --echo # Testing internal representation format for DATETIME(N) --echo # @@ -5052,6 +5066,32 @@ SELECT a, LENGTH(a) FROM t2; DROP TABLE t2; DROP TABLE t1; + +--echo # +--echo # Testing that default precision in "DEFAULT CURRENT_TIMESTAMP(N)" +--echo # and "ON UPDATE CURRENT_TIMESTAMP(N)" is the same to the precision +--echo # of the field itself. +--echo # +CREATE TABLE t1 (a TIMESTAMP(1) NOT NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(2) NOT NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(3) NOT NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(4) NOT NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(5) NOT NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; + + --echo # --echo # Testing DEFAULT value --echo # === modified file 'sql/field.cc' --- a/sql/field.cc 2011-11-21 11:58:25 +0000 +++ b/sql/field.cc 2011-11-21 15:17:51 +0000 @@ -5712,13 +5712,6 @@ int Field_time::store_internal(const MYS } -int Field_time::store_internal(const lldiv_t *lld) -{ - int3store(ptr, lld->quot); - return 0; -} - - int Field_time::store_packed(longlong nr) { MYSQL_TIME ltime; @@ -5785,17 +5778,6 @@ void Field_time::sql_type(String &res) c ****************************************************************************/ -int Field_timef::store_internal(const lldiv_t *lld) -{ - MYSQL_TIME ltime; - ltime.neg= lld->quot < 0 || lld->rem < 0; - ltime.year= ltime.month= ltime.day= 0; - TIME_set_hhmmss(<ime, (uint) (lld->quot < 0 ? -lld->quot : lld->quot)); - ltime.second_part= (uint) ((lld->rem < 0 ? -lld->rem : lld->rem) / 1000); - return store_internal_with_round(<ime, NULL); -} - - longlong Field_timef::val_int() { ASSERT_COLUMN_MARKED_FOR_READ; === modified file 'sql/field.h' --- a/sql/field.h 2011-11-21 11:58:25 +0000 +++ b/sql/field.h 2011-11-21 15:17:51 +0000 @@ -1797,7 +1797,7 @@ protected: @retval false In case of success. @retval true In case of error. */ - virtual int store_lldiv_t(const lldiv_t *lld, int *warning); + int store_lldiv_t(const lldiv_t *lld, int *warning); /** Convert a string to MYSQL_TIME, according to the field type. @@ -2366,11 +2366,6 @@ protected: */ virtual int store_internal(const MYSQL_TIME *ltime, int *error)= 0; /** - Low-level function to store time value in lldiv_t format. - The value must be rounded or truncated according to decimals(). - */ - virtual int store_internal(const lldiv_t *lld)= 0; - /** Function to store time value. The value is rounded according to decimals(). */ @@ -2418,7 +2413,6 @@ public: class Field_time :public Field_time_common { protected: int store_internal(const MYSQL_TIME *ltime, int *error); - int store_internal(const lldiv_t *lld); public: Field_time(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg) @@ -2464,7 +2458,6 @@ private: } protected: int store_internal(const MYSQL_TIME *ltime, int *error); - int store_internal(const lldiv_t *lld); public: /** Constructor for Field_timef No bundle (reason: useless for push emails).