PostgreSQL Source Code
git master
Loading...
Searching...
No Matches
genbki.h
Go to the documentation of this file.
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-2026, 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
22
/*
23
* These macros should be written before and after each catalog structure
24
* definition. On most platforms they do nothing, but on some platforms
25
* we need special hacks to coax the compiler into laying out the catalog
26
* struct compatibly with our tuple forming/deforming rules.
27
*
28
* On AIX, where ALIGNOF_DOUBLE < ALIGNOF_INT64_T, we need to coerce int64
29
* catalog fields to be aligned on just 4-byte boundaries. Ideally we'd
30
* write this like pack(push,ALIGNOF_DOUBLE), but gcc seems unwilling
31
* to take anything but a plain string literal as the argument of _Pragma.
32
*/
33
#if ALIGNOF_DOUBLE < ALIGNOF_INT64_T
34
#define BEGIN_CATALOG_STRUCT _Pragma("pack(push,4)")
35
#define END_CATALOG_STRUCT _Pragma("pack(pop)")
36
#else
37
#define BEGIN_CATALOG_STRUCT
38
#define END_CATALOG_STRUCT
39
#endif
40
41
/* Introduces a catalog's structure definition */
42
#define CATALOG(name,oid,oidmacro) typedef struct CppConcat(FormData_,name)
43
44
/* Options that may appear after CATALOG (on the same line) */
45
#define BKI_BOOTSTRAP
46
#define BKI_SHARED_RELATION
47
#define BKI_ROWTYPE_OID(oid,oidmacro)
48
#define BKI_SCHEMA_MACRO
49
50
/* Options that may appear after an attribute (on the same line) */
51
#define BKI_FORCE_NULL
52
#define BKI_FORCE_NOT_NULL
53
/* Specifies a default value for a catalog field */
54
#define BKI_DEFAULT(value)
55
/* Specifies a default value for auto-generated array types */
56
#define BKI_ARRAY_DEFAULT(value)
57
/*
58
* Indicates that the attribute contains OIDs referencing the named catalog;
59
* can be applied to columns of oid, regproc, oid[], or oidvector type.
60
* genbki.pl uses this to know how to perform name lookups in the initial
61
* data (if any), and it also feeds into regression-test validity checks.
62
* The _OPT suffix indicates that values can be zero instead of
63
* a valid OID reference.
64
*/
65
#define BKI_LOOKUP(catalog)
66
#define BKI_LOOKUP_OPT(catalog)
67
68
/*
69
* These lines are processed by genbki.pl to create the statements
70
* the bootstrap parser will turn into BootstrapToastTable commands.
71
* Each line specifies the system catalog that needs a toast table,
72
* the OID to assign to the toast table, and the OID to assign to the
73
* toast table's index. The reason we hard-wire these OIDs is that we
74
* need stable OIDs for shared relations, and that includes toast tables
75
* of shared relations.
76
*
77
* The DECLARE_TOAST_WITH_MACRO variant is used when C macros are needed
78
* for the toast table/index OIDs (usually only for shared catalogs).
79
*
80
* The macro definitions are just to keep the C compiler from spitting up.
81
*/
82
#define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
83
#define DECLARE_TOAST_WITH_MACRO(name,toastoid,indexoid,toastoidmacro,indexoidmacro) extern int no_such_variable
84
85
/*
86
* These lines are processed by genbki.pl to create the statements
87
* the bootstrap parser will turn into DefineIndex calls.
88
*
89
* The keyword is DECLARE_INDEX or DECLARE_UNIQUE_INDEX or
90
* DECLARE_UNIQUE_INDEX_PKEY. ("PKEY" marks the index as being the catalog's
91
* primary key; currently this is only cosmetically different from a regular
92
* unique index. By convention, we usually make a catalog's OID column its
93
* pkey, if it has one.)
94
*
95
* The first two arguments are the index's name and OID. The third argument
96
* is the name of a #define to generate for its OID. References to the index
97
* in the C code should always use these #defines, not the actual index name
98
* (much less the numeric OID). The fourth argument is the table name. The
99
* rest is much like a standard 'create index' SQL command.
100
*
101
* The macro definitions are just to keep the C compiler from spitting up.
102
*/
103
#define DECLARE_INDEX(name,oid,oidmacro,tblname,decl) extern int no_such_variable
104
#define DECLARE_UNIQUE_INDEX(name,oid,oidmacro,tblname,decl) extern int no_such_variable
105
#define DECLARE_UNIQUE_INDEX_PKEY(name,oid,oidmacro,tblname,decl) extern int no_such_variable
106
107
/*
108
* These lines inform genbki.pl about manually-assigned OIDs that do not
109
* correspond to any entry in the catalog *.dat files, but should be subject
110
* to uniqueness verification and renumber_oids.pl renumbering. A C macro
111
* to #define the given name is emitted into the corresponding *_d.h file.
112
*/
113
#define DECLARE_OID_DEFINING_MACRO(name,oid) extern int no_such_variable
114
115
/*
116
* These lines are processed by genbki.pl to create a table for use
117
* by the pg_get_catalog_foreign_keys() function. We do not have any
118
* mechanism that actually enforces foreign-key relationships in the
119
* system catalogs, but it is still useful to record the intended
120
* relationships in a machine-readable form.
121
*
122
* The keyword is DECLARE_FOREIGN_KEY[_OPT] or DECLARE_ARRAY_FOREIGN_KEY[_OPT].
123
* The first argument is a parenthesized list of the referencing columns;
124
* the second, the name of the referenced table; the third, a parenthesized
125
* list of the referenced columns. Use of the ARRAY macros means that the
126
* last referencing column is an array, each of whose elements is supposed
127
* to match some entry in the last referenced column. Use of the OPT suffix
128
* indicates that the referencing column(s) can be zero instead of a valid
129
* reference.
130
*
131
* Columns that are marked with a BKI_LOOKUP rule do not need an explicit
132
* DECLARE_FOREIGN_KEY macro, as genbki.pl can infer the FK relationship
133
* from that. Thus, these macros are only needed in special cases.
134
*
135
* The macro definitions are just to keep the C compiler from spitting up.
136
*/
137
#define DECLARE_FOREIGN_KEY(cols,reftbl,refcols) extern int no_such_variable
138
#define DECLARE_FOREIGN_KEY_OPT(cols,reftbl,refcols) extern int no_such_variable
139
#define DECLARE_ARRAY_FOREIGN_KEY(cols,reftbl,refcols) extern int no_such_variable
140
#define DECLARE_ARRAY_FOREIGN_KEY_OPT(cols,reftbl,refcols) extern int no_such_variable
141
142
/*
143
* Create a syscache with the given name, index, and bucket size. See
144
* syscache.c.
145
*/
146
#define MAKE_SYSCACHE(name,idxname,nbuckets) extern int no_such_variable
147
148
/* The following are never defined; they are here only for documentation. */
149
150
/*
151
* Variable-length catalog fields (except possibly the first not nullable one)
152
* should not be visible in C structures, so they are made invisible by #ifdefs
153
* of an undefined symbol. See also the BOOTCOL_NULL_AUTO code in bootstrap.c
154
* for how this is handled.
155
*/
156
#undef CATALOG_VARLEN
157
158
/*
159
* There is code in some catalog headers that needs to be visible to clients,
160
* but we don't want clients to include the full header because of safety
161
* issues with other code in the header. To handle that, surround code that
162
* should be visible to clients with "#ifdef EXPOSE_TO_CLIENT_CODE". That
163
* instructs genbki.pl to copy the section when generating the corresponding
164
* "_d" header, which can be included by both client and backend code.
165
*/
166
#undef EXPOSE_TO_CLIENT_CODE
167
168
#endif
/* GENBKI_H */
src
include
catalog
genbki.h
Generated on Wed Mar 11 2026 06:13:16 for PostgreSQL Source Code by
1.9.8