mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Make more use of castNode()
This commit is contained in:
@ -2320,8 +2320,7 @@ view_cols_are_auto_updatable(Query *viewquery,
|
||||
* there should be a single base relation.
|
||||
*/
|
||||
Assert(list_length(viewquery->jointree->fromlist) == 1);
|
||||
rtr = (RangeTblRef *) linitial(viewquery->jointree->fromlist);
|
||||
Assert(IsA(rtr, RangeTblRef));
|
||||
rtr = castNode(RangeTblRef, linitial(viewquery->jointree->fromlist));
|
||||
|
||||
/* Initialize the optional return values */
|
||||
if (updatable_cols != NULL)
|
||||
@ -2578,8 +2577,7 @@ adjust_view_column_set(Bitmapset *cols, List *targetlist)
|
||||
|
||||
if (tle->resjunk)
|
||||
continue;
|
||||
var = (Var *) tle->expr;
|
||||
Assert(IsA(var, Var));
|
||||
var = castNode(Var, tle->expr);
|
||||
result = bms_add_member(result,
|
||||
var->varattno - FirstLowInvalidHeapAttributeNumber);
|
||||
}
|
||||
@ -2761,8 +2759,7 @@ rewriteTargetView(Query *parsetree, Relation view)
|
||||
* view contains a single base relation.
|
||||
*/
|
||||
Assert(list_length(viewquery->jointree->fromlist) == 1);
|
||||
rtr = (RangeTblRef *) linitial(viewquery->jointree->fromlist);
|
||||
Assert(IsA(rtr, RangeTblRef));
|
||||
rtr = castNode(RangeTblRef, linitial(viewquery->jointree->fromlist));
|
||||
|
||||
base_rt_index = rtr->rtindex;
|
||||
base_rte = rt_fetch(base_rt_index, viewquery->rtable);
|
||||
@ -3119,11 +3116,9 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
|
||||
foreach(lc1, parsetree->cteList)
|
||||
{
|
||||
CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc1);
|
||||
Query *ctequery = (Query *) cte->ctequery;
|
||||
Query *ctequery = castNode(Query, cte->ctequery);
|
||||
List *newstuff;
|
||||
|
||||
Assert(IsA(ctequery, Query));
|
||||
|
||||
if (ctequery->commandType == CMD_SELECT)
|
||||
continue;
|
||||
|
||||
@ -3137,8 +3132,7 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
|
||||
if (list_length(newstuff) == 1)
|
||||
{
|
||||
/* Push the single Query back into the CTE node */
|
||||
ctequery = (Query *) linitial(newstuff);
|
||||
Assert(IsA(ctequery, Query));
|
||||
ctequery = castNode(Query, linitial(newstuff));
|
||||
/* WITH queries should never be canSetTag */
|
||||
Assert(!ctequery->canSetTag);
|
||||
cte->ctequery = (Node *) ctequery;
|
||||
|
Reference in New Issue
Block a user