Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026

Diff for scripts/perl/mysql/mysql-table-copy.pl between version 1.6 and 1.7

version 1.6, 2005/05/10 09:19:23 version 1.7, 2005/05/10 09:40:39
Line 10 
Line 10 
 # 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.5 2005/05/10 08:36:03 nepto Exp $  # $Platon: scripts/perl/mysql/mysql-table-copy.pl,v 1.6 2005/05/10 09:19:23 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
         $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 36  sub read_input();
Line 37  sub read_input();
   
 $default_timeout = 10; # 10 seconds  $default_timeout = 10; # 10 seconds
   
 if ($#ARGV < 2) {  while ($ARGV[0] =~ /^-/) {
         print STDERR "Usage: $0 database=DB1,host=localhost database=DB2,host=localhost Table [user1] [pass1] [user2] [pass2] [<time_interval>]\n";          my $option = shift @ARGV;
         exit 1;          if ($option eq '-pk') {
                   $opt_pk = 1;
           }
 }  }
   
 ($db_name1, $db_name2, $table, $user1, $pass1, $user2, $pass2, $timeout) = @ARGV;  ($db_name1, $db_name2, $table, $user1, $pass1, $user2, $pass2, $timeout) = @ARGV;
   
   if (! defined $db_name1 or ! defined $db_name2) {
           print STDERR "Usage:\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 "Options:\n";
           print STDERR "  -pk - copy/replicate primary key as well\n";
           exit 1;
   }
   
 # we are using ',' as separators, because ';' is separator in shell  # we are using ',' as separators, because ';' is separator in shell
 $db_name1 =~ s/,/;/g;  $db_name1 =~ s/,/;/g;
 $db_name2 =~ s/,/;/g;  $db_name2 =~ s/,/;/g;
Line 96  foreach my $key (sort keys %$info) {
Line 108  foreach my $key (sort keys %$info) {
         if ($$info{$key}->{Key} eq 'PRI') {          if ($$info{$key}->{Key} eq 'PRI') {
                 print "# Primary key is '$key'\n";                  print "# Primary key is '$key'\n";
                 $primary_key = $key;                  $primary_key = $key;
                   push @columns, $key if ($opt_pk);
         }          }
         else {          else {
                 print "# Found column '$key'\n";                  print "# Found column '$key'\n";

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top