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 1pSiRZ-0003zs-7o for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 17:53:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pSiRY-0003gR-0p for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 17:53:16 +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 1pSiRX-0003fm-NO for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 17:53:15 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSiRV-0000u9-1w for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 17:53:14 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 2EBCA5C0124; Thu, 16 Feb 2023 12:53:09 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 16 Feb 2023 12:53:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1676569989; x=1676656389; bh=r XA+UURthE2HzkiAI1oElUz/tzTyuXAdrKPhvv0LVZ8=; b=Lrh1fLNkgMoJaP99X Xcl35oDVQEdQ2NnU5Ixo+QI+aJAL6JK0W5jZImGCxijJSOwDJSmgtM0uc6XSY/oC 7AevYcN6MQqZuCbHpkUk8iBL8racMeWoBcQrVCt3Q4i7I2wbd2w5rlqb78fI2eXW Ecd7MqyO0vqxeMeujn3e1zIgdtrO7//qNpt7UdzjKYcPXSWtzIf7mpMdJ7+CzYFS 9qlpdZSZj9c0l5KQWho/L6LmncfR3AmWCbivP/9GMJhYjRRU1sFrFrUBEGT1h5zx rxZqFB+fyaahg0JMJaLYV9vL9YU4ZZbbYUjPXYoX780hQhJyj/s4B9N8h83Pp/tw LdjGA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeijedguddtgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeej keffgfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghl vhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 Feb 2023 12:53:08 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D3A7F9E; Thu, 16 Feb 2023 18:53:05 +0100 (CET) Date: Thu, 16 Feb 2023 18:53:05 +0100 From: Alvaro Herrera To: "Jonathan S. Katz" Cc: "houzj.fnst@fujitsu.com" , Amit Kapila , Ajin Cherian , Peter Smith , vignesh C , Zheng Li , li jie , Dilip Kumar , Masahiko Sawada , Japin Li , rajesh singarapu , PostgreSQL Hackers Subject: Re: Support logical replication of DDLs Message-ID: <20230216175305.2ayyrxrm3lz6oy5l@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <263bea1c-a897-417d-3765-ba6e1e24711e@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Feb-16, Jonathan S. Katz wrote: [replication tries to execute this command] > 2023-02-16 16:11:10.570 UTC [25207] STATEMENT: CREATE OR REPLACE FUNCTION > public.availability_rule_bulk_insert ( IN availability_rule > public.availability_rule, IN day_of_week pg_catalog.int4 ) RETURNS > pg_catalog.void LANGUAGE sql VOLATILE PARALLEL UNSAFE CALLED ON NULL INPUT > SECURITY INVOKER COST 100 AS $_$ > INSERT INTO availability ( > room_id, > availability_rule_id, > available_date, > available_range > ) [which results in:] > 2023-02-16 16:11:10.570 UTC [25207] ERROR: relation "availability" does not > exist at character 279 I don't think this is the fault of logical replication. Consider that for the backend server, the function source code is just an opaque string that is given to the plpgsql engine to interpret. So there's no way for the logical DDL replication engine to turn this into runnable code if the table name is not qualified. (The fact that this is a security-invoker function prevents you from attaching a SET search_path clause to the function, I believe? Which means it is extra dangerous to have an unqualified table reference there.) > My high level guess without looking at the code is that the apply worker is > not aware of the search_path to use when processing functions during > creation. Provided that the publisher/subscriber environments are similar > (if not identical), I would expect that if the function create succeeds on > the publisher, it should also succeed on the subscriber. If we're going to force search_path and all other settings to be identical, then we might as well give up the whole deparsing design and transmit the original string for execution in the replica; it is much simpler. But this idea was rejected outright when this stuff was first proposed years ago. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "Crear es tan difícil como ser libre" (Elsa Triolet)