Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vmwPm-000Pb5-2y for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Feb 2026 16:04:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vmwPm-000Jfq-03 for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Feb 2026 16:04:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vmwPl-000Jfg-1p for pgsql-hackers@lists.postgresql.org; Mon, 02 Feb 2026 16:04:37 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vmwPi-00000000h08-3tQQ for pgsql-hackers@lists.postgresql.org; Mon, 02 Feb 2026 16:04:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1770048273; bh=7t7PnH/MaCB7QCSq0hrIoOyjIKmOvYEk7ltZqYtW2Gk=; h=Message-ID:Date:User-Agent:Subject:To:References:From:In-Reply-To: From; b=IJF2FWZvp8wq/lZ2rAyBSzCFqAFBcojZvIf5X8ekW77RgSgfGbXmyHASNC0agYQ2Y cC4jDWIoRzM88/ujqZlktmEyxemyPeHqlbRFAleS25WC0oA8YdVeoMyMph7tiTZrvI Ob/S5juZhiu7DeDLdL61JuG6RfYgeWm3WV0sTMyWJTYIgBx5M/UBuazcUlyKtLZo4V 4vHonoNdg4/axKLmeieBuVVr4eZSVOhulU/u/hUeObJhMh76Ig8UchhbZHTjaedX+2 4RaGhZIfRoAaxaYCrm2lXEwXethHDHqv7Q7HpmwLjMgEN+oobviJMs0yzsxpg0iOhz 314/pBatkjHMQ== Received: from [192.168.23.100] (unknown [81.200.24.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: v.davydov@postgrespro.ru) by mail.postgrespro.ru (Postfix/465) with ESMTPSA id 46D9760780 for ; Mon, 2 Feb 2026 19:04:33 +0300 (MSK) Message-ID: <080f9394-c127-4cef-865e-10f2f997125c@postgrespro.ru> Date: Mon, 2 Feb 2026 19:04:32 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Support logical replication of DDLs To: pgsql-hackers@lists.postgresql.org References: Content-Language: en-US From: Vitaly Davydov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2026/02/02 13:57:00 #28172407 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dear Hackers, I see, that the primary idea in this thread is to capture DDL statements with the use of the utility hook, convert it into a json-like format, save it in the WAL (xl_logical_message) and send it to a peer using the logical replication subsystem (walsender). This approach has a major challenge that was already highlighted: DDL statements may be too complex to convert it into a json string (for example, unlogged/temporary objects in DDL statements). An alternative approach, that was highlighted in the discussion by Dilip Kumar is to decode system catalog changes. It helps to deal with complex DDL statements containing temp objects and to work with a final representation of changes stored in the WAL. Personally, I like this approach. I would share the following idea: 1. Log into the WAL system catalog changes (tuples) suitable for logical decoding (introduce a new wal_level = logical_ddl). I think, not all system catalog changes are needed for decoding (not sure, we have to decode pg_depend changes). 2. Implement a decoder of system catalog changes, that can produce a parse tree using existing structures from parsenodes.h. 3. Based on the decoded parse tree, we can convert it into json or DDL SQL statements in the output plugin. ParseTree to DDL SQL converter can be built-in into the core. Output plugin can decide which converter to use. DDL sql can be directly applied on the replica. 4. Another option is to create json/ddl-sql from system catalog changes without an intermediate representation, but, anyway, when we interpret system catalog changes we have to temporary save current data in some structures. Parsenodes is the already existing solution for it. The open question: can we unambiguously decode system catalog changes? I would appreciate any feedback. With best regards, Vitaly