From faa9c92765f641a3af3b7a757544f64bc0c6ab82 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Wed, 10 Mar 2004 22:54:07 +0400 Subject: fixed BUG #2874 "Grant table bug" and added tests for testing structure of mysql db --- scripts/mysql_fix_privilege_tables.sh | 98 ++++++++++++++++++++++++++++++---- scripts/mysql_fix_privilege_tables.sql | 13 +++++ scripts/mysql_install_db.sh | 2 +- 3 files changed, 102 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 7ba42e560bb..5e3e4210aa4 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -1,20 +1,79 @@ #!/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 +# - fix tables for host "localhost" as "root" with +# 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= +# --port= +# --socket= +# --user= +# --password= +# --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 <