Don't drop new table if there are any @triggers_not_dropped.

This commit is contained in:
Daniel Nichter
2013-06-07 13:51:29 -07:00
parent cb68de027d
commit df0eb984d7
3 changed files with 136 additions and 9 deletions

View File

@@ -0,0 +1,36 @@
package pt_online_schema_change_plugin;
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
sub new {
my ($class, %args) = @_;
my $self = { %args };
return bless $self, $class;
}
sub init {
my ($self, %args) = @_;
print "PLUGIN: init()\n";
$self->{orig_tbl} = $args{orig_tbl};
}
sub before_drop_triggers {
my ($self, %args) = @_;
print "PLUGIN: before_drop_triggers()\n";
my $dbh = $self->{aux_cxn}->dbh;
my $orig_tbl = $self->{orig_tbl};
# Start a trx and get a metadata lock on the table being altered.
$dbh->do('SET autocommit=0');
$dbh->{AutoCommit} = 0;
$dbh->do("START TRANSACTION");
$dbh->do("SELECT * FROM " . $orig_tbl->{name});
return;
}
1;