Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0ca27ea

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 7a2f70f commit 0ca27ea

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
*/
@@ -3345,6 +3349,20 @@ _outParamRef(StringInfo str, const ParamRef *node)
33453349
WRITE_LOCATION_FIELD(location);
33463350
}
33473351

3352+
/*
3353+
* Node types found in raw parse trees (supported for debug purposes)
3354+
*/
3355+
3356+
static void
3357+
_outRawStmt(StringInfo str, const RawStmt *node)
3358+
{
3359+
WRITE_NODE_TYPE("RAWSTMT");
3360+
3361+
WRITE_NODE_FIELD(stmt);
3362+
WRITE_LOCATION_FIELD(stmt_location);
3363+
WRITE_INT_FIELD(stmt_len);
3364+
}
3365+
33483366
static void
33493367
_outAConst(StringInfo str, const A_Const *node)
33503368
{
@@ -4250,6 +4268,9 @@ outNode(StringInfo str, const void *obj)
42504268
case T_ParamRef:
42514269
_outParamRef(str, obj);
42524270
break;
4271+
case T_RawStmt:
4272+
_outRawStmt(str, obj);
4273+
break;
42534274
case T_A_Const:
42544275
_outAConst(str, obj);
42554276
break;

0 commit comments

Comments
 (0)