File: ndb_restore_conv_padding.test

package info (click to toggle)
percona-xtrabackup 2.2.3-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 293,260 kB
  • ctags: 146,881
  • sloc: cpp: 1,051,960; ansic: 570,217; java: 54,595; perl: 53,495; pascal: 44,194; sh: 27,826; yacc: 15,314; python: 12,142; xml: 7,848; sql: 4,125; makefile: 1,459; awk: 785; lex: 758
file content (260 lines) | stat: -rw-r--r-- 9,305 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
######################################################################
# Test restoring backups with preserving padding in char/bin conversions
######################################################################

-- source include/have_ndb.inc

# mysqld's configuration is not relevant to this test
-- source include/not_embedded.inc

--echo ************************************************************
--echo * Creating table with char+binary types
--echo ************************************************************

CREATE TABLE t3(
  c1 char(32),
  b1 binary(32)
) ENGINE=NDB;

INSERT INTO t3 VALUES('aaaaaaaa', 'bbbbbbbb');
SELECT length(c1), length(b1) FROM t3;

--echo ************************************************************
--echo * Backing up table with char+binary types
--echo ************************************************************

--source include/ndb_backup.inc

# command shortcuts
--let $restore_cmd=$NDB_RESTORE --no-defaults -b $the_backup_id
--let $restore_cmd=$restore_cmd -r --backup_path=$NDB_BACKUPS-$the_backup_id

--echo ************************************************************
--echo * Restoring table with unchanged char+binary types (sanity check):
--echo *     char(32)           -->    char(32)
--echo *     binary(32)         -->    binary(32)
--echo ************************************************************

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
# for debugging:
#    --exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 1 -L -r --print $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
#    --exec $NDB_RESTORE --no-defaults -b $the_backup_id -n 2 -L -r --print $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $restore_cmd -n 1 --print > /dev/null
--exec $restore_cmd -n 2 --print > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Restoring table with promoted char+binary types preserving padding:
--echo *     char(32)           -->    varchar(32)
--echo *     binary(32)         -->    varbinary(32)
--echo ************************************************************

# demote char+binary type attibutes
--disable_warnings
ALTER TABLE t3 MODIFY c1 varchar(32), MODIFY b1 varbinary(32);
--enable_warnings
SELECT length(c1), length(b1) FROM t3;

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
--exec $restore_cmd -n 1 --print -A -P > /dev/null
--exec $restore_cmd -n 2 --print -A -P > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Restoring table with promoted char+binary types preserving padding:
--echo *     char(32)           -->    varchar(64)
--echo *     binary(32)         -->    varbinary(64)
--echo ************************************************************

# demote char+binary type attibutes
--disable_warnings
ALTER TABLE t3 MODIFY c1 varchar(64), MODIFY b1 varbinary(64);
--enable_warnings
SELECT length(c1), length(b1) FROM t3;

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
--exec $restore_cmd -n 1 --print -A -P > /dev/null
--exec $restore_cmd -n 2 --print -A -P > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Restoring table with promoted char+binary types preserving padding:
--echo *     char(32)           -->    varchar(512)
--echo *     binary(32)         -->    varbinary(512)
--echo ************************************************************

# demote char+binary type attibutes
--disable_warnings
ALTER TABLE t3 MODIFY c1 varchar(512), MODIFY b1 varbinary(512);
--enable_warnings
SELECT length(c1), length(b1) FROM t3;

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
--exec $restore_cmd -n 1 --print -A -P > /dev/null
--exec $restore_cmd -n 2 --print -A -P > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Restoring table with demoted char+binary types preserving padding:
--echo *     char(32)           -->    varchar(16)
--echo *     binary(32)         -->    varbinary(16)
--echo ************************************************************

# demote char+binary type attibutes
--disable_warnings
ALTER TABLE t3 MODIFY c1 varchar(16), MODIFY b1 varbinary(16);
--enable_warnings
SELECT length(c1), length(b1) FROM t3;

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
--exec $restore_cmd -n 1 --print -L -P > /dev/null
--exec $restore_cmd -n 2 --print -L -P > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Restoring table with promoted char+binary types discarding padding:
--echo *     char(32)           -->    varchar(32)
--echo *     binary(32)         -->    varbinary(32)
--echo ************************************************************

# demote char+binary type attibutes
--disable_warnings
DELETE FROM t3;
ALTER TABLE t3 MODIFY c1 varchar(32), MODIFY b1 varbinary(32);
INSERT INTO t3 VALUES('aaaaaaaa', 'bbbbbbbb');
--enable_warnings
SELECT length(c1), length(b1) FROM t3;

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
--exec $restore_cmd -n 1 --print -A > /dev/null
--exec $restore_cmd -n 2 --print -A > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Restoring table with promoted char+binary types discarding padding:
--echo *     char(32)           -->    varchar(64)
--echo *     binary(32)         -->    varbinary(64)
--echo ************************************************************

# demote char+binary type attibutes
--disable_warnings
ALTER TABLE t3 MODIFY c1 varchar(64), MODIFY b1 varbinary(64);
--enable_warnings
SELECT length(c1), length(b1) FROM t3;

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
--exec $restore_cmd -n 1 --print -A > /dev/null
--exec $restore_cmd -n 2 --print -A > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Restoring table with promoted char+binary types discarding padding:
--echo *     char(32)           -->    varchar(512)
--echo *     binary(32)         -->    varbinary(512)
--echo ************************************************************

# demote char+binary type attibutes
--disable_warnings
ALTER TABLE t3 MODIFY c1 varchar(512), MODIFY b1 varbinary(512);
--enable_warnings
SELECT length(c1), length(b1) FROM t3;

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
--exec $restore_cmd -n 1 --print -A > /dev/null
--exec $restore_cmd -n 2 --print -A > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Restoring table with demoted char+binary types discarding padding:
--echo *     char(32)           -->    varchar(16)
--echo *     binary(32)         -->    varbinary(16)
--echo ************************************************************

# demote char+binary type attibutes
--disable_warnings
ALTER TABLE t3 MODIFY c1 varchar(16), MODIFY b1 varbinary(16);
--enable_warnings
SELECT length(c1), length(b1) FROM t3;

# create a MyISAM table from NDB table, against which to compare data
CREATE TABLE t3_myisam ENGINE=MYISAM AS SELECT * FROM t3;

# restore table
DELETE FROM t3;
--exec $restore_cmd -n 1 --print -L > /dev/null
--exec $restore_cmd -n 2 --print -L > /dev/null
SELECT length(c1), length(b1) FROM t3;

# verify data
SELECT COUNT(*) FROM t3 NATURAL JOIN t3_myisam;
DROP TABLE t3_myisam;

--echo ************************************************************
--echo * Deleting table with char+binary types
--echo ************************************************************

DROP TABLE t3;