OSDN Git Service

49aa7228382c7fe877e96593535361024bd551c4
[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-2002, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * $Id: parsetree.h,v 1.20 2003/02/09 06:56:28 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 nth(), etc */
20
21
22 /* ----------------
23  *              range table macros
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 *) nth((rangetable_index)-1, rangetable))
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 #endif   /* PARSETREE_H */