--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 --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:22240@1'; 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,); 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,); 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,); 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,); 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,); 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