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 1nJSQz-0002FK-HQ for pgsql-general@arkaria.postgresql.org; Mon, 14 Feb 2022 03:53:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJSQx-0000wn-No for pgsql-general@arkaria.postgresql.org; Mon, 14 Feb 2022 03:53:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJSQx-0000we-DL for pgsql-general@lists.postgresql.org; Mon, 14 Feb 2022 03:53:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJSQu-0005Qz-Ur for pgsql-general@lists.postgresql.org; Mon, 14 Feb 2022 03:53:51 +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 21E3rjrG2768413; Sun, 13 Feb 2022 22:53:46 -0500 From: Tom Lane To: Michael Mauger cc: "pgsql-general@lists.postgresql.org" Subject: Re: FDW error on remote view In-reply-to: References: Comments: In-reply-to Michael Mauger message dated "Mon, 14 Feb 2022 03:10:38 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2768411.1644810825.1@sss.pgh.pa.us> Date: Sun, 13 Feb 2022 22:53:45 -0500 Message-ID: <2768412.1644810825@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Mauger writes: > Why is there an error in the app context only when I invoke the view > through a FOREIGN TABLE. And more importantly, how do I get around it? It's hard to be sure with this amount of detail, but I think what is happening is that your view invokes a plpgsql function and that function is sensitive to the active search_path. postgres_fdw runs the remote session with minimal search path (i.e., search_path = 'pg_catalog'), so a function that tries to reference something in 'public' is not gonna work unless it provides an explicit schema-qualification or a function-local setting of search_path. regards, tom lane