aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/copyfuncs.c
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/backend/nodes/copyfuncs.c
parent2373fe78dfc9d4aa2348a86fffdf8eb9d757e9d5 (diff)
downloadpostgresql-964d01ae90c314eb31132c2e7712d5d9fc237331.tar.gz
postgresql-964d01ae90c314eb31132c2e7712d5d9fc237331.zip
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/copyfuncs.c')
-rw-r--r--src/backend/nodes/copyfuncs.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 2c834e4d0d4..b72c79f2dfe 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -23,11 +23,7 @@
#include "postgres.h"
#include "miscadmin.h"
-#include "nodes/extensible.h"
-#include "nodes/pathnodes.h"
-#include "nodes/plannodes.h"
#include "utils/datum.h"
-#include "utils/rel.h"
/*
@@ -73,6 +69,9 @@
(newnode->fldname = from->fldname)
+#include "copyfuncs.funcs.c"
+
+#ifdef OBSOLETE
/* ****************************************************************
* plannodes.h copy functions
* ****************************************************************
@@ -1431,6 +1430,7 @@ _copyVar(const Var *from)
return newnode;
}
+#endif /* OBSOLETE */
/*
* _copyConst
@@ -1470,6 +1470,7 @@ _copyConst(const Const *from)
return newnode;
}
+#ifdef OBSOLETE
/*
* _copyParam
*/
@@ -3214,6 +3215,7 @@ _copyParamRef(const ParamRef *from)
return newnode;
}
+#endif /* OBSOLETE */
static A_Const *
_copyA_Const(const A_Const *from)
@@ -3254,6 +3256,7 @@ _copyA_Const(const A_Const *from)
return newnode;
}
+#ifdef OBSOLETE
static FuncCall *
_copyFuncCall(const FuncCall *from)
{
@@ -5419,6 +5422,7 @@ _copyDropSubscriptionStmt(const DropSubscriptionStmt *from)
return newnode;
}
+#endif /* OBSOLETE */
/* ****************************************************************
* extensible.h copy functions
@@ -5441,6 +5445,7 @@ _copyExtensibleNode(const ExtensibleNode *from)
return newnode;
}
+#ifdef OBSOLETE
/* ****************************************************************
* value.h copy functions
* ****************************************************************
@@ -5511,6 +5516,7 @@ _copyForeignKeyCacheInfo(const ForeignKeyCacheInfo *from)
return newnode;
}
+#endif /* OBSOLETE */
/*
* copyObjectImpl -- implementation of copyObject(); see nodes/nodes.h
@@ -5531,6 +5537,8 @@ copyObjectImpl(const void *from)
switch (nodeTag(from))
{
+#include "copyfuncs.switch.c"
+#ifdef OBSOLETE
/*
* PLAN NODES
*/
@@ -5969,6 +5977,7 @@ copyObjectImpl(const void *from)
case T_BitString:
retval = _copyBitString(from);
break;
+#endif /* OBSOLETE */
/*
* LIST NODES
@@ -5986,6 +5995,8 @@ copyObjectImpl(const void *from)
retval = list_copy(from);
break;
+#ifdef OBSOLETE
+
/*
* EXTENSIBLE NODES
*/
@@ -6537,6 +6548,7 @@ copyObjectImpl(const void *from)
case T_ForeignKeyCacheInfo:
retval = _copyForeignKeyCacheInfo(from);
break;
+#endif /* OBSOLETE */
default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(from));