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 1oAvTs-0007I4-JR for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Jul 2022 15:37:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oAvTr-0001n0-6K for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Jul 2022 15:37:51 +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 1oAvTq-0001mr-TX for pgsql-hackers@lists.postgresql.org; Mon, 11 Jul 2022 15:37:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oAvTk-0008Fq-AX for pgsql-hackers@postgresql.org; Mon, 11 Jul 2022 15:37:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 26BFbd4T1116890; Mon, 11 Jul 2022 11:37:39 -0400 From: Tom Lane To: Peter Eisentraut cc: Andres Freund , David Rowley , pgsql-hackers Subject: Re: automatically generating node support functions In-reply-to: <45f508cb-e30b-c252-e081-4548deafa34c@enterprisedb.com> References: <1294462.1656875649@sss.pgh.pa.us> <57df9f30-d2cf-9126-28d4-ae40a2e733a9@enterprisedb.com> <1593978.1656953960@sss.pgh.pa.us> <2592455.1657140387@sss.pgh.pa.us> <3302658.1657288366@sss.pgh.pa.us> <611d2e! 93-6330-47fa-0970-72316aed50f2@enterprisedb.com> <3488143.1657310625@sss.pgh.pa.us> <11148777-fbe2-5188-195d-48f5083573c5@enterprisedb.com> <20220710214622.haiektrjzisob6rl@awork3.anarazel.de> <815831.1657494597@sss.pgh.pa.us> <45f508cb-e30b-c252-e081-4548deafa34c@enterprisedb.com> Comments: In-reply-to Peter Eisentraut message dated "Mon, 11 Jul 2022 16:09:24 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1116888.1657553859.1@sss.pgh.pa.us> Date: Mon, 11 Jul 2022 11:37:39 -0400 Message-ID: <1116889.1657553859@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > On 11.07.22 01:09, Tom Lane wrote: >> Andres Freund writes: > I was just rebasing meson ontop of this and was wondering whether the input > filenames were in a particular order: > First, things used by later files need to be found in earlier files. So > that constrains the order a bit. Yeah, the script needs to see supertype nodes before subtype nodes, else it will not realize that the subtypes are nodes at all. However, there is not very much cross-header-file subtyping. I experimented with rearranging the input-file order, and found that the *only* thing that breaks it is to put primnodes.h after pathnodes.h (which fails because PlaceHolderVar is a subtype of Expr). You don't even need nodes.h to be first, which astonished me initially, but then I realized that both NodeTag and struct Node are special-cased in gen_node_support.pl, so we know enough to get by even before reading nodes.h. More generally, the main *nodes.h files themselves are arranged in pipeline order, eg parsenodes.h #includes primnodes.h. So that seems to be a pretty safe thing to rely on even if we grow more cross-header subtyping cases later. But I'd vote for putting the incidental files in alphabetical order. > Second, the order of the files determines the ordering of the output. > The current order of the files reflects approximately the order how the > manual code was arranged. That could be changed. We could also just > sort the node types in the script and dump out everything alphabetically. +1 for sorting alphabetically. I experimented with that and it's a really trivial change. regards, tom lane