PostgreSQL Source Code  git master
pg_index.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_index.h
4  * definition of the "index" system catalog (pg_index)
5  *
6  *
7  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/catalog/pg_index.h
11  *
12  * NOTES
13  * The Catalog.pm module reads this file and derives schema
14  * information.
15  *
16  *-------------------------------------------------------------------------
17  */
18 #ifndef PG_INDEX_H
19 #define PG_INDEX_H
20 
21 #include "catalog/genbki.h"
22 #include "catalog/pg_index_d.h"
23 
24 /* ----------------
25  * pg_index definition. cpp turns this into
26  * typedef struct FormData_pg_index.
27  * ----------------
28  */
29 CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO
30 {
31  Oid indexrelid BKI_LOOKUP(pg_class); /* OID of the index */
32  Oid indrelid BKI_LOOKUP(pg_class); /* OID of the relation it
33  * indexes */
34  int16 indnatts; /* total number of columns in index */
35  int16 indnkeyatts; /* number of key columns in index */
36  bool indisunique; /* is this a unique index? */
37  bool indnullsnotdistinct; /* null treatment in unique index */
38  bool indisprimary; /* is this index for primary key? */
39  bool indisexclusion; /* is this index for exclusion constraint? */
40  bool indimmediate; /* is uniqueness enforced immediately? */
41  bool indisclustered; /* is this the index last clustered by? */
42  bool indisvalid; /* is this index valid for use by queries? */
43  bool indcheckxmin; /* must we wait for xmin to be old? */
44  bool indisready; /* is this index ready for inserts? */
45  bool indislive; /* is this index alive at all? */
46  bool indisreplident; /* is this index the identity for replication? */
47 
48  /* variable-length fields start here, but we allow direct access to indkey */
49  int2vector indkey BKI_FORCE_NOT_NULL; /* column numbers of indexed cols,
50  * or 0 */
51 
52 #ifdef CATALOG_VARLEN
53  oidvector indcollation BKI_LOOKUP_OPT(pg_collation) BKI_FORCE_NOT_NULL; /* collation identifiers */
54  oidvector indclass BKI_LOOKUP(pg_opclass) BKI_FORCE_NOT_NULL; /* opclass identifiers */
55  int2vector indoption BKI_FORCE_NOT_NULL; /* per-column flags
56  * (AM-specific meanings) */
57  pg_node_tree indexprs; /* expression trees for index attributes that
58  * are not simple column references; one for
59  * each zero entry in indkey[] */
60  pg_node_tree indpred; /* expression tree for predicate, if a partial
61  * index; else NULL */
62 #endif
64 
65 /* ----------------
66  * Form_pg_index corresponds to a pointer to a tuple with
67  * the format of pg_index relation.
68  * ----------------
69  */
71 
72 DECLARE_INDEX(pg_index_indrelid_index, 2678, IndexIndrelidIndexId, on pg_index using btree(indrelid oid_ops));
73 DECLARE_UNIQUE_INDEX_PKEY(pg_index_indexrelid_index, 2679, IndexRelidIndexId, on pg_index using btree(indexrelid oid_ops));
74 
75 /* indkey can contain zero (InvalidAttrNumber) to represent expressions */
76 DECLARE_ARRAY_FOREIGN_KEY_OPT((indrelid, indkey), pg_attribute, (attrelid, attnum));
77 
78 #ifdef EXPOSE_TO_CLIENT_CODE
79 
80 /*
81  * Index AMs that support ordered scans must support these two indoption
82  * bits. Otherwise, the content of the per-column indoption fields is
83  * open for future definition.
84  */
85 #define INDOPTION_DESC 0x0001 /* values are in reverse order */
86 #define INDOPTION_NULLS_FIRST 0x0002 /* NULLs are first instead of last */
87 
88 #endif /* EXPOSE_TO_CLIENT_CODE */
89 
90 #endif /* PG_INDEX_H */
signed short int16
Definition: c.h:429
#define BKI_LOOKUP(catalog)
Definition: genbki.h:46
#define BKI_LOOKUP_OPT(catalog)
Definition: genbki.h:47
#define BKI_FORCE_NOT_NULL
Definition: genbki.h:33
#define BKI_SCHEMA_MACRO
Definition: genbki.h:29
int16 attnum
Definition: pg_attribute.h:83
DECLARE_INDEX(pg_index_indrelid_index, 2678, IndexIndrelidIndexId, on pg_index using btree(indrelid oid_ops))
FormData_pg_index
Definition: pg_index.h:63
DECLARE_UNIQUE_INDEX_PKEY(pg_index_indexrelid_index, 2679, IndexRelidIndexId, on pg_index using btree(indexrelid oid_ops))
DECLARE_ARRAY_FOREIGN_KEY_OPT((indrelid, indkey), pg_attribute,(attrelid, attnum))
CATALOG(pg_index, 2610, IndexRelationId) BKI_SCHEMA_MACRO
Definition: pg_index.h:29
FormData_pg_index * Form_pg_index
Definition: pg_index.h:70
unsigned int Oid
Definition: postgres_ext.h:31
Definition: c.h:651
Definition: c.h:662