/[rserv]/share/RServ.pm
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 /share/RServ.pm

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

revision 1.7 by dpavlin, Tue Oct 28 20:09:47 2003 UTC revision 1.8 by dpavlin, Tue Oct 28 20:16:39 2003 UTC
# Line 43  sub GetSlaveId Line 43  sub GetSlaveId
43    
44  sub PrepareSnapshot  sub PrepareSnapshot
45  {  {
46      my ($mconn, $sconn, $outf, $server, $onlytables) = @_;      my ($mconn, $sconn, $outf, $sserver, $onlytables) = @_;
47    
48      # first, we must know for wich tables the slave subscribed      # first, we must know for wich tables the slave subscribed
49      my $result = $sconn->exec("SELECT tname FROM _RSERV_SLAVE_TABLES_");      my $result = $sconn->exec("SELECT tname FROM _RSERV_SLAVE_TABLES_");
# Line 98  sub PrepareSnapshot Line 98  sub PrepareSnapshot
98            
99      # Read last succeeded sync      # Read last succeeded sync
100      my $sql = "select syncid, synctime, minid, maxid, active from _RSERV_SYNC_" .      my $sql = "select syncid, synctime, minid, maxid, active from _RSERV_SYNC_" .
101          " where server = $server AND syncid = (select max(syncid) from" .          " where server = $sserver AND syncid = (select max(syncid) from" .
102          " _RSERV_SYNC_ where server = $server AND status > 0)";          " _RSERV_SYNC_ where server = $sserver AND status > 0)";
103            
104      printf "$sql\n" if $debug;      printf "$sql\n" if $debug;
105    
# Line 273  sub PrepareSnapshot Line 273  sub PrepareSnapshot
273      }      }
274            
275      # Remember this snapshot info      # Remember this snapshot info
276      $result = $mconn->exec("select _rserv_sync_($server)");      $result = $mconn->exec("select _rserv_sync_($sserver)");
277      if ($result->resultStatus ne PGRES_TUPLES_OK)      if ($result->resultStatus ne PGRES_TUPLES_OK)
278      {      {
279          printf $outf "-- ERROR\n";          printf $outf "-- ERROR\n";
# Line 916  sub GetSyncID Line 916  sub GetSyncID
916  #  #
917  sub SyncSyncID  sub SyncSyncID
918  {  {
919      my ($mconn, $server, $syncid) = @_; # (@_[0], @_[1], @_[2]);      my ($mconn, $sserver, $syncid) = @_; # (@_[0], @_[1], @_[2]);
920            
921      my $result = $mconn->exec("BEGIN");      my $result = $mconn->exec("BEGIN");
922      if ($result->resultStatus ne PGRES_COMMAND_OK)      if ($result->resultStatus ne PGRES_COMMAND_OK)
# Line 927  sub SyncSyncID Line 927  sub SyncSyncID
927      }      }
928            
929      $result = $mconn->exec("select synctime, status from _RSERV_SYNC_" .      $result = $mconn->exec("select synctime, status from _RSERV_SYNC_" .
930                            " where server = $server AND syncid = $syncid" .                            " where server = $sserver AND syncid = $syncid" .
931                            " for update");                            " for update");
932      if ($result->resultStatus ne PGRES_TUPLES_OK)      if ($result->resultStatus ne PGRES_TUPLES_OK)
933      {      {
# Line 938  sub SyncSyncID Line 938  sub SyncSyncID
938      my @row = $result->fetchrow;      my @row = $result->fetchrow;
939      if (! defined $row[0])      if (! defined $row[0])
940      {      {
941          printf STDERR "No SyncID $syncid found for server $server\n" unless ($quiet);          printf STDERR "No SyncID $syncid found for server $sserver\n" unless ($quiet);
942          $mconn->exec("ROLLBACK");          $mconn->exec("ROLLBACK");
943          return(0);          return(0);
944      }      }
945      if ($row[1] > 0)      if ($row[1] > 0)
946      {      {
947          printf STDERR "SyncID $syncid for server ".          printf STDERR "SyncID $syncid for server ".
948              "$server already updated\n" unless ($quiet);              "$sserver already updated\n" unless ($quiet);
949          $mconn->exec("ROLLBACK");          $mconn->exec("ROLLBACK");
950          return(0);          return(0);
951      }      }
952      $result = $mconn->exec("update _RSERV_SYNC_" .      $result = $mconn->exec("update _RSERV_SYNC_" .
953                            " set synctime = now(), status = 1" .                            " set synctime = now(), status = 1" .
954                            " where server = $server AND syncid = $syncid");                            " where server = $sserver AND syncid = $syncid");
955      if ($result->resultStatus ne PGRES_COMMAND_OK)      if ($result->resultStatus ne PGRES_COMMAND_OK)
956      {      {
957          print STDERR $mconn->errorMessage unless ($quiet);          print STDERR $mconn->errorMessage unless ($quiet);
# Line 959  sub SyncSyncID Line 959  sub SyncSyncID
959          return(-1);          return(-1);
960      }      }
961      $result = $mconn->exec("delete from _RSERV_SYNC_" .      $result = $mconn->exec("delete from _RSERV_SYNC_" .
962                            " where server = $server AND syncid < $syncid");                            " where server = $sserver AND syncid < $syncid");
963      if ($result->resultStatus ne PGRES_COMMAND_OK)      if ($result->resultStatus ne PGRES_COMMAND_OK)
964      {      {
965          print STDERR $mconn->errorMessage unless ($quiet);          print STDERR $mconn->errorMessage unless ($quiet);

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

  ViewVC Help
Powered by ViewVC 1.1.26