Re: Schema in trigger in logical replication

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: "Fontana Daniel C(dot) (Desartec S(dot)R(dot)L(dot))" <desartecsrl(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Schema in trigger in logical replication
Date: 2021-03-04 18:07:31
Message-ID: 1374775.1614881251@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
> On 3/3/21 3:58 PM, Fontana Daniel C. (Desartec S.R.L.) wrote:
>> When the update is manual, it works.
>> It does not work when the update is done using logical replication.
>> It is as if the logical replication wizard did not use the search_path

> Replication would imply at least two database instances in use. If they
> both don't have the same search_path set then there would be a problem.

I'm fairly sure that replication workers run with search_path set
to just "pg_catalog" for security reasons. Any user-written code
that needs to execute in a replication worker *must* schema-qualify
all references to non-system objects.

As a general rule, code that runs in expression indexes, check
constraints, and the like needs to be written to not make assumptions
about what search path it's invoked with. Just fix it; your life
will be less painful.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2021-03-04 18:13:57 Re: Duplicate key error
Previous Message Andrus 2021-03-04 17:17:16 Re: Duplicate key error