aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/explain.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-01-26 22:09:34 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2017-01-26 22:09:34 -0500
commit7afd56c3c6d8360a5bfdfb2de30038b239fd756b (patch)
treedf9eb70bc951cdfe35629861285d5c6f31789ad7 /src/backend/commands/explain.c
parent9ba8a9ce4548bb34b7136b7463a61b2c499979a3 (diff)
downloadpostgresql-7afd56c3c6d8360a5bfdfb2de30038b239fd756b.tar.gz
postgresql-7afd56c3c6d8360a5bfdfb2de30038b239fd756b.zip
Use castNode() in a bunch of statement-list-related code.
When I wrote commit ab1f0c822, I really missed the castNode() macro that Peter E. had proposed shortly before. This back-fills the uses I would have put it to. It's probably not all that significant, but there are more assertions here than there were before, and conceivably they will help catch any bugs associated with those representation changes. I left behind a number of usages like "(Query *) copyObject(query_var)". Those could have been converted as well, but Peter has proposed another notational improvement that would handle copyObject cases automatically, so I let that be for now.
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r--src/backend/commands/explain.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 5d61a0195ed..0a67be031be 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -224,8 +224,7 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
* executed repeatedly. (See also the same hack in DECLARE CURSOR and
* PREPARE.) XXX FIXME someday.
*/
- Assert(IsA(stmt->query, Query));
- rewritten = QueryRewrite((Query *) copyObject(stmt->query));
+ rewritten = QueryRewrite(castNode(Query, copyObject(stmt->query)));
/* emit opening boilerplate */
ExplainBeginOutput(es);
@@ -246,7 +245,7 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
/* Explain every plan */
foreach(l, rewritten)
{
- ExplainOneQuery((Query *) lfirst(l),
+ ExplainOneQuery(castNode(Query, lfirst(l)),
CURSOR_OPT_PARALLEL_OK, NULL, es,
queryString, params);
@@ -395,10 +394,9 @@ ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es,
CreateTableAsStmt *ctas = (CreateTableAsStmt *) utilityStmt;
List *rewritten;
- Assert(IsA(ctas->query, Query));
- rewritten = QueryRewrite((Query *) copyObject(ctas->query));
+ rewritten = QueryRewrite(castNode(Query, copyObject(ctas->query)));
Assert(list_length(rewritten) == 1);
- ExplainOneQuery((Query *) linitial(rewritten),
+ ExplainOneQuery(castNode(Query, linitial(rewritten)),
0, ctas->into, es,
queryString, params);
}
@@ -415,10 +413,9 @@ ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es,
DeclareCursorStmt *dcs = (DeclareCursorStmt *) utilityStmt;
List *rewritten;
- Assert(IsA(dcs->query, Query));
- rewritten = QueryRewrite((Query *) copyObject(dcs->query));
+ rewritten = QueryRewrite(castNode(Query, copyObject(dcs->query)));
Assert(list_length(rewritten) == 1);
- ExplainOneQuery((Query *) linitial(rewritten),
+ ExplainOneQuery(castNode(Query, linitial(rewritten)),
dcs->options, NULL, es,
queryString, params);
}