#include "catalog/catversion.h"
#include "storage/relfilenode.h"
Go to the source code of this file.
Defines | |
#define | OIDCHARS 10 |
#define | TABLESPACE_VERSION_DIRECTORY |
#define | relpath(rnode, forknum) relpathbackend((rnode).node, (rnode).backend, (forknum)) |
#define | relpathperm(rnode, forknum) relpathbackend((rnode), InvalidBackendId, (forknum)) |
Functions | |
int | forkname_chars (const char *str, ForkNumber *fork) |
char * | relpathbackend (RelFileNode rnode, BackendId backend, ForkNumber forknum) |
Variables | |
const char * | forkNames [] |
#define OIDCHARS 10 |
Definition at line 24 of file relpath.h.
Referenced by create_tablespace_directories(), CreateTableSpace(), destroy_tablespace_directories(), GetDatabasePath(), parse_filename_for_nontemp_relation(), pg_tablespace_databases(), relpathbackend(), and ResetUnloggedRelationsInDbspaceDir().
#define relpath | ( | rnode, | ||
forknum | ||||
) | relpathbackend((rnode).node, (rnode).backend, (forknum)) |
Definition at line 34 of file relpath.h.
Referenced by _mdfd_segpath(), GetNewRelFileNode(), mdcreate(), mdextend(), mdopen(), mdtruncate(), mdunlinkfork(), process_file(), and ReadBuffer_common().
#define relpathperm | ( | rnode, | ||
forknum | ||||
) | relpathbackend((rnode), InvalidBackendId, (forknum)) |
Definition at line 38 of file relpath.h.
Referenced by AbortBufferIO(), forget_invalid_pages(), forget_invalid_pages_db(), mdpostckpt(), report_invalid_page(), shared_buffer_write_error_callback(), smgr_desc(), xact_desc_abort(), xact_desc_commit(), and xlog_desc().
#define TABLESPACE_VERSION_DIRECTORY |
"PG_" PG_MAJORVERSION "_" \ CppAsString2(CATALOG_VERSION_NO)
Definition at line 25 of file relpath.h.
Referenced by calculate_database_size(), calculate_tablespace_size(), create_tablespace_directories(), CreateTableSpace(), destroy_tablespace_directories(), GetDatabasePath(), OpenTemporaryFileInTablespace(), pg_tablespace_databases(), RelationCacheInitFileRemove(), relpathbackend(), RemovePgTempFiles(), ResetUnloggedRelations(), and sendTablespace().
int forkname_chars | ( | const char * | str, | |
ForkNumber * | fork | |||
) |
Definition at line 51 of file relpath.c.
References forkNames.
Referenced by looks_like_temp_rel_name(), and parse_filename_for_nontemp_relation().
{ ForkNumber forkNum; for (forkNum = 1; forkNum <= MAX_FORKNUM; forkNum++) { int len = strlen(forkNames[forkNum]); if (strncmp(forkNames[forkNum], str, len) == 0) { if (fork) *fork = forkNum; return len; } } return 0; }
char* relpathbackend | ( | RelFileNode | rnode, | |
BackendId | backend, | |||
ForkNumber | forknum | |||
) |
Definition at line 75 of file relpath.c.
References Assert, RelFileNode::dbNode, DEFAULTTABLESPACE_OID, FORKNAMECHARS, forkNames, GLOBALTABLESPACE_OID, InvalidBackendId, MAIN_FORKNUM, OIDCHARS, palloc(), RelFileNode::relNode, snprintf(), RelFileNode::spcNode, and TABLESPACE_VERSION_DIRECTORY.
Referenced by calculate_relation_size(), copy_relation_data(), DropRelFileNodeAllLocalBuffers(), DropRelFileNodeLocalBuffers(), local_buffer_write_error_callback(), pg_relation_filepath(), and PrintBufferLeakWarning().
{ int pathlen; char *path; if (rnode.spcNode == GLOBALTABLESPACE_OID) { /* Shared system relations live in {datadir}/global */ Assert(rnode.dbNode == 0); Assert(backend == InvalidBackendId); pathlen = 7 + OIDCHARS + 1 + FORKNAMECHARS + 1; path = (char *) palloc(pathlen); if (forknum != MAIN_FORKNUM) snprintf(path, pathlen, "global/%u_%s", rnode.relNode, forkNames[forknum]); else snprintf(path, pathlen, "global/%u", rnode.relNode); } else if (rnode.spcNode == DEFAULTTABLESPACE_OID) { /* The default tablespace is {datadir}/base */ if (backend == InvalidBackendId) { pathlen = 5 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1; path = (char *) palloc(pathlen); if (forknum != MAIN_FORKNUM) snprintf(path, pathlen, "base/%u/%u_%s", rnode.dbNode, rnode.relNode, forkNames[forknum]); else snprintf(path, pathlen, "base/%u/%u", rnode.dbNode, rnode.relNode); } else { /* OIDCHARS will suffice for an integer, too */ pathlen = 5 + OIDCHARS + 2 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1; path = (char *) palloc(pathlen); if (forknum != MAIN_FORKNUM) snprintf(path, pathlen, "base/%u/t%d_%u_%s", rnode.dbNode, backend, rnode.relNode, forkNames[forknum]); else snprintf(path, pathlen, "base/%u/t%d_%u", rnode.dbNode, backend, rnode.relNode); } } else { /* All other tablespaces are accessed via symlinks */ if (backend == InvalidBackendId) { pathlen = 9 + 1 + OIDCHARS + 1 + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1; path = (char *) palloc(pathlen); if (forknum != MAIN_FORKNUM) snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u_%s", rnode.spcNode, TABLESPACE_VERSION_DIRECTORY, rnode.dbNode, rnode.relNode, forkNames[forknum]); else snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u", rnode.spcNode, TABLESPACE_VERSION_DIRECTORY, rnode.dbNode, rnode.relNode); } else { /* OIDCHARS will suffice for an integer, too */ pathlen = 9 + 1 + OIDCHARS + 1 + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 2 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1; path = (char *) palloc(pathlen); if (forknum != MAIN_FORKNUM) snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/t%d_%u_%s", rnode.spcNode, TABLESPACE_VERSION_DIRECTORY, rnode.dbNode, backend, rnode.relNode, forkNames[forknum]); else snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/t%d_%u", rnode.spcNode, TABLESPACE_VERSION_DIRECTORY, rnode.dbNode, backend, rnode.relNode); } } return path; }
const char* forkNames[] |
Definition at line 32 of file relpath.c.
Referenced by forkname_chars(), forkname_to_number(), relpathbackend(), ResetUnloggedRelationsInDbspaceDir(), and XLogDumpDisplayRecord().