Skip to content

Commit 01b50ea

Browse files
committed
first part of 397158f
1 parent ea3b250 commit 01b50ea

File tree

3 files changed

+11
-60
lines changed

3 files changed

+11
-60
lines changed

ext/mysql2/client.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -236,26 +236,12 @@ static void rb_mysql_client_free(void *ptr) {
236236

237237
void decr_mysql2_client(mysql_client_wrapper *wrapper)
238238
{
239-
240-
printf("decr_mysql2_client\n");
241-
printf(" >> refcount before: %i\n", wrapper->refcount);
242-
243239
wrapper->refcount--;
244240

245-
printf(" >> refcount after: %i\n", wrapper->refcount);
246-
247241
if (wrapper->refcount == 0) {
248-
printf(" -- wrapper->refcount == 0\n");
249-
250242
nogvl_close(wrapper);
251-
printf(" -- nogvl_close\n");
252-
253243
xfree(wrapper->client);
254-
printf(" -- xfree wrapper client\n");
255-
256244
xfree(wrapper);
257-
printf(" -- xfree wrapper\n");
258-
printf(" -- refcount: %i\n\n", wrapper->refcount);
259245
}
260246
}
261247

@@ -273,8 +259,6 @@ static VALUE allocate(VALUE klass) {
273259
wrapper->refcount = 1;
274260
wrapper->client = (MYSQL*)xmalloc(sizeof(MYSQL));
275261

276-
printf("init refcount: %i == 1\n", wrapper->refcount);
277-
278262
return obj;
279263
}
280264

@@ -705,7 +689,6 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
705689

706690
rb_rescue2(do_query, (VALUE)&async_args, disconnect_and_raise, self, rb_eException, (VALUE)0);
707691

708-
printf("calling rb_mysql_client_async_result\n");
709692
return rb_mysql_client_async_result(self);
710693
} else {
711694
return Qnil;
@@ -1237,8 +1220,6 @@ static VALUE rb_mysql_client_prepare_statement(VALUE self, VALUE sql) {
12371220
GET_CLIENT(self);
12381221
REQUIRE_CONNECTED(wrapper);
12391222

1240-
printf("prepare refcount: %i\n", wrapper->refcount);
1241-
12421223
return rb_mysql_stmt_new(self, sql);
12431224
}
12441225

ext/mysql2/result.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,11 @@ static void rb_mysql_result_free(void *ptr) {
8383
mysql2_result_wrapper *wrapper = ptr;
8484
rb_mysql_result_free_result(wrapper);
8585

86-
printf("rb_mysql_result_free\n");
87-
8886
// If the GC gets to client first it will be nil
8987
if (wrapper->client != Qnil) {
9088
decr_mysql2_client(wrapper->client_wrapper);
9189
}
9290

93-
printf("result.c xfree wrapper\n");
9491
xfree(wrapper);
9592
}
9693

@@ -615,13 +612,9 @@ VALUE rb_mysql_result_to_obj(VALUE client, VALUE encoding, VALUE options, MYSQL_
615612
wrapper->streamingComplete = 0;
616613
wrapper->client = client;
617614
wrapper->client_wrapper = DATA_PTR(client);
618-
619-
printf("refcount++ before: %i\n", wrapper->client_wrapper->refcount);
620615
wrapper->client_wrapper->refcount++;
621-
printf("refcount++ after: %i\n", wrapper->client_wrapper->refcount);
622616

623617
rb_obj_call_init(obj, 0, NULL);
624-
625618
rb_iv_set(obj, "@query_options", options);
626619

627620
/* Options that cannot be changed in results.each(...) { |row| }

ext/mysql2/statement.c

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,6 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
260260
FREE_BINDS;
261261
}
262262

263-
264-
// ===============
265-
266-
267263
result = mysql_stmt_result_metadata(stmt);
268264
if(result == NULL) {
269265
if(mysql_stmt_errno(stmt) != 0) {
@@ -274,40 +270,21 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
274270
return Qnil;
275271
}
276272

277-
278273
VALUE current;
279274
current = rb_hash_dup(rb_iv_get(stmt_wrapper->client, "@query_options"));
280275
GET_CLIENT(stmt_wrapper->client);
281276

282-
printf("in statement.c: %i\n", wrapper->refcount);
283-
284-
285277
resultObj = rb_mysql_result_to_obj(stmt_wrapper->client, wrapper->encoding, current, result, stmt);
286278

287-
// resultObj = rb_mysql_result_to_obj(result, stmt);
288-
// rb_iv_set(resultObj, "@query_options", rb_funcall(rb_iv_get(stmt_wrapper->client, "@query_options"), rb_intern("dup"), 0));
289-
290-
291-
292-
// mysql2_result_wrapper* result_wrapper;
293-
294-
// GET_CLIENT(stmt_wrapper->client);
295-
// GetMysql2Result(resultObj, result_wrapper);
296-
// result_wrapper->encoding = wrapper->encoding;
297-
298-
299-
// return self;
300-
// return resultObj;
301-
302-
// ===============
303-
304-
305-
306-
307-
// VALUE current;
308-
// current = rb_hash_dup(rb_iv_get(stmt_wrapper->client, "@query_options"));
279+
#ifdef HAVE_RUBY_ENCODING_H
280+
{
281+
mysql2_result_wrapper *result_wrapper;
309282

310-
printf("exiting statement.c\n");
283+
GET_CLIENT(stmt_wrapper->client);
284+
GetMysql2Result(resultObj, result_wrapper);
285+
result_wrapper->encoding = wrapper->encoding;
286+
}
287+
#endif
311288

312289
return resultObj;
313290
}
@@ -360,10 +337,10 @@ static VALUE fields(VALUE self) {
360337
return field_list;
361338
}
362339

340+
#if 0
363341
// FIXME refactor into Mysql2::Result
364342
static VALUE each(VALUE self) {
365343
MYSQL_STMT *stmt;
366-
MYSQL_RES *result;
367344
GET_STATEMENT(self);
368345
stmt = stmt_wrapper->stmt;
369346

@@ -372,7 +349,6 @@ static VALUE each(VALUE self) {
372349
rb_raise(cMysql2Error, "FIXME: current limitation: each require block");
373350
}
374351

375-
result = mysql_stmt_result_metadata(stmt);
376352
if (result) {
377353
MYSQL_BIND *result_buffers;
378354
my_bool *is_null;
@@ -600,6 +576,7 @@ static VALUE each(VALUE self) {
600576

601577
return self;
602578
}
579+
#endif
603580

604581
void init_mysql2_statement() {
605582
cMysql2Statement = rb_define_class_under(mMysql2, "Statement", rb_cObject);
@@ -608,5 +585,5 @@ void init_mysql2_statement() {
608585
rb_define_method(cMysql2Statement, "field_count", field_count, 0);
609586
rb_define_method(cMysql2Statement, "execute", execute, -1);
610587
rb_define_method(cMysql2Statement, "fields", fields, 0);
611-
rb_define_method(cMysql2Statement, "each", each, 0);
588+
// rb_define_method(cMysql2Statement, "each", each, 0);
612589
}

0 commit comments

Comments
 (0)