pg_index.h 3.9 KB

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