Header And Logo

PostgreSQL
| The world's most advanced open source database.

off.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * off.h
00004  *    POSTGRES disk "offset" definitions.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * src/include/storage/off.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef OFF_H
00015 #define OFF_H
00016 
00017 #include "storage/itemid.h"
00018 /*
00019  * OffsetNumber:
00020  *
00021  * this is a 1-based index into the linp (ItemIdData) array in the
00022  * header of each disk page.
00023  */
00024 typedef uint16 OffsetNumber;
00025 
00026 #define InvalidOffsetNumber     ((OffsetNumber) 0)
00027 #define FirstOffsetNumber       ((OffsetNumber) 1)
00028 #define MaxOffsetNumber         ((OffsetNumber) (BLCKSZ / sizeof(ItemIdData)))
00029 #define OffsetNumberMask        (0xffff)        /* valid uint16 bits */
00030 
00031 /* ----------------
00032  *      support macros
00033  * ----------------
00034  */
00035 
00036 /*
00037  * OffsetNumberIsValid
00038  *      True iff the offset number is valid.
00039  */
00040 #define OffsetNumberIsValid(offsetNumber) \
00041     ((bool) ((offsetNumber != InvalidOffsetNumber) && \
00042              (offsetNumber <= MaxOffsetNumber)))
00043 
00044 /*
00045  * OffsetNumberNext
00046  * OffsetNumberPrev
00047  *      Increments/decrements the argument.  These macros look pointless
00048  *      but they help us disambiguate the different manipulations on
00049  *      OffsetNumbers (e.g., sometimes we subtract one from an
00050  *      OffsetNumber to move back, and sometimes we do so to form a
00051  *      real C array index).
00052  */
00053 #define OffsetNumberNext(offsetNumber) \
00054     ((OffsetNumber) (1 + (offsetNumber)))
00055 #define OffsetNumberPrev(offsetNumber) \
00056     ((OffsetNumber) (-1 + (offsetNumber)))
00057 
00058 #endif   /* OFF_H */