Permalink
Browse files

A few additional fixups for adding TRUNCATE triggers.

-Do not call the deprecated/removed add_replica_trigger function
-Have the unit test use the proper syntax for a cascaded truncate
-truncate triggers do not show up in the information_schema (at least up to 9.1).
 query pg_trigger directly to check if the truncate triggers exist.
  • Loading branch information...
1 parent 6838c61 commit 16cbe8ec0caf64d0c9c630385ac83b9957b8d65e @ssinger ssinger committed Oct 11, 2011
Showing with 15 additions and 10 deletions.
  1. +2 −4 RELEASE
  2. +1 −1 clustertest/regression/testtruncate/truncate-cascade.sql
  3. +12 −5 src/backend/slony1_funcs.v84.sql
View
@@ -1,14 +1,12 @@
#+OPTIONS: ^:{}
* Slony-I Release Notes
-** 2.1.0 RC 3
-
-- Bug #237 :: Drop set did not remove truncate triggers.
-
** 2.1.0 RC 2
- Add support for PostgreSQL 9.1. Simply marking it a supported version
+- Bug #237 :: Drop set did not remove truncate triggers.
+
** 2.1.0 RC 1
- Bug #236 :: Fix default formatting of timestamp in logs
@@ -1 +1 @@
-truncate orders with cascade;
+truncate orders cascade;
@@ -113,9 +113,14 @@ begin
begin
perform @NAMESPACE@.alterTableAddTruncateTrigger(@NAMESPACE@.slon_quote_brute(tab_nspname) || '.' || @NAMESPACE@.slon_quote_brute(tab_relname), tab_id)
from @NAMESPACE@.sl_table
- where 2 <> (select count(*) from information_schema.triggers where
- event_object_schema = tab_nspname and trigger_name in ('_@CLUSTERNAME@_truncatedeny', '_@CLUSTERNAME@_truncatetrigger') and
- event_object_table = tab_relname);
+ where 2 <> (select count(*) from pg_catalog.pg_trigger,
+ pg_catalog.pg_class, pg_catalog.pg_namespace where
+ pg_trigger.tgrelid=pg_class.oid
+ AND pg_class.relnamespace=pg_namespace.oid
+ AND
+ pg_namespace.nspname = tab_nspname and tgname in ('_@CLUSTERNAME@_truncatedeny', '_@CLUSTERNAME@_truncatetrigger') and
+ pg_class.relname = tab_relname
+ );
exception when unique_violation then
raise warning 'upgradeSchemaAddTruncateTriggers() - uniqueness violation';
@@ -124,12 +129,14 @@ begin
end;
-- Activate truncate triggers for replica
- perform @NAMESPACE@.replica_truncate_trigger(@NAMESPACE@.slon_quote_brute(tab_nspname) || '.' || @NAMESPACE@.slon_quote_brute(tab_relname))
+ perform @NAMESPACE@.alterTableConfigureTruncateTrigger(@NAMESPACE@.slon_quote_brute(tab_nspname) || '.' || @NAMESPACE@.slon_quote_brute(tab_relname)
+ ,'disable','enable')
from @NAMESPACE@.sl_table
where tab_set not in (select set_id from @NAMESPACE@.sl_set where set_origin = @NAMESPACE@.getLocalNodeId('_@CLUSTERNAME@'));
-- Activate truncate triggers for origin
- perform @NAMESPACE@.origin_truncate_trigger(@NAMESPACE@.slon_quote_brute(tab_nspname) || '.' || @NAMESPACE@.slon_quote_brute(tab_relname))
+ perform @NAMESPACE@.alterTableConfigureTruncateTrigger(@NAMESPACE@.slon_quote_brute(tab_nspname) || '.' || @NAMESPACE@.slon_quote_brute(tab_relname)
+ ,'enable','disable')
from @NAMESPACE@.sl_table
where tab_set in (select set_id from @NAMESPACE@.sl_set where set_origin = @NAMESPACE@.getLocalNodeId('_@CLUSTERNAME@'));

0 comments on commit 16cbe8e

Please sign in to comment.