/[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.1 - (show annotations)
Tue Aug 5 09:52:36 2003 UTC (20 years, 8 months ago) by dpavlin
Branch: MAIN
rserv 0.2 changes by Nélio Alves Pereira Filho

1 #!/usr/bin/perl
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 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 masterdb table\n";
22 exit ((scalar(@ARGV) < 3)? 1: 0);
23 }
24
25 my $dbname = $ARGV[0];
26 my $table = $ARGV[1];
27 #my $keyname = $ARGV[2];
28
29 my $minfo = "dbname=$dbname";
30 $minfo = "$minfo host=$opt_host" if (defined($opt_host));
31 $minfo = "$minfo user=$opt_user" if (defined($opt_user));
32 $minfo = "$minfo password=$opt_password" if (defined($opt_password));
33
34 my $conn = Pg::connectdb($minfo);
35 if ($conn->status != PGRES_CONNECTION_OK) {
36 print STDERR "Failed opening $minfo\n";
37 exit 1;
38 }
39
40 my $result = $conn->exec("BEGIN");
41 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
42
43 $result = $conn->exec("DROP TRIGGER _RSERV_TRIGGER_T_ ON \"$table\"");
44 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
45
46 $result = $conn->exec("DELETE FROM _RSERV_TABLES_ WHERE tname='$table'");
47 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
48
49 $result = $conn->exec("COMMIT");
50 die $conn->errorMessage if $result->resultStatus ne PGRES_COMMAND_OK;
51
52 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26