summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2022-07-09 08:52:19 +0200
committerPeter Eisentraut <peter@eisentraut.org>2022-07-09 08:53:59 +0200
commit964d01ae90c314eb31132c2e7712d5d9fc237331 (patch)
tree244be052514e9c37bfa31f2799038964d12a2c88 /src/tools
parent2373fe78dfc9d4aa2348a86fffdf8eb9d757e9d5 (diff)
downloadpostgresql-964d01ae90c314eb31132c2e7712d5d9fc237331.tar.gz
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
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/msvc/Solution.pm48
-rw-r--r--src/tools/pgindent/exclude_file_patterns5
2 files changed, 53 insertions, 0 deletions
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 52ff56ba83..b8b1728df7 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -839,6 +839,54 @@ EOF
close($chs);
}
+ if (IsNewer(
+ 'src/backend/nodes/node-support-stamp',
+ 'src/backend/nodes/gen_node_support.pl'))
+ {
+ # XXX duplicates src/backend/nodes/Makefile
+
+ my @node_headers = qw(
+ nodes/nodes.h
+ nodes/execnodes.h
+ nodes/plannodes.h
+ nodes/primnodes.h
+ nodes/pathnodes.h
+ nodes/extensible.h
+ nodes/parsenodes.h
+ nodes/replnodes.h
+ nodes/value.h
+ commands/trigger.h
+ commands/event_trigger.h
+ foreign/fdwapi.h
+ access/amapi.h
+ access/tableam.h
+ access/tsmapi.h
+ utils/rel.h
+ nodes/supportnodes.h
+ executor/tuptable.h
+ nodes/lockoptions.h
+ access/sdir.h
+ );
+
+ chdir('src/backend/nodes');
+
+ my @node_files = map { "../../../src/include/$_" } @node_headers;
+
+ system("perl gen_node_support.pl @node_files");
+ open(my $f, '>', 'node-support-stamp')
+ || confess "Could not touch node-support-stamp";
+ close($f);
+ chdir('../../..');
+ }
+
+ if (IsNewer(
+ 'src/include/nodes/nodetags.h',
+ 'src/backend/nodes/nodetags.h'))
+ {
+ copyFile('src/backend/nodes/nodetags.h',
+ 'src/include/nodes/nodetags.h');
+ }
+
open(my $o, '>', "doc/src/sgml/version.sgml")
|| croak "Could not write to version.sgml\n";
print $o <<EOF;
diff --git a/src/tools/pgindent/exclude_file_patterns b/src/tools/pgindent/exclude_file_patterns
index f08180b0d0..f5c8857e31 100644
--- a/src/tools/pgindent/exclude_file_patterns
+++ b/src/tools/pgindent/exclude_file_patterns
@@ -7,6 +7,11 @@ src/include/port/atomics/
# This contains C++ constructs that confuse pgindent.
src/include/jit/llvmjit\.h$
#
+# These are generated files with incomplete code fragments that
+# confuse pgindent.
+src/backend/nodes/\w+\.funcs\.c$
+src/backend/nodes/\w+\.switch\.c$
+#
# This confuses pgindent, and it's a derived file anyway.
src/backend/utils/fmgrtab\.c$
#