/[rserv]/bin/SlaveDelTable
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/SlaveDelTable

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Tue Aug 5 09:52:36 2003 UTC revision 1.3 by dpavlin, Sun Nov 2 10:21:45 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl -w
2  # SlaveAddTable  # SlaveAddTable
3  # Vadim Mikheev, (c) 2000, PostgreSQL Inc.  # Vadim Mikheev, (c) 2000, PostgreSQL Inc.
4    
# Line 6  eval '(exit $?0)' && eval 'exec perl -S Line 6  eval '(exit $?0)' && eval 'exec perl -S
6      & eval 'exec perl -S $0 $argv:q'      & eval 'exec perl -S $0 $argv:q'
7      if 0;      if 0;
8    
9    use strict;
10  use Pg;  use Pg;
11  use Getopt::Long;  use Getopt::Long;
12    
13  $| = 1;  $| = 1;
14    
15  $result = GetOptions("debug!", "verbose!", "help",  my ($debug,$verbose) = (0,0);
16                       "host=s", "user=s", "password=s");  my ($help,$slavehost,$slaveport,$slaveuser,$slavepassword);
17    
18  my $debug = $opt_debug || 0;  my $result = GetOptions(
19  my $verbose = $opt_verbose || 0;          "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
20            "slavehost=s" => \$slavehost, "slaveport=i" => \$slaveport,
21  if (defined($opt_help) || (scalar(@ARGV) < 2)) {          "slaveuser=s" => \$slaveuser, "slavepassword=s" => \$slavepassword,
22      print "Usage: $0 --host=name --user=name --password=string slavedb table\n";          );
23      exit ((scalar(@ARGV) < 2)? 1: 0);  
24    if (defined($help) || (scalar(@ARGV) < 2)) {
25        print "Usage: $0 [options] slavedb table
26    Options:
27            --slavehost=hostname --slaveport=port
28            --slaveuser=username --slavepassword=string
29    ";
30        exit ((scalar(@ARGV) < 2)? 1:0);
31  }  }
32    
33  my $dbname = $ARGV[0];  my $dbname = $ARGV[0];
34  my $table = $ARGV[1];  my $table = $ARGV[1];
35  #my $keyname = $ARGV[2];  #my $keyname = $ARGV[2];
36    
37  my $sinfo = "dbname=$dbname";  my $sinfo = MkInfo($dbname,$slavehost,$slaveport,$slaveuser,$slavepassword);
 $sinfo = "$sinfo host=$opt_host" if (defined($opt_host));  
 $sinfo = "$sinfo user=$opt_user" if (defined($opt_user));  
 $sinfo = "$sinfo password=$opt_password" if (defined($opt_password));  
   
 my $dbname = $ARGV[0];  
 my $table = $ARGV[1];  
 my $keyname = $ARGV[2];  
38    
39  my $conn = Pg::connectdb($sinfo);  my $conn = Pg::connectdb($sinfo);
40  if ($conn->status != PGRES_CONNECTION_OK) {  if ($conn->status != PGRES_CONNECTION_OK) {
# Line 41  if ($conn->status != PGRES_CONNECTION_OK Line 42  if ($conn->status != PGRES_CONNECTION_OK
42      exit 1;      exit 1;
43  }  }
44    
45  my $result = $conn->exec("BEGIN");  $result = $conn->exec("BEGIN");
46  die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;  die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
47    
48  $result = $conn->exec("DELETE FROM _RSERV_SLAVE_TABLES_ WHERE tname='$table'");  $result = $conn->exec("DELETE FROM _RSERV_SLAVE_TABLES_ WHERE tname='$table'");

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.26