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

Commit66cd411

Browse files
committed
fixed recreation of AND restrictions for partitions
1 parent337a092 commit66cd411

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

‎pg_pathman.c

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ static WrapperNode *handle_arrexpr(const ScalarArrayOpExpr *expr, const PartRela
8888
staticvoidchange_varnos_in_restrinct_info(RestrictInfo*rinfo,change_varno_context*context);
8989
staticvoidchange_varnos(Node*node,Oidold_varno,Oidnew_varno);
9090
staticboolchange_varno_walker(Node*node,change_varno_context*context);
91+
staticRestrictInfo*rebuild_restrictinfo(Node*clause,RestrictInfo*old_rinfo);
9192

9293
/* copied from allpaths.h */
9394
staticvoidset_plain_rel_pathlist(PlannerInfo*root,RelOptInfo*rel,RangeTblEntry*rte);
@@ -509,28 +510,38 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
509510
boolalwaysTrue;
510511
WrapperNode*wrap= (WrapperNode*)lfirst(lc);
511512
Node*new_clause=wrapper_make_expression(wrap,index,&alwaysTrue);
512-
RestrictInfo*old_rinfo= (RestrictInfo*)lfirst(lc2),
513-
*new_rinfo;
513+
RestrictInfo*old_rinfo= (RestrictInfo*)lfirst(lc2);
514514

515515
if (alwaysTrue)
516516
{
517517
continue;
518518
}
519519
Assert(new_clause);
520520

521-
new_rinfo=make_restrictinfo((Expr*)new_clause,
522-
old_rinfo->is_pushed_down,
523-
old_rinfo->outerjoin_delayed,
524-
old_rinfo->pseudoconstant,
525-
old_rinfo->required_relids,
526-
old_rinfo->outer_relids,
527-
old_rinfo->nullable_relids);
521+
if (and_clause((Node*)new_clause))
522+
{
523+
ListCell*alc;
524+
525+
foreach(alc, ((BoolExpr*)new_clause)->args)
526+
{
527+
Node*arg= (Node*)lfirst(alc);
528+
RestrictInfo*new_rinfo=rebuild_restrictinfo(arg,old_rinfo);
529+
530+
change_varnos((Node*)new_rinfo,rel->relid,childrel->relid);
531+
childrel->baserestrictinfo=lappend(childrel->baserestrictinfo,
532+
new_rinfo);
533+
}
534+
}
535+
else
536+
{
537+
RestrictInfo*new_rinfo=rebuild_restrictinfo(new_clause,old_rinfo);
528538

529-
/* Replace old relids with new ones */
530-
change_varnos((Node*)new_rinfo,rel->relid,childrel->relid);
539+
/* Replace old relids with new ones */
540+
change_varnos((Node*)new_rinfo,rel->relid,childrel->relid);
531541

532-
childrel->baserestrictinfo=lappend(childrel->baserestrictinfo,
533-
(void*)new_rinfo);
542+
childrel->baserestrictinfo=lappend(childrel->baserestrictinfo,
543+
(void*)new_rinfo);
544+
}
534545
}
535546

536547
/* Build an AppendRelInfo for this parent and child */
@@ -544,6 +555,19 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
544555
heap_close(newrelation,NoLock);
545556
}
546557

558+
/* Create new restriction based on clause */
559+
staticRestrictInfo*
560+
rebuild_restrictinfo(Node*clause,RestrictInfo*old_rinfo)
561+
{
562+
returnmake_restrictinfo((Expr*)clause,
563+
old_rinfo->is_pushed_down,
564+
old_rinfo->outerjoin_delayed,
565+
old_rinfo->pseudoconstant,
566+
old_rinfo->required_relids,
567+
old_rinfo->outer_relids,
568+
old_rinfo->nullable_relids);
569+
}
570+
547571
/* Convert wrapper into expression for given index */
548572
staticNode*
549573
wrapper_make_expression(WrapperNode*wrap,intindex,bool*alwaysTrue)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp