forked from yuanrongxi/innodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata0type.inl
126 lines (101 loc) · 2.28 KB
/
data0type.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "mach0data.h"
/*±¾ÎļþÊǶÔdtypeµÄ·â×°*/
UNIV_INLINE void dtype_set(dtype_t* type, ulint mtype, ulint prtype, ulint len, ulint prec)
{
ut_ad(type);
ut_ad(mtype <= DATA_MTYPE_MAX);
type->mtype = mtype;
type->prec = prtype;
type->len = len;
type->prec = prec;
ut_ad(dtype_validate(type));
}
UNIV_INLINE void dtype_copy(dtype_t* type1, dtype_t* type2)
{
*type1 = *type2;
ut_ad(dtype_validate(type1));
}
UNIV_INLINE ulint dtype_get_mtype(dtype_t* type)
{
ut_ad(type);
return type->mtype;
}
UNIV_INLINE ulint dtype_get_prtype(dtype_t* type)
{
ut_ad(type);
return type->prtype;
}
UNIV_INLINE ulint dtype_get_len(dtype_t* type)
{
ut_ad(type);
return type->len;
}
UNIV_INLINE ulint dtype_get_prec(dtype_t* type)
{
ut_ad(type);
return type->prec;
}
UNIV_INLINE ulint dtype_get_pad_char(dtype_t* type)
{
if(type->mtype == DATA_CHAR || type->mtype == DATA_VARCHAR
|| type->mtype == DATA_FIXBINARY || type->mtype == DATA_FIXBINARY){
return ((ulint)' ');
}
return ULINT_UNDEFINED;
}
UNIV_INLINE void dtype_store_for_order_and_null_size(byte* buf, dtype_t* type)
{
ut_ad(4 == DATA_ORDER_NULL_TYPE_BUF_SIZE);
buf[0] = (byte)(type->mtype & 0xff);
buf[1] = (byte)(type->prtype & 0xff);
mach_write_to_2(buf + 2, type->len & 0xffff);
}
UNIV_INLINE void dtype_read_for_order_and_null_size(dtype_t* type, byte* buf)
{
ut_ad(4 == DATA_ORDER_NULL_TYPE_BUF_SIZE);
type->mtype = buf[0];
type->prtype = buf[1];
type->len = mach_read_from_2(buf + 2);
}
UNIV_INLINE ulint dtype_get_fixed_size(dtype_t* type)
{
switch(type->mtype){
case DATA_CHAR:
case DATA_FIXBINARY:
case DATA_INT:
case DATA_FLOAT:
case DATA_DOUBLE:
case DATA_MYSQL:
return dtype_get_len(type);
case DATA_SYS:
if(type->prtype == DATA_ROW_ID)
return DATA_ROW_ID_LEN;
else if(type->prtype == DATA_TRX_ID)
return DATA_TRX_ID_LEN;
else if(type->prtype == DATA_ROLL_PTR)
return DATA_ROLL_PTR_LEN;
else
return 0;
case DATA_VARCHAR:
case DATA_BINARY:
case DATA_DECIMAL:
case DATA_VARMYSQL:
case DATA_BLOB:
return 0;
default:
ut_a(0);
}
return 0;
}
UNIV_INLINE ulint dtype_get_sql_null_size(dtype_t* type)
{
return dtype_get_fixed_size(type);
}
UNIV_INLINE ibool dtype_is_fixed_size(dtype_t* type)
{
lint size;
size = dtype_get_fixed_size(type);
if(size)
return TRUE;
return FALSE;
}