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 1psMTZ-0001oV-9S for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Apr 2023 11:41:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1psMTY-0005A0-6X for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Apr 2023 11:41:20 +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 1psMTX-00059j-TN for pgsql-hackers@lists.postgresql.org; Fri, 28 Apr 2023 11:41:19 +0000 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1psMTU-002Ldq-1G for pgsql-hackers@lists.postgresql.org; Fri, 28 Apr 2023 11:41:18 +0000 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-546615d6f47so5857237eaf.0 for ; Fri, 28 Apr 2023 04:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682682075; x=1685274075; 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=i6x0iHcZeR6/lCOWp/onxsMAoS82yTTrPDzgWqRfMps=; b=MpY1kbIRAFs70jHMbA7MNa/YOsYnFn825KfpMXNZMkLC4p5qQMQ364pnk9ELMDnGtJ 2qTUl+55043sKQjwF2o5C9DOvRnFu5oMJ/fZcJ8A214eXlyceBqsXp6elipDx1yUUldM TES1S0RUErFGRioD/P4z1HwHLxGcGDOwudEd5QfaoOZHaqMX/wlDq6+VJwSnx8xpeu07 UAQtdKly5Qt7C8xU1JLi/KzOb86DhIoSNEiP/WF4K0mEyKC1bb4PErGO7QFcANNuHyn+ xTbE6lO3lNn8Lt4DVyjsjejdfOoC1eMIA/0YrayAEwQWxyQyPdQxCzaJ9sc3zMEcFfhM aF4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682682075; x=1685274075; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i6x0iHcZeR6/lCOWp/onxsMAoS82yTTrPDzgWqRfMps=; b=i5pdYrqbJzvEnrwN2W0I4b1Qb+f85CKcgL1SfzhAPFkN2i+N29sTUVDHn0WlADFiTy s9HVWn30X/UMSi6jcCo4HML5rGmFoV9lpwF0r4kypr7ATZQXphXF1oBk8BPidtv2lbET Av5xAkie17mO8WrXuM8IeQlMupSHvK2gXFMoFdYdSDKU6XaXLh6EPNbt+VyxbPeYUdwA GWHKjrN/Kd8XNZdJYTL869tOYXZpjeFKmy6U+8M4NUuHZj07fxdwoTSW2DP1xkPN80N8 O0WcHl0S6sfcGIpscWucoUnxT+Yr4ZQ4oKXkGx1XFHJL65SyS/gopj5mWdKmK61F2WoS jPtA== X-Gm-Message-State: AC+VfDx3lpBk9WPVhMXhdy8Z371phgOXTzK59qW4SLUrNKNfyXgyj223 n1CR8YmYOZg6Zlgw6n84EBE8ADAtYq87asCSEvs= X-Google-Smtp-Source: ACHHUZ6elLEYA0eT+tCr3KdD7gSvVkQ0P2xVNKqGD0ZQ86L9NTcGqwgmiNapy9HlOmE7s0m9VMXj0w0yLvs47EMCRmM= X-Received: by 2002:a05:6808:60f:b0:38e:4b70:a5d6 with SMTP id y15-20020a056808060f00b0038e4b70a5d6mr2265654oih.24.1682682074992; Fri, 28 Apr 2023 04:41:14 -0700 (PDT) MIME-Version: 1.0 References: <3032112.1679865718@sss.pgh.pa.us> In-Reply-To: From: Amit Kapila Date: Fri, 28 Apr 2023 17:11:03 +0530 Message-ID: Subject: Re: Support logical replication of DDLs To: "Zhijie Hou (Fujitsu)" Cc: shveta malik , vignesh C , Ajin Cherian , "Wei Wang (Fujitsu)" , Runqi Tian , Peter Smith , Tom Lane , li jie , Dilip Kumar , Alvaro Herrera , Masahiko Sawada , Japin Li , rajesh singarapu , PostgreSQL Hackers , Zheng Li 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 Tue, Apr 25, 2023 at 9:28=E2=80=AFAM Zhijie Hou (Fujitsu) wrote: > I have a few high-level comments on the deparsing approach used in the patch. As per my understanding, we first build an ObjTree from the DDL command, then convert the ObjTree to Jsonb which is then converted to a JSON string. Now, in the consecutive patch, via publication event triggers, we get the JSON string via the conversions mentioned, WAL log it, which then walsender will send to the subscriber, which will convert the JSON string back to the DDL command and execute it. Now, I think we can try to eliminate this entire ObjTree machinery and directly from the JSON blob during deparsing. We have previously also discussed this in an email chain at [1]. I think now the functionality of JSONB has also been improved and we should investigate whether it is feasible to directly use JSONB APIs to form the required blob. The other general point is that one of the primary reasons to convert DDL into JSONB blob is to allow replacing the elements. For example, say on the publisher, the table is in Schema A and then on the subscriber the same table is in Schema B, so, we would like to change the Schema in the DDL before replaying it, or we want to change the persistence of table to UNLOGGED before replaying the DDL on the subscriber. Is it possible to have such an API exposed from this module so that we can verify if that works? It can be a separate patch though. [1] - https://www.postgresql.org/message-id/CAB7nPqRX6w9UY%2B%3DOy2jqTVwi0h= qT2y4%3DfUc7fNG4U-296JBvYQ%40mail.gmail.com --=20 With Regards, Amit Kapila.