Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2022-07-09 06:52:19 +0000
committerPeter Eisentraut2022-07-09 06:53:59 +0000
commit964d01ae90c314eb31132c2e7712d5d9fc237331 (patch)
tree244be052514e9c37bfa31f2799038964d12a2c88 /src/backend/nodes/readfuncs.c
parent2373fe78dfc9d4aa2348a86fffdf8eb9d757e9d5 (diff)
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/backend/nodes/readfuncs.c')
-rw-r--r--src/backend/nodes/readfuncs.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index 6b11f0481bf..21176cd4c04 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -33,9 +33,7 @@
#include <math.h>
#include "miscadmin.h"
-#include "nodes/extensible.h"
-#include "nodes/parsenodes.h"
-#include "nodes/plannodes.h"
+#include "nodes/bitmapset.h"
#include "nodes/readfuncs.h"
@@ -238,6 +236,8 @@ readBitmapset(void)
return _readBitmapset();
}
+#include "readfuncs.funcs.c"
+
/*
* _readQuery
*/
@@ -291,6 +291,7 @@ _readQuery(void)
READ_DONE();
}
+#ifdef OBSOLETE
/*
* _readNotifyStmt
*/
@@ -629,6 +630,7 @@ _readVar(void)
READ_DONE();
}
+#endif /* OBSOLETE */
/*
* _readConst
@@ -655,6 +657,7 @@ _readConst(void)
READ_DONE();
}
+#ifdef OBSOLETE
/*
* _readParam
*/
@@ -880,6 +883,7 @@ _readScalarArrayOpExpr(void)
READ_DONE();
}
+#endif /* OBSOLETE */
/*
* _readBoolExpr
@@ -907,6 +911,7 @@ _readBoolExpr(void)
READ_DONE();
}
+#ifdef OBSOLETE
/*
* _readSubLink
*/
@@ -1649,6 +1654,7 @@ _readAppendRelInfo(void)
/*
* Stuff from parsenodes.h.
*/
+#endif /* OBSOLETE */
/*
* _readRangeTblEntry
@@ -1744,6 +1750,7 @@ _readRangeTblEntry(void)
READ_DONE();
}
+#ifdef OBSOLETE
/*
* _readRangeTblFunction
*/
@@ -2846,6 +2853,7 @@ _readAlternativeSubPlan(void)
READ_DONE();
}
+#endif /* OBSOLETE */
/*
* _readExtensibleNode
@@ -2877,6 +2885,7 @@ _readExtensibleNode(void)
READ_DONE();
}
+#ifdef OBSOLETE
/*
* _readPartitionBoundSpec
*/
@@ -2911,6 +2920,7 @@ _readPartitionRangeDatum(void)
READ_DONE();
}
+#endif /* OBSOLETE */
/*
* parseNodeString
@@ -2935,7 +2945,11 @@ parseNodeString(void)
#define MATCH(tokname, namelen) \
(length == namelen && memcmp(token, tokname, namelen) == 0)
- if (MATCH("QUERY", 5))
+ if (false)
+ ;
+#include "readfuncs.switch.c"
+#ifdef OBSOLETE
+ else if (MATCH("QUERY", 5))
return_value = _readQuery();
else if (MATCH("WITHCHECKOPTION", 15))
return_value = _readWithCheckOption();
@@ -3205,6 +3219,7 @@ parseNodeString(void)
return_value = _readJsonTableParent();
else if (MATCH("JSONTABLESIBLING", 16))
return_value = _readJsonTableSibling();
+#endif /* OBSOLETE */
else
{
elog(ERROR, "badly formatted node string \"%.32s\"...", token);