]> granicus.if.org Git - postgresql/blob - src/include/access/attnum.h
Another PGINDENT run that changes variable indenting and case label indenting. Also...
[postgresql] / src / include / access / attnum.h
1 /*-------------------------------------------------------------------------
2  *
3  * attnum.h--
4  *        POSTGRES attribute number definitions.
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: attnum.h,v 1.6 1997/09/08 02:34:02 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef ATTNUM_H
14 #define ATTNUM_H
15
16
17 /*
18  * user defined attribute numbers start at 1.   -ay 2/95
19  */
20 typedef int16 AttrNumber;
21
22 #define InvalidAttrNumber               0
23
24 /* ----------------
25  *              support macros
26  * ----------------
27  */
28 /*
29  * AttributeNumberIsValid --
30  *              True iff the attribute number is valid.
31  */
32 #define AttributeNumberIsValid(attributeNumber) \
33         ((bool) ((attributeNumber) != InvalidAttrNumber))
34
35 /*
36  * AttrNumberIsForUserDefinedAttr --
37  *              True iff the attribute number corresponds to an user defined attribute.
38  */
39 #define AttrNumberIsForUserDefinedAttr(attributeNumber) \
40         ((bool) ((attributeNumber) > 0))
41
42 /*
43  * AttrNumberGetAttrOffset --
44  *              Returns the attribute offset for an attribute number.
45  *
46  * Note:
47  *              Assumes the attribute number is for an user defined attribute.
48  */
49 #define AttrNumberGetAttrOffset(attNum) \
50          (AssertMacro(AttrNumberIsForUserDefinedAttr(attNum)) ? \
51           ((attNum - 1)) : 0)
52
53 /*
54  * AttributeOffsetGetAttributeNumber --
55  *              Returns the attribute number for an attribute offset.
56  */
57 #define AttrOffsetGetAttrNumber(attributeOffset) \
58          ((AttrNumber) (1 + attributeOffset))
59
60 #endif                                                  /* ATTNUM_H */