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

Contents of /bin/SlaveDelTable

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue Aug 5 09:52:36 2003 UTC (20 years, 10 months ago) by dpavlin
Branch: MAIN
rserv 0.2 changes by Nélio Alves Pereira Filho

1 #!/usr/bin/perl
2 # 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 use Pg;
10 use Getopt::Long;
11
12 $| = 1;
13
14 $result = GetOptions("debug!", "verbose!", "help",
15 "host=s", "user=s", "password=s");
16
17 my $debug = $opt_debug || 0;
18 my $verbose = $opt_verbose || 0;
19
20 if (defined($opt_help) || (scalar(@ARGV) < 2)) {
21 print "Usage: $0 --host=name --user=name --password=string slavedb table\n";
22 exit ((scalar(@ARGV) < 2)? 1: 0);
23 }
24
25 my $dbname = $ARGV[0];
26 my $table = $ARGV[1];
27 #my $keyname = $ARGV[2];
28
29 my $sinfo = "dbname=$dbname";
30 $sinfo = "$sinfo host=$opt_host" if (defined($opt_host));
31 $sinfo = "$sinfo user=$opt_user" if (defined($opt_user));
32 $sinfo = "$sinfo password=$opt_password" if (defined($opt_password));
33
34 my $dbname = $ARGV[0];
35 my $table = $ARGV[1];
36 my $keyname = $ARGV[2];
37
38 my $conn = Pg::connectdb($sinfo);
39 if ($conn->status != PGRES_CONNECTION_OK) {
40 print STDERR "Failed opening $sinfo\n";
41 exit 1;
42 }
43
44 my $result = $conn->exec("BEGIN");
45 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
46
47 $result = $conn->exec("DELETE FROM _RSERV_SLAVE_TABLES_ WHERE tname='$table'");
48 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
49
50 $result = $conn->exec("COMMIT");
51 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
52
53 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26