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

Function scanNameSpaceForCTE

src/backend/parser/parse_relation.c:267–291  ·  view source on GitHub ↗

* Search the query's CTE namespace for a CTE matching the given unqualified * refname. Return the CTE (and its levelsup count) if a match, or NULL * if no match. We need not worry about multiple matches, since parse_cte.c * rejects WITH lists containing duplicate CTE names. */

Source from the content-addressed store, hash-verified

265 * rejects WITH lists containing duplicate CTE names.
266 */
267CommonTableExpr *
268scanNameSpaceForCTE(ParseState *pstate, const char *refname,
269 Index *ctelevelsup)
270{
271 Index levelsup;
272
273 for (levelsup = 0;
274 pstate != NULL;
275 pstate = pstate->parentParseState, levelsup++)
276 {
277 ListCell *lc;
278
279 foreach(lc, pstate->p_ctenamespace)
280 {
281 CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc);
282
283 if (strcmp(cte->ctename, refname) == 0)
284 {
285 *ctelevelsup = levelsup;
286 return cte;
287 }
288 }
289 }
290 return NULL;
291}
292
293/*
294 * Search for a possible "future CTE", that is one that is not yet in scope

Callers 2

searchRangeTableForRelFunction · 0.85

Calls 1

foreachFunction · 0.50

Tested by

no test coverage detected