/[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.6 - (show annotations)
Fri Aug 15 23:00:27 2003 UTC (20 years, 8 months ago) by dpavlin
Branch: MAIN
CVS Tags: before_onlytables, before_multmaster, r_0_3
Changes since 1.5: +0 -3 lines
Snapshot fixes

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
23 my $result = GetOptions(
24 "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
25 "masterhost=s" => \$masterhost, "masterport=i" => \$masterport,
26 "masteruser=s" => \$masteruser, "masterpassword=s" => \$masterpassword,
27 );
28
29 if (defined($help) || (scalar(@ARGV) < 2) || ($ARGV[1] !~ /^\d+$/)) {
30 print "Usage: $0 [options] masterdb syncid
31 Options:
32 --masterhost=hostname --masterport=port
33 --masteruser=username --masterpassword=string
34 ";
35 exit ((scalar(@ARGV) < 2)? 1:0);
36 }
37
38 $RServ::quiet = !$verbose;
39 if ($debug) {
40 $RServ::quiet = 0;
41 no warnings 'vars';
42 $RServ::debug = $debug;
43 }
44
45 my $dbname = $ARGV[0];
46 my $howold = $ARGV[1];
47
48 my $minfo = "dbname=$dbname";
49 $minfo = "$minfo host=$masterhost" if (defined($masterhost));
50 $minfo = "$minfo port=$masterport" if (defined($masterport));
51 $minfo = "$minfo user=$masteruser" if (defined($masteruser));
52 $minfo = "$minfo password=$masterpassword" if (defined($masterpassword));
53
54 print "Master connection is $minfo\n" if ($debug);
55
56 my $conn = Pg::connectdb($minfo);
57
58 my $res = CleanLog($conn, $howold);
59
60 exit(1) if $res < 0;
61
62 printf STDERR "Deleted %d log records\n", $res if $res > 0;
63
64 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26