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 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  char *colname, int location,
58  int fuzzy_rte_penalty, FuzzyAttrMatchState *fuzzystate);
59 extern Node *colNameToVar(ParseState *pstate, 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  Alias *alias,
73  bool inh,
74  bool inFromCl);
76  Query *subquery,
77  Alias *alias,
78  bool lateral,
79  bool inFromCl);
81  List *funcnames,
82  List *funcexprs,
83  List *coldeflists,
84  RangeFunction *rangefunc,
85  bool lateral,
86  bool inFromCl);
88  List *exprs,
89  List *coltypes,
90  List *coltypmods,
91  List *colcollations,
92  Alias *alias,
93  bool lateral,
94  bool inFromCl);
96  TableFunc *tf,
97  Alias *alias,
98  bool lateral,
99  bool inFromCl);
101  List *colnames,
102  JoinType jointype,
103  List *aliasvars,
104  Alias *alias,
105  bool inFromCl);
107  CommonTableExpr *cte,
108  Index levelsup,
109  RangeVar *rv,
110  bool inFromCl);
112  RangeVar *rv,
113  bool inFromCl);
114 extern bool isLockedRefname(ParseState *pstate, const char *refname);
115 extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
116  bool addToJoinList,
117  bool addToRelNameSpace, bool addToVarNameSpace);
118 extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn();
119 extern void errorMissingColumn(ParseState *pstate,
120  char *relname, char *colname, int location) pg_attribute_noreturn();
121 extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
122  int location, bool include_dropped,
123  List **colnames, List **colvars);
124 extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte,
125  int rtindex, int sublevels_up, int location);
126 extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK);
127 extern Name attnumAttName(Relation rd, int attid);
128 extern Oid attnumTypeId(Relation rd, int attid);
129 extern Oid attnumCollationId(Relation rd, int attid);
130 extern bool isQueryUsingTempRelation(Query *query);
131 
132 #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:509
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)
JoinType
Definition: nodes.h:673
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:487
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:359
int RTERangeTablePosn(ParseState *pstate, RangeTblEntry *rte, int *sublevels_up)
RangeTblEntry * addRangeTableEntryForENR(ParseState *pstate, RangeVar *rv, bool inFromCl)
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:642
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)
bool scanNameSpaceForENR(ParseState *pstate, const char *refname)