PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_database.h File Reference
#include "catalog/genbki.h"
#include "catalog/pg_database_d.h"
Include dependency graph for pg_database.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DATCONNLIMIT_UNLIMITED   -1 /* no limit */
 
#define DATCONNLIMIT_INVALID_DB   -2
 

Typedefs

typedef FormData_pg_databaseForm_pg_database
 

Functions

 CATALOG (pg_database, 1262, DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248
 
Oid datdba BKI_DEFAULT (POSTGRES) BKI_LOOKUP(pg_authid)
 
Oid dattablespace BKI_LOOKUP (pg_tablespace)
 
 DECLARE_TOAST_WITH_MACRO (pg_database, 4177, 4178, PgDatabaseToastTable, PgDatabaseToastIndex)
 
 DECLARE_UNIQUE_INDEX (pg_database_datname_index, 2671, DatabaseNameIndexId, pg_database, btree(datname name_ops))
 
 DECLARE_UNIQUE_INDEX_PKEY (pg_database_oid_index, 2672, DatabaseOidIndexId, pg_database, btree(oid oid_ops))
 
 MAKE_SYSCACHE (DATABASEOID, pg_database_oid_index, 4)
 
 DECLARE_OID_DEFINING_MACRO (Template0DbOid, 4)
 
 DECLARE_OID_DEFINING_MACRO (PostgresDbOid, 5)
 
Oid get_database_oid (const char *dbname, bool missing_ok)
 
bool database_is_invalid_form (Form_pg_database datform)
 
bool database_is_invalid_oid (Oid dboid)
 

Variables

DatabaseRelation_Rowtype_Id BKI_SCHEMA_MACRO
 
NameData datname
 
int32 encoding
 
char datlocprovider
 
bool datistemplate
 
bool datallowconn
 
bool dathasloginevt
 
int32 datconnlimit
 
TransactionId datfrozenxid
 
TransactionId datminmxid
 
 FormData_pg_database
 

Macro Definition Documentation

◆ DATCONNLIMIT_INVALID_DB

#define DATCONNLIMIT_INVALID_DB   -2

Definition at line 124 of file pg_database.h.

◆ DATCONNLIMIT_UNLIMITED

#define DATCONNLIMIT_UNLIMITED   -1 /* no limit */

Definition at line 117 of file pg_database.h.

Typedef Documentation

◆ Form_pg_database

Function Documentation

◆ BKI_DEFAULT()

Oid datdba BKI_DEFAULT ( POSTGRES  )

◆ BKI_LOOKUP()

Oid dattablespace BKI_LOOKUP ( pg_tablespace  )

◆ CATALOG()

CATALOG ( pg_database  ,
1262  ,
DatabaseRelationId   
)

◆ database_is_invalid_form()

bool database_is_invalid_form ( Form_pg_database  datform)
extern

Definition at line 3215 of file dbcommands.c.

3216{
3217 return datform->datconnlimit == DATCONNLIMIT_INVALID_DB;
3218}
#define DATCONNLIMIT_INVALID_DB
static int fb(int x)

References DATCONNLIMIT_INVALID_DB, and fb().

Referenced by AlterDatabase(), database_is_invalid_oid(), get_database_list(), InitPostgres(), and vac_truncate_clog().

◆ database_is_invalid_oid()

bool database_is_invalid_oid ( Oid  dboid)
extern

Definition at line 3225 of file dbcommands.c.

3226{
3229 bool invalid;
3230
3232 if (!HeapTupleIsValid(dbtup))
3233 elog(ERROR, "cache lookup failed for database %u", dboid);
3235
3237
3239
3240 return invalid;
3241}
bool database_is_invalid_form(Form_pg_database datform)
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
#define HeapTupleIsValid(tuple)
Definition htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
invalidindex index d is invalid
Definition isn.c:138
FormData_pg_database * Form_pg_database
Definition pg_database.h:96
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
void ReleaseSysCache(HeapTuple tuple)
Definition syscache.c:264
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition syscache.c:220

References database_is_invalid_form(), elog, ERROR, fb(), GETSTRUCT(), HeapTupleIsValid, invalid, ObjectIdGetDatum(), ReleaseSysCache(), and SearchSysCache1().

Referenced by createdb().

◆ DECLARE_OID_DEFINING_MACRO() [1/2]

DECLARE_OID_DEFINING_MACRO ( PostgresDbOid  ,
 
)

◆ DECLARE_OID_DEFINING_MACRO() [2/2]

DECLARE_OID_DEFINING_MACRO ( Template0DbOid  ,
 
)

◆ DECLARE_TOAST_WITH_MACRO()

DECLARE_TOAST_WITH_MACRO ( pg_database  ,
4177  ,
4178  ,
PgDatabaseToastTable  ,
PgDatabaseToastIndex   
)

◆ DECLARE_UNIQUE_INDEX()

DECLARE_UNIQUE_INDEX ( pg_database_datname_index  ,
2671  ,
DatabaseNameIndexId  ,
pg_database  ,
btree(datname name_ops  
)

◆ DECLARE_UNIQUE_INDEX_PKEY()

DECLARE_UNIQUE_INDEX_PKEY ( pg_database_oid_index  ,
2672  ,
DatabaseOidIndexId  ,
pg_database  ,
btree(oid oid_ops  
)

◆ get_database_oid()

Oid get_database_oid ( const char dbname,
bool  missing_ok 
)
extern

Definition at line 3168 of file dbcommands.c.

3169{
3171 ScanKeyData entry[1];
3172 SysScanDesc scan;
3174 Oid oid;
3175
3176 /*
3177 * There's no syscache for pg_database indexed by name, so we must look
3178 * the hard way.
3179 */
3181 ScanKeyInit(&entry[0],
3186 NULL, 1, entry);
3187
3188 dbtuple = systable_getnext(scan);
3189
3190 /* We assume that there can be at most one matching tuple */
3192 oid = ((Form_pg_database) GETSTRUCT(dbtuple))->oid;
3193 else
3194 oid = InvalidOid;
3195
3196 systable_endscan(scan);
3198
3199 if (!OidIsValid(oid) && !missing_ok)
3200 ereport(ERROR,
3202 errmsg("database \"%s\" does not exist",
3203 dbname)));
3204
3205 return oid;
3206}
#define OidIsValid(objectId)
Definition c.h:788
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define ereport(elevel,...)
Definition elog.h:150
void systable_endscan(SysScanDesc sysscan)
Definition genam.c:603
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition genam.c:514
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition genam.c:388
#define AccessShareLock
Definition lockdefs.h:36
static Datum CStringGetDatum(const char *X)
Definition postgres.h:380
#define InvalidOid
unsigned int Oid
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition scankey.c:76
#define BTEqualStrategyNumber
Definition stratnum.h:31
char * dbname
Definition streamutil.c:49
void table_close(Relation relation, LOCKMODE lockmode)
Definition table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition table.c:40

References AccessShareLock, BTEqualStrategyNumber, CStringGetDatum(), dbname, ereport, errcode(), errmsg(), ERROR, fb(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, OidIsValid, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().

Referenced by AlterDatabaseSet(), AlterRoleSet(), CommentObject(), convert_database_name(), createdb(), get_object_address_unqualified(), pg_database_size_name(), regdatabasein(), RenameDatabase(), sepgsql_database_post_create(), synchronize_slots(), and worker_spi_launch().

◆ MAKE_SYSCACHE()

MAKE_SYSCACHE ( DATABASEOID  ,
pg_database_oid_index  ,
 
)

Variable Documentation

◆ BKI_SCHEMA_MACRO

DatabaseRelation_Rowtype_Id BKI_SCHEMA_MACRO
Initial value:
{
Oid oid

Definition at line 29 of file pg_database.h.

◆ datallowconn

bool datallowconn

Definition at line 50 of file pg_database.h.

Referenced by check_for_connection_status(), and set_frozenxids().

◆ datconnlimit

int32 datconnlimit

Definition at line 59 of file pg_database.h.

Referenced by check_for_connection_status(), and dumpDatabase().

◆ datfrozenxid

TransactionId datfrozenxid

Definition at line 62 of file pg_database.h.

Referenced by vac_truncate_clog().

◆ dathasloginevt

bool dathasloginevt

Definition at line 53 of file pg_database.h.

◆ datistemplate

bool datistemplate

Definition at line 47 of file pg_database.h.

Referenced by dumpDatabase().

◆ datlocprovider

char datlocprovider

◆ datminmxid

TransactionId datminmxid

Definition at line 65 of file pg_database.h.

Referenced by vac_truncate_clog().

◆ datname

◆ encoding

int32 encoding

Definition at line 41 of file pg_database.h.

◆ FormData_pg_database

FormData_pg_database

Definition at line 89 of file pg_database.h.

Referenced by vac_truncate_clog().