PostgreSQL Source Code git master
Macros | Typedefs | Functions | Variables
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

 

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)
 
 
 

Variables

DatabaseRelation_Rowtype_Id  BKI_SCHEMA_MACRO
 
 
 
 
bool  datistemplate
 
bool  datallowconn
 
 
 
 
 
 

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

Definition at line 96 of file pg_database.h.

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 )

Definition at line 3214 of file dbcommands.c.

3215{
3216 return datform->datconnlimit == DATCONNLIMIT_INVALID_DB;
3217}
#define DATCONNLIMIT_INVALID_DB
Definition: pg_database.h:124

References DATCONNLIMIT_INVALID_DB.

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 )

Definition at line 3224 of file dbcommands.c.

3225{
3226 HeapTuple dbtup;
3227 Form_pg_database dbform;
3228 bool invalid;
3229
3230 dbtup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dboid));
3231 if (!HeapTupleIsValid(dbtup))
3232 elog(ERROR, "cache lookup failed for database %u", dboid);
3233 dbform = (Form_pg_database) GETSTRUCT(dbtup);
3234
3236
3237 ReleaseSysCache(dbtup);
3238
3239 return invalid;
3240}
bool database_is_invalid_form(Form_pg_database datform)
Definition: dbcommands.c:3214
#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)
Definition: htup_details.h:728
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, GETSTRUCT(), HeapTupleIsValid, invalid, ObjectIdGetDatum(), ReleaseSysCache(), and SearchSysCache1().

Referenced by createdb().

DECLARE_OID_DEFINING_MACRO() [1/2]

DECLARE_OID_DEFINING_MACRO ( PostgresDbOid  ,
5   
)

DECLARE_OID_DEFINING_MACRO() [2/2]

DECLARE_OID_DEFINING_MACRO ( Template0DbOid  ,
4   
)

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 
)

Definition at line 3167 of file dbcommands.c.

3168{
3169 Relation pg_database;
3170 ScanKeyData entry[1];
3171 SysScanDesc scan;
3172 HeapTuple dbtuple;
3173 Oid oid;
3174
3175 /*
3176 * There's no syscache for pg_database indexed by name, so we must look
3177 * the hard way.
3178 */
3179 pg_database = table_open(DatabaseRelationId, AccessShareLock);
3180 ScanKeyInit(&entry[0],
3181 Anum_pg_database_datname,
3182 BTEqualStrategyNumber, F_NAMEEQ,
3184 scan = systable_beginscan(pg_database, DatabaseNameIndexId, true,
3185 NULL, 1, entry);
3186
3187 dbtuple = systable_getnext(scan);
3188
3189 /* We assume that there can be at most one matching tuple */
3190 if (HeapTupleIsValid(dbtuple))
3191 oid = ((Form_pg_database) GETSTRUCT(dbtuple))->oid;
3192 else
3193 oid = InvalidOid;
3194
3195 systable_endscan(scan);
3196 table_close(pg_database, AccessShareLock);
3197
3198 if (!OidIsValid(oid) && !missing_ok)
3199 ereport(ERROR,
3200 (errcode(ERRCODE_UNDEFINED_DATABASE),
3201 errmsg("database \"%s\" does not exist",
3202 dbname)));
3203
3204 return oid;
3205}
#define OidIsValid(objectId)
Definition: c.h:774
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#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:360
#define InvalidOid
Definition: postgres_ext.h:37
unsigned int Oid
Definition: postgres_ext.h:32
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
Definition: rel.h:56
Definition: skey.h:65
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, 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  ,
4   
)

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

Definition at line 44 of file pg_database.h.

Referenced by dumpDatabase(), pg_collation_actual_version(), and pg_database_collation_actual_version().

datminmxid

TransactionId datminmxid

Definition at line 65 of file pg_database.h.

Referenced by vac_truncate_clog().

datname

NameData datname

Definition at line 35 of file pg_database.h.

Referenced by check_for_connection_status(), compile_database_list(), dumpDatabase(), get_database_name(), getObjectDescription(), getObjectIdentityParts(), progress_report(), RenameDatabase(), and set_frozenxids().

encoding

int32 encoding

Definition at line 41 of file pg_database.h.

Referenced by append_btree_pattern(), append_database_pattern(), append_heap_pattern(), append_relation_pattern(), append_relation_pattern_helper(), append_schema_pattern(), appendReloptionsArray(), appendStringLiteral(), ascii(), assign_client_encoding(), builtin_validate_locale(), cache_locale_time(), cache_single_string(), canonicalize_path_enc(), CATALOG(), check_client_encoding(), check_encoding_locale_matches(), chr(), createdb(), db_encoding_convert(), dequote_downcase_identifier(), dumpDatabase(), encoding_conflicts_ascii(), entry_alloc(), exec_command_encoding(), fmtIdEnc(), fmtQualifiedIdEnc(), get_encoding_name_for_icu(), get_json_format(), getJsonEncodingConst(), is_encoding_supported_by_icu(), iso8859_to_utf8(), latin2mic(), latin2mic_with_table(), LocalToUtf(), lookup_collation(), main(), makeJsonByteaToTextConversion(), makeJsonFormat(), makeJsonLexContextCstringLen(), makeJsonLexContextIncremental(), mbvalidate(), mic2latin(), mic2latin_with_table(), patternToSQLRegex(), pg_any_to_server(), pg_encoding_dsplen(), pg_encoding_max_length(), pg_encoding_max_length_sql(), pg_encoding_mb2wchar_with_len(), pg_encoding_mbcliplen(), pg_encoding_mblen(), pg_encoding_mblen_bounded(), pg_encoding_mblen_or_incomplete(), pg_encoding_set_invalid(), pg_encoding_to_char(), PG_encoding_to_char(), pg_encoding_verifymbchar(), pg_encoding_verifymbstr(), pg_encoding_wchar2mb_with_len(), pg_server_to_any(), pg_valid_server_encoding_id(), pg_verify_mbstr(), pg_verify_mbstr_len(), pg_wcsformat(), pg_wcssize(), pg_wcswidth(), PGLC_localeconv(), pgss_store(), PQdsplen(), PQenv2encoding(), PQescapeStringInternal(), PQmblen(), PQmblenBounded(), PQsetClientEncoding(), PrepareClientEncoding(), print_aligned_text(), print_aligned_vertical(), processEncodingEntry(), psql_scan_setup(), quote_if_needed(), report_invalid_encoding(), reportErrorPosition(), SetClientEncoding(), SetDatabaseEncoding(), setFmtEncoding(), SetMessageEncoding(), splitTableColumnsSpec(), strip_quotes(), strlen_max_width(), strtokx(), utf8_to_iso8859(), utf8_to_win(), UtfToLocal(), win_to_utf8(), and xml_recv().

FormData_pg_database

FormData_pg_database

Definition at line 89 of file pg_database.h.

Referenced by vac_truncate_clog().

AltStyle によって変換されたページ (->オリジナル) /