75 #define MAX_FUZZY_DISTANCE 3
87 const char *colname,
int location,
88 int fuzzy_rte_penalty,
93 int rtindex,
int sublevels_up,
94 int location,
bool include_dropped,
97 int count,
int offset,
98 int rtindex,
int sublevels_up,
99 int location,
bool include_dropped,
130 const char *schemaname,
140 if (schemaname != NULL)
160 while (pstate != NULL)
220 (
errcode(ERRCODE_AMBIGUOUS_ALIAS),
221 errmsg(
"table reference \"%s\" is ambiguous",
259 rte->
relid == relid &&
264 (
errcode(ERRCODE_AMBIGUOUS_ALIAS),
265 errmsg(
"table reference %u is ambiguous",
297 if (strcmp(cte->
ctename, refname) == 0)
299 *ctelevelsup = levelsup;
323 if (strcmp(cte->
ctename, refname) == 0)
358 const char *refname = relation->
relname;
362 Index ctelevelsup = 0;
405 strcmp(rte->
ctename, refname) == 0)
409 strcmp(rte->
enrname, refname) == 0)
439 foreach(l1, namespace1)
449 foreach(l2, namespace2)
457 if (strcmp(aliasname2, aliasname1) != 0)
464 (
errcode(ERRCODE_DUPLICATE_ALIAS),
465 errmsg(
"table name \"%s\" specified more than once",
493 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
494 errmsg(
"invalid reference to FROM-clause entry for table \"%s\"",
498 errhint(
"There is an entry for table \"%s\", but it cannot be referenced from this part of the query.",
500 errdetail(
"The combining JOIN type must be INNER or LEFT for a LATERAL reference."),
516 while (sublevels_up-- > 0)
528 elog(
ERROR,
"nsitem not found (internal error)");
541 while (sublevels_up-- > 0)
564 while (levelsup-- > 0)
589 const char *actual,
const char *match,
int attnum)
595 if (fuzzy_rte_penalty > fuzzystate->
distance)
602 if (actual[0] ==
'\0')
606 matchlen = strlen(match);
618 if (columndistance > matchlen / 2)
625 columndistance += fuzzy_rte_penalty;
631 if (columndistance < fuzzystate->distance)
634 fuzzystate->
distance = columndistance;
639 else if (columndistance == fuzzystate->
distance)
642 if (fuzzystate->
rsecond != NULL)
651 fuzzystate->
rfirst = NULL;
654 else if (fuzzystate->
rfirst != NULL)
681 int sublevels_up,
const char *colname,
int location)
702 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
703 errmsg(
"system column \"%s\" reference in check constraint is invalid",
711 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
712 errmsg(
"cannot use system column \"%s\" in column generation expression",
722 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
723 errmsg(
"cannot use system column \"%s\" in MERGE WHEN condition",
736 (
errcode(ERRCODE_UNDEFINED_COLUMN),
737 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
761 sysatt->attcollation,
802 const char *colname,
int location,
803 int fuzzy_rte_penalty,
828 if (strcmp(attcolname, colname) == 0)
832 (
errcode(ERRCODE_AMBIGUOUS_COLUMN),
833 errmsg(
"column reference \"%s\" is ambiguous",
840 if (fuzzystate != NULL)
842 rte, attcolname, colname,
attnum);
858 rte->
relkind != RELKIND_COMPOSITE_TYPE)
887 int sublevels_up = 0;
890 while (pstate != NULL)
914 (
errcode(ERRCODE_AMBIGUOUS_COLUMN),
915 errmsg(
"column reference \"%s\" is ambiguous",
923 if (result != NULL || localonly)
959 fuzzystate->
rfirst = NULL;
964 while (pstate != NULL)
971 int fuzzy_rte_penalty = 0;
1006 fuzzy_rte_penalty, fuzzystate);
1009 if (fuzzystate->
rexact1 == NULL)
1037 int rtindex = var->
varno;
1055 var->varnullingrels =
bms_union(var->varnullingrels, relids);
1097 elog(
ERROR,
"could not find JoinExpr for whole-row reference");
1108 int varno = ((
JoinExpr *)
j->larg)->rtindex;
1113 elog(
ERROR,
"unrecognized node type: %d",
1123 int varno = ((
JoinExpr *)
j->rarg)->rtindex;
1128 elog(
ERROR,
"unrecognized node type: %d",
1179 int maxattrs = tupdesc->
natts;
1203 for (varattno = 0; varattno < maxattrs; varattno++)
1208 if (attr->attisdropped)
1220 aliaslc =
lnext(aliaslist, aliaslc);
1235 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
1236 errmsg(
"table \"%s\" has %d columns available but %d columns specified",
1237 eref->
aliasname, maxattrs - numdropped, numaliases)));
1255 Alias *alias,
int nfuncs)
1275 if (nfuncs == 1 && alias)
1300 int maxattrs = tupdesc->
natts;
1310 for (varattno = 0; varattno < maxattrs; varattno++)
1315 if (attr->attisdropped)
1318 nscolumns[varattno].
p_varno = rtindex;
1319 nscolumns[varattno].
p_varattno = varattno + 1;
1320 nscolumns[varattno].
p_vartype = attr->atttypid;
1321 nscolumns[varattno].
p_vartypmod = attr->atttypmod;
1322 nscolumns[varattno].
p_varcollid = attr->attcollation;
1330 nsitem->
p_rte = rte;
1380 nscolumns[varattno].
p_varno = rtindex;
1381 nscolumns[varattno].
p_varattno = varattno + 1;
1393 nsitem->
p_rte = rte;
1430 errmsg(
"relation \"%s.%s\" does not exist",
1443 errmsg(
"relation \"%s\" does not exist",
1445 errdetail(
"There is a WITH item named \"%s\", but it cannot be referenced from this part of the query.",
1447 errhint(
"Use WITH RECURSIVE, or re-order the WITH items to remove forward references.")));
1451 errmsg(
"relation \"%s\" does not exist",
1664 coltypes = coltypmods = colcollations =
NIL;
1674 if (varattno > numaliases)
1678 attrname =
pstrdup(te->resname);
1688 if (varattno < numaliases)
1690 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
1691 errmsg(
"table \"%s\" has %d columns available but %d columns specified",
1692 eref->
aliasname, varattno, numaliases)));
1718 coltypes, coltypmods, colcollations);
1786 forthree(lc1, funcexprs, lc2, funcnames, lc3, coldeflists)
1797 rtfunc->funccolnames =
NIL;
1798 rtfunc->funccoltypes =
NIL;
1799 rtfunc->funccoltypmods =
NIL;
1800 rtfunc->funccolcollations =
NIL;
1801 rtfunc->funcparams = NULL;
1816 if (coldeflist !=
NIL)
1818 switch (functypclass)
1831 if (
exprType(funcexpr) == RECORDOID)
1833 (
errcode(ERRCODE_SYNTAX_ERROR),
1834 errmsg(
"a column definition list is redundant for a function with OUT parameters"),
1839 (
errcode(ERRCODE_SYNTAX_ERROR),
1840 errmsg(
"a column definition list is redundant for a function returning a named composite type"),
1846 (
errcode(ERRCODE_SYNTAX_ERROR),
1847 errmsg(
"a column definition list is only allowed for functions returning \"record\""),
1857 (
errcode(ERRCODE_SYNTAX_ERROR),
1858 errmsg(
"a column definition list is required for functions returning \"record\""),
1894 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1895 errmsg(
"column definition lists can have at most %d entries",
1901 foreach(col, coldeflist)
1912 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
1913 errmsg(
"column \"%s\" cannot be declared SETOF",
1917 &attrtype, &attrtypmod);
1928 rtfunc->funccolnames =
lappend(rtfunc->funccolnames,
1930 rtfunc->funccoltypes =
lappend_oid(rtfunc->funccoltypes,
1932 rtfunc->funccoltypmods =
lappend_int(rtfunc->funccoltypmods,
1934 rtfunc->funccolcollations =
lappend_oid(rtfunc->funccolcollations,
1954 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1955 errmsg(
"function \"%s\" in FROM has unsupported return type %s",
1960 rtfunc->funccolcount = tupdesc->
natts;
1964 functupdescs[funcno] = tupdesc;
1965 totalatts += tupdesc->
natts;
1981 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1982 errmsg(
"functions in FROM can return at most %d columns",
1990 for (
i = 0;
i < nfuncs;
i++)
1992 for (
j = 1;
j <= functupdescs[
i]->
natts;
j++)
2008 Assert(natts == totalatts);
2013 tupdesc = functupdescs[0];
2067 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
2068 errmsg(
"functions in FROM can return at most %d columns",
2097 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2098 errmsg(
"%s function has %d columns available but %d columns specified",
2141 List *colcollations,
2168 while (numaliases < numcolumns)
2173 snprintf(attrname,
sizeof(attrname),
"column%d", numaliases);
2177 if (numcolumns < numaliases)
2179 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2180 errmsg(
"VALUES lists \"%s\" have %d columns available but %d columns specified",
2181 refname, numcolumns, numaliases)));
2228 Alias *join_using_alias,
2245 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2246 errmsg(
"joins can have at most %d columns",
2270 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2271 errmsg(
"join expression \"%s\" has %d columns available but %d columns specified",
2299 nsitem->
p_rte = rte;
2332 int n_dontexpand_columns = 0;
2360 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2361 errmsg(
"WITH query \"%s\" does not have a RETURNING clause",
2379 foreach(lc, cte->ctecolnames)
2382 if (varattno > numaliases)
2385 if (varattno < numaliases)
2387 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2388 errmsg(
"table \"%s\" has %d columns available but %d columns specified",
2389 refname, varattno, numaliases)));
2393 if (cte->search_clause)
2396 if (cte->search_clause->search_breadth_first)
2403 n_dontexpand_columns += 1;
2406 if (cte->cycle_clause)
2418 n_dontexpand_columns += 2;
2451 for (
int i = 0;
i < n_dontexpand_columns;
i++)
2517 for (attno = 1; attno <= tupdesc->
natts; ++attno)
2521 if (att->attisdropped)
2532 elog(
ERROR,
"atttypid is invalid for non-dropped column in \"%s\"",
2601 else if (refname != NULL)
2610 if (strcmp(refname, thisrel->
relname) == 0)
2627 bool addToRelNameSpace,
bool addToVarNameSpace)
2636 if (addToRelNameSpace || addToVarNameSpace)
2666 int location,
bool include_dropped,
2681 rtindex, sublevels_up, location,
2682 include_dropped, colnames, colvars);
2709 elog(
ERROR,
"too few column names for subquery %s",
2723 varnode =
makeVar(rtindex, varattno,
2730 *colvars =
lappend(*colvars, varnode);
2759 rtfunc->funccolcount, atts_done,
2760 rtindex, sublevels_up, location,
2761 include_dropped, colnames, colvars);
2767 *colnames =
lappend(*colnames,
2775 varnode =
makeVar(rtindex, atts_done + 1,
2782 *colvars =
lappend(*colvars, varnode);
2795 rtfunc->funccolcount);
2807 l2, rtfunc->funccoltypmods,
2808 l3, rtfunc->funccolcollations)
2823 *colvars =
lappend(*colvars, varnode);
2830 elog(
ERROR,
"function in FROM has unsupported return type");
2832 atts_done += rtfunc->funccolcount;
2839 *colnames =
lappend(*colnames,
2851 *colvars =
lappend(*colvars, varnode);
2881 if (include_dropped)
2884 *colnames =
lappend(*colnames,
2905 *colnames =
lappend(*colnames,
2928 varnode =
makeVar(rtindex, varattno,
2935 *colvars =
lappend(*colvars, varnode);
2969 *colnames =
lappend(*colnames,
2972 else if (include_dropped)
2973 *colnames =
lappend(*colnames,
2985 varnode =
makeVar(rtindex, varattno,
2986 coltype, coltypmod, colcoll,
2990 *colvars =
lappend(*colvars, varnode);
2992 else if (include_dropped)
3019 int location,
bool include_dropped,
3027 rtindex, sublevels_up,
3028 location, include_dropped,
3044 int rtindex,
int sublevels_up,
3045 int location,
bool include_dropped,
3054 Assert(count <= tupdesc->natts);
3055 for (varattno = 0; varattno < count; varattno++)
3059 if (attr->attisdropped)
3061 if (include_dropped)
3101 varnode =
makeVar(rtindex, varattno + offset + 1,
3102 attr->atttypid, attr->atttypmod,
3107 *colvars =
lappend(*colvars, varnode);
3125 int sublevels_up,
int location,
3138 const char *colname =
strVal(colnameval);
3145 else if (colname[0])
3164 result =
lappend(result, var);
3166 *colnames =
lappend(*colnames, colnameval);
3189 int sublevels_up,
bool require_col_privs,
int location)
3211 Assert(perminfo != NULL);
3225 te_list =
lappend(te_list, te);
3227 if (require_col_privs)
3282 elog(
ERROR,
"invalid attnum %d for rangetable entry %s",
3310 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
3313 result = att_tup->attisdropped;
3353 result = (aliasvar == NULL);
3373 if (
attnum > atts_done &&
3374 attnum <= atts_done + rtfunc->funccolcount)
3389 return att_tup->attisdropped;
3394 atts_done += rtfunc->funccolcount;
3403 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3404 errmsg(
"column %d of relation \"%s\" does not exist",
3413 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3414 errmsg(
"column %d of relation \"%s\" does not exist",
3444 if (tle->
resno == resno)
3464 if (rc->
rti == rtindex)
3517 return sysatt->attnum;
3537 return &sysatt->attname;
3540 elog(
ERROR,
"invalid attribute number %d", attid);
3559 return sysatt->atttypid;
3562 elog(
ERROR,
"invalid attribute number %d", attid);
3580 elog(
ERROR,
"invalid attribute number %d", attid);
3594 const char *badAlias = NULL;
3613 if (rte && rte->
alias &&
3622 if (nsitem && nsitem->
p_rte == rte)
3630 errmsg(
"invalid reference to FROM-clause entry for table \"%s\"",
3632 errhint(
"Perhaps you meant to reference the table alias \"%s\".",
3639 errmsg(
"invalid reference to FROM-clause entry for table \"%s\"",
3641 errdetail(
"There is an entry for table \"%s\", but it cannot be referenced from this part of the query.",
3644 errhint(
"To reference that table, you must mark this subquery with LATERAL.") : 0,
3650 errmsg(
"missing FROM-clause entry for table \"%s\"",
3663 const char *
relname,
const char *colname,
int location)
3686 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3689 errmsg(
"column \"%s\" does not exist", colname),
3690 errdetail(
"There are columns named \"%s\", but they are in tables that cannot be referenced from this part of the query.",
3696 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3699 errmsg(
"column \"%s\" does not exist", colname),
3700 errdetail(
"There is a column named \"%s\" in table \"%s\", but it cannot be referenced from this part of the query.",
3701 colname,
state->rexact1->eref->aliasname),
3703 errhint(
"To reference that column, you must mark this subquery with LATERAL.") :
3705 errhint(
"To reference that column, you must use a table-qualified name.") : 0,
3709 if (!
state->rsecond)
3714 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3717 errmsg(
"column \"%s\" does not exist", colname),
3721 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3724 errmsg(
"column \"%s\" does not exist", colname),
3725 errhint(
"Perhaps you meant to reference the column \"%s.%s\".",
3726 state->rfirst->eref->aliasname,
3728 state->first - 1))),
3735 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3738 errmsg(
"column \"%s\" does not exist", colname),
3739 errhint(
"Perhaps you meant to reference the column \"%s.%s\" or the column \"%s.%s\".",
3740 state->rfirst->eref->aliasname,
3743 state->rsecond->eref->aliasname,
3745 state->second - 1))),
3757 while (pstate != NULL)
3765 if (nsitem->
p_rte == rte)
3837 foreach(rtable, query->
rtable)
3844 char relpersistence = rel->
rd_rel->relpersistence;
3847 if (relpersistence == RELPERSISTENCE_TEMP)
3881 perminfo->
inh = rte->
inh;
3884 *rteperminfos =
lappend(*rteperminfos, perminfo);
3906 elog(
ERROR,
"invalid perminfoindex %u in RTE with relid %u",
3911 elog(
ERROR,
"permission info at index %u (with relid=%u) does not match provided RTE (with relid=%u)",
#define InvalidAttrNumber
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
#define OidIsValid(objectId)
elog(ERROR, "%s: %s", p2, msg)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
char * get_func_result_name(Oid functionId)
TupleDesc get_expr_result_tupdesc(Node *expr, bool noError)
TypeFuncClass get_expr_result_type(Node *expr, Oid *resultTypeId, TupleDesc *resultTupleDesc)
@ TYPEFUNC_COMPOSITE_DOMAIN
const FormData_pg_attribute * SystemAttributeDefinition(AttrNumber attno)
void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind, int flags)
const FormData_pg_attribute * SystemAttributeByName(const char *attname)
#define CHKATYPE_ANYRECORD
#define HeapTupleIsValid(tuple)
#define MaxTupleAttributeNumber
#define MaxHeapAttributeNumber
if(TABLE==NULL||TABLE_index==NULL)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * list_truncate(List *list, int new_size)
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
List * list_copy(const List *oldlist)
List * list_copy_tail(const List *oldlist, int nskip)
List * list_concat(List *list1, const List *list2)
bool CheckRelationLockedByMe(Relation relation, LOCKMODE lockmode, bool orstronger)
Oid get_relname_relid(const char *relname, Oid relnamespace)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
Alias * makeAlias(const char *aliasname, List *colnames)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
char * pstrdup(const char *in)
void * palloc0(Size size)
int namestrcmp(Name name, const char *str)
Oid LookupNamespaceNoError(const char *nspname)
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
int exprLocation(const Node *expr)
#define query_tree_walker(q, w, c, f)
#define expression_tree_walker(n, w, c)
#define QTW_IGNORE_JOINALIASES
#define IsA(nodeptr, _type_)
EphemeralNamedRelationMetadata get_visible_ENR(ParseState *pstate, const char *refname)
bool name_matches_visible_ENR(ParseState *pstate, const char *refname)
void cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
int parser_errposition(ParseState *pstate, int location)
void setup_parser_errposition_callback(ParseCallbackState *pcbstate, ParseState *pstate, int location)
@ EXPR_KIND_GENERATED_COLUMN
@ EXPR_KIND_CHECK_CONSTRAINT
static bool rte_visible_if_lateral(ParseState *pstate, RangeTblEntry *rte)
static void expandRelation(Oid relid, Alias *eref, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars)
void markNullableIfNeeded(ParseState *pstate, Var *var)
ParseNamespaceItem * addRangeTableEntryForCTE(ParseState *pstate, CommonTableExpr *cte, Index levelsup, RangeVar *rv, bool inFromCl)
RangeTblEntry * GetRTEByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)
static void expandTupleDesc(TupleDesc tupdesc, Alias *eref, int count, int offset, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars)
ParseNamespaceItem * addRangeTableEntry(ParseState *pstate, RangeVar *relation, Alias *alias, bool inh, bool inFromCl)
void errorMissingColumn(ParseState *pstate, const char *relname, const char *colname, int location)
static int specialAttNum(const char *attname)
RTEPermissionInfo * addRTEPermissionInfo(List **rteperminfos, RangeTblEntry *rte)
static ParseNamespaceItem * scanNameSpaceForRelid(ParseState *pstate, Oid relid, int location)
static FuzzyAttrMatchState * searchRangeTableForCol(ParseState *pstate, const char *alias, const char *colname, int location)
ParseNamespaceItem * addRangeTableEntryForJoin(ParseState *pstate, List *colnames, ParseNamespaceColumn *nscolumns, JoinType jointype, int nummergedcols, List *aliasvars, List *leftcols, List *rightcols, Alias *join_using_alias, Alias *alias, bool inFromCl)
Oid attnumCollationId(Relation rd, int attid)
void markVarForSelectPriv(ParseState *pstate, Var *var)
RowMarkClause * get_parse_rowmark(Query *qry, Index rtindex)
CommonTableExpr * scanNameSpaceForCTE(ParseState *pstate, const char *refname, Index *ctelevelsup)
static RangeTblEntry * searchRangeTableForRel(ParseState *pstate, RangeVar *relation)
ParseNamespaceItem * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, bool inFromCl)
static ParseNamespaceItem * scanNameSpaceForRefname(ParseState *pstate, const char *refname, int location)
void errorMissingRTE(ParseState *pstate, RangeVar *relation)
static bool isFutureCTE(ParseState *pstate, const char *refname)
bool get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
static void updateFuzzyAttrMatchState(int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate, RangeTblEntry *rte, const char *actual, const char *match, int attnum)
RTEPermissionInfo * getRTEPermissionInfo(List *rteperminfos, RangeTblEntry *rte)
const NameData * attnumAttName(Relation rd, int attid)
Relation parserOpenTable(ParseState *pstate, const RangeVar *relation, int lockmode)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
static int scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, Alias *eref, const char *colname, int location, int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate)
#define MAX_FUZZY_DISTANCE
static ParseNamespaceItem * buildNSItemFromTupleDesc(RangeTblEntry *rte, Index rtindex, RTEPermissionInfo *perminfo, TupleDesc tupdesc)
ParseNamespaceItem * GetNSItemByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)
ParseNamespaceItem * addRangeTableEntryForSubquery(ParseState *pstate, Query *subquery, Alias *alias, bool lateral, bool inFromCl)
Node * scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, const char *colname, int location)
ParseNamespaceItem * refnameNamespaceItem(ParseState *pstate, const char *schemaname, const char *refname, int location, int *sublevels_up)
char * get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
bool scanNameSpaceForENR(ParseState *pstate, const char *refname)
bool isLockedRefname(ParseState *pstate, const char *refname)
Oid attnumTypeId(Relation rd, int attid)
ParseNamespaceItem * addRangeTableEntryForFunction(ParseState *pstate, List *funcnames, List *funcexprs, List *coldeflists, RangeFunction *rangefunc, bool lateral, bool inFromCl)
static ParseNamespaceItem * findNSItemForRTE(ParseState *pstate, RangeTblEntry *rte)
Node * colNameToVar(ParseState *pstate, const char *colname, bool localonly, int location)
static bool rte_visible_if_qualified(ParseState *pstate, RangeTblEntry *rte)
static void markRTEForSelectPriv(ParseState *pstate, int rtindex, AttrNumber col)
ParseNamespaceItem * addRangeTableEntryForTableFunc(ParseState *pstate, TableFunc *tf, Alias *alias, bool lateral, bool inFromCl)
ParseNamespaceItem * addRangeTableEntryForValues(ParseState *pstate, List *exprs, List *coltypes, List *coltypmods, List *colcollations, Alias *alias, bool lateral, bool inFromCl)
List * expandNSItemVars(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, int location, List **colnames)
static char * chooseScalarFunctionAlias(Node *funcexpr, char *funcname, Alias *alias, int nfuncs)
static ParseNamespaceItem * buildNSItemFromLists(RangeTblEntry *rte, Index rtindex, List *coltypes, List *coltypmods, List *colcollations)
List * expandNSItemAttrs(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, bool require_col_privs, int location)
bool isQueryUsingTempRelation(Query *query)
ParseNamespaceItem * addRangeTableEntryForENR(ParseState *pstate, RangeVar *rv, bool inFromCl)
void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars)
CommonTableExpr * GetCTEForRTE(ParseState *pstate, RangeTblEntry *rte, int rtelevelsup)
static void buildRelationAliases(TupleDesc tupdesc, Alias *alias, Alias *eref)
int attnameAttNum(Relation rd, const char *attname, bool sysColOK)
void checkNameSpaceConflicts(ParseState *pstate, List *namespace1, List *namespace2)
static void check_lateral_ref_ok(ParseState *pstate, ParseNamespaceItem *nsitem, int location)
static bool isQueryUsingTempRelation_walker(Node *node, void *context)
void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, Oid *typeid_p, int32 *typmod_p)
Oid GetColumnDefCollation(ParseState *pstate, ColumnDef *coldef, Oid typeOid)
#define rt_fetch(rangetable_index, rangetable)
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
static Oid list_nth_oid(const List *list, int n)
#define forthree(cell1, list1, cell2, list2, cell3, list3)
static ListCell * list_head(const List *l)
static ListCell * list_nth_cell(const List *list, int n)
static void * list_nth(const List *list, int n)
#define list_nth_node(type, list, n)
static ListCell * lnext(const List *l, const ListCell *c)
#define ERRCODE_UNDEFINED_TABLE
static Datum Int16GetDatum(int16 X)
static Datum ObjectIdGetDatum(Oid X)
TupleDesc ENRMetadataGetTupDesc(EphemeralNamedRelationMetadata enrmd)
#define RelationGetRelid(relation)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
ParseNamespaceColumn * p_nscolumns
RTEPermissionInfo * p_perminfo
ParseState * parentParseState
ParseNamespaceItem * p_target_nsitem
ParseExprKind p_expr_kind
bool p_locked_from_parent
#define FirstLowInvalidHeapAttributeNumber
#define TableOidAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
#define SearchSysCacheExists2(cacheId, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
Relation table_openrv_extended(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok)
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
void TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno, TupleDesc src, AttrNumber srcAttno)
#define TupleDescAttr(tupdesc, i)
String * makeString(char *str)
int varstr_levenshtein_less_equal(const char *source, int slen, const char *target, int tlen, int ins_c, int del_c, int sub_c, int max_d, bool trusted)