1** Setup ** 2 3SET @session_time_zone = @@SESSION.time_zone; 4SET @global_time_zone = @@GLOBAL.time_zone; 5CREATE TABLE t1 (a datetime); 6CREATE TABLE t2 (a timestamp); 7'#-----------------------------FN_DYNVARS_177_01--------------------#' 8SET @@time_zone = DEFAULT; 9SELECT @@time_zone; 10@@time_zone 11SYSTEM 12SYSTEM Expected 13'#-----------------------------FN_DYNVARS_177_02-------------------#' 14SET @@time_zone = '+05:00'; 15SELECT @@time_zone; 16@@time_zone 17+05:00 18+05:00 Expected 19SET @@time_zone = '-01:00'; 20SELECT @@time_zone; 21@@time_zone 22-01:00 23-01:00 Expected 24SET @@time_zone = '+00:00'; 25SELECT @@time_zone; 26@@time_zone 27+00:00 28+00:00 Expected 29SET @@time_zone = '-00:00'; 30SELECT @@time_zone; 31@@time_zone 32+00:00 33-00:00 Expected 34'#-----------------------------FN_DYNVARS_177_03----------------#' 35SET @@time_zone = '+00:00'; 36INSERT INTO t1 VALUES('2008-03-05 16:28:00'); 37INSERT INTO t1 VALUES('1970-01-01 00:05:00'),('1970-01-01 01:05:00'); 38INSERT INTO t2 VALUES(20080305162800); 39INSERT INTO t2 VALUES(19730101235900); 40INSERT INTO t2 VALUES('1970-01-01 00:05:00'),('1970-01-01 01:05:00'); 41INSERT INTO t2 VALUES(19700101000500); 42SELECT a,UNIX_TIMESTAMP(a) FROM t1; 43a UNIX_TIMESTAMP(a) 442008-03-05 16:28:00 1204734480 451970-01-01 00:05:00 300 461970-01-01 01:05:00 3900 47SELECT a,UNIX_TIMESTAMP(a) FROM t2; 48a UNIX_TIMESTAMP(a) 492008-03-05 16:28:00 1204734480 501973-01-01 23:59:00 94780740 511970-01-01 00:05:00 300 521970-01-01 01:05:00 3900 531970-01-01 00:05:00 300 54SET @@time_zone = 'MET'; 55SELECT a,UNIX_TIMESTAMP(a) FROM t1; 56a UNIX_TIMESTAMP(a) 572008-03-05 16:28:00 1204730880 581970-01-01 00:05:00 0 591970-01-01 01:05:00 300 60SELECT a,UNIX_TIMESTAMP(a) FROM t2; 61a UNIX_TIMESTAMP(a) 622008-03-05 17:28:00 1204734480 631973-01-02 00:59:00 94780740 641970-01-01 01:05:00 300 651970-01-01 02:05:00 3900 661970-01-01 01:05:00 300 67SET @@time_zone = '+05:00'; 68SELECT a,UNIX_TIMESTAMP(a) FROM t1; 69a UNIX_TIMESTAMP(a) 702008-03-05 16:28:00 1204716480 711970-01-01 00:05:00 0 721970-01-01 01:05:00 0 73SELECT a,UNIX_TIMESTAMP(a) FROM t2; 74a UNIX_TIMESTAMP(a) 752008-03-05 21:28:00 1204734480 761973-01-02 04:59:00 94780740 771970-01-01 05:05:00 300 781970-01-01 06:05:00 3900 791970-01-01 05:05:00 300 80SET @@time_zone = '+06:00'; 81SELECT a,UNIX_TIMESTAMP(a) FROM t1; 82a UNIX_TIMESTAMP(a) 832008-03-05 16:28:00 1204712880 841970-01-01 00:05:00 0 851970-01-01 01:05:00 0 86SELECT a,UNIX_TIMESTAMP(a) FROM t2; 87a UNIX_TIMESTAMP(a) 882008-03-05 22:28:00 1204734480 891973-01-02 05:59:00 94780740 901970-01-01 06:05:00 300 911970-01-01 07:05:00 3900 921970-01-01 06:05:00 300 93SET @@time_zone = '+01:00'; 94SELECT a,UNIX_TIMESTAMP(a) FROM t1; 95a UNIX_TIMESTAMP(a) 962008-03-05 16:28:00 1204730880 971970-01-01 00:05:00 0 981970-01-01 01:05:00 300 99SELECT a,UNIX_TIMESTAMP(a) FROM t2; 100a UNIX_TIMESTAMP(a) 1012008-03-05 17:28:00 1204734480 1021973-01-02 00:59:00 94780740 1031970-01-01 01:05:00 300 1041970-01-01 02:05:00 3900 1051970-01-01 01:05:00 300 106SET @@time_zone = '+02:00'; 107SELECT a,UNIX_TIMESTAMP(a) FROM t1; 108a UNIX_TIMESTAMP(a) 1092008-03-05 16:28:00 1204727280 1101970-01-01 00:05:00 0 1111970-01-01 01:05:00 0 112SELECT a,UNIX_TIMESTAMP(a) FROM t2; 113a UNIX_TIMESTAMP(a) 1142008-03-05 18:28:00 1204734480 1151973-01-02 01:59:00 94780740 1161970-01-01 02:05:00 300 1171970-01-01 03:05:00 3900 1181970-01-01 02:05:00 300 119SET @@time_zone = '+00:00'; 120SELECT a,UNIX_TIMESTAMP(a) FROM t1; 121a UNIX_TIMESTAMP(a) 1222008-03-05 16:28:00 1204734480 1231970-01-01 00:05:00 300 1241970-01-01 01:05:00 3900 125SELECT a,UNIX_TIMESTAMP(a) FROM t2; 126a UNIX_TIMESTAMP(a) 1272008-03-05 16:28:00 1204734480 1281973-01-01 23:59:00 94780740 1291970-01-01 00:05:00 300 1301970-01-01 01:05:00 3900 1311970-01-01 00:05:00 300 132SET @@time_zone = '+06:00'; 133SELECT a,UNIX_TIMESTAMP(a) FROM t1; 134a UNIX_TIMESTAMP(a) 1352008-03-05 16:28:00 1204712880 1361970-01-01 00:05:00 0 1371970-01-01 01:05:00 0 138SELECT a,UNIX_TIMESTAMP(a) FROM t2; 139a UNIX_TIMESTAMP(a) 1402008-03-05 22:28:00 1204734480 1411973-01-02 05:59:00 94780740 1421970-01-01 06:05:00 300 1431970-01-01 07:05:00 3900 1441970-01-01 06:05:00 300 145Potential Feature: upon recovery of timezone, 146the original value of the timestamp should be recovered. 147'#-----------------------------FN_DYNVARS_177_04--------------------#' 148SET @@time_zone = '6'; 149ERROR HY000: Unknown or incorrect time zone: '6' 150'#-----------------------------FN_DYNVARS_177_05---------------#' 151SET GLOBAL time_zone = 'SYSTEM'; 152** Connecting con_int1 using root ** 153** Connection con_int1 ** 154SELECT @@SESSION.time_zone; 155@@SESSION.time_zone 156SYSTEM 157SYSTEM Expected 158SET SESSION time_zone = '+05:00'; 159** Connecting con_int2 using root ** 160** Connection con_int2 ** 161SELECT @@SESSION.time_zone; 162@@SESSION.time_zone 163SYSTEM 164SYSTEM Expected 165SET SESSION time_zone = '-10:00'; 166** Connection con_int2 ** 167SELECT @@SESSION.time_zone; 168@@SESSION.time_zone 169-10:00 170-10:00 Expected 171** Connection con_int1 ** 172SELECT @@SESSION.time_zone; 173@@SESSION.time_zone 174+05:00 175+05:00 Expected 176SELECT @@GLOBAL.time_zone; 177@@GLOBAL.time_zone 178SYSTEM 179SYSTEM Expected 180** Connection default ** 181Disconnecting Connections con_int1, con_int2 182SET @@SESSION.time_zone = @session_time_zone; 183SET @@GLOBAL.time_zone = @global_time_zone; 184DROP TABLE t1; 185DROP TABLE t2; 186