Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lHsO0-0002W5-Fi for pgsql-general@arkaria.postgresql.org; Thu, 04 Mar 2021 18:07:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lHsNy-0000tA-Id for pgsql-general@arkaria.postgresql.org; Thu, 04 Mar 2021 18:07:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lHsNy-0000t3-BB for pgsql-general@lists.postgresql.org; Thu, 04 Mar 2021 18:07:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lHsNr-0006LS-E3 for pgsql-general@postgresql.org; Thu, 04 Mar 2021 18:07:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 124I7V071374777; Thu, 4 Mar 2021 13:07:31 -0500 From: Tom Lane To: Adrian Klaver cc: "Fontana Daniel C. (Desartec S.R.L.)" , pgsql-general Subject: Re: Schema in trigger in logical replication In-reply-to: References: <003501d7107d$75a67a80$60f36f80$@gmail.com> <217507fd-1fde-20f7-3950-7341602277a2@aklaver.com> <003601d71089$2b2a10a0$817e31e0$@gmail.com> Comments: In-reply-to Adrian Klaver message dated "Thu, 04 Mar 2021 08:58:30 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1374774.1614881251.1@sss.pgh.pa.us> Date: Thu, 04 Mar 2021 13:07:31 -0500 Message-ID: <1374775.1614881251@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Adrian Klaver 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