1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
############# mysql-test\t\time_zone_func.test #############################
# #
# Variable Name: time_zone #
# Scope: GLOBAL, SESSION #
# Access Type: Dynamic #
# Data Type: STRING #
# Default Value: TRUE 1, FALSE 0 #
# Values: FALSE 0 #
# #
# #
# Creation Date: 2008-02-25 #
# Author: Sharique Abdullah #
# #
# Description: Test Cases of Dynamic System Variable "time_zone" #
# that checks behavior of this variable in the following ways #
# * Functionality based on different values #
# #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html #
# #
############################################################################
--echo ** Setup **
--echo
#
# Setup
#
SET @session_time_zone = @@SESSION.time_zone;
SET @global_time_zone = @@GLOBAL.time_zone;
CREATE TABLE t1 (a datetime);
CREATE TABLE t2 (a timestamp);
--echo '#-----------------------------FN_DYNVARS_177_01--------------------#'
#
# Value DEFAULT
#
SET @@time_zone = DEFAULT;
SELECT @@time_zone;
--echo SYSTEM Expected
--echo '#-----------------------------FN_DYNVARS_177_02-------------------#'
#
# Testing difference values
#
SET @@time_zone = '+05:00';
SELECT @@time_zone;
--echo +05:00 Expected
SET @@time_zone = '-01:00';
SELECT @@time_zone;
--echo -01:00 Expected
SET @@time_zone = '+00:00';
SELECT @@time_zone;
--echo +00:00 Expected
SET @@time_zone = '-00:00';
SELECT @@time_zone;
--echo -00:00 Expected
--echo '#-----------------------------FN_DYNVARS_177_03----------------#'
#
# Setting possible values
#
SET @@time_zone = '+00:00';
INSERT INTO t1 VALUES('2008-03-05 16:28:00');
INSERT INTO t1 VALUES('1970-01-01 00:05:00'),('1970-01-01 01:05:00');
INSERT INTO t2 VALUES(20080305162800);
INSERT INTO t2 VALUES(19730101235900);
INSERT INTO t2 VALUES('1970-01-01 00:05:00'),('1970-01-01 01:05:00');
INSERT INTO t2 VALUES(19700101000500);
SELECT a,UNIX_TIMESTAMP(a) FROM t1;
SELECT a,UNIX_TIMESTAMP(a) FROM t2;
SET @@time_zone = 'MET';
SELECT a,UNIX_TIMESTAMP(a) FROM t1;
SELECT a,UNIX_TIMESTAMP(a) FROM t2;
SET @@time_zone = '+05:00';
SELECT a,UNIX_TIMESTAMP(a) FROM t1;
SELECT a,UNIX_TIMESTAMP(a) FROM t2;
SET @@time_zone = '+06:00';
SELECT a,UNIX_TIMESTAMP(a) FROM t1;
SELECT a,UNIX_TIMESTAMP(a) FROM t2;
SET @@time_zone = '+01:00';
SELECT a,UNIX_TIMESTAMP(a) FROM t1;
SELECT a,UNIX_TIMESTAMP(a) FROM t2;
SET @@time_zone = '+02:00';
SELECT a,UNIX_TIMESTAMP(a) FROM t1;
SELECT a,UNIX_TIMESTAMP(a) FROM t2;
SET @@time_zone = '+00:00';
SELECT a,UNIX_TIMESTAMP(a) FROM t1;
SELECT a,UNIX_TIMESTAMP(a) FROM t2;
SET @@time_zone = '+06:00';
SELECT a,UNIX_TIMESTAMP(a) FROM t1;
SELECT a,UNIX_TIMESTAMP(a) FROM t2;
--echo Potential Feature: upon recovery of timezone,
--echo the original value of the timestamp should be recovered.
--echo '#-----------------------------FN_DYNVARS_177_04--------------------#'
#
# Testing invalid values
#
--error ER_UNKNOWN_TIME_ZONE
SET @@time_zone = '6';
--echo '#-----------------------------FN_DYNVARS_177_05---------------#'
#
# Session data integrity check & GLOBAL Value check
#
SET GLOBAL time_zone = 'SYSTEM';
connect (con_int1,localhost,root,,);
connection con_int1;
SELECT @@SESSION.time_zone;
--echo SYSTEM Expected
SET SESSION time_zone = '+05:00';
connect (con_int2,localhost,root,,);
connection con_int2;
SELECT @@SESSION.time_zone;
--echo SYSTEM Expected
SET SESSION time_zone = '-10:00';
connection con_int2;
SELECT @@SESSION.time_zone;
--echo -10:00 Expected
connection con_int1;
SELECT @@SESSION.time_zone;
--echo +05:00 Expected
SELECT @@GLOBAL.time_zone;
--echo SYSTEM Expected
connection default;
disconnect con_int1;
disconnect con_int2;
#
# Cleanup
#
SET @@SESSION.time_zone = @session_time_zone;
SET @@GLOBAL.time_zone = @global_time_zone;
DROP TABLE t1;
DROP TABLE t2;
|