0
@@ -60,6 +60,7 @@ struct mysql {
0
char query_with_result;
0
@@ -181,7 +182,7 @@ static void mysql_raise(MYSQL* m)
0
-static VALUE mysqlres2obj(MYSQL_RES* res
)
0
+static VALUE mysqlres2obj(MYSQL_RES* res
, VALUE gc_disabled)
0
struct mysql_res* resp;
0
@@ -191,8 +192,9 @@ static VALUE mysqlres2obj(MYSQL_RES* res)
0
rb_obj_call_init(obj, 0, NULL);
0
- if (++store_result_count > GC_STORE_RESULT_LIMIT)
0
+ if (++store_result_count > GC_STORE_RESULT_LIMIT && gc_disabled == Qfalse){
0
@@ -228,6 +230,7 @@ static VALUE init(VALUE klass)
0
mysql_init(&myp->handler);
0
myp->connection = Qfalse;
0
myp->query_with_result = Qtrue;
0
+ myp->gc_disabled = Qfalse;
0
rb_obj_call_init(obj, 0, NULL);
0
@@ -646,7 +649,7 @@ static VALUE list_fields(int argc, VALUE* argv, VALUE obj)
0
res = mysql_list_fields(m, StringValuePtr(table), NILorSTRING(field));
0
- return mysqlres2obj(res
);
0
+ return mysqlres2obj(res
, GetMysqlStruct(obj)->gc_disabled);
0
@@ -656,7 +659,7 @@ static VALUE list_processes(VALUE obj)
0
MYSQL_RES* res = mysql_list_processes(m);
0
- return mysqlres2obj(res
);
0
+ return mysqlres2obj(res
, GetMysqlStruct(obj)->gc_disabled);
0
/* list_tables(table=nil) */
0
@@ -750,7 +753,7 @@ static VALUE store_result(VALUE obj)
0
MYSQL_RES* res = mysql_store_result(m);
0
- return mysqlres2obj(res
);
0
+ return mysqlres2obj(res
, GetMysqlStruct(obj)->gc_disabled);
0
@@ -766,7 +769,7 @@ static VALUE use_result(VALUE obj)
0
MYSQL_RES* res = mysql_use_result(m);
0
- return mysqlres2obj(res
);
0
+ return mysqlres2obj(res
, GetMysqlStruct(obj)->gc_disabled);
0
static VALUE res_free(VALUE);
0
@@ -788,7 +791,7 @@ static VALUE query(VALUE obj, VALUE sql)
0
if (mysql_field_count(m) != 0)
0
- VALUE robj = mysqlres2obj(res
);
0
+ VALUE robj = mysqlres2obj(res
, GetMysqlStruct(obj)->gc_disabled);
0
rb_ensure(rb_yield, robj, res_free, robj);
0
#if MYSQL_VERSION_ID >= 40101
0
@@ -859,6 +862,20 @@ static VALUE reconnected( VALUE obj ){
0
return ( current_connection_id == mysql_thread_id( m ) ) ? Qfalse : Qtrue;
0
+/* disable_gc(true|false) */
0
+static VALUE disable_gc_set(VALUE obj, VALUE flag)
0
+ if (TYPE(flag) != T_TRUE && TYPE(flag) != T_FALSE)
0
+ rb_raise(rb_eTypeError, "invalid type, required true or false.");
0
+ GetMysqlStruct(obj)->gc_disabled = flag;
0
+static VALUE gc_disabled( VALUE obj ){
0
+ return GetMysqlStruct(obj)->gc_disabled ? Qtrue: Qfalse;
0
static void validate_async_query( VALUE obj )
0
MYSQL* m = GetHandler(obj);
0
@@ -1986,7 +2003,7 @@ static VALUE stmt_result_metadata(VALUE obj)
0
mysql_stmt_raise(s->stmt);
0
- return mysqlres2obj(res
);
0
+ return mysqlres2obj(res
, Qfalse);
0
@@ -2254,6 +2271,8 @@ void Init_mysql(void)
0
rb_define_method(cMysql, "retry?", retry, 0);
0
rb_define_method(cMysql, "interrupted?", interrupted, 0);
0
rb_define_method(cMysql, "blocking?", blocking, 0);
0
+ rb_define_method(cMysql, "gc_disabled?", gc_disabled, 0);
0
+ rb_define_method(cMysql, "disable_gc=", disable_gc_set, 1);
0
rb_define_method(cMysql, "socket", socket, 0);
0
rb_define_method(cMysql, "refresh", refresh, 1);
0
rb_define_method(cMysql, "reload", reload, 0);