diff options
author | unknown <tsmith@ramayana.hindu.god> | 2007-08-20 11:00:51 -0600 |
---|---|---|
committer | unknown <tsmith@ramayana.hindu.god> | 2007-08-20 11:00:51 -0600 |
commit | 539d58a36aac78f23c670f5b785fe9e4a3d48655 (patch) | |
tree | cc789ad0546804ad02fa63ac62b5e54afda31e33 | |
parent | db53902678c00759eb352884fd8a90525b4e2aee (diff) | |
download | mariadb-git-539d58a36aac78f23c670f5b785fe9e4a3d48655.tar.gz |
Bug #27694: mysqlhotcopy & p5-DBD-mysql51-4.003
Use "SHOW TABLES FROM `db`" instead of $dbh->tables() in the
get_list_of_tables() routine.
The symptom is that, when used with recent versions of DBD::mysql,
mysqlhotcopy uses a double-qualified table name, for example:
Invalid db.table name 'test.test`.`x' at /usr/bin/mysqlhotcopy line 855.
This is caused by a change in DBD::mysql. See this diff:
http://svn.perl.org/viewcvs/modules/DBD-mysql/trunk/lib/DBD/mysql.pm?r1=9183&r2=9188
Basically, older DBD::mysql implemented a limited ->table_info method;
now the full method is implemented, and as a result DBI's ->tables()
method has access to the schema value, so it uses it.
scripts/mysqlhotcopy.sh:
Use "SHOW TABLES FROM `db`" instead of $dbh->tables() in
get_list_of_tables(). DBI's ->tables() method calls
"SHOW TABLES" under the hood, and then quotes the
names and (depending on DBD::mysql version) adds the schema
name, too. mysqlhotcopy doesn't want the schema name
or the quotes, so it's all around better to just call
"SHOW TABLES" itself.
-rw-r--r-- | scripts/mysqlhotcopy.sh | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index 61cd59457d1..6ad5c77b954 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -821,30 +821,14 @@ sub get_raid_dirs { sub get_list_of_tables { my ( $db ) = @_; - # "use database" cannot cope with database names containing spaces - # so create a new connection - - my $dbh = DBI->connect("dbi:mysql:${db}${dsn};mysql_read_default_group=mysqlhotcopy", - $opt{user}, $opt{password}, - { - RaiseError => 1, - PrintError => 0, - AutoCommit => 1, - }); - - my @dbh_tables = eval { $dbh->tables() }; - - ## Remove quotes around table names - my $quote = $dbh->get_info(29); # SQL_IDENTIFIER_QUOTE_CHAR - if ($quote) { - foreach (@dbh_tables) { - s/^$quote(.*)$quote$/$1/; - s/$quote$quote/$quote/g; - } - } - - $dbh->disconnect(); - return @dbh_tables; + my $tables = + eval { + $dbh->selectall_arrayref('SHOW TABLES FROM ' . + $dbh->quote_identifier($db)) + } || []; + warn "Unable to retrieve list of tables in $db: $@" if $@; + + return (map { $_->[0] } @$tables); } sub quote_names { |