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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
pub use self::{
attributes::*, bulk_operation::*, c_data_type::*, desc::*, fetch_orientation::*, functions::*,
indicator::*, info_type::*, interval::*, nullability::*, param_type::*, sql_data_type::*,
sqlreturn::*,
};
use std::os::raw::{c_int, c_void};
mod attributes;
mod bulk_operation;
mod c_data_type;
mod desc;
mod fetch_orientation;
mod functions;
mod indicator;
mod info_type;
mod interval;
mod nullability;
mod param_type;
mod sql_data_type;
mod sqlreturn;
pub enum Obj {}
pub enum Env {}
pub enum Dbc {}
pub enum Stmt {}
pub enum Description {}
pub type Handle = *mut Obj;
pub type HEnv = *mut Env;
pub type HDesc = *mut Description;
pub type HDbc = *mut Dbc;
pub type HStmt = *mut Stmt;
pub type SmallInt = i16;
pub type USmallInt = u16;
pub type Integer = i32;
pub type UInteger = u32;
pub type Pointer = *mut c_void;
pub type Char = u8;
pub type SChar = i8;
pub type WChar = u16;
pub type Len = isize;
pub type ULen = usize;
pub type HWnd = Pointer;
pub type RetCode = i16;
pub const NTS: isize = -3;
pub const NTSL: isize = -3;
pub const MAX_MESSAGE_LENGTH: SmallInt = 512;
pub const SQLSTATE_SIZE: usize = 5;
pub const SQLSTATE_SIZEW: usize = 10;
#[repr(u16)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum FreeStmtOption {
Close = 0,
Unbind = 2,
ResetParams = 3,
}
#[repr(i16)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum HandleType {
Env = 1,
Dbc = 2,
Stmt = 3,
Desc = 4,
}
#[repr(u16)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum DriverConnectOption {
NoPrompt = 0,
Complete = 1,
Prompt = 2,
CompleteRequired = 3,
}
pub const IS_POINTER: i32 = -4;
pub const IS_UINTEGER: i32 = -5;
pub const IS_INTEGER: i32 = -6;
pub const IS_USMALLINT: i32 = -7;
pub const IS_SMALLINT: i32 = -8;
#[repr(C)]
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Hash)]
pub struct YearMonth {
pub year: UInteger,
pub month: UInteger,
}
#[repr(C)]
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Hash)]
pub struct DaySecond {
pub day: UInteger,
pub hour: UInteger,
pub minute: UInteger,
pub second: UInteger,
pub fraction: UInteger,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union IntervalUnion {
pub year_month: YearMonth,
pub day_second: DaySecond,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct IntervalStruct {
pub interval_type: c_int,
pub interval_sign: SmallInt,
pub interval_value: IntervalUnion,
}
#[repr(C)]
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Hash)]
pub struct Date {
pub year: SmallInt,
pub month: USmallInt,
pub day: USmallInt,
}
#[repr(C)]
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Hash)]
pub struct Time {
pub hour: USmallInt,
pub minute: USmallInt,
pub second: USmallInt,
}
#[repr(C)]
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Hash)]
pub struct Timestamp {
pub year: SmallInt,
pub month: USmallInt,
pub day: USmallInt,
pub hour: USmallInt,
pub minute: USmallInt,
pub second: USmallInt,
pub fraction: UInteger,
}
#[repr(C)]
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Hash)]
pub struct Guid {
pub d1: u32,
pub d2: u16,
pub d3: u16,
pub d4: [u8; 8],
}
#[repr(i32)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum ConnectionAttribute {
AsyncEnable = 4,
AccessMode = 101,
AutoCommit = 102,
LoginTimeout = 103,
Trace = 104,
TraceFile = 105,
TranslateLib = 106,
TranslateOption = 107,
TxnIsolation = 108,
CurrentCatalog = 109,
OdbcCursors = 110,
QuietMode = 111,
PacketSize = 112,
ConnectionTimeout = 113,
DisconnectBehaviour = 114,
AsyncDbcFunctionsEnable = 117,
AsyncDbcEvent = 119,
EnlistInDtc = 1207,
EnlistInXa = 1208,
ConnectionDead = 1209,
AutoIpd = 10001,
MetadataId = 10014,
}
#[repr(i32)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum HeaderDiagnosticIdentifier {
ReturnCode = 1,
Number = 2,
RowCount = 3,
SqlState = 4,
Native = 5,
MessageText = 6,
DynamicFunction = 7,
ClassOrigin = 8,
SubclassOrigin = 9,
ConnectionName = 10,
ServerName = 11,
DynamicFunctionCode = 12,
CursorRowCount = -1249,
RowNumber = -1248,
ColumnNumber = -1247,
}
#[repr(i32)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum AsyncConnectionBehavior {
On = 1,
Off = 0,
}
impl Default for AsyncConnectionBehavior {
fn default() -> AsyncConnectionBehavior {
AsyncConnectionBehavior::Off
}
}
#[repr(i32)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum DynamicDiagnosticIdentifier {
AlterDomain = 3,
AlterTable = 4,
Call = 7,
CreateAssertion = 6,
CreateCharacterSet = 8,
CreateCollation = 10,
CreateDomain = 23,
CreateIndex = -1,
CreateSchema = 64,
CreateTable = 77,
CreateTranslation = 79,
CreateView = 84,
DeleteWhere = 19,
DropAssertion = 24,
DropCharacterSet = 25,
DropCollation = 26,
DropDomain = 27,
DropIndex = -2,
DropSchema = 31,
DropTable = 32,
DropTranslation = 33,
DropView = 36,
DynamicDeleteCursor = 38,
DynamicUpdateCursor = 81,
Grant = 48,
Insert = 50,
Revoke = 59,
SelectCursor = 85,
UnknownStatement = 0,
UpdateWhere = 82,
}
#[repr(i16)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum CompletionType {
Commit = 0,
Rollback = 1,
}
pub const MAX_NUMERIC_LEN: usize = 16;
#[repr(C)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
pub struct Numeric {
pub precision: Char,
pub scale: SChar,
pub sign: Char,
pub val: [Char; MAX_NUMERIC_LEN],
}