56 elog(
DEBUG1,
"resetting unlogged relations: cleanup %d init %d",
65 "ResetUnloggedRelations",
82 while ((spc_de =
ReadDir(spc_dir,
"pg_tblspc")) != NULL)
84 if (strcmp(spc_de->
d_name,
".") == 0 ||
85 strcmp(spc_de->
d_name,
"..") == 0)
88 snprintf(temp_path,
sizeof(temp_path),
"pg_tblspc/%s/%s",
122 if (ts_dir == NULL && errno == ENOENT)
126 errmsg(
"could not open directory \"%s\": %m",
131 while ((de =
ReadDir(ts_dir, tsdirname)) != NULL)
138 if (strspn(de->
d_name,
"0123456789") != strlen(de->
d_name))
141 snprintf(dbspace_path,
sizeof(dbspace_path),
"%s/%s",
195 while ((de =
ReadDir(dbspace_dir, dbspacedirname)) != NULL)
235 while ((de =
ReadDir(dbspace_dir, dbspacedirname)) != NULL)
257 snprintf(rm_path,
sizeof(rm_path),
"%s/%s",
258 dbspacedirname, de->
d_name);
259 if (unlink(rm_path) < 0)
262 errmsg(
"could not remove file \"%s\": %m",
265 elog(
DEBUG2,
"unlinked file \"%s\"", rm_path);
285 while ((de =
ReadDir(dbspace_dir, dbspacedirname)) != NULL)
303 snprintf(srcpath,
sizeof(srcpath),
"%s/%s",
304 dbspacedirname, de->
d_name);
307 memcpy(relnumbuf, de->
d_name, relnumchars);
308 relnumbuf[relnumchars] =
'\0';
310 dbspacedirname, relnumbuf, de->
d_name + relnumchars + 1 +
328 while ((de =
ReadDir(dbspace_dir, dbspacedirname)) != NULL)
345 memcpy(relnumbuf, de->
d_name, relnumchars);
346 relnumbuf[relnumchars] =
'\0';
347 snprintf(mainpath,
sizeof(mainpath),
"%s/%s%s",
348 dbspacedirname, relnumbuf, de->
d_name + relnumchars + 1 +
387 for (pos = 0; isdigit((
unsigned char)
name[pos]); ++pos)
394 if (
name[pos] !=
'_')
407 if (
name[pos] ==
'.')
411 for (segchar = 1; isdigit((
unsigned char)
name[pos + segchar]); ++segchar)
419 if (
name[pos] !=
'\0')
void begin_startup_progress_phase(void)
void copy_file(const char *fromfile, const char *tofile)
elog(ERROR, "%s: %s", p2, msg)
void hash_destroy(HTAB *hashp)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
long hash_get_num_entries(HTAB *hashp)
int errcode_for_file_access(void)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
struct dirent * ReadDir(DIR *dir, const char *dirname)
void fsync_fname(const char *fname, bool isdir)
DIR * AllocateDir(const char *dirname)
static char dstpath[MAXPGPATH]
Assert(fmt[strlen(fmt) - 1] !='\n')
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static unsigned hash(unsigned *uv, int n)
static void ResetUnloggedRelationsInTablespaceDir(const char *tsdirname, int op)
void ResetUnloggedRelations(int op)
bool parse_filename_for_nontemp_relation(const char *name, int *relnumchars, ForkNumber *fork)
static void ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
#define UNLOGGED_RELATION_INIT
#define UNLOGGED_RELATION_CLEANUP
int forkname_chars(const char *str, ForkNumber *fork)
const char *const forkNames[]
#define TABLESPACE_VERSION_DIRECTORY
#define ereport_startup_progress(msg,...)