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

Contents of /bin/MasterDelTable

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Sun Nov 2 10:31:44 2003 UTC (20 years, 6 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +6 -0 lines
another code clean-up

1 #!/usr/bin/perl -w
2 # 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 BEGIN {
10 my $basedir = $0; $basedir =~ s#/[^/]+$##;
11 unshift(@INC, "$basedir/../share");
12 }
13
14 use Pg;
15 use Getopt::Long;
16 use strict;
17 use RServ;
18
19 $| = 1;
20
21 my ($debug,$verbose) = (0,0);
22 my ($help,$masterhost,$masterport,$masteruser,$masterpassword);
23
24 my $result = GetOptions(
25 "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
26 "masterhost=s" => \$masterhost, "masterport=i" => \$masterport,
27 "masteruser=s" => \$masteruser, "masterpassword=s" => \$masterpassword,
28 );
29
30 if (defined($help) || (scalar(@ARGV) < 2)) {
31 print "Usage: $0 [options] masterdb table
32 Options:
33 --masterhost=hostname --masterport=port
34 --masteruser=username --masterpassword=string
35 ";
36 exit ((scalar(@ARGV) < 2)? 1:0);
37 }
38
39 my $dbname = $ARGV[0];
40 my $table = $ARGV[1];
41 #my $keyname = $ARGV[2];
42
43 my $minfo = MkInfo($dbname,$masterhost,$masterport,$masteruser,$masterpassword);
44
45 my $conn = Pg::connectdb($minfo);
46 if ($conn->status != PGRES_CONNECTION_OK) {
47 print STDERR "Failed opening $minfo\n";
48 exit 1;
49 }
50
51 $result = $conn->exec("BEGIN");
52 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
53
54 $result = $conn->exec("DROP TRIGGER _RSERV_TRIGGER_T_ ON \"$table\"");
55 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
56
57 $result = $conn->exec("DELETE FROM _RSERV_TABLES_ WHERE tname='$table'");
58 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
59
60 $result = $conn->exec("COMMIT");
61 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
62
63 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26