]> granicus.if.org Git - postgresql/blob - src/include/storage/pos.h
Centralize definition of integer limits.
[postgresql] / src / include / storage / pos.h
1 /*-------------------------------------------------------------------------
2  *
3  * pos.h
4  *        POSTGRES "position" definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2015, 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
18 /*
19  * a 'position' used to be <pagenumber, offset> in postgres.  this has
20  * been changed to just <offset> as the notion of having multiple pages
21  * within a block has been removed.
22  *
23  * the 'offset' abstraction is somewhat confusing.  it is NOT a byte
24  * offset within the page; instead, it is an offset into the line
25  * pointer array contained on every page that store (heap or index)
26  * tuples.
27  */
28 typedef bits16 PositionIdData;
29 typedef PositionIdData *PositionId;
30
31 /* ----------------
32  *              support macros
33  * ----------------
34  */
35
36 /*
37  * PositionIdIsValid
38  *              True iff the position identifier is valid.
39  */
40 #define PositionIdIsValid(positionId) \
41         PointerIsValid(positionId)
42
43 /*
44  * PositionIdSetInvalid
45  *              Make an invalid position.
46  */
47 #define PositionIdSetInvalid(positionId) \
48         *(positionId) = (bits16) 0
49
50 /*
51  * PositionIdSet
52  *              Sets a position identifier to the specified value.
53  */
54 #define PositionIdSet(positionId, offsetNumber) \
55         *(positionId) = (offsetNumber)
56
57 /*
58  * PositionIdGetOffsetNumber
59  *              Retrieve the offset number from a position identifier.
60  */
61 #define PositionIdGetOffsetNumber(positionId) \
62         ((OffsetNumber) *(positionId))
63
64 #endif   /* POS_H */