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.9 and 1.10

version 1.9, 2005/05/10 09:52:55 version 1.10, 2005/05/10 09:54:25
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.8 2005/05/10 09:49:25 nepto Exp $  # $Platon: scripts/perl/mysql/mysql-table-copy.pl,v 1.9 2005/05/10 09:52:55 rajo 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_exit          $opt_pk $opt_exit $opt_verbose
         $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 43  while ($ARGV[0] =~ /^-/) {
Line 43  while ($ARGV[0] =~ /^-/) {
                 $opt_pk = 1;                  $opt_pk = 1;
         } elsif ($option eq '-exit') {          } elsif ($option eq '-exit') {
                 $opt_exit = 1;                  $opt_exit = 1;
           } elsif ($option eq '-verbose') {
                   $opt_verbose = 1;
         }          }
 }  }
   
Line 53  if (! defined $db_name1 or ! defined $db
Line 55  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 "  -exit   exit immediately after execution\n";          print STDERR "  -exit     exit immediately after execution\n";
         print STDERR "  -pk     copy/replicate primary key as well\n";          print STDERR "  -pk       copy/replicate primary key as well\n";
           print STDERR "  -verbose  add some notes on the output\n";
         exit 1;          exit 1;
 }  }
   
Line 66  $db_name1 =~ m/^DBI:/ or $db_name1 = "DB
Line 69  $db_name1 =~ m/^DBI:/ or $db_name1 = "DB
 $db_name2 =~ m/^DBI:/ or $db_name2 = "DBI:mysql:$db_name2";  $db_name2 =~ m/^DBI:/ or $db_name2 = "DBI:mysql:$db_name2";
   
 if (!defined $timeout or $timeout !~ m/^[0-9]+$/) {  if (!defined $timeout or $timeout !~ m/^[0-9]+$/) {
         print STDERR "Using default timeout $default_timeout seconds\n";          print STDERR "Using default timeout $default_timeout seconds\n" if ($opt_verbose);
         $timeout = $default_timeout;          $timeout = $default_timeout;
 }  }
   
Line 109  $sql_info->execute();
Line 112  $sql_info->execute();
 my $info= $sql_info->fetchall_hashref('Field');  my $info= $sql_info->fetchall_hashref('Field');
 foreach my $key (sort keys %$info) {  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" if ($opt_verbose);
                 $primary_key = $key;                  $primary_key = $key;
                 push @columns, $key if ($opt_pk);                  push @columns, $key if ($opt_pk);
         }          }
         else {          else {
                 print "# Found column '$key'\n";                  print "# Found column '$key'\n" if ($opt_verbose);
                 push @columns, $key;                  push @columns, $key;
         }          }
 }  }
 #$sql_info->dump_results();  #$sql_info->dump_results();
   
 print "# Preparing SQL commands...\n";  print "# Preparing SQL commands...\n" if ($opt_verbose);
 #print "SELECT $primary_key, " . join(', ', @columns) . " FROM $table\n";  #print "SELECT $primary_key, " . join(', ', @columns) . " FROM $table\n";
 #print "INSERT INTO $table  (" . join(', ', @columns) . ") VALUES (?" . ", ?" x $#columns . ")\n";  #print "INSERT INTO $table  (" . join(', ', @columns) . ") VALUES (?" . ", ?" x $#columns . ")\n";
 #print "DELETE FROM $table WHERE $primary_key = ? LIMIT 1\n";  #print "DELETE FROM $table WHERE $primary_key = ? LIMIT 1\n";

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

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