pg_database.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pg_database.h
  4. * definition of the "database" system catalog (pg_database)
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2022, 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. #include "catalog/genbki.h"
  21. #include "catalog/pg_database_d.h"
  22. /* ----------------
  23. * pg_database definition. cpp turns this into
  24. * typedef struct FormData_pg_database
  25. * ----------------
  26. */
  27. CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248,DatabaseRelation_Rowtype_Id) BKI_SCHEMA_MACRO
  28. {
  29. /* oid */
  30. Oid oid;
  31. /* database name */
  32. NameData datname;
  33. /* owner of database */
  34. Oid datdba BKI_DEFAULT(POSTGRES) BKI_LOOKUP(pg_authid);
  35. /* character encoding */
  36. int32 encoding;
  37. /* locale provider, see pg_collation.collprovider */
  38. char datlocprovider;
  39. /* allowed as CREATE DATABASE template? */
  40. bool datistemplate;
  41. /* new connections allowed? */
  42. bool datallowconn;
  43. /*
  44. * Max connections allowed. Negative values have special meaning, see
  45. * DATCONNLIMIT_* defines below.
  46. */
  47. int32 datconnlimit;
  48. /* all Xids < this are frozen in this DB */
  49. TransactionId datfrozenxid;
  50. /* all multixacts in the DB are >= this */
  51. TransactionId datminmxid;
  52. /* default table space for this DB */
  53. Oid dattablespace BKI_LOOKUP(pg_tablespace);
  54. #ifdef CATALOG_VARLEN /* variable-length fields start here */
  55. /* LC_COLLATE setting */
  56. text datcollate BKI_FORCE_NOT_NULL;
  57. /* LC_CTYPE setting */
  58. text datctype BKI_FORCE_NOT_NULL;
  59. /* ICU locale ID */
  60. text daticulocale;
  61. /* provider-dependent version of collation data */
  62. text datcollversion BKI_DEFAULT(_null_);
  63. /* access permissions */
  64. aclitem datacl[1];
  65. #endif
  66. } FormData_pg_database;
  67. /* ----------------
  68. * Form_pg_database corresponds to a pointer to a tuple with
  69. * the format of pg_database relation.
  70. * ----------------
  71. */
  72. typedef FormData_pg_database *Form_pg_database;
  73. DECLARE_TOAST_WITH_MACRO(pg_database, 4177, 4178, PgDatabaseToastTable, PgDatabaseToastIndex);
  74. DECLARE_UNIQUE_INDEX(pg_database_datname_index, 2671, DatabaseNameIndexId, on pg_database using btree(datname name_ops));
  75. DECLARE_UNIQUE_INDEX_PKEY(pg_database_oid_index, 2672, DatabaseOidIndexId, on pg_database using btree(oid oid_ops));
  76. /*
  77. * pg_database.dat contains an entry for template1, but not for the template0
  78. * or postgres databases, because those are created later in initdb.
  79. * However, we still want to manually assign the OIDs for template0 and
  80. * postgres, so declare those here.
  81. */
  82. DECLARE_OID_DEFINING_MACRO(Template0DbOid, 4);
  83. DECLARE_OID_DEFINING_MACRO(PostgresDbOid, 5);
  84. /*
  85. * Special values for pg_database.datconnlimit. Normal values are >= 0.
  86. */
  87. #define DATCONNLIMIT_UNLIMITED -1 /* no limit */
  88. /*
  89. * A database is set to invalid partway through being dropped. Using
  90. * datconnlimit=-2 for this purpose isn't particularly clean, but is
  91. * backpatchable.
  92. */
  93. #define DATCONNLIMIT_INVALID_DB -2
  94. extern bool database_is_invalid_form(Form_pg_database datform);
  95. extern bool database_is_invalid_oid(Oid dboid);
  96. #endif /* PG_DATABASE_H */