CUBRID Engine  latest
object_representation_constants.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * object_representation_typesize.h - Definitions related to the representation of
22  * objects on disk and in memory.
23  * his file is shared by both the client and server.
24  */
25 
26 #ifndef _OBJECT_REPRESENTATION_CONSTANTS_H_
27 #define _OBJECT_REPRESENTATION_CONSTANTS_H_
28 
29 #include "dbtype_def.h"
30 #include "memory_alloc.h"
31 
32 /*
33  * NUMERIC TYPE SIZES
34  *
35  * These constants define the byte sizes for the fundamental
36  * primitives types as represented in memory and on disk.
37  * WARNING: The disk size for the "short" type is actually the same
38  * as integer since there is no intelligent attribute packing at this
39  * time.
40  */
41 #define OR_BYTE_SIZE 1
42 #define OR_SHORT_SIZE 2
43 #define OR_INT_SIZE 4
44 #define OR_BIGINT_SIZE 8
45 #define OR_FLOAT_SIZE 4
46 #define OR_DOUBLE_SIZE 8
47 
48 #define OR_BIGINT_ALIGNED_SIZE (OR_BIGINT_SIZE + MAX_ALIGNMENT)
49 #define OR_DOUBLE_ALIGNED_SIZE (OR_DOUBLE_SIZE + MAX_ALIGNMENT)
50 #define OR_PTR_ALIGNED_SIZE (OR_PTR_SIZE + MAX_ALIGNMENT)
51 
52 /*
53  * DISK IDENTIFIER SIZES
54  *
55  * These constants describe the size and contents of various disk
56  * identifiers as they are represented in a communication buffer.
57  * The OID can also be used in an attribute value.
58  */
59 
60 #define OR_OID_SIZE 8
61 #define OR_OID_PAGEID 0
62 #define OR_OID_SLOTID 4
63 #define OR_OID_VOLID 6
64 
65 #define OR_VPID_SIZE 6
66 #define OR_VPID_PAGEID 0
67 #define OR_VPID_VOLID 4
68 
69 #define OR_HFID_SIZE 12
70 #define OR_HFID_PAGEID 0
71 #define OR_HFID_VFID_FILEID 4
72 #define OR_HFID_VFID_VOLID 8
73 
74 #define OR_BTID_SIZE 10
75 #define OR_BTID_ALIGNED_SIZE (OR_BTID_SIZE + OR_SHORT_SIZE)
76 #define OR_BTID_PAGEID 0
77 #define OR_BTID_VFID_FILEID 4
78 #define OR_BTID_VFID_VOLID 8
79 
80 #define OR_EHID_SIZE 12
81 #define OR_EHID_VOLID 0
82 #define OR_EHID_FILEID 4
83 #define OR_EHID_PAGEID 8
84 
85 #define OR_LOG_LSA_SIZE 10
86 #define OR_LOG_LSA_ALIGNED_SIZE (OR_LOG_LSA_SIZE + OR_SHORT_SIZE)
87 #define OR_LOG_LSA_PAGEID 0
88 #define OR_LOG_LSA_OFFSET 8
89 
90 /*
91  * EXTENDED TYPE SIZES
92  *
93  * These define the sizes and contents of the primitive types that
94  * are not simple numeric types.
95  */
96 #define OR_TIME_SIZE 4
97 #define OR_UTIME_SIZE 4
98 #define OR_DATE_SIZE 4
99 
100 #define OR_TIMETZ_SIZE (OR_TIME_SIZE + sizeof (TZ_ID))
101 #define OR_TIMETZ_TZID 4
102 
103 #define OR_DATETIME_SIZE 8
104 #define OR_DATETIME_DATE 0
105 #define OR_DATETIME_TIME 4
106 
107 #define OR_TIMESTAMPTZ_SIZE (OR_UTIME_SIZE + sizeof (TZ_ID))
108 #define OR_TIMESTAMPTZ_TZID 4
109 
110 #define OR_DATETIMETZ_SIZE (OR_DATETIME_SIZE + sizeof (TZ_ID))
111 #define OR_DATETIMETZ_TZID 8
112 
113 #define OR_MONETARY_SIZE 12
114 #define OR_MONETARY_TYPE 0
115 #define OR_MONETARY_AMOUNT 4
116 #define OR_ELO_LENGTH_SIZE 4
117 #define OR_ELO_HEADER_SIZE (OR_ELO_LENGTH_SIZE)
118 
119 #define OR_SHA1_SIZE (5 * OR_INT_SIZE)
120 
121 /* NUMERIC RANGES */
122 #define OR_MAX_BYTE 127
123 #define OR_MIN_BYTE -128
124 
125 #define OR_MAX_SHORT_UNSIGNED 65535 /* 0xFFFF */
126 #define OR_MAX_SHORT 32767 /* 0x7FFF */
127 #define OR_MIN_SHORT -32768 /* 0x8000 */
128 
129 #define OR_MAX_INT 2147483647 /* 0x7FFFFFFF */
130 #define OR_MIN_INT -2147483648 /* 0x80000000 */
131 
132 /* OBJECT HEADER LAYOUT */
133 /* representation id, CHN, MVCC insert id, MVCC delete id, prev_version_lsa = 32 */
134 #define OR_MVCC_MAX_HEADER_SIZE 32
135 
136 /* representation id and CHN */
137 #define OR_MVCC_MIN_HEADER_SIZE 8
138 
139 /* representation id, MVCC insert id and CHN */
140 #define OR_MVCC_INSERT_HEADER_SIZE 16
141 
142 #define OR_NON_MVCC_HEADER_SIZE (8) /* two integers */
143 
144 /* 01 stand for 1byte, 10-> 2byte, 11-> 4byte */
145 #define OR_OFFSET_SIZE_FLAG 0x60000000
146 #define OR_OFFSET_SIZE_1BYTE 0x20000000
147 #define OR_OFFSET_SIZE_2BYTE 0x40000000
148 #define OR_OFFSET_SIZE_4BYTE 0x60000000
149 
150 /* Use for MVCC flags the remainder of 5 bits in the first byte. */
151 /* Flag will be shifter by 24 bits to the right */
152 #define OR_MVCC_FLAG_MASK 0x1f
153 #define OR_MVCC_FLAG_SHIFT_BITS 24
154 
155 /* The following flags are used for dynamic MVCC information */
156 /* The record contains MVCC insert id */
157 #define OR_MVCC_FLAG_VALID_INSID 0x01
158 
159 /* The record contains MVCC delete id. If not set, the record contains chn */
160 #define OR_MVCC_FLAG_VALID_DELID 0x02
161 
162 /* The record have an LSA with the location of the previous version */
163 #define OR_MVCC_FLAG_VALID_PREV_VERSION 0x04
164 
165 #define OR_MVCC_REPID_MASK 0x00FFFFFF
166 
167 #endif /* !_OBJECT_REPRESENTATION_CONSTANTS_H_ */