diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.am | 13 | ||||
-rw-r--r-- | scripts/fill_func_tables.sh | 6 | ||||
-rw-r--r-- | scripts/make_binary_distribution.sh | 49 | ||||
-rwxr-xr-x | scripts/make_win_bin_dist | 13 | ||||
-rw-r--r-- | scripts/make_win_src_distribution.sh | 538 | ||||
-rw-r--r-- | scripts/mysql_convert_table_format.sh | 4 | ||||
-rw-r--r-- | scripts/mysql_create_system_tables.sh | 174 | ||||
-rw-r--r-- | scripts/mysql_explain_log.sh | 394 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sh | 6 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sql | 275 | ||||
-rw-r--r-- | scripts/mysql_install_db.sh | 5 | ||||
-rw-r--r-- | scripts/mysql_prepare_privilege_tables_for_5.sql | 53 | ||||
-rw-r--r-- | scripts/mysql_tableinfo.sh | 494 | ||||
-rw-r--r-- | scripts/mysql_upgrade_shell.sh | 203 | ||||
-rw-r--r-- | scripts/mysqld_safe-watch.sh | 150 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 77 |
16 files changed, 492 insertions, 1962 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 585c8ca8655..84c8636ecb9 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -29,19 +29,14 @@ bin_SCRIPTS = @server_scripts@ \ mysql_find_rows \ mysqlhotcopy \ mysqldumpslow \ - mysql_explain_log \ - mysql_tableinfo \ - mysql_upgrade_shell \ mysqld_multi \ mysql_create_system_tables noinst_SCRIPTS = make_binary_distribution \ - make_sharedlib_distribution \ - make_win_src_distribution + make_sharedlib_distribution EXTRA_SCRIPTS = make_binary_distribution.sh \ make_sharedlib_distribution.sh \ - make_win_src_distribution.sh \ msql2mysql.sh \ mysql_config.sh \ mysql_fix_privilege_tables.sh \ @@ -56,10 +51,7 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \ mysql_find_rows.sh \ mysqlhotcopy.sh \ mysqldumpslow.sh \ - mysql_explain_log.sh \ mysqld_multi.sh \ - mysql_tableinfo.sh \ - mysql_upgrade_shell.sh \ mysqld_safe.sh \ mysql_create_system_tables.sh @@ -87,11 +79,8 @@ CLEANFILES = @server_scripts@ \ mysql_find_rows \ mysqlhotcopy \ mysqldumpslow \ - mysql_explain_log \ mysql_tableinfo \ - mysql_upgrade_shell \ mysqld_multi \ - make_win_src_distribution \ mysql_create_system_tables DISTCLEANFILES = mysqlbug diff --git a/scripts/fill_func_tables.sh b/scripts/fill_func_tables.sh index ad5b7fbb521..e71849962fa 100644 --- a/scripts/fill_func_tables.sh +++ b/scripts/fill_func_tables.sh @@ -145,7 +145,7 @@ print " max_args tinyint,"; print " date_created datetime not null,"; print " last_modified timestamp not null,"; print " primary key (func_id)"; -print ") type=myisam;\n\n"; +print ") ENGINE=MYISAM;\n\n"; print "DROP TABLE IF EXISTS function_category_name;\n"; print "CREATE TABLE function_category_name ("; @@ -155,14 +155,14 @@ print " url char(128) not null,"; print " date_created datetime not null,"; print " last_modified timestamp not null,"; print " primary key (cat_id)"; -print ") type=myisam;\n\n"; +print ") ENGINE=MYISAM;\n\n"; print "DROP TABLE IF EXISTS function_category;\n"; print "CREATE TABLE function_category ("; print " cat_id smallint unsigned not null references function_category_name,"; print " func_id int unsigned not null references function,"; print " primary key (cat_id, func_id)"; -print ") type=myisam;\n\n"; +print ") ENGINE=MYISAM;\n\n"; print "DELETE FROM function_category_name;\n"; print "DELETE FROM function_category;\n"; diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 9469cca875d..bb90cb5178e 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -92,7 +92,9 @@ esac mkdir $BASE $BASE/bin $BASE/docs \ $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \ $BASE/mysql-test $BASE/mysql-test/t $BASE/mysql-test/r \ - $BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/mysql-test/lib + $BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/mysql-test/lib \ + $BASE/mysql-test/extra \ + $BASE/mysql-test/extra/binlog_tests $BASE/mysql-test/extra/rpl_tests if [ $BASE_SYSTEM != "netware" ] ; then mkdir $BASE/share/mysql $BASE/tests $BASE/sql-bench $BASE/man \ @@ -127,11 +129,13 @@ 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 \ - myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \ - myisam/myisam_ftdump$BS \ - sql/mysqld$BS sql/mysql_tzinfo_to_sql$BS \ + storage/myisam/myisamchk$BS storage/myisam/myisampack$BS \ + storage/myisam/myisamlog$BS storage/myisam/myisam_ftdump$BS \ + sql/mysqld$BS sql/mysqld-debug$BS \ + sql/mysql_tzinfo_to_sql$BS \ server-tools/instance-manager/mysqlmanager$BS \ client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \ + client/mysqlslap$BS \ client/mysqldump$BS client/mysqlimport$BS \ client/mysqltest$BS client/mysqlcheck$BS \ client/mysqlbinlog$BS client/mysql_upgrade$BS \ @@ -144,19 +148,17 @@ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \ 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/init_db.sql netware/test_db.sql$BS \ netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql \ "; # For all other platforms: else BIN_FILES="$BIN_FILES \ - client/mysqltestmanagerc \ - client/mysqltestmanager-pwgen tools/mysqltestmanager \ client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \ + client/.libs/mysqlslap \ client/.libs/mysqldump client/.libs/mysqlimport \ client/.libs/mysqltest client/.libs/mysqlcheck \ - client/.libs/mysqlbinlog client/.libs/mysqltestmanagerc \ - client/.libs/mysqltestmanager-pwgen tools/.libs/mysqltestmanager \ + client/.libs/mysqlbinlog \ tests/.libs/mysql_client_test \ libmysqld/examples/.libs/mysql_client_test_embedded \ libmysqld/examples/.libs/mysqltest_embedded \ @@ -169,8 +171,9 @@ if [ x$STRIP = x1 ] ; then strip $BASE/bin/* fi -# Copy not binary files -copyfileto $BASE/bin sql/mysqld.sym.gz +# Obsolete, starting from 5.1.6-beta +# # Copy not binary files +# copyfileto $BASE/bin sql/mysqld.sym.gz if [ $BASE_SYSTEM = "netware" ] ; then $CP netware/*.pl $BASE/scripts @@ -248,11 +251,14 @@ $CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \ mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \ mysql-test/std_data/*.cnf \ $BASE/mysql-test/std_data -$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 +$CP mysql-test/t/*.test $BASE/mysql-test/t +$CP mysql-test/t/*.imtest mysql-test/t/*.disabled $BASE/mysql-test/t +$CP mysql-test/t/*.opt mysql-test/t/*.slave-mi $BASE/mysql-test/t +$CP mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t +$CP mysql-test/r/*.result $BASE/mysql-test/r +$CP mysql-test/r/*.require $BASE/mysql-test/r +$CP mysql-test/extra/binlog_tests/*.test $BASE/mysql-test/extra/binlog_tests +$CP mysql-test/extra/rpl_tests/*.test $BASE/mysql-test/extra/rpl_tests if [ $BASE_SYSTEM != "netware" ] ; then chmod a+x $BASE/bin/* @@ -314,20 +320,23 @@ if [ $BASE_SYSTEM != "netware" ] ; then fi # Clean up if we did this from a bk tree -if [ -d $BASE/sql-bench/SCCS ] ; then +if [ -d $BASE/share/SCCS ] ; then find $BASE/share -name SCCS -print | xargs rm -rf find $BASE/sql-bench -name SCCS -print | xargs rm -rf fi # NDB Cluster if [ x$NDBCLUSTER = x1 ]; then - ( cd ndb ; @MAKE@ DESTDIR=$BASE/ndb-stage install ) - ( cd mysql-test/ndb ; @MAKE@ DESTDIR=$BASE/ndb-stage install ) + ( cd storage/ndb ; @MAKE@ DESTDIR=$BASE/ndb-stage install ) + ( cd mysql-test ; @MAKE@ DESTDIR=$BASE/ndb-stage install ) $CP $BASE/ndb-stage@bindir@/* $BASE/bin/. $CP $BASE/ndb-stage@libexecdir@/* $BASE/bin/. $CP $BASE/ndb-stage@pkglibdir@/* $BASE/lib/. - $CP -r $BASE/ndb-stage@pkgincludedir@/ndb $BASE/include + test -d $BASE/include/storage || mkdir $BASE/include/storage + $CP -r $BASE/ndb-stage@pkgincludedir@/storage/ndb $BASE/include/storage/ $CP -r $BASE/ndb-stage@prefix@/mysql-test/ndb $BASE/mysql-test/. || exit 1 + $CP -r $BASE/ndb-stage@prefix@/mysql-test/std_data/ndb_backup50 $BASE/mysql-test/std_data/. || exit 1 + $CP -r $BASE/ndb-stage@prefix@/mysql-test/std_data/ndb_backup51 $BASE/mysql-test/std_data/. || exit 1 rm -rf $BASE/ndb-stage fi diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 38e7ab88f22..b200e5428be 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -122,7 +122,7 @@ mkdir $DESTDIR mkdir $DESTDIR/bin cp client/$TARGET/*.exe $DESTDIR/bin/ cp extra/$TARGET/*.exe $DESTDIR/bin/ -cp myisam/$TARGET/*.exe $DESTDIR/bin/ +cp storage/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/ @@ -234,7 +234,6 @@ cp include/conf*.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/ @@ -283,7 +282,13 @@ 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/std_data/Moscow_leap $DESTDIR/mysql-test/std_data/ +cp mysql-test/std_data/des_key_file $DESTDIR/mysql-test/std_data/ +cp mysql-test/std_data/*.000001 $DESTDIR/mysql-test/std_data/ +cp mysql-test/std_data/*.cnf $DESTDIR/mysql-test/std_data/ +cp mysql-test/std_data/*.dat $DESTDIR/mysql-test/std_data/ +cp mysql-test/std_data/*.frm $DESTDIR/mysql-test/std_data/ +cp mysql-test/std_data/*.pem $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/ @@ -323,8 +328,6 @@ for i in `cd scripts && ls`; do \ 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 diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh deleted file mode 100644 index 6206ca64121..00000000000 --- a/scripts/make_win_src_distribution.sh +++ /dev/null @@ -1,538 +0,0 @@ -#!/bin/sh - -# Terminate loudly on error, we don't want partial package -set -e -trap "echo '*** script failed ***'" 0 - -# -# Script to create a Windows src package -# - -version=@VERSION@ -CP="cp -p" - -DEBUG=0 -SILENT=0 -SUFFIX="" -DIRNAME="" -OUTTAR="0" -OUTZIP="0" - -# -# An "abort" function taking a variable number of strings (one per line) -# - -abort() -{ - for line - do - echo "$line" - done - exit 1 -} - - -# -# This script must run from MySQL top directory -# - -if [ ! -f scripts/make_win_src_distribution ]; then - abort "ERROR : You must run this script from the MySQL top-level directory" -fi -SOURCE=`pwd` - -# -# Check for source compilation/configuration -# - -if [ ! -f sql/sql_yacc.cc ]; then - abort "ERROR : Sorry, you must run this script after the complete build," \ - " hope you know what you are trying to do !!" -fi - -# -# Debug print of the status -# - -print_debug() -{ - for statement - do - if [ "$DEBUG" = "1" ] ; then - echo $statement - fi - done -} - -# -# Usage of the script -# - -show_usage() -{ - echo "MySQL utility script to create a Windows src package, and it takes" - echo "the following arguments:" - echo "" - echo " --debug Debug, without creating the package" - echo " --tmp Specify the temporary location" - echo " --suffix Suffix name for the package" - echo " --dirname Directory name to copy files (intermediate)" - echo " --silent Show no progress information" - echo " --tar Create tar.gz package" - echo " --zip Create zip package" - echo " --help Show this help message" - - exit 0 -} - -# -# Parse the input arguments -# - -parse_arguments() { - for arg do - case "$arg" in - --add-tar) ADDTAR=1 ;; - --debug) DEBUG=1;; - --tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;; - --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;; - --dirname=*) DIRNAME=`echo "$arg" | sed -e "s;--dirname=;;"` ;; - --silent) SILENT=1 ;; - --tar) OUTTAR=1 ;; - --zip) OUTZIP=1 ;; - --help) show_usage ;; - *) abort "Unknown argument '$arg'" - ;; - esac - done -} - -parse_arguments "$@" - -# -# Assign the tmp directory if it was set from the environment variables -# - -for i in $TMP $TMPDIR $TEMPDIR $TEMP /tmp -do - if [ "$i" ]; then - print_debug "Setting TMP to '$i'" - TMP=$i - break - fi -done - - -# -# Convert argument file from unix to DOS text -# - -unix_to_dos() -{ - for arg do - print_debug "Replacing LF -> CRLF from '$arg'" - - awk '{sub(/$/,"\r");print}' < $arg > $arg.tmp - rm -f $arg - mv $arg.tmp $arg - done -} - - -# -# Create a tmp dest directory to copy files -# - -BASE=$TMP/my_win_dist$SUFFIX.$$ -trap "rm -r -f $BASE; echo '*** interrupted ***'; exit 1" 1 2 3 13 15 - -if [ -d $BASE ] ; then - echo "WARNING: Destination directory '$BASE' already exists, deleting it" - rm -r -f $BASE -fi - -$CP -r $SOURCE/VC++Files $BASE -# This includes an implicit 'mkdir $BASE' ! - -# -# Process version tags in InstallShield files -# - -vreplace() -{ - for arg do - unix_to_dos $arg - cat $arg | sed -e 's!@''VERSION''@!@VERSION@!' > $arg.tmp - rm -f $arg - mv $arg.tmp $arg - done -} - -if test -d $BASE/InstallShield -then - for d in 4.1.XX-gpl 4.1.XX-pro 4.1.XX-classic - do - cd $BASE/InstallShield/$d/String\ Tables/0009-English - vreplace value.shl - cd ../../Setup\ Files/Compressed\ Files/Language\ Independent/OS\ Independent - vreplace infolist.txt - done -fi - -# -# Move all error message files to root directory -# - -$CP -r $SOURCE/sql/share $BASE/ -rm -r -f "$BASE/share/Makefile" -rm -r -f "$BASE/share/Makefile.in" -rm -r -f "$BASE/share/Makefile.am" - -mkdir $BASE/Docs $BASE/extra $BASE/include - -# -# Copy directory files -# - -copy_dir_files() -{ - for arg do - print_debug "Copying files from directory '$arg'" - cd $SOURCE/$arg - if [ ! -d $BASE/$arg ]; then - print_debug "Creating directory '$arg'" - mkdir $BASE/$arg - fi - 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 - do - if [ -f $i ] - then - $CP $SOURCE/$arg/$i $BASE/$arg/$i - fi - done - for i in *.cc - do - if [ -f $i ] - then - i=`echo $i | sed 's/.cc$//g'` - $CP $SOURCE/$arg/$i.cc $BASE/$arg/$i.cpp - fi - done - done -} - -# -# Copy directory contents recursively -# - -copy_dir_dirs() { - - for arg do - - cd $SOURCE - ( - find $arg -type d \ - -and -not -path \*SCCS\* \ - -and -not -path \*.deps\* \ - -and -not -path \*.libs\* \ - -and -not -path \*autom4te.cache -print - )|( - while read v - do - copy_dir_files $v - done - ) - - done -} - -# -# Input directories to be copied -# - -for i in client dbug extra heap include \ - libmysql libmysqld myisam \ - myisammrg mysys regex sql strings sql-common sql/examples \ - tools vio zlib -do - copy_dir_files $i -done - -# -# Create project files for ndb -# -make -C $SOURCE/ndb windoze || true - -# -# Input directories to be copied recursively -# - -for i in bdb innobase ndb extra/yassl server-tools -do - copy_dir_dirs $i -done - -# -# Create dummy innobase configure header -# - -if [ -f $BASE/innobase/ib_config.h ]; then - rm -f $BASE/innobase/ib_config.h -fi -touch $BASE/innobase/ib_config.h - - -# -# Copy miscellaneous files -# - -cd $SOURCE -for i in COPYING ChangeLog README EXCEPTIONS-CLIENT\ - INSTALL-SOURCE INSTALL-WIN \ - INSTALL-WIN-SOURCE \ - Docs/INSTALL-BINARY Docs/manual.chm -do - print_debug "Copying file '$i'" - if [ -f $i ] - then - $CP $i $BASE/$i - fi -done - -# -# support files -# -mkdir $BASE/support-files - -# Rename the cnf files to <file>.ini -for i in support-files/*.cnf -do - i=`echo $i | sed 's/.cnf$//g'` - cp $i.cnf $BASE/$i.ini -done - -# -# Raw dirs from source tree -# - -for i in scripts sql-bench mysql-test SSL tests -do - print_debug "Copying directory '$i'" - if [ -d $i ] - then - if [ -d $BASE/$i ] - then - $CP -R $i $BASE - else - $CP -R $i $BASE/$i - fi - fi - # But remove object files from destination - find $BASE/$i -type f -name \*.o | xargs rm -f -done - -# -# Fix some windows files to avoid compiler warnings -# - -if [ -x extra/replace ] ; then - ./extra/replace std:: "" < $BASE/sql/sql_yacc.cpp | \ - sed '/^ *switch (yytype)$/ { N; /\n *{$/ { N; /\n *default:$/ { N; /\n *break;$/ { N; /\n *}$/ d; };};};} ' \ - > $BASE/sql/sql_yacc.cpp-new - mv $BASE/sql/sql_yacc.cpp-new $BASE/sql/sql_yacc.cpp -else - if [ "$SILENT" = "0" ] ; then - echo 'WARNING: "extra/replace" not built, can not filter "sql_yacc.ccp"' - echo 'WARNING: to reduce the number of warnings when building' - fi -fi - -# -# Search the tree for plain text files and adapt the line end marker -# -find $BASE \( -name "*.cnf" -o -name "*.ini" \ - -o -name COPYING -o -name ChangeLog -o -name EXCEPTIONS-CLIENT \ - -o -name "INSTALL*" -o -name LICENSE -o -name "README*" \ - -o -name "*.dsp" -o -name "*.dsw" \ - -o -name "*.vcproj" -o -name "*.sln" \) -type f -print \ -| while read v - do - unix_to_dos $v - done - -mv $BASE/README $BASE/README.txt - -# -# Clean up if we did this from a bk tree -# - -find $BASE -type d \( -name SCCS -o -name .deps -o -name .libs \) -print0 | \ -xargs -0 rm -r -f -rm -r -f "$BASE/mysql-test/var" - -# -# Initialize the initial data directory -# - -if [ ! -f scripts/mysql_install_db ] ; then - if [ "$SILENT" = "0" ] ; then - echo 'WARNING: "scripts/mysql_install_db" is not built, can not initiate databases' - fi -elif [ ! -f extra/my_print_defaults ]; then - if [ "$SILENT" = "0" ] ; then - echo 'WARNING: "extra/my_print_defaults" is not built, can not initiate databases' - fi -else - print_debug "Initializing the 'data' directory" - scripts/mysql_install_db --no-defaults --windows --datadir=$BASE/data - if test "$?" = 1 - then - exit 1; - fi -fi - -# -# Specify the distribution package name and copy it -# - -if test -z $DIRNAME -then - NEW_DIR_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version$SUFFIX -else - NEW_DIR_NAME=$DIRNAME -fi -NEW_NAME=$NEW_DIR_NAME-win-src - -BASE2=$TMP/$NEW_DIR_NAME -rm -r -f $BASE2 -mv $BASE $BASE2 -BASE=$BASE2 - -# -# If debugging, don't create a zip/tar/gz -# - -if [ "$DEBUG" = "1" ] ; then - echo "Please check the distribution files from $BASE" - echo "Exiting (without creating the package).." - exit -fi - -# -# This is needed to prefere gnu tar instead of tar because tar can't -# always handle long filenames -# - -PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' ` -which_1 () -{ - for cmd - do - for d in $PATH_DIRS - do - for file in $d/$cmd - do - if test -x $file -a ! -d $file - then - echo $file - exit 0 - fi - done - done - done - exit 1 -} - -# -# Create the result zip/tar file -# - -if [ "$OUTTAR" = "0" ]; then - if [ "$OUTZIP" = "0" ]; then - OUTZIP=1 - fi -fi - -set_tarzip_options() -{ - for arg - do - if [ "$arg" = "tar" ]; then - ZIPFILE1=gnutar - ZIPFILE2=gtar - OPT=cf - EXT=".tar" - NEED_COMPRESS=1 - else - ZIPFILE1=zip - ZIPFILE2="" - OPT="-r -q" - EXT=".zip" - NEED_COMPRESS=0 - fi - done -} - - -# -# Create the archive -# -create_archive() -{ - - print_debug "Using $tar to create archive" - - cd $TMP - - rm -f $SOURCE/$NEW_NAME$EXT - $tar $OPT $SOURCE/$NEW_NAME$EXT $NEW_DIR_NAME - cd $SOURCE - - if [ "$NEED_COMPRESS" = "1" ] - then - print_debug "Compressing archive" - gzip -9 $NEW_NAME$EXT - EXT="$EXT.gz" - fi - - if [ "$SILENT" = "0" ] ; then - echo "$NEW_NAME$EXT created successfully !!" - fi -} - -if [ "$OUTTAR" = "1" ]; then - set_tarzip_options 'tar' - - tar=`which_1 $ZIPFILE1 $ZIPFILE2` - if test "$?" = "1" -o "$tar" = "" - then - print_debug "Search failed for '$ZIPFILE1', '$ZIPFILE2', using default 'tar'" - tar=tar - set_tarzip_options 'tar' - fi - - create_archive -fi - -if [ "$OUTZIP" = "1" ]; then - set_tarzip_options 'zip' - - tar=`which_1 $ZIPFILE1 $ZIPFILE2` - if test "$?" = "1" -o "$tar" = "" - then - echo "Search failed for '$ZIPFILE1', '$ZIPFILE2', cannot create zip!" - fi - - create_archive -fi - -print_debug "Removing temporary directory" -rm -r -f $BASE - -# No need to report anything if we got here -trap "" 0 - -# End of script diff --git a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh index c1955e632fb..4b68d6c5039 100644 --- a/scripts/mysql_convert_table_format.sh +++ b/scripts/mysql_convert_table_format.sh @@ -69,7 +69,7 @@ foreach $table (@ARGV) } } print "converting $table\n" if ($opt_verbose); - if (!$dbh->do("ALTER TABLE $table type=$opt_type")) + if (!$dbh->do("ALTER TABLE $table ENGINE=$opt_type")) { print STDERR "Can't convert $table: Error $DBI::errstr\n"; exit(1) if (!$opt_force); @@ -114,7 +114,7 @@ Conversion of a MySQL tables to other table types. --socket='/path/to/socket' Socket to connect with. ---type='table-type' +--ENGINE='table-type' Converts tables to the given table type (Default: $opt_type) MySQL 3.23 supports at least the BDB, ISAM and MYISAM types. diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index 54f0ef230ad..44fbb7183b9 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -30,6 +30,7 @@ windows=$4 # Initialize variables c_d="" i_d="" +c_s="" i_s="" c_h="" i_h="" c_u="" i_u="" c_f="" i_f="" @@ -39,9 +40,11 @@ c_hc="" c_hr="" 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_tzn="" c_tz="" c_tzt="" c_tztt="" c_tzls="" c_pl="" +i_tzn="" i_tz="" i_tzt="" i_tztt="" i_tzls="" i_pl="" c_p="" c_pp="" +c_gl="" c_sl="" +c_ev="" # Check for old tables if test ! -f $mdata/db.frm @@ -72,14 +75,16 @@ then 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 Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_d="$c_d Trigger_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','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');" + i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y'); + INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y');" fi if test ! -f $mdata/host.frm @@ -108,6 +113,7 @@ then 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 Trigger_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" @@ -150,6 +156,8 @@ then 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 Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL," + c_u="$c_u Trigger_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," @@ -165,26 +173,53 @@ 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','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); + 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','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','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','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','Y','Y','Y','Y','Y','','','','',0,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','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','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','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','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','Y','Y','','','','',0,0,0);" fi fi fi +# Check for old tables +if test ! -f $mdata/servers.frm +then + if test "$1" = "verbose" ; then + echo "Preparing servers table" 1>&2; + fi + + c_s=" +CREATE TABLE servers (" + c_s="$c_s Server_name char(64) NOT NULL," + c_s="$c_s Host char(64) NOT NULL," + c_s="$c_s Db char(64) NOT NULL," + c_s="$c_s Username char(64) NOT NULL," + c_s="$c_s Password char(64) NOT NULL," + c_s="$c_s Port INT(4)," + c_s="$c_s Socket char(64)," + c_s="$c_s Wrapper char(64) NOT NULL," + c_s="$c_s Owner char(64) NOT NULL," + c_s="$c_s PRIMARY KEY (Server_name))" + c_s="$c_s CHARACTER SET utf8 comment='MySQL Foreign Servers table';" + + i_s="INSERT INTO servers VALUES + ('test','localhost','test','root','', 0, + '','mysql','root'); + " +fi + if test ! -f $mdata/func.frm then if test "$1" = "verbose" ; then @@ -202,6 +237,21 @@ then c_f="$c_f comment='User defined functions';" fi +if test ! -f $mdata/plugin.frm +then + if test "$1" = "verbose" ; then + echo "Preparing plugin table" 1>&2; + fi + + c_pl="$c_pl CREATE TABLE plugin (" + c_pl="$c_pl name char(64) binary DEFAULT '' NOT NULL," + c_pl="$c_pl dl char(128) DEFAULT '' NOT NULL," + c_pl="$c_pl PRIMARY KEY (name)" + c_pl="$c_pl ) engine=MyISAM" + c_pl="$c_pl CHARACTER SET utf8 COLLATE utf8_bin" + c_pl="$c_pl comment='MySQL plugins';" +fi + if test ! -f $mdata/tables_priv.frm then if test "$1" = "verbose" ; then @@ -214,8 +264,8 @@ then c_t="$c_t User char(16) binary DEFAULT '' NOT NULL," c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL," c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL," - c_t="$c_t Timestamp timestamp(14)," - c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL," + c_t="$c_t Timestamp timestamp," + c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') 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)" @@ -236,7 +286,7 @@ then c_c="$c_c User char(16) binary DEFAULT '' NOT NULL," c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL," c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL," - c_c="$c_c Timestamp timestamp(14)," + c_c="$c_c Timestamp timestamp," c_c="$c_c Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL," c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)" c_c="$c_c ) engine=MyISAM" @@ -258,7 +308,7 @@ then 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 Timestamp timestamp," 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" @@ -337,6 +387,7 @@ then c_hr="$c_hr comment='keyword-topic relation';" fi + if test ! -f $mdata/time_zone_name.frm then if test "$1" = "verbose" ; then @@ -726,9 +777,91 @@ then c_p="$c_p comment='Stored Procedures';" fi + +if test ! -f $mdata/general_log.frm +then + if test "$1" = "verbose" ; then + echo "Preparing general_log table" 1>&2; + fi + c_gl="$c_gl CREATE PROCEDURE create_general_log_table() BEGIN DECLARE is_csv_enabled int DEFAULT 0; SELECT @@have_csv = 'YES' INTO is_csv_enabled; IF (is_csv_enabled) THEN CREATE TABLE general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT, thread_id INTEGER, server_id INTEGER, command_type VARCHAR(64), argument MEDIUMTEXT) engine=CSV CHARACTER SET utf8 comment='General log'; END IF; END; +CALL create_general_log_table(); +DROP PROCEDURE create_general_log_table;" +fi + + +if test ! -f $mdata/slow_log.frm +then + if test "$1" = "verbose" ; then + echo "Preparing slow_log table" 1>&2; + fi + c_sl="$c_sl CREATE PROCEDURE create_slow_log_table() BEGIN DECLARE is_csv_enabled int DEFAULT 0; SELECT @@have_csv = 'YES' INTO is_csv_enabled; IF (is_csv_enabled) THEN CREATE TABLE slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512), last_insert_id INTEGER, insert_id INTEGER, server_id INTEGER, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment='Slow log'; END IF; END; +CALL create_slow_log_table(); +DROP PROCEDURE create_slow_log_table;" +fi + +if test ! -f $mdata/event.frm +then + c_ev="$c_ev CREATE TABLE event (" + c_ev="$c_ev db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default ''," + c_ev="$c_ev name char(64) CHARACTER SET utf8 NOT NULL default ''," + c_ev="$c_ev body longblob NOT NULL," + c_ev="$c_ev definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default ''," + c_ev="$c_ev execute_at DATETIME default NULL," + c_ev="$c_ev interval_value int(11) default NULL," + c_ev="$c_ev interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK'," + c_ev="$c_ev 'SECOND','MICROSECOND', 'YEAR_MONTH','DAY_HOUR'," + c_ev="$c_ev 'DAY_MINUTE','DAY_SECOND'," + c_ev="$c_ev 'HOUR_MINUTE','HOUR_SECOND'," + c_ev="$c_ev 'MINUTE_SECOND','DAY_MICROSECOND'," + c_ev="$c_ev 'HOUR_MICROSECOND','MINUTE_MICROSECOND'," + c_ev="$c_ev 'SECOND_MICROSECOND') default NULL," + c_ev="$c_ev created TIMESTAMP NOT NULL," + c_ev="$c_ev modified TIMESTAMP NOT NULL," + c_ev="$c_ev last_executed DATETIME default NULL," + c_ev="$c_ev starts DATETIME default NULL," + c_ev="$c_ev ends DATETIME default NULL," + c_ev="$c_ev status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED'," + c_ev="$c_ev on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP'," + c_ev="$c_ev sql_mode set(" + c_ev="$c_ev 'REAL_AS_FLOAT'," + c_ev="$c_ev 'PIPES_AS_CONCAT'," + c_ev="$c_ev 'ANSI_QUOTES'," + c_ev="$c_ev 'IGNORE_SPACE'," + c_ev="$c_ev 'NOT_USED'," + c_ev="$c_ev 'ONLY_FULL_GROUP_BY'," + c_ev="$c_ev 'NO_UNSIGNED_SUBTRACTION'," + c_ev="$c_ev 'NO_DIR_IN_CREATE'," + c_ev="$c_ev 'POSTGRESQL'," + c_ev="$c_ev 'ORACLE'," + c_ev="$c_ev 'MSSQL'," + c_ev="$c_ev 'DB2'," + c_ev="$c_ev 'MAXDB'," + c_ev="$c_ev 'NO_KEY_OPTIONS'," + c_ev="$c_ev 'NO_TABLE_OPTIONS'," + c_ev="$c_ev 'NO_FIELD_OPTIONS'," + c_ev="$c_ev 'MYSQL323'," + c_ev="$c_ev 'MYSQL40'," + c_ev="$c_ev 'ANSI'," + c_ev="$c_ev 'NO_AUTO_VALUE_ON_ZERO'," + c_ev="$c_ev 'NO_BACKSLASH_ESCAPES'," + c_ev="$c_ev 'STRICT_TRANS_TABLES'," + c_ev="$c_ev 'STRICT_ALL_TABLES'," + c_ev="$c_ev 'NO_ZERO_IN_DATE'," + c_ev="$c_ev 'NO_ZERO_DATE'," + c_ev="$c_ev 'INVALID_DATES'," + c_ev="$c_ev 'ERROR_FOR_DIVISION_BY_ZERO'," + c_ev="$c_ev 'TRADITIONAL'," + c_ev="$c_ev 'NO_AUTO_CREATE_USER'," + c_ev="$c_ev 'HIGH_NOT_PRECEDENCE'" + c_ev="$c_ev ) DEFAULT '' NOT NULL," + c_ev="$c_ev comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default ''," + c_ev="$c_ev PRIMARY KEY (db, name)" + c_ev="$c_ev ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';" +fi + cat << END_OF_DATA use mysql; -set table_type=myisam; +set storage_engine=myisam; $c_d $i_d @@ -741,6 +874,12 @@ $i_u $c_f $i_f +$c_pl +$i_pl + +$c_s +$i_s + $c_t $c_c @@ -763,5 +902,10 @@ $i_tzls $c_p $c_pp +$c_gl +$c_sl +$c_ev +CREATE TABLE IF NOT EXISTS mysql.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; + END_OF_DATA diff --git a/scripts/mysql_explain_log.sh b/scripts/mysql_explain_log.sh deleted file mode 100644 index fd468fdf091..00000000000 --- a/scripts/mysql_explain_log.sh +++ /dev/null @@ -1,394 +0,0 @@ -#!@PERL@ -use strict; -use warnings; -use DBI; - -use Getopt::Long; -$Getopt::Long::ignorecase=0; - -print "explain_log provided by http://www.mobile.de\n"; -print "=========== ================================\n"; - -my $Param={}; - -$Param->{host}=''; -$Param->{user}=''; -$Param->{password}=''; -$Param->{PrintError}=0; -$Param->{socket}=''; - -if (!GetOptions ('date|d:i' => \$Param->{ViewDate}, - 'host|h:s' => \$Param->{host}, - 'user|u:s' => \$Param->{user}, - 'password|p:s' => \$Param->{password}, - 'printerror|e:s' => \$Param->{PrintError}, - 'socket|s:s' => \$Param->{socket}, - )) { - ShowOptions(); -} -else { - $Param->{UpdateCount} = 0; - $Param->{SelectCount} = 0; - $Param->{IdxUseCount} = 0; - $Param->{LineCount} = 0; - - $Param->{Init} = 0; - $Param->{Field} = 0; - $Param->{Refresh} = 0; - $Param->{QueryCount} = 0; - $Param->{Statistics} =0; - - $Param->{Query} = undef; - $Param->{ALL} = undef ; - $Param->{Comment} = undef ; - - @{$Param->{Rows}} = (qw|possible_keys key type|); - - if ($Param->{ViewDate}) { - $Param->{View} = 0; - } - else { - $Param->{View} = 1; - } - - #print "Date=$Param->{ViewDate}, host=$Param->{host}, user=$Param->{user}, password=$Param->{password}\n"; - - $Param->{dbh}=DBI->connect("DBI:mysql:host=$Param->{host}".($Param->{socket}?";mysql_socket=$Param->{socket}":""),$Param->{user},$Param->{password},{PrintError=>0}); - if (DBI::err()) { - print "Error: " . DBI::errstr() . "\n"; - } - else { - $Param->{Start} = time; - while(<>) { - $Param->{LineCount} ++ ; - - if ($Param->{ViewDate} ) { - if (m/^(\d{6})\s+\d{1,2}:\d\d:\d\d\s.*$/) { # get date - #print "# $1 #\n"; - if ($1 == $Param->{ViewDate}) { - $Param->{View} = 1; - } - else { - $Param->{View} = 0; - } - } - } - if ($Param->{View} ) { - #print "->>>$_"; - - if (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Connect.+\s+on\s+(.*)$/i) { # get connection ID($2) and database($3) - #print "C-$1--$2--$3------\n"; - RunQuery($Param); - if (defined $3) { - $Param->{CID}->{$2} = $3 ; - #print "DB:$Param->{CID}->{$2} .. $2 .. $3 \n"; - } - } - - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Connect.+$/i) { # get connection ID($2) and database($3) - #print "\n <<<<<<<<<<<<<<<<<<----------------------------<<<<<<<<<<<<<<<< \n"; - #print "Connect \n"; - RunQuery($Param); - } - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Change user .*\s+on\s+(.*)$/i) { # get connection ID($2) and database($3) - #print "C-$1--$2--$3------\n"; - RunQuery($Param); - if (defined $3) { - $Param->{CID}->{$2} = $3 ; - #print "DB:$Param->{CID}->{$2} .. $2 .. $3 \n"; - } - } - - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Quit\s+$/i) { # remove connection ID($2) and querystring - #print "Q-$1--$2--------\n"; - RunQuery($Param); - delete $Param->{CID}->{$2} ; - } - - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(select.+)$/i) { # get connection ID($2) and querystring - #print "S1-$1--$2--$3------\n"; - RunQuery($Param); - unless ($Param->{CID}->{$2}) { - #print "Error: No Database for Handle: $2 found\n"; - } - else { - $Param->{DB}=$Param->{CID}->{$2}; - - my $s = "$3"; - $s =~ s/from\s/from $Param->{DB}./i; - $Param->{Query}="EXPLAIN $s"; - - #$s =~ m/from\s+(\w+[.]\w+)/i; - #$Param->{tab} =$1; - #print "-- $Param->{tab} -- $s --\n"; - } - } - - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(update.+)$/i) { # get connection ID($2) and querystring - #print "S2--$1--$2--$3------\n"; - RunQuery($Param); - unless ($Param->{CID}->{$2}) { - #print "Error: No Database for Handle: $2 found\n"; - } - else { - $Param->{DB}=$Param->{CID}->{$2}; - - my $ud = $3; - $ud =~ m/^update\s+(\w+).+(where.+)$/i; - $Param->{Query} ="EXPLAIN SELECT * FROM $1 $2"; - $Param->{Query} =~ s/from\s/from $Param->{DB}./i; - - #$Param->{Query} =~ m/from\s+(\w+[.]\w+)/i; - #$Param->{tab} =$1; - } - } - - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Statistics\s+(.*)$/i) { # get connection ID($2) and info? - $Param->{Statistics} ++; - #print "Statistics--$1--$2--$3------\n"; - RunQuery($Param); - } - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Query\s+(.+)$/i) { # get connection ID($2) - $Param->{QueryCount} ++; - #print "Query-NULL $3\n"; - RunQuery($Param); - } - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Refresh\s+(.+)$/i) { # get connection ID($2) - $Param->{Refresh} ++; - #print "Refresh\n"; - RunQuery($Param); - } - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Init\s+(.+)$/i) { # get connection ID($2) - $Param->{Init} ++; - #print "Init $3\n"; - RunQuery($Param); - } - elsif (m/^(\d{6}\s+\d{1,2}:\d\d:\d\d\s+|\s+)(\d+)\s+Field\s+(.+)$/i) { # get connection ID($2) - $Param->{Field} ++; - #print "Field $3\n"; - RunQuery($Param); - } - - elsif (m/^\s+(.+)$/ ) { # command could be some lines ... - #print "multi-lined ($1)\n"; - my ($A)=$1; - chomp $A; - $Param->{Query} .= " $1"; - #print "multi-lined ($1)<<$Param->{Query}>>\n"; - } - - - } - - } - - $Param->{dbh}->disconnect(); - - if (1 == 0) { - print "\nunclosed handles----------------------------------------\n"; - my $count=0; - foreach (sort keys %{$Param->{CID}}) { - print "$count | $_ : $Param->{CID}->{$_} \n"; - $count ++; - } - } - - print "\nIndex usage ------------------------------------\n"; - foreach my $t (sort keys %{$Param->{Data}}) { - print "\nTable\t$t: ---\n"; - foreach my $k (sort keys %{$Param->{Data}->{$t}}) { - print " count\t$k:\n"; - my %h = %{$Param->{Data}->{$t}->{$k}}; - foreach (sort {$h{$a} <=> $h{$b}} keys %h) { - print " $Param->{Data}->{$t}->{$k}->{$_}\t$_\n"; - } - } - } - - $Param->{AllCount}=0; - print "\nQueries causing table scans -------------------\n\n"; - foreach (@{$Param->{ALL}}) { - $Param->{AllCount} ++; - print "$_\n"; - } - print "Sum: $Param->{AllCount} table scans\n"; - - print "\nSummary ---------------------------------------\n\n"; - print "Select: \t$Param->{SelectCount} queries\n"; - print "Update: \t$Param->{UpdateCount} queries\n"; - print "\n"; - - print "Init: \t$Param->{Init} times\n"; - print "Field: \t$Param->{Field} times\n"; - print "Refresh: \t$Param->{Refresh} times\n"; - print "Query: \t$Param->{QueryCount} times\n"; - print "Statistics:\t$Param->{Statistics} times\n"; - print "\n"; - - print "Logfile: \t$Param->{LineCount} lines\n"; - print "Started: \t".localtime($Param->{Start})."\n"; - print "Finished: \t".localtime(time)."\n"; - - } -} - - -########################################################################### -# -# -# -sub RunQuery { - my $Param = shift ; - - if (defined $Param->{Query}) { - if (defined $Param->{DB} ) { - - $Param->{Query} =~ m/from\s+(\w+[.]\w+|\w+)/i; - $Param->{tab} =$1; - #print "||$Param->{tab} -- $Param->{Query}\n"; - - my $sth=$Param->{dbh}->prepare("USE $Param->{DB}"); - if (DBI::err()) { - if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";} - } - else { - $sth->execute(); - if (DBI::err()) { - if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";} - } - else { - $sth->finish(); - - $sth=$Param->{dbh}->prepare($Param->{Query}); - if (DBI::err()) { - if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";} - } - else { - #print "$Param->{Query}\n"; - $sth->execute(); - if (DBI::err()) { - if ($Param->{PrintError}) {print "[$Param->{LineCount}]<<$Param->{Query}>>\n";} - if ($Param->{PrintError}) {print "Error: ".DBI::errstr()."\n";} - } - else { - my $row = undef; - while ($row = $sth->fetchrow_hashref()) { - $Param->{SelectCount} ++; - - if (defined $row->{Comment}) { - push (@{$Param->{Comment}}, "$row->{Comment}; $_; $Param->{DB}; $Param->{Query}"); - } - foreach (@{$Param->{Rows}}) { - if (defined $row->{$_}) { - #if (($_ eq 'type' ) and ($row->{$_} eq 'ALL')) { - if ($row->{type} eq 'ALL') { - push (@{$Param->{ALL}}, "$Param->{Query}"); - #print ">> $row->{$_} $_ $Param->{DB} $Param->{Query}\n"; - } - $Param->{IdxUseCount} ++; - $Param->{Data}->{$Param->{tab}}->{$_}->{$row->{$_}} ++; - } - } - } - } - } - } - } - $sth->finish(); - } - $Param->{Query} = undef ; - } -} - -########################################################################### -# -# -# -sub ShowOptions { - print <<EOF; -Usage: $0 [OPTIONS] < LOGFILE - ---date=YYMMDD select only entrys of date --d=YYMMDD ---host=HOSTNAME db-host to ask --h=HOSTNAME ---user=USERNAME db-user --u=USERNAME ---password=PASSWORD password of db-user --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. - -EOF -} - -1; - -__END__ - -=pod - -=head1 NAME - -mysql_explain_log - -Feed a mysqld general logfile (created with mysqld --log) back into mysql -and collect statistics about index usage with EXPLAIN. - -=head1 DISCUSSION - -To optimize your indices, you have to know which ones are actually -used and what kind of queries are causing table scans. Especially -if you are generating your queries dynamically and you have a huge -amount of queries going on, this isn't easy. - -Use this tool to take a look at the effects of your real life queries. -Then add indices to avoid table scans and remove those which aren't used. - -=head1 USAGE - -mysql_explain_log [--date=YYMMDD] --host=dbhost] [--user=dbuser] [--password=dbpw] [--socket=/path/to/socket] < logfile - ---date=YYMMDD select only entrys of date - --d=YYMMDD - ---host=HOSTNAME db-host to ask - --h=HOSTNAME - ---user=USERNAME db-user - --u=USERNAME - ---password=PASSWORD password of db-user - --p=PASSWORD - ---socket=SOCKET change path to the socket - --s=SOCKET - ---printerror=1 enable error output - --e 1 - -=head1 EXAMPLE - -mysql_explain_log --host=localhost --user=foo --password=bar < /var/lib/mysql/mobile.log - -=head1 AUTHORS - - Stefan Nitz - Jan Willamowius <jan@willamowius.de>, http://www.willamowius.de - Dennis Haney <davh@davh.dk> (Added socket support) - -=head1 SEE ALSO - -mysql documentation - -=cut diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 910992191f3..932857890e6 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -160,11 +160,7 @@ s_echo() } 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, stored procedures, or" -s_echo "more secure passwords in 4.1" +s_echo "MySQL 5.1 and above." s_echo "" if test $verbose = 1 diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 5709fb96793..056761f3ad0 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -1,13 +1,12 @@ --- This script converts any old privilege tables to privilege tables suitable --- for MySQL 4.1 +# This script converts any old privilege tables to privilege tables suitable +# for this version of MySQL +# You can safely ignore all 'Duplicate column' and 'Unknown column' errors" +# 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! --- You can safely ignore all 'Duplicate column' and 'Unknown column' errors" --- 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' +# 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 storage_engine=MyISAM; @@ -19,9 +18,15 @@ CREATE TABLE IF NOT EXISTS func ( PRIMARY KEY (name) ) CHARACTER SET utf8 COLLATE utf8_bin; +CREATE TABLE IF NOT EXISTS plugin ( + name char(64) binary DEFAULT '' NOT NULL, + dl char(128) DEFAULT '' NOT NULL, + PRIMARY KEY (name) +) CHARACTER SET utf8 COLLATE utf8_bin; + ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; --- Detect whether or not we had the Grant_priv column +# Detect whether or not we had the Grant_priv column SET @hadGrantPriv:=0; SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%'; @@ -29,14 +34,14 @@ ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,a ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL; --- Fix privileges for old tables +# Fix privileges for old tables UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; UPDATE db SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0; --- --- The second alter changes ssl_type to new 4.0.2 format --- Adding columns needed by GRANT .. REQUIRE (openssl)" +# +# The second alter changes ssl_type to new 4.0.2 format +# Adding columns needed by GRANT .. REQUIRE (openssl)" ALTER TABLE user ADD ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci NOT NULL, @@ -45,9 +50,9 @@ ADD x509_issuer BLOB NOT NULL, ADD x509_subject BLOB NOT NULL; ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL; --- --- tables_priv --- +# +# tables_priv +# CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, @@ -62,7 +67,7 @@ CREATE TABLE IF NOT EXISTS tables_priv ( 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); @@ -84,9 +89,9 @@ ALTER TABLE tables_priv COLLATE utf8_general_ci DEFAULT '' NOT NULL, COMMENT='Table privileges'; --- --- columns_priv --- +# +# columns_priv +# CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) DEFAULT '' NOT NULL, Db char(64) DEFAULT '' NOT NULL, @@ -97,8 +102,9 @@ CREATE TABLE IF NOT EXISTS columns_priv ( 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; - --- Name change of Type -> Column_priv from MySQL 3.22.12 +# +# 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; @@ -117,15 +123,15 @@ 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. --- +# +# Add the new 'type' column to the func table. +# ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL; --- --- Change the user,db and host tables to current format --- +# +# Change the user,db and host tables to MySQL 4.0 format +# # Detect whether we had Show_db_priv SET @hadShowDbPriv:=0; @@ -140,30 +146,29 @@ ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTE ADD Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Execute_priv, ADD Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_slave_priv; --- Convert privileges so that users have similar privileges as before +# Convert privileges so that users have similar privileges as before UPDATE user SET Show_db_priv= Select_priv, Super_priv=Process_priv, Execute_priv=Process_priv, Create_tmp_table_priv='Y', Lock_tables_priv='Y', Repl_slave_priv=file_priv, Repl_client_priv=File_priv where user<>"" AND @hadShowDbPriv = 0; --- Add fields that can be used to limit number of questions and connections --- for some users. - +# Add fields that can be used to limit number of questions and connections +# for some users. ALTER TABLE user 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; --- --- Add Create_tmp_table_priv and Lock_tables_priv to db and host --- +# +# Add Create_tmp_table_priv and Lock_tables_priv to db and host +# ALTER TABLE db 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 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; +ADD Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL, +ADD Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL; alter table user change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL; @@ -173,8 +178,8 @@ 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'; --- Convert all tables to UTF-8 with binary collation --- and reset all char columns to correct width +# 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 '', @@ -375,6 +380,22 @@ ALTER TABLE procs_priv MODIFY Timestamp timestamp(14) AFTER Proc_priv; -- +-- servers +-- +CREATE TABLE servers ( + Server_name char(64) NOT NULL DEFAULT '', + Host char(64) NOT NULL DEFAULT '', + Db char(64) NOT NULL DEFAULT '', + Username char(64) NOT NULL DEFAULT '', + Password char(64) NOT NULL DEFAULT '', + Port INT(4) NOT NULL DEFAULT '0', + Socket char(64) NOT NULL DEFAULT '', + Wrapper char(64) NOT NULL DEFAULT '', + Owner char(64) NOT NULL DEFAULT '', + PRIMARY KEY (Server_name)) + CHARACTER SET utf8 comment='MySQL Foreign Servers table'; + +-- -- help_topic -- CREATE TABLE IF NOT EXISTS help_topic ( @@ -424,7 +445,7 @@ Time_zone_id int unsigned NOT NULL auto_increment, Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY TzId (Time_zone_id) ) CHARACTER SET utf8 comment='Time zones'; --- Make enum field case-insensitive +# Make enum field case-insensitive ALTER TABLE time_zone MODIFY Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; @@ -566,6 +587,178 @@ ALTER TABLE proc MODIFY db MODIFY comment char(64) collate utf8_bin DEFAULT '' NOT NULL; +# +# Create missing log tables (5.1) +# + +delimiter // +CREATE PROCEDURE create_log_tables() +BEGIN + DECLARE is_csv_enabled int DEFAULT 0; + SELECT @@have_csv = 'YES' INTO is_csv_enabled; + IF (is_csv_enabled) THEN + CREATE TABLE IF NOT EXISTS general_log ( + event_time TIMESTAMP NOT NULL, + user_host MEDIUMTEXT, + thread_id INTEGER, + server_id INTEGER, + command_type VARCHAR(64), + argument MEDIUMTEXT + ) engine=CSV CHARACTER SET utf8 comment='General log'; + CREATE TABLE IF NOT EXISTS slow_log ( + start_time TIMESTAMP NOT NULL, + user_host MEDIUMTEXT NOT NULL, + query_time TIME NOT NULL, + lock_time TIME NOT NULL, + rows_sent INTEGER NOT NULL, + rows_examined INTEGER NOT NULL, + db VARCHAR(512), + last_insert_id INTEGER, + insert_id INTEGER, + server_id INTEGER, + sql_text MEDIUMTEXT NOT NULL + ) engine=CSV CHARACTER SET utf8 comment='Slow log'; + END IF; +END// +delimiter ; +CALL create_log_tables(); +DROP PROCEDURE create_log_tables; +# +# EVENT table +# + + +CREATE TABLE event ( + db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', + name char(64) CHARACTER SET utf8 NOT NULL default '', + body longblob NOT NULL, + definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', + execute_at DATETIME default NULL, + interval_value int(11) default NULL, + interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK', + 'SECOND','MICROSECOND', 'YEAR_MONTH','DAY_HOUR', + 'DAY_MINUTE','DAY_SECOND', + 'HOUR_MINUTE','HOUR_SECOND', + 'MINUTE_SECOND','DAY_MICROSECOND', + 'HOUR_MICROSECOND','MINUTE_MICROSECOND', + 'SECOND_MICROSECOND') default NULL, + created TIMESTAMP NOT NULL, + modified TIMESTAMP NOT NULL, + last_executed DATETIME default NULL, + starts DATETIME default NULL, + ends DATETIME default NULL, + status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', + on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', + 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) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', + PRIMARY KEY (db,name) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; + + +# +# EVENT privilege +# + +SET @hadEventPriv := 0; +SELECT @hadEventPriv :=1 FROM user WHERE Event_priv LIKE '%'; + +ALTER TABLE user add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv; +ALTER TABLE user MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv; + +ALTER TABLE db add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL; +ALTER TABLE db MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL; + +ALTER TABLE event DROP PRIMARY KEY; +ALTER TABLE event ADD PRIMARY KEY(db, name); +ALTER TABLE event ADD 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 AFTER on_completion; + +UPDATE user SET Event_priv=Super_priv WHERE @hadEventPriv = 0; +ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default ''; + +# +# TRIGGER privilege +# + +SET @hadTriggerPriv := 0; +SELECT @hadTriggerPriv :=1 FROM user WHERE Trigger_priv LIKE '%'; + +ALTER TABLE user ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Event_priv; +ALTER TABLE user MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Event_priv; + +ALTER TABLE host ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; +ALTER TABLE host MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; + +ALTER TABLE db ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; +ALTER TABLE db MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; + +ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL; + +UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0; + +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; + # Activate the new, possible modified privilege tables # This should not be needed, but gives us some extra testing that the above # changes was correct diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index e43b586054e..354b338fbf2 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -226,7 +226,7 @@ then fi mysqld_install_cmd_line="$mysqld $defaults $mysqld_opt --bootstrap \ --skip-grant-tables --basedir=$basedir --datadir=$ldata --skip-innodb \ ---skip-bdb --skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K" +--skip-ndbcluster $args --max_allowed_packet=8M --net_buffer_length=16K" if $scriptdir/mysql_create_system_tables $create_option $mdata $hostname $windows \ | eval "$mysqld_install_cmd_line" then @@ -275,9 +275,6 @@ then echo "You can start the MySQL daemon with:" echo "cd @prefix@ ; $bindir/mysqld_safe &" echo - echo "You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:" - echo "cd sql-bench ; perl run-all-tests" - echo fi echo "Please report any problems with the @scriptdir@/mysqlbug script!" echo diff --git a/scripts/mysql_prepare_privilege_tables_for_5.sql b/scripts/mysql_prepare_privilege_tables_for_5.sql deleted file mode 100644 index a9b6d43aee0..00000000000 --- a/scripts/mysql_prepare_privilege_tables_for_5.sql +++ /dev/null @@ -1,53 +0,0 @@ - -use mysql; - --- --- merging `host` table and `db` --- - -UPDATE IGNORE host SET Host='%' WHERE Host=''; -DELETE FROM host WHERE Host=''; - -INSERT IGNORE INTO db (User, Host, Select_priv, Insert_priv, Update_priv, - Delete_priv, Create_priv, Drop_priv, Grant_priv, References_priv, - Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv) - SELECT d.User, h.Host, - (d.Select_priv = 'Y' || h.Select_priv = 'Y') + 1, - (d.Insert_priv = 'Y' || h.Select_priv = 'Y') + 1, - (d.Update_priv = 'Y' || h.Update_priv = 'Y') + 1, - (d.Delete_priv = 'Y' || h.Delete_priv = 'Y') + 1, - (d.Create_priv = 'Y' || h.Create_priv = 'Y') + 1, - (d.Drop_priv = 'Y' || h.Drop_priv = 'Y') + 1, - (d.Grant_priv = 'Y' || h.Grant_priv = 'Y') + 1, - (d.References_priv = 'Y' || h.References_priv = 'Y') + 1, - (d.Index_priv = 'Y' || h.Index_priv = 'Y') + 1, - (d.Alter_priv = 'Y' || h.Alter_priv = 'Y') + 1, - (d.Create_tmp_table_priv = 'Y' || h.Create_tmp_table_priv = 'Y') + 1, - (d.Lock_tables_priv = 'Y' || h.Lock_tables_priv = 'Y') + 1 - FROM db d, host h WHERE d.Host = ''; - -UPDATE IGNORE db SET Host='%' WHERE Host = ''; -DELETE FROM db WHERE Host=''; - -TRUNCATE TABLE host; - --- --- Adding missing users to `user` table --- --- note that invalid password causes the user to be skipped during the --- load of grand tables (at mysqld startup) thus three following inserts --- do not affect anything - -INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM db; -INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM tables_priv; -INSERT IGNORE user (User, Host, Password) SELECT User, Host, "*" FROM columns_priv; - -SELECT DISTINCT -"There are user accounts with the username 'PUBLIC'. In the SQL-1999 -(or later) standard this name is reserved for PUBLIC role and can -not be used as a valid user name. Consider renaming these accounts before -upgrading to MySQL-5.0. -These accounts are:" x -FROM user WHERE user='PUBLIC'; -SELECT CONCAT(user,'@',host) FROM user WHERE user='PUBLIC'; - diff --git a/scripts/mysql_tableinfo.sh b/scripts/mysql_tableinfo.sh deleted file mode 100644 index 2ed7e381fa3..00000000000 --- a/scripts/mysql_tableinfo.sh +++ /dev/null @@ -1,494 +0,0 @@ -#!@PERL@ -w - -use strict; -use Getopt::Long; -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. - -This is version 1.1. - -=head1 SYNOPSIS - - mysql_tableinfo [OPTIONS] database_to_write [database_like_wild] [table_like_wild] - - Do not backquote (``) database_to_write, - and do not quote ('') database_like_wild or table_like_wild - - Examples: - - mysql_tableinfo info - - mysql_tableinfo info this_db - - mysql_tableinfo info %a% b% - - mysql_tableinfo info --clear-only - - mysql_tableinfo info --col --idx --table-status - -=cut - -# Documentation continued at end of file - - -sub usage { - die @_,"\nExecute 'perldoc $0' for documentation\n"; -} - -my %opt = ( - 'user' => scalar getpwuid($>), - 'host' => "localhost", - 'prefix' => "", #to avoid 'use of uninitialized value...' -); -Getopt::Long::Configure(qw(no_ignore_case)); # disambuguate -p and -P -GetOptions( \%opt, - "help", - "user|u=s", - "password|p=s", - "host|h=s", - "port|P=s", - "socket|S=s", - "tbl-status", - "col", - "idx", - "clear", - "clear-only", - "prefix=s", - "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); -if (@ARGV==0) -{ - usage("Not enough arguments"); -} -$db_to_write="`$ARGV[0]`"; shift @ARGV; -$db_like_wild=($ARGV[0])?$ARGV[0]:"%"; shift @ARGV; -$tbl_like_wild=($ARGV[0])?$ARGV[0]:"%"; shift @ARGV; -if (@ARGV>0) { usage("Too many arguments"); } - -$0 = $1 if $0 =~ m:/([^/]+)$:; - -my $info_db="`".$opt{'prefix'}."db`"; -my $info_tbl="`".$opt{'prefix'}."tbl". - (($opt{'tbl-status'})?"_status":"")."`"; -my $info_col="`".$opt{'prefix'}."col`"; -my $info_idx="`".$opt{'prefix'}."idx`"; - - -# --- connect to the database --- - -my $dsn = ";host=$opt{'host'}"; -$dsn .= ";port=$opt{'port'}" if $opt{'port'}; -$dsn .= ";mysql_socket=$opt{'socket'}" if $opt{'socket'}; - -my $dbh = DBI->connect("dbi:mysql:$dsn;mysql_read_default_group=perl", - $opt{'user'}, $opt{'password'}, -{ - RaiseError => 1, - PrintError => 0, - AutoCommit => 1, -}); - -$db_like_wild=$dbh->quote($db_like_wild); -$tbl_like_wild=$dbh->quote($tbl_like_wild); - -#Ask - -if (!$opt{'quiet'}) -{ - 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 ... - -on the following tables :\n"; - - foreach (($info_db, $info_tbl), - (($opt{'col'})?$info_col:()), - (($opt{'idx'})?$info_idx:())) - { - print(" $db_to_write.$_\n"); - } - print "\nContinue (you can skip this confirmation step with --quiet) ? (y|n) [n]"; - if (<STDIN> !~ /^\s*y\s*$/i) - { - print "Nothing done!\n";exit; - } -} - -if ($opt{'clear'} or $opt{'clear-only'}) -{ -#do not drop the $db_to_write database ! - foreach (($info_db, $info_tbl), - (($opt{'col'})?$info_col:()), - (($opt{'idx'})?$info_idx:())) - { - $dbh->do("DROP TABLE IF EXISTS $db_to_write.$_"); - } - if ($opt{'clear-only'}) - { - print "Wrote to database $db_to_write .\n" unless ($opt{'quiet'}); - exit; - } -} - - -my %sth; -my %extra_col_desc; -my %row; -my %done_create_table; - -#create the $db_to_write database -$dbh->do("CREATE DATABASE IF NOT EXISTS $db_to_write"); -$dbh->do("USE $db_to_write"); - -#get databases -$sth{'db'}=$dbh->prepare("SHOW DATABASES LIKE $db_like_wild"); -$sth{'db'}->execute; - -#create $info_db which will receive info about databases. -#Ensure that the first column to be called "Database" (as SHOW DATABASES LIKE -#returns a varying -#column name (of the form "Database (%...)") which is not suitable) -$extra_col_desc{'db'}=do_create_table("db",$info_db,undef,"`Database`"); -#we'll remember the type of the `Database` column (as returned by -#SHOW DATABASES), which we will need when creating the next tables. - -#clear out-of-date info from this table -$dbh->do("DELETE FROM $info_db WHERE `Database` LIKE $db_like_wild"); - - -while ($row{'db'}=$sth{'db'}->fetchrow_arrayref) #go through all databases -{ - -#insert the database name - $dbh->do("INSERT INTO $info_db VALUES(" - .join(',' , ( map $dbh->quote($_), @{$row{'db'}} ) ).")" ); - -#for each database, get tables - - $sth{'tbl'}=$dbh->prepare("SHOW TABLE" - .( ($opt{'tbl-status'}) ? - " STATUS" - : "S" ) - ." from `$row{'db'}->[0]` LIKE $tbl_like_wild"); - $sth{'tbl'}->execute; - unless ($done_create_table{$info_tbl}) - -#tables must be created only once, and out-of-date info must be -#cleared once - { - $done_create_table{$info_tbl}=1; - $extra_col_desc{'tbl'}= - do_create_table("tbl",$info_tbl, -#add an extra column (database name) at the left -#and ensure that the table name will be called "Table" -#(this is unncessesary with -#SHOW TABLE STATUS, but necessary with SHOW TABLES (which returns a column -#named "Tables_in_...")) - "`Database` ".$extra_col_desc{'db'},"`Table`"); - $dbh->do("DELETE FROM $info_tbl WHERE `Database` LIKE $db_like_wild AND `Table` LIKE $tbl_like_wild"); - } - - while ($row{'tbl'}=$sth{'tbl'}->fetchrow_arrayref) - { - $dbh->do("INSERT INTO $info_tbl VALUES(" - .$dbh->quote($row{'db'}->[0])."," - .join(',' , ( map $dbh->quote($_), @{$row{'tbl'}} ) ).")"); - -#for each table, get columns... - - if ($opt{'col'}) - { - $sth{'col'}=$dbh->prepare("SHOW COLUMNS FROM `$row{'tbl'}->[0]` FROM `$row{'db'}->[0]`"); - $sth{'col'}->execute; - unless ($done_create_table{$info_col}) - { - $done_create_table{$info_col}=1; - do_create_table("col",$info_col, - "`Database` ".$extra_col_desc{'db'}."," - ."`Table` ".$extra_col_desc{'tbl'}."," - ."`Seq_in_table` BIGINT(3)"); -#We need to add a sequence number (1 for the first column of the table, -#2 for the second etc) so that users are able to retrieve columns in order -#if they want. This is not needed for INDEX -#(where there is already Seq_in_index) - $dbh->do("DELETE FROM $info_col WHERE `Database` - LIKE $db_like_wild - AND `Table` LIKE $tbl_like_wild"); - } - my $col_number=0; - while ($row{'col'}=$sth{'col'}->fetchrow_arrayref) - { - $dbh->do("INSERT INTO $info_col VALUES(" - .$dbh->quote($row{'db'}->[0])."," - .$dbh->quote($row{'tbl'}->[0])."," - .++$col_number."," - .join(',' , ( map $dbh->quote($_), @{$row{'col'}} ) ).")"); - } - } - -#and get index. - - if ($opt{'idx'}) - { - $sth{'idx'}=$dbh->prepare("SHOW INDEX FROM `$row{'tbl'}->[0]` FROM `$row{'db'}->[0]`"); - $sth{'idx'}->execute; - unless ($done_create_table{$info_idx}) - { - $done_create_table{$info_idx}=1; - do_create_table("idx",$info_idx, - "`Database` ".$extra_col_desc{'db'}); - $dbh->do("DELETE FROM $info_idx WHERE `Database` - LIKE $db_like_wild - AND `Table` LIKE $tbl_like_wild"); - } - while ($row{'idx'}=$sth{'idx'}->fetchrow_arrayref) - { - $dbh->do("INSERT INTO $info_idx VALUES(" - .$dbh->quote($row{'db'}->[0])."," - .join(',' , ( map $dbh->quote($_), @{$row{'idx'}} ) ).")"); - } - } - } -} - -print "Wrote to database $db_to_write .\n" unless ($opt{'quiet'}); -exit; - - -sub do_create_table -{ - my ($sth_key,$target_tbl,$extra_col_desc,$first_col_name)=@_; - my $create_table_query=$extra_col_desc; - my ($i,$first_col_desc,$col_desc); - - for ($i=0;$i<$sth{$sth_key}->{NUM_OF_FIELDS};$i++) - { - if ($create_table_query) { $create_table_query.=", "; } - $col_desc=$sth{$sth_key}->{mysql_type_name}->[$i]; - if ($col_desc =~ /char|int/i) - { - $col_desc.="($sth{$sth_key}->{PRECISION}->[$i])"; - } - elsif ($col_desc =~ /decimal|numeric/i) #(never seen that) - { - $col_desc.= - "($sth{$sth_key}->{PRECISION}->[$i],$sth{$sth_key}->{SCALE}->[$i])"; - } - elsif ($col_desc !~ /date/i) #date and datetime are OK, - #no precision or scale for them - { - warn "unexpected column type '$col_desc' -(neither 'char','int','decimal|numeric') -when creating $target_tbl, hope table creation will go OK\n"; - } - if ($i==0) {$first_col_desc=$col_desc}; - $create_table_query.= - ( ($i==0 and $first_col_name) ? - "$first_col_name " :"`$sth{$sth_key}->{NAME}->[$i]` " ) - .$col_desc; - } -if ($create_table_query) -{ - $dbh->do("CREATE TABLE IF NOT EXISTS $target_tbl ($create_table_query)"); -} -return $first_col_desc; -} - -__END__ - - -=head1 DESCRIPTION - -mysql_tableinfo asks a MySQL server information about its -databases, tables, table columns and index, and stores this -in tables called `db`, `tbl` (or `tbl_status`), `col`, `idx` -(with an optional prefix specified with --prefix). -After that, you can query these information tables, for example -to build your admin scripts with SQL queries, like - -SELECT CONCAT("CHECK TABLE ",`database`,".",`table`," EXTENDED;") -FROM info.tbl WHERE ... ; - -as people usually do with some other RDBMS -(note: to increase the speed of your queries on the info tables, -you may add some index on them). - -The database_like_wild and table_like_wild instructs the program -to gather information only about databases and tables -whose names match these patterns. If the info -tables already exist, their rows matching the patterns are simply -deleted and replaced by the new ones. That is, -old rows not matching the patterns are not touched. -If the database_like_wild and table_like_wild arguments -are not specified on the command-line they default to "%". - -The program : - -- does CREATE DATABASE IF NOT EXISTS database_to_write -where database_to_write is the database name specified on the command-line. - -- does CREATE TABLE IF NOT EXISTS database_to_write.`db` - -- fills database_to_write.`db` with the output of -SHOW DATABASES LIKE database_like_wild - -- does CREATE TABLE IF NOT EXISTS database_to_write.`tbl` -(respectively database_to_write.`tbl_status` -if the --tbl-status option is on) - -- for every found database, -fills database_to_write.`tbl` (respectively database_to_write.`tbl_status`) -with the output of -SHOW TABLES FROM found_db LIKE table_like_wild -(respectively SHOW TABLE STATUS FROM found_db LIKE table_like_wild) - -- if the --col option is on, - * does CREATE TABLE IF NOT EXISTS database_to_write.`col` - * for every found table, - fills database_to_write.`col` with the output of - SHOW COLUMNS FROM found_tbl FROM found_db - -- if the --idx option is on, - * does CREATE TABLE IF NOT EXISTS database_to_write.`idx` - * for every found table, - fills database_to_write.`idx` with the output of - SHOW INDEX FROM found_tbl FROM found_db - -Some options may modify this general scheme (see below). - -As mentioned, the contents of the info tables are the output of -SHOW commands. In fact the contents are slightly more complete : - -- the `tbl` (or `tbl_status`) info table - has an extra column which contains the database name, - -- the `col` info table - has an extra column which contains the table name, - and an extra column which contains, for each described column, - the number of this column in the table owning it (this extra column - is called `Seq_in_table`). `Seq_in_table` makes it possible for you - to retrieve your columns in sorted order, when you are querying - the `col` table. - -- the `index` info table - has an extra column which contains the database name. - -Caution: info tables contain certain columns (e.g. -Database, Table, Null...) whose names, as they are MySQL reserved words, -need to be backquoted (`...`) when used in SQL statements. - -Caution: as information fetching and info tables filling happen at the -same time, info tables may contain inaccurate information about -themselves. - -=head1 OPTIONS - -=over 4 - -=item --clear - -Does DROP TABLE on the info tables (only those that the program is -going to fill, for example if you do not use --col it won't drop -the `col` table) and processes normally. Does not drop database_to_write. - -=item --clear-only - -Same as --clear but exits after the DROPs. - -=item --col - -Adds columns information (into table `col`). - -=item --idx - -Adds index information (into table `idx`). - -=item --prefix prefix - -The info tables are named from the concatenation of prefix and, -respectively, db, tbl (or tbl_status), col, idx. Do not quote ('') -or backquote (``) prefix. - -=item -q, --quiet - -Does not warn you about what the script is going to do (DROP TABLE etc) -and does not ask for a confirmation before starting. - -=item --tbl-status - -Instead of using SHOW TABLES, uses SHOW TABLE STATUS -(much more complete information, but slower). - -=item --help - -Display helpscreen and exit - -=item -u, --user=# - -user for database login if not current user. Give a user -who has sufficient privileges (CREATE, ...). - -=item -p, --password=# - -password to use when connecting to server - -=item -h, --host=# - -host to connect to - -=item -P, --port=# - -port to use when connecting to server - -=item -S, --socket=# - -UNIX domain socket to use when connecting to server - -=head1 WARRANTY - -This software is free and comes without warranty of any kind. - -Patches adding bug fixes, documentation and new features are welcome. - -=head1 TO DO - -Nothing: starting from MySQL 5.0, this program is replaced by the -INFORMATION_SCHEMA pseudo-database. - -=head1 AUTHOR - -2002-06-18 Guilhem Bichot (guilhem.bichot@mines-paris.org) - -And all the authors of mysqlhotcopy, which served as a model for -the structure of the program. diff --git a/scripts/mysql_upgrade_shell.sh b/scripts/mysql_upgrade_shell.sh deleted file mode 100644 index c9f375b6c5b..00000000000 --- a/scripts/mysql_upgrade_shell.sh +++ /dev/null @@ -1,203 +0,0 @@ -#!/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_safe-watch.sh b/scripts/mysqld_safe-watch.sh deleted file mode 100644 index c837ba9a118..00000000000 --- a/scripts/mysqld_safe-watch.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/sh -# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -# This file is public domain and comes with NO WARRANTY of any kind -# -# scripts to start the MySQL demon and restart it if it dies unexpectedly -# -# This should be executed in the MySQL base directory if you are using a -# binary installation that has other paths than you are using. -# -# mysql.server works by first doing a cd to the base directory and from there -# executing mysqld_safe - -# Check if we are starting this relative (for the binary release) -if test -f ./data/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \ - -x ./bin/mysqld -then - MY_BASEDIR_VERSION=`pwd` # Where bin, share and data is - DATADIR=$MY_BASEDIR_VERSION/data # Where the databases are - ledir=$MY_BASEDIR_VERSION/bin # Where mysqld are -# Check if this is a 'moved install directory' -elif test -f ./var/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \ - -x ./libexec/mysqld -then - MY_BASEDIR_VERSION=`pwd` # Where libexec, share and var is - DATADIR=$MY_BASEDIR_VERSION/var # Where the databases are - ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld are -else - MY_BASEDIR_VERSION=/usr/local/mysql - DATADIR=/usr/local/mysql/var - ledir=/usr/local/mysql/libexec -fi - -hostname=`@HOSTNAME@` -pidfile=$DATADIR/$hostname.pid -log=$DATADIR/$hostname.log -err=$DATADIR/$hostname.err -lockfile=$DATADIR/$hostname.lock - -# -# If there exists an old pid file, check if the demon is already running -# Note: The switches to 'ps' may depend on your operating system - -if test -f $pidfile -then - PID=`cat $pidfile` - if /bin/kill -0 $PID - then - if /bin/ps -p $PID | grep mysqld > /dev/null - then # The pid contains a mysqld process - echo "A mysqld process already exists" - echo "A mysqld process already exists at " `date` >> $log - exit 1; - fi - fi - rm -f $pidfile - if test -f $pidfile - then - echo "Fatal error: Can't remove the pid file: $pidfile" - echo "Fatal error: Can't remove the pid file: $pidfile at " `date` >> $log - echo "Please remove it manually and start $0 again" - echo "mysqld demon not started" - exit 1; - fi -fi - -echo "Starting mysqld demon with databases from $DATADIR" - -#Default communication ports -#MYSQL_TCP_PORT=3306 -if test -z "$MYSQL_UNIX_PORT" -then - MYSQL_UNIX_PORT="/tmp/mysql.sock" - export MYSQL_UNIX_PORT -fi -#export MYSQL_TCP_PORT - -# Does this work on all systems? -#if type ulimit | grep "shell builtin" > /dev/null -#then -# ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems -#fi - -echo "mysqld started on " `date` >> $log -bin/zap -f $lockfile < /dev/null > /dev/null 2>&1 -rm -f $lockfile -$MY_BASEDIR_VERSION/bin/watchdog_mysqld $lockfile $pidfile $MY_BASEDIR_VERSION/bin $DATADIR 3 10 >> $err 2>&1 & -restart_pid=$! - -while true -do - rm -f $MYSQL_UNIX_PORT $pidfile # Some extra safety - lockfile -1 -r10 $lockfile >/dev/null 2>&1 - if test "$#" -eq 0 - then - nohup $ledir/mysqld --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR \ - --skip-external-locking >> $err 2>&1 & - else - nohup $ledir/mysqld --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR \ - --skip-external-locking "$@" >> $err 2>&1 & - fi - pid=$! - rm -f $lockfile - wait $pid; - - lockfile -1 -r10 $lockfile >/dev/null 2>&1 - rm -f $lockfile - if test ! -f $pidfile # This is removed if normal shutdown - then - break; - fi - if true - then - # Test if one proces was hanging. - # This is only a fix for Linux (running as base 3 mysqld processes) - # but should work for the rest of the servers. - # The only thing is ps x => redhat 5 gives warnings when using ps -x. - # kill -9 is used or the proces won't react on the kill. - numofproces=`ps x | grep -v "grep" | grep -c $ledir/mysqld` - echo -e "\nNumber of processes running now: $numofproces" | tee -a $log - I=1 - while test "$I" -le "$numofproces" - do - PROC=`ps x | grep $ledir/mysqld | grep -v "grep" | tail -1` - for T in $PROC - do - break - done - # echo "TEST $I - $T **" - if kill -9 $T - then - echo "mysqld proces hanging, pid $T - killed" | tee -a $log - else - break - fi - I=`expr $I + 1` - done - fi - echo "mysqld restarted" | tee -a $log - # Check all tables and repair any wrong tables. - $MY_BASEDIR_VERSION/bin/isamchk -sf $DATADIR/*/*.ISM >> $err 2>&1 -done -if test $restart_pid -gt 0 -then - kill $restart_pid > /dev/null 2>&1 - sleep 1; - kill -9 $restart_pid > /dev/null 2>&1 -fi - -echo -n "mysqld ended on " `date` >> $log -echo "mysqld demon ended" diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 02a961dc3ec..91d53c412f7 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -31,7 +31,6 @@ 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 - --log-error=FILE Log errors to the specified log file --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 @@ -46,6 +45,11 @@ EOF exit 1 } +shell_quote_string() { + # This sed command makes sure that any special chars are quoted, + # so the arg gets passed exactly to the server. + echo "$1" | sed -e 's,\([^a-zA-Z0-9/_.=-]\),\\\1,g' +} parse_arguments() { # We only need to pass arguments through to the server if we don't @@ -69,14 +73,14 @@ parse_arguments() { --pid-file=*) pid_file=`echo "$arg" | sed -e "s;--pid-file=;;"` ;; --user=*) user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1 ;; - # these two might have been set in a [mysqld_safe] section of my.cnf + # these might have been set in a [mysqld_safe] section of my.cnf # they are added to mysqld command line to override settings from my.cnf + --log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;; --socket=*) mysql_unix_port=`echo "$arg" | sed -e "s;--socket=;;"` ;; --port=*) mysql_tcp_port=`echo "$arg" | sed -e "s;--port=;;"` ;; # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! --ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;; - --log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;; --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; ;; @@ -97,9 +101,7 @@ parse_arguments() { *) 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'` + append_arg_to_args "$arg" fi ;; esac @@ -194,6 +196,10 @@ else print_defaults="my_print_defaults" fi +append_arg_to_args () { + args="$args "`shell_quote_string "$1"` +} + args= SET_USER=2 parse_arguments `$print_defaults $defaults --loose-verbose mysqld server` @@ -213,15 +219,10 @@ then chown $user $mysql_unix_port_dir fi -# Use the mysqld-max binary by default if the user doesn't specify a binary +# If the user doesn't specify a binary, we assume name "mysqld" if test -z "$MYSQLD" then - if test -x $ledir/mysqld-max - then - MYSQLD=mysqld-max - else - MYSQLD=mysqld - fi + MYSQLD=mysqld fi if test ! -x $ledir/$MYSQLD @@ -244,15 +245,39 @@ else * ) pid_file="$DATADIR/$pid_file" ;; esac fi -test -z "$err_log" && err_log=$DATADIR/`@HOSTNAME@`.err +append_arg_to_args "--pid-file=$pid_file" + +if [ -n "$err_log" ] +then + # mysqld adds ".err" if there is no extension on the --log-err + # argument; must match that here, or mysqld_safe will write to a + # different log file than mysqld + + # mysqld does not add ".err" to "--log-error=foo."; it considers a + # trailing "." as an extension + if expr "$err_log" : '.*\.[^/]*$' > /dev/null + then + : + else + err_log="$err_log".err + fi + + case "$err_log" in + /* ) ;; + * ) err_log="$DATADIR/$err_log" ;; + esac +else + err_log=$DATADIR/`@HOSTNAME@`.err +fi +append_arg_to_args "--log-error=$err_log" if test -n "$mysql_unix_port" then - args="--socket=$mysql_unix_port $args" + append_arg_to_args "--socket=$mysql_unix_port" fi if test -n "$mysql_tcp_port" then - args="--port=$mysql_tcp_port $args" + append_arg_to_args "--port=$mysql_tcp_port" fi if test $niceness -eq 0 @@ -319,7 +344,7 @@ then if test -n "$open_files" then ulimit -n $open_files - args="--open-files-limit=$open_files $args" + append_arg_to_args "--open-files-limit=$open_files" fi fi @@ -380,12 +405,18 @@ echo "`date +'%y%m%d %H:%M:%S mysqld started'`" >> $err_log while true do rm -f $safe_mysql_unix_port $pid_file # Some extra safety - if test -z "$args" - then - $NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ >> $err_log 2>&1 - else - eval "$NOHUP_NICENESS $ledir/$MYSQLD $defaults --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR $USER_OPTION --pid-file=$pid_file @MYSQLD_DEFAULT_SWITCHES@ $args >> $err_log 2>&1" - fi + + cmd="$NOHUP_NICENESS" + + for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ + "--datadir=$DATADIR" "$USER_OPTION" + do + cmd="$cmd "`shell_quote_string "$i"` + done + cmd="$cmd $args >> "`shell_quote_string "$err_log"`" 2>&1" + #echo "Running mysqld: [$cmd]" + eval "$cmd" + if test ! -f $pid_file # This is removed if normal shutdown then echo "STOPPING server from pid file $pid_file" |