From e40e7f7bcda2ab65590c0a34bbc7bb483cb1cbb4 Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Wed, 6 Dec 2017 17:08:46 +0100 Subject: [PATCH] Fix wrong value of type YEAR on big endian environment. --- ext/mysql2/result.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mysql2/result.c b/ext/mysql2/result.c index 9224e6548..f93a52f84 100644 --- a/ext/mysql2/result.c +++ b/ext/mysql2/result.c @@ -234,12 +234,12 @@ static void rb_mysql_result_alloc_result_buffers(VALUE self, MYSQL_FIELD *fields wrapper->result_buffers[i].buffer_length = sizeof(signed char); break; case MYSQL_TYPE_SHORT: // short int + case MYSQL_TYPE_YEAR: // short int wrapper->result_buffers[i].buffer = xcalloc(1, sizeof(short int)); wrapper->result_buffers[i].buffer_length = sizeof(short int); break; case MYSQL_TYPE_INT24: // int case MYSQL_TYPE_LONG: // int - case MYSQL_TYPE_YEAR: // int wrapper->result_buffers[i].buffer = xcalloc(1, sizeof(int)); wrapper->result_buffers[i].buffer_length = sizeof(int); break; @@ -365,6 +365,7 @@ static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, co } break; case MYSQL_TYPE_SHORT: // short int + case MYSQL_TYPE_YEAR: // short int if (result_buffer->is_unsigned) { val = UINT2NUM(*((unsigned short int*)result_buffer->buffer)); } else { @@ -373,7 +374,6 @@ static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, co break; case MYSQL_TYPE_INT24: // int case MYSQL_TYPE_LONG: // int - case MYSQL_TYPE_YEAR: // int if (result_buffer->is_unsigned) { val = UINT2NUM(*((unsigned int*)result_buffer->buffer)); } else {