sqlanywhere 0.1.4 → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  //====================================================
2
2
  //
3
- // Copyright 2008-2009 iAnywhere Solutions, Inc.
3
+ // Copyright 2008-2010 iAnywhere Solutions, Inc.
4
4
  //
5
5
  // Licensed under the Apache License, Version 2.0 (the "License");
6
6
  // you may not use this file except in compliance with the License.
@@ -82,6 +82,9 @@ void * findSymbol( void * dll_handle, char * name )
82
82
  #endif
83
83
  }
84
84
 
85
+ #define LookupSymbol( api, sym ) \
86
+ api->sym = (sym ## _func)findSymbol( api->dll_handle, #sym );
87
+
85
88
  #define LookupSymbolAndCheck( api, sym ) \
86
89
  api->sym = (sym ## _func)findSymbol( api->dll_handle, #sym ); \
87
90
  if( api->sym == NULL ) { \
@@ -149,6 +152,18 @@ loaded:
149
152
  LookupSymbolAndCheck( api, sqlany_error );
150
153
  LookupSymbolAndCheck( api, sqlany_sqlstate );
151
154
  LookupSymbolAndCheck( api, sqlany_clear_error );
155
+
156
+ #if _SACAPI_VERSION+0 >= 2
157
+ /* We don't report an error if we don't find the v2 entry points.
158
+ That allows the calling app to revert to v1 */
159
+ LookupSymbol( api, sqlany_init_ex );
160
+ LookupSymbol( api, sqlany_fini_ex );
161
+ LookupSymbol( api, sqlany_new_connection_ex );
162
+ LookupSymbol( api, sqlany_make_connection_ex );
163
+ LookupSymbol( api, sqlany_client_version_ex );
164
+ LookupSymbolAndCheck( api, sqlany_cancel );
165
+ #endif
166
+
152
167
  api->initialized = 1;
153
168
  return 1;
154
169
  }
@@ -1,6 +1,6 @@
1
1
  /* ====================================================
2
2
  *
3
- * Copyright 2008-2009 iAnywhere Solutions, Inc.
3
+ * Copyright 2008-2010 iAnywhere Solutions, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -70,15 +70,29 @@ typedef sacapi_bool (*sqlany_client_version_func)( char * buffer, size_t len );
70
70
  typedef sacapi_i32 (*sqlany_error_func)( a_sqlany_connection * sqlany_conn, char * buffer, size_t size );
71
71
  typedef size_t (*sqlany_sqlstate_func)( a_sqlany_connection * sqlany_conn, char * buffer, size_t size );
72
72
  typedef void (*sqlany_clear_error_func)( a_sqlany_connection * sqlany_conn );
73
+ #if _SACAPI_VERSION+0 >= 2
74
+ typedef a_sqlany_interface_context *(*sqlany_init_ex_func)( const char *app_name, sacapi_u32 api_version, sacapi_u32 *max_version );
75
+ typedef void (*sqlany_fini_ex_func)( a_sqlany_interface_context *context );
76
+ typedef a_sqlany_connection *(*sqlany_new_connection_ex_func)( a_sqlany_interface_context *context );
77
+ typedef a_sqlany_connection *(*sqlany_make_connection_ex_func)( a_sqlany_interface_context *context, void *arg );
78
+ typedef sacapi_bool (*sqlany_client_version_ex_func)( a_sqlany_interface_context *context, char *buffer, size_t len );
79
+ typedef void (*sqlany_cancel_func)( a_sqlany_connection * sqlany_conn );
80
+ #endif
73
81
 
74
82
  #if defined( __cplusplus )
75
83
  }
76
84
  #endif
77
85
 
86
+ /// @internal
78
87
  #define function( x ) x ## _func x
79
- /** An API interface structure.
80
- * The user would need only one instance of this in their environment. When the
81
- * instance is initialized, the DLL will be loaded and all the entry points will be looked up.
88
+
89
+ /** The SQL Anywhere C API interface structure.
90
+ *
91
+ * Only one instance of this structure is required in your application environment. This structure
92
+ * is initialized by the sqlany_initialize_interface method. It attempts to load the SQL Anywhere C
93
+ * API DLL or shared object dynamically and looks up all the entry points of the DLL. The fields in
94
+ * the SQLAnywhereInterface structure is populated to point to the corresponding functions in the DLL.
95
+ * \sa sqlany_initialize_interface()
82
96
  */
83
97
  typedef struct SQLAnywhereInterface {
84
98
  /** DLL handle.
@@ -225,26 +239,91 @@ typedef struct SQLAnywhereInterface {
225
239
  */
226
240
  function( sqlany_clear_error );
227
241
 
242
+ #if _SACAPI_VERSION+0 >= 2
243
+ /** Pointer to ::sqlany_init_ex() function.
244
+ */
245
+ function( sqlany_init_ex );
246
+
247
+ /** Pointer to ::sqlany_fini_ex() function.
248
+ */
249
+ function( sqlany_fini_ex );
250
+
251
+ /** Pointer to ::sqlany_new_connection_ex() function.
252
+ */
253
+ function( sqlany_new_connection_ex );
254
+
255
+ /** Pointer to ::sqlany_make_connection_ex() function.
256
+ */
257
+ function( sqlany_make_connection_ex );
258
+
259
+ /** Pointer to ::sqlany_client_version_ex() function.
260
+ */
261
+ function( sqlany_client_version_ex );
262
+
263
+ /** Pointer to ::sqlany_cancel() function.
264
+ */
265
+ function( sqlany_cancel );
266
+ #endif
267
+
228
268
  } SQLAnywhereInterface;
229
269
  #undef function
230
270
 
231
271
  /** Initializes the SQLAnywhereInterface object and loads the DLL dynamically.
272
+ *
273
+ * Use the following statement to include the function prototype:
274
+ *
275
+ * <pre>
276
+ * \#include "sacapidll.h"
277
+ * </pre>
278
+ *
232
279
  * This function attempts to load the SQL Anywhere C API DLL dynamically and looks up all
233
- * the entry points of the DLL. The fields in the SQLAnywhereInterface structure will be
280
+ * the entry points of the DLL. The fields in the SQLAnywhereInterface structure are
234
281
  * populated to point to the corresponding functions in the DLL. If the optional path argument
235
- * is NULL, the environment variable SQLANY_DLL_PATH will be checked. If the variable is set,
236
- * the library will attempt to load the DLL specified by the environment variable. If that fails,
237
- * the interface will attempt to load the DLL directly (this relies on the environment being
282
+ * is NULL, the environment variable SQLANY_DLL_PATH is checked. If the variable is set,
283
+ * the library attempts to load the DLL specified by the environment variable. If that fails,
284
+ * the interface attempts to load the DLL directly (this relies on the environment being
238
285
  * setup correctly).
286
+ *
287
+ * To view examples of the sqlany_initialize_interface method in use, see the following topics:
288
+ *
289
+ * <ul>
290
+ * <li>\salink{connecting.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-connecting-cpp.html", "programming", "pg-c-api-connecting-cpp"}
291
+ * <li>\salink{dbcapi_isql.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-dbcapi-isql-cpp.html", "programming", "pg-c-api-dbcapi-isql-cpp"}
292
+ * <li>\salink{fetching_a_result_set.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-fetching-a-result-set-cpp.html", "programming", "pg-c-api-fetching-a-result-set-cpp"}
293
+ * <li>\salink{fetching_multiple_from_sp.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-fetching-multiple-from-sp-cpp.html", "programming", "pg-c-api-fetching-multiple-from-sp-cpp"}
294
+ * <li>\salink{preparing_statements.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-preparing-statements-cpp.html", "programming", "pg-c-api-preparing-statements-cpp"}
295
+ * <li>\salink{send_retrieve_full_blob.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-send-retrieve-full-blob-cpp.html", "programming", "pg-c-api-send-retrieve-full-blob-cpp"}
296
+ * <li>\salink{send_retrieve_part_blob.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-send-retrieve-part-blob-cpp.html", "programming", "pg-c-api-send-retrieve-part-blob-cpp"}
297
+ * </ul>
298
+ *
239
299
  * \param api An API structure to initialize.
240
- * \param optional_path_to_dll An optional argument that specifies a path to the DLL API to load.
300
+ * \param optional_path_to_dll An optional argument that specifies a path to the SQL Anywhere C API DLL.
241
301
  * \return 1 on successful initialization, and 0 on failure.
242
302
  */
243
303
  int sqlany_initialize_interface( SQLAnywhereInterface * api, const char * optional_path_to_dll );
244
304
 
245
- /** Finalize and free resources associated with the SQL Anywhere C API DLL.
246
- * This function will unload the library and uninitialize the supplied SQLAnywhereInterface
247
- * structure.
305
+ /** Unloads the C API DLL library and uninitializes the SQLAnywhereInterface structure.
306
+ *
307
+ * Use the following statement to include the function prototype:
308
+ *
309
+ * <pre>
310
+ * \#include "sacapidll.h"
311
+ * </pre>
312
+ *
313
+ * Use this method to finalize and free resources associated with the SQL Anywhere C API DLL.
314
+ *
315
+ * To view examples of the sqlany_finalize_interface method in use, see the following topics:
316
+ *
317
+ * <ul>
318
+ * <li>\salink{connecting.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-connecting-cpp.html", "programming", "pg-c-api-connecting-cpp"}
319
+ * <li>\salink{dbcapi_isql.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-dbcapi-isql-cpp.html", "programming", "pg-c-api-dbcapi-isql-cpp"}
320
+ * <li>\salink{fetching_a_result_set.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-fetching-a-result-set-cpp.html", "programming", "pg-c-api-fetching-a-result-set-cpp"}
321
+ * <li>\salink{fetching_multiple_from_sp.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-fetching-multiple-from-sp-cpp.html", "programming", "pg-c-api-fetching-multiple-from-sp-cpp"}
322
+ * <li>\salink{preparing_statements.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-preparing-statements-cpp.html", "programming", "pg-c-api-preparing-statements-cpp"}
323
+ * <li>\salink{send_retrieve_full_blob.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-send-retrieve-full-blob-cpp.html", "programming", "pg-c-api-send-retrieve-full-blob-cpp"}
324
+ * <li>\salink{send_retrieve_part_blob.cpp, "http://dcx.sybase.com/1200en/dbprogramming/pg-c-api-send-retrieve-part-blob-cpp.html", "programming", "pg-c-api-send-retrieve-part-blob-cpp"}
325
+ * </ul>
326
+ *
248
327
  * \param api An initialized structure to finalize.
249
328
  */
250
329
 
@@ -1,6 +1,6 @@
1
1
  /*====================================================
2
2
  *
3
- * Copyright 2008-2009 iAnywhere Solutions, Inc.
3
+ * Copyright 2008-2010 iAnywhere Solutions, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -22,9 +22,19 @@
22
22
  *
23
23
  *====================================================*/
24
24
  #include "ruby.h"
25
+
26
+ #define _SACAPI_VERSION 2
27
+
25
28
  #include "sacapidll.h"
26
29
 
27
- const char* VERSION = "0.1.4";
30
+ #define IS_SACAPI_V2(api) ((api.sqlany_init_ex) != NULL)
31
+
32
+ const char* VERSION = "0.1.6";
33
+
34
+ typedef struct imp_drh_st {
35
+ SQLAnywhereInterface api;
36
+ void *sacapi_context;
37
+ } imp_drh_st;
28
38
 
29
39
  // Defining the Ruby Modules
30
40
  static VALUE mSQLAnywhere;
@@ -45,10 +55,10 @@ void Init_sqlanywhere();
45
55
  // Wrapper functions for the DBICAPI functions
46
56
 
47
57
  static VALUE
48
- static_API_sqlany_initialize_interface(VALUE module, VALUE api);
58
+ static_API_sqlany_initialize_interface(VALUE module, VALUE imp_drh);
49
59
 
50
60
  static VALUE
51
- static_API_sqlany_finalize_interface(VALUE module, VALUE api);
61
+ static_API_sqlany_finalize_interface(VALUE module, VALUE imp_drh);
52
62
 
53
63
  static VALUE
54
64
  static_SQLAnywhereInterface_alloc(VALUE class);
@@ -60,64 +70,67 @@ static VALUE
60
70
  static_SQLAnywhereInterface_sqlany_new_connection(VALUE class);
61
71
 
62
72
  static VALUE
63
- static_SQLAnywhereInterface_sqlany_client_version(VALUE api);
73
+ static_SQLAnywhereInterface_sqlany_client_version(VALUE imp_drh);
64
74
 
65
75
  static VALUE
66
- static_SQLAnywhereInterface_sqlany_connect(VALUE api, VALUE sqlany_conn, VALUE str);
76
+ static_SQLAnywhereInterface_sqlany_connect(VALUE imp_drh, VALUE sqlany_conn, VALUE str);
67
77
 
68
78
  static VALUE
69
- static_SQLAnywhereInterface_sqlany_disconnect(VALUE api, VALUE sqlany_conn);
79
+ static_SQLAnywhereInterface_sqlany_disconnect(VALUE imp_drh, VALUE sqlany_conn);
70
80
 
71
81
  static VALUE
72
- static_SQLAnywhereInterface_sqlany_free_connection(VALUE api, VALUE sqlany_conn);
82
+ static_SQLAnywhereInterface_sqlany_free_connection(VALUE imp_drh, VALUE sqlany_conn);
73
83
 
74
84
  static VALUE
75
- static_SQLAnywhereInterface_sqlany_fini(VALUE api);
85
+ static_SQLAnywhereInterface_sqlany_fini(VALUE imp_drh);
76
86
 
77
87
  static VALUE
78
- static_SQLAnywhereInterface_sqlany_error(VALUE api, VALUE sqlany_conn);
88
+ static_SQLAnywhereInterface_sqlany_error(VALUE imp_drh, VALUE sqlany_conn);
79
89
 
80
90
  static VALUE
81
- static_SQLAnywhereInterface_sqlany_execute_immediate(VALUE api, VALUE sqlany_conn, VALUE sql);
91
+ static_SQLAnywhereInterface_sqlany_execute_immediate(VALUE imp_drh, VALUE sqlany_conn, VALUE sql);
82
92
 
83
93
  static VALUE
84
- static_SQLAnywhereInterface_sqlany_execute_direct(VALUE api, VALUE sqlany_conn, VALUE sql);
94
+ static_SQLAnywhereInterface_sqlany_execute_direct(VALUE imp_drh, VALUE sqlany_conn, VALUE sql);
85
95
 
86
96
  static VALUE
87
- static_SQLAnywhereInterface_sqlany_num_cols(VALUE api, VALUE sqlany_stmt);
97
+ static_SQLAnywhereInterface_sqlany_num_cols(VALUE imp_drh, VALUE sqlany_stmt);
88
98
 
89
99
  static VALUE
90
- static_SQLAnywhereInterface_sqlany_num_rows(VALUE api, VALUE sqlany_stmt);
100
+ static_SQLAnywhereInterface_sqlany_num_rows(VALUE imp_drh, VALUE sqlany_stmt);
91
101
 
92
102
  static VALUE
93
- static_SQLAnywhereInterface_sqlany_get_column(VALUE api, VALUE sqlany_stmt, VALUE col_num);
103
+ static_SQLAnywhereInterface_sqlany_get_column(VALUE imp_drh, VALUE sqlany_stmt, VALUE col_num);
94
104
 
95
105
  static VALUE
96
- static_SQLAnywhereInterface_sqlany_fetch_next(VALUE api, VALUE sqlany_stmt);
106
+ static_SQLAnywhereInterface_sqlany_fetch_next(VALUE imp_drh, VALUE sqlany_stmt);
97
107
 
98
108
  static VALUE
99
- static_SQLAnywhereInterface_sqlany_get_column_info(VALUE api, VALUE sqlany_stmt, VALUE col_num);
109
+ static_SQLAnywhereInterface_sqlany_get_column_info(VALUE imp_drh, VALUE sqlany_stmt, VALUE col_num);
100
110
 
101
111
  static VALUE
102
- static_SQLAnywhereInterface_sqlany_commit(VALUE api, VALUE sqlany_conn);
112
+ static_SQLAnywhereInterface_sqlany_commit(VALUE imp_drh, VALUE sqlany_conn);
103
113
 
104
114
  static VALUE
105
- static_SQLAnywhereInterface_sqlany_rollback(VALUE api, VALUE sqlany_conn);
115
+ static_SQLAnywhereInterface_sqlany_rollback(VALUE imp_drh, VALUE sqlany_conn);
106
116
 
107
117
  static VALUE
108
- static_SQLAnywhereInterface_sqlany_prepare(VALUE api, VALUE sqlany_conn, VALUE sql);
118
+ static_SQLAnywhereInterface_sqlany_prepare(VALUE imp_drh, VALUE sqlany_conn, VALUE sql);
109
119
 
110
120
  static VALUE
111
- static_SQLAnywhereInterface_sqlany_free_stmt(VALUE api, VALUE sqlany_stmt);
121
+ static_SQLAnywhereInterface_sqlany_free_stmt(VALUE imp_drh, VALUE sqlany_stmt);
112
122
 
113
123
  static VALUE
114
- static_SQLAnywhereInterface_sqlany_execute(VALUE api, VALUE sqlany_stmt);
124
+ static_SQLAnywhereInterface_sqlany_reset(VALUE imp_drh, VALUE sqlany_stmt);
115
125
 
116
126
  static VALUE
117
- static_SQLAnywhereInterface_sqlany_affected_rows(VALUE api, VALUE sqlany_stmt);
127
+ static_SQLAnywhereInterface_sqlany_execute(VALUE imp_drh, VALUE sqlany_stmt);
118
128
 
119
129
  static VALUE
120
- static_SQLAnywhereInterface_sqlany_describe_bind_param(VALUE api, VALUE sqlany_stmt, VALUE index);
130
+ static_SQLAnywhereInterface_sqlany_affected_rows(VALUE imp_drh, VALUE sqlany_stmt);
131
+
132
+ static VALUE
133
+ static_SQLAnywhereInterface_sqlany_describe_bind_param(VALUE imp_drh, VALUE sqlany_stmt, VALUE index);
121
134
 
122
135
  /*
123
136
  * C to Ruby Data conversion function to convert DBCAPI column type into the correct Ruby type
@@ -179,7 +192,7 @@ static VALUE C2RB(a_sqlany_data_value* value)
179
192
 
180
193
  /*
181
194
  * call-seq:
182
- * sqlany_initialize_interface(VALUE api) -> int result
195
+ * sqlany_initialize_interface(VALUE imp_drh) -> int result
183
196
  *
184
197
  * Initializes the SQLAnywhereInterface object and loads the DLL dynamically.
185
198
  *
@@ -187,28 +200,28 @@ static VALUE C2RB(a_sqlany_data_value* value)
187
200
  * looks up all the entry points of the DLL.
188
201
  *
189
202
  * <b>Parameters</b>:
190
- * - <tt>VALUE api</tt> -- An API structure to initialize.
203
+ * - <tt>VALUE imp_drh</tt> -- An API structure to initialize.
191
204
  *
192
205
  * <b>Returns</b>:
193
206
  * - <tt>result</tt>: <tt>1</tt> on successful initialization, <tt>0</tt> on failure.
194
207
  *
195
208
  */
196
209
  static VALUE
197
- static_API_sqlany_initialize_interface(VALUE module, VALUE api)
210
+ static_API_sqlany_initialize_interface(VALUE module, VALUE imp_drh)
198
211
  {
199
- SQLAnywhereInterface* s_api;
212
+ imp_drh_st* s_imp_drh;
200
213
  int result;
201
214
 
202
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
215
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
203
216
 
204
- result = sqlany_initialize_interface( s_api, NULL );
217
+ result = sqlany_initialize_interface( &(s_imp_drh->api), NULL );
205
218
 
206
219
  return( INT2NUM(result) );
207
220
  }
208
221
 
209
222
  /*
210
223
  * call-seq:
211
- * sqlany_finalize_interface(VALUE api) -> nil
224
+ * sqlany_finalize_interface(VALUE imp_drh) -> nil
212
225
  *
213
226
  * Finalize and free resources associated with the SQL Anywhere C API DLL.
214
227
  *
@@ -216,22 +229,22 @@ static_API_sqlany_initialize_interface(VALUE module, VALUE api)
216
229
  * SQLAnywhereInterface structure.
217
230
  *
218
231
  * <b>Parameters</b>:
219
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
232
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
220
233
  *
221
234
  * <b>Returns</b>:
222
235
  * - <tt>nil</tt>.
223
236
  *
224
237
  */
225
238
  static VALUE
226
- static_API_sqlany_finalize_interface(VALUE module, VALUE api)
239
+ static_API_sqlany_finalize_interface(VALUE module, VALUE imp_drh)
227
240
  {
228
- SQLAnywhereInterface* s_api;
241
+ imp_drh_st* s_imp_drh;
229
242
 
230
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
243
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
231
244
 
232
- sqlany_finalize_interface(s_api);
245
+ sqlany_finalize_interface(&(s_imp_drh->api));
233
246
 
234
- free(s_api);
247
+ free(&(s_imp_drh->api));
235
248
 
236
249
  return( Qnil );
237
250
  }
@@ -239,24 +252,24 @@ static_API_sqlany_finalize_interface(VALUE module, VALUE api)
239
252
  static VALUE
240
253
  static_SQLAnywhereInterface_alloc(VALUE class)
241
254
  {
242
- SQLAnywhereInterface *s_api = NULL;
255
+ imp_drh_st *imp_drh = NULL;
243
256
  VALUE tdata;
244
257
 
245
- s_api = malloc( sizeof(SQLAnywhereInterface) );
246
- memset( s_api, 0, sizeof(SQLAnywhereInterface));
258
+ imp_drh = malloc( sizeof(imp_drh_st) );
259
+ memset( imp_drh, 0, sizeof(imp_drh_st));
247
260
 
248
- tdata = Data_Wrap_Struct(class, 0, 0, s_api);
261
+ tdata = Data_Wrap_Struct(class, 0, 0, imp_drh);
249
262
  return tdata;
250
263
  }
251
264
 
252
265
  /*
253
266
  * call-seq:
254
- * sqlany_init(VALUE api) -> [VALUE result, VALUE version]
267
+ * sqlany_init(VALUE imp_drh) -> [VALUE result, VALUE version]
255
268
  *
256
269
  * Initializes the interface.
257
270
  *
258
271
  * <b>Parameters</b>:
259
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
272
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
260
273
  *
261
274
  * <b>Returns</b>:
262
275
  * - <tt>VALUE result</tt>: <tt>1</tt> on success, <tt>0</tt> on failure.
@@ -264,24 +277,36 @@ static_SQLAnywhereInterface_alloc(VALUE class)
264
277
  *
265
278
  */
266
279
  static VALUE
267
- static_SQLAnywhereInterface_sqlany_init(VALUE api)
280
+ static_SQLAnywhereInterface_sqlany_init(VALUE imp_drh)
268
281
  {
269
- SQLAnywhereInterface* s_api;
282
+ imp_drh_st* s_imp_drh;
270
283
  sacapi_bool result;
271
284
  sacapi_u32 s_version_available;
272
285
  VALUE multi_result;
273
286
 
274
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
287
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
275
288
 
276
289
  multi_result = rb_ary_new();
277
290
 
278
- if( s_api == NULL ) {
291
+ if( &(s_imp_drh->api) == NULL ) {
279
292
  rb_ary_push(multi_result, INT2NUM(0));
280
293
  rb_ary_push(multi_result, Qnil );
281
294
  } else {
282
- result = s_api->sqlany_init("RUBY", SQLANY_CURRENT_API_VERSION , &s_version_available );
295
+ if (IS_SACAPI_V2(s_imp_drh->api)) {
296
+ s_imp_drh->sacapi_context = s_imp_drh->api.sqlany_init_ex("RUBY", SQLANY_API_VERSION_2 , &s_version_available );
297
+ if ( s_imp_drh->sacapi_context == NULL ) {
298
+ rb_ary_push(multi_result, INT2NUM(0));
299
+ }
300
+ else {
301
+ rb_ary_push(multi_result, INT2NUM(1));
302
+ }
303
+ rb_ary_push(multi_result, INT2NUM(s_version_available));
304
+ }
305
+ else {
306
+ result = s_imp_drh->api.sqlany_init("RUBY", SQLANY_API_VERSION_1 , &s_version_available );
283
307
  rb_ary_push(multi_result, INT2NUM(result));
284
308
  rb_ary_push(multi_result, INT2NUM(s_version_available));
309
+ }
285
310
  }
286
311
 
287
312
  return( multi_result );
@@ -289,7 +314,7 @@ static_SQLAnywhereInterface_sqlany_init(VALUE api)
289
314
 
290
315
  /*
291
316
  * call-seq:
292
- * sqlany_new_connection(VALUE api) -> VALUE connection
317
+ * sqlany_new_connection(VALUE imp_drh) -> VALUE connection
293
318
  *
294
319
  * Creates a connection object.
295
320
  *
@@ -298,21 +323,21 @@ static_SQLAnywhereInterface_sqlany_init(VALUE api)
298
323
  * one request can be processed on a connection at a time.
299
324
  *
300
325
  * <b>Parameters</b>:
301
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
326
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
302
327
  *
303
328
  * <b>Returns</b>:
304
329
  * - <tt>VALUE connection</tt>: A connection object.
305
330
  *
306
331
  */
307
332
  static VALUE
308
- static_SQLAnywhereInterface_sqlany_new_connection(VALUE api)
333
+ static_SQLAnywhereInterface_sqlany_new_connection(VALUE imp_drh)
309
334
  {
310
- SQLAnywhereInterface* s_api;
335
+ imp_drh_st* s_imp_drh;
311
336
  a_sqlany_connection* ptr;
312
337
  VALUE tdata;
313
338
 
314
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
315
- ptr = s_api->sqlany_new_connection();
339
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
340
+ ptr = s_imp_drh->api.sqlany_new_connection();
316
341
 
317
342
  tdata = Data_Wrap_Struct(cA_sqlany_connection, 0, 0, ptr);
318
343
 
@@ -321,14 +346,14 @@ static_SQLAnywhereInterface_sqlany_new_connection(VALUE api)
321
346
 
322
347
  /*
323
348
  * call-seq:
324
- * sqlany_client_version(VALUE api) -> [VALUE verstr]
349
+ * sqlany_client_version(VALUE imp_drh) -> [VALUE verstr]
325
350
  *
326
351
  * Retrieves the client version as a string.
327
352
  *
328
353
  * This function can be used to retrieve the client version.
329
354
  *
330
355
  * <b>Parameters</b>:
331
- * - <tt>VALUE api</tt> -- an initialized API structure to finalize
356
+ * - <tt>VALUE imp_drh</tt> -- an initialized API structure to finalize
332
357
  *
333
358
  * <b>Returns</b>:
334
359
  * - <tt>VALUE verstr</tt>: The client version string.
@@ -336,22 +361,22 @@ static_SQLAnywhereInterface_sqlany_new_connection(VALUE api)
336
361
  */
337
362
 
338
363
  static VALUE
339
- static_SQLAnywhereInterface_sqlany_client_version(VALUE api)
364
+ static_SQLAnywhereInterface_sqlany_client_version(VALUE imp_drh)
340
365
  {
341
- SQLAnywhereInterface* s_api;
366
+ imp_drh_st* s_imp_drh;
342
367
  size_t s_size;
343
368
  char s_buffer[255];
344
369
 
345
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
370
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
346
371
 
347
- s_api->sqlany_client_version(s_buffer, 255);
372
+ s_imp_drh->api.sqlany_client_version(s_buffer, 255);
348
373
 
349
374
  return (rb_str_new2(s_buffer));
350
375
  }
351
376
 
352
377
  /*
353
378
  * call-seq:
354
- * sqlany_connect(VALUE api, VALUE sqlany_conn, VALUE str) -> VALUE result
379
+ * sqlany_connect(VALUE imp_drh, VALUE sqlany_conn, VALUE str) -> VALUE result
355
380
  *
356
381
  * Creates a connection object.
357
382
  *
@@ -360,7 +385,7 @@ static_SQLAnywhereInterface_sqlany_client_version(VALUE api)
360
385
  * one request can be processed on a connection at a time.
361
386
  *
362
387
  * <b>Parameters</b>:
363
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
388
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
364
389
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was created by sqlany_new_connection().
365
390
  * - <tt>VALUE str</tt> -- A SQL Anywhere connection string.
366
391
  *
@@ -369,26 +394,26 @@ static_SQLAnywhereInterface_sqlany_client_version(VALUE api)
369
394
  *
370
395
  */
371
396
  static VALUE
372
- static_SQLAnywhereInterface_sqlany_connect(VALUE api, VALUE sqlany_conn, VALUE str)
397
+ static_SQLAnywhereInterface_sqlany_connect(VALUE imp_drh, VALUE sqlany_conn, VALUE str)
373
398
  {
374
- SQLAnywhereInterface* s_api;
399
+ imp_drh_st* s_imp_drh;
375
400
  a_sqlany_connection* s_sqlany_conn;
376
401
  char* s_str;
377
402
  sacapi_bool result;
378
403
 
379
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
404
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
380
405
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
381
406
 
382
407
  s_str = StringValueCStr( str );
383
408
 
384
- result = s_api->sqlany_connect( s_sqlany_conn, s_str );
409
+ result = s_imp_drh->api.sqlany_connect( s_sqlany_conn, s_str );
385
410
 
386
411
  return( INT2NUM(result) );
387
412
  }
388
413
 
389
414
  /*
390
415
  * call-seq:
391
- * sqlany_disconnect(VALUE api, VALUE sqlany_conn) -> nil
416
+ * sqlany_disconnect(VALUE imp_drh, VALUE sqlany_conn) -> nil
392
417
  *
393
418
  * Disconnect an already established connection.
394
419
  *
@@ -396,7 +421,7 @@ static_SQLAnywhereInterface_sqlany_connect(VALUE api, VALUE sqlany_conn, VALUE s
396
421
  * uncommitted transactions will be rolled back.
397
422
  *
398
423
  * <b>Parameters</b>:
399
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
424
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
400
425
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
401
426
  *
402
427
  * <b>Returns</b>:
@@ -404,28 +429,28 @@ static_SQLAnywhereInterface_sqlany_connect(VALUE api, VALUE sqlany_conn, VALUE s
404
429
  *
405
430
  */
406
431
  static VALUE
407
- static_SQLAnywhereInterface_sqlany_disconnect(VALUE api, VALUE sqlany_conn)
432
+ static_SQLAnywhereInterface_sqlany_disconnect(VALUE imp_drh, VALUE sqlany_conn)
408
433
  {
409
- SQLAnywhereInterface* s_api;
434
+ imp_drh_st* s_imp_drh;
410
435
  a_sqlany_connection* s_sqlany_conn;
411
436
 
412
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
437
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
413
438
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
414
439
 
415
440
 
416
- s_api->sqlany_disconnect( s_sqlany_conn );
441
+ s_imp_drh->api.sqlany_disconnect( s_sqlany_conn );
417
442
 
418
443
  return( Qnil );
419
444
  }
420
445
 
421
446
  /*
422
447
  * call-seq:
423
- * sqlany_free_connection(VALUE api, VALUE sqlany_conn) -> nil
448
+ * sqlany_free_connection(VALUE imp_drh, VALUE sqlany_conn) -> nil
424
449
  *
425
450
  * Frees the resources associated with a connection object.
426
451
  *
427
452
  * <b>Parameters</b>:
428
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
453
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
429
454
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was disconnected by sqlany_disconnect().
430
455
  *
431
456
  * <b>Returns</b>:
@@ -433,50 +458,56 @@ static_SQLAnywhereInterface_sqlany_disconnect(VALUE api, VALUE sqlany_conn)
433
458
  *
434
459
  */
435
460
  static VALUE
436
- static_SQLAnywhereInterface_sqlany_free_connection(VALUE api, VALUE sqlany_conn)
461
+ static_SQLAnywhereInterface_sqlany_free_connection(VALUE imp_drh, VALUE sqlany_conn)
437
462
  {
438
- SQLAnywhereInterface* s_api;
463
+ imp_drh_st* s_imp_drh;
439
464
  a_sqlany_connection* s_sqlany_conn;
440
465
 
441
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
466
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
442
467
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
443
468
 
444
469
 
445
- s_api->sqlany_free_connection( s_sqlany_conn );
470
+ s_imp_drh->api.sqlany_free_connection( s_sqlany_conn );
446
471
 
447
472
  return( Qnil );
448
473
  }
449
474
 
450
475
  /*
451
476
  * call-seq:
452
- * sqlany_fini(VALUE api) -> nil
477
+ * sqlany_fini(VALUE imp_drh) -> nil
453
478
  *
454
479
  * Finalizes the interface.
455
480
  *
456
481
  * Thus function frees any resources allocated by the API.
457
482
  *
458
483
  * <b>Parameters</b>:
459
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
484
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
460
485
  *
461
486
  * <b>Returns</b>:
462
487
  * - <tt>nil</tt>.
463
488
  *
464
489
  */
465
490
  static VALUE
466
- static_SQLAnywhereInterface_sqlany_fini(VALUE api)
491
+ static_SQLAnywhereInterface_sqlany_fini(VALUE imp_drh)
467
492
  {
468
- SQLAnywhereInterface* s_api;
493
+ imp_drh_st* s_imp_drh;
469
494
 
470
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
495
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
471
496
 
472
- s_api->sqlany_fini();
497
+ if( IS_SACAPI_V2(s_imp_drh->api) ) {
498
+ s_imp_drh->api.sqlany_fini_ex(s_imp_drh->sacapi_context);
499
+ s_imp_drh->sacapi_context = NULL;
500
+ }
501
+ else {
502
+ s_imp_drh->api.sqlany_fini();
503
+ }
473
504
 
474
505
  return( Qnil );
475
506
  }
476
507
 
477
508
  /*
478
509
  * call-seq:
479
- * sqlany_error(VALUE api, VALUE sqlany_conn) -> [VALUE result, VALUE errstr]
510
+ * sqlany_error(VALUE imp_drh, VALUE sqlany_conn) -> [VALUE result, VALUE errstr]
480
511
  *
481
512
  * Retrieves the last error code and message.
482
513
  *
@@ -484,7 +515,7 @@ static_SQLAnywhereInterface_sqlany_fini(VALUE api)
484
515
  * stored in the connection object.
485
516
  *
486
517
  * <b>Parameters</b>:
487
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
518
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
488
519
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
489
520
  *
490
521
  * <b>Returns</b>:
@@ -494,19 +525,19 @@ static_SQLAnywhereInterface_sqlany_fini(VALUE api)
494
525
  */
495
526
 
496
527
  static VALUE
497
- static_SQLAnywhereInterface_sqlany_error(VALUE api, VALUE sqlany_conn)
528
+ static_SQLAnywhereInterface_sqlany_error(VALUE imp_drh, VALUE sqlany_conn)
498
529
  {
499
- SQLAnywhereInterface* s_api;
530
+ imp_drh_st* s_imp_drh;
500
531
  a_sqlany_connection* s_sqlany_conn;
501
532
  size_t s_size;
502
533
  char s_buffer[255];
503
534
  sacapi_i32 result;
504
535
  VALUE multi_result;
505
536
 
506
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
537
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
507
538
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
508
539
 
509
- result = s_api->sqlany_error(s_sqlany_conn, s_buffer, 255);
540
+ result = s_imp_drh->api.sqlany_error(s_sqlany_conn, s_buffer, 255);
510
541
 
511
542
  multi_result = rb_ary_new();
512
543
 
@@ -518,7 +549,7 @@ static_SQLAnywhereInterface_sqlany_error(VALUE api, VALUE sqlany_conn)
518
549
 
519
550
  /*
520
551
  * call-seq:
521
- * sqlany_execute_immediate(VALUE api, VALUE sqlany_conn, VALUE sql) -> VALUE result
552
+ * sqlany_execute_immediate(VALUE imp_drh, VALUE sqlany_conn, VALUE sql) -> VALUE result
522
553
  *
523
554
  * Executes a SQL statement immediately without returning a result set.
524
555
  *
@@ -527,7 +558,7 @@ static_SQLAnywhereInterface_sqlany_error(VALUE api, VALUE sqlany_conn)
527
558
  *
528
559
  *
529
560
  * <b>Parameters</b>:
530
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
561
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
531
562
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
532
563
  * - <tt>VALUE sql</tt> -- A SQL query string.
533
564
  *
@@ -536,26 +567,26 @@ static_SQLAnywhereInterface_sqlany_error(VALUE api, VALUE sqlany_conn)
536
567
  *
537
568
  */
538
569
  static VALUE
539
- static_SQLAnywhereInterface_sqlany_execute_immediate(VALUE api, VALUE sqlany_conn, VALUE sql)
570
+ static_SQLAnywhereInterface_sqlany_execute_immediate(VALUE imp_drh, VALUE sqlany_conn, VALUE sql)
540
571
  {
541
- SQLAnywhereInterface* s_api;
572
+ imp_drh_st* s_imp_drh;
542
573
  a_sqlany_connection* s_sqlany_conn;
543
574
  char* s_sql;
544
575
  sacapi_bool result;
545
576
 
546
577
  s_sql = StringValueCStr( sql );
547
578
 
548
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
579
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
549
580
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
550
581
 
551
- result = s_api->sqlany_execute_immediate(s_sqlany_conn, s_sql);
582
+ result = s_imp_drh->api.sqlany_execute_immediate(s_sqlany_conn, s_sql);
552
583
 
553
584
  return( INT2NUM(result) );
554
585
  }
555
586
 
556
587
  /*
557
588
  * call-seq:
558
- * sqlany_execute_direct(VALUE api, VALUE sqlany_conn, VALUE sql) -> VALUE resultset
589
+ * sqlany_execute_direct(VALUE imp_drh, VALUE sqlany_conn, VALUE sql) -> VALUE resultset
559
590
  *
560
591
  * Executes a SQL statement and possibly returns a result set.
561
592
  *
@@ -568,7 +599,7 @@ static_SQLAnywhereInterface_sqlany_execute_immediate(VALUE api, VALUE sqlany_con
568
599
  * parameters.
569
600
  *
570
601
  * <b>Parameters</b>:
571
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
602
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
572
603
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
573
604
  * - <tt>VALUE sql</tt> -- A SQL query string.
574
605
  *
@@ -577,9 +608,9 @@ static_SQLAnywhereInterface_sqlany_execute_immediate(VALUE api, VALUE sqlany_con
577
608
  *
578
609
  */
579
610
  static VALUE
580
- static_SQLAnywhereInterface_sqlany_execute_direct(VALUE api, VALUE sqlany_conn, VALUE sql)
611
+ static_SQLAnywhereInterface_sqlany_execute_direct(VALUE imp_drh, VALUE sqlany_conn, VALUE sql)
581
612
  {
582
- SQLAnywhereInterface* s_api;
613
+ imp_drh_st* s_imp_drh;
583
614
  a_sqlany_connection* s_sqlany_conn;
584
615
  a_sqlany_stmt* resultset = NULL;
585
616
  char* s_sql;
@@ -587,10 +618,10 @@ static_SQLAnywhereInterface_sqlany_execute_direct(VALUE api, VALUE sqlany_conn,
587
618
 
588
619
  s_sql = StringValueCStr( sql );
589
620
 
590
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
621
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
591
622
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
592
623
 
593
- resultset = s_api->sqlany_execute_direct(s_sqlany_conn, s_sql);
624
+ resultset = s_imp_drh->api.sqlany_execute_direct(s_sqlany_conn, s_sql);
594
625
 
595
626
  if (resultset)
596
627
  {
@@ -606,12 +637,12 @@ static_SQLAnywhereInterface_sqlany_execute_direct(VALUE api, VALUE sqlany_conn,
606
637
 
607
638
  /*
608
639
  * call-seq:
609
- * sqlany_num_cols(VALUE api, VALUE sqlany_stmt) -> VALUE num_cols
640
+ * sqlany_num_cols(VALUE imp_drh, VALUE sqlany_stmt) -> VALUE num_cols
610
641
  *
611
642
  * Returns number of columns in the result set.
612
643
  *
613
644
  * <b>Parameters</b>:
614
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
645
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
615
646
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
616
647
  *
617
648
  * <b>Returns</b>:
@@ -619,23 +650,23 @@ static_SQLAnywhereInterface_sqlany_execute_direct(VALUE api, VALUE sqlany_conn,
619
650
  *
620
651
  */
621
652
  static VALUE
622
- static_SQLAnywhereInterface_sqlany_num_cols(VALUE api, VALUE sqlany_stmt)
653
+ static_SQLAnywhereInterface_sqlany_num_cols(VALUE imp_drh, VALUE sqlany_stmt)
623
654
  {
624
- SQLAnywhereInterface* s_api;
655
+ imp_drh_st* s_imp_drh;
625
656
  a_sqlany_stmt* s_stmt;
626
657
  sacapi_i32 result;
627
658
 
628
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
659
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
629
660
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
630
661
 
631
- result = s_api->sqlany_num_cols(s_stmt);
662
+ result = s_imp_drh->api.sqlany_num_cols(s_stmt);
632
663
 
633
664
  return( INT2NUM(result) );
634
665
  }
635
666
 
636
667
  /*
637
668
  * call-seq:
638
- * sqlany_num_rows(VALUE api, VALUE sqlany_stmt) -> VALUE num_rows
669
+ * sqlany_num_rows(VALUE imp_drh, VALUE sqlany_stmt) -> VALUE num_rows
639
670
  *
640
671
  * Returns number of rows in the result set.
641
672
  *
@@ -644,7 +675,7 @@ static_SQLAnywhereInterface_sqlany_num_cols(VALUE api, VALUE sqlany_stmt)
644
675
  * Refer to SQL Anywhere documentation for the SQL syntax to set this option.
645
676
  *
646
677
  * <b>Parameters</b>:
647
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
678
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
648
679
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
649
680
  *
650
681
  * <b>Returns</b>:
@@ -652,28 +683,28 @@ static_SQLAnywhereInterface_sqlany_num_cols(VALUE api, VALUE sqlany_stmt)
652
683
  *
653
684
  */
654
685
  static VALUE
655
- static_SQLAnywhereInterface_sqlany_num_rows(VALUE api, VALUE sqlany_stmt)
686
+ static_SQLAnywhereInterface_sqlany_num_rows(VALUE imp_drh, VALUE sqlany_stmt)
656
687
  {
657
- SQLAnywhereInterface* s_api;
688
+ imp_drh_st* s_imp_drh;
658
689
  a_sqlany_stmt* s_stmt;
659
690
  sacapi_i32 result;
660
691
 
661
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
692
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
662
693
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
663
694
 
664
- result = s_api->sqlany_num_rows(s_stmt);
695
+ result = s_imp_drh->api.sqlany_num_rows(s_stmt);
665
696
 
666
697
  return( INT2NUM(result) );
667
698
  }
668
699
 
669
700
  /*
670
701
  * call-seq:
671
- * sqlany_get_column(VALUE api, VALUE sqlany_stmt, VALUE col_num) -> [VALUE result, VALUE column_value]
702
+ * sqlany_get_column(VALUE imp_drh, VALUE sqlany_stmt, VALUE col_num) -> [VALUE result, VALUE column_value]
672
703
  *
673
704
  * Retrieves the data fetched for the specified column.
674
705
  *
675
706
  * <b>Parameters</b>:
676
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
707
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
677
708
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
678
709
  * - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and sqlany_num_cols() - 1.
679
710
  *
@@ -682,20 +713,20 @@ static_SQLAnywhereInterface_sqlany_num_rows(VALUE api, VALUE sqlany_stmt)
682
713
  *
683
714
  */
684
715
  static VALUE
685
- static_SQLAnywhereInterface_sqlany_get_column(VALUE api, VALUE sqlany_stmt, VALUE col_num)
716
+ static_SQLAnywhereInterface_sqlany_get_column(VALUE imp_drh, VALUE sqlany_stmt, VALUE col_num)
686
717
  {
687
- SQLAnywhereInterface* s_api;
718
+ imp_drh_st* s_imp_drh;
688
719
  a_sqlany_stmt* s_stmt;
689
720
  sacapi_u32 s_col_num;
690
721
  a_sqlany_data_value value;
691
722
  sacapi_bool result;
692
723
  VALUE multi_result;
693
724
 
694
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
725
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
695
726
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
696
727
  s_col_num = NUM2INT(col_num);
697
728
 
698
- result = s_api->sqlany_get_column(s_stmt, s_col_num, &value );
729
+ result = s_imp_drh->api.sqlany_get_column(s_stmt, s_col_num, &value );
699
730
 
700
731
  multi_result = rb_ary_new();
701
732
  rb_ary_push(multi_result, INT2NUM(result));
@@ -720,7 +751,7 @@ static_SQLAnywhereInterface_sqlany_get_column(VALUE api, VALUE sqlany_stmt, VALU
720
751
 
721
752
  /*
722
753
  * call-seq:
723
- * sqlany_fetch_next(VALUE api, VALUE sqlany_stmt) -> VALUE result
754
+ * sqlany_fetch_next(VALUE imp_drh, VALUE sqlany_stmt) -> VALUE result
724
755
  *
725
756
  * Fetches the next row from the result set.
726
757
  *
@@ -731,7 +762,7 @@ static_SQLAnywhereInterface_sqlany_get_column(VALUE api, VALUE sqlany_stmt, VALU
731
762
  * at the new row.
732
763
  *
733
764
  * <b>Parameters</b>:
734
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
765
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
735
766
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
736
767
  *
737
768
  * <b>Returns</b>:
@@ -739,23 +770,23 @@ static_SQLAnywhereInterface_sqlany_get_column(VALUE api, VALUE sqlany_stmt, VALU
739
770
  *
740
771
  */
741
772
  static VALUE
742
- static_SQLAnywhereInterface_sqlany_fetch_next(VALUE api, VALUE sqlany_stmt)
773
+ static_SQLAnywhereInterface_sqlany_fetch_next(VALUE imp_drh, VALUE sqlany_stmt)
743
774
  {
744
- SQLAnywhereInterface* s_api;
775
+ imp_drh_st* s_imp_drh;
745
776
  a_sqlany_stmt* s_stmt;
746
777
  sacapi_bool result;
747
778
 
748
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
779
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
749
780
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
750
781
 
751
- result = s_api->sqlany_fetch_next(s_stmt);
782
+ result = s_imp_drh->api.sqlany_fetch_next(s_stmt);
752
783
 
753
784
  return( INT2NUM(result) );
754
785
  }
755
786
 
756
787
  /*
757
788
  * call-seq:
758
- * sqlany_get_column_info(VALUE api, VALUE sqlany_stmt, VALUE col_num) -> [VALUE result, VALUE col_num, VALUE name, VALUE type, VALUE max_size]
789
+ * sqlany_get_column_info(VALUE imp_drh, VALUE sqlany_stmt, VALUE col_num) -> [VALUE result, VALUE col_num, VALUE name, VALUE type, VALUE max_size]
759
790
  *
760
791
  * Fetches the next row from the result set.
761
792
  *
@@ -766,7 +797,7 @@ static_SQLAnywhereInterface_sqlany_fetch_next(VALUE api, VALUE sqlany_stmt)
766
797
  * at the new row.
767
798
  *
768
799
  * <b>Parameters</b>:
769
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
800
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
770
801
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
771
802
  * - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and sqlany_num_cols() - 1.
772
803
  *
@@ -783,20 +814,20 @@ static_SQLAnywhereInterface_sqlany_fetch_next(VALUE api, VALUE sqlany_stmt)
783
814
  *
784
815
  */
785
816
  static VALUE
786
- static_SQLAnywhereInterface_sqlany_get_column_info(VALUE api, VALUE sqlany_stmt, VALUE col_num)
817
+ static_SQLAnywhereInterface_sqlany_get_column_info(VALUE imp_drh, VALUE sqlany_stmt, VALUE col_num)
787
818
  {
788
- SQLAnywhereInterface* s_api;
819
+ imp_drh_st* s_imp_drh;
789
820
  a_sqlany_stmt* s_stmt;
790
821
  sacapi_u32 s_col_num;
791
822
  a_sqlany_column_info info;
792
823
  sacapi_bool result;
793
824
  VALUE multi_result;
794
825
 
795
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
826
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
796
827
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
797
828
  s_col_num = NUM2INT(col_num);
798
829
 
799
- result = s_api->sqlany_get_column_info(s_stmt, s_col_num, &info );
830
+ result = s_imp_drh->api.sqlany_get_column_info(s_stmt, s_col_num, &info );
800
831
 
801
832
  multi_result = rb_ary_new();
802
833
  rb_ary_push(multi_result, INT2NUM(result));
@@ -814,12 +845,12 @@ static_SQLAnywhereInterface_sqlany_get_column_info(VALUE api, VALUE sqlany_stmt,
814
845
 
815
846
  /*
816
847
  * call-seq:
817
- * sqlany_commit(VALUE api, VALUE sqlany_conn) -> VALUE result
848
+ * sqlany_commit(VALUE imp_drh, VALUE sqlany_conn) -> VALUE result
818
849
  *
819
850
  * Commits the current transaction.
820
851
  *
821
852
  * <b>Parameters</b>:
822
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
853
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
823
854
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
824
855
  *
825
856
  * <b>Returns</b>:
@@ -827,16 +858,16 @@ static_SQLAnywhereInterface_sqlany_get_column_info(VALUE api, VALUE sqlany_stmt,
827
858
  *
828
859
  */
829
860
  static VALUE
830
- static_SQLAnywhereInterface_sqlany_commit(VALUE api, VALUE sqlany_conn)
861
+ static_SQLAnywhereInterface_sqlany_commit(VALUE imp_drh, VALUE sqlany_conn)
831
862
  {
832
- SQLAnywhereInterface* s_api;
863
+ imp_drh_st* s_imp_drh;
833
864
  a_sqlany_connection* s_sqlany_conn;
834
865
  sacapi_bool result;
835
866
 
836
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
867
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
837
868
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
838
869
 
839
- result = s_api->sqlany_commit(s_sqlany_conn);
870
+ result = s_imp_drh->api.sqlany_commit(s_sqlany_conn);
840
871
 
841
872
  return( INT2NUM(result) );
842
873
  }
@@ -844,12 +875,12 @@ static_SQLAnywhereInterface_sqlany_commit(VALUE api, VALUE sqlany_conn)
844
875
 
845
876
  /*
846
877
  * call-seq:
847
- * sqlany_rollback(VALUE api, VALUE sqlany_conn) -> VALUE result
878
+ * sqlany_rollback(VALUE imp_drh, VALUE sqlany_conn) -> VALUE result
848
879
  *
849
880
  * Rolls back the current transaction.
850
881
  *
851
882
  * <b>Parameters</b>:
852
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
883
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
853
884
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
854
885
  *
855
886
  * <b>Returns</b>:
@@ -857,23 +888,23 @@ static_SQLAnywhereInterface_sqlany_commit(VALUE api, VALUE sqlany_conn)
857
888
  *
858
889
  */
859
890
  static VALUE
860
- static_SQLAnywhereInterface_sqlany_rollback(VALUE api, VALUE sqlany_conn)
891
+ static_SQLAnywhereInterface_sqlany_rollback(VALUE imp_drh, VALUE sqlany_conn)
861
892
  {
862
- SQLAnywhereInterface* s_api;
893
+ imp_drh_st* s_imp_drh;
863
894
  a_sqlany_connection* s_sqlany_conn;
864
895
  sacapi_bool result;
865
896
 
866
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
897
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
867
898
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
868
899
 
869
- result = s_api->sqlany_rollback(s_sqlany_conn);
900
+ result = s_imp_drh->api.sqlany_rollback(s_sqlany_conn);
870
901
 
871
902
  return( INT2NUM(result) );
872
903
  }
873
904
 
874
905
  /*
875
906
  * call-seq:
876
- * sqlany_prepare(VALUE api, VALUE sqlany_conn, VALUE sql) -> VALUE stmt
907
+ * sqlany_prepare(VALUE imp_drh, VALUE sqlany_conn, VALUE sql) -> VALUE stmt
877
908
  *
878
909
  * Prepares a SQL statement.
879
910
  *
@@ -883,7 +914,7 @@ static_SQLAnywhereInterface_sqlany_rollback(VALUE api, VALUE sqlany_conn)
883
914
  *
884
915
  *
885
916
  * <b>Parameters</b>:
886
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
917
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
887
918
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
888
919
  * - <tt>VALUE sql</tt> -- SQL query to prepare.
889
920
  *
@@ -892,9 +923,9 @@ static_SQLAnywhereInterface_sqlany_rollback(VALUE api, VALUE sqlany_conn)
892
923
  *
893
924
  */
894
925
  static VALUE
895
- static_SQLAnywhereInterface_sqlany_prepare(VALUE api, VALUE sqlany_conn, VALUE sql)
926
+ static_SQLAnywhereInterface_sqlany_prepare(VALUE imp_drh, VALUE sqlany_conn, VALUE sql)
896
927
  {
897
- SQLAnywhereInterface* s_api;
928
+ imp_drh_st* s_imp_drh;
898
929
  a_sqlany_connection* s_sqlany_conn;
899
930
  a_sqlany_stmt* ptr = NULL;
900
931
  char* s_sql;
@@ -903,10 +934,10 @@ static_SQLAnywhereInterface_sqlany_prepare(VALUE api, VALUE sqlany_conn, VALUE s
903
934
 
904
935
  s_sql = StringValueCStr( sql );
905
936
 
906
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
937
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
907
938
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
908
939
 
909
- ptr = s_api->sqlany_prepare(s_sqlany_conn, s_sql);
940
+ ptr = s_imp_drh->api.sqlany_prepare(s_sqlany_conn, s_sql);
910
941
 
911
942
  if (ptr)
912
943
  {
@@ -922,7 +953,7 @@ static_SQLAnywhereInterface_sqlany_prepare(VALUE api, VALUE sqlany_conn, VALUE s
922
953
 
923
954
  /*
924
955
  * call-seq:
925
- * sqlany_free_stmt(VALUE api, VALUE sqlany_stmt) -> nil
956
+ * sqlany_free_stmt(VALUE imp_drh, VALUE sqlany_stmt) -> nil
926
957
  *
927
958
  * Frees resources associated with a prepared statement object.
928
959
  *
@@ -930,7 +961,7 @@ static_SQLAnywhereInterface_sqlany_prepare(VALUE api, VALUE sqlany_conn, VALUE s
930
961
  * object.
931
962
  *
932
963
  * <b>Parameters</b>:
933
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
964
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
934
965
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
935
966
  *
936
967
  * <b>Returns</b>:
@@ -938,22 +969,22 @@ static_SQLAnywhereInterface_sqlany_prepare(VALUE api, VALUE sqlany_conn, VALUE s
938
969
  *
939
970
  */
940
971
  static VALUE
941
- static_SQLAnywhereInterface_sqlany_free_stmt(VALUE api, VALUE sqlany_stmt)
972
+ static_SQLAnywhereInterface_sqlany_free_stmt(VALUE imp_drh, VALUE sqlany_stmt)
942
973
  {
943
- SQLAnywhereInterface* s_api;
974
+ imp_drh_st* s_imp_drh;
944
975
  a_sqlany_stmt* s_sqlany_stmt;
945
976
  int i;
946
977
  int number_of_params = 0;
947
978
  a_sqlany_bind_param_info bind_info;
948
979
 
949
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
980
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
950
981
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
951
982
 
952
- number_of_params = s_api->sqlany_num_params(s_sqlany_stmt);
983
+ number_of_params = s_imp_drh->api.sqlany_num_params(s_sqlany_stmt);
953
984
 
954
985
  for (i = 0; i < number_of_params; i++)
955
986
  {
956
- if( s_api->sqlany_get_bind_param_info(s_sqlany_stmt, i, &bind_info) )
987
+ if( s_imp_drh->api.sqlany_get_bind_param_info(s_sqlany_stmt, i, &bind_info) )
957
988
  {
958
989
  // We don't free bind_info.name as it's not allocated
959
990
  // if (bind_info.name) {free (bind_info.name);}
@@ -968,19 +999,48 @@ static_SQLAnywhereInterface_sqlany_free_stmt(VALUE api, VALUE sqlany_stmt)
968
999
  }
969
1000
  }
970
1001
 
971
- s_api->sqlany_free_stmt(s_sqlany_stmt);
1002
+ s_imp_drh->api.sqlany_free_stmt(s_sqlany_stmt);
972
1003
 
973
1004
  return ( Qnil );
974
1005
  }
975
1006
 
976
1007
  /*
977
1008
  * call-seq:
978
- * sqlany_execute(VALUE api, VALUE sqlany_stmt) -> VALUE result
1009
+ * sqlany_reset(VALUE imp_drh, VALUE sqlany_stmt) -> VALUE result
1010
+ *
1011
+ *
1012
+ * <b>Parameters</b>:
1013
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1014
+ * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
1015
+ *
1016
+ * <b>Returns</b>:
1017
+ * - <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
1018
+ *
1019
+ */
1020
+ static VALUE
1021
+ static_SQLAnywhereInterface_sqlany_reset(VALUE imp_drh, VALUE sqlany_stmt)
1022
+ {
1023
+ imp_drh_st* s_imp_drh;
1024
+ a_sqlany_stmt* s_sqlany_stmt;
1025
+ sacapi_bool result;
1026
+
1027
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1028
+ Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
1029
+
1030
+ result = s_imp_drh->api.sqlany_reset(s_sqlany_stmt);
1031
+
1032
+ return (INT2NUM(result));
1033
+ }
1034
+
1035
+
1036
+ /*
1037
+ * call-seq:
1038
+ * sqlany_execute(VALUE imp_drh, VALUE sqlany_stmt) -> VALUE result
979
1039
  *
980
1040
  * Executes a prepared statement.
981
1041
  *
982
1042
  * <b>Parameters</b>:
983
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1043
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
984
1044
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
985
1045
  *
986
1046
  * <b>Returns</b>:
@@ -988,29 +1048,29 @@ static_SQLAnywhereInterface_sqlany_free_stmt(VALUE api, VALUE sqlany_stmt)
988
1048
  *
989
1049
  */
990
1050
  static VALUE
991
- static_SQLAnywhereInterface_sqlany_execute(VALUE api, VALUE sqlany_stmt)
1051
+ static_SQLAnywhereInterface_sqlany_execute(VALUE imp_drh, VALUE sqlany_stmt)
992
1052
  {
993
- SQLAnywhereInterface* s_api;
1053
+ imp_drh_st* s_imp_drh;
994
1054
  a_sqlany_stmt* s_sqlany_stmt;
995
1055
  sacapi_bool result;
996
1056
 
997
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1057
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
998
1058
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
999
1059
 
1000
- result = s_api->sqlany_execute(s_sqlany_stmt);
1060
+ result = s_imp_drh->api.sqlany_execute(s_sqlany_stmt);
1001
1061
 
1002
1062
  return (INT2NUM(result));
1003
1063
  }
1004
1064
 
1005
1065
  /*
1006
1066
  * call-seq:
1007
- * sqlany_affected_rows(VALUE api, VALUE sqlany_stmt) -> VALUE result
1067
+ * sqlany_affected_rows(VALUE imp_drh, VALUE sqlany_stmt) -> VALUE result
1008
1068
  *
1009
1069
  * Returns the number of rows affected by execution of the prepared
1010
1070
  * statement.
1011
1071
  *
1012
1072
  * <b>Parameters</b>:
1013
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1073
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1014
1074
  * - <tt>VALUE sqlany_stmt</tt> -- A statement that was prepared and executed successfully with no result set returned.
1015
1075
  *
1016
1076
  * <b>Returns</b>:
@@ -1018,23 +1078,23 @@ static_SQLAnywhereInterface_sqlany_execute(VALUE api, VALUE sqlany_stmt)
1018
1078
  *
1019
1079
  */
1020
1080
  static VALUE
1021
- static_SQLAnywhereInterface_sqlany_affected_rows(VALUE api, VALUE sqlany_stmt)
1081
+ static_SQLAnywhereInterface_sqlany_affected_rows(VALUE imp_drh, VALUE sqlany_stmt)
1022
1082
  {
1023
- SQLAnywhereInterface* s_api;
1083
+ imp_drh_st* s_imp_drh;
1024
1084
  a_sqlany_stmt* s_sqlany_stmt;
1025
1085
  sacapi_i32 result;
1026
1086
 
1027
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1087
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1028
1088
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
1029
1089
 
1030
- result = s_api->sqlany_affected_rows(s_sqlany_stmt);
1090
+ result = s_imp_drh->api.sqlany_affected_rows(s_sqlany_stmt);
1031
1091
 
1032
1092
  return ( INT2NUM(result) );
1033
1093
  }
1034
1094
 
1035
1095
  /*
1036
1096
  * call-seq:
1037
- * sqlany_describe_bind_param(VALUE api, VALUE sqlany_stmt, VALUE index) -> [VALUE result, VALUE bind_param]
1097
+ * sqlany_describe_bind_param(VALUE imp_drh, VALUE sqlany_stmt, VALUE index) -> [VALUE result, VALUE bind_param]
1038
1098
  *
1039
1099
  * Describes the bind parameters of a prepared statement.
1040
1100
  *
@@ -1045,7 +1105,7 @@ static_SQLAnywhereInterface_sqlany_affected_rows(VALUE api, VALUE sqlany_stmt)
1045
1105
  * of the parameters (input, output, or input-output).
1046
1106
  *
1047
1107
  * <b>Parameters</b>:
1048
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1108
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1049
1109
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was returned from sqlany_prepare().
1050
1110
  * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and sqlany_num_params()- 1.
1051
1111
  *
@@ -1055,9 +1115,9 @@ static_SQLAnywhereInterface_sqlany_affected_rows(VALUE api, VALUE sqlany_stmt)
1055
1115
  *
1056
1116
  */
1057
1117
  static VALUE
1058
- static_SQLAnywhereInterface_sqlany_describe_bind_param(VALUE api, VALUE sqlany_stmt, VALUE index)
1118
+ static_SQLAnywhereInterface_sqlany_describe_bind_param(VALUE imp_drh, VALUE sqlany_stmt, VALUE index)
1059
1119
  {
1060
- SQLAnywhereInterface* s_api;
1120
+ imp_drh_st* s_imp_drh;
1061
1121
  a_sqlany_stmt* s_sqlany_stmt;
1062
1122
  a_sqlany_bind_param* s_sqlany_bind_param;
1063
1123
  sacapi_bool result;
@@ -1068,11 +1128,11 @@ static_SQLAnywhereInterface_sqlany_describe_bind_param(VALUE api, VALUE sqlany_s
1068
1128
  s_sqlany_bind_param = malloc(sizeof(a_sqlany_bind_param));
1069
1129
  memset( s_sqlany_bind_param, 0, sizeof(a_sqlany_bind_param) );
1070
1130
 
1071
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1131
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1072
1132
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
1073
1133
  s_index = NUM2INT(index);
1074
1134
 
1075
- result = s_api->sqlany_describe_bind_param(s_sqlany_stmt, s_index, s_sqlany_bind_param);
1135
+ result = s_imp_drh->api.sqlany_describe_bind_param(s_sqlany_stmt, s_index, s_sqlany_bind_param);
1076
1136
 
1077
1137
  //FIXME handle failed result
1078
1138
 
@@ -1088,12 +1148,12 @@ static_SQLAnywhereInterface_sqlany_describe_bind_param(VALUE api, VALUE sqlany_s
1088
1148
 
1089
1149
  /*
1090
1150
  * call-seq:
1091
- * sqlany_bind_param(VALUE api, VALUE sqlany_stmt, VALUE index, VALUE sqlany_bind_param) -> VALUE result
1151
+ * sqlany_bind_param(VALUE imp_drh, VALUE sqlany_stmt, VALUE index, VALUE sqlany_bind_param) -> VALUE result
1092
1152
  *
1093
1153
  * Binds a user supplied buffer as a parameter to the prepared statement.
1094
1154
  *
1095
1155
  * <b>Parameters</b>:
1096
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1156
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1097
1157
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was returned from sqlany_prepare().
1098
1158
  * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and sqlany_num_params() - 1.
1099
1159
  * - <tt>VALUE sqlany_bind_param</tt> -- A filled bind object retrieved from sqlany_describe_bind_param().
@@ -1103,27 +1163,27 @@ static_SQLAnywhereInterface_sqlany_describe_bind_param(VALUE api, VALUE sqlany_s
1103
1163
  *
1104
1164
  */
1105
1165
  static VALUE
1106
- static_SQLAnywhereInterface_sqlany_bind_param(VALUE api, VALUE sqlany_stmt, VALUE index, VALUE sqlany_bind_param )
1166
+ static_SQLAnywhereInterface_sqlany_bind_param(VALUE imp_drh, VALUE sqlany_stmt, VALUE index, VALUE sqlany_bind_param )
1107
1167
  {
1108
- SQLAnywhereInterface* s_api;
1168
+ imp_drh_st* s_imp_drh;
1109
1169
  a_sqlany_stmt* s_sqlany_stmt;
1110
1170
  a_sqlany_bind_param* s_sqlany_bind_param;
1111
1171
  sacapi_bool result;
1112
1172
  sacapi_u32 s_index;
1113
1173
 
1114
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1174
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1115
1175
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
1116
1176
  Data_Get_Struct(sqlany_bind_param, a_sqlany_bind_param, s_sqlany_bind_param);
1117
1177
  s_index = NUM2INT(index);
1118
1178
 
1119
- result = s_api->sqlany_bind_param(s_sqlany_stmt, s_index, s_sqlany_bind_param);
1179
+ result = s_imp_drh->api.sqlany_bind_param(s_sqlany_stmt, s_index, s_sqlany_bind_param);
1120
1180
 
1121
1181
  return( INT2NUM(result) );
1122
1182
  }
1123
1183
 
1124
1184
  /*
1125
1185
  * call-seq:
1126
- * sqlany_get_bind_param_info(VALUE api, VALUE sqlany_stmt, VALUE index) -> [VALUE result, VALUE bind_param]
1186
+ * sqlany_get_bind_param_info(VALUE imp_drh, VALUE sqlany_stmt, VALUE index) -> [VALUE result, VALUE bind_param]
1127
1187
  *
1128
1188
  * Gets bound parameter info.
1129
1189
  *
@@ -1131,7 +1191,7 @@ static_SQLAnywhereInterface_sqlany_bind_param(VALUE api, VALUE sqlany_stmt, VALU
1131
1191
  * bound using sqlany_bind_param().
1132
1192
  *
1133
1193
  * <b>Parameters</b>:
1134
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1194
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1135
1195
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was returned from sqlany_prepare().
1136
1196
  * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and sqlany_num_params() - 1.
1137
1197
  *
@@ -1141,9 +1201,9 @@ static_SQLAnywhereInterface_sqlany_bind_param(VALUE api, VALUE sqlany_stmt, VALU
1141
1201
  *
1142
1202
  */
1143
1203
  static VALUE
1144
- static_SQLAnywhereInterface_sqlany_get_bind_param_info(VALUE api, VALUE sqlany_stmt, VALUE index)
1204
+ static_SQLAnywhereInterface_sqlany_get_bind_param_info(VALUE imp_drh, VALUE sqlany_stmt, VALUE index)
1145
1205
  {
1146
- SQLAnywhereInterface* s_api;
1206
+ imp_drh_st* s_imp_drh;
1147
1207
  a_sqlany_stmt* s_sqlany_stmt;
1148
1208
  a_sqlany_bind_param_info s_sqlany_bind_param_info;
1149
1209
  sacapi_bool result;
@@ -1151,11 +1211,11 @@ static_SQLAnywhereInterface_sqlany_get_bind_param_info(VALUE api, VALUE sqlany_s
1151
1211
  VALUE tdata;
1152
1212
  VALUE multi_result;
1153
1213
 
1154
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1214
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1155
1215
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
1156
1216
  s_index = NUM2INT(index);
1157
1217
 
1158
- result = s_api->sqlany_get_bind_param_info(s_sqlany_stmt, s_index, &s_sqlany_bind_param_info);
1218
+ result = s_imp_drh->api.sqlany_get_bind_param_info(s_sqlany_stmt, s_index, &s_sqlany_bind_param_info);
1159
1219
 
1160
1220
  //FIXME handle failed result
1161
1221
  multi_result = rb_ary_new();
@@ -1171,7 +1231,7 @@ static_SQLAnywhereInterface_sqlany_get_bind_param_info(VALUE api, VALUE sqlany_s
1171
1231
 
1172
1232
  /*
1173
1233
  * call-seq:
1174
- * sqlany_num_params(VALUE api, VALUE sqlany_stmt) -> VALUE result
1234
+ * sqlany_num_params(VALUE imp_drh, VALUE sqlany_stmt) -> VALUE result
1175
1235
  *
1176
1236
  * Returns the number of parameters that are expected for a prepared
1177
1237
  * statement.
@@ -1180,7 +1240,7 @@ static_SQLAnywhereInterface_sqlany_get_bind_param_info(VALUE api, VALUE sqlany_s
1180
1240
  * using sqlany_bind_param().
1181
1241
  *
1182
1242
  * <b>Parameters</b>:
1183
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1243
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1184
1244
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was returned from sqlany_prepare().
1185
1245
  *
1186
1246
  * <b>Returns</b>:
@@ -1188,23 +1248,23 @@ static_SQLAnywhereInterface_sqlany_get_bind_param_info(VALUE api, VALUE sqlany_s
1188
1248
  *
1189
1249
  */
1190
1250
  static VALUE
1191
- static_SQLAnywhereInterface_sqlany_num_params(VALUE api, VALUE sqlany_stmt)
1251
+ static_SQLAnywhereInterface_sqlany_num_params(VALUE imp_drh, VALUE sqlany_stmt)
1192
1252
  {
1193
- SQLAnywhereInterface* s_api;
1253
+ imp_drh_st* s_imp_drh;
1194
1254
  a_sqlany_stmt* s_sqlany_stmt;
1195
1255
  sacapi_i32 result;
1196
1256
 
1197
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1257
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1198
1258
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
1199
1259
 
1200
- result = s_api->sqlany_num_params(s_sqlany_stmt);
1260
+ result = s_imp_drh->api.sqlany_num_params(s_sqlany_stmt);
1201
1261
 
1202
1262
  return( INT2NUM(result) );
1203
1263
  }
1204
1264
 
1205
1265
  /*
1206
1266
  * call-seq:
1207
- * sqlany_get_next_result(VALUE api, VALUE sqlany_stmt) -> VALUE result
1267
+ * sqlany_get_next_result(VALUE imp_drh, VALUE sqlany_stmt) -> VALUE result
1208
1268
  *
1209
1269
  * Advances to the next result set in a multiple result set query.
1210
1270
  *
@@ -1213,7 +1273,7 @@ static_SQLAnywhereInterface_sqlany_num_params(VALUE api, VALUE sqlany_stmt)
1213
1273
  *
1214
1274
  *
1215
1275
  * <b>Parameters</b>:
1216
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1276
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1217
1277
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was executed by sqlany_execute() or sqlany_execute_direct().
1218
1278
  *
1219
1279
  * <b>Returns</b>:
@@ -1221,23 +1281,23 @@ static_SQLAnywhereInterface_sqlany_num_params(VALUE api, VALUE sqlany_stmt)
1221
1281
  *
1222
1282
  */
1223
1283
  static VALUE
1224
- static_SQLAnywhereInterface_sqlany_get_next_result(VALUE api, VALUE sqlany_stmt)
1284
+ static_SQLAnywhereInterface_sqlany_get_next_result(VALUE imp_drh, VALUE sqlany_stmt)
1225
1285
  {
1226
- SQLAnywhereInterface* s_api;
1286
+ imp_drh_st* s_imp_drh;
1227
1287
  a_sqlany_stmt* s_sqlany_stmt;
1228
1288
  sacapi_bool result;
1229
1289
 
1230
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1290
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1231
1291
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
1232
1292
 
1233
- result = s_api->sqlany_get_next_result(s_sqlany_stmt);
1293
+ result = s_imp_drh->api.sqlany_get_next_result(s_sqlany_stmt);
1234
1294
 
1235
1295
  return( INT2NUM(result) );
1236
1296
  }
1237
1297
 
1238
1298
  /*
1239
1299
  * call-seq:
1240
- * sqlany_fetch_absolute(VALUE api, VALUE sqlany_stmt, VALUE offset) -> VALUE result
1300
+ * sqlany_fetch_absolute(VALUE imp_drh, VALUE sqlany_stmt, VALUE offset) -> VALUE result
1241
1301
  *
1242
1302
  * Fetches data at a specific row number in the result set.
1243
1303
  *
@@ -1245,7 +1305,7 @@ static_SQLAnywhereInterface_sqlany_get_next_result(VALUE api, VALUE sqlany_stmt)
1245
1305
  * specified and fetches the data at that row.
1246
1306
  *
1247
1307
  * <b>Parameters</b>:
1248
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1308
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1249
1309
  * - <tt>VALUE sqlany_stmt</tt> -- A statement object that was executed by sqlany_execute() or sqlany_execute_direct().
1250
1310
  * - <tt>VALUE offset</tt> -- The row number to be fetched. The first row is <tt>1</tt>, the last row is <tt>-1</tt>.
1251
1311
  *
@@ -1254,29 +1314,29 @@ static_SQLAnywhereInterface_sqlany_get_next_result(VALUE api, VALUE sqlany_stmt)
1254
1314
  *
1255
1315
  */
1256
1316
  static VALUE
1257
- static_SQLAnywhereInterface_sqlany_fetch_absolute(VALUE api, VALUE sqlany_stmt, VALUE offset)
1317
+ static_SQLAnywhereInterface_sqlany_fetch_absolute(VALUE imp_drh, VALUE sqlany_stmt, VALUE offset)
1258
1318
  {
1259
- SQLAnywhereInterface* s_api;
1319
+ imp_drh_st* s_imp_drh;
1260
1320
  a_sqlany_stmt* s_sqlany_stmt;
1261
1321
  sacapi_i32 s_offset;
1262
1322
  sacapi_bool result;
1263
1323
 
1264
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1324
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1265
1325
  Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
1266
1326
  s_offset = NUM2INT(offset);
1267
- result = s_api->sqlany_fetch_absolute(s_sqlany_stmt, s_offset);
1327
+ result = s_imp_drh->api.sqlany_fetch_absolute(s_sqlany_stmt, s_offset);
1268
1328
 
1269
1329
  return( INT2NUM(result) );
1270
1330
  }
1271
1331
 
1272
1332
  /*
1273
1333
  * call-seq:
1274
- * sqlany_sqlstate(VALUE api, VALUE sqlany_conn) -> VALUE sqlstate_str
1334
+ * sqlany_sqlstate(VALUE imp_drh, VALUE sqlany_conn) -> VALUE sqlstate_str
1275
1335
  *
1276
1336
  * Retrieves the current SQL state.
1277
1337
  *
1278
1338
  * <b>Parameters</b>:
1279
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1339
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1280
1340
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
1281
1341
  *
1282
1342
  * <b>Returns</b>:
@@ -1284,29 +1344,29 @@ static_SQLAnywhereInterface_sqlany_fetch_absolute(VALUE api, VALUE sqlany_stmt,
1284
1344
  *
1285
1345
  */
1286
1346
  static VALUE
1287
- static_SQLAnywhereInterface_sqlany_sqlstate(VALUE api, VALUE sqlany_conn)
1347
+ static_SQLAnywhereInterface_sqlany_sqlstate(VALUE imp_drh, VALUE sqlany_conn)
1288
1348
  {
1289
- SQLAnywhereInterface* s_api;
1349
+ imp_drh_st* s_imp_drh;
1290
1350
  a_sqlany_connection* s_sqlany_conn;
1291
1351
  size_t s_size;
1292
1352
  char s_buffer[255];
1293
1353
 
1294
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1354
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1295
1355
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
1296
1356
 
1297
- s_size = s_api->sqlany_sqlstate(s_sqlany_conn, s_buffer, sizeof(s_buffer));
1357
+ s_size = s_imp_drh->api.sqlany_sqlstate(s_sqlany_conn, s_buffer, sizeof(s_buffer));
1298
1358
 
1299
1359
  return( rb_str_new(s_buffer, s_size));
1300
1360
  }
1301
1361
 
1302
1362
  /*
1303
1363
  * call-seq:
1304
- * sqlany_clear_error(VALUE api, VALUE sqlany_conn) -> nil
1364
+ * sqlany_clear_error(VALUE imp_drh, VALUE sqlany_conn) -> nil
1305
1365
  *
1306
1366
  * Clears the last stored error code.
1307
1367
  *
1308
1368
  * <b>Parameters</b>:
1309
- * - <tt>VALUE api</tt> -- An initialized API structure to finalize.
1369
+ * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1310
1370
  * - <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
1311
1371
  *
1312
1372
  * <b>Returns</b>:
@@ -1314,15 +1374,15 @@ static_SQLAnywhereInterface_sqlany_sqlstate(VALUE api, VALUE sqlany_conn)
1314
1374
  *
1315
1375
  */
1316
1376
  static VALUE
1317
- static_SQLAnywhereInterface_sqlany_clear_error(VALUE api, VALUE sqlany_conn)
1377
+ static_SQLAnywhereInterface_sqlany_clear_error(VALUE imp_drh, VALUE sqlany_conn)
1318
1378
  {
1319
- SQLAnywhereInterface* s_api;
1379
+ imp_drh_st* s_imp_drh;
1320
1380
  a_sqlany_connection* s_sqlany_conn;
1321
1381
 
1322
- Data_Get_Struct(api, SQLAnywhereInterface, s_api);
1382
+ Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1323
1383
  Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
1324
1384
 
1325
- s_api->sqlany_clear_error(s_sqlany_conn);
1385
+ s_imp_drh->api.sqlany_clear_error(s_sqlany_conn);
1326
1386
 
1327
1387
  return( Qnil );
1328
1388
  }
@@ -1400,16 +1460,22 @@ static_Bind_set_value(VALUE bind, VALUE val)
1400
1460
  {
1401
1461
  case T_STRING:
1402
1462
  s_bind->value.length = malloc(sizeof(size_t));
1403
- length = RSTRING(val)->len;
1463
+ length = RSTRING_LEN(val);
1404
1464
  *s_bind->value.length = length;
1405
1465
  s_bind->value.buffer = malloc(length);
1406
- memcpy(s_bind->value.buffer, RSTRING(val)->ptr, length);
1466
+ memcpy(s_bind->value.buffer, RSTRING_PTR(val), length);
1407
1467
  s_bind->value.type = A_STRING;
1408
1468
  break;
1409
1469
  case T_FIXNUM:
1410
- s_bind->value.buffer = malloc(sizeof(int));
1411
- *((int*)s_bind->value.buffer) = FIX2INT(val);
1412
- s_bind->value.type = A_VAL32;
1470
+ if(sizeof(void*) == 4){ //32-bit
1471
+ s_bind->value.buffer = malloc(sizeof(int));
1472
+ *((int*)s_bind->value.buffer) = FIX2INT(val);
1473
+ s_bind->value.type = A_VAL32;
1474
+ }else{ //64-bit
1475
+ s_bind->value.buffer = malloc(sizeof(long));
1476
+ *((long*)s_bind->value.buffer) = FIX2LONG(val);
1477
+ s_bind->value.type = A_VAL64;
1478
+ }
1413
1479
  break;
1414
1480
  case T_BIGNUM:
1415
1481
  s_bind->value.buffer = malloc(sizeof(LONG_LONG));
@@ -1651,6 +1717,7 @@ void Init_sqlanywhere()
1651
1717
  rb_define_method(cSQLAnywhereInterface, "sqlany_rollback", static_SQLAnywhereInterface_sqlany_rollback, 1);
1652
1718
  rb_define_method(cSQLAnywhereInterface, "sqlany_prepare", static_SQLAnywhereInterface_sqlany_prepare, 2);
1653
1719
  rb_define_method(cSQLAnywhereInterface, "sqlany_free_stmt", static_SQLAnywhereInterface_sqlany_free_stmt, 1);
1720
+ rb_define_method(cSQLAnywhereInterface, "sqlany_reset", static_SQLAnywhereInterface_sqlany_reset, 1);
1654
1721
  rb_define_method(cSQLAnywhereInterface, "sqlany_execute", static_SQLAnywhereInterface_sqlany_execute, 1);
1655
1722
  rb_define_method(cSQLAnywhereInterface, "sqlany_affected_rows", static_SQLAnywhereInterface_sqlany_affected_rows, 1);
1656
1723
  rb_define_method(cSQLAnywhereInterface, "sqlany_describe_bind_param", static_SQLAnywhereInterface_sqlany_describe_bind_param, 2);