/usr/share/perl5/TableSyncStream.pm is in percona-toolkit 3.0.6+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | # This program is copyright 2007-2011 Baron Schwartz, 2011 Percona Ireland Ltd.
# Feedback and improvements are welcome.
#
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, version 2; OR the Perl Artistic License. On UNIX and similar
# systems, you can issue `man perlgpl' or `man perlartistic' to read these
# licenses.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
# ###########################################################################
# TableSyncStream package
# ###########################################################################
{
# Package: TableSyncStream
# TableSyncStream is a table sync algo that selects all rows.
# This package implements the simplest possible table-sync algorithm:
# read every row from the tables and compare them.
package TableSyncStream;
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
sub new {
my ( $class, %args ) = @_;
foreach my $arg ( qw(Quoter) ) {
die "I need a $arg argument" unless $args{$arg};
}
my $self = { %args };
return bless $self, $class;
}
sub name {
return 'Stream';
}
sub can_sync {
return 1; # We can sync anything.
}
sub prepare_to_sync {
my ( $self, %args ) = @_;
my @required_args = qw(cols ChangeHandler);
foreach my $arg ( @required_args ) {
die "I need a $arg argument" unless $args{$arg};
}
$self->{cols} = $args{cols};
$self->{buffer_in_mysql} = $args{buffer_in_mysql};
$self->{ChangeHandler} = $args{ChangeHandler};
$self->{done} = 0;
return;
}
sub uses_checksum {
return 0; # We don't need checksum queries.
}
sub set_checksum_queries {
return; # This shouldn't be called, but just in case.
}
sub prepare_sync_cycle {
my ( $self, $host ) = @_;
return;
}
sub get_sql {
my ( $self, %args ) = @_;
return "SELECT "
. ($self->{buffer_in_mysql} ? 'SQL_BUFFER_RESULT ' : '')
. join(', ', map { $self->{Quoter}->quote($_) } @{$self->{cols}})
. ' FROM ' . $self->{Quoter}->quote(@args{qw(database table)})
. ' WHERE ' . ( $args{where} || '1=1' );
}
sub same_row {
my ( $self, %args ) = @_;
return;
}
sub not_in_right {
my ( $self, %args ) = @_;
$self->{ChangeHandler}->change('INSERT', $args{lr}, $self->key_cols());
}
sub not_in_left {
my ( $self, %args ) = @_;
$self->{ChangeHandler}->change('DELETE', $args{rr}, $self->key_cols());
}
sub done_with_rows {
my ( $self ) = @_;
$self->{done} = 1;
}
sub done {
my ( $self ) = @_;
return $self->{done};
}
sub key_cols {
my ( $self ) = @_;
return $self->{cols};
}
# Return 1 if you have changes yet to make and you don't want the TableSyncer to
# commit your transaction or release your locks.
sub pending_changes {
my ( $self ) = @_;
return;
}
sub _d {
my ($package, undef, $line) = caller 0;
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
map { defined $_ ? $_ : 'undef' }
@_;
print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
}
1;
}
# ###########################################################################
# End TableSyncStream package
# ###########################################################################
|