2
0

genbki.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*-------------------------------------------------------------------------
  2. *
  3. * genbki.h
  4. * Required include file for all POSTGRES catalog header files
  5. *
  6. * genbki.h defines CATALOG(), BKI_BOOTSTRAP and related macros
  7. * so that the catalog header files can be read by the C compiler.
  8. * (These same words are recognized by genbki.pl to build the BKI
  9. * bootstrap file from these header files.)
  10. *
  11. *
  12. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  13. * Portions Copyright (c) 1994, Regents of the University of California
  14. *
  15. * src/include/catalog/genbki.h
  16. *
  17. *-------------------------------------------------------------------------
  18. */
  19. #ifndef GENBKI_H
  20. #define GENBKI_H
  21. /* Introduces a catalog's structure definition */
  22. #define CATALOG(name,oid,oidmacro) typedef struct CppConcat(FormData_,name)
  23. /* Options that may appear after CATALOG (on the same line) */
  24. #define BKI_BOOTSTRAP
  25. #define BKI_SHARED_RELATION
  26. #define BKI_ROWTYPE_OID(oid,oidmacro)
  27. #define BKI_SCHEMA_MACRO
  28. /* Options that may appear after an attribute (on the same line) */
  29. #define BKI_FORCE_NULL
  30. #define BKI_FORCE_NOT_NULL
  31. /* Specifies a default value for a catalog field */
  32. #define BKI_DEFAULT(value)
  33. /* Specifies a default value for auto-generated array types */
  34. #define BKI_ARRAY_DEFAULT(value)
  35. /*
  36. * Indicates that the attribute contains OIDs referencing the named catalog;
  37. * can be applied to columns of oid, regproc, oid[], or oidvector type.
  38. * genbki.pl uses this to know how to perform name lookups in the initial
  39. * data (if any), and it also feeds into regression-test validity checks.
  40. * The _OPT suffix indicates that values can be zero instead of
  41. * a valid OID reference.
  42. */
  43. #define BKI_LOOKUP(catalog)
  44. #define BKI_LOOKUP_OPT(catalog)
  45. /*
  46. * These lines are processed by genbki.pl to create the statements
  47. * the bootstrap parser will turn into BootstrapToastTable commands.
  48. * Each line specifies the system catalog that needs a toast table,
  49. * the OID to assign to the toast table, and the OID to assign to the
  50. * toast table's index. The reason we hard-wire these OIDs is that we
  51. * need stable OIDs for shared relations, and that includes toast tables
  52. * of shared relations.
  53. *
  54. * The DECLARE_TOAST_WITH_MACRO variant is used when C macros are needed
  55. * for the toast table/index OIDs (usually only for shared catalogs).
  56. *
  57. * The macro definitions are just to keep the C compiler from spitting up.
  58. */
  59. #define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
  60. #define DECLARE_TOAST_WITH_MACRO(name,toastoid,indexoid,toastoidmacro,indexoidmacro) extern int no_such_variable
  61. /*
  62. * These lines are processed by genbki.pl to create the statements
  63. * the bootstrap parser will turn into DefineIndex calls.
  64. *
  65. * The keyword is DECLARE_INDEX or DECLARE_UNIQUE_INDEX or
  66. * DECLARE_UNIQUE_INDEX_PKEY. ("PKEY" marks the index as being the catalog's
  67. * primary key; currently this is only cosmetically different from a regular
  68. * unique index. By convention, we usually make a catalog's OID column its
  69. * pkey, if it has one.) The first two arguments are the index's name and
  70. * OID, the rest is much like a standard 'create index' SQL command.
  71. *
  72. * For each index, we also provide a #define for its OID. References to
  73. * the index in the C code should always use these #defines, not the actual
  74. * index name (much less the numeric OID).
  75. *
  76. * The macro definitions are just to keep the C compiler from spitting up.
  77. */
  78. #define DECLARE_INDEX(name,oid,oidmacro,decl) extern int no_such_variable
  79. #define DECLARE_UNIQUE_INDEX(name,oid,oidmacro,decl) extern int no_such_variable
  80. #define DECLARE_UNIQUE_INDEX_PKEY(name,oid,oidmacro,decl) extern int no_such_variable
  81. /*
  82. * These lines inform genbki.pl about manually-assigned OIDs that do not
  83. * correspond to any entry in the catalog *.dat files, but should be subject
  84. * to uniqueness verification and renumber_oids.pl renumbering. A C macro
  85. * to #define the given name is emitted into the corresponding *_d.h file.
  86. */
  87. #define DECLARE_OID_DEFINING_MACRO(name,oid) extern int no_such_variable
  88. /*
  89. * These lines are processed by genbki.pl to create a table for use
  90. * by the pg_get_catalog_foreign_keys() function. We do not have any
  91. * mechanism that actually enforces foreign-key relationships in the
  92. * system catalogs, but it is still useful to record the intended
  93. * relationships in a machine-readable form.
  94. *
  95. * The keyword is DECLARE_FOREIGN_KEY[_OPT] or DECLARE_ARRAY_FOREIGN_KEY[_OPT].
  96. * The first argument is a parenthesized list of the referencing columns;
  97. * the second, the name of the referenced table; the third, a parenthesized
  98. * list of the referenced columns. Use of the ARRAY macros means that the
  99. * last referencing column is an array, each of whose elements is supposed
  100. * to match some entry in the last referenced column. Use of the OPT suffix
  101. * indicates that the referencing column(s) can be zero instead of a valid
  102. * reference.
  103. *
  104. * Columns that are marked with a BKI_LOOKUP rule do not need an explicit
  105. * DECLARE_FOREIGN_KEY macro, as genbki.pl can infer the FK relationship
  106. * from that. Thus, these macros are only needed in special cases.
  107. *
  108. * The macro definitions are just to keep the C compiler from spitting up.
  109. */
  110. #define DECLARE_FOREIGN_KEY(cols,reftbl,refcols) extern int no_such_variable
  111. #define DECLARE_FOREIGN_KEY_OPT(cols,reftbl,refcols) extern int no_such_variable
  112. #define DECLARE_ARRAY_FOREIGN_KEY(cols,reftbl,refcols) extern int no_such_variable
  113. #define DECLARE_ARRAY_FOREIGN_KEY_OPT(cols,reftbl,refcols) extern int no_such_variable
  114. /* The following are never defined; they are here only for documentation. */
  115. /*
  116. * Variable-length catalog fields (except possibly the first not nullable one)
  117. * should not be visible in C structures, so they are made invisible by #ifdefs
  118. * of an undefined symbol. See also the BOOTCOL_NULL_AUTO code in bootstrap.c
  119. * for how this is handled.
  120. */
  121. #undef CATALOG_VARLEN
  122. /*
  123. * There is code in some catalog headers that needs to be visible to clients,
  124. * but we don't want clients to include the full header because of safety
  125. * issues with other code in the header. To handle that, surround code that
  126. * should be visible to clients with "#ifdef EXPOSE_TO_CLIENT_CODE". That
  127. * instructs genbki.pl to copy the section when generating the corresponding
  128. * "_d" header, which can be included by both client and backend code.
  129. */
  130. #undef EXPOSE_TO_CLIENT_CODE
  131. #endif /* GENBKI_H */