OSDN Git Service

Standardize on the assumption that the arguments of a RowExpr correspond
[pg-rex/syncrep.git] / src / include / parser / parsetree.h
1 /*-------------------------------------------------------------------------
2  *
3  * parsetree.h
4  *        Routines to access various components and subcomponents of
5  *        parse trees.
6  *
7  *
8  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $PostgreSQL: pgsql/src/include/parser/parsetree.h,v 1.25 2004/08/17 18:47:09 tgl Exp $
12  *
13  *-------------------------------------------------------------------------
14  */
15 #ifndef PARSETREE_H
16 #define PARSETREE_H
17
18 #include "nodes/parsenodes.h"
19 #include "nodes/pg_list.h"              /* for list_nth(), etc */
20
21
22 /* ----------------
23  *              range table operations
24  * ----------------
25  */
26
27 /*
28  *              rt_fetch
29  *
30  * NB: this will crash and burn if handed an out-of-range RT index
31  */
32 #define rt_fetch(rangetable_index, rangetable) \
33         ((RangeTblEntry *) list_nth(rangetable, (rangetable_index)-1))
34
35 /*
36  *              getrelid
37  *
38  *              Given the range index of a relation, return the corresponding
39  *              relation OID.  Note that InvalidOid will be returned if the
40  *              RTE is for a non-relation-type RTE.
41  */
42 #define getrelid(rangeindex,rangetable) \
43         (rt_fetch(rangeindex, rangetable)->relid)
44
45 /*
46  * Given an RTE and an attribute number, return the appropriate
47  * variable name or alias for that attribute of that RTE.
48  */
49 extern char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum);
50
51 /*
52  * Given an RTE and an attribute number, return the appropriate
53  * type and typemod info for that attribute of that RTE.
54  */
55 extern void get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
56                                            Oid *vartype, int32 *vartypmod);
57
58 /*
59  * Check whether an attribute of an RTE has been dropped (note that
60  * get_rte_attribute_type will fail on such an attr)
61  */
62 extern bool get_rte_attribute_is_dropped(RangeTblEntry *rte,
63                                                                                  AttrNumber attnum);
64
65
66 /* ----------------
67  *              target list operations
68  * ----------------
69  */
70
71 extern TargetEntry *get_tle_by_resno(List *tlist, AttrNumber resno);
72
73 #endif   /* PARSETREE_H */