1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

merge with 5.5

This commit is contained in:
Sergei Golubchik
2012-11-03 12:28:51 +01:00
210 changed files with 5894 additions and 1460 deletions

View File

@ -257,7 +257,7 @@ fi
# Now we can get arguments from the groups [mysqld] and [mysql_install_db]
# in the my.cfg file, then re-run to merge with command line arguments.
parse_arguments `$print_defaults $defaults mysqld mariadb mysql_install_db client-server`
parse_arguments `"$print_defaults" $defaults mysqld mariadb mysql_install_db client-server`
parse_arguments PICK-ARGS-FROM-ARGV "$@"
# Configure paths to support files
@ -307,7 +307,7 @@ fill_help_tables="$pkgdatadir/fill_help_tables.sql"
create_system_tables="$pkgdatadir/mysql_system_tables.sql"
fill_system_tables="$pkgdatadir/mysql_system_tables_data.sql"
for f in $fill_help_tables $create_system_tables $fill_system_tables
for f in "$fill_help_tables" "$create_system_tables" "$fill_system_tables"
do
if test ! -f "$f"
then
@ -330,22 +330,25 @@ then
exit 1
fi
mysqld_opt="--lc-messages-dir=$langdir/.."
else
mysqld_opt="--lc-messages=en_US"
fi
# Try to determine the hostname
hostname=`@HOSTNAME@`
# Check if hostname is valid
if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
then
resolved=`$extra_bindir/resolveip $hostname 2>&1`
resolved=`"$extra_bindir/resolveip" $hostname 2>&1`
if test $? -ne 0
then
resolved=`$extra_bindir/resolveip localhost 2>&1`
resolved=`"$extra_bindir/resolveip" localhost 2>&1`
if test $? -ne 0
then
echo "Neither host '$hostname' nor 'localhost' could be looked up with"
echo "$extra_bindir/resolveip"
echo "'$extra_bindir/resolveip'"
echo "Please configure the 'hostname' command to return a correct"
echo "hostname."
echo "If you want to solve this at a later stage, restart this script"
@ -368,21 +371,21 @@ then
fi
# Create database directories
for dir in $ldata $ldata/mysql $ldata/test
for dir in "$ldata" "$ldata/mysql" "$ldata/test"
do
if test ! -d $dir
if test ! -d "$dir"
then
if ! `mkdir -p $dir`
if ! `mkdir -p "$dir"`
then
echo "Fatal error Can't create database directory '$dir'"
link_to_help
exit 1
fi
chmod 700 $dir
chmod 700 "$dir"
fi
if test -n "$user"
then
chown $user $dir
chown $user "$dir"
if test $? -ne 0
then
echo "Cannot change ownership of the database directories to the '$user'"
@ -409,15 +412,19 @@ fi
# Configure mysqld command line
mysqld_bootstrap="${MYSQLD_BOOTSTRAP-$mysqld}"
mysqld_install_cmd_line="$mysqld_bootstrap $defaults $mysqld_opt --bootstrap \
--basedir=$basedir --datadir=$ldata --log-warnings=0 \
mysqld_install_cmd_line()
{
"$mysqld_bootstrap" $defaults "$mysqld_opt" --bootstrap \
"--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 \
--loose-skip-ndbcluster --loose-skip-pbxt $args --max_allowed_packet=8M \
--default-storage-engine=myisam \
--net_buffer_length=16K"
--net_buffer_length=16K
}
# Create the system and help tables by passing them to "mysqld --bootstrap"
s_echo "Installing MariaDB/MySQL system tables in '$ldata' ..."
if { echo "use mysql;"; cat $create_system_tables $fill_system_tables; } | eval "$filter_cmd_line" | $mysqld_install_cmd_line > /dev/null
if { echo "use mysql;"; cat "$create_system_tables" "$fill_system_tables"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null
then
s_echo "OK"
else
@ -452,7 +459,7 @@ else
fi
s_echo "Filling help tables..."
if { echo "use mysql;"; cat $fill_help_tables; } | $mysqld_install_cmd_line > /dev/null
if { echo "use mysql;"; cat "$fill_help_tables"; } | mysqld_install_cmd_line > /dev/null
then
s_echo "OK"
else
@ -474,11 +481,11 @@ then
echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !"
echo "To do so, start the server, then issue the following commands:"
echo
echo "$bindir/mysqladmin -u root password 'new-password'"
echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
echo "'$bindir/mysqladmin' -u root password 'new-password'"
echo "'$bindir/mysqladmin' -u root -h $hostname password 'new-password'"
echo
echo "Alternatively you can run:"
echo "$bindir/mysql_secure_installation"
echo "'$bindir/mysql_secure_installation'"
echo
echo "which will also give you the option of removing the test"
echo "databases and anonymous user created by default. This is"
@ -491,14 +498,14 @@ then
then
echo
echo "You can start the MariaDB daemon with:"
echo "cd $basedir ; $bindir/mysqld_safe --datadir=$ldata"
echo "cd '$basedir' ; $bindir/mysqld_safe --datadir='$ldata'"
echo
echo "You can test the MariaDB daemon with mysql-test-run.pl"
echo "cd $basedir/mysql-test ; perl mysql-test-run.pl"
echo "cd '$basedir/mysql-test' ; perl mysql-test-run.pl"
fi
echo
echo "Please report any problems with the $scriptdir/mysqlbug script!"
echo "Please report any problems with the '$scriptdir/mysqlbug' script!"
echo
echo "The latest information about MariaDB is available at http://mariadb.org/."
echo "You can find additional information about the MySQL part at:"

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl
# -*- cperl -*-
#
# Copyright (c) 2007, 2010, Oracle and/or its affiliates
# Copyright (c) 2007, 2012, Oracle and/or its affiliates
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -28,7 +28,7 @@ my $mysql; # How to call the mysql client
my $rootpass = "";
$SIG{QUIT} = $SIG{INT} = sub {
$SIG{QUIT} = $SIG{INT} = $SIG{TERM} = $SIG{ABRT} = $SIG{HUP} = sub {
print "\nAborting!\n\n";
echo_on();
cleanup();
@ -242,7 +242,11 @@ sub reload_privilege_tables {
}
sub cleanup {
unlink($config,$command);
print "Cleaning up...\n";
foreach my $file ($config, $command) {
unlink $file or warn "Warning: Could not unlink $file: $!\n";
}
}

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2002, 2010, Oracle and/or its affiliates
# Copyright (c) 2002, 2012, Oracle and/or its affiliates
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -18,7 +18,7 @@
config=".my.cnf.$$"
command=".mysql.$$"
trap "interrupt" 2
trap "interrupt" 1 2 3 6 15
rootpass=""
echo_n=
@ -286,13 +286,16 @@ set_root_password() {
if [ $? -eq 0 ]; then
echo "Password updated successfully!"
echo "Reloading privilege tables.."
reload_privilege_tables || exit 1
reload_privilege_tables
if [ $? -eq 1 ]; then
clean_and_exit
fi
echo
rootpass=$password1
make_config
else
echo "Password update failed!"
exit 1
clean_and_exit
fi
return 0
@ -304,7 +307,7 @@ remove_anonymous_users() {
echo " ... Success!"
else
echo " ... Failed!"
exit 1
clean_and_exit
fi
return 0
@ -364,6 +367,11 @@ cleanup() {
rm -f $config $command
}
# Remove the files before exiting.
clean_and_exit() {
cleanup
exit 1
}
# The actual script starts here

View File

@ -272,23 +272,28 @@ if ( defined $opt{regexp} ) {
}
}
# --- get list of tables to hotcopy ---
# --- get list of tables and views to hotcopy ---
my $hc_locks = "";
my $hc_tables = "";
my $hc_base_tables = "";
my $hc_views = "";
my $num_base_tables = 0;
my $num_views = 0;
my $num_tables = 0;
my $num_files = 0;
foreach my $rdb ( @db_desc ) {
my $db = $rdb->{src};
my @dbh_tables = get_list_of_tables( $db );
my @dbh_base_tables = get_list_of_tables( $db );
my @dbh_views = get_list_of_views( $db );
## filter out certain system non-lockable tables.
## keep in sync with mysqldump.
if ($db =~ m/^mysql$/i)
{
@dbh_tables = grep
{ !/^(apply_status|schema|general_log|slow_log)$/ } @dbh_tables
@dbh_base_tables = grep
{ !/^(apply_status|schema|general_log|slow_log)$/ } @dbh_base_tables
}
## generate regex for tables/files
@ -303,11 +308,20 @@ foreach my $rdb ( @db_desc ) {
## filter (out) tables specified in t_regex
print "Filtering tables with '$t_regex'\n" if $opt{debug};
@dbh_tables = ( $negated
? grep { $_ !~ $t_regex } @dbh_tables
: grep { $_ =~ $t_regex } @dbh_tables );
@dbh_base_tables = ( $negated
? grep { $_ !~ $t_regex } @dbh_base_tables
: grep { $_ =~ $t_regex } @dbh_base_tables );
## filter (out) views specified in t_regex
print "Filtering tables with '$t_regex'\n" if $opt{debug};
@dbh_views = ( $negated
? grep { $_ !~ $t_regex } @dbh_views
: grep { $_ =~ $t_regex } @dbh_views );
}
## Now concatenate the base table and view arrays.
my @dbh_tables = (@dbh_base_tables, @dbh_views);
## get list of files to copy
my $db_dir = "$datadir/$db";
opendir(DBDIR, $db_dir )
@ -347,15 +361,25 @@ foreach my $rdb ( @db_desc ) {
$rdb->{files} = [ @db_files ];
$rdb->{index} = [ @index_files ];
my @hc_tables = map { quote_names("$db.$_") } @dbh_tables;
my @hc_base_tables = map { quote_names("$db.$_") } @dbh_base_tables;
my @hc_views = map { quote_names("$db.$_") } @dbh_views;
my @hc_tables = (@hc_base_tables, @hc_views);
$rdb->{tables} = [ @hc_tables ];
$hc_locks .= ", " if ( length $hc_locks && @hc_tables );
$hc_locks .= join ", ", map { "$_ READ" } @hc_tables;
$hc_tables .= ", " if ( length $hc_tables && @hc_tables );
$hc_tables .= join ", ", @hc_tables;
$num_tables += scalar @hc_tables;
$hc_base_tables .= ", " if ( length $hc_base_tables && @hc_base_tables );
$hc_base_tables .= join ", ", @hc_base_tables;
$hc_views .= ", " if ( length $hc_views && @hc_views );
$hc_views .= join " READ, ", @hc_views;
@hc_tables = (@hc_base_tables, @hc_views);
$num_base_tables += scalar @hc_base_tables;
$num_views += scalar @hc_views;
$num_tables += $num_base_tables + $num_views;
$num_files += scalar @{$rdb->{files}};
}
@ -467,7 +491,10 @@ if ( $opt{dryrun} ) {
print "FLUSH TABLES /*!32323 $hc_tables */\n";
}
else {
print "FLUSH TABLES $hc_tables WITH READ LOCK\n";
# Lock base tables and views separately.
print "FLUSH TABLES $hc_base_tables WITH READ LOCK\n"
if ( $hc_base_tables );
print "LOCK TABLES $hc_views READ\n" if ( $hc_views );
}
print "FLUSH LOGS\n" if ( $opt{flushlog} );
@ -484,16 +511,24 @@ else {
# flush tables to make on-disk copy up to date
$start = time;
$dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
}
else {
$dbh->do("FLUSH TABLES $hc_tables WITH READ LOCK");
printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet};
$hc_started = time; # count from time lock is granted
# Lock base tables and views separately, as 'FLUSH TABLES <tbl_name>
# ... WITH READ LOCK' (introduced in 5.5) would fail for views.
# Also, flush tables to make on-disk copy up to date
$dbh->do("FLUSH TABLES $hc_base_tables WITH READ LOCK")
if ( $hc_base_tables );
printf "Flushed $num_base_tables tables with read lock ($hc_base_tables) in %d seconds.\n",
time-$start unless $opt{quiet};
# flush tables to make on-disk copy up to date
$start = time;
$dbh->do("LOCK TABLES $hc_views READ") if ( $hc_views );
printf "Locked $num_views views ($hc_views) in %d seconds.\n",
time-$start unless $opt{quiet};
$hc_started = time; # count from time lock is granted
}
printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
$dbh->do( "FLUSH LOGS" ) if ( $opt{flushlog} );
$dbh->do( "RESET MASTER" ) if ( $opt{resetmaster} );
$dbh->do( "RESET SLAVE" ) if ( $opt{resetslave} );
@ -802,14 +837,29 @@ sub get_list_of_tables {
my $tables =
eval {
$dbh->selectall_arrayref('SHOW TABLES FROM ' .
$dbh->quote_identifier($db))
$dbh->selectall_arrayref('SHOW FULL TABLES FROM ' .
$dbh->quote_identifier($db) .
' WHERE Table_type = \'BASE TABLE\'')
} || [];
warn "Unable to retrieve list of tables in $db: $@" if $@;
return (map { $_->[0] } @$tables);
}
sub get_list_of_views {
my ( $db ) = @_;
my $views =
eval {
$dbh->selectall_arrayref('SHOW FULL TABLES FROM ' .
$dbh->quote_identifier($db) .
' WHERE Table_type = \'VIEW\'')
} || [];
warn "Unable to retrieve list of views in $db: $@" if $@;
return (map { $_->[0] } @$views);
}
sub quote_names {
my ( $name ) = @_;
# given a db.table name, add quotes