From 1d20b6ffd548d87f20ae999d54fef41f0c696ee0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Mar 2008 16:27:35 +0200 Subject: [PATCH] Bug #33544: UDF_INIT member decimals initialized wrong with STRING_RESULT argument There is a "magic" number for precision : NOT_FIXED_DEC. This means that the precision is not a fixed number. But this constant was re-defined in several files and was not available to the UDF developers. Moved the NOT_FIXED_DEC definition to the correct header and removed the redundant definitions. client/sql_string.cc: Bug #33544: moved NOT_FIXED_DEC to the correct header client/sql_string.h: Bug #33544: moved NOT_FIXED_DEC to the correct header include/mysql_com.h: Bug #33544: moved NOT_FIXED_DEC to the correct header libmysql/libmysql.c: Bug #33544: moved NOT_FIXED_DEC to the correct header sql/field.h: Bug #33544: moved NOT_FIXED_DEC to the correct header sql/sql_string.cc: Bug #33544: moved NOT_FIXED_DEC to the correct header sql/sql_string.h: Bug #33544: moved NOT_FIXED_DEC to the correct header storage/ndb/include/kernel/signaldata/DictTabInfo.hpp: Bug #33544: moved NOT_FIXED_DEC to the correct header --- client/sql_string.cc | 1 + client/sql_string.h | 4 ---- include/mysql_com.h | 1 + libmysql/libmysql.c | 3 --- sql/field.h | 1 - sql/sql_string.cc | 1 + sql/sql_string.h | 4 ---- storage/ndb/include/kernel/signaldata/DictTabInfo.hpp | 4 ---- 8 files changed, 3 insertions(+), 16 deletions(-) diff --git a/client/sql_string.cc b/client/sql_string.cc index c41463999aa..9ccccca6f73 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef HAVE_FCONVERT #include #endif diff --git a/client/sql_string.h b/client/sql_string.h index da19c1ccfe5..f134e59e6b2 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -19,10 +19,6 @@ #pragma interface /* gcc class implementation */ #endif -#ifndef NOT_FIXED_DEC -#define NOT_FIXED_DEC 31 -#endif - class String; int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); diff --git a/include/mysql_com.h b/include/mysql_com.h index 7eefad44716..60f6660c789 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -468,4 +468,5 @@ uchar *net_store_length(uchar *pkg, ulonglong length); #define MYSQL_STMT_HEADER 4 #define MYSQL_LONG_DATA_HEADER 6 +#define NOT_FIXED_DEC 31 #endif diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index a1fb1d8a3c4..7d438612251 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3794,10 +3794,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, */ char buff[MAX_DOUBLE_STRING_REP_LENGTH]; char *end; - /* TODO: move this to a header shared between client and server. */ -#define NOT_FIXED_DEC 31 if (field->decimals >= NOT_FIXED_DEC) -#undef NOT_FIXED_DEC { /* The 14 below is to ensure that the server and client has the same diff --git a/sql/field.h b/sql/field.h index 9855ec563d5..c3a90dc0754 100644 --- a/sql/field.h +++ b/sql/field.h @@ -23,7 +23,6 @@ #pragma interface /* gcc class implementation */ #endif -#define NOT_FIXED_DEC 31 #define DATETIME_DEC 6 const uint32 max_field_size= (uint32) 4294967295U; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 7fa3786c382..d2899f496a5 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef HAVE_FCONVERT #include #endif diff --git a/sql/sql_string.h b/sql/sql_string.h index 128ed749b5f..19d63a94f54 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -19,10 +19,6 @@ #pragma interface /* gcc class implementation */ #endif -#ifndef NOT_FIXED_DEC -#define NOT_FIXED_DEC 31 -#endif - class String; int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); diff --git a/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp b/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp index 3923d8e6fbf..43de91b7c22 100644 --- a/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -30,10 +30,6 @@ #define DECIMAL_MAX_LENGTH ((8 * 9) - 8) -#ifndef NOT_FIXED_DEC -#define NOT_FIXED_DEC 31 -#endif - C_MODE_START extern int decimal_bin_size(int, int); C_MODE_END