FreeTDS API

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tds_types.h
1 /*
2 * This file produced from ./types.pl
3 * CVS Id: types.pl,v 1.3 2010-10-29 08:49:30 freddy77 Exp
4 */
5
9 int
10 tds_get_size_by_type(int servertype)
11 {
12 switch (servertype) {
13 case SYBVOID:
14 return 0;
15 case SYBBIT:
16 case SYBBITN:
17 case SYBINT1:
18 case SYBSINT1:
19 case SYBUINT1:
20 return 1;
21 case SYBINT2:
22 case SYBUINT2:
23 return 2;
24 case SYBDATE:
25 case SYBDATEN:
26 case SYBDATETIME4:
27 case SYBINT4:
28 case SYBMONEY4:
29 case SYBREAL:
30 case SYBTIME:
31 case SYBTIMEN:
32 case SYBUINT4:
33 return 4;
34 case SYB5INT8:
35 case SYBDATETIME:
36 case SYBFLT8:
37 case SYBINT8:
38 case SYBINTERVAL:
39 case SYBMONEY:
40 case SYBUINT8:
41 return 8;
42 case SYBUNIQUE:
43 return 16;
44 default:
45 return -1;
46 }
47 }
48
53 int
54 tds_get_varint_size(TDSSOCKET * tds, int datatype)
55 {
56 switch (datatype) {
57 case SYBBIT:
58 case SYBDATETIME:
59 case SYBDATETIME4:
60 case SYBFLT8:
61 case SYBINT1:
62 case SYBINT2:
63 case SYBINT4:
64 case SYBMONEY:
65 case SYBMONEY4:
66 case SYBREAL:
67 case SYBVOID:
68 return 0;
69 case SYBIMAGE:
70 case SYBTEXT:
71 return 4;
72 }
73
74 if (IS_TDS7_PLUS(tds)) {
75 switch (datatype) {
76 case SYBINT8:
77 return 0;
78 case XSYBBINARY:
79 case XSYBCHAR:
80 case XSYBNCHAR:
81 case XSYBNVARCHAR:
82 case XSYBVARBINARY:
83 case XSYBVARCHAR:
84 return 2;
85 case SYBNTEXT:
86 case SYBVARIANT:
87 return 4;
88 case SYBMSXML:
89 return 8;
90 }
91 } else if (IS_TDS50(tds)) {
92 switch (datatype) {
93 case SYB5INT8:
94 case SYBDATE:
95 case SYBINTERVAL:
96 case SYBSINT1:
97 case SYBTIME:
98 case SYBUINT1:
99 case SYBUINT2:
100 case SYBUINT4:
101 case SYBUINT8:
102 return 0;
103 case SYBUNITEXT:
104 case SYBXML:
105 return 4;
106 case SYBLONGBINARY:
107 case SYBLONGCHAR:
108 return 5;
109 }
110 }
111 return 1;
112 }
113
120 int
121 tds_get_conversion_type(int srctype, int colsize)
122 {
123 switch (srctype) {
124 case SYBBITN:
125 return SYBBIT;
126 case SYBDATEN:
127 return SYBDATE;
128 case SYBDATETIMN:
129 switch (colsize) {
130 case 8:
131 return SYBDATETIME;
132 case 4:
133 return SYBDATETIME4;
134 }
135 break;
136 case SYBFLTN:
137 switch (colsize) {
138 case 8:
139 return SYBFLT8;
140 case 4:
141 return SYBREAL;
142 }
143 break;
144 case SYBINTN:
145 switch (colsize) {
146 case 8:
147 return SYBINT8;
148 case 4:
149 return SYBINT4;
150 case 2:
151 return SYBINT2;
152 case 1:
153 return SYBINT1;
154 }
155 break;
156 case SYBMONEYN:
157 switch (colsize) {
158 case 8:
159 return SYBMONEY;
160 case 4:
161 return SYBMONEY4;
162 }
163 break;
164 case SYBTIMEN:
165 return SYBTIME;
166 case SYBUINTN:
167 switch (colsize) {
168 case 8:
169 return SYBUINT8;
170 case 4:
171 return SYBUINT4;
172 case 2:
173 return SYBUINT2;
174 case 1:
175 return SYBUINT1;
176 }
177 break;
178 case SYB5INT8:
179 return SYBINT8;
180 }
181 return srctype;
182 }
183