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

Commit3e9c206

Browse files
committed
pathman: fixed recreation of AND restrictions for partitions
1 parenteb11166 commit3e9c206

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

‎contrib/pg_pathman/pg_pathman.c

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

9394
/* copied from allpaths.h */
9495
staticvoidset_plain_rel_size(PlannerInfo*root,RelOptInfo*rel,
@@ -636,28 +637,38 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
636637
boolalwaysTrue;
637638
WrapperNode*wrap= (WrapperNode*)lfirst(lc);
638639
Node*new_clause=wrapper_make_expression(wrap,index,&alwaysTrue);
639-
RestrictInfo*old_rinfo= (RestrictInfo*)lfirst(lc2),
640-
*new_rinfo;
640+
RestrictInfo*old_rinfo= (RestrictInfo*)lfirst(lc2);
641641

642642
if (alwaysTrue)
643643
{
644644
continue;
645645
}
646646
Assert(new_clause);
647647

648-
new_rinfo=make_restrictinfo((Expr*)new_clause,
649-
old_rinfo->is_pushed_down,
650-
old_rinfo->outerjoin_delayed,
651-
old_rinfo->pseudoconstant,
652-
old_rinfo->required_relids,
653-
old_rinfo->outer_relids,
654-
old_rinfo->nullable_relids);
648+
if (and_clause((Node*)new_clause))
649+
{
650+
ListCell*alc;
651+
652+
foreach(alc, ((BoolExpr*)new_clause)->args)
653+
{
654+
Node*arg= (Node*)lfirst(alc);
655+
RestrictInfo*new_rinfo=rebuild_restrictinfo(arg,old_rinfo);
656+
657+
change_varnos((Node*)new_rinfo,rel->relid,childrel->relid);
658+
childrel->baserestrictinfo=lappend(childrel->baserestrictinfo,
659+
new_rinfo);
660+
}
661+
}
662+
else
663+
{
664+
RestrictInfo*new_rinfo=rebuild_restrictinfo(new_clause,old_rinfo);
655665

656-
/* Replace old relids with new ones */
657-
change_varnos((Node*)new_rinfo,rel->relid,childrel->relid);
666+
/* Replace old relids with new ones */
667+
change_varnos((Node*)new_rinfo,rel->relid,childrel->relid);
658668

659-
childrel->baserestrictinfo=lappend(childrel->baserestrictinfo,
660-
(void*)new_rinfo);
669+
childrel->baserestrictinfo=lappend(childrel->baserestrictinfo,
670+
(void*)new_rinfo);
671+
}
661672
}
662673

663674
/* Build an AppendRelInfo for this parent and child */
@@ -707,6 +718,19 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
707718
returnchildRTindex;
708719
}
709720

721+
/* Create new restriction based on clause */
722+
staticRestrictInfo*
723+
rebuild_restrictinfo(Node*clause,RestrictInfo*old_rinfo)
724+
{
725+
returnmake_restrictinfo((Expr*)clause,
726+
old_rinfo->is_pushed_down,
727+
old_rinfo->outerjoin_delayed,
728+
old_rinfo->pseudoconstant,
729+
old_rinfo->required_relids,
730+
old_rinfo->outer_relids,
731+
old_rinfo->nullable_relids);
732+
}
733+
710734
/* Convert wrapper into expression for given index */
711735
staticNode*
712736
wrapper_make_expression(WrapperNode*wrap,intindex,bool*alwaysTrue)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp