title: Cannot delete a row when the trigger is enabled
body: <p>Help Needed. i have a table and the respective audit table in emp schema.I was not able to delete the entry from the source table when the trigger is enabled.
  The table is mapped to a trigger as stated below.</p>
  
  <p>Below is the generic function , which  i have used to audit across all the tables.</p>
  
  <pre><code>Function:
  ============
  CREATE OR REPLACE FUNCTION emp.fn_entry_audit()
   RETURNS trigger
   LANGUAGE plpgsql
  AS $function$
  declare
  col_name  text:='';
  audit_table_name text := TG_TABLE_NAME || '_audit';
  begin
   if TG_OP = 'UPDATE' or TG_OP = 'INSERT' THEN 
  EXECUTE format('INSERT INTO emp.%1$I  SELECT ($1).*,'''||TG_OP||'''',audit_table_name) using NEW;
  else 
  EXECUTE format('INSERT INTO emp.%1$I  SELECT ($1).*,'''||TG_OP||'''',audit_table_name) using old;
   end if;
  return new;
  END $function$
  
  Trigger creation
  =================
  create trigger trig_anish before insert or delete or update on emp.test_empname for each row execute procedure acaas.fn_entry_audit()
  
  Table
  ======
  create table emp.test_empname(id int4,fname varchar(300) not null,lname varchar(400),salary int4,last_modified_dt timestamp);
  create table emp.test_empname_audit(id int4,fname varchar(300) not null,lname varchar(400),salary int4,last_modified_dt timestamp,modified_type varchar(10));
  </code></pre>
  
  <p>The difference between the two is modified_type column, which will mention whether the data is of insert, update or delete(TG_OP from above function).</p>
  
  <p>now when i insert the values in emp.test_empname, it is getting inserted correctly in emp.test_empname_audit.</p>
  
  <pre><code>select * from emp.test_empname;
  emp.test_empname:
  ==================
  
  id  fname       lname       salary      last_modified_dt
  ===============================================================
  1   stacker     pentacost   1000            04-04-18
  2   lyri        pav         2000            04-04-18
  3   TEST        TEST1       1000            04-04-18      
  
     select * from emp.test_empname_audit;
  
      id  fname       lname       salary      last_modified_dt  modified_type
      ===============================================================
      1   stacker     pentacost   1000            04-04-18      INSERT
      2   lyri        pav         1000            04-04-18      INSERT    
      2   lyri        pav         2000            04-04-18      UPDATE
      3   TEST        TEST1       1000            04-04-18      Delete
  </code></pre>
  
  <p>Now, the issue is whenever I perform delete on source table (test_empname), the query is executing fine, but it shows 0 rows affected.
  when i query in the table select * from test_empname where id=3, it still exists.But you can see the entry in audit as delete.</p>
  
  <p>I disabled the trigger and performed delete function ,it executes fine and the row gets affected.How is the trigger affecting my delete functionality.Please help!!</p>