Skip to content

Commit dc88e57

Browse files
author
msvensson@neptunus.(none)
committed
Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
into neptunus.(none):/home/msvensson/mysql/mysql-5.1-maint
2 parents e753d61 + e36384f commit dc88e57

8 files changed

+224
-61
lines changed

mysql-test/mysql-test-run.pl

+4
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,10 @@ ()
19001900
# ----------------------------------------------------
19011901
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults;
19021902

1903+
# ----------------------------------------------------
1904+
# Setup env so childs can execute mysqladmin
1905+
# ----------------------------------------------------
1906+
$ENV{'MYSQLADMIN'}= $exe_mysqladmin;
19031907

19041908
# ----------------------------------------------------
19051909
# Setup env so childs can execute perror

mysql-test/r/fix_priv_tables.result

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
drop table if exists t1,t1aa,t2aa;
2+
DROP DATABASE IF EXISTS testdb;
3+
CREATE DATABASE testdb;
4+
CREATE TABLE testdb.t1 (
5+
c1 INT,
6+
c3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
7+
CREATE VIEW testdb.v1 AS
8+
SELECT * FROM testdb.t1;
9+
GRANT CREATE VIEW, SHOW VIEW ON testdb.v1 TO 'show_view_tbl'@'localhost';
10+
SHOW GRANTS FOR 'show_view_tbl'@'localhost';
11+
Grants for show_view_tbl@localhost
12+
GRANT USAGE ON *.* TO 'show_view_tbl'@'localhost'
13+
GRANT CREATE VIEW, SHOW VIEW ON `testdb`.`v1` TO 'show_view_tbl'@'localhost'
14+
15+
GRANT SELECT(c1) on testdb.v1 to 'select_only_c1'@localhost;
16+
SHOW GRANTS FOR 'select_only_c1'@'localhost';
17+
Grants for select_only_c1@localhost
18+
GRANT USAGE ON *.* TO 'select_only_c1'@'localhost'
19+
GRANT SELECT (c1) ON `testdb`.`v1` TO 'select_only_c1'@'localhost'
20+
21+
"after fix privs"
22+
SHOW GRANTS FOR 'show_view_tbl'@'localhost';
23+
Grants for show_view_tbl@localhost
24+
GRANT USAGE ON *.* TO 'show_view_tbl'@'localhost'
25+
GRANT CREATE VIEW, SHOW VIEW ON `testdb`.`v1` TO 'show_view_tbl'@'localhost'
26+
27+
SHOW GRANTS FOR 'select_only_c1'@'localhost';
28+
Grants for select_only_c1@localhost
29+
GRANT USAGE ON *.* TO 'select_only_c1'@'localhost'
30+
GRANT SELECT (c1) ON `testdb`.`v1` TO 'select_only_c1'@'localhost'
31+
32+
DROP USER 'show_view_tbl'@'localhost';
33+
DROP USER 'select_only_c1'@'localhost';
34+
DROP VIEW testdb.v1;
35+
DROP TABLE testdb.t1;
36+
DROP DATABASE testdb;

mysql-test/r/fix_priv_tabs.result

Whitespace-only changes.

mysql-test/r/mysqladmin.result

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mysqld is alive
2+
mysqladmin: unknown variable 'database=db1'
3+
Warning: mysqladmin: unknown variable 'loose-database=db2'
4+
mysqld is alive

mysql-test/t/fix_priv_tables.test

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Embedded server doesn't support external clients
2+
--source include/not_embedded.inc
3+
4+
#
5+
# This is the test for mysql_fix_privilege_tables
6+
# It checks that a system tables from mysql 4.1.23
7+
# can be upgraded to current system table format
8+
#
9+
# Note: If this test fails, don't be confused about the errors reported
10+
# by mysql-test-run This shows warnings generated by
11+
# mysql_fix_system_tables which should be ignored.
12+
# Instead, concentrate on the errors in r/system_mysql_db.reject
13+
14+
--disable_warnings
15+
drop table if exists t1,t1aa,t2aa;
16+
--enable_warnings
17+
18+
#
19+
# Bug #20589 Missing some table level privileges after upgrade
20+
#
21+
# Add some grants that should survive the "upgrade"
22+
23+
--disable_warnings
24+
DROP DATABASE IF EXISTS testdb;
25+
--enable_warnings
26+
CREATE DATABASE testdb;
27+
CREATE TABLE testdb.t1 (
28+
c1 INT,
29+
c3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
30+
31+
CREATE VIEW testdb.v1 AS
32+
SELECT * FROM testdb.t1;
33+
34+
GRANT CREATE VIEW, SHOW VIEW ON testdb.v1 TO 'show_view_tbl'@'localhost';
35+
SHOW GRANTS FOR 'show_view_tbl'@'localhost';
36+
echo;
37+
38+
# Some extra GRANTS for more complete test
39+
GRANT SELECT(c1) on testdb.v1 to 'select_only_c1'@localhost;
40+
SHOW GRANTS FOR 'select_only_c1'@'localhost';
41+
echo;
42+
43+
-- disable_result_log
44+
-- disable_query_log
45+
46+
# Run the mysql_fix_privilege_tables.sql using "mysql --force"
47+
--exec $MYSQL --force mysql < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/log/fix_priv_tables.log 2>&1
48+
49+
-- enable_query_log
50+
-- enable_result_log
51+
52+
echo "after fix privs";
53+
54+
SHOW GRANTS FOR 'show_view_tbl'@'localhost';
55+
echo;
56+
SHOW GRANTS FOR 'select_only_c1'@'localhost';
57+
echo;
58+
59+
DROP USER 'show_view_tbl'@'localhost';
60+
DROP USER 'select_only_c1'@'localhost';
61+
62+
DROP VIEW testdb.v1;
63+
DROP TABLE testdb.t1;
64+
DROP DATABASE testdb;
65+
66+
# End of 4.1 tests

mysql-test/t/mysqladmin.test

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# Test "mysqladmin ping"
3+
#
4+
5+
--exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
6+
7+
8+
#
9+
# Bug#10608 mysqladmin breaks on "database" variable in my.cnf
10+
#
11+
12+
# When mysqladmin finds database in .cnf file it shall fail
13+
--write_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf
14+
[client]
15+
database=db1
16+
EOF
17+
18+
--replace_regex /\/.*mysqladmin/mysqladmin/
19+
--error 7
20+
--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
21+
22+
23+
# When mysqladmin finds "loose-database" in .cnf file it shall print
24+
# a warning and continue
25+
--write_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf
26+
[client]
27+
loose-database=db2
28+
EOF
29+
30+
--replace_regex /Warning: .*mysqladmin/Warning: mysqladmin/
31+
--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
32+

mysys/my_getopt.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ char *disabled_my_option= (char*) "0";
5959

6060
my_bool my_getopt_print_errors= 1;
6161

62-
static void default_reporter(enum loglevel level __attribute__((unused)),
62+
static void default_reporter(enum loglevel level,
6363
const char *format, ...)
6464
{
6565
va_list args;
6666
va_start(args, format);
67+
if (level == WARNING_LEVEL)
68+
fprintf(stderr, "%s", "Warning: ");
69+
else if (level == INFORMATION_LEVEL)
70+
fprintf(stderr, "%s", "Info: ");
6771
vfprintf(stderr, format, args);
6872
va_end(args);
6973
}

scripts/mysql_fix_privilege_tables.sql

+77-60
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# This script converts any old privilege tables to privilege tables suitable
22
# for this version of MySQL
3-
43
# You can safely ignore all 'Duplicate column' and 'Unknown column' errors"
54
# because these just mean that your tables are already up to date.
65
# This script is safe to run even if your tables are already up to date!
@@ -52,32 +51,47 @@ ADD x509_subject BLOB NOT NULL;
5251
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
5352

5453
#
55-
# Create tables_priv and columns_priv if they don't exists
54+
# tables_priv
5655
#
57-
5856
CREATE TABLE IF NOT EXISTS tables_priv (
5957
Host char(60) binary DEFAULT '' NOT NULL,
6058
Db char(64) binary DEFAULT '' NOT NULL,
6159
User char(16) binary DEFAULT '' NOT NULL,
6260
Table_name char(64) binary DEFAULT '' NOT NULL,
6361
Grantor char(77) DEFAULT '' NOT NULL,
6462
Timestamp timestamp(14),
65-
Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
66-
Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
63+
Table_priv set('Select','Insert','Update','Delete','Create',
64+
'Drop','Grant','References','Index','Alter')
65+
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
66+
Column_priv set('Select','Insert','Update','References')
67+
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
6768
PRIMARY KEY (Host,Db,User,Table_name)
6869
) CHARACTER SET utf8 COLLATE utf8_bin;
6970
# Fix collation of set fields
7071
ALTER TABLE tables_priv
71-
modify Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
72-
modify Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
73-
ALTER TABLE procs_priv ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
74-
ALTER TABLE procs_priv
75-
modify Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
76-
ALTER TABLE procs_priv
77-
add Routine_type enum('FUNCTION','PROCEDURE') COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
78-
ALTER TABLE procs_priv
79-
modify Timestamp timestamp(14) AFTER Proc_priv;
72+
ADD KEY Grantor (Grantor);
8073

74+
ALTER TABLE tables_priv
75+
MODIFY Host char(60) NOT NULL default '',
76+
MODIFY Db char(64) NOT NULL default '',
77+
MODIFY User char(16) NOT NULL default '',
78+
MODIFY Table_name char(64) NOT NULL default '',
79+
MODIFY Grantor char(77) NOT NULL default '',
80+
ENGINE=MyISAM,
81+
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
82+
83+
ALTER TABLE tables_priv
84+
MODIFY Column_priv set('Select','Insert','Update','References')
85+
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
86+
MODIFY Table_priv set('Select','Insert','Update','Delete','Create',
87+
'Drop','Grant','References','Index','Alter',
88+
'Create View','Show view')
89+
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
90+
COMMENT='Table privileges';
91+
92+
#
93+
# columns_priv
94+
#
8195
CREATE TABLE IF NOT EXISTS columns_priv (
8296
Host char(60) DEFAULT '' NOT NULL,
8397
Db char(64) DEFAULT '' NOT NULL,
@@ -88,16 +102,26 @@ CREATE TABLE IF NOT EXISTS columns_priv (
88102
Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
89103
PRIMARY KEY (Host,Db,User,Table_name,Column_name)
90104
) CHARACTER SET utf8 COLLATE utf8_bin;
91-
# Fix collation of set fields
92-
ALTER TABLE columns_priv
93-
MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
94-
95-
96105
#
97106
# Name change of Type -> Column_priv from MySQL 3.22.12
98107
#
108+
ALTER TABLE columns_priv
109+
CHANGE Type Column_priv set('Select','Insert','Update','References')
110+
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
111+
112+
ALTER TABLE columns_priv
113+
MODIFY Host char(60) NOT NULL default '',
114+
MODIFY Db char(64) NOT NULL default '',
115+
MODIFY User char(16) NOT NULL default '',
116+
MODIFY Table_name char(64) NOT NULL default '',
117+
MODIFY Column_name char(64) NOT NULL default '',
118+
ENGINE=MyISAM,
119+
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin,
120+
COMMENT='Column privileges';
99121

100-
ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
122+
ALTER TABLE columns_priv
123+
MODIFY Column_priv set('Select','Insert','Update','References')
124+
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
101125

102126
#
103127
# Add the new 'type' column to the func table.
@@ -147,14 +171,12 @@ ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
147171
ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
148172

149173
alter table user change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL;
150-
alter table tables_priv add KEY Grantor (Grantor);
174+
151175

152176
alter table db comment='Database privileges';
153177
alter table host comment='Host privileges; Merged with database privileges';
154178
alter table user comment='Users and global privileges';
155179
alter table func comment='User defined functions';
156-
alter table tables_priv comment='Table privileges';
157-
alter table columns_priv comment='Column privileges';
158180

159181
# Convert all tables to UTF-8 with binary collation
160182
# and reset all char columns to correct width
@@ -228,25 +250,6 @@ ALTER TABLE func
228250
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
229251
ALTER TABLE func
230252
MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
231-
ALTER TABLE columns_priv
232-
MODIFY Host char(60) NOT NULL default '',
233-
MODIFY Db char(64) NOT NULL default '',
234-
MODIFY User char(16) NOT NULL default '',
235-
MODIFY Table_name char(64) NOT NULL default '',
236-
MODIFY Column_name char(64) NOT NULL default '',
237-
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
238-
ALTER TABLE columns_priv
239-
MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
240-
ALTER TABLE tables_priv
241-
MODIFY Host char(60) NOT NULL default '',
242-
MODIFY Db char(64) NOT NULL default '',
243-
MODIFY User char(16) NOT NULL default '',
244-
MODIFY Table_name char(64) NOT NULL default '',
245-
MODIFY Grantor char(77) NOT NULL default '',
246-
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
247-
ALTER TABLE tables_priv
248-
MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
249-
MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
250253

251254
#
252255
# Detect whether we had Create_view_priv
@@ -278,11 +281,6 @@ ALTER TABLE host MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEF
278281
ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
279282
ALTER TABLE user MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
280283

281-
#
282-
# Show/Create views table privileges (v5.0)
283-
#
284-
ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
285-
286284
#
287285
# Assign create/show view privileges to people who have create provileges
288286
#
@@ -349,22 +347,41 @@ UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y'
349347
WHERE @hadCreateUserPriv = 0 AND
350348
(user.Grant_priv = 'Y' OR db.Grant_priv = 'Y');
351349

352-
#
353-
# Create some possible missing tables
354-
#
350+
--
351+
-- procs_priv
352+
--
355353
CREATE TABLE IF NOT EXISTS procs_priv (
356-
Host char(60) binary DEFAULT '' NOT NULL,
357-
Db char(64) binary DEFAULT '' NOT NULL,
358-
User char(16) binary DEFAULT '' NOT NULL,
359-
Routine_name char(64) binary DEFAULT '' NOT NULL,
360-
Routine_type enum('FUNCTION','PROCEDURE') NOT NULL,
361-
Grantor char(77) DEFAULT '' NOT NULL,
362-
Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL,
363-
Timestamp timestamp(14),
364-
PRIMARY KEY (Host,Db,User,Routine_name,Routine_type),
365-
KEY Grantor (Grantor)
354+
Host char(60) binary DEFAULT '' NOT NULL,
355+
Db char(64) binary DEFAULT '' NOT NULL,
356+
User char(16) binary DEFAULT '' NOT NULL,
357+
Routine_name char(64) binary DEFAULT '' NOT NULL,
358+
Routine_type enum('FUNCTION','PROCEDURE') NOT NULL,
359+
Grantor char(77) DEFAULT '' NOT NULL,
360+
Proc_priv set('Execute','Alter Routine','Grant')
361+
COLLATE utf8_general_ci DEFAULT '' NOT NULL,
362+
Timestamp timestamp(14),
363+
PRIMARY KEY (Host, Db, User, Routine_name, Routine_type),
364+
KEY Grantor (Grantor)
366365
) CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
367366

367+
ALTER TABLE procs_priv
368+
ENGINE=MyISAM,
369+
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
370+
371+
ALTER TABLE procs_priv
372+
MODIFY Proc_priv set('Execute','Alter Routine','Grant')
373+
COLLATE utf8_general_ci DEFAULT '' NOT NULL;
374+
375+
ALTER TABLE procs_priv
376+
ADD Routine_type enum('FUNCTION','PROCEDURE')
377+
COLLATE utf8_general_ci NOT NULL AFTER Routine_name;
378+
379+
ALTER TABLE procs_priv
380+
MODIFY Timestamp timestamp(14) AFTER Proc_priv;
381+
382+
--
383+
-- help_topic
384+
--
368385
CREATE TABLE IF NOT EXISTS help_topic (
369386
help_topic_id int unsigned not null,
370387
name varchar(64) not null,

0 commit comments

Comments
 (0)