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 1oDUln-00052j-MC for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jul 2022 17:43:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oDUll-000246-LS for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jul 2022 17:42:57 +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 1oDUlk-0001w8-Li for pgsql-hackers@lists.postgresql.org; Mon, 18 Jul 2022 17:42:57 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oDUlh-00023q-Rt for pgsql-hackers@lists.postgresql.org; Mon, 18 Jul 2022 17:42:55 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 071D93200344; Mon, 18 Jul 2022 13:42:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 18 Jul 2022 13:42:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1658166169; x= 1658252569; bh=HjxqeLiqyBE2WNnC7NrbHu6wOxrUO4ut0tK1Pc4812E=; b=O kx/vljeqD5oFN8+Z/6+X/i7XTOAJ0GjOMJByTd90vPaX4rJCZydWrb7Kek5S440g YARe5uN40GNoHtJdbKErpUGwO15D6IX3CYGiQJPxKuCYvjuF9sFEO/LUX7mUU9Bt PSsbt9KOPU5m5OZ90US3J/p2eIjGS2buOrhlO6uo5Zsx9nL2FDNlWGEEiPPLTS7s WFKRXVkkY1REQCfx/KHu6+AjnGkojMvwVY+qF6uIL8v+oxGlBT3M34kHGmBzCKnC dzjZphdwC44thbuBmcrW712QvU7kv1Hhww1q/gVC/24DBUjf4R7NO9KfG4qx9bCV CFEiTRaMUnCvn7r8VCTyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1658166169; x= 1658252569; bh=HjxqeLiqyBE2WNnC7NrbHu6wOxrUO4ut0tK1Pc4812E=; b=1 flyjjs+R9MFYOyQvolKZVMBE6Mhhle/a7HtVAL4SKqYsMGPoWp1trREZknsUjKjD 9tHq8YOkIutCeFmD8qB6k8s2BgLNGPT+wj2/p8bK1qtBYWKrXiej/0eRBquHRCfM 5iXWNsK3b92Gt61udC1FQF0f1yz4HHWTqHt+O67abcjfKQFhHp3lknFT7SGKMaim tAnd7p/2XGv/B14A3D0g3m+CbQdMNHuSWzhAETW/k5nKV6B9Wgpv8Uanqf25Owjc QoF0drJB4NU+wuf1k0agHLNRk1blUZ7cXKX60qunguVXgUNbeGttyOoABwWiaO5A wjlF/tA8M6oRuTAZfS+wQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudekkedguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufhffjgfkfgggtgfgse htkeertddtreejnecuhfhrohhmpeffrghgfhhinhhnpgfklhhmrghrihgpofgrnhhnshon khgvrhcuoehilhhmrghrihesihhlmhgrrhhirdhorhhgqeenucggtffrrghtthgvrhhnpe eggeekgfefheelkeeuhfevveektddtfedtffeuveeujeeftdegtdetffegtdfhleenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehilhhmrghrih esihhlmhgrrhhirdhorhhg X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 18 Jul 2022 13:42:48 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Convert planner's AggInfo and AggTransInfo to Nodes References: <742479.1658160504@sss.pgh.pa.us> Date: Mon, 18 Jul 2022 18:42:47 +0100 In-Reply-To: <742479.1658160504@sss.pgh.pa.us> (Tom Lane's message of "Mon, 18 Jul 2022 12:08:24 -0400") Message-ID: <87pmi2iag8.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tom Lane writes: > I got annoyed just now upon finding that pprint() applied to the planner's > "root" pointer doesn't dump root->agginfos or root->aggtransinfos. That's > evidently because AggInfo and AggTransInfo aren't proper Nodes, just bare > structs, which presumably is because somebody couldn't be bothered to > write outfuncs support for them. I'd say that was a questionable shortcut > even when it was made, and there's certainly precious little excuse now > that gen_node_support.pl can do all the heavy lifting. Hence, PFA a > little finger exercise to turn them into Nodes. I took the opportunity > to improve related comments too, and in particular to fix some comments > that leave the impression that preprocess_minmax_aggregates still does > its own scan of the query tree. (It was momentary confusion over that > idea that got me to the point of being annoyed in the first place.) > > Any objections so far? It seems like a reasonable idea, but I don't know enough to judge the wider ramifications of it. But one thing that the patch should also do, is switch to using the l*_node() functions instead of manual casting. The ones I noticed in the patch/context are below, but there are a few more: > foreach(lc, root->agginfos) > { > AggInfo *agginfo = (AggInfo *) lfirst(lc); AggInfo *agginfo = lfirst_node(AggInfo, lc); […] > foreach(lc, transnos) > { > int transno = lfirst_int(lc); > - AggTransInfo *pertrans = (AggTransInfo *) list_nth(root->aggtransinfos, transno); > + AggTransInfo *pertrans = (AggTransInfo *) list_nth(root->aggtransinfos, > + transno); > + AggTransInfo *pertrans = (AggTransInfo *) list_nth(root->aggtransinfos, > + transno); AggTransInfo *pertrans = list_nth_node(AggTransInfo, root->aggtransinfos, transno); - ilmari