43 |
|
|
44 |
sub PrepareSnapshot |
sub PrepareSnapshot |
45 |
{ |
{ |
46 |
my ($conn, $sconn, $outf, $server) = @_; # (@_[0], @_[1], @_[2], $_[3]); |
my ($conn, $sconn, $outf, $server, $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_"); |
89 |
while (@row = $result->fetchrow) |
while (@row = $result->fetchrow) |
90 |
{ |
{ |
91 |
# printf "$row[0], $row[1], $row[2]\n"; |
# printf "$row[0], $row[1], $row[2]\n"; |
92 |
|
if (ref($onlytables) eq 'HASH') { |
93 |
|
next unless (exists $onlytables->{$row[1]}); |
94 |
|
$onlytables->{$row[1]} = $row[0] unless ($onlytables->{$row[1]}); |
95 |
|
} |
96 |
push @{$Mtables{$row[0]}}, $row[1], $row[2], $row[3]; |
push @{$Mtables{$row[0]}}, $row[1], $row[2], $row[3]; |
97 |
} |
} |
98 |
|
|
334 |
|
|
335 |
sub CleanLog |
sub CleanLog |
336 |
{ |
{ |
337 |
my ($conn, $howold) = @_; # (@_[0], @_[1]); |
my ($conn, $howold, $onlytables) = @_; # (@_[0], @_[1]); |
338 |
|
|
339 |
my $result = $conn->exec("BEGIN"); |
my $result = $conn->exec("BEGIN"); |
340 |
if ($result->resultStatus ne PGRES_COMMAND_OK) |
if ($result->resultStatus ne PGRES_COMMAND_OK) |
376 |
my $alist = join(',', keys %active); |
my $alist = join(',', keys %active); |
377 |
my $sinfo = "logid < $maxid"; |
my $sinfo = "logid < $maxid"; |
378 |
$sinfo .= " AND logid not in ($alist)" if $alist ne ''; |
$sinfo .= " AND logid not in ($alist)" if $alist ne ''; |
379 |
|
#if (ref($onlytables) eq 'HASH') { |
380 |
|
# foreach my $onlytable (keys %{$onlytables}) { |
381 |
|
# $sinfo |
382 |
|
# } |
383 |
|
#} |
384 |
$sql = "delete from _RSERV_LOG_ where " . |
$sql = "delete from _RSERV_LOG_ where " . |
385 |
"logtime < now() - '$howold second'::interval AND $sinfo"; |
"logtime < now() - '$howold second'::interval AND $sinfo"; |
386 |
|
|
408 |
|
|
409 |
sub ApplySnapshot |
sub ApplySnapshot |
410 |
{ |
{ |
411 |
my ($conn, $inpf) = @_; # (@_[0], @_[1]); |
my ($conn, $inpf, $onlytables) = @_; # (@_[0], @_[1]); |
412 |
|
|
413 |
my $result = $conn->exec("BEGIN"); |
my $result = $conn->exec("BEGIN"); |
414 |
if ($result->resultStatus ne PGRES_COMMAND_OK) |
if ($result->resultStatus ne PGRES_COMMAND_OK) |
443 |
while (my @row = $result->fetchrow) |
while (my @row = $result->fetchrow) |
444 |
{ |
{ |
445 |
# printf "\t%s\t%s\t%s\t\n", $row[1], $row[0], $row[2], $row[3]; |
# printf "\t%s\t%s\t%s\t\n", $row[1], $row[0], $row[2], $row[3]; |
446 |
|
if (ref($onlytables) eq 'HASH') { |
447 |
|
next unless (exists $onlytables->{$row[1]}); |
448 |
|
$onlytables->{$row[1]} = $row[0] unless ($onlytables->{$row[1]}); |
449 |
|
} |
450 |
push @{$Stables{$row[1]}}, $row[0], $row[2], $row[3]; |
push @{$Stables{$row[1]}}, $row[0], $row[2], $row[3]; |
451 |
} |
} |
452 |
|
|