summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authordlenev@mysql.com <>2004-11-03 17:59:03 +0000
committerdlenev@mysql.com <>2004-11-03 17:59:03 +0000
commitfa21feda932a9ccc68142dd04b18fe37daf15655 (patch)
tree19189bd6aebd643a3d14a5e47ce221a80424acb9 /mysql-test
parent22269d451af650f887a7679ba6fffe7577d1c007 (diff)
downloadmariadb-git-fa21feda932a9ccc68142dd04b18fe37daf15655.tar.gz
Fix for bug #6387 "Queried timestamp values do not match the inserted
value if server runs in time zone with leap seconds". Now in my_gmt_sec() function we take into account difference between our target and estimation in seconds part.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/Makefile.am2
-rw-r--r--mysql-test/r/have_moscow_leap_timezone.require2
-rw-r--r--mysql-test/r/timezone3.result41
-rw-r--r--mysql-test/std_data/Moscow_leapbin0 -> 991 bytes
-rw-r--r--mysql-test/t/timezone3-master.opt1
-rw-r--r--mysql-test/t/timezone3.test59
6 files changed, 105 insertions, 0 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index ba96c5947ba..8b0c096120a 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -32,6 +32,7 @@ dist-hook:
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.001 $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(distdir)/std_data
+ $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(distdir)/std_data
install-data-local:
$(mkinstalldirs) \
@@ -50,6 +51,7 @@ install-data-local:
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.*001 $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(DESTDIR)$(testdir)/std_data
+ $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data
SUFFIXES = .sh
diff --git a/mysql-test/r/have_moscow_leap_timezone.require b/mysql-test/r/have_moscow_leap_timezone.require
new file mode 100644
index 00000000000..f27452d7770
--- /dev/null
+++ b/mysql-test/r/have_moscow_leap_timezone.require
@@ -0,0 +1,2 @@
+from_unixtime(1072904422)
+2004-01-01 00:00:00
diff --git a/mysql-test/r/timezone3.result b/mysql-test/r/timezone3.result
new file mode 100644
index 00000000000..2135dd33511
--- /dev/null
+++ b/mysql-test/r/timezone3.result
@@ -0,0 +1,41 @@
+drop table if exists t1;
+create table t1 (i int, c varchar(20));
+insert into t1 values
+(unix_timestamp("2004-01-01 00:00:00"), "2004-01-01 00:00:00");
+insert into t1 values
+(unix_timestamp("2004-03-28 01:59:59"), "2004-03-28 01:59:59"),
+(unix_timestamp("2004-03-28 02:30:00"), "2004-03-28 02:30:00"),
+(unix_timestamp("2004-03-28 03:00:00"), "2004-03-28 03:00:00");
+insert into t1 values
+(unix_timestamp('2004-05-01 00:00:00'),'2004-05-01 00:00:00');
+insert into t1 values
+(unix_timestamp('2004-10-31 01:00:00'),'2004-10-31 01:00:00'),
+(unix_timestamp('2004-10-31 02:00:00'),'2004-10-31 02:00:00'),
+(unix_timestamp('2004-10-31 02:59:59'),'2004-10-31 02:59:59'),
+(unix_timestamp('2004-10-31 04:00:00'),'2004-10-31 04:00:00'),
+(unix_timestamp('2004-10-31 02:59:59'),'2004-10-31 02:59:59');
+insert into t1 values
+(unix_timestamp('1981-07-01 03:59:59'),'1981-07-01 03:59:59'),
+(unix_timestamp('1981-07-01 04:00:00'),'1981-07-01 04:00:00');
+select i, from_unixtime(i), c from t1;
+i from_unixtime(i) c
+1072904422 2004-01-01 00:00:00 2004-01-01 00:00:00
+1080428421 2004-03-28 01:59:59 2004-03-28 01:59:59
+1080428422 2004-03-28 03:00:00 2004-03-28 02:30:00
+1080428422 2004-03-28 03:00:00 2004-03-28 03:00:00
+1083355222 2004-05-01 00:00:00 2004-05-01 00:00:00
+1099170022 2004-10-31 01:00:00 2004-10-31 01:00:00
+1099177222 2004-10-31 02:00:00 2004-10-31 02:00:00
+1099180821 2004-10-31 02:59:59 2004-10-31 02:59:59
+1099184422 2004-10-31 04:00:00 2004-10-31 04:00:00
+1099180821 2004-10-31 02:59:59 2004-10-31 02:59:59
+362793608 1981-07-01 03:59:59 1981-07-01 03:59:59
+362793610 1981-07-01 04:00:00 1981-07-01 04:00:00
+drop table t1;
+create table t1 (ts timestamp);
+insert into t1 values (19730101235900), (20040101235900);
+select * from t1;
+ts
+19730101235900
+20040101235900
+drop table t1;
diff --git a/mysql-test/std_data/Moscow_leap b/mysql-test/std_data/Moscow_leap
new file mode 100644
index 00000000000..4994c005595
--- /dev/null
+++ b/mysql-test/std_data/Moscow_leap
Binary files differ
diff --git a/mysql-test/t/timezone3-master.opt b/mysql-test/t/timezone3-master.opt
new file mode 100644
index 00000000000..6910e6e6e8d
--- /dev/null
+++ b/mysql-test/t/timezone3-master.opt
@@ -0,0 +1 @@
+--timezone=:$MYSQL_TEST_DIR/std_data/Moscow_leap
diff --git a/mysql-test/t/timezone3.test b/mysql-test/t/timezone3.test
new file mode 100644
index 00000000000..8910783cd85
--- /dev/null
+++ b/mysql-test/t/timezone3.test
@@ -0,0 +1,59 @@
+#
+# Test of handling time zone with leap seconds.
+#
+# This test should be run with TZ=:$MYSQL_TEST_DIR/std_data/Moscow_leap
+# This implies that this test should be run only on systems that interpret
+# characters after colon in TZ variable as path to zoneinfo file.
+#
+# Check that we have successfully set time zone with leap seconds.
+--require r/have_moscow_leap_timezone.require
+disable_query_log;
+select from_unixtime(1072904422);
+enable_query_log;
+
+# Initial clean-up
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Let us check behavior of conversion from broken-down representation
+# to time_t representation, for normal, non-existent and ambigious dates
+# (This check is similar to the one in timezone2.test in 4.1)
+#
+create table t1 (i int, c varchar(20));
+# Normal value without DST
+insert into t1 values
+ (unix_timestamp("2004-01-01 00:00:00"), "2004-01-01 00:00:00");
+# Values around and in spring time-gap
+insert into t1 values
+ (unix_timestamp("2004-03-28 01:59:59"), "2004-03-28 01:59:59"),
+ (unix_timestamp("2004-03-28 02:30:00"), "2004-03-28 02:30:00"),
+ (unix_timestamp("2004-03-28 03:00:00"), "2004-03-28 03:00:00");
+# Normal value with DST
+insert into t1 values
+ (unix_timestamp('2004-05-01 00:00:00'),'2004-05-01 00:00:00');
+# Ambiguos values (also check for determenism)
+insert into t1 values
+ (unix_timestamp('2004-10-31 01:00:00'),'2004-10-31 01:00:00'),
+ (unix_timestamp('2004-10-31 02:00:00'),'2004-10-31 02:00:00'),
+ (unix_timestamp('2004-10-31 02:59:59'),'2004-10-31 02:59:59'),
+ (unix_timestamp('2004-10-31 04:00:00'),'2004-10-31 04:00:00'),
+ (unix_timestamp('2004-10-31 02:59:59'),'2004-10-31 02:59:59');
+# Test of leap
+insert into t1 values
+ (unix_timestamp('1981-07-01 03:59:59'),'1981-07-01 03:59:59'),
+ (unix_timestamp('1981-07-01 04:00:00'),'1981-07-01 04:00:00');
+
+select i, from_unixtime(i), c from t1;
+drop table t1;
+
+#
+# Test for bug #6387 "Queried timestamp values do not match the
+# inserted". my_gmt_sec() function was not working properly if we
+# had time zone with leap seconds
+#
+create table t1 (ts timestamp);
+insert into t1 values (19730101235900), (20040101235900);
+select * from t1;
+drop table t1;