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.

2
  • what is the error message? Commented Nov 27, 2018 at 13:02
  • It can not find the log table in which the audit details are to be inserted.It shows relation [table_name] does not exists though the table is available in db1. @JGH Commented Nov 27, 2018 at 13:08

1 Answer 1

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;
Sign up to request clarification or add additional context in comments.

1 Comment

Let me try this and I shall get back to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.