PostgreSQL Source Code  git master
parse_relation.h
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-2019, 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  */
14 #ifndef PARSE_RELATION_H
15 #define PARSE_RELATION_H
16 
17 #include "parser/parse_node.h"
18 
19 
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 */
35 
36 
38  const char *schemaname,
39  const char *refname,
40  int location,
41  int *sublevels_up);
43  const char *refname,
44  Index *ctelevelsup);
45 extern bool scanNameSpaceForENR(ParseState *pstate, const char *refname);
46 extern void checkNameSpaceConflicts(ParseState *pstate, List *namespace1,
47  List *namespace2);
48 extern int RTERangeTablePosn(ParseState *pstate,
49  RangeTblEntry *rte,
50  int *sublevels_up);
52  int varno,
53  int sublevels_up);
55  int rtelevelsup);
56 extern Node *scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
57  const char *colname, int location,
58  int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate);
59 extern Node *colNameToVar(ParseState *pstate, const char *colname, bool localonly,
60  int location);
61 extern void markVarForSelectPriv(ParseState *pstate, Var *var,
62  RangeTblEntry *rte);
63 extern Relation parserOpenTable(ParseState *pstate, const RangeVar *relation,
64  int lockmode);
66  RangeVar *relation,
67  Alias *alias,
68  bool inh,
69  bool inFromCl);
71  Relation rel,
72  int lockmode,
73  Alias *alias,
74  bool inh,
75  bool inFromCl);
77  Query *subquery,
78  Alias *alias,
79  bool lateral,
80  bool inFromCl);
82  List *funcnames,
83  List *funcexprs,
84  List *coldeflists,
85  RangeFunction *rangefunc,
86  bool lateral,
87  bool inFromCl);
89  List *exprs,
90  List *coltypes,
91  List *coltypmods,
92  List *colcollations,
93  Alias *alias,
94  bool lateral,
95  bool inFromCl);
97  TableFunc *tf,
98  Alias *alias,
99  bool lateral,
100  bool inFromCl);
102  List *colnames,
103  JoinType jointype,
104  List *aliasvars,
105  Alias *alias,
106  bool inFromCl);
108  CommonTableExpr *cte,
109  Index levelsup,
110  RangeVar *rv,
111  bool inFromCl);
113  RangeVar *rv,
114  bool inFromCl);
115 extern bool isLockedRefname(ParseState *pstate, const char *refname);
116 extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
117  bool addToJoinList,
118  bool addToRelNameSpace, bool addToVarNameSpace);
119 extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn();
120 extern void errorMissingColumn(ParseState *pstate,
121  const char *relname, const char *colname, int location) pg_attribute_noreturn();
122 extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
123  int location, bool include_dropped,
124  List **colnames, List **colvars);
125 extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte,
126  int rtindex, int sublevels_up, int location);
127 extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK);
128 extern const NameData *attnumAttName(Relation rd, int attid);
129 extern Oid attnumTypeId(Relation rd, int attid);
130 extern Oid attnumCollationId(Relation rd, int attid);
131 extern bool isQueryUsingTempRelation(Query *query);
132 
133 #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)
CommonTableExpr * GetCTEForRTE(ParseState *pstate, RangeTblEntry *rte, int rtelevelsup)
Relation parserOpenTable(ParseState *pstate, const RangeVar *relation, int lockmode)
Definition: nodes.h:525
RangeTblEntry * refnameRangeTblEntry(ParseState *pstate, const char *schemaname, const char *refname, int location, int *sublevels_up)
NameData relname
Definition: pg_class.h:35
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:167
Node * colNameToVar(ParseState *pstate, const char *colname, bool localonly, int location)
Oid attnumCollationId(Relation rd, int attid)
JoinType
Definition: nodes.h:692
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)
NameData attname
Definition: pg_attribute.h:40
List * expandRelAttrs(ParseState *pstate, RangeTblEntry *rte, int rtindex, int sublevels_up, int location)
RangeTblEntry * rfirst
Definition: c.h:604
RangeTblEntry * addRangeTableEntry(ParseState *pstate, RangeVar *relation, Alias *alias, bool inh, bool inFromCl)
void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars)
const NameData * attnumAttName(Relation rd, int attid)
void markVarForSelectPriv(ParseState *pstate, Var *var, RangeTblEntry *rte)
unsigned int Index
Definition: c.h:476
int RTERangeTablePosn(ParseState *pstate, RangeTblEntry *rte, int *sublevels_up)
RangeTblEntry * addRangeTableEntryForENR(ParseState *pstate, RangeVar *rv, bool inFromCl)
Node * scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, const char *colname, int location, int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate)
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:147
RangeTblEntry * addRangeTableEntryForTableFunc(ParseState *pstate, TableFunc *tf, Alias *alias, bool lateral, bool inFromCl)
RangeTblEntry * addRangeTableEntryForRelation(ParseState *pstate, Relation rel, int lockmode, Alias *alias, bool inh, 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)
Definition: pg_list.h:50
void errorMissingColumn(ParseState *pstate, const char *relname, const char *colname, int location) pg_attribute_noreturn()
int16 AttrNumber
Definition: attnum.h:21
RangeTblEntry * GetRTEByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)
bool scanNameSpaceForENR(ParseState *pstate, const char *refname)