summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane2018-09-16 17:02:47 +0000
committerTom Lane2018-09-16 17:02:47 +0000
commit3844adbf3c2521c0956064c1c27096c96ca92201 (patch)
treeb76329a77f43a79dbb63110ed3a0ffd4e68c5e68 /src
parentda1db404358ebc2d4f1abcee712405cd888148de (diff)
Add outfuncs.c support for RawStmt nodes.
I noticed while poking at a report from Andrey Lepikhov that the recent addition of RawStmt nodes at the top of raw parse trees makes it impossible to print any raw parse trees whatsoever, because outfuncs.c doesn't know RawStmt and hence fails to descend into it. While we generally lack outfuncs.c support for utility statements, there is reasonably complete support for what you can find in a raw SELECT statement. It was not my intention to make that all dead code ... so let's add support for RawStmt. Back-patch to v10 where RawStmt appeared.
Diffstat (limited to 'src')
-rw-r--r--src/backend/nodes/outfuncs.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index b5af904c183..69fd5b29805 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -15,9 +15,13 @@
* have an output function defined here (as well as an input function
* in readfuncs.c). In addition, plan nodes should have input and
* output functions so that they can be sent to parallel workers.
+ *
* For use in debugging, we also provide output functions for nodes
- * that appear in raw parsetrees and path. These nodes however need
- * not have input functions.
+ * that appear in raw parsetrees and planner Paths. These node types
+ * need not have input functions. Output support for raw parsetrees
+ * is somewhat incomplete, too; in particular, utility statements are
+ * almost entirely unsupported. We try to support everything that can
+ * appear in a raw SELECT, though.
*
*-------------------------------------------------------------------------
*/
@@ -3347,6 +3351,20 @@ _outParamRef(StringInfo str, const ParamRef *node)
WRITE_LOCATION_FIELD(location);
}
+/*
+ * Node types found in raw parse trees (supported for debug purposes)
+ */
+
+static void
+_outRawStmt(StringInfo str, const RawStmt *node)
+{
+ WRITE_NODE_TYPE("RAWSTMT");
+
+ WRITE_NODE_FIELD(stmt);
+ WRITE_LOCATION_FIELD(stmt_location);
+ WRITE_INT_FIELD(stmt_len);
+}
+
static void
_outAConst(StringInfo str, const A_Const *node)
{
@@ -4252,6 +4270,9 @@ outNode(StringInfo str, const void *obj)
case T_ParamRef:
_outParamRef(str, obj);
break;
+ case T_RawStmt:
+ _outRawStmt(str, obj);
+ break;
case T_A_Const:
_outAConst(str, obj);
break;