File: dd_bootstrap_debug.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 (323 lines) | stat: -rw-r--r-- 11,010 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
--source include/big_test.inc
--source include/have_debug.inc

--echo #
--echo # This file contains bootstrap test cases that
--echo # need to be run with a debug build. See also the
--echo # test file 'dd_bootstrap.test' for test cases
--echo # that can be run with a non-debug server build.
--echo #

let BASEDIR=    `select @@basedir`;
let DDIR=       $MYSQL_TMP_DIR/dd_bootstrap_test;
let extra_args= --no-defaults --innodb_dedicated_server=OFF --secure-file-priv="" --loose-skip-auto_generate_certs --loose-skip-sha256_password_auto_generate_rsa_keys --skip-ssl --basedir=$BASEDIR --lc-messages-dir=$MYSQL_SHAREDIR;
let BOOTSTRAP_SQL= $MYSQL_TMP_DIR/tiny_bootstrap.sql;
let PASSWD_FILE=   $MYSQL_TMP_DIR/password_file.txt;

--echo # Preparation: Shut server down.
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc

--echo #
--echo # 1. Try restart after setting an invalid version.
--echo # ------------------------------------------------

let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_1.log;
let ENV_MYSQLD_LOG= $MYSQLD_LOG;

--echo # 1.1 Create bootstrap file.
write_file $BOOTSTRAP_SQL;
  SET SESSION debug= '+d,skip_dd_table_access_check';
  CREATE SCHEMA test;
  UPDATE mysql.dd_properties SET properties= 'invalid';
  SET SESSION debug= '-d,skip_dd_table_access_check';
EOF

--echo # 1.2 First start the server with --initialize, and update the version.
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL

--echo # 1.3 Restart the server against DDIR - should fail.
--error 1
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --datadir=$DDIR

--echo # 1.4 Look for error.
perl;
  use strict;
  my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
  open(FILE, "$log") or die;
  my $c_w= grep(/No data dictionary version number found./gi,<FILE>);
  print "#     Data Dictionary initialization error found $c_w times.\n";
  close(FILE);
EOF

--echo # 1.5 Delete bootstrap file and datadir.
remove_file $BOOTSTRAP_SQL;
--force-rmdir $DDIR

--echo #
--echo # 2. Try restart after dropping the properties table.
--echo # ---------------------------------------------------

let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_2.log;
let ENV_MYSQLD_LOG= $MYSQLD_LOG;

--echo # 2.1 Create bootstrap file.
write_file $BOOTSTRAP_SQL;
  CREATE SCHEMA test;
  SET SESSION debug= '+d,skip_dd_table_access_check';
  DROP TABLE mysql.dd_properties;
  SET SESSION debug= '-d,skip_dd_table_access_check';
EOF

--echo # 2.2 First start the server with --initialize, and drop the properties table. Should fail.
--error 1
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL

--echo # 2.3 Look for error.
perl;
  use strict;
  my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
  open(FILE, "$log") or die;
  my $c_w= grep(/The used command is not allowed with this MySQL version/gi,<FILE>);
  print "#     Data Dictionary initialization error found $c_w times.\n";
  close(FILE);
EOF

--echo # 2.4 Delete bootstrap file and datadir.
remove_file $BOOTSTRAP_SQL;
--force-rmdir $DDIR

--echo #
--echo # 3. Try restart after dropping the tables table.
--echo # -----------------------------------------------

let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_3.log;
let ENV_MYSQLD_LOG= $MYSQLD_LOG;

--echo # 3.1 Create bootstrap file.
write_file $BOOTSTRAP_SQL;
  CREATE SCHEMA test;
  SET FOREIGN_KEY_CHECKS= 0;
  SET SESSION debug= '+d,skip_dd_table_access_check';
  DROP TABLE mysql.tables;
  SET SESSION debug= '-d,skip_dd_table_access_check';
EOF

--echo # 3.2 First start the server with --initialize, and drop the tables table: Should fail.
--error 1
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL

--echo # 3.3 Look for error.
perl;
  use strict;
  my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
  open(FILE, "$log") or die;
  my $c_w= grep(/The used command is not allowed with this MySQL version/gi,<FILE>);
  print "#     Data Dictionary initialization error found $c_w times.\n";
  close(FILE);
EOF

--echo # 3.4 Delete bootstrap file and datadir.
remove_file $BOOTSTRAP_SQL;
--force-rmdir $DDIR

--echo #
--echo # 4. Try restart after altering the schemata table.
--echo # -------------------------------------------------

let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_4.log;
let ENV_MYSQLD_LOG= $MYSQLD_LOG;

--echo # 4.1 Create bootstrap file.
write_file $BOOTSTRAP_SQL;
  CREATE SCHEMA test;
  SET SESSION debug= '+d,skip_dd_table_access_check';
  ALTER TABLE mysql.schemata COMMENT 'Altered table';
  SET SESSION debug= '-d,skip_dd_table_access_check';
EOF

--echo # 4.2 First start the server with --initialize, and alter the schemata table.
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL

--echo # 4.3 Restart the server against DDIR.
--exec echo "restart: --datadir=$DDIR --no-console --log-error=$MYSQLD_LOG" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # 4.4 Connect as root.
connect(root_con,localhost,root,,mysql);

--echo # 4.5 Verify that the modified table is present.
SET SESSION debug= '+d,skip_dd_table_access_check';
SELECT t.comment FROM mysql.tables AS t, mysql.schemata AS s WHERE
  t.name = 'schemata' AND
  t.schema_id = s.id AND
  s.name = 'mysql';
SET SESSION debug= '-d,skip_dd_table_access_check';

--echo # 4.6 Shut server down.
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc

--echo # 4.7 Close the test connection.
connection default;
disconnect root_con;

--echo # 4.8 Delete bootstrap file and datadir.
remove_file $BOOTSTRAP_SQL;
--force-rmdir $DDIR

--echo #
--echo # 5. Try to access a DD table in an init-file during --initialize.
--echo # ----------------------------------------------------------------

let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_5.log;
let ENV_MYSQLD_LOG= $MYSQLD_LOG;

--echo # 5.1 Create bootstrap file.
write_file $BOOTSTRAP_SQL;
  SELECT * FROM mysql.st_spatial_reference_systems;
EOF

--echo # 5.2 First start the server with --initialize, and submit the init file.
--error 1
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR --init-file=$BOOTSTRAP_SQL

--echo # 5.3 Look for error.
perl;
  use strict;
  my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
  open(FILE, "$log") or die;
  my $c_w= grep(/Access to data dictionary table \'mysql.st_spatial_reference_systems\' is rejected/gi,<FILE>);
  print "#     Data Dictionary table access error found $c_w times.\n";
  close(FILE);
EOF

--echo # 5.4 Delete bootstrap file and datadir.
remove_file $BOOTSTRAP_SQL;
--force-rmdir $DDIR

--echo #
--echo # 6. Try to access a DD table in an init-file during plain restart.
--echo # -----------------------------------------------------------------

let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_6.log;
let ENV_MYSQLD_LOG= $MYSQLD_LOG;

--echo # 6.1 Create bootstrap file.
write_file $BOOTSTRAP_SQL;
  CREATE SCHEMA test;
  SELECT * FROM mysql.tables;
EOF

--echo # 6.2 First start the server with --initialize.
--exec $MYSQLD $extra_args --log-error=$MYSQLD_LOG --initialize-insecure --datadir=$DDIR

--echo # 6.3 Restart the server against DDIR with an init-file.
--exec echo "restart: --datadir=$DDIR --no-console --log-error=$MYSQLD_LOG --init-file=$BOOTSTRAP_SQL" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # 6.4 An init file error does not make the server exit, so we need to stop the server.
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc

--echo # 6.5 Look for error.
perl;
  use strict;
  my $log= $ENV{'ENV_MYSQLD_LOG'} or die;
  open(FILE, "$log") or die;
  my $c_w= grep(/Access to data dictionary table \'mysql.tables\' is rejected/gi,<FILE>);
  print "#     Data Dictionary initialization error found $c_w times.\n";
  close(FILE);
EOF

--echo # 6.6 Delete bootstrap file and datadir.
remove_file $BOOTSTRAP_SQL;
--force-rmdir $DDIR


--echo #
--echo # 7. Try initialize and start with --require-primary-key
--echo #
--echo # Bug#17468242/Wl#11807: Provide an option to prevent creation of tables
--echo # without a unique/pk
--echo #
--echo # Check that this option can be set on command line without compromising
--echo # bootstrap
--echo # ------------------------------------------------------

let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_bootstrap_7.log;
let ENV_MYSQLD_LOG= $MYSQLD_LOG;

--echo # 7.1 Create bootstrap file.
write_file $BOOTSTRAP_SQL;
  CREATE SCHEMA test;
EOF

--echo # 7.2 First start the server with --initialize
--exec $MYSQLD $extra_args --initialize-insecure --datadir=$DDIR --sql-require-primary-key=ON --init-file=$BOOTSTRAP_SQL

--echo # 7.3 Restart the server against DDIR.
--exec echo "restart: --datadir=$DDIR --no-console --log-error=$MYSQLD_LOG --sql-require-primary-key=ON" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # 7.4 Connect as root.
connect(root_con,localhost,root,,mysql);

--error ER_TABLE_WITHOUT_PK
CREATE TABLE t1(i INT);

--echo # 7.5 Shut server down.
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc

--echo # 7.6 Close the test connection.
connection default;
disconnect root_con;

--echo # 7.7 Delete bootstrap file, log file and datadir.
remove_file $BOOTSTRAP_SQL;
remove_file $MYSQLD_LOG;
--force-rmdir $DDIR

--echo # ------------------------------------------------------
--echo # Check that this option can be set on command line without
--echo # compromising restart against the normal datadir, without
--echo # initialize
--echo # ------------------------------------------------------

--echo # 8.1 Restart the server without initialize against the normal datadir
--exec echo "restart: --no-console --log-error=$MYSQLD_LOG --sql-require-primary-key=ON" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc

--echo # 8.2 Connect as root.
connect(root_con,localhost,root,,mysql);

--echo # Verify that the system variable is in effect
--error ER_TABLE_WITHOUT_PK
CREATE TABLE t1(i INT);

--echo # 8.3 Shut server down.
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc

--echo # 8.4 Close the test connection.
connection default;
disconnect root_con;

--echo # 8.5 Delete log file.
remove_file $MYSQLD_LOG;

--echo #
--echo # Cleanup: Restarting the server against default datadir.
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc