1 |
dpavlin |
1.2 |
#!/usr/bin/perl |
2 |
dpavlin |
1.1 |
# 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 |
dpavlin |
1.2 |
use lib "/usr/share/postgresql/contrib"; |
10 |
dpavlin |
1.1 |
|
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 |
dpavlin |
1.2 |
$RServ::quiet = !$verbose; |
41 |
|
|
|
42 |
dpavlin |
1.1 |
$res = GetSyncID($conn); |
43 |
|
|
|
44 |
|
|
die "ERROR\n" if $res < 0; |
45 |
|
|
|
46 |
|
|
if (! defined $res) |
47 |
|
|
{ |
48 |
|
|
printf STDERR "No SyncID found\n"; |
49 |
|
|
} |
50 |
|
|
else |
51 |
|
|
{ |
52 |
|
|
print("Last SyncID applied: ") if ($verbose); |
53 |
|
|
printf "%d", $res; |
54 |
|
|
print("\n") if ($verbose); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
exit(0); |