diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-01-26 22:09:34 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-01-26 22:09:34 -0500 |
commit | 7afd56c3c6d8360a5bfdfb2de30038b239fd756b (patch) | |
tree | df9eb70bc951cdfe35629861285d5c6f31789ad7 /src/backend/tcop/postgres.c | |
parent | 9ba8a9ce4548bb34b7136b7463a61b2c499979a3 (diff) | |
download | postgresql-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/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 62d49c8625f..b07d6c6cb9b 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -962,7 +962,7 @@ exec_simple_query(const char *query_string) */ foreach(parsetree_item, parsetree_list) { - RawStmt *parsetree = (RawStmt *) lfirst(parsetree_item); + RawStmt *parsetree = castNode(RawStmt, lfirst(parsetree_item)); bool snapshot_set = false; const char *commandTag; char completionTag[COMPLETION_TAG_BUFSIZE]; @@ -1286,7 +1286,7 @@ exec_parse_message(const char *query_string, /* string to execute */ bool snapshot_set = false; int i; - raw_parse_tree = (RawStmt *) linitial(parsetree_list); + raw_parse_tree = castNode(RawStmt, linitial(parsetree_list)); /* * Get the command name for possible use in status display. @@ -2148,7 +2148,7 @@ errdetail_execute(List *raw_parsetree_list) foreach(parsetree_item, raw_parsetree_list) { - RawStmt *parsetree = (RawStmt *) lfirst(parsetree_item); + RawStmt *parsetree = castNode(RawStmt, lfirst(parsetree_item)); if (IsA(parsetree->stmt, ExecuteStmt)) { @@ -2502,9 +2502,8 @@ IsTransactionExitStmtList(List *pstmts) { if (list_length(pstmts) == 1) { - PlannedStmt *pstmt = (PlannedStmt *) linitial(pstmts); + PlannedStmt *pstmt = castNode(PlannedStmt, linitial(pstmts)); - Assert(IsA(pstmt, PlannedStmt)); if (pstmt->commandType == CMD_UTILITY && IsTransactionExitStmt(pstmt->utilityStmt)) return true; @@ -2518,9 +2517,8 @@ IsTransactionStmtList(List *pstmts) { if (list_length(pstmts) == 1) { - PlannedStmt *pstmt = (PlannedStmt *) linitial(pstmts); + PlannedStmt *pstmt = castNode(PlannedStmt, linitial(pstmts)); - Assert(IsA(pstmt, PlannedStmt)); if (pstmt->commandType == CMD_UTILITY && IsA(pstmt->utilityStmt, TransactionStmt)) return true; |