ibm_db 2.5.18-x86-mingw32 → 2.5.25-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,489 +1,489 @@
1
- /*
2
- +----------------------------------------------------------------------+
3
- | Licensed Materials - Property of IBM |
4
- | |
5
- | (C) Copyright IBM Corporation 2009, 2010, 2012 |
6
- +----------------------------------------------------------------------+
7
- | Authors: Praveen Devarao |
8
- +----------------------------------------------------------------------+
9
- */
10
-
11
- #ifndef RUBY_IBM_DB_CLI_H
12
- #define RUBY_IBM_DB_CLI_H
13
-
14
- #ifdef _WIN32
15
- #include <windows.h>
16
- #else
17
- #include <dlfcn.h>
18
- #endif
19
-
20
- #ifdef _WIN32
21
- #define DLOPEN LoadLibrary
22
- #define DLSYM GetProcAddress
23
- #define DLCLOSE FreeLibrary
24
- #define LIBDB2 "db2cli.dll"
25
- #elif _AIX
26
- #define DLOPEN dlopen
27
- #define DLSYM dlsym
28
- #define DLCLOSE dlclose
29
- #ifdef __64BIT__
30
- /*64-bit library in the archive libdb2.a*/
31
- #define LIBDB2 "libdb2.a(shr_64.o)"
32
- #else
33
- /*32-bit library in the archive libdb2.a*/
34
- #define LIBDB2 "libdb2.a(shr.o)"
35
- #endif
36
- #elif __APPLE__
37
- #define DLOPEN dlopen
38
- #define DLSYM dlsym
39
- #define DLCLOSE dlclose
40
- #define LIBDB2 "libdb2.dylib"
41
- #else
42
- #define DLOPEN dlopen
43
- #define DLSYM dlsym
44
- #define DLCLOSE dlclose
45
- #define LIBDB2 "libdb2.so.1"
46
- #endif
47
-
48
- #include <ruby.h>
49
- #include <stdio.h>
50
- #include <string.h>
51
- #include <stdlib.h>
52
- #include <sqlcli1.h>
53
-
54
- /* Defines a linked list structure for caching param data */
55
- typedef struct _param_cache_node {
56
- SQLSMALLINT data_type; /* Datatype */
57
- SQLUINTEGER param_size; /* param size */
58
- SQLSMALLINT nullable; /* is Nullable */
59
- SQLSMALLINT scale; /* Decimal scale */
60
- SQLUINTEGER file_options; /* File options if PARAM_FILE */
61
- SQLINTEGER bind_indicator; /* indicator variable for SQLBindParameter */
62
- int param_num; /* param number in stmt */
63
- int param_type; /* Type of param - INP/OUT/INP-OUT/FILE */
64
- int size; /* Size of param */
65
- char *varname; /* bound variable name */
66
- SQLBIGINT ivalue; /* Temp storage value */
67
- SQLDOUBLE fvalue; /* Temp storage value */
68
- SQLPOINTER svalue; /* Temp storage value */
69
- struct _param_cache_node *next; /* Pointer to next node */
70
- } param_node;
71
-
72
- typedef struct _conn_handle_struct {
73
- SQLHANDLE henv;
74
- SQLHANDLE hdbc;
75
- long auto_commit;
76
- long c_bin_mode;
77
- long c_case_mode;
78
- long c_cursor_type;
79
- int handle_active;
80
- int transaction_active;
81
- SQLSMALLINT error_recno_tracker;
82
- SQLSMALLINT errormsg_recno_tracker;
83
- int flag_pconnect; /* Indicates that this connection is persistent */
84
-
85
- int errorType; /*Indicates Whether the error logged in ruby_error_msg is a statement error or connection error*/
86
-
87
- SQLPOINTER ruby_error_msg;
88
- SQLPOINTER ruby_error_state;
89
- SQLSMALLINT ruby_error_msg_len;
90
-
91
- SQLINTEGER sqlcode;
92
-
93
- } conn_handle;
94
-
95
- typedef union {
96
- SQLINTEGER i_val;
97
- SQLDOUBLE d_val;
98
- SQLFLOAT f_val;
99
- SQLSMALLINT s_val;
100
- SQLPOINTER str_val;
101
- } ibm_db_row_data_type;
102
-
103
- typedef struct {
104
- SQLINTEGER out_length;
105
- ibm_db_row_data_type data;
106
- } ibm_db_row_type;
107
-
108
- typedef struct _ibm_db_result_set_info_struct {
109
- #ifdef UNICODE_SUPPORT_VERSION
110
- SQLWCHAR *name;
111
- long name_length;
112
- #else
113
- SQLCHAR *name;
114
- #endif
115
- SQLSMALLINT type;
116
- SQLUINTEGER size;
117
- SQLSMALLINT scale;
118
- SQLSMALLINT nullable;
119
- SQLINTEGER lob_loc;
120
- SQLINTEGER loc_ind;
121
- SQLSMALLINT loc_type;
122
- } ibm_db_result_set_info;
123
-
124
- typedef struct _row_hash_struct {
125
- VALUE hash;
126
- } row_hash_struct;
127
-
128
- typedef struct _stmt_handle_struct {
129
- SQLHANDLE hdbc;
130
- SQLHANDLE hstmt;
131
- long s_bin_mode;
132
- long cursor_type;
133
- long s_case_mode;
134
- SQLSMALLINT error_recno_tracker;
135
- SQLSMALLINT errormsg_recno_tracker;
136
-
137
- /* Parameter Caching variables */
138
- param_node *head_cache_list;
139
- param_node *current_node;
140
-
141
- int num_params; /* Number of Params */
142
- int file_param; /* if option passed in is FILE_PARAM */
143
- int num_columns;
144
- int is_executing;
145
- int is_freed; /* Indicates if the SQLFreeHandle is been called on the handle or not.*/
146
-
147
- ibm_db_result_set_info *column_info;
148
- ibm_db_row_type *row_data;
149
-
150
- SQLPOINTER ruby_stmt_err_msg;
151
- SQLPOINTER ruby_stmt_err_state;
152
- SQLSMALLINT ruby_stmt_err_msg_len;
153
- SQLINTEGER sqlcode;
154
- } stmt_handle;
155
-
156
- /*
157
- Structure holding the data to be passed to SQLConnect or SQLDriverConnect CLI call
158
- */
159
- typedef struct _ibm_db_connect_args_struct {
160
- #ifdef UNICODE_SUPPORT_VERSION
161
- SQLWCHAR *database;
162
- SQLWCHAR *uid;
163
- SQLWCHAR *password;
164
- #else
165
- SQLCHAR *database;
166
- SQLCHAR *uid;
167
- SQLCHAR *password;
168
- #endif
169
- SQLSMALLINT database_len;
170
- SQLSMALLINT uid_len;
171
- SQLSMALLINT password_len;
172
- int ctlg_conn; /*Indicates if the connection is a cataloged connection or not*/
173
- SQLHANDLE *hdbc;
174
- } connect_args;
175
-
176
- /*
177
- Structure holding the necessary info to be passed to SQLEndTran CLI call
178
- */
179
- typedef struct _ibm_db_end_tran_args_struct {
180
- SQLHANDLE *hdbc;
181
- SQLSMALLINT handleType;
182
- SQLSMALLINT completionType;
183
- } end_tran_args;
184
-
185
- /*
186
- Structure holding the necessary info to be passed to SQLDescribeparam CLI call
187
- */
188
- typedef struct _ibm_db_describeparam_args_struct {
189
- stmt_handle *stmt_res;
190
- SQLUSMALLINT param_no;
191
- SQLSMALLINT sql_data_type;
192
- SQLUINTEGER sql_precision;
193
- SQLSMALLINT sql_scale;
194
- SQLSMALLINT sql_nullable;
195
- } describeparam_args;
196
-
197
- /*
198
- Structure holding the necessary info to be passed to SQLDescribeCol CLI call
199
- */
200
- typedef struct _ibm_db_describecol_args_struct {
201
- stmt_handle *stmt_res;
202
- SQLUSMALLINT col_no;
203
- SQLSMALLINT name_length;
204
- SQLSMALLINT buff_length;
205
- } describecol_args;
206
- /*
207
- Structure holding the necessary info to be passed to CLI calls like SQLColumns
208
- SQLForeignKeys etc. The same structure is used to get the SP parameters, with table_name as proc_name
209
- */
210
- typedef struct _ibm_db_metadata_args_struct {
211
- stmt_handle *stmt_res;
212
- #ifdef UNICODE_SUPPORT_VERSION
213
- SQLWCHAR *qualifier;
214
- SQLWCHAR *owner;
215
- SQLWCHAR *table_name;
216
- SQLWCHAR *proc_name; /*Used for call SQLProcedureColumns*/
217
- SQLWCHAR *column_name;
218
- SQLWCHAR *table_type;
219
- #else
220
- SQLCHAR *qualifier;
221
- SQLCHAR *owner;
222
- SQLCHAR *table_name;
223
- SQLCHAR *proc_name; /*Used for call SQLProcedureColumns*/
224
- SQLCHAR *column_name;
225
- SQLCHAR *table_type;
226
- #endif
227
- SQLSMALLINT qualifier_len;
228
- SQLSMALLINT owner_len;
229
- SQLSMALLINT table_name_len;
230
- SQLSMALLINT proc_name_len; /*Used for call SQLProcedureColumns*/
231
- SQLSMALLINT column_name_len;
232
- SQLSMALLINT table_type_len;
233
- int scope; /*Used in SQLSpecialColumns To determine the scope of the unique row identifier*/
234
- int unique; /*Used in SQLStatistics to determine if only unique indexes are to be fetched or all*/
235
-
236
- } metadata_args;
237
-
238
- /*
239
- Structure holding the necessary info to be passed to SQLPrepare and SQLExecDirect CLI call
240
- */
241
- typedef struct _ibm_db_exec_direct_args_struct {
242
- stmt_handle *stmt_res;
243
- #ifdef UNICODE_SUPPORT_VERSION
244
- SQLWCHAR *stmt_string;
245
- #else
246
- SQLCHAR *stmt_string;
247
- #endif
248
- long stmt_string_len;
249
- } exec_cum_prepare_args;
250
-
251
- /*
252
- Structure holding the necessary info to be passed to SQLCreateDB and SQLDropDB CLI call
253
- */
254
- typedef struct _ibm_db_create_drop_db_args_struct {
255
- conn_handle *conn_res;
256
- #ifdef UNICODE_SUPPORT_VERSION
257
- SQLWCHAR *dbName;
258
- SQLWCHAR *codeSet;
259
- SQLWCHAR *mode;
260
- #else
261
- SQLCHAR *dbName;
262
- SQLCHAR *codeSet;
263
- SQLCHAR *mode;
264
- #endif
265
- long dbName_string_len;
266
- long codeSet_string_len;
267
- long mode_string_len;
268
- } create_drop_db_args;
269
-
270
- /*
271
- Structure holding the necessary info to be passed to SQLParamData and SQLPutData CLI call
272
- */
273
- typedef struct _ibm_db_param_and_put_data_struct {
274
- stmt_handle *stmt_res;
275
- SQLPOINTER valuePtr;
276
- } param_cum_put_data_args;
277
-
278
- /*
279
- Structure holding the necessary info to be passed to SQLNextResult CLI call
280
- */
281
- typedef struct _ibm_db_next_result_args_struct {
282
- SQLHSTMT *new_hstmt;
283
- stmt_handle *stmt_res;
284
-
285
- } next_result_args;
286
-
287
- /*
288
- Structure holding the necessary info to be passed to calls SQLNumResultCols/SQLNumParams
289
- */
290
- typedef struct _ibm_db_row_col_count_struct {
291
- stmt_handle *stmt_res;
292
- SQLSMALLINT count;
293
- } row_col_count_args;
294
-
295
- /*
296
- Structure holding the necessary info to be passed to call SQLRowcount
297
- */
298
- typedef struct _ibm_db_row_count_struct {
299
- stmt_handle *stmt_res;
300
- SQLINTEGER count;
301
- } sql_row_count_args;
302
-
303
- /*
304
- Structure holding the necessary info to be passed to call SQLColAttributes
305
- */
306
- typedef struct _ibm_db_col_attr_struct {
307
- stmt_handle *stmt_res;
308
- SQLSMALLINT col_num;
309
- SQLSMALLINT FieldIdentifier;
310
- SQLINTEGER num_attr;
311
- } col_attr_args;
312
-
313
- /*
314
- Structure holding the necessary info to be passed to call SQLBindCol
315
- */
316
- typedef struct _ibm_db_bind_col_struct {
317
- stmt_handle *stmt_res;
318
- SQLUSMALLINT col_num;
319
- SQLSMALLINT TargetType;
320
- SQLPOINTER TargetValuePtr;
321
- SQLLEN buff_length;
322
- SQLLEN *out_length;
323
- } bind_col_args;
324
-
325
- /*
326
- Structure holding the necessary info to be passed to call SQLGetData
327
- */
328
- typedef struct _ibm_db_get_data_args_struct {
329
- stmt_handle *stmt_res;
330
- SQLSMALLINT col_num;
331
- SQLSMALLINT targetType;
332
- SQLPOINTER buff;
333
- SQLLEN buff_length;
334
- SQLLEN *out_length;
335
- } get_data_args;
336
-
337
- /*
338
- Structure holding the necessary info to be passed to call SQLGetLength
339
- */
340
- typedef struct _ibm_db_get_data_length_struct {
341
- SQLHSTMT *new_hstmt;
342
- SQLSMALLINT col_num;
343
- stmt_handle *stmt_res;
344
- SQLINTEGER *sLength;
345
-
346
- } get_length_args;
347
-
348
- /*
349
- Structure holding the necessary info to be passed to call SQLGetSubString
350
- */
351
- typedef struct _ibm_db_get_data_subString_struct {
352
- SQLHSTMT *new_hstmt;
353
- SQLSMALLINT col_num;
354
- stmt_handle *stmt_res;
355
- SQLUINTEGER forLength;
356
- SQLSMALLINT targetCType;
357
- SQLPOINTER buffer;
358
- SQLLEN buff_length;
359
- SQLINTEGER *out_length;
360
-
361
- } get_subString_args;
362
-
363
- /*
364
- Structure holding the necessary info to be passed to call SQLFetchScroll and SQLFetch
365
- */
366
- typedef struct _ibm_db_fetch_data_struct {
367
- stmt_handle *stmt_res;
368
- SQLSMALLINT fetchOrientation;
369
- SQLLEN fetchOffset;
370
- } fetch_data_args;
371
-
372
- /*
373
- Structure holding the necessary info to be passed to calls SQLSetStmtAttr/SQLSetConnectAttr/SQLEnvAttr
374
- */
375
- typedef struct _ibm_db_set_handle_attr_struct {
376
- SQLHANDLE *handle;
377
- SQLINTEGER attribute;
378
- SQLPOINTER valuePtr;
379
- SQLINTEGER strLength;
380
-
381
- } set_handle_attr_args;
382
-
383
- /*
384
- Structure holding the necessary info to be passed to call SQLGetStmtAttr and SQLGetConnectAttr
385
- */
386
- typedef struct _ibm_db_get_handle_attr_struct {
387
- SQLHANDLE *handle;
388
- SQLINTEGER attribute;
389
- SQLPOINTER valuePtr;
390
- SQLINTEGER buff_length;
391
- SQLINTEGER *out_length;
392
- } get_handle_attr_args;
393
-
394
- /*
395
- Structure holding the necessary info to be passed to call SQLBindParameter
396
- */
397
- typedef struct _ibm_db_bind_parameter_struct {
398
- stmt_handle *stmt_res;
399
- SQLSMALLINT param_num;
400
- SQLSMALLINT IOType;
401
- SQLSMALLINT valueType;
402
- SQLSMALLINT paramType;
403
- SQLULEN colSize;
404
- SQLSMALLINT decimalDigits;
405
- SQLPOINTER paramValPtr;
406
- SQLLEN buff_length;
407
- SQLLEN *out_length;
408
- } bind_parameter_args;
409
-
410
- /*
411
- Structure holding the necessary info to be passed to call SQLGetInfo
412
- */
413
- typedef struct _ibm_db_get_info_struct {
414
- conn_handle *conn_res;
415
- SQLUSMALLINT infoType;
416
- SQLPOINTER infoValue;
417
- SQLSMALLINT buff_length;
418
- SQLSMALLINT *out_length;
419
- } get_info_args;
420
-
421
- /*
422
- Structure holding the necessary info to be passed to call SQLGetDiagRec
423
- */
424
- typedef struct _ibm_db_get_diagRec_struct {
425
- SQLSMALLINT hType;
426
- SQLHANDLE handle;
427
- SQLSMALLINT recNum;
428
- SQLPOINTER SQLState;
429
- SQLPOINTER msgText;
430
- SQLINTEGER *NativeErrorPtr;
431
- SQLSMALLINT buff_length;
432
- SQLSMALLINT *text_length_ptr;
433
- } get_diagRec_args;
434
-
435
- /*
436
- Structure holding the necessary info to be passed to call SQLFreestmt
437
- */
438
- typedef struct _ibm_db_free_stmt_struct {
439
- stmt_handle *stmt_res;
440
- SQLUSMALLINT option;
441
- } free_stmt_args;
442
-
443
- int _ruby_ibm_db_SQLConnect_helper(connect_args *data);
444
- int _ruby_ibm_db_SQLDisconnect_helper(SQLHANDLE *hdbc);
445
- void _ruby_ibm_db_Connection_level_UBF(void *data);
446
- int _ruby_ibm_db_SQLEndTran(end_tran_args *endtran_args);
447
- int _ruby_ibm_db_SQLDescribeParam_helper(describeparam_args *data);
448
- int _ruby_ibm_db_SQLDescribeCol_helper(describecol_args *data);
449
- int _ruby_ibm_db_SQLBindCol_helper(bind_col_args *data);
450
- int _ruby_ibm_db_SQLColumnPrivileges_helper(metadata_args *data);
451
- int _ruby_ibm_db_SQLColumns_helper(metadata_args *data);
452
- int _ruby_ibm_db_SQLPrimaryKeys_helper(metadata_args *data);
453
- int _ruby_ibm_db_SQLForeignKeys_helper(metadata_args *data);
454
- int _ruby_ibm_db_SQLProcedureColumns_helper(metadata_args *data);
455
- int _ruby_ibm_db_SQLProcedures_helper(metadata_args *data);
456
- int _ruby_ibm_db_SQLSpecialColumns_helper(metadata_args *data);
457
- int _ruby_ibm_db_SQLStatistics_helper(metadata_args *data);
458
- int _ruby_ibm_db_SQLTablePrivileges_helper(metadata_args *data);
459
- int _ruby_ibm_db_SQLTables_helper(metadata_args *data);
460
- int _ruby_ibm_db_SQLExecDirect_helper(exec_cum_prepare_args *data);
461
- int _ruby_ibm_db_SQLPrepare_helper(exec_cum_prepare_args *data);
462
- int _ruby_ibm_db_SQLFreeStmt_helper(free_stmt_args *data);
463
- int _ruby_ibm_db_SQLExecute_helper(stmt_handle *stmt_res);
464
- int _ruby_ibm_db_SQLParamData_helper(param_cum_put_data_args *data);
465
- int _ruby_ibm_db_SQLColAttributes_helper(col_attr_args *data);
466
- int _ruby_ibm_db_SQLPutData_helper(param_cum_put_data_args *data);
467
- int _ruby_ibm_db_SQLGetData_helper(get_data_args *data);
468
- int _ruby_ibm_db_SQLGetLength_helper(get_length_args *data);
469
- int _ruby_ibm_db_SQLGetSubString_helper(get_subString_args *data);
470
- int _ruby_ibm_db_SQLNextResult_helper(next_result_args *data);
471
- int _ruby_ibm_db_SQLFetchScroll_helper(fetch_data_args *data);
472
- int _ruby_ibm_db_SQLFetch_helper(fetch_data_args *data);
473
- int _ruby_ibm_db_SQLNumResultCols_helper(row_col_count_args *data);
474
- int _ruby_ibm_db_SQLNumParams_helper(row_col_count_args *data);
475
- int _ruby_ibm_db_SQLRowCount_helper(sql_row_count_args *data);
476
- int _ruby_ibm_db_SQLGetInfo_helper(get_info_args *data);
477
- int _ruby_ibm_db_SQLGetDiagRec_helper(get_diagRec_args *data);
478
- int _ruby_ibm_db_SQLSetStmtAttr_helper(set_handle_attr_args *data);
479
- int _ruby_ibm_db_SQLSetConnectAttr_helper(set_handle_attr_args *data);
480
- int _ruby_ibm_db_SQLSetEnvAttr_helper(set_handle_attr_args *data);
481
- int _ruby_ibm_db_SQLGetStmtAttr_helper(get_handle_attr_args *data);
482
- int _ruby_ibm_db_SQLGetConnectAttr_helper(get_handle_attr_args *data);
483
- int _ruby_ibm_db_SQLBindFileToParam_helper(stmt_handle *stmt_res, param_node *curr);
484
- int _ruby_ibm_db_SQLBindParameter_helper(bind_parameter_args *data);
485
- void _ruby_ibm_db_Statement_level_UBF(stmt_handle *stmt_res);
486
- int _ruby_ibm_db_SQLCreateDB_helper(create_drop_db_args *data);
487
- int _ruby_ibm_db_SQLDropDB_helper(create_drop_db_args *data);
488
-
489
- #endif /* RUBY_IBM_DB_CLI_H */
1
+ /*
2
+ +----------------------------------------------------------------------+
3
+ | Licensed Materials - Property of IBM |
4
+ | |
5
+ | (C) Copyright IBM Corporation 2009, 2010, 2012 |
6
+ +----------------------------------------------------------------------+
7
+ | Authors: Praveen Devarao |
8
+ +----------------------------------------------------------------------+
9
+ */
10
+
11
+ #ifndef RUBY_IBM_DB_CLI_H
12
+ #define RUBY_IBM_DB_CLI_H
13
+
14
+ #ifdef _WIN32
15
+ #include <windows.h>
16
+ #else
17
+ #include <dlfcn.h>
18
+ #endif
19
+
20
+ #ifdef _WIN32
21
+ #define DLOPEN LoadLibrary
22
+ #define DLSYM GetProcAddress
23
+ #define DLCLOSE FreeLibrary
24
+ #define LIBDB2 "db2cli.dll"
25
+ #elif _AIX
26
+ #define DLOPEN dlopen
27
+ #define DLSYM dlsym
28
+ #define DLCLOSE dlclose
29
+ #ifdef __64BIT__
30
+ /*64-bit library in the archive libdb2.a*/
31
+ #define LIBDB2 "libdb2.a(shr_64.o)"
32
+ #else
33
+ /*32-bit library in the archive libdb2.a*/
34
+ #define LIBDB2 "libdb2.a(shr.o)"
35
+ #endif
36
+ #elif __APPLE__
37
+ #define DLOPEN dlopen
38
+ #define DLSYM dlsym
39
+ #define DLCLOSE dlclose
40
+ #define LIBDB2 "libdb2.dylib"
41
+ #else
42
+ #define DLOPEN dlopen
43
+ #define DLSYM dlsym
44
+ #define DLCLOSE dlclose
45
+ #define LIBDB2 "libdb2.so.1"
46
+ #endif
47
+
48
+ #include <ruby.h>
49
+ #include <stdio.h>
50
+ #include <string.h>
51
+ #include <stdlib.h>
52
+ #include <sqlcli1.h>
53
+
54
+ /* Defines a linked list structure for caching param data */
55
+ typedef struct _param_cache_node {
56
+ SQLSMALLINT data_type; /* Datatype */
57
+ SQLUINTEGER param_size; /* param size */
58
+ SQLSMALLINT nullable; /* is Nullable */
59
+ SQLSMALLINT scale; /* Decimal scale */
60
+ SQLUINTEGER file_options; /* File options if PARAM_FILE */
61
+ SQLINTEGER bind_indicator; /* indicator variable for SQLBindParameter */
62
+ int param_num; /* param number in stmt */
63
+ int param_type; /* Type of param - INP/OUT/INP-OUT/FILE */
64
+ int size; /* Size of param */
65
+ char *varname; /* bound variable name */
66
+ SQLBIGINT ivalue; /* Temp storage value */
67
+ SQLDOUBLE fvalue; /* Temp storage value */
68
+ SQLPOINTER svalue; /* Temp storage value */
69
+ struct _param_cache_node *next; /* Pointer to next node */
70
+ } param_node;
71
+
72
+ typedef struct _conn_handle_struct {
73
+ SQLHANDLE henv;
74
+ SQLHANDLE hdbc;
75
+ long auto_commit;
76
+ long c_bin_mode;
77
+ long c_case_mode;
78
+ long c_cursor_type;
79
+ int handle_active;
80
+ int transaction_active;
81
+ SQLSMALLINT error_recno_tracker;
82
+ SQLSMALLINT errormsg_recno_tracker;
83
+ int flag_pconnect; /* Indicates that this connection is persistent */
84
+
85
+ int errorType; /*Indicates Whether the error logged in ruby_error_msg is a statement error or connection error*/
86
+
87
+ SQLPOINTER ruby_error_msg;
88
+ SQLPOINTER ruby_error_state;
89
+ SQLSMALLINT ruby_error_msg_len;
90
+
91
+ SQLINTEGER sqlcode;
92
+
93
+ } conn_handle;
94
+
95
+ typedef union {
96
+ SQLINTEGER i_val;
97
+ SQLDOUBLE d_val;
98
+ SQLFLOAT f_val;
99
+ SQLSMALLINT s_val;
100
+ SQLPOINTER str_val;
101
+ } ibm_db_row_data_type;
102
+
103
+ typedef struct {
104
+ SQLINTEGER out_length;
105
+ ibm_db_row_data_type data;
106
+ } ibm_db_row_type;
107
+
108
+ typedef struct _ibm_db_result_set_info_struct {
109
+ #ifdef UNICODE_SUPPORT_VERSION
110
+ SQLWCHAR *name;
111
+ long name_length;
112
+ #else
113
+ SQLCHAR *name;
114
+ #endif
115
+ SQLSMALLINT type;
116
+ SQLUINTEGER size;
117
+ SQLSMALLINT scale;
118
+ SQLSMALLINT nullable;
119
+ SQLINTEGER lob_loc;
120
+ SQLINTEGER loc_ind;
121
+ SQLSMALLINT loc_type;
122
+ } ibm_db_result_set_info;
123
+
124
+ typedef struct _row_hash_struct {
125
+ VALUE hash;
126
+ } row_hash_struct;
127
+
128
+ typedef struct _stmt_handle_struct {
129
+ SQLHANDLE hdbc;
130
+ SQLHANDLE hstmt;
131
+ long s_bin_mode;
132
+ long cursor_type;
133
+ long s_case_mode;
134
+ SQLSMALLINT error_recno_tracker;
135
+ SQLSMALLINT errormsg_recno_tracker;
136
+
137
+ /* Parameter Caching variables */
138
+ param_node *head_cache_list;
139
+ param_node *current_node;
140
+
141
+ int num_params; /* Number of Params */
142
+ int file_param; /* if option passed in is FILE_PARAM */
143
+ int num_columns;
144
+ int is_executing;
145
+ int is_freed; /* Indicates if the SQLFreeHandle is been called on the handle or not.*/
146
+
147
+ ibm_db_result_set_info *column_info;
148
+ ibm_db_row_type *row_data;
149
+
150
+ SQLPOINTER ruby_stmt_err_msg;
151
+ SQLPOINTER ruby_stmt_err_state;
152
+ SQLSMALLINT ruby_stmt_err_msg_len;
153
+ SQLINTEGER sqlcode;
154
+ } stmt_handle;
155
+
156
+ /*
157
+ Structure holding the data to be passed to SQLConnect or SQLDriverConnect CLI call
158
+ */
159
+ typedef struct _ibm_db_connect_args_struct {
160
+ #ifdef UNICODE_SUPPORT_VERSION
161
+ SQLWCHAR *database;
162
+ SQLWCHAR *uid;
163
+ SQLWCHAR *password;
164
+ #else
165
+ SQLCHAR *database;
166
+ SQLCHAR *uid;
167
+ SQLCHAR *password;
168
+ #endif
169
+ SQLSMALLINT database_len;
170
+ SQLSMALLINT uid_len;
171
+ SQLSMALLINT password_len;
172
+ int ctlg_conn; /*Indicates if the connection is a cataloged connection or not*/
173
+ SQLHANDLE *hdbc;
174
+ } connect_args;
175
+
176
+ /*
177
+ Structure holding the necessary info to be passed to SQLEndTran CLI call
178
+ */
179
+ typedef struct _ibm_db_end_tran_args_struct {
180
+ SQLHANDLE *hdbc;
181
+ SQLSMALLINT handleType;
182
+ SQLSMALLINT completionType;
183
+ } end_tran_args;
184
+
185
+ /*
186
+ Structure holding the necessary info to be passed to SQLDescribeparam CLI call
187
+ */
188
+ typedef struct _ibm_db_describeparam_args_struct {
189
+ stmt_handle *stmt_res;
190
+ SQLUSMALLINT param_no;
191
+ SQLSMALLINT sql_data_type;
192
+ SQLUINTEGER sql_precision;
193
+ SQLSMALLINT sql_scale;
194
+ SQLSMALLINT sql_nullable;
195
+ } describeparam_args;
196
+
197
+ /*
198
+ Structure holding the necessary info to be passed to SQLDescribeCol CLI call
199
+ */
200
+ typedef struct _ibm_db_describecol_args_struct {
201
+ stmt_handle *stmt_res;
202
+ SQLUSMALLINT col_no;
203
+ SQLSMALLINT name_length;
204
+ SQLSMALLINT buff_length;
205
+ } describecol_args;
206
+ /*
207
+ Structure holding the necessary info to be passed to CLI calls like SQLColumns
208
+ SQLForeignKeys etc. The same structure is used to get the SP parameters, with table_name as proc_name
209
+ */
210
+ typedef struct _ibm_db_metadata_args_struct {
211
+ stmt_handle *stmt_res;
212
+ #ifdef UNICODE_SUPPORT_VERSION
213
+ SQLWCHAR *qualifier;
214
+ SQLWCHAR *owner;
215
+ SQLWCHAR *table_name;
216
+ SQLWCHAR *proc_name; /*Used for call SQLProcedureColumns*/
217
+ SQLWCHAR *column_name;
218
+ SQLWCHAR *table_type;
219
+ #else
220
+ SQLCHAR *qualifier;
221
+ SQLCHAR *owner;
222
+ SQLCHAR *table_name;
223
+ SQLCHAR *proc_name; /*Used for call SQLProcedureColumns*/
224
+ SQLCHAR *column_name;
225
+ SQLCHAR *table_type;
226
+ #endif
227
+ SQLSMALLINT qualifier_len;
228
+ SQLSMALLINT owner_len;
229
+ SQLSMALLINT table_name_len;
230
+ SQLSMALLINT proc_name_len; /*Used for call SQLProcedureColumns*/
231
+ SQLSMALLINT column_name_len;
232
+ SQLSMALLINT table_type_len;
233
+ int scope; /*Used in SQLSpecialColumns To determine the scope of the unique row identifier*/
234
+ int unique; /*Used in SQLStatistics to determine if only unique indexes are to be fetched or all*/
235
+
236
+ } metadata_args;
237
+
238
+ /*
239
+ Structure holding the necessary info to be passed to SQLPrepare and SQLExecDirect CLI call
240
+ */
241
+ typedef struct _ibm_db_exec_direct_args_struct {
242
+ stmt_handle *stmt_res;
243
+ #ifdef UNICODE_SUPPORT_VERSION
244
+ SQLWCHAR *stmt_string;
245
+ #else
246
+ SQLCHAR *stmt_string;
247
+ #endif
248
+ long stmt_string_len;
249
+ } exec_cum_prepare_args;
250
+
251
+ /*
252
+ Structure holding the necessary info to be passed to SQLCreateDB and SQLDropDB CLI call
253
+ */
254
+ typedef struct _ibm_db_create_drop_db_args_struct {
255
+ conn_handle *conn_res;
256
+ #ifdef UNICODE_SUPPORT_VERSION
257
+ SQLWCHAR *dbName;
258
+ SQLWCHAR *codeSet;
259
+ SQLWCHAR *mode;
260
+ #else
261
+ SQLCHAR *dbName;
262
+ SQLCHAR *codeSet;
263
+ SQLCHAR *mode;
264
+ #endif
265
+ long dbName_string_len;
266
+ long codeSet_string_len;
267
+ long mode_string_len;
268
+ } create_drop_db_args;
269
+
270
+ /*
271
+ Structure holding the necessary info to be passed to SQLParamData and SQLPutData CLI call
272
+ */
273
+ typedef struct _ibm_db_param_and_put_data_struct {
274
+ stmt_handle *stmt_res;
275
+ SQLPOINTER valuePtr;
276
+ } param_cum_put_data_args;
277
+
278
+ /*
279
+ Structure holding the necessary info to be passed to SQLNextResult CLI call
280
+ */
281
+ typedef struct _ibm_db_next_result_args_struct {
282
+ SQLHSTMT *new_hstmt;
283
+ stmt_handle *stmt_res;
284
+
285
+ } next_result_args;
286
+
287
+ /*
288
+ Structure holding the necessary info to be passed to calls SQLNumResultCols/SQLNumParams
289
+ */
290
+ typedef struct _ibm_db_row_col_count_struct {
291
+ stmt_handle *stmt_res;
292
+ SQLSMALLINT count;
293
+ } row_col_count_args;
294
+
295
+ /*
296
+ Structure holding the necessary info to be passed to call SQLRowcount
297
+ */
298
+ typedef struct _ibm_db_row_count_struct {
299
+ stmt_handle *stmt_res;
300
+ SQLINTEGER count;
301
+ } sql_row_count_args;
302
+
303
+ /*
304
+ Structure holding the necessary info to be passed to call SQLColAttributes
305
+ */
306
+ typedef struct _ibm_db_col_attr_struct {
307
+ stmt_handle *stmt_res;
308
+ SQLSMALLINT col_num;
309
+ SQLSMALLINT FieldIdentifier;
310
+ SQLINTEGER num_attr;
311
+ } col_attr_args;
312
+
313
+ /*
314
+ Structure holding the necessary info to be passed to call SQLBindCol
315
+ */
316
+ typedef struct _ibm_db_bind_col_struct {
317
+ stmt_handle *stmt_res;
318
+ SQLUSMALLINT col_num;
319
+ SQLSMALLINT TargetType;
320
+ SQLPOINTER TargetValuePtr;
321
+ SQLLEN buff_length;
322
+ SQLLEN *out_length;
323
+ } bind_col_args;
324
+
325
+ /*
326
+ Structure holding the necessary info to be passed to call SQLGetData
327
+ */
328
+ typedef struct _ibm_db_get_data_args_struct {
329
+ stmt_handle *stmt_res;
330
+ SQLSMALLINT col_num;
331
+ SQLSMALLINT targetType;
332
+ SQLPOINTER buff;
333
+ SQLLEN buff_length;
334
+ SQLLEN *out_length;
335
+ } get_data_args;
336
+
337
+ /*
338
+ Structure holding the necessary info to be passed to call SQLGetLength
339
+ */
340
+ typedef struct _ibm_db_get_data_length_struct {
341
+ SQLHSTMT *new_hstmt;
342
+ SQLSMALLINT col_num;
343
+ stmt_handle *stmt_res;
344
+ SQLINTEGER *sLength;
345
+
346
+ } get_length_args;
347
+
348
+ /*
349
+ Structure holding the necessary info to be passed to call SQLGetSubString
350
+ */
351
+ typedef struct _ibm_db_get_data_subString_struct {
352
+ SQLHSTMT *new_hstmt;
353
+ SQLSMALLINT col_num;
354
+ stmt_handle *stmt_res;
355
+ SQLUINTEGER forLength;
356
+ SQLSMALLINT targetCType;
357
+ SQLPOINTER buffer;
358
+ SQLLEN buff_length;
359
+ SQLINTEGER *out_length;
360
+
361
+ } get_subString_args;
362
+
363
+ /*
364
+ Structure holding the necessary info to be passed to call SQLFetchScroll and SQLFetch
365
+ */
366
+ typedef struct _ibm_db_fetch_data_struct {
367
+ stmt_handle *stmt_res;
368
+ SQLSMALLINT fetchOrientation;
369
+ SQLLEN fetchOffset;
370
+ } fetch_data_args;
371
+
372
+ /*
373
+ Structure holding the necessary info to be passed to calls SQLSetStmtAttr/SQLSetConnectAttr/SQLEnvAttr
374
+ */
375
+ typedef struct _ibm_db_set_handle_attr_struct {
376
+ SQLHANDLE *handle;
377
+ SQLINTEGER attribute;
378
+ SQLPOINTER valuePtr;
379
+ SQLINTEGER strLength;
380
+
381
+ } set_handle_attr_args;
382
+
383
+ /*
384
+ Structure holding the necessary info to be passed to call SQLGetStmtAttr and SQLGetConnectAttr
385
+ */
386
+ typedef struct _ibm_db_get_handle_attr_struct {
387
+ SQLHANDLE *handle;
388
+ SQLINTEGER attribute;
389
+ SQLPOINTER valuePtr;
390
+ SQLINTEGER buff_length;
391
+ SQLINTEGER *out_length;
392
+ } get_handle_attr_args;
393
+
394
+ /*
395
+ Structure holding the necessary info to be passed to call SQLBindParameter
396
+ */
397
+ typedef struct _ibm_db_bind_parameter_struct {
398
+ stmt_handle *stmt_res;
399
+ SQLSMALLINT param_num;
400
+ SQLSMALLINT IOType;
401
+ SQLSMALLINT valueType;
402
+ SQLSMALLINT paramType;
403
+ SQLULEN colSize;
404
+ SQLSMALLINT decimalDigits;
405
+ SQLPOINTER paramValPtr;
406
+ SQLLEN buff_length;
407
+ SQLLEN *out_length;
408
+ } bind_parameter_args;
409
+
410
+ /*
411
+ Structure holding the necessary info to be passed to call SQLGetInfo
412
+ */
413
+ typedef struct _ibm_db_get_info_struct {
414
+ conn_handle *conn_res;
415
+ SQLUSMALLINT infoType;
416
+ SQLPOINTER infoValue;
417
+ SQLSMALLINT buff_length;
418
+ SQLSMALLINT *out_length;
419
+ } get_info_args;
420
+
421
+ /*
422
+ Structure holding the necessary info to be passed to call SQLGetDiagRec
423
+ */
424
+ typedef struct _ibm_db_get_diagRec_struct {
425
+ SQLSMALLINT hType;
426
+ SQLHANDLE handle;
427
+ SQLSMALLINT recNum;
428
+ SQLPOINTER SQLState;
429
+ SQLPOINTER msgText;
430
+ SQLINTEGER *NativeErrorPtr;
431
+ SQLSMALLINT buff_length;
432
+ SQLSMALLINT *text_length_ptr;
433
+ } get_diagRec_args;
434
+
435
+ /*
436
+ Structure holding the necessary info to be passed to call SQLFreestmt
437
+ */
438
+ typedef struct _ibm_db_free_stmt_struct {
439
+ stmt_handle *stmt_res;
440
+ SQLUSMALLINT option;
441
+ } free_stmt_args;
442
+
443
+ int _ruby_ibm_db_SQLConnect_helper(connect_args *data);
444
+ int _ruby_ibm_db_SQLDisconnect_helper(SQLHANDLE *hdbc);
445
+ void _ruby_ibm_db_Connection_level_UBF(void *data);
446
+ int _ruby_ibm_db_SQLEndTran(end_tran_args *endtran_args);
447
+ int _ruby_ibm_db_SQLDescribeParam_helper(describeparam_args *data);
448
+ int _ruby_ibm_db_SQLDescribeCol_helper(describecol_args *data);
449
+ int _ruby_ibm_db_SQLBindCol_helper(bind_col_args *data);
450
+ int _ruby_ibm_db_SQLColumnPrivileges_helper(metadata_args *data);
451
+ int _ruby_ibm_db_SQLColumns_helper(metadata_args *data);
452
+ int _ruby_ibm_db_SQLPrimaryKeys_helper(metadata_args *data);
453
+ int _ruby_ibm_db_SQLForeignKeys_helper(metadata_args *data);
454
+ int _ruby_ibm_db_SQLProcedureColumns_helper(metadata_args *data);
455
+ int _ruby_ibm_db_SQLProcedures_helper(metadata_args *data);
456
+ int _ruby_ibm_db_SQLSpecialColumns_helper(metadata_args *data);
457
+ int _ruby_ibm_db_SQLStatistics_helper(metadata_args *data);
458
+ int _ruby_ibm_db_SQLTablePrivileges_helper(metadata_args *data);
459
+ int _ruby_ibm_db_SQLTables_helper(metadata_args *data);
460
+ int _ruby_ibm_db_SQLExecDirect_helper(exec_cum_prepare_args *data);
461
+ int _ruby_ibm_db_SQLPrepare_helper(exec_cum_prepare_args *data);
462
+ int _ruby_ibm_db_SQLFreeStmt_helper(free_stmt_args *data);
463
+ int _ruby_ibm_db_SQLExecute_helper(stmt_handle *stmt_res);
464
+ int _ruby_ibm_db_SQLParamData_helper(param_cum_put_data_args *data);
465
+ int _ruby_ibm_db_SQLColAttributes_helper(col_attr_args *data);
466
+ int _ruby_ibm_db_SQLPutData_helper(param_cum_put_data_args *data);
467
+ int _ruby_ibm_db_SQLGetData_helper(get_data_args *data);
468
+ int _ruby_ibm_db_SQLGetLength_helper(get_length_args *data);
469
+ int _ruby_ibm_db_SQLGetSubString_helper(get_subString_args *data);
470
+ int _ruby_ibm_db_SQLNextResult_helper(next_result_args *data);
471
+ int _ruby_ibm_db_SQLFetchScroll_helper(fetch_data_args *data);
472
+ int _ruby_ibm_db_SQLFetch_helper(fetch_data_args *data);
473
+ int _ruby_ibm_db_SQLNumResultCols_helper(row_col_count_args *data);
474
+ int _ruby_ibm_db_SQLNumParams_helper(row_col_count_args *data);
475
+ int _ruby_ibm_db_SQLRowCount_helper(sql_row_count_args *data);
476
+ int _ruby_ibm_db_SQLGetInfo_helper(get_info_args *data);
477
+ int _ruby_ibm_db_SQLGetDiagRec_helper(get_diagRec_args *data);
478
+ int _ruby_ibm_db_SQLSetStmtAttr_helper(set_handle_attr_args *data);
479
+ int _ruby_ibm_db_SQLSetConnectAttr_helper(set_handle_attr_args *data);
480
+ int _ruby_ibm_db_SQLSetEnvAttr_helper(set_handle_attr_args *data);
481
+ int _ruby_ibm_db_SQLGetStmtAttr_helper(get_handle_attr_args *data);
482
+ int _ruby_ibm_db_SQLGetConnectAttr_helper(get_handle_attr_args *data);
483
+ int _ruby_ibm_db_SQLBindFileToParam_helper(stmt_handle *stmt_res, param_node *curr);
484
+ int _ruby_ibm_db_SQLBindParameter_helper(bind_parameter_args *data);
485
+ void _ruby_ibm_db_Statement_level_UBF(stmt_handle *stmt_res);
486
+ int _ruby_ibm_db_SQLCreateDB_helper(create_drop_db_args *data);
487
+ int _ruby_ibm_db_SQLDropDB_helper(create_drop_db_args *data);
488
+
489
+ #endif /* RUBY_IBM_DB_CLI_H */