Improve castNode notation by introducing list-extraction-specific variants.
This extends the castNode() notation introduced by commit 5bcab1114 to provide, in one step, extraction of a list cell's pointer and coercion to a concrete node type. For example, "lfirst_node(Foo, lc)" is the same as "castNode(Foo, lfirst(lc))". Almost half of the uses of castNode that have appeared so far include a list extraction call, so this is pretty widely useful, and it saves a few more keystrokes compared to the old way. As with the previous patch, back-patch the addition of these macros to pg_list.h, so that the notation will be available when back-patching. Patch by me, after an idea of Andrew Gierth's. Discussion: https://postgr.es/m/14197.1491841216@sss.pgh.pa.us
This commit is contained in:
parent
56dd8e85c4
commit
8f0530f580
@ -2393,7 +2393,7 @@ JumbleRangeTable(pgssJumbleState *jstate, List *rtable)
|
||||
|
||||
foreach(lc, rtable)
|
||||
{
|
||||
RangeTblEntry *rte = castNode(RangeTblEntry, lfirst(lc));
|
||||
RangeTblEntry *rte = lfirst_node(RangeTblEntry, lc);
|
||||
|
||||
APP_JUMB(rte->rtekind);
|
||||
switch (rte->rtekind)
|
||||
@ -2656,7 +2656,7 @@ JumbleExpr(pgssJumbleState *jstate, Node *node)
|
||||
JumbleExpr(jstate, (Node *) caseexpr->arg);
|
||||
foreach(temp, caseexpr->args)
|
||||
{
|
||||
CaseWhen *when = castNode(CaseWhen, lfirst(temp));
|
||||
CaseWhen *when = lfirst_node(CaseWhen, temp);
|
||||
|
||||
JumbleExpr(jstate, (Node *) when->expr);
|
||||
JumbleExpr(jstate, (Node *) when->result);
|
||||
|
@ -1350,7 +1350,7 @@ deparseExplicitTargetList(List *tlist, List **retrieved_attrs,
|
||||
|
||||
foreach(lc, tlist)
|
||||
{
|
||||
TargetEntry *tle = castNode(TargetEntry, lfirst(lc));
|
||||
TargetEntry *tle = lfirst_node(TargetEntry, lc);
|
||||
|
||||
if (i > 0)
|
||||
appendStringInfoString(buf, ", ");
|
||||
|
@ -1169,7 +1169,7 @@ postgresGetForeignPlan(PlannerInfo *root,
|
||||
*/
|
||||
foreach(lc, scan_clauses)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
|
||||
|
||||
/* Ignore any pseudoconstants, they're dealt with elsewhere */
|
||||
if (rinfo->pseudoconstant)
|
||||
@ -5022,8 +5022,8 @@ conversion_error_callback(void *arg)
|
||||
EState *estate = fsstate->ss.ps.state;
|
||||
TargetEntry *tle;
|
||||
|
||||
tle = castNode(TargetEntry, list_nth(fsplan->fdw_scan_tlist,
|
||||
errpos->cur_attno - 1));
|
||||
tle = list_nth_node(TargetEntry, fsplan->fdw_scan_tlist,
|
||||
errpos->cur_attno - 1);
|
||||
|
||||
/*
|
||||
* Target list can have Vars and expressions. For Vars, we can get
|
||||
|
@ -854,7 +854,7 @@ get_object_address(ObjectType objtype, Node *object,
|
||||
|
||||
objlist = castNode(List, object);
|
||||
domaddr = get_object_address_type(OBJECT_DOMAIN,
|
||||
castNode(TypeName, linitial(objlist)),
|
||||
linitial_node(TypeName, objlist),
|
||||
missing_ok);
|
||||
constrname = strVal(lsecond(objlist));
|
||||
|
||||
@ -932,8 +932,8 @@ get_object_address(ObjectType objtype, Node *object,
|
||||
break;
|
||||
case OBJECT_CAST:
|
||||
{
|
||||
TypeName *sourcetype = castNode(TypeName, linitial(castNode(List, object)));
|
||||
TypeName *targettype = castNode(TypeName, lsecond(castNode(List, object)));
|
||||
TypeName *sourcetype = linitial_node(TypeName, castNode(List, object));
|
||||
TypeName *targettype = lsecond_node(TypeName, castNode(List, object));
|
||||
Oid sourcetypeid;
|
||||
Oid targettypeid;
|
||||
|
||||
@ -947,7 +947,7 @@ get_object_address(ObjectType objtype, Node *object,
|
||||
break;
|
||||
case OBJECT_TRANSFORM:
|
||||
{
|
||||
TypeName *typename = castNode(TypeName, linitial(castNode(List, object)));
|
||||
TypeName *typename = linitial_node(TypeName, castNode(List, object));
|
||||
char *langname = strVal(lsecond(castNode(List, object)));
|
||||
Oid type_id = LookupTypeNameOid(NULL, typename, missing_ok);
|
||||
Oid lang_id = get_language_oid(langname, missing_ok);
|
||||
@ -1597,7 +1597,7 @@ get_object_address_opf_member(ObjectType objtype,
|
||||
{
|
||||
ObjectAddress typaddr;
|
||||
|
||||
typenames[i] = castNode(TypeName, lfirst(cell));
|
||||
typenames[i] = lfirst_node(TypeName, cell);
|
||||
typaddr = get_object_address_type(OBJECT_TYPE, typenames[i], missing_ok);
|
||||
typeoids[i] = typaddr.objectId;
|
||||
if (++i >= 2)
|
||||
@ -2319,8 +2319,8 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
|
||||
case OBJECT_CAST:
|
||||
{
|
||||
/* We can only check permissions on the source/target types */
|
||||
TypeName *sourcetype = castNode(TypeName, linitial(castNode(List, object)));
|
||||
TypeName *targettype = castNode(TypeName, lsecond(castNode(List, object)));
|
||||
TypeName *sourcetype = linitial_node(TypeName, castNode(List, object));
|
||||
TypeName *targettype = lsecond_node(TypeName, castNode(List, object));
|
||||
Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
|
||||
Oid targettypeid = typenameTypeId(NULL, targettype);
|
||||
|
||||
@ -2345,7 +2345,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
|
||||
break;
|
||||
case OBJECT_TRANSFORM:
|
||||
{
|
||||
TypeName *typename = castNode(TypeName, linitial(castNode(List, object)));
|
||||
TypeName *typename = linitial_node(TypeName, castNode(List, object));
|
||||
Oid typeid = typenameTypeId(NULL, typename);
|
||||
|
||||
if (!pg_type_ownercheck(typeid, roleid))
|
||||
|
@ -928,7 +928,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
|
||||
querytree_list = NIL;
|
||||
foreach(lc, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(lc));
|
||||
RawStmt *parsetree = lfirst_node(RawStmt, lc);
|
||||
List *querytree_sublist;
|
||||
|
||||
querytree_sublist = pg_analyze_and_rewrite_params(parsetree,
|
||||
|
@ -109,13 +109,13 @@ DefineAggregate(ParseState *pstate, List *name, List *args, bool oldstyle, List
|
||||
aggKind = AGGKIND_ORDERED_SET;
|
||||
else
|
||||
numDirectArgs = 0;
|
||||
args = castNode(List, linitial(args));
|
||||
args = linitial_node(List, args);
|
||||
}
|
||||
|
||||
/* Examine aggregate's definition clauses */
|
||||
foreach(pl, parameters)
|
||||
{
|
||||
DefElem *defel = castNode(DefElem, lfirst(pl));
|
||||
DefElem *defel = lfirst_node(DefElem, pl);
|
||||
|
||||
/*
|
||||
* sfunc1, stype1, and initcond1 are accepted as obsolete spellings
|
||||
|
@ -1636,7 +1636,7 @@ AtSubCommit_Notify(void)
|
||||
List *parentPendingActions;
|
||||
List *parentPendingNotifies;
|
||||
|
||||
parentPendingActions = castNode(List, linitial(upperPendingActions));
|
||||
parentPendingActions = linitial_node(List, upperPendingActions);
|
||||
upperPendingActions = list_delete_first(upperPendingActions);
|
||||
|
||||
Assert(list_length(upperPendingActions) ==
|
||||
@ -1647,7 +1647,7 @@ AtSubCommit_Notify(void)
|
||||
*/
|
||||
pendingActions = list_concat(parentPendingActions, pendingActions);
|
||||
|
||||
parentPendingNotifies = castNode(List, linitial(upperPendingNotifies));
|
||||
parentPendingNotifies = linitial_node(List, upperPendingNotifies);
|
||||
upperPendingNotifies = list_delete_first(upperPendingNotifies);
|
||||
|
||||
Assert(list_length(upperPendingNotifies) ==
|
||||
@ -1679,13 +1679,13 @@ AtSubAbort_Notify(void)
|
||||
*/
|
||||
while (list_length(upperPendingActions) > my_level - 2)
|
||||
{
|
||||
pendingActions = castNode(List, linitial(upperPendingActions));
|
||||
pendingActions = linitial_node(List, upperPendingActions);
|
||||
upperPendingActions = list_delete_first(upperPendingActions);
|
||||
}
|
||||
|
||||
while (list_length(upperPendingNotifies) > my_level - 2)
|
||||
{
|
||||
pendingNotifies = castNode(List, linitial(upperPendingNotifies));
|
||||
pendingNotifies = linitial_node(List, upperPendingNotifies);
|
||||
upperPendingNotifies = list_delete_first(upperPendingNotifies);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
|
||||
|
||||
foreach(pl, parameters)
|
||||
{
|
||||
DefElem *defel = castNode(DefElem, lfirst(pl));
|
||||
DefElem *defel = lfirst_node(DefElem, pl);
|
||||
DefElem **defelp;
|
||||
|
||||
if (pg_strcasecmp(defel->defname, "from") == 0)
|
||||
|
@ -1034,7 +1034,7 @@ ProcessCopyOptions(ParseState *pstate,
|
||||
/* Extract options from the statement node tree */
|
||||
foreach(option, options)
|
||||
{
|
||||
DefElem *defel = castNode(DefElem, lfirst(option));
|
||||
DefElem *defel = lfirst_node(DefElem, option);
|
||||
|
||||
if (strcmp(defel->defname, "format") == 0)
|
||||
{
|
||||
@ -1488,7 +1488,7 @@ BeginCopy(ParseState *pstate,
|
||||
/* examine queries to determine which error message to issue */
|
||||
foreach(lc, rewritten)
|
||||
{
|
||||
Query *q = castNode(Query, lfirst(lc));
|
||||
Query *q = lfirst_node(Query, lc);
|
||||
|
||||
if (q->querySource == QSRC_QUAL_INSTEAD_RULE)
|
||||
ereport(ERROR,
|
||||
@ -1505,7 +1505,7 @@ BeginCopy(ParseState *pstate,
|
||||
errmsg("multi-statement DO INSTEAD rules are not supported for COPY")));
|
||||
}
|
||||
|
||||
query = castNode(Query, linitial(rewritten));
|
||||
query = linitial_node(Query, rewritten);
|
||||
|
||||
/* The grammar allows SELECT INTO, but we don't support that */
|
||||
if (query->utilityStmt != NULL &&
|
||||
|
@ -323,7 +323,7 @@ ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
|
||||
elog(ERROR, "unexpected rewrite result for %s",
|
||||
is_matview ? "CREATE MATERIALIZED VIEW" :
|
||||
"CREATE TABLE AS SELECT");
|
||||
query = castNode(Query, linitial(rewritten));
|
||||
query = linitial_node(Query, rewritten);
|
||||
Assert(query->commandType == CMD_SELECT);
|
||||
|
||||
/* plan the query --- note we disallow parallelism */
|
||||
|
@ -214,7 +214,7 @@ type_in_list_does_not_exist_skipping(List *typenames, const char **msg,
|
||||
|
||||
foreach(l, typenames)
|
||||
{
|
||||
TypeName *typeName = castNode(TypeName, lfirst(l));
|
||||
TypeName *typeName = lfirst_node(TypeName, l);
|
||||
|
||||
if (typeName != NULL)
|
||||
{
|
||||
@ -371,8 +371,8 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
{
|
||||
/* XXX quote or no quote? */
|
||||
msg = gettext_noop("cast from type %s to type %s does not exist, skipping");
|
||||
name = TypeNameToString(castNode(TypeName, linitial(castNode(List, object))));
|
||||
args = TypeNameToString(castNode(TypeName, lsecond(castNode(List, object))));
|
||||
name = TypeNameToString(linitial_node(TypeName, castNode(List, object)));
|
||||
args = TypeNameToString(lsecond_node(TypeName, castNode(List, object)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -380,7 +380,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
if (!type_in_list_does_not_exist_skipping(list_make1(linitial(castNode(List, object))), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("transform for type %s language \"%s\" does not exist, skipping");
|
||||
name = TypeNameToString(castNode(TypeName, linitial(castNode(List, object))));
|
||||
name = TypeNameToString(linitial_node(TypeName, castNode(List, object)));
|
||||
args = strVal(lsecond(castNode(List, object)));
|
||||
}
|
||||
break;
|
||||
|
@ -253,7 +253,7 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
|
||||
/* Explain every plan */
|
||||
foreach(l, rewritten)
|
||||
{
|
||||
ExplainOneQuery(castNode(Query, lfirst(l)),
|
||||
ExplainOneQuery(lfirst_node(Query, l),
|
||||
CURSOR_OPT_PARALLEL_OK, NULL, es,
|
||||
queryString, params, queryEnv);
|
||||
|
||||
@ -408,7 +408,7 @@ ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es,
|
||||
|
||||
rewritten = QueryRewrite(castNode(Query, copyObject(ctas->query)));
|
||||
Assert(list_length(rewritten) == 1);
|
||||
ExplainOneQuery(castNode(Query, linitial(rewritten)),
|
||||
ExplainOneQuery(linitial_node(Query, rewritten),
|
||||
0, ctas->into, es,
|
||||
queryString, params, queryEnv);
|
||||
}
|
||||
@ -427,7 +427,7 @@ ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es,
|
||||
|
||||
rewritten = QueryRewrite(castNode(Query, copyObject(dcs->query)));
|
||||
Assert(list_length(rewritten) == 1);
|
||||
ExplainOneQuery(castNode(Query, linitial(rewritten)),
|
||||
ExplainOneQuery(linitial_node(Query, rewritten),
|
||||
dcs->options, NULL, es,
|
||||
queryString, params, queryEnv);
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ execute_sql_string(const char *sql, const char *filename)
|
||||
*/
|
||||
foreach(lc1, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(lc1));
|
||||
RawStmt *parsetree = lfirst_node(RawStmt, lc1);
|
||||
List *stmt_list;
|
||||
ListCell *lc2;
|
||||
|
||||
@ -727,7 +727,7 @@ execute_sql_string(const char *sql, const char *filename)
|
||||
|
||||
foreach(lc2, stmt_list)
|
||||
{
|
||||
PlannedStmt *stmt = castNode(PlannedStmt, lfirst(lc2));
|
||||
PlannedStmt *stmt = lfirst_node(PlannedStmt, lc2);
|
||||
|
||||
CommandCounterIncrement();
|
||||
|
||||
|
@ -1589,7 +1589,7 @@ ImportForeignSchema(ImportForeignSchemaStmt *stmt)
|
||||
*/
|
||||
foreach(lc2, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *rs = castNode(RawStmt, lfirst(lc2));
|
||||
RawStmt *rs = lfirst_node(RawStmt, lc2);
|
||||
CreateForeignTableStmt *cstmt = (CreateForeignTableStmt *) rs->stmt;
|
||||
PlannedStmt *pstmt;
|
||||
|
||||
|
@ -578,7 +578,7 @@ update_proconfig_value(ArrayType *a, List *set_items)
|
||||
|
||||
foreach(l, set_items)
|
||||
{
|
||||
VariableSetStmt *sstmt = castNode(VariableSetStmt, lfirst(l));
|
||||
VariableSetStmt *sstmt = lfirst_node(VariableSetStmt, l);
|
||||
|
||||
if (sstmt->kind == VAR_RESET_ALL)
|
||||
a = NULL;
|
||||
@ -972,7 +972,8 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
|
||||
|
||||
foreach(lc, castNode(List, transformDefElem))
|
||||
{
|
||||
Oid typeid = typenameTypeId(NULL, lfirst(lc));
|
||||
Oid typeid = typenameTypeId(NULL,
|
||||
lfirst_node(TypeName, lc));
|
||||
Oid elt = get_base_element_type(typeid);
|
||||
|
||||
typeid = elt ? elt : typeid;
|
||||
|
@ -264,7 +264,7 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
|
||||
* The stored query was rewritten at the time of the MV definition, but
|
||||
* has not been scribbled on by the planner.
|
||||
*/
|
||||
dataQuery = castNode(Query, linitial(actions));
|
||||
dataQuery = linitial_node(Query, actions);
|
||||
|
||||
/*
|
||||
* Check for active uses of the relation in the current transaction, such
|
||||
|
@ -460,7 +460,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
*/
|
||||
foreach(l, stmt->items)
|
||||
{
|
||||
CreateOpClassItem *item = castNode(CreateOpClassItem, lfirst(l));
|
||||
CreateOpClassItem *item = lfirst_node(CreateOpClassItem, l);
|
||||
Oid operOid;
|
||||
Oid funcOid;
|
||||
Oid sortfamilyOid;
|
||||
@ -834,7 +834,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
|
||||
*/
|
||||
foreach(l, items)
|
||||
{
|
||||
CreateOpClassItem *item = castNode(CreateOpClassItem, lfirst(l));
|
||||
CreateOpClassItem *item = lfirst_node(CreateOpClassItem, l);
|
||||
Oid operOid;
|
||||
Oid funcOid;
|
||||
Oid sortfamilyOid;
|
||||
@ -959,7 +959,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
|
||||
*/
|
||||
foreach(l, items)
|
||||
{
|
||||
CreateOpClassItem *item = castNode(CreateOpClassItem, lfirst(l));
|
||||
CreateOpClassItem *item = lfirst_node(CreateOpClassItem, l);
|
||||
Oid lefttype,
|
||||
righttype;
|
||||
OpFamilyMember *member;
|
||||
|
@ -83,7 +83,7 @@ PerformCursorOpen(DeclareCursorStmt *cstmt, ParamListInfo params,
|
||||
if (list_length(rewritten) != 1)
|
||||
elog(ERROR, "non-SELECT statement in DECLARE CURSOR");
|
||||
|
||||
query = castNode(Query, linitial(rewritten));
|
||||
query = linitial_node(Query, rewritten);
|
||||
|
||||
if (query->commandType != CMD_SELECT)
|
||||
elog(ERROR, "non-SELECT statement in DECLARE CURSOR");
|
||||
|
@ -267,7 +267,7 @@ ExecuteQuery(ExecuteStmt *stmt, IntoClause *intoClause,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("prepared statement is not a SELECT")));
|
||||
pstmt = castNode(PlannedStmt, linitial(plan_list));
|
||||
pstmt = linitial_node(PlannedStmt, plan_list);
|
||||
if (pstmt->commandType != CMD_SELECT)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
@ -679,7 +679,7 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
|
||||
/* Explain each query */
|
||||
foreach(p, plan_list)
|
||||
{
|
||||
PlannedStmt *pstmt = castNode(PlannedStmt, lfirst(p));
|
||||
PlannedStmt *pstmt = lfirst_node(PlannedStmt, p);
|
||||
|
||||
if (pstmt->commandType != CMD_UTILITY)
|
||||
ExplainOnePlan(pstmt, into, es, query_string, paramLI, queryEnv,
|
||||
|
@ -5942,7 +5942,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
|
||||
|
||||
foreach(option, castNode(List, def))
|
||||
{
|
||||
DefElem *defel = castNode(DefElem, lfirst(option));
|
||||
DefElem *defel = lfirst_node(DefElem, option);
|
||||
|
||||
if (strcmp(defel->defname, "generated") == 0)
|
||||
{
|
||||
@ -9547,7 +9547,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
|
||||
querytree_list = NIL;
|
||||
foreach(list_item, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *rs = castNode(RawStmt, lfirst(list_item));
|
||||
RawStmt *rs = lfirst_node(RawStmt, list_item);
|
||||
Node *stmt = rs->stmt;
|
||||
|
||||
if (IsA(stmt, IndexStmt))
|
||||
|
@ -340,7 +340,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
|
||||
foreach(lc, varList)
|
||||
{
|
||||
TriggerTransition *tt = castNode(TriggerTransition, lfirst(lc));
|
||||
TriggerTransition *tt = lfirst_node(TriggerTransition, lc);
|
||||
|
||||
if (!(tt->isTable))
|
||||
ereport(ERROR,
|
||||
|
@ -1388,7 +1388,7 @@ roleSpecsToIds(List *memberNames)
|
||||
|
||||
foreach(l, memberNames)
|
||||
{
|
||||
RoleSpec *rolespec = castNode(RoleSpec, lfirst(l));
|
||||
RoleSpec *rolespec = lfirst_node(RoleSpec, l);
|
||||
Oid roleid;
|
||||
|
||||
roleid = get_rolespec_oid(rolespec, false);
|
||||
|
@ -516,7 +516,7 @@ DefineView(ViewStmt *stmt, const char *queryString,
|
||||
|
||||
foreach(targetList, viewParse->targetList)
|
||||
{
|
||||
TargetEntry *te = castNode(TargetEntry, lfirst(targetList));
|
||||
TargetEntry *te = lfirst_node(TargetEntry, targetList);
|
||||
|
||||
/* junk columns don't get aliases */
|
||||
if (te->resjunk)
|
||||
|
@ -322,7 +322,7 @@ ExecBuildProjectionInfo(List *targetList,
|
||||
/* Now compile each tlist column */
|
||||
foreach(lc, targetList)
|
||||
{
|
||||
TargetEntry *tle = castNode(TargetEntry, lfirst(lc));
|
||||
TargetEntry *tle = lfirst_node(TargetEntry, lc);
|
||||
Var *variable = NULL;
|
||||
AttrNumber attnum = 0;
|
||||
bool isSafeVar = false;
|
||||
|
@ -160,7 +160,7 @@ ExecResetTupleTable(List *tupleTable, /* tuple table */
|
||||
|
||||
foreach(lc, tupleTable)
|
||||
{
|
||||
TupleTableSlot *slot = castNode(TupleTableSlot, lfirst(lc));
|
||||
TupleTableSlot *slot = lfirst_node(TupleTableSlot, lc);
|
||||
|
||||
/* Always release resources and reset the slot to empty */
|
||||
ExecClearTuple(slot);
|
||||
|
@ -978,7 +978,7 @@ ExecCleanTargetListLength(List *targetlist)
|
||||
|
||||
foreach(tl, targetlist)
|
||||
{
|
||||
TargetEntry *curTle = castNode(TargetEntry, lfirst(tl));
|
||||
TargetEntry *curTle = lfirst_node(TargetEntry, tl);
|
||||
|
||||
if (!curTle->resjunk)
|
||||
len++;
|
||||
|
@ -479,14 +479,14 @@ init_execution_state(List *queryTree_list,
|
||||
|
||||
foreach(lc1, queryTree_list)
|
||||
{
|
||||
List *qtlist = castNode(List, lfirst(lc1));
|
||||
List *qtlist = lfirst_node(List, lc1);
|
||||
execution_state *firstes = NULL;
|
||||
execution_state *preves = NULL;
|
||||
ListCell *lc2;
|
||||
|
||||
foreach(lc2, qtlist)
|
||||
{
|
||||
Query *queryTree = castNode(Query, lfirst(lc2));
|
||||
Query *queryTree = lfirst_node(Query, lc2);
|
||||
PlannedStmt *stmt;
|
||||
execution_state *newes;
|
||||
|
||||
@ -707,7 +707,7 @@ init_sql_fcache(FmgrInfo *finfo, Oid collation, bool lazyEvalOK)
|
||||
flat_query_list = NIL;
|
||||
foreach(lc, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(lc));
|
||||
RawStmt *parsetree = lfirst_node(RawStmt, lc);
|
||||
List *queryTree_sublist;
|
||||
|
||||
queryTree_sublist = pg_analyze_and_rewrite_params(parsetree,
|
||||
@ -1555,7 +1555,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
|
||||
parse = NULL;
|
||||
foreach(lc, queryTreeList)
|
||||
{
|
||||
Query *q = castNode(Query, lfirst(lc));
|
||||
Query *q = lfirst_node(Query, lc);
|
||||
|
||||
if (q->canSetTag)
|
||||
parse = q;
|
||||
|
@ -2866,7 +2866,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
|
||||
|
||||
if (phaseidx > 0)
|
||||
{
|
||||
aggnode = castNode(Agg, list_nth(node->chain, phaseidx - 1));
|
||||
aggnode = list_nth_node(Agg, node->chain, phaseidx - 1);
|
||||
sortnode = castNode(Sort, aggnode->plan.lefttree);
|
||||
}
|
||||
else
|
||||
@ -3360,7 +3360,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
|
||||
*/
|
||||
foreach(arg, pertrans->aggref->args)
|
||||
{
|
||||
TargetEntry *source_tle = castNode(TargetEntry, lfirst(arg));
|
||||
TargetEntry *source_tle = lfirst_node(TargetEntry, arg);
|
||||
TargetEntry *tle;
|
||||
|
||||
tle = flatCopyTargetEntry(source_tle);
|
||||
|
@ -517,7 +517,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
|
||||
hoperators = NIL;
|
||||
foreach(l, node->hashclauses)
|
||||
{
|
||||
OpExpr *hclause = castNode(OpExpr, lfirst(l));
|
||||
OpExpr *hclause = lfirst_node(OpExpr, l);
|
||||
|
||||
lclauses = lappend(lclauses, ExecInitExpr(linitial(hclause->args),
|
||||
(PlanState *) hjstate));
|
||||
|
@ -401,7 +401,7 @@ ExecInitLockRows(LockRows *node, EState *estate, int eflags)
|
||||
epq_arowmarks = NIL;
|
||||
foreach(lc, node->rowMarks)
|
||||
{
|
||||
PlanRowMark *rc = castNode(PlanRowMark, lfirst(lc));
|
||||
PlanRowMark *rc = lfirst_node(PlanRowMark, lc);
|
||||
ExecRowMark *erm;
|
||||
ExecAuxRowMark *aerm;
|
||||
|
||||
|
@ -1968,7 +1968,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
|
||||
*/
|
||||
foreach(l, node->rowMarks)
|
||||
{
|
||||
PlanRowMark *rc = castNode(PlanRowMark, lfirst(l));
|
||||
PlanRowMark *rc = lfirst_node(PlanRowMark, l);
|
||||
ExecRowMark *erm;
|
||||
|
||||
/* ignore "parent" rowmarks; they are irrelevant at runtime */
|
||||
|
@ -817,7 +817,7 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
|
||||
i = 1;
|
||||
foreach(l, oplist)
|
||||
{
|
||||
OpExpr *opexpr = castNode(OpExpr, lfirst(l));
|
||||
OpExpr *opexpr = lfirst_node(OpExpr, l);
|
||||
Expr *expr;
|
||||
TargetEntry *tle;
|
||||
Oid rhs_eq_oper;
|
||||
@ -1148,7 +1148,7 @@ ExecInitAlternativeSubPlan(AlternativeSubPlan *asplan, PlanState *parent)
|
||||
*/
|
||||
foreach(lc, asplan->subplans)
|
||||
{
|
||||
SubPlan *sp = castNode(SubPlan, lfirst(lc));
|
||||
SubPlan *sp = lfirst_node(SubPlan, lc);
|
||||
SubPlanState *sps = ExecInitSubPlan(sp, parent);
|
||||
|
||||
asstate->subplans = lappend(asstate->subplans, sps);
|
||||
@ -1197,8 +1197,8 @@ ExecAlternativeSubPlan(AlternativeSubPlanState *node,
|
||||
bool *isNull)
|
||||
{
|
||||
/* Just pass control to the active subplan */
|
||||
SubPlanState *activesp = castNode(SubPlanState,
|
||||
list_nth(node->subplans, node->active));
|
||||
SubPlanState *activesp = list_nth_node(SubPlanState,
|
||||
node->subplans, node->active);
|
||||
|
||||
return ExecSubPlan(activesp, econtext, isNull);
|
||||
}
|
||||
|
@ -1233,9 +1233,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 &&
|
||||
castNode(PlannedStmt, linitial(stmt_list))->commandType != CMD_UTILITY &&
|
||||
castNode(PlannedStmt, linitial(stmt_list))->rowMarks == NIL &&
|
||||
ExecSupportsBackwardScan(castNode(PlannedStmt, linitial(stmt_list))->planTree))
|
||||
linitial_node(PlannedStmt, stmt_list)->commandType != CMD_UTILITY &&
|
||||
linitial_node(PlannedStmt, stmt_list)->rowMarks == NIL &&
|
||||
ExecSupportsBackwardScan(linitial_node(PlannedStmt, stmt_list)->planTree))
|
||||
portal->cursorOptions |= CURSOR_OPT_SCROLL;
|
||||
else
|
||||
portal->cursorOptions |= CURSOR_OPT_NO_SCROLL;
|
||||
@ -1249,8 +1249,8 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
|
||||
if (portal->cursorOptions & CURSOR_OPT_SCROLL)
|
||||
{
|
||||
if (list_length(stmt_list) == 1 &&
|
||||
castNode(PlannedStmt, linitial(stmt_list))->commandType != CMD_UTILITY &&
|
||||
castNode(PlannedStmt, linitial(stmt_list))->rowMarks != NIL)
|
||||
linitial_node(PlannedStmt, stmt_list)->commandType != CMD_UTILITY &&
|
||||
linitial_node(PlannedStmt, stmt_list)->rowMarks != NIL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("DECLARE SCROLL CURSOR ... FOR UPDATE/SHARE is not supported"),
|
||||
@ -1274,7 +1274,7 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
|
||||
|
||||
foreach(lc, stmt_list)
|
||||
{
|
||||
PlannedStmt *pstmt = castNode(PlannedStmt, lfirst(lc));
|
||||
PlannedStmt *pstmt = lfirst_node(PlannedStmt, lc);
|
||||
|
||||
if (!CommandIsReadOnly(pstmt))
|
||||
{
|
||||
@ -1770,7 +1770,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan)
|
||||
|
||||
foreach(list_item, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(list_item));
|
||||
RawStmt *parsetree = lfirst_node(RawStmt, list_item);
|
||||
List *stmt_list;
|
||||
CachedPlanSource *plansource;
|
||||
|
||||
@ -1874,7 +1874,7 @@ _SPI_prepare_oneshot_plan(const char *src, SPIPlanPtr plan)
|
||||
|
||||
foreach(list_item, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(list_item));
|
||||
RawStmt *parsetree = lfirst_node(RawStmt, list_item);
|
||||
CachedPlanSource *plansource;
|
||||
|
||||
plansource = CreateOneShotCachedPlan(parsetree,
|
||||
@ -2035,7 +2035,7 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
|
||||
|
||||
foreach(lc2, stmt_list)
|
||||
{
|
||||
PlannedStmt *stmt = castNode(PlannedStmt, lfirst(lc2));
|
||||
PlannedStmt *stmt = lfirst_node(PlannedStmt, lc2);
|
||||
bool canSetTag = stmt->canSetTag;
|
||||
DestReceiver *dest;
|
||||
|
||||
|
@ -111,7 +111,7 @@ exprType(const Node *expr)
|
||||
|
||||
if (!qtree || !IsA(qtree, Query))
|
||||
elog(ERROR, "cannot get type for untransformed sublink");
|
||||
tent = castNode(TargetEntry, linitial(qtree->targetList));
|
||||
tent = linitial_node(TargetEntry, qtree->targetList);
|
||||
Assert(!tent->resjunk);
|
||||
type = exprType((Node *) tent->expr);
|
||||
if (sublink->subLinkType == ARRAY_SUBLINK)
|
||||
@ -324,7 +324,7 @@ exprTypmod(const Node *expr)
|
||||
|
||||
if (!qtree || !IsA(qtree, Query))
|
||||
elog(ERROR, "cannot get type for untransformed sublink");
|
||||
tent = castNode(TargetEntry, linitial(qtree->targetList));
|
||||
tent = linitial_node(TargetEntry, qtree->targetList);
|
||||
Assert(!tent->resjunk);
|
||||
return exprTypmod((Node *) tent->expr);
|
||||
/* note we don't need to care if it's an array */
|
||||
@ -382,7 +382,7 @@ exprTypmod(const Node *expr)
|
||||
return -1; /* no point in trying harder */
|
||||
foreach(arg, cexpr->args)
|
||||
{
|
||||
CaseWhen *w = castNode(CaseWhen, lfirst(arg));
|
||||
CaseWhen *w = lfirst_node(CaseWhen, arg);
|
||||
|
||||
if (exprType((Node *) w->result) != casetype)
|
||||
return -1;
|
||||
@ -809,7 +809,7 @@ exprCollation(const Node *expr)
|
||||
|
||||
if (!qtree || !IsA(qtree, Query))
|
||||
elog(ERROR, "cannot get collation for untransformed sublink");
|
||||
tent = castNode(TargetEntry, linitial(qtree->targetList));
|
||||
tent = linitial_node(TargetEntry, qtree->targetList);
|
||||
Assert(!tent->resjunk);
|
||||
coll = exprCollation((Node *) tent->expr);
|
||||
/* collation doesn't change if it's converted to array */
|
||||
@ -1054,7 +1054,7 @@ exprSetCollation(Node *expr, Oid collation)
|
||||
|
||||
if (!qtree || !IsA(qtree, Query))
|
||||
elog(ERROR, "cannot set collation for untransformed sublink");
|
||||
tent = castNode(TargetEntry, linitial(qtree->targetList));
|
||||
tent = linitial_node(TargetEntry, qtree->targetList);
|
||||
Assert(!tent->resjunk);
|
||||
Assert(collation == exprCollation((Node *) tent->expr));
|
||||
}
|
||||
@ -2058,7 +2058,7 @@ expression_tree_walker(Node *node,
|
||||
/* we assume walker doesn't care about CaseWhens, either */
|
||||
foreach(temp, caseexpr->args)
|
||||
{
|
||||
CaseWhen *when = castNode(CaseWhen, lfirst(temp));
|
||||
CaseWhen *when = lfirst_node(CaseWhen, temp);
|
||||
|
||||
if (walker(when->expr, context))
|
||||
return true;
|
||||
@ -3308,7 +3308,7 @@ raw_expression_tree_walker(Node *node,
|
||||
/* we assume walker doesn't care about CaseWhens, either */
|
||||
foreach(temp, caseexpr->args)
|
||||
{
|
||||
CaseWhen *when = castNode(CaseWhen, lfirst(temp));
|
||||
CaseWhen *when = lfirst_node(CaseWhen, temp);
|
||||
|
||||
if (walker(when->expr, context))
|
||||
return true;
|
||||
@ -3807,7 +3807,7 @@ planstate_walk_subplans(List *plans,
|
||||
|
||||
foreach(lc, plans)
|
||||
{
|
||||
SubPlanState *sps = castNode(SubPlanState, lfirst(lc));
|
||||
SubPlanState *sps = lfirst_node(SubPlanState, lc);
|
||||
|
||||
if (walker(sps->planstate, context))
|
||||
return true;
|
||||
|
@ -757,7 +757,7 @@ extract_nonindex_conditions(List *qual_clauses, List *indexquals)
|
||||
|
||||
foreach(lc, qual_clauses)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
|
||||
|
||||
if (rinfo->pseudoconstant)
|
||||
continue; /* we may drop pseudoconstants here */
|
||||
@ -1990,7 +1990,7 @@ cost_windowagg(Path *path, PlannerInfo *root,
|
||||
*/
|
||||
foreach(lc, windowFuncs)
|
||||
{
|
||||
WindowFunc *wfunc = castNode(WindowFunc, lfirst(lc));
|
||||
WindowFunc *wfunc = lfirst_node(WindowFunc, lc);
|
||||
Cost wfunccost;
|
||||
QualCost argcosts;
|
||||
|
||||
@ -3066,7 +3066,7 @@ final_cost_hashjoin(PlannerInfo *root, HashPath *path,
|
||||
innerbucketsize = 1.0;
|
||||
foreach(hcl, hashclauses)
|
||||
{
|
||||
RestrictInfo *restrictinfo = castNode(RestrictInfo, lfirst(hcl));
|
||||
RestrictInfo *restrictinfo = lfirst_node(RestrictInfo, hcl);
|
||||
Selectivity thisbucketsize;
|
||||
|
||||
/*
|
||||
@ -3760,7 +3760,7 @@ compute_semi_anti_join_factors(PlannerInfo *root,
|
||||
joinquals = NIL;
|
||||
foreach(l, restrictlist)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
|
||||
if (!rinfo->is_pushed_down)
|
||||
joinquals = lappend(joinquals, rinfo);
|
||||
@ -4192,7 +4192,7 @@ calc_joinrel_size_estimate(PlannerInfo *root,
|
||||
/* Grovel through the clauses to separate into two lists */
|
||||
foreach(l, restrictlist)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
|
||||
if (rinfo->is_pushed_down)
|
||||
pushedquals = lappend(pushedquals, rinfo);
|
||||
@ -4568,7 +4568,7 @@ set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel)
|
||||
*/
|
||||
foreach(lc, subroot->parse->targetList)
|
||||
{
|
||||
TargetEntry *te = castNode(TargetEntry, lfirst(lc));
|
||||
TargetEntry *te = lfirst_node(TargetEntry, lc);
|
||||
Node *texpr = (Node *) te->expr;
|
||||
int32 item_width = 0;
|
||||
|
||||
|
@ -1277,7 +1277,7 @@ generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
foreach(lc, clauses)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
|
||||
List *pathlist;
|
||||
Path *bitmapqual;
|
||||
ListCell *j;
|
||||
@ -2188,7 +2188,7 @@ match_clauses_to_index(IndexOptInfo *index,
|
||||
|
||||
foreach(lc, clauses)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
|
||||
|
||||
match_clause_to_index(index, rinfo, clauseset);
|
||||
}
|
||||
|
@ -1250,7 +1250,7 @@ restriction_is_constant_false(List *restrictlist, bool only_pushed_down)
|
||||
*/
|
||||
foreach(lc, restrictlist)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
|
||||
|
||||
if (only_pushed_down && !rinfo->is_pushed_down)
|
||||
continue;
|
||||
|
@ -601,7 +601,7 @@ rel_is_distinct_for(PlannerInfo *root, RelOptInfo *rel, List *clause_list)
|
||||
*/
|
||||
foreach(l, clause_list)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
Oid op;
|
||||
Var *var;
|
||||
|
||||
|
@ -2550,7 +2550,7 @@ create_indexscan_plan(PlannerInfo *root,
|
||||
qpqual = NIL;
|
||||
foreach(l, scan_clauses)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
|
||||
if (rinfo->pseudoconstant)
|
||||
continue; /* we may drop pseudoconstants here */
|
||||
@ -2710,7 +2710,7 @@ create_bitmap_scan_plan(PlannerInfo *root,
|
||||
qpqual = NIL;
|
||||
foreach(l, scan_clauses)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
Node *clause = (Node *) rinfo->clause;
|
||||
|
||||
if (rinfo->pseudoconstant)
|
||||
@ -3867,7 +3867,7 @@ create_mergejoin_plan(PlannerInfo *root,
|
||||
i = 0;
|
||||
foreach(lc, best_path->path_mergeclauses)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
|
||||
EquivalenceClass *oeclass;
|
||||
EquivalenceClass *ieclass;
|
||||
PathKey *opathkey;
|
||||
@ -4414,7 +4414,7 @@ fix_indexqual_references(PlannerInfo *root, IndexPath *index_path)
|
||||
|
||||
forboth(lcc, index_path->indexquals, lci, index_path->indexqualcols)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lcc));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lcc);
|
||||
int indexcol = lfirst_int(lci);
|
||||
Node *clause;
|
||||
|
||||
|
@ -4631,7 +4631,7 @@ create_one_window_path(PlannerInfo *root,
|
||||
window_target = copy_pathtarget(window_target);
|
||||
foreach(lc2, wflists->windowFuncs[wc->winref])
|
||||
{
|
||||
WindowFunc *wfunc = castNode(WindowFunc, lfirst(lc2));
|
||||
WindowFunc *wfunc = lfirst_node(WindowFunc, lc2);
|
||||
|
||||
add_column_to_pathtarget(window_target, (Expr *) wfunc, 0);
|
||||
window_target->width += get_typavgwidth(wfunc->wintype, -1);
|
||||
|
@ -224,7 +224,7 @@ set_plan_references(PlannerInfo *root, Plan *plan)
|
||||
*/
|
||||
foreach(lc, root->rowMarks)
|
||||
{
|
||||
PlanRowMark *rc = castNode(PlanRowMark, lfirst(lc));
|
||||
PlanRowMark *rc = lfirst_node(PlanRowMark, lc);
|
||||
PlanRowMark *newrc;
|
||||
|
||||
/* flat copy is enough since all fields are scalars */
|
||||
|
@ -433,7 +433,7 @@ get_first_col_type(Plan *plan, Oid *coltype, int32 *coltypmod,
|
||||
/* In cases such as EXISTS, tlist might be empty; arbitrarily use VOID */
|
||||
if (plan->targetlist)
|
||||
{
|
||||
TargetEntry *tent = castNode(TargetEntry, linitial(plan->targetlist));
|
||||
TargetEntry *tent = linitial_node(TargetEntry, plan->targetlist);
|
||||
|
||||
if (!tent->resjunk)
|
||||
{
|
||||
|
@ -1750,7 +1750,7 @@ translate_col_privs(const Bitmapset *parent_privs,
|
||||
attno = InvalidAttrNumber;
|
||||
foreach(lc, translated_vars)
|
||||
{
|
||||
Var *var = castNode(Var, lfirst(lc));
|
||||
Var *var = lfirst_node(Var, lc);
|
||||
|
||||
attno++;
|
||||
if (var == NULL) /* ignore dropped columns */
|
||||
|
@ -3090,7 +3090,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
const_true_cond = false;
|
||||
foreach(arg, caseexpr->args)
|
||||
{
|
||||
CaseWhen *oldcasewhen = castNode(CaseWhen, lfirst(arg));
|
||||
CaseWhen *oldcasewhen = lfirst_node(CaseWhen, arg);
|
||||
Node *casecond;
|
||||
Node *caseresult;
|
||||
|
||||
|
@ -188,7 +188,7 @@ extract_or_clause(RestrictInfo *or_rinfo, RelOptInfo *rel)
|
||||
|
||||
foreach(lc2, andargs)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lc2));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc2);
|
||||
|
||||
if (restriction_is_or_clause(rinfo))
|
||||
{
|
||||
|
@ -335,7 +335,7 @@ get_actual_clauses(List *restrictinfo_list)
|
||||
|
||||
foreach(l, restrictinfo_list)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
|
||||
Assert(!rinfo->pseudoconstant);
|
||||
|
||||
@ -359,7 +359,7 @@ extract_actual_clauses(List *restrictinfo_list,
|
||||
|
||||
foreach(l, restrictinfo_list)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
|
||||
if (rinfo->pseudoconstant == pseudoconstant)
|
||||
result = lappend(result, rinfo->clause);
|
||||
@ -389,7 +389,7 @@ extract_actual_join_clauses(List *restrictinfo_list,
|
||||
|
||||
foreach(l, restrictinfo_list)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(l));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
|
||||
|
||||
if (rinfo->is_pushed_down)
|
||||
{
|
||||
|
@ -829,7 +829,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
|
||||
AttrNumber attr_num;
|
||||
TargetEntry *tle;
|
||||
|
||||
col = castNode(ResTarget, lfirst(icols));
|
||||
col = lfirst_node(ResTarget, icols);
|
||||
attr_num = (AttrNumber) lfirst_int(attnos);
|
||||
|
||||
tle = makeTargetEntry(expr,
|
||||
@ -954,7 +954,7 @@ transformInsertRow(ParseState *pstate, List *exprlist,
|
||||
Expr *expr = (Expr *) lfirst(lc);
|
||||
ResTarget *col;
|
||||
|
||||
col = castNode(ResTarget, lfirst(icols));
|
||||
col = lfirst_node(ResTarget, icols);
|
||||
|
||||
expr = transformAssignedExpr(pstate, expr,
|
||||
EXPR_KIND_INSERT_TARGET,
|
||||
@ -2300,7 +2300,7 @@ transformUpdateTargetList(ParseState *pstate, List *origTlist)
|
||||
}
|
||||
if (orig_tl == NULL)
|
||||
elog(ERROR, "UPDATE target count mismatch --- internal error");
|
||||
origTarget = castNode(ResTarget, lfirst(orig_tl));
|
||||
origTarget = lfirst_node(ResTarget, orig_tl);
|
||||
|
||||
attrno = attnameAttNum(pstate->p_target_relation,
|
||||
origTarget->name, true);
|
||||
|
@ -798,7 +798,7 @@ stmtmulti: stmtmulti ';' stmt
|
||||
if ($1 != NIL)
|
||||
{
|
||||
/* update length of previous stmt */
|
||||
updateRawStmtEnd(castNode(RawStmt, llast($1)), @2);
|
||||
updateRawStmtEnd(llast_node(RawStmt, $1), @2);
|
||||
}
|
||||
if ($3 != NULL)
|
||||
$$ = lappend($1, makeRawStmt($3, @2 + 1));
|
||||
|
@ -514,7 +514,7 @@ assign_collations_walker(Node *node, assign_collations_context *context)
|
||||
|
||||
if (qtree->targetList == NIL)
|
||||
return false;
|
||||
tent = castNode(TargetEntry, linitial(qtree->targetList));
|
||||
tent = linitial_node(TargetEntry, qtree->targetList);
|
||||
if (tent->resjunk)
|
||||
return false;
|
||||
|
||||
@ -649,7 +649,7 @@ assign_collations_walker(Node *node, assign_collations_context *context)
|
||||
|
||||
foreach(lc, expr->args)
|
||||
{
|
||||
CaseWhen *when = castNode(CaseWhen, lfirst(lc));
|
||||
CaseWhen *when = lfirst_node(CaseWhen, lc);
|
||||
|
||||
/*
|
||||
* The condition expressions mustn't affect
|
||||
@ -865,7 +865,7 @@ assign_aggregate_collations(Aggref *aggref,
|
||||
/* Process aggregated args, holding resjunk ones at arm's length */
|
||||
foreach(lc, aggref->args)
|
||||
{
|
||||
TargetEntry *tle = castNode(TargetEntry, lfirst(lc));
|
||||
TargetEntry *tle = lfirst_node(TargetEntry, lc);
|
||||
|
||||
if (tle->resjunk)
|
||||
assign_expr_collations(loccontext->pstate, (Node *) tle);
|
||||
@ -909,7 +909,7 @@ assign_ordered_set_collations(Aggref *aggref,
|
||||
/* Process aggregated args appropriately */
|
||||
foreach(lc, aggref->args)
|
||||
{
|
||||
TargetEntry *tle = castNode(TargetEntry, lfirst(lc));
|
||||
TargetEntry *tle = lfirst_node(TargetEntry, lc);
|
||||
|
||||
if (merge_sort_collations)
|
||||
(void) assign_collations_walker((Node *) tle, loccontext);
|
||||
|
@ -1669,7 +1669,7 @@ transformCaseExpr(ParseState *pstate, CaseExpr *c)
|
||||
resultexprs = NIL;
|
||||
foreach(l, c->args)
|
||||
{
|
||||
CaseWhen *w = castNode(CaseWhen, lfirst(l));
|
||||
CaseWhen *w = lfirst_node(CaseWhen, l);
|
||||
CaseWhen *neww = makeNode(CaseWhen);
|
||||
Node *warg;
|
||||
|
||||
@ -2334,7 +2334,7 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
|
||||
|
||||
foreach(lc, x->named_args)
|
||||
{
|
||||
ResTarget *r = castNode(ResTarget, lfirst(lc));
|
||||
ResTarget *r = lfirst_node(ResTarget, lc);
|
||||
Node *expr;
|
||||
char *argname;
|
||||
|
||||
|
@ -337,7 +337,7 @@ transformArraySubscripts(ParseState *pstate,
|
||||
*/
|
||||
foreach(idx, indirection)
|
||||
{
|
||||
A_Indices *ai = castNode(A_Indices, lfirst(idx));
|
||||
A_Indices *ai = lfirst_node(A_Indices, idx);
|
||||
Node *subexpr;
|
||||
|
||||
if (isSlice)
|
||||
|
@ -931,7 +931,7 @@ markRTEForSelectPriv(ParseState *pstate, RangeTblEntry *rte,
|
||||
JoinExpr *j;
|
||||
|
||||
if (rtindex > 0 && rtindex <= list_length(pstate->p_joinexprs))
|
||||
j = castNode(JoinExpr, list_nth(pstate->p_joinexprs, rtindex - 1));
|
||||
j = list_nth_node(JoinExpr, pstate->p_joinexprs, rtindex - 1);
|
||||
else
|
||||
j = NULL;
|
||||
if (j == NULL)
|
||||
|
@ -478,7 +478,7 @@ TypeNameListToString(List *typenames)
|
||||
initStringInfo(&string);
|
||||
foreach(l, typenames)
|
||||
{
|
||||
TypeName *typeName = castNode(TypeName, lfirst(l));
|
||||
TypeName *typeName = lfirst_node(TypeName, l);
|
||||
|
||||
if (l != list_head(typenames))
|
||||
appendStringInfoChar(&string, ',');
|
||||
@ -719,7 +719,7 @@ typeStringToTypeName(const char *str)
|
||||
*/
|
||||
if (list_length(raw_parsetree_list) != 1)
|
||||
goto fail;
|
||||
stmt = (SelectStmt *) castNode(RawStmt, linitial(raw_parsetree_list))->stmt;
|
||||
stmt = (SelectStmt *) linitial_node(RawStmt, raw_parsetree_list)->stmt;
|
||||
if (stmt == NULL ||
|
||||
!IsA(stmt, SelectStmt) ||
|
||||
stmt->distinctClause != NIL ||
|
||||
|
@ -388,7 +388,7 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column,
|
||||
|
||||
foreach(option, seqoptions)
|
||||
{
|
||||
DefElem *defel = castNode(DefElem, lfirst(option));
|
||||
DefElem *defel = lfirst_node(DefElem, option);
|
||||
|
||||
if (strcmp(defel->defname, "sequence_name") == 0)
|
||||
{
|
||||
@ -605,7 +605,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
|
||||
|
||||
foreach(clist, column->constraints)
|
||||
{
|
||||
Constraint *constraint = castNode(Constraint, lfirst(clist));
|
||||
Constraint *constraint = lfirst_node(Constraint, clist);
|
||||
|
||||
switch (constraint->contype)
|
||||
{
|
||||
@ -1635,7 +1635,7 @@ transformIndexConstraints(CreateStmtContext *cxt)
|
||||
*/
|
||||
foreach(lc, cxt->ixconstraints)
|
||||
{
|
||||
Constraint *constraint = castNode(Constraint, lfirst(lc));
|
||||
Constraint *constraint = lfirst_node(Constraint, lc);
|
||||
|
||||
Assert(constraint->contype == CONSTR_PRIMARY ||
|
||||
constraint->contype == CONSTR_UNIQUE ||
|
||||
@ -1956,8 +1956,8 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
List *opname;
|
||||
|
||||
Assert(list_length(pair) == 2);
|
||||
elem = castNode(IndexElem, linitial(pair));
|
||||
opname = castNode(List, lsecond(pair));
|
||||
elem = linitial_node(IndexElem, pair);
|
||||
opname = lsecond_node(List, pair);
|
||||
|
||||
index->indexParams = lappend(index->indexParams, elem);
|
||||
index->excludeOpNames = lappend(index->excludeOpNames, opname);
|
||||
@ -1984,7 +1984,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
|
||||
foreach(columns, cxt->columns)
|
||||
{
|
||||
column = castNode(ColumnDef, lfirst(columns));
|
||||
column = lfirst_node(ColumnDef, columns);
|
||||
if (strcmp(column->colname, key) == 0)
|
||||
{
|
||||
found = true;
|
||||
@ -2013,7 +2013,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
|
||||
|
||||
foreach(inher, cxt->inhRelations)
|
||||
{
|
||||
RangeVar *inh = castNode(RangeVar, lfirst(inher));
|
||||
RangeVar *inh = lfirst_node(RangeVar, inher);
|
||||
Relation rel;
|
||||
int count;
|
||||
|
||||
@ -2823,7 +2823,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
*/
|
||||
foreach(lc, castNode(List, cmd->def))
|
||||
{
|
||||
DefElem *def = castNode(DefElem, lfirst(lc));
|
||||
DefElem *def = lfirst_node(DefElem, lc);
|
||||
|
||||
if (strcmp(def->defname, "generated") == 0)
|
||||
newdef = lappend(newdef, def);
|
||||
@ -2900,7 +2900,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
||||
*/
|
||||
foreach(l, cxt.alist)
|
||||
{
|
||||
IndexStmt *idxstmt = castNode(IndexStmt, lfirst(l));
|
||||
IndexStmt *idxstmt = lfirst_node(IndexStmt, l);
|
||||
|
||||
idxstmt = transformIndexStmt(relid, idxstmt, queryString);
|
||||
newcmd = makeNode(AlterTableCmd);
|
||||
|
@ -171,7 +171,7 @@ InsertRule(char *rulname,
|
||||
if (event_qual != NULL)
|
||||
{
|
||||
/* Find query containing OLD/NEW rtable entries */
|
||||
Query *qry = castNode(Query, linitial(action));
|
||||
Query *qry = linitial_node(Query, action);
|
||||
|
||||
qry = getInsertSelectQuery(qry, NULL);
|
||||
recordDependencyOnExpr(&myself, event_qual, qry->rtable,
|
||||
@ -284,7 +284,7 @@ DefineQueryRewrite(char *rulename,
|
||||
*/
|
||||
foreach(l, action)
|
||||
{
|
||||
query = castNode(Query, lfirst(l));
|
||||
query = lfirst_node(Query, l);
|
||||
if (query->resultRelation == 0)
|
||||
continue;
|
||||
/* Don't be fooled by INSERT/SELECT */
|
||||
@ -326,7 +326,7 @@ DefineQueryRewrite(char *rulename,
|
||||
/*
|
||||
* ... the one action must be a SELECT, ...
|
||||
*/
|
||||
query = castNode(Query, linitial(action));
|
||||
query = linitial_node(Query, action);
|
||||
if (!is_instead ||
|
||||
query->commandType != CMD_SELECT)
|
||||
ereport(ERROR,
|
||||
@ -480,7 +480,7 @@ DefineQueryRewrite(char *rulename,
|
||||
|
||||
foreach(l, action)
|
||||
{
|
||||
query = castNode(Query, lfirst(l));
|
||||
query = lfirst_node(Query, l);
|
||||
|
||||
if (!query->returningList)
|
||||
continue;
|
||||
|
@ -2367,7 +2367,7 @@ view_cols_are_auto_updatable(Query *viewquery,
|
||||
* there should be a single base relation.
|
||||
*/
|
||||
Assert(list_length(viewquery->jointree->fromlist) == 1);
|
||||
rtr = castNode(RangeTblRef, linitial(viewquery->jointree->fromlist));
|
||||
rtr = linitial_node(RangeTblRef, viewquery->jointree->fromlist);
|
||||
|
||||
/* Initialize the optional return values */
|
||||
if (updatable_cols != NULL)
|
||||
@ -2619,7 +2619,7 @@ adjust_view_column_set(Bitmapset *cols, List *targetlist)
|
||||
|
||||
foreach(lc, targetlist)
|
||||
{
|
||||
TargetEntry *tle = (TargetEntry *) lfirst(lc);
|
||||
TargetEntry *tle = lfirst_node(TargetEntry, lc);
|
||||
Var *var;
|
||||
|
||||
if (tle->resjunk)
|
||||
@ -2806,7 +2806,7 @@ rewriteTargetView(Query *parsetree, Relation view)
|
||||
* view contains a single base relation.
|
||||
*/
|
||||
Assert(list_length(viewquery->jointree->fromlist) == 1);
|
||||
rtr = castNode(RangeTblRef, linitial(viewquery->jointree->fromlist));
|
||||
rtr = linitial_node(RangeTblRef, viewquery->jointree->fromlist);
|
||||
|
||||
base_rt_index = rtr->rtindex;
|
||||
base_rte = rt_fetch(base_rt_index, viewquery->rtable);
|
||||
@ -3162,7 +3162,7 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
|
||||
*/
|
||||
foreach(lc1, parsetree->cteList)
|
||||
{
|
||||
CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc1);
|
||||
CommonTableExpr *cte = lfirst_node(CommonTableExpr, lc1);
|
||||
Query *ctequery = castNode(Query, cte->ctequery);
|
||||
List *newstuff;
|
||||
|
||||
@ -3179,7 +3179,7 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
|
||||
if (list_length(newstuff) == 1)
|
||||
{
|
||||
/* Push the single Query back into the CTE node */
|
||||
ctequery = castNode(Query, linitial(newstuff));
|
||||
ctequery = linitial_node(Query, newstuff);
|
||||
/* WITH queries should never be canSetTag */
|
||||
Assert(!ctequery->canSetTag);
|
||||
cte->ctequery = (Node *) ctequery;
|
||||
|
@ -850,7 +850,7 @@ pg_plan_queries(List *querytrees, int cursorOptions, ParamListInfo boundParams)
|
||||
|
||||
foreach(query_list, querytrees)
|
||||
{
|
||||
Query *query = castNode(Query, lfirst(query_list));
|
||||
Query *query = lfirst_node(Query, query_list);
|
||||
PlannedStmt *stmt;
|
||||
|
||||
if (query->commandType == CMD_UTILITY)
|
||||
@ -966,7 +966,7 @@ exec_simple_query(const char *query_string)
|
||||
*/
|
||||
foreach(parsetree_item, parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(parsetree_item));
|
||||
RawStmt *parsetree = lfirst_node(RawStmt, parsetree_item);
|
||||
bool snapshot_set = false;
|
||||
const char *commandTag;
|
||||
char completionTag[COMPLETION_TAG_BUFSIZE];
|
||||
@ -1291,7 +1291,7 @@ exec_parse_message(const char *query_string, /* string to execute */
|
||||
bool snapshot_set = false;
|
||||
int i;
|
||||
|
||||
raw_parse_tree = castNode(RawStmt, linitial(parsetree_list));
|
||||
raw_parse_tree = linitial_node(RawStmt, parsetree_list);
|
||||
|
||||
/*
|
||||
* Get the command name for possible use in status display.
|
||||
@ -2154,7 +2154,7 @@ errdetail_execute(List *raw_parsetree_list)
|
||||
|
||||
foreach(parsetree_item, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(parsetree_item));
|
||||
RawStmt *parsetree = lfirst_node(RawStmt, parsetree_item);
|
||||
|
||||
if (IsA(parsetree->stmt, ExecuteStmt))
|
||||
{
|
||||
@ -2508,7 +2508,7 @@ IsTransactionExitStmtList(List *pstmts)
|
||||
{
|
||||
if (list_length(pstmts) == 1)
|
||||
{
|
||||
PlannedStmt *pstmt = castNode(PlannedStmt, linitial(pstmts));
|
||||
PlannedStmt *pstmt = linitial_node(PlannedStmt, pstmts);
|
||||
|
||||
if (pstmt->commandType == CMD_UTILITY &&
|
||||
IsTransactionExitStmt(pstmt->utilityStmt))
|
||||
@ -2523,7 +2523,7 @@ IsTransactionStmtList(List *pstmts)
|
||||
{
|
||||
if (list_length(pstmts) == 1)
|
||||
{
|
||||
PlannedStmt *pstmt = castNode(PlannedStmt, linitial(pstmts));
|
||||
PlannedStmt *pstmt = linitial_node(PlannedStmt, pstmts);
|
||||
|
||||
if (pstmt->commandType == CMD_UTILITY &&
|
||||
IsA(pstmt->utilityStmt, TransactionStmt))
|
||||
|
@ -496,7 +496,7 @@ PortalStart(Portal portal, ParamListInfo params,
|
||||
* Create QueryDesc in portal's context; for the moment, set
|
||||
* the destination to DestNone.
|
||||
*/
|
||||
queryDesc = CreateQueryDesc(castNode(PlannedStmt, linitial(portal->stmts)),
|
||||
queryDesc = CreateQueryDesc(linitial_node(PlannedStmt, portal->stmts),
|
||||
portal->sourceText,
|
||||
GetActiveSnapshot(),
|
||||
InvalidSnapshot,
|
||||
@ -1036,7 +1036,7 @@ FillPortalStore(Portal portal, bool isTopLevel)
|
||||
break;
|
||||
|
||||
case PORTAL_UTIL_SELECT:
|
||||
PortalRunUtility(portal, castNode(PlannedStmt, linitial(portal->stmts)),
|
||||
PortalRunUtility(portal, linitial_node(PlannedStmt, portal->stmts),
|
||||
isTopLevel, true, treceiver, completionTag);
|
||||
break;
|
||||
|
||||
@ -1232,7 +1232,7 @@ PortalRunMulti(Portal portal,
|
||||
*/
|
||||
foreach(stmtlist_item, portal->stmts)
|
||||
{
|
||||
PlannedStmt *pstmt = castNode(PlannedStmt, lfirst(stmtlist_item));
|
||||
PlannedStmt *pstmt = lfirst_node(PlannedStmt, stmtlist_item);
|
||||
|
||||
/*
|
||||
* If we got a cancel signal in prior command, quit
|
||||
|
@ -7809,7 +7809,7 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
appendStringInfoString(buf, "(alternatives: ");
|
||||
foreach(lc, asplan->subplans)
|
||||
{
|
||||
SubPlan *splan = castNode(SubPlan, lfirst(lc));
|
||||
SubPlan *splan = lfirst_node(SubPlan, lc);
|
||||
|
||||
if (splan->useHashTable)
|
||||
appendStringInfo(buf, "hashed %s", splan->plan_name);
|
||||
@ -8364,7 +8364,7 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
get_rule_expr((Node *) linitial(xexpr->args),
|
||||
context, true);
|
||||
|
||||
con = castNode(Const, lsecond(xexpr->args));
|
||||
con = lsecond_node(Const, xexpr->args);
|
||||
Assert(!con->constisnull);
|
||||
if (DatumGetBool(con->constvalue))
|
||||
appendStringInfoString(buf,
|
||||
@ -8387,7 +8387,7 @@ get_rule_expr(Node *node, deparse_context *context,
|
||||
else
|
||||
get_rule_expr((Node *) con, context, false);
|
||||
|
||||
con = castNode(Const, lthird(xexpr->args));
|
||||
con = lthird_node(Const, xexpr->args);
|
||||
if (con->constisnull)
|
||||
/* suppress STANDALONE NO VALUE */ ;
|
||||
else
|
||||
@ -8899,7 +8899,7 @@ get_agg_expr(Aggref *aggref, deparse_context *context,
|
||||
*/
|
||||
if (DO_AGGSPLIT_COMBINE(aggref->aggsplit))
|
||||
{
|
||||
TargetEntry *tle = castNode(TargetEntry, linitial(aggref->args));
|
||||
TargetEntry *tle = linitial_node(TargetEntry, aggref->args);
|
||||
|
||||
Assert(list_length(aggref->args) == 1);
|
||||
resolve_special_varno((Node *) tle->expr, context, original_aggref,
|
||||
@ -9360,7 +9360,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context)
|
||||
sep = "";
|
||||
foreach(l, ((BoolExpr *) sublink->testexpr)->args)
|
||||
{
|
||||
OpExpr *opexpr = castNode(OpExpr, lfirst(l));
|
||||
OpExpr *opexpr = lfirst_node(OpExpr, l);
|
||||
|
||||
appendStringInfoString(buf, sep);
|
||||
get_rule_expr(linitial(opexpr->args), context, true);
|
||||
|
@ -6243,7 +6243,7 @@ deconstruct_indexquals(IndexPath *path)
|
||||
|
||||
forboth(lcc, path->indexquals, lci, path->indexqualcols)
|
||||
{
|
||||
RestrictInfo *rinfo = castNode(RestrictInfo, lfirst(lcc));
|
||||
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lcc);
|
||||
int indexcol = lfirst_int(lci);
|
||||
Expr *clause;
|
||||
Node *leftop,
|
||||
|
22
src/backend/utils/cache/plancache.c
vendored
22
src/backend/utils/cache/plancache.c
vendored
@ -979,7 +979,7 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
|
||||
is_transient = false;
|
||||
foreach(lc, plist)
|
||||
{
|
||||
PlannedStmt *plannedstmt = castNode(PlannedStmt, lfirst(lc));
|
||||
PlannedStmt *plannedstmt = lfirst_node(PlannedStmt, lc);
|
||||
|
||||
if (plannedstmt->commandType == CMD_UTILITY)
|
||||
continue; /* Ignore utility statements */
|
||||
@ -1074,7 +1074,7 @@ cached_plan_cost(CachedPlan *plan, bool include_planner)
|
||||
|
||||
foreach(lc, plan->stmt_list)
|
||||
{
|
||||
PlannedStmt *plannedstmt = castNode(PlannedStmt, lfirst(lc));
|
||||
PlannedStmt *plannedstmt = lfirst_node(PlannedStmt, lc);
|
||||
|
||||
if (plannedstmt->commandType == CMD_UTILITY)
|
||||
continue; /* Ignore utility statements */
|
||||
@ -1462,7 +1462,7 @@ QueryListGetPrimaryStmt(List *stmts)
|
||||
|
||||
foreach(lc, stmts)
|
||||
{
|
||||
Query *stmt = castNode(Query, lfirst(lc));
|
||||
Query *stmt = lfirst_node(Query, lc);
|
||||
|
||||
if (stmt->canSetTag)
|
||||
return stmt;
|
||||
@ -1481,7 +1481,7 @@ AcquireExecutorLocks(List *stmt_list, bool acquire)
|
||||
|
||||
foreach(lc1, stmt_list)
|
||||
{
|
||||
PlannedStmt *plannedstmt = castNode(PlannedStmt, lfirst(lc1));
|
||||
PlannedStmt *plannedstmt = lfirst_node(PlannedStmt, lc1);
|
||||
int rt_index;
|
||||
ListCell *lc2;
|
||||
|
||||
@ -1551,7 +1551,7 @@ AcquirePlannerLocks(List *stmt_list, bool acquire)
|
||||
|
||||
foreach(lc, stmt_list)
|
||||
{
|
||||
Query *query = castNode(Query, lfirst(lc));
|
||||
Query *query = lfirst_node(Query, lc);
|
||||
|
||||
if (query->commandType == CMD_UTILITY)
|
||||
{
|
||||
@ -1618,7 +1618,7 @@ ScanQueryForLocks(Query *parsetree, bool acquire)
|
||||
/* Recurse into subquery-in-WITH */
|
||||
foreach(lc, parsetree->cteList)
|
||||
{
|
||||
CommonTableExpr *cte = castNode(CommonTableExpr, lfirst(lc));
|
||||
CommonTableExpr *cte = lfirst_node(CommonTableExpr, lc);
|
||||
|
||||
ScanQueryForLocks(castNode(Query, cte->ctequery), acquire);
|
||||
}
|
||||
@ -1676,7 +1676,7 @@ PlanCacheComputeResultDesc(List *stmt_list)
|
||||
{
|
||||
case PORTAL_ONE_SELECT:
|
||||
case PORTAL_ONE_MOD_WITH:
|
||||
query = castNode(Query, linitial(stmt_list));
|
||||
query = linitial_node(Query, stmt_list);
|
||||
return ExecCleanTypeFromTL(query->targetList, false);
|
||||
|
||||
case PORTAL_ONE_RETURNING:
|
||||
@ -1685,7 +1685,7 @@ PlanCacheComputeResultDesc(List *stmt_list)
|
||||
return ExecCleanTypeFromTL(query->returningList, false);
|
||||
|
||||
case PORTAL_UTIL_SELECT:
|
||||
query = castNode(Query, linitial(stmt_list));
|
||||
query = linitial_node(Query, stmt_list);
|
||||
Assert(query->utilityStmt);
|
||||
return UtilityTupleDescriptor(query->utilityStmt);
|
||||
|
||||
@ -1742,7 +1742,7 @@ PlanCacheRelCallback(Datum arg, Oid relid)
|
||||
|
||||
foreach(lc, plansource->gplan->stmt_list)
|
||||
{
|
||||
PlannedStmt *plannedstmt = castNode(PlannedStmt, lfirst(lc));
|
||||
PlannedStmt *plannedstmt = lfirst_node(PlannedStmt, lc);
|
||||
|
||||
if (plannedstmt->commandType == CMD_UTILITY)
|
||||
continue; /* Ignore utility statements */
|
||||
@ -1815,7 +1815,7 @@ PlanCacheFuncCallback(Datum arg, int cacheid, uint32 hashvalue)
|
||||
{
|
||||
foreach(lc, plansource->gplan->stmt_list)
|
||||
{
|
||||
PlannedStmt *plannedstmt = castNode(PlannedStmt, lfirst(lc));
|
||||
PlannedStmt *plannedstmt = lfirst_node(PlannedStmt, lc);
|
||||
ListCell *lc3;
|
||||
|
||||
if (plannedstmt->commandType == CMD_UTILITY)
|
||||
@ -1888,7 +1888,7 @@ ResetPlanCache(void)
|
||||
*/
|
||||
foreach(lc, plansource->query_list)
|
||||
{
|
||||
Query *query = castNode(Query, lfirst(lc));
|
||||
Query *query = lfirst_node(Query, lc);
|
||||
|
||||
if (query->commandType != CMD_UTILITY ||
|
||||
UtilityContainsQuery(query->utilityStmt))
|
||||
|
@ -7366,7 +7366,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel)
|
||||
}
|
||||
else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
|
||||
{
|
||||
A_Const *con = castNode(A_Const, linitial(stmt->args));
|
||||
A_Const *con = linitial_node(A_Const, stmt->args);
|
||||
|
||||
if (stmt->is_local)
|
||||
ereport(ERROR,
|
||||
|
@ -153,7 +153,7 @@ PortalGetPrimaryStmt(Portal portal)
|
||||
|
||||
foreach(lc, portal->stmts)
|
||||
{
|
||||
PlannedStmt *stmt = castNode(PlannedStmt, lfirst(lc));
|
||||
PlannedStmt *stmt = lfirst_node(PlannedStmt, lc);
|
||||
|
||||
if (stmt->canSetTag)
|
||||
return stmt;
|
||||
|
@ -106,26 +106,32 @@ list_length(const List *l)
|
||||
#define lfirst(lc) ((lc)->data.ptr_value)
|
||||
#define lfirst_int(lc) ((lc)->data.int_value)
|
||||
#define lfirst_oid(lc) ((lc)->data.oid_value)
|
||||
#define lfirst_node(type,lc) castNode(type, lfirst(lc))
|
||||
|
||||
#define linitial(l) lfirst(list_head(l))
|
||||
#define linitial_int(l) lfirst_int(list_head(l))
|
||||
#define linitial_oid(l) lfirst_oid(list_head(l))
|
||||
#define linitial_node(type,l) castNode(type, linitial(l))
|
||||
|
||||
#define lsecond(l) lfirst(lnext(list_head(l)))
|
||||
#define lsecond_int(l) lfirst_int(lnext(list_head(l)))
|
||||
#define lsecond_oid(l) lfirst_oid(lnext(list_head(l)))
|
||||
#define lsecond_node(type,l) castNode(type, lsecond(l))
|
||||
|
||||
#define lthird(l) lfirst(lnext(lnext(list_head(l))))
|
||||
#define lthird_int(l) lfirst_int(lnext(lnext(list_head(l))))
|
||||
#define lthird_oid(l) lfirst_oid(lnext(lnext(list_head(l))))
|
||||
#define lthird_node(type,l) castNode(type, lthird(l))
|
||||
|
||||
#define lfourth(l) lfirst(lnext(lnext(lnext(list_head(l)))))
|
||||
#define lfourth_int(l) lfirst_int(lnext(lnext(lnext(list_head(l)))))
|
||||
#define lfourth_oid(l) lfirst_oid(lnext(lnext(lnext(list_head(l)))))
|
||||
#define lfourth_node(type,l) castNode(type, lfourth(l))
|
||||
|
||||
#define llast(l) lfirst(list_tail(l))
|
||||
#define llast_int(l) lfirst_int(list_tail(l))
|
||||
#define llast_oid(l) lfirst_oid(list_tail(l))
|
||||
#define llast_node(type,l) castNode(type, llast(l))
|
||||
|
||||
/*
|
||||
* Convenience macros for building fixed-length lists
|
||||
@ -204,6 +210,7 @@ extern ListCell *list_nth_cell(const List *list, int n);
|
||||
extern void *list_nth(const List *list, int n);
|
||||
extern int list_nth_int(const List *list, int n);
|
||||
extern Oid list_nth_oid(const List *list, int n);
|
||||
#define list_nth_node(type,list,n) castNode(type, list_nth(list, n))
|
||||
|
||||
extern bool list_member(const List *list, const void *datum);
|
||||
extern bool list_member_ptr(const List *list, const void *datum);
|
||||
|
@ -3639,7 +3639,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
|
||||
|
||||
foreach(l2, plansource->query_list)
|
||||
{
|
||||
Query *q = castNode(Query, lfirst(l2));
|
||||
Query *q = lfirst_node(Query, l2);
|
||||
|
||||
if (q->canSetTag)
|
||||
{
|
||||
@ -6835,7 +6835,7 @@ exec_simple_recheck_plan(PLpgSQL_expr *expr, CachedPlan *cplan)
|
||||
*/
|
||||
if (list_length(cplan->stmt_list) != 1)
|
||||
return;
|
||||
stmt = castNode(PlannedStmt, linitial(cplan->stmt_list));
|
||||
stmt = linitial_node(PlannedStmt, cplan->stmt_list);
|
||||
|
||||
/*
|
||||
* 2. It must be a RESULT plan --> no scan's required
|
||||
|
Loading…
x
Reference in New Issue
Block a user