Created
January 3, 2009 17:55
-
-
Save gwik/42909 to your computer and use it in GitHub Desktop.
Patch for mysql-ruby-2.6 to work with ruby 1.9.1rc1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 7df6d1b37b57476771ee7ae764e3236eb0d22e8f | |
Author: Antonin Amand <[email protected]> | |
Date: Sat Jan 3 18:42:57 2009 +0100 | |
fixes for 1.9 | |
diff --git a/extconf.rb b/extconf.rb | |
index bc00612..f502d4f 100644 | |
--- a/extconf.rb | |
+++ b/extconf.rb | |
@@ -67,4 +67,6 @@ File.open('error_const.h', 'w') do |f| | |
end | |
end | |
+have_func('rb_thread_start_timer') | |
+ | |
create_makefile("mysql") | |
diff --git a/mysql.c b/mysql.c | |
index ba1e06b..4d138b0 100644 | |
--- a/mysql.c | |
+++ b/mysql.c | |
@@ -12,6 +12,9 @@ | |
#ifndef HAVE_RB_STR_SET_LEN | |
#define rb_str_set_len(str, length) (RSTRING_LEN(str) = (length)) | |
#endif | |
+#ifndef RARRAY_PTR | |
+#define RARRAY_PTR(ary) RARRAY(ary)->ptr | |
+#endif | |
#ifdef HAVE_MYSQL_H | |
#include <mysql.h> | |
@@ -248,7 +251,9 @@ static VALUE real_connect(int argc, VALUE* argv, VALUE klass) | |
pp = NILorINT(port); | |
s = NILorSTRING(sock); | |
+#if HAVE_RB_THREAD_START_TIMER | |
rb_thread_stop_timer(); | |
+#endif | |
obj = Data_Make_Struct(klass, struct mysql, 0, free_mysql, myp); | |
#if MYSQL_VERSION_ID >= 32200 | |
mysql_init(&myp->handler); | |
@@ -259,10 +264,14 @@ static VALUE real_connect(int argc, VALUE* argv, VALUE klass) | |
if (mysql_real_connect(&myp->handler, h, u, p, pp, s) == NULL) | |
#endif | |
{ | |
+#if HAVE_RB_THREAD_START_TIMER | |
rb_thread_start_timer(); | |
+#endif | |
mysql_raise(&myp->handler); | |
} | |
+#if HAVE_RB_THREAD_START_TIMER | |
rb_thread_start_timer(); | |
+#endif | |
myp->handler.reconnect = 0; | |
myp->connection = Qtrue; | |
@@ -326,12 +335,18 @@ static VALUE real_connect2(int argc, VALUE* argv, VALUE obj) | |
pp = NILorINT(port); | |
s = NILorSTRING(sock); | |
+#if HAVE_RB_THREAD_START_TIMER | |
rb_thread_stop_timer(); | |
+#endif | |
if (mysql_real_connect(m, h, u, p, d, pp, s, f) == NULL) { | |
+#if HAVE_RB_THREAD_START_TIMER | |
rb_thread_start_timer(); | |
+#endif | |
mysql_raise(m); | |
} | |
+#if HAVE_RB_THREAD_START_TIMER | |
rb_thread_start_timer(); | |
+#endif | |
m->reconnect = 0; | |
GetMysqlStruct(obj)->connection = Qtrue; | |
@@ -1389,12 +1404,12 @@ static VALUE stmt_execute(int argc, VALUE *argv, VALUE obj) | |
s->param.bind[i].buffer = &(s->param.buffer[i]); | |
t.second_part = 0; | |
t.neg = 0; | |
- t.second = FIX2INT(RARRAY(a)->ptr[0]); | |
- t.minute = FIX2INT(RARRAY(a)->ptr[1]); | |
- t.hour = FIX2INT(RARRAY(a)->ptr[2]); | |
- t.day = FIX2INT(RARRAY(a)->ptr[3]); | |
- t.month = FIX2INT(RARRAY(a)->ptr[4]); | |
- t.year = FIX2INT(RARRAY(a)->ptr[5]); | |
+ t.second = FIX2INT(RARRAY_PTR(a)[0]); | |
+ t.minute = FIX2INT(RARRAY_PTR(a)[1]); | |
+ t.hour = FIX2INT(RARRAY_PTR(a)[2]); | |
+ t.day = FIX2INT(RARRAY_PTR(a)[3]); | |
+ t.month = FIX2INT(RARRAY_PTR(a)[4]); | |
+ t.year = FIX2INT(RARRAY_PTR(a)[5]); | |
*(MYSQL_TIME*)&(s->param.buffer[i]) = t; | |
} else if (CLASS_OF(argv[i]) == cMysqlTime) { | |
MYSQL_TIME t; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment