Header And Logo

PostgreSQL
| The world's most advanced open source database.

parsetree.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * parsetree.h
00004  *    Routines to access various components and subcomponents of
00005  *    parse trees.
00006  *
00007  *
00008  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00009  * Portions Copyright (c) 1994, Regents of the University of California
00010  *
00011  * src/include/parser/parsetree.h
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 #ifndef PARSETREE_H
00016 #define PARSETREE_H
00017 
00018 #include "nodes/parsenodes.h"
00019 
00020 
00021 /* ----------------
00022  *      range table operations
00023  * ----------------
00024  */
00025 
00026 /*
00027  *      rt_fetch
00028  *
00029  * NB: this will crash and burn if handed an out-of-range RT index
00030  */
00031 #define rt_fetch(rangetable_index, rangetable) \
00032     ((RangeTblEntry *) list_nth(rangetable, (rangetable_index)-1))
00033 
00034 /*
00035  *      getrelid
00036  *
00037  *      Given the range index of a relation, return the corresponding
00038  *      relation OID.  Note that InvalidOid will be returned if the
00039  *      RTE is for a non-relation-type RTE.
00040  */
00041 #define getrelid(rangeindex,rangetable) \
00042     (rt_fetch(rangeindex, rangetable)->relid)
00043 
00044 /*
00045  * Given an RTE and an attribute number, return the appropriate
00046  * variable name or alias for that attribute of that RTE.
00047  */
00048 extern char *get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum);
00049 
00050 /*
00051  * Given an RTE and an attribute number, return the appropriate
00052  * type and typemod info for that attribute of that RTE.
00053  */
00054 extern void get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
00055                        Oid *vartype, int32 *vartypmod, Oid *varcollid);
00056 
00057 /*
00058  * Check whether an attribute of an RTE has been dropped (note that
00059  * get_rte_attribute_type will fail on such an attr)
00060  */
00061 extern bool get_rte_attribute_is_dropped(RangeTblEntry *rte,
00062                              AttrNumber attnum);
00063 
00064 
00065 /* ----------------
00066  *      target list operations
00067  * ----------------
00068  */
00069 
00070 extern TargetEntry *get_tle_by_resno(List *tlist, AttrNumber resno);
00071 
00072 /* ----------------
00073  *      FOR UPDATE/SHARE info
00074  * ----------------
00075  */
00076 
00077 extern RowMarkClause *get_parse_rowmark(Query *qry, Index rtindex);
00078 
00079 #endif   /* PARSETREE_H */