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

Function get_rte_attribute_is_dropped

src/backend/parser/parse_relation.c:3545–3680  ·  view source on GitHub ↗

* get_rte_attribute_is_dropped * Check whether attempted attribute ref is to a dropped column */

Source from the content-addressed store, hash-verified

3543 * Check whether attempted attribute ref is to a dropped column
3544 */
3545bool
3546get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
3547{
3548 bool result;
3549
3550 switch (rte->rtekind)
3551 {
3552 case RTE_RELATION:
3553 {
3554 /*
3555 * Plain relation RTE --- get the attribute's catalog entry
3556 */
3557 HeapTuple tp;
3558 Form_pg_attribute att_tup;
3559
3560 tp = SearchSysCache2(ATTNUM,
3561 ObjectIdGetDatum(rte->relid),
3562 Int16GetDatum(attnum));
3563 if (!HeapTupleIsValid(tp)) /* shouldn't happen */
3564 elog(ERROR, "cache lookup failed for attribute %d of relation %u",
3565 attnum, rte->relid);
3566 att_tup = (Form_pg_attribute) GETSTRUCT(tp);
3567 result = att_tup->attisdropped;
3568 ReleaseSysCache(tp);
3569 }
3570 break;
3571 case RTE_SUBQUERY:
3572 case RTE_TABLEFUNC:
3573 case RTE_VALUES:
3574 case RTE_CTE:
3575
3576 /*
3577 * Subselect, Table Functions, Values, CTE RTEs never have dropped
3578 * columns
3579 */
3580 result = false;
3581 break;
3582 case RTE_NAMEDTUPLESTORE:
3583 {
3584 /* Check dropped-ness by testing for valid coltype */
3585 if (attnum <= 0 ||
3586 attnum > list_length(rte->coltypes))
3587 elog(ERROR, "invalid varattno %d", attnum);
3588 result = !OidIsValid((list_nth_oid(rte->coltypes, attnum - 1)));
3589 }
3590 break;
3591 case RTE_JOIN:
3592 {
3593 /*
3594 * A join RTE would not have dropped columns when constructed,
3595 * but one in a stored rule might contain columns that were
3596 * dropped from the underlying tables, if said columns are
3597 * nowhere explicitly referenced in the rule. This will be
3598 * signaled to us by a null pointer in the joinaliasvars list.
3599 */
3600 Var *aliasvar;
3601
3602 if (attnum <= 0 ||

Callers 1

AcquireRewriteLocksFunction · 0.85

Calls 11

SearchSysCache2Function · 0.85
ObjectIdGetDatumFunction · 0.85
Int16GetDatumFunction · 0.85
ReleaseSysCacheFunction · 0.85
list_lengthFunction · 0.85
list_nth_oidFunction · 0.85
list_nthFunction · 0.85
get_expr_result_tupdescFunction · 0.85
foreachFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected