]> granicus.if.org Git - postgresql/blob - src/include/access/attnum.h
Add parentheses to macros when args are used in computations. Without
[postgresql] / src / include / access / attnum.h
1 /*-------------------------------------------------------------------------
2  *
3  * attnum.h
4  *        POSTGRES attribute number definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $PostgreSQL: pgsql/src/include/access/attnum.h,v 1.21 2005/05/25 21:40:42 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef ATTNUM_H
15 #define ATTNUM_H
16
17
18 /*
19  * user defined attribute numbers start at 1.   -ay 2/95
20  */
21 typedef int16 AttrNumber;
22
23 #define InvalidAttrNumber               0
24
25 /* ----------------
26  *              support macros
27  * ----------------
28  */
29 /*
30  * AttributeNumberIsValid
31  *              True iff the attribute number is valid.
32  */
33 #define AttributeNumberIsValid(attributeNumber) \
34         ((bool) ((attributeNumber) != InvalidAttrNumber))
35
36 /*
37  * AttrNumberIsForUserDefinedAttr
38  *              True iff the attribute number corresponds to an user defined attribute.
39  */
40 #define AttrNumberIsForUserDefinedAttr(attributeNumber) \
41         ((bool) ((attributeNumber) > 0))
42
43 /*
44  * AttrNumberGetAttrOffset
45  *              Returns the attribute offset for an attribute number.
46  *
47  * Note:
48  *              Assumes the attribute number is for an user defined attribute.
49  */
50 #define AttrNumberGetAttrOffset(attNum) \
51 ( \
52         AssertMacro(AttrNumberIsForUserDefinedAttr(attNum)), \
53         ((attNum) - 1) \
54 )
55
56 /*
57  * AttributeOffsetGetAttributeNumber
58  *              Returns the attribute number for an attribute offset.
59  */
60 #define AttrOffsetGetAttrNumber(attributeOffset) \
61          ((AttrNumber) (1 + (attributeOffset)))
62
63 #endif   /* ATTNUM_H */