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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 #!/usr/bin/perl -w
2 # GetSyncID
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 Pg;
16 use Getopt::Long;
17 use RServ;
18
19 $| = 1;
20
21 my ($debug,$verbose) = (0,1);
22 my ($help,$slavehost,$slaveport,$slaveuser,$slavepassword);
23
24 my $result = GetOptions(
25 "debug!" => \$debug, "verbose!" => \$verbose, "help" => \$help,
26 "slavehost=s" => \$slavehost, "slaveport=i" => \$slaveport,
27 "slaveuser=s" => \$slaveuser, "slavepassword=s" => \$slavepassword,
28 );
29
30 if (defined($help) || (scalar(@ARGV) < 1)) {
31 print "Usage: $0 [options] slavedb table column
32 Options:
33 --slavehost=hostname --slaveport=port
34 --slaveuser=username --slavepassword=string
35 ";
36 exit ((scalar(@ARGV) < 1)? 1:0);
37 }
38
39 my $dbname = $ARGV[0];
40
41 my $sinfo = "dbname=$dbname";
42 $sinfo = "$sinfo host=$slavehost" if (defined($slavehost));
43 $sinfo = "$sinfo port=$slaveport" if (defined($slaveport));
44 $sinfo = "$sinfo user=$slaveuser" if (defined($slaveuser));
45 $sinfo = "$sinfo password=$slavepassword" if (defined($slavepassword));
46
47 print("Connecting to '$sinfo'\n") if ($debug || $verbose);
48 my $conn = Pg::connectdb($sinfo);
49
50 my $res = GetSyncID($conn);
51
52 die "ERROR\n" if $res < 0;
53
54 if (! defined $res)
55 {
56 printf STDERR "No SyncID found\n";
57 }
58 else
59 {
60 print("Last SyncID applied: ") if ($verbose);
61 printf "%d", $res;
62 print("\n") if ($verbose);
63 }
64
65 exit(0);

  ViewVC Help
Powered by ViewVC 1.1.26