1 /*-------------------------------------------------------------------------
4 * definition of the "database" system catalog (pg_database)
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/catalog/pg_database.h
13 * The Catalog.pm module reads this file and derives schema
16 *-------------------------------------------------------------------------
21 #include "catalog/genbki.h"
22 #include "catalog/pg_database_d.h" /* IWYU pragma: export */
25 * pg_database definition. cpp turns this into
26 * typedef struct FormData_pg_database
29 CATALOG(pg_database
,1262,DatabaseRelationId
) BKI_SHARED_RELATION
BKI_ROWTYPE_OID(1248,DatabaseRelation_Rowtype_Id
) BKI_SCHEMA_MACRO
37 /* owner of database */
38 Oid datdba
BKI_DEFAULT(POSTGRES
) BKI_LOOKUP(pg_authid
);
40 /* character encoding */
43 /* locale provider, see pg_collation.collprovider */
46 /* allowed as CREATE DATABASE template? */
49 /* new connections allowed? */
52 /* database has login event triggers? */
56 * Max connections allowed. Negative values have special meaning, see
57 * DATCONNLIMIT_* defines below.
61 /* all Xids < this are frozen in this DB */
62 TransactionId datfrozenxid
;
64 /* all multixacts in the DB are >= this */
65 TransactionId datminmxid
;
67 /* default table space for this DB */
68 Oid dattablespace
BKI_LOOKUP(pg_tablespace
);
70 #ifdef CATALOG_VARLEN /* variable-length fields start here */
71 /* LC_COLLATE setting */
72 text datcollate BKI_FORCE_NOT_NULL
;
74 /* LC_CTYPE setting */
75 text datctype BKI_FORCE_NOT_NULL
;
80 /* ICU collation rules */
83 /* provider-dependent version of collation data */
84 text datcollversion
BKI_DEFAULT(_null_
);
86 /* access permissions */
89 } FormData_pg_database
;
92 * Form_pg_database corresponds to a pointer to a tuple with
93 * the format of pg_database relation.
96 typedef FormData_pg_database
*Form_pg_database
;
98 DECLARE_TOAST_WITH_MACRO(pg_database
, 4177, 4178, PgDatabaseToastTable
, PgDatabaseToastIndex
);
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
));
103 MAKE_SYSCACHE(DATABASEOID
, pg_database_oid_index
, 4);
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.
111 DECLARE_OID_DEFINING_MACRO(Template0DbOid
, 4);
112 DECLARE_OID_DEFINING_MACRO(PostgresDbOid
, 5);
115 * Special values for pg_database.datconnlimit. Normal values are >= 0.
117 #define DATCONNLIMIT_UNLIMITED -1 /* no limit */
120 * A database is set to invalid partway through being dropped. Using
121 * datconnlimit=-2 for this purpose isn't particularly clean, but is
124 #define DATCONNLIMIT_INVALID_DB -2
126 extern bool database_is_invalid_form(Form_pg_database datform
);
127 extern bool database_is_invalid_oid(Oid dboid
);
129 #endif /* PG_DATABASE_H */