Hi,
Attached is a patch to be applied to v1.17 of mysqlhotcopy.
This fixes a bug introduced by the quoting mechanism
used to handle databases and tables with spaces in their
names. This bug caused a problem when the --record-log-pos
or --checkpoint options were used.
Also, this patch fixes a bug which is exposed if a database only
contains raid tables.
==
Martin
=========================================
--- mysqlhotcopy Tue Jan 21 21:18:48 2003
+++ mysqlhotcopy-18 Mon Feb 24 09:32:25 2003
@@ -172,6 +172,7 @@
# --- check that checkpoint table exists if specified ---
if ( $opt{checkpoint} ) {
+ $opt{checkpoint} = quote_names( $opt{checkpoint} );
eval { $dbh->do( qq{ select time_stamp, src, dest, msg
from $opt{checkpoint} where 1 != 1} );
};
@@ -182,6 +183,8 @@
# --- check that log_pos table exists if specified ---
if ( $opt{record_log_pos} ) {
+ $opt{record_log_pos} = quote_names( $opt{record_log_pos} );
+
eval { $dbh->do( qq{ select host, time_stamp, log_file, log_pos,
master_host, master_log_file, master_log_pos
from $opt{record_log_pos} where 1 != 1} );
};
@@ -308,7 +311,7 @@
$rdb->{files} = [ @db_files ];
$rdb->{index} = [ @index_files ];
- my @hc_tables = map { "`$db`.`$_`" } @dbh_tables;
+ my @hc_tables = map { quote_names("$db.$_") } @dbh_tables;
$rdb->{tables} = [ @hc_tables ];
$rdb->{raid_dirs} = [ get_raid_dirs( $rdb->{files} ) ];
@@ -568,7 +571,7 @@
my @non_raid = map { "'$_'" } grep { ! m:/\d{2}/[^/]+$: } @$files;
# add files to copy and the destination directory
- safe_system( @cp, @non_raid, "'$target'" );
+ safe_system( @cp, @non_raid, "'$target'" ) if (@non_raid);
foreach my $rd ( @$raid_dirs ) {
my @raid = map { "'$_'" } grep { m:$rd/: } @$files;
@@ -755,6 +758,16 @@
my @dbh_tables = eval { $dbh->tables() };
$dbh->disconnect();
return @dbh_tables;
+}
+
+sub quote_names {
+ my ( $name ) = @_;
+ # given a db.table name, add quotes
+
+ my ($db, $table, @cruft) = split( /\./, $name );
+ die "Invalid db.table name '$name'" if (@cruft || !defined $db || !defined
$table );
+
+ return "`$db`.`$table`";
}
__END__
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail internals-thread7139@xxxxxxxxxxxxxxx
To unsubscribe, e-mail <internals-unsubscribe@xxxxxxxxxxxxxxx>
|