| version 1.7, 2005/05/10 09:40:39 |
version 1.8, 2005/05/10 09:49:25 |
|
|
| # Licensed under terms of GNU General Public License. |
# Licensed under terms of GNU General Public License. |
| # All rights reserved. |
# All rights reserved. |
| # |
# |
| # $Platon: scripts/perl/mysql/mysql-table-copy.pl,v 1.6 2005/05/10 09:19:23 nepto Exp $ |
# $Platon: scripts/perl/mysql/mysql-table-copy.pl,v 1.7 2005/05/10 09:40:39 nepto Exp $ |
| |
|
| # TODO: - reconnect on closed connection |
# TODO: - reconnect on closed connection |
| # - managment for tables with multiple KEY columns |
# - managment for tables with multiple KEY columns |
| Line 22 use Time::HiRes qw(gettimeofday tv_inter |
|
| Line 22 use Time::HiRes qw(gettimeofday tv_inter |
|
| use POSIX qw(strftime); |
use POSIX qw(strftime); |
| |
|
| use vars qw ( |
use vars qw ( |
| $opt_pk |
$opt_pk $opt_exit |
| $dbh1 $db_name1 $user1 $pass1 |
$dbh1 $db_name1 $user1 $pass1 |
| $dbh2 $db_name2 $user2 $pass2 |
$dbh2 $db_name2 $user2 $pass2 |
| $table $timeout |
$table $timeout |
| Line 41 while ($ARGV[0] =~ /^-/) { |
|
| Line 41 while ($ARGV[0] =~ /^-/) { |
|
| my $option = shift @ARGV; |
my $option = shift @ARGV; |
| if ($option eq '-pk') { |
if ($option eq '-pk') { |
| $opt_pk = 1; |
$opt_pk = 1; |
| |
} elsif ($option eq '-exit') { |
| |
$opt_exit = 1; |
| } |
} |
| } |
} |
| |
|
| Line 51 if (! defined $db_name1 or ! defined $db |
|
| Line 53 if (! defined $db_name1 or ! defined $db |
|
| print STDERR " $0 [options] database=DB1,host=localhost database=DB2,host=localhost Table\n"; |
print STDERR " $0 [options] database=DB1,host=localhost database=DB2,host=localhost Table\n"; |
| print STDERR " [user1] [pass1] [user2] [pass2] [<time_interval>]\n"; |
print STDERR " [user1] [pass1] [user2] [pass2] [<time_interval>]\n"; |
| print STDERR "Options:\n"; |
print STDERR "Options:\n"; |
| print STDERR " -pk - copy/replicate primary key as well\n"; |
print STDERR " -exit exit immediately after execution\n"; |
| |
print STDERR " -pk copy/replicate primary key as well\n"; |
| exit 1; |
exit 1; |
| } |
} |
| |
|
|
|
| } |
} |
| } |
} |
| |
|
| |
last if ($opt_exit); |
| sleep $timeout; |
sleep $timeout; |
| } |
} |
| |
|