bdr: Always use the correct relation name in truncation triggers.
authorAndres Freund <[email protected]>
Mon, 28 Apr 2014 18:47:32 +0000 (20:47 +0200)
committerAndres Freund <[email protected]>
Thu, 3 Jul 2014 15:55:28 +0000 (17:55 +0200)
contrib/bdr/bdr--0.5.sql

index 4df82521e2b2a35d9fdd267878e6be63c4ee8833..f5ba5303eecd1aa1943d49f4550e54b89fb949c2 100644 (file)
@@ -165,7 +165,7 @@ DECLARE
     ident TEXT;
 BEGIN
 
-    ident := TG_ARGV[0];
+    ident := quote_ident(TG_TABLE_SCHEMA)||'.'||quote_ident(TG_TABLE_NAME);
 
     INSERT INTO bdr.bdr_queued_commands
         (obj_type, obj_identity, command, executed)
@@ -214,9 +214,7 @@ BEGIN
         IF TG_TAG = 'CREATE TABLE' and r.object_type = 'table' THEN
             EXECUTE 'CREATE TRIGGER truncate_trigger AFTER TRUNCATE ON ' ||
                     r.identity ||
-                    ' FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate(' ||
-                    quote_literal(r.identity) ||
-                    ')';
+                    ' FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()';
         END IF;
     END LOOP;
 END;