From 5d4e0417ad5a4b7758f216f86ad91b97287eec29 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Feb 2007 11:49:24 +0100 Subject: Bug#20166 mysql-test-run.pl does not test system privilege tables creation - Use mysql_system_tables.sql to create MySQL system tables in all places where we create them(mysql_install_db, mysql-test-run-pl and mysql_fix_privilege_tables.sql) BitKeeper/deleted/.del-init_db.sql: Rename: mysql-test/init_db.sql -> BitKeeper/deleted/.del-init_db.sql BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8: Rename: mysql-test/lib/init_db.sql -> BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8 BitKeeper/deleted/.del-mysql_create_system_tables.sh: Rename: scripts/mysql_create_system_tables.sh -> BitKeeper/deleted/.del-mysql_create_system_tables.sh BitKeeper/etc/ignore: Added scripts/mysql_fix_privilege_tables.sql to the ignore list mysql-test/Makefile.am: lib/init_db.sql has been removed mysql-test/mysql-test-run.pl: - Build var/tmp/bootstrap.sql from mysql_system_tables.sql, mysql_test_data_timezone.sql and fill_help_tables.sql and use it when bootsraping the system tables to use during test. mysql-test/r/create.result: Update result file mysql-test/r/derived.result: Update result file mysql-test/r/join.result: Update result file mysql-test/r/mysql_upgrade.result: Update result file mysql-test/r/sp-security.result: Update result file mysql-test/t/create.test: Add user mysqltest_1 before trying to connect as that user - no anon users by default anymore mysql-test/t/derived.test: Add user mysqltest_1 before trying to connect as that user - no anon users by default anymore mysql-test/t/grant2.test: Add anonymous users for part of thes that need it. mysql-test/t/grant_cache.test: Add anonymous users for part of thes that need it. mysql-test/t/init_connect.test: Add anonymous users for part of thes that need it. mysql-test/t/lock_multi.test: Add anonymous users for part of thes that need it. mysql-test/t/ndb_basic.test: Connect as "root", blank user will take currently logged in username mysql-test/t/ndb_index_ordered.test: Connect as "root", blank user will take currently logged in username mysql-test/t/ndb_multi.test: Connect as "root", blank user will take currently logged in username mysql-test/t/overflow.test: Connect as root - no anonymous users by default anymore mysql-test/t/rpl_temporary.test: Add anonymous users for the test mysql-test/t/xa.test: Connect as "root", blank user wil pick currently logged in user scripts/Makefile.am: Remove mysql_create_system_tables.sh Add mysql_system_tables.sql and mysql_test_data_timezone.sql Build mysql_fix_privilege_tables.sql from mysql_system_tables.sql and mysql_fix_privilege_tables.sql.in scripts/mysql_fix_privilege_tables.sh: Update message describing what the script does scripts/mysql_fix_privilege_tables.sql.in: Remove the part that creates system tables as that will be added to mysql_fix_privileg_tables.sql from mysql_system_tables.sql Change all comments to use # scripts/mysql_install_db.sh: Use mysql_system_tables.sql to create the MySQL system tables Update comments and indentation Add more descriptive comments about --windows switch Reduce number of hardcoded names for the SQL files the script looks for mysql-test/include/add_anonymous_users.inc: New BitKeeper file ``mysql-test/include/add_anonymous_users.inc'' mysql-test/include/delete_anonymous_users.inc: New BitKeeper file ``mysql-test/include/delete_anonymous_users.inc'' scripts/mysql_system_tables.sql: New BitKeeper file ``scripts/mysql_system_tables.sql'' scripts/mysql_test_data_timezone.sql: New BitKeeper file ``scripts/mysql_test_data_timezone.sql'' --- mysql-test/mysql-test-run.pl | 71 +++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 34 deletions(-) (limited to 'mysql-test/mysql-test-run.pl') diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index cefa1bae6d5..8920997b15d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -299,6 +299,8 @@ our $path_ndb_examples_dir; our $exe_ndb_example; our $path_ndb_testrun_log; +our $path_sql_dir; + our @data_dir_lst; our $used_binlog_format; @@ -1497,12 +1499,16 @@ sub executable_setup () { $exe_mysql_fix_system_tables= mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables", "$path_client_bindir/mysql_fix_privilege_tables"); + } + # Look for SQL scripts directory + $path_sql_dir= mtr_path_exists("$glob_basedir/share", + "$glob_basedir/scripts"); + # Look for mysql_fix_privilege_tables.sql script $file_mysql_fix_privilege_tables= - mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", - "$glob_basedir/share/mysql_fix_privilege_tables.sql"); + mtr_file_exists("$path_sql_dir/mysql_fix_privilege_tables.sql"); if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) { @@ -1940,6 +1946,7 @@ sub environment_setup () { "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'}"; $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; + } $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables; @@ -2856,38 +2863,11 @@ sub install_db ($$) { my $type= shift; my $data_dir= shift; - my $init_db_sql= "lib/init_db.sql"; - my $init_db_sql_tmp= "/tmp/init_db.sql$$"; - my $args; - mtr_report("Installing \u$type Database"); - open(IN, $init_db_sql) - or mtr_error("Can't open $init_db_sql: $!"); - open(OUT, ">", $init_db_sql_tmp) - or mtr_error("Can't write to $init_db_sql_tmp: $!"); - while () - { - chomp; - s/\@HOSTNAME\@/$glob_hostname/; - if ( /^\s*$/ ) - { - print OUT "\n"; - } - elsif (/;$/) - { - print OUT "$_\n"; - } - else - { - print OUT "$_ "; - } - } - close OUT; - close IN; + my $args; mtr_init_args(\$args); - mtr_add_arg($args, "--no-defaults"); mtr_add_arg($args, "--bootstrap"); mtr_add_arg($args, "--basedir=%s", $path_my_basedir); @@ -2921,21 +2901,44 @@ sub install_db ($$) { # ---------------------------------------------------------------------- $ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args); + # ---------------------------------------------------------------------- + # Create the bootstrap.sql file + # ---------------------------------------------------------------------- + my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql$$"; + + # Use the mysql database for system tables + mtr_tofile($bootstrap_sql_file, "use mysql"); + + # Add the offical mysql system tables and initial system data + # for a prodcuction system + mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables.sql", + $bootstrap_sql_file); + + # Add test data for timezone - this is just a subset, on a real + # system these tables will be populated either by mysql_tzinfo_to_sql + # or by downloading the timezone table package from our website + mtr_appendfile_to_file("$path_sql_dir/mysql_test_data_timezone.sql", + $bootstrap_sql_file); + + # Fill help tables, just an empty file when running from bk repo + # but will be replaced by a real fill_help_tables.sql when + # building the source dist + mtr_appendfile_to_file("$path_sql_dir/fill_help_tables.sql", + $bootstrap_sql_file); + # Log bootstrap command my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log"; mtr_tofile($path_bootstrap_log, "$exe_mysqld_bootstrap " . join(" ", @$args) . "\n"); - if ( mtr_run($exe_mysqld_bootstrap, $args, $init_db_sql_tmp, + if ( mtr_run($exe_mysqld_bootstrap, $args, $bootstrap_sql_file, $path_bootstrap_log, $path_bootstrap_log, "", { append_log_file => 1 }) != 0 ) { - unlink($init_db_sql_tmp); mtr_error("Error executing mysqld --bootstrap\n" . - "Could not install $type test DBs"); + "Could not install system database, see $path_bootstrap_log"); } - unlink($init_db_sql_tmp); } -- cgit v1.2.1