1
package pt_online_schema_change_plugin;
4
use warnings FATAL => 'all';
5
use English qw(-no_match_vars);
6
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
9
my ($class, %args) = @_;
11
return bless $self, $class;
15
my ($self, %args) = @_;
16
print "PLUGIN: init()\n";
17
$self->{orig_tbl} = $args{orig_tbl};
20
sub before_create_triggers {
21
my ($self, %args) = @_;
22
print "PLUGIN: before_create_triggers()\n";
24
my $dbh = $self->{aux_cxn}->dbh;
25
my $orig_tbl = $self->{orig_tbl};
27
# Start a trx and get a metadata lock on the table being altered.
28
$dbh->do('SET autocommit=0');
29
$dbh->{AutoCommit} = 0;
30
$dbh->do("START TRANSACTION");
31
$dbh->do("SELECT * FROM " . $orig_tbl->{name});
36
sub after_create_triggers {
37
my ($self, %args) = @_;
38
print "PLUGIN: after_create_triggers()\n";
40
my $dbh = $self->{aux_cxn}->dbh;
42
# Commit the trx to release the metadata lock.