diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-07-12 11:22:52 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-07-12 11:22:52 -0400 |
commit | eea9fa9b250f4044aa35d537f234c7d44fa9db3d (patch) | |
tree | f3103887808ab4b30e634d84cd2b740c6a246ed2 /src/include/nodes/nodes.h | |
parent | ca187d7455f174da40e26e6e0c8361821ee19559 (diff) |
Add defenses against unexpected changes in the NodeTag enum list.
Having different build systems producing different contents of the
NodeTag enum would be catastrophic for extension ABI stability.
But that ordering depends on the order in which gen_node_support.pl
processes its input files. It seems too fragile to let the Makefiles,
MSVC build scripts, and soon meson build scripts all set this order
independently. As a klugy but serviceable solution, put a canonical
copy of the file list into gen_node_support.pl itself, and check that
against the files given on the command line.
Also, while it's fine to add and delete node tags during development,
we must not let the assigned NodeTag values change unexpectedly in
stable branches. Add a cross-check that can be enabled when a branch
is forked off (or later, but that is a time when we're unlikely to
miss doing it). It just checks that the last auto-assigned number
doesn't change, which is simplistic but will catch the most likely
sorts of mistakes.
From time to time we do need to add a node tag in a stable branch.
To support doing that without changing the branch's auto-assigned
tag numbers, invent pg_node_attr(nodetag_number(VALUE)) which can
be used to give such a node a hand-assigned tag above the last
auto-assigned one.
Discussion: https://postgr.es/m/1249010.1657574337@sss.pgh.pa.us
Diffstat (limited to 'src/include/nodes/nodes.h')
-rw-r--r-- | src/include/nodes/nodes.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index c8ed4e05524..cdd6debfa0e 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -66,6 +66,11 @@ typedef enum NodeTag * * - special_read_write: Has special treatment in outNode() and nodeRead(). * + * - nodetag_number(VALUE): assign the specified nodetag number instead of + * an auto-generated number. Typically this would only be used in stable + * branches, to give a newly-added node type a number without breaking ABI + * by changing the numbers of existing node types. + * * Node types can be supertypes of other types whether or not they are marked * abstract: if a node struct appears as the first field of another struct * type, then it is the supertype of that type. The no_copy, no_equal, and |