Thread

  1. [PATCH] fixup! Allow FOR EACH ROW triggers on partitioned tables

    Peter Eisentraut <peter_e@gmx.net> — 2018-03-22T16:07:54Z

    ---
     src/include/catalog/pg_constraint.h    |  2 +-
     src/include/commands/trigger.h         |  2 +-
     src/test/regress/expected/triggers.out | 36 +++++++++++++++++-----------------
     src/test/regress/sql/triggers.sql      | 10 +++++-----
     4 files changed, 25 insertions(+), 25 deletions(-)
    
    diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
    index 45b26cdfa8..3957e07235 100644
    --- a/src/include/catalog/pg_constraint.h
    +++ b/src/include/catalog/pg_constraint.h
    @@ -73,7 +73,7 @@ CATALOG(pg_constraint,2606)
     	Oid			conindid;		/* index supporting this constraint */
     
     	/*
    -	 * if this constraint is on a partition inherited from a partitioned table,
    +	 * If this constraint is on a partition inherited from a partitioned table,
     	 * this is the OID of the corresponding constraint in the parent.
     	 */
     	Oid			conparentid;
    diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
    index 2a6f2cd934..a5b8610fa2 100644
    --- a/src/include/commands/trigger.h
    +++ b/src/include/commands/trigger.h
    @@ -159,7 +159,7 @@ extern PGDLLIMPORT int SessionReplicationRole;
     
     extern ObjectAddress CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
     			  Oid relOid, Oid refRelOid, Oid constraintOid, Oid indexOid,
    -			  Oid funcid, Oid parentTriggerOid, Node *whenClause,
    +			  Oid funcoid, Oid parentTriggerOid, Node *whenClause,
     			  bool isInternal, bool in_partition);
     
     extern void RemoveTriggerById(Oid trigOid);
    diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
    index 2cb56efdf9..a4e9ea03f3 100644
    --- a/src/test/regress/expected/triggers.out
    +++ b/src/test/regress/expected/triggers.out
    @@ -1871,7 +1871,7 @@ drop table parted_trig;
     --
     create table trigpart (a int, b int) partition by range (a);
     create table trigpart1 partition of trigpart for values from (0) to (1000);
    -create trigger f after insert on trigpart for each row execute procedure trigger_nothing();
    +create trigger trg1 after insert on trigpart for each row execute procedure trigger_nothing();
     create table trigpart2 partition of trigpart for values from (1000) to (2000);
     create table trigpart3 (like trigpart);
     alter table trigpart attach partition trigpart3 for values from (2000) to (3000);
    @@ -1879,32 +1879,32 @@ select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger
       where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text;
       tgrelid  | tgname |     tgfoid      
     -----------+--------+-----------------
    - trigpart  | f      | trigger_nothing
    - trigpart1 | f      | trigger_nothing
    - trigpart2 | f      | trigger_nothing
    - trigpart3 | f      | trigger_nothing
    + trigpart  | trg1   | trigger_nothing
    + trigpart1 | trg1   | trigger_nothing
    + trigpart2 | trg1   | trigger_nothing
    + trigpart3 | trg1   | trigger_nothing
     (4 rows)
     
    -drop trigger f on trigpart1;	-- fail
    -ERROR:  cannot drop trigger f on table trigpart1 because trigger f on table trigpart requires it
    -HINT:  You can drop trigger f on table trigpart instead.
    -drop trigger f on trigpart2;	-- fail
    -ERROR:  cannot drop trigger f on table trigpart2 because trigger f on table trigpart requires it
    -HINT:  You can drop trigger f on table trigpart instead.
    -drop trigger f on trigpart3;	-- fail
    -ERROR:  cannot drop trigger f on table trigpart3 because trigger f on table trigpart requires it
    -HINT:  You can drop trigger f on table trigpart instead.
    +drop trigger trg1 on trigpart1;	-- fail
    +ERROR:  cannot drop trigger trg1 on table trigpart1 because trigger trg1 on table trigpart requires it
    +HINT:  You can drop trigger trg1 on table trigpart instead.
    +drop trigger trg1 on trigpart2;	-- fail
    +ERROR:  cannot drop trigger trg1 on table trigpart2 because trigger trg1 on table trigpart requires it
    +HINT:  You can drop trigger trg1 on table trigpart instead.
    +drop trigger trg1 on trigpart3;	-- fail
    +ERROR:  cannot drop trigger trg1 on table trigpart3 because trigger trg1 on table trigpart requires it
    +HINT:  You can drop trigger trg1 on table trigpart instead.
     drop table trigpart2;			-- ok, trigger should be gone in that partition
     select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger
       where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text;
       tgrelid  | tgname |     tgfoid      
     -----------+--------+-----------------
    - trigpart  | f      | trigger_nothing
    - trigpart1 | f      | trigger_nothing
    - trigpart3 | f      | trigger_nothing
    + trigpart  | trg1   | trigger_nothing
    + trigpart1 | trg1   | trigger_nothing
    + trigpart3 | trg1   | trigger_nothing
     (3 rows)
     
    -drop trigger f on trigpart;		-- ok, all gone
    +drop trigger trg1 on trigpart;		-- ok, all gone
     select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger
       where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text;
      tgrelid | tgname | tgfoid 
    diff --git a/src/test/regress/sql/triggers.sql b/src/test/regress/sql/triggers.sql
    index 4d35f39f29..edb7a2f978 100644
    --- a/src/test/regress/sql/triggers.sql
    +++ b/src/test/regress/sql/triggers.sql
    @@ -1305,19 +1305,19 @@ CREATE RULE european_city_delete_rule AS ON DELETE TO european_city_view
     --
     create table trigpart (a int, b int) partition by range (a);
     create table trigpart1 partition of trigpart for values from (0) to (1000);
    -create trigger f after insert on trigpart for each row execute procedure trigger_nothing();
    +create trigger trg1 after insert on trigpart for each row execute procedure trigger_nothing();
     create table trigpart2 partition of trigpart for values from (1000) to (2000);
     create table trigpart3 (like trigpart);
     alter table trigpart attach partition trigpart3 for values from (2000) to (3000);
     select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger
       where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text;
    -drop trigger f on trigpart1;	-- fail
    -drop trigger f on trigpart2;	-- fail
    -drop trigger f on trigpart3;	-- fail
    +drop trigger trg1 on trigpart1;	-- fail
    +drop trigger trg1 on trigpart2;	-- fail
    +drop trigger trg1 on trigpart3;	-- fail
     drop table trigpart2;			-- ok, trigger should be gone in that partition
     select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger
       where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text;
    -drop trigger f on trigpart;		-- ok, all gone
    +drop trigger trg1 on trigpart;		-- ok, all gone
     select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger
       where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text;
     
    -- 
    2.16.2
    
    
    --------------B66B6AFF9463E5DA9B36B7A2--