Skip to content

Commit e391b86

Browse files
author
msvensson@pilot.blaudden
committed
Bug#20166 mysql-test-run.pl does not test system privilege tables creation
- Split out initial data in mysql_system_tables.sql to it's own file - Use file from mysql_install_db and mysql-test-run
1 parent c66f902 commit e391b86

File tree

6 files changed

+43
-22
lines changed

6 files changed

+43
-22
lines changed

mysql-test/mysql-test-run.pl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,16 +2904,21 @@ ($$)
29042904
# ----------------------------------------------------------------------
29052905
# Create the bootstrap.sql file
29062906
# ----------------------------------------------------------------------
2907-
my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql$$";
2907+
my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql";
29082908

29092909
# Use the mysql database for system tables
29102910
mtr_tofile($bootstrap_sql_file, "use mysql");
29112911

2912-
# Add the offical mysql system tables and initial system data
2913-
# for a prodcuction system
2912+
# Add the offical mysql system tables
2913+
# for a production system
29142914
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables.sql",
29152915
$bootstrap_sql_file);
29162916

2917+
# Add the mysql system tables initial data
2918+
# for a production system
2919+
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables_data.sql",
2920+
$bootstrap_sql_file);
2921+
29172922
# Add test data for timezone - this is just a subset, on a real
29182923
# system these tables will be populated either by mysql_tzinfo_to_sql
29192924
# or by downloading the timezone table package from our website
@@ -2937,7 +2942,8 @@ ($$)
29372942

29382943
{
29392944
mtr_error("Error executing mysqld --bootstrap\n" .
2940-
"Could not install system database, see $path_bootstrap_log");
2945+
"Could not install system database from $bootstrap_sql_file\n" .
2946+
"see $path_bootstrap_log for errors");
29412947
}
29422948
}
29432949

scripts/Makefile.am

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,14 @@ EXTRA_DIST = $(EXTRA_SCRIPTS) \
6565
mysqlaccess.conf \
6666
mysqlbug \
6767
make_win_bin_dist \
68-
mysql_fix_privilege_tables.sql.in
68+
mysql_system_tables_fix.sql
6969

7070
dist_pkgdata_DATA = fill_help_tables.sql \
7171
mysql_fix_privilege_tables.sql \
7272
mysql_system_tables.sql \
73+
mysql_system_tables_data.sql \
7374
mysql_test_data_timezone.sql
7475

75-
# mysqlbug should be distributed built so that people can report build
76-
# failures with it.
7776
CLEANFILES = @server_scripts@ \
7877
make_binary_distribution \
7978
make_sharedlib_distribution \
@@ -94,8 +93,11 @@ CLEANFILES = @server_scripts@ \
9493
mysql_upgrade_shell \
9594
mysqld_multi \
9695
make_win_src_distribution \
97-
mysql_create_system_tables
96+
mysql_create_system_tables \
97+
mysql_fix_privilege_tables.sql
9898

99+
# mysqlbug should be distributed built so that people can report build
100+
# failures with it.
99101
DISTCLEANFILES = mysqlbug
100102

101103
# We want the right version and configure comand line in mysqlbug
@@ -104,10 +106,10 @@ mysqlbug: ${top_builddir}/config.status mysqlbug.sh
104106
# Build mysql_fix_privilege_tables.sql from the files that contain
105107
# the system tables for this version of MySQL plus any commands
106108
# needed to upgrade the system tables from an older version
107-
mysql_fix_privilege_tables.sql: mysql_fix_privilege_tables.sql.in \
108-
mysql_system_tables.sql
109+
mysql_fix_privilege_tables.sql: mysql_system_tables.sql \
110+
mysql_system_tables_fix.sql
109111
@echo "Building $@";
110-
@cat mysql_system_tables.sql $@.in > $@
112+
@cat mysql_system_tables.sql mysql_system_tables_fix.sql > $@
111113

112114
SUFFIXES = .sh
113115

scripts/mysql_install_db.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,12 @@ fi
138138
# Find SQL scripts needed for bootstrap
139139
fill_help_tables="fill_help_tables.sql"
140140
create_system_tables="mysql_system_tables.sql"
141+
fill_system_tables="mysql_system_tables_data.sql"
141142
if test -n "$srcdir"
142143
then
143144
fill_help_tables=$srcdir/scripts/$fill_help_tables
144145
create_system_tables=$srcdir/scripts/$create_system_tables
146+
fill_system_tables=$srcdir/scripts/$fill_system_tables
145147
else
146148
for i in $basedir/support-files $basedir/share $basedir/share/mysql \
147149
$basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@
@@ -154,6 +156,7 @@ else
154156

155157
fill_help_tables=$pkgdatadir/$fill_help_tables
156158
create_system_tables=$pkgdatadir/$create_system_tables
159+
fill_system_tables=$pkgdatadir/$fill_system_tables
157160
fi
158161

159162
if test ! -f $create_system_tables
@@ -170,6 +173,13 @@ then
170173
exit 1;
171174
fi
172175

176+
if test ! -f $fill_system_tables
177+
then
178+
echo "FATAL ERROR: Could not find help file '$fill_system_tables' in"
179+
echo "@pkgdatadir@ or inside $basedir"
180+
exit 1;
181+
fi
182+
173183
# Find executables and paths
174184
mdata=$ldata/mysql
175185
mysqld=$execdir/mysqld
@@ -273,7 +283,7 @@ mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
273283

274284
# Pipe mysql_system_tables.sql to "mysqld --bootstrap"
275285
s_echo "Installing MySQL system tables..."
276-
if `(echo "use mysql;"; cat $create_system_tables) | $mysqld_install_cmd_line`
286+
if `(echo "use mysql;"; cat $create_system_tables $fill_system_tables) | $mysqld_install_cmd_line`
277287
then
278288
s_echo "OK"
279289

scripts/mysql_system_tables.sql

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ set storage_engine=myisam;
66

77
CREATE TABLE IF NOT EXISTS db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges';
88

9-
-- default grants for anyone to access database 'test' and 'test_%'
10-
INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
11-
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
12-
139

1410
CREATE TABLE IF NOT EXISTS host ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges';
1511

@@ -57,9 +53,3 @@ CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NU
5753

5854
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
5955

60-
-- default users allowing root access from local machine
61-
INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
62-
REPLACE INTO user VALUES (@@hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
63-
REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
64-
65-

scripts/mysql_system_tables_data.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--
2+
-- The inital data for system tables of MySQL Server
3+
--
4+
5+
-- default grants for anyone to access database 'test' and 'test_%'
6+
INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
7+
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
8+
9+
-- default users allowing root access from local machine
10+
INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
11+
REPLACE INTO user VALUES (@@hostname,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
12+
REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
13+

0 commit comments

Comments
 (0)