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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
Initialize Time Zone
connection master_1;
SET GLOBAL time_zone='MET';
SET time_zone='MET';
connection child2_1;
SET GLOBAL time_zone='MET';
SET time_zone='MET';
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS ts_test_local;
CREATE DATABASE ts_test_local;
USE ts_test_local;
connection child2_1;
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = 'TABLE,FILE';
DROP DATABASE IF EXISTS ts_test_remote;
CREATE DATABASE ts_test_remote;
USE ts_test_remote;
test select 1
connection master_1;
SELECT 1;
1
1
connection child2_1;
SELECT 1;
1
1
create table
connection child2_1;
CHILD2_1_DROP_TABLE
CHILD2_1_DROP_TABLE_F
CHILD2_1_CREATE_TABLE
CHILD2_1_CREATE_TABLE_F
TRUNCATE TABLE mysql.general_log;
connection master_1;
DROP TABLE IF EXISTS tbl_a;
CREATE TABLE tbl_a (
col_a INT UNSIGNED NOT NULL AUTO_INCREMENT,
col_dt DATETIME,
col_ts TIMESTAMP NOT NULL
DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY(col_a),
UNIQUE INDEX i_ts (col_ts)
) MASTER_1_ENGINE MASTER_1_AUTO_INCREMENT_2_1 MASTER_1_COMMENT_2_1
CREATE TABLE tbl_f (
col_d DATE,
col_t TIME
) ENGINE=Spider COMMENT='database "ts_test_remote", table "tbl_f", srv "s_2_1"'
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(10) unsigned NOT NULL AUTO_INCREMENT,
`col_dt` datetime DEFAULT NULL,
`col_ts` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`col_a`),
UNIQUE KEY `i_ts` (`col_ts`)
) ENGINE=SPIDER AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COMMENT='database "ts_test_remote", table "tbl_a", srv "s_2_1"'
SHOW CREATE TABLE tbl_f;
Table Create Table
tbl_f CREATE TABLE `tbl_f` (
`col_d` date DEFAULT NULL,
`col_t` time DEFAULT NULL
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COMMENT='database "ts_test_remote", table "tbl_f", srv "s_2_1"'
Set a different time zone that has DST
SET time_zone='+01:00';
Insert Rows
connection master_1;
Min value
SET @@timestamp=1;
INSERT INTO tbl_a VALUES (1, now(), now());
SET @@timestamp=0;
Ambiguous DST values for MET time zone that result in the
same UTC timestamp
INSERT INTO tbl_a VALUES (2, '2018-03-25 02:00:00', '2018-03-25 02:00:00');
INSERT INTO tbl_a VALUES (3, '2018-03-25 02:30:00', '2018-03-25 02:30:00');
Ambiguous DST values for MET time zone in the 2:00 am to 3:00 am hour
that occur twice when transitioning from DST to standard time
SET @@timestamp=1540686600;
INSERT INTO tbl_a VALUES (4, now(), now());
SET @@timestamp=1540690200;
INSERT INTO tbl_a VALUES (5, now(), now());
Max value
SET @@timestamp=2147483647;
INSERT INTO tbl_a VALUES (6, now(), now());
SET @@timestamp=0;
SELECTs
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT *, unix_timestamp(col_ts) FROM tbl_a;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %';
argument
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 03:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 03:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 02:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
DELETEs
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
DELETE FROM tbl_a WHERE col_ts='1970-01-01 01:00:01';
SELECT *, unix_timestamp(col_ts) FROM tbl_a;
col_a col_dt col_ts unix_timestamp(col_ts)
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %';
argument
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
2 2018-03-25 02:00:00 2018-03-25 03:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 03:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 02:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SET @@timestamp=1;
INSERT INTO tbl_a VALUES (1, now(), now());
SET @@timestamp=0;
SELECT *, unix_timestamp(col_ts) FROM tbl_a;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %';
argument
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 03:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 03:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 02:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
UPDATEs
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
UPDATE tbl_a SET col_ts=col_dt;
SELECT *, unix_timestamp(col_ts) FROM tbl_a;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %';
argument
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` for update
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 03:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 03:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 02:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
Lookups
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > '2018-01-01';
col_a col_dt col_ts unix_timestamp(col_ts)
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts < '2018-10-28 02:30:00';
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE '2018-10-28 02:30:00' > col_ts;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts BETWEEN '2018-10-28 01:30:00' AND '2018-10-28 02:30:00';
col_a col_dt col_ts unix_timestamp(col_ts)
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts >= '2018-10-28 01:30:00' AND col_ts <= '2018-10-28 02:30:00';
col_a col_dt col_ts unix_timestamp(col_ts)
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 180325020000;
col_a col_dt col_ts unix_timestamp(col_ts)
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 19700101010001;
col_a col_dt col_ts unix_timestamp(col_ts)
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %';
argument
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2017-12-31 23:00:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` < _latin1'2018-10-28 01:30:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (_latin1'2018-10-28 01:30:00' > t0.`col_ts`)
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` between _latin1'2018-10-28 00:30:00' and _latin1'2018-10-28 01:30:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= _latin1'2018-10-28 00:30:00') and (t0.`col_ts` <= _latin1'2018-10-28 01:30:00'))
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2018-03-25 01:00:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01')
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 03:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 03:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 02:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
Drop the index on the timestamp column
connection child2_1;
DROP INDEX i_ts ON tbl_a;
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(10) unsigned NOT NULL AUTO_INCREMENT,
`col_dt` datetime DEFAULT NULL,
`col_ts` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`col_a`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4
TRUNCATE TABLE mysql.general_log;
connection master_1;
DROP INDEX i_ts ON tbl_a;
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(10) unsigned NOT NULL AUTO_INCREMENT,
`col_dt` datetime DEFAULT NULL,
`col_ts` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COMMENT='database "ts_test_remote", table "tbl_a", srv "s_2_1"'
Retry lookups on unindexed timestamp column
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > '2018-01-01';
col_a col_dt col_ts unix_timestamp(col_ts)
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts < '2018-10-28 02:30:00';
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE '2018-10-28 02:30:00' > col_ts;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts BETWEEN '2018-10-28 01:30:00' AND '2018-10-28 02:30:00';
col_a col_dt col_ts unix_timestamp(col_ts)
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts >= '2018-10-28 01:30:00' AND col_ts <= '2018-10-28 02:30:00';
col_a col_dt col_ts unix_timestamp(col_ts)
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 180325020000;
col_a col_dt col_ts unix_timestamp(col_ts)
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 19700101010001;
col_a col_dt col_ts unix_timestamp(col_ts)
2 2018-03-25 02:00:00 2018-03-25 02:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 02:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 01:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %';
argument
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2017-12-31 23:00:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` < _latin1'2018-10-28 01:30:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (_latin1'2018-10-28 01:30:00' > t0.`col_ts`)
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` between _latin1'2018-10-28 00:30:00' and _latin1'2018-10-28 01:30:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= _latin1'2018-10-28 00:30:00') and (t0.`col_ts` <= _latin1'2018-10-28 01:30:00'))
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2018-03-25 01:00:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01')
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
1 1970-01-01 01:00:01 1970-01-01 01:00:01 1
2 2018-03-25 02:00:00 2018-03-25 03:00:00 1521939600
3 2018-03-25 02:30:00 2018-03-25 03:30:00 1521941400
4 2018-10-28 01:30:00 2018-10-28 02:30:00 1540686600
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
Test the TIMESTAMP function
connection master_1;
INSERT INTO tbl_f VALUES ('2018-06-24', '01:23:45'),
('2018-06-24', '01:23:45'),
('2018-08-01', '12:34:56');
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT * FROM tbl_f;
col_d col_t
2018-06-24 01:23:45
2018-06-24 01:23:45
2018-08-01 12:34:56
SELECT TIMESTAMP(col_d, col_t) FROM tbl_f;
TIMESTAMP(col_d, col_t)
2018-06-24 01:23:45
2018-06-24 01:23:45
2018-08-01 12:34:56
SELECT TIMESTAMP('2018-06-25', col_t) FROM tbl_f;
TIMESTAMP('2018-06-25', col_t)
2018-06-25 01:23:45
2018-06-25 01:23:45
2018-06-25 12:34:56
SELECT TIMESTAMP(col_d, '10:43:21') FROM tbl_f;
TIMESTAMP(col_d, '10:43:21')
2018-06-24 10:43:21
2018-06-24 10:43:21
2018-08-01 10:43:21
SELECT TIMESTAMP('2018-06-25', '10:43:21') FROM tbl_f;
TIMESTAMP('2018-06-25', '10:43:21')
2018-06-25 10:43:21
2018-06-25 10:43:21
2018-06-25 10:43:21
connection child2_1;
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %';
argument
select t0.`col_d` `col_d`,t0.`col_t` `col_t` from `ts_test_remote`.`tbl_f` t0
select (timestamp(t0.`col_d` , t0.`col_t`)) `TIMESTAMP(col_d, col_t)` from `ts_test_remote`.`tbl_f` t0
select (timestamp('2018-06-25' , t0.`col_t`)) `TIMESTAMP('2018-06-25', col_t)` from `ts_test_remote`.`tbl_f` t0
select (timestamp(t0.`col_d` , '10:43:21')) `TIMESTAMP(col_d, '10:43:21')` from `ts_test_remote`.`tbl_f` t0
select 1 from `ts_test_remote`.`tbl_f` t0
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'
SELECT col_d, col_t FROM tbl_f;
col_d col_t
2018-06-24 01:23:45
2018-06-24 01:23:45
2018-08-01 12:34:56
Restore Time Zone settings
connection master_1;
SET GLOBAL time_zone=DEFAULT;
SET time_zone=DEFAULT;
connection child2_1;
SET GLOBAL time_zone=DEFAULT;
SET time_zone=DEFAULT;
deinit
connection master_1;
DROP DATABASE IF EXISTS ts_test_local;
connection child2_1;
DROP DATABASE IF EXISTS ts_test_remote;
SET GLOBAL log_output = @old_log_output;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test
|