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

Diff of /bin/MasterDelTable

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.4 by dpavlin, Sun Nov 2 10:31:44 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl -w
2  # MasterAddTable  # MasterAddTable
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    BEGIN {
10            my $basedir = $0; $basedir =~ s#/[^/]+$##;
11            unshift(@INC, "$basedir/../share");
12    }
13    
14  use Pg;  use Pg;
15  use Getopt::Long;  use Getopt::Long;
16    use strict;
17    use RServ;
18    
19  $| = 1;  $| = 1;
20    
21  $result = GetOptions("debug!", "verbose!", "help",  my ($debug,$verbose) = (0,0);
22                       "host=s", "user=s", "password=s");  my ($help,$masterhost,$masterport,$masteruser,$masterpassword);
   
 my $debug = $opt_debug || 0;  
 my $verbose = $opt_verbose || 0;  
23    
24  if (defined($opt_help) || (scalar(@ARGV) < 2)) {  my $result = GetOptions(
25      print "Usage: $0 --host=name --user=name --password=string masterdb table\n";          "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
26      exit ((scalar(@ARGV) < 3)? 1: 0);          "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];  my $dbname = $ARGV[0];
40  my $table = $ARGV[1];  my $table = $ARGV[1];
41  #my $keyname = $ARGV[2];  #my $keyname = $ARGV[2];
42    
43  my $minfo = "dbname=$dbname";  my $minfo = MkInfo($dbname,$masterhost,$masterport,$masteruser,$masterpassword);
 $minfo = "$minfo host=$opt_host" if (defined($opt_host));  
 $minfo = "$minfo user=$opt_user" if (defined($opt_user));  
 $minfo = "$minfo password=$opt_password" if (defined($opt_password));  
44    
45  my $conn = Pg::connectdb($minfo);  my $conn = Pg::connectdb($minfo);
46  if ($conn->status != PGRES_CONNECTION_OK) {  if ($conn->status != PGRES_CONNECTION_OK) {
# Line 37  if ($conn->status != PGRES_CONNECTION_OK Line 48  if ($conn->status != PGRES_CONNECTION_OK
48      exit 1;      exit 1;
49  }  }
50    
51  my $result = $conn->exec("BEGIN");  $result = $conn->exec("BEGIN");
52  die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;  die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
53    
54  $result = $conn->exec("DROP TRIGGER _RSERV_TRIGGER_T_ ON \"$table\"");  $result = $conn->exec("DROP TRIGGER _RSERV_TRIGGER_T_ ON \"$table\"");

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

  ViewVC Help
Powered by ViewVC 1.1.26