/[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

Annotation of /bin/SlaveDelTable

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Tue Aug 5 21:10:28 2003 UTC (20 years, 8 months ago) by dpavlin
Branch: MAIN
CVS Tags: before_onlytables, before_multmaster, r_0_3
Changes since 1.1: +22 -17 lines
command line options cleanup and cosistency fix, modification to work
under "use strict;"

1 dpavlin 1.2 #!/usr/bin/perl -w
2 dpavlin 1.1 # SlaveAddTable
3     # Vadim Mikheev, (c) 2000, PostgreSQL Inc.
4    
5     eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
6     & eval 'exec perl -S $0 $argv:q'
7     if 0;
8    
9 dpavlin 1.2 use strict;
10 dpavlin 1.1 use Pg;
11     use Getopt::Long;
12    
13     $| = 1;
14    
15 dpavlin 1.2 my ($debug,$verbose) = (0,0);
16     my ($help,$slavehost,$slaveport,$slaveuser,$slavepassword);
17 dpavlin 1.1
18 dpavlin 1.2 my $result = GetOptions(
19     "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
20     "slavehost=s" => \$slavehost, "slaveport=i" => \$slaveport,
21     "slaveuser=s" => \$slaveuser, "slavepassword=s" => \$slavepassword,
22     );
23    
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 dpavlin 1.1 }
32    
33     my $dbname = $ARGV[0];
34     my $table = $ARGV[1];
35     #my $keyname = $ARGV[2];
36    
37     my $sinfo = "dbname=$dbname";
38 dpavlin 1.2 $sinfo = "$sinfo host=$slavehost" if (defined($slavehost));
39     $sinfo = "$sinfo port=$slaveport" if (defined($slaveport));
40     $sinfo = "$sinfo user=$slaveuser" if (defined($slaveuser));
41     $sinfo = "$sinfo password=$slavepassword" if (defined($slavepassword));
42 dpavlin 1.1
43     my $conn = Pg::connectdb($sinfo);
44     if ($conn->status != PGRES_CONNECTION_OK) {
45     print STDERR "Failed opening $sinfo\n";
46     exit 1;
47     }
48    
49 dpavlin 1.2 $result = $conn->exec("BEGIN");
50 dpavlin 1.1 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
51    
52     $result = $conn->exec("DELETE FROM _RSERV_SLAVE_TABLES_ WHERE tname='$table'");
53     die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
54    
55     $result = $conn->exec("COMMIT");
56     die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
57    
58     exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26