aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/outfuncs.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/outfuncs.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/outfuncs.c')
-rw-r--r--src/backend/nodes/outfuncs.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 3e1c3e6be57..28d983c9a87 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -26,6 +26,7 @@
#include <ctype.h>
#include "lib/stringinfo.h"
+#include "nodes/extensible.h"
#include "nodes/plannodes.h"
#include "nodes/relation.h"
#include "utils/datum.h"
@@ -140,6 +141,13 @@ _outToken(StringInfo str, const char *s)
}
}
+/* for use by extensions which define extensible nodes */
+void
+outToken(StringInfo str, const char *s)
+{
+ _outToken(str, s);
+}
+
static void
_outList(StringInfo str, const List *node)
{
@@ -196,6 +204,13 @@ _outBitmapset(StringInfo str, const Bitmapset *bms)
appendStringInfoChar(str, ')');
}
+/* for use by extensions which define extensible nodes */
+void
+outBitmapset(StringInfo str, const Bitmapset *bms)
+{
+ _outBitmapset(str, bms);
+}
+
/*
* Print the value of a Datum given its type.
*/
@@ -2114,6 +2129,27 @@ _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
/*****************************************************************************
*
+ * Stuff from extensible.h
+ *
+ *****************************************************************************/
+
+static void
+_outExtensibleNode(StringInfo str, const ExtensibleNode *node)
+{
+ const ExtensibleNodeMethods *methods;
+
+ methods = GetExtensibleNodeMethods(node->extnodename, false);
+
+ WRITE_NODE_TYPE("EXTENSIBLENODE");
+
+ WRITE_STRING_FIELD(extnodename);
+
+ /* serialize the private fields */
+ methods->nodeOut(str, node);
+}
+
+/*****************************************************************************
+ *
* Stuff from parsenodes.h.
*
*****************************************************************************/
@@ -3367,6 +3403,10 @@ _outNode(StringInfo str, const void *obj)
_outPlannerParamItem(str, obj);
break;
+ case T_ExtensibleNode:
+ _outExtensibleNode(str, obj);
+ break;
+
case T_CreateStmt:
_outCreateStmt(str, obj);
break;