56 elog(
DEBUG1,
"resetting unlogged relations: cleanup %d init %d",
65 "ResetUnloggedRelations",
84 if (strcmp(spc_de->
d_name,
".") == 0 ||
85 strcmp(spc_de->
d_name,
"..") == 0)
88 snprintf(temp_path,
sizeof(temp_path),
"%s/%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",
187 ctl.keysize =
sizeof(
Oid);
195 while ((de =
ReadDir(dbspace_dir, dbspacedirname)) != NULL)
234 while ((de =
ReadDir(dbspace_dir, dbspacedirname)) != NULL)
256 snprintf(rm_path,
sizeof(rm_path),
"%s/%s",
257 dbspacedirname, de->
d_name);
258 if (unlink(rm_path) < 0)
261 errmsg(
"could not remove file \"%s\": %m",
264 elog(
DEBUG2,
"unlinked file \"%s\"", rm_path);
284 while ((de =
ReadDir(dbspace_dir, dbspacedirname)) != NULL)
302 snprintf(srcpath,
sizeof(srcpath),
"%s/%s",
303 dbspacedirname, de->
d_name);
308 dbspacedirname, relNumber);
311 dbspacedirname, relNumber, segno);
328 while ((de =
ReadDir(dbspace_dir, dbspacedirname)) != NULL)
346 snprintf(mainpath,
sizeof(mainpath),
"%s/%u",
347 dbspacedirname, relNumber);
349 snprintf(mainpath,
sizeof(mainpath),
"%s/%u.%u",
350 dbspacedirname, relNumber, segno);
410 n = strtoul(
name, &endp, 10);
425 name += forkchar + 1;
438 s = strtoul(
name + 1, &endp, 10);
451 *segno = (unsigned) s;
void begin_startup_progress_phase(void)
#define Assert(condition)
void copy_file(const char *fromfile, const char *tofile)
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]
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
MemoryContextSwitchTo(old_ctx)
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, RelFileNumber *relnumber, ForkNumber *fork, unsigned *segno)
static void ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
#define UNLOGGED_RELATION_INIT
#define UNLOGGED_RELATION_CLEANUP
int forkname_chars(const char *str, ForkNumber *fork)
#define InvalidRelFileNumber
#define TABLESPACE_VERSION_DIRECTORY
#define ereport_startup_progress(msg,...)