summaryrefslogtreecommitdiff
path: root/src/backend/commands/portalcmds.c
diff options
context:
space:
mode:
authorTom Lane2017-01-27 03:09:34 +0000
committerTom Lane2017-01-27 03:09:34 +0000
commit7afd56c3c6d8360a5bfdfb2de30038b239fd756b (patch)
treedf9eb70bc951cdfe35629861285d5c6f31789ad7 /src/backend/commands/portalcmds.c
parent9ba8a9ce4548bb34b7136b7463a61b2c499979a3 (diff)
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/portalcmds.c')
-rw-r--r--src/backend/commands/portalcmds.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c
index 1d3e39299b9..29d0430dd87 100644
--- a/src/backend/commands/portalcmds.c
+++ b/src/backend/commands/portalcmds.c
@@ -42,14 +42,12 @@ void
PerformCursorOpen(DeclareCursorStmt *cstmt, ParamListInfo params,
const char *queryString, bool isTopLevel)
{
- Query *query = (Query *) cstmt->query;
+ Query *query = castNode(Query, cstmt->query);
List *rewritten;
PlannedStmt *plan;
Portal portal;
MemoryContext oldContext;
- Assert(IsA(query, Query)); /* else parse analysis wasn't done */
-
/*
* Disallow empty-string cursor name (conflicts with protocol-level
* unnamed portal).
@@ -85,7 +83,7 @@ PerformCursorOpen(DeclareCursorStmt *cstmt, ParamListInfo params,
if (list_length(rewritten) != 1)
elog(ERROR, "non-SELECT statement in DECLARE CURSOR");
- query = (Query *) linitial(rewritten);
+ query = castNode(Query, linitial(rewritten));
if (query->commandType != CMD_SELECT)
elog(ERROR, "non-SELECT statement in DECLARE CURSOR");