| 1 | /*------------------------------------------------------------------------- |
| 2 | * |
| 3 | * parsetree.h |
| 4 | * Routines to access various components and subcomponents of |
| 5 | * parse trees. |
| 6 | * |
| 7 | * |
| 8 | * Portions Copyright (c) 1996-2019, 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 | * Given an RTE and an attribute number, return the appropriate |
| 36 | * variable name or alias for that attribute of that RTE. |
| 37 | */ |
| 38 | extern char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum); |
| 39 | |
| 40 | /* |
| 41 | * Given an RTE and an attribute number, return the appropriate |
| 42 | * type and typemod info for that attribute of that RTE. |
| 43 | */ |
| 44 | extern void get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, |
| 45 | Oid *vartype, int32 *vartypmod, Oid *varcollid); |
| 46 | |
| 47 | /* |
| 48 | * Check whether an attribute of an RTE has been dropped (note that |
| 49 | * get_rte_attribute_type will fail on such an attr) |
| 50 | */ |
| 51 | extern bool get_rte_attribute_is_dropped(RangeTblEntry *rte, |
| 52 | AttrNumber attnum); |
| 53 | |
| 54 | |
| 55 | /* ---------------- |
| 56 | * target list operations |
| 57 | * ---------------- |
| 58 | */ |
| 59 | |
| 60 | extern TargetEntry *get_tle_by_resno(List *tlist, AttrNumber resno); |
| 61 | |
| 62 | /* ---------------- |
| 63 | * FOR UPDATE/SHARE info |
| 64 | * ---------------- |
| 65 | */ |
| 66 | |
| 67 | extern RowMarkClause *get_parse_rowmark(Query *qry, Index rtindex); |
| 68 | |
| 69 | #endif /* PARSETREE_H */ |
| 70 | |