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;
1429 errmsg(
"relation \"%s.%s\" does not exist",
1442 errmsg(
"relation \"%s\" does not exist",
1444 errdetail(
"There is a WITH item named \"%s\", but it cannot be referenced from this part of the query.",
1446 errhint(
"Use WITH RECURSIVE, or re-order the WITH items to remove forward references.")));
1450 errmsg(
"relation \"%s\" does not exist",
1663 coltypes = coltypmods = colcollations =
NIL;
1673 if (varattno > numaliases)
1677 attrname =
pstrdup(te->resname);
1687 if (varattno < numaliases)
1689 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
1690 errmsg(
"table \"%s\" has %d columns available but %d columns specified",
1691 eref->
aliasname, varattno, numaliases)));
1717 coltypes, coltypmods, colcollations);
1785 forthree(lc1, funcexprs, lc2, funcnames, lc3, coldeflists)
1796 rtfunc->funccolnames =
NIL;
1797 rtfunc->funccoltypes =
NIL;
1798 rtfunc->funccoltypmods =
NIL;
1799 rtfunc->funccolcollations =
NIL;
1800 rtfunc->funcparams = NULL;
1815 if (coldeflist !=
NIL)
1817 switch (functypclass)
1830 if (
exprType(funcexpr) == RECORDOID)
1832 (
errcode(ERRCODE_SYNTAX_ERROR),
1833 errmsg(
"a column definition list is redundant for a function with OUT parameters"),
1838 (
errcode(ERRCODE_SYNTAX_ERROR),
1839 errmsg(
"a column definition list is redundant for a function returning a named composite type"),
1845 (
errcode(ERRCODE_SYNTAX_ERROR),
1846 errmsg(
"a column definition list is only allowed for functions returning \"record\""),
1856 (
errcode(ERRCODE_SYNTAX_ERROR),
1857 errmsg(
"a column definition list is required for functions returning \"record\""),
1893 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1894 errmsg(
"column definition lists can have at most %d entries",
1900 foreach(col, coldeflist)
1911 (
errcode(ERRCODE_INVALID_TABLE_DEFINITION),
1912 errmsg(
"column \"%s\" cannot be declared SETOF",
1916 &attrtype, &attrtypmod);
1927 rtfunc->funccolnames =
lappend(rtfunc->funccolnames,
1929 rtfunc->funccoltypes =
lappend_oid(rtfunc->funccoltypes,
1931 rtfunc->funccoltypmods =
lappend_int(rtfunc->funccoltypmods,
1933 rtfunc->funccolcollations =
lappend_oid(rtfunc->funccolcollations,
1953 (
errcode(ERRCODE_DATATYPE_MISMATCH),
1954 errmsg(
"function \"%s\" in FROM has unsupported return type %s",
1959 rtfunc->funccolcount = tupdesc->
natts;
1963 functupdescs[funcno] = tupdesc;
1964 totalatts += tupdesc->
natts;
1980 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
1981 errmsg(
"functions in FROM can return at most %d columns",
1989 for (
i = 0;
i < nfuncs;
i++)
1991 for (
j = 1;
j <= functupdescs[
i]->
natts;
j++)
2007 Assert(natts == totalatts);
2012 tupdesc = functupdescs[0];
2066 (
errcode(ERRCODE_TOO_MANY_COLUMNS),
2067 errmsg(
"functions in FROM can return at most %d columns",
2096 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2097 errmsg(
"%s function has %d columns available but %d columns specified",
2140 List *colcollations,
2167 while (numaliases < numcolumns)
2172 snprintf(attrname,
sizeof(attrname),
"column%d", numaliases);
2176 if (numcolumns < numaliases)
2178 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2179 errmsg(
"VALUES lists \"%s\" have %d columns available but %d columns specified",
2180 refname, numcolumns, numaliases)));
2227 Alias *join_using_alias,
2244 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2245 errmsg(
"joins can have at most %d columns",
2269 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2270 errmsg(
"join expression \"%s\" has %d columns available but %d columns specified",
2298 nsitem->
p_rte = rte;
2331 int n_dontexpand_columns = 0;
2359 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2360 errmsg(
"WITH query \"%s\" does not have a RETURNING clause",
2378 foreach(lc, cte->ctecolnames)
2381 if (varattno > numaliases)
2384 if (varattno < numaliases)
2386 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
2387 errmsg(
"table \"%s\" has %d columns available but %d columns specified",
2388 refname, varattno, numaliases)));
2392 if (cte->search_clause)
2395 if (cte->search_clause->search_breadth_first)
2402 n_dontexpand_columns += 1;
2405 if (cte->cycle_clause)
2417 n_dontexpand_columns += 2;
2450 for (
int i = 0;
i < n_dontexpand_columns;
i++)
2516 for (attno = 1; attno <= tupdesc->
natts; ++attno)
2520 if (att->attisdropped)
2531 elog(
ERROR,
"atttypid is invalid for non-dropped column in \"%s\"",
2600 else if (refname != NULL)
2609 if (strcmp(refname, thisrel->
relname) == 0)
2626 bool addToRelNameSpace,
bool addToVarNameSpace)
2635 if (addToRelNameSpace || addToVarNameSpace)
2665 int location,
bool include_dropped,
2680 rtindex, sublevels_up, location,
2681 include_dropped, colnames, colvars);
2708 elog(
ERROR,
"too few column names for subquery %s",
2722 varnode =
makeVar(rtindex, varattno,
2729 *colvars =
lappend(*colvars, varnode);
2758 rtfunc->funccolcount, atts_done,
2759 rtindex, sublevels_up, location,
2760 include_dropped, colnames, colvars);
2766 *colnames =
lappend(*colnames,
2774 varnode =
makeVar(rtindex, atts_done + 1,
2781 *colvars =
lappend(*colvars, varnode);
2794 rtfunc->funccolcount);
2806 l2, rtfunc->funccoltypmods,
2807 l3, rtfunc->funccolcollations)
2822 *colvars =
lappend(*colvars, varnode);
2829 elog(
ERROR,
"function in FROM has unsupported return type");
2831 atts_done += rtfunc->funccolcount;
2838 *colnames =
lappend(*colnames,
2850 *colvars =
lappend(*colvars, varnode);
2880 if (include_dropped)
2883 *colnames =
lappend(*colnames,
2904 *colnames =
lappend(*colnames,
2927 varnode =
makeVar(rtindex, varattno,
2934 *colvars =
lappend(*colvars, varnode);
2968 *colnames =
lappend(*colnames,
2971 else if (include_dropped)
2972 *colnames =
lappend(*colnames,
2984 varnode =
makeVar(rtindex, varattno,
2985 coltype, coltypmod, colcoll,
2989 *colvars =
lappend(*colvars, varnode);
2991 else if (include_dropped)
3018 int location,
bool include_dropped,
3026 rtindex, sublevels_up,
3027 location, include_dropped,
3043 int rtindex,
int sublevels_up,
3044 int location,
bool include_dropped,
3053 Assert(count <= tupdesc->natts);
3054 for (varattno = 0; varattno < count; varattno++)
3058 if (attr->attisdropped)
3060 if (include_dropped)
3100 varnode =
makeVar(rtindex, varattno + offset + 1,
3101 attr->atttypid, attr->atttypmod,
3106 *colvars =
lappend(*colvars, varnode);
3124 int sublevels_up,
int location,
3137 const char *colname =
strVal(colnameval);
3144 else if (colname[0])
3163 result =
lappend(result, var);
3165 *colnames =
lappend(*colnames, colnameval);
3188 int sublevels_up,
bool require_col_privs,
int location)
3210 Assert(perminfo != NULL);
3224 te_list =
lappend(te_list, te);
3226 if (require_col_privs)
3281 elog(
ERROR,
"invalid attnum %d for rangetable entry %s",
3309 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
3312 result = att_tup->attisdropped;
3352 result = (aliasvar == NULL);
3372 if (
attnum > atts_done &&
3373 attnum <= atts_done + rtfunc->funccolcount)
3388 return att_tup->attisdropped;
3393 atts_done += rtfunc->funccolcount;
3402 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3403 errmsg(
"column %d of relation \"%s\" does not exist",
3412 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3413 errmsg(
"column %d of relation \"%s\" does not exist",
3443 if (tle->
resno == resno)
3463 if (rc->
rti == rtindex)
3516 return sysatt->attnum;
3536 return &sysatt->attname;
3539 elog(
ERROR,
"invalid attribute number %d", attid);
3558 return sysatt->atttypid;
3561 elog(
ERROR,
"invalid attribute number %d", attid);
3579 elog(
ERROR,
"invalid attribute number %d", attid);
3593 const char *badAlias = NULL;
3612 if (rte && rte->
alias &&
3621 if (nsitem && nsitem->
p_rte == rte)
3629 errmsg(
"invalid reference to FROM-clause entry for table \"%s\"",
3631 errhint(
"Perhaps you meant to reference the table alias \"%s\".",
3638 errmsg(
"invalid reference to FROM-clause entry for table \"%s\"",
3640 errdetail(
"There is an entry for table \"%s\", but it cannot be referenced from this part of the query.",
3643 errhint(
"To reference that table, you must mark this subquery with LATERAL.") : 0,
3649 errmsg(
"missing FROM-clause entry for table \"%s\"",
3662 const char *
relname,
const char *colname,
int location)
3685 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3688 errmsg(
"column \"%s\" does not exist", colname),
3689 errdetail(
"There are columns named \"%s\", but they are in tables that cannot be referenced from this part of the query.",
3695 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3698 errmsg(
"column \"%s\" does not exist", colname),
3699 errdetail(
"There is a column named \"%s\" in table \"%s\", but it cannot be referenced from this part of the query.",
3700 colname,
state->rexact1->eref->aliasname),
3702 errhint(
"To reference that column, you must mark this subquery with LATERAL.") :
3704 errhint(
"To reference that column, you must use a table-qualified name.") : 0,
3708 if (!
state->rsecond)
3713 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3716 errmsg(
"column \"%s\" does not exist", colname),
3720 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3723 errmsg(
"column \"%s\" does not exist", colname),
3724 errhint(
"Perhaps you meant to reference the column \"%s.%s\".",
3725 state->rfirst->eref->aliasname,
3727 state->first - 1))),
3734 (
errcode(ERRCODE_UNDEFINED_COLUMN),
3737 errmsg(
"column \"%s\" does not exist", colname),
3738 errhint(
"Perhaps you meant to reference the column \"%s.%s\" or the column \"%s.%s\".",
3739 state->rfirst->eref->aliasname,
3742 state->rsecond->eref->aliasname,
3744 state->second - 1))),
3756 while (pstate != NULL)
3764 if (nsitem->
p_rte == rte)
3836 foreach(rtable, query->
rtable)
3843 char relpersistence = rel->
rd_rel->relpersistence;
3846 if (relpersistence == RELPERSISTENCE_TEMP)
3880 perminfo->
inh = rte->
inh;
3883 *rteperminfos =
lappend(*rteperminfos, perminfo);
3905 elog(
ERROR,
"invalid perminfoindex %u in RTE with relid %u",
3910 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)