MCPcopy Create free account
hub / github.com/apache/cloudberry / ExplainTargetRel

Function ExplainTargetRel

src/backend/commands/explain.c:4768–4926  ·  view source on GitHub ↗

* Show the target relation of a scan or modify node */

Source from the content-addressed store, hash-verified

4766 * Show the target relation of a scan or modify node
4767 */
4768static void
4769ExplainTargetRel(Plan *plan, Index rti, ExplainState *es)
4770{
4771 char *objectname = NULL;
4772 char *namespace = NULL;
4773 const char *objecttag = NULL;
4774 RangeTblEntry *rte;
4775 char *refname;
4776 int dynamicScanId = 0;
4777
4778 rte = rt_fetch(rti, es->rtable);
4779 refname = (char *) list_nth(es->rtable_names, rti - 1);
4780 if (refname == NULL)
4781 refname = rte->eref->aliasname;
4782
4783 switch (nodeTag(plan))
4784 {
4785 case T_SeqScan:
4786 case T_DynamicSeqScan:
4787 case T_SampleScan:
4788 case T_IndexScan:
4789 case T_DynamicIndexScan:
4790 case T_DynamicIndexOnlyScan:
4791 case T_IndexOnlyScan:
4792 case T_BitmapHeapScan:
4793 case T_DynamicBitmapHeapScan:
4794 case T_TidScan:
4795 case T_TidRangeScan:
4796 case T_ForeignScan:
4797 case T_DynamicForeignScan:
4798 case T_CustomScan:
4799 case T_ModifyTable:
4800 /* Assert it's on a real relation */
4801 Assert(rte->rtekind == RTE_RELATION);
4802 objectname = get_rel_name(rte->relid);
4803 if (es->verbose)
4804 namespace = get_namespace_name(get_rel_namespace(rte->relid));
4805 objecttag = "Relation Name";
4806 break;
4807 case T_FunctionScan:
4808 {
4809 FunctionScan *fscan = (FunctionScan *) plan;
4810
4811 /* Assert it's on a RangeFunction */
4812 Assert(rte->rtekind == RTE_FUNCTION);
4813
4814 /*
4815 * If the expression is still a function call of a single
4816 * function, we can get the real name of the function.
4817 * Otherwise, punt. (Even if it was a single function call
4818 * originally, the optimizer could have simplified it away.)
4819 */
4820 if (list_length(fscan->functions) == 1)
4821 {
4822 RangeTblFunction *rtfunc = (RangeTblFunction *) linitial(fscan->functions);
4823
4824 if (IsA(rtfunc->funcexpr, FuncExpr))
4825 {

Callers 3

ExplainScanTargetFunction · 0.85
ExplainModifyTargetFunction · 0.85
show_modifytable_infoFunction · 0.85

Calls 12

list_nthFunction · 0.85
get_rel_nameFunction · 0.85
get_namespace_nameFunction · 0.85
get_rel_namespaceFunction · 0.85
list_lengthFunction · 0.85
get_func_nameFunction · 0.85
get_func_namespaceFunction · 0.85
appendStringInfoStringFunction · 0.85
appendStringInfoFunction · 0.85
ExplainPropertyTextFunction · 0.85
ExplainPropertyIntegerFunction · 0.85
quote_identifierFunction · 0.50

Tested by

no test coverage detected