Header And Logo

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

attnum.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * attnum.h
00004  *    POSTGRES attribute number 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/access/attnum.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef ATTNUM_H
00015 #define ATTNUM_H
00016 
00017 
00018 /*
00019  * user defined attribute numbers start at 1.   -ay 2/95
00020  */
00021 typedef int16 AttrNumber;
00022 
00023 #define InvalidAttrNumber       0
00024 #define MaxAttrNumber           32767
00025 
00026 /* ----------------
00027  *      support macros
00028  * ----------------
00029  */
00030 /*
00031  * AttributeNumberIsValid
00032  *      True iff the attribute number is valid.
00033  */
00034 #define AttributeNumberIsValid(attributeNumber) \
00035     ((bool) ((attributeNumber) != InvalidAttrNumber))
00036 
00037 /*
00038  * AttrNumberIsForUserDefinedAttr
00039  *      True iff the attribute number corresponds to an user defined attribute.
00040  */
00041 #define AttrNumberIsForUserDefinedAttr(attributeNumber) \
00042     ((bool) ((attributeNumber) > 0))
00043 
00044 /*
00045  * AttrNumberGetAttrOffset
00046  *      Returns the attribute offset for an attribute number.
00047  *
00048  * Note:
00049  *      Assumes the attribute number is for an user defined attribute.
00050  */
00051 #define AttrNumberGetAttrOffset(attNum) \
00052 ( \
00053     AssertMacro(AttrNumberIsForUserDefinedAttr(attNum)), \
00054     ((attNum) - 1) \
00055 )
00056 
00057 /*
00058  * AttributeOffsetGetAttributeNumber
00059  *      Returns the attribute number for an attribute offset.
00060  */
00061 #define AttrOffsetGetAttrNumber(attributeOffset) \
00062      ((AttrNumber) (1 + (attributeOffset)))
00063 
00064 #endif   /* ATTNUM_H */