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 1pZAfd-0003yC-Ef for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Mar 2023 13:14:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pZAfb-0008P6-KR for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Mar 2023 13:14:27 +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 1pZAfb-0008J7-6h for pgsql-hackers@lists.postgresql.org; Mon, 06 Mar 2023 13:14:27 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pZAfW-0000B9-0K for pgsql-hackers@lists.postgresql.org; Mon, 06 Mar 2023 13:14:26 +0000 Received: by mail-ot1-x335.google.com with SMTP id q11-20020a056830440b00b00693c1a62101so5295408otv.0 for ; Mon, 06 Mar 2023 05:14:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678108459; 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=5LKLX2GbJ+9K8c3CLjcrGPTQXqQh5VupyL4DCBjwuqs=; b=ZGIMnQaaAT8pFBb121QO8MF6/4zYxqe3ymG5unvEw21zz4deqPxZX5jn3iXEY80P8C MMjPhposEBE0DwBoQ86jww5nQ+L9Bmb+3BdSLzGrzxPbtcO4kA5uelYS9xyVTF+piNEj 3yCUVVkTdi5GJnQSAodPaJC/ue8KTyIXozgh9MPlirMJcnSB/VZHVEMqc6luSNZockUq vgOGd75+jnacEGEff+Awujk4sDLgGSIdPapBuuZrJQgQUcLV2TqR46IpDOpMJPzIaJ7f 3Qw+VYAJI9XnTZ/HvyG3sCSLW7epcX0esyGVUxQVzLpHldq7YhsALXds0ucAr5WFnfNq PHPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678108459; 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=5LKLX2GbJ+9K8c3CLjcrGPTQXqQh5VupyL4DCBjwuqs=; b=KBJLpKJ1YcYTncFeBl7DNWcqtdkJp2gAflSFtnIvCGI3tgnjV6YD93XScJlBknXCyT N4pGnUAUKjx9gijNXhXVHMVlJBQRnNNRwisJDpht0g0/DzV0LorHta1+VAlI9XInohog aaKaFT/HvjQMS4AhS1eInea26qXQ5WJni1sdbR5e02Ce82yoKIy9RomG5bqXoYvPWVrt Ch43oNZONaXQTQ9Cs0eu0bfyQUGtzS08+QHyZzpnKfFILPP/ZPh58I966TNrHhMADJ6P gTwpx18u3NcqQ6zIBJ+zdSaqGuNMNdUI+/6/JELCd955hblPIV+LEx6LLFaEKnx4Z4MR d8iA== X-Gm-Message-State: AO0yUKX3bHtuG+WcwzJu1MeiwBEcRU83K6C19ta8oXfXuTQnNmYwjJa9 oJlTqX+L6DH96yUFteMKCrO4WAX4RMSQ/eOZIwU= X-Google-Smtp-Source: AK7set8oBRog4BDAIFRkkkQVl8K3pkMXccK2KPFhsNz3YEVrLM3bPNpGhWv94HoKJwuSPNsIjSrkn1psAQdo2ntEVy0= X-Received: by 2002:a9d:6112:0:b0:68d:4b7f:e993 with SMTP id i18-20020a9d6112000000b0068d4b7fe993mr3720243otj.3.1678108459261; Mon, 06 Mar 2023 05:14:19 -0800 (PST) MIME-Version: 1.0 References: <20221006171601.6um4ey5idm4h62vf@alvherre.pgsql> In-Reply-To: From: vignesh C Date: Mon, 6 Mar 2023 18:43:51 +0530 Message-ID: Subject: Re: Support logical replication of DDLs To: Ajin Cherian Cc: Peter Smith , Zheng Li , li jie , Dilip Kumar , Alvaro Herrera , "houzj.fnst@fujitsu.com" , Amit Kapila , Masahiko Sawada , Japin Li , rajesh singarapu , 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 Mon, 6 Mar 2023 at 12:04, Ajin Cherian wrote: > > On Wed, Feb 15, 2023 at 3:33=E2=80=AFPM Peter Smith wrote: > > > > > > > > > > 9. > > > > + > > > > +/* > > > > + * Append the parenthesized arguments of the given pg_proc row int= o the output > > > > + * buffer. force_qualify indicates whether to schema-qualify type = names > > > > + * regardless of visibility. > > > > + */ > > > > +static void > > > > +format_procedure_args_internal(Form_pg_proc procform, StringInfo b= uf, > > > > + bool force_qualify) > > > > +{ > > > > + int i; > > > > + char* (*func[2])(Oid) =3D {format_type_be, format_type_be_qualifi= ed}; > > > > + > > > > + appendStringInfoChar(buf, '('); > > > > + for (i =3D 0; i < procform->pronargs; i++) > > > > + { > > > > + Oid thisargtype =3D procform->proargtypes.values[i]; > > > > + char *argtype =3D NULL; > > > > + > > > > + if (i > 0) > > > > + appendStringInfoChar(buf, ','); > > > > + > > > > + argtype =3D func[force_qualify](thisargtype); > > > > + appendStringInfoString(buf, argtype); > > > > + pfree(argtype); > > > > + } > > > > + appendStringInfoChar(buf, ')'); > > > > +} > > > > > > > > 9b. > > > > I understand why this function was put here beside the other static > > > > functions in "Support Routines" but IMO it really belongs nearby (i= .e. > > > > directly above) the only caller (format_procedure_args). Keeping bo= th > > > > those functional together will improve the readability of both, and > > > > will also remove the need to have the static forward declaration. > > > > > > > > There was no reply for 9b. Was it accidentally overlooked, or just > > chose not to do it? > > Fixed this. Moved the function up and removed the forward declaration. > > On Wed, Feb 15, 2023 at 3:00=E2=80=AFPM Peter Smith wrote: > > > > On Sat, Feb 11, 2023 at 3:21 AM vignesh C wrote: > > > > > > On Thu, 9 Feb 2023 at 03:47, Peter Smith wrot= e: > > > > > > > > Hi Vignesh, thanks for addressing my v63-0002 review comments. > > > > > > > > I confirmed most of the changes. Below is a quick follow-up for the > > > > remaining ones. > > > > > > > > On Mon, Feb 6, 2023 at 10:32 PM vignesh C wro= te: > > > > > > > > > > On Mon, 6 Feb 2023 at 06:47, Peter Smith = wrote: > > > > > > > > > > ... > > > > > > > > > > > > 8. > > > > > > + value =3D findJsonbValueFromContainer(container, JB_FOBJECT, = &key); > > > > > > > > > > > > Should the code be checking or asserting value is not NULL? > > > > > > > > > > > > (IIRC I asked this a long time ago - sorry if it was already an= swered) > > > > > > > > > > > > > > > > Yes, this was already answered by Zheng, quoting as "The null che= cking > > > > > for value is done in the upcoming call of expand_one_jsonb_elemen= t()." > > > > > in [1] > > > > > > > > Thanks for the info. I saw that Zheng-san only wrote it is handled = in > > > > the =E2=80=9Cupcoming call of expand_one_jsonb_element=E2=80=9D, bu= t I don=E2=80=99t know if > > > > that is sufficient. For example, if the execution heads down the ot= her > > > > path (expand_jsonb_array) with a NULL jsonarr then it going to cras= h, > > > > isn't it? So I still think some change may be needed here. > > > > > > Added an Assert for this. > > > > > > > Was this a correct change to make here? > > > > IIUC this Assert is now going to intercept both cases including the > > expand_one_jsonb_element() which previously would have thrown a proper > > ERROR. > > > Fixed this. Added an error check in expand_jsonb_array() as well. > > Changes are in patch 1 and patch 2 Few comments: 1) The following statement crashes: CREATE TABLE itest7b (a int); CREATE TABLE itest7c (a int GENERATED ALWAYS AS IDENTITY) INHERITS (itest7b= ); #0 0x0000559018aff927 in RangeVarGetRelidExtended (relation=3D0x0, lockmode=3D0, flags=3D0, callback=3D0x0, callback_arg=3D0x0) at namespace.c:255 #1 0x0000559018be09dc in deparse_ColumnDef (relation=3D0x7f3e917abba8, dpcontext=3D0x55901a792668, composite=3Dfalse, coldef=3D0x55901a77d758, is_alter=3Dfalse, exprs=3D0x0) at ddl_deparse.c:1657 #2 0x0000559018be2271 in deparse_TableElements (relation=3D0x7f3e917abba8, tableElements=3D0x55901a77d708, dpcontext=3D0x55901a792668, typed=3Dfalse, composite=3Dfalse) at ddl_deparse.c:2460 #3 0x0000559018be2b89 in deparse_CreateStmt (objectId=3D16420, parsetree=3D0x55901a77d5f8) at ddl_deparse.c:2722 #4 0x0000559018bf72c3 in deparse_simple_command (cmd=3D0x55901a77d590, include_owner=3D0x7ffe4e611234) at ddl_deparse.c:10019 #5 0x0000559018bf7563 in deparse_utility_command (cmd=3D0x55901a77d590, include_owner=3Dtrue, verbose_mode=3Dfalse) at ddl_deparse.c:10122 #6 0x0000559018eb650d in publication_deparse_ddl_command_end (fcinfo=3D0x7ffe4e6113f0) at ddltrigger.c:203 2) invalid type storage error: CREATE TYPE myvarchar; CREATE FUNCTION myvarcharin(cstring, oid, integer) RETURNS myvarchar LANGUAGE internal IMMUTABLE PARALLEL SAFE STRICT AS 'varcharin'; CREATE FUNCTION myvarcharout(myvarchar) RETURNS cstring LANGUAGE internal IMMUTABLE PARALLEL SAFE STRICT AS 'varcharout'; CREATE FUNCTION myvarcharsend(myvarchar) RETURNS bytea LANGUAGE internal STABLE PARALLEL SAFE STRICT AS 'varcharsend'; CREATE FUNCTION myvarcharrecv(internal, oid, integer) RETURNS myvarchar LANGUAGE internal STABLE PARALLEL SAFE STRICT AS 'varcharrecv'; CREATE TYPE myvarchar ( input =3D myvarcharin, output =3D myvarcharout, alignment =3D integer, storage =3D main ); -- want to check updating of a domain over the target type, too CREATE DOMAIN myvarchardom AS myvarchar; ALTER TYPE myvarchar SET (storage =3D extended); 3) invalid type option send ALTER TYPE myvarchar SET ( send =3D myvarcharsend, receive =3D myvarcharrecv, typmod_in =3D varchartypmodin, typmod_out =3D varchartypmodout, -- these are bogus, but it's safe as long as we don't use the type: analyze =3D ts_typanalyze, subscript =3D raw_array_subscript_handler ); 4) There are some unsupported alter table subtype: CREATE FOREIGN DATA WRAPPER dummy; CREATE SERVER s0 FOREIGN DATA WRAPPER dummy; CREATE FOREIGN TABLE ft1 ( c1 integer OPTIONS ("param 1" 'val1') NOT NULL, c2 text OPTIONS (param2 'val2', param3 'val3') CHECK (c2 <> ''), c3 date, CHECK (c3 BETWEEN '1994-01-01'::date AND '1994-01-31'::date) ) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value'); 5) similarly in case of alter foreign table: ALTER FOREIGN TABLE ft1 ADD COLUMN c10 integer OPTIONS (p1 'v1'); 6) Few whitespace errors: Applying: Infrastructure to support DDL deparsing. .git/rebase-apply/patch:486: indent with spaces. bool force_qualify) .git/rebase-apply/patch:488: indent with spaces. int i; .git/rebase-apply/patch:489: indent with spaces. char* (*func[2])(Oid) =3D {format_type_be, format_type_be_qualifi= ed}; .git/rebase-apply/patch:491: indent with spaces. appendStringInfoChar(buf, '('); .git/rebase-apply/patch:492: indent with spaces. for (i =3D 0; i < procform->pronargs; i++) warning: squelched 10 whitespace errors warning: 15 lines add whitespace errors. 7) Alter foreign table rename not handled: ALTER FOREIGN TABLE foreign_schema.ft1 RENAME TO foreign_table_1; Regards, Vignesh