PostgreSQL Source Code  git master
pg_database.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_database.h
4  * definition of the "database" system catalog (pg_database)
5  *
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/catalog/pg_database.h
11  *
12  * NOTES
13  * The Catalog.pm module reads this file and derives schema
14  * information.
15  *
16  *-------------------------------------------------------------------------
17  */
18 #ifndef PG_DATABASE_H
19 #define PG_DATABASE_H
20 
21 #include "catalog/genbki.h"
22 #include "catalog/pg_database_d.h"
23 
24 /* ----------------
25  * pg_database definition. cpp turns this into
26  * typedef struct FormData_pg_database
27  * ----------------
28  */
29 CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248,DatabaseRelation_Rowtype_Id) BKI_SCHEMA_MACRO
30 {
31  /* oid */
32  Oid oid;
33 
34  /* database name */
36 
37  /* owner of database */
38  Oid datdba BKI_DEFAULT(POSTGRES) BKI_LOOKUP(pg_authid);
39 
40  /* character encoding */
42 
43  /* locale provider, see pg_collation.collprovider */
45 
46  /* allowed as CREATE DATABASE template? */
48 
49  /* new connections allowed? */
51 
52  /* database has login event triggers? */
54 
55  /*
56  * Max connections allowed. Negative values have special meaning, see
57  * DATCONNLIMIT_* defines below.
58  */
60 
61  /* all Xids < this are frozen in this DB */
63 
64  /* all multixacts in the DB are >= this */
66 
67  /* default table space for this DB */
68  Oid dattablespace BKI_LOOKUP(pg_tablespace);
69 
70 #ifdef CATALOG_VARLEN /* variable-length fields start here */
71  /* LC_COLLATE setting */
72  text datcollate BKI_FORCE_NOT_NULL;
73 
74  /* LC_CTYPE setting */
75  text datctype BKI_FORCE_NOT_NULL;
76 
77  /* ICU locale ID */
79 
80  /* ICU collation rules */
81  text daticurules;
82 
83  /* provider-dependent version of collation data */
84  text datcollversion BKI_DEFAULT(_null_);
85 
86  /* access permissions */
87  aclitem datacl[1];
88 #endif
90 
91 /* ----------------
92  * Form_pg_database corresponds to a pointer to a tuple with
93  * the format of pg_database relation.
94  * ----------------
95  */
97 
98 DECLARE_TOAST_WITH_MACRO(pg_database, 4177, 4178, PgDatabaseToastTable, PgDatabaseToastIndex);
99 
100 DECLARE_UNIQUE_INDEX(pg_database_datname_index, 2671, DatabaseNameIndexId, pg_database, btree(datname name_ops));
101 DECLARE_UNIQUE_INDEX_PKEY(pg_database_oid_index, 2672, DatabaseOidIndexId, pg_database, btree(oid oid_ops));
102 
103 MAKE_SYSCACHE(DATABASEOID, pg_database_oid_index, 4);
104 
105 /*
106  * pg_database.dat contains an entry for template1, but not for the template0
107  * or postgres databases, because those are created later in initdb.
108  * However, we still want to manually assign the OIDs for template0 and
109  * postgres, so declare those here.
110  */
111 DECLARE_OID_DEFINING_MACRO(Template0DbOid, 4);
112 DECLARE_OID_DEFINING_MACRO(PostgresDbOid, 5);
113 
114 /*
115  * Special values for pg_database.datconnlimit. Normal values are >= 0.
116  */
117 #define DATCONNLIMIT_UNLIMITED -1 /* no limit */
118 
119 /*
120  * A database is set to invalid partway through being dropped. Using
121  * datconnlimit=-2 for this purpose isn't particularly clean, but is
122  * backpatchable.
123  */
124 #define DATCONNLIMIT_INVALID_DB -2
125 
126 extern bool database_is_invalid_form(Form_pg_database datform);
127 extern bool database_is_invalid_oid(Oid dboid);
128 
129 #endif /* PG_DATABASE_H */
signed int int32
Definition: c.h:494
uint32 TransactionId
Definition: c.h:652
#define BKI_FORCE_NOT_NULL
Definition: genbki.h:33
#define BKI_SHARED_RELATION
Definition: genbki.h:27
#define BKI_ROWTYPE_OID(oid, oidmacro)
Definition: genbki.h:28
static char * datlocale
Definition: initdb.c:149
Oid dattablespace BKI_LOOKUP(pg_tablespace)
TransactionId datfrozenxid
Definition: pg_database.h:62
MAKE_SYSCACHE(DATABASEOID, pg_database_oid_index, 4)
TransactionId datminmxid
Definition: pg_database.h:65
char datlocprovider
Definition: pg_database.h:44
FormData_pg_database * Form_pg_database
Definition: pg_database.h:96
DatabaseRelation_Rowtype_Id BKI_SCHEMA_MACRO
Definition: pg_database.h:30
NameData datname
Definition: pg_database.h:35
bool database_is_invalid_form(Form_pg_database datform)
Definition: dbcommands.c:3177
int32 encoding
Definition: pg_database.h:41
DECLARE_OID_DEFINING_MACRO(Template0DbOid, 4)
FormData_pg_database
Definition: pg_database.h:89
bool datallowconn
Definition: pg_database.h:50
DECLARE_UNIQUE_INDEX_PKEY(pg_database_oid_index, 2672, DatabaseOidIndexId, pg_database, btree(oid oid_ops))
DECLARE_UNIQUE_INDEX(pg_database_datname_index, 2671, DatabaseNameIndexId, pg_database, btree(datname name_ops))
DECLARE_TOAST_WITH_MACRO(pg_database, 4177, 4178, PgDatabaseToastTable, PgDatabaseToastIndex)
bool datistemplate
Definition: pg_database.h:47
int32 datconnlimit
Definition: pg_database.h:59
bool dathasloginevt
Definition: pg_database.h:53
Oid datdba BKI_DEFAULT(POSTGRES) BKI_LOOKUP(pg_authid)
CATALOG(pg_database, 1262, DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248
bool database_is_invalid_oid(Oid dboid)
Definition: dbcommands.c:3187
unsigned int Oid
Definition: postgres_ext.h:31
Definition: c.h:741
Definition: c.h:687