PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
parsetree.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * parsetree.h
4  * Routines to access various components and subcomponents of
5  * parse trees.
6  *
7  *
8  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * src/include/parser/parsetree.h
12  *
13  *-------------------------------------------------------------------------
14  */
15 #ifndef PARSETREE_H
16 #define PARSETREE_H
17 
18 #include "nodes/parsenodes.h"
19 
20 
21 /* ----------------
22  * range table operations
23  * ----------------
24  */
25 
26 /*
27  * rt_fetch
28  *
29  * NB: this will crash and burn if handed an out-of-range RT index
30  */
31 #define rt_fetch(rangetable_index, rangetable) \
32  ((RangeTblEntry *) list_nth(rangetable, (rangetable_index)-1))
33 
34 /*
35  * getrelid
36  *
37  * Given the range index of a relation, return the corresponding
38  * relation OID. Note that InvalidOid will be returned if the
39  * RTE is for a non-relation-type RTE.
40  */
41 #define getrelid(rangeindex,rangetable) \
42  (rt_fetch(rangeindex, rangetable)->relid)
43 
44 /*
45  * Given an RTE and an attribute number, return the appropriate
46  * variable name or alias for that attribute of that RTE.
47  */
48 extern char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum);
49 
50 /*
51  * Given an RTE and an attribute number, return the appropriate
52  * type and typemod info for that attribute of that RTE.
53  */
54 extern void get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
55  Oid *vartype, int32 *vartypmod, Oid *varcollid);
56 
57 /*
58  * Check whether an attribute of an RTE has been dropped (note that
59  * get_rte_attribute_type will fail on such an attr)
60  */
62  AttrNumber attnum);
63 
64 
65 /* ----------------
66  * target list operations
67  * ----------------
68  */
69 
70 extern TargetEntry *get_tle_by_resno(List *tlist, AttrNumber resno);
71 
72 /* ----------------
73  * FOR UPDATE/SHARE info
74  * ----------------
75  */
76 
77 extern RowMarkClause *get_parse_rowmark(Query *qry, Index rtindex);
78 
79 #endif /* PARSETREE_H */
void get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, Oid *vartype, int32 *vartypmod, Oid *varcollid)
char * get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
unsigned int Oid
Definition: postgres_ext.h:31
signed int int32
Definition: c.h:253
bool get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
RowMarkClause * get_parse_rowmark(Query *qry, Index rtindex)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
unsigned int Index
Definition: c.h:361
Definition: pg_list.h:45
int16 AttrNumber
Definition: attnum.h:21