Debian Codegraph @

mysql-test/suite/ndb/t/ndb_blob_corrupt.test

raw
1 -- source include/have_ndb.inc
2 -- source suite/ndb/include/backup_restore_setup.inc
3
4 # Test is using error insert, check that binaries support it
5 --source have_ndb_error_insert.inc
6
7 create table t1 (a int primary key,
8 utf_t text character set utf8mb4,
9 tb tinyblob, b blob, mb mediumblob, lb longblob,
10 tt tinytext, t text, mt mediumtext, lt longtext) engine=ndb;
11
12 insert into t1 values (1, REPEAT("A",5000),
13 REPEAT("A",255), REPEAT("A",5000), REPEAT("A",65536), REPEAT("A", 30000),
14 REPEAT("A",255), REPEAT("A",5000), REPEAT("A",65536), REPEAT("A", 30000));
15 insert into t1 values (2, NULL,
16 NULL, NULL, NULL, NULL,
17 NULL, NULL, NULL, NULL);
18 insert into t1 values (3, "",
19 "", "", "", "",
20 "", "", "", "");
21 insert into t1 values (4, REPEAT("a%d4 ",51),
22 REPEAT("a%d4 ",51), REPEAT("a%d4 ",1000), REPEAT("a%d4 ",2000), REPEAT("a%d4 ", 6000),
23 REPEAT("a%d4 ",51), REPEAT("a%d4 ",1000), REPEAT("a%d4 ",2000), REPEAT("a%d4 ", 6000));
24 insert into t1 values (5, "less_than_inline_len",
25 "less_than_inline_len", "less_than_inline_len", "less_than_inline_len", "less_than_inline_len",
26 "less_than_inline_len", "less_than_inline_len", "less_than_inline_len", "less_than_inline_len");
27 insert into t1 values (6, REPEAT(" ",1000),
28 REPEAT(" ",51), REPEAT(" ",1000), REPEAT(" ",2000), REPEAT(" ", 6000),
29 REPEAT(" ",51), REPEAT(" ",1000), REPEAT(" ",2000), REPEAT(" ", 6000));
30 insert into t1 values (7, REPEAT(" -,.;",1000),
31 REPEAT(" -,.;",51), REPEAT(" -,.;",1000), REPEAT(" -,.;",2000), REPEAT(" -,.;", 6000),
32 REPEAT(" -,.;",51), REPEAT(" -,.;",1000), REPEAT(" -,.;",2001), REPEAT(" -,.;", 6000));
33 insert into t1 values (8, REPEAT("12345",1000),
34 REPEAT("12345",51), REPEAT("12345",1000), REPEAT("12345",2000), REPEAT("12345", 6000),
35 REPEAT("12345",51), REPEAT("12345",1000), REPEAT("12345",2001), REPEAT("12345", 6000));
36 insert into t1 values (9, REPEAT("abcde",1000),
37 REPEAT("abcde",51), REPEAT("abcde",1000), REPEAT("abcde",2000), REPEAT("abcde", 6000),
38 REPEAT("abcde",51), REPEAT("abcde",1000), REPEAT("abcde",2001), REPEAT("abcde", 6000));
39 insert into t1 values (10, REPEAT("ABCDE",1000),
40 REPEAT("ABCDE",51), REPEAT("ABCDE",1000), REPEAT("ABCDE",2000), REPEAT("ABCDE", 6000),
41 REPEAT("ABCDE",51), REPEAT("ABCDE",1000), REPEAT("ABCDE",2001), REPEAT("ABCDE", 6000));
42
43 insert into t1 select a+10, utf_t, tb, b, mb, lb, tt, t, mt, lt from t1;
44 insert into t1 select a+20, utf_t, tb, b, mb, lb, tt, t, mt, lt from t1;
45
46 --echo # run backup
47 --source include/ndb_backup.inc
48
49 truncate table t1;
50
51 --echo # run broken restore of data
52
53 --exec $NDB_RESTORE -b $the_backup_id -n 1 --print-data -r --error-insert=2 $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
54 --exec $NDB_RESTORE -b $the_backup_id -n 2 --print-data -r --error-insert=2 $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
55
56 select count(1) into @count_parent_rows_before from t1;
57
58 --echo Observe "blob corruption error" failures on queries
59
60 --echo Fully ordered OI scan
61 --error 1296
62 select * from test.t1 order by a;
63 show warnings limit 1;
64
65 --echo Fully ordered OI scan, different first tuple
66 --error 1296
67 select * from test.t1 order by a desc;
68 show warnings limit 1;
69
70 --echo OI scan
71 --error 1296
72 select * from test.t1 where a > 0;
73 show warnings limit 1;
74
75 --echo OI scan, different first tuple
76 --error 1296
77 select * from test.t1 where a < 6;
78 show warnings limit 1;
79
80 --echo Table scan
81 --error 1296
82 select * from test.t1;
83 show warnings limit 1;
84
85 --echo ndb_blob_tool errors out on finding missing blob parts
86 --error 1
87 --exec $NDB_BLOB_TOOL --check-missing -dtest t1 >> $NDB_TOOLS_OUTPUT 2>&1
88
89 --echo Add in missing parts
90 --exec $NDB_BLOB_TOOL --add-missing -dtest t1 >> $NDB_TOOLS_OUTPUT 2>&1
91 --exec $NDB_BLOB_TOOL --delete-orphans -dtest t1 >> $NDB_TOOLS_OUTPUT 2>&1
92
93 --echo Verify that there are no missing parts or orphan rows
94 --exec $NDB_BLOB_TOOL --check-missing -dtest t1 >> $NDB_TOOLS_OUTPUT 2>&1
95 --exec $NDB_BLOB_TOOL --check-orphans -dtest t1 >> $NDB_TOOLS_OUTPUT 2>&1
96
97 --echo Show that data read is not an empty set
98 select count(1) into @count_parent_rows_after from t1;
99 select sum(a) > 0, sum(utf_t) > 0,
100 sum(tb) > 0, sum(b) > 0, sum(mb) > 0, sum(lb) > 0,
101 sum(tt) > 0, sum(t) > 0, sum(mt) > 0, sum(lt) > 0 from t1;
102
103 select @count_parent_rows_before >= @count_parent_rows_after;
104 select @count_parent_rows_after > 0;
105
106 drop table t1;
107
108 --echo Verify that blob deletes with scans handle pending blob writes correctly
109 create table t1 (pk bigint unsigned auto_increment primary key , blob_col TEXT)engine=ndbcluster;
110 create table t2 (pk bigint unsigned auto_increment primary key , varchar_col varchar(100), virtual_blob_col TEXT as (REPEAT(varchar_col,40)) VIRTUAL)engine=ndbcluster;
111
112 insert into t1 (pk, blob_col) values(NULL,NULL);
113 insert into t1 select NULL, NULL from t1;
114 insert into t1 select NULL, NULL from t1;
115 insert into t1 select NULL, NULL from t1;
116 insert into t1 select NULL, NULL from t1;
117
118 insert into t2 (pk, varchar_col) select pk, blob_col from t1;
119
120 update t1 set blob_col = repeat('mysql', 2000) limit 8;
121 update t2 set varchar_col = repeat('mysql', 20) limit 8;
122
123 set ndb_blob_write_batch_bytes=0;
124 set ndb_blob_read_batch_bytes=0;
125
126 create table ndb_blob_corrupt_temp_table(pk varchar(10) primary key, exec_count_serialised int, exec_count_batched int)engine=ndb;
127 let temp_table=ndb_blob_corrupt_temp_table;
128 insert into ndb_blob_corrupt_temp_table values
129 ("DELETE", 0, 0), ("UPDATE", 0, 0);
130
131 --echo update with blob column in WHERE clause
132 ## Must serialise for correct execution of blob updates, so exec count high
133
134 --source suite/ndb/include/ndb_init_execute_count.inc
135 let temp_pk = "UPDATE";
136 let temp_col = exec_count_serialised;
137 update t1 set blob_col = repeat('mysql', 400) where blob_col like '%mysql%';
138 --source suite/ndb/include/ndb_execute_count_load.inc
139
140 --echo update with virtual blob column in WHERE clause
141 ## No need to serialise for blobs since blob is virtual, allow batching for lower exec count
142
143 --source suite/ndb/include/ndb_init_execute_count.inc
144 let temp_pk = "UPDATE";
145 let temp_col = exec_count_batched;
146 update t2 set varchar_col = repeat('mysql', 10) where virtual_blob_col like '%mysql%';
147 --source suite/ndb/include/ndb_execute_count_load.inc
148
149 --echo delete with blob column in WHERE clause
150 ## Must serialise for correct execution of blob deletes, so exec count high
151
152 --source suite/ndb/include/ndb_init_execute_count.inc
153 let temp_pk = "DELETE";
154 let temp_col = exec_count_serialised;
155 delete from t1 where blob_col is NOT NULL;
156 --source suite/ndb/include/ndb_execute_count_load.inc
157
158 --echo delete with virtual blob column in WHERE clause
159 ## No need to serialise for blobs since blob is virtual, allow batching for lower exec count
160
161 --source suite/ndb/include/ndb_init_execute_count.inc
162 let temp_pk = "DELETE";
163 let temp_col = exec_count_batched;
164 delete from t2 where virtual_blob_col is NOT NULL;
165 --source suite/ndb/include/ndb_execute_count_load.inc
166
167 ## Check that all DELETES/UPDATES which should be serialised for blob exec show
168 ## effects of serialisation, i.e. higher exec counts than batched equivalents
169 select exec_count_serialised > exec_count_batched from ndb_blob_corrupt_temp_table;
170
171 drop table ndb_blob_corrupt_temp_table;
172 drop table t1;
173 drop table t2;
174
175 -- source suite/ndb/include/backup_restore_cleanup.inc
176 -- remove_file $NDB_TOOLS_OUTPUT