pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Automatically generate node support functions
Date: Sat, 09 Jul 2022 07:03:31 +0000
Message-ID: <E1oA4V0-001v81-1T@gemulon.postgresql.org> (raw)

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@sss.pgh.pa.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(-)



Message-ID: <E1oA4V0-001v81-1T@gemulon.postgresql.org>
Permalink:  ../E1oA4V0-001v81-1T@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oA4V0-001v81-1T@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org
  Subject: Re: pgsql: Automatically generate node support functions
  In-Reply-To: <E1oA4V0-001v81-1T@gemulon.postgresql.org>
  References: <E1oA4V0-001v81-1T@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox