summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/CMakeLists.txt2
-rw-r--r--scripts/Makefile.am3
-rw-r--r--scripts/mysql_fix_privilege_tables.sh223
-rw-r--r--scripts/mysql_system_tables.sql84
-rw-r--r--scripts/mysql_system_tables_fix.sql4
-rw-r--r--scripts/mysqld_safe.sh8
6 files changed, 87 insertions, 237 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 26dfb243897..3352eb23a73 100755
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -65,7 +65,7 @@ ADD_CUSTOM_TARGET(GenFixPrivs
IF(UNIX)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution
- "cd ${CMAKE_BINARY_DIR} && ${CMAKE_CPACK_COMMAND} -G TGZ --config CPackConfig.cmake" )
+ "cd ${CMAKE_BINARY_DIR} && '${CMAKE_CPACK_COMMAND}' -G TGZ --config CPackConfig.cmake" )
EXECUTE_PROCESS(
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution
)
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 118c312d218..9179995e814 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -23,7 +23,6 @@ EXTRA_PROGRAMS = comp_sql
bin_SCRIPTS = @server_scripts@ \
msql2mysql \
mysql_config \
- mysql_fix_privilege_tables \
mysql_fix_extensions \
mysql_setpermission \
mysql_secure_installation \
@@ -45,7 +44,6 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \
msql2mysql.sh \
mysql_config.sh \
mysql_config.pl.in \
- mysql_fix_privilege_tables.sh \
mysql_fix_extensions.sh \
mysql_install_db.sh \
mysql_install_db.pl.in \
@@ -82,7 +80,6 @@ CLEANFILES = @server_scripts@ \
make_sharedlib_distribution \
msql2mysql \
mysql_config \
- mysql_fix_privilege_tables \
mysql_fix_extensions \
mysql_setpermission \
mysql_secure_installation \
diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh
deleted file mode 100644
index dd5edb699a0..00000000000
--- a/scripts/mysql_fix_privilege_tables.sh
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2000-2006 MySQL AB
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-# This script is a wrapper to pipe the mysql_fix_privilege_tables.sql
-# through the mysql client program to the mysqld server
-
-# Default values (Can be changed in my.cnf)
-password=""
-host="localhost"
-user="root"
-sql_only=0
-basedir="@prefix@"
-verbose=0
-args=""
-# no elaborate fallback here; with no argument, it will happen in "mysql"
-port=""
-socket=""
-database="mysql"
-bindir=""
-pkgdatadir="@pkgdatadir@"
-print_defaults_bindir="."
-
-file=mysql_fix_privilege_tables.sql
-
-# The following test is to make this script compatible with the 4.0 where
-# the single argument could be a password
-if test "$#" = 1
-then
- case "$1" in
- --*) ;;
- *) old_style_password="$1" ; shift ;;
- esac
-fi
-
-# The following code is almost identical to the code in mysql_install_db.sh
-
-case "$1" in
- --no-defaults|--defaults-file=*|--defaults-extra-file=*)
- defaults="$1"; shift
- ;;
-esac
-
-parse_arguments() {
- # We only need to pass arguments through to the server if we don't
- # handle them here. So, we collect unrecognized options (passed on
- # the command line) into the args variable.
- pick_args=
- if test "$1" = PICK-ARGS-FROM-ARGV
- then
- pick_args=1
- shift
- fi
-
- for arg do
- case "$arg" in
- --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
- --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
- --password=*) password=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
- --host=*) host=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
- --sql|--sql-only) sql_only=1 ;;
- --verbose) verbose=1 ;;
- --port=*) port=`echo "$arg" | sed -e "s;--port=;;"` ;;
- --socket=*) socket=`echo "$arg" | sed -e "s;--socket=;;"` ;;
- --database=*) database=`echo "$arg" | sed -e "s;--database=;;"` ;;
- --bindir=*) bindir=`echo "$arg" | sed -e "s;--bindir=;;"`
- print_defaults_bindir=$bindir
- ;;
- *)
- if test -n "$pick_args"
- then
- # This sed command makes sure that any special chars are quoted,
- # so the arg gets passed exactly to the server.
- args="$args "`echo "$arg" | sed -e 's,\([^=a-zA-Z0-9_.-]\),\\\\\1,g'`
- fi
- ;;
- esac
- done
-}
-
-# Get first arguments from the my.cfg file, groups [mysqld] and
-# [mysql_install_db], and then merge with the command line arguments
-
-print_defaults=my_print_defaults
-for dir in ./bin @bindir@ @bindir@ extra $print_defaults_bindir/../bin $print_defaults_bindir/../extra
-do
- if test -x $dir/my_print_defaults
- then
- print_defaults="$dir/my_print_defaults"
- break
- fi
-done
-
-parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables`
-parse_arguments PICK-ARGS-FROM-ARGV "$@"
-
-if test -z "$password"
-then
- password=$old_style_password
-fi
-
-# Find where 'mysql' command is located
-
-dirname=`dirname "$0"`
-
-if test -z "$bindir"
-then
- for i in @bindir@ $basedir/bin "$dirname/../client"
- do
- if test -f $i/mysql
- then
- bindir=$i
- break
- fi
- done
-fi
-
-if test -z "$bindir"
-then
- echo "Could not find MySQL command-line client (mysql)."
- echo "Please use --basedir to specify the directory where MySQL is installed."
- exit 1
-fi
-
-cmd="$bindir/mysql --no-defaults --default-character-set=latin1 --force --user=$user --host=$host"
-if test ! -z "$port"; then
- cmd="$cmd --port=$port"
-fi
-if test ! -z "$socket"; then
- cmd="$cmd --socket=$socket"
-fi
-cmd="$cmd --database=$database"
-
-if test $sql_only = 1
-then
- cmd="cat"
-fi
-
-# Find where first mysql_fix_privilege_tables.sql is located
-for i in $basedir/support-files $basedir/share $basedir/share/mysql \
- $basedir/scripts $pkgdatadir . "$dirname"
-do
- if test -f $i/$file
- then
- pkgdatadir=$i
- break
- fi
-done
-
-sql_file="$pkgdatadir/$file"
-if test ! -f $sql_file
-then
- echo "Could not find file '$file'."
- echo "Please use --basedir to specify the directory where MySQL is installed"
- exit 1
-fi
-
-s_echo()
-{
- if test $sql_only = 0
- then
- echo $1
- fi
-}
-
-s_echo "This script updates all the mysql privilege tables to be usable by"
-s_echo "the current version of MySQL"
-s_echo ""
-
-if test $verbose = 1
-then
- s_echo "You can safely ignore all 'Duplicate column' and 'Unknown column' errors"
- s_echo "because these just mean that your tables are already up to date."
- s_echo "This script is safe to run even if your tables are already up to date!"
- s_echo ""
-fi
-
-run_cmd() {
- # Password argument is added here to allow for spaces in password.
-
- if test ! -z "$password"
- then
- cat $sql_file | $cmd --password="$password"
- else
- cat $sql_file | $cmd
- fi
-}
-
-if test $verbose = 0
-then
- run_cmd > /dev/null 2>&1
-else
- run_cmd > /dev/null
-fi
-if test $? = 0
-then
- s_echo "done"
-else
- s_echo "Got a failure from command:"
- s_echo "cat $sql_file | $cmd"
- s_echo "Please check the above output and try again."
- if test $verbose = 0
- then
- s_echo ""
- s_echo "Running the script with the --verbose option may give you some information"
- s_echo "of what went wrong."
- fi
- s_echo ""
- s_echo "If you get an 'Access denied' error, you should run this script again and"
- s_echo "give the MySQL root user password as an argument with the --password= option"
-fi
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index bcbedae4d0f..69d6d6d7feb 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -1,4 +1,4 @@
--- Copyright (C) 2008-2009 Sun Microsystems, Inc
+-- Copyright (C) 2008, 2010 Oracle and/or its affiliates. All rights reserved.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@@ -100,18 +100,92 @@ CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_b
CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM;
+--
+-- PERFORMANCE SCHEMA INSTALLATION
+-- Note that this script is also reused by mysql_upgrade,
+-- so we have to be very careful here to not destroy any
+-- existing database named 'performance_schema' if it
+-- can contain user data.
+-- In case of downgrade, it's ok to drop unknown tables
+-- from a future version, as long as they belong to the
+-- performance schema engine.
+--
+
+set @have_old_pfs= (select count(*) from information_schema.schemata where schema_name='performance_schema');
+
+SET @l1="SET @broken_tables = (select count(*) from information_schema.tables";
+SET @l2=" where engine != \'PERFORMANCE_SCHEMA\' and table_schema=\'performance_schema\')";
+SET @cmd=concat(@l1,@l2);
+
+-- Work around for bug#49542
+SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_tables = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+SET @l1="SET @broken_views = (select count(*) from information_schema.views";
+SET @l2=" where table_schema='performance_schema')";
+SET @cmd=concat(@l1,@l2);
+
+-- Work around for bug#49542
+SET @str = IF(@have_old_pfs = 1, @cmd, 'SET @broken_views = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+SET @broken_routines = (select count(*) from mysql.proc where db='performance_schema');
+
+SET @broken_events = (select count(*) from mysql.event where db='performance_schema');
+
+SET @broken_pfs= (select @broken_tables + @broken_views + @broken_routines + @broken_events);
--
-- The performance schema database.
--- This database is always created, even in --without-perfschema builds,
+-- Only drop and create the database if this is safe (no broken_pfs).
+-- This database is created, even in --without-perfschema builds,
-- so that the database name is always reserved by the MySQL implementation.
--
-set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO');
+SET @cmd= "DROP DATABASE IF EXISTS performance_schema";
+
+SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
-DROP DATABASE IF EXISTS performance_schema;
+SET @cmd= "CREATE DATABASE performance_schema character set utf8";
-CREATE DATABASE performance_schema character set utf8;
+SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+--
+-- Unlike 'performance_schema', the 'mysql' database is reserved already,
+-- so no user procedure is supposed to be there
+--
+drop procedure if exists mysql.die;
+create procedure mysql.die() signal sqlstate 'HY000' set message_text='Unexpected content found in the performance_schema database.';
+
+--
+-- For broken upgrades, SIGNAL the error
+--
+
+SET @cmd="call mysql.die()";
+
+SET @str = IF(@broken_pfs > 0, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+drop procedure mysql.die;
+
+--
+-- From this point, only create the performance schema tables
+-- if the server is build with performance schema
+--
+
+set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO');
--
-- TABLE COND_INSTANCES
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index 8551e4cd6c9..6ddb9ef4c9c 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -5,10 +5,6 @@
# because these just mean that your tables are already up to date.
# This script is safe to run even if your tables are already up to date!
-# On unix, you should use the mysql_fix_privilege_tables script to execute
-# this sql script.
-# On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql'
-
set sql_mode='';
set storage_engine=MyISAM;
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index f08e870d5e0..5420ebd908e 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -54,6 +54,8 @@ Usage: $0 [OPTIONS]
--mysqld=FILE Use the specified file as mysqld
--mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
--nice=NICE Set the scheduling priority of mysqld
+ --plugin-dir=DIR Plugins are under DIR or DIR/VERSION, if
+ VERSION is given
--skip-kill-mysqld Don't try to kill stray mysqld processes
--syslog Log messages to syslog with 'logger'
--skip-syslog Log messages to error log (default)
@@ -172,6 +174,7 @@ parse_arguments() {
--basedir=*) MY_BASEDIR_VERSION="$val" ;;
--datadir=*) DATADIR="$val" ;;
--pid-file=*) pid_file="$val" ;;
+ --plugin-dir=*) PLUGIN_DIR="$val" ;;
--user=*) user="$val"; SET_USER=1 ;;
# these might have been set in a [mysqld_safe] section of my.cnf
@@ -189,6 +192,7 @@ parse_arguments() {
if test -n "$val"
then
MYSQLD="mysqld-$val"
+ PLUGIN_VARIANT="/$val"
else
MYSQLD="mysqld"
fi
@@ -695,8 +699,10 @@ fi
cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS"
+plugin_dir="${PLUGIN_DIR:-@pkgplugindir@}${PLUGIN_VARIANT}"
+
for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \
- "--datadir=$DATADIR" "$USER_OPTION"
+ "--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION"
do
cmd="$cmd "`shell_quote_string "$i"`
done