Обсуждение: pgsql: Automatically generate node support functions

Поиск
Список
Период
Сортировка

pgsql: Automatically generate node support functions

От
Peter Eisentraut
Дата:
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(-)