PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * parse_relation.h
4  * prototypes for parse_relation.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/parser/parse_relation.h
11  *
12  *-------------------------------------------------------------------------
13  */
17 #include "parser/parse_node.h"
20 /*
21  * Support for fuzzily matching column.
22  *
23  * This is for building diagnostic messages, where non-exact matching
24  * attributes are suggested to the user. The struct's fields may be facets of
25  * a particular RTE, or of an entire range table, depending on context.
26  */
27 typedef struct
28 {
29  int distance; /* Weighted distance (lowest so far) */
30  RangeTblEntry *rfirst; /* RTE of first */
31  AttrNumber first; /* Closest attribute so far */
32  RangeTblEntry *rsecond; /* RTE of second */
33  AttrNumber second; /* Second closest attribute so far */
38  const char *schemaname,
39  const char *refname,
40  int location,
41  int *sublevels_up);
43  const char *refname,
44  Index *ctelevelsup);
45 extern void checkNameSpaceConflicts(ParseState *pstate, List *namespace1,
46  List *namespace2);
47 extern int RTERangeTablePosn(ParseState *pstate,
48  RangeTblEntry *rte,
49  int *sublevels_up);
51  int varno,
52  int sublevels_up);
54  int rtelevelsup);
55 extern Node *scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
56  char *colname, int location,
57  int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate);
58 extern Node *colNameToVar(ParseState *pstate, char *colname, bool localonly,
59  int location);
60 extern void markVarForSelectPriv(ParseState *pstate, Var *var,
61  RangeTblEntry *rte);
62 extern Relation parserOpenTable(ParseState *pstate, const RangeVar *relation,
63  int lockmode);
65  RangeVar *relation,
66  Alias *alias,
67  bool inh,
68  bool inFromCl);
70  Relation rel,
71  Alias *alias,
72  bool inh,
73  bool inFromCl);
75  Query *subquery,
76  Alias *alias,
77  bool lateral,
78  bool inFromCl);
80  List *funcnames,
81  List *funcexprs,
82  List *coldeflists,
83  RangeFunction *rangefunc,
84  bool lateral,
85  bool inFromCl);
87  List *exprs,
88  List *coltypes,
89  List *coltypmods,
90  List *colcollations,
91  Alias *alias,
92  bool lateral,
93  bool inFromCl);
95  TableFunc *tf,
96  Alias *alias,
97  bool lateral,
98  bool inFromCl);
100  List *colnames,
101  JoinType jointype,
102  List *aliasvars,
103  Alias *alias,
104  bool inFromCl);
106  CommonTableExpr *cte,
107  Index levelsup,
108  RangeVar *rv,
109  bool inFromCl);
110 extern bool isLockedRefname(ParseState *pstate, const char *refname);
111 extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
112  bool addToJoinList,
113  bool addToRelNameSpace, bool addToVarNameSpace);
114 extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn();
115 extern void errorMissingColumn(ParseState *pstate,
116  char *relname, char *colname, int location) pg_attribute_noreturn();
117 extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
118  int location, bool include_dropped,
119  List **colnames, List **colvars);
120 extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte,
121  int rtindex, int sublevels_up, int location);
122 extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK);
123 extern Name attnumAttName(Relation rd, int attid);
124 extern Oid attnumTypeId(Relation rd, int attid);
125 extern Oid attnumCollationId(Relation rd, int attid);
126 extern bool isQueryUsingTempRelation(Query *query);
128 #endif /* PARSE_RELATION_H */
void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace)
RangeTblEntry * addRangeTableEntryForSubquery(ParseState *pstate, Query *subquery, Alias *alias, bool lateral, bool inFromCl)
Node * scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname, int location, int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate)
CommonTableExpr * GetCTEForRTE(ParseState *pstate, RangeTblEntry *rte, int rtelevelsup)
Relation parserOpenTable(ParseState *pstate, const RangeVar *relation, int lockmode)
Definition: nodes.h:506
RangeTblEntry * refnameRangeTblEntry(ParseState *pstate, const char *schemaname, const char *refname, int location, int *sublevels_up)
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:163
Oid attnumCollationId(Relation rd, int attid)
Definition: nodes.h:669
void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn()
Oid attnumTypeId(Relation rd, int attid)
void checkNameSpaceConflicts(ParseState *pstate, List *namespace1, List *namespace2)
bool isLockedRefname(ParseState *pstate, const char *refname)
int attnameAttNum(Relation rd, const char *attname, bool sysColOK)
List * expandRelAttrs(ParseState *pstate, RangeTblEntry *rte, int rtindex, int sublevels_up, int location)
RangeTblEntry * rfirst
Definition: c.h:493
RangeTblEntry * addRangeTableEntry(ParseState *pstate, RangeVar *relation, Alias *alias, bool inh, bool inFromCl)
RangeTblEntry * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, Alias *alias, bool inh, bool inFromCl)
void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars)
Name attnumAttName(Relation rd, int attid)
Node * colNameToVar(ParseState *pstate, char *colname, bool localonly, int location)
void markVarForSelectPriv(ParseState *pstate, Var *var, RangeTblEntry *rte)
unsigned int Index
Definition: c.h:365
int RTERangeTablePosn(ParseState *pstate, RangeTblEntry *rte, int *sublevels_up)
RangeTblEntry * addRangeTableEntryForFunction(ParseState *pstate, List *funcnames, List *funcexprs, List *coldeflists, RangeFunction *rangefunc, bool lateral, bool inFromCl)
CommonTableExpr * scanNameSpaceForCTE(ParseState *pstate, const char *refname, Index *ctelevelsup)
RangeTblEntry * rsecond
bool isQueryUsingTempRelation(Query *query)
RangeTblEntry * addRangeTableEntryForJoin(ParseState *pstate, List *colnames, JoinType jointype, List *aliasvars, Alias *alias, bool inFromCl)
#define pg_attribute_noreturn()
Definition: c.h:653
RangeTblEntry * addRangeTableEntryForTableFunc(ParseState *pstate, TableFunc *tf, Alias *alias, bool lateral, bool inFromCl)
RangeTblEntry * addRangeTableEntryForValues(ParseState *pstate, List *exprs, List *coltypes, List *coltypmods, List *colcollations, Alias *alias, bool lateral, bool inFromCl)
RangeTblEntry * addRangeTableEntryForCTE(ParseState *pstate, CommonTableExpr *cte, Index levelsup, RangeVar *rv, bool inFromCl)
void errorMissingColumn(ParseState *pstate, char *relname, char *colname, int location) pg_attribute_noreturn()
Definition: pg_list.h:45
int16 AttrNumber
Definition: attnum.h:21
RangeTblEntry * GetRTEByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)