~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to plugin/transaction_log/tests/r/transaction_log_delete.result

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Testing DELETE basic 
2
 
DROP TABLE IF EXISTS t1, t2;
3
 
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
4
 
INSERT INTO t1 (b) VALUES (10),(20),(30),(40),(50),(60);
5
 
DELETE FROM t1;
6
 
Check transaction_log_entries
7
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
8
 
COUNT(*)
9
 
3
10
 
 
11
 
Check transaction_log_transactions
12
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
13
 
COUNT(*)
14
 
3
15
 
Check transaction log contents
16
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
17
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
18
 
transaction_context {
19
 
  server_id: 1
20
 
  TRANSACTION_ID
21
 
  START_TIMESTAMP
22
 
  END_TIMESTAMP
23
 
}
24
 
statement {
25
 
  type: DELETE
26
 
  START_TIMESTAMP
27
 
  END_TIMESTAMP
28
 
  delete_header {
29
 
    table_metadata {
30
 
      schema_name: "test"
31
 
      table_name: "t1"
32
 
    }
33
 
    key_field_metadata {
34
 
      type: INTEGER
35
 
      name: "a"
36
 
    }
37
 
  }
38
 
  delete_data {
39
 
    segment_id: 1
40
 
    end_segment: true
41
 
    record {
42
 
      key_value: "1"
43
 
    }
44
 
    record {
45
 
      key_value: "2"
46
 
    }
47
 
    record {
48
 
      key_value: "3"
49
 
    }
50
 
    record {
51
 
      key_value: "4"
52
 
    }
53
 
    record {
54
 
      key_value: "5"
55
 
    }
56
 
    record {
57
 
      key_value: "6"
58
 
    }
59
 
  }
60
 
}
61
 
segment_id: 1
62
 
end_segment: true
63
 
 
64
 
 
65
 
COMMIT;
66
 
 
67
 
DROP TABLE t1;
68
 
SET GLOBAL transaction_log_truncate_debug= true;
69
 
 
70
 
Testing simple DELETE with WHERE 
71
 
DROP TABLE IF EXISTS t1, t2;
72
 
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, c CHAR(100), PRIMARY KEY(a));
73
 
INSERT INTO t1 (b,c) VALUES (10,'a'),(20,'b'),(30,'c'),(40,'d'),(50,'e'),(60,'f');
74
 
DELETE FROM t1 WHERE a%2=0 ;
75
 
Check transaction_log_entries
76
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
77
 
COUNT(*)
78
 
3
79
 
 
80
 
Check transaction_log_transactions
81
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
82
 
COUNT(*)
83
 
3
84
 
Check transaction log contents
85
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
86
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
87
 
transaction_context {
88
 
  server_id: 1
89
 
  TRANSACTION_ID
90
 
  START_TIMESTAMP
91
 
  END_TIMESTAMP
92
 
}
93
 
statement {
94
 
  type: DELETE
95
 
  START_TIMESTAMP
96
 
  END_TIMESTAMP
97
 
  delete_header {
98
 
    table_metadata {
99
 
      schema_name: "test"
100
 
      table_name: "t1"
101
 
    }
102
 
    key_field_metadata {
103
 
      type: INTEGER
104
 
      name: "a"
105
 
    }
106
 
  }
107
 
  delete_data {
108
 
    segment_id: 1
109
 
    end_segment: true
110
 
    record {
111
 
      key_value: "2"
112
 
    }
113
 
    record {
114
 
      key_value: "4"
115
 
    }
116
 
    record {
117
 
      key_value: "6"
118
 
    }
119
 
  }
120
 
}
121
 
segment_id: 1
122
 
end_segment: true
123
 
 
124
 
 
125
 
COMMIT;
126
 
 
127
 
DROP TABLE t1;
128
 
SET GLOBAL transaction_log_truncate_debug= true;
129
 
 
130
 
Testing simple DELETE with WHERE + LIMIT
131
 
DROP TABLE IF EXISTS t1, t2;
132
 
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, c CHAR(100), PRIMARY KEY(a));
133
 
INSERT INTO t1 (b,c) VALUES (10,'a'),(20,'b'),(30,'c'),(40,'d'),(50,'e'),(60,'f');
134
 
DELETE FROM t1 WHERE a%2=0 LIMIT 1;
135
 
Check transaction_log_entries
136
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
137
 
COUNT(*)
138
 
3
139
 
 
140
 
Check transaction_log_transactions
141
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
142
 
COUNT(*)
143
 
3
144
 
Check transaction log contents
145
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
146
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
147
 
transaction_context {
148
 
  server_id: 1
149
 
  TRANSACTION_ID
150
 
  START_TIMESTAMP
151
 
  END_TIMESTAMP
152
 
}
153
 
statement {
154
 
  type: DELETE
155
 
  START_TIMESTAMP
156
 
  END_TIMESTAMP
157
 
  delete_header {
158
 
    table_metadata {
159
 
      schema_name: "test"
160
 
      table_name: "t1"
161
 
    }
162
 
    key_field_metadata {
163
 
      type: INTEGER
164
 
      name: "a"
165
 
    }
166
 
  }
167
 
  delete_data {
168
 
    segment_id: 1
169
 
    end_segment: true
170
 
    record {
171
 
      key_value: "2"
172
 
    }
173
 
  }
174
 
}
175
 
segment_id: 1
176
 
end_segment: true
177
 
 
178
 
 
179
 
COMMIT;
180
 
 
181
 
DROP TABLE t1;
182
 
SET GLOBAL transaction_log_truncate_debug= true;
183
 
 
184
 
Testing simple DELETE with WHERE + LIMIT + ORDER BY1 
185
 
DROP TABLE IF EXISTS t1, t2;
186
 
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, c CHAR(100), PRIMARY KEY(a));
187
 
INSERT INTO t1 (b,c) VALUES (10,'a'),(20,'b'),(30,'c'),(40,'d'),(50,'e'),(60,'f');
188
 
DELETE FROM t1 WHERE a%2=0 ORDER BY a DESC LIMIT 1;
189
 
Check transaction_log_entries
190
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
191
 
COUNT(*)
192
 
3
193
 
 
194
 
Check transaction_log_transactions
195
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
196
 
COUNT(*)
197
 
3
198
 
Check transaction log contents
199
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
200
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
201
 
transaction_context {
202
 
  server_id: 1
203
 
  TRANSACTION_ID
204
 
  START_TIMESTAMP
205
 
  END_TIMESTAMP
206
 
}
207
 
statement {
208
 
  type: DELETE
209
 
  START_TIMESTAMP
210
 
  END_TIMESTAMP
211
 
  delete_header {
212
 
    table_metadata {
213
 
      schema_name: "test"
214
 
      table_name: "t1"
215
 
    }
216
 
    key_field_metadata {
217
 
      type: INTEGER
218
 
      name: "a"
219
 
    }
220
 
  }
221
 
  delete_data {
222
 
    segment_id: 1
223
 
    end_segment: true
224
 
    record {
225
 
      key_value: "6"
226
 
    }
227
 
  }
228
 
}
229
 
segment_id: 1
230
 
end_segment: true
231
 
 
232
 
 
233
 
COMMIT;
234
 
 
235
 
DROP TABLE t1;
236
 
SET GLOBAL transaction_log_truncate_debug= true;
237
 
 
238
 
Testing simple DELETE with WHERE + LIMIT + ORDER BY2
239
 
DROP TABLE IF EXISTS t1, t2;
240
 
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, c CHAR(100), PRIMARY KEY(a));
241
 
INSERT INTO t1 (b,c) VALUES (10,'a'),(20,'b'),(30,'c'),(40,'d'),(50,'e'),(60,'f');
242
 
DELETE FROM t1 WHERE a%2=0 ORDER BY a DESC LIMIT 10000;
243
 
Check transaction_log_entries
244
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
245
 
COUNT(*)
246
 
3
247
 
 
248
 
Check transaction_log_transactions
249
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
250
 
COUNT(*)
251
 
3
252
 
Check transaction log contents
253
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
254
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
255
 
transaction_context {
256
 
  server_id: 1
257
 
  TRANSACTION_ID
258
 
  START_TIMESTAMP
259
 
  END_TIMESTAMP
260
 
}
261
 
statement {
262
 
  type: DELETE
263
 
  START_TIMESTAMP
264
 
  END_TIMESTAMP
265
 
  delete_header {
266
 
    table_metadata {
267
 
      schema_name: "test"
268
 
      table_name: "t1"
269
 
    }
270
 
    key_field_metadata {
271
 
      type: INTEGER
272
 
      name: "a"
273
 
    }
274
 
  }
275
 
  delete_data {
276
 
    segment_id: 1
277
 
    end_segment: true
278
 
    record {
279
 
      key_value: "6"
280
 
    }
281
 
    record {
282
 
      key_value: "4"
283
 
    }
284
 
    record {
285
 
      key_value: "2"
286
 
    }
287
 
  }
288
 
}
289
 
segment_id: 1
290
 
end_segment: true
291
 
 
292
 
 
293
 
COMMIT;
294
 
 
295
 
DROP TABLE t1;
296
 
SET GLOBAL transaction_log_truncate_debug= true;
297
 
 
298
 
Testing DELETE - Foreign Key constraints CASCADE
299
 
DROP TABLE IF EXISTS t1, t2;
300
 
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
301
 
CREATE TABLE t2(a INT NOT NULL AUTO_INCREMENT, b INT , PRIMARY KEY(a), KEY b_key (b),
302
 
CONSTRAINT fk_constraint_t2 FOREIGN KEY (b) REFERENCES t1(b) ON DELETE CASCADE ON UPDATE CASCADE);
303
 
INSERT INTO t1 (b) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(100),(101);
304
 
INSERT INTO t2 (b) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(100),(101);
305
 
DELETE FROM t1 WHERE b%2=0;
306
 
Check transaction_log_entries
307
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
308
 
COUNT(*)
309
 
5
310
 
 
311
 
Check transaction_log_transactions
312
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
313
 
COUNT(*)
314
 
5
315
 
Check transaction log contents
316
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
317
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
318
 
transaction_context {
319
 
  server_id: 1
320
 
  TRANSACTION_ID
321
 
  START_TIMESTAMP
322
 
  END_TIMESTAMP
323
 
}
324
 
statement {
325
 
  type: DELETE
326
 
  START_TIMESTAMP
327
 
  END_TIMESTAMP
328
 
  delete_header {
329
 
    table_metadata {
330
 
      schema_name: "test"
331
 
      table_name: "t1"
332
 
    }
333
 
    key_field_metadata {
334
 
      type: INTEGER
335
 
      name: "a"
336
 
    }
337
 
  }
338
 
  delete_data {
339
 
    segment_id: 1
340
 
    end_segment: true
341
 
    record {
342
 
      key_value: "2"
343
 
    }
344
 
    record {
345
 
      key_value: "4"
346
 
    }
347
 
    record {
348
 
      key_value: "6"
349
 
    }
350
 
    record {
351
 
      key_value: "8"
352
 
    }
353
 
    record {
354
 
      key_value: "10"
355
 
    }
356
 
    record {
357
 
      key_value: "11"
358
 
    }
359
 
  }
360
 
}
361
 
segment_id: 1
362
 
end_segment: true
363
 
 
364
 
 
365
 
COMMIT;
366
 
 
367
 
DROP TABLE t2;
368
 
DROP TABLE t1;
369
 
SET GLOBAL transaction_log_truncate_debug= true;
370
 
 
371
 
SET GLOBAL transaction_log_truncate_debug= true;
372
 
 
373
 
Testing DELETE - Foreign Key constraints SET NULL 
374
 
DROP TABLE IF EXISTS t1, t2;
375
 
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
376
 
CREATE TABLE t2(a INT NOT NULL AUTO_INCREMENT, b INT , PRIMARY KEY(a), KEY b_key (b),
377
 
CONSTRAINT fk_constraint_t2 FOREIGN KEY (b) REFERENCES t1(b) ON DELETE SET NULL ON UPDATE CASCADE);
378
 
INSERT INTO t1 (b) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(100),(101);
379
 
INSERT INTO t2 (b) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(100),(101);
380
 
DELETE FROM t1 WHERE b%2=0;
381
 
Check transaction_log_entries
382
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
383
 
COUNT(*)
384
 
5
385
 
 
386
 
Check transaction_log_transactions
387
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
388
 
COUNT(*)
389
 
5
390
 
Check transaction log contents
391
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
392
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
393
 
transaction_context {
394
 
  server_id: 1
395
 
  TRANSACTION_ID
396
 
  START_TIMESTAMP
397
 
  END_TIMESTAMP
398
 
}
399
 
statement {
400
 
  type: DELETE
401
 
  START_TIMESTAMP
402
 
  END_TIMESTAMP
403
 
  delete_header {
404
 
    table_metadata {
405
 
      schema_name: "test"
406
 
      table_name: "t1"
407
 
    }
408
 
    key_field_metadata {
409
 
      type: INTEGER
410
 
      name: "a"
411
 
    }
412
 
  }
413
 
  delete_data {
414
 
    segment_id: 1
415
 
    end_segment: true
416
 
    record {
417
 
      key_value: "2"
418
 
    }
419
 
    record {
420
 
      key_value: "4"
421
 
    }
422
 
    record {
423
 
      key_value: "6"
424
 
    }
425
 
    record {
426
 
      key_value: "8"
427
 
    }
428
 
    record {
429
 
      key_value: "10"
430
 
    }
431
 
    record {
432
 
      key_value: "11"
433
 
    }
434
 
  }
435
 
}
436
 
segment_id: 1
437
 
end_segment: true
438
 
 
439
 
 
440
 
COMMIT;
441
 
 
442
 
DROP TABLE t2;
443
 
DROP TABLE t1;
444
 
SET GLOBAL transaction_log_truncate_debug= true;
445
 
 
446
 
SET GLOBAL transaction_log_truncate_debug= true;
447
 
 
448
 
Testing DELETE - Foreign Key constraints CASCADE
449
 
DROP TABLE IF EXISTS t1, t2;
450
 
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
451
 
CREATE TABLE t2(a INT NOT NULL AUTO_INCREMENT, b INT , PRIMARY KEY(a), KEY b_key (b),
452
 
CONSTRAINT fk_constraint_t2 FOREIGN KEY (b) REFERENCES t1(b) ON DELETE RESTRICT ON UPDATE CASCADE);
453
 
INSERT INTO t1 (b) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(100),(101);
454
 
INSERT INTO t2 (b) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(100),(101);
455
 
DELETE FROM t1 WHERE b%2=0;
456
 
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_constraint_t2` FOREIGN KEY (`b`) REFERENCES `t1` (`b`) ON UPDATE CASCADE)
457
 
Check transaction_log_entries
458
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
459
 
COUNT(*)
460
 
4
461
 
 
462
 
Check transaction_log_transactions
463
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
464
 
COUNT(*)
465
 
4
466
 
Check transaction log contents
467
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
468
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
469
 
transaction_context {
470
 
  server_id: 1
471
 
  TRANSACTION_ID
472
 
  START_TIMESTAMP
473
 
  END_TIMESTAMP
474
 
}
475
 
statement {
476
 
  type: INSERT
477
 
  START_TIMESTAMP
478
 
  END_TIMESTAMP
479
 
  insert_header {
480
 
    table_metadata {
481
 
      schema_name: "test"
482
 
      table_name: "t2"
483
 
    }
484
 
    field_metadata {
485
 
      type: INTEGER
486
 
      name: "a"
487
 
    }
488
 
    field_metadata {
489
 
      type: INTEGER
490
 
      name: "b"
491
 
    }
492
 
  }
493
 
  insert_data {
494
 
    segment_id: 1
495
 
    end_segment: true
496
 
    record {
497
 
      insert_value: "1"
498
 
      insert_value: "1"
499
 
      is_null: false
500
 
      is_null: false
501
 
    }
502
 
    record {
503
 
      insert_value: "2"
504
 
      insert_value: "2"
505
 
      is_null: false
506
 
      is_null: false
507
 
    }
508
 
    record {
509
 
      insert_value: "3"
510
 
      insert_value: "3"
511
 
      is_null: false
512
 
      is_null: false
513
 
    }
514
 
    record {
515
 
      insert_value: "4"
516
 
      insert_value: "4"
517
 
      is_null: false
518
 
      is_null: false
519
 
    }
520
 
    record {
521
 
      insert_value: "5"
522
 
      insert_value: "5"
523
 
      is_null: false
524
 
      is_null: false
525
 
    }
526
 
    record {
527
 
      insert_value: "6"
528
 
      insert_value: "6"
529
 
      is_null: false
530
 
      is_null: false
531
 
    }
532
 
    record {
533
 
      insert_value: "7"
534
 
      insert_value: "7"
535
 
      is_null: false
536
 
      is_null: false
537
 
    }
538
 
    record {
539
 
      insert_value: "8"
540
 
      insert_value: "8"
541
 
      is_null: false
542
 
      is_null: false
543
 
    }
544
 
    record {
545
 
      insert_value: "9"
546
 
      insert_value: "9"
547
 
      is_null: false
548
 
      is_null: false
549
 
    }
550
 
    record {
551
 
      insert_value: "10"
552
 
      insert_value: "10"
553
 
      is_null: false
554
 
      is_null: false
555
 
    }
556
 
    record {
557
 
      insert_value: "11"
558
 
      insert_value: "100"
559
 
      is_null: false
560
 
      is_null: false
561
 
    }
562
 
    record {
563
 
      insert_value: "12"
564
 
      insert_value: "101"
565
 
      is_null: false
566
 
      is_null: false
567
 
    }
568
 
  }
569
 
}
570
 
segment_id: 1
571
 
end_segment: true
572
 
 
573
 
 
574
 
COMMIT;
575
 
 
576
 
DROP TABLE t2;
577
 
DROP TABLE t1;
578
 
SET GLOBAL transaction_log_truncate_debug= true;
579
 
 
580
 
Testing DELETE basic2 
581
 
DROP TABLE IF EXISTS t1;
582
 
CREATE TABLE t1 (
583
 
id INT NOT NULL
584
 
, padding VARCHAR(200) NOT NULL
585
 
, PRIMARY KEY (id)
586
 
);
587
 
INSERT INTO t1 VALUES (1, "I love testing.");
588
 
INSERT INTO t1 VALUES (2, "I hate testing.");
589
 
DELETE FROM t1 where id = 1;
590
 
Check transaction_log_entries
591
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
592
 
COUNT(*)
593
 
4
594
 
 
595
 
Check transaction_log_transactions
596
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
597
 
COUNT(*)
598
 
4
599
 
Check transaction log contents
600
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
601
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
602
 
transaction_context {
603
 
  server_id: 1
604
 
  TRANSACTION_ID
605
 
  START_TIMESTAMP
606
 
  END_TIMESTAMP
607
 
}
608
 
statement {
609
 
  type: DELETE
610
 
  START_TIMESTAMP
611
 
  END_TIMESTAMP
612
 
  delete_header {
613
 
    table_metadata {
614
 
      schema_name: "test"
615
 
      table_name: "t1"
616
 
    }
617
 
    key_field_metadata {
618
 
      type: INTEGER
619
 
      name: "id"
620
 
    }
621
 
  }
622
 
  delete_data {
623
 
    segment_id: 1
624
 
    end_segment: true
625
 
    record {
626
 
      key_value: "1"
627
 
    }
628
 
  }
629
 
}
630
 
segment_id: 1
631
 
end_segment: true
632
 
 
633
 
 
634
 
COMMIT;
635
 
 
636
 
DROP TABLE t1;
637
 
SET GLOBAL transaction_log_truncate_debug= true;
638
 
 
639
 
Testing DELETE / TRUNCATE optimization
640
 
CREATE TABLE t1 (
641
 
id INT NOT NULL
642
 
, other INT NOT NULL
643
 
, PRIMARY KEY (id)
644
 
);
645
 
INSERT INTO t1 VALUES (1, 1);
646
 
INSERT INTO t1 VALUES (2, 2);
647
 
INSERT INTO t1 VALUES (3, 3);
648
 
INSERT INTO t1 VALUES (4, 4);
649
 
INSERT INTO t1 VALUES (5, 5);
650
 
INSERT INTO t1 VALUES (6, 6);
651
 
INSERT INTO t1 VALUES (7, 7);
652
 
INSERT INTO t1 VALUES (8, 8);
653
 
This should produce a TRUNCATE event
654
 
DELETE FROM t1;
655
 
Check transaction_log_entries
656
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
657
 
COUNT(*)
658
 
10
659
 
 
660
 
Check transaction_log_transactions
661
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
662
 
COUNT(*)
663
 
10
664
 
Check transaction log contents
665
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
666
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
667
 
transaction_context {
668
 
  server_id: 1
669
 
  TRANSACTION_ID
670
 
  START_TIMESTAMP
671
 
  END_TIMESTAMP
672
 
}
673
 
statement {
674
 
  type: DELETE
675
 
  START_TIMESTAMP
676
 
  END_TIMESTAMP
677
 
  delete_header {
678
 
    table_metadata {
679
 
      schema_name: "test"
680
 
      table_name: "t1"
681
 
    }
682
 
    key_field_metadata {
683
 
      type: INTEGER
684
 
      name: "id"
685
 
    }
686
 
  }
687
 
  delete_data {
688
 
    segment_id: 1
689
 
    end_segment: true
690
 
    record {
691
 
      key_value: "1"
692
 
    }
693
 
    record {
694
 
      key_value: "2"
695
 
    }
696
 
    record {
697
 
      key_value: "3"
698
 
    }
699
 
    record {
700
 
      key_value: "4"
701
 
    }
702
 
    record {
703
 
      key_value: "5"
704
 
    }
705
 
    record {
706
 
      key_value: "6"
707
 
    }
708
 
    record {
709
 
      key_value: "7"
710
 
    }
711
 
    record {
712
 
      key_value: "8"
713
 
    }
714
 
  }
715
 
}
716
 
segment_id: 1
717
 
end_segment: true
718
 
 
719
 
 
720
 
COMMIT;
721
 
 
722
 
DROP TABLE t1;
723
 
SET GLOBAL transaction_log_truncate_debug= true;
724
 
 
725
 
Testing DELETE Bug#496101
726
 
DROP TABLE IF EXISTS t1;
727
 
CREATE TABLE t1 (
728
 
id INT NOT NULL
729
 
, padding VARCHAR(200) NOT NULL
730
 
, PRIMARY KEY (id)
731
 
);
732
 
START TRANSACTION;
733
 
INSERT INTO t1 VALUES (1, "I love testing.");
734
 
INSERT INTO t1 VALUES (2, "I hate testing.");
735
 
DELETE FROM t1 where id = 1;
736
 
COMMIT;
737
 
Check transaction_log_entries
738
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
739
 
COUNT(*)
740
 
2
741
 
 
742
 
Check transaction_log_transactions
743
 
SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
744
 
COUNT(*)
745
 
2
746
 
Check transaction log contents
747
 
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
748
 
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
749
 
transaction_context {
750
 
  server_id: 1
751
 
  TRANSACTION_ID
752
 
  START_TIMESTAMP
753
 
  END_TIMESTAMP
754
 
}
755
 
statement {
756
 
  type: INSERT
757
 
  START_TIMESTAMP
758
 
  END_TIMESTAMP
759
 
  insert_header {
760
 
    table_metadata {
761
 
      schema_name: "test"
762
 
      table_name: "t1"
763
 
    }
764
 
    field_metadata {
765
 
      type: INTEGER
766
 
      name: "id"
767
 
    }
768
 
    field_metadata {
769
 
      type: VARCHAR
770
 
      name: "padding"
771
 
    }
772
 
  }
773
 
  insert_data {
774
 
    segment_id: 1
775
 
    end_segment: true
776
 
    record {
777
 
      insert_value: "1"
778
 
      insert_value: "I love testing."
779
 
      is_null: false
780
 
      is_null: false
781
 
    }
782
 
  }
783
 
}
784
 
statement {
785
 
  type: INSERT
786
 
  START_TIMESTAMP
787
 
  END_TIMESTAMP
788
 
  insert_header {
789
 
    table_metadata {
790
 
      schema_name: "test"
791
 
      table_name: "t1"
792
 
    }
793
 
    field_metadata {
794
 
      type: INTEGER
795
 
      name: "id"
796
 
    }
797
 
    field_metadata {
798
 
      type: VARCHAR
799
 
      name: "padding"
800
 
    }
801
 
  }
802
 
  insert_data {
803
 
    segment_id: 1
804
 
    end_segment: true
805
 
    record {
806
 
      insert_value: "2"
807
 
      insert_value: "I hate testing."
808
 
      is_null: false
809
 
      is_null: false
810
 
    }
811
 
  }
812
 
}
813
 
statement {
814
 
  type: DELETE
815
 
  START_TIMESTAMP
816
 
  END_TIMESTAMP
817
 
  delete_header {
818
 
    table_metadata {
819
 
      schema_name: "test"
820
 
      table_name: "t1"
821
 
    }
822
 
    key_field_metadata {
823
 
      type: INTEGER
824
 
      name: "id"
825
 
    }
826
 
  }
827
 
  delete_data {
828
 
    segment_id: 1
829
 
    end_segment: true
830
 
    record {
831
 
      key_value: "1"
832
 
    }
833
 
  }
834
 
}
835
 
segment_id: 1
836
 
end_segment: true
837
 
 
838
 
 
839
 
COMMIT;
840
 
 
841
 
DROP TABLE t1;
842
 
SET GLOBAL transaction_log_truncate_debug= true;
843