/[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

Diff of /bin/GetSyncID

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by dpavlin, Thu Dec 21 14:27:11 2000 UTC revision 1.8 by dpavlin, Sun Nov 2 10:21:45 2003 UTC
# Line 1  Line 1 
1  # -*- perl -*-  #!/usr/bin/perl -w
2  # GetSyncID  # GetSyncID
3  # Vadim Mikheev, (c) 2000, PostgreSQL Inc.  # Vadim Mikheev, (c) 2000, PostgreSQL Inc.
4    
# Line 6  eval '(exit $?0)' && eval 'exec perl -S Line 6  eval '(exit $?0)' && eval 'exec perl -S
6      & eval 'exec perl -S $0 $argv:q'      & eval 'exec perl -S $0 $argv:q'
7      if 0;      if 0;
8    
9  use lib "@LIBDIR@";  BEGIN {
10            my $basedir = $0; $basedir =~ s#/[^/]+$##;
11            unshift(@INC, "$basedir/../share");
12    }
13    
14    use strict;
15  use Pg;  use Pg;
16  use Getopt::Long;  use Getopt::Long;
17  use RServ;  use RServ;
18    
19  $| = 1;  $| = 1;
20    
21  my $verbose = 1;  my ($debug,$verbose) = (0,1);
22    my ($help,$slavehost,$slaveport,$slaveuser,$slavepassword);
 $result = GetOptions("debug!", "verbose!", "help",  
                      "host=s", "user=s", "password=s");  
23    
24  my $debug = $opt_debug || 0;  my $result = GetOptions(
25  my $verbose = $opt_verbose if (defined($opt_verbose));          "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
32    Options:
33            --slavehost=hostname --slaveport=port
34            --slaveuser=username --slavepassword=string
35    ";
36        exit ((scalar(@ARGV) < 1)? 1:0);
37    }
38    
39  if (defined($opt_help) || (scalar(@ARGV) < 1)) {  $RServ::quiet = !$verbose;
40      print "Usage: $0 --host=name --user=name --password=string slavedb\n";  if ($debug) {
41      exit ((scalar(@ARGV) < 1)? 1: 0);          $RServ::quiet = 0;
42            no warnings 'vars';
43            $RServ::debug = $debug;
44  }  }
45    
46  my $dbname = $ARGV[0];  my $dbname = $ARGV[0];
47    
48  my $sinfo = "dbname=$dbname";  my $sinfo = MkInfo($dbname,$slavehost,$slaveport,$slaveuser,$slavepassword);
 $sinfo = "$sinfo host=$opt_host" if (defined($opt_host));  
 $sinfo = "$sinfo user=$opt_user" if (defined($opt_user));  
 $sinfo = "$sinfo password=$opt_password" if (defined($opt_password));  
49    
50  print("Connecting to '$sinfo'\n") if ($debug || $verbose);  print("Connecting to '$sinfo'\n") if ($debug || $verbose);
51  my $conn = Pg::connectdb($sinfo);  my $conn = Pg::connectdb($sinfo);
52    
53  $res = GetSyncID($conn);  my $res = GetSyncID($conn);
   
 die "ERROR\n" if $res < 0;  
54    
55  if (! defined $res)  if (! defined $res || $res < 0)
56  {  {
57      printf STDERR "No SyncID found\n";      printf STDERR "No SyncID found in $dbname\n";
58        exit(1);
59  }  }
60  else  else
61  {  {

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.26