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

Function addRangeTableEntryForENR

src/backend/parser/parse_relation.c:2628–2725  ·  view source on GitHub ↗

* Add an entry for an ephemeral named relation reference to the pstate's * range table (p_rtable). * Then, construct and return a ParseNamespaceItem for the new RTE. * * It is expected that the RangeVar, which up until now is only known to be an * ephemeral named relation, will (in conjunction with the QueryEnvironment in * the ParseState), create a RangeTblEntry for a specific *kind* of eph

Source from the content-addressed store, hash-verified

2626 * ephemeral named relation.
2627 */
2628ParseNamespaceItem *
2629addRangeTableEntryForENR(ParseState *pstate,
2630 RangeVar *rv,
2631 bool inFromCl)
2632{
2633 RangeTblEntry *rte = makeNode(RangeTblEntry);
2634 Alias *alias = rv->alias;
2635 char *refname = alias ? alias->aliasname : rv->relname;
2636 EphemeralNamedRelationMetadata enrmd;
2637 TupleDesc tupdesc;
2638 int attno;
2639
2640 Assert(pstate != NULL);
2641 enrmd = get_visible_ENR(pstate, rv->relname);
2642 Assert(enrmd != NULL);
2643
2644 switch (enrmd->enrtype)
2645 {
2646 case ENR_NAMED_TUPLESTORE:
2647 rte->rtekind = RTE_NAMEDTUPLESTORE;
2648 break;
2649
2650 default:
2651 elog(ERROR, "unexpected enrtype: %d", enrmd->enrtype);
2652 return NULL; /* for fussy compilers */
2653 }
2654
2655 /*
2656 * Record dependency on a relation. This allows plans to be invalidated
2657 * if they access transition tables linked to a table that is altered.
2658 */
2659 rte->relid = enrmd->reliddesc;
2660
2661 /*
2662 * Build the list of effective column names using user-supplied aliases
2663 * and/or actual column names.
2664 */
2665 tupdesc = ENRMetadataGetTupDesc(enrmd);
2666 rte->eref = makeAlias(refname, NIL);
2667 buildRelationAliases(tupdesc, alias, rte->eref);
2668
2669 /* Record additional data for ENR, including column type info */
2670 rte->enrname = enrmd->name;
2671 rte->enrtuples = enrmd->enrtuples;
2672 rte->coltypes = NIL;
2673 rte->coltypmods = NIL;
2674 rte->colcollations = NIL;
2675 for (attno = 1; attno <= tupdesc->natts; ++attno)
2676 {
2677 Form_pg_attribute att = TupleDescAttr(tupdesc, attno - 1);
2678
2679 if (att->attisdropped)
2680 {
2681 /* Record zeroes for a dropped column */
2682 rte->coltypes = lappend_oid(rte->coltypes, InvalidOid);
2683 rte->coltypmods = lappend_int(rte->coltypmods, 0);
2684 rte->colcollations = lappend_oid(rte->colcollations, InvalidOid);
2685 }

Callers 2

register_delta_ENRsFunction · 0.85

Calls 9

get_visible_ENRFunction · 0.85
ENRMetadataGetTupDescFunction · 0.85
makeAliasFunction · 0.85
buildRelationAliasesFunction · 0.85
lappend_oidFunction · 0.85
lappend_intFunction · 0.85
lappendFunction · 0.85
buildNSItemFromTupleDescFunction · 0.85
list_lengthFunction · 0.85

Tested by

no test coverage detected