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

Function ExecTypeSetColNames

src/backend/executor/execTuples.c:2046–2077  ·  view source on GitHub ↗

* ExecTypeSetColNames - set column names in a RECORD TupleDesc * * Column names must be provided as an alias list (list of String nodes). */

Source from the content-addressed store, hash-verified

2044 * Column names must be provided as an alias list (list of String nodes).
2045 */
2046void
2047ExecTypeSetColNames(TupleDesc typeInfo, List *namesList)
2048{
2049 int colno = 0;
2050 ListCell *lc;
2051
2052 /* It's only OK to change col names in a not-yet-blessed RECORD type */
2053 Assert(typeInfo->tdtypeid == RECORDOID);
2054 Assert(typeInfo->tdtypmod < 0);
2055
2056 foreach(lc, namesList)
2057 {
2058 char *cname = strVal(lfirst(lc));
2059 Form_pg_attribute attr;
2060
2061 /* Guard against too-long names list (probably can't happen) */
2062 if (colno >= typeInfo->natts)
2063 break;
2064 attr = TupleDescAttr(typeInfo, colno);
2065 colno++;
2066
2067 /*
2068 * Do nothing for empty aliases or dropped columns (these cases
2069 * probably can't arise in RECORD types, either)
2070 */
2071 if (cname[0] == '\0' || attr->attisdropped)
2072 continue;
2073
2074 /* OK, assign the column name */
2075 namestrcpy(&(attr->attname), cname);
2076 }
2077}
2078
2079/*
2080 * BlessTupleDesc - make a completed tuple descriptor useful for SRFs

Callers 2

ExecEvalWholeRowVarFunction · 0.85
ExecInitExprRecFunction · 0.85

Calls 2

namestrcpyFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected