2
2
3
3
VALUE cMysql2Statement ;
4
4
extern VALUE mMysql2 , cMysql2Error , cBigDecimal , cDateTime , cDate ;
5
+ static VALUE sym_stream ;
5
6
6
7
static void rb_mysql_stmt_mark (void * ptr ) {
7
8
mysql_stmt_wrapper * stmt_wrapper = (mysql_stmt_wrapper * )ptr ;
@@ -150,6 +151,7 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
150
151
VALUE resultObj ;
151
152
VALUE * params_enc = alloca (sizeof (VALUE ) * argc );
152
153
unsigned long * length_buffers = NULL ;
154
+ int is_streaming = 0 ;
153
155
#ifdef HAVE_RUBY_ENCODING_H
154
156
rb_encoding * conn_enc ;
155
157
#endif
@@ -160,6 +162,12 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
160
162
conn_enc = rb_to_encoding (wrapper -> encoding );
161
163
}
162
164
#endif
165
+ {
166
+ VALUE valStreaming = rb_hash_aref (rb_iv_get (stmt_wrapper -> client , "@query_options" ), sym_stream );
167
+ if (valStreaming == Qtrue ) {
168
+ is_streaming = 1 ;
169
+ }
170
+ }
163
171
164
172
stmt = stmt_wrapper -> stmt ;
165
173
@@ -284,11 +292,15 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
284
292
current = rb_hash_dup (rb_iv_get (stmt_wrapper -> client , "@query_options" ));
285
293
GET_CLIENT (stmt_wrapper -> client );
286
294
287
- // FIXME: don't do this if streaming opt.
288
- if (mysql_stmt_store_result (stmt )) {
289
- rb_raise (cMysql2Error , "%s" , mysql_stmt_error (stmt ));
295
+ if (is_streaming ) {
296
+ rb_raise (cMysql2Error , "TODO: streaming stmt execute not yet impl." );
297
+ } else {
298
+ // recieve the whole result set from ther server
299
+ if (mysql_stmt_store_result (stmt )) {
300
+ rb_raise (cMysql2Error , "%s" , mysql_stmt_error (stmt ));
301
+ }
302
+ MARK_CONN_INACTIVE (stmt_wrapper -> client );
290
303
}
291
- MARK_CONN_INACTIVE (stmt_wrapper -> client );
292
304
293
305
resultObj = rb_mysql_result_to_obj (stmt_wrapper -> client , wrapper -> encoding , current , metadata , stmt );
294
306
@@ -360,4 +372,6 @@ void init_mysql2_statement() {
360
372
rb_define_method (cMysql2Statement , "field_count" , field_count , 0 );
361
373
rb_define_method (cMysql2Statement , "execute" , execute , -1 );
362
374
rb_define_method (cMysql2Statement , "fields" , fields , 0 );
375
+
376
+ sym_stream = ID2SYM (rb_intern ("stream" ));
363
377
}
0 commit comments