automatically generating node support functions

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: automatically generating node support functions
Date: 2021-06-07 20:27:52
Message-ID: c1097590-a6a4-486a-64b1-e1f9cc0533ce@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote 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.

The first eight patches are to clean up various inconsistencies to make
parsing or generation easier.

The interesting stuff is in patch 0009.

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

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. Eventually,
that should all be changed to delete the code. When we do that, some
code comments should probably be preserved elsewhere, so that will need
another pass of consideration.

I have tried to mostly make the coverage of the output match what is
currently there. For example, one could do out/read coverage of utility
statement nodes easily with this, 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.

There are a couple of additional minor issues mentioned in the script
source. But basically, it all seems to work.

Attachment Content-Type Size
v1-0001-Rename-NodeTag-of-ExprState.patch text/plain 1.7 KB
v1-0002-Rename-argument-of-_outValue.patch text/plain 2.1 KB
v1-0003-Rename-some-node-support-functions-for-consistenc.patch text/plain 5.2 KB
v1-0004-Change-SeqScan-node-to-contain-Scan-node.patch text/plain 3.8 KB
v1-0005-Change-NestPath-node-to-contain-JoinPath-node.patch text/plain 10.2 KB
v1-0006-Add-missing-enum-tags-in-enums-used-in-nodes.patch text/plain 1.9 KB
v1-0007-Check-the-size-in-COPY_POINTER_FIELD.patch text/plain 4.1 KB
v1-0008-Remove-T_MemoryContext.patch text/plain 689 bytes
v1-0009-Add-script-to-generate-node-support-functions.patch text/plain 52.3 KB
v1-0010-XXX-Debugging-support.patch text/plain 1015 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-06-07 20:34:06 Re: CALL versus procedures with output-only arguments
Previous Message Peter Eisentraut 2021-06-07 19:54:33 Re: CALL versus procedures with output-only arguments