Commit 12f5e3eb authored by unknown's avatar unknown

Merge eagle.mysql.r18.ru:/home/vva/work/mysql.orig/clear/mysql-4.0

into eagle.mysql.r18.ru:/home/vva/work/BUG_2874/mysql-4.0


mysql-test/mysql-test-run.sh:
  Auto merged
parents 65cc7890 2053f8f8
......@@ -867,36 +867,46 @@ int do_exec(struct st_query* q)
if (!*cmd)
die("Missing argument in exec\n");
if (q->record_file[0])
if (disable_result_log)
{
init_dynamic_string(&ds_tmp, "", 16384, 65536);
ds= &ds_tmp;
if (!(res_file= popen(cmd, "r")) && q->abort_on_error)
die("popen() failed\n");
while (fgets(buf, sizeof(buf), res_file));
pclose(res_file);
}
else
ds= &ds_res;
{
if (q->record_file[0])
{
init_dynamic_string(&ds_tmp, "", 16384, 65536);
ds= &ds_tmp;
}
else
ds= &ds_res;
if (!(res_file= popen(cmd, "r")) && q->abort_on_error)
die("popen() failed\n");
while (fgets(buf, sizeof(buf), res_file))
replace_dynstr_append_mem(ds, buf, strlen(buf));
pclose(res_file);
if (!(res_file= popen(cmd, "r")) && q->abort_on_error)
die("popen() failed\n");
while (fgets(buf, sizeof(buf), res_file))
replace_dynstr_append_mem(ds, buf, strlen(buf));
pclose(res_file);
if (glob_replace)
free_replace();
if (glob_replace)
free_replace();
if (record)
{
if (!q->record_file[0] && !result_file)
die("At line %u: Missing result file", start_lineno);
if (!result_file)
str_to_file(q->record_file, ds->str, ds->length);
}
else if (q->record_file[0])
{
error= check_result(ds, q->record_file, q->require_file);
if (record)
{
if (!q->record_file[0] && !result_file)
die("At line %u: Missing result file", start_lineno);
if (!result_file)
str_to_file(q->record_file, ds->str, ds->length);
}
else if (q->record_file[0])
{
error= check_result(ds, q->record_file, q->require_file);
}
if (ds == &ds_tmp)
dynstr_free(&ds_tmp);
}
if (ds == &ds_tmp)
dynstr_free(&ds_tmp);
return error;
}
......@@ -2251,7 +2261,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
{
if (i)
dynstr_append_mem(ds, "\t", 1);
dynstr_append(ds, fields[i].name);
replace_dynstr_append_mem(ds, fields[i].name, strlen(fields[i].name));
}
dynstr_append_mem(ds, "\n", 1);
append_result(ds, res);
......
#
# This test must examine structure of current system database
#
-- replace_result Tables_in_mysql Tables_in_db Tables_in_test Tables_in_db
show tables;
show create table db;
show create table host;
show create table user;
show create table func;
show create table tables_priv;
show create table columns_priv;
......@@ -72,9 +72,9 @@ if test ! -f $mdata/db.frm
then
# mysqld --bootstrap wants one command/line
c_d="$c_d CREATE TABLE db ("
c_d="$c_d Host char(60) DEFAULT '' NOT NULL,"
c_d="$c_d Db char(64) DEFAULT '' NOT NULL,"
c_d="$c_d User char(16) DEFAULT '' NOT NULL,"
c_d="$c_d Host char(60) binary DEFAULT '' NOT NULL,"
c_d="$c_d Db char(64) binary DEFAULT '' NOT NULL,"
c_d="$c_d User char(16) binary DEFAULT '' NOT NULL,"
c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
......@@ -99,8 +99,8 @@ fi
if test ! -f $mdata/host.frm
then
c_h="$c_h CREATE TABLE host ("
c_h="$c_h Host char(60) DEFAULT '' NOT NULL,"
c_h="$c_h Db char(64) DEFAULT '' NOT NULL,"
c_h="$c_h Host char(60) binary DEFAULT '' NOT NULL,"
c_h="$c_h Db char(64) binary DEFAULT '' NOT NULL,"
c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
......@@ -178,10 +178,10 @@ fi
if test ! -f $mdata/tables_priv.frm
then
c_t="$c_t CREATE TABLE tables_priv ("
c_t="$c_t Host char(60) DEFAULT '' NOT NULL,"
c_t="$c_t Db char(64) DEFAULT '' NOT NULL,"
c_t="$c_t User char(16) DEFAULT '' NOT NULL,"
c_t="$c_t Table_name char(60) DEFAULT '' NOT NULL,"
c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL,"
c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t User char(16) binary DEFAULT '' NOT NULL,"
c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14),"
c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
......@@ -195,11 +195,11 @@ fi
if test ! -f $mdata/columns_priv.frm
then
c_c="$c_c CREATE TABLE columns_priv ("
c_c="$c_c Host char(60) DEFAULT '' NOT NULL,"
c_c="$c_c Db char(64) DEFAULT '' NOT NULL,"
c_c="$c_c User char(16) DEFAULT '' NOT NULL,"
c_c="$c_c Table_name char(64) DEFAULT '' NOT NULL,"
c_c="$c_c Column_name char(64) DEFAULT '' NOT NULL,"
c_c="$c_c Host char(60) binary DEFAULT '' NOT NULL,"
c_c="$c_c Db char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c User char(16) binary DEFAULT '' NOT NULL,"
c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Timestamp timestamp(14),"
c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
......
......@@ -468,6 +468,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
LANGUAGE="$BASEDIR/sql/share/english/"
CHARSETSDIR="$BASEDIR/sql/share/charsets"
INSTALL_DB="./install_test_db"
MYSQL_FIX_SYSTEM_TABLES="$BASEDIR/scripts/mysql_fix_privilege_tables"
else
if test -x "$BASEDIR/libexec/mysqld"
then
......@@ -485,6 +486,7 @@ else
MYSQL_MANAGER_PWGEN="$BASEDIR/bin/mysqlmanager-pwgen"
MYSQL="$BASEDIR/bin/mysql"
INSTALL_DB="./install_test_db -bin"
MYSQL_FIX_SYSTEM_TABLES="$BASEDIR/bin/mysql_fix_privilege_tables"
if test -d "$BASEDIR/share/mysql/english"
then
LANGUAGE="$BASEDIR/share/mysql/english/"
......@@ -497,8 +499,12 @@ fi
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR"
MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password="
MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password="
export MYSQL
export MYSQL_DUMP
export MYSQL_BINLOG
export MYSQL_FIX_SYSTEM_TABLES
if [ -z "$MASTER_MYSQLD" ]
then
......@@ -1175,6 +1181,7 @@ run_testcase ()
master_init_script=$TESTDIR/$tname-master.sh
slave_init_script=$TESTDIR/$tname-slave.sh
slave_master_info_file=$TESTDIR/$tname.slave-mi
result_file=$tname
echo $tname > $CURRENT_TEST
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ $USE_MANAGER = 1 ] ; then
......@@ -1224,6 +1231,11 @@ run_testcase ()
# Note that this must be set to space, not "" for test-reset to work
EXTRA_MASTER_OPT=" "
;;
--result-file=*)
result_file=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--result-file=;;"`
# Note that this must be set to space, not "" for test-reset to work
EXTRA_MASTER_OPT=" "
;;
esac
stop_master
echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
......@@ -1281,7 +1293,7 @@ run_testcase ()
if [ -f $tf ] ; then
$RM -f r/$tname.*reject
mysql_test_args="-R r/$tname.result $EXTRA_MYSQL_TEST_OPT"
mysql_test_args="-R r/$result_file.result $EXTRA_MYSQL_TEST_OPT"
if [ -z "$DO_CLIENT_GDB" ] ; then
`$MYSQL_TEST $mysql_test_args < $tf 2> $TIMEFILE`;
else
......@@ -1313,7 +1325,7 @@ run_testcase ()
$ECHO "$RES$RES_SPACE [ fail ]"
$ECHO
error_is
show_failed_diff $tname
show_failed_diff $result_file
$ECHO
if [ x$FORCE != x1 ] ; then
$ECHO "Aborting. To continue, re-run with '--force'."
......
show tables;
Tables_in_db
columns_priv
db
func
host
tables_priv
user
show create table db;
Table Create Table
db CREATE TABLE `db` (
`Host` char(60) binary NOT NULL default '',
`Db` char(64) binary NOT NULL default '',
`User` char(16) binary NOT NULL default '',
`Select_priv` enum('N','Y') NOT NULL default 'N',
`Insert_priv` enum('N','Y') NOT NULL default 'N',
`Update_priv` enum('N','Y') NOT NULL default 'N',
`Delete_priv` enum('N','Y') NOT NULL default 'N',
`Create_priv` enum('N','Y') NOT NULL default 'N',
`Drop_priv` enum('N','Y') NOT NULL default 'N',
`Grant_priv` enum('N','Y') NOT NULL default 'N',
`References_priv` enum('N','Y') NOT NULL default 'N',
`Index_priv` enum('N','Y') NOT NULL default 'N',
`Alter_priv` enum('N','Y') NOT NULL default 'N',
`Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N',
`Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
PRIMARY KEY (`Host`,`Db`,`User`),
KEY `User` (`User`)
) TYPE=MyISAM COMMENT='Database privileges'
show create table host;
Table Create Table
host CREATE TABLE `host` (
`Host` char(60) binary NOT NULL default '',
`Db` char(64) binary NOT NULL default '',
`Select_priv` enum('N','Y') NOT NULL default 'N',
`Insert_priv` enum('N','Y') NOT NULL default 'N',
`Update_priv` enum('N','Y') NOT NULL default 'N',
`Delete_priv` enum('N','Y') NOT NULL default 'N',
`Create_priv` enum('N','Y') NOT NULL default 'N',
`Drop_priv` enum('N','Y') NOT NULL default 'N',
`Grant_priv` enum('N','Y') NOT NULL default 'N',
`References_priv` enum('N','Y') NOT NULL default 'N',
`Index_priv` enum('N','Y') NOT NULL default 'N',
`Alter_priv` enum('N','Y') NOT NULL default 'N',
`Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N',
`Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
PRIMARY KEY (`Host`,`Db`)
) TYPE=MyISAM COMMENT='Host privileges; Merged with database privileges'
show create table user;
Table Create Table
user CREATE TABLE `user` (
`Host` varchar(60) binary NOT NULL default '',
`User` varchar(16) binary NOT NULL default '',
`Password` varchar(16) binary NOT NULL default '',
`Select_priv` enum('N','Y') NOT NULL default 'N',
`Insert_priv` enum('N','Y') NOT NULL default 'N',
`Update_priv` enum('N','Y') NOT NULL default 'N',
`Delete_priv` enum('N','Y') NOT NULL default 'N',
`Create_priv` enum('N','Y') NOT NULL default 'N',
`Drop_priv` enum('N','Y') NOT NULL default 'N',
`Reload_priv` enum('N','Y') NOT NULL default 'N',
`Shutdown_priv` enum('N','Y') NOT NULL default 'N',
`Process_priv` enum('N','Y') NOT NULL default 'N',
`File_priv` enum('N','Y') NOT NULL default 'N',
`Grant_priv` enum('N','Y') NOT NULL default 'N',
`References_priv` enum('N','Y') NOT NULL default 'N',
`Index_priv` enum('N','Y') NOT NULL default 'N',
`Alter_priv` enum('N','Y') NOT NULL default 'N',
`Show_db_priv` enum('N','Y') NOT NULL default 'N',
`Super_priv` enum('N','Y') NOT NULL default 'N',
`Create_tmp_table_priv` enum('N','Y') NOT NULL default 'N',
`Lock_tables_priv` enum('N','Y') NOT NULL default 'N',
`Execute_priv` enum('N','Y') NOT NULL default 'N',
`Repl_slave_priv` enum('N','Y') NOT NULL default 'N',
`Repl_client_priv` enum('N','Y') NOT NULL default 'N',
`ssl_type` enum('','ANY','X509','SPECIFIED') NOT NULL default '',
`ssl_cipher` blob NOT NULL,
`x509_issuer` blob NOT NULL,
`x509_subject` blob NOT NULL,
`max_questions` int(11) unsigned NOT NULL default '0',
`max_updates` int(11) unsigned NOT NULL default '0',
`max_connections` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`Host`,`User`)
) TYPE=MyISAM COMMENT='Users and global privileges'
show create table func;
Table Create Table
func CREATE TABLE `func` (
`name` char(64) NOT NULL default '',
`ret` tinyint(1) NOT NULL default '0',
`dl` char(128) NOT NULL default '',
`type` enum('function','aggregate') NOT NULL default 'function',
PRIMARY KEY (`name`)
) TYPE=MyISAM COMMENT='User defined functions'
show create table tables_priv;
Table Create Table
tables_priv CREATE TABLE `tables_priv` (
`Host` char(60) binary NOT NULL default '',
`Db` char(64) binary NOT NULL default '',
`User` char(16) binary NOT NULL default '',
`Table_name` char(64) binary NOT NULL default '',
`Grantor` char(77) NOT NULL default '',
`Timestamp` timestamp(14) NOT NULL,
`Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') NOT NULL default '',
`Column_priv` set('Select','Insert','Update','References') NOT NULL default '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`)
) TYPE=MyISAM COMMENT='Table privileges'
show create table columns_priv;
Table Create Table
columns_priv CREATE TABLE `columns_priv` (
`Host` char(60) binary NOT NULL default '',
`Db` char(64) binary NOT NULL default '',
`User` char(16) binary NOT NULL default '',
`Table_name` char(64) binary NOT NULL default '',
`Column_name` char(64) binary NOT NULL default '',
`Timestamp` timestamp(14) NOT NULL,
`Column_priv` set('Select','Insert','Update','References') NOT NULL default '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
) TYPE=MyISAM COMMENT='Column privileges'
set @name="This is a very long string, that mustn't find room in a system field like Table_name. Thus it should be cut by the actual size of the field. So we can use this string to find out the actual length of the field and to use it in any compare queries";
create table test_db select * from mysql.db;
delete from test_db;
insert into test_db (Host,Db,User) values (@name,@name,@name);
create table test_host select * from mysql.host;
delete from test_host;
insert into test_host (Host,Db) values (@name,@name);
create table test_user select * from mysql.user;
delete from test_user;
insert into test_user (Host,User) values (@name,@name);
create table test_func select * from mysql.func;
delete from test_func;
insert into test_func (name) values (@name);
create table test_tables_priv select * from mysql.tables_priv;
delete from test_tables_priv;
insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name);
create table test_columns_priv select * from mysql.columns_priv;
delete from test_columns_priv;
insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name);
select
if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host,
if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host,
if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host,
if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host,
if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host
from test_db
left join test_host on test_db.Host=test_host.Host
left join test_user on test_db.Host=test_user.Host
left join test_tables_priv on test_db.Host=test_tables_priv.Host
left join test_columns_priv on test_db.Host=test_columns_priv.Host;
test_db_Host test_host_Host test_user_Host test_tables_priv_Host test_columns_priv_Host
ok ok ok ok ok
select
if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db,
if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db,
if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db,
if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db
from test_db
left join test_host on test_db.Db=test_host.Db
left join test_tables_priv on test_db.Db=test_tables_priv.Db
left join test_columns_priv on test_db.Db=test_columns_priv.Db;
test_db_Db test_host_Db test_tables_priv_Db est_columns_priv_Db
ok ok ok ok
select
if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User,
if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User,
if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
from test_db
left join test_user on test_db.User=test_user.User
left join test_tables_priv on test_db.User=test_tables_priv.User
left join test_columns_priv on test_db.User=test_columns_priv.User;
test_db_User test_user_User test_tables_priv_User test_columns_priv_User
ok ok ok ok
select
if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
from test_tables_priv
left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name;
test_tables_priv_User test_columns_priv_User
ok ok
drop table test_columns_priv;
drop table test_tables_priv;
drop table test_func;
drop table test_host;
drop table test_user;
drop table test_db;
#
# This test must examine integrity of system database "mysql"
#
-- disable_query_log
use mysql;
-- enable_query_log
-- source include/system_db_struct.inc
--result-file=system_mysql_db
\ No newline at end of file
#
# This is the test for mysql_fix_privilege_tables
#
-- disable_query_log
-- source include/create_old_system_tables.inc
-- exec $MYSQL_FIX_SYSTEM_TABLES --database=test > nil 2>nil
-- enable_query_log
-- source include/system_db_struct.inc
-- disable_query_log
-- source include/drop_system_tables.inc
-- enable_query_log
#
# This test must examine integrity of current system database
#
set @name="This is a very long string, that mustn't find room in a system field like Table_name. Thus it should be cut by the actual size of the field. So we can use this string to find out the actual length of the field and to use it in any compare queries";
#
# If this part is wrong, most likely you've done wrong modification of system database "mysql"
#
create table test_db select * from mysql.db;
delete from test_db;
insert into test_db (Host,Db,User) values (@name,@name,@name);
create table test_host select * from mysql.host;
delete from test_host;
insert into test_host (Host,Db) values (@name,@name);
create table test_user select * from mysql.user;
delete from test_user;
insert into test_user (Host,User) values (@name,@name);
create table test_func select * from mysql.func;
delete from test_func;
insert into test_func (name) values (@name);
create table test_tables_priv select * from mysql.tables_priv;
delete from test_tables_priv;
insert into test_tables_priv (Host,Db,User,Table_name) values (@name,@name,@name,@name);
create table test_columns_priv select * from mysql.columns_priv;
delete from test_columns_priv;
insert into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name);
# 'Host' field must be the same for all the tables:
select
if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host,
if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host,
if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host,
if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host,
if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host
from test_db
left join test_host on test_db.Host=test_host.Host
left join test_user on test_db.Host=test_user.Host
left join test_tables_priv on test_db.Host=test_tables_priv.Host
left join test_columns_priv on test_db.Host=test_columns_priv.Host;
# 'Db' field must be the same for all the tables:
select
if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db,
if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db,
if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db,
if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db
from test_db
left join test_host on test_db.Db=test_host.Db
left join test_tables_priv on test_db.Db=test_tables_priv.Db
left join test_columns_priv on test_db.Db=test_columns_priv.Db;
# 'User' field must be the same for all the tables:
select
if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User,
if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User,
if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
from test_db
left join test_user on test_db.User=test_user.User
left join test_tables_priv on test_db.User=test_tables_priv.User
left join test_columns_priv on test_db.User=test_columns_priv.User;
# 'Table_name' field must be the same for all the tables:
select
if(isnull(test_tables_priv.User),'WRONG!!!','ok') as test_tables_priv_User,
if(isnull(test_columns_priv.User),'WRONG!!!','ok') as test_columns_priv_User
from test_tables_priv
left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Table_name;
drop table test_columns_priv;
drop table test_tables_priv;
drop table test_func;
drop table test_host;
drop table test_user;
drop table test_db;
#!/bin/sh
#
# Copyright (C) 2004 MySQL AB
# For a more info consult the file COPYRIGHT distributed with this file.
#
# This script converts any old privilege tables to privilege tables suitable
# for MySQL 4.0.
#
# You can safely ignore all 'Duplicate column' and 'Unknown column' errors"
# as this just means that your tables where already up to date.
# This script is safe to run even if your tables are already up to date!
#
# On windows you should do 'mysql --force < mysql_fix_privilege_tables.sql'
# instead of this script
#
# Usage:
# mysql_fix_privilege_tables
# - fix tables for host "localhost" as "root" with no password
# mysql_fix_privilege_tables <password>
# - fix tables for host "localhost" as "root" with <password>
# mysql_fix_privilege_tables --sql-only
# - output sql-script to file /usr/share/mysql/echo_stderr
# mysql_fix_privilege_tables OPTIONS
# - fix tables on connection with OPTIONS
#
# where OPTIONS are
# --host=<host>
# --port=<port>
# --socket=<socket>
# --user=<user>
# --password=<password>
# --database=<database>
root_password="$1"
host="localhost"
user="root"
port=""
socket=""
comment=""
database="mysql"
if test -z "$1" ; then
cmd="@bindir@/mysql -f --user=$user --host=$host mysql"
else
root_password="$1"
cmd="@bindir@/mysql -f --user=$user --password=$root_password --host=$host mysql"
fi
# read all the options
parse_arguments()
{
for arg do
case "$arg" in
--sql-only) cmd="/usr/share/mysql/echo_stderr" ;;
--port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;;
--user=*) user=`echo "$arg" | sed -e "s;--user=;;"` ;;
--host=*) host=`echo "$arg" | sed -e "s;--host=;;"` ;;
--socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;;
--password=*) root_password=`echo "$arg" | sed -e "s;--password=;;"` ;;
--database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;;
*)
echo "Unknown argument '$arg'"
exit 1
;;
esac
done
}
parse_arguments "$@"
# Debian addition
if [ "$1" = "--sql-only" ]; then
root_password=""
cmd="/usr/share/mysql/echo_stderr"
if test -z "$cmd"; then
cmd="@bindir@/mysql -f --user=$user --host=$host"
if test ! -z "$root_password"; then
cmd="$cmd --password=$root_password"
fi
if test ! -z "$port"; then
cmd="$cmd --port=$port"
fi
if test ! -z "$socket"; then
cmd="$cmd --socket=$socket"
fi
cmd="$cmd $database"
fi
echo "This scripts updates the mysql.user, mysql.db, mysql.host and the"
......@@ -201,3 +260,22 @@ alter table host
add Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
add Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
END_OF_DATA
#
# Fix the new bugs discovered by new tests (for Bug #2874 Grant table bugs )
#
$cmd <<END_OF_DATA
alter table db change Db Db char(64) binary DEFAULT '' NOT NULL;
alter table host change Db Db char(64) binary DEFAULT '' NOT NULL;
alter table user change password Password char(16) binary NOT NULL, change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL;
alter table tables_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL;
alter table tables_priv add KEY Grantor (Grantor);
alter table columns_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL, change Column_name Column_name char(64) binary DEFAULT '' NOT NULL;
alter table db comment='Database privileges';
alter table host comment='Host privileges; Merged with database privileges';
alter table user comment='Users and global privileges';
alter table func comment='User defined functions';
alter table tables_priv comment='Table privileges';
alter table columns_priv comment='Column privileges';
END_OF_DATA
......@@ -135,3 +135,16 @@ ALTER TABLE host
ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,
ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL;
alter table db change Db Db char(64) binary DEFAULT '' NOT NULL;
alter table host change Db Db char(64) binary DEFAULT '' NOT NULL;
alter table user change password Password char(16) binary NOT NULL, change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL;
alter table tables_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL;
alter table tables_priv add KEY Grantor (Grantor);
alter table columns_priv change Db Db char(64) binary DEFAULT '' NOT NULL, change Host Host char(60) binary DEFAULT '' NOT NULL, change User User char(16) binary DEFAULT '' NOT NULL, change Table_name Table_name char(64) binary DEFAULT '' NOT NULL, change Column_name Column_name char(64) binary DEFAULT '' NOT NULL;
alter table db comment='Database privileges';
alter table host comment='Host privileges; Merged with database privileges';
alter table user comment='Users and global privileges';
alter table func comment='User defined functions';
alter table tables_priv comment='Table privileges';
alter table columns_priv comment='Column privileges';
......@@ -284,7 +284,7 @@ then
c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL,"
c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t User char(16) binary DEFAULT '' NOT NULL,"
c_t="$c_t Table_name char(60) binary DEFAULT '' NOT NULL,"
c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14),"
c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment