PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include "access/genam.h"
#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/multixact.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "access/xloginsert.h"
#include "access/xlogutils.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
#include "catalog/pg_subscription.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
#include "commands/dbcommands_xlog.h"
#include "commands/defrem.h"
#include "commands/seclabel.h"
#include "commands/tablespace.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postmaster/bgwriter.h"
#include "replication/slot.h"
#include "storage/copydir.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/lmgr.h"
#include "storage/md.h"
#include "storage/procarray.h"
#include "storage/smgr.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/pg_locale.h"
#include "utils/relmapper.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | createdb_failure_params |
struct | movedb_failure_params |
struct | CreateDBRelInfo |
Typedefs | |
typedef enum CreateDBStrategy | CreateDBStrategy |
typedef struct CreateDBRelInfo | CreateDBRelInfo |
Enumerations | |
enum | CreateDBStrategy { CREATEDB_WAL_LOG , CREATEDB_FILE_COPY } |
Functions | |
static void | createdb_failure_callback (int code, Datum arg) |
static void | movedb (const char *dbname, const char *tblspcname) |
static void | movedb_failure_callback (int code, Datum arg) |
static bool | get_db_info (const char *name, LOCKMODE lockmode, Oid *dbIdP, Oid *ownerIdP, int *encodingP, bool *dbIsTemplateP, bool *dbAllowConnP, TransactionId *dbFrozenXidP, MultiXactId *dbMinMultiP, Oid *dbTablespace, char **dbCollate, char **dbCtype, char **dbIculocale, char *dbLocProvider, char **dbCollversion) |
static bool | have_createdb_privilege (void) |
static void | remove_dbtablespaces (Oid db_id) |
static bool | check_db_file_conflict (Oid db_id) |
static int | errdetail_busy_db (int notherbackends, int npreparedxacts) |
static void | CreateDatabaseUsingWalLog (Oid src_dboid, Oid dboid, Oid src_tsid, Oid dst_tsid) |
static List * | ScanSourceDatabasePgClass (Oid srctbid, Oid srcdbid, char *srcpath) |
static List * | ScanSourceDatabasePgClassPage (Page page, Buffer buf, Oid tbid, Oid dbid, char *srcpath, List *rnodelist, Snapshot snapshot) |
static CreateDBRelInfo * | ScanSourceDatabasePgClassTuple (HeapTupleData *tuple, Oid tbid, Oid dbid, char *srcpath) |
static void | CreateDirAndVersionFile (char *dbpath, Oid dbid, Oid tsid, bool isRedo) |
static void | CreateDatabaseUsingFileCopy (Oid src_dboid, Oid dboid, Oid src_tsid, Oid dst_tsid) |
Oid | createdb (ParseState *pstate, const CreatedbStmt *stmt) |
void | check_encoding_locale_matches (int encoding, const char *collate, const char *ctype) |
void | dropdb (const char *dbname, bool missing_ok, bool force) |
ObjectAddress | RenameDatabase (const char *oldname, const char *newname) |
void | DropDatabase (ParseState *pstate, DropdbStmt *stmt) |
Oid | AlterDatabase (ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel) |
ObjectAddress | AlterDatabaseRefreshColl (AlterDatabaseRefreshCollStmt *stmt) |
Oid | AlterDatabaseSet (AlterDatabaseSetStmt *stmt) |
ObjectAddress | AlterDatabaseOwner (const char *dbname, Oid newOwnerId) |
Datum | pg_database_collation_actual_version (PG_FUNCTION_ARGS) |
Oid | get_database_oid (const char *dbname, bool missing_ok) |
char * | get_database_name (Oid dbid) |
void | dbase_redo (XLogReaderState *record) |
typedef struct CreateDBRelInfo CreateDBRelInfo |
typedef enum CreateDBStrategy CreateDBStrategy |
enum CreateDBStrategy |
Oid AlterDatabase | ( | ParseState * | pstate, |
AlterDatabaseStmt * | stmt, | ||
bool | isTopLevel | ||
) |
Definition at line 2180 of file dbcommands.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, DefElem::arg, BoolGetDatum, BTEqualStrategyNumber, CatalogTupleUpdate(), CStringGetDatum, AlterDatabaseStmt::dbname, defGetBoolean(), defGetInt32(), defGetString(), DefElem::defname, ereport, errcode(), errmsg(), ERROR, errorConflictingDefElem(), GETSTRUCT, GetUserId(), heap_modify_tuple(), HeapTupleIsValid, Int32GetDatum, InvalidOid, InvokeObjectPostAlterHook, lfirst, list_length(), DefElem::location, MemSet, movedb(), MyDatabaseId, NoLock, OBJECT_DATABASE, AlterDatabaseStmt::options, parser_errposition(), pg_database_ownercheck(), PreventInTransactionBlock(), RelationGetDescr, RowExclusiveLock, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by standard_ProcessUtility().
ObjectAddress AlterDatabaseOwner | ( | const char * | dbname, |
Oid | newOwnerId | ||
) |
Definition at line 2456 of file dbcommands.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, aclnewowner(), BTEqualStrategyNumber, CatalogTupleUpdate(), changeDependencyOnOwner(), check_is_member_of_role(), CStringGetDatum, DatumGetAclP, dbname, ereport, errcode(), errmsg(), ERROR, GETSTRUCT, GetUserId(), have_createdb_privilege(), heap_freetuple(), heap_getattr(), heap_modify_tuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, NoLock, OBJECT_DATABASE, ObjectAddressSet, ObjectIdGetDatum, pg_database_ownercheck(), PointerGetDatum, RelationGetDescr, RowExclusiveLock, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by ExecAlterOwnerStmt().
ObjectAddress AlterDatabaseRefreshColl | ( | AlterDatabaseRefreshCollStmt * | stmt | ) |
Definition at line 2347 of file dbcommands.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, BTEqualStrategyNumber, CatalogTupleUpdate(), CStringGetDatum, CStringGetTextDatum, AlterDatabaseRefreshCollStmt::dbname, elog, ereport, errcode(), errmsg(), ERROR, get_collation_actual_version(), GETSTRUCT, GetUserId(), heap_freetuple(), heap_getattr(), heap_modify_tuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, NoLock, NOTICE, OBJECT_DATABASE, ObjectAddressSet, pg_database_ownercheck(), RelationGetDescr, RowExclusiveLock, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), table_open(), TextDatumGetCString, and values.
Referenced by standard_ProcessUtility().
Oid AlterDatabaseSet | ( | AlterDatabaseSetStmt * | stmt | ) |
Definition at line 2430 of file dbcommands.c.
References AccessShareLock, aclcheck_error(), ACLCHECK_NOT_OWNER, AlterSetting(), AlterDatabaseSetStmt::dbname, get_database_oid(), GetUserId(), InvalidOid, OBJECT_DATABASE, pg_database_ownercheck(), AlterDatabaseSetStmt::setstmt, shdepLockAndCheckObject(), and UnlockSharedObject().
Referenced by standard_ProcessUtility().
Definition at line 2874 of file dbcommands.c.
References AccessShareLock, dstpath, ForwardScanDirection, GetDatabasePath(), GETSTRUCT, heap_getnext(), lstat, pfree(), table_beginscan_catalog(), table_close(), table_endscan(), and table_open().
Referenced by createdb().
void check_encoding_locale_matches | ( | int | encoding, |
const char * | collate, | ||
const char * | ctype | ||
) |
Definition at line 1434 of file dbcommands.c.
References encoding, ereport, errcode(), errdetail(), errmsg(), ERROR, pg_encoding_to_char(), pg_get_encoding_from_locale(), PG_SQL_ASCII, PG_UTF8, and superuser().
Referenced by createdb(), and DefineCollation().
|
static |
Definition at line 554 of file dbcommands.c.
References AccessShareLock, CHECKPOINT_FLUSH_ALL, CHECKPOINT_FORCE, CHECKPOINT_IMMEDIATE, CHECKPOINT_WAIT, copydir(), xl_dbase_create_file_copy_rec::db_id, directory_is_empty(), dstpath, ForwardScanDirection, GetDatabasePath(), GETSTRUCT, heap_getnext(), pfree(), RequestCheckpoint(), S_ISDIR, xl_dbase_create_file_copy_rec::src_db_id, xl_dbase_create_file_copy_rec::src_tablespace_id, stat::st_mode, stat, table_beginscan_catalog(), table_close(), table_endscan(), table_open(), xl_dbase_create_file_copy_rec::tablespace_id, XLOG_DBASE_CREATE_FILE_COPY, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), and XLR_SPECIAL_REL_UPDATE.
Referenced by createdb().
|
static |
Definition at line 145 of file dbcommands.c.
References AccessShareLock, Assert(), CreateAndCopyRelationData(), CreateDirAndVersionFile(), LockRelId::dbId, RelFileNode::dbNode, dstpath, GetDatabasePath(), lfirst, list_free_deep(), LockRelationId(), NIL, CreateDBRelInfo::permanent, pfree(), RelationMapCopy(), LockRelId::relId, RelFileNode::relNode, CreateDBRelInfo::reloid, CreateDBRelInfo::rnode, ScanSourceDatabasePgClass(), RelFileNode::spcNode, and UnlockRelationId().
Referenced by createdb().
Oid createdb | ( | ParseState * | pstate, |
const CreatedbStmt * | stmt | ||
) |
Definition at line 674 of file dbcommands.c.
References AccessShareLock, ACL_CREATE, aclcheck_error(), ACLCHECK_OK, allowSystemTableMods, DefElem::arg, Assert(), BoolGetDatum, CatalogTupleInsert(), CharGetDatum, check_db_file_conflict(), check_encoding_locale_matches(), check_icu_locale(), check_is_member_of_role(), check_locale(), copyTemplateDependencies(), CountOtherDBBackends(), CreateDatabaseUsingFileCopy(), CreateDatabaseUsingWalLog(), createdb_failure_callback(), CREATEDB_FILE_COPY, CREATEDB_WAL_LOG, CStringGetDatum, CStringGetTextDatum, dbname, CreatedbStmt::dbname, defGetBoolean(), defGetInt32(), defGetString(), DefElem::defname, createdb_failure_params::dest_dboid, DirectFunctionCall1, directory_is_empty(), elog, encoding, ereport, errcode(), errdetail(), errdetail_busy_db(), errhint(), errmsg(), ERROR, errorConflictingDefElem(), FirstNormalObjectId, ForceSyncCommit(), get_collation_actual_version(), get_database_name(), get_database_oid(), get_db_info(), get_role_oid(), get_tablespace_oid(), GetDatabasePath(), GetNewOidWithIndex(), GetUserId(), have_createdb_privilege(), heap_form_tuple(), Int32GetDatum, InvalidMultiXactId, InvalidOid, InvalidTransactionId, InvokeObjectPostCreateHook, IsA, IsBinaryUpgrade, IsUnderPostmaster, lfirst, DefElem::location, LockSharedObject(), MemSet, namein(), NoLock, OBJECT_TABLESPACE, ObjectIdGetDatum, OidIsValid, CreatedbStmt::options, parser_errposition(), pfree(), pg_database_ownercheck(), pg_encoding_to_char(), PG_END_ENSURE_ERROR_CLEANUP, PG_ENSURE_ERROR_CLEANUP, pg_strcasecmp(), pg_tablespace_aclcheck(), PG_VALID_BE_ENCODING, pg_valid_server_encoding(), PointerGetDatum, quote_identifier(), recordDependencyOnOwner(), RelationGetDescr, RowExclusiveLock, S_ISDIR, ShareLock, createdb_failure_params::src_dboid, stat::st_mode, stat, createdb_failure_params::strategy, table_close(), table_open(), TransactionIdGetDatum, and WARNING.
Referenced by CreateRole(), main(), and standard_ProcessUtility().
|
static |
Definition at line 1472 of file dbcommands.c.
References AccessShareLock, arg, CREATEDB_WAL_LOG, DatumGetPointer, createdb_failure_params::dest_dboid, DropDatabaseBuffers(), ForgetDatabaseSyncRequests(), remove_dbtablespaces(), ShareLock, createdb_failure_params::src_dboid, createdb_failure_params::strategy, and UnlockSharedObject().
Referenced by createdb().
Definition at line 460 of file dbcommands.c.
References buf, CloseTransientFile(), xl_dbase_create_wal_log_rec::db_id, END_CRIT_SECTION, ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), MakePGDirectory(), MAXPGPATH, OpenTransientFile(), PG_BINARY, pgstat_report_wait_end(), pgstat_report_wait_start(), snprintf, sprintf, START_CRIT_SECTION, xl_dbase_create_wal_log_rec::tablespace_id, WAIT_EVENT_VERSION_FILE_WRITE, write, XLOG_DBASE_CREATE_WAL_LOG, XLogBeginInsert(), XLogFlush(), XLogInsert(), and XLogRegisterData().
Referenced by CreateDatabaseUsingWalLog(), and dbase_redo().
void dbase_redo | ( | XLogReaderState * | record | ) |
Definition at line 3015 of file dbcommands.c.
References AccessExclusiveLock, Assert(), copydir(), CreateDirAndVersionFile(), xl_dbase_create_file_copy_rec::db_id, xl_dbase_create_wal_log_rec::db_id, xl_dbase_drop_rec::db_id, DropDatabaseBuffers(), elog, EmitProcSignalBarrier(), ereport, errmsg(), FlushDatabaseBuffers(), ForgetDatabaseSyncRequests(), GetDatabasePath(), i, InHotStandby, LockSharedObjectForSession(), xl_dbase_drop_rec::ntablespaces, PANIC, pfree(), PROCSIGNAL_BARRIER_SMGRRELEASE, ReplicationSlotsDropDBSlots(), ResolveRecoveryConflictWithDatabase(), rmtree(), S_ISDIR, xl_dbase_create_file_copy_rec::src_db_id, xl_dbase_create_file_copy_rec::src_tablespace_id, stat::st_mode, stat, xl_dbase_create_file_copy_rec::tablespace_id, xl_dbase_create_wal_log_rec::tablespace_id, xl_dbase_drop_rec::tablespace_ids, UnlockSharedObjectForSession(), WaitForProcSignalBarrier(), WARNING, XLOG_DBASE_CREATE_FILE_COPY, XLOG_DBASE_CREATE_WAL_LOG, XLOG_DBASE_DROP, XLogDropDatabase(), XLogRecGetData, XLogRecGetInfo, XLogRecHasAnyBlockRefs, and XLR_INFO_MASK.
void DropDatabase | ( | ParseState * | pstate, |
DropdbStmt * | stmt | ||
) |
Definition at line 2155 of file dbcommands.c.
References DropdbStmt::dbname, DefElem::defname, dropdb(), ereport, errcode(), errmsg(), ERROR, lfirst, DefElem::location, DropdbStmt::missing_ok, DropdbStmt::options, and parser_errposition().
Referenced by standard_ProcessUtility().
Definition at line 1511 of file dbcommands.c.
References AccessExclusiveLock, aclcheck_error(), ACLCHECK_NOT_OWNER, CatalogTupleDelete(), CHECKPOINT_FORCE, CHECKPOINT_IMMEDIATE, CHECKPOINT_WAIT, CountDBSubscriptions(), CountOtherDBBackends(), DATABASEOID, dbname, DeleteSharedComments(), DeleteSharedSecurityLabel(), DropDatabaseBuffers(), dropDatabaseDependencies(), DropSetting(), elog, EmitProcSignalBarrier(), ereport, errcode(), errdetail_busy_db(), errdetail_plural(), errmsg(), ERROR, ForceSyncCommit(), ForgetDatabaseSyncRequests(), get_db_info(), GetUserId(), HeapTupleIsValid, InvalidOid, InvokeObjectDropHook, MyDatabaseId, NoLock, NOTICE, OBJECT_DATABASE, ObjectIdGetDatum, pg_database_ownercheck(), pgstat_drop_database(), PROCSIGNAL_BARRIER_SMGRRELEASE, ReleaseSysCache(), remove_dbtablespaces(), ReplicationSlotsCountDBSlots(), ReplicationSlotsDropDBSlots(), RequestCheckpoint(), RowExclusiveLock, SearchSysCache1(), HeapTupleData::t_self, table_close(), table_open(), TerminateOtherDBBackends(), and WaitForProcSignalBarrier().
Referenced by DropDatabase().
|
static |
Definition at line 2917 of file dbcommands.c.
References errdetail(), and errdetail_plural().
Referenced by createdb(), dropdb(), movedb(), and RenameDatabase().
char* get_database_name | ( | Oid | dbid | ) |
Definition at line 2994 of file dbcommands.c.
References DATABASEOID, datname, GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache1().
Referenced by AfterTriggerSetState(), AlterPublicationOwner_internal(), AlterSchemaOwner_internal(), calculate_database_size(), createdb(), CreatePublication(), CreateSchemaCommand(), current_database(), database_to_xml_internal(), DeconstructQualifiedName(), do_analyze_rel(), do_autovacuum(), exec_object_restorecon(), ExpandColumnRefStar(), GetNewMultiXactId(), GetNewTransactionId(), getObjectDescription(), getObjectIdentityParts(), heap_vacuum_rel(), IdentifySystem(), InitTempTableNamespace(), lazy_check_wraparound_failsafe(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), perform_work_item(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetCreationNamespace(), RangeVarGetRelidExtended(), ReindexMultipleTables(), RenameSchema(), SetMultiXactIdLimit(), SetTransactionIdLimit(), shdepLockAndCheckObject(), TerminateOtherDBBackends(), and transformColumnRef().
Definition at line 2947 of file dbcommands.c.
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(), objectNamesToOids(), pg_database_size_name(), RenameDatabase(), and sepgsql_database_post_create().
|
static |
Definition at line 2611 of file dbcommands.c.
References AccessShareLock, Assert(), AssertArg, BTEqualStrategyNumber, CStringGetDatum, DATABASEOID, GETSTRUCT, HeapTupleIsValid, LockSharedObject(), name, NameStr, NoLock, ObjectIdGetDatum, ReleaseSysCache(), ScanKeyInit(), SearchSysCache1(), SysCacheGetAttr(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), table_open(), TextDatumGetCString, and UnlockSharedObject().
Referenced by createdb(), dropdb(), movedb(), and RenameDatabase().
|
static |
Definition at line 2759 of file dbcommands.c.
References AUTHOID, GETSTRUCT, GetUserId(), HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), rolcreatedb, SearchSysCache1(), and superuser().
Referenced by AlterDatabaseOwner(), createdb(), and RenameDatabase().
|
static |
Definition at line 1815 of file dbcommands.c.
References AccessExclusiveLock, ACL_CREATE, aclcheck_error(), ACLCHECK_NOT_OWNER, ACLCHECK_OK, AllocateDir(), BTEqualStrategyNumber, CatalogTupleUpdate(), CHECKPOINT_FLUSH_ALL, CHECKPOINT_FORCE, CHECKPOINT_IMMEDIATE, CHECKPOINT_WAIT, CommitTransactionCommand(), copydir(), CountOtherDBBackends(), CStringGetDatum, dirent::d_name, xl_dbase_create_file_copy_rec::db_id, xl_dbase_drop_rec::db_id, dbname, movedb_failure_params::dest_dboid, movedb_failure_params::dest_tsoid, DropDatabaseBuffers(), elog, EmitProcSignalBarrier(), ereport, errcode(), errdetail_busy_db(), errhint(), errmsg(), ERROR, ForceSyncCommit(), FreeDir(), get_db_info(), get_tablespace_oid(), GetDatabasePath(), GetUserId(), heap_modify_tuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, LockSharedObjectForSession(), MemSet, movedb_failure_callback(), MyDatabaseId, NoLock, xl_dbase_drop_rec::ntablespaces, OBJECT_DATABASE, OBJECT_TABLESPACE, ObjectIdGetDatum, pfree(), pg_database_ownercheck(), PG_END_ENSURE_ERROR_CLEANUP, PG_ENSURE_ERROR_CLEANUP, pg_tablespace_aclcheck(), PointerGetDatum, PopActiveSnapshot(), PROCSIGNAL_BARRIER_SMGRRELEASE, ReadDir(), RelationGetDescr, RequestCheckpoint(), rmtree(), RowExclusiveLock, ScanKeyInit(), xl_dbase_create_file_copy_rec::src_db_id, xl_dbase_create_file_copy_rec::src_tablespace_id, StartTransactionCommand(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), table_open(), xl_dbase_create_file_copy_rec::tablespace_id, UnlockSharedObjectForSession(), WaitForProcSignalBarrier(), WARNING, XLOG_DBASE_CREATE_FILE_COPY, XLOG_DBASE_DROP, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), and XLR_SPECIAL_REL_UPDATE.
Referenced by AlterDatabase().
|
static |
Definition at line 2138 of file dbcommands.c.
References arg, DatumGetPointer, movedb_failure_params::dest_dboid, movedb_failure_params::dest_tsoid, dstpath, GetDatabasePath(), pfree(), and rmtree().
Referenced by movedb().
Datum pg_database_collation_actual_version | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2569 of file dbcommands.c.
References cstring_to_text(), DATABASEOID, datlocprovider, elog, ereport, errcode(), errmsg(), ERROR, get_collation_actual_version(), GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PG_GETARG_OID, PG_RETURN_NULL, PG_RETURN_TEXT_P, ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttr(), and TextDatumGetCString.
|
static |
Definition at line 2784 of file dbcommands.c.
References AccessShareLock, xl_dbase_drop_rec::db_id, dstpath, ereport, errmsg(), ForwardScanDirection, GetDatabasePath(), GETSTRUCT, heap_getnext(), i, lappend_oid(), lfirst_oid, list_free(), list_length(), lstat, MinSizeOfDbaseDropRec, NIL, xl_dbase_drop_rec::ntablespaces, palloc(), pfree(), rmtree(), S_ISDIR, stat::st_mode, table_beginscan_catalog(), table_close(), table_endscan(), table_open(), WARNING, XLOG_DBASE_DROP, XLogBeginInsert(), XLogInsert(), XLogRegisterData(), and XLR_SPECIAL_REL_UPDATE.
Referenced by createdb_failure_callback(), and dropdb().
ObjectAddress RenameDatabase | ( | const char * | oldname, |
const char * | newname | ||
) |
Definition at line 1717 of file dbcommands.c.
References AccessExclusiveLock, aclcheck_error(), ACLCHECK_NOT_OWNER, CatalogTupleUpdate(), CountOtherDBBackends(), DATABASEOID, datname, elog, ereport, errcode(), errdetail_busy_db(), errmsg(), ERROR, get_database_oid(), get_db_info(), GETSTRUCT, GetUserId(), have_createdb_privilege(), HeapTupleIsValid, InvokeObjectPostAlterHook, MyDatabaseId, namestrcpy(), NoLock, OBJECT_DATABASE, ObjectAddressSet, ObjectIdGetDatum, OidIsValid, pg_database_ownercheck(), RowExclusiveLock, SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), table_open(), and WARNING.
Referenced by ExecRenameStmt().
Definition at line 247 of file dbcommands.c.
References AccessShareLock, BAS_BULKREAD, buf, BUFFER_LOCK_SHARE, BufferGetPage, CHECK_FOR_INTERRUPTS, CreateFakeRelcacheEntry(), LockRelId::dbId, RelFileNode::dbNode, FreeFakeRelcacheEntry(), GetAccessStrategy(), GetLatestSnapshot(), LockBuffer(), LockRelationId(), MAIN_FORKNUM, NIL, PageIsEmpty, PageIsNew, RBM_NORMAL, ReadBufferWithoutRelcache(), RelationGetSmgr(), RelationMapOidToFilenodeForDatabase(), LockRelId::relId, RelFileNode::relNode, ScanSourceDatabasePgClassPage(), smgrnblocks(), RelFileNode::spcNode, UnlockRelationId(), and UnlockReleaseBuffer().
Referenced by CreateDatabaseUsingWalLog().
|
static |
Definition at line 332 of file dbcommands.c.
References Assert(), buf, BufferGetBlockNumber(), FirstOffsetNumber, HeapTupleSatisfiesVisibility(), ItemIdGetLength, ItemIdIsDead, ItemIdIsNormal, ItemIdIsRedirected, ItemIdIsUsed, ItemPointerSet, lappend(), OffsetNumberNext, PageGetItem, PageGetItemId, PageGetMaxOffsetNumber, ScanSourceDatabasePgClassTuple(), HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, and HeapTupleData::t_tableOid.
Referenced by ScanSourceDatabasePgClass().
|
static |
Definition at line 395 of file dbcommands.c.
References Assert(), RelFileNode::dbNode, elog, ERROR, GETSTRUCT, InvalidOid, OidIsValid, palloc(), CreateDBRelInfo::permanent, RelationMapOidToFilenodeForDatabase(), RelFileNode::relNode, CreateDBRelInfo::reloid, CreateDBRelInfo::rnode, and RelFileNode::spcNode.
Referenced by ScanSourceDatabasePgClassPage().