Debian Codegraph @

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

raw
1 -- source include/have_ndb.inc
2 -- source include/have_ndb_debug.inc
3 -- source suite/ndb/include/backup_restore_setup.inc
4
5 --disable_query_log
6 set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz;
7 set ndb_autoincrement_prefetch_sz = 1;
8 --enable_query_log
9
10 use test;
11
12 --echo ********************************
13 --echo Autoincrement extend pk
14 --echo Prepare table + backup with log
15 --echo ********************************
16
17 create table test.autokey (
18 ak bigint unsigned not null auto_increment,
19 ok bigint unsigned not null,
20 data varchar(200) not null,
21 primary key(ak),
22 key(ok))
23 engine=ndb;
24
25 insert into test.autokey (ok,data) values
26 (1, "1-1"),
27 (1, "1-2"),
28 (1, "1-3"),
29 (1, "1-4"),
30 (2, "2-1"),
31 (2, "2-2"),
32 (2, "2-3"),
33 (3, "3-1"),
34 (3, "3-2"),
35 (3, "3-3");
36
37 select * from test.autokey order by data;
38
39 --echo Stall backup completion
40 --exec $NDB_MGM -e "all error 10039" >> $NDB_TOOLS_OUTPUT 2>&1
41 --echo Run backup
42 --source suite/ndb/t/ndb_backup_nowait_start.inc
43
44 --echo Make some changes which will be logged...
45 insert into test.autokey (ok,data) values
46 (4, "4-1"),
47 (4, "4-2"),
48 (4, "4-3"),
49 (5, "5-1"),
50 (5, "5-2");
51
52 update test.autokey set data = concat(data, "-mk2");
53
54 # Make some changes to all non-pk cols
55 # Null change to ok
56 update test.autokey set ok=ok, data=concat(data,"-1");
57 # Non-null change to ok, still unique (transactionally)
58 # update test.autokey set ok=ok+1, data=concat(data,"-2");
59 # update test.autokey set ok=ok-1, data=concat(data,"-3");
60
61 delete from test.autokey where ok=2;
62
63 --echo Allow backup to complete...
64 --exec $NDB_MGM -e "all error 0" >> $NDB_TOOLS_OUTPUT 2>&1
65
66 --source suite/ndb/t/ndb_backup_nowait_wait.inc
67
68 select * from test.autokey order by data;
69
70 --echo Check next auto-inc value
71 insert into test.autokey (ok,data) values (6, "6-1");
72 select ak from test.autokey where ok=6;
73
74 #--exec $NDB_DESC -dtest autokey
75
76 drop table test.autokey;
77
78
79 --echo Primary key extended to include another column
80 --echo PK order changed
81 --echo Extra secondary index dropped
82 --echo **********************************************
83 create table test.autokey (
84 ak bigint unsigned not null auto_increment,
85 ok bigint unsigned not null,
86 data varchar(200) not null,
87 primary key(ok,ak))
88 engine=ndb partition by key(ok);
89
90 --echo Run restore
91 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r --allow-pk-changes --ignore-extended-pk-updates $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
92 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r --allow-pk-changes --ignore-extended-pk-updates $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
93
94 select * from test.autokey order by data;
95
96 --echo Check next auto-inc value
97 insert into test.autokey (ok,data) values (6, "6-1");
98 select ak from test.autokey where ok=6;
99
100 #--exec $NDB_DESC -dtest autokey
101
102 drop table test.autokey;
103
104
105 --echo Primary key extended to include another column
106 --echo PK column demoted
107 --echo !PK column promoted
108 --echo PK order changed
109 --echo Extra secondary index dropped
110 --echo **********************************************
111 create table test.autokey (
112 ak bigint unsigned not null auto_increment,
113 ok int unsigned not null,
114 data varchar(250) not null,
115 primary key(ok,ak))
116 engine=ndb partition by key(ok);
117
118 --echo Run restore
119 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r --allow-pk-changes --ignore-extended-pk-updates --promote-attributes --lossy-conversions $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
120 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r --allow-pk-changes --ignore-extended-pk-updates --promote-attributes --lossy-conversions $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
121
122 select * from test.autokey order by data;
123
124 --echo Check next auto-inc value
125 insert into test.autokey (ok,data) values (6, "6-1");
126 select ak from test.autokey where ok=6;
127
128 #--exec $NDB_DESC -dtest autokey
129
130 drop table test.autokey;
131
132
133 --echo ********************************
134 --echo Autoincrement reduce pk
135 --echo Prepare table + backup with log
136 --echo ********************************
137 create table test.autokey (
138 ak bigint unsigned not null auto_increment,
139 ok bigint unsigned not null,
140 data varchar(200) not null,
141 primary key(ok,ak))
142 engine=ndb partition by key(ok);
143
144 insert into test.autokey (ok,data) values
145 (1, "1-1"),
146 (1, "1-2"),
147 (1, "1-3"),
148 (1, "1-4"),
149 (2, "2-1"),
150 (2, "2-2"),
151 (2, "2-3"),
152 (3, "3-1"),
153 (3, "3-2"),
154 (3, "3-3");
155
156 select * from test.autokey order by data;
157
158 --echo Stall backup completion
159 --exec $NDB_MGM -e "all error 10039" >> $NDB_TOOLS_OUTPUT 2>&1
160 --echo Run backup
161 --source suite/ndb/t/ndb_backup_nowait_start.inc
162
163 --echo Make some changes which will be logged...
164 insert into test.autokey (ok,data) values
165 (4, "4-1"),
166 (4, "4-2"),
167 (4, "4-3"),
168 (5, "5-1"),
169 (5, "5-2");
170
171 update test.autokey set data = concat(data, "-mk2");
172 delete from test.autokey where ok=2;
173
174 --echo Allow backup to complete...
175 --exec $NDB_MGM -e "all error 0" >> $NDB_TOOLS_OUTPUT 2>&1
176
177 --source suite/ndb/t/ndb_backup_nowait_wait.inc
178
179 select * from test.autokey order by data;
180
181 --echo Check next auto-inc value
182 insert into test.autokey (ok,data) values (6, "6-1");
183 select ak from test.autokey where ok=6;
184
185 #--exec $NDB_DESC -dtest autokey
186
187 drop table test.autokey;
188
189 --echo Primary key reduced down to autoincrement
190 --echo Extra secondary index
191 --echo **********************************************
192 create table test.autokey (
193 ak bigint unsigned not null auto_increment,
194 ok bigint unsigned not null,
195 data varchar(200) not null,
196 primary key(ak),
197 key(ok))
198 engine=ndb;
199
200 --echo Run restore
201 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r --allow-pk-changes --ignore-extended-pk-updates --lossy-conversions $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
202 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r --allow-pk-changes --ignore-extended-pk-updates --lossy-conversions $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
203
204 select * from test.autokey order by data;
205
206 --echo Check next auto-inc value
207 insert into test.autokey (ok,data) values (6, "6-1");
208 select ak from test.autokey where ok=6;
209
210 #--exec $NDB_DESC -dtest autokey
211
212 drop table test.autokey;
213
214 --echo Primary key reduced down to autoincrement
215 --echo Ex-PK demoted
216 --echo Non-PK demoted
217 --echo Extra secondary index
218 --echo **********************************************
219 create table test.autokey (
220 ak bigint unsigned not null auto_increment,
221 ok int unsigned not null,
222 data varchar(20) not null,
223 primary key(ak),
224 key(ok))
225 engine=ndb;
226
227 --echo Run restore
228 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r --allow-pk-changes --ignore-extended-pk-updates --promote-attributes --lossy-conversions $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
229 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r --allow-pk-changes --ignore-extended-pk-updates --promote-attributes --lossy-conversions $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT 2>&1
230
231 select * from test.autokey order by data;
232
233 --echo Check next auto-inc value
234 insert into test.autokey (ok,data) values (6, "6-1");
235 select ak from test.autokey where ok=6;
236
237 #--exec $NDB_DESC -dtest autokey
238
239 drop table test.autokey;
240
241 --disable_query_log
242 set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz;
243 --enable_query_log
244
245 --source suite/ndb/include/backup_restore_cleanup.inc
246 --remove_file $NDB_TOOLS_OUTPUT