]> granicus.if.org Git - postgresql/blob - src/include/catalog/pg_index.h
Reorganize our CRC source files again.
[postgresql] / src / include / catalog / pg_index.h
1 /*-------------------------------------------------------------------------
2  *
3  * pg_index.h
4  *        definition of the system "index" relation (pg_index)
5  *        along with the relation's initial contents.
6  *
7  *
8  * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  * src/include/catalog/pg_index.h
12  *
13  * NOTES
14  *        the genbki.pl script reads this file and generates .bki
15  *        information from the DATA() statements.
16  *
17  *-------------------------------------------------------------------------
18  */
19 #ifndef PG_INDEX_H
20 #define PG_INDEX_H
21
22 #include "catalog/genbki.h"
23
24 /* ----------------
25  *              pg_index definition.  cpp turns this into
26  *              typedef struct FormData_pg_index.
27  * ----------------
28  */
29 #define IndexRelationId  2610
30
31 CATALOG(pg_index,2610) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
32 {
33         Oid                     indexrelid;             /* OID of the index */
34         Oid                     indrelid;               /* OID of the relation it indexes */
35         int16           indnatts;               /* number of columns in index */
36         bool            indisunique;    /* is this a unique index? */
37         bool            indisprimary;   /* is this index for primary key? */
38         bool            indisexclusion; /* is this index for exclusion constraint? */
39         bool            indimmediate;   /* is uniqueness enforced immediately? */
40         bool            indisclustered; /* is this the index last clustered by? */
41         bool            indisvalid;             /* is this index valid for use by queries? */
42         bool            indcheckxmin;   /* must we wait for xmin to be old? */
43         bool            indisready;             /* is this index ready for inserts? */
44         bool            indislive;              /* is this index alive at all? */
45         bool            indisreplident; /* is this index the identity for replication? */
46
47         /* variable-length fields start here, but we allow direct access to indkey */
48         int2vector      indkey;                 /* column numbers of indexed cols, or 0 */
49
50 #ifdef CATALOG_VARLEN
51         oidvector       indcollation;   /* collation identifiers */
52         oidvector       indclass;               /* opclass identifiers */
53         int2vector      indoption;              /* per-column flags (AM-specific meanings) */
54         pg_node_tree indexprs;          /* expression trees for index attributes that
55                                                                  * are not simple column references; one for
56                                                                  * each zero entry in indkey[] */
57         pg_node_tree indpred;           /* expression tree for predicate, if a partial
58                                                                  * index; else NULL */
59 #endif
60 } FormData_pg_index;
61
62 /* ----------------
63  *              Form_pg_index corresponds to a pointer to a tuple with
64  *              the format of pg_index relation.
65  * ----------------
66  */
67 typedef FormData_pg_index *Form_pg_index;
68
69 /* ----------------
70  *              compiler constants for pg_index
71  * ----------------
72  */
73 #define Natts_pg_index                                  19
74 #define Anum_pg_index_indexrelid                1
75 #define Anum_pg_index_indrelid                  2
76 #define Anum_pg_index_indnatts                  3
77 #define Anum_pg_index_indisunique               4
78 #define Anum_pg_index_indisprimary              5
79 #define Anum_pg_index_indisexclusion    6
80 #define Anum_pg_index_indimmediate              7
81 #define Anum_pg_index_indisclustered    8
82 #define Anum_pg_index_indisvalid                9
83 #define Anum_pg_index_indcheckxmin              10
84 #define Anum_pg_index_indisready                11
85 #define Anum_pg_index_indislive                 12
86 #define Anum_pg_index_indisreplident    13
87 #define Anum_pg_index_indkey                    14
88 #define Anum_pg_index_indcollation              15
89 #define Anum_pg_index_indclass                  16
90 #define Anum_pg_index_indoption                 17
91 #define Anum_pg_index_indexprs                  18
92 #define Anum_pg_index_indpred                   19
93
94 /*
95  * Index AMs that support ordered scans must support these two indoption
96  * bits.  Otherwise, the content of the per-column indoption fields is
97  * open for future definition.
98  */
99 #define INDOPTION_DESC                  0x0001  /* values are in reverse order */
100 #define INDOPTION_NULLS_FIRST   0x0002  /* NULLs are first instead of last */
101
102 /*
103  * Use of these macros is recommended over direct examination of the state
104  * flag columns where possible; this allows source code compatibility with
105  * the hacky representation used in 9.2.
106  */
107 #define IndexIsValid(indexForm) ((indexForm)->indisvalid)
108 #define IndexIsReady(indexForm) ((indexForm)->indisready)
109 #define IndexIsLive(indexForm)  ((indexForm)->indislive)
110
111 #endif   /* PG_INDEX_H */