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.94.2) (envelope-from ) id 1rQVvT-001m4L-Hp for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jan 2024 17:11:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rQVvR-004R2z-Rm for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jan 2024 17:11:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rQVvR-004R2r-67 for pgsql-hackers@lists.postgresql.org; Thu, 18 Jan 2024 17:11:33 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rQVvJ-002UiL-3P for pgsql-hackers@postgresql.org; Thu, 18 Jan 2024 17:11:32 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 344815C018E; Thu, 18 Jan 2024 12:11:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 18 Jan 2024 12:11:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1705597883; x= 1705684283; bh=9ZvgFOnthV//FHO5k7tc4D5hfjoDbWRcxsURY7LivZk=; b=P VAIqnO70y4/R45Z3AABmgRFkzH2RlO0s65juC3SrJ7wvjbUfakUKEmPJYTYc3hwc PaaPsFagCplVPx10pvTpifjk78bG1CJnW5vPrVaUS9KXYKR1YnL8bM+Jzdu9QxrZ K44RFz+aSuBQHq3c+OZGzHfpgRrxLW2UAJJ9xdyptM7DbrAoydgAQeFGzQja9Bmg UWGA7/B0sdVLYjQ9gCCbUvNaeDG/LMdCglcps4hUiloYF0REhHe4lbiwlWUswUAI 9FC2Yj7rPZKOZKvPUnJkF0gnf0Q+Gvhu3dgdbi1UdXmWhEWszeTyEMflyQOB6pK5 RgwapOGEACyHMBe+i2XLA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejkedgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepudelkeekgfdttdettdekgfduvdeiffelteegjeeihfet heekveeftedtuddvhfeunecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jan 2024 12:11:22 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1705597878; bh=T2+l0sioPMTCQ1EdvmnPJtNi9zrUINFaeJfC41osudo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=GsDUW8cAm+fsbN8hA2ncmsy1OxfkFFb60fjEpyFMA9Gn9OoJQWTtNdu+hba8H45q1 7ilaj5Y0rpc+KDH/PcMegW7cUx60dKcezOi2GvNtDTODWuyGa3IvRxDLuLohR7x+Af rDJOg9uo/rxb5zhf8rthnp4MvdiAXGxek+MjcthdDKwoM+m8qyxR5fLHssc50Ou5+W 1mLc2ccrPdPnQd2oa8PMYW8e4xCn73zaQplUvTtw3Jcif9J4rootlw8dFRTUp5EgDd A42std5CYIGy4bwtAzS/K1Up5OcohIhAKNJqX0aVksFXF/Ts6Hnb1yyGnycGosrilw xMm2XPDfmGI1g== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id CB8E791; Thu, 18 Jan 2024 18:11:18 +0100 (CET) Date: Thu, 18 Jan 2024 18:11:18 +0100 From: Alvaro Herrera To: Amit Langote Cc: Andres Freund , Erik Rijkers , jian he , Andrew Dunstan , PostgreSQL-development Subject: Re: remaining sql/json patches Message-ID: <202401181711.qxjxpnl3ohnw@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="cjzngvutdwv27npt" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202401181146.fuoeskfzriq7@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --cjzngvutdwv27npt Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2024-Jan-18, Alvaro Herrera wrote: > commands/explain.c (Hmm, I think this is a preexisting bug actually) > > 3893 18 : case T_TableFuncScan: > 3894 18 : Assert(rte->rtekind == RTE_TABLEFUNC); > 3895 18 : if (rte->tablefunc) > 3896 0 : if (rte->tablefunc->functype == TFT_XMLTABLE) > 3897 0 : objectname = "xmltable"; > 3898 : else /* Must be TFT_JSON_TABLE */ > 3899 0 : objectname = "json_table"; > 3900 : else > 3901 18 : objectname = NULL; > 3902 18 : objecttag = "Table Function Name"; > 3903 18 : break; Indeed -- the problem seems to be that add_rte_to_flat_rtable is creating a new RTE and zaps the ->tablefunc pointer for it. So when EXPLAIN goes to examine the struct, there's a NULL pointer there and nothing is printed. One simple fix is to change add_rte_to_flat_rtable so that it doesn't zero out the tablefunc pointer, but this is straight against what that function is trying to do, namely to remove substructure. Which means that we need to preserve the name somewhere else. I added a new member to RangeTblEntry for this, which perhaps is a little ugly. So here's the patch for that. (I also added an alias to one XMLTABLE invocation under EXPLAIN, to show what it looks like when an alias is specified. Otherwise they're always shown as "XMLTABLE" "xmltable" which is a bit dumb). Another possible way out is to decide that we don't want the "objectname" to be reported here. I admit it's perhaps redundant. In this case we'd just remove lines 3896-3899 shown above and let it be NULL. Thoughts? -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ --cjzngvutdwv27npt Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Show-function-name-in-TableFuncScan.patch"