From 89b0b23464ddbaa47864e78fe944b4889cb68768 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 1 Dec 2001 19:37:30 -0700 Subject: get correct paths in mysql_config even if the user moves basedir scripts/mysql_config.sh: get correct paths even if the user moves basedir --- scripts/mysql_config.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'scripts') diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index ed344f4b1e3..05cc8632363 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -18,11 +18,50 @@ # This script reports various configuration settings that may be needed # when using the MySQL client library. +which () +{ + IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' + for file + do + for dir in $PATH + do + if test -f $dir/$file + then + echo "$dir/$file" + continue 2 + fi + done + echo "which: no $file in ($PATH)" + exit 1 + done + IFS="$save_ifs" +} + +fix_path () +{ + eval path=\$"$1" + if [ ! -f "$path" ] ; + then + eval "$1"=$basedir/$2 + fi +} + +abs_path=`expr \( substr $0 1 1 \) = '/'` +if [ "x$abs_path" = "x1" ] ; then + me=$0 +else + me=`which mysql_config` +fi + +basedir=`echo $me | sed -e 's;/bin/mysql_config;;'` + ldata='@localstatedir@' execdir='@libexecdir@' bindir='@bindir@' pkglibdir='@pkglibdir@' +fix_path pkglibdir lib/mysql pkgincludedir='@pkgincludedir@' +fix_path pkgincludedir include/mysql version='@VERSION@' socket='@MYSQL_UNIX_ADDR@' port='@MYSQL_TCP_PORT@' -- cgit v1.2.1 From e8d81970be33a5a6594bfb7a7ea0c0de02647227 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Dec 2001 23:15:05 +0200 Subject: Fixed bug in LEFT JOIN Docs/manual.texi: ChangeLog myisam/mi_locking.c: Remove wrong optimistic locking. (Doesn't affect MySQL) mysys/my_init.c: Release character sets at end scripts/mysqlhotcopy.sh: RAID tables are now copied --- scripts/mysqlhotcopy.sh | 96 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 21 deletions(-) (limited to 'scripts') diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index 655e5a2a52b..caf2615fe7a 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -37,7 +37,7 @@ WARNING: THIS PROGRAM IS STILL IN BETA. Comments/patches welcome. # Documentation continued at end of file -my $VERSION = "1.13"; +my $VERSION = "1.14"; my $opt_tmpdir = $ENV{TMPDIR} || "/tmp"; @@ -120,6 +120,7 @@ GetOptions( \%opt, # 'target' - destination directory of the copy # 'tables' - array-ref to list of tables in the db # 'files' - array-ref to list of files to be copied +# (RAID files look like 'nn/name.MYD') # 'index' - array-ref to list of indexes to be copied # @@ -265,11 +266,23 @@ foreach my $rdb ( @db_desc ) { or die "Cannot open dir '$db_dir': $!"; my %db_files; - map { ( /(.+)\.\w+$/ ? ( $db_files{$_} = $1 ) : () ) } readdir(DBDIR); + my @raid_dir = (); + + while ( defined( my $name = readdir DBDIR ) ) { + if ( $name =~ /^\d\d$/ && -d "$db_dir/$name" ) { + push @raid_dir, $name; + } + else { + $db_files{$name} = $1 if ( $name =~ /(.+)\.\w+$/ ); + } + } + closedir( DBDIR ); + + scan_raid_dir( \%db_files, $db_dir, @raid_dir ); + unless( keys %db_files ) { warn "'$db' is an empty database\n"; } - closedir( DBDIR ); ## filter (out) files specified in t_regex my @db_files; @@ -297,6 +310,8 @@ foreach my $rdb ( @db_desc ) { my @hc_tables = map { "$db.$_" } @dbh_tables; $rdb->{tables} = [ @hc_tables ]; + $rdb->{raid_dirs} = [ get_raid_dirs( $rdb->{files} ) ]; + $hc_locks .= ", " if ( length $hc_locks && @hc_tables ); $hc_locks .= join ", ", map { "$_ READ" } @hc_tables; $hc_tables .= ", " if ( length $hc_tables && @hc_tables ); @@ -370,17 +385,20 @@ if ($opt{method} =~ /^cp\b/) retire_directory( @existing ) if ( @existing ); foreach my $rdb ( @db_desc ) { - my $tgt_dirpath = $rdb->{target}; - if ( $opt{dryrun} ) { - print "mkdir $tgt_dirpath, 0750\n"; - } - elsif ($opt{method} =~ /^scp\b/) { - ## assume it's there? - ## ... - } - else { - mkdir($tgt_dirpath, 0750) - or die "Can't create '$tgt_dirpath': $!\n"; + foreach my $td ( '', @{$rdb->{raid_dirs}} ) { + + my $tgt_dirpath = "$rdb->{target}/$td"; + if ( $opt{dryrun} ) { + print "mkdir $tgt_dirpath, 0750\n"; + } + elsif ($opt{method} =~ /^scp\b/) { + ## assume it's there? + ## ... + } + else { + mkdir($tgt_dirpath, 0750) + or die "Can't create '$tgt_dirpath': $!\n"; + } } } @@ -438,7 +456,7 @@ foreach my $rdb ( @db_desc ) my @files = map { "$datadir/$rdb->{src}/$_" } @{$rdb->{files}}; next unless @files; - eval { copy_files($opt{method}, \@files, $rdb->{target} ); }; + eval { copy_files($opt{method}, \@files, $rdb->{target}, $rdb->{raid_dirs} ); }; push @failed, "$rdb->{src} -> $rdb->{target} failed: $@" if ( $@ ); @@ -531,27 +549,33 @@ exit 0; # --- sub copy_files { - my ($method, $files, $target) = @_; + my ($method, $files, $target, $raid_dirs) = @_; my @cmd; print "Copying ".@$files." files...\n" unless $opt{quiet}; if ($method =~ /^s?cp\b/) { # cp or scp with optional flags - @cmd = ($method); + my @cp = ($method); # add option to preserve mod time etc of copied files # not critical, but nice to have - push @cmd, "-p" if $^O =~ m/^(solaris|linux|freebsd)$/; + push @cp, "-p" if $^O =~ m/^(solaris|linux|freebsd)$/; # add recursive option for scp - push @cmd, "-r" if $^O =~ /m^(solaris|linux|freebsd)$/ && $method =~ /^scp\b/; + push @cp, "-r" if $^O =~ /m^(solaris|linux|freebsd)$/ && $method =~ /^scp\b/; + + my @non_raid = grep { $_ !~ m:\d\d/: } @$files; # add files to copy and the destination directory - push @cmd, @$files, $target; + safe_system( @cp, @non_raid, $target ); + + foreach my $rd ( @$raid_dirs ) { + my @raid = grep { m:$rd/: } @$files; + safe_system( @cp, @raid, "$target/$rd" ) if ( @raid ); + } } else { die "Can't use unsupported method '$method'\n"; } - safe_system (@cmd); } # @@ -682,6 +706,35 @@ sub get_row { return $sth->fetchrow_array(); } +sub scan_raid_dir { + my ( $r_db_files, $data_dir, @raid_dir ) = @_; + + local(*RAID_DIR); + + foreach my $rd ( @raid_dir ) { + + opendir(RAID_DIR, "$data_dir/$rd" ) + or die "Cannot open dir '$data_dir/$rd': $!"; + + while ( defined( my $name = readdir RAID_DIR ) ) { + $r_db_files->{"$rd/$name"} = $1 if ( $name =~ /(.+)\.\w+$/ ); + } + closedir( RAID_DIR ); + } +} + +sub get_raid_dirs { + my ( $r_files ) = @_; + + my %dirs = (); + foreach my $f ( @$r_files ) { + if ( $f =~ m:^(\d\d)/: ) { + $dirs{$1} = 1; + } + } + return sort keys %dirs; +} + __END__ =head1 DESCRIPTION @@ -905,6 +958,7 @@ Tim Bunce Martin Waite - added checkpoint, flushlog, regexp and dryrun options Fixed cleanup of targets when hotcopy fails. Added --record_log_pos. + RAID tables are now copied (don't know if this works over scp). Ralph Corderoy - added synonyms for commands -- cgit v1.2.1 From 6f8f45e9592aa7f2ca48168d51e1624cce158797 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Dec 2001 23:56:56 +0200 Subject: Small changes to mysql_config.sh Docs/manual.texi: Changelog scripts/mysql_config.sh: Fix script to search in different directories for include and lib --- scripts/mysql_config.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 05cc8632363..af11957576b 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -37,20 +37,32 @@ which () IFS="$save_ifs" } +# +# If we can find the given directory relatively to where mysql_config is +# we should use this instead of the incompiled one. +# This is to ensure that this script also works with the binary MySQL +# version + fix_path () { - eval path=\$"$1" - if [ ! -f "$path" ] ; - then - eval "$1"=$basedir/$2 - fi + var=$1 + shift + for filename + do + path=$basedir/$filename + if [ -d "$path" ] ; + then + eval "$var"=$path + return + fi + done } abs_path=`expr \( substr $0 1 1 \) = '/'` if [ "x$abs_path" = "x1" ] ; then me=$0 else - me=`which mysql_config` + me=`which $0` fi basedir=`echo $me | sed -e 's;/bin/mysql_config;;'` @@ -59,9 +71,9 @@ ldata='@localstatedir@' execdir='@libexecdir@' bindir='@bindir@' pkglibdir='@pkglibdir@' -fix_path pkglibdir lib/mysql +fix_path pkglibdir lib/mysql lib pkgincludedir='@pkgincludedir@' -fix_path pkgincludedir include/mysql +fix_path pkgincludedir include/mysql include version='@VERSION@' socket='@MYSQL_UNIX_ADDR@' port='@MYSQL_TCP_PORT@' -- cgit v1.2.1