1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

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.
This commit is contained in:
Tom Lane
2017-01-26 22:09:34 -05:00
parent 9ba8a9ce45
commit 7afd56c3c6
20 changed files with 63 additions and 90 deletions

View File

@ -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;