2
0

relpath.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*-------------------------------------------------------------------------
  2. *
  3. * relpath.h
  4. * Declarations for GetRelationPath() and friends
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * src/include/common/relpath.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef RELPATH_H
  14. #define RELPATH_H
  15. /*
  16. * 'pgrminclude ignore' needed here because CppAsString2() does not throw
  17. * an error if the symbol is not defined.
  18. */
  19. #include "catalog/catversion.h" /* pgrminclude ignore */
  20. /*
  21. * Name of major-version-specific tablespace subdirectories
  22. */
  23. #define TABLESPACE_VERSION_DIRECTORY "PG_" PG_MAJORVERSION "_" \
  24. CppAsString2(CATALOG_VERSION_NO)
  25. /* Characters to allow for an OID in a relation path */
  26. #define OIDCHARS 10 /* max chars printed by %u */
  27. /*
  28. * Stuff for fork names.
  29. *
  30. * The physical storage of a relation consists of one or more forks.
  31. * The main fork is always created, but in addition to that there can be
  32. * additional forks for storing various metadata. ForkNumber is used when
  33. * we need to refer to a specific fork in a relation.
  34. */
  35. typedef enum ForkNumber
  36. {
  37. InvalidForkNumber = -1,
  38. MAIN_FORKNUM = 0,
  39. FSM_FORKNUM,
  40. VISIBILITYMAP_FORKNUM,
  41. INIT_FORKNUM
  42. /*
  43. * NOTE: if you add a new fork, change MAX_FORKNUM and possibly
  44. * FORKNAMECHARS below, and update the forkNames array in
  45. * src/common/relpath.c
  46. */
  47. } ForkNumber;
  48. #define MAX_FORKNUM INIT_FORKNUM
  49. #define FORKNAMECHARS 4 /* max chars for a fork name */
  50. extern PGDLLIMPORT const char *const forkNames[];
  51. extern ForkNumber forkname_to_number(const char *forkName);
  52. extern int forkname_chars(const char *str, ForkNumber *fork);
  53. /*
  54. * Stuff for computing filesystem pathnames for relations.
  55. */
  56. extern char *GetDatabasePath(Oid dbNode, Oid spcNode);
  57. extern char *GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode,
  58. int backendId, ForkNumber forkNumber);
  59. /*
  60. * Wrapper macros for GetRelationPath. Beware of multiple
  61. * evaluation of the RelFileNode or RelFileNodeBackend argument!
  62. */
  63. /* First argument is a RelFileNode */
  64. #define relpathbackend(rnode, backend, forknum) \
  65. GetRelationPath((rnode).dbNode, (rnode).spcNode, (rnode).relNode, \
  66. backend, forknum)
  67. /* First argument is a RelFileNode */
  68. #define relpathperm(rnode, forknum) \
  69. relpathbackend(rnode, InvalidBackendId, forknum)
  70. /* First argument is a RelFileNodeBackend */
  71. #define relpath(rnode, forknum) \
  72. relpathbackend((rnode).node, (rnode).backend, forknum)
  73. #endif /* RELPATH_H */