codekingpro/portable-devtools
115k
1/*-------------------------------------------------------------------------2 *3 * pg_database.h4 * definition of the "database" system catalog (pg_database)5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/catalog/pg_database.h11 *12 * NOTES13 * The Catalog.pm module reads this file and derives schema14 * information.15 *16 *-------------------------------------------------------------------------17 */18#ifndef PG_DATABASE_H19#define PG_DATABASE_H20 21#include "catalog/genbki.h"22#include "catalog/pg_database_d.h"23 24/* ----------------25 * pg_database definition. cpp turns this into26 * typedef struct FormData_pg_database27 * ----------------28 */29CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248,DatabaseRelation_Rowtype_Id) BKI_SCHEMA_MACRO30{31 /* oid */32 Oid oid;33 34 /* database name */35 NameData datname;36 37 /* owner of database */38 Oid datdba BKI_DEFAULT(POSTGRES) BKI_LOOKUP(pg_authid);39 40 /* character encoding */41 int32 encoding;42 43 /* locale provider, see pg_collation.collprovider */44 char datlocprovider;45 46 /* allowed as CREATE DATABASE template? */47 bool datistemplate;48 49 /* new connections allowed? */50 bool datallowconn;51 52 /*53 * Max connections allowed. Negative values have special meaning, see54 * DATCONNLIMIT_* defines below.55 */56 int32 datconnlimit;57 58 /* all Xids < this are frozen in this DB */59 TransactionId datfrozenxid;60 61 /* all multixacts in the DB are >= this */62 TransactionId datminmxid;63 64 /* default table space for this DB */65 Oid dattablespace BKI_LOOKUP(pg_tablespace);66 67#ifdef CATALOG_VARLEN /* variable-length fields start here */68 /* LC_COLLATE setting */69 text datcollate BKI_FORCE_NOT_NULL;70 71 /* LC_CTYPE setting */72 text datctype BKI_FORCE_NOT_NULL;73 74 /* ICU locale ID */75 text daticulocale;76 77 /* ICU collation rules */78 text daticurules;79 80 /* provider-dependent version of collation data */81 text datcollversion BKI_DEFAULT(_null_);82 83 /* access permissions */84 aclitem datacl[1];85#endif86} FormData_pg_database;87 88/* ----------------89 * Form_pg_database corresponds to a pointer to a tuple with90 * the format of pg_database relation.91 * ----------------92 */93typedef FormData_pg_database *Form_pg_database;94 95DECLARE_TOAST_WITH_MACRO(pg_database, 4177, 4178, PgDatabaseToastTable, PgDatabaseToastIndex);96 97DECLARE_UNIQUE_INDEX(pg_database_datname_index, 2671, DatabaseNameIndexId, on pg_database using btree(datname name_ops));98DECLARE_UNIQUE_INDEX_PKEY(pg_database_oid_index, 2672, DatabaseOidIndexId, on pg_database using btree(oid oid_ops));99 100/*101 * pg_database.dat contains an entry for template1, but not for the template0102 * or postgres databases, because those are created later in initdb.103 * However, we still want to manually assign the OIDs for template0 and104 * postgres, so declare those here.105 */106DECLARE_OID_DEFINING_MACRO(Template0DbOid, 4);107DECLARE_OID_DEFINING_MACRO(PostgresDbOid, 5);108 109/*110 * Special values for pg_database.datconnlimit. Normal values are >= 0.111 */112#define DATCONNLIMIT_UNLIMITED -1 /* no limit */113 114/*115 * A database is set to invalid partway through being dropped. Using116 * datconnlimit=-2 for this purpose isn't particularly clean, but is117 * backpatchable.118 */119#define DATCONNLIMIT_INVALID_DB -2120 121extern bool database_is_invalid_form(Form_pg_database datform);122extern bool database_is_invalid_oid(Oid dboid);123 124#endif /* PG_DATABASE_H */125 