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 1mTlCe-0006hW-7Y for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Sep 2021 13:25:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mTlCd-00039j-6x for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Sep 2021 13:25:23 +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 1mTlCc-00039b-VQ for pgsql-hackers@lists.postgresql.org; Fri, 24 Sep 2021 13:25:22 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mTlCW-0000wQ-2d for pgsql-hackers@postgresql.org; Fri, 24 Sep 2021 13:25:22 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4CEDA3200A2F; Fri, 24 Sep 2021 09:25:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 24 Sep 2021 09:25:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=m4JHIZgYua6ep5GkfLbDfFmRtacqgosXSAmPj4lfwhU=; b=Og6t787f j/hjjsQy0Km6MHQJ3Y4xeKtTHqjH3EfVBMq/Wc2p4vArm2cCc+Z9eNBhNimBZawv d8hGCbfBvDWJGQ/U1P1RRK5wrCRrIvXyLuNySMyEcPuGex/fe3GRBROYQ4QgtUXD J12N4seiT/ZneIGIagPNAwxzJp3UVGdrKHxhjUjzW4G1D7KvQyOtdYvTAS3bR70Y /LsnonZDrNcX7a0dm6UHxI+agN0xozZRl3fdpcbNl0sd7GYAlBLlSNsF49ZyZCRc XcaS6DysikLTbo9vgGzuvdQ7mwBBk2G/hTSGOyb3deZJRRldM6MdLCTQII9AAErb 6L7uMLPLQbZjuw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejuddgieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedujeevjeffjeevuddutedvkeeiueeitddvieelfeekveej udefgeeuvdejhfeuleenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 24 Sep 2021 09:25:12 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 627372A0754; Fri, 24 Sep 2021 10:25:09 -0300 (-03) Date: Fri, 24 Sep 2021 10:25:09 -0300 From: Alvaro Herrera To: Amit Kapila Cc: vignesh C , Rahila Syed , Tomas Vondra , Peter Smith , PostgreSQL-development Subject: Re: Column Filtering in Logical Replication Message-ID: <202109241325.eag5g6mpvoup@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Sep-23, Amit Kapila wrote: > Alvaro, do you have any thoughts on these proposed grammar changes? Yeah, I think pubobj_name remains a problem in that you don't know its return type -- could be a String or a RangeVar, and the user of that production can't distinguish. So you're still (unnecessarily, IMV) stashing an object of undetermined type into ->object. I think you should get rid of both pubobj_name and pubobj_expr and do somethine like this: /* FOR TABLE and FOR ALL TABLES IN SCHEMA specifications */ PublicationObjSpec: TABLE ColId { $$ = makeNode(PublicationObjSpec); $$->pubobjtype = PUBLICATIONOBJ_TABLE; $$->rangevar = makeRangeVarFromQualifiedName($1, NULL, @1, yyscanner); } | TABLE ColId indirection { $$ = makeNode(PublicationObjSpec); $$->pubobjtype = PUBLICATIONOBJ_TABLE; $$->rangevar = makeRangeVarFromQualifiedName($1, $2, @1, yyscanner); } | ALL TABLES IN_P SCHEMA ColId { $$ = makeNode(PublicationObjSpec); $$->pubobjtype = PUBLICATIONOBJ_REL_IN_SCHEMA; $$->name = $4; } | ALL TABLES IN_P SCHEMA CURRENT_SCHEMA /* XXX should this be "IN_P CURRENT_SCHEMA"? */ { $$ = makeNode(PublicationObjSpec); $$->pubobjtype = PUBLICATIONOBJ_CURRSCHEMA; $$->name = $4; } | ColId { $$ = makeNode(PublicationObjSpec); $$->name = $1; $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION; } | ColId indirection { $$ = makeNode(PublicationObjSpec); $$->rangevar = makeRangeVarFromQualifiedName($1, $2, @1, yyscanner); $$->pubobjtype = PUBLICATIONOBJ_CONTINUATION; } | CURRENT_SCHEMA { $$ = makeNode(PublicationObjSpec); $$->pubobjtype = PUBLICATIONOBJ_CURRSCHEMA; } ; so in AlterPublicationStmt you would have stanzas like | ALTER PUBLICATION name ADD_P pub_obj_list { AlterPublicationStmt *n = makeNode(AlterPublicationStmt); n->pubname = $3; n->pubobjects = preprocess_pubobj_list($5); n->action = DEFELEM_ADD; $$ = (Node *)n; } where preprocess_pubobj_list (defined right after processCASbits and somewhat mimicking it and SplitColQualList) takes all PUBLICATIONOBJ_CONTINUATION and turns them into either PUBLICATIONOBJ_TABLE entries or PUBLICATIONOBJ_REL_IN_SCHEMA entries, depending on what the previous entry was. (And of course if there is no previous entry, raise an error immediately). Note that node PublicationObjSpec now has two fields, one for RangeVar and another for a plain name, and tables always use the second one, except when they are continuations, but of course those continuations that use name are turned into rangevars in the preprocess step. I think that would make the code in ObjectsInPublicationToOids less messy. (I don't think using the string "CURRENT_SCHEMA" is a great solution. Did you try having a schema named CURRENT_SCHEMA?) I verified that bison is happy with the grammar I proposed; I also verified that you can add opt_column_list to the stanzas for tables, and it remains happy. -- Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/ Y una voz del caos me habló y me dijo "Sonríe y sé feliz, podría ser peor". Y sonreí. Y fui feliz. Y fue peor.