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

Function buildNSItemFromLists

src/backend/parser/parse_relation.c:1306–1356  ·  view source on GitHub ↗

* buildNSItemFromLists * Build a ParseNamespaceItem, given column type information in lists. * * rte: the new RangeTblEntry for the rel * rtindex: its index in the rangetable list * coltypes: per-column datatype OIDs * coltypmods: per-column type modifiers * colcollation: per-column collation OIDs */

Source from the content-addressed store, hash-verified

1304 * colcollation: per-column collation OIDs
1305 */
1306static ParseNamespaceItem *
1307buildNSItemFromLists(RangeTblEntry *rte, Index rtindex,
1308 List *coltypes, List *coltypmods, List *colcollations)
1309{
1310 ParseNamespaceItem *nsitem;
1311 ParseNamespaceColumn *nscolumns;
1312 int maxattrs = list_length(coltypes);
1313 int varattno;
1314 ListCell *lct;
1315 ListCell *lcm;
1316 ListCell *lcc;
1317
1318 /* colnames must have the same number of entries as the nsitem */
1319 Assert(maxattrs == list_length(rte->eref->colnames));
1320
1321 Assert(maxattrs == list_length(coltypmods));
1322 Assert(maxattrs == list_length(colcollations));
1323
1324 /* extract per-column data from the lists */
1325 nscolumns = (ParseNamespaceColumn *)
1326 palloc0(maxattrs * sizeof(ParseNamespaceColumn));
1327
1328 varattno = 0;
1329 forthree(lct, coltypes,
1330 lcm, coltypmods,
1331 lcc, colcollations)
1332 {
1333 nscolumns[varattno].p_varno = rtindex;
1334 nscolumns[varattno].p_varattno = varattno + 1;
1335 nscolumns[varattno].p_vartype = lfirst_oid(lct);
1336 nscolumns[varattno].p_vartypmod = lfirst_int(lcm);
1337 nscolumns[varattno].p_varcollid = lfirst_oid(lcc);
1338 nscolumns[varattno].p_varnosyn = rtindex;
1339 nscolumns[varattno].p_varattnosyn = varattno + 1;
1340 varattno++;
1341 }
1342
1343 /* ... and build the nsitem */
1344 nsitem = (ParseNamespaceItem *) palloc(sizeof(ParseNamespaceItem));
1345 nsitem->p_names = rte->eref;
1346 nsitem->p_rte = rte;
1347 nsitem->p_rtindex = rtindex;
1348 nsitem->p_nscolumns = nscolumns;
1349 /* set default visibility flags; might get changed later */
1350 nsitem->p_rel_visible = true;
1351 nsitem->p_cols_visible = true;
1352 nsitem->p_lateral_only = false;
1353 nsitem->p_lateral_ok = true;
1354
1355 return nsitem;
1356}
1357
1358/*
1359 * Open a table during parse analysis

Calls 3

list_lengthFunction · 0.85
palloc0Function · 0.50
pallocFunction · 0.50

Tested by

no test coverage detected