Commit a7b46e40 authored by unknown's avatar unknown

Conversion fix - bug report from PHP

Added a new conversion bug test
Changed options with default_options read from my.ini from [client] section
More cleanups for better usage


libmysql/libmysql.c:
  Conversion fix - bug report from PHP
tests/client_test.c:
  Added a new conversion bug test
  Changed options with default_options read from my.ini from [client] section
  More cleanups for better usage
parent 15b099cf
...@@ -163,6 +163,11 @@ void STDCALL mysql_thread_end() ...@@ -163,6 +163,11 @@ void STDCALL mysql_thread_end()
#define reset_sigpipe(mysql) #define reset_sigpipe(mysql)
#endif #endif
#define map_to_size(A,L) {\
char *tmp= (char *)&A;\
memset(tmp+L,0,8-L);\
}
static MYSQL* spawn_init(MYSQL* parent, const char* host, static MYSQL* spawn_init(MYSQL* parent, const char* host,
unsigned int port, unsigned int port,
const char* user, const char* user,
...@@ -4686,13 +4691,13 @@ static void send_data_long(MYSQL_BIND *param, longlong value) ...@@ -4686,13 +4691,13 @@ static void send_data_long(MYSQL_BIND *param, longlong value)
*param->buffer= (uchar) value; *param->buffer= (uchar) value;
break; break;
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
int2store(buffer, (short)value); int2store(buffer, value);
break; break;
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
int4store(buffer, (int32)value); int4store(buffer, value);
break; break;
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
int8store(buffer, (longlong)value); int8store(buffer, value);
break; break;
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
{ {
...@@ -4726,13 +4731,13 @@ static void send_data_double(MYSQL_BIND *param, double value) ...@@ -4726,13 +4731,13 @@ static void send_data_double(MYSQL_BIND *param, double value)
*buffer= (uchar)value; *buffer= (uchar)value;
break; break;
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
int2store(buffer, (short)value); int2store(buffer, value);
break; break;
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
int4store(buffer, (int32)value); int4store(buffer, value);
break; break;
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
int8store(buffer, (longlong)value); int8store(buffer, value);
break; break;
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
{ {
...@@ -4873,24 +4878,24 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row) ...@@ -4873,24 +4878,24 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row)
switch (field_type) { switch (field_type) {
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
{ {
uchar value= (uchar) **row; longlong value= (longlong) **row;
send_data_long(param,(longlong)value); map_to_size(value,(length= 1));
length= 1; send_data_long(param,value);
break; break;
} }
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_YEAR: case MYSQL_TYPE_YEAR:
{ {
short value= (short)sint2korr(*row); longlong value= (longlong)sint2korr(*row);
send_data_long(param,(longlong)value); map_to_size(value,(length= 2));
length= 2; send_data_long(param, value);
break; break;
} }
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
{ {
int32 value= (int32)sint4korr(*row); longlong value= (longlong)sint4korr(*row);
send_data_long(param,(int32)value); map_to_size(value,(length= 4));
length= 4; send_data_long(param,value);
break; break;
} }
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
...@@ -4904,7 +4909,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row) ...@@ -4904,7 +4909,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row)
{ {
float value; float value;
float4get(value,*row); float4get(value,*row);
send_data_double(param,(double)value); send_data_double(param,value);
length= 4; length= 4;
break; break;
} }
...@@ -4912,7 +4917,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row) ...@@ -4912,7 +4917,7 @@ static void fetch_results(MYSQL_BIND *param, uint field_type, uchar **row)
{ {
double value; double value;
float8get(value,*row); float8get(value,*row);
send_data_double(param,(double)value); send_data_double(param,value);
length= 8; length= 8;
break; break;
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment