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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Tue Aug 5 21:10:28 2003 UTC (20 years, 8 months ago) by dpavlin
Branch: MAIN
Changes since 1.3: +30 -17 lines
command line options cleanup and cosistency fix, modification to work
under "use strict;"

1 #!/usr/bin/perl -w
2 # CleanLog
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 strict;
15 use Getopt::Long;
16 use RServ;
17
18 $| = 1;
19
20 my ($debug,$verbose) = (0,0);
21 my ($help,$masterhost,$masterport,$masteruser,$masterpassword);
22 my $snapshot = "__Snapshot";
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 "snapshot=s" => \$snapshot,
29 );
30
31 if (defined($help) || (scalar(@ARGV) < 2) || ($ARGV[1] !~ /^\d+$/)) {
32 print "Usage: $0 [options] masterdb syncid
33 Options:
34 --masterhost=hostname --masterport=port
35 --masteruser=username --masterpassword=string
36 --snapshot=snapshot
37 ";
38 exit ((scalar(@ARGV) < 2)? 1:0);
39 }
40
41 my $dbname = $ARGV[0];
42 my $howold = $ARGV[1];
43
44 my $minfo = "dbname=$dbname";
45 $minfo = "$minfo host=$masterhost" if (defined($masterhost));
46 $minfo = "$minfo port=$masterport" if (defined($masterport));
47 $minfo = "$minfo user=$masteruser" if (defined($masteruser));
48 $minfo = "$minfo password=$masterpassword" if (defined($masterpassword));
49
50 print "Master connection is $minfo\n" if ($debug);
51
52 my $conn = Pg::connectdb($minfo);
53
54 my $res = CleanLog($conn, $howold);
55
56 exit(1) if $res < 0;
57
58 printf STDERR "Deleted %d log records\n", $res if $res > 0;
59
60 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26