diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.am | 8 | ||||
-rw-r--r-- | scripts/fill_func_tables.sh | 8 | ||||
-rw-r--r-- | scripts/make_binary_distribution.sh | 55 | ||||
-rwxr-xr-x | scripts/make_win_bin_dist | 352 | ||||
-rw-r--r-- | scripts/make_win_src_distribution.sh | 8 | ||||
-rw-r--r-- | scripts/mysql_config.sh | 2 | ||||
-rw-r--r-- | scripts/mysql_create_system_tables.sh | 133 | ||||
-rw-r--r-- | scripts/mysql_explain_log.sh | 24 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sh | 56 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sql | 360 | ||||
-rw-r--r-- | scripts/mysql_install_db.sh | 38 | ||||
-rw-r--r-- | scripts/mysql_tableinfo.sh | 32 | ||||
-rw-r--r-- | scripts/mysql_upgrade_shell.sh | 203 | ||||
-rw-r--r-- | scripts/mysqld_multi.sh | 73 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 41 | ||||
-rw-r--r-- | scripts/mysqlhotcopy.sh | 1 |
16 files changed, 1218 insertions, 176 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 30ba75c551d..dd4c133ff94 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -32,6 +32,7 @@ bin_SCRIPTS = @server_scripts@ \ mysqldumpslow \ mysql_explain_log \ mysql_tableinfo \ + mysql_upgrade_shell \ mysqld_multi \ mysql_create_system_tables @@ -59,12 +60,14 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \ mysql_explain_log.sh \ mysqld_multi.sh \ mysql_tableinfo.sh \ + mysql_upgrade_shell.sh \ mysqld_safe.sh \ mysql_create_system_tables.sh EXTRA_DIST = $(EXTRA_SCRIPTS) \ mysqlaccess.conf \ - mysqlbug + mysqlbug \ + make_win_bin_dist dist_pkgdata_DATA = fill_help_tables.sql mysql_fix_privilege_tables.sql @@ -87,11 +90,12 @@ CLEANFILES = @server_scripts@ \ mysqldumpslow \ mysql_explain_log \ mysql_tableinfo \ + mysql_upgrade_shell \ mysqld_multi \ make_win_src_distribution \ mysql_create_system_tables -DISTCLEANFILES = mysqlbug +DISTCLEANFILES = mysqlbug # We want the right version and configure comand line in mysqlbug mysqlbug: ${top_builddir}/config.status mysqlbug.sh diff --git a/scripts/fill_func_tables.sh b/scripts/fill_func_tables.sh index b7bd3736392..ad5b7fbb521 100644 --- a/scripts/fill_func_tables.sh +++ b/scripts/fill_func_tables.sh @@ -136,8 +136,8 @@ print "USE mysql_help;\n"; print "DROP TABLE IF EXISTS function;\n"; print "CREATE TABLE function ("; print " func_id int unsigned not null auto_increment,"; -print " name varchar(64) not null,"; -print " url varchar(128) not null,"; +print " name char(64) not null,"; +print " url char(128) not null,"; print " description text not null,"; print " example text not null,"; print " min_args tinyint not null,"; @@ -150,8 +150,8 @@ print ") type=myisam;\n\n"; print "DROP TABLE IF EXISTS function_category_name;\n"; print "CREATE TABLE function_category_name ("; print " cat_id smallint unsigned not null auto_increment,"; -print " name varchar(64) not null,"; -print " url varchar(128) not null,"; +print " name char(64) not null,"; +print " url char(128) not null,"; print " date_created datetime not null,"; print " last_modified timestamp not null,"; print " primary key (cat_id)"; diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 6359eb009ce..ec1c6b70bb6 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -40,6 +40,22 @@ for arg do esac done +# Remove vendor from $system +system=`echo $system | sed -e 's/[a-z]*-\(.*\)/\1/g'` + +# Map OS names to "our" OS names (eg. darwin6.8 -> osx10.2) +system=`echo $system | sed -e 's/darwin6.*/osx10.2/g'` +system=`echo $system | sed -e 's/darwin7.*/osx10.3/g'` +system=`echo $system | sed -e 's/darwin8.*/osx10.4/g'` +system=`echo $system | sed -e 's/\(aix4.3\).*/\1/g'` +system=`echo $system | sed -e 's/\(aix5.1\).*/\1/g'` +system=`echo $system | sed -e 's/\(aix5.2\).*/\1/g'` +system=`echo $system | sed -e 's/\(aix5.3\).*/\1/g'` +system=`echo $system | sed -e 's/osf5.1b/tru64/g'` +system=`echo $system | sed -e 's/linux-gnu/linux/g'` +system=`echo $system | sed -e 's/solaris2.\([0-9]*\)/solaris\1/g'` +system=`echo $system | sed -e 's/sco3.2v\(.*\)/openserver\1/g'` + if [ x"$MACHINE" != x"" ] ; then machine=$MACHINE fi @@ -111,14 +127,14 @@ copyfileto $BASE COPYING COPYING.LIB README Docs/INSTALL-BINARY \ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \ extra/resolveip$BS extra/my_print_defaults$BS \ extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \ - isam/isamchk$BS isam/pack_isam$BS \ myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \ myisam/myisam_ftdump$BS \ sql/mysqld$BS sql/mysql_tzinfo_to_sql$BS \ + server-tools/instance-manager/mysqlmanager$BS \ client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \ client/mysqldump$BS client/mysqlimport$BS \ client/mysqltest$BS client/mysqlcheck$BS \ - client/mysqlbinlog$BS \ + client/mysqlbinlog$BS client/mysql_upgrade$BS \ tests/mysql_client_test$BS \ libmysqld/examples/mysql_client_test_embedded$BS \ libmysqld/examples/mysqltest_embedded$BS \ @@ -129,18 +145,18 @@ if [ $BASE_SYSTEM = "netware" ] ; then BIN_FILES="$BIN_FILES \ netware/mysqld_safe$BS netware/mysql_install_db$BS \ netware/init_db.sql netware/test_db.sql netware/mysql_explain_log$BS \ - netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql + netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql \ "; +# For all other platforms: else - # For all other platforms: BIN_FILES="$BIN_FILES \ - client/mysqlmanagerc \ - client/mysqlmanager-pwgen tools/mysqlmanager \ + client/mysqltestmanagerc \ + client/mysqltestmanager-pwgen tools/mysqltestmanager \ client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \ client/.libs/mysqldump client/.libs/mysqlimport \ client/.libs/mysqltest client/.libs/mysqlcheck \ - client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \ - client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \ + client/.libs/mysqlbinlog client/.libs/mysqltestmanagerc \ + client/.libs/mysqltestmanager-pwgen tools/.libs/mysqltestmanager \ tests/.libs/mysql_client_test \ libmysqld/examples/.libs/mysql_client_test_embedded \ libmysqld/examples/.libs/mysqltest_embedded \ @@ -225,13 +241,17 @@ $CP mysql-test/lib/*.sql $BASE/mysql-test/lib $CP mysql-test/t/*.def $BASE/mysql-test/t $CP mysql-test/include/*.inc $BASE/mysql-test/include $CP mysql-test/include/*.test $BASE/mysql-test/include -$CP mysql-test/std_data/*.dat mysql-test/std_data/*.*001 \ - mysql-test/std_data/*.cnf \ +$CP mysql-test/t/*.def $BASE/mysql-test/t +$CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \ + mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \ + mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \ + mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \ $BASE/mysql-test/std_data -$CP mysql-test/std_data/des_key_file $BASE/mysql-test/std_data -$CP mysql-test/t/*test mysql-test/t/*.opt mysql-test/t/*.slave-mi \ - mysql-test/t/*.sh $BASE/mysql-test/t -$CP mysql-test/r/*result mysql-test/r/*.require $BASE/mysql-test/r +$CP mysql-test/t/*.test mysql-test/t/*.imtest \ + mysql-test/t/*.disabled mysql-test/t/*.opt \ + mysql-test/t/*.slave-mi mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t +$CP mysql-test/r/*.result mysql-test/r/*.require \ + $BASE/mysql-test/r if [ $BASE_SYSTEM != "netware" ] ; then chmod a+x $BASE/bin/* @@ -241,7 +261,8 @@ if [ $BASE_SYSTEM != "netware" ] ; then @HOSTNAME@ \@pkgdatadir\@ ./support-files \ < scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \ - \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data \ + \@sbindir\@ ./bin \@libexecdir\@ ./bin \ + \@MYSQLD_USER\@ @MYSQLD_USER@ \@localstatedir\@ /usr/local/mysql/data \ \@HOSTNAME\@ @HOSTNAME@ \ < support-files/mysql.server.sh > $BASE/support-files/mysql.server $BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe @@ -287,7 +308,9 @@ if [ $BASE_SYSTEM = "netware" ] ; then fi # Make safe_mysqld a symlink to mysqld_safe for backwards portability -(cd $BASE/bin ; ln -s mysqld_safe safe_mysqld ) +if [ $BASE_SYSTEM != "netware" ] ; then + (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld ) +fi # Clean up if we did this from a bk tree if [ -d $BASE/sql-bench/SCCS ] ; then diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist new file mode 100755 index 00000000000..38e7ab88f22 --- /dev/null +++ b/scripts/make_win_bin_dist @@ -0,0 +1,352 @@ +#!/bin/sh + +# Exit if failing to copy, we want exact specifications, not +# just "what happen to be built". +set -e + +# ---------------------------------------------------------------------- +# Read first argument that is the base name of the resulting TAR file. +# See usage() function below for a description on the arguments. +# +# NOTE: We will read the rest of the command line later on. +# NOTE: Pattern matching with "{..,..}" can't be used, not portable. +# ---------------------------------------------------------------------- + +# FIXME FIXME "debug", own build or handled here? +# FIXME FIXME add way to copy from other builds executables + +usage() +{ + echo <<EOF +Usage: make_win_bin_dist [ options ] package-base-name [ copy-defs... ] + +This is a script to run from the top of a source tree built on Windows. +The "package-base-name" argument should be something like + + mysql-noinstall-5.0.25-win32 (or winx64) + +and will be the name of the directory of the unpacked ZIP (stripping +away the "noinstall" part of the ZIP file name if any) and the base +for the resulting package name. + +Options are + + --embedded Pack the embedded server and give error if not built. + The default is to pack it if it is built. + + --no-embedded Don't pack the embedded server even if built + + --debug Pack the debug binaries and give error if not built. + + --no-debug Don't pack the debug binaries even if built + + --only-debug The target for this build was "Debug", and we just + want to replace the normal binaries with debug + versions, i.e. no separate "debug" directories. + + --exe-suffix=SUF Add a suffix to the "mysqld" binary. + +As you might want to include files of directories from other builds +(like a "mysqld-max.exe" server), you can instruct this script do copy +them in for you. This is the "copy-def" arguments, and they are of the +form + + relative-dest-name=source-name ..... + +i.e. can be something like + + bin/mysqld-max.exe=../my-max-build/sql/release/mysqld.exe + +If you specify a directory the whole directory will be copied. + +EOF + exit 1 +} + +# ---------------------------------------------------------------------- +# We need to be at the top of a source tree, check that we are +# ---------------------------------------------------------------------- + +if [ ! -d "sql" ] ; then + echo "You need to run this script from inside the source tree" + usage +fi + +# ---------------------------------------------------------------------- +# Actual argument processing, first part +# ---------------------------------------------------------------------- + +NOINST_NAME="" +TARGET="release" +PACK_EMBEDDED="" # Could be "no", "yes" or empty +PACK_DEBUG="" # Could be "no", "yes" or empty +EXE_SUFFIX="" + +for arg do + shift + case "$arg" in + --embedded) PACK_EMBEDDED="yes" ;; + --no-embedded) PACK_EMBEDDED="no" ;; + --debug) PACK_DEBUG="yes" ;; + --no-debug) PACK_DEBUG="no" ;; + --only-debug) TARGET="debug" ; PACK_DEBUG="no" ;; + --exe-suffix=*) EXE_SUFFIX=`echo "$arg" | sed -e "s,--exe-suffix=,,"` ;; + -*) + echo "Unknown argument '$arg'" + usage + ;; + *) + NOINST_NAME="$arg" + break + esac +done + +if [ x"$NOINST_NAME" = x"" ] ; then + echo "No base package name given" + usage +fi +DESTDIR=`echo $NOINST_NAME | sed 's/-noinstall-/-/'` + +if [ -e $DESTDIR ] ; then + echo "Please remove the old $DESTDIR before running this script" + usage +fi + +# ---------------------------------------------------------------------- +# Copy executables, and client DLL (FIXME why?) +# ---------------------------------------------------------------------- + +trap 'echo "Clearning up and exiting..." ; rm -fr $DESTDIR; exit 1' ERR + +mkdir $DESTDIR +mkdir $DESTDIR/bin +cp client/$TARGET/*.exe $DESTDIR/bin/ +cp extra/$TARGET/*.exe $DESTDIR/bin/ +cp myisam/$TARGET/*.exe $DESTDIR/bin/ +cp server-tools/instance-manager/$TARGET/*.exe $DESTDIR/bin/ +cp tests/$TARGET/*.exe $DESTDIR/bin/ +cp libmysql/$TARGET/*.exe $DESTDIR/bin/ +cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/ + +# FIXME really needed?! +mv $DESTDIR/bin/comp_err.exe $DESTDIR/bin/comp-err.exe + +cp sql/$TARGET/mysqld.exe $DESTDIR/bin/mysqld$EXE_SUFFIX.exe + +if [ x"$PACK_DEBUG" = "" -a -f "sql/debug/mysqld.exe" -o \ + x"$PACK_DEBUG" = "yes" ] ; then + cp sql/debug/mysqld.exe $DESTDIR/bin/mysqld-debug.exe + cp sql/debug/mysqld.pdb $DESTDIR/bin/mysqld-debug.pdb + cp sql/debug/mysqld.map $DESTDIR/bin/mysqld-debug.map +fi + +# ---------------------------------------------------------------------- +# Copy data directory, readme files etc +# ---------------------------------------------------------------------- + +# FIXME is there ever a data directory to copy? +if [ -d win/data ] ; then + cp -pR win/data $DESTDIR/data +fi + +# FIXME maybe a flag to define "release build", or do the +# check from the calling script that all these are there, +# and with the correct content. + +mkdir $DESTDIR/Docs +cp Docs/INSTALL-BINARY $DESTDIR/Docs/ +cp Docs/manual.chm $DESTDIR/Docs/ || /bin/true +cp ChangeLog $DESTDIR/Docs/ || /bin/true +cp support-files/my-*.ini $DESTDIR/ + +if [ -f COPYING ] ; then + cp COPYING EXCEPTIONS-CLIENT $DESTDIR/ + cp COPYING $DESTDIR/Docs/ +fi + +# ---------------------------------------------------------------------- +# These will be filled in when we enable embedded. Note that if no +# argument is given, it is copied if exists, else a check is done. +# ---------------------------------------------------------------------- + +copy_embedded() +{ + mkdir -p $DESTDIR/Embedded/DLL/release \ + $DESTDIR/Embedded/static/release \ + $DESTDIR/include + cp libmysqld/libmysqld.def $DESTDIR/include/ + cp libmysqld/$TARGET/mysqlserver.lib $DESTDIR/Embedded/static/release/ + cp libmysqld/$TARGET/libmysqld.dll $DESTDIR/Embedded/DLL/release/ + cp libmysqld/$TARGET/libmysqld.exp $DESTDIR/Embedded/DLL/release/ + cp libmysqld/$TARGET/libmysqld.lib $DESTDIR/Embedded/DLL/release/ + + if [ x"$PACK_DEBUG" = "" -a -f "libmysqld/debug/libmysqld.lib" -o \ + x"$PACK_DEBUG" = "yes" ] ; then + mkdir -p $DESTDIR/Embedded/DLL/debug + cp libmysqld/debug/libmysqld.dll $DESTDIR/Embedded/DLL/debug/ + cp libmysqld/debug/libmysqld.exp $DESTDIR/Embedded/DLL/debug/ + cp libmysqld/debug/libmysqld.lib $DESTDIR/Embedded/DLL/debug/ + fi +} + +if [ x"$PACK_EMBEDDED" = "" -a \ + -f "libmysqld/$TARGET/mysqlserver.lib" -a \ + -f "libmysqld/$TARGET/libmysqld.lib" -o \ + x"$PACK_EMBEDDED" = "yes" ] ; then + copy_embedded +fi + +# ---------------------------------------------------------------------- +# FIXME test stuff that is useless garbage? +# ---------------------------------------------------------------------- + +mkdir -p $DESTDIR/examples/libmysqltest/release +cp libmysql/mytest.c libmysql/myTest.vcproj libmysql/$TARGET/myTest.exe \ + $DESTDIR/examples/libmysqltest/ +cp libmysql/$TARGET/myTest.exe $DESTDIR/examples/libmysqltest/release/ + +if [ x"$PACK_DEBUG" = "" -a -f "libmysql/debug/myTest.exe" -o \ + x"$PACK_DEBUG" = "yes" ] ; then + mkdir -p $DESTDIR/examples/libmysqltest/debug + cp libmysql/debug/myTest.exe $DESTDIR/examples/libmysqltest/debug/ +fi + +mkdir -p $DESTDIR/examples/tests +cp tests/*.res tests/*.tst tests/*.pl tests/*.c $DESTDIR/examples/tests/ + +mkdir -p $DESTDIR/examples/udf_example +cp sql/udf_example.def sql/udf_example.vcproj sql/udf_example.c $DESTDIR/examples/udf_example/ + +# ---------------------------------------------------------------------- +# FIXME why not copy it all in "include"?! +# ---------------------------------------------------------------------- + +mkdir -p $DESTDIR/include +cp include/conf*.h \ + include/mysql*.h \ + include/errmsg.h \ + include/my_alloc.h \ + include/my_getopt.h \ + include/my_sys.h \ + include/my_list.h \ + include/my_pthread.h \ + include/my_dbug.h \ + include/m_string.h \ + include/m_ctype.h \ + include/my_global.h \ + include/raid.h \ + include/typelib.h $DESTDIR/include/ +cp libmysql/libmysql.def $DESTDIR/include/ + +# ---------------------------------------------------------------------- +# Client libraries, and other libraries +# FIXME why "libmysql.dll" installed both in "bin" and "lib/opt"? +# ---------------------------------------------------------------------- + +mkdir -p $DESTDIR/lib/opt +cp libmysql/$TARGET/libmysql.dll \ + libmysql/$TARGET/libmysql.lib \ + client/$TARGET/mysqlclient.lib \ + regex/$TARGET/regex.lib \ + strings/$TARGET/strings.lib \ + zlib/$TARGET/zlib.lib $DESTDIR/lib/opt/ + +if [ x"$PACK_DEBUG" = "" -a -f "libmysql/debug/libmysql.lib" -o \ + x"$PACK_DEBUG" = "yes" ] ; then + mkdir -p $DESTDIR/lib/debug + cp libmysql/debug/libmysql.dll \ + libmysql/debug/libmysql.lib \ + client/debug/mysqlclient.lib \ + mysys/debug/mysys.lib \ + regex/debug/regex.lib \ + strings/debug/strings.lib \ + zlib/debug/zlib.lib $DESTDIR/lib/debug/ +fi + +# FIXME sort this out... +cp mysys/$TARGET/mysys.lib $DESTDIR/lib/opt/mysys_tls.lib + +# ---------------------------------------------------------------------- +# Copy the test directory +# ---------------------------------------------------------------------- + +mkdir -p $DESTDIR/mysql-test/include $DESTDIR/mysql-test/lib \ + $DESTDIR/mysql-test/r $DESTDIR/mysql-test/std_data \ + $DESTDIR/mysql-test/t +cp mysql-test/mysql-test-run.pl $DESTDIR/mysql-test/ +cp mysql-test/README $DESTDIR/mysql-test/ +cp mysql-test/install_test_db.sh $DESTDIR/mysql-test/install_test_db +cp mysql-test/include/*.inc $DESTDIR/mysql-test/include/ +cp mysql-test/lib/*.pl $DESTDIR/mysql-test/lib/ +cp mysql-test/lib/*.sql $DESTDIR/mysql-test/lib/ +cp mysql-test/r/*.require $DESTDIR/mysql-test/r/ +# Need this trick, or we get "argument list too long". +ABS_DST=`pwd`/$DESTDIR +(cd mysql-test/r/ && cp *.result $ABS_DST/mysql-test/r/) +cp mysql-test/std_data/* $DESTDIR/mysql-test/std_data/ +cp mysql-test/t/*.opt $DESTDIR/mysql-test/t/ +cp mysql-test/t/*.sh $DESTDIR/mysql-test/t/ +cp mysql-test/t/*.slave-mi $DESTDIR/mysql-test/t/ +cp mysql-test/t/*.sql $DESTDIR/mysql-test/t/ +cp mysql-test/t/*.def $DESTDIR/mysql-test/t/ +(cd mysql-test/t/ && cp *.test $ABS_DST/mysql-test/t/) + +# Note that this will not copy "extra" if a soft link +if [ -d mysql-test/extra ] ; then + mkdir -p $DESTDIR/mysql-test/extra + cp -pR mysql-test/extra/* $DESTDIR/mysql-test/extra/ +fi + +# ---------------------------------------------------------------------- +# Copy what could be usable in the "scripts" directory. Currently +# only SQL files, others are bourne shell scripts or Perl scripts +# not really usable on Windows. +# +# But to be nice to the few Cygwin users we might have in 5.0 we +# continue to copy the stuff, but don't include it include it in +# the WiX install. +# ---------------------------------------------------------------------- + +mkdir -p $DESTDIR/scripts + +# Uncomment and remove the for loop in 5.1 +#cp scripts/*.sql $DESTDIR/scripts/ + +for i in `cd scripts && ls`; do \ + if echo $i | grep -q '\.sh'; then \ + cp scripts/$i $DESTDIR/scripts/`echo $i | sed -e 's/\.sh$//'`; \ + elif [ $i = Makefile.am -o $i = Makefile.in -o -e scripts/$i.sh ] ; then \ + : ; \ + else \ + cp scripts/$i $DESTDIR/scripts/$i; \ + fi; \ +done + +cp -pR sql/share $DESTDIR/ +cp -pR sql-bench $DESTDIR/ +rm -f $DESTDIR/sql-bench/*.sh $DESTDIR/sql-bench/Makefile* + +# ---------------------------------------------------------------------- +# Copy other files specified on command line DEST=SOURCE +# ---------------------------------------------------------------------- + +for arg do + dst=`echo $arg | sed 's/=.*$//'` + src=`echo $arg | sed 's/^.*=//'` + + if [ x"$dst" = x"" -o x"$src" = x"" ] ; then + echo "Invalid specification of what to copy" + usage + fi + + mkdir -p `dirname $DESTDIR/$dst` + cp -pR "$src" $DESTDIR/$dst +done + +# ---------------------------------------------------------------------- +# Finally creat the ZIP archive +# ---------------------------------------------------------------------- + +rm -f $NOINST_NAME.zip +zip -r $NOINST_NAME.zip $DESTDIR +rm -Rf $DESTDIR diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 742f6b9e994..6206ca64121 100644 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -203,7 +203,7 @@ copy_dir_files() print_debug "Creating directory '$arg'" mkdir $BASE/$arg fi - for i in *.c *.cpp *.h *.ih *.i *.ic *.asm *.def *.hpp *.yy \ + for i in *.c *.cpp *.h *.ih *.i *.ic *.asm *.def *.hpp *.yy *dsp *.dsw \ README INSTALL* LICENSE AUTHORS NEWS ChangeLog \ *.inc *.test *.result *.pem Moscow_leap des_key_file \ *.vcproj *.sln *.dat *.000001 *.require *.opt *.cnf @@ -253,8 +253,8 @@ copy_dir_dirs() { # Input directories to be copied # -for i in client dbug extra heap include isam \ - libmysql libmysqld merge myisam \ +for i in client dbug extra heap include \ + libmysql libmysqld myisam \ myisammrg mysys regex sql strings sql-common sql/examples \ tools vio zlib do @@ -270,7 +270,7 @@ make -C $SOURCE/ndb windoze || true # Input directories to be copied recursively # -for i in bdb innobase ndb +for i in bdb innobase ndb extra/yassl server-tools do copy_dir_dirs $i done diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 1fcad16affb..92201a2c8af 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -101,7 +101,7 @@ ldflags='@LDFLAGS@' libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@" libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ " libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@ " -embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ " +embedded_libs=" $ldflags -L$pkglibdir -lmysqld @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @innodb_system_libs@ @openssl_libs@ " cflags="-I$pkgincludedir @CFLAGS@ " #note: end space! include="-I$pkgincludedir" diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index 4c642423879..54f0ef230ad 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -41,6 +41,7 @@ c_hk="" i_ht="" c_tzn="" c_tz="" c_tzt="" c_tztt="" c_tzls="" i_tzn="" i_tz="" i_tzt="" i_tztt="" i_tzls="" +c_p="" c_pp="" # Check for old tables if test ! -f $mdata/db.frm @@ -66,14 +67,19 @@ then c_d="$c_d Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_d="$c_d Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_d="$c_d Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_d="$c_d Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_d="$c_d Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_d="$c_d Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_d="$c_d Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_d="$c_d Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_d="$c_d PRIMARY KEY Host (Host,Db,User)," c_d="$c_d KEY User (User)" c_d="$c_d ) engine=MyISAM" c_d="$c_d CHARACTER SET utf8 COLLATE utf8_bin" c_d="$c_d comment='Database privileges';" - i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); - INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');" + i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N'); + INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');" fi if test ! -f $mdata/host.frm @@ -97,6 +103,11 @@ then c_h="$c_h Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_h="$c_h Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_h="$c_h Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_h="$c_h Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_h="$c_h Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_h="$c_h Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_h="$c_h Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_h="$c_h Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_h="$c_h PRIMARY KEY Host (Host,Db)" c_h="$c_h ) engine=MyISAM" c_h="$c_h CHARACTER SET utf8 COLLATE utf8_bin" @@ -112,7 +123,7 @@ then c_u="$c_u CREATE TABLE user (" c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL," c_u="$c_u User char(16) binary DEFAULT '' NOT NULL," - c_u="$c_u Password char(41) binary DEFAULT '' NOT NULL," + c_u="$c_u Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL," c_u="$c_u Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_u="$c_u Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_u="$c_u Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," @@ -134,6 +145,11 @@ then c_u="$c_u Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_u="$c_u Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_u="$c_u Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_u="$c_u Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_u="$c_u Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_u="$c_u Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_u="$c_u Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_u="$c_u Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL," c_u="$c_u ssl_cipher BLOB NOT NULL," c_u="$c_u x509_issuer BLOB NOT NULL," @@ -141,6 +157,7 @@ then c_u="$c_u max_questions int(11) unsigned DEFAULT 0 NOT NULL," c_u="$c_u max_updates int(11) unsigned DEFAULT 0 NOT NULL," c_u="$c_u max_connections int(11) unsigned DEFAULT 0 NOT NULL," + c_u="$c_u max_user_connections int(11) unsigned DEFAULT 0 NOT NULL," c_u="$c_u PRIMARY KEY Host (Host,User)" c_u="$c_u ) engine=MyISAM" c_u="$c_u CHARACTER SET utf8 COLLATE utf8_bin" @@ -148,22 +165,22 @@ then if test "$1" = "test" then - i_u="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','','','','',0,0,0); - INSERT 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','','','','',0,0,0); - 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','','','','',0,0,0); + i_u="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); + INSERT 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); + 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); INSERT INTO user (host,user) values ('localhost',''); INSERT INTO user (host,user) values ('$hostname','');" else - i_u="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','','','','',0,0,0);" + i_u="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);" if test "$windows" = "0" then i_u="$i_u - INSERT 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','','','','',0,0,0); + INSERT 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); INSERT INTO user (host,user) values ('$hostname',''); INSERT INTO user (host,user) values ('localhost','');" else i_u="$i_u - INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);" + INSERT INTO user VALUES ('localhost','','','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);" fi fi fi @@ -198,7 +215,7 @@ then 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') COLLATE utf8_general_ci DEFAULT '' NOT NULL," + c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL," c_t="$c_t Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL," c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name)," c_t="$c_t KEY Grantor (Grantor)" @@ -227,6 +244,28 @@ then c_c="$c_c comment='Column privileges';" fi +if test ! -f $mdata/procs_priv.frm +then + if test "$1" = "verbose" ; then + echo "Preparing procs_priv table" 1>&2; + fi + + c_pp="$c_pp CREATE TABLE procs_priv (" + c_pp="$c_pp Host char(60) binary DEFAULT '' NOT NULL," + c_pp="$c_pp Db char(64) binary DEFAULT '' NOT NULL," + c_pp="$c_pp User char(16) binary DEFAULT '' NOT NULL," + c_pp="$c_pp Routine_name char(64) binary DEFAULT '' NOT NULL," + c_pp="$c_pp Routine_type enum('FUNCTION','PROCEDURE') NOT NULL," + c_pp="$c_pp Grantor char(77) DEFAULT '' NOT NULL," + c_pp="$c_pp Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL," + c_pp="$c_pp Timestamp timestamp(14)," + c_pp="$c_pp PRIMARY KEY (Host,Db,User,Routine_name,Routine_type)," + c_pp="$c_pp KEY Grantor (Grantor)" + c_pp="$c_pp ) engine=MyISAM" + c_pp="$c_pp CHARACTER SET utf8 COLLATE utf8_bin" + c_pp="$c_pp comment='Procedure privileges';" +fi + if test ! -f $mdata/help_topic.frm then if test "$1" = "verbose" ; then @@ -235,11 +274,11 @@ then c_ht="$c_ht CREATE TABLE help_topic (" c_ht="$c_ht help_topic_id int unsigned not null," - c_ht="$c_ht name varchar(64) not null," + c_ht="$c_ht name char(64) not null," c_ht="$c_ht help_category_id smallint unsigned not null," c_ht="$c_ht description text not null," c_ht="$c_ht example text not null," - c_ht="$c_ht url varchar(128) not null," + c_ht="$c_ht url char(128) not null," c_ht="$c_ht primary key (help_topic_id)," c_ht="$c_ht unique index (name)" c_ht="$c_ht ) engine=MyISAM" @@ -257,9 +296,9 @@ then c_hc="$c_hc CREATE TABLE help_category (" c_hc="$c_hc help_category_id smallint unsigned not null," - c_hc="$c_hc name varchar(64) not null," + c_hc="$c_hc name char(64) not null," c_hc="$c_hc parent_category_id smallint unsigned null," - c_hc="$c_hc url varchar(128) not null," + c_hc="$c_hc url char(128) not null," c_hc="$c_hc primary key (help_category_id)," c_hc="$c_hc unique index (name)" c_hc="$c_hc ) engine=MyISAM" @@ -275,7 +314,7 @@ then c_hk="$c_hk CREATE TABLE help_keyword (" c_hk="$c_hk help_keyword_id int unsigned not null," - c_hk="$c_hk name varchar(64) not null," + c_hk="$c_hk name char(64) not null," c_hk="$c_hk primary key (help_keyword_id)," c_hk="$c_hk unique index (name)" c_hk="$c_hk ) engine=MyISAM" @@ -627,6 +666,66 @@ then fi fi +if test ! -f $mdata/proc.frm +then + c_p="$c_p CREATE TABLE proc (" + c_p="$c_p db char(64) collate utf8_bin DEFAULT '' NOT NULL," + c_p="$c_p name char(64) DEFAULT '' NOT NULL," + c_p="$c_p type enum('FUNCTION','PROCEDURE') NOT NULL," + c_p="$c_p specific_name char(64) DEFAULT '' NOT NULL," + c_p="$c_p language enum('SQL') DEFAULT 'SQL' NOT NULL," + c_p="$c_p sql_data_access enum('CONTAINS_SQL'," + c_p="$c_p 'NO_SQL'," + c_p="$c_p 'READS_SQL_DATA'," + c_p="$c_p 'MODIFIES_SQL_DATA'" + c_p="$c_p ) DEFAULT 'CONTAINS_SQL' NOT NULL," + c_p="$c_p is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL," + c_p="$c_p security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL," + c_p="$c_p param_list blob DEFAULT '' NOT NULL," + c_p="$c_p returns char(64) DEFAULT '' NOT NULL," + c_p="$c_p body longblob DEFAULT '' NOT NULL," + c_p="$c_p definer char(77) collate utf8_bin DEFAULT '' NOT NULL," + c_p="$c_p created timestamp," + c_p="$c_p modified timestamp," + c_p="$c_p sql_mode set(" + c_p="$c_p 'REAL_AS_FLOAT'," + c_p="$c_p 'PIPES_AS_CONCAT'," + c_p="$c_p 'ANSI_QUOTES'," + c_p="$c_p 'IGNORE_SPACE'," + c_p="$c_p 'NOT_USED'," + c_p="$c_p 'ONLY_FULL_GROUP_BY'," + c_p="$c_p 'NO_UNSIGNED_SUBTRACTION'," + c_p="$c_p 'NO_DIR_IN_CREATE'," + c_p="$c_p 'POSTGRESQL'," + c_p="$c_p 'ORACLE'," + c_p="$c_p 'MSSQL'," + c_p="$c_p 'DB2'," + c_p="$c_p 'MAXDB'," + c_p="$c_p 'NO_KEY_OPTIONS'," + c_p="$c_p 'NO_TABLE_OPTIONS'," + c_p="$c_p 'NO_FIELD_OPTIONS'," + c_p="$c_p 'MYSQL323'," + c_p="$c_p 'MYSQL40'," + c_p="$c_p 'ANSI'," + c_p="$c_p 'NO_AUTO_VALUE_ON_ZERO'," + c_p="$c_p 'NO_BACKSLASH_ESCAPES'," + c_p="$c_p 'STRICT_TRANS_TABLES'," + c_p="$c_p 'STRICT_ALL_TABLES'," + c_p="$c_p 'NO_ZERO_IN_DATE'," + c_p="$c_p 'NO_ZERO_DATE'," + c_p="$c_p 'INVALID_DATES'," + c_p="$c_p 'ERROR_FOR_DIVISION_BY_ZERO'," + c_p="$c_p 'TRADITIONAL'," + c_p="$c_p 'NO_AUTO_CREATE_USER'," + c_p="$c_p 'HIGH_NOT_PRECEDENCE'" + c_p="$c_p ) DEFAULT '' NOT NULL," + c_p="$c_p comment char(64) collate utf8_bin DEFAULT '' NOT NULL," + c_p="$c_p PRIMARY KEY (db,name,type)" + c_p="$c_p ) engine=MyISAM" + c_p="$c_p character set utf8" + c_p="$c_p comment='Stored Procedures';" +fi + cat << END_OF_DATA use mysql; set table_type=myisam; @@ -660,5 +759,9 @@ $c_tztt $i_tztt $c_tzls $i_tzls + +$c_p +$c_pp + END_OF_DATA diff --git a/scripts/mysql_explain_log.sh b/scripts/mysql_explain_log.sh index 973d9e8a363..fd468fdf091 100644 --- a/scripts/mysql_explain_log.sh +++ b/scripts/mysql_explain_log.sh @@ -1,5 +1,6 @@ -#!@PERL@ -w +#!@PERL@ use strict; +use warnings; use DBI; use Getopt::Long; @@ -58,7 +59,7 @@ else { } else { $Param->{Start} = time; - while(<STDIN>) { + while(<>) { $Param->{LineCount} ++ ; if ($Param->{ViewDate} ) { @@ -317,6 +318,8 @@ Usage: $0 [OPTIONS] < LOGFILE -p=PASSWORD --socket=SOCKET mysqld socket file to connect -s=SOCKET +--printerror=1 enable error output +-e 1 Read logfile from STDIN an try to EXPLAIN all SELECT statements. All UPDATE statements are rewritten to an EXPLAIN SELECT statement. The results of the EXPLAIN statement are collected and counted. All results with type=ALL are collected in an separete list. Results are printed to STDOUT. @@ -331,7 +334,7 @@ __END__ =head1 NAME -explain_log.pl +mysql_explain_log Feed a mysqld general logfile (created with mysqld --log) back into mysql and collect statistics about index usage with EXPLAIN. @@ -348,7 +351,7 @@ Then add indices to avoid table scans and remove those which aren't used. =head1 USAGE -explain_log.pl [--date=YYMMDD] --host=dbhost] [--user=dbuser] [--password=dbpw] [--socket=/path/to/socket] < logfile +mysql_explain_log [--date=YYMMDD] --host=dbhost] [--user=dbuser] [--password=dbpw] [--socket=/path/to/socket] < logfile --date=YYMMDD select only entrys of date @@ -370,21 +373,20 @@ explain_log.pl [--date=YYMMDD] --host=dbhost] [--user=dbuser] [--password=dbpw] -s=SOCKET +--printerror=1 enable error output + +-e 1 + =head1 EXAMPLE -explain_log.pl --host=localhost --user=foo --password=bar < /var/lib/mysql/mobile.log +mysql_explain_log --host=localhost --user=foo --password=bar < /var/lib/mysql/mobile.log =head1 AUTHORS Stefan Nitz - Jan Willamowius <jan@mobile.de>, http://www.mobile.de + Jan Willamowius <jan@willamowius.de>, http://www.willamowius.de Dennis Haney <davh@davh.dk> (Added socket support) -=head1 RECRUITING - -If you are looking for a MySQL or Perl job, take a look at http://www.mobile.de -and send me an email with your resume (you must be speaking German!). - =head1 SEE ALSO mysql documentation diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 361affae247..910992191f3 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -7,13 +7,14 @@ password="" host="localhost" user="root" sql_only=0 -basedir="" +basedir="@prefix@" verbose=0 args="" port="" socket="" database="mysql" bindir="" +pkgdatadir="@pkgdatadir@" print_defaults_bindir="." file=mysql_fix_privilege_tables.sql @@ -89,34 +90,32 @@ done parse_arguments `$print_defaults $defaults mysql_install_db mysql_fix_privilege_tables` parse_arguments PICK-ARGS-FROM-ARGV "$@" -if test -z "$basedir" +if test -z "$password" then - basedir=@prefix@ - if test -z "$bindir" - then - bindir=@bindir@ - fi - execdir=@libexecdir@ - pkgdatadir=@pkgdatadir@ -else - if test -z "$bindir" - then - bindir="$basedir/bin" - fi - if test -x "$basedir/libexec/mysqld" - then - execdir="$basedir/libexec" - elif test -x "@libexecdir@/mysqld" - then - execdir="@libexecdir@" - else - execdir="$basedir/bin" - fi + password=$old_style_password fi -if test -z "$password" +# Find where 'mysql' command is located + +dirname=`dirname "$0"` + +if test -z "$bindir" then - password=$old_style_password + 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 --force --user=$user --host=$host" @@ -135,7 +134,7 @@ 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@ . ./scripts + $basedir/scripts $pkgdatadir . "$dirname" do if test -f $i/$file then @@ -164,7 +163,8 @@ s_echo "This script updates all the mysql privilege tables to be usable by" s_echo "MySQL 4.0 and above." s_echo "" s_echo "This is needed if you want to use the new GRANT functions," -s_echo "CREATE AGGREGATE FUNCTION, or the more secure passwords in 4.1" +s_echo "CREATE AGGREGATE FUNCTION, stored procedures, or" +s_echo "more secure passwords in 4.1" s_echo "" if test $verbose = 1 @@ -197,7 +197,7 @@ then s_echo "done" else s_echo "Got a failure from command:" - s_echo "$cmd" + s_echo "cat $sql_file | $cmd" s_echo "Please check the above output and try again." if test $verbose = 0 then diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index a72bd2799aa..5709fb96793 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -1,5 +1,5 @@ -- This script converts any old privilege tables to privilege tables suitable --- for MySQL 4.0. +-- for MySQL 4.1 -- You can safely ignore all 'Duplicate column' and 'Unknown column' errors" -- because these just mean that your tables are already up to date. @@ -9,7 +9,7 @@ -- this sql script. -- On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' -set table_type=MyISAM; +set storage_engine=MyISAM; CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, @@ -46,9 +46,8 @@ ADD x509_subject BLOB NOT NULL; ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL; -- --- Create tables_priv and columns_priv if they don't exists +-- tables_priv -- - CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, @@ -56,35 +55,67 @@ CREATE TABLE IF NOT EXISTS tables_priv ( Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), - Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, + Table_priv set('Select','Insert','Update','Delete','Create', + 'Drop','Grant','References','Index','Alter') + COLLATE utf8_general_ci DEFAULT '' NOT NULL, + Column_priv set('Select','Insert','Update','References') + COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name) ) CHARACTER SET utf8 COLLATE utf8_bin; --- Fix collation of set fields + +ALTER TABLE tables_priv + ADD KEY Grantor (Grantor); + +ALTER TABLE tables_priv + MODIFY Host char(60) NOT NULL default '', + MODIFY Db char(64) NOT NULL default '', + MODIFY User char(16) NOT NULL default '', + MODIFY Table_name char(64) NOT NULL default '', + MODIFY Grantor char(77) NOT NULL default '', + ENGINE=MyISAM, + CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; + ALTER TABLE tables_priv - modify Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - modify Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; + MODIFY Column_priv set('Select','Insert','Update','References') + COLLATE utf8_general_ci DEFAULT '' NOT NULL, + 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, + COMMENT='Table privileges'; +-- +-- columns_priv +-- CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) DEFAULT '' NOT NULL, - Db char(60) DEFAULT '' NOT NULL, + Db char(64) DEFAULT '' NOT NULL, User char(16) DEFAULT '' NOT NULL, - Table_name char(60) DEFAULT '' NOT NULL, - Column_name char(59) DEFAULT '' NOT NULL, + Table_name char(64) DEFAULT '' NOT NULL, + Column_name char(64) DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) CHARACTER SET utf8 COLLATE utf8_bin; --- Fix collation of set fields -ALTER TABLE columns_priv - MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; - --- -- Name change of Type -> Column_priv from MySQL 3.22.12 --- +ALTER TABLE columns_priv + CHANGE Type Column_priv set('Select','Insert','Update','References') + COLLATE utf8_general_ci DEFAULT '' NOT NULL; -ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; +ALTER TABLE columns_priv + MODIFY Host char(60) NOT NULL default '', + MODIFY Db char(64) NOT NULL default '', + MODIFY User char(16) NOT NULL default '', + MODIFY Table_name char(64) NOT NULL default '', + MODIFY Column_name char(64) NOT NULL default '', + ENGINE=MyISAM, + CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin, + COMMENT='Column privileges'; + +ALTER TABLE columns_priv + MODIFY Column_priv set('Select','Insert','Update','References') + COLLATE utf8_general_ci DEFAULT '' NOT NULL; -- -- Add the new 'type' column to the func table. @@ -93,7 +124,7 @@ ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update', ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL; -- --- Change the user,db and host tables to MySQL 4.0 format +-- Change the user,db and host tables to current format -- # Detect whether we had Show_db_priv @@ -118,9 +149,9 @@ UPDATE user SET Show_db_priv= Select_priv, Super_priv=Process_priv, Execute_priv -- for some users. ALTER TABLE user -ADD max_questions int(11) NOT NULL AFTER x509_subject, -ADD max_updates int(11) unsigned NOT NULL AFTER max_questions, -ADD max_connections int(11) unsigned NOT NULL AFTER max_updates; +ADD max_questions int(11) NOT NULL DEFAULT 0 AFTER x509_subject, +ADD max_updates int(11) unsigned NOT NULL DEFAULT 0 AFTER max_questions, +ADD max_connections int(11) unsigned NOT NULL DEFAULT 0 AFTER max_updates; -- @@ -134,28 +165,22 @@ ALTER TABLE host ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci 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 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'; -- Convert all tables to UTF-8 with binary collation -- and reset all char columns to correct width ALTER TABLE user MODIFY Host char(60) NOT NULL default '', MODIFY User char(16) NOT NULL default '', - MODIFY Password char(41) NOT NULL default '', ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; ALTER TABLE user + MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default '', MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, @@ -178,6 +203,7 @@ ALTER TABLE user MODIFY Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL; + ALTER TABLE db MODIFY Host char(60) NOT NULL default '', MODIFY Db char(64) NOT NULL default '', @@ -196,6 +222,7 @@ ALTER TABLE db MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; + ALTER TABLE host MODIFY Host char(60) NOT NULL default '', MODIFY Db char(64) NOT NULL default '', @@ -213,33 +240,143 @@ ALTER TABLE host MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; + ALTER TABLE func ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; ALTER TABLE func MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL; -ALTER TABLE columns_priv - MODIFY Host char(60) NOT NULL default '', - MODIFY Db char(64) NOT NULL default '', - MODIFY User char(16) NOT NULL default '', - MODIFY Table_name char(64) NOT NULL default '', - MODIFY Column_name char(64) NOT NULL default '', - ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; -ALTER TABLE columns_priv - MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; -ALTER TABLE tables_priv - MODIFY Host char(60) NOT NULL default '', - MODIFY Db char(64) NOT NULL default '', - MODIFY User char(16) NOT NULL default '', - MODIFY Table_name char(64) NOT NULL default '', - MODIFY Grantor char(77) NOT NULL default '', - ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; -ALTER TABLE tables_priv - MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; # -# Create some possible missing tables +# Detect whether we had Create_view_priv +# +SET @hadCreateViewPriv:=0; +SELECT @hadCreateViewPriv:=1 FROM user WHERE Create_view_priv LIKE '%'; + +# +# Create VIEWs privileges (v5.0) +# +ALTER TABLE db ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv; +ALTER TABLE db MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv; + +ALTER TABLE host ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv; +ALTER TABLE host MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv; + +ALTER TABLE user ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv; +ALTER TABLE user MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv; + # +# Show VIEWs privileges (v5.0) +# +ALTER TABLE db ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; +ALTER TABLE db MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; + +ALTER TABLE host ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; +ALTER TABLE host MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; + +ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; +ALTER TABLE user MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; + +# +# Assign create/show view privileges to people who have create provileges +# +UPDATE user SET Create_view_priv=Create_priv, Show_view_priv=Create_priv where user<>"" AND @hadCreateViewPriv = 0; + +# +# +# +SET @hadCreateRoutinePriv:=0; +SELECT @hadCreateRoutinePriv:=1 FROM user WHERE Create_routine_priv LIKE '%'; + +# +# Create PROCEDUREs privileges (v5.0) +# +ALTER TABLE db ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; +ALTER TABLE db MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; + +ALTER TABLE host ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; +ALTER TABLE host MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; + +ALTER TABLE user ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; +ALTER TABLE user MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; + +# +# Alter PROCEDUREs privileges (v5.0) +# +ALTER TABLE db ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; +ALTER TABLE db MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; + +ALTER TABLE host ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; +ALTER TABLE host MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; + +ALTER TABLE user ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; +ALTER TABLE user MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; + +ALTER TABLE db ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; +ALTER TABLE db MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; + +ALTER TABLE host ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; +ALTER TABLE host MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; + +# +# Assign create/alter routine privileges to people who have create privileges +# +UPDATE user SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv where user<>"" AND @hadCreateRoutinePriv = 0; +UPDATE db SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where user<>"" AND @hadCreateRoutinePriv = 0; +UPDATE host SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, Execute_priv=Select_priv where @hadCreateRoutinePriv = 0; + +# +# Add max_user_connections resource limit +# +ALTER TABLE user ADD max_user_connections int(11) unsigned DEFAULT '0' NOT NULL AFTER max_connections; + +# +# user.Create_user_priv +# + +SET @hadCreateUserPriv:=0; +SELECT @hadCreateUserPriv:=1 FROM user WHERE Create_user_priv LIKE '%'; + +ALTER TABLE user ADD Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; +ALTER TABLE user MODIFY Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; +UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y' + WHERE @hadCreateUserPriv = 0 AND + (user.Grant_priv = 'Y' OR db.Grant_priv = 'Y'); + +-- +-- procs_priv +-- +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) +) CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; + +ALTER TABLE procs_priv + ENGINE=MyISAM, + CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; + +ALTER TABLE procs_priv + MODIFY Proc_priv set('Execute','Alter Routine','Grant') + COLLATE utf8_general_ci DEFAULT '' NOT NULL; + +ALTER TABLE procs_priv + ADD Routine_type enum('FUNCTION','PROCEDURE') + COLLATE utf8_general_ci NOT NULL AFTER Routine_name; + +ALTER TABLE procs_priv + MODIFY Timestamp timestamp(14) AFTER Proc_priv; + +-- +-- help_topic +-- CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name varchar(64) not null, @@ -313,3 +450,124 @@ Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) CHARACTER SET utf8 comment='Leap seconds information for time zones'; + +# +# Create proc table if it does not exists +# + +CREATE TABLE IF NOT EXISTS proc ( + db char(64) collate utf8_bin DEFAULT '' NOT NULL, + name char(64) DEFAULT '' NOT NULL, + type enum('FUNCTION','PROCEDURE') NOT NULL, + specific_name char(64) DEFAULT '' NOT NULL, + language enum('SQL') DEFAULT 'SQL' NOT NULL, + sql_data_access enum('CONTAINS_SQL', + 'NO_SQL', + 'READS_SQL_DATA', + 'MODIFIES_SQL_DATA' + ) DEFAULT 'CONTAINS_SQL' NOT NULL, + is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, + security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, + param_list blob DEFAULT '' NOT NULL, + returns char(64) DEFAULT '' NOT NULL, + body longblob DEFAULT '' NOT NULL, + definer char(77) collate utf8_bin DEFAULT '' NOT NULL, + created timestamp, + modified timestamp, + sql_mode set( + 'REAL_AS_FLOAT', + 'PIPES_AS_CONCAT', + 'ANSI_QUOTES', + 'IGNORE_SPACE', + 'NOT_USED', + 'ONLY_FULL_GROUP_BY', + 'NO_UNSIGNED_SUBTRACTION', + 'NO_DIR_IN_CREATE', + 'POSTGRESQL', + 'ORACLE', + 'MSSQL', + 'DB2', + 'MAXDB', + 'NO_KEY_OPTIONS', + 'NO_TABLE_OPTIONS', + 'NO_FIELD_OPTIONS', + 'MYSQL323', + 'MYSQL40', + 'ANSI', + 'NO_AUTO_VALUE_ON_ZERO', + 'NO_BACKSLASH_ESCAPES', + 'STRICT_TRANS_TABLES', + 'STRICT_ALL_TABLES', + 'NO_ZERO_IN_DATE', + 'NO_ZERO_DATE', + 'INVALID_DATES', + 'ERROR_FOR_DIVISION_BY_ZERO', + 'TRADITIONAL', + 'NO_AUTO_CREATE_USER', + 'HIGH_NOT_PRECEDENCE' + ) DEFAULT '' NOT NULL, + comment char(64) collate utf8_bin DEFAULT '' NOT NULL, + PRIMARY KEY (db,name,type) +) engine=MyISAM + character set utf8 + comment='Stored Procedures'; + +# Correct the name fields to not binary, and expand sql_data_access +ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL, + MODIFY specific_name char(64) DEFAULT '' NOT NULL, + MODIFY sql_data_access + enum('CONTAINS_SQL', + 'NO_SQL', + 'READS_SQL_DATA', + 'MODIFIES_SQL_DATA' + ) DEFAULT 'CONTAINS_SQL' NOT NULL, + MODIFY body longblob DEFAULT '' NOT NULL, + MODIFY sql_mode + set('REAL_AS_FLOAT', + 'PIPES_AS_CONCAT', + 'ANSI_QUOTES', + 'IGNORE_SPACE', + 'NOT_USED', + 'ONLY_FULL_GROUP_BY', + 'NO_UNSIGNED_SUBTRACTION', + 'NO_DIR_IN_CREATE', + 'POSTGRESQL', + 'ORACLE', + 'MSSQL', + 'DB2', + 'MAXDB', + 'NO_KEY_OPTIONS', + 'NO_TABLE_OPTIONS', + 'NO_FIELD_OPTIONS', + 'MYSQL323', + 'MYSQL40', + 'ANSI', + 'NO_AUTO_VALUE_ON_ZERO', + 'NO_BACKSLASH_ESCAPES', + 'STRICT_TRANS_TABLES', + 'STRICT_ALL_TABLES', + 'NO_ZERO_IN_DATE', + 'NO_ZERO_DATE', + 'INVALID_DATES', + 'ERROR_FOR_DIVISION_BY_ZERO', + 'TRADITIONAL', + 'NO_AUTO_CREATE_USER', + 'HIGH_NOT_PRECEDENCE' + ) DEFAULT '' NOT NULL, + DEFAULT CHARACTER SET utf8; + +# Correct the character set and collation +ALTER TABLE proc CONVERT TO CHARACTER SET utf8; +# Reset some fields after the conversion +ALTER TABLE proc MODIFY db + char(64) collate utf8_bin DEFAULT '' NOT NULL, + MODIFY definer + char(77) collate utf8_bin DEFAULT '' NOT NULL, + MODIFY comment + char(64) collate utf8_bin DEFAULT '' NOT NULL; + +# Activate the new, possible modified privilege tables +# This should not be needed, but gives us some extra testing that the above +# changes was correct + +flush privileges; diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 56a432db741..e43b586054e 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -3,7 +3,7 @@ # For a more info consult the file COPYRIGHT distributed with this file. # This scripts creates the privilege tables db, host, user, tables_priv, -# columns_priv in the mysql database, as well as the func table. +# columns_priv, procs_priv in the mysql database, as well as the func table. # # All unrecognized arguments to this script are passed to mysqld. @@ -33,6 +33,7 @@ parse_arguments() { case "$arg" in --force) force=1 ;; --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --srcdir=*) srcdir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --ldata=*|--datadir=*) ldata=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --user=*) # Note that the user will be passed to mysqld so that it runs @@ -78,6 +79,7 @@ ldata= execdir= bindir= basedir= +srcdir= force=0 verbose=0 fill_help_tables="" @@ -106,18 +108,24 @@ else fi # find fill_help_tables.sh -for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@ -do - if test -f $i/fill_help_tables.sql - then - pkgdatadir=$i - fi -done - -if test -f $pkgdatadir/fill_help_tables.sql +if test -n "$srcdir" then - fill_help_tables=$pkgdatadir/fill_help_tables.sql + fill_help_tables=$srcdir/scripts/fill_help_tables.sql else + for i in $basedir/support-files $basedir/share $basedir/share/mysql \ + $basedir/scripts `pwd` `pwd`/scripts @pkgdatadir@ + do + if test -f $i/fill_help_tables.sql + then + pkgdatadir=$i + fi + done + + fill_help_tables=$pkgdatadir/fill_help_tables.sql +fi + +if test ! -f $fill_help_tables +then echo "Could not find help file 'fill_help_tables.sql' in @pkgdatadir@ or inside $basedir". exit 1; fi @@ -130,7 +138,13 @@ scriptdir=$bindir if test "$windows" = 1 then mysqld="./sql/mysqld" - mysqld_opt="--language=./sql/share/english" + if test -n "$srcdir" -a -f $srcdir/sql/share/english/errmsg.sys + then + langdir=$srcdir/sql/share/english + else + langdir=./sql/share/english + fi + mysqld_opt="--language=$langdir" scriptdir="./scripts" fi diff --git a/scripts/mysql_tableinfo.sh b/scripts/mysql_tableinfo.sh index f5083a776c6..2ed7e381fa3 100644 --- a/scripts/mysql_tableinfo.sh +++ b/scripts/mysql_tableinfo.sh @@ -6,6 +6,14 @@ use DBI; =head1 NAME +WARNING: MySQL versions 5.0 and above feature the INFORMATION_SCHEMA +pseudo-database which contains always up-to-date metadata information +about all tables. So instead of using this script one can now +simply query the INFORMATION_SCHEMA.SCHEMATA, INFORMATION_SCHEMA.TABLES, +INFORMATION_SCHEMA.COLUMNS, INFORMATION_SCHEMA.STATISTICS pseudo-tables. +Please see the MySQL manual for more information about INFORMATION_SCHEMA. +This script will be removed from the MySQL distribution in version 5.1. + mysql_tableinfo - creates and populates information tables with the output of SHOW DATABASES, SHOW TABLES (or SHOW TABLE STATUS), SHOW COLUMNS and SHOW INDEX. @@ -62,6 +70,19 @@ GetOptions( \%opt, "quiet|q", ) or usage("Invalid option"); +if (!$opt{'quiet'}) + { + print <<EOF +WARNING: MySQL versions 5.0 and above feature the INFORMATION_SCHEMA +pseudo-database which contains always up-to-date metadata information +about all tables. So instead of using this script one can now +simply query the INFORMATION_SCHEMA.SCHEMATA, INFORMATION_SCHEMA.TABLES, +INFORMATION_SCHEMA.COLUMNS, INFORMATION_SCHEMA.STATISTICS pseudo-tables. +Please see the MySQL manual for more information about INFORMATION_SCHEMA. +This script will be removed from the MySQL distribution in version 5.1. +EOF + } + if ($opt{'help'}) {usage();} my ($db_to_write,$db_like_wild,$tbl_like_wild); @@ -104,7 +125,7 @@ $tbl_like_wild=$dbh->quote($tbl_like_wild); if (!$opt{'quiet'}) { - print "\n!! This program is doing to do:\n\n"; + print "\n!! This program is going to do:\n\n"; print "**DROP** TABLE ...\n" if ($opt{'clear'} or $opt{'clear-only'}); print "**DELETE** FROM ... WHERE `Database` LIKE $db_like_wild AND `Table` LIKE $tbl_like_wild **INSERT** INTO ... @@ -456,17 +477,14 @@ UNIX domain socket to use when connecting to server =head1 WARRANTY -This software is free and comes without warranty of any kind. You -should never trust backup software without studying the code yourself. -Study the code inside this script and only rely on it if I<you> believe -that it does the right thing for you. +This software is free and comes without warranty of any kind. Patches adding bug fixes, documentation and new features are welcome. =head1 TO DO -Use extended inserts to be faster (for servers with many databases -or tables). But to do that, must care about net-buffer-length. +Nothing: starting from MySQL 5.0, this program is replaced by the +INFORMATION_SCHEMA pseudo-database. =head1 AUTHOR diff --git a/scripts/mysql_upgrade_shell.sh b/scripts/mysql_upgrade_shell.sh new file mode 100644 index 00000000000..c9f375b6c5b --- /dev/null +++ b/scripts/mysql_upgrade_shell.sh @@ -0,0 +1,203 @@ +#!/bin/sh +# Copyright (C) 2002-2003 MySQL AB +# For a more info consult the file COPYRIGHT distributed with this file. + +# Runs mysqlcheck --check-upgrade in case it has not been done on this +# major MySQL version + +# This script should always be run when upgrading from one major version +# to another (ie: 4.1 -> 5.0 -> 5.1) + +# +# Note that in most cases one have to use '--password' as +# arguments as these needs to be passed on to the mysqlcheck command + + +user=root + +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=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --ldata=*|--data=*|--datadir=*) DATADIR=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --force) force=1 ;; + --verbose) verbose=1 ;; + --help) help_option=1 ;; + *) + 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 +} + +# +# Find where my_print_defaults is +# + +find_my_print_defaults () { + if test -x ./bin/my_print_defaults + then + print_defaults="./bin/my_print_defaults" + elif test -x ./extra/my_print_defaults + then + print_defaults="./extra/my_print_defaults" + elif test -x @bindir@/my_print_defaults + then + print_defaults="@bindir@/my_print_defaults" + elif test -x @bindir@/mysql_print_defaults + then + print_defaults="@bindir@/mysql_print_defaults" + else + print_defaults="my_print_defaults" + fi +} + +find_my_print_defaults + +# Get first arguments from the my.cfg file, groups [mysqld] and +# [mysql_upgrade], and then merge with the command line arguments + +args= +DATADIR= +bindir= +MY_BASEDIR_VERSION= +verbose=0 +force=0 +help_option=0 + +parse_arguments `$print_defaults $defaults mysqld mysql_upgrade` +parse_arguments PICK-ARGS-FROM-ARGV "$@" + +if test $help_option = 1 +then + echo "MySQL utility script to upgrade database to the current server version" + echo "" + echo "It takes the following arguments:" + echo " --help Show this help message" + echo " --basedir Specifies the directory where MySQL is installed" + echo " --datadir Specifies the data directory" + echo " --force Mysql_upgrade.info file will be ignored" + echo " --user Username for server login if not current user" + echo " --verbose Display more output about the process" + echo "" + + exit 0 +fi + +# +# Try to find where binaries are installed +# + +MY_PWD=`pwd` +# Check for the directories we would expect from a binary release install +if test -z "$MY_BASEDIR_VERSION" +then + if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld + then + MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are + bindir="$MY_BASEDIR_VERSION/bin" + # Check for the directories we would expect from a source install + elif test -f ./share/mysql/english/errmsg.sys -a -x ./libexec/mysqld + then + MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are + bindir="$MY_BASEDIR_VERSION/bin" +# Since we didn't find anything, used the compiled-in defaults + else + MY_BASEDIR_VERSION=@prefix@ + bindir=@bindir@ + fi +else + bindir="$MY_BASEDIR_VERSION/bin" +fi + +# +# Try to find the data directory +# + +if test -z "$DATADIR" +then + # Try where the binary installs put it + if test -d $MY_BASEDIR_VERSION/data/mysql + then + DATADIR=$MY_BASEDIR_VERSION/data + # Next try where the source installs put it + elif test -d $MY_BASEDIR_VERSION/var/mysql + then + DATADIR=$MY_BASEDIR_VERSION/var + # Or just give up and use our compiled-in default + else + DATADIR=@localstatedir@ + fi +fi + +if test ! -x "$bindir/mysqlcheck" +then + echo "Can't find program '$bindir/mysqlcheck'" + echo "Please restart with --basedir=mysql-install-directory" + exit 1 +fi + +if test ! -f "$DATADIR/mysql/user.frm" +then + echo "Can't find data directory. Please restart with --datadir=path-to-data-dir" + exit 1 +fi + +CHECK_FILE=$DATADIR/mysql_upgrade.info + +if test -f $CHECK_FILE -a $force = 0 +then + version=`cat $CHECK_FILE` + if test "$version" = "@MYSQL_BASE_VERSION@" + then + if test $verbose = 1 + then + echo "mysql_upgrade already done for this version" + fi + $bindir/mysql_fix_privilege_tables --silent $args + exit 0 + fi +fi + +# +# Run the upgrade +# + +check_args="--check-upgrade --all-databases --auto-repair --user=$user" + +if test $verbose = 1 +then + echo "Running $bindir/mysqlcheck $args $check_args" +fi + +$bindir/mysqlcheck $check_args $args +if [ $? = 0 ] +then + # Remember base version so that we don't run this script again on the + # same base version + echo "@MYSQL_BASE_VERSION@" > $CHECK_FILE +fi + +$bindir/mysql_fix_privilege_tables --silent --user=$user $args diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 4a6f380494f..2dcc8dc7bc4 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -4,7 +4,7 @@ use Getopt::Long; use POSIX qw(strftime); $|=1; -$VER="2.11"; +$VER="2.15"; $opt_config_file = undef(); $opt_example = 0; @@ -37,13 +37,13 @@ main(); sub main { - my ($flag_exit); + my $flag_exit= 0; if (!defined(my_which(my_print_defaults))) { # We can't throw out yet, since --version, --help, or --example may # have been given - print "WARNING! my_print_defaults command not found!\n"; + print "WARNING: my_print_defaults command not found.\n"; print "Please make sure you have this command available and\n"; print "in your path. The command is available from the latest\n"; print "MySQL distribution.\n"; @@ -66,6 +66,11 @@ sub main else { $opt_config_file= $1; + if (!($opt_config_file =~ m/\//)) + { + # No path. Use current working directory + $opt_config_file= "./" . $opt_config_file; + } } } } @@ -76,10 +81,18 @@ sub main chop @defops; splice @ARGV, 0, 0, @defops; } - GetOptions("help","example","version","mysqld=s","mysqladmin=s", - "config-file=s","user=s","password=s","log=s","no-log","tcp-ip", - "silent","verbose") - || die "Wrong option! See $my_progname --help for detailed information!\n"; + if (!GetOptions("help","example","version","mysqld=s","mysqladmin=s", + "config-file=s","user=s","password=s","log=s","no-log", + "tcp-ip", "silent","verbose")) + { + $flag_exit= 1; + } + if (defined($opt_config_file) && !($opt_config_file =~ m/\//)) + { + # No path. Use current working directory + $opt_config_file= "./" . $opt_config_file; + } + usage() if ($opt_help); if ($opt_verbose && $opt_silent) { @@ -95,15 +108,14 @@ sub main exit(0); } example() if ($opt_example); - usage() if ($opt_help); if ($flag_exit) { - print "Error with an option, see $my_progname --help for more info!\n"; + print "Error with an option, see $my_progname --help for more info.\n"; exit(1); } if (!defined(my_which(my_print_defaults))) { - print "ABORT: Can't find command 'my_print_defaults'!\n"; + print "ABORT: Can't find command 'my_print_defaults'.\n"; print "This command is available from the latest MySQL\n"; print "distribution. Please make sure you have the command\n"; print "in your PATH.\n"; @@ -157,6 +169,31 @@ sub main } #### +#### Quote option argument. Add double quotes around the argument +#### and escape the following: $, \, " +#### This function is needed, because my_print_defaults drops possible +#### quotes, single or double, from in front of an argument and from +#### the end. +#### + +sub quote_opt_arg +{ + my ($option)= @_; + + if ($option =~ m/(\-\-[a-zA-Z0-9\_\-]+)=(.*)/) + { + $option= $1; + $arg= $2; + $arg=~ s/\\/\\\\/g; # Escape escape character first to avoid doubling. + $arg=~ s/\$/\\\$/g; + $arg=~ s/\"/\\\"/g; + $arg= "\"" . $arg . "\""; + $option= $option . "=" . $arg; + } + return $option; +} + +#### #### Init log file. Check for appropriate place for log file, in the following #### order my_print_defaults mysqld datadir, @datadir@, /var/log, /tmp #### @@ -289,10 +326,8 @@ sub start_mysqlds() } else { - # we single-quote the argument, but first convert single-quotes to - # '"'"' so they are passed through correctly - $options[$j]=~ s/'/'"'"'/g; - $tmp.= " '$options[$j]'"; + $options[$j]= quote_opt_arg($options[$j]); + $tmp.= " $options[$j]"; } } if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent) @@ -437,6 +472,16 @@ sub find_groups { $data[$i] = $line; } + if (defined($ENV{MYSQL_HOME}) && -f "$ENV{MYSQL_HOME}/my.cnf" && + -r "$ENV{MYSQL_HOME}/my.cnf") + { + open(MY_CNF, "<$ENV{MYSQL_HOME}/my.cnf") && (@tmp=<MY_CNF>) && + close(MY_CNF); + } + for (; ($line = shift @tmp); $i++) + { + $data[$i] = $line; + } if (-f "$homedir/.my.cnf" && -r "$homedir/.my.cnf") { open(MY_CNF, "<$homedir/.my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF); diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index c867d15a389..52fe282f916 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -31,9 +31,7 @@ Usage: $0 [OPTIONS] --defaults-file=FILE Use the specified defaults file --defaults-extra-file=FILE Also use defaults from the specified file --ledir=DIRECTORY Look for mysqld in the specified directory - --err-log=FILE Obsolete, use '--log-error' --log-error=FILE Log errors to the specified log file - --open-files=LIMIT Obsolete, use '--open-files-limit' --open-files-limit=LIMIT Limit the number of open files --core-file-size=LIMIT Limit core files to the specified size --timezone=TZ Set the system timezone @@ -78,11 +76,7 @@ parse_arguments() { # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! --ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;; - # err-log should be removed in 5.0 - --err-log=*) err_log=`echo "$arg" | sed -e "s;--err-log=;;"` ;; --log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;; - # QQ The --open-files should be removed in 5.0 - --open-files=*) open_files=`echo "$arg" | sed -e "s;--open-files=;;"` ;; --open-files-limit=*) open_files=`echo "$arg" | sed -e "s;--open-files-limit=;;"` ;; --core-file-size=*) core_file_size=`echo "$arg" | sed -e "s;--core-file-size=;;"` ;; --timezone=*) TZ=`echo "$arg" | sed -e "s;--timezone=;;"` ; export TZ; ;; @@ -143,7 +137,7 @@ fi if test -d $MY_BASEDIR_VERSION/data/mysql then DATADIR=$MY_BASEDIR_VERSION/data - if test -z "$defaults" + if test -z "$defaults" -a -r "$DATADIR/my.cnf" then defaults="--defaults-extra-file=$DATADIR/my.cnf" fi @@ -156,6 +150,28 @@ else DATADIR=@localstatedir@ fi +if test -z "$MYSQL_HOME" +then + if test -r "$MY_BASEDIR_VERSION/my.cnf" && test -r "$DATADIR/my.cnf" + then + echo "WARNING: Found two instances of my.cnf -" + echo "$MY_BASEDIR_VERSION/my.cnf and" + echo "$DATADIR/my.cnf" + echo "IGNORING $DATADIR/my.cnf" + echo + MYSQL_HOME=$MY_BASEDIR_VERSION + elif test -r "$DATADIR/my.cnf" + then + echo "WARNING: Found $DATADIR/my.cnf" + echo "Datadir is deprecated place for my.cnf, please move it to $MY_BASEDIR_VERSION" + echo + MYSQL_HOME=$DATADIR + else + MYSQL_HOME=$MY_BASEDIR_VERSION + fi +fi +export MYSQL_HOME + user=@MYSQLD_USER@ niceness=0 @@ -306,10 +322,13 @@ then ulimit -n $open_files args="--open-files-limit=$open_files $args" fi - if test -n "$core_file_size" - then - ulimit -c $core_file_size - fi +fi + +# Try to set the core file size (even if we aren't root) because many systems +# don't specify a hard limit on core file size. +if test -n "$core_file_size" +then + ulimit -c $core_file_size fi # diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index cd615cf7fc3..61cd59457d1 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -252,6 +252,7 @@ if ( defined $opt{regexp} ) { my $sth_dbs = $dbh->prepare("show databases"); $sth_dbs->execute; while ( my ($db_name) = $sth_dbs->fetchrow_array ) { + next if $db_name =~ m/^information_schema$/i; push @db_desc, { 'src' => $db_name, 't_regex' => $t_regex } if ( $db_name =~ m/$opt{regexp}/o ); } } |