From d5237fd09f71ccc8e008118607f8f22af4be630e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Apr 2004 03:00:19 +0400 Subject: Fix for Bug#3035 "Prepared statement integer inserts": now unsigned flag is sent to server with placeholder types. There were no need to extend the protocol as one additional byte was reserved for placeholder code, when placeholder code is in range 0-255. So this byte is now used for flags. Post-review fixes added. include/config-win.h: added floaststore implementation include/my_global.h: added floatstore implementation include/mysql.h: Bug#3035: added 'is_unsigned' member binary_data wasn't used, removed null_field wasn't necessary, removed include/mysql_com.h: Unused defines were removed. libmysql/libmysql.c: Function store_param_type was removed - too much for a function, especially with bug in it. New implementation is inline and takes into account signedness of placeholder. Fixed store functions to not perform double network-host order conversion on high-byte-first systems (should also fix Bug#3578 "Prepared statement integer conversions work wrong in 64-bit Power Mac G5 CPUs"). null_field removed. sql/sql_prepare.cc: Placeholder sign is taken into account when reading data from network. tests/client_test.c: Test for BUG#3035 added: insert and retrieve minimum and maximum of all integer types. --- include/config-win.h | 1 + include/my_global.h | 9 +++++++++ include/mysql.h | 3 +-- include/mysql_com.h | 11 ----------- 4 files changed, 11 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/config-win.h b/include/config-win.h index 518f445861a..0298c9012ce 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -252,6 +252,7 @@ inline double ulonglong2double(ulonglong value) #define doublestore(T,V) { *((long *) T) = *((long*) &V); \ *(((long *) T)+1) = *(((long*) &V)+1); } #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); } +#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float)) #define float8get(V,M) doubleget((V),(M)) #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) #define float8store(V,M) doublestore((V),(M)) diff --git a/include/my_global.h b/include/my_global.h index 6a5b7663c66..7540897e6f4 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -964,10 +964,15 @@ do { doubleget_union _tmp; \ #define float4get(V,M) do { *((long *) &(V)) = *((long*) (M)); } while(0) #define float8get(V,M) doubleget((V),(M)) #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) +#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float)) #define float8store(V,M) doublestore((V),(M)) #endif /* __i386__ */ #ifndef sint2korr +/* + We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines + were done before) +*/ #define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\ ((int16) ((int16) (A)[1]) << 8)) #define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ @@ -1121,6 +1126,7 @@ do { doubleget_union _tmp; \ *((T)+1)=(((A) >> 16));\ *((T)+0)=(((A) >> 24)); } while(0) +#define floatstore(T,V) memcpy_fixed((byte*)(T), (byte*)(&V), sizeof(float)) #define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) #define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) @@ -1134,6 +1140,9 @@ do { doubleget_union _tmp; \ #define ulongget(V,M) do { V = uint4korr(M); } while(0) #define shortstore(T,V) int2store(T,V) #define longstore(T,V) int4store(T,V) +#ifndef floatstore +#define floatstore(T,V) memcpy_fixed((byte*)(T), (byte*)(&V), sizeof(float)) +#endif #ifndef doubleget #define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) diff --git a/include/mysql.h b/include/mysql.h index 852d633facf..b8476682bb3 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -547,9 +547,8 @@ typedef struct st_mysql_bind unsigned long offset; /* offset position for char/binary fetch */ unsigned long internal_length; /* Used if length is 0 */ unsigned int param_number; /* For null count and error messages */ + my_bool is_unsigned; /* set if integer type is unsigned */ my_bool long_data_used; /* If used with mysql_send_long_data */ - my_bool binary_data; /* data buffer is binary */ - my_bool null_field; /* NULL data cache flag */ my_bool internal_is_null; /* Used if is_null is 0 */ void (*store_param_func)(NET *net, struct st_mysql_bind *param); void (*fetch_result)(struct st_mysql_bind *, unsigned char **row); diff --git a/include/mysql_com.h b/include/mysql_com.h index 578ef964d8d..ada2bd1f679 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -223,17 +223,6 @@ enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, #define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM #define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY -#if TO_BE_INCLUDED_LATER -/* For bind applications, to indicate unsigned buffers */ -#define MYSQL_TYPE_UTINY -10 -#define MYSQL_TYPE_USHORT -9 -#define MYSQL_TYPE_ULONG -8 -#define MYSQL_TYPE_UFLOAT -7 -#define MYSQL_TYPE_UDOUBLE -6 -#define MYSQL_TYPE_ULONGLONG -5 -#define MYSQL_TYPE_UINT24 -4 -#endif - /* options for mysql_set_option */ enum enum_mysql_set_option { -- cgit v1.2.1