--------------------------------------------------------------------------- @function: COptTasks::GetPlanHints @doc: Generate an instance of plan hints by parsing the query tree. ---------------------------------------------------------------------------
| 644 | // |
| 645 | //--------------------------------------------------------------------------- |
| 646 | CPlanHint * |
| 647 | COptTasks::GetPlanHints(CMemoryPool *mp, Query *query) |
| 648 | { |
| 649 | HintState *hintstate = nullptr; |
| 650 | if (plan_hint_hook != nullptr) |
| 651 | { |
| 652 | // Calling plan_hint_hook creates pg_hint_plan hint structures |
| 653 | // (see optimizer/hints.h). |
| 654 | hintstate = (HintState *) plan_hint_hook(query); |
| 655 | if (hintstate != nullptr && hintstate->log_level > 0) |
| 656 | { |
| 657 | GPOS_SET_TRACE(EopttracePrintPgHintPlanLog); |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | if (nullptr == hintstate) |
| 662 | { |
| 663 | return nullptr; |
| 664 | } |
| 665 | |
| 666 | // Following code translates pg_hint_plan hint structures into ORCA hint |
| 667 | // structures (see gpopt/hints/CPlanHint.h). |
| 668 | |
| 669 | CPlanHint *plan_hints = GPOS_NEW(mp) CPlanHint(mp); |
| 670 | |
| 671 | // Translate ScanMethodHint => CScanHint |
| 672 | for (int ul = 0; ul < hintstate->num_hints[HINT_TYPE_SCAN_METHOD]; ul++) |
| 673 | { |
| 674 | ScanMethodHint *scan_hint = |
| 675 | (ScanMethodHint *) hintstate->scan_hints[ul]; |
| 676 | if (nullptr == scan_hint->relname) |
| 677 | { |
| 678 | continue; |
| 679 | } |
| 680 | |
| 681 | CScanHint::EType type = CScanHint::Sentinal; |
| 682 | switch (scan_hint->base.hint_keyword) |
| 683 | { |
| 684 | case HINT_KEYWORD_SEQSCAN: |
| 685 | { |
| 686 | type = CScanHint::SeqScan; |
| 687 | break; |
| 688 | } |
| 689 | case HINT_KEYWORD_NOSEQSCAN: |
| 690 | { |
| 691 | type = CScanHint::NoSeqScan; |
| 692 | break; |
| 693 | } |
| 694 | case HINT_KEYWORD_INDEXSCAN: |
| 695 | { |
| 696 | type = CScanHint::IndexScan; |
| 697 | break; |
| 698 | } |
| 699 | case HINT_KEYWORD_NOINDEXSCAN: |
| 700 | { |
| 701 | type = CScanHint::NoIndexScan; |
| 702 | break; |
| 703 | } |
nothing calls this directly
no test coverage detected