1 |
# -*- perl -*- |
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 |
use lib "@LIBDIR@"; |
10 |
|
11 |
use Pg; |
12 |
use Getopt::Long; |
13 |
use RServ; |
14 |
|
15 |
$| = 1; |
16 |
|
17 |
my $verbose = 1; |
18 |
|
19 |
$result = GetOptions("debug!", "verbose!", "help", |
20 |
"host=s", "user=s", "password=s"); |
21 |
|
22 |
my $debug = $opt_debug || 0; |
23 |
my $verbose = $opt_verbose if (defined($opt_verbose)); |
24 |
|
25 |
if (defined($opt_help) || (scalar(@ARGV) < 1)) { |
26 |
print "Usage: $0 --host=name --user=name --password=string slavedb\n"; |
27 |
exit ((scalar(@ARGV) < 1)? 1: 0); |
28 |
} |
29 |
|
30 |
my $dbname = $ARGV[0]; |
31 |
|
32 |
my $sinfo = "dbname=$dbname"; |
33 |
$sinfo = "$sinfo host=$opt_host" if (defined($opt_host)); |
34 |
$sinfo = "$sinfo user=$opt_user" if (defined($opt_user)); |
35 |
$sinfo = "$sinfo password=$opt_password" if (defined($opt_password)); |
36 |
|
37 |
print("Connecting to '$sinfo'\n") if ($debug || $verbose); |
38 |
my $conn = Pg::connectdb($sinfo); |
39 |
|
40 |
$res = GetSyncID($conn); |
41 |
|
42 |
die "ERROR\n" if $res < 0; |
43 |
|
44 |
if (! defined $res) |
45 |
{ |
46 |
printf STDERR "No SyncID found\n"; |
47 |
} |
48 |
else |
49 |
{ |
50 |
print("Last SyncID applied: ") if ($verbose); |
51 |
printf "%d", $res; |
52 |
print("\n") if ($verbose); |
53 |
} |
54 |
|
55 |
exit(0); |