List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:November 21 2011 7:18pm
Subject:bzr push into mysql-trunk branch (alexander.barkov:3606 to 3607) WL#946
View as plain text  
 3607 Alexander Barkov	2011-11-21
      WL#946 Better gcov coverage. Adding tests for the old fields.

    added:
      mysql-test/r/type_temporal_upgrade.result
      mysql-test/std_data/55_temporal.MYD
      mysql-test/std_data/55_temporal.MYI
      mysql-test/std_data/55_temporal.frm
      mysql-test/t/type_temporal_upgrade.test
 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
=== added file 'mysql-test/r/type_temporal_upgrade.result'
--- a/mysql-test/r/type_temporal_upgrade.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/type_temporal_upgrade.result	2011-11-21 19:17:25 +0000
@@ -0,0 +1,204 @@
+DROP TABLE IF EXISTS t1;
+#
+# Test with a saved table from 5.5
+#
+SET time_zone='+03:00';
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `f_time` time DEFAULT NULL,
+  `f_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  `f_datetime` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+f_time	f_timestamp	f_datetime
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+00:00:00	2001-01-21 18:11:01	2000-01-01 01:01:01
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+NULL	2015-11-21 17:11:01	2000-01-01 01:01:01
+00:00:00	2011-11-21 17:11:01	NULL
+SELECT * FROM t1 ORDER BY f_time;
+f_time	f_timestamp	f_datetime
+NULL	2015-11-21 17:11:01	2000-01-01 01:01:01
+00:00:00	2001-01-21 18:11:01	2000-01-01 01:01:01
+00:00:00	2011-11-21 17:11:01	NULL
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+SELECT * FROM t1 WHERE f_time > '00:00:00';
+f_time	f_timestamp	f_datetime
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+SELECT * FROM t1 WHERE f_time > '00:00:00' ORDER BY f_time;
+f_time	f_timestamp	f_datetime
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+SELECT * FROM t1 WHERE f_time = '01:01:10';
+f_time	f_timestamp	f_datetime
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+SELECT * FROM t1 WHERE f_time IS NULL;
+f_time	f_timestamp	f_datetime
+NULL	2015-11-21 17:11:01	2000-01-01 01:01:01
+SELECT * FROM t1 ORDER BY f_timestamp;
+f_time	f_timestamp	f_datetime
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+00:00:00	2001-01-21 18:11:01	2000-01-01 01:01:01
+00:00:00	2011-11-21 17:11:01	NULL
+NULL	2015-11-21 17:11:01	2000-01-01 01:01:01
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+SELECT * FROM t1 WHERE f_timestamp > '2011-11-21 17:11:01';
+f_time	f_timestamp	f_datetime
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+NULL	2015-11-21 17:11:01	2000-01-01 01:01:01
+SELECT * FROM t1 WHERE f_timestamp > '2011-11-21 17:11:01' ORDER BY f_timestamp;
+f_time	f_timestamp	f_datetime
+NULL	2015-11-21 17:11:01	2000-01-01 01:01:01
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+SELECT * FROM t1 WHERE f_timestamp = '2015-11-21 17:11:01';
+f_time	f_timestamp	f_datetime
+NULL	2015-11-21 17:11:01	2000-01-01 01:01:01
+SELECT * FROM t1 WHERE f_timestamp IS NULL;
+f_time	f_timestamp	f_datetime
+SELECT * FROM t1 ORDER BY f_datetime;
+f_time	f_timestamp	f_datetime
+00:00:00	2011-11-21 17:11:01	NULL
+00:00:00	2001-01-21 18:11:01	2000-01-01 01:01:01
+NULL	2015-11-21 17:11:01	2000-01-01 01:01:01
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+SELECT * FROM t1 WHERE f_datetime > '2000-01-01 01:01:01';
+f_time	f_timestamp	f_datetime
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+SELECT * FROM t1 WHERE f_datetime > '2000-01-01 01:01:01' ORDER BY f_datetime;
+f_time	f_timestamp	f_datetime
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+01:01:10	1980-11-21 18:06:01	2020-01-01 01:01:01
+SELECT * FROM t1 WHERE f_datetime = '2010-10-10 10:10:10';
+f_time	f_timestamp	f_datetime
+10:10:10	2031-11-21 17:11:01	2010-10-10 10:10:10
+SELECT * FROM t1 WHERE f_datetime IS NULL;
+f_time	f_timestamp	f_datetime
+00:00:00	2011-11-21 17:11:01	NULL
+#
+# Checking various val_xxx() methods for the old fields
+#
+SELECT CAST(f_time AS CHAR), CAST(f_time AS SIGNED), CAST(f_time AS DECIMAL(23,6)) FROM t1;
+CAST(f_time AS CHAR)	CAST(f_time AS SIGNED)	CAST(f_time AS DECIMAL(23,6))
+10:10:10	101010	101010.000000
+00:00:00	0	0.000000
+01:01:10	10110	10110.000000
+NULL	NULL	NULL
+00:00:00	0	0.000000
+SELECT CAST(f_datetime AS CHAR), CAST(f_datetime AS SIGNED), CAST(f_datetime AS DECIMAL(23,6)) FROM t1;
+CAST(f_datetime AS CHAR)	CAST(f_datetime AS SIGNED)	CAST(f_datetime AS DECIMAL(23,6))
+2010-10-10 10:10:10	20101010101010	20101010101010.000000
+2000-01-01 01:01:01	20000101010101	20000101010101.000000
+2020-01-01 01:01:01	20200101010101	20200101010101.000000
+2000-01-01 01:01:01	20000101010101	20000101010101.000000
+NULL	NULL	NULL
+SELECT CAST(f_timestamp AS CHAR), CAST(f_timestamp AS SIGNED), CAST(f_timestamp AS DECIMAL(23,6)) FROM t1;
+CAST(f_timestamp AS CHAR)	CAST(f_timestamp AS SIGNED)	CAST(f_timestamp AS DECIMAL(23,6))
+2031-11-21 17:11:01	20311121171101	20311121171101.000000
+2001-01-21 18:11:01	20010121181101	20010121181101.000000
+1980-11-21 18:06:01	19801121180601	19801121180601.000000
+2015-11-21 17:11:01	20151121171101	20151121171101.000000
+2011-11-21 17:11:01	20111121171101	20111121171101.000000
+#
+# Checking old table
+#
+INSERT INTO t1 VALUES ('22:22:22.5','2011-11-21 22:22:22.5','2011-11-21 22:22:22.5');
+SELECT f_time, HEX(WEIGHT_STRING(f_time)) FROM t1;
+f_time	HEX(WEIGHT_STRING(f_time))
+10:10:10	818A92
+00:00:00	800000
+01:01:10	80277E
+NULL	NULL
+00:00:00	800000
+22:22:23	83640F
+SELECT f_timestamp, HEX(WEIGHT_STRING(f_timestamp)) FROM t1;
+f_timestamp	HEX(WEIGHT_STRING(f_timestamp))
+2031-11-21 17:11:01	7468F975
+2001-01-21 18:11:01	3A6AFC05
+1980-11-21 18:06:01	147BF1D9
+2015-11-21 17:11:01	56507B75
+2011-11-21 17:11:01	4ECA5BF5
+2011-11-21 22:22:23	4ECAA4EF
+SELECT f_datetime, HEX(WEIGHT_STRING(f_datetime)) FROM t1;
+f_datetime	HEX(WEIGHT_STRING(f_datetime))
+2010-10-10 10:10:10	0000124821911312
+2000-01-01 01:01:01	00001230A2EA8AB5
+2020-01-01 01:01:01	0000125F33D85AB5
+2000-01-01 01:01:01	00001230A2EA8AB5
+NULL	NULL
+2011-11-21 22:22:23	0000124A7C3C8A4F
+#
+# This ALTER does not change old fields to new fields
+# Still expect old WEIGHT_STRING for the TIME and DATETIME fields
+#
+ALTER TABLE t1 FORCE;
+INSERT INTO t1 VALUES ('22:22:22.5','2011-11-21 22:22:22.5','2011-11-21 22:22:22.5');
+SELECT f_time, HEX(WEIGHT_STRING(f_time)) FROM t1;
+f_time	HEX(WEIGHT_STRING(f_time))
+10:10:10	818A92
+00:00:00	800000
+01:01:10	80277E
+NULL	NULL
+00:00:00	800000
+22:22:23	83640F
+22:22:23	83640F
+SELECT f_timestamp, HEX(WEIGHT_STRING(f_timestamp)) FROM t1;
+f_timestamp	HEX(WEIGHT_STRING(f_timestamp))
+2031-11-21 17:11:01	7468F975
+2001-01-21 18:11:01	3A6AFC05
+1980-11-21 18:06:01	147BF1D9
+2015-11-21 17:11:01	56507B75
+2011-11-21 17:11:01	4ECA5BF5
+2011-11-21 22:22:23	4ECAA4EF
+2011-11-21 22:22:23	4ECAA4EF
+SELECT f_datetime, HEX(WEIGHT_STRING(f_datetime)) FROM t1;
+f_datetime	HEX(WEIGHT_STRING(f_datetime))
+2010-10-10 10:10:10	0000124821911312
+2000-01-01 01:01:01	00001230A2EA8AB5
+2020-01-01 01:01:01	0000125F33D85AB5
+2000-01-01 01:01:01	00001230A2EA8AB5
+NULL	NULL
+2011-11-21 22:22:23	0000124A7C3C8A4F
+2011-11-21 22:22:23	0000124A7C3C8A4F
+#
+# This ALTER should change old fields to new fields
+# Expecting new WEIGHT_STRING the rounding.
+#
+ALTER TABLE t1 MODIFY f_time TIME, MODIFY f_timestamp TIMESTAMP, MODIFY f_datetime DATETIME;
+INSERT INTO t1 VALUES ('22:22:22.5','2011-11-21 22:22:22.5','2011-11-21 22:22:22.5');
+SELECT f_time, HEX(WEIGHT_STRING(f_time)) FROM t1;
+f_time	HEX(WEIGHT_STRING(f_time))
+10:10:10	80A28A
+00:00:00	800000
+01:01:10	80104A
+NULL	NULL
+00:00:00	800000
+22:22:23	816597
+22:22:23	816597
+22:22:23	816597
+SELECT f_timestamp, HEX(WEIGHT_STRING(f_timestamp)) FROM t1;
+f_timestamp	HEX(WEIGHT_STRING(f_timestamp))
+2031-11-21 17:11:01	7468F975
+2001-01-21 18:11:01	3A6AFC05
+1980-11-21 18:06:01	147BF1D9
+2015-11-21 17:11:01	56507B75
+2011-11-21 17:11:01	4ECA5BF5
+2011-11-21 22:22:23	4ECAA4EF
+2011-11-21 22:22:23	4ECAA4EF
+2011-11-21 22:22:23	4ECAA4EF
+SELECT f_datetime, HEX(WEIGHT_STRING(f_datetime)) FROM t1;
+f_datetime	HEX(WEIGHT_STRING(f_datetime))
+2010-10-10 10:10:10	998714A28A
+2000-01-01 01:01:01	9964421041
+2020-01-01 01:01:01	99A5421041
+2000-01-01 01:01:01	9964421041
+NULL	NULL
+2011-11-21 22:22:23	998AAB6597
+2011-11-21 22:22:23	998AAB6597
+2011-11-21 22:22:23	998AAB6597
+DROP TABLE t1;
+SET time_zone=DEFAULT;

=== added file 'mysql-test/std_data/55_temporal.MYD'
Binary files a/mysql-test/std_data/55_temporal.MYD	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/55_temporal.MYD	2011-11-21 19:17:25 +0000 differ

=== added file 'mysql-test/std_data/55_temporal.MYI'
Binary files a/mysql-test/std_data/55_temporal.MYI	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/55_temporal.MYI	2011-11-21 19:17:25 +0000 differ

=== added file 'mysql-test/std_data/55_temporal.frm'
Binary files a/mysql-test/std_data/55_temporal.frm	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/55_temporal.frm	2011-11-21 19:17:25 +0000 differ

=== added file 'mysql-test/t/type_temporal_upgrade.test'
--- a/mysql-test/t/type_temporal_upgrade.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/type_temporal_upgrade.test	2011-11-21 19:17:25 +0000
@@ -0,0 +1,75 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Test with a saved table from 5.5
+--echo #
+
+SET time_zone='+03:00';
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+--copy_file std_data/55_temporal.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/55_temporal.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/55_temporal.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+SHOW CREATE TABLE t1;
+
+SELECT * FROM t1;
+
+SELECT * FROM t1 ORDER BY f_time;
+SELECT * FROM t1 WHERE f_time > '00:00:00';
+SELECT * FROM t1 WHERE f_time > '00:00:00' ORDER BY f_time;
+SELECT * FROM t1 WHERE f_time = '01:01:10';
+SELECT * FROM t1 WHERE f_time IS NULL;
+
+SELECT * FROM t1 ORDER BY f_timestamp;
+SELECT * FROM t1 WHERE f_timestamp > '2011-11-21 17:11:01';
+SELECT * FROM t1 WHERE f_timestamp > '2011-11-21 17:11:01' ORDER BY f_timestamp;
+SELECT * FROM t1 WHERE f_timestamp = '2015-11-21 17:11:01';
+SELECT * FROM t1 WHERE f_timestamp IS NULL;
+
+SELECT * FROM t1 ORDER BY f_datetime;
+SELECT * FROM t1 WHERE f_datetime > '2000-01-01 01:01:01';
+SELECT * FROM t1 WHERE f_datetime > '2000-01-01 01:01:01' ORDER BY f_datetime;
+SELECT * FROM t1 WHERE f_datetime = '2010-10-10 10:10:10';
+SELECT * FROM t1 WHERE f_datetime IS NULL;
+
+--echo #
+--echo # Checking various val_xxx() methods for the old fields
+--echo #
+SELECT CAST(f_time AS CHAR), CAST(f_time AS SIGNED), CAST(f_time AS DECIMAL(23,6)) FROM t1;
+SELECT CAST(f_datetime AS CHAR), CAST(f_datetime AS SIGNED), CAST(f_datetime AS DECIMAL(23,6)) FROM t1;
+SELECT CAST(f_timestamp AS CHAR), CAST(f_timestamp AS SIGNED), CAST(f_timestamp AS DECIMAL(23,6)) FROM t1;
+
+--echo #
+--echo # Checking old table
+--echo #
+INSERT INTO t1 VALUES ('22:22:22.5','2011-11-21 22:22:22.5','2011-11-21 22:22:22.5');
+SELECT f_time, HEX(WEIGHT_STRING(f_time)) FROM t1;
+SELECT f_timestamp, HEX(WEIGHT_STRING(f_timestamp)) FROM t1;
+SELECT f_datetime, HEX(WEIGHT_STRING(f_datetime)) FROM t1;
+
+--echo #
+--echo # This ALTER does not change old fields to new fields
+--echo # Still expect old WEIGHT_STRING for the TIME and DATETIME fields
+--echo #
+ALTER TABLE t1 FORCE;
+INSERT INTO t1 VALUES ('22:22:22.5','2011-11-21 22:22:22.5','2011-11-21 22:22:22.5');
+SELECT f_time, HEX(WEIGHT_STRING(f_time)) FROM t1;
+SELECT f_timestamp, HEX(WEIGHT_STRING(f_timestamp)) FROM t1;
+SELECT f_datetime, HEX(WEIGHT_STRING(f_datetime)) FROM t1;
+
+--echo #
+--echo # This ALTER should change old fields to new fields
+--echo # Expecting new WEIGHT_STRING the rounding.
+--echo #
+ALTER TABLE t1 MODIFY f_time TIME, MODIFY f_timestamp TIMESTAMP, MODIFY f_datetime DATETIME;
+INSERT INTO t1 VALUES ('22:22:22.5','2011-11-21 22:22:22.5','2011-11-21 22:22:22.5');
+SELECT f_time, HEX(WEIGHT_STRING(f_time)) FROM t1;
+SELECT f_timestamp, HEX(WEIGHT_STRING(f_timestamp)) FROM t1;
+SELECT f_datetime, HEX(WEIGHT_STRING(f_datetime)) FROM t1;
+
+DROP TABLE t1; 
+
+SET time_zone=DEFAULT;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (alexander.barkov:3606 to 3607) WL#946Alexander Barkov22 Nov