File: binlog_multi_valued_index.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (72 lines) | stat: -rw-r--r-- 2,638 bytes parent folder | download
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
--source include/have_log_bin.inc
--source include/have_binlog_format_row.inc
--source include/have_grep.inc

# ==== Requirements ====
#
# R1. When using binlog_transaction_dependency_tracking = 'WRITESET', two
#   transactions that conflict on a unique multi-valued index must be marked as
#   dependent in the binary log.
# R2. When using binlog_row_image=MINIMAL, the before-image shall not be
#   generated from a multi-valued index.
#
# ==== Implementation ====
#
# To test R1:
# 1. Create a table with a multi-valued index
# 2. Insert rows that conflict only on a multi-valued index
# 3. Verify that the logical timestamps are set in a way that indicates the
#  transactions are dependent
#
# To test R2;
# 1. Set binlog_row_image=MINIMAL
# 2. Create a table having only one index, a unique multi-valued index
# 3. Update/delete rows
# 4. Use mysqlbinlog -v -v to verify that the full row is included, and not
#  just the columns of the multi-valued index
#
# ==== References ====
#
# WL#8955: Add support for multi-valued indexes

--let $mysqlbinlog_only_decoded_rows = 1
--source include/save_binlog_position.inc

CREATE TABLE t1 (id INT, c INT, j JSON NOT NULL,
  UNIQUE INDEX i1((CAST(CAST(j AS JSON) AS UNSIGNED ARRAY))));
SET @@session.binlog_row_image = MINIMAL;
INSERT INTO t1 VALUES (1, 1, '[1,2,3,4]'), (2, 2, '[5,6,7,8]');
UPDATE t1 SET j = '[9,0]' WHERE JSON_CONTAINS(CAST(j AS JSON),'2');
SET @@session.binlog_row_image = FULL;
INSERT INTO t1 VALUES (10, 10, '[10,20,30,40]'), (20, 20, '[50,60,70,80]');
UPDATE t1 SET j = '[11,12,13,14]' WHERE JSON_CONTAINS(CAST(j AS JSON),'10');
SET @@session.binlog_row_image = NOBLOB;
INSERT INTO t1 VALUES (100, 100, '[100,200,300,400]'),
  (200, 200, '[500,600,700,800]');
UPDATE t1 SET j = '[101,201,301,401]' WHERE JSON_CONTAINS(CAST(j AS JSON),'200');
DROP TABLE t1;

FLUSH LOGS;
--source include/mysqlbinlog.inc
--source include/save_binlog_position.inc

--echo # Check that when the only unique NOT NULL index is a functional index,
--echo # the binary log contains a full before-image regardless of
--echo # binlog_row_image.
CREATE TABLE t1 (id INT, c INT, j JSON NOT NULL,
  UNIQUE INDEX i1((CAST(CAST(j AS JSON) AS UNSIGNED ARRAY))));
INSERT INTO t1 VALUES (1, 1, '[1,2,3,4]'), (2, 2, '[5,6,7,8]');

SET binlog_row_image = MINIMAL;
UPDATE t1 SET j = '[2,9,10]' WHERE JSON_CONTAINS(CAST(j AS JSON),'2');

SET binlog_row_image = FULL;
UPDATE t1 SET j = '[2,11,12]' WHERE JSON_CONTAINS(CAST(j AS JSON),'2');

SET binlog_row_image = NOBLOB;
UPDATE t1 SET j = '[2,13,14]' WHERE JSON_CONTAINS(CAST(j AS JSON),'2');

DROP TABLE t1;

FLUSH LOGS;
--source include/mysqlbinlog.inc