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

Function check_lateral_ref_ok

src/backend/parser/parse_relation.c:471–492  ·  view source on GitHub ↗

* Complain if a namespace item is currently disallowed as a LATERAL reference. * This enforces both SQL:2008's rather odd idea of what to do with a LATERAL * reference to the wrong side of an outer join, and our own prohibition on * referencing the target table of an UPDATE or DELETE as a lateral reference * in a FROM/USING clause. * * Note: the pstate should be the same query level the nsit

Source from the content-addressed store, hash-verified

469 * Convenience subroutine to avoid multiple copies of a rather ugly ereport.
470 */
471static void
472check_lateral_ref_ok(ParseState *pstate, ParseNamespaceItem *nsitem,
473 int location)
474{
475 if (nsitem->p_lateral_only && !nsitem->p_lateral_ok)
476 {
477 /* SQL:2008 demands this be an error, not an invisible item */
478 RangeTblEntry *rte = nsitem->p_rte;
479 char *refname = nsitem->p_names->aliasname;
480
481 ereport(ERROR,
482 (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
483 errmsg("invalid reference to FROM-clause entry for table \"%s\"",
484 refname),
485 (pstate->p_target_nsitem != NULL &&
486 rte == pstate->p_target_nsitem->p_rte) ?
487 errhint("There is an entry for table \"%s\", but it cannot be referenced from this part of the query.",
488 refname) :
489 errdetail("The combining JOIN type must be INNER or LEFT for a LATERAL reference."),
490 parser_errposition(pstate, location)));
491 }
492}
493
494/*
495 * Given an RT index and nesting depth, find the corresponding

Callers 3

scanNameSpaceForRefnameFunction · 0.85
scanNameSpaceForRelidFunction · 0.85
colNameToVarFunction · 0.85

Calls 5

parser_errpositionFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errhintFunction · 0.50
errdetailFunction · 0.50

Tested by

no test coverage detected