Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2b00db4

Browse files
committed
Use l*_node() family of functions where appropriate
Instead of castNode(…, lfoo(…))Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>Discussion:https://www.postgresql.org/message-id/flat/87eecahraj.fsf@wibble.ilmari.org
1 parent29abde6 commit2b00db4

File tree

13 files changed

+33
-33
lines changed

13 files changed

+33
-33
lines changed

‎src/backend/commands/publicationcmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ OpenTableList(List *tables)
514514
*/
515515
foreach(lc,tables)
516516
{
517-
RangeVar*rv=castNode(RangeVar,lfirst(lc));
517+
RangeVar*rv=lfirst_node(RangeVar,lc);
518518
boolrecurse=rv->inh;
519519
Relationrel;
520520
Oidmyrelid;

‎src/backend/commands/tablecmds.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4770,7 +4770,7 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode,
47704770

47714771
foreach(lcmd, subcmds)
47724772
ATExecCmd(wqueue, tab,
4773-
castNode(AlterTableCmd,lfirst(lcmd)),
4773+
lfirst_node(AlterTableCmd, lcmd),
47744774
lockmode, pass, context);
47754775

47764776
/*
@@ -12842,7 +12842,7 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
1284212842

1284312843
foreach(lcmd, stmt->cmds)
1284412844
{
12845-
AlterTableCmd *cmd =castNode(AlterTableCmd,lfirst(lcmd));
12845+
AlterTableCmd *cmd =lfirst_node(AlterTableCmd, lcmd);
1284612846

1284712847
if (cmd->subtype == AT_AddIndex)
1284812848
{
@@ -16671,7 +16671,7 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy)
1667116671
/* take care of any partition expressions */
1667216672
foreach(l, partspec->partParams)
1667316673
{
16674-
PartitionElem *pelem =castNode(PartitionElem,lfirst(l));
16674+
PartitionElem *pelem =lfirst_node(PartitionElem,l);
1667516675

1667616676
if (pelem->expr)
1667716677
{
@@ -16708,7 +16708,7 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu
1670816708
attn = 0;
1670916709
foreach(lc, partParams)
1671016710
{
16711-
PartitionElem *pelem =castNode(PartitionElem,lfirst(lc));
16711+
PartitionElem *pelem =lfirst_node(PartitionElem,lc);
1671216712
Oidatttype;
1671316713
Oidattcollation;
1671416714

‎src/backend/executor/execPartition.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
585585

586586
foreach(ll,wcoList)
587587
{
588-
WithCheckOption*wco=castNode(WithCheckOption,lfirst(ll));
588+
WithCheckOption*wco=lfirst_node(WithCheckOption,ll);
589589
ExprState*wcoExpr=ExecInitQual(castNode(List,wco->qual),
590590
&mtstate->ps);
591591

‎src/backend/executor/nodeValuesscan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags)
285285
i=0;
286286
foreach(vtl,node->values_lists)
287287
{
288-
List*exprs=castNode(List,lfirst(vtl));
288+
List*exprs=lfirst_node(List,vtl);
289289

290290
scanstate->exprlists[i]=exprs;
291291

‎src/backend/optimizer/util/paramassign.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ process_subquery_nestloop_params(PlannerInfo *root, List *subplan_params)
431431

432432
foreach(lc,subplan_params)
433433
{
434-
PlannerParamItem*pitem=castNode(PlannerParamItem,lfirst(lc));
434+
PlannerParamItem*pitem=lfirst_node(PlannerParamItem,lc);
435435

436436
if (IsA(pitem->item,Var))
437437
{

‎src/backend/parser/parse_clause.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2807,7 +2807,7 @@ transformWindowDefinitions(ParseState *pstate,
28072807
(errcode(ERRCODE_WINDOWING_ERROR),
28082808
errmsg("RANGE with offset PRECEDING/FOLLOWING requires exactly one ORDER BY column"),
28092809
parser_errposition(pstate,windef->location)));
2810-
sortcl=castNode(SortGroupClause,linitial(wc->orderClause));
2810+
sortcl=linitial_node(SortGroupClause,wc->orderClause);
28112811
sortkey=get_sortgroupclause_expr(sortcl,*targetlist);
28122812
/* Find the sort operator in pg_amop */
28132813
if (!get_ordering_op_properties(sortcl->sortop,

‎src/backend/parser/parse_utilcmd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
24242424
/* Make sure referenced column exists. */
24252425
foreach(columns,cxt->columns)
24262426
{
2427-
column=castNode(ColumnDef,lfirst(columns));
2427+
column=lfirst_node(ColumnDef,columns);
24282428
if (strcmp(column->colname,key)==0)
24292429
{
24302430
found= true;
@@ -2462,7 +2462,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt)
24622462

24632463
foreach(inher,cxt->inhRelations)
24642464
{
2465-
RangeVar*inh=castNode(RangeVar,lfirst(inher));
2465+
RangeVar*inh=lfirst_node(RangeVar,inher);
24662466
Relationrel;
24672467
intcount;
24682468

@@ -4088,7 +4088,7 @@ transformPartitionBound(ParseState *pstate, Relation parent,
40884088
duplicate= false;
40894089
foreach(cell2,result_spec->listdatums)
40904090
{
4091-
Const*value2=castNode(Const,lfirst(cell2));
4091+
Const*value2=lfirst_node(Const,cell2);
40924092

40934093
if (equal(value,value2))
40944094
{
@@ -4267,7 +4267,7 @@ validateInfiniteBounds(ParseState *pstate, List *blist)
42674267

42684268
foreach(lc,blist)
42694269
{
4270-
PartitionRangeDatum*prd=castNode(PartitionRangeDatum,lfirst(lc));
4270+
PartitionRangeDatum*prd=lfirst_node(PartitionRangeDatum,lc);
42714271

42724272
if (kind==prd->kind)
42734273
continue;

‎src/backend/partitioning/partbounds.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ get_non_null_list_datum_count(PartitionBoundSpec **boundspecs, int nparts)
452452

453453
foreach(lc,boundspecs[i]->listdatums)
454454
{
455-
Const*val=castNode(Const,lfirst(lc));
455+
Const*val=lfirst_node(Const,lc);
456456

457457
if (!val->constisnull)
458458
count++;
@@ -513,7 +513,7 @@ create_list_bounds(PartitionBoundSpec **boundspecs, int nparts,
513513

514514
foreach(c,spec->listdatums)
515515
{
516-
Const*val=castNode(Const,lfirst(c));
516+
Const*val=lfirst_node(Const,c);
517517

518518
if (!val->constisnull)
519519
{
@@ -3014,7 +3014,7 @@ check_new_partition_bound(char *relname, Relation parent,
30143014

30153015
foreach(cell,spec->listdatums)
30163016
{
3017-
Const*val=castNode(Const,lfirst(cell));
3017+
Const*val=lfirst_node(Const,cell);
30183018

30193019
overlap_location=val->location;
30203020
if (!val->constisnull)
@@ -3399,7 +3399,7 @@ make_one_partition_rbound(PartitionKey key, int index, List *datums, bool lower)
33993399
i=0;
34003400
foreach(lc,datums)
34013401
{
3402-
PartitionRangeDatum*datum=castNode(PartitionRangeDatum,lfirst(lc));
3402+
PartitionRangeDatum*datum=lfirst_node(PartitionRangeDatum,lc);
34033403

34043404
/* What's contained in this range datum? */
34053405
bound->kind[i]=datum->kind;
@@ -4103,7 +4103,7 @@ get_qual_for_list(Relation parent, PartitionBoundSpec *spec)
41034103
*/
41044104
foreach(cell,spec->listdatums)
41054105
{
4106-
Const*val=castNode(Const,lfirst(cell));
4106+
Const*val=lfirst_node(Const,cell);
41074107

41084108
if (val->constisnull)
41094109
list_has_null= true;
@@ -4358,8 +4358,8 @@ get_qual_for_range(Relation parent, PartitionBoundSpec *spec,
43584358
Datumtest_result;
43594359
boolisNull;
43604360

4361-
ldatum=castNode(PartitionRangeDatum,lfirst(cell1));
4362-
udatum=castNode(PartitionRangeDatum,lfirst(cell2));
4361+
ldatum=lfirst_node(PartitionRangeDatum,cell1);
4362+
udatum=lfirst_node(PartitionRangeDatum,cell2);
43634363

43644364
/*
43654365
* Since get_range_key_properties() modifies partexprs_item, and we
@@ -4440,11 +4440,11 @@ get_qual_for_range(Relation parent, PartitionBoundSpec *spec,
44404440
PartitionRangeDatum*ldatum_next=NULL,
44414441
*udatum_next=NULL;
44424442

4443-
ldatum=castNode(PartitionRangeDatum,lfirst(cell1));
4443+
ldatum=lfirst_node(PartitionRangeDatum,cell1);
44444444
if (lnext(spec->lowerdatums,cell1))
44454445
ldatum_next=castNode(PartitionRangeDatum,
44464446
lfirst(lnext(spec->lowerdatums,cell1)));
4447-
udatum=castNode(PartitionRangeDatum,lfirst(cell2));
4447+
udatum=lfirst_node(PartitionRangeDatum,cell2);
44484448
if (lnext(spec->upperdatums,cell2))
44494449
udatum_next=castNode(PartitionRangeDatum,
44504450
lfirst(lnext(spec->upperdatums,cell2)));

‎src/backend/rewrite/rewriteSearchCycle.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ rewriteSearchAndCycle(CommonTableExpr *cte)
307307
list_nth_oid(cte->ctecolcollations,i),
308308
0);
309309
tle=makeTargetEntry((Expr*)var,i+1,strVal(list_nth(cte->ctecolnames,i)), false);
310-
tle->resorigtbl=castNode(TargetEntry,list_nth(rte1->subquery->targetList,i))->resorigtbl;
311-
tle->resorigcol=castNode(TargetEntry,list_nth(rte1->subquery->targetList,i))->resorigcol;
310+
tle->resorigtbl=list_nth_node(TargetEntry,rte1->subquery->targetList,i)->resorigtbl;
311+
tle->resorigcol=list_nth_node(TargetEntry,rte1->subquery->targetList,i)->resorigcol;
312312
newq1->targetList=lappend(newq1->targetList,tle);
313313
}
314314

@@ -482,8 +482,8 @@ rewriteSearchAndCycle(CommonTableExpr *cte)
482482
list_nth_oid(cte->ctecolcollations,i),
483483
0);
484484
tle=makeTargetEntry((Expr*)var,i+1,strVal(list_nth(cte->ctecolnames,i)), false);
485-
tle->resorigtbl=castNode(TargetEntry,list_nth(rte2->subquery->targetList,i))->resorigtbl;
486-
tle->resorigcol=castNode(TargetEntry,list_nth(rte2->subquery->targetList,i))->resorigcol;
485+
tle->resorigtbl=list_nth_node(TargetEntry,rte2->subquery->targetList,i)->resorigtbl;
486+
tle->resorigcol=list_nth_node(TargetEntry,rte2->subquery->targetList,i)->resorigcol;
487487
newq2->targetList=lappend(newq2->targetList,tle);
488488
}
489489

‎src/backend/tcop/postgres.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ pg_rewrite_query(Query *query)
785785
*/
786786
foreach(lc,querytree_list)
787787
{
788-
Query*query=castNode(Query,lfirst(lc));
788+
Query*query=lfirst_node(Query,lc);
789789

790790
if (query->commandType!=CMD_UTILITY)
791791
{

‎src/backend/utils/adt/ruleutils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7793,7 +7793,7 @@ find_param_referent(Param *param, deparse_context *context,
77937793
*/
77947794
foreach(lc2, ((Plan*)ancestor)->initPlan)
77957795
{
7796-
SubPlan*subplan=castNode(SubPlan,lfirst(lc2));
7796+
SubPlan*subplan=lfirst_node(SubPlan,lc2);
77977797

77987798
if (child_plan!= (Plan*)list_nth(dpns->subplans,
77997799
subplan->plan_id-1))
@@ -9407,7 +9407,7 @@ get_rule_expr(Node *node, deparse_context *context,
94079407
sep="";
94089408
foreach(cell,spec->listdatums)
94099409
{
9410-
Const*val=castNode(Const,lfirst(cell));
9410+
Const*val=lfirst_node(Const,cell);
94119411

94129412
appendStringInfoString(buf,sep);
94139413
get_const_expr(val,context,-1);
@@ -11990,7 +11990,7 @@ get_range_partbound_string(List *bound_datums)
1199011990
foreach(cell,bound_datums)
1199111991
{
1199211992
PartitionRangeDatum*datum=
11993-
castNode(PartitionRangeDatum,lfirst(cell));
11993+
lfirst_node(PartitionRangeDatum,cell);
1199411994

1199511995
appendStringInfoString(buf,sep);
1199611996
if (datum->kind==PARTITION_RANGE_DATUM_MINVALUE)

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7996,7 +7996,7 @@ exec_save_simple_expr(PLpgSQL_expr *expr, CachedPlan *cplan)
79967996
{
79977997
/* Extract the single tlist expression */
79987998
Assert(list_length(plan->targetlist)==1);
7999-
tle_expr=castNode(TargetEntry,linitial(plan->targetlist))->expr;
7999+
tle_expr=linitial_node(TargetEntry,plan->targetlist)->expr;
80008000

80018001
if (IsA(plan,Result))
80028002
{

‎src/test/modules/test_predtest/test_predtest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ test_predtest(PG_FUNCTION_ARGS)
131131
elog(ERROR,"failed to decipher query plan");
132132
plan=stmt->planTree;
133133
Assert(list_length(plan->targetlist) >=2);
134-
clause1=castNode(TargetEntry,linitial(plan->targetlist))->expr;
135-
clause2=castNode(TargetEntry,lsecond(plan->targetlist))->expr;
134+
clause1=linitial_node(TargetEntry,plan->targetlist)->expr;
135+
clause2=lsecond_node(TargetEntry,plan->targetlist)->expr;
136136

137137
/*
138138
* Because the clauses are in the SELECT list, preprocess_expression did

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp