Header And Logo

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

pg_index.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * pg_index.h
00004  *    definition of the system "index" relation (pg_index)
00005  *    along with the relation's initial contents.
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/catalog/pg_index.h
00012  *
00013  * NOTES
00014  *    the genbki.pl script reads this file and generates .bki
00015  *    information from the DATA() statements.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #ifndef PG_INDEX_H
00020 #define PG_INDEX_H
00021 
00022 #include "catalog/genbki.h"
00023 
00024 /* ----------------
00025  *      pg_index definition.  cpp turns this into
00026  *      typedef struct FormData_pg_index.
00027  * ----------------
00028  */
00029 #define IndexRelationId  2610
00030 
00031 CATALOG(pg_index,2610) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
00032 {
00033     Oid         indexrelid;     /* OID of the index */
00034     Oid         indrelid;       /* OID of the relation it indexes */
00035     int16       indnatts;       /* number of columns in index */
00036     bool        indisunique;    /* is this a unique index? */
00037     bool        indisprimary;   /* is this index for primary key? */
00038     bool        indisexclusion; /* is this index for exclusion constraint? */
00039     bool        indimmediate;   /* is uniqueness enforced immediately? */
00040     bool        indisclustered; /* is this the index last clustered by? */
00041     bool        indisvalid;     /* is this index valid for use by queries? */
00042     bool        indcheckxmin;   /* must we wait for xmin to be old? */
00043     bool        indisready;     /* is this index ready for inserts? */
00044     bool        indislive;      /* is this index alive at all? */
00045 
00046     /* variable-length fields start here, but we allow direct access to indkey */
00047     int2vector  indkey;         /* column numbers of indexed cols, or 0 */
00048 
00049 #ifdef CATALOG_VARLEN
00050     oidvector   indcollation;   /* collation identifiers */
00051     oidvector   indclass;       /* opclass identifiers */
00052     int2vector  indoption;      /* per-column flags (AM-specific meanings) */
00053     pg_node_tree indexprs;      /* expression trees for index attributes that
00054                                  * are not simple column references; one for
00055                                  * each zero entry in indkey[] */
00056     pg_node_tree indpred;       /* expression tree for predicate, if a partial
00057                                  * index; else NULL */
00058 #endif
00059 } FormData_pg_index;
00060 
00061 /* ----------------
00062  *      Form_pg_index corresponds to a pointer to a tuple with
00063  *      the format of pg_index relation.
00064  * ----------------
00065  */
00066 typedef FormData_pg_index *Form_pg_index;
00067 
00068 /* ----------------
00069  *      compiler constants for pg_index
00070  * ----------------
00071  */
00072 #define Natts_pg_index                  18
00073 #define Anum_pg_index_indexrelid        1
00074 #define Anum_pg_index_indrelid          2
00075 #define Anum_pg_index_indnatts          3
00076 #define Anum_pg_index_indisunique       4
00077 #define Anum_pg_index_indisprimary      5
00078 #define Anum_pg_index_indisexclusion    6
00079 #define Anum_pg_index_indimmediate      7
00080 #define Anum_pg_index_indisclustered    8
00081 #define Anum_pg_index_indisvalid        9
00082 #define Anum_pg_index_indcheckxmin      10
00083 #define Anum_pg_index_indisready        11
00084 #define Anum_pg_index_indislive         12
00085 #define Anum_pg_index_indkey            13
00086 #define Anum_pg_index_indcollation      14
00087 #define Anum_pg_index_indclass          15
00088 #define Anum_pg_index_indoption         16
00089 #define Anum_pg_index_indexprs          17
00090 #define Anum_pg_index_indpred           18
00091 
00092 /*
00093  * Index AMs that support ordered scans must support these two indoption
00094  * bits.  Otherwise, the content of the per-column indoption fields is
00095  * open for future definition.
00096  */
00097 #define INDOPTION_DESC          0x0001  /* values are in reverse order */
00098 #define INDOPTION_NULLS_FIRST   0x0002  /* NULLs are first instead of last */
00099 
00100 /*
00101  * Use of these macros is recommended over direct examination of the state
00102  * flag columns where possible; this allows source code compatibility with
00103  * the hacky representation used in 9.2.
00104  */
00105 #define IndexIsValid(indexForm) ((indexForm)->indisvalid)
00106 #define IndexIsReady(indexForm) ((indexForm)->indisready)
00107 #define IndexIsLive(indexForm)  ((indexForm)->indislive)
00108 
00109 #endif   /* PG_INDEX_H */