Allow 'bucardo validate' to drop the autokick triggers if they are no longer needed.
authorGreg Sabino Mullane <greg@endpoint.com>
Mon, 27 Jul 2015 02:18:58 +0000 (22:18 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Mon, 27 Jul 2015 02:18:58 +0000 (22:18 -0400)
For example, if one does: bucardo update sync foobar autokick=false; bucardo validate foobar
Outputs a large warning so this should not catch people unaware.

bucardo.schema

index ff26d352f6798638da72ff27e5bbeb97a0bc17ec..c366f30dd2677863e28b4624a167536853cc440a 100644 (file)
@@ -2507,7 +2507,16 @@ FOR EACH ROW EXECUTE PROCEDURE bucardo.bucardo_delta_names_helper();
 
             ## Add in the autokick triggers as needed
             ## Skip if autokick is false
-            $info->{autokick} eq 'f' and next TABLE;
+                       if ($info->{autokick} eq 'f') {
+                if (exists $btriggerinfo{$schema}{$table}{$kickfunc}) {
+                    $SQL = qq{DROP TRIGGER "$kickfunc" ON $safeschema.$safetable};
+                                       ## This is important enough that we want to be verbose about it:
+                                       warn "Dropped trigger $kickfunc from table $safeschema.$safetable\n";
+                    $run_sql->($SQL,$dbh);
+                    delete $btriggerinfo{$schema}{$table}{$kickfunc};
+                }
+                           next TABLE;
+            }
             if (! exists $btriggerinfo{$schema}{$table}{$kickfunc}) {
                 my $ttrig = $dbh->{pg_server_version} >= 80400 ? ' OR TRUNCATE' : '';
                 my $custom_trigger_level = '';