ibmi_db 2.5.14-powerpc-aix-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGES +3 -0
- data/LICENSE +18 -0
- data/MANIFEST +24 -0
- data/README +1 -0
- data/README_IBM_i +458 -0
- data/ext/extconf.rb +202 -0
- data/ext/ibm_db.c +12452 -0
- data/ext/ruby_ibm_db.h +191 -0
- data/ext/ruby_ibm_db_cli.c +2453 -0
- data/ext/ruby_ibm_db_cli.h +499 -0
- data/ext/ruby_sql_com.h +143 -0
- data/ext/ruby_sql_luw.h +250 -0
- data/ext/ruby_sql_pase.h +206 -0
- data/lib/IBM_DB.rb +3 -0
- data/lib/active_record/connection_adapters/ibm_db_adapter.rb +3782 -0
- data/lib/active_record/connection_adapters/ibm_db_password.rb +212 -0
- data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1965 -0
- data/lib/active_record/connection_adapters/ibmdb_adapter.rb +2 -0
- data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -0
- data/lib/ibm_db.so +0 -0
- data/version.txt +1 -0
- metadata +119 -0
data/ext/ruby_ibm_db.h
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
/*
|
2
|
+
+----------------------------------------------------------------------+
|
3
|
+
| Licensed Materials - Property of IBM |
|
4
|
+
| |
|
5
|
+
| (C) Copyright IBM Corporation 2006, 2007, 2008, 2009, 2010, 2012 |
|
6
|
+
+----------------------------------------------------------------------+
|
7
|
+
| Authors: Sushant Koduru, Lynh Nguyen, Kanchana Padmanabhan, |
|
8
|
+
| Dan Scott, Helmut Tessarek, Kellen Bombardier, Sam Ruby |
|
9
|
+
| Ambrish Bhargava, Tarun Pasrija, Praveen Devarao |
|
10
|
+
| Tony Cairns |
|
11
|
+
+----------------------------------------------------------------------+
|
12
|
+
*/
|
13
|
+
|
14
|
+
#ifndef RUBY_IBM_DB_H
|
15
|
+
#define RUBY_IBM_DB_H
|
16
|
+
|
17
|
+
#include "ruby_ibm_db_cli.h" /* include here for overrided to work */
|
18
|
+
|
19
|
+
|
20
|
+
#ifdef _WIN32
|
21
|
+
#define RUBY_IBM_DB_API __declspec(dllexport)
|
22
|
+
#else
|
23
|
+
#define RUBY_IBM_DB_API
|
24
|
+
#endif
|
25
|
+
|
26
|
+
/* strlen(" SQLCODE=") added in */
|
27
|
+
#define DB2_MAX_ERR_MSG_LEN (SQL_MAX_MESSAGE_LENGTH + SQL_SQLSTATE_SIZE + 10)
|
28
|
+
|
29
|
+
/*Used to find the type of resource and the error type required*/
|
30
|
+
#define DB_ERRMSG 1
|
31
|
+
#define DB_ERR_STATE 2
|
32
|
+
|
33
|
+
#define DB_CONN 1
|
34
|
+
#define DB_STMT 2
|
35
|
+
|
36
|
+
#define CONN_ERROR 1
|
37
|
+
#define STMT_ERROR 2
|
38
|
+
|
39
|
+
/*Used to decide if LITERAL REPLACEMENT should be turned on or not*/
|
40
|
+
#define SET_QUOTED_LITERAL_REPLACEMENT_ON 1
|
41
|
+
#define SET_QUOTED_LITERAL_REPLACEMENT_OFF 0
|
42
|
+
|
43
|
+
/* DB2 instance environment variable */
|
44
|
+
#define DB2_VAR_INSTANCE "DB2INSTANCE="
|
45
|
+
|
46
|
+
/******** Makes code compatible with the options used by the user */
|
47
|
+
#define BINARY 1
|
48
|
+
#define CONVERT 2
|
49
|
+
#define PASSTHRU 3
|
50
|
+
#define PARAM_FILE 11
|
51
|
+
|
52
|
+
/*fetch*/
|
53
|
+
#define FETCH_INDEX 0x01
|
54
|
+
#define FETCH_ASSOC 0x02
|
55
|
+
#define FETCH_BOTH 0x03
|
56
|
+
|
57
|
+
/* Change column case */
|
58
|
+
#define ATTR_CASE 3271982
|
59
|
+
#define CASE_NATURAL 0
|
60
|
+
#define CASE_LOWER 1
|
61
|
+
#define CASE_UPPER 2
|
62
|
+
|
63
|
+
/* maximum sizes */
|
64
|
+
#define USERID_LEN 16
|
65
|
+
#define ACCTSTR_LEN 200
|
66
|
+
#define APPLNAME_LEN 32
|
67
|
+
#define WRKSTNNAME_LEN 18
|
68
|
+
|
69
|
+
#ifndef ROUND_HALF_EVEN /* IBM i already defined V7+ sqlcli.h */
|
70
|
+
/*
|
71
|
+
* Enum for Decfloat Rounding Modes
|
72
|
+
* */
|
73
|
+
enum
|
74
|
+
{
|
75
|
+
ROUND_HALF_EVEN = 0,
|
76
|
+
ROUND_HALF_UP,
|
77
|
+
ROUND_DOWN,
|
78
|
+
ROUND_CEILING,
|
79
|
+
ROUND_FLOOR
|
80
|
+
}ROUNDING_MODE;
|
81
|
+
#endif
|
82
|
+
|
83
|
+
void Init_ibm_db();
|
84
|
+
|
85
|
+
/* Function Declarations */
|
86
|
+
|
87
|
+
VALUE ibm_db_connect(int argc, VALUE *argv, VALUE self);
|
88
|
+
VALUE ibm_db_createDB(int argc, VALUE *argv, VALUE self);
|
89
|
+
VALUE ibm_db_dropDB(int argc, VALUE *argv, VALUE self);
|
90
|
+
VALUE ibm_db_createDBNX(int argc, VALUE *argv, VALUE self);
|
91
|
+
VALUE ibm_db_commit(int argc, VALUE *argv, VALUE self);
|
92
|
+
VALUE ibm_db_pconnect(int argc, VALUE *argv, VALUE self);
|
93
|
+
VALUE ibm_db_autocommit(int argc, VALUE *argv, VALUE self);
|
94
|
+
VALUE ibm_db_bind_param(int argc, VALUE *argv, VALUE self);
|
95
|
+
VALUE ibm_db_close(int argc, VALUE *argv, VALUE self);
|
96
|
+
VALUE ibm_db_columnprivileges(int argc, VALUE *argv, VALUE self);
|
97
|
+
VALUE ibm_db_column_privileges(int argc, VALUE *argv, VALUE self);
|
98
|
+
VALUE ibm_db_columns(int argc, VALUE *argv, VALUE self);
|
99
|
+
VALUE ibm_db_foreignkeys(int argc, VALUE *argv, VALUE self);
|
100
|
+
VALUE ibm_db_foreign_keys(int argc, VALUE *argv, VALUE self);
|
101
|
+
VALUE ibm_db_primarykeys(int argc, VALUE *argv, VALUE self);
|
102
|
+
VALUE ibm_db_primary_keys(int argc, VALUE *argv, VALUE self);
|
103
|
+
VALUE ibm_db_procedure_columns(int argc, VALUE *argv, VALUE self);
|
104
|
+
VALUE ibm_db_procedures(int argc, VALUE *argv, VALUE self);
|
105
|
+
VALUE ibm_db_specialcolumns(int argc, VALUE *argv, VALUE self);
|
106
|
+
VALUE ibm_db_special_columns(int argc, VALUE *argv, VALUE self);
|
107
|
+
VALUE ibm_db_statistics(int argc, VALUE *argv, VALUE self);
|
108
|
+
VALUE ibm_db_tableprivileges(int argc, VALUE *argv, VALUE self);
|
109
|
+
VALUE ibm_db_table_privileges(int argc, VALUE *argv, VALUE self);
|
110
|
+
VALUE ibm_db_tables(int argc, VALUE *argv, VALUE self);
|
111
|
+
VALUE ibm_db_commit(int argc, VALUE *argv, VALUE self);
|
112
|
+
VALUE ibm_db_exec(int argc, VALUE *argv, VALUE self);
|
113
|
+
VALUE ibm_db_prepare(int argc, VALUE *argv, VALUE self);
|
114
|
+
VALUE ibm_db_execute(int argc, VALUE *argv, VALUE self);
|
115
|
+
VALUE ibm_db_conn_errormsg(int argc, VALUE *argv, VALUE self);
|
116
|
+
VALUE ibm_db_stmt_errormsg(int argc, VALUE *argv, VALUE self);
|
117
|
+
VALUE ibm_db_getErrormsg(int argc, VALUE *argv, VALUE self);
|
118
|
+
VALUE ibm_db_getErrorstate(int argc, VALUE *argv, VALUE self);
|
119
|
+
VALUE ibm_db_conn_error(int argc, VALUE *argv, VALUE self);
|
120
|
+
VALUE ibm_db_stmt_error(int argc, VALUE *argv, VALUE self);
|
121
|
+
VALUE ibm_db_next_result(int argc, VALUE *argv, VALUE self);
|
122
|
+
VALUE ibm_db_num_fields(int argc, VALUE *argv, VALUE self);
|
123
|
+
VALUE ibm_db_num_rows(int argc, VALUE *argv, VALUE self);
|
124
|
+
VALUE ibm_db_result_cols(int argc, VALUE *argv, VALUE self);
|
125
|
+
VALUE ibm_db_field_name(int argc, VALUE *argv, VALUE self);
|
126
|
+
VALUE ibm_db_field_display_size(int argc, VALUE *argv, VALUE self);
|
127
|
+
VALUE ibm_db_field_num(int argc, VALUE *argv, VALUE self);
|
128
|
+
VALUE ibm_db_field_precision(int argc, VALUE *argv, VALUE self);
|
129
|
+
VALUE ibm_db_field_scale(int argc, VALUE *argv, VALUE self);
|
130
|
+
VALUE ibm_db_field_type(int argc, VALUE *argv, VALUE self);
|
131
|
+
VALUE ibm_db_field_width(int argc, VALUE *argv, VALUE self);
|
132
|
+
VALUE ibm_db_cursor_type(int argc, VALUE *argv, VALUE self);
|
133
|
+
VALUE ibm_db_rollback(int argc, VALUE *argv, VALUE self);
|
134
|
+
VALUE ibm_db_free_stmt(int argc, VALUE *argv, VALUE self);
|
135
|
+
VALUE ibm_db_result(int argc, VALUE *argv, VALUE self);
|
136
|
+
VALUE ibm_db_fetch_row(int argc, VALUE *argv, VALUE self);
|
137
|
+
VALUE ibm_db_fetch_assoc(int argc, VALUE *argv, VALUE self);
|
138
|
+
VALUE ibm_db_fetch_array(int argc, VALUE *argv, VALUE self);
|
139
|
+
VALUE ibm_db_fetch_both(int argc, VALUE *argv, VALUE self);
|
140
|
+
VALUE ibm_db_result_all(int argc, VALUE *argv, VALUE self);
|
141
|
+
VALUE ibm_db_free_result(int argc, VALUE *argv, VALUE self);
|
142
|
+
VALUE ibm_db_set_option(int argc, VALUE *argv, VALUE self);
|
143
|
+
VALUE ibm_db_setoption(int argc, VALUE *argv, VALUE self);
|
144
|
+
VALUE ibm_db_get_option(int argc, VALUE *argv, VALUE self);
|
145
|
+
VALUE ibm_db_get_last_serial_value(int argc, VALUE *argv, VALUE self);
|
146
|
+
VALUE ibm_db_getoption(int argc, VALUE *argv, VALUE self);
|
147
|
+
VALUE ibm_db_fetch_object(int argc, VALUE *argv, VALUE self);
|
148
|
+
VALUE ibm_db_server_info(int argc, VALUE *argv, VALUE self);
|
149
|
+
VALUE ibm_db_client_info(int argc, VALUE *argv, VALUE self);
|
150
|
+
VALUE ibm_db_active(int argc, VALUE *argv, VALUE self);
|
151
|
+
|
152
|
+
VALUE ibm_db_trace(int argc, VALUE *argv, VALUE self);
|
153
|
+
VALUE ibm_db_trace_include(int argc, VALUE *argv, VALUE self);
|
154
|
+
VALUE ibm_db_trace_exclude(int argc, VALUE *argv, VALUE self);
|
155
|
+
VALUE ibm_db_trace_clear(int argc, VALUE *argv, VALUE self);
|
156
|
+
|
157
|
+
/*
|
158
|
+
Declare any global variables you may need between the BEGIN
|
159
|
+
and END macros here:
|
160
|
+
*/
|
161
|
+
struct _ibm_db_globals {
|
162
|
+
int bin_mode;
|
163
|
+
#ifdef UNICODE_SUPPORT_VERSION
|
164
|
+
SQLWCHAR __ruby_conn_err_msg[DB2_MAX_ERR_MSG_LEN];
|
165
|
+
SQLWCHAR __ruby_stmt_err_msg[DB2_MAX_ERR_MSG_LEN];
|
166
|
+
SQLWCHAR __ruby_conn_err_state[SQL_SQLSTATE_SIZE + 1];
|
167
|
+
SQLWCHAR __ruby_stmt_err_state[SQL_SQLSTATE_SIZE + 1];
|
168
|
+
#else
|
169
|
+
char __ruby_conn_err_msg[DB2_MAX_ERR_MSG_LEN];
|
170
|
+
char __ruby_stmt_err_msg[DB2_MAX_ERR_MSG_LEN];
|
171
|
+
char __ruby_conn_err_state[SQL_SQLSTATE_SIZE + 1];
|
172
|
+
char __ruby_stmt_err_state[SQL_SQLSTATE_SIZE + 1];
|
173
|
+
#endif
|
174
|
+
};
|
175
|
+
|
176
|
+
/*
|
177
|
+
TODO: make this threadsafe
|
178
|
+
*/
|
179
|
+
|
180
|
+
#define IBM_DB_G(v) (ibm_db_globals->v)
|
181
|
+
|
182
|
+
#endif /* RUBY_IBM_DB_H */
|
183
|
+
|
184
|
+
|
185
|
+
/*
|
186
|
+
* Local variables:
|
187
|
+
* tab-width: 4
|
188
|
+
* c-basic-offset: 4
|
189
|
+
* indent-tabs-mode: t
|
190
|
+
* End:
|
191
|
+
*/
|
@@ -0,0 +1,2453 @@
|
|
1
|
+
/*
|
2
|
+
+----------------------------------------------------------------------+
|
3
|
+
| Licensed Materials - Property of IBM |
|
4
|
+
| |
|
5
|
+
| (C) Copyright IBM Corporation 2009, 2010, 2012 |
|
6
|
+
+----------------------------------------------------------------------+
|
7
|
+
| Authors: Praveen Devarao |
|
8
|
+
| Tony Cairns |
|
9
|
+
+----------------------------------------------------------------------+
|
10
|
+
*/
|
11
|
+
|
12
|
+
/* ==============================
|
13
|
+
* Story of sql_luw.h and sql_pase.h ...
|
14
|
+
* see sql_com.h to understand.
|
15
|
+
* ==============================
|
16
|
+
*/
|
17
|
+
|
18
|
+
/*
|
19
|
+
This C file contains functions that perform DB operations, which can take long time to complete.
|
20
|
+
For Eg: - Like SQLConnect, SQLFetch etc.
|
21
|
+
|
22
|
+
This file in general will contain functions that make CLI calls and
|
23
|
+
depending on whether the call will be transferred to server or not the functions are termed long time comsuming or not.
|
24
|
+
|
25
|
+
The functions which will contact the server and hence can be time consuming will be called by ruby's (1.9 onwards)
|
26
|
+
rb_thread_blocking_region method, which inturn will release the GVL while these operations are being performed.
|
27
|
+
With this the executing thread will become unblocking allowing concurrent threads perform operations simultaneously.
|
28
|
+
*/
|
29
|
+
|
30
|
+
#include "ruby_ibm_db.h" /* define override (see ruby_ibm_db_cli.h) */
|
31
|
+
|
32
|
+
static int _ruby_IBM_DB_ON_ERROR = -1;
|
33
|
+
static void _ruby_ibm_db_check_env_vars();
|
34
|
+
static int _ruby_ibm_db_set_attr_override(set_handle_attr_args *data);
|
35
|
+
static int _ruby_ibm_db_get_attr_override(get_handle_attr_args *data);
|
36
|
+
static int _ruby_IBM_DB_DBCS_ALLOC = -1;
|
37
|
+
|
38
|
+
|
39
|
+
static int _ruby_IBM_DB_TRACE = -1;
|
40
|
+
static int _ruby_IBM_DB_TRACE_ERROR = -1;
|
41
|
+
#define IBM_DB_TRACE_ERROR_BUFFER_MAX 4096
|
42
|
+
static char _ruby_IBM_DB_TRACE_ERROR_BUFFER[IBM_DB_TRACE_ERROR_BUFFER_MAX + 1];
|
43
|
+
static int _ruby_IBM_DB_STOP = -1;
|
44
|
+
static char * _ruby_IBM_DB_FILE = NULL;
|
45
|
+
static int _ruby_IBM_DB_GIL = -1;
|
46
|
+
static void _ruby_ibm_db_console(const char * format, ...);
|
47
|
+
static void _ruby_ibm_db_trace_hexdump(void *string, unsigned int len);
|
48
|
+
static void _ruby_ibm_db_trace_addr(void * addr);
|
49
|
+
static void _ruby_ibm_db_trace_bin_hex(int data);
|
50
|
+
static void _ruby_ibm_db_trace_sql_type(int column_type);
|
51
|
+
static void _ruby_ibm_db_trace_verbose(char * errhead, void *string, unsigned int len, int rc);
|
52
|
+
static void _ruby_ibm_db_trace_output(char * errhead, void *string, unsigned int len);
|
53
|
+
static void _ruby_ibm_db_trace_memory(char * bigbuff, int flag);
|
54
|
+
|
55
|
+
|
56
|
+
typedef struct _param_cache_node2 {
|
57
|
+
stmt_handle *stmt_res;
|
58
|
+
param_node *curr;
|
59
|
+
} param_node2;
|
60
|
+
|
61
|
+
|
62
|
+
/*
|
63
|
+
Connection level release GIL/GVL (see ruby_sql_com.h)
|
64
|
+
*/
|
65
|
+
int _ruby_ibm_db_SQLConnect_GIL_release = 1; /* 0 */
|
66
|
+
int _ruby_ibm_db_SQLDisconnect_GIL_release = 1; /* 1 */
|
67
|
+
int _ruby_ibm_db_SQLEndTran_GIL_release = 1; /* 2 */
|
68
|
+
int _ruby_ibm_db_SQLDescribeParam_GIL_release = 1; /* 3 */
|
69
|
+
int _ruby_ibm_db_SQLDescribeCol_GIL_release = 1; /* 4 */
|
70
|
+
int _ruby_ibm_db_SQLBindCol_GIL_release = 1; /* 5 */
|
71
|
+
int _ruby_ibm_db_SQLColumnPrivileges_GIL_release = 1; /* 6 */
|
72
|
+
int _ruby_ibm_db_SQLColumns_GIL_release = 1; /* 7 */
|
73
|
+
int _ruby_ibm_db_SQLPrimaryKeys_GIL_release = 1; /* 8 */
|
74
|
+
int _ruby_ibm_db_SQLForeignKeys_GIL_release = 1; /* 9 */
|
75
|
+
int _ruby_ibm_db_SQLProcedureColumns_GIL_release = 1; /* 10 */
|
76
|
+
int _ruby_ibm_db_SQLProcedures_GIL_release = 1; /* 11 */
|
77
|
+
int _ruby_ibm_db_SQLSpecialColumns_GIL_release = 1; /* 12 */
|
78
|
+
int _ruby_ibm_db_SQLStatistics_GIL_release = 1; /* 13 */
|
79
|
+
int _ruby_ibm_db_SQLTablePrivileges_GIL_release = 1; /* 14 */
|
80
|
+
int _ruby_ibm_db_SQLTables_GIL_release = 1; /* 15 */
|
81
|
+
int _ruby_ibm_db_SQLExecDirect_GIL_release = 1; /* 16 */
|
82
|
+
int _ruby_ibm_db_SQLCreateDB_GIL_release = 1; /* 17 */
|
83
|
+
int _ruby_ibm_db_SQLDropDB_GIL_release = 1; /* 18 */
|
84
|
+
int _ruby_ibm_db_SQLPrepare_GIL_release = 1; /* 19 */
|
85
|
+
int _ruby_ibm_db_SQLGetInfo_GIL_release = 1; /* 20 */
|
86
|
+
int _ruby_ibm_db_SQLGetDiagRec_GIL_release = 1; /* 21 */
|
87
|
+
int _ruby_ibm_db_SQLSetStmtAttr_GIL_release = 1; /* 22 */
|
88
|
+
int _ruby_ibm_db_SQLSetConnectAttr_GIL_release = 1; /* 23 */
|
89
|
+
int _ruby_ibm_db_SQLSetEnvAttr_GIL_release = 1; /* 24 */
|
90
|
+
int _ruby_ibm_db_SQLGetStmtAttr_GIL_release = 1; /* 25 */
|
91
|
+
int _ruby_ibm_db_SQLGetConnectAttr_GIL_release = 1; /* 26 */
|
92
|
+
int _ruby_ibm_db_SQLGetEnvAttr_GIL_release = 1; /* 27*/
|
93
|
+
/*
|
94
|
+
Statement level release GIL/GVL (see ruby_sql_com.h)
|
95
|
+
*/
|
96
|
+
int _ruby_ibm_db_SQLFreeStmt_GIL_release = 1; /* 28 */
|
97
|
+
int _ruby_ibm_db_SQLExecute_GIL_release = 1; /* 29 */
|
98
|
+
int _ruby_ibm_db_SQLParamData_GIL_release = 1; /* 30 */
|
99
|
+
int _ruby_ibm_db_SQLColAttributes_GIL_release = 1; /* 31 */
|
100
|
+
int _ruby_ibm_db_SQLPutData_GIL_release = 1; /* 32 */
|
101
|
+
int _ruby_ibm_db_SQLGetData_GIL_release = 1; /* 33 */
|
102
|
+
int _ruby_ibm_db_SQLGetLength_GIL_release = 1; /* 34 */
|
103
|
+
int _ruby_ibm_db_SQLGetSubString_GIL_release = 1; /* 35 */
|
104
|
+
int _ruby_ibm_db_SQLNextResult_GIL_release = 1; /* 36 */
|
105
|
+
int _ruby_ibm_db_SQLFetchScroll_GIL_release = 1; /* 37 */
|
106
|
+
int _ruby_ibm_db_SQLFetch_GIL_release = 1; /* 38 */
|
107
|
+
int _ruby_ibm_db_SQLNumResultCols_GIL_release = 1; /* 39 */
|
108
|
+
int _ruby_ibm_db_SQLNumParams_GIL_release = 1; /* 40 */
|
109
|
+
int _ruby_ibm_db_SQLRowCount_GIL_release = 1; /* 41 */
|
110
|
+
int _ruby_ibm_db_SQLBindFileToParam_GIL_release = 1; /* 42 */
|
111
|
+
int _ruby_ibm_db_SQLBindParameter_GIL_release = 1; /* 43 */
|
112
|
+
|
113
|
+
static void _ruby_ibm_db_set_GIL(int i, char a) {
|
114
|
+
switch(i) {
|
115
|
+
case 0:
|
116
|
+
if (a =='0') _ruby_ibm_db_SQLConnect_GIL_release= 0;
|
117
|
+
else _ruby_ibm_db_SQLConnect_GIL_release= 1;
|
118
|
+
break;
|
119
|
+
case 1:
|
120
|
+
if (a =='0') _ruby_ibm_db_SQLDisconnect_GIL_release= 0;
|
121
|
+
else _ruby_ibm_db_SQLDisconnect_GIL_release= 1;
|
122
|
+
break;
|
123
|
+
case 2:
|
124
|
+
if (a =='0') _ruby_ibm_db_SQLEndTran_GIL_release= 0;
|
125
|
+
else _ruby_ibm_db_SQLEndTran_GIL_release= 1;
|
126
|
+
break;
|
127
|
+
case 3:
|
128
|
+
if (a =='0') _ruby_ibm_db_SQLDescribeParam_GIL_release= 0;
|
129
|
+
else _ruby_ibm_db_SQLDescribeParam_GIL_release= 1;
|
130
|
+
break;
|
131
|
+
case 4:
|
132
|
+
if (a =='0') _ruby_ibm_db_SQLDescribeCol_GIL_release= 0;
|
133
|
+
else _ruby_ibm_db_SQLDescribeCol_GIL_release= 1;
|
134
|
+
break;
|
135
|
+
case 5:
|
136
|
+
if (a =='0') _ruby_ibm_db_SQLBindCol_GIL_release= 0;
|
137
|
+
else _ruby_ibm_db_SQLBindCol_GIL_release= 1;
|
138
|
+
break;
|
139
|
+
case 6:
|
140
|
+
if (a =='0') _ruby_ibm_db_SQLColumnPrivileges_GIL_release= 0;
|
141
|
+
else _ruby_ibm_db_SQLColumnPrivileges_GIL_release= 1;
|
142
|
+
break;
|
143
|
+
case 7:
|
144
|
+
if (a =='0') _ruby_ibm_db_SQLColumns_GIL_release= 0;
|
145
|
+
else _ruby_ibm_db_SQLColumns_GIL_release= 1;
|
146
|
+
break;
|
147
|
+
case 8:
|
148
|
+
if (a =='0') _ruby_ibm_db_SQLPrimaryKeys_GIL_release= 0;
|
149
|
+
else _ruby_ibm_db_SQLPrimaryKeys_GIL_release= 1;
|
150
|
+
break;
|
151
|
+
case 9:
|
152
|
+
if (a =='0') _ruby_ibm_db_SQLForeignKeys_GIL_release= 0;
|
153
|
+
else _ruby_ibm_db_SQLForeignKeys_GIL_release= 1;
|
154
|
+
break;
|
155
|
+
case 10:
|
156
|
+
if (a =='0') _ruby_ibm_db_SQLProcedureColumns_GIL_release= 0;
|
157
|
+
else _ruby_ibm_db_SQLProcedureColumns_GIL_release= 1;
|
158
|
+
break;
|
159
|
+
case 11:
|
160
|
+
if (a =='0') _ruby_ibm_db_SQLProcedures_GIL_release= 0;
|
161
|
+
else _ruby_ibm_db_SQLProcedures_GIL_release= 1;
|
162
|
+
break;
|
163
|
+
case 12:
|
164
|
+
if (a =='0') _ruby_ibm_db_SQLSpecialColumns_GIL_release= 0;
|
165
|
+
else _ruby_ibm_db_SQLSpecialColumns_GIL_release= 1;
|
166
|
+
break;
|
167
|
+
case 13:
|
168
|
+
if (a =='0') _ruby_ibm_db_SQLStatistics_GIL_release= 0;
|
169
|
+
else _ruby_ibm_db_SQLStatistics_GIL_release= 1;
|
170
|
+
break;
|
171
|
+
case 14:
|
172
|
+
if (a =='0') _ruby_ibm_db_SQLTablePrivileges_GIL_release= 0;
|
173
|
+
else _ruby_ibm_db_SQLTablePrivileges_GIL_release= 1;
|
174
|
+
break;
|
175
|
+
case 15:
|
176
|
+
if (a =='0') _ruby_ibm_db_SQLTables_GIL_release= 0;
|
177
|
+
else _ruby_ibm_db_SQLTables_GIL_release= 1;
|
178
|
+
break;
|
179
|
+
case 16:
|
180
|
+
if (a =='0') _ruby_ibm_db_SQLExecDirect_GIL_release= 0;
|
181
|
+
else _ruby_ibm_db_SQLExecDirect_GIL_release= 1;
|
182
|
+
break;
|
183
|
+
case 17:
|
184
|
+
if (a =='0') _ruby_ibm_db_SQLCreateDB_GIL_release= 0;
|
185
|
+
else _ruby_ibm_db_SQLCreateDB_GIL_release= 1;
|
186
|
+
break;
|
187
|
+
case 18:
|
188
|
+
if (a =='0') _ruby_ibm_db_SQLDropDB_GIL_release= 0;
|
189
|
+
else _ruby_ibm_db_SQLDropDB_GIL_release= 1;
|
190
|
+
break;
|
191
|
+
case 19:
|
192
|
+
if (a =='0') _ruby_ibm_db_SQLPrepare_GIL_release= 0;
|
193
|
+
else _ruby_ibm_db_SQLPrepare_GIL_release= 1;
|
194
|
+
break;
|
195
|
+
case 20:
|
196
|
+
if (a =='0') _ruby_ibm_db_SQLGetInfo_GIL_release= 0;
|
197
|
+
else _ruby_ibm_db_SQLGetInfo_GIL_release= 1;
|
198
|
+
break;
|
199
|
+
case 21:
|
200
|
+
if (a =='0') _ruby_ibm_db_SQLGetDiagRec_GIL_release= 0;
|
201
|
+
else _ruby_ibm_db_SQLGetDiagRec_GIL_release= 1;
|
202
|
+
break;
|
203
|
+
case 22:
|
204
|
+
if (a =='0') _ruby_ibm_db_SQLSetStmtAttr_GIL_release= 0;
|
205
|
+
else _ruby_ibm_db_SQLSetStmtAttr_GIL_release= 1;
|
206
|
+
break;
|
207
|
+
case 23:
|
208
|
+
if (a =='0') _ruby_ibm_db_SQLSetConnectAttr_GIL_release= 0;
|
209
|
+
else _ruby_ibm_db_SQLSetConnectAttr_GIL_release= 1;
|
210
|
+
break;
|
211
|
+
case 24:
|
212
|
+
if (a =='0') _ruby_ibm_db_SQLSetEnvAttr_GIL_release= 0;
|
213
|
+
else _ruby_ibm_db_SQLSetEnvAttr_GIL_release= 1;
|
214
|
+
break;
|
215
|
+
case 25:
|
216
|
+
if (a =='0') _ruby_ibm_db_SQLGetStmtAttr_GIL_release= 0;
|
217
|
+
else _ruby_ibm_db_SQLGetStmtAttr_GIL_release= 1;
|
218
|
+
break;
|
219
|
+
case 26:
|
220
|
+
if (a =='0') _ruby_ibm_db_SQLGetConnectAttr_GIL_release= 0;
|
221
|
+
else _ruby_ibm_db_SQLGetConnectAttr_GIL_release= 1;
|
222
|
+
break;
|
223
|
+
case 27:
|
224
|
+
if (a =='0') _ruby_ibm_db_SQLGetEnvAttr_GIL_release= 0;
|
225
|
+
else _ruby_ibm_db_SQLGetEnvAttr_GIL_release= 1;
|
226
|
+
break;
|
227
|
+
case 28:
|
228
|
+
if (a =='0') _ruby_ibm_db_SQLFreeStmt_GIL_release= 0;
|
229
|
+
else _ruby_ibm_db_SQLFreeStmt_GIL_release= 1;
|
230
|
+
break;
|
231
|
+
case 29:
|
232
|
+
if (a =='0') _ruby_ibm_db_SQLExecute_GIL_release= 0;
|
233
|
+
else _ruby_ibm_db_SQLExecute_GIL_release= 1;
|
234
|
+
break;
|
235
|
+
case 30:
|
236
|
+
if (a =='0') _ruby_ibm_db_SQLParamData_GIL_release= 0;
|
237
|
+
else _ruby_ibm_db_SQLParamData_GIL_release= 1;
|
238
|
+
break;
|
239
|
+
case 31:
|
240
|
+
if (a =='0') _ruby_ibm_db_SQLColAttributes_GIL_release= 0;
|
241
|
+
else _ruby_ibm_db_SQLColAttributes_GIL_release= 1;
|
242
|
+
break;
|
243
|
+
case 32:
|
244
|
+
if (a =='0') _ruby_ibm_db_SQLPutData_GIL_release= 0;
|
245
|
+
else _ruby_ibm_db_SQLPutData_GIL_release= 1;
|
246
|
+
break;
|
247
|
+
case 33:
|
248
|
+
if (a =='0') _ruby_ibm_db_SQLGetData_GIL_release= 0;
|
249
|
+
else _ruby_ibm_db_SQLGetData_GIL_release= 1;
|
250
|
+
break;
|
251
|
+
case 34:
|
252
|
+
if (a =='0') _ruby_ibm_db_SQLGetLength_GIL_release= 0;
|
253
|
+
else _ruby_ibm_db_SQLGetLength_GIL_release= 1;
|
254
|
+
break;
|
255
|
+
case 35:
|
256
|
+
if (a =='0') _ruby_ibm_db_SQLGetSubString_GIL_release= 0;
|
257
|
+
else _ruby_ibm_db_SQLGetSubString_GIL_release= 1;
|
258
|
+
break;
|
259
|
+
case 36:
|
260
|
+
if (a =='0') _ruby_ibm_db_SQLNextResult_GIL_release= 0;
|
261
|
+
else _ruby_ibm_db_SQLNextResult_GIL_release= 1;
|
262
|
+
break;
|
263
|
+
case 37:
|
264
|
+
if (a =='0') _ruby_ibm_db_SQLFetchScroll_GIL_release= 0;
|
265
|
+
else _ruby_ibm_db_SQLFetchScroll_GIL_release= 1;
|
266
|
+
break;
|
267
|
+
case 38:
|
268
|
+
if (a =='0') _ruby_ibm_db_SQLFetch_GIL_release= 0;
|
269
|
+
else _ruby_ibm_db_SQLFetch_GIL_release= 1;
|
270
|
+
break;
|
271
|
+
case 39:
|
272
|
+
if (a =='0') _ruby_ibm_db_SQLNumResultCols_GIL_release= 0;
|
273
|
+
else _ruby_ibm_db_SQLNumResultCols_GIL_release= 1;
|
274
|
+
break;
|
275
|
+
case 40:
|
276
|
+
if (a =='0') _ruby_ibm_db_SQLNumParams_GIL_release= 0;
|
277
|
+
else _ruby_ibm_db_SQLNumParams_GIL_release= 1;
|
278
|
+
break;
|
279
|
+
case 41:
|
280
|
+
if (a =='0') _ruby_ibm_db_SQLRowCount_GIL_release= 0;
|
281
|
+
else _ruby_ibm_db_SQLRowCount_GIL_release= 1;
|
282
|
+
break;
|
283
|
+
case 42:
|
284
|
+
if (a =='0') _ruby_ibm_db_SQLBindFileToParam_GIL_release= 0;
|
285
|
+
else _ruby_ibm_db_SQLBindFileToParam_GIL_release= 1;
|
286
|
+
break;
|
287
|
+
case 43:
|
288
|
+
if (a =='0') _ruby_ibm_db_SQLBindParameter_GIL_release= 0;
|
289
|
+
else _ruby_ibm_db_SQLBindParameter_GIL_release= 1;
|
290
|
+
break;
|
291
|
+
default:
|
292
|
+
break;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
static void _ruby_ibm_db_talk_GIL() {
|
296
|
+
if (_ruby_IBM_DB_TRACE_ERROR == 1) return;
|
297
|
+
_ruby_ibm_db_console("%s\n","-------------");
|
298
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLConnect_GIL_release = %d\n",_ruby_ibm_db_SQLConnect_GIL_release);
|
299
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLDisconnect_GIL_release = %d\n",_ruby_ibm_db_SQLDisconnect_GIL_release);
|
300
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLEndTran_GIL_release = %d\n",_ruby_ibm_db_SQLEndTran_GIL_release);
|
301
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLDescribeParam_GIL_release = %d\n",_ruby_ibm_db_SQLDescribeParam_GIL_release);
|
302
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLDescribeCol_GIL_release = %d\n",_ruby_ibm_db_SQLDescribeCol_GIL_release);
|
303
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLBindCol_GIL_release = %d\n",_ruby_ibm_db_SQLBindCol_GIL_release);
|
304
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLColumnPrivileges_GIL_release = %d\n",_ruby_ibm_db_SQLColumnPrivileges_GIL_release);
|
305
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLColumns_GIL_release = %d\n",_ruby_ibm_db_SQLColumns_GIL_release);
|
306
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLPrimaryKeys_GIL_release = %d\n",_ruby_ibm_db_SQLPrimaryKeys_GIL_release);
|
307
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLForeignKeys_GIL_release = %d\n",_ruby_ibm_db_SQLForeignKeys_GIL_release);
|
308
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLProcedureColumns_GIL_release = %d\n",_ruby_ibm_db_SQLProcedureColumns_GIL_release);
|
309
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLProcedures_GIL_release = %d\n",_ruby_ibm_db_SQLProcedures_GIL_release);
|
310
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLSpecialColumns_GIL_release = %d\n",_ruby_ibm_db_SQLSpecialColumns_GIL_release);
|
311
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLStatistics_GIL_release = %d\n",_ruby_ibm_db_SQLStatistics_GIL_release);
|
312
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLTablePrivileges_GIL_release = %d\n",_ruby_ibm_db_SQLTablePrivileges_GIL_release);
|
313
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLTables_GIL_release = %d\n",_ruby_ibm_db_SQLTables_GIL_release);
|
314
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLExecDirect_GIL_release = %d\n",_ruby_ibm_db_SQLExecDirect_GIL_release);
|
315
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLCreateDB_GIL_release = %d\n",_ruby_ibm_db_SQLCreateDB_GIL_release);
|
316
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLDropDB_GIL_release = %d\n",_ruby_ibm_db_SQLDropDB_GIL_release);
|
317
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLPrepare_GIL_release = %d\n",_ruby_ibm_db_SQLPrepare_GIL_release);
|
318
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLGetInfo_GIL_release = %d\n",_ruby_ibm_db_SQLGetInfo_GIL_release);
|
319
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLGetDiagRec_GIL_release = %d\n",_ruby_ibm_db_SQLGetDiagRec_GIL_release);
|
320
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLSetStmtAttr_GIL_release = %d\n",_ruby_ibm_db_SQLSetStmtAttr_GIL_release);
|
321
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLSetConnectAttr_GIL_release = %d\n",_ruby_ibm_db_SQLSetConnectAttr_GIL_release);
|
322
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLSetEnvAttr_GIL_release = %d\n",_ruby_ibm_db_SQLSetEnvAttr_GIL_release);
|
323
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLGetStmtAttr_GIL_release = %d\n",_ruby_ibm_db_SQLGetStmtAttr_GIL_release);
|
324
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLGetConnectAttr_GIL_release = %d\n",_ruby_ibm_db_SQLGetConnectAttr_GIL_release);
|
325
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLGetEnvAttr_GIL_release = %d\n",_ruby_ibm_db_SQLGetEnvAttr_GIL_release);
|
326
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLFreeStmt_GIL_release = %d\n",_ruby_ibm_db_SQLFreeStmt_GIL_release);
|
327
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLExecute_GIL_release = %d\n",_ruby_ibm_db_SQLExecute_GIL_release);
|
328
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLParamData_GIL_release = %d\n",_ruby_ibm_db_SQLParamData_GIL_release);
|
329
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLColAttributes_GIL_release = %d\n",_ruby_ibm_db_SQLColAttributes_GIL_release);
|
330
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLPutData_GIL_release = %d\n",_ruby_ibm_db_SQLPutData_GIL_release);
|
331
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLGetData_GIL_release = %d\n",_ruby_ibm_db_SQLGetData_GIL_release);
|
332
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLGetLength_GIL_release = %d\n",_ruby_ibm_db_SQLGetLength_GIL_release);
|
333
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLGetSubString_GIL_release = %d\n",_ruby_ibm_db_SQLGetSubString_GIL_release);
|
334
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLNextResult_GIL_release = %d\n",_ruby_ibm_db_SQLNextResult_GIL_release);
|
335
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLFetchScroll_GIL_release = %d\n",_ruby_ibm_db_SQLFetchScroll_GIL_release);
|
336
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLFetch_GIL_release = %d\n",_ruby_ibm_db_SQLFetch_GIL_release);
|
337
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLNumResultCols_GIL_release = %d\n",_ruby_ibm_db_SQLNumResultCols_GIL_release);
|
338
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLNumParams_GIL_release = %d\n",_ruby_ibm_db_SQLNumParams_GIL_release);
|
339
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLRowCount_GIL_release = %d\n",_ruby_ibm_db_SQLRowCount_GIL_release);
|
340
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLBindFileToParam_GIL_release = %d\n",_ruby_ibm_db_SQLBindFileToParam_GIL_release);
|
341
|
+
_ruby_ibm_db_console(" _ruby_ibm_db_SQLBindParameter_GIL_release = %d\n",_ruby_ibm_db_SQLBindParameter_GIL_release);
|
342
|
+
_ruby_ibm_db_console("%s\n","-------------");
|
343
|
+
}
|
344
|
+
static void _ruby_ibm_db_check_env_vars() {
|
345
|
+
char a;
|
346
|
+
int i;
|
347
|
+
char *trace;
|
348
|
+
char *dbcs;
|
349
|
+
if (_ruby_IBM_DB_TRACE == -1) {
|
350
|
+
trace = getenv(IBM_DB_TRACE);
|
351
|
+
if (trace) {
|
352
|
+
_ruby_IBM_DB_TRACE = 1;
|
353
|
+
if (strcmp(trace,"on")) {
|
354
|
+
_ruby_IBM_DB_FILE = trace;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
else _ruby_IBM_DB_TRACE = 0;
|
358
|
+
}
|
359
|
+
if (_ruby_IBM_DB_TRACE_ERROR == -1) {
|
360
|
+
trace = getenv(IBM_DB_TRACE_ERROR);
|
361
|
+
if (trace) _ruby_IBM_DB_TRACE_ERROR = 1;
|
362
|
+
else _ruby_IBM_DB_TRACE_ERROR = 0;
|
363
|
+
memset(_ruby_IBM_DB_TRACE_ERROR_BUFFER,0,IBM_DB_TRACE_ERROR_BUFFER_MAX+1);
|
364
|
+
}
|
365
|
+
if (_ruby_IBM_DB_STOP == -1) {
|
366
|
+
trace = getenv(IBM_DB_STOP);
|
367
|
+
if (trace) _ruby_IBM_DB_STOP = 1;
|
368
|
+
else _ruby_IBM_DB_STOP = 0;
|
369
|
+
}
|
370
|
+
if (_ruby_IBM_DB_ON_ERROR == -1) {
|
371
|
+
trace = getenv(IBM_DB_ON_ERROR);
|
372
|
+
if (trace) _ruby_IBM_DB_ON_ERROR = 1;
|
373
|
+
else _ruby_IBM_DB_ON_ERROR = 0;
|
374
|
+
}
|
375
|
+
if (_ruby_IBM_DB_DBCS_ALLOC == -1) {
|
376
|
+
dbcs = getenv(IBM_DB_DBCS_ALLOC);
|
377
|
+
if (dbcs) _ruby_IBM_DB_DBCS_ALLOC = 1;
|
378
|
+
else _ruby_IBM_DB_DBCS_ALLOC = 0;
|
379
|
+
}
|
380
|
+
if (_ruby_IBM_DB_GIL == -1) {
|
381
|
+
trace = getenv(IBM_DB_GIL);
|
382
|
+
if (trace) {
|
383
|
+
_ruby_IBM_DB_GIL = 1;
|
384
|
+
for (i=0;i<strlen(trace);i++) {
|
385
|
+
a = trace[i];
|
386
|
+
_ruby_ibm_db_set_GIL(i,a);
|
387
|
+
}
|
388
|
+
}
|
389
|
+
else _ruby_IBM_DB_GIL = 0;
|
390
|
+
if (_ruby_IBM_DB_TRACE) {
|
391
|
+
_ruby_ibm_db_talk_GIL();
|
392
|
+
}
|
393
|
+
}
|
394
|
+
}
|
395
|
+
static int _ruby_ibm_db_set_attr_override(set_handle_attr_args *data) {
|
396
|
+
if (_ruby_IBM_DB_ON_ERROR > 0) return SQL_SUCCESS;
|
397
|
+
return SQL_ERROR;
|
398
|
+
}
|
399
|
+
static int _ruby_ibm_db_get_attr_override(get_handle_attr_args *data) {
|
400
|
+
if (_ruby_IBM_DB_ON_ERROR > 0) {
|
401
|
+
*(int*)data->valuePtr == SQL_TRUE;
|
402
|
+
return SQL_SUCCESS;
|
403
|
+
}
|
404
|
+
return SQL_ERROR;
|
405
|
+
}
|
406
|
+
|
407
|
+
static int forget_blocking_region( void * helper, void *args, void *UBF, void * stmt_res ) {
|
408
|
+
int(*go)(void *) = helper;
|
409
|
+
return go(args);
|
410
|
+
}
|
411
|
+
|
412
|
+
static int _ruby_i5_dbcs_alloc(int col_type, int col_size) {
|
413
|
+
/* i5_dbcs_alloc - ADC */
|
414
|
+
if (_ruby_IBM_DB_DBCS_ALLOC > 0) {
|
415
|
+
switch (col_type) {
|
416
|
+
case SQL_CHAR:
|
417
|
+
case SQL_VARCHAR:
|
418
|
+
case SQL_CLOB:
|
419
|
+
case SQL_DBCLOB:
|
420
|
+
case SQL_UTF8_CHAR:
|
421
|
+
case SQL_WCHAR:
|
422
|
+
case SQL_WVARCHAR:
|
423
|
+
case SQL_GRAPHIC:
|
424
|
+
case SQL_VARGRAPHIC:
|
425
|
+
return col_size * 6;
|
426
|
+
default:
|
427
|
+
break;
|
428
|
+
}
|
429
|
+
}
|
430
|
+
return col_size;
|
431
|
+
}
|
432
|
+
|
433
|
+
/*
|
434
|
+
Connection level Unblock function. This function is called when a thread interruput is issued while executing a
|
435
|
+
connection level SQL call
|
436
|
+
*/
|
437
|
+
void _ruby_ibm_db_Connection_level_UBF(void *data) {
|
438
|
+
return;
|
439
|
+
}
|
440
|
+
|
441
|
+
/*
|
442
|
+
Statement level thread unblock function. This fuction cancels a statement level SQL call issued when requested for,
|
443
|
+
allowing for a safe interrupt of the thread.
|
444
|
+
*/
|
445
|
+
void _ruby_ibm_db_Statement_level_UBF(stmt_handle *stmt_res) {
|
446
|
+
int rc = 0;
|
447
|
+
if( stmt_res->is_executing == 1 ) {
|
448
|
+
rc = SQLCancel( (SQLHSTMT) stmt_res->hstmt );
|
449
|
+
}
|
450
|
+
return;
|
451
|
+
}
|
452
|
+
|
453
|
+
|
454
|
+
#ifdef PASE
|
455
|
+
static void _ruby_ibm_db_meta_helper(metadata_args *data)
|
456
|
+
{
|
457
|
+
data->qualifier = NULL;
|
458
|
+
data->qualifier_len = 0;
|
459
|
+
|
460
|
+
if (*data->owner == '\0') {
|
461
|
+
data->owner = NULL;
|
462
|
+
data->owner_len = 0;
|
463
|
+
}
|
464
|
+
else data->owner_len = SQL_NTS;
|
465
|
+
|
466
|
+
if (*data->table_name == '\0') {
|
467
|
+
data->table_name = NULL;
|
468
|
+
data->table_name_len = 0;
|
469
|
+
}
|
470
|
+
else data->table_name_len = SQL_NTS;
|
471
|
+
|
472
|
+
if (*data->column_name == '\0') {
|
473
|
+
data->column_name = NULL;
|
474
|
+
data->column_name_len = 0;
|
475
|
+
}
|
476
|
+
else data->column_name_len = SQL_NTS;
|
477
|
+
}
|
478
|
+
/*
|
479
|
+
This function sets PASE CCSID before any DB2 actions.
|
480
|
+
*/
|
481
|
+
int _ruby_ibm_db_SQLOverrideCCSID400_helper(int newCCSID) {
|
482
|
+
int rc = 0;
|
483
|
+
|
484
|
+
_ruby_ibm_db_trace_output("SQLOverrideCCSID400", &newCCSID, sizeof(newCCSID));
|
485
|
+
|
486
|
+
rc = (newCCSID > 0 ? SQLOverrideCCSID400(newCCSID) : SQLOverrideCCSID400(1208));
|
487
|
+
|
488
|
+
return rc;
|
489
|
+
}
|
490
|
+
#endif /* PASE */
|
491
|
+
|
492
|
+
/*
|
493
|
+
This function connects to the database using either SQLConnect or SQLDriverConnect CLI API
|
494
|
+
depending on whether it is a cataloged or an uncataloged connection.
|
495
|
+
*/
|
496
|
+
int _ruby_ibm_db_SQLConnect_helper2(connect_args *data) {
|
497
|
+
int rc = 0;
|
498
|
+
|
499
|
+
_ruby_ibm_db_trace_output("SQLConnect", data, sizeof(connect_args));
|
500
|
+
|
501
|
+
if(data->ctlg_conn == 1) {
|
502
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
503
|
+
rc = SQLConnect( (SQLHDBC)*(data->hdbc), (SQLCHAR *)data->database,
|
504
|
+
(SQLSMALLINT)data->database_len, (SQLCHAR *)data->uid, (SQLSMALLINT)data->uid_len,
|
505
|
+
(SQLCHAR *)data->password, (SQLSMALLINT)data->password_len );
|
506
|
+
#else
|
507
|
+
rc = SQLConnectW( (SQLHDBC)*(data->hdbc), data->database,
|
508
|
+
data->database_len, data->uid, data->uid_len,
|
509
|
+
data->password, data->password_len );
|
510
|
+
#endif
|
511
|
+
} else {
|
512
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
513
|
+
rc = SQLDriverConnect( (SQLHDBC) *(data->hdbc), (SQLHWND)NULL,
|
514
|
+
(SQLCHAR*)data->database, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
|
515
|
+
#else
|
516
|
+
rc = SQLDriverConnectW( (SQLHDBC) *(data->hdbc), (SQLHWND)NULL,
|
517
|
+
data->database, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
|
518
|
+
#endif
|
519
|
+
}
|
520
|
+
return rc;
|
521
|
+
}
|
522
|
+
|
523
|
+
/*
|
524
|
+
This function issues SQLDisconnect to disconnect from the Dataserver
|
525
|
+
*/
|
526
|
+
int _ruby_ibm_db_SQLDisconnect_helper2(SQLHANDLE *hdbc) {
|
527
|
+
int rc = 0;
|
528
|
+
|
529
|
+
_ruby_ibm_db_trace_output("SQLDisconnect", hdbc, sizeof(hdbc));
|
530
|
+
|
531
|
+
rc = SQLDisconnect( (SQLHDBC) *hdbc );
|
532
|
+
|
533
|
+
return rc;
|
534
|
+
}
|
535
|
+
|
536
|
+
|
537
|
+
/*
|
538
|
+
This function will commit and end the inprogress transaction by issuing a SQLCommit
|
539
|
+
*/
|
540
|
+
int _ruby_ibm_db_SQLEndTran2(end_tran_args *endtran_args) {
|
541
|
+
int rc = 0;
|
542
|
+
|
543
|
+
_ruby_ibm_db_trace_output("SQLEndTran", endtran_args, sizeof(end_tran_args));
|
544
|
+
|
545
|
+
rc = SQLEndTran( endtran_args->handleType, *(endtran_args->hdbc), endtran_args->completionType );
|
546
|
+
|
547
|
+
return rc;
|
548
|
+
}
|
549
|
+
|
550
|
+
/*
|
551
|
+
This function call the SQLDescribeParam cli call to get the description of the parameter in the sql specified
|
552
|
+
*/
|
553
|
+
int _ruby_ibm_db_SQLDescribeParam_helper2(describeparam_args *data) {
|
554
|
+
int rc = 0;
|
555
|
+
|
556
|
+
_ruby_ibm_db_trace_output("SQLDescribeParam", data, sizeof(describeparam_args));
|
557
|
+
|
558
|
+
data->stmt_res->is_executing = 1;
|
559
|
+
|
560
|
+
rc = SQLDescribeParam( (SQLHSTMT) data->stmt_res->hstmt, (SQLUSMALLINT)data->param_no, &(data->sql_data_type),
|
561
|
+
&(data->sql_precision), &(data->sql_scale), &(data->sql_nullable) );
|
562
|
+
|
563
|
+
_ruby_ibm_db_trace_verbose("SQLDescribeParam", data, sizeof(describeparam_args), rc);
|
564
|
+
|
565
|
+
data->stmt_res->is_executing = 0;
|
566
|
+
|
567
|
+
return rc;
|
568
|
+
}
|
569
|
+
|
570
|
+
/*
|
571
|
+
This function call the SQLDescribeCol cli call to get the description of the parameter in the sql specified
|
572
|
+
*/
|
573
|
+
int _ruby_ibm_db_SQLDescribeCol_helper2(describecol_args *data) {
|
574
|
+
int i = data->col_no - 1;
|
575
|
+
int rc = 0;
|
576
|
+
|
577
|
+
_ruby_ibm_db_trace_output("SQLDescribeCol", data, sizeof(describecol_args));
|
578
|
+
|
579
|
+
data->stmt_res->is_executing = 1;
|
580
|
+
|
581
|
+
#if defined(UNICODE_SUPPORT_VERSION) && ! defined(UTF8_OVERRIDE_VERSION)
|
582
|
+
rc = SQLDescribeColW( (SQLHSTMT)data->stmt_res->hstmt, (SQLSMALLINT)(data->col_no),
|
583
|
+
data->stmt_res->column_info[i].name, data->buff_length, &(data->name_length),
|
584
|
+
&(data->stmt_res->column_info[i].type), &(data->stmt_res->column_info[i].size),
|
585
|
+
&(data->stmt_res->column_info[i].scale), &(data->stmt_res->column_info[i].nullable) );
|
586
|
+
#else
|
587
|
+
rc = SQLDescribeCol( (SQLHSTMT)data->stmt_res->hstmt, (SQLSMALLINT)(data->col_no),
|
588
|
+
data->stmt_res->column_info[i].name, data->buff_length, &(data->name_length),
|
589
|
+
&(data->stmt_res->column_info[i].type), &(data->stmt_res->column_info[i].size),
|
590
|
+
&(data->stmt_res->column_info[i].scale), &(data->stmt_res->column_info[i].nullable) );
|
591
|
+
#endif
|
592
|
+
|
593
|
+
|
594
|
+
/* i5_dbcs_alloc - ADC */
|
595
|
+
data->stmt_res->column_info[i].size = _ruby_i5_dbcs_alloc(data->stmt_res->column_info[i].type, data->stmt_res->column_info[i].size);
|
596
|
+
|
597
|
+
_ruby_ibm_db_trace_verbose("SQLDescribeCol", data, sizeof(describecol_args), rc);
|
598
|
+
|
599
|
+
data->stmt_res->is_executing = 0;
|
600
|
+
|
601
|
+
return rc;
|
602
|
+
}
|
603
|
+
|
604
|
+
/*
|
605
|
+
This function call the SQLBindCol cli call to get the description of the parameter in the sql specified
|
606
|
+
*/
|
607
|
+
int _ruby_ibm_db_SQLBindCol_helper2(bind_col_args *data) {
|
608
|
+
int rc = 0;
|
609
|
+
|
610
|
+
_ruby_ibm_db_trace_output("SQLBindCol",data, sizeof(bind_col_args));
|
611
|
+
|
612
|
+
data->stmt_res->is_executing = 1;
|
613
|
+
|
614
|
+
rc = SQLBindCol( (SQLHSTMT) data->stmt_res->hstmt, (SQLUSMALLINT)(data->col_num),
|
615
|
+
data->TargetType, data->TargetValuePtr, data->buff_length,
|
616
|
+
data->out_length );
|
617
|
+
|
618
|
+
_ruby_ibm_db_trace_verbose("SQLBindCol", data, sizeof(describecol_args), rc);
|
619
|
+
|
620
|
+
data->stmt_res->is_executing = 0;
|
621
|
+
|
622
|
+
return rc;
|
623
|
+
}
|
624
|
+
|
625
|
+
/*
|
626
|
+
This function calls SQLColumnPrivileges cli call to get the list of columns and the associated privileges
|
627
|
+
*/
|
628
|
+
int _ruby_ibm_db_SQLColumnPrivileges_helper2(metadata_args *data) {
|
629
|
+
int rc = 0;
|
630
|
+
|
631
|
+
_ruby_ibm_db_trace_output("SQLColumnPrivileges", data, sizeof(metadata_args));
|
632
|
+
|
633
|
+
#ifdef PASE
|
634
|
+
_ruby_ibm_db_meta_helper(data);
|
635
|
+
#endif /* PASE */
|
636
|
+
|
637
|
+
data->stmt_res->is_executing = 1;
|
638
|
+
|
639
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
640
|
+
rc = SQLColumnPrivileges( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
641
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len,
|
642
|
+
data->column_name, data->column_name_len );
|
643
|
+
#else
|
644
|
+
rc = SQLColumnPrivilegesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
645
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len,
|
646
|
+
data->column_name, data->column_name_len );
|
647
|
+
#endif
|
648
|
+
|
649
|
+
data->stmt_res->is_executing = 0;
|
650
|
+
|
651
|
+
return rc;
|
652
|
+
|
653
|
+
}
|
654
|
+
|
655
|
+
/*
|
656
|
+
This function calls SQLColumns cli call to get the list of columns and the associated metadata of the table
|
657
|
+
*/
|
658
|
+
int _ruby_ibm_db_SQLColumns_helper2(metadata_args *data) {
|
659
|
+
int rc = 0;
|
660
|
+
|
661
|
+
_ruby_ibm_db_trace_output("SQLColumns", data, sizeof(metadata_args));
|
662
|
+
|
663
|
+
#ifdef PASE
|
664
|
+
_ruby_ibm_db_meta_helper(data);
|
665
|
+
#endif /* PASE */
|
666
|
+
|
667
|
+
data->stmt_res->is_executing = 1;
|
668
|
+
|
669
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
670
|
+
rc = SQLColumns( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
671
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len,
|
672
|
+
data->column_name, data->column_name_len );
|
673
|
+
#else
|
674
|
+
rc = SQLColumnsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
675
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len,
|
676
|
+
data->column_name, data->column_name_len );
|
677
|
+
#endif
|
678
|
+
|
679
|
+
data->stmt_res->is_executing = 0;
|
680
|
+
|
681
|
+
return rc;
|
682
|
+
}
|
683
|
+
|
684
|
+
/*
|
685
|
+
This function calls SQLPrimaryKeys cli call to get the list of primay key columns and the associated metadata
|
686
|
+
*/
|
687
|
+
int _ruby_ibm_db_SQLPrimaryKeys_helper2(metadata_args *data) {
|
688
|
+
int rc = 0;
|
689
|
+
|
690
|
+
_ruby_ibm_db_trace_output("SQLPrimaryKeys", data, sizeof(metadata_args));
|
691
|
+
|
692
|
+
#ifdef PASE
|
693
|
+
_ruby_ibm_db_meta_helper(data);
|
694
|
+
#endif /* PASE */
|
695
|
+
|
696
|
+
data->stmt_res->is_executing = 1;
|
697
|
+
|
698
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
699
|
+
rc = SQLPrimaryKeys( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
700
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len );
|
701
|
+
#else
|
702
|
+
rc = SQLPrimaryKeysW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
703
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len );
|
704
|
+
#endif
|
705
|
+
|
706
|
+
data->stmt_res->is_executing = 0;
|
707
|
+
|
708
|
+
return rc;
|
709
|
+
}
|
710
|
+
|
711
|
+
/*
|
712
|
+
This function calls SQLForeignKeys cli call to get the list of foreign key columns and the associated metadata
|
713
|
+
*/
|
714
|
+
int _ruby_ibm_db_SQLForeignKeys_helper2(metadata_args *data) {
|
715
|
+
int rc = 0;
|
716
|
+
|
717
|
+
_ruby_ibm_db_trace_output("SQLForeignKeys", data, sizeof(metadata_args));
|
718
|
+
|
719
|
+
#ifdef PASE
|
720
|
+
_ruby_ibm_db_meta_helper(data);
|
721
|
+
#endif /* PASE */
|
722
|
+
|
723
|
+
data->stmt_res->is_executing = 1;
|
724
|
+
|
725
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
726
|
+
rc = SQLForeignKeys( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
727
|
+
data->owner, data->owner_len, data->table_name , data->table_name_len, NULL, SQL_NTS,
|
728
|
+
NULL, SQL_NTS, NULL, SQL_NTS );
|
729
|
+
#else
|
730
|
+
rc = SQLForeignKeysW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
731
|
+
data->owner, data->owner_len, data->table_name , data->table_name_len, NULL, SQL_NTS,
|
732
|
+
NULL, SQL_NTS, NULL, SQL_NTS );
|
733
|
+
#endif
|
734
|
+
|
735
|
+
data->stmt_res->is_executing = 0;
|
736
|
+
|
737
|
+
return rc;
|
738
|
+
}
|
739
|
+
|
740
|
+
/*
|
741
|
+
This function calls SQLProcedureColumns cli call to get the list of parameters
|
742
|
+
and associated metadata of the stored procedure
|
743
|
+
*/
|
744
|
+
int _ruby_ibm_db_SQLProcedureColumns_helper2(metadata_args *data) {
|
745
|
+
int rc = 0;
|
746
|
+
|
747
|
+
_ruby_ibm_db_trace_output("SQLProcedureColumns", data, sizeof(metadata_args));
|
748
|
+
|
749
|
+
#ifdef PASE
|
750
|
+
_ruby_ibm_db_meta_helper(data);
|
751
|
+
#endif /* PASE */
|
752
|
+
|
753
|
+
data->stmt_res->is_executing = 1;
|
754
|
+
|
755
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
756
|
+
rc = SQLProcedureColumns( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
|
757
|
+
data->owner_len, data->proc_name, data->proc_name_len, data->column_name, data->column_name_len );
|
758
|
+
#else
|
759
|
+
rc = SQLProcedureColumnsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
|
760
|
+
data->owner_len, data->proc_name, data->proc_name_len, data->column_name, data->column_name_len );
|
761
|
+
#endif
|
762
|
+
|
763
|
+
data->stmt_res->is_executing = 0;
|
764
|
+
|
765
|
+
return rc;
|
766
|
+
}
|
767
|
+
|
768
|
+
/*
|
769
|
+
This function calls SQLProcedures cli call to get the list of stored procedures
|
770
|
+
and associated metadata of the stored procedure
|
771
|
+
*/
|
772
|
+
int _ruby_ibm_db_SQLProcedures_helper2(metadata_args *data) {
|
773
|
+
int rc = 0;
|
774
|
+
|
775
|
+
_ruby_ibm_db_trace_output("SQLProcedures", data, sizeof(metadata_args));
|
776
|
+
|
777
|
+
#ifdef PASE
|
778
|
+
_ruby_ibm_db_meta_helper(data);
|
779
|
+
#endif /* PASE */
|
780
|
+
|
781
|
+
data->stmt_res->is_executing = 1;
|
782
|
+
|
783
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
784
|
+
rc = SQLProcedures( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
|
785
|
+
data->owner_len, data->proc_name, data->proc_name_len );
|
786
|
+
#else
|
787
|
+
rc = SQLProceduresW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
|
788
|
+
data->owner_len, data->proc_name, data->proc_name_len );
|
789
|
+
#endif
|
790
|
+
|
791
|
+
data->stmt_res->is_executing = 0;
|
792
|
+
|
793
|
+
return rc;
|
794
|
+
}
|
795
|
+
|
796
|
+
/*
|
797
|
+
This function calls SQLSpecialColumns cli call to get the metadata related to the special columns
|
798
|
+
(Unique index or primary key column) and associated metadata
|
799
|
+
*/
|
800
|
+
int _ruby_ibm_db_SQLSpecialColumns_helper2(metadata_args *data) {
|
801
|
+
int rc = 0;
|
802
|
+
|
803
|
+
_ruby_ibm_db_trace_output("SQLSpecialColumns", data, sizeof(metadata_args));
|
804
|
+
|
805
|
+
#ifdef PASE
|
806
|
+
_ruby_ibm_db_meta_helper(data);
|
807
|
+
#endif /* PASE */
|
808
|
+
|
809
|
+
data->stmt_res->is_executing = 1;
|
810
|
+
|
811
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
812
|
+
rc = SQLSpecialColumns( (SQLHSTMT) data->stmt_res->hstmt, SQL_BEST_ROWID, data->qualifier, data->qualifier_len,
|
813
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len,
|
814
|
+
(SQLUSMALLINT)data->scope, SQL_NULLABLE );
|
815
|
+
#else
|
816
|
+
rc = SQLSpecialColumnsW( (SQLHSTMT) data->stmt_res->hstmt, SQL_BEST_ROWID, data->qualifier, data->qualifier_len,
|
817
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len,
|
818
|
+
(SQLUSMALLINT)data->scope, SQL_NULLABLE );
|
819
|
+
#endif
|
820
|
+
|
821
|
+
data->stmt_res->is_executing = 0;
|
822
|
+
|
823
|
+
return rc;
|
824
|
+
}
|
825
|
+
|
826
|
+
/*
|
827
|
+
This function calls SQLStatistics cli call to get the index information for a given table.
|
828
|
+
*/
|
829
|
+
int _ruby_ibm_db_SQLStatistics_helper2(metadata_args *data) {
|
830
|
+
int rc = 0;
|
831
|
+
|
832
|
+
_ruby_ibm_db_trace_output("SQLStatistics", data, sizeof(metadata_args));
|
833
|
+
|
834
|
+
#ifdef PASE
|
835
|
+
_ruby_ibm_db_meta_helper(data);
|
836
|
+
#endif /* PASE */
|
837
|
+
|
838
|
+
data->stmt_res->is_executing = 1;
|
839
|
+
|
840
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
841
|
+
rc = SQLStatistics( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
|
842
|
+
data->owner_len, data->table_name, data->table_name_len, (SQLUSMALLINT)data->unique, SQL_QUICK );
|
843
|
+
#else
|
844
|
+
rc = SQLStatisticsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
|
845
|
+
data->owner_len, data->table_name, data->table_name_len, (SQLUSMALLINT)data->unique, SQL_QUICK );
|
846
|
+
#endif
|
847
|
+
|
848
|
+
data->stmt_res->is_executing = 0;
|
849
|
+
|
850
|
+
return rc;
|
851
|
+
}
|
852
|
+
|
853
|
+
/*
|
854
|
+
This function calls SQLTablePrivileges cli call to retrieve list of tables and
|
855
|
+
the asscociated privileges for each table.
|
856
|
+
*/
|
857
|
+
int _ruby_ibm_db_SQLTablePrivileges_helper2(metadata_args *data) {
|
858
|
+
int rc = 0;
|
859
|
+
|
860
|
+
_ruby_ibm_db_trace_output("SQLTablePrivileges", data, sizeof(metadata_args));
|
861
|
+
|
862
|
+
#ifdef PASE
|
863
|
+
_ruby_ibm_db_meta_helper(data);
|
864
|
+
#endif /* PASE */
|
865
|
+
|
866
|
+
data->stmt_res->is_executing = 1;
|
867
|
+
|
868
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
869
|
+
rc = SQLTablePrivileges( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
870
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len );
|
871
|
+
#else
|
872
|
+
rc = SQLTablePrivilegesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
|
873
|
+
data->owner, data->owner_len, data->table_name, data->table_name_len );
|
874
|
+
#endif
|
875
|
+
|
876
|
+
data->stmt_res->is_executing = 0;
|
877
|
+
|
878
|
+
return rc;
|
879
|
+
}
|
880
|
+
|
881
|
+
/*
|
882
|
+
This function calls SQLTables cli call to retrieve list of tables in the specified schema and
|
883
|
+
the asscociated metadata for each table.
|
884
|
+
*/
|
885
|
+
int _ruby_ibm_db_SQLTables_helper2(metadata_args *data) {
|
886
|
+
int rc = 0;
|
887
|
+
|
888
|
+
_ruby_ibm_db_trace_output("SQLTables", data, sizeof(metadata_args));
|
889
|
+
|
890
|
+
#ifdef PASE
|
891
|
+
_ruby_ibm_db_meta_helper(data);
|
892
|
+
#endif /* PASE */
|
893
|
+
|
894
|
+
data->stmt_res->is_executing = 1;
|
895
|
+
|
896
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
897
|
+
rc = SQLTables( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
|
898
|
+
data->owner_len, data->table_name, data->table_name_len, data->table_type, data->table_type_len );
|
899
|
+
#else
|
900
|
+
rc = SQLTablesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
|
901
|
+
data->owner_len, data->table_name, data->table_name_len, data->table_type, data->table_type_len );
|
902
|
+
#endif
|
903
|
+
|
904
|
+
data->stmt_res->is_executing = 0;
|
905
|
+
|
906
|
+
return rc;
|
907
|
+
}
|
908
|
+
|
909
|
+
/*
|
910
|
+
This function calls SQLExecDirect cli call to execute a statement directly
|
911
|
+
*/
|
912
|
+
int _ruby_ibm_db_SQLExecDirect_helper2(exec_cum_prepare_args *data) {
|
913
|
+
int rc = 0;
|
914
|
+
|
915
|
+
_ruby_ibm_db_trace_output("SQLExecDirect", data, sizeof(exec_cum_prepare_args));
|
916
|
+
|
917
|
+
data->stmt_res->is_executing = 1;
|
918
|
+
|
919
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
920
|
+
rc = SQLExecDirect( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
|
921
|
+
#else
|
922
|
+
rc = SQLExecDirectW( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
|
923
|
+
#endif
|
924
|
+
|
925
|
+
_ruby_ibm_db_trace_verbose("SQLExecDirect", data, sizeof(get_data_args), rc);
|
926
|
+
|
927
|
+
data->stmt_res->is_executing = 0;
|
928
|
+
|
929
|
+
return rc;
|
930
|
+
}
|
931
|
+
|
932
|
+
/*
|
933
|
+
This function calls SQLCreateDb cli call
|
934
|
+
*/
|
935
|
+
int _ruby_ibm_db_SQLCreateDB_helper2(create_drop_db_args *data) {
|
936
|
+
int rc = 0;
|
937
|
+
#ifndef PASE
|
938
|
+
#ifndef UNICODE_SUPPORT_VERSION
|
939
|
+
#ifdef _WIN32
|
940
|
+
HINSTANCE cliLib = NULL;
|
941
|
+
FARPROC sqlcreatedb;
|
942
|
+
cliLib = DLOPEN( LIBDB2 );
|
943
|
+
sqlcreatedb = DLSYM( cliLib, "SQLCreateDb" );
|
944
|
+
#elif _AIX
|
945
|
+
void *cliLib = NULL;
|
946
|
+
typedef int (*sqlcreatedbType)( SQLHDBC, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER );
|
947
|
+
sqlcreatedbType sqlcreatedb;
|
948
|
+
/* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
|
949
|
+
cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
|
950
|
+
sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDb" );
|
951
|
+
#else
|
952
|
+
void *cliLib = NULL;
|
953
|
+
typedef int (*sqlcreatedbType)( SQLHDBC, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER );
|
954
|
+
sqlcreatedbType sqlcreatedb;
|
955
|
+
cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
|
956
|
+
sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDb" );
|
957
|
+
#endif
|
958
|
+
#else
|
959
|
+
#ifdef _WIN32
|
960
|
+
HINSTANCE cliLib = NULL;
|
961
|
+
FARPROC sqlcreatedb;
|
962
|
+
cliLib = DLOPEN( LIBDB2 );
|
963
|
+
sqlcreatedb = DLSYM( cliLib, "SQLCreateDbW" );
|
964
|
+
#elif _AIX
|
965
|
+
void *cliLib = NULL;
|
966
|
+
typedef int (*sqlcreatedbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER );
|
967
|
+
sqlcreatedbType sqlcreatedb;
|
968
|
+
/* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
|
969
|
+
cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
|
970
|
+
sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDbW" );
|
971
|
+
#else
|
972
|
+
void *cliLib = NULL;
|
973
|
+
typedef int (*sqlcreatedbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER );
|
974
|
+
sqlcreatedbType sqlcreatedb;
|
975
|
+
cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
|
976
|
+
sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDbW" );
|
977
|
+
#endif
|
978
|
+
#endif
|
979
|
+
|
980
|
+
rc = (*sqlcreatedb)( (SQLHSTMT) data->conn_res->hdbc, data->dbName, (SQLINTEGER)data->dbName_string_len,
|
981
|
+
data->codeSet, (SQLINTEGER)data->codeSet_string_len,
|
982
|
+
data->mode, (SQLINTEGER)data->mode_string_len );
|
983
|
+
DLCLOSE( cliLib );
|
984
|
+
#endif /* PASE */
|
985
|
+
return rc;
|
986
|
+
}
|
987
|
+
|
988
|
+
/*
|
989
|
+
This function calls SQLDropDb cli call
|
990
|
+
*/
|
991
|
+
int _ruby_ibm_db_SQLDropDB_helper2(create_drop_db_args *data) {
|
992
|
+
int rc = 0;
|
993
|
+
#ifndef PASE
|
994
|
+
#ifndef UNICODE_SUPPORT_VERSION
|
995
|
+
#ifdef _WIN32
|
996
|
+
HINSTANCE cliLib = NULL;
|
997
|
+
FARPROC sqldropdb;
|
998
|
+
cliLib = DLOPEN( LIBDB2 );
|
999
|
+
sqldropdb = DLSYM( cliLib, "SQLDropDb" );
|
1000
|
+
#elif _AIX
|
1001
|
+
void *cliLib = NULL;
|
1002
|
+
typedef int (*sqldropdbType)( SQLHDBC, SQLCHAR *, SQLINTEGER);
|
1003
|
+
sqldropdbType sqldropdb;
|
1004
|
+
/* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
|
1005
|
+
cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
|
1006
|
+
sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDb" );
|
1007
|
+
#else
|
1008
|
+
void *cliLib = NULL;
|
1009
|
+
typedef int (*sqldropdbType)( SQLHDBC, SQLCHAR *, SQLINTEGER);
|
1010
|
+
sqldropdbType sqldropdb;
|
1011
|
+
cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
|
1012
|
+
sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDb" );
|
1013
|
+
#endif
|
1014
|
+
#else
|
1015
|
+
#ifdef _WIN32
|
1016
|
+
HINSTANCE cliLib = NULL;
|
1017
|
+
FARPROC sqldropdb;
|
1018
|
+
cliLib = DLOPEN( LIBDB2 );
|
1019
|
+
sqldropdb = DLSYM( cliLib, "SQLDropDbW" );
|
1020
|
+
#elif _AIX
|
1021
|
+
void *cliLib = NULL;
|
1022
|
+
typedef int (*sqldropdbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER);
|
1023
|
+
sqldropdbType sqldropdb;
|
1024
|
+
/* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
|
1025
|
+
cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
|
1026
|
+
sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDbW" );
|
1027
|
+
#else
|
1028
|
+
void *cliLib = NULL;
|
1029
|
+
typedef int (*sqldropdbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER);
|
1030
|
+
sqldropdbType sqldropdb;
|
1031
|
+
cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
|
1032
|
+
sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDbW" );
|
1033
|
+
#endif
|
1034
|
+
#endif
|
1035
|
+
|
1036
|
+
rc = (*sqldropdb)( (SQLHSTMT) data->conn_res->hdbc, data->dbName, (SQLINTEGER)data->dbName_string_len );
|
1037
|
+
|
1038
|
+
DLCLOSE( cliLib );
|
1039
|
+
#endif /* PASE */
|
1040
|
+
return rc;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
/*
|
1044
|
+
This function calls SQLPrepare cli call to prepare the given statement
|
1045
|
+
*/
|
1046
|
+
int _ruby_ibm_db_SQLPrepare_helper2(exec_cum_prepare_args *data) {
|
1047
|
+
int rc = 0;
|
1048
|
+
|
1049
|
+
_ruby_ibm_db_trace_output("SQLPrepare", data, sizeof(exec_cum_prepare_args));
|
1050
|
+
|
1051
|
+
data->stmt_res->is_executing = 1;
|
1052
|
+
|
1053
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
1054
|
+
rc = SQLPrepare( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
|
1055
|
+
#else
|
1056
|
+
rc = SQLPrepareW( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
|
1057
|
+
#endif
|
1058
|
+
|
1059
|
+
_ruby_ibm_db_trace_verbose("SQLPrepare", data, sizeof(get_data_args), rc);
|
1060
|
+
|
1061
|
+
data->stmt_res->is_executing = 0;
|
1062
|
+
|
1063
|
+
return rc;
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
/*
|
1067
|
+
This function calls SQLFreeStmt to end processing on the statement referenced by statement handle
|
1068
|
+
*/
|
1069
|
+
int _ruby_ibm_db_SQLFreeStmt_helper2(free_stmt_args *data) {
|
1070
|
+
int rc = 0;
|
1071
|
+
|
1072
|
+
_ruby_ibm_db_trace_output("SQLFreeStmt", data, sizeof(free_stmt_args));
|
1073
|
+
|
1074
|
+
data->stmt_res->is_executing = 1;
|
1075
|
+
|
1076
|
+
SQLFreeStmt((SQLHSTMT)data->stmt_res->hstmt, data->option );
|
1077
|
+
|
1078
|
+
data->stmt_res->is_executing = 0;
|
1079
|
+
|
1080
|
+
return rc;
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
/*
|
1084
|
+
This function calls SQLExecute cli call to execute the prepared
|
1085
|
+
*/
|
1086
|
+
int _ruby_ibm_db_SQLExecute_helper2(stmt_handle *stmt_res) {
|
1087
|
+
int rc = 0;
|
1088
|
+
|
1089
|
+
_ruby_ibm_db_trace_output("SQLExecute", stmt_res, sizeof(stmt_handle));
|
1090
|
+
|
1091
|
+
stmt_res->is_executing = 1;
|
1092
|
+
|
1093
|
+
rc = SQLExecute( (SQLHSTMT) stmt_res->hstmt );
|
1094
|
+
|
1095
|
+
stmt_res->is_executing = 0;
|
1096
|
+
|
1097
|
+
return rc;
|
1098
|
+
}
|
1099
|
+
|
1100
|
+
/*
|
1101
|
+
This function calls SQLParamData cli call to read if there is still data to be sent
|
1102
|
+
*/
|
1103
|
+
int _ruby_ibm_db_SQLParamData_helper2(param_cum_put_data_args *data) {
|
1104
|
+
int rc = 0;
|
1105
|
+
|
1106
|
+
_ruby_ibm_db_trace_output("SQLParamData", (SQLPOINTER *) &(data->valuePtr), sizeof(char *));
|
1107
|
+
|
1108
|
+
data->stmt_res->is_executing = 1;
|
1109
|
+
|
1110
|
+
rc = SQLParamData( (SQLHSTMT) data->stmt_res->hstmt, (SQLPOINTER *) &(data->valuePtr) );
|
1111
|
+
|
1112
|
+
data->stmt_res->is_executing = 0;
|
1113
|
+
|
1114
|
+
return rc;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
/*
|
1118
|
+
This function calls SQLColAttributes cli call to get the specified attribute of the column in result set
|
1119
|
+
*/
|
1120
|
+
int _ruby_ibm_db_SQLColAttributes_helper2(col_attr_args *data) {
|
1121
|
+
int rc = 0;
|
1122
|
+
|
1123
|
+
_ruby_ibm_db_trace_output("SQLColAttributes", data, sizeof(col_attr_args));
|
1124
|
+
|
1125
|
+
data->stmt_res->is_executing = 1;
|
1126
|
+
|
1127
|
+
rc = SQLColAttributes( (SQLHSTMT) data->stmt_res->hstmt, data->col_num,
|
1128
|
+
data->FieldIdentifier, NULL, 0, NULL, &(data->num_attr) );
|
1129
|
+
|
1130
|
+
data->stmt_res->is_executing = 0;
|
1131
|
+
|
1132
|
+
return rc;
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
/*
|
1136
|
+
This function calls SQLPutData cli call to supply parameter data value
|
1137
|
+
*/
|
1138
|
+
int _ruby_ibm_db_SQLPutData_helper2(param_cum_put_data_args *data) {
|
1139
|
+
int rc = 0;
|
1140
|
+
|
1141
|
+
_ruby_ibm_db_trace_output("SQLPutData", data, sizeof(param_cum_put_data_args));
|
1142
|
+
|
1143
|
+
data->stmt_res->is_executing = 1;
|
1144
|
+
|
1145
|
+
rc = SQLPutData( (SQLHSTMT) data->stmt_res->hstmt, (SQLPOINTER)(((param_node*)(data->valuePtr))->svalue),
|
1146
|
+
((param_node*)(data->valuePtr))->ivalue );
|
1147
|
+
|
1148
|
+
data->stmt_res->is_executing = 0;
|
1149
|
+
|
1150
|
+
return rc;
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
/*
|
1154
|
+
This function calls SQLGetData cli call to retrieve data for a single column
|
1155
|
+
*/
|
1156
|
+
int _ruby_ibm_db_SQLGetData_helper2(get_data_args *data) {
|
1157
|
+
int rc = 0;
|
1158
|
+
|
1159
|
+
_ruby_ibm_db_trace_output("SQLGetData", data, sizeof(get_data_args));
|
1160
|
+
|
1161
|
+
data->stmt_res->is_executing = 1;
|
1162
|
+
|
1163
|
+
rc = SQLGetData( (SQLHSTMT) data->stmt_res->hstmt, data->col_num, data->targetType, data->buff,
|
1164
|
+
data->buff_length, data->out_length);
|
1165
|
+
|
1166
|
+
_ruby_ibm_db_trace_verbose("SQLGetData", data, sizeof(get_data_args), rc);
|
1167
|
+
|
1168
|
+
data->stmt_res->is_executing = 0;
|
1169
|
+
|
1170
|
+
return rc;
|
1171
|
+
}
|
1172
|
+
|
1173
|
+
/*
|
1174
|
+
This function calls SQLGetLength cli call to retrieve the length of the lob value
|
1175
|
+
*/
|
1176
|
+
int _ruby_ibm_db_SQLGetLength_helper2(get_length_args *data) {
|
1177
|
+
int col_num = data->col_num;
|
1178
|
+
int rc = 0;
|
1179
|
+
|
1180
|
+
_ruby_ibm_db_trace_output("SQLGetLength", data, sizeof(get_length_args));
|
1181
|
+
|
1182
|
+
data->stmt_res->is_executing = 1;
|
1183
|
+
|
1184
|
+
|
1185
|
+
rc = SQLGetLength( (SQLHSTMT) *( data->new_hstmt ), data->stmt_res->column_info[col_num-1].loc_type,
|
1186
|
+
data->stmt_res->column_info[col_num-1].lob_loc, data->sLength,
|
1187
|
+
&(data->stmt_res->column_info[col_num-1].loc_ind) );
|
1188
|
+
|
1189
|
+
data->stmt_res->is_executing = 0;
|
1190
|
+
|
1191
|
+
/* i5_dbcs_alloc - ADC */
|
1192
|
+
data->sLength = _ruby_i5_dbcs_alloc(data->stmt_res->column_info[col_num-1].loc_type, data->sLength);
|
1193
|
+
|
1194
|
+
return rc;
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
/*
|
1198
|
+
This function calls SQLGetSubString cli call to retrieve portion of the lob value
|
1199
|
+
*/
|
1200
|
+
int _ruby_ibm_db_SQLGetSubString_helper2(get_subString_args *data) {
|
1201
|
+
int col_num = data->col_num;
|
1202
|
+
int rc = 0;
|
1203
|
+
|
1204
|
+
_ruby_ibm_db_trace_output("SQLGetSubString", data, sizeof(get_subString_args));
|
1205
|
+
|
1206
|
+
data->stmt_res->is_executing = 1;
|
1207
|
+
|
1208
|
+
/* FromPosition(1) + ForLength - 1 (ForLength 0 <= upsets IBMi and wrong LUW anyway) */
|
1209
|
+
if (data->forLength < 1) data->forLength = 1;
|
1210
|
+
|
1211
|
+
rc = SQLGetSubString( (SQLHSTMT) *( data->new_hstmt ), data->stmt_res->column_info[col_num-1].loc_type,
|
1212
|
+
data->stmt_res->column_info[col_num-1].lob_loc, 1, data->forLength, data->targetCType,
|
1213
|
+
data->buffer, data->buff_length, data->out_length,
|
1214
|
+
&(data->stmt_res->column_info[col_num-1].loc_ind) );
|
1215
|
+
|
1216
|
+
_ruby_ibm_db_trace_verbose("SQLGetSubString", data, sizeof(get_subString_args), rc);
|
1217
|
+
|
1218
|
+
data->stmt_res->is_executing = 0;
|
1219
|
+
|
1220
|
+
return rc;
|
1221
|
+
}
|
1222
|
+
|
1223
|
+
/*
|
1224
|
+
This function calls SQLNextResult cli call to fetch the multiple result sets that might be returned by a stored Proc
|
1225
|
+
*/
|
1226
|
+
int _ruby_ibm_db_SQLNextResult_helper2(next_result_args *data) {
|
1227
|
+
int rc = 0;
|
1228
|
+
|
1229
|
+
_ruby_ibm_db_trace_output("SQLNextResult", data, sizeof(next_result_args));
|
1230
|
+
|
1231
|
+
data->stmt_res->is_executing = 1;
|
1232
|
+
|
1233
|
+
rc = SQLNextResult( (SQLHSTMT) data->stmt_res->hstmt, (SQLHSTMT) *(data->new_hstmt) );
|
1234
|
+
|
1235
|
+
data->stmt_res->is_executing = 0;
|
1236
|
+
|
1237
|
+
return rc;
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
/*
|
1241
|
+
This function calls SQLFetchScroll cli call to fetch the specified rowset of data from result
|
1242
|
+
*/
|
1243
|
+
int _ruby_ibm_db_SQLFetchScroll_helper2(fetch_data_args *data) {
|
1244
|
+
int rc = 0;
|
1245
|
+
|
1246
|
+
_ruby_ibm_db_trace_output("SQLFetchScroll", data, sizeof(fetch_data_args));
|
1247
|
+
|
1248
|
+
data->stmt_res->is_executing = 1;
|
1249
|
+
|
1250
|
+
rc = SQLFetchScroll( (SQLHSTMT) data->stmt_res->hstmt, data->fetchOrientation, data->fetchOffset);
|
1251
|
+
|
1252
|
+
data->stmt_res->is_executing = 0;
|
1253
|
+
|
1254
|
+
return rc;
|
1255
|
+
}
|
1256
|
+
|
1257
|
+
/*
|
1258
|
+
This function calls SQLFetch cli call to advance the cursor to
|
1259
|
+
the next row of the result set, and retrieves any bound columns
|
1260
|
+
*/
|
1261
|
+
int _ruby_ibm_db_SQLFetch_helper2(fetch_data_args *data) {
|
1262
|
+
int rc = 0;
|
1263
|
+
|
1264
|
+
_ruby_ibm_db_trace_output("SQLFetch", data, sizeof(fetch_data_args));
|
1265
|
+
|
1266
|
+
data->stmt_res->is_executing = 1;
|
1267
|
+
|
1268
|
+
rc = SQLFetch( (SQLHSTMT) data->stmt_res->hstmt );
|
1269
|
+
|
1270
|
+
data->stmt_res->is_executing = 0;
|
1271
|
+
|
1272
|
+
return rc;
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
/*
|
1276
|
+
This function calls SQLNumResultCols cli call to fetch the number of fields contained in a result set
|
1277
|
+
*/
|
1278
|
+
int _ruby_ibm_db_SQLNumResultCols_helper2(row_col_count_args *data) {
|
1279
|
+
int rc = 0;
|
1280
|
+
|
1281
|
+
_ruby_ibm_db_trace_output("SQLNumResultCols", data, sizeof(fetch_data_args));
|
1282
|
+
|
1283
|
+
data->stmt_res->is_executing = 1;
|
1284
|
+
|
1285
|
+
rc = SQLNumResultCols( (SQLHSTMT) data->stmt_res->hstmt, (SQLSMALLINT*) &(data->count) );
|
1286
|
+
|
1287
|
+
data->stmt_res->is_executing = 0;
|
1288
|
+
|
1289
|
+
return rc;
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
/*
|
1293
|
+
This function calls SQLNumParams cli call to fetch the number of parameter markers in an SQL statement
|
1294
|
+
*/
|
1295
|
+
int _ruby_ibm_db_SQLNumParams_helper2(row_col_count_args *data) {
|
1296
|
+
int rc = 0;
|
1297
|
+
|
1298
|
+
_ruby_ibm_db_trace_output("SQLNumParams", data, sizeof(row_col_count_args));
|
1299
|
+
|
1300
|
+
data->stmt_res->is_executing = 1;
|
1301
|
+
|
1302
|
+
rc = SQLNumParams( (SQLHSTMT) data->stmt_res->hstmt, (SQLSMALLINT*) &(data->count) );
|
1303
|
+
|
1304
|
+
data->stmt_res->is_executing = 0;
|
1305
|
+
|
1306
|
+
return rc;
|
1307
|
+
}
|
1308
|
+
|
1309
|
+
/*
|
1310
|
+
This function calls SQLRowCount cli call to fetch the number of rows affected by the SQL statement
|
1311
|
+
*/
|
1312
|
+
int _ruby_ibm_db_SQLRowCount_helper2(sql_row_count_args *data) {
|
1313
|
+
int rc = 0;
|
1314
|
+
|
1315
|
+
_ruby_ibm_db_trace_output("SQLRowCount", data, sizeof(sql_row_count_args));
|
1316
|
+
|
1317
|
+
data->stmt_res->is_executing = 1;
|
1318
|
+
|
1319
|
+
rc = SQLRowCount( (SQLHSTMT) data->stmt_res->hstmt, (SQLLEN*) &(data->count) );
|
1320
|
+
|
1321
|
+
data->stmt_res->is_executing = 0;
|
1322
|
+
|
1323
|
+
return rc;
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
/*
|
1327
|
+
This function calls SQLGetInfo cli call to get general information about DBMS, which the app is connected to
|
1328
|
+
*/
|
1329
|
+
int _ruby_ibm_db_SQLGetInfo_helper2(get_info_args *data) {
|
1330
|
+
int rc = 0;
|
1331
|
+
|
1332
|
+
_ruby_ibm_db_trace_output("SQLGetInfo", data, sizeof(get_info_args));
|
1333
|
+
|
1334
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
1335
|
+
rc = SQLGetInfo( data->conn_res->hdbc, data->infoType, data->infoValue, data->buff_length, data->out_length);
|
1336
|
+
#else
|
1337
|
+
rc = SQLGetInfoW( data->conn_res->hdbc, data->infoType, data->infoValue, data->buff_length, data->out_length);
|
1338
|
+
#endif
|
1339
|
+
|
1340
|
+
return rc;
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
/*
|
1344
|
+
This function calls SQLGetDiagRec cli call to get the current values of a diagnostic record that contains error
|
1345
|
+
*/
|
1346
|
+
int _ruby_ibm_db_SQLGetDiagRec_helper2(get_diagRec_args *data) {
|
1347
|
+
int rc = 0;
|
1348
|
+
|
1349
|
+
_ruby_ibm_db_trace_output("SQLGetDiagRec", data, sizeof(get_diagRec_args));
|
1350
|
+
|
1351
|
+
#if defined(UNICODE_SUPPORT_VERSION) && ! defined(UTF8_OVERRIDE_VERSION)
|
1352
|
+
rc = SQLGetDiagRecW( data->hType, data->handle, data->recNum, data->SQLState, data->NativeErrorPtr,
|
1353
|
+
data->msgText, data->buff_length, data->text_length_ptr );
|
1354
|
+
#else
|
1355
|
+
rc = SQLGetDiagRec(data->hType, data->handle, data->recNum, data->SQLState, data->NativeErrorPtr,
|
1356
|
+
data->msgText, data->buff_length, data->text_length_ptr );
|
1357
|
+
#endif
|
1358
|
+
|
1359
|
+
_ruby_ibm_db_trace_verbose("SQLGetDiagRec", data, sizeof(get_diagRec_args), rc);
|
1360
|
+
|
1361
|
+
if (_ruby_IBM_DB_TRACE_ERROR == 1) {
|
1362
|
+
_ruby_ibm_db_trace_memory((char *)NULL,0);
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
return rc;
|
1366
|
+
}
|
1367
|
+
|
1368
|
+
/*
|
1369
|
+
This function calls SQLSetStmtAttr cli call to set attributes related to a statement
|
1370
|
+
*/
|
1371
|
+
int _ruby_ibm_db_SQLSetStmtAttr_helper2(set_handle_attr_args *data) {
|
1372
|
+
int rc = SQL_ERROR;
|
1373
|
+
|
1374
|
+
_ruby_ibm_db_trace_output("SQLSetStmtAttr", data, sizeof(set_handle_attr_args));
|
1375
|
+
|
1376
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
1377
|
+
rc = SQLSetStmtAttr( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr, data->strLength );
|
1378
|
+
#else
|
1379
|
+
rc = SQLSetStmtAttrW( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr, data->strLength );
|
1380
|
+
#endif
|
1381
|
+
|
1382
|
+
if (_ruby_ibm_db_set_attr_override(data) == SQL_SUCCESS) rc = SQL_SUCCESS;
|
1383
|
+
|
1384
|
+
_ruby_ibm_db_trace_verbose("SQLSetStmtAttr", data, sizeof(set_handle_attr_args), rc);
|
1385
|
+
|
1386
|
+
return rc;
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
/*
|
1390
|
+
This function calls SQLSetConnectAttr cli call to set attributes that govern aspects of connections
|
1391
|
+
*/
|
1392
|
+
int _ruby_ibm_db_SQLSetConnectAttr_helper2(set_handle_attr_args *data) {
|
1393
|
+
int rc = SQL_ERROR;
|
1394
|
+
|
1395
|
+
_ruby_ibm_db_trace_output("SQLSetConnectAttr", data, sizeof(set_handle_attr_args));
|
1396
|
+
|
1397
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
1398
|
+
rc = SQLSetConnectAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr, data->strLength );
|
1399
|
+
#else
|
1400
|
+
rc = SQLSetConnectAttrW( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr, data->strLength );
|
1401
|
+
#endif
|
1402
|
+
|
1403
|
+
if (_ruby_ibm_db_set_attr_override(data) == SQL_SUCCESS) rc = SQL_SUCCESS;
|
1404
|
+
|
1405
|
+
_ruby_ibm_db_trace_verbose("SQLSetConnectAttr", data, sizeof(set_handle_attr_args), rc);
|
1406
|
+
|
1407
|
+
return rc;
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
/*
|
1411
|
+
This function calls SQLSetEnvAttr cli call to set an environment attribute
|
1412
|
+
*/
|
1413
|
+
int _ruby_ibm_db_SQLSetEnvAttr_helper2(set_handle_attr_args *data) {
|
1414
|
+
int rc = SQL_ERROR;
|
1415
|
+
|
1416
|
+
_ruby_ibm_db_trace_output("SQLSetEnvAttr", data, sizeof(set_handle_attr_args));
|
1417
|
+
|
1418
|
+
rc = SQLSetEnvAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr, data->strLength );
|
1419
|
+
|
1420
|
+
if (_ruby_ibm_db_set_attr_override(data) == SQL_SUCCESS) rc = SQL_SUCCESS;
|
1421
|
+
|
1422
|
+
_ruby_ibm_db_trace_verbose("SQLSetEnvAttr", data, sizeof(set_handle_attr_args), rc);
|
1423
|
+
|
1424
|
+
return rc;
|
1425
|
+
}
|
1426
|
+
|
1427
|
+
/*
|
1428
|
+
This function calls SQLGetStmtAttr cli call to set an statement attribute
|
1429
|
+
|
1430
|
+
The unicode equivalent of SQLGetStmtAttr is not used because the attributes being retrieved currently are not of type char or binary (SQL_IS_INTEGER). If support for retrieving a string type is provided then use the SQLGetStmtAttrW function accordingly
|
1431
|
+
In get_last_serial_id although we are retrieving a char type, it is converted back to an integer (atoi). The char to integer conversion function in unicode equivalent will be more complicated and is unnecessary for this case.
|
1432
|
+
|
1433
|
+
*/
|
1434
|
+
int _ruby_ibm_db_SQLGetStmtAttr_helper2(get_handle_attr_args *data) {
|
1435
|
+
int rc = SQL_ERROR;
|
1436
|
+
|
1437
|
+
_ruby_ibm_db_trace_output("SQLGetStmtAttr", data, sizeof(get_handle_attr_args));
|
1438
|
+
|
1439
|
+
if (_ruby_ibm_db_get_attr_override(data) == SQL_SUCCESS) return SQL_SUCCESS;
|
1440
|
+
|
1441
|
+
rc = SQLGetStmtAttr( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr,
|
1442
|
+
data->buff_length, data->out_length);
|
1443
|
+
|
1444
|
+
if (_ruby_ibm_db_get_attr_override(data) == SQL_SUCCESS) rc = SQL_SUCCESS;
|
1445
|
+
|
1446
|
+
_ruby_ibm_db_trace_verbose("SQLGetStmtAttr", data, sizeof(get_handle_attr_args), rc);
|
1447
|
+
|
1448
|
+
return rc;
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
/*
|
1452
|
+
This function calls SQLGetConnectAttr cli call to get a connection attribute
|
1453
|
+
*/
|
1454
|
+
int _ruby_ibm_db_SQLGetConnectAttr_helper2(get_handle_attr_args *data) {
|
1455
|
+
int rc = SQL_ERROR;
|
1456
|
+
|
1457
|
+
_ruby_ibm_db_trace_output("SQLGetConnectAttr", data, sizeof(get_handle_attr_args));
|
1458
|
+
|
1459
|
+
#if ! defined(UNICODE_SUPPORT_VERSION) || defined(UTF8_OVERRIDE_VERSION)
|
1460
|
+
rc = SQLGetConnectAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr,
|
1461
|
+
data->buff_length, data->out_length);
|
1462
|
+
#else
|
1463
|
+
rc = SQLGetConnectAttrW( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr,
|
1464
|
+
data->buff_length, data->out_length);
|
1465
|
+
#endif
|
1466
|
+
|
1467
|
+
if (_ruby_ibm_db_get_attr_override(data) == SQL_SUCCESS) rc = SQL_SUCCESS;
|
1468
|
+
|
1469
|
+
_ruby_ibm_db_trace_verbose("SQLGetConnectAttr", data, sizeof(get_handle_attr_args), rc);
|
1470
|
+
|
1471
|
+
return rc;
|
1472
|
+
}
|
1473
|
+
|
1474
|
+
/*
|
1475
|
+
This function calls SQLGetEnvAttr cli call to get an environment attribute
|
1476
|
+
*/
|
1477
|
+
int _ruby_ibm_db_SQLGetEnvAttr_helper2(get_handle_attr_args *data) {
|
1478
|
+
int rc = SQL_ERROR;
|
1479
|
+
|
1480
|
+
_ruby_ibm_db_trace_output("SQLGetEnvAttr", data, sizeof(get_handle_attr_args));
|
1481
|
+
|
1482
|
+
rc = SQLGetEnvAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr,
|
1483
|
+
data->buff_length, data->out_length);
|
1484
|
+
|
1485
|
+
if (_ruby_ibm_db_get_attr_override(data) == SQL_SUCCESS) rc = SQL_SUCCESS;
|
1486
|
+
|
1487
|
+
_ruby_ibm_db_trace_verbose("SQLGetEnvAttr", data, sizeof(get_handle_attr_args), rc);
|
1488
|
+
|
1489
|
+
return rc;
|
1490
|
+
}
|
1491
|
+
|
1492
|
+
/*
|
1493
|
+
This function calls SQLBindFileToParam cli call
|
1494
|
+
|
1495
|
+
SQLRETURN SQLBindFileToParam (
|
1496
|
+
SQLHSTMT StatementHandle,
|
1497
|
+
SQLUSMALLINT TargetType,
|
1498
|
+
SQLSMALLINT DataType,
|
1499
|
+
SQLCHAR *FileName,
|
1500
|
+
SQLSMALLINT *FileNameLength, <--- bug LUW
|
1501
|
+
SQLUINTEGER *FileOptions,
|
1502
|
+
SQLSMALLINT MaxFileNameLength,
|
1503
|
+
SQLINTEGER *IndicatorValue);
|
1504
|
+
*/
|
1505
|
+
int _ruby_ibm_db_SQLBindFileToParam_helper2(param_node2 *data) {
|
1506
|
+
int rc = 0;
|
1507
|
+
stmt_handle *stmt_res = data->stmt_res;
|
1508
|
+
param_node *curr = data->curr;
|
1509
|
+
SQLSMALLINT FileNameLength = curr->ivalue;
|
1510
|
+
|
1511
|
+
_ruby_ibm_db_trace_output("SQLBindFileToParam", curr, sizeof(param_node));
|
1512
|
+
|
1513
|
+
stmt_res->is_executing = 1;
|
1514
|
+
|
1515
|
+
/* FIX LUW (@ADC 7/23/2013):
|
1516
|
+
* ERROR ivalue truncation -- (SQLSMALLINT*)&(curr->ivalue)
|
1517
|
+
* typical cast above -- &(FileNameLength)
|
1518
|
+
*/
|
1519
|
+
rc = SQLBindFileToParam( (SQLHSTMT)stmt_res->hstmt, curr->param_num,
|
1520
|
+
curr->data_type, (SQLCHAR*)curr->svalue,
|
1521
|
+
&(FileNameLength), &(curr->file_options),
|
1522
|
+
curr->ivalue, &(curr->bind_indicator) );
|
1523
|
+
|
1524
|
+
stmt_res->is_executing = 0;
|
1525
|
+
|
1526
|
+
return rc;
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
/*
|
1530
|
+
This function calls SQLBindParameter cli call
|
1531
|
+
*/
|
1532
|
+
int _ruby_ibm_db_SQLBindParameter_helper2(bind_parameter_args *data) {
|
1533
|
+
int rc = 0;
|
1534
|
+
|
1535
|
+
_ruby_ibm_db_trace_output("SQLBindParameter", data, sizeof(bind_parameter_args));
|
1536
|
+
|
1537
|
+
data->stmt_res->is_executing = 1;
|
1538
|
+
|
1539
|
+
rc = SQLBindParameter( (SQLHSTMT) data->stmt_res->hstmt, data->param_num, data->IOType, data->valueType,
|
1540
|
+
data->paramType, data->colSize, data->decimalDigits, data->paramValPtr, data->buff_length,
|
1541
|
+
data->out_length );
|
1542
|
+
|
1543
|
+
_ruby_ibm_db_trace_verbose("SQLBindParameter", data, sizeof(bind_parameter_args), rc);
|
1544
|
+
|
1545
|
+
data->stmt_res->is_executing = 0;
|
1546
|
+
|
1547
|
+
return rc;
|
1548
|
+
}
|
1549
|
+
/*
|
1550
|
+
Connection level release GIL/GVL
|
1551
|
+
*/
|
1552
|
+
int _ruby_ibm_db_SQLConnect_helper(connect_args *data) {
|
1553
|
+
int rc = 0;
|
1554
|
+
if (_ruby_ibm_db_SQLConnect_GIL_release)
|
1555
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLConnect_helper2, data,
|
1556
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1557
|
+
else
|
1558
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLConnect_helper2, data,
|
1559
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1560
|
+
return rc;
|
1561
|
+
}
|
1562
|
+
int _ruby_ibm_db_SQLDisconnect_helper(SQLHANDLE *data) {
|
1563
|
+
int rc = 0;
|
1564
|
+
if (_ruby_ibm_db_SQLDisconnect_GIL_release)
|
1565
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDisconnect_helper2, data,
|
1566
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1567
|
+
else
|
1568
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLDisconnect_helper2, data,
|
1569
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1570
|
+
return rc;
|
1571
|
+
}
|
1572
|
+
int _ruby_ibm_db_SQLEndTran(end_tran_args *data) {
|
1573
|
+
int rc = 0;
|
1574
|
+
if (_ruby_ibm_db_SQLEndTran_GIL_release)
|
1575
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLEndTran2, data,
|
1576
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1577
|
+
else
|
1578
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLEndTran2, data,
|
1579
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1580
|
+
return rc;
|
1581
|
+
}
|
1582
|
+
int _ruby_ibm_db_SQLDescribeParam_helper(describeparam_args *data) {
|
1583
|
+
int rc = 0;
|
1584
|
+
if (_ruby_ibm_db_SQLDescribeParam_GIL_release)
|
1585
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDescribeParam_helper2, data,
|
1586
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1587
|
+
else
|
1588
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLDescribeParam_helper2, data,
|
1589
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1590
|
+
return rc;
|
1591
|
+
}
|
1592
|
+
int _ruby_ibm_db_SQLDescribeCol_helper(describecol_args *data) {
|
1593
|
+
int rc = 0;
|
1594
|
+
if (_ruby_ibm_db_SQLDescribeCol_GIL_release)
|
1595
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDescribeCol_helper2, data,
|
1596
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1597
|
+
else
|
1598
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLDescribeCol_helper2, data,
|
1599
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1600
|
+
return rc;
|
1601
|
+
}
|
1602
|
+
int _ruby_ibm_db_SQLBindCol_helper(bind_col_args *data) {
|
1603
|
+
int rc = 0;
|
1604
|
+
if (_ruby_ibm_db_SQLBindCol_GIL_release)
|
1605
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLBindCol_helper2, data,
|
1606
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1607
|
+
else
|
1608
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLBindCol_helper2, data,
|
1609
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1610
|
+
return rc;
|
1611
|
+
}
|
1612
|
+
int _ruby_ibm_db_SQLColumnPrivileges_helper(metadata_args *data) {
|
1613
|
+
int rc = 0;
|
1614
|
+
if (_ruby_ibm_db_SQLColumnPrivileges_GIL_release)
|
1615
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLColumnPrivileges_helper2, data,
|
1616
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1617
|
+
else
|
1618
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLColumnPrivileges_helper2, data,
|
1619
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1620
|
+
return rc;
|
1621
|
+
}
|
1622
|
+
int _ruby_ibm_db_SQLColumns_helper(metadata_args *data) {
|
1623
|
+
int rc = 0;
|
1624
|
+
if (_ruby_ibm_db_SQLColumns_GIL_release)
|
1625
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLColumns_helper2, data,
|
1626
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1627
|
+
else
|
1628
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLColumns_helper2, data,
|
1629
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1630
|
+
return rc;
|
1631
|
+
}
|
1632
|
+
int _ruby_ibm_db_SQLPrimaryKeys_helper(metadata_args *data) {
|
1633
|
+
int rc = 0;
|
1634
|
+
if (_ruby_ibm_db_SQLPrimaryKeys_GIL_release)
|
1635
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLPrimaryKeys_helper2, data,
|
1636
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1637
|
+
else
|
1638
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLPrimaryKeys_helper2, data,
|
1639
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1640
|
+
return rc;
|
1641
|
+
}
|
1642
|
+
int _ruby_ibm_db_SQLForeignKeys_helper(metadata_args *data) {
|
1643
|
+
int rc = 0;
|
1644
|
+
if (_ruby_ibm_db_SQLForeignKeys_GIL_release)
|
1645
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLForeignKeys_helper2, data,
|
1646
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1647
|
+
else
|
1648
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLForeignKeys_helper2, data,
|
1649
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1650
|
+
return rc;
|
1651
|
+
}
|
1652
|
+
int _ruby_ibm_db_SQLProcedureColumns_helper(metadata_args *data) {
|
1653
|
+
int rc = 0;
|
1654
|
+
if (_ruby_ibm_db_SQLProcedureColumns_GIL_release)
|
1655
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLProcedureColumns_helper2, data,
|
1656
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1657
|
+
else
|
1658
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLProcedureColumns_helper2, data,
|
1659
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1660
|
+
return rc;
|
1661
|
+
}
|
1662
|
+
int _ruby_ibm_db_SQLProcedures_helper(metadata_args *data) {
|
1663
|
+
int rc = 0;
|
1664
|
+
if (_ruby_ibm_db_SQLProcedures_GIL_release)
|
1665
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLProcedures_helper2, data,
|
1666
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1667
|
+
else
|
1668
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLProcedures_helper2, data,
|
1669
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1670
|
+
return rc;
|
1671
|
+
}
|
1672
|
+
int _ruby_ibm_db_SQLSpecialColumns_helper(metadata_args *data) {
|
1673
|
+
int rc = 0;
|
1674
|
+
if (_ruby_ibm_db_SQLSpecialColumns_GIL_release)
|
1675
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLSpecialColumns_helper2, data,
|
1676
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1677
|
+
else
|
1678
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLSpecialColumns_helper2, data,
|
1679
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1680
|
+
return rc;
|
1681
|
+
}
|
1682
|
+
int _ruby_ibm_db_SQLStatistics_helper(metadata_args *data) {
|
1683
|
+
int rc = 0;
|
1684
|
+
if (_ruby_ibm_db_SQLStatistics_GIL_release)
|
1685
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLStatistics_helper2, data,
|
1686
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1687
|
+
else
|
1688
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLStatistics_helper2, data,
|
1689
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1690
|
+
return rc;
|
1691
|
+
}
|
1692
|
+
int _ruby_ibm_db_SQLTablePrivileges_helper(metadata_args *data) {
|
1693
|
+
int rc = 0;
|
1694
|
+
if (_ruby_ibm_db_SQLTablePrivileges_GIL_release)
|
1695
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLTablePrivileges_helper2, data,
|
1696
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1697
|
+
else
|
1698
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLTablePrivileges_helper2, data,
|
1699
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1700
|
+
return rc;
|
1701
|
+
}
|
1702
|
+
int _ruby_ibm_db_SQLTables_helper(metadata_args *data) {
|
1703
|
+
int rc = 0;
|
1704
|
+
if (_ruby_ibm_db_SQLTables_GIL_release)
|
1705
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLTables_helper2, data,
|
1706
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1707
|
+
else
|
1708
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLTables_helper2, data,
|
1709
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1710
|
+
return rc;
|
1711
|
+
}
|
1712
|
+
int _ruby_ibm_db_SQLExecDirect_helper(exec_cum_prepare_args *data) {
|
1713
|
+
int rc = 0;
|
1714
|
+
if (_ruby_ibm_db_SQLExecDirect_GIL_release)
|
1715
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLExecDirect_helper2, data,
|
1716
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1717
|
+
else
|
1718
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLExecDirect_helper2, data,
|
1719
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1720
|
+
return rc;
|
1721
|
+
}
|
1722
|
+
int _ruby_ibm_db_SQLCreateDB_helper(create_drop_db_args *data) {
|
1723
|
+
int rc = 0;
|
1724
|
+
if (_ruby_ibm_db_SQLCreateDB_GIL_release)
|
1725
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLCreateDB_helper2, data,
|
1726
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1727
|
+
else
|
1728
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLCreateDB_helper2, data,
|
1729
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1730
|
+
return rc;
|
1731
|
+
}
|
1732
|
+
int _ruby_ibm_db_SQLDropDB_helper(create_drop_db_args *data) {
|
1733
|
+
int rc = 0;
|
1734
|
+
if (_ruby_ibm_db_SQLDropDB_GIL_release)
|
1735
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDropDB_helper2, data,
|
1736
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1737
|
+
else
|
1738
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLDropDB_helper2, data,
|
1739
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1740
|
+
return rc;
|
1741
|
+
}
|
1742
|
+
int _ruby_ibm_db_SQLPrepare_helper(exec_cum_prepare_args *data) {
|
1743
|
+
int rc = 0;
|
1744
|
+
if (_ruby_ibm_db_SQLPrepare_GIL_release)
|
1745
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLPrepare_helper2, data,
|
1746
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1747
|
+
else
|
1748
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLPrepare_helper2, data,
|
1749
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1750
|
+
return rc;
|
1751
|
+
}
|
1752
|
+
int _ruby_ibm_db_SQLGetInfo_helper(get_info_args *data) {
|
1753
|
+
int rc = 0;
|
1754
|
+
if (_ruby_ibm_db_SQLGetInfo_GIL_release)
|
1755
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetInfo_helper2, data,
|
1756
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1757
|
+
else
|
1758
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLGetInfo_helper2, data,
|
1759
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1760
|
+
return rc;
|
1761
|
+
}
|
1762
|
+
int _ruby_ibm_db_SQLGetDiagRec_helper(get_diagRec_args *data) {
|
1763
|
+
int rc = 0;
|
1764
|
+
if (_ruby_ibm_db_SQLGetDiagRec_GIL_release)
|
1765
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetDiagRec_helper2, data,
|
1766
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1767
|
+
else
|
1768
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLGetDiagRec_helper2, data,
|
1769
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1770
|
+
return rc;
|
1771
|
+
}
|
1772
|
+
int _ruby_ibm_db_SQLSetStmtAttr_helper(set_handle_attr_args *data) {
|
1773
|
+
int rc = 0;
|
1774
|
+
if (_ruby_ibm_db_SQLSetStmtAttr_GIL_release)
|
1775
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLSetStmtAttr_helper2, data,
|
1776
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1777
|
+
else
|
1778
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLSetStmtAttr_helper2, data,
|
1779
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1780
|
+
return rc;
|
1781
|
+
}
|
1782
|
+
int _ruby_ibm_db_SQLSetConnectAttr_helper(set_handle_attr_args *data) {
|
1783
|
+
int rc = 0;
|
1784
|
+
if (_ruby_ibm_db_SQLSetConnectAttr_GIL_release)
|
1785
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLSetConnectAttr_helper2, data,
|
1786
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1787
|
+
else
|
1788
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLSetConnectAttr_helper2, data,
|
1789
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1790
|
+
return rc;
|
1791
|
+
}
|
1792
|
+
int _ruby_ibm_db_SQLSetEnvAttr_helper(set_handle_attr_args *data) {
|
1793
|
+
int rc = 0;
|
1794
|
+
if (_ruby_ibm_db_SQLSetEnvAttr_GIL_release)
|
1795
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLSetEnvAttr_helper2, data,
|
1796
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1797
|
+
else
|
1798
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLSetEnvAttr_helper2, data,
|
1799
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1800
|
+
return rc;
|
1801
|
+
}
|
1802
|
+
int _ruby_ibm_db_SQLGetStmtAttr_helper(get_handle_attr_args *data) {
|
1803
|
+
int rc = 0;
|
1804
|
+
if (_ruby_ibm_db_SQLGetStmtAttr_GIL_release)
|
1805
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetStmtAttr_helper2, data,
|
1806
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1807
|
+
else
|
1808
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLGetStmtAttr_helper2, data,
|
1809
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1810
|
+
return rc;
|
1811
|
+
}
|
1812
|
+
int _ruby_ibm_db_SQLGetConnectAttr_helper(get_handle_attr_args *data) {
|
1813
|
+
int rc = 0;
|
1814
|
+
if (_ruby_ibm_db_SQLGetConnectAttr_GIL_release)
|
1815
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetConnectAttr_helper2, data,
|
1816
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1817
|
+
else
|
1818
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLGetConnectAttr_helper2, data,
|
1819
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1820
|
+
return rc;
|
1821
|
+
}
|
1822
|
+
int _ruby_ibm_db_SQLGetEnvAttr_helper(get_handle_attr_args *data) {
|
1823
|
+
int rc = 0;
|
1824
|
+
if (_ruby_ibm_db_SQLGetEnvAttr_GIL_release)
|
1825
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetEnvAttr_helper2, data,
|
1826
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1827
|
+
else
|
1828
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLGetEnvAttr_helper2, data,
|
1829
|
+
(void *)_ruby_ibm_db_Connection_level_UBF, NULL);
|
1830
|
+
return rc;
|
1831
|
+
}
|
1832
|
+
/*
|
1833
|
+
Statement level release GIL/GVL
|
1834
|
+
*/
|
1835
|
+
int _ruby_ibm_db_SQLFreeStmt_helper(free_stmt_args *data) {
|
1836
|
+
int rc = 0;
|
1837
|
+
if (_ruby_ibm_db_SQLFreeStmt_GIL_release)
|
1838
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLFreeStmt_helper2, data,
|
1839
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1840
|
+
else
|
1841
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLFreeStmt_helper2, data,
|
1842
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1843
|
+
return rc;
|
1844
|
+
}
|
1845
|
+
int _ruby_ibm_db_SQLExecute_helper(stmt_handle *data) {
|
1846
|
+
int rc = 0;
|
1847
|
+
if (_ruby_ibm_db_SQLExecute_GIL_release)
|
1848
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLExecute_helper2, data,
|
1849
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data);
|
1850
|
+
else
|
1851
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLExecute_helper2, data,
|
1852
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data);
|
1853
|
+
return rc;
|
1854
|
+
}
|
1855
|
+
int _ruby_ibm_db_SQLParamData_helper(param_cum_put_data_args *data) {
|
1856
|
+
int rc = 0;
|
1857
|
+
if (_ruby_ibm_db_SQLParamData_GIL_release)
|
1858
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLParamData_helper2, data,
|
1859
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1860
|
+
else
|
1861
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLParamData_helper2, data,
|
1862
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1863
|
+
return rc;
|
1864
|
+
}
|
1865
|
+
int _ruby_ibm_db_SQLColAttributes_helper(col_attr_args *data) {
|
1866
|
+
int rc = 0;
|
1867
|
+
if (_ruby_ibm_db_SQLColAttributes_GIL_release)
|
1868
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLColAttributes_helper2, data,
|
1869
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1870
|
+
else
|
1871
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLColAttributes_helper2, data,
|
1872
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1873
|
+
return rc;
|
1874
|
+
}
|
1875
|
+
int _ruby_ibm_db_SQLPutData_helper(param_cum_put_data_args *data) {
|
1876
|
+
int rc = 0;
|
1877
|
+
if (_ruby_ibm_db_SQLPutData_GIL_release)
|
1878
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLPutData_helper2, data,
|
1879
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1880
|
+
else
|
1881
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLPutData_helper2, data,
|
1882
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1883
|
+
return rc;
|
1884
|
+
}
|
1885
|
+
int _ruby_ibm_db_SQLGetData_helper(get_data_args *data) {
|
1886
|
+
int rc = 0;
|
1887
|
+
if (_ruby_ibm_db_SQLGetData_GIL_release)
|
1888
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetData_helper2, data,
|
1889
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1890
|
+
else
|
1891
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLGetData_helper2, data,
|
1892
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1893
|
+
return rc;
|
1894
|
+
}
|
1895
|
+
int _ruby_ibm_db_SQLGetLength_helper(get_length_args *data) {
|
1896
|
+
int rc = 0;
|
1897
|
+
if (_ruby_ibm_db_SQLGetLength_GIL_release)
|
1898
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetLength_helper2, data,
|
1899
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1900
|
+
else
|
1901
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLGetLength_helper2, data,
|
1902
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1903
|
+
return rc;
|
1904
|
+
}
|
1905
|
+
int _ruby_ibm_db_SQLGetSubString_helper(get_subString_args *data) {
|
1906
|
+
int rc = 0;
|
1907
|
+
if (_ruby_ibm_db_SQLGetSubString_GIL_release)
|
1908
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetSubString_helper2, data,
|
1909
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1910
|
+
else
|
1911
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLGetSubString_helper2, data,
|
1912
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1913
|
+
return rc;
|
1914
|
+
}
|
1915
|
+
int _ruby_ibm_db_SQLNextResult_helper(next_result_args *data) {
|
1916
|
+
int rc = 0;
|
1917
|
+
if (_ruby_ibm_db_SQLNextResult_GIL_release)
|
1918
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLNextResult_helper2, data,
|
1919
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1920
|
+
else
|
1921
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLNextResult_helper2, data,
|
1922
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1923
|
+
return rc;
|
1924
|
+
}
|
1925
|
+
int _ruby_ibm_db_SQLFetchScroll_helper(fetch_data_args *data) {
|
1926
|
+
int rc = 0;
|
1927
|
+
if (_ruby_ibm_db_SQLFetchScroll_GIL_release)
|
1928
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLFetchScroll_helper2, data,
|
1929
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1930
|
+
else
|
1931
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLFetchScroll_helper2, data,
|
1932
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1933
|
+
return rc;
|
1934
|
+
}
|
1935
|
+
int _ruby_ibm_db_SQLFetch_helper(fetch_data_args *data) {
|
1936
|
+
int rc = 0;
|
1937
|
+
if (_ruby_ibm_db_SQLFetch_GIL_release)
|
1938
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLFetch_helper2, data,
|
1939
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1940
|
+
else
|
1941
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLFetch_helper2, data,
|
1942
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1943
|
+
return rc;
|
1944
|
+
}
|
1945
|
+
int _ruby_ibm_db_SQLNumResultCols_helper(row_col_count_args *data) {
|
1946
|
+
int rc = 0;
|
1947
|
+
if (_ruby_ibm_db_SQLNumResultCols_GIL_release)
|
1948
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLNumResultCols_helper2, data,
|
1949
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1950
|
+
else
|
1951
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLNumResultCols_helper2, data,
|
1952
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1953
|
+
return rc;
|
1954
|
+
}
|
1955
|
+
int _ruby_ibm_db_SQLNumParams_helper(row_col_count_args *data) {
|
1956
|
+
int rc = 0;
|
1957
|
+
if (_ruby_ibm_db_SQLNumParams_GIL_release)
|
1958
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLNumParams_helper2, data,
|
1959
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1960
|
+
else
|
1961
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLNumParams_helper2, data,
|
1962
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1963
|
+
return rc;
|
1964
|
+
}
|
1965
|
+
int _ruby_ibm_db_SQLRowCount_helper(sql_row_count_args *data) {
|
1966
|
+
int rc = 0;
|
1967
|
+
if (_ruby_ibm_db_SQLRowCount_GIL_release)
|
1968
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLRowCount_helper2, data,
|
1969
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1970
|
+
else
|
1971
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLRowCount_helper2, data,
|
1972
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1973
|
+
return rc;
|
1974
|
+
}
|
1975
|
+
int _ruby_ibm_db_SQLBindFileToParam_helper(stmt_handle *stmt_res, param_node *curr) {
|
1976
|
+
int rc = 0;
|
1977
|
+
param_node2 indata;
|
1978
|
+
param_node2 *data = (param_node2 *)&indata;
|
1979
|
+
indata.stmt_res = stmt_res;
|
1980
|
+
indata.curr = curr;
|
1981
|
+
if (_ruby_ibm_db_SQLBindFileToParam_GIL_release)
|
1982
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLBindFileToParam_helper2, data,
|
1983
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1984
|
+
else
|
1985
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLBindFileToParam_helper2, data,
|
1986
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1987
|
+
return rc;
|
1988
|
+
}
|
1989
|
+
int _ruby_ibm_db_SQLBindParameter_helper(bind_parameter_args *data) {
|
1990
|
+
int rc = 0;
|
1991
|
+
if (_ruby_ibm_db_SQLBindParameter_GIL_release)
|
1992
|
+
rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLBindParameter_helper2, data,
|
1993
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1994
|
+
else
|
1995
|
+
rc = forget_blocking_region( (void *)_ruby_ibm_db_SQLBindParameter_helper2, data,
|
1996
|
+
(void *)_ruby_ibm_db_Statement_level_UBF, data->stmt_res);
|
1997
|
+
return rc;
|
1998
|
+
}
|
1999
|
+
|
2000
|
+
|
2001
|
+
/*
|
2002
|
+
==========================================================
|
2003
|
+
Handy CLI trace dump functions
|
2004
|
+
*/
|
2005
|
+
static void _ruby_ibm_db_console(const char * format, ...) {
|
2006
|
+
char bigbuff[4096];
|
2007
|
+
char *p = (char *) &bigbuff;
|
2008
|
+
FILE * pFile;
|
2009
|
+
|
2010
|
+
va_list args;
|
2011
|
+
va_start(args, format);
|
2012
|
+
vsprintf(p, format, args);
|
2013
|
+
va_end(args);
|
2014
|
+
|
2015
|
+
if (_ruby_IBM_DB_TRACE_ERROR == 1) {
|
2016
|
+
_ruby_ibm_db_trace_memory(bigbuff,1);
|
2017
|
+
return;
|
2018
|
+
}
|
2019
|
+
if (! _ruby_IBM_DB_FILE) {
|
2020
|
+
printf("%s",p);
|
2021
|
+
}
|
2022
|
+
else {
|
2023
|
+
pFile = fopen (_ruby_IBM_DB_FILE,"a+");
|
2024
|
+
if (pFile!=NULL)
|
2025
|
+
{
|
2026
|
+
fputs (p,pFile);
|
2027
|
+
fclose (pFile);
|
2028
|
+
}
|
2029
|
+
}
|
2030
|
+
}
|
2031
|
+
static void _ruby_ibm_db_trace_memory(char * bigbuff, int flag) {
|
2032
|
+
int have, want, remain, need;
|
2033
|
+
char tmp[IBM_DB_TRACE_ERROR_BUFFER_MAX+1];
|
2034
|
+
/* dump data -- start over */
|
2035
|
+
if (!flag) {
|
2036
|
+
_ruby_IBM_DB_TRACE_ERROR = 0;
|
2037
|
+
_ruby_ibm_db_console("%s\n", _ruby_IBM_DB_TRACE_ERROR_BUFFER);
|
2038
|
+
memset(_ruby_IBM_DB_TRACE_ERROR_BUFFER,0,IBM_DB_TRACE_ERROR_BUFFER_MAX+1);
|
2039
|
+
_ruby_IBM_DB_TRACE_ERROR = 1;
|
2040
|
+
return;
|
2041
|
+
}
|
2042
|
+
/* save data -- last in */
|
2043
|
+
want = strlen(bigbuff);
|
2044
|
+
have = strlen(_ruby_IBM_DB_TRACE_ERROR_BUFFER);
|
2045
|
+
remain = IBM_DB_TRACE_ERROR_BUFFER_MAX-have;
|
2046
|
+
if (remain < want) {
|
2047
|
+
need = want - remain;
|
2048
|
+
memset(tmp,0,IBM_DB_TRACE_ERROR_BUFFER_MAX);
|
2049
|
+
strcpy(tmp,&_ruby_IBM_DB_TRACE_ERROR_BUFFER[need]);
|
2050
|
+
memset(_ruby_IBM_DB_TRACE_ERROR_BUFFER,0,IBM_DB_TRACE_ERROR_BUFFER_MAX+1);
|
2051
|
+
strcpy(_ruby_IBM_DB_TRACE_ERROR_BUFFER,tmp);
|
2052
|
+
}
|
2053
|
+
strcat(_ruby_IBM_DB_TRACE_ERROR_BUFFER,bigbuff);
|
2054
|
+
_ruby_IBM_DB_TRACE_ERROR_BUFFER[IBM_DB_TRACE_ERROR_BUFFER_MAX] = '\0';
|
2055
|
+
}
|
2056
|
+
static void _ruby_ibm_db_trace_hexdump(void *string, unsigned int len) {
|
2057
|
+
char charbuf[17];
|
2058
|
+
char c0, c1;
|
2059
|
+
char *p = (char*)string;
|
2060
|
+
char *end;
|
2061
|
+
unsigned int i;
|
2062
|
+
|
2063
|
+
/* dump less */
|
2064
|
+
if (_ruby_IBM_DB_TRACE_ERROR == 1) {
|
2065
|
+
if (len > 64) {
|
2066
|
+
len = 64;
|
2067
|
+
}
|
2068
|
+
} else {
|
2069
|
+
if (len > 512) {
|
2070
|
+
len = 512;
|
2071
|
+
}
|
2072
|
+
}
|
2073
|
+
|
2074
|
+
end = p + len;
|
2075
|
+
for (i = 0; p < end ; ++p, ++i)
|
2076
|
+
{
|
2077
|
+
if ((i & 3) == 0)
|
2078
|
+
_ruby_ibm_db_console(" ");
|
2079
|
+
if ((i & 7) == 0)
|
2080
|
+
_ruby_ibm_db_console(" ");
|
2081
|
+
if ((i & 15) == 0)
|
2082
|
+
{
|
2083
|
+
if (i > 0)
|
2084
|
+
{
|
2085
|
+
charbuf[16] = 0;
|
2086
|
+
_ruby_ibm_db_console(">%s<", charbuf);
|
2087
|
+
}
|
2088
|
+
_ruby_ibm_db_console("\n %08x : ", p);
|
2089
|
+
}
|
2090
|
+
|
2091
|
+
charbuf[i & 15] = (isgraph(*p)? *p: '.');
|
2092
|
+
c0 = '0' + ((unsigned char)*p >> 4);
|
2093
|
+
if (c0 > '9')
|
2094
|
+
c0 = c0 - '9' + 'a' - 1;
|
2095
|
+
|
2096
|
+
c1 = '0' + (*p & 0x0f);
|
2097
|
+
if (c1 > '9')
|
2098
|
+
c1 = c1 - '9' + 'a' - 1;
|
2099
|
+
|
2100
|
+
_ruby_ibm_db_console("%c%c", c0, c1);
|
2101
|
+
}
|
2102
|
+
|
2103
|
+
for (; (i & 15) != 0; ++i)
|
2104
|
+
{
|
2105
|
+
if ((i & 3) == 0)
|
2106
|
+
_ruby_ibm_db_console(" ");
|
2107
|
+
if ((i & 7) == 0)
|
2108
|
+
_ruby_ibm_db_console(" ");
|
2109
|
+
charbuf[i & 15] = 0;
|
2110
|
+
_ruby_ibm_db_console(" ");
|
2111
|
+
}
|
2112
|
+
|
2113
|
+
charbuf[16] = 0;
|
2114
|
+
_ruby_ibm_db_console(" >%s<\n", charbuf);
|
2115
|
+
}
|
2116
|
+
static void _ruby_ibm_db_trace_addr(void * addr) {
|
2117
|
+
_ruby_ibm_db_console(" %x\n",addr);
|
2118
|
+
}
|
2119
|
+
static void _ruby_ibm_db_trace_bin_hex(int data) {
|
2120
|
+
_ruby_ibm_db_console(" %d (%x)\n",data,data);
|
2121
|
+
}
|
2122
|
+
static void _ruby_ibm_db_trace_sql_type(int column_type) {
|
2123
|
+
_ruby_ibm_db_console(" ");
|
2124
|
+
switch(column_type) {
|
2125
|
+
case SQL_CHAR:
|
2126
|
+
_ruby_ibm_db_console("SQL_CHAR");
|
2127
|
+
break;
|
2128
|
+
case SQL_WCHAR:
|
2129
|
+
_ruby_ibm_db_console("SQL_WCHAR");
|
2130
|
+
break;
|
2131
|
+
case SQL_VARCHAR:
|
2132
|
+
_ruby_ibm_db_console("SQL_VARCHAR");
|
2133
|
+
break;
|
2134
|
+
case SQL_WVARCHAR:
|
2135
|
+
_ruby_ibm_db_console("SQL_WVARCHAR");
|
2136
|
+
break;
|
2137
|
+
case SQL_GRAPHIC:
|
2138
|
+
_ruby_ibm_db_console("SQL_GRAPHIC");
|
2139
|
+
break;
|
2140
|
+
case SQL_VARGRAPHIC:
|
2141
|
+
_ruby_ibm_db_console("SQL_VARGRAPHIC");
|
2142
|
+
break;
|
2143
|
+
#ifndef PASE /* IBM i SQL_LONGVARCHAR is SQL_VARCHAR */
|
2144
|
+
case SQL_LONGVARCHAR:
|
2145
|
+
_ruby_ibm_db_console("SQL_LONGVARCHAR");
|
2146
|
+
break;
|
2147
|
+
case SQL_WLONGVARCHAR:
|
2148
|
+
_ruby_ibm_db_console("SQL_WLONGVARCHAR");
|
2149
|
+
break;
|
2150
|
+
#endif /* PASE */
|
2151
|
+
case SQL_BINARY:
|
2152
|
+
_ruby_ibm_db_console("SQL_BINARY");
|
2153
|
+
break;
|
2154
|
+
#ifndef PASE /* IBM i SQL_LONGVARBINARY is SQL_VARBINARY */
|
2155
|
+
case SQL_LONGVARBINARY:
|
2156
|
+
_ruby_ibm_db_console("SQL_LONGVARBINARY");
|
2157
|
+
break;
|
2158
|
+
#endif /* PASE */
|
2159
|
+
case SQL_VARBINARY:
|
2160
|
+
_ruby_ibm_db_console("SQL_VARBINARY");
|
2161
|
+
break;
|
2162
|
+
case SQL_TYPE_DATE:
|
2163
|
+
_ruby_ibm_db_console("SQL_TYPE_DATE");
|
2164
|
+
break;
|
2165
|
+
case SQL_TYPE_TIME:
|
2166
|
+
_ruby_ibm_db_console("SQL_TYPE_TIME");
|
2167
|
+
break;
|
2168
|
+
case SQL_TYPE_TIMESTAMP:
|
2169
|
+
_ruby_ibm_db_console("SQL_TYPE_TIMESTAMP");
|
2170
|
+
break;
|
2171
|
+
case SQL_BIGINT:
|
2172
|
+
_ruby_ibm_db_console("SQL_BIGINT");
|
2173
|
+
break;
|
2174
|
+
case SQL_DECFLOAT:
|
2175
|
+
_ruby_ibm_db_console("SQL_DECFLOAT");
|
2176
|
+
break;
|
2177
|
+
case SQL_SMALLINT:
|
2178
|
+
_ruby_ibm_db_console("SQL_SMALLINT");
|
2179
|
+
break;
|
2180
|
+
case SQL_INTEGER:
|
2181
|
+
_ruby_ibm_db_console("SQL_INTEGER");
|
2182
|
+
break;
|
2183
|
+
case SQL_REAL:
|
2184
|
+
_ruby_ibm_db_console("SQL_REAL");
|
2185
|
+
break;
|
2186
|
+
case SQL_FLOAT:
|
2187
|
+
_ruby_ibm_db_console("SQL_FLOAT");
|
2188
|
+
break;
|
2189
|
+
case SQL_DOUBLE:
|
2190
|
+
_ruby_ibm_db_console("SQL_DOUBLE");
|
2191
|
+
break;
|
2192
|
+
case SQL_DECIMAL:
|
2193
|
+
_ruby_ibm_db_console("SQL_DECIMAL");
|
2194
|
+
break;
|
2195
|
+
case SQL_NUMERIC:
|
2196
|
+
_ruby_ibm_db_console("SQL_NUMERIC");
|
2197
|
+
break;
|
2198
|
+
case SQL_CLOB:
|
2199
|
+
_ruby_ibm_db_console("SQL_CLOB");
|
2200
|
+
break;
|
2201
|
+
case SQL_DBCLOB:
|
2202
|
+
_ruby_ibm_db_console("SQL_DBCLOB");
|
2203
|
+
break;
|
2204
|
+
case SQL_BLOB:
|
2205
|
+
_ruby_ibm_db_console("SQL_BLOB");
|
2206
|
+
break;
|
2207
|
+
case SQL_XML:
|
2208
|
+
_ruby_ibm_db_console("SQL_XML");
|
2209
|
+
break;
|
2210
|
+
case SQL_BLOB_LOCATOR:
|
2211
|
+
_ruby_ibm_db_console("SQL_BLOB_LOCATOR");
|
2212
|
+
break;
|
2213
|
+
case SQL_CLOB_LOCATOR:
|
2214
|
+
_ruby_ibm_db_console("SQL_CLOB_LOCATOR");
|
2215
|
+
break;
|
2216
|
+
case SQL_DBCLOB_LOCATOR:
|
2217
|
+
_ruby_ibm_db_console("SQL_DBCLOB_LOCATOR");
|
2218
|
+
break;
|
2219
|
+
case SQL_C_DEFAULT:
|
2220
|
+
_ruby_ibm_db_console("SQL_C_DEFAULT");
|
2221
|
+
break;
|
2222
|
+
default:
|
2223
|
+
_ruby_ibm_db_console("UNKNOWN");
|
2224
|
+
break;
|
2225
|
+
}
|
2226
|
+
_ruby_ibm_db_trace_bin_hex(column_type);
|
2227
|
+
}
|
2228
|
+
static void _ruby_ibm_db_trace_verbose(char * errhead, void *string, unsigned int len, int rc) {
|
2229
|
+
exec_cum_prepare_args *prepexec = (exec_cum_prepare_args *) string;
|
2230
|
+
get_diagRec_args *diagrec = (get_diagRec_args *) string;
|
2231
|
+
get_data_args *getdata = (get_data_args *) string;
|
2232
|
+
get_subString_args *subdata = (get_subString_args *) string;
|
2233
|
+
describecol_args *describecol = (describecol_args *) string;
|
2234
|
+
bind_col_args *bindcol = (bind_col_args *) string;
|
2235
|
+
bind_parameter_args *bindparm = (bind_parameter_args *) string;
|
2236
|
+
describeparam_args *describeparm = (describeparam_args *) string;
|
2237
|
+
set_handle_attr_args *setattr = (set_handle_attr_args*) string;
|
2238
|
+
get_handle_attr_args *getattr = (get_handle_attr_args *) string;
|
2239
|
+
int max = 128;
|
2240
|
+
int i = 0;
|
2241
|
+
|
2242
|
+
_ruby_ibm_db_check_env_vars();
|
2243
|
+
|
2244
|
+
if (_ruby_IBM_DB_TRACE < 1) return;
|
2245
|
+
|
2246
|
+
if (!string || len < 1) return;
|
2247
|
+
|
2248
|
+
_ruby_ibm_db_console(" %s = %d\n",errhead,rc);
|
2249
|
+
|
2250
|
+
|
2251
|
+
/* special output */
|
2252
|
+
if (!strcmp(errhead,"SQLBindParameter")) {
|
2253
|
+
_ruby_ibm_db_console(" bindparm nbr =");
|
2254
|
+
_ruby_ibm_db_trace_bin_hex(bindparm->param_num);
|
2255
|
+
_ruby_ibm_db_console(" bindparm iotype =");
|
2256
|
+
_ruby_ibm_db_trace_sql_type(bindparm->IOType);
|
2257
|
+
_ruby_ibm_db_console(" bindparm valuetype =");
|
2258
|
+
_ruby_ibm_db_trace_sql_type(bindparm->valueType);
|
2259
|
+
_ruby_ibm_db_console(" bindparm paramtype =");
|
2260
|
+
_ruby_ibm_db_trace_sql_type(bindparm->paramType);
|
2261
|
+
_ruby_ibm_db_console(" bindparm colsize =");
|
2262
|
+
_ruby_ibm_db_trace_bin_hex(bindparm->colSize);
|
2263
|
+
_ruby_ibm_db_console(" bindparm scale =");
|
2264
|
+
_ruby_ibm_db_trace_bin_hex(bindparm->decimalDigits);
|
2265
|
+
_ruby_ibm_db_console(" bindparm buff =");
|
2266
|
+
_ruby_ibm_db_trace_addr(bindparm->paramValPtr);
|
2267
|
+
_ruby_ibm_db_console(" bindparm buff_len =");
|
2268
|
+
_ruby_ibm_db_trace_bin_hex(bindparm->buff_length);
|
2269
|
+
_ruby_ibm_db_console(" bindparm out_len =");
|
2270
|
+
_ruby_ibm_db_trace_addr(bindparm->out_length);
|
2271
|
+
}
|
2272
|
+
else if (!strcmp(errhead,"SQLBindCol")) {
|
2273
|
+
_ruby_ibm_db_console(" bindcol nbr =");
|
2274
|
+
_ruby_ibm_db_trace_bin_hex(bindcol->col_num);
|
2275
|
+
_ruby_ibm_db_console(" bindcol type =");
|
2276
|
+
_ruby_ibm_db_trace_sql_type(bindcol->TargetType);
|
2277
|
+
_ruby_ibm_db_console(" bindcol buff =");
|
2278
|
+
_ruby_ibm_db_trace_addr(bindcol->TargetValuePtr);
|
2279
|
+
_ruby_ibm_db_console(" bindcol buff_len =");
|
2280
|
+
_ruby_ibm_db_trace_bin_hex(bindcol->buff_length);
|
2281
|
+
_ruby_ibm_db_console(" bindcol out_len =");
|
2282
|
+
_ruby_ibm_db_trace_addr(bindcol->out_length);
|
2283
|
+
}
|
2284
|
+
else if (!strcmp(errhead,"SQLDescribeParam")) {
|
2285
|
+
_ruby_ibm_db_console(" parm nbr =");
|
2286
|
+
_ruby_ibm_db_trace_bin_hex(describeparm->param_no);
|
2287
|
+
_ruby_ibm_db_console(" parm type =");
|
2288
|
+
_ruby_ibm_db_trace_sql_type(describeparm->sql_data_type);
|
2289
|
+
_ruby_ibm_db_console(" parm size =");
|
2290
|
+
_ruby_ibm_db_trace_bin_hex(describeparm->sql_precision);
|
2291
|
+
_ruby_ibm_db_console(" parm scale =");
|
2292
|
+
_ruby_ibm_db_trace_bin_hex(describeparm->sql_scale);
|
2293
|
+
_ruby_ibm_db_console(" parm nullable =");
|
2294
|
+
_ruby_ibm_db_trace_bin_hex(describeparm->sql_nullable);
|
2295
|
+
}
|
2296
|
+
else if (!strcmp(errhead,"SQLDescribeCol")) {
|
2297
|
+
i = describecol->col_no - 1;
|
2298
|
+
if (describecol->name_length > 0) {
|
2299
|
+
if (max > describecol->name_length) {
|
2300
|
+
max = describecol->name_length;
|
2301
|
+
_ruby_ibm_db_console(" col name");
|
2302
|
+
}
|
2303
|
+
else {
|
2304
|
+
_ruby_ibm_db_console(" col name...");
|
2305
|
+
}
|
2306
|
+
_ruby_ibm_db_trace_hexdump(describecol->stmt_res->column_info[i].name, max);
|
2307
|
+
}
|
2308
|
+
_ruby_ibm_db_console(" col nbr =");
|
2309
|
+
_ruby_ibm_db_trace_bin_hex(describecol->col_no);
|
2310
|
+
_ruby_ibm_db_console(" col type =");
|
2311
|
+
_ruby_ibm_db_trace_sql_type(describecol->stmt_res->column_info[i].type);
|
2312
|
+
_ruby_ibm_db_console(" col size =");
|
2313
|
+
_ruby_ibm_db_trace_bin_hex(describecol->stmt_res->column_info[i].size);
|
2314
|
+
_ruby_ibm_db_console(" col scale =");
|
2315
|
+
_ruby_ibm_db_trace_bin_hex(describecol->stmt_res->column_info[i].scale);
|
2316
|
+
_ruby_ibm_db_console(" col nullable =");
|
2317
|
+
_ruby_ibm_db_trace_bin_hex(describecol->stmt_res->column_info[i].nullable);
|
2318
|
+
}
|
2319
|
+
else if (!strcmp(errhead,"SQLGetData")) {
|
2320
|
+
_ruby_ibm_db_console(" nbr =");
|
2321
|
+
_ruby_ibm_db_trace_bin_hex(getdata->col_num);
|
2322
|
+
_ruby_ibm_db_console(" type =");
|
2323
|
+
_ruby_ibm_db_trace_sql_type(getdata->targetType);
|
2324
|
+
_ruby_ibm_db_console(" buf len =");
|
2325
|
+
_ruby_ibm_db_trace_bin_hex(getdata->buff_length);
|
2326
|
+
if (getdata->out_length && *getdata->out_length == SQL_NULL_DATA) {
|
2327
|
+
_ruby_ibm_db_console(" buff is SQL_NULL_DATA\n");
|
2328
|
+
}
|
2329
|
+
else if (getdata->out_length && *getdata->out_length > 0) {
|
2330
|
+
_ruby_ibm_db_console(" out len =");
|
2331
|
+
_ruby_ibm_db_trace_bin_hex(*getdata->out_length);
|
2332
|
+
if (max > *getdata->out_length) {
|
2333
|
+
max = *getdata->out_length;
|
2334
|
+
_ruby_ibm_db_console(" buff");
|
2335
|
+
}
|
2336
|
+
else {
|
2337
|
+
_ruby_ibm_db_console(" buff...");
|
2338
|
+
}
|
2339
|
+
_ruby_ibm_db_trace_hexdump(getdata->buff, max);
|
2340
|
+
}
|
2341
|
+
}
|
2342
|
+
else if (!strcmp(errhead,"SQLGetSubString")) {
|
2343
|
+
_ruby_ibm_db_console(" nbr =");
|
2344
|
+
_ruby_ibm_db_trace_bin_hex(subdata->col_num);
|
2345
|
+
_ruby_ibm_db_console(" c type =");
|
2346
|
+
_ruby_ibm_db_trace_sql_type(subdata->targetCType);
|
2347
|
+
_ruby_ibm_db_console(" for len =");
|
2348
|
+
_ruby_ibm_db_trace_bin_hex(subdata->forLength);
|
2349
|
+
_ruby_ibm_db_console(" buf len =");
|
2350
|
+
_ruby_ibm_db_trace_bin_hex(subdata->buff_length);
|
2351
|
+
if (subdata->out_length && *subdata->out_length > 0) {
|
2352
|
+
if (max > *subdata->out_length) {
|
2353
|
+
max = *subdata->out_length;
|
2354
|
+
_ruby_ibm_db_console(" buff");
|
2355
|
+
}
|
2356
|
+
else {
|
2357
|
+
_ruby_ibm_db_console(" buff...");
|
2358
|
+
}
|
2359
|
+
_ruby_ibm_db_trace_hexdump(subdata->buffer, max);
|
2360
|
+
}
|
2361
|
+
}
|
2362
|
+
else if (!strcmp(errhead,"SQLGetDiagRec")) {
|
2363
|
+
if (diagrec->SQLState) {
|
2364
|
+
_ruby_ibm_db_console(" state");
|
2365
|
+
_ruby_ibm_db_trace_hexdump(diagrec->SQLState, 5);
|
2366
|
+
}
|
2367
|
+
if (diagrec->NativeErrorPtr) {
|
2368
|
+
_ruby_ibm_db_console(" code");
|
2369
|
+
_ruby_ibm_db_trace_hexdump(diagrec->NativeErrorPtr, sizeof(SQLINTEGER));
|
2370
|
+
}
|
2371
|
+
if (diagrec->msgText && diagrec->text_length_ptr && *diagrec->text_length_ptr > 0) {
|
2372
|
+
if (max > *diagrec->text_length_ptr) {
|
2373
|
+
max = *diagrec->text_length_ptr;
|
2374
|
+
_ruby_ibm_db_console(" message");
|
2375
|
+
}
|
2376
|
+
else {
|
2377
|
+
_ruby_ibm_db_console(" message...");
|
2378
|
+
}
|
2379
|
+
_ruby_ibm_db_trace_hexdump(diagrec->msgText, *diagrec->text_length_ptr);
|
2380
|
+
}
|
2381
|
+
if (_ruby_IBM_DB_STOP > 0) exit(-999);
|
2382
|
+
}
|
2383
|
+
else if (!strcmp(errhead,"SQLPrepare")) {
|
2384
|
+
if (prepexec->stmt_string && prepexec->stmt_string_len > 0) {
|
2385
|
+
_ruby_ibm_db_console(" prepare");
|
2386
|
+
_ruby_ibm_db_trace_hexdump(prepexec->stmt_string, prepexec->stmt_string_len);
|
2387
|
+
}
|
2388
|
+
}
|
2389
|
+
else if (!strcmp(errhead,"SQLExecDirect")) {
|
2390
|
+
if (prepexec->stmt_string && prepexec->stmt_string_len > 0) {
|
2391
|
+
_ruby_ibm_db_console(" exec");
|
2392
|
+
_ruby_ibm_db_trace_hexdump(prepexec->stmt_string, prepexec->stmt_string_len);
|
2393
|
+
}
|
2394
|
+
}
|
2395
|
+
else if (!strcmp(errhead,"SQLGetEnvAttr") || !strcmp(errhead,"SQLGetConnectAttr") || !strcmp(errhead,"SQLGetStmtAttr")) {
|
2396
|
+
_ruby_ibm_db_console(" attr =");
|
2397
|
+
_ruby_ibm_db_trace_bin_hex(getattr->attribute);
|
2398
|
+
if (getattr->buff_length < 1) {
|
2399
|
+
#ifndef PASE
|
2400
|
+
_ruby_ibm_db_console(" value =");
|
2401
|
+
_ruby_ibm_db_trace_bin_hex((int)getattr->valuePtr);
|
2402
|
+
#else /* PASE */
|
2403
|
+
_ruby_ibm_db_console(" value =");
|
2404
|
+
_ruby_ibm_db_trace_bin_hex(*(int*)getattr->valuePtr);
|
2405
|
+
#endif /* PASE */
|
2406
|
+
}
|
2407
|
+
else {
|
2408
|
+
if (max > getattr->buff_length) {
|
2409
|
+
max = getattr->buff_length;
|
2410
|
+
}
|
2411
|
+
_ruby_ibm_db_console(" value");
|
2412
|
+
_ruby_ibm_db_trace_hexdump(getattr->valuePtr, max);
|
2413
|
+
}
|
2414
|
+
}
|
2415
|
+
else if (!strcmp(errhead,"SQLSetEnvAttr") || !strcmp(errhead,"SQLSetConnectAttr") || !strcmp(errhead,"SQLSetStmtAttr")) {
|
2416
|
+
_ruby_ibm_db_console(" attr =");
|
2417
|
+
_ruby_ibm_db_trace_bin_hex(setattr->attribute);
|
2418
|
+
if (setattr->strLength < 1) {
|
2419
|
+
#ifndef PASE
|
2420
|
+
_ruby_ibm_db_console(" value =");
|
2421
|
+
_ruby_ibm_db_trace_bin_hex((int)setattr->valuePtr);
|
2422
|
+
#else /* PASE */
|
2423
|
+
_ruby_ibm_db_console(" value =");
|
2424
|
+
_ruby_ibm_db_trace_bin_hex(*(int*)setattr->valuePtr);
|
2425
|
+
#endif /* PASE */
|
2426
|
+
}
|
2427
|
+
else {
|
2428
|
+
if (max > setattr->strLength) {
|
2429
|
+
max = setattr->strLength;
|
2430
|
+
}
|
2431
|
+
_ruby_ibm_db_console(" value");
|
2432
|
+
_ruby_ibm_db_trace_hexdump(setattr->valuePtr, max);
|
2433
|
+
}
|
2434
|
+
}
|
2435
|
+
}
|
2436
|
+
static void _ruby_ibm_db_trace_output(char * errhead, void *string, unsigned int len) {
|
2437
|
+
_ruby_ibm_db_check_env_vars();
|
2438
|
+
|
2439
|
+
if (_ruby_IBM_DB_TRACE < 1) return;
|
2440
|
+
|
2441
|
+
_ruby_ibm_db_console("%s\n","-------------");
|
2442
|
+
#ifdef UNICODE_SUPPORT_VERSION
|
2443
|
+
#ifdef UTF8_OVERRIDE_VERSION
|
2444
|
+
_ruby_ibm_db_console("%s (utf-8 non-wide)",errhead);
|
2445
|
+
#else
|
2446
|
+
_ruby_ibm_db_console("%s (utf-16 wide)",errhead);
|
2447
|
+
#endif
|
2448
|
+
#else
|
2449
|
+
_ruby_ibm_db_console("%s (non-wide)",errhead);
|
2450
|
+
#endif
|
2451
|
+
_ruby_ibm_db_trace_hexdump(string, len);
|
2452
|
+
}
|
2453
|
+
|