aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
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/executor
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/executor')
-rw-r--r--src/backend/executor/functions.c4
-rw-r--r--src/backend/executor/spi.c18
2 files changed, 11 insertions, 11 deletions
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 15c709139ad..2d49a656502 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -707,7 +707,7 @@ init_sql_fcache(FmgrInfo *finfo, Oid collation, bool lazyEvalOK)
flat_query_list = NIL;
foreach(lc, raw_parsetree_list)
{
- RawStmt *parsetree = (RawStmt *) lfirst(lc);
+ RawStmt *parsetree = castNode(RawStmt, lfirst(lc));
List *queryTree_sublist;
queryTree_sublist = pg_analyze_and_rewrite_params(parsetree,
@@ -1551,7 +1551,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
parse = NULL;
foreach(lc, queryTreeList)
{
- Query *q = (Query *) lfirst(lc);
+ Query *q = castNode(Query, lfirst(lc));
if (q->canSetTag)
parse = q;
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 7bd37283b7f..55f97b14e6e 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -1232,9 +1232,9 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
if (!(portal->cursorOptions & (CURSOR_OPT_SCROLL | CURSOR_OPT_NO_SCROLL)))
{
if (list_length(stmt_list) == 1 &&
- ((PlannedStmt *) linitial(stmt_list))->commandType != CMD_UTILITY &&
- ((PlannedStmt *) linitial(stmt_list))->rowMarks == NIL &&
- ExecSupportsBackwardScan(((PlannedStmt *) linitial(stmt_list))->planTree))
+ castNode(PlannedStmt, linitial(stmt_list))->commandType != CMD_UTILITY &&
+ castNode(PlannedStmt, linitial(stmt_list))->rowMarks == NIL &&
+ ExecSupportsBackwardScan(castNode(PlannedStmt, linitial(stmt_list))->planTree))
portal->cursorOptions |= CURSOR_OPT_SCROLL;
else
portal->cursorOptions |= CURSOR_OPT_NO_SCROLL;
@@ -1248,8 +1248,8 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
if (portal->cursorOptions & CURSOR_OPT_SCROLL)
{
if (list_length(stmt_list) == 1 &&
- ((PlannedStmt *) linitial(stmt_list))->commandType != CMD_UTILITY &&
- ((PlannedStmt *) linitial(stmt_list))->rowMarks != NIL)
+ castNode(PlannedStmt, linitial(stmt_list))->commandType != CMD_UTILITY &&
+ castNode(PlannedStmt, linitial(stmt_list))->rowMarks != NIL)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("DECLARE SCROLL CURSOR ... FOR UPDATE/SHARE is not supported"),
@@ -1270,7 +1270,7 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
foreach(lc, stmt_list)
{
- PlannedStmt *pstmt = (PlannedStmt *) lfirst(lc);
+ PlannedStmt *pstmt = castNode(PlannedStmt, lfirst(lc));
if (!CommandIsReadOnly(pstmt))
{
@@ -1757,7 +1757,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan)
foreach(list_item, raw_parsetree_list)
{
- RawStmt *parsetree = (RawStmt *) lfirst(list_item);
+ RawStmt *parsetree = castNode(RawStmt, lfirst(list_item));
List *stmt_list;
CachedPlanSource *plansource;
@@ -1859,7 +1859,7 @@ _SPI_prepare_oneshot_plan(const char *src, SPIPlanPtr plan)
foreach(list_item, raw_parsetree_list)
{
- RawStmt *parsetree = (RawStmt *) lfirst(list_item);
+ RawStmt *parsetree = castNode(RawStmt, lfirst(list_item));
CachedPlanSource *plansource;
plansource = CreateOneShotCachedPlan(parsetree,
@@ -2018,7 +2018,7 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
foreach(lc2, stmt_list)
{
- PlannedStmt *stmt = (PlannedStmt *) lfirst(lc2);
+ PlannedStmt *stmt = castNode(PlannedStmt, lfirst(lc2));
bool canSetTag = stmt->canSetTag;
DestReceiver *dest;