aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/copyfuncs.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-02-12 09:31:16 -0500
committerRobert Haas <rhaas@postgresql.org>2016-02-12 09:38:11 -0500
commitbcac23de73b89b001fbc628d84471a392e928d1c (patch)
tree91e5ec8553f54fbeef109eff48f86f8d47dfcf2a /src/backend/nodes/copyfuncs.c
parent63461a63f94a333eae272be3d44ae1602cda75cb (diff)
downloadpostgresql-bcac23de73b89b001fbc628d84471a392e928d1c.tar.gz
postgresql-bcac23de73b89b001fbc628d84471a392e928d1c.zip
Introduce extensible node types.
An extensible node is always tagged T_Extensible, but the extnodename field identifies it more specifically; it may also include arbitrary private data. Extensible nodes can be copied, tested for equality, serialized, and deserialized, but the core system doesn't know anything about them otherwise. Some extensions may find it useful to include these nodes in fdw_private or custom_private lists in lieu of arm-wrestling their data into a format that the core code can understand. Along the way, so as not to burden the authors of such extensible node types too much, expose the functions for writing serialized tokens, and for serializing and deserializing bitmapsets. KaiGai Kohei, per a design suggested by me. Reviewed by Andres Freund and by me, and further edited by me.
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r--src/backend/nodes/copyfuncs.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index e54d1744b0a..a9e9cc379b8 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -23,6 +23,7 @@
#include "postgres.h"
#include "miscadmin.h"
+#include "nodes/extensible.h"
#include "nodes/plannodes.h"
#include "nodes/relation.h"
#include "utils/datum.h"
@@ -4166,6 +4167,27 @@ _copyList(const List *from)
}
/* ****************************************************************
+ * extensible.h copy functions
+ * ****************************************************************
+ */
+static ExtensibleNode *
+_copyExtensibleNode(const ExtensibleNode *from)
+{
+ ExtensibleNode *newnode;
+ const ExtensibleNodeMethods *methods;
+
+ methods = GetExtensibleNodeMethods(from->extnodename, false);
+ newnode = (ExtensibleNode *) newNode(methods->node_size,
+ T_ExtensibleNode);
+ COPY_STRING_FIELD(extnodename);
+
+ /* copy the private fields */
+ methods->nodeCopy(newnode, from);
+
+ return newnode;
+}
+
+/* ****************************************************************
* value.h copy functions
* ****************************************************************
*/
@@ -4545,6 +4567,13 @@ copyObject(const void *from)
break;
/*
+ * EXTENSIBLE NODES
+ */
+ case T_ExtensibleNode:
+ retval = _copyExtensibleNode(from);
+ break;
+
+ /*
* PARSE NODES
*/
case T_Query: