ibm_db 2.5.26 → 2.5.27

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,489 +1,500 @@
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 - 2015 |
6
+ +----------------------------------------------------------------------+
7
+ | Authors: Praveen Devarao, Arvind Gupta |
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
+ } conn_handle;
93
+
94
+ typedef union {
95
+ SQLINTEGER i_val;
96
+ SQLDOUBLE d_val;
97
+ SQLFLOAT f_val;
98
+ SQLSMALLINT s_val;
99
+ SQLPOINTER str_val;
100
+ } ibm_db_row_data_type;
101
+
102
+ typedef struct {
103
+ SQLINTEGER out_length;
104
+ ibm_db_row_data_type data;
105
+ } ibm_db_row_type;
106
+
107
+ typedef struct _ibm_db_result_set_info_struct {
108
+ #ifdef UNICODE_SUPPORT_VERSION
109
+ SQLWCHAR *name;
110
+ long name_length;
111
+ #else
112
+ SQLCHAR *name;
113
+ #endif
114
+ SQLSMALLINT type;
115
+ SQLUINTEGER size;
116
+ SQLSMALLINT scale;
117
+ SQLSMALLINT nullable;
118
+ SQLINTEGER lob_loc;
119
+ SQLINTEGER loc_ind;
120
+ SQLSMALLINT loc_type;
121
+ } ibm_db_result_set_info;
122
+
123
+ typedef struct _row_hash_struct {
124
+ VALUE hash;
125
+ } row_hash_struct;
126
+
127
+ typedef struct _stmt_handle_struct {
128
+ SQLHANDLE hdbc;
129
+ SQLHANDLE hstmt;
130
+ long s_bin_mode;
131
+ long cursor_type;
132
+ long s_case_mode;
133
+ SQLSMALLINT error_recno_tracker;
134
+ SQLSMALLINT errormsg_recno_tracker;
135
+
136
+ /* Parameter Caching variables */
137
+ param_node *head_cache_list;
138
+ param_node *current_node;
139
+
140
+ int num_params; /* Number of Params */
141
+ int file_param; /* if option passed in is FILE_PARAM */
142
+ int num_columns;
143
+ int is_executing;
144
+ int is_freed; /* Indicates if the SQLFreeHandle is been called on the handle or not.*/
145
+
146
+ ibm_db_result_set_info *column_info;
147
+ ibm_db_row_type *row_data;
148
+
149
+ SQLPOINTER ruby_stmt_err_msg;
150
+ SQLPOINTER ruby_stmt_err_state;
151
+ SQLSMALLINT ruby_stmt_err_msg_len;
152
+ SQLINTEGER sqlcode;
153
+ int rc;
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
+ int rc;
184
+ } end_tran_args;
185
+
186
+ /*
187
+ Structure holding the necessary info to be passed to SQLDescribeparam CLI call
188
+ */
189
+ typedef struct _ibm_db_describeparam_args_struct {
190
+ stmt_handle *stmt_res;
191
+ SQLUSMALLINT param_no;
192
+ SQLSMALLINT sql_data_type;
193
+ SQLUINTEGER sql_precision;
194
+ SQLSMALLINT sql_scale;
195
+ SQLSMALLINT sql_nullable;
196
+ int rc;
197
+ } describeparam_args;
198
+
199
+ /*
200
+ Structure holding the necessary info to be passed to SQLDescribeCol CLI call
201
+ */
202
+ typedef struct _ibm_db_describecol_args_struct {
203
+ stmt_handle *stmt_res;
204
+ SQLUSMALLINT col_no;
205
+ SQLSMALLINT name_length;
206
+ SQLSMALLINT buff_length;
207
+ } describecol_args;
208
+ /*
209
+ Structure holding the necessary info to be passed to CLI calls like SQLColumns
210
+ SQLForeignKeys etc. The same structure is used to get the SP parameters, with table_name as proc_name
211
+ */
212
+ typedef struct _ibm_db_metadata_args_struct {
213
+ stmt_handle *stmt_res;
214
+ #ifdef UNICODE_SUPPORT_VERSION
215
+ SQLWCHAR *qualifier;
216
+ SQLWCHAR *owner;
217
+ SQLWCHAR *table_name;
218
+ SQLWCHAR *proc_name; /*Used for call SQLProcedureColumns*/
219
+ SQLWCHAR *column_name;
220
+ SQLWCHAR *table_type;
221
+ #else
222
+ SQLCHAR *qualifier;
223
+ SQLCHAR *owner;
224
+ SQLCHAR *table_name;
225
+ SQLCHAR *proc_name; /*Used for call SQLProcedureColumns*/
226
+ SQLCHAR *column_name;
227
+ SQLCHAR *table_type;
228
+ #endif
229
+ SQLSMALLINT qualifier_len;
230
+ SQLSMALLINT owner_len;
231
+ SQLSMALLINT table_name_len;
232
+ SQLSMALLINT proc_name_len; /*Used for call SQLProcedureColumns*/
233
+ SQLSMALLINT column_name_len;
234
+ SQLSMALLINT table_type_len;
235
+ int scope; /*Used in SQLSpecialColumns To determine the scope of the unique row identifier*/
236
+ int unique; /*Used in SQLStatistics to determine if only unique indexes are to be fetched or all*/
237
+ int rc;
238
+
239
+ } metadata_args;
240
+
241
+ /*
242
+ Structure holding the necessary info to be passed to SQLPrepare and SQLExecDirect CLI call
243
+ */
244
+ typedef struct _ibm_db_exec_direct_args_struct {
245
+ stmt_handle *stmt_res;
246
+ #ifdef UNICODE_SUPPORT_VERSION
247
+ SQLWCHAR *stmt_string;
248
+ #else
249
+ SQLCHAR *stmt_string;
250
+ #endif
251
+ long stmt_string_len;
252
+ int rc;
253
+ } exec_cum_prepare_args;
254
+
255
+ /*
256
+ Structure holding the necessary info to be passed to SQLCreateDB and SQLDropDB CLI call
257
+ */
258
+ typedef struct _ibm_db_create_drop_db_args_struct {
259
+ conn_handle *conn_res;
260
+ #ifdef UNICODE_SUPPORT_VERSION
261
+ SQLWCHAR *dbName;
262
+ SQLWCHAR *codeSet;
263
+ SQLWCHAR *mode;
264
+ #else
265
+ SQLCHAR *dbName;
266
+ SQLCHAR *codeSet;
267
+ SQLCHAR *mode;
268
+ #endif
269
+ long dbName_string_len;
270
+ long codeSet_string_len;
271
+ long mode_string_len;
272
+ int rc;
273
+ } create_drop_db_args;
274
+
275
+ /*
276
+ Structure holding the necessary info to be passed to SQLParamData and SQLPutData CLI call
277
+ */
278
+ typedef struct _ibm_db_param_and_put_data_struct {
279
+ stmt_handle *stmt_res;
280
+ SQLPOINTER valuePtr;
281
+ } param_cum_put_data_args;
282
+
283
+ /*
284
+ Structure holding the necessary info to be passed to SQLNextResult CLI call
285
+ */
286
+ typedef struct _ibm_db_next_result_args_struct {
287
+ SQLHSTMT *new_hstmt;
288
+ stmt_handle *stmt_res;
289
+ int rc;
290
+ } next_result_args;
291
+
292
+ /*
293
+ Structure holding the necessary info to be passed to calls SQLNumResultCols/SQLNumParams
294
+ */
295
+ typedef struct _ibm_db_row_col_count_struct {
296
+ stmt_handle *stmt_res;
297
+ SQLSMALLINT count;
298
+ int rc;
299
+ } row_col_count_args;
300
+
301
+ /*
302
+ Structure holding the necessary info to be passed to call SQLRowcount
303
+ */
304
+ typedef struct _ibm_db_row_count_struct {
305
+ stmt_handle *stmt_res;
306
+ SQLINTEGER count;
307
+ int rc;
308
+ } sql_row_count_args;
309
+
310
+ /*
311
+ Structure holding the necessary info to be passed to call SQLColAttributes
312
+ */
313
+ typedef struct _ibm_db_col_attr_struct {
314
+ stmt_handle *stmt_res;
315
+ SQLSMALLINT col_num;
316
+ SQLSMALLINT FieldIdentifier;
317
+ SQLINTEGER num_attr;
318
+ int rc;
319
+ } col_attr_args;
320
+
321
+ /*
322
+ Structure holding the necessary info to be passed to call SQLBindCol
323
+ */
324
+ typedef struct _ibm_db_bind_col_struct {
325
+ stmt_handle *stmt_res;
326
+ SQLUSMALLINT col_num;
327
+ SQLSMALLINT TargetType;
328
+ SQLPOINTER TargetValuePtr;
329
+ SQLLEN buff_length;
330
+ SQLLEN *out_length;
331
+ } bind_col_args;
332
+
333
+ /*
334
+ Structure holding the necessary info to be passed to call SQLGetData
335
+ */
336
+ typedef struct _ibm_db_get_data_args_struct {
337
+ stmt_handle *stmt_res;
338
+ SQLSMALLINT col_num;
339
+ SQLSMALLINT targetType;
340
+ SQLPOINTER buff;
341
+ SQLLEN buff_length;
342
+ SQLLEN *out_length;
343
+ } get_data_args;
344
+
345
+ /*
346
+ Structure holding the necessary info to be passed to call SQLGetLength
347
+ */
348
+ typedef struct _ibm_db_get_data_length_struct {
349
+ SQLHSTMT *new_hstmt;
350
+ SQLSMALLINT col_num;
351
+ stmt_handle *stmt_res;
352
+ SQLINTEGER *sLength;
353
+
354
+ } get_length_args;
355
+
356
+ /*
357
+ Structure holding the necessary info to be passed to call SQLGetSubString
358
+ */
359
+ typedef struct _ibm_db_get_data_subString_struct {
360
+ SQLHSTMT *new_hstmt;
361
+ SQLSMALLINT col_num;
362
+ stmt_handle *stmt_res;
363
+ SQLUINTEGER forLength;
364
+ SQLSMALLINT targetCType;
365
+ SQLPOINTER buffer;
366
+ SQLLEN buff_length;
367
+ SQLINTEGER *out_length;
368
+
369
+ } get_subString_args;
370
+
371
+ /*
372
+ Structure holding the necessary info to be passed to call SQLFetchScroll and SQLFetch
373
+ */
374
+ typedef struct _ibm_db_fetch_data_struct {
375
+ stmt_handle *stmt_res;
376
+ SQLSMALLINT fetchOrientation;
377
+ SQLLEN fetchOffset;
378
+ } fetch_data_args;
379
+
380
+ /*
381
+ Structure holding the necessary info to be passed to calls SQLSetStmtAttr/SQLSetConnectAttr/SQLEnvAttr
382
+ */
383
+ typedef struct _ibm_db_set_handle_attr_struct {
384
+ SQLHANDLE *handle;
385
+ SQLINTEGER attribute;
386
+ SQLPOINTER valuePtr;
387
+ SQLINTEGER strLength;
388
+
389
+ } set_handle_attr_args;
390
+
391
+ /*
392
+ Structure holding the necessary info to be passed to call SQLGetStmtAttr and SQLGetConnectAttr
393
+ */
394
+ typedef struct _ibm_db_get_handle_attr_struct {
395
+ SQLHANDLE *handle;
396
+ SQLINTEGER attribute;
397
+ SQLPOINTER valuePtr;
398
+ SQLINTEGER buff_length;
399
+ SQLINTEGER *out_length;
400
+ } get_handle_attr_args;
401
+
402
+ /*
403
+ Structure holding the necessary info to be passed to call SQLBindParameter
404
+ */
405
+ typedef struct _ibm_db_bind_parameter_struct {
406
+ stmt_handle *stmt_res;
407
+ SQLSMALLINT param_num;
408
+ SQLSMALLINT IOType;
409
+ SQLSMALLINT valueType;
410
+ SQLSMALLINT paramType;
411
+ SQLULEN colSize;
412
+ SQLSMALLINT decimalDigits;
413
+ SQLPOINTER paramValPtr;
414
+ SQLLEN buff_length;
415
+ SQLLEN *out_length;
416
+ } bind_parameter_args;
417
+
418
+ /*
419
+ Structure holding the necessary info to be passed to call SQLGetInfo
420
+ */
421
+ typedef struct _ibm_db_get_info_struct {
422
+ conn_handle *conn_res;
423
+ SQLUSMALLINT infoType;
424
+ SQLPOINTER infoValue;
425
+ SQLSMALLINT buff_length;
426
+ SQLSMALLINT *out_length;
427
+ VALUE return_value;
428
+ } get_info_args;
429
+
430
+ /*
431
+ Structure holding the necessary info to be passed to call SQLGetDiagRec
432
+ */
433
+ typedef struct _ibm_db_get_diagRec_struct {
434
+ SQLSMALLINT hType;
435
+ SQLHANDLE handle;
436
+ SQLSMALLINT recNum;
437
+ SQLPOINTER SQLState;
438
+ SQLPOINTER msgText;
439
+ SQLINTEGER *NativeErrorPtr;
440
+ SQLSMALLINT buff_length;
441
+ SQLSMALLINT *text_length_ptr;
442
+ int return_code;
443
+ } get_diagRec_args;
444
+
445
+ /*
446
+ Structure holding the necessary info to be passed to call SQLFreestmt
447
+ */
448
+ typedef struct _ibm_db_free_stmt_struct {
449
+ stmt_handle *stmt_res;
450
+ SQLUSMALLINT option;
451
+ int rc;
452
+ } free_stmt_args;
453
+
454
+ int _ruby_ibm_db_SQLConnect_helper(connect_args *data);
455
+ int _ruby_ibm_db_SQLDisconnect_helper(SQLHANDLE *hdbc);
456
+ void _ruby_ibm_db_Connection_level_UBF(void *data);
457
+ int _ruby_ibm_db_SQLEndTran(end_tran_args *endtran_args);
458
+ int _ruby_ibm_db_SQLDescribeParam_helper(describeparam_args *data);
459
+ int _ruby_ibm_db_SQLDescribeCol_helper(describecol_args *data);
460
+ int _ruby_ibm_db_SQLBindCol_helper(bind_col_args *data);
461
+ int _ruby_ibm_db_SQLColumnPrivileges_helper(metadata_args *data);
462
+ int _ruby_ibm_db_SQLColumns_helper(metadata_args *data);
463
+ int _ruby_ibm_db_SQLPrimaryKeys_helper(metadata_args *data);
464
+ int _ruby_ibm_db_SQLForeignKeys_helper(metadata_args *data);
465
+ int _ruby_ibm_db_SQLProcedureColumns_helper(metadata_args *data);
466
+ int _ruby_ibm_db_SQLProcedures_helper(metadata_args *data);
467
+ int _ruby_ibm_db_SQLSpecialColumns_helper(metadata_args *data);
468
+ int _ruby_ibm_db_SQLStatistics_helper(metadata_args *data);
469
+ int _ruby_ibm_db_SQLTablePrivileges_helper(metadata_args *data);
470
+ int _ruby_ibm_db_SQLTables_helper(metadata_args *data);
471
+ int _ruby_ibm_db_SQLExecDirect_helper(exec_cum_prepare_args *data);
472
+ int _ruby_ibm_db_SQLPrepare_helper(exec_cum_prepare_args *data);
473
+ int _ruby_ibm_db_SQLFreeStmt_helper(free_stmt_args *data);
474
+ int _ruby_ibm_db_SQLExecute_helper(stmt_handle *stmt_res);
475
+ int _ruby_ibm_db_SQLParamData_helper(param_cum_put_data_args *data);
476
+ int _ruby_ibm_db_SQLColAttributes_helper(col_attr_args *data);
477
+ int _ruby_ibm_db_SQLPutData_helper(param_cum_put_data_args *data);
478
+ int _ruby_ibm_db_SQLGetData_helper(get_data_args *data);
479
+ int _ruby_ibm_db_SQLGetLength_helper(get_length_args *data);
480
+ int _ruby_ibm_db_SQLGetSubString_helper(get_subString_args *data);
481
+ int _ruby_ibm_db_SQLNextResult_helper(next_result_args *data);
482
+ int _ruby_ibm_db_SQLFetchScroll_helper(fetch_data_args *data);
483
+ int _ruby_ibm_db_SQLFetch_helper(fetch_data_args *data);
484
+ int _ruby_ibm_db_SQLNumResultCols_helper(row_col_count_args *data);
485
+ int _ruby_ibm_db_SQLNumParams_helper(row_col_count_args *data);
486
+ int _ruby_ibm_db_SQLRowCount_helper(sql_row_count_args *data);
487
+ int _ruby_ibm_db_SQLGetInfo_helper(get_info_args *data);
488
+ int _ruby_ibm_db_SQLGetDiagRec_helper(get_diagRec_args *data);
489
+ int _ruby_ibm_db_SQLSetStmtAttr_helper(set_handle_attr_args *data);
490
+ int _ruby_ibm_db_SQLSetConnectAttr_helper(set_handle_attr_args *data);
491
+ int _ruby_ibm_db_SQLSetEnvAttr_helper(set_handle_attr_args *data);
492
+ int _ruby_ibm_db_SQLGetStmtAttr_helper(get_handle_attr_args *data);
493
+ int _ruby_ibm_db_SQLGetConnectAttr_helper(get_handle_attr_args *data);
494
+ int _ruby_ibm_db_SQLBindFileToParam_helper(stmt_handle *stmt_res, param_node *curr);
495
+ int _ruby_ibm_db_SQLBindParameter_helper(bind_parameter_args *data);
496
+ void _ruby_ibm_db_Statement_level_UBF(stmt_handle *stmt_res);
497
+ int _ruby_ibm_db_SQLCreateDB_helper(create_drop_db_args *data);
498
+ int _ruby_ibm_db_SQLDropDB_helper(create_drop_db_args *data);
499
+
500
+ #endif /* RUBY_IBM_DB_CLI_H */