8000 Merge branch 'selection_handler' into piggyback_master · mpws2013n1/postgres@0dbd50a · GitHub
[go: up one dir, main page]

Skip to content

Commit 0dbd50a

Browse files
committed
Merge branch 'selection_handler' into piggyback_master
2 parents cf31f6e + 5973072 commit 0dbd50a

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

src/backend/executor/execProcnode.c

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,32 +176,44 @@ ExecInitNode(Plan *node, EState *estate, int eflags) {
176176
break;
177177

178178
case T_ModifyTable:
179+
oids = piggyback->tableOids;
179180
result = (PlanState *) ExecInitModifyTable((ModifyTable *) node, estate,
180181
eflags);
182+
InvalidateStatisticsForTables(oids);
181183
break;
182184

183185
case T_Append:
186+
oids = piggyback->tableOids;
184187
result = (PlanState *) ExecInitAppend((Append *) node, estate, eflags);
188+
InvalidateStatisticsForTables(oids);
185189
break;
186190

187191
case T_MergeAppend:
192+
oids = piggyback->tableOids;
188193
result = (PlanState *) ExecInitMergeAppend((MergeAppend *) node, estate,
189194
eflags);
195+
InvalidateStatisticsForTables(oids);
190196
break;
191197

192198
case T_RecursiveUnion:
199+
oids = piggyback->tableOids;
193200
result = (PlanState *) ExecInitRecursiveUnion((RecursiveUnion *) node,
194201
estate, eflags);
202+
InvalidateStatisticsForTables(oids);
195203
break;
196204

197205
case T_BitmapAnd:
206+
oids = piggyback->tableOids;
198207
result = (PlanState *) ExecInitBitmapAnd((BitmapAnd *) node, estate,
199208
eflags);
209+
InvalidateStatisticsForTables(oids);
200210
break;
201211

202212
case T_BitmapOr:
213+
oids = piggyback->tableOids;
203214
result = (PlanState *) ExecInitBitmapOr((BitmapOr *) node, estate,
204215
eflags);
216+
InvalidateStatisticsForTables(oids);
205217
break;
206218

207219
/*
@@ -354,12 +366,16 @@ ExecInitNode(Plan *node, EState *estate, int eflags) {
354366

355367
// we do not want to invalid the statistic values, because they do not change the values from the original tables
356368
case T_Agg:
369+
oids = piggyback->tableOids;
357370
result = (PlanState *) ExecInitAgg((Agg *) node, estate, eflags);
371+
InvalidateStatisticsForTables(oids);
358372
break;
359373

360374
case T_WindowAgg:
375+
oids = piggyback->tableOids;
361376
result = (PlanState *) ExecInitWindowAgg((WindowAgg *) node, estate,
362377
eflags);
378+
InvalidateStatisticsForTables(oids);
363379
break;
364380

365381
case T_Unique:
@@ -380,7 +396,9 @@ ExecInitNode(Plan *node, EState *estate, int eflags) {
380396
break;
381397

382398
case T_Limit:
399+
oids = piggyback->tableOids;
383400
result = (PlanState *) ExecInitLimit((Limit *) node, estate, eflags);
401+
InvalidateStatisticsForTables(oids);
384402
break;
385403

386404
default:
@@ -416,11 +434,29 @@ void
416434
InvalidateStatisticsForTables(List* oldTableOids)
417435
{
418436
List* relevantTableOids = NULL;
419-
ListCell* l;
420-
relevantTableOids = list_difference(piggyback->tableOids, oldTableOids);
421-
foreach (l, relevantTableOids)
437+
ListCell* l1;
438+
ListCell* l2;
439+
//relevantTableOids = list_difference(piggyback->tableOids, oldTableOids);
440+
foreach(l1, piggyback->tableOids)
441+
{
442+
int isNewOid = 1;
443+
foreach(l2, oldTableOids)
444+
{
445+
if (*((int*)lfirst(l1)) == *((int*)lfirst(l2)))
446+
{
447+
isNewOid = 0;
448+
break;
449+
}
450+
}
451+
if (isNewOid == 1)
452+
{
453+
relevantTableOids = lappend(relevantTableOids, (int*)lfirst(l1));
454+
}
455+
}
456+
457+
foreach (l1, relevantTableOids)
422458
{
423-
int currentOid = *((int*)lfirst(l));
459+
int currentOid = *((int*)lfirst(l1));
424460
InvalidateStatisticsForTable(currentOid);
425461
}
426462
}
@@ -530,6 +566,9 @@ LookForFilterWithEquality(PlanState* result, Oid tableOid, List* qual)
530566
break;
531567
}
532568

569+
// invalid all columns of this table, because there is a selection
570+
InvalidateStatisticsForTable(tableOid);
571+
533572
// the magic numbers are operator identifiers from posgres/src/include/catalog/pg_operator.h
534573
// equals
535574
if(opno == 94 || opno == 96 || opno == 410 || opno == 416 || opno == 1862 || opno == 1868 || opno == 15 || opno == 532 || opno == 533) { // it is a equality like number_of_tracks = 3
@@ -590,7 +629,7 @@ LookForFilterWithEquality(PlanState* result, Oid tableOid, List* qual)
590629
else {
591630
printf("this opno is no =, <, >, <= or >=: %d (for column id %d)\n", opno, columnId);
592631
// found a selection, therefore we cannot use old statistics
593-
InvalidateStatisticsForTable(tableOid);
632+
// InvalidateStatisticsForTable(tableOid); (this has to be always, because there could be more than one column of this table in the result
594633
}
595634
}
596635
}

0 commit comments

Comments
 (0)
0