| Line | Hits | Source | Commit |
|---|---|---|---|
| 2468 | - | create_windowagg_plan(PlannerInfo *root, WindowAggPath *best_path) | - |
| 2469 | - | { | - |
| 2470 | - | WindowAgg *plan; | - |
| 2471 | - | WindowClause *wc = best_path->winclause; | - |
| 2472 | - | int numPart = list_length(wc->partitionClause); | - |
| 2473 | - | int numOrder = list_length(wc->orderClause); | - |
| 2474 | - | Plan *subplan; | - |
| 2475 | - | List *tlist; | - |
| 2476 | - | int partNumCols; | - |
| 2477 | - | AttrNumber *partColIdx; | - |
| 2478 | - | Oid *partOperators; | - |
| 2479 | - | Oid *partCollations; | - |
| 2480 | - | int ordNumCols; | - |
| 2481 | - | AttrNumber *ordColIdx; | - |
| 2482 | - | Oid *ordOperators; | - |
| 2483 | - | Oid *ordCollations; | - |
| 2484 | - | ListCell *lc; | - |
| 2485 | - | - | |
| 2486 | - | /* | - |
| 2487 | - | * Choice of tlist here is motivated by the fact that WindowAgg will be | - |
| 2488 | - | * storing the input rows of window frames in a tuplestore; it therefore | - |
| 2489 | - | * behooves us to request a small tlist to avoid wasting space. We do of | - |
| 2490 | - | * course need grouping columns to be available. | - |
| 2491 | - | */ | - |
| 2492 | - | subplan = create_plan_recurse(root, best_path->subpath, | - |
| 2493 | - | CP_LABEL_TLIST | CP_SMALL_TLIST); | - |
| 2494 | - | - | |
| 2495 | - | tlist = build_path_tlist(root, &best_path->path); | - |
| 2496 | - | - | |
| 2497 | - | /* | - |
| 2498 | - | * Convert SortGroupClause lists into arrays of attr indexes and equality | - |
| 2499 | - | * operators, as wanted by executor. | - |
| 2500 | - | */ | - |
| 2501 | - | partColIdx = palloc_array(AttrNumber, numPart); | - |
| 2502 | - | partOperators = palloc_array(Oid, numPart); | - |
| 2503 | - | partCollations = palloc_array(Oid, numPart); | - |
| 2504 | - | - | |
| 2505 | - | partNumCols = 0; | - |
| 2506 | - | foreach(lc, wc->partitionClause) | - |
| 2507 | - | { | - |
| 2508 | - | SortGroupClause *sgc = (SortGroupClause *) lfirst(lc); | - |
| 2509 | - | TargetEntry *tle = get_sortgroupclause_tle(sgc, subplan->targetlist); | - |
| 2510 | - | - | |
| 2511 | - | Assert(OidIsValid(sgc->eqop)); | - |
| 2512 | - | partColIdx[partNumCols] = tle->resno; | - |
| 2513 | - | partOperators[partNumCols] = sgc->eqop; | - |
| 2514 | - | partCollations[partNumCols] = exprCollation((Node *) tle->expr); | - |
| 2515 | - | partNumCols++; | - |
| 2516 | - | } | - |
| 2517 | - | - | |
| 2518 | - | ordColIdx = palloc_array(AttrNumber, numOrder); | - |
| 2519 | - | ordOperators = palloc_array(Oid, numOrder); | - |
| 2520 | - | ordCollations = palloc_array(Oid, numOrder); | - |
| 2521 | - | - | |
| 2522 | - | ordNumCols = 0; | - |
| 2523 | - | foreach(lc, wc->orderClause) | - |
| 2524 | - | { | - |
| 2525 | - | SortGroupClause *sgc = (SortGroupClause *) lfirst(lc); | - |
| 2526 | - | TargetEntry *tle = get_sortgroupclause_tle(sgc, subplan->targetlist); | - |
| 2527 | - | - | |
| 2528 | - | Assert(OidIsValid(sgc->eqop)); | - |
| 2529 | - | ordColIdx[ordNumCols] = tle->resno; | - |
| 2530 | - | ordOperators[ordNumCols] = sgc->eqop; | - |
| 2531 | - | ordCollations[ordNumCols] = exprCollation((Node *) tle->expr); | - |
| 2532 | - | ordNumCols++; | - |
| 2533 | - | } | - |
| 2534 | - | - | |
| 2535 | - | /* And finally we can make the WindowAgg node */ | - |
| 2536 | - | plan = make_windowagg(tlist, | - |
| 2537 | - | wc, | - |
| 2538 | - | partNumCols, | - |
| 2539 | - | partColIdx, | - |
| 2540 | - | partOperators, | - |
| 2541 | - | partCollations, | - |
| 2542 | - | ordNumCols, | - |
| 2543 | - | ordColIdx, | - |
| 2544 | - | ordOperators, | - |
| 2545 | - | ordCollations, | - |
| 2546 | - | best_path->runCondition, | - |
| 2547 | - | wc->rpSkipTo, | e33632aRow pattern recognition patch (planner). |
| 2548 | - | wc->patternVariable, | e33632aRow pattern recognition patch (planner). |
| 2549 | - | wc->patternRegexp, | e33632aRow pattern recognition patch (planner). |
| 2550 | - | wc->defineClause, | e33632aRow pattern recognition patch (planner). |
| 2551 | - | wc->defineInitial, | e33632aRow pattern recognition patch (planner). |
| 2552 | - | best_path->qual, | - |
| 2553 | - | best_path->topwindow, | - |
| 2554 | - | subplan); | - |
| 2555 | - | - | |
| 2556 | - | copy_generic_path_info(&plan->plan, (Path *) best_path); | - |
| 2557 | - | - | |
| 2558 | - | return plan; | - |
| 2559 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 6611 | - | make_windowagg(List *tlist, WindowClause *wc, | - |
| 6612 | - | int partNumCols, AttrNumber *partColIdx, Oid *partOperators, Oid *partCollations, | - |
| 6613 | - | int ordNumCols, AttrNumber *ordColIdx, Oid *ordOperators, Oid *ordCollations, | - |
| 6614 | - | List *runCondition, RPSkipTo rpSkipTo, List *patternVariable, | e33632aRow pattern recognition patch (planner). |
| 6615 | - | List *patternRegexp, List *defineClause, List *defineInitial, | e33632aRow pattern recognition patch (planner). |
| 6616 | - | List *qual, bool topWindow, Plan *lefttree) | e33632aRow pattern recognition patch (planner). |
| 6617 | - | { | - |
| 6618 | - | WindowAgg *node = makeNode(WindowAgg); | - |
| 6619 | - | Plan *plan = &node->plan; | - |
| 6620 | - | - | |
| 6621 | - | node->winname = wc->name; | - |
| 6622 | - | node->winref = wc->winref; | - |
| 6623 | - | node->partNumCols = partNumCols; | - |
| 6624 | - | node->partColIdx = partColIdx; | - |
| 6625 | - | node->partOperators = partOperators; | - |
| 6626 | - | node->partCollations = partCollations; | - |
| 6627 | - | node->ordNumCols = ordNumCols; | - |
| 6628 | - | node->ordColIdx = ordColIdx; | - |
| 6629 | - | node->ordOperators = ordOperators; | - |
| 6630 | - | node->ordCollations = ordCollations; | - |
| 6631 | - | node->frameOptions = wc->frameOptions; | - |
| 6632 | - | node->startOffset = wc->startOffset; | - |
| 6633 | - | node->endOffset = wc->endOffset; | - |
| 6634 | - | node->runCondition = runCondition; | - |
| 6635 | - | /* a duplicate of the above for EXPLAIN */ | - |
| 6636 | - | node->runConditionOrig = runCondition; | - |
| 6637 | - | node->startInRangeFunc = wc->startInRangeFunc; | - |
| 6638 | - | node->endInRangeFunc = wc->endInRangeFunc; | - |
| 6639 | - | node->inRangeColl = wc->inRangeColl; | - |
| 6640 | - | node->inRangeAsc = wc->inRangeAsc; | - |
| 6641 | - | node->inRangeNullsFirst = wc->inRangeNullsFirst; | - |
| 6642 | - | node->topWindow = topWindow; | - |
| 6643 | 1453 | node->rpSkipTo = rpSkipTo; | e33632aRow pattern recognition patch (planner). |
| 6644 | 1453 | node->patternVariable = patternVariable; | e33632aRow pattern recognition patch (planner). |
| 6645 | 1453 | node->patternRegexp = patternRegexp; | e33632aRow pattern recognition patch (planner). |
| 6646 | 1453 | node->defineClause = defineClause; | e33632aRow pattern recognition patch (planner). |
| 6647 | 1453 | node->defineInitial = defineInitial; | e33632aRow pattern recognition patch (planner). |
| 6648 | - | - | |
| 6649 | - | plan->targetlist = tlist; | - |
| 6650 | - | plan->lefttree = lefttree; | - |
| 6651 | - | plan->righttree = NULL; | - |
| 6652 | - | plan->qual = qual; | - |
| 6653 | - | - | |
| 6654 | - | return node; | - |
| 6655 | - | } | - |