Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created September 14, 2008 01:26
Show Gist options
  • Save methodmissing/10681 to your computer and use it in GitHub Desktop.
Save methodmissing/10681 to your computer and use it in GitHub Desktop.
diff --git a/ext/mysql.c b/ext/mysql.c
index b804723..d957978 100644
--- a/ext/mysql.c
+++ b/ext/mysql.c
@@ -798,13 +798,16 @@ static VALUE send_query(VALUE obj, VALUE sql)
{
MYSQL* m = GetHandler(obj);
+ free_old_query(m);
+
Check_Type(sql, T_STRING);
if (GetMysqlStruct(obj)->connection == Qfalse) {
rb_raise(eMysql, "query: not connected");
}
- if (mysql_send_query(m, RSTRING_PTR(sql), RSTRING_LEN(sql)) != 0)
- mysql_raise(m);
- return Qnil;
+ if (mysql_send_query(m, RSTRING_PTR(sql), RSTRING_LEN(sql)) != 0)
+ mysql_raise(m);
+ GetMysqlStruct(obj)->query_with_result = Qtrue;
+ return Qnil;
}
/* get_result */
@@ -814,8 +817,8 @@ static VALUE get_result(VALUE obj)
if (GetMysqlStruct(obj)->connection == Qfalse) {
rb_raise(eMysql, "query: not connected");
}
- if (mysql_read_query_result(m) != 0)
- mysql_raise(m);
+ if (mysql_read_query_result(m) != 0)
+ mysql_raise(m);
if (GetMysqlStruct(obj)->query_with_result == Qfalse)
return obj;
if (mysql_field_count(m) == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment