
Go to the source code of this file.
Defines | |
| #define | UNLOGGED_RELATION_CLEANUP 0x0001 |
| #define | UNLOGGED_RELATION_INIT 0x0002 |
Functions | |
| void | ResetUnloggedRelations (int op) |
| #define UNLOGGED_RELATION_CLEANUP 0x0001 |
Definition at line 20 of file reinit.h.
Referenced by ResetUnloggedRelations(), ResetUnloggedRelationsInDbspaceDir(), and StartupXLOG().
| #define UNLOGGED_RELATION_INIT 0x0002 |
Definition at line 21 of file reinit.h.
Referenced by ResetUnloggedRelations(), ResetUnloggedRelationsInDbspaceDir(), and StartupXLOG().
| void ResetUnloggedRelations | ( | int | op | ) |
Definition at line 49 of file reinit.c.
References AllocateDir(), ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE, ALLOCSET_DEFAULT_MINSIZE, AllocSetContextCreate(), CurrentMemoryContext, dirent::d_name, DEBUG1, elog, FreeDir(), MemoryContextDelete(), MemoryContextSwitchTo(), NULL, ReadDir(), ResetUnloggedRelationsInTablespaceDir(), snprintf(), TABLESPACE_VERSION_DIRECTORY, UNLOGGED_RELATION_CLEANUP, and UNLOGGED_RELATION_INIT.
Referenced by StartupXLOG().
{
char temp_path[MAXPGPATH];
DIR *spc_dir;
struct dirent *spc_de;
MemoryContext tmpctx,
oldctx;
/* Log it. */
elog(DEBUG1, "resetting unlogged relations: cleanup %d init %d",
(op & UNLOGGED_RELATION_CLEANUP) != 0,
(op & UNLOGGED_RELATION_INIT) != 0);
/*
* Just to be sure we don't leak any memory, let's create a temporary
* memory context for this operation.
*/
tmpctx = AllocSetContextCreate(CurrentMemoryContext,
"ResetUnloggedRelations",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
oldctx = MemoryContextSwitchTo(tmpctx);
/*
* First process unlogged files in pg_default ($PGDATA/base)
*/
ResetUnloggedRelationsInTablespaceDir("base", op);
/*
* Cycle through directories for all non-default tablespaces.
*/
spc_dir = AllocateDir("pg_tblspc");
while ((spc_de = ReadDir(spc_dir, "pg_tblspc")) != NULL)
{
if (strcmp(spc_de->d_name, ".") == 0 ||
strcmp(spc_de->d_name, "..") == 0)
continue;
snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s",
spc_de->d_name, TABLESPACE_VERSION_DIRECTORY);
ResetUnloggedRelationsInTablespaceDir(temp_path, op);
}
FreeDir(spc_dir);
/*
* Restore memory context.
*/
MemoryContextSwitchTo(oldctx);
MemoryContextDelete(tmpctx);
}
1.7.1