Skip to content

Commit 3f8e418

Browse files
akorotkovzilder
authored andcommitted
Works in simple case.
1 parent 03f73fa commit 3f8e418

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

contrib/pathman/pathman.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
297297
PartRelationInfo *prel;
298298

299299
Node *node;
300-
ListCell *lc;
300+
ListCell *lc, *lc2;
301301

302302
prel = (PartRelationInfo *)
303303
hash_search(relations, (const void *) &rte->relid, HASH_FIND, 0);
@@ -328,18 +328,24 @@ append_child_relation(PlannerInfo *root, RelOptInfo *rel, Index rti,
328328

329329
/* copy restrictions */
330330
childrel->baserestrictinfo = NIL;
331-
foreach(lc, wrappers)
331+
forboth(lc, wrappers, lc2, rel->baserestrictinfo)
332332
{
333333
bool alwaysTrue;
334334
WrapperNode *wrap = (WrapperNode *) lfirst(lc);
335-
Node *new_rinfo = wrapper_make_expression(wrap, index, &alwaysTrue);
335+
Node *new_clause = wrapper_make_expression(wrap, index, &alwaysTrue);
336+
RestrictInfo *new_rinfo;
336337

337338
if (alwaysTrue)
338339
continue;
339-
Assert(new_rinfo);
340+
Assert(new_clause);
341+
342+
/* TODO: evade double copy of clause */
343+
344+
new_rinfo = copyObject((Node *) lfirst(lc2));
345+
new_rinfo->clause = (Expr *)new_clause;
340346

341347
/* replace old relids with new ones */
342-
change_varnos(new_rinfo, rel->relid, childrel->relid);
348+
change_varnos((Node *)new_rinfo, rel->relid, childrel->relid);
343349

344350
childrel->baserestrictinfo = lappend(childrel->baserestrictinfo,
345351
new_rinfo);
@@ -380,20 +386,24 @@ wrapper_make_expression(WrapperNode *wrap, int index, bool *alwaysTrue)
380386
if (expr->boolop == OR_EXPR || expr->boolop == AND_EXPR)
381387
{
382388
ListCell *lc;
383-
List *args;
389+
List *args = NIL;
384390

385391
foreach (lc, wrap->args)
386392
{
387393
Node *arg;
388394

389395
arg = wrapper_make_expression((WrapperNode *)lfirst(lc), index, alwaysTrue);
390-
Assert(!(*alwaysTrue));
391-
Assert(arg || *alwaysTrue);
396+
#ifdef USE_ASSERT_CHECKING
397+
if (expr->boolop == OR_EXPR)
398+
Assert(!(*alwaysTrue));
399+
if (expr->boolop == AND_EXPR)
400+
Assert(arg || *alwaysTrue);
401+
#endif
392402
if (arg)
393403
args = lappend(args, arg);
394404
}
395405

396-
Assert(list_length(args) > 1);
406+
Assert(list_length(args) >= 1);
397407
if (list_length(args) == 1)
398408
return (Node *) linitial(args);
399409

contrib/pathman/rangeset.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,25 @@ irange_list_union(List *a, List *b)
5050
if (ca && cb)
5151
{
5252
if (irange_lower(lfirst_irange(ca)) <= irange_lower(lfirst_irange(cb)))
53+
{
5354
next = lfirst_irange(ca);
55+
ca = lnext(ca);
56+
}
5457
else
58+
{
5559
next = lfirst_irange(cb);
60+
cb = lnext(cb);
61+
}
5662
}
5763
else if (ca)
5864
{
5965
next = lfirst_irange(ca);
66+
ca = lnext(ca);
6067
}
6168
else if (cb)
6269
{
6370
next = lfirst_irange(cb);
71+
cb = lnext(cb);
6472
}
6573

6674
if (!have_cur)

0 commit comments

Comments
 (0)