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

Function addRangeTableEntryForValues

src/backend/parser/parse_relation.c:2277–2356  ·  view source on GitHub ↗

* Add an entry for a VALUES list to the pstate's range table (p_rtable). * Then, construct and return a ParseNamespaceItem for the new RTE. * * This is much like addRangeTableEntry() except that it makes a values RTE. */

Source from the content-addressed store, hash-verified

2275 * This is much like addRangeTableEntry() except that it makes a values RTE.
2276 */
2277ParseNamespaceItem *
2278addRangeTableEntryForValues(ParseState *pstate,
2279 List *exprs,
2280 List *coltypes,
2281 List *coltypmods,
2282 List *colcollations,
2283 Alias *alias,
2284 bool lateral,
2285 bool inFromCl)
2286{
2287 RangeTblEntry *rte = makeNode(RangeTblEntry);
2288 char *refname = alias ? alias->aliasname : pstrdup("*VALUES*");
2289 Alias *eref;
2290 int numaliases;
2291 int numcolumns;
2292
2293 Assert(pstate != NULL);
2294
2295 rte->rtekind = RTE_VALUES;
2296 rte->relid = InvalidOid;
2297 rte->subquery = NULL;
2298 rte->values_lists = exprs;
2299 rte->coltypes = coltypes;
2300 rte->coltypmods = coltypmods;
2301 rte->colcollations = colcollations;
2302 rte->alias = alias;
2303
2304 eref = alias ? copyObject(alias) : makeAlias(refname, NIL);
2305
2306 /* fill in any unspecified alias columns */
2307 numcolumns = list_length((List *) linitial(exprs));
2308 numaliases = list_length(eref->colnames);
2309 while (numaliases < numcolumns)
2310 {
2311 char attrname[64];
2312
2313 numaliases++;
2314 snprintf(attrname, sizeof(attrname), "column%d", numaliases);
2315 eref->colnames = lappend(eref->colnames,
2316 makeString(pstrdup(attrname)));
2317 }
2318 if (numcolumns < numaliases)
2319 ereport(ERROR,
2320 (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2321 errmsg("VALUES lists \"%s\" have %d columns available but %d columns specified",
2322 refname, numcolumns, numaliases)));
2323
2324 rte->eref = eref;
2325
2326 /*
2327 * Set flags and access permissions.
2328 *
2329 * Subqueries are never checked for access rights.
2330 */
2331 rte->lateral = lateral;
2332 rte->inh = false; /* never true for values RTEs */
2333 rte->inFromCl = inFromCl;
2334

Callers 2

transformInsertStmtFunction · 0.85
transformValuesClauseFunction · 0.85

Calls 8

makeAliasFunction · 0.85
list_lengthFunction · 0.85
lappendFunction · 0.85
makeStringFunction · 0.85
buildNSItemFromListsFunction · 0.85
pstrdupFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected