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 1ppTZa-0001x8-HX for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Apr 2023 12:39:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ppTZZ-0001Ti-D9 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Apr 2023 12:39:37 +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 1ppTZZ-0001TZ-3j for pgsql-hackers@lists.postgresql.org; Thu, 20 Apr 2023 12:39:37 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ppTZX-0041zY-1f for pgsql-hackers@lists.postgresql.org; Thu, 20 Apr 2023 12:39:36 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f09b9ac51dso18457255e9.0 for ; Thu, 20 Apr 2023 05:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681994373; x=1684586373; 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=ano8nT1dk0TznjnpbwR7MXcT/OX5VDeIVnpsT8od+vU=; b=buKcQGv8qxcDR3SwzTvgyJtfETeV0mJEAVuzAuqVaM5rW8ZDk9fQIVwNWYhBMAbyXH ObDelTC8PcFr06n5TsMFfDVWHnZZQklQRzdX7yLJq9ebjLcDme89l89gtU/qWRYwDNEY rD8AsEX/sCJTfKUV92dwSgKAN2lN+9ULvo/5nK7mZeC4X1v9pB3G+2pSrsqw5ZT4BSbY rPXS5j9/BHslLBr7k7N0dK59ZsRtu9QxoBKgOFSVdD1TiNwsa8agijfLg8oryUB3nKFp 56ArHIQJ60N2meSjFIEkqI4HEn67I2Y3vYDjIjtnnYcfCT8BAMKfGHp1QHCuL35xTFQx gdHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681994373; x=1684586373; 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=ano8nT1dk0TznjnpbwR7MXcT/OX5VDeIVnpsT8od+vU=; b=XviEYBZ1VfDnF/c2f+214Acyyflt/GwAhhM/6iiaAyCbII8eQQ1L3F5ommEEH0QGNZ KYT3PPcrfx9DItBZNh7xircf5hOpLsh35cL92tW2Gsh2r0a+Bl/mpJYDNNhDNqKacygs lx2iM2ez14j0EkKq3FbjMlRpgmK+zbxqSThnH0lgbpt3xqaefpRtf/NRhE9ErZcTamDr VucmiMpqRuMY2jFQxvvs5x9R3PMjRs6TBVWRVU5aCO8rdsd9pAyMjnGA7HxuzTBKrnjf aSGY5u/tluIg1pFx8nl1fBRHd8RGYFPBiHNGc7jn6+FAKUJTSZVldV7MrkLS+dAH3kQx fgng== X-Gm-Message-State: AAQBX9dTkK0Ot5lNrmOrOegLK8zjuB0aL91Ddo+jsOJqoIRfw4WmBKR7 g4u78mJdUcsH+0Rmnmy6E6NOk3Jg/F63g5huRyE= X-Google-Smtp-Source: AKy350agFlw14UwqdB9ftKIik0N+cwg6RJ9hQMhkunG7dRwy12VFWNsec53XirEMuN+vzU5vmnuFmBvQYnZSRzqveRw= X-Received: by 2002:adf:e749:0:b0:2fa:88d3:f8b8 with SMTP id c9-20020adfe749000000b002fa88d3f8b8mr4797898wrn.12.1681994372792; Thu, 20 Apr 2023 05:39:32 -0700 (PDT) MIME-Version: 1.0 References: <3032112.1679865718@sss.pgh.pa.us> In-Reply-To: From: shveta malik Date: Thu, 20 Apr 2023 18:09:21 +0530 Message-ID: Subject: Re: Support logical replication of DDLs To: "Zhijie Hou (Fujitsu)" Cc: Amit Kapila , 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 Thu, Apr 20, 2023 at 2:28=E2=80=AFPM shveta malik wrote: > > On Thu, Apr 20, 2023 at 9:11=E2=80=AFAM shveta malik wrote: >> >> On Mon, Apr 17, 2023 at 5:32=E2=80=AFPM Zhijie Hou (Fujitsu) >> wrote: >> > >> > Attach the new version patch set which include the following changes: >> Few comments for ddl_deparse.c in patch dated April17: >> > Few comments for ddl_json.c in the patch dated April17: > Few more comments, mainly for event_trigger.c in the patch dated April17: 1)EventTriggerCommonSetup() + pub_funcoid =3D LookupFuncName(pubfuncname, 0, NULL, true); This is the code where we have special handling for ddl-triggers. Here we are passing 'missing_ok' as true, so shouldn't we check pub_funcoid against 'InvalidOid' ? 2) EventTriggerTableInitWriteEnd() + if (stmt->objtype =3D=3D OBJECT_TABLE) + { + parent =3D currentEventTriggerState->currentCommand->parent; + pfree(currentEventTriggerState->currentCommand); + currentEventTriggerState->currentCommand =3D parent; + } + else + { + MemoryContext oldcxt; + oldcxt =3D MemoryContextSwitchTo(currentEventTriggerState->cxt); + currentEventTriggerState->currentCommand->d.simple.address =3D address= ; + currentEventTriggerState->commandList =3D + lappend(currentEventTriggerState->commandList, + currentEventTriggerState->currentCommand); + + MemoryContextSwitchTo(oldcxt); + } +} It will be good to add some comments in the 'else' part. It is not very much clear what exactly we are doing here and for which scenario. 3) EventTriggerTableInitWrite() + if (!currentEventTriggerState) + return; + + /* Do nothing if no command was collected. */ + if (!currentEventTriggerState->currentCommand) + return; Is it possible that when we reach here no command is collected yet? I think this can happen only for the case when commandCollectionInhibited is true. If so, above can be modified to: if (!currentEventTriggerState || currentEventTriggerState->commandCollectionInhibited) return; Assert(currentEventTriggerState->currentCommand !=3D NULL); This will make the behaviour and checks consistent across similar functions in this file. 4) EventTriggerTableInitWriteEnd() Here as well, we can have the same assert as below: Assert(currentEventTriggerState->currentCommand !=3D NULL); 'currentEventTriggerState' and 'commandCollectionInhibited' checks are already present. 5) logical_replication.sgml: + 'This is especially useful if you have lots schema changes over time that need replication.' lots schema --> lots of schema thanks Shveta