From: David E. Wheeler Date: Fri, 7 Dec 2012 01:05:01 +0000 (-0800) Subject: Try always committing deltas on 8.4 and higher. X-Git-Tag: 4.99.7~59 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=964ac9b960bf85fe7bf01d0ece9f944170f20703;p=bucardo.git Try always committing deltas on 8.4 and higher. 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). --- diff --git a/bucardo.schema b/bucardo.schema index a3dfa3e88..fa135f647 100644 --- a/bucardo.schema +++ b/bucardo.schema @@ -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 diff --git a/t/10-makedelta.t b/t/10-makedelta.t index 1e025e767..88b44f935 100644 --- a/t/10-makedelta.t +++ b/t/10-makedelta.t @@ -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(