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 1wJsKY-000NQS-1d for pgsql-hackers@arkaria.postgresql.org; Mon, 04 May 2026 12:23:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wJsKW-0076Xl-1u for pgsql-hackers@arkaria.postgresql.org; Mon, 04 May 2026 12:23:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wJsKW-0076Xc-0J for pgsql-hackers@lists.postgresql.org; Mon, 04 May 2026 12:23:20 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wJsKT-000000008ov-2xd5 for pgsql-hackers@lists.postgresql.org; Mon, 04 May 2026 12:23:19 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-3938d17d6c5so12765751fa.1 for ; Mon, 04 May 2026 05:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777897397; cv=none; d=google.com; s=arc-20240605; b=DWjAmdJUgpwhf8qHTxPH9Op6aChPOp3h04MlvjNZekNw85v0HoNCWkos8SV4U3Dgc7 eTsTjihfwLV7Pwdqjju5ZvDqFhNlTTLekC05vM4DhzY1duijxbQY44aEucsKFYI3+KB1 VexmO/TOj6sx+VOow/2NABVs5EJ2yYfBh2wYj1bHBS3HP/0w6FzJh1PZIZ7mNVwuryP2 ARMsFePnQwQJ6P2s73zWbhtKAib+W96kkemGg3sLxFJG+tJXh5bu83BN+ojYEdV46upZ cLoU2rcGl8bRSgT2LEnv6eqA/Wdxtat6ZmNjCPkD0C/ZDn1Wa4+H2aksWcaLt5PKEWpS M9vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5HNsGOTupBXfzH5wh0FmCleVeZyFk8raDeC+v/bLTbo=; fh=ZQfffitEQVUW2Wbl2Y+3ifXRep3RKEjidLhmTugALBA=; b=GoXk3rSG5U7fsaYzNI4fxC7jjnIAjwxDeOmukXxPtqiJffTf4Ca5gK9eY/v1w3en5C hLf6jCy7YSzH7syZKKlLlMLDNiRsnSGFKYrEryW0l4vM4BoxEJf1CSVxHafvnsONP7Vw VNaLJvvUPVHvky7zTo9V0CkaV/UrXYRE9GTQFnk3zjj8RoVNPOd86WPoLPOHE0pxsXuT +sfeN4RjAvNZj+pqz3DkKYcS9vbLckAywhazZHZSYyU7uoI3ppmfIYLWQc+fE9VVFR7Y yrQhUcihlvfR+4vKQM7zLp75/ZJiZD1CPxKSB6ULkYBsmGDX+P9u+qX3julcwcjUE1NG xGUA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777897397; x=1778502197; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5HNsGOTupBXfzH5wh0FmCleVeZyFk8raDeC+v/bLTbo=; b=EDN81Soh4vZQBHWp5VCaOZq1dehOjJ/ABH8Pxb6QjD7KH9eHb3lIajkY1kYR6UCS4X 2XW0drOyd+uwB1LVh97BNJWTvKNZYlB9ZfjNxkevL48ej4U4YpeKWfu0drfBoh+i1jfH QOMR2/EY6bQc4fyaxBaErrhxj/KsiMjTHS0HzKCSpyN+utLi3uMh3Xo7sMR2YQbMo7Yl ySBxqNGKVkLVhiJprmr59TRz76/wJ7oZxysjELBUS3JgpbfG0bwW4zzWXc8TzqxJVHpj lxH9n6ETQyh5g7EehtX6TQ7TnYzeUXODxG/XfYVQ49TfDo3Yi36OfwOMofbZVTj/fdRo 3FYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777897397; x=1778502197; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5HNsGOTupBXfzH5wh0FmCleVeZyFk8raDeC+v/bLTbo=; b=jHl3tYnGybfjInHJ84fkgGBcSJ8dMEg6ghRBqTbyKtXmKwqcpZVe8Br8Jr6WQVw7XB 88guSNuwRGkXWhbdJM7YvENAkr8gt1Jqd0wGREMl78KewYYhGKtkmYqfi5zM3YEEQG12 uCp+ri8bhs/PRbjp3/jVfHxYGP2RSQYrT+5fqObS/kHo+S0Rx77TKvA3ny9Ia4jkfZMr /EpOfI8AJo+J73NX5tLXDgbFnaFKlsdNhBDu+zk6kAYP/s7rPijE82olK4UYDF1HRIng lTaoJG+qXAL486TXdZJfkxXiMuVcpsEZNkR8Ta0ivFEeLIv590gpit0NjaBWvBDUdgjW Heow== X-Forwarded-Encrypted: i=1; AFNElJ8i8InWlwgo/Mk5T79sXEfLhLmyuT9C5ujpvyhYemuRcxu6A0gmphNpPimOFWl/HtmZk/J6DbDiqsreTT78@lists.postgresql.org X-Gm-Message-State: AOJu0Yx63WlkEHuE84tbwcxwEp+TRImiVZnLpSosJ/1chGllH4n6mZ0c RqkPXTRCSnNfhLdVF151nvvR6BVh+QXJ3N4l9sssFiFjjpXoknCee6uuIF+VZbp6AZ79dji8tNW X+iK9u+K1PgSbM626pUOhZr3pO74A0pU= X-Gm-Gg: AeBDies5aSZY43TFuNfzhcQX4/Azq2lZ/qrMtf9DmY0L3+jML3arMi5w+0SvtvcmQ50 YYm8xapD15ODdHeK6RYjxvjUnudiwb31gCqwNvM5lGozXVZr8HoMgXsHVBhQJlHSkVFId500GWV h0H+1qncR044uYEaOVe9XYKCLBBT3JnSyFPnlRKldV9liS8J/N1AEduAYX+hviKZsfPIhp5ircc Tnc/cxbkUNCwDkEe/V6ew8sjvEuyzCyjykyalD6yKb3U/o8idorZEHhUiip7MC6sdDYdCgkg/MZ ePNXE58G9+GQKVyi9p5PZPB7IqBZ19aRk+MbGLcZgIY1mMSGZcws X-Received: by 2002:a05:651c:2116:b0:383:7f85:8eef with SMTP id 38308e7fff4ca-39378597cc5mr32215981fa.29.1777897396247; Mon, 04 May 2026 05:23:16 -0700 (PDT) MIME-Version: 1.0 References: <080f9394-c127-4cef-865e-10f2f997125c@postgrespro.ru> <38690b0e-f91b-46fa-b72a-57775612e463@postgrespro.ru> In-Reply-To: From: Amit Kapila Date: Mon, 4 May 2026 17:53:04 +0530 X-Gm-Features: AVHnY4JQS9TOhynXv8A6VWMVY_Cw-7NRaDiCKVzvVip-Q4W8I0m5zFYabucJ-9k Message-ID: Subject: Re: Support logical replication of DDLs, take2 To: Masahiko Sawada Cc: Vitaly Davydov , Ashutosh Bapat , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, May 1, 2026 at 2:11=E2=80=AFAM Masahiko Sawada wrote: > > On Wed, Apr 29, 2026 at 9:44=E2=80=AFPM Amit Kapila wrote: > > > > On Wed, Apr 29, 2026 at 3:19=E2=80=AFAM Masahiko Sawada wrote: > > > > > > On Mon, Apr 27, 2026 at 11:32=E2=80=AFPM Amit Kapila wrote: > > > > > > > > Yes, there will be a maintenance cost of JSON-based deparsing > > > > approach. But note that multiple senior people (Alvaro Herrera, Rob= ert > > > > Haas) [1] seems to favor that approach. So, I am not sure we can > > > > conclude to abandon that approach without those people or some othe= r > > > > senior people agreeing to abandon it. To be clear, I am not against > > > > considering a new/different approach for DDL replication but just t= hat > > > > it is not clear that old/existing approach can be ruled out without > > > > more discussion on it, > > > > > > Thank you for pointing it out. Just to be clear, IIUC what they liked > > > was to use JSON string representation of DDLs, but not JSON string > > > representation of DDLs that are deparsed from parse nodes, no? > > > > > > > As per my understanding, we built deparsing stuff with a goal of > > supporting DDL replication and Alvaro was the original author of that > > work, see [1]. The benefit it provides flexibility in terms of > > filtering by decoding plugin, if any, or changing the DDL (like > > schema-mapping) during apply. It is not clear to me if we can achive > > similar level of flexibility with other approach. > > I think we can generate the same JSON-string representation of DDLs > from catalog information, it would also require a lot of code, though. > It would be independent from parse nodes and if we implement it as an > option for pg_get_xxx_ddl() functionality it would be able to be > reused by other tools too. > IIRC, this was discussed previously as well but we were not sure if we can build all (especially some complex ones) without parsetree. See discussion/emails around [1][2]. > > > > > > > > > > > > > We would need to maintain the JSON serialization code whenever > > > > > creating or modifying parse nodes, regardless of whether the chan= ges > > > > > were related to DDL replication. IIUC, this was the primary reaso= n the > > > > > feature didn't cross the finish line. > > > > > > > > > > Additionally, I think there is another design issue: it is not > > > > > output-plugin agnostic. Since the deparsed DDL was written by a > > > > > logical-replication-specific event trigger, third-party logical > > > > > decoding plugins cannot easily detect DDL events. > > > > > > > > > > > > > Why RmgrId like RM_LOGICALDDLMSG_ID and XLOG_LOGICAL_DDL_MESSAGE wa= l > > > > info is not sufficient for this? Decoder will add a message like > > > > REORDER_BUFFER_CHANGE_DDL which can be used to detect DDL message, = no? > > > > > > Right, but I'm not sure this is a good developer experience that > > > additional steps are required to capture DDL events for other plugins > > > while changes of INSERT/UPDATE/DELETE/TRUNCATE are passed from the > > > logical decoding by default. > > > > > > > Yes, there could probably be additional steps for plugins but they > > must be doing a few things already which are defined at publication > > level like column lists, row filtering, something related to RI, etc. > > I think those publication-level features operate at a somewhat > different layer than the fundamental mechanism of capturing DDL > events. Plugins filter rows or columns based on configuration, but the > logical decoding itself guarantees that the DML events are reliably > passed to them. Given that the TRUNCATE in logical replication already > works so, I guess DDL should have the same fundamental guarantee. > > it's unclear to me how plugins could reliably manage these event > triggers. While a plugin might create an event trigger during the > startup callback if it doesn't exist, it cannot drop it during the > shutdown callback. We also cannot establish a dependency between an > event trigger and a logical replication slot. We would likely need to > invent a new plugin callback specifically invoked at slot drop time > just to clean it up. Also, if different plugins want to capture DDL > events, they could end up registering different event triggers, > emitting multiple DDL WAL records for the same DDL event. > Why would different plugins end up registering different event triggers? I mean if they are already registered by the first plugin what is the need to re-register. [1] - https://www.postgresql.org/message-id/20150221212017.GD2037@awork2.an= arazel.de [2] - https://www.postgresql.org/message-id/20150224021018.GH30784@awork2.a= narazel.de --=20 With Regards, Amit Kapila.