/[rserv]/bin/MasterDelTable
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/MasterDelTable

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Sun Nov 2 10:21:45 2003 UTC (20 years, 6 months ago) by dpavlin
Branch: MAIN
Changes since 1.2: +1 -5 lines
moved all info preparation into MkInfo in RServ.pm

1 dpavlin 1.2 #!/usr/bin/perl -w
2 dpavlin 1.1 # MasterAddTable
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 dpavlin 1.2 use strict;
12 dpavlin 1.1
13     $| = 1;
14    
15 dpavlin 1.2 my ($debug,$verbose) = (0,0);
16     my ($help,$masterhost,$masterport,$masteruser,$masterpassword);
17 dpavlin 1.1
18 dpavlin 1.2 my $result = GetOptions(
19     "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
20     "masterhost=s" => \$masterhost, "masterport=i" => \$masterport,
21     "masteruser=s" => \$masteruser, "masterpassword=s" => \$masterpassword,
22     );
23    
24     if (defined($help) || (scalar(@ARGV) < 2)) {
25     print "Usage: $0 [options] masterdb table
26     Options:
27     --masterhost=hostname --masterport=port
28     --masteruser=username --masterpassword=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 dpavlin 1.3 my $minfo = MkInfo($dbname,$masterhost,$masterport,$masteruser,$masterpassword);
38 dpavlin 1.1
39     my $conn = Pg::connectdb($minfo);
40     if ($conn->status != PGRES_CONNECTION_OK) {
41     print STDERR "Failed opening $minfo\n";
42     exit 1;
43     }
44    
45 dpavlin 1.2 $result = $conn->exec("BEGIN");
46 dpavlin 1.1 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
47    
48     $result = $conn->exec("DROP TRIGGER _RSERV_TRIGGER_T_ ON \"$table\"");
49     die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
50    
51     $result = $conn->exec("DELETE FROM _RSERV_TABLES_ WHERE tname='$table'");
52     die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
53    
54     $result = $conn->exec("COMMIT");
55     die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
56    
57     exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26