0

I have two databases db1 and db2.db2 has foreign table, say tableA whose schema has been imported from db1. A trigger runs on tableA in db1 for every row update. Now using postgres_fdw I can fetch the records from db2 but unable to update any record on tableA due to that trigger function.Update works fine in case I disable the trigger.I need that trigger for audit log.

Please suggest me a suitable suggestion to resolve the issue.I am using postgres 9.6.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

Make sure the user establishing the link has access to the audit tables.

You could also add the required schema to the trigger function search path:

CREATE OR REPLACE FUNCTION abc.mytrigger() RETURNS trigger AS
$BODY$BEGIN
 [...] -- do something in the xyz schema
  RETURN NEW;
END;$BODY$ 
LANGUAGE plpgsql 
SET search_path = xyz;
JGH
  • 15,928
  • 4
  • 31
  • 48