1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * off.h |
4 | * POSTGRES disk "offset" definitions. |
5 | * |
6 | * |
7 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
8 | * Portions Copyright (c) 1994, Regents of the University of California |
9 | * |
10 | * src/include/storage/off.h |
11 | * |
12 | *------------------------------------------------------------------------- |
13 | */ |
14 | #ifndef OFF_H |
15 | #define OFF_H |
16 | |
17 | #include "storage/itemid.h" |
18 | /* |
19 | * OffsetNumber: |
20 | * |
21 | * this is a 1-based index into the linp (ItemIdData) array in the |
22 | * header of each disk page. |
23 | */ |
24 | typedef uint16 OffsetNumber; |
25 | |
26 | #define InvalidOffsetNumber ((OffsetNumber) 0) |
27 | #define FirstOffsetNumber ((OffsetNumber) 1) |
28 | #define MaxOffsetNumber ((OffsetNumber) (BLCKSZ / sizeof(ItemIdData))) |
29 | #define OffsetNumberMask (0xffff) /* valid uint16 bits */ |
30 | |
31 | /* ---------------- |
32 | * support macros |
33 | * ---------------- |
34 | */ |
35 | |
36 | /* |
37 | * OffsetNumberIsValid |
38 | * True iff the offset number is valid. |
39 | */ |
40 | #define OffsetNumberIsValid(offsetNumber) \ |
41 | ((bool) ((offsetNumber != InvalidOffsetNumber) && \ |
42 | (offsetNumber <= MaxOffsetNumber))) |
43 | |
44 | /* |
45 | * OffsetNumberNext |
46 | * OffsetNumberPrev |
47 | * Increments/decrements the argument. These macros look pointless |
48 | * but they help us disambiguate the different manipulations on |
49 | * OffsetNumbers (e.g., sometimes we subtract one from an |
50 | * OffsetNumber to move back, and sometimes we do so to form a |
51 | * real C array index). |
52 | */ |
53 | #define OffsetNumberNext(offsetNumber) \ |
54 | ((OffsetNumber) (1 + (offsetNumber))) |
55 | #define OffsetNumberPrev(offsetNumber) \ |
56 | ((OffsetNumber) (-1 + (offsetNumber))) |
57 | |
58 | #endif /* OFF_H */ |
59 | |