diff options
author | Guilhem Bichot <guilhem@mysql.com> | 2009-08-04 13:25:19 +0200 |
---|---|---|
committer | Guilhem Bichot <guilhem@mysql.com> | 2009-08-04 13:25:19 +0200 |
commit | b57e4dbd88671df86e2cf39aff5178976d710b64 (patch) | |
tree | 32be2bfec3ca062c65566c60ecf59b673d1f97e9 /scripts | |
parent | 1a0c2153a036296785dcdfa7b5f4974515616e11 (diff) | |
parent | 94efc1c6b084ed531b513e70fb66e7b7a1186b56 (diff) | |
download | mariadb-git-b57e4dbd88671df86e2cf39aff5178976d710b64.tar.gz |
Creation of mysql-trunk = {summit + "Innodb plugin replacing the builtin"}:
bzr branch mysql-5.1-performance-version mysql-trunk # Summit
cd mysql-trunk
bzr merge mysql-5.1-innodb_plugin # which is 5.1 + Innodb plugin
bzr rm innobase # remove the builtin
Next step: build, test fixes.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mysql_convert_table_format.sh | 81 | ||||
-rw-r--r-- | scripts/mysql_find_rows.sh | 2 | ||||
-rw-r--r-- | scripts/mysql_fix_extensions.sh | 2 | ||||
-rw-r--r-- | scripts/mysql_setpermission.sh | 2 | ||||
-rw-r--r-- | scripts/mysql_zap.sh | 6 | ||||
-rw-r--r-- | scripts/mysqlaccess.sh | 2 | ||||
-rw-r--r-- | scripts/mysqld_multi.sh | 30 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 18 | ||||
-rw-r--r-- | scripts/mysqldumpslow.sh | 11 |
9 files changed, 100 insertions, 54 deletions
diff --git a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh index d15c7b28410..6f586d0e8e0 100644 --- a/scripts/mysql_convert_table_format.sh +++ b/scripts/mysql_convert_table_format.sh @@ -23,18 +23,30 @@ $opt_help=$opt_version=$opt_verbose=$opt_force=0; $opt_user=$opt_database=$opt_password=undef; $opt_host="localhost"; $opt_socket=""; -$opt_type="MYISAM"; +$opt_engine="MYISAM"; $opt_port=0; $exit_status=0; -GetOptions("force","help","host=s","password=s","user=s","type=s","verbose","version","socket=s", "port=i") || - usage(0); +GetOptions( + "e|engine|type=s" => \$opt_type, + "f|force" => \$opt_force, + "help|?" => \$opt_help, + "h|host=s" => \$opt_host, + "p|password=s" => \$opt_password, + "u|user=s" => \$opt_user, + "v|verbose" => \$opt_verbose, + "V|version" => \$opt_version, + "S|socket=s" => \$opt_socket, + "P|port=i" => \$opt_port +) || usage(0); + usage($opt_version) if ($#ARGV < 0 || $opt_help || $opt_version); + $opt_database=shift(@ARGV); -if (uc($opt_type) eq "HEAP") +if (grep { /^$opt_engine$/i } qw(HEAP MEMORY BLACKHOLE)) { - print "Converting to type HEAP would delete your tables; aborting\n"; + print "Converting to '$opt_engine' would delete your data; aborting\n"; exit(1); } @@ -54,21 +66,29 @@ $dbh = DBI->connect("DBI:mysql:$opt_database:${opt_host}$connect_opt", { PrintError => 0}) || die "Can't connect to database $opt_database: $DBI::errstr\n"; -if ($#ARGV < 0) +my @tables; + +push(@ARGV, "%") if(!@ARGV); + +foreach $pattern (@ARGV) { - # Fetch all table names from the database my ($sth,$row); - $sth=$dbh->prepare("show tables"); - $sth->execute || die "Can't get tables from $opt_database; $DBI::errstr\n"; + $sth=$dbh->prepare("SHOW TABLES LIKE ?"); + $rv= $sth->execute($pattern); + if(!int($rv)) + { + warn "Can't get tables matching '$pattern' from $opt_database; $DBI::errstr\n"; + exit(1) unless $opt_force; + } while (($row = $sth->fetchrow_arrayref)) { - push(@ARGV,$row->[0]); + push(@tables, $row->[0]); } $sth->finish; } print "Converting tables:\n" if ($opt_verbose); -foreach $table (@ARGV) +foreach $table (@tables) { my ($sth,$row); @@ -76,14 +96,15 @@ foreach $table (@ARGV) $sth=$dbh->prepare("show table status like '$table'"); if ($sth->execute && ($row = $sth->fetchrow_arrayref)) { - if (uc($row->[1]) eq uc($opt_type)) + if (uc($row->[1]) eq uc($opt_engine)) { - print "$table is already of type $opt_type; Ignored\n"; + print "$table already uses the '$opt_engine' engine; Ignored\n"; next; } } print "converting $table\n" if ($opt_verbose); - if (!$dbh->do("ALTER TABLE $table ENGINE=$opt_type")) + $table=~ s/`/``/g; + if (!$dbh->do("ALTER TABLE `$table` ENGINE=$opt_engine")) { print STDERR "Can't convert $table: Error $DBI::errstr\n"; exit(1) if (!$opt_force); @@ -103,43 +124,43 @@ sub usage print <<EOF; -Conversion of a MySQL tables to other table types. +Conversion of a MySQL tables to other storage engines - Usage: $0 database [tables] + Usage: $0 database [table[ table ...]] If no tables has been specifed, all tables in the database will be converted. + You can also use wildcards, ie "my%" The following options are available: ---force +-f, --force Continue even if there is some error. ---help or --Information +-?, --help Shows this help ---host='host name' (Default $opt_host) - Host name where the database server is located. +-e, --engine=ENGINE + Converts tables to the given storage engine (Default: $opt_engine) ---password='password' +-h, --host=HOST + Host name where the database server is located. (Default: $opt_host) + +-p, --password=PASSWORD Password for the current user. ---port=port +-P, --port=PORT TCP/IP port to connect to if host is not "localhost". ---socket='/path/to/socket' +-S, --socket=SOCKET Socket to connect with. ---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. - ---user='user_name' +-u, --user=USER User name to log into the SQL server. ---verbose +-v, --verbose This is a test specific option that is only used when debugging a test. Print more information about what is going on. ---version +-V, --version Shows the version of this program. EOF exit(1); diff --git a/scripts/mysql_find_rows.sh b/scripts/mysql_find_rows.sh index 77eacc8a9b4..967a8196ebd 100644 --- a/scripts/mysql_find_rows.sh +++ b/scripts/mysql_find_rows.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000, 2004 MySQL AB # # This program is free software; you can redistribute it and/or modify diff --git a/scripts/mysql_fix_extensions.sh b/scripts/mysql_fix_extensions.sh index fbc72406f5e..6d4e017f678 100644 --- a/scripts/mysql_fix_extensions.sh +++ b/scripts/mysql_fix_extensions.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # This is a utility for MySQL. It is not needed by any standard part # of MySQL. diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index b1ea26a9b7d..5fa6b969e39 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl ## Emacs, this is -*- perl -*- mode? :-) ## ## Permission setter for MySQL diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh index 6c05afb772c..f78212e2578 100644 --- a/scripts/mysql_zap.sh +++ b/scripts/mysql_zap.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # Copyright (C) 2000-2002, 2004 MySQL AB # # This program is free software; you can redistribute it and/or modify @@ -27,8 +27,8 @@ $opt_f= 0; $opt_t= 0; $opt_a = ""; -$BSD = -f '/vmunix' || $ENV{"OS"} eq "SunOS4" || $^O eq 'darwin'; -$LINUX = $^O eq 'linux'; +$BSD = -f '/vmunix' || $ENV{"OS"} eq "SunOS4"; +$LINUX = $^O eq 'linux' || $^O eq 'darwin'; $pscmd = $BSD ? "/bin/ps -auxww" : $LINUX ? "/bin/ps axuw" : "/bin/ps -ef"; open(TTYIN, "</dev/tty") || die "can't read /dev/tty: $!"; diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index bcaf9f8af8e..0153a3afa7c 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -1,4 +1,4 @@ -#!@PERL@ +#!/usr/bin/perl # **************************** package MySQLaccess; #use strict; diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 3cb4665eb1c..430c74874eb 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -1,7 +1,7 @@ #!/usr/bin/perl use Getopt::Long; -use POSIX qw(strftime); +use POSIX qw(strftime getcwd); $|=1; $VER="2.16"; @@ -295,6 +295,7 @@ sub start_mysqlds() { @options = defaults_for_group($groups[$i]); + $basedir_found= 0; # The default $mysqld_found= 1; # The default $mysqld_found= 0 if (!length($mysqld)); $com= "$mysqld"; @@ -310,17 +311,25 @@ sub start_mysqlds() $com= $options[$j]; $mysqld_found= 1; } + elsif ("--basedir=" eq substr($options[$j], 0, 10)) + { + $basedir= $options[$j]; + $basedir =~ s/^--basedir=//; + $basedir_found= 1; + $options[$j]= quote_shell_word($options[$j]); + $tmp.= " $options[$j]"; + } else { $options[$j]= quote_shell_word($options[$j]); $tmp.= " $options[$j]"; } } - if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent) + if ($opt_verbose && $com =~ m/\/(safe_mysqld|mysqld_safe)$/ && !$info_sent) { - print "WARNING: safe_mysqld is being used to start mysqld. In this case you "; + print "WARNING: $1 is being used to start mysqld. In this case you "; print "may need to pass\n\"ledir=...\" under groups [mysqldN] to "; - print "safe_mysqld in order to find the actual mysqld binary.\n"; + print "$1 in order to find the actual mysqld binary.\n"; print "ledir (library executable directory) should be the path to the "; print "wanted mysqld binary.\n\n"; $info_sent= 1; @@ -337,7 +346,16 @@ sub start_mysqlds() print "group [$groups[$i]] separately.\n"; exit(1); } + if ($basedir_found) + { + $curdir=getcwd(); + chdir($basedir) or die "Can't change to datadir $basedir"; + } system($com); + if ($basedir_found) + { + chdir($curdir) or die "Can't change back to original dir $curdir"; + } } if (!$i && !$opt_no_log) { @@ -670,9 +688,9 @@ language = @datadir@/mysql/english user = unix_user1 [mysqld3] -mysqld = /path/to/safe_mysqld/safe_mysqld +mysqld = /path/to/mysqld_safe ledir = /path/to/mysqld-binary/ -mysqladmin = /path/to/mysqladmin/mysqladmin +mysqladmin = /path/to/mysqladmin socket = /tmp/mysql.sock3 port = 3308 pid-file = @localstatedir@3/hostname.pid3 diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 960c3e39bab..23b5efcaf2b 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -67,7 +67,7 @@ my_which () ret=0 for file do - for dir in "$PATH" + for dir in $PATH do if [ -f "$dir/$file" ] then @@ -391,8 +391,8 @@ then fi # Change the err log to the right user, if it is in use if [ $want_syslog -eq 0 ]; then - touch $err_log - chown $user $err_log + touch "$err_log" + chown $user "$err_log" fi if test -n "$open_files" then @@ -509,9 +509,9 @@ fi # # If there exists an old pid file, check if the daemon is already running # Note: The switches to 'ps' may depend on your operating system -if test -f $pid_file +if test -f "$pid_file" then - PID=`cat $pid_file` + PID=`cat "$pid_file"` if @CHECK_PID@ then if @FIND_PROC@ @@ -520,8 +520,8 @@ then exit 1 fi fi - rm -f $pid_file - if test -f $pid_file + rm -f "$pid_file" + if test -f "$pid_file" then log_error "Fatal error: Can't remove the pid file: $pid_file @@ -563,11 +563,11 @@ test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null" log_notice "Starting $MYSQLD daemon with databases from $DATADIR" while true do - rm -f $safe_mysql_unix_port $pid_file # Some extra safety + rm -f $safe_mysql_unix_port "$pid_file" # Some extra safety eval_log_error "$cmd" - if test ! -f $pid_file # This is removed if normal shutdown + if test ! -f "$pid_file" # This is removed if normal shutdown then break fi diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh index ce2670b2abd..8580b8e6203 100644 --- a/scripts/mysqldumpslow.sh +++ b/scripts/mysqldumpslow.sh @@ -20,7 +20,7 @@ GetOptions(\%opt, 'v|verbose+',# verbose 'help+', # write usage info 'd|debug+', # debug - 's=s', # what to sort by (t, at, l, al, r, ar etc) + 's=s', # what to sort by (al, at, ar, c, t, l, r) 'r!', # reverse the sort order (largest last instead of first) 't=i', # just show the top n queries 'a!', # don't abstract all numbers to N and strings to 'S' @@ -163,7 +163,14 @@ Parse and summarize the MySQL slow query log. Options are -v verbose -d debug - -s ORDER what to sort by (t, at, l, al, r, ar etc), 'at' is default + -s ORDER what to sort by (al, at, ar, c, l, r, t), 'at' is default + al: average lock time + ar: average rows sent + at: average query time + c: count + l: lock time + r: rows sent + t: query time -r reverse the sort order (largest last instead of first) -t NUM just show the top n queries -a don't abstract all numbers to N and strings to 'S' |