Skip to content

Commit c374017

Browse files
committed
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.
1 parent 99cbbbb commit c374017

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/backend/nodes/outfuncs.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515
* have an output function defined here (as well as an input function
1616
* in readfuncs.c). In addition, plan nodes should have input and
1717
* output functions so that they can be sent to parallel workers.
18+
*
1819
* For use in debugging, we also provide output functions for nodes
19-
* that appear in raw parsetrees and path. These nodes however need
20-
* not have input functions.
20+
* that appear in raw parsetrees and planner Paths. These node types
21+
* need not have input functions. Output support for raw parsetrees
22+
* is somewhat incomplete, too; in particular, utility statements are
23+
* almost entirely unsupported. We try to support everything that can
24+
* appear in a raw SELECT, though.
2125
*
2226
*-------------------------------------------------------------------------
2327
*/
@@ -3264,6 +3268,20 @@ _outParamRef(StringInfo str, const ParamRef *node)
32643268
WRITE_LOCATION_FIELD(location);
32653269
}
32663270

3271+
/*
3272+
* Node types found in raw parse trees (supported for debug purposes)
3273+
*/
3274+
3275+
static void
3276+
_outRawStmt(StringInfo str, const RawStmt *node)
3277+
{
3278+
WRITE_NODE_TYPE("RAWSTMT");
3279+
3280+
WRITE_NODE_FIELD(stmt);
3281+
WRITE_LOCATION_FIELD(stmt_location);
3282+
WRITE_INT_FIELD(stmt_len);
3283+
}
3284+
32673285
static void
32683286
_outAConst(StringInfo str, const A_Const *node)
32693287
{
@@ -4154,6 +4172,9 @@ outNode(StringInfo str, const void *obj)
41544172
case T_ParamRef:
41554173
_outParamRef(str, obj);
41564174
break;
4175+
case T_RawStmt:
4176+
_outRawStmt(str, obj);
4177+
break;
41574178
case T_A_Const:
41584179
_outAConst(str, obj);
41594180
break;

0 commit comments

Comments
 (0)