codekingpro/portable-devtools
114k
1/*-------------------------------------------------------------------------2 *3 * genbki.h4 * Required include file for all POSTGRES catalog header files5 *6 * genbki.h defines CATALOG(), BKI_BOOTSTRAP and related macros7 * 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 BKI9 * bootstrap file from these header files.)10 *11 *12 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group13 * Portions Copyright (c) 1994, Regents of the University of California14 *15 * src/include/catalog/genbki.h16 *17 *-------------------------------------------------------------------------18 */19#ifndef GENBKI_H20#define GENBKI_H21 22/* Introduces a catalog's structure definition */23#define CATALOG(name,oid,oidmacro) typedef struct CppConcat(FormData_,name)24 25/* Options that may appear after CATALOG (on the same line) */26#define BKI_BOOTSTRAP27#define BKI_SHARED_RELATION28#define BKI_ROWTYPE_OID(oid,oidmacro)29#define BKI_SCHEMA_MACRO30 31/* Options that may appear after an attribute (on the same line) */32#define BKI_FORCE_NULL33#define BKI_FORCE_NOT_NULL34/* Specifies a default value for a catalog field */35#define BKI_DEFAULT(value)36/* Specifies a default value for auto-generated array types */37#define BKI_ARRAY_DEFAULT(value)38/*39 * Indicates that the attribute contains OIDs referencing the named catalog;40 * can be applied to columns of oid, regproc, oid[], or oidvector type.41 * genbki.pl uses this to know how to perform name lookups in the initial42 * data (if any), and it also feeds into regression-test validity checks.43 * The _OPT suffix indicates that values can be zero instead of44 * a valid OID reference.45 */46#define BKI_LOOKUP(catalog)47#define BKI_LOOKUP_OPT(catalog)48 49/*50 * These lines are processed by genbki.pl to create the statements51 * the bootstrap parser will turn into BootstrapToastTable commands.52 * Each line specifies the system catalog that needs a toast table,53 * the OID to assign to the toast table, and the OID to assign to the54 * toast table's index. The reason we hard-wire these OIDs is that we55 * need stable OIDs for shared relations, and that includes toast tables56 * of shared relations.57 *58 * The DECLARE_TOAST_WITH_MACRO variant is used when C macros are needed59 * for the toast table/index OIDs (usually only for shared catalogs).60 *61 * The macro definitions are just to keep the C compiler from spitting up.62 */63#define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable64#define DECLARE_TOAST_WITH_MACRO(name,toastoid,indexoid,toastoidmacro,indexoidmacro) extern int no_such_variable65 66/*67 * These lines are processed by genbki.pl to create the statements68 * the bootstrap parser will turn into DefineIndex calls.69 *70 * The keyword is DECLARE_INDEX or DECLARE_UNIQUE_INDEX or71 * DECLARE_UNIQUE_INDEX_PKEY. ("PKEY" marks the index as being the catalog's72 * primary key; currently this is only cosmetically different from a regular73 * unique index. By convention, we usually make a catalog's OID column its74 * pkey, if it has one.)75 *76 * The first two arguments are the index's name and OID. The third argument77 * is the name of a #define to generate for its OID. References to the index78 * in the C code should always use these #defines, not the actual index name79 * (much less the numeric OID). The rest is much like a standard 'create80 * index' SQL command.81 *82 * The macro definitions are just to keep the C compiler from spitting up.83 */84#define DECLARE_INDEX(name,oid,oidmacro,decl) extern int no_such_variable85#define DECLARE_UNIQUE_INDEX(name,oid,oidmacro,decl) extern int no_such_variable86#define DECLARE_UNIQUE_INDEX_PKEY(name,oid,oidmacro,decl) extern int no_such_variable87 88/*89 * These lines inform genbki.pl about manually-assigned OIDs that do not90 * correspond to any entry in the catalog *.dat files, but should be subject91 * to uniqueness verification and renumber_oids.pl renumbering. A C macro92 * to #define the given name is emitted into the corresponding *_d.h file.93 */94#define DECLARE_OID_DEFINING_MACRO(name,oid) extern int no_such_variable95 96/*97 * These lines are processed by genbki.pl to create a table for use98 * by the pg_get_catalog_foreign_keys() function. We do not have any99 * mechanism that actually enforces foreign-key relationships in the100 * system catalogs, but it is still useful to record the intended101 * relationships in a machine-readable form.102 *103 * The keyword is DECLARE_FOREIGN_KEY[_OPT] or DECLARE_ARRAY_FOREIGN_KEY[_OPT].104 * The first argument is a parenthesized list of the referencing columns;105 * the second, the name of the referenced table; the third, a parenthesized106 * list of the referenced columns. Use of the ARRAY macros means that the107 * last referencing column is an array, each of whose elements is supposed108 * to match some entry in the last referenced column. Use of the OPT suffix109 * indicates that the referencing column(s) can be zero instead of a valid110 * reference.111 *112 * Columns that are marked with a BKI_LOOKUP rule do not need an explicit113 * DECLARE_FOREIGN_KEY macro, as genbki.pl can infer the FK relationship114 * from that. Thus, these macros are only needed in special cases.115 *116 * The macro definitions are just to keep the C compiler from spitting up.117 */118#define DECLARE_FOREIGN_KEY(cols,reftbl,refcols) extern int no_such_variable119#define DECLARE_FOREIGN_KEY_OPT(cols,reftbl,refcols) extern int no_such_variable120#define DECLARE_ARRAY_FOREIGN_KEY(cols,reftbl,refcols) extern int no_such_variable121#define DECLARE_ARRAY_FOREIGN_KEY_OPT(cols,reftbl,refcols) extern int no_such_variable122 123/* The following are never defined; they are here only for documentation. */124 125/*126 * Variable-length catalog fields (except possibly the first not nullable one)127 * should not be visible in C structures, so they are made invisible by #ifdefs128 * of an undefined symbol. See also the BOOTCOL_NULL_AUTO code in bootstrap.c129 * for how this is handled.130 */131#undef CATALOG_VARLEN132 133/*134 * There is code in some catalog headers that needs to be visible to clients,135 * but we don't want clients to include the full header because of safety136 * issues with other code in the header. To handle that, surround code that137 * should be visible to clients with "#ifdef EXPOSE_TO_CLIENT_CODE". That138 * instructs genbki.pl to copy the section when generating the corresponding139 * "_d" header, which can be included by both client and backend code.140 */141#undef EXPOSE_TO_CLIENT_CODE142 143#endif /* GENBKI_H */144 