PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-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  */
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 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  List *colnames,
96  JoinType jointype,
97  List *aliasvars,
98  Alias *alias,
99  bool inFromCl);
101  CommonTableExpr *cte,
102  Index levelsup,
103  RangeVar *rv,
104  bool inFromCl);
105 extern bool isLockedRefname(ParseState *pstate, const char *refname);
106 extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
107  bool addToJoinList,
108  bool addToRelNameSpace, bool addToVarNameSpace);
109 extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn();
110 extern void errorMissingColumn(ParseState *pstate,
111  char *relname, char *colname, int location) pg_attribute_noreturn();
112 extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
113  int location, bool include_dropped,
114  List **colnames, List **colvars);
115 extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte,
116  int rtindex, int sublevels_up, int location);
117 extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK);
118 extern Name attnumAttName(Relation rd, int attid);
119 extern Oid attnumTypeId(Relation rd, int attid);
120 extern Oid attnumCollationId(Relation rd, int attid);
121 extern bool isQueryUsingTempRelation(Query *query);
122 
123 #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:508
RangeTblEntry * refnameRangeTblEntry(ParseState *pstate, const char *schemaname, const char *refname, int location, int *sublevels_up)
#define pg_attribute_noreturn()
Definition: c.h:649
unsigned int Oid
Definition: postgres_ext.h:31
Definition: primnodes.h:141
Oid attnumCollationId(Relation rd, int attid)
JoinType
Definition: nodes.h:665
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:489
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:362
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)
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)