relpath.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*-------------------------------------------------------------------------
  2. *
  3. * relpath.h
  4. * Declarations for GetRelationPath() and friends
  5. *
  6. * Portions Copyright (c) 1996-2016, 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. * Stuff for fork names.
  17. *
  18. * The physical storage of a relation consists of one or more forks.
  19. * The main fork is always created, but in addition to that there can be
  20. * additional forks for storing various metadata. ForkNumber is used when
  21. * we need to refer to a specific fork in a relation.
  22. */
  23. typedef enum ForkNumber
  24. {
  25. InvalidForkNumber = -1,
  26. MAIN_FORKNUM = 0,
  27. FSM_FORKNUM,
  28. VISIBILITYMAP_FORKNUM,
  29. INIT_FORKNUM
  30. /*
  31. * NOTE: if you add a new fork, change MAX_FORKNUM and possibly
  32. * FORKNAMECHARS below, and update the forkNames array in
  33. * src/common/relpath.c
  34. */
  35. } ForkNumber;
  36. #define MAX_FORKNUM INIT_FORKNUM
  37. #define FORKNAMECHARS 4 /* max chars for a fork name */
  38. extern const char *const forkNames[];
  39. extern ForkNumber forkname_to_number(const char *forkName);
  40. extern int forkname_chars(const char *str, ForkNumber *fork);
  41. /*
  42. * Stuff for computing filesystem pathnames for relations.
  43. */
  44. extern char *GetDatabasePath(Oid dbNode, Oid spcNode);
  45. extern char *GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode,
  46. int backendId, ForkNumber forkNumber);
  47. /*
  48. * Wrapper macros for GetRelationPath. Beware of multiple
  49. * evaluation of the RelFileNode or RelFileNodeBackend argument!
  50. */
  51. /* First argument is a RelFileNode */
  52. #define relpathbackend(rnode, backend, forknum) \
  53. GetRelationPath((rnode).dbNode, (rnode).spcNode, (rnode).relNode, \
  54. backend, forknum)
  55. /* First argument is a RelFileNode */
  56. #define relpathperm(rnode, forknum) \
  57. relpathbackend(rnode, InvalidBackendId, forknum)
  58. /* First argument is a RelFileNodeBackend */
  59. #define relpath(rnode, forknum) \
  60. relpathbackend((rnode).node, (rnode).backend, forknum)
  61. #endif /* RELPATH_H */