pgsql: Automatically generate node support functions

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Automatically generate node support functions
Date: 2022-07-09 07:03:31
Message-ID: E1oA4V0-001v81-1T@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Automatically generate node support functions

Add a script to automatically generate the node support functions
(copy, equal, out, and read, as well as the node tags enum) from the
struct definitions.

For each of the four node support files, it creates two include files,
e.g., copyfuncs.funcs.c and copyfuncs.switch.c, to include in the main
file. All the scaffolding of the main file stays in place.

I have tried to mostly make the coverage of the output match what is
currently there. For example, one could now do out/read coverage of
utility statement nodes, but I have manually excluded those for now.
The reason is mainly that it's easier to diff the before and after,
and adding a bunch of stuff like this might require a separate
analysis and review.

Subtyping (TidScan -> Scan) is supported.

For the hard cases, you can just write a manual function and exclude
generating one. For the not so hard cases, there is a way of
annotating struct fields to get special behaviors. For example,
pg_node_attr(equal_ignore) has the field ignored in equal functions.

(In this patch, I have only ifdef'ed out the code to could be removed,
mainly so that it won't constantly have merge conflicts. It will be
deleted in a separate patch. All the code comments that are worth
keeping from those sections have already been moved to the header
files where the structs are defined.)

Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://www.postgresql.org/message-id/flat/c1097590-a6a4-486a-64b1-e1f9cc0533ce%40enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/964d01ae90c314eb31132c2e7712d5d9fc237331

Modified Files
--------------
src/backend/Makefile | 10 +-
src/backend/nodes/.gitignore | 4 +
src/backend/nodes/Makefile | 59 ++
src/backend/nodes/README | 80 +--
src/backend/nodes/copyfuncs.c | 20 +-
src/backend/nodes/equalfuncs.c | 22 +-
src/backend/nodes/gen_node_support.pl | 920 +++++++++++++++++++++++++++++++
src/backend/nodes/outfuncs.c | 34 +-
src/backend/nodes/readfuncs.c | 23 +-
src/include/Makefile | 1 +
src/include/catalog/catversion.h | 2 +-
src/include/executor/tuptable.h | 8 +
src/include/nodes/.gitignore | 2 +
src/include/nodes/extensible.h | 2 +
src/include/nodes/nodes.h | 66 +++
src/include/nodes/parsenodes.h | 19 +-
src/include/nodes/pathnodes.h | 331 +++++++----
src/include/nodes/plannodes.h | 117 ++--
src/include/nodes/primnodes.h | 46 +-
src/include/nodes/value.h | 10 +
src/include/utils/rel.h | 8 +-
src/tools/msvc/Solution.pm | 48 ++
src/tools/pgindent/exclude_file_patterns | 5 +
23 files changed, 1614 insertions(+), 223 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2022-07-09 07:44:24 pgsql: Fix vpath build
Previous Message Bruce Momjian 2022-07-09 00:24:00 pgsql: doc: add examples for array_length() and jsonb_array_length()