Try always committing deltas on 8.4 and higher.
authorDavid E. Wheeler <david@justatheory.com>
Fri, 7 Dec 2012 01:05:01 +0000 (17:05 -0800)
committerDavid E. Wheeler <david@justatheory.com>
Fri, 7 Dec 2012 01:05:01 +0000 (17:05 -0800)
If we always log deltas and kick queues, we *never* need a `makedelta` option.
I'm not sure if this will really work in practice, however, for these reasons:

* I'm not entirely sure how Bucardo will handle the dupes. Given the previous
  presence of `makedelta`, I'm assuming fine, but even so I'm not sure we want
  to *always* enable them: it could create a lot more traffic between nodes.
  This could potentially be mediated by adding separate delta functions for
  each table and sync, but that might be a PITA.
* There is a failing test in t/40-postgres.t -- the very last test, in fact.
  Something related to customcols: Database D ends up with the rows values 30,
  60, 90, and 210 rather than 2, 3, 7, and 30. I am unable to figure out why
  this would be.
* There may be some other consequence of doing this that could break things
  that I, in my ignorance, and completely unaware of.
* This leaves older versions of PostgreSQL behind. But maybe we don't care?
  8.3 is mighty old (I suspect that today's release of 8.3.22 will be the
  last).

However, given all that, if this could be made to work, it's pretty damned
simple! If not, please revert this and we can come up with something else.
(Ref issue #19).

bucardo.schema
t/10-makedelta.t

index a3dfa3e88b114742aedae9d5614176a0bcba01ef..fa135f6473773564a9d4a4b5449df0f14dfbc42e 100644 (file)
@@ -2135,8 +2135,10 @@ SELECT 'Fixme'::TEXT;
                     $SQL = qq{
           CREATE TRIGGER "$trunctrig"
           AFTER TRUNCATE ON "$schema"."$table"
-          FOR EACH STATEMENT EXECUTE PROCEDURE bucardo.bucardo_note_truncation('$syncname')
+          FOR EACH STATEMENT EXECUTE PROCEDURE bucardo.bucardo_note_truncation('$syncname');
         };
+                    $SQL .= qq{ALTER TABLE "$schema"."$table" ENABLE ALWAYS TRIGGER "$trunctrig";}
+                        if $dbh->{pg_server_version} >= 80300;
                     $run_sql->($SQL,$dbh);
                 }
             }
@@ -2287,8 +2289,10 @@ SELECT 'Fixme'::TEXT;
                 $SQL = qq{
         CREATE TRIGGER bucardo_delta
         AFTER INSERT OR UPDATE OR DELETE ON "$schema"."$table"
-        FOR EACH ROW EXECUTE PROCEDURE bucardo.$func()
+        FOR EACH ROW EXECUTE PROCEDURE bucardo.$func();
       };
+                $SQL .= qq{ALTER TABLE "$schema"."$table" ENABLE ALWAYS TRIGGER bucardo_delta;}
+                    if $dbh->{pg_server_version} >= 80300;
                 $run_sql->($SQL,$dbh);
             }
 
@@ -2377,16 +2381,18 @@ SELECT 'Fixme'::TEXT;
                     $SQL = qq{
                     CREATE TRIGGER "$kickfunc" FIXMENAME
                     AFTER INSERT OR UPDATE OR DELETE$ttrig ON $safeschema.$safetable
-                    FOR EACH $custom_trigger_level EXECUTE PROCEDURE bucardo."$custom_function_name"()
+                    FOR EACH $custom_trigger_level EXECUTE PROCEDURE bucardo."$custom_function_name"();
                     };
                 }
                 else {
                     $SQL = qq{
                     CREATE TRIGGER "$kickfunc"
                     AFTER INSERT OR UPDATE OR DELETE$ttrig ON $safeschema.$safetable
-                    FOR EACH STATEMENT EXECUTE PROCEDURE bucardo."$kickfunc"()
+                    FOR EACH STATEMENT EXECUTE PROCEDURE bucardo."$kickfunc"();
                     };
                 }
+                $SQL .= qq{ALTER TABLE $safeschema.$safetable ENABLE ALWAYS TRIGGER "$kickfunc";}
+                    if $dbh->{pg_server_version} >= 80300;
                 $run_sql->($SQL,$dbh);
             }
         } ## end each TABLE
index 1e025e767bc5da6e758185272d3e942529c5e955..88b44f935c80bad0fea4e667c085b67004a670eb 100644 (file)
@@ -78,8 +78,8 @@ $dbhA->commit;
 ok $bct->wait_for_notice($dbhX, 'bucardo_syncdone_deltatest1'),
     'Second deltatest1 sync should finish';
 # XXX Uncomment once makedelta actually works.
-ok $bct->wait_for_notice($dbhX, 'bucardo_syncdone_deltatest2'),
-    'Second deltatest2 sync should finish';
+ok $bct->wait_for_notice($dbhX, 'bucardo_syncdone_deltatest2'),
+    'Second deltatest2 sync should finish';
 
 # The row should be in all three databases.
 is_deeply $dbhB->selectall_arrayref(