PostgreSQL Source Code git master
|
#include "postgres.h"
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/reloptions.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "access/xloginsert.h"
#include "access/xlogutils.h"
#include "catalog/binary_upgrade.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/seclabel.h"
#include "commands/tablespace.h"
#include "common/file_perm.h"
#include "miscadmin.h"
#include "postmaster/bgwriter.h"
#include "storage/fd.h"
#include "storage/standby.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/guc_hooks.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
struct | temp_tablespaces_extra |
Variables | |
char * | default_tablespace = NULL |
char * | temp_tablespaces = NULL |
bool | allow_in_place_tablespaces = false |
Oid | binary_upgrade_next_pg_tablespace_oid = InvalidOid |
Oid AlterTableSpaceOptions | ( | AlterTableSpaceOptionsStmt * | stmt | ) |
Definition at line 1015 of file tablespace.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, BTEqualStrategyNumber, CatalogTupleUpdate(), CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, ForwardScanDirection, GETSTRUCT(), GetUserId(), heap_freetuple(), heap_getattr(), heap_getnext(), heap_modify_tuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, NoLock, object_ownercheck(), OBJECT_TABLESPACE, RelationGetDescr, RowExclusiveLock, ScanKeyInit(), stmt, HeapTupleData::t_self, table_beginscan_catalog(), table_close(), table_endscan(), table_open(), tablespace_reloptions(), and transformRelOptions().
Referenced by standard_ProcessUtility().
void assign_temp_tablespaces | ( | const char * | newval, |
void * | extra | ||
) |
Definition at line 1306 of file tablespace.c.
References temp_tablespaces_extra::numSpcs, SetTempTablespaces(), and temp_tablespaces_extra::tblSpcs.
bool check_default_tablespace | ( | char ** | newval, |
void ** | extra, | ||
GucSource | source | ||
) |
Definition at line 1091 of file tablespace.c.
References ereport, errcode(), errmsg(), get_tablespace_oid(), GUC_check_errdetail, InvalidOid, IsTransactionState(), MyDatabaseId, newval, NOTICE, OidIsValid, PGC_S_TEST, and source.
bool check_temp_tablespaces | ( | char ** | newval, |
void ** | extra, | ||
GucSource | source | ||
) |
Definition at line 1198 of file tablespace.c.
References ACL_CREATE, aclcheck_error(), ACLCHECK_OK, ereport, errcode(), errmsg(), get_tablespace_oid(), GetUserId(), GUC_check_errdetail, guc_malloc(), InvalidOid, IsTransactionState(), lfirst, list_free(), list_length(), LOG, MyDatabaseId, MyDatabaseTableSpace, newval, NOTICE, temp_tablespaces_extra::numSpcs, object_aclcheck(), OBJECT_TABLESPACE, palloc(), pfree(), PGC_S_INTERACTIVE, PGC_S_TEST, pstrdup(), source, SplitIdentifierString(), and temp_tablespaces_extra::tblSpcs.
|
static |
Definition at line 572 of file tablespace.c.
References ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), ERROR, InRecovery, MakePGDirectory(), pfree(), pg_dir_create_mode, PG_TBLSPC_DIR, psprintf(), remove_tablespace_symlink(), S_ISDIR, stat::st_mode, stat, symlink, and TABLESPACE_VERSION_DIRECTORY.
Referenced by CreateTableSpace(), and tblspc_redo().
Oid CreateTableSpace | ( | CreateTableSpaceStmt * | stmt | ) |
Definition at line 208 of file tablespace.c.
References allow_in_place_tablespaces, allowSystemTableMods, binary_upgrade_next_pg_tablespace_oid, canonicalize_path(), CatalogTupleInsert(), create_tablespace_directories(), CStringGetDatum(), DataDir, DirectFunctionCall1, elog, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errdetail(), errhint(), errmsg(), ERROR, ForceSyncCommit(), FORKNAMECHARS, get_rolespec_oid(), get_tablespace_oid(), GetNewOidWithIndex(), GetUserId(), heap_form_tuple(), heap_freetuple(), InvalidOid, InvokeObjectPostCreateHook, is_absolute_path, IsBinaryUpgrade, IsReservedName(), MAXPGPATH, namein(), NoLock, ObjectIdGetDatum(), OIDCHARS, OidIsValid, path_is_prefix_of_path(), pfree(), pstrdup(), RelationData::rd_att, recordDependencyOnOwner(), RowExclusiveLock, stmt, superuser(), table_close(), table_open(), tablespace_reloptions(), TABLESPACE_VERSION_DIRECTORY, transformRelOptions(), xl_tblspc_create_rec::ts_id, values, WARNING, XLOG_TBLSPC_CREATE, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().
Referenced by standard_ProcessUtility().
|
static |
Definition at line 686 of file tablespace.c.
References AllocateDir(), dirent::d_name, directory_is_empty(), ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, FreeDir(), get_parent_directory(), LOG, lstat, pfree(), PG_TBLSPC_DIR, psprintf(), pstrdup(), ReadDir(), S_ISDIR, S_ISLNK, stat::st_mode, TABLESPACE_VERSION_DIRECTORY, and WARNING.
Referenced by DropTableSpace(), and tblspc_redo().
bool directory_is_empty | ( | const char * | path | ) |
Definition at line 853 of file tablespace.c.
References AllocateDir(), dirent::d_name, FreeDir(), and ReadDir().
Referenced by CreateDatabaseUsingFileCopy(), createdb(), destroy_tablespace_directories(), and pg_tablespace_databases().
void DropTableSpace | ( | DropTableSpaceStmt * | stmt | ) |
Definition at line 395 of file tablespace.c.
References aclcheck_error(), ACLCHECK_NO_PRIV, ACLCHECK_NOT_OWNER, BTEqualStrategyNumber, CatalogTupleDelete(), CHECKPOINT_FORCE, CHECKPOINT_IMMEDIATE, CHECKPOINT_WAIT, checkSharedDependencies(), CStringGetDatum(), DeleteSharedComments(), deleteSharedDependencyRecordsFor(), DeleteSharedSecurityLabel(), destroy_tablespace_directories(), EmitProcSignalBarrier(), ereport, errcode(), errdetail_internal(), errdetail_log(), errmsg(), ERROR, ForceSyncCommit(), ForwardScanDirection, GETSTRUCT(), GetUserId(), heap_getnext(), HeapTupleIsValid, InvokeObjectDropHook, IsPinnedObject(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), NoLock, NOTICE, object_ownercheck(), OBJECT_TABLESPACE, PROCSIGNAL_BARRIER_SMGRRELEASE, RequestCheckpoint(), RowExclusiveLock, ScanKeyInit(), stmt, HeapTupleData::t_self, table_beginscan_catalog(), table_close(), table_endscan(), table_open(), xl_tblspc_drop_rec::ts_id, WaitForProcSignalBarrier(), XLOG_TBLSPC_DROP, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().
Referenced by standard_ProcessUtility().
char * get_tablespace_name | ( | Oid | spc_oid | ) |
Definition at line 1472 of file tablespace.c.
References AccessShareLock, BTEqualStrategyNumber, ForwardScanDirection, GETSTRUCT(), heap_getnext(), HeapTupleIsValid, NameStr, ObjectIdGetDatum(), pstrdup(), ScanKeyInit(), table_beginscan_catalog(), table_close(), table_endscan(), and table_open().
Referenced by AlterTableMoveAll(), calculate_tablespace_size(), DefineIndex(), DefineRelation(), ExecReindex(), generateClonedIndexStmt(), getObjectDescription(), getObjectIdentityParts(), pg_get_constraintdef_worker(), pg_get_indexdef_worker(), ReindexMultipleInternal(), ReindexRelationConcurrently(), and shdepLockAndCheckObject().
Oid get_tablespace_oid | ( | const char * | tablespacename, |
bool | missing_ok | ||
) |
Definition at line 1426 of file tablespace.c.
References AccessShareLock, BTEqualStrategyNumber, CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, ForwardScanDirection, GETSTRUCT(), heap_getnext(), HeapTupleIsValid, InvalidOid, OidIsValid, ScanKeyInit(), table_beginscan_catalog(), table_close(), table_endscan(), and table_open().
Referenced by AlterTableMoveAll(), ATPrepSetTableSpace(), check_default_tablespace(), check_temp_tablespaces(), convert_tablespace_name(), createdb(), CreateTableSpace(), DefineIndex(), DefineRelation(), ExecReindex(), get_object_address_unqualified(), GetDefaultTablespace(), movedb(), pg_tablespace_size_name(), and PrepareTempTablespaces().
Oid GetDefaultTablespace | ( | char | relpersistence, |
bool | partitioned | ||
) |
Definition at line 1143 of file tablespace.c.
References default_tablespace, ereport, errcode(), errmsg(), ERROR, get_tablespace_oid(), GetNextTempTableSpace(), InvalidOid, MyDatabaseTableSpace, and PrepareTempTablespaces().
Referenced by DefineIndex(), DefineRelation(), and RefreshMatViewByOid().
void PrepareTempTablespaces | ( | void | ) |
Definition at line 1331 of file tablespace.c.
References ACL_CREATE, ACLCHECK_OK, get_tablespace_oid(), GetUserId(), InvalidOid, IsTransactionState(), lfirst, list_free(), list_length(), MemoryContextAlloc(), MyDatabaseTableSpace, object_aclcheck(), pfree(), pstrdup(), SetTempTablespaces(), SplitIdentifierString(), temp_tablespaces, TempTablespacesAreSet(), and TopTransactionContext.
Referenced by BufFileCreateTemp(), ExecHashIncreaseNumBatches(), ExecHashTableCreate(), FileSetInit(), GetDefaultTablespace(), inittapestate(), and tuplestore_puttuple_common().
void remove_tablespace_symlink | ( | const char * | linkloc | ) |
Definition at line 883 of file tablespace.c.
References ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, lstat, S_ISDIR, S_ISLNK, and stat::st_mode.
Referenced by create_tablespace_directories(), and InitWalRecovery().
ObjectAddress RenameTableSpace | ( | const char * | oldname, |
const char * | newname | ||
) |
Definition at line 930 of file tablespace.c.
References aclcheck_error(), ACLCHECK_NO_PRIV, allowSystemTableMods, BTEqualStrategyNumber, CatalogTupleUpdate(), CStringGetDatum(), elog, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errdetail(), errmsg(), ERROR, ForwardScanDirection, GETSTRUCT(), GetUserId(), heap_copytuple(), heap_getnext(), HeapTupleIsValid, InvokeObjectPostAlterHook, IsReservedName(), namestrcpy(), NoLock, object_ownercheck(), OBJECT_TABLESPACE, ObjectAddressSet, RowExclusiveLock, ScanKeyInit(), HeapTupleData::t_self, table_beginscan_catalog(), table_close(), table_endscan(), table_open(), and WARNING.
Referenced by ExecRenameStmt().
Definition at line 112 of file tablespace.c.
References Assert, ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, GetDatabasePath(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MakePGDirectory(), OidIsValid, pfree(), pg_dir_create_mode, pg_mkdir_p(), S_ISDIR, stat::st_mode, and stat.
Referenced by mdcreate().
void tblspc_redo | ( | XLogReaderState * | record | ) |
Definition at line 1511 of file tablespace.c.
References Assert, create_tablespace_directories(), destroy_tablespace_directories(), elog, EmitProcSignalBarrier(), ereport, errcode(), errhint(), errmsg(), LOG, PANIC, PROCSIGNAL_BARRIER_SMGRRELEASE, ResolveRecoveryConflictWithTablespace(), xl_tblspc_create_rec::ts_id, xl_tblspc_drop_rec::ts_id, xl_tblspc_create_rec::ts_path, WaitForProcSignalBarrier(), XLOG_TBLSPC_CREATE, XLOG_TBLSPC_DROP, XLogRecGetData, XLogRecGetInfo, and XLogRecHasAnyBlockRefs.
bool allow_in_place_tablespaces = false |
Definition at line 85 of file tablespace.c.
Referenced by CheckTablespaceDirectory(), CreateTableSpace(), and recovery_create_dbdir().
Oid binary_upgrade_next_pg_tablespace_oid = InvalidOid |
Definition at line 87 of file tablespace.c.
Referenced by binary_upgrade_set_next_pg_tablespace_oid(), and CreateTableSpace().
char* default_tablespace = NULL |
Definition at line 83 of file tablespace.c.
Referenced by GetDefaultTablespace().
char* temp_tablespaces = NULL |
Definition at line 84 of file tablespace.c.
Referenced by PrepareTempTablespaces().