pos.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pos.h
  4. * POSTGRES "position" definitions.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  8. * Portions Copyright (c) 1994, Regents of the University of California
  9. *
  10. * src/include/storage/pos.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef POS_H
  15. #define POS_H
  16. /*
  17. * a 'position' used to be <pagenumber, offset> in postgres. this has
  18. * been changed to just <offset> as the notion of having multiple pages
  19. * within a block has been removed.
  20. *
  21. * the 'offset' abstraction is somewhat confusing. it is NOT a byte
  22. * offset within the page; instead, it is an offset into the line
  23. * pointer array contained on every page that store (heap or index)
  24. * tuples.
  25. */
  26. typedef bits16 PositionIdData;
  27. typedef PositionIdData *PositionId;
  28. /* ----------------
  29. * support macros
  30. * ----------------
  31. */
  32. /*
  33. * PositionIdIsValid
  34. * True iff the position identifier is valid.
  35. */
  36. #define PositionIdIsValid(positionId) \
  37. PointerIsValid(positionId)
  38. /*
  39. * PositionIdSetInvalid
  40. * Make an invalid position.
  41. */
  42. #define PositionIdSetInvalid(positionId) \
  43. *(positionId) = (bits16) 0
  44. /*
  45. * PositionIdSet
  46. * Sets a position identifier to the specified value.
  47. */
  48. #define PositionIdSet(positionId, offsetNumber) \
  49. *(positionId) = (offsetNumber)
  50. /*
  51. * PositionIdGetOffsetNumber
  52. * Retrieve the offset number from a position identifier.
  53. */
  54. #define PositionIdGetOffsetNumber(positionId) \
  55. ((OffsetNumber) *(positionId))
  56. #endif /* POS_H */