@@ -31,6 +31,7 @@ VALUE rb_raise_mysql2_stmt_error2(MYSQL_STMT *stmt
31
31
) {
32
32
VALUE rb_error_msg = rb_str_new2 (mysql_stmt_error (stmt ));
33
33
VALUE rb_sql_state = rb_tainted_str_new2 (mysql_stmt_sqlstate (stmt ));
34
+ VALUE e = rb_exc_new3 (cMysql2Error , rb_error_msg );
34
35
#ifdef HAVE_RUBY_ENCODING_H
35
36
rb_encoding * default_internal_enc = rb_default_internal_encoding ();
36
37
@@ -41,8 +42,6 @@ VALUE rb_raise_mysql2_stmt_error2(MYSQL_STMT *stmt
41
42
rb_sql_state = rb_str_export_to_enc (rb_sql_state , default_internal_enc );
42
43
}
43
44
#endif
44
-
45
- VALUE e = rb_exc_new3 (cMysql2Error , rb_error_msg );
46
45
rb_funcall (e , intern_error_number_eql , 1 , UINT2NUM (mysql_stmt_errno (stmt )));
47
46
rb_funcall (e , intern_sql_state_eql , 1 , rb_sql_state );
48
47
rb_exc_raise (e );
@@ -209,19 +208,15 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
209
208
long i ;
210
209
MYSQL_STMT * stmt ;
211
210
MYSQL_RES * metadata ;
211
+ VALUE current ;
212
212
VALUE resultObj ;
213
213
VALUE * params_enc = alloca (sizeof (VALUE ) * argc );
214
214
unsigned long * length_buffers = NULL ;
215
215
int is_streaming = 0 ;
216
- #ifdef HAVE_RUBY_ENCODING_H
217
- rb_encoding * conn_enc ;
218
- #endif
219
216
GET_STATEMENT (self );
217
+ GET_CLIENT (stmt_wrapper -> client );
220
218
#ifdef HAVE_RUBY_ENCODING_H
221
- {
222
- GET_CLIENT (stmt_wrapper -> client );
223
- conn_enc = rb_to_encoding (wrapper -> encoding );
224
- }
219
+ rb_encoding * conn_enc = rb_to_encoding (wrapper -> encoding );
225
220
#endif
226
221
{
227
222
VALUE valStreaming = rb_hash_aref (rb_iv_get (stmt_wrapper -> client , "@query_options" ), sym_stream );
@@ -287,11 +282,12 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
287
282
default :
288
283
// TODO: what Ruby type should support MYSQL_TYPE_TIME
289
284
if (CLASS_OF (argv [i ]) == rb_cTime || CLASS_OF (argv [i ]) == cDateTime ) {
285
+ MYSQL_TIME t ;
286
+ VALUE rb_time = argv [i ];
287
+
290
288
bind_buffers [i ].buffer_type = MYSQL_TYPE_DATETIME ;
291
289
bind_buffers [i ].buffer = xmalloc (sizeof (MYSQL_TIME ));
292
290
293
- MYSQL_TIME t ;
294
- VALUE rb_time = argv [i ];
295
291
memset (& t , 0 , sizeof (MYSQL_TIME ));
296
292
t .neg = 0 ;
297
293
t .second_part = FIX2INT (rb_funcall (rb_time , rb_intern ("usec" ), 0 ));
@@ -304,13 +300,12 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
304
300
305
301
* (MYSQL_TIME * )(bind_buffers [i ].buffer ) = t ;
306
302
} else if (CLASS_OF (argv [i ]) == cDate ) {
303
+ MYSQL_TIME t ;
304
+ VALUE rb_time = argv [i ];
307
305
308
306
bind_buffers [i ].buffer_type = MYSQL_TYPE_DATE ;
309
-
310
307
bind_buffers [i ].buffer = xmalloc (sizeof (MYSQL_TIME ));
311
308
312
- MYSQL_TIME t ;
313
- VALUE rb_time = argv [i ];
314
309
memset (& t , 0 , sizeof (MYSQL_TIME ));
315
310
t .second_part = 0 ;
316
311
t .neg = 0 ;
@@ -352,9 +347,7 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
352
347
return Qnil ;
353
348
}
354
349
355
- VALUE current ;
356
350
current = rb_hash_dup (rb_iv_get (stmt_wrapper -> client , "@query_options" ));
357
- GET_CLIENT (stmt_wrapper -> client );
358
351
359
352
if (!is_streaming ) {
360
353
// recieve the whole result set from the server
0 commit comments