Skip to content

Commit c550a45

Browse files
author
msvensson@pilot.blaudden
committed
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)
1 parent 6caa0a2 commit c550a45

31 files changed

Lines changed: 354 additions & 1793 deletions

.bzrignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,3 +1335,4 @@ win/vs71cache.txt
13351335
win/vs8cache.txt
13361336
zlib/*.ds?
13371337
zlib/*.vcproj
1338+
scripts/mysql_fix_privilege_tables.sql

mysql-test/Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ dist-hook:
6666
$(INSTALL_DATA) $(srcdir)/std_data/*.frm $(distdir)/std_data
6767
$(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(distdir)/std_data
6868
$(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(distdir)/std_data
69-
$(INSTALL_DATA) $(srcdir)/lib/init_db.sql $(distdir)/lib
7069
$(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib
7170

7271
install-data-local:
@@ -98,7 +97,6 @@ install-data-local:
9897
$(INSTALL_DATA) $(srcdir)/std_data/*.frm $(DESTDIR)$(testdir)/std_data
9998
$(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(testdir)/std_data
10099
$(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data
101-
$(INSTALL_DATA) $(srcdir)/lib/init_db.sql $(DESTDIR)$(testdir)/lib
102100
$(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib
103101

104102
uninstall-local:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Allow anonymous users to connect
2+
disable_warnings;
3+
disable_query_log;
4+
INSERT INTO mysql.user (host, user) VALUES ('localhost','');
5+
FLUSH PRIVILEGES;
6+
enable_query_log;
7+
enable_warnings;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Remove anonymous users added by add_anonymous_users.inc
2+
disable_query_log;
3+
DELETE FROM mysql.user where host='localhost' and user='';
4+
FLUSH PRIVILEGES;
5+
enable_query_log;

mysql-test/init_db.sql

Lines changed: 0 additions & 58 deletions
This file was deleted.

mysql-test/lib/init_db.sql

Lines changed: 0 additions & 559 deletions
This file was deleted.

mysql-test/mysql-test-run.pl

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@
299299
our $exe_ndb_example;
300300
our $path_ndb_testrun_log;
301301

302+
our $path_sql_dir;
303+
302304
our @data_dir_lst;
303305

304306
our $used_binlog_format;
@@ -1497,12 +1499,16 @@ ()
14971499
$exe_mysql_fix_system_tables=
14981500
mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
14991501
"$path_client_bindir/mysql_fix_privilege_tables");
1502+
15001503
}
15011504

1505+
# Look for SQL scripts directory
1506+
$path_sql_dir= mtr_path_exists("$glob_basedir/share",
1507+
"$glob_basedir/scripts");
1508+
15021509
# Look for mysql_fix_privilege_tables.sql script
15031510
$file_mysql_fix_privilege_tables=
1504-
mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql",
1505-
"$glob_basedir/share/mysql_fix_privilege_tables.sql");
1511+
mtr_file_exists("$path_sql_dir/mysql_fix_privilege_tables.sql");
15061512

15071513
if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
15081514
{
@@ -1940,6 +1946,7 @@ ()
19401946
"--port=$master->[0]->{'port'} " .
19411947
"--socket=$master->[0]->{'path_sock'}";
19421948
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
1949+
19431950
}
19441951
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
19451952

@@ -2856,38 +2863,11 @@ ($$)
28562863
my $type= shift;
28572864
my $data_dir= shift;
28582865

2859-
my $init_db_sql= "lib/init_db.sql";
2860-
my $init_db_sql_tmp= "/tmp/init_db.sql$$";
2861-
my $args;
2862-
28632866
mtr_report("Installing \u$type Database");
28642867

2865-
open(IN, $init_db_sql)
2866-
or mtr_error("Can't open $init_db_sql: $!");
2867-
open(OUT, ">", $init_db_sql_tmp)
2868-
or mtr_error("Can't write to $init_db_sql_tmp: $!");
2869-
while (<IN>)
2870-
{
2871-
chomp;
2872-
s/\@HOSTNAME\@/$glob_hostname/;
2873-
if ( /^\s*$/ )
2874-
{
2875-
print OUT "\n";
2876-
}
2877-
elsif (/;$/)
2878-
{
2879-
print OUT "$_\n";
2880-
}
2881-
else
2882-
{
2883-
print OUT "$_ ";
2884-
}
2885-
}
2886-
close OUT;
2887-
close IN;
28882868

2869+
my $args;
28892870
mtr_init_args(\$args);
2890-
28912871
mtr_add_arg($args, "--no-defaults");
28922872
mtr_add_arg($args, "--bootstrap");
28932873
mtr_add_arg($args, "--basedir=%s", $path_my_basedir);
@@ -2921,21 +2901,44 @@ ($$)
29212901
# ----------------------------------------------------------------------
29222902
$ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
29232903

2904+
# ----------------------------------------------------------------------
2905+
# Create the bootstrap.sql file
2906+
# ----------------------------------------------------------------------
2907+
my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql$$";
2908+
2909+
# Use the mysql database for system tables
2910+
mtr_tofile($bootstrap_sql_file, "use mysql");
2911+
2912+
# Add the offical mysql system tables and initial system data
2913+
# for a prodcuction system
2914+
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables.sql",
2915+
$bootstrap_sql_file);
2916+
2917+
# Add test data for timezone - this is just a subset, on a real
2918+
# system these tables will be populated either by mysql_tzinfo_to_sql
2919+
# or by downloading the timezone table package from our website
2920+
mtr_appendfile_to_file("$path_sql_dir/mysql_test_data_timezone.sql",
2921+
$bootstrap_sql_file);
2922+
2923+
# Fill help tables, just an empty file when running from bk repo
2924+
# but will be replaced by a real fill_help_tables.sql when
2925+
# building the source dist
2926+
mtr_appendfile_to_file("$path_sql_dir/fill_help_tables.sql",
2927+
$bootstrap_sql_file);
2928+
29242929
# Log bootstrap command
29252930
my $path_bootstrap_log= "$opt_vardir/log/bootstrap.log";
29262931
mtr_tofile($path_bootstrap_log,
29272932
"$exe_mysqld_bootstrap " . join(" ", @$args) . "\n");
29282933

2929-
if ( mtr_run($exe_mysqld_bootstrap, $args, $init_db_sql_tmp,
2934+
if ( mtr_run($exe_mysqld_bootstrap, $args, $bootstrap_sql_file,
29302935
$path_bootstrap_log, $path_bootstrap_log,
29312936
"", { append_log_file => 1 }) != 0 )
29322937

29332938
{
2934-
unlink($init_db_sql_tmp);
29352939
mtr_error("Error executing mysqld --bootstrap\n" .
2936-
"Could not install $type test DBs");
2940+
"Could not install system database, see $path_bootstrap_log");
29372941
}
2938-
unlink($init_db_sql_tmp);
29392942
}
29402943

29412944

mysql-test/r/create.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,11 @@ drop database mysqltest;
509509
select database();
510510
database()
511511
NULL
512+
create user mysqltest_1;
512513
select database(), user();
513514
database() user()
514515
NULL mysqltest_1@localhost
516+
drop user mysqltest_1;
515517
use test;
516518
create table t1 (a int, index `primary` (a));
517519
ERROR 42000: Incorrect index name 'primary'

mysql-test/r/derived.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ drop table t1,t2;
202202
SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
203203
x
204204
1
205+
create user mysqltest_1;
205206
create table t1 select 1 as a;
206207
select 2 as a from (select * from t1) b;
207208
ERROR 3D000: No database selected
@@ -380,3 +381,4 @@ ID DATA FID
380381
select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID;
381382
ID DATA FID
382383
drop table t1, t2;
384+
drop user mysqltest_1;

mysql-test/r/join.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ select * from information_schema.statistics join information_schema.columns
701701
using(table_name,column_name) where table_name='user';
702702
TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
703703
user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI #
704-
user User NULL mysql 0 mysql PRIMARY 2 A 5 NULL NULL BTREE NULL mysql 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI #
704+
user User NULL mysql 0 mysql PRIMARY 2 A 3 NULL NULL BTREE NULL mysql 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI #
705705
drop table t1;
706706
drop table t2;
707707
drop table t3;

0 commit comments

Comments
 (0)