Debian Codegraph @

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

raw
1 ######################################################################
2 # Test ndb_restore's print_data feature
3 ######################################################################
4
5 -- source include/have_ndb.inc
6 -- source suite/ndb/include/backup_restore_setup.inc
7
8 --disable_warnings
9 use test;
10 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
11 --enable_warnings
12
13 # basic datatypes
14 create table t1
15 (pk int key
16 ,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64)
17 ,b1 TINYINT, b2 TINYINT UNSIGNED
18 ,c1 SMALLINT, c2 SMALLINT UNSIGNED
19 ,d1 INT, d2 INT UNSIGNED
20 ,e1 BIGINT, e2 BIGINT UNSIGNED
21 ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY
22 ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY
23 ,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255)
24 ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000)
25 ) engine myisam;
26
27 # max values
28 insert into t1 values
29 (1
30 ,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001
31 ,127, 255
32 ,32767, 65535
33 ,2147483647, 4294967295
34 ,9223372036854775807, 18446744073709551615
35 ,'1','12345678901234567890123456789012','123456789'
36 ,'1','12345678901234567890123456789012','123456789'
37 ,0x12,0x123456789abcdef0, 0x012345
38 ,0x12,0x123456789abcdef0, 0x00123450
39 );
40
41 # min values
42 insert into t1 values
43 (2
44 ,0, 0, 0, 0, 0
45 ,-128, 0
46 ,-32768, 0
47 ,-2147483648, 0
48 ,-9223372036854775808, 0
49 ,'','',''
50 ,'','',''
51 ,0x0,0x0,0x0
52 ,0x0,0x0,0x0
53 );
54
55 # null values
56 insert into t1 values
57 (3
58 ,NULL,NULL,NULL,NULL,NULL
59 ,NULL,NULL
60 ,NULL,NULL
61 ,NULL,NULL
62 ,NULL,NULL
63 ,NULL,NULL,NULL
64 ,NULL,NULL,NULL
65 ,NULL,NULL,NULL
66 ,NULL,NULL,NULL
67 );
68
69 --vertical_results
70 select pk
71 ,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5)
72 ,b1, b2
73 ,c1 , c2
74 ,d1 , d2
75 ,e1 , e2
76 ,f1 , f2, f3
77 ,g1 , g2, g3
78 ,hex(h1), hex(h2), hex(h3)
79 ,hex(i1), hex(i2), hex(i3)
80 from t1 order by pk;
81
82 alter table t1 engine ndb;
83
84 select pk
85 ,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5)
86 ,b1, b2
87 ,c1 , c2
88 ,d1 , d2
89 ,e1 , e2
90 ,f1 , f2, f3
91 ,g1 , g2, g3
92 ,hex(h1), hex(h2), hex(h3)
93 ,hex(i1), hex(i2), hex(i3)
94 from t1 order by pk;
95 --horizontal_results
96
97 --source include/ndb_backup.inc
98
99 --let ndb_restore_filter=test t1
100 --let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";"
101 --source include/ndb_backup_print.inc
102
103 --let ndb_restore_filter=test t1
104 --let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by="," --fields-optionally-enclosed-by="'"
105 --source include/ndb_backup_print.inc
106
107
108 drop table t1;
109
110 # some binary char tests with trailing spaces
111 create table t1
112 (pk int key
113 ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY
114 ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY
115 ,h1 BINARY(1), h2 BINARY(9), h3 BINARY(255)
116 ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000)
117 ) engine ndb;
118
119 insert into t1 values
120 (1
121 ,'1','12345678901234567890123456789012','123456789 '
122 ,'1 ','12345678901234567890123456789012 ','123456789 '
123 ,0x20,0x123456789abcdef020, 0x012345000020
124 ,0x1200000020,0x123456789abcdef000000020, 0x00123450000020
125 );
126
127 create table t2 (pk int key, a int) engine ndb;
128 create table t3 (pk int key, a int) engine ndb;
129 create table t4 (pk int key, a int) engine ndb;
130
131 insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15);
132 insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25);
133 insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35);
134
135 --source include/ndb_backup.inc
136 --let ndb_restore_opts=--verbose=0 --print_data --hex --fields-enclosed-by="'" --fields-optionally-enclosed-by="X"
137 --let ndb_restore_filter=test t1
138 --source include/ndb_backup_print.inc
139
140 --error 0,1
141 --remove_file $MYSQLTEST_VARDIR/tmp/t1.txt
142 --error 0,1
143 --remove_file $MYSQLTEST_VARDIR/tmp/t2.txt
144 --error 0,1
145 --remove_file $MYSQLTEST_VARDIR/tmp/t3.txt
146 --error 0,1
147 --remove_file $MYSQLTEST_VARDIR/tmp/t4.txt
148
149 --let ndb_restore_opts=--verbose=0 --print_data --hex --tab $MYSQLTEST_VARDIR/tmp --append
150 --let ndb_restore_filter=test
151 --source include/ndb_backup_print.inc
152
153 --let $message= t1
154 --source include/show_msg.inc
155 --exec sort $MYSQLTEST_VARDIR/tmp/t1.txt
156 --let $message= t2
157 --source include/show_msg.inc
158 --exec sort $MYSQLTEST_VARDIR/tmp/t2.txt
159 --let $message= t3
160 --source include/show_msg.inc
161 --exec sort $MYSQLTEST_VARDIR/tmp/t3.txt
162 --let $message= t4
163 --source include/show_msg.inc
164 --exec sort $MYSQLTEST_VARDIR/tmp/t4.txt
165
166 --remove_file $MYSQLTEST_VARDIR/tmp/t1.txt
167 --remove_file $MYSQLTEST_VARDIR/tmp/t2.txt
168 --remove_file $MYSQLTEST_VARDIR/tmp/t3.txt
169 --remove_file $MYSQLTEST_VARDIR/tmp/t4.txt
170
171 # now test some other datatypes
172 drop table t1;
173 create table t1
174 (pk int key
175 ,a1 MEDIUMINT, a2 MEDIUMINT UNSIGNED
176 ) engine ndb;
177
178 # max values
179 insert into t1 values(1, 8388607, 16777215);
180 # min values
181 insert into t1 values(2, -8388608, 0);
182 # small values
183 insert into t1 values(3, -1, 1);
184
185 # backup and print
186 --source include/ndb_backup.inc
187
188 --let ndb_restore_filter=test t1
189 --let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";"
190 --source include/ndb_backup_print.inc
191
192 # clean up
193 drop table t1;
194 drop table t2;
195 drop table t3;
196 drop table t4;
197
198 # bug 37171 ndb_restore --print_data garbles decimal data
199
200 create table t1 (a int primary key,
201 normal decimal (20,10),
202 unormal decimal (20, 10) unsigned,
203 biggest decimal (65,30),
204 ubiggest decimal (65,30) unsigned,
205 small1 decimal (1,0),
206 usmall1 decimal (1,0) unsigned,
207 small2 decimal (1,1),
208 usmall2 decimal (1,1) unsigned) engine=ndb;
209
210 insert into t1 values (1,
211 -9999999999.9999999999,
212 9999999999.9999999999,
213 -99999999999999999999999999999999999.999999999999999999999999999999,
214 99999999999999999999999999999999999.999999999999999999999999999999,
215 -9,
216 9,
217 -0.9,
218 0.9);
219 insert into t1 values (2,
220 -1000000000.0000000001,
221 1000000000.0000000001,
222 -10000000000000000000000000000000000.000000000000000000000000000001,
223 10000000000000000000000000000000000.000000000000000000000000000001,
224 -1,
225 1,
226 -0.1,
227 0.1);
228 insert into t1 values (3,
229 -0099.0099,
230 0099.0099,
231 -0.1,
232 0.1,
233 -5,
234 5,
235 -0.5,
236 0.5);
237 --vertical_results
238
239 select * from t1 order by a;
240
241 --horizontal_results
242
243 # backup and print
244 --source include/ndb_backup.inc
245
246 --let ndb_restore_filter=test t1
247 --let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";"
248 --source include/ndb_backup_print.inc
249
250 # clean up
251 drop table t1;
252
253 # Bug#27282595 NDB_RESTORE WITH --PRINT-DATA IS CRASHING
254
255 create table t1(a int primary key AUTO_INCREMENT, b blob) engine=ndb;
256
257 insert into t1 values (NULL, "AAAAABBBBCCCCCDDDDD");
258
259 insert into t1 (a,b) select NULL, b from t1;
260
261 insert into t1 (a,b) select NULL, b from t1;
262
263 insert into t1 (a,b) select NULL, b from t1;
264
265 insert into t1 (a,b) select NULL, b from t1;
266
267 insert into t1 (a,b) select NULL, b from t1;
268
269 insert into t1 (a,b) select NULL, b from t1;
270
271 insert into t1 (a,b) select NULL, b from t1;
272
273 insert into t1 (a,b) select NULL, b from t1;
274
275 insert into t1 (a,b) select NULL, b from t1;
276
277 insert into t1 (a,b) select NULL, b from t1;
278
279 insert into t1 (a,b) select NULL, b from t1;
280
281 # backup and print
282 --source include/ndb_backup.inc
283
284 # clean up
285 drop table t1;
286
287 --let ndb_restore_filter=test t1
288 --let ndb_restore_opts=--verbose=0 --print_data --hex --fields-enclosed-by="'" --fields-optionally-enclosed-by="X"
289 --source include/ndb_backup_print.inc
290
291 ### Test ndb_restore --stored-grants
292 CREATE USER u1@a;
293 GRANT NDB_STORED_USER ON *.* to u1@a;
294 --source include/ndb_backup.inc
295 --let ndb_restore_filter=mysql
296 --let ndb_restore_opts=--include-stored-grants --print_data --verbose=0
297 --source include/ndb_backup_print.inc
298
299 # clean up
300 drop user u1@a;
301 --source suite/ndb/include/backup_restore_cleanup.inc
302 --remove_file $NDB_TOOLS_OUTPUT