76#include "utils/fmgroids.h"
129 if (
stat(dir, &st) < 0)
157 errmsg(
"could not create directory \"%s\": %m",
173 errmsg(
"could not create directory \"%s\": %m",
184 errmsg(
"could not stat directory \"%s\": %m", dir)));
193 errmsg(
"\"%s\" exists but is not a directory",
224 errmsg(
"permission denied to create tablespace \"%s\"",
225 stmt->tablespacename),
226 errhint(
"Must be superuser to create a tablespace.")));
239 if (
strchr(location,
'\''))
242 errmsg(
"tablespace location cannot contain single quotes")));
255 errmsg(
"tablespace location must be an absolute path")));
267 errmsg(
"tablespace location \"%s\" is too long",
274 errmsg(
"tablespace location should not be inside the data directory")));
283 errmsg(
"unacceptable tablespace name \"%s\"",
284 stmt->tablespacename),
285 errdetail(
"The prefix \"pg_\" is reserved for system tablespaces.")));
291#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS
292 if (
strncmp(
stmt->tablespacename,
"regress_", 8) != 0)
293 elog(
WARNING,
"tablespaces created by regression test cases should have names starting with \"regress_\"");
304 errmsg(
"tablespace \"%s\" already exists",
305 stmt->tablespacename)));
320 errmsg(
"pg_tablespace OID value not set when in binary upgrade mode")));
397 char *tablespacename =
stmt->tablespacename;
421 if (!
stmt->missing_ok)
425 errmsg(
"tablespace \"%s\" does not exist",
431 (
errmsg(
"tablespace \"%s\" does not exist, skipping",
454 &detail, &detail_log))
457 errmsg(
"tablespace \"%s\" cannot be dropped because some objects depend on it",
524 errmsg(
"tablespace \"%s\" is not empty",
586 in_place =
strlen(location) == 0;
593 errmsg(
"could not create directory \"%s\": %m",
611 errmsg(
"directory \"%s\" does not exist", location),
613 "restarting the server.") : 0));
617 errmsg(
"could not set permissions on directory \"%s\": %m",
633 errmsg(
"could not stat directory \"%s\": %m",
638 errmsg(
"could not create directory \"%s\": %m",
644 errmsg(
"\"%s\" exists but is not a directory",
649 errmsg(
"directory \"%s\" already in use as a tablespace",
664 errmsg(
"could not create symbolic link \"%s\": %m",
728 errmsg(
"could not open directory \"%s\": %m",
738 errmsg(
"could not open directory \"%s\": %m",
767 errmsg(
"could not remove directory \"%s\": %m",
780 errmsg(
"could not remove directory \"%s\": %m",
800 int saved_errno =
errno;
804 errmsg(
"could not stat file \"%s\": %m",
811 int saved_errno =
errno;
815 errmsg(
"could not remove directory \"%s\": %m",
823 int saved_errno =
errno;
827 errmsg(
"could not remove symbolic link \"%s\": %m",
836 errmsg(
"\"%s\" is not a directory or symbolic link",
905 errmsg(
"could not remove directory \"%s\": %m",
913 errmsg(
"could not remove symbolic link \"%s\": %m",
921 errmsg(
"\"%s\" is not a directory or symbolic link",
953 errmsg(
"tablespace \"%s\" does not exist",
970 errmsg(
"unacceptable tablespace name \"%s\"", newname),
971 errdetail(
"The prefix \"pg_\" is reserved for system tablespaces.")));
977#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS
978 if (
strncmp(newname,
"regress_", 8) != 0)
979 elog(
WARNING,
"tablespaces created by regression test cases should have names starting with \"regress_\"");
992 errmsg(
"tablespace \"%s\" already exists",
1042 errmsg(
"tablespace \"%s\" does not exist",
1043 stmt->tablespacename)));
1050 stmt->tablespacename);
1111 errmsg(
"tablespace \"%s\" does not exist",
1178 errmsg(
"cannot specify default tablespace for partitioned relations")));
1257 errmsg(
"tablespace \"%s\" does not exist",
1283 tblSpcs[numSpcs++] =
curoid;
1288 numSpcs *
sizeof(
Oid));
1409 tblSpcs[numSpcs++] =
curoid;
1460 errmsg(
"tablespace \"%s\" does not exist",
1562 errmsg(
"directories for tablespace %u could not be removed",
1564 errhint(
"You can remove the directories manually if necessary.")));
1568 elog(
PANIC,
"tblspc_redo: unknown op code %u", info);
Oid get_rolespec_oid(const RoleSpec *role, bool missing_ok)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
Oid AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt)
Oid binary_upgrade_next_pg_tablespace_oid
bool directory_is_empty(const char *path)
void remove_tablespace_symlink(const char *linkloc)
static bool destroy_tablespace_directories(Oid tablespaceoid, bool redo)
bool check_default_tablespace(char **newval, void **extra, GucSource source)
char * get_tablespace_name(Oid spc_oid)
void DropTableSpace(DropTableSpaceStmt *stmt)
void PrepareTempTablespaces(void)
Oid get_tablespace_oid(const char *tablespacename, bool missing_ok)
ObjectAddress RenameTableSpace(const char *oldname, const char *newname)
void assign_temp_tablespaces(const char *newval, void *extra)
Oid GetDefaultTablespace(char relpersistence, bool partitioned)
void TablespaceCreateDbspace(Oid spcOid, Oid dbOid, bool isRedo)
bool check_temp_tablespaces(char **newval, void **extra, GucSource source)
Oid CreateTableSpace(CreateTableSpaceStmt *stmt)
char * default_tablespace
static void create_tablespace_directories(const char *location, const Oid tablespaceoid)
void tblspc_redo(XLogReaderState *record)
bool allow_in_place_tablespaces
static Datum values[MAXATTR]
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
#define OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
bool IsPinnedObject(Oid classId, Oid objectId)
bool IsReservedName(const char *name)
void RequestCheckpoint(int flags)
int errdetail_internal(const char *fmt,...)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
int errdetail_log(const char *fmt,...)
#define ereport(elevel,...)
int MakePGDirectory(const char *directoryName)
bool TempTablespacesAreSet(void)
Oid GetNextTempTableSpace(void)
DIR * AllocateDir(const char *dirname)
struct dirent * ReadDir(DIR *dir, const char *dirname)
void SetTempTablespaces(Oid *tableSpaces, int numSpaces)
#define DirectFunctionCall1(func, arg1)
bool allowSystemTableMods
void * guc_malloc(int elevel, size_t size)
#define GUC_check_errdetail
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_copytuple(HeapTuple tuple)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static void * GETSTRUCT(const HeapTupleData *tuple)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
void list_free(List *list)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void * MemoryContextAlloc(MemoryContext context, Size size)
MemoryContext TopTransactionContext
char * pstrdup(const char *in)
void pfree(void *pointer)
void namestrcpy(Name name, const char *str)
Datum namein(PG_FUNCTION_ARGS)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
#define InvokeObjectDropHook(classId, objectId, subId)
#define ObjectAddressSet(addr, class_id, object_id)
static int list_length(const List *l)
static rewind_source * source
void deleteSharedDependencyRecordsFor(Oid classId, Oid objectId, int32 objectSubId)
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
bool checkSharedDependencies(Oid classId, Oid objectId, char **detail_msg, char **detail_log_msg)
FormData_pg_tablespace * Form_pg_tablespace
int pg_mkdir_p(char *path, int omode)
#define is_absolute_path(filename)
bool path_is_prefix_of_path(const char *path1, const char *path2)
void canonicalize_path(char *path)
void get_parent_directory(char *path)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
void WaitForProcSignalBarrier(uint64 generation)
uint64 EmitProcSignalBarrier(ProcSignalBarrierType type)
@ PROCSIGNAL_BARRIER_SMGRRELEASE
char * psprintf(const char *fmt,...)
#define RelationGetDescr(relation)
bytea * tablespace_reloptions(Datum reloptions, bool validate)
Datum transformRelOptions(Datum oldOptions, List *defList, const char *nameSpace, const char *const validnsps[], bool acceptOidsOff, bool isReset)
char * GetDatabasePath(Oid dbOid, Oid spcOid)
#define TABLESPACE_VERSION_DIRECTORY
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
void DeleteSharedSecurityLabel(Oid objectId, Oid classId)
void ResolveRecoveryConflictWithTablespace(Oid tsid)
#define BTEqualStrategyNumber
#define ERRCODE_DUPLICATE_OBJECT
char ts_path[FLEXIBLE_ARRAY_MEMBER]
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, ScanKeyData *key)
static void table_endscan(TableScanDesc scan)
#define XLOG_TBLSPC_CREATE
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
#define symlink(oldpath, newpath)
bool IsTransactionState(void)
void ForceSyncCommit(void)
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterData(const void *data, uint32 len)
void XLogBeginInsert(void)
#define XLogRecGetInfo(decoder)
#define XLogRecGetData(decoder)
#define XLogRecHasAnyBlockRefs(decoder)