remove cached values for better rbx compatibility (this may come back in the near future)
This commit is contained in:
parent
c110d0d263
commit
d12c5e2e27
|
@ -305,6 +305,7 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
|
||||||
// the below code is largely from do_mysql
|
// the below code is largely from do_mysql
|
||||||
// http://github.com/datamapper/do
|
// http://github.com/datamapper/do
|
||||||
fd = client->net.fd;
|
fd = client->net.fd;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fdset);
|
||||||
FD_SET(fd, &fdset);
|
FD_SET(fd, &fdset);
|
||||||
|
|
|
@ -6,7 +6,6 @@ rb_encoding *binaryEncoding;
|
||||||
|
|
||||||
VALUE cMysql2Result;
|
VALUE cMysql2Result;
|
||||||
VALUE cBigDecimal, cDate, cDateTime;
|
VALUE cBigDecimal, cDate, cDateTime;
|
||||||
VALUE opt_decimal_zero, opt_float_zero, opt_time_year, opt_time_month, opt_utc_offset;
|
|
||||||
extern VALUE mMysql2, cMysql2Client, cMysql2Error;
|
extern VALUE mMysql2, cMysql2Client, cMysql2Error;
|
||||||
static VALUE intern_encoding_from_charset;
|
static VALUE intern_encoding_from_charset;
|
||||||
static ID intern_new, intern_utc, intern_local, intern_encoding_from_charset_code,
|
static ID intern_new, intern_utc, intern_local, intern_encoding_from_charset_code,
|
||||||
|
@ -149,27 +148,19 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
|
||||||
break;
|
break;
|
||||||
case MYSQL_TYPE_DECIMAL: // DECIMAL or NUMERIC field
|
case MYSQL_TYPE_DECIMAL: // DECIMAL or NUMERIC field
|
||||||
case MYSQL_TYPE_NEWDECIMAL: // Precision math DECIMAL or NUMERIC field (MySQL 5.0.3 and up)
|
case MYSQL_TYPE_NEWDECIMAL: // Precision math DECIMAL or NUMERIC field (MySQL 5.0.3 and up)
|
||||||
if (strtod(row[i], NULL) == 0.000000){
|
|
||||||
val = rb_funcall(cBigDecimal, intern_new, 1, opt_decimal_zero);
|
|
||||||
}else{
|
|
||||||
val = rb_funcall(cBigDecimal, intern_new, 1, rb_str_new(row[i], fieldLengths[i]));
|
val = rb_funcall(cBigDecimal, intern_new, 1, rb_str_new(row[i], fieldLengths[i]));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MYSQL_TYPE_FLOAT: // FLOAT field
|
case MYSQL_TYPE_FLOAT: // FLOAT field
|
||||||
case MYSQL_TYPE_DOUBLE: { // DOUBLE or REAL field
|
case MYSQL_TYPE_DOUBLE: { // DOUBLE or REAL field
|
||||||
double column_to_double;
|
double column_to_double;
|
||||||
column_to_double = strtod(row[i], NULL);
|
column_to_double = strtod(row[i], NULL);
|
||||||
if (column_to_double == 0.000000){
|
|
||||||
val = opt_float_zero;
|
|
||||||
}else{
|
|
||||||
val = rb_float_new(column_to_double);
|
val = rb_float_new(column_to_double);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MYSQL_TYPE_TIME: { // TIME field
|
case MYSQL_TYPE_TIME: { // TIME field
|
||||||
int hour, min, sec, tokens;
|
int hour, min, sec, tokens;
|
||||||
tokens = sscanf(row[i], "%2d:%2d:%2d", &hour, &min, &sec);
|
tokens = sscanf(row[i], "%2d:%2d:%2d", &hour, &min, &sec);
|
||||||
val = rb_funcall(rb_cTime, db_timezone, 6, opt_time_year, opt_time_month, opt_time_month, INT2NUM(hour), INT2NUM(min), INT2NUM(sec));
|
val = rb_funcall(rb_cTime, db_timezone, 6, INT2NUM(2000), INT2NUM(1), INT2NUM(1), INT2NUM(hour), INT2NUM(min), INT2NUM(sec));
|
||||||
if (!NIL_P(app_timezone)) {
|
if (!NIL_P(app_timezone)) {
|
||||||
if (app_timezone == intern_local) {
|
if (app_timezone == intern_local) {
|
||||||
val = rb_funcall(val, intern_localtime, 0);
|
val = rb_funcall(val, intern_localtime, 0);
|
||||||
|
@ -201,7 +192,7 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
|
||||||
offset = rb_funcall(cMysql2Client, intern_local_offset, 0);
|
offset = rb_funcall(cMysql2Client, intern_local_offset, 0);
|
||||||
val = rb_funcall(val, intern_new_offset, 1, offset);
|
val = rb_funcall(val, intern_new_offset, 1, offset);
|
||||||
} else { // utc
|
} else { // utc
|
||||||
val = rb_funcall(val, intern_new_offset, 1, opt_utc_offset);
|
val = rb_funcall(val, intern_new_offset, 1, INT2NUM(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -461,14 +452,6 @@ void init_mysql2_result() {
|
||||||
sym_application_timezone = ID2SYM(rb_intern("application_timezone"));
|
sym_application_timezone = ID2SYM(rb_intern("application_timezone"));
|
||||||
sym_cache_rows = ID2SYM(rb_intern("cache_rows"));
|
sym_cache_rows = ID2SYM(rb_intern("cache_rows"));
|
||||||
|
|
||||||
rb_global_variable(&opt_decimal_zero); //never GC
|
|
||||||
opt_decimal_zero = rb_str_new2("0.0");
|
|
||||||
rb_global_variable(&opt_float_zero);
|
|
||||||
opt_float_zero = rb_float_new((double)0);
|
|
||||||
opt_time_year = INT2NUM(2000);
|
|
||||||
opt_time_month = INT2NUM(1);
|
|
||||||
opt_utc_offset = INT2NUM(0);
|
|
||||||
|
|
||||||
#ifdef HAVE_RUBY_ENCODING_H
|
#ifdef HAVE_RUBY_ENCODING_H
|
||||||
binaryEncoding = rb_enc_find("binary");
|
binaryEncoding = rb_enc_find("binary");
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue