summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCMakeLists.txt8
-rw-r--r--client/Makefile.am2
-rw-r--r--client/sql_string.cc80
-rw-r--r--configure.in17
-rw-r--r--include/atomic/x86-gcc.h2
-rw-r--r--include/m_string.h37
-rw-r--r--include/myisam.h2
-rwxr-xr-xlibmysql/CMakeLists.txt4
-rw-r--r--libmysql/Makefile.shared4
-rw-r--r--libmysql/client_settings.h3
-rw-r--r--libmysql/libmysql.c54
-rw-r--r--libmysqld/libmysqld.def1
-rw-r--r--mysql-test/collections/default.experimental1
-rw-r--r--mysql-test/include/check_key_reads.inc6
-rw-r--r--mysql-test/include/check_key_req.inc9
-rw-r--r--mysql-test/include/handler.inc9
-rw-r--r--mysql-test/r/archive_gis.result8
-rw-r--r--mysql-test/r/cast.result10
-rw-r--r--mysql-test/r/exampledb.result8
-rw-r--r--mysql-test/r/func_group.result18
-rw-r--r--mysql-test/r/func_math.result34
-rw-r--r--mysql-test/r/func_str.result4
-rw-r--r--mysql-test/r/gis.result12
-rw-r--r--mysql-test/r/handler_innodb.result8
-rw-r--r--mysql-test/r/handler_myisam.result8
-rw-r--r--mysql-test/r/innodb_gis.result8
-rw-r--r--mysql-test/r/insert.result70
-rw-r--r--mysql-test/r/loaddata.result6
-rw-r--r--mysql-test/r/mysqlbinlog_row_innodb.result32
-rw-r--r--mysql-test/r/mysqlbinlog_row_myisam.result32
-rw-r--r--mysql-test/r/mysqldump.result2
-rw-r--r--mysql-test/r/not_partition.result8
-rw-r--r--mysql-test/r/parser.result4
-rw-r--r--mysql-test/r/partition_column.result40
-rw-r--r--mysql-test/r/partition_key_cache.result417
-rw-r--r--mysql-test/r/partition_range.result37
-rw-r--r--mysql-test/r/partition_utf8.result6
-rw-r--r--mysql-test/r/ps_2myisam.result74
-rw-r--r--mysql-test/r/ps_3innodb.result74
-rw-r--r--mysql-test/r/ps_4heap.result68
-rw-r--r--mysql-test/r/ps_5merge.result148
-rw-r--r--mysql-test/r/query_cache.result107
-rw-r--r--mysql-test/r/select.result14
-rw-r--r--mysql-test/r/show_check.result15
-rw-r--r--mysql-test/r/sp.result20
-rw-r--r--mysql-test/r/strict.result14
-rw-r--r--mysql-test/r/type_decimal.result12
-rw-r--r--mysql-test/r/type_float.result82
-rw-r--r--mysql-test/r/type_newdecimal.result124
-rw-r--r--mysql-test/r/variables.result2
-rw-r--r--mysql-test/r/view.result2
-rw-r--r--mysql-test/std_data/ndb_backup51_data_be/BACKUP-1-0.1.Databin43068 -> 43068 bytes
-rw-r--r--mysql-test/std_data/ndb_backup51_data_le/BACKUP-1-0.2.Databin49556 -> 49556 bytes
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_func_view.result144
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_views.result12
-rw-r--r--mysql-test/suite/funcs_1/r/memory_func_view.result144
-rw-r--r--mysql-test/suite/funcs_1/r/memory_views.result12
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_func_view.result144
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_views.result12
-rw-r--r--mysql-test/suite/funcs_1/r/ndb_func_view.result144
-rw-r--r--mysql-test/suite/funcs_1/r/ndb_views.result12
-rw-r--r--mysql-test/suite/funcs_1/r/storedproc.result11
-rw-r--r--mysql-test/suite/ndb/r/ndb_gis.result16
-rw-r--r--mysql-test/suite/ndb/r/ndb_restore_different_endian_data.result4
-rw-r--r--mysql-test/suite/ndb/r/ps_7ndb.result74
-rw-r--r--mysql-test/suite/parts/r/partition_float_innodb.result50
-rw-r--r--mysql-test/suite/parts/r/partition_float_myisam.result50
-rw-r--r--mysql-test/suite/rpl/t/rpl_view_multi.test4
-rw-r--r--mysql-test/t/cast.test2
-rw-r--r--mysql-test/t/disabled.def1
-rw-r--r--mysql-test/t/exampledb.test22
-rw-r--r--mysql-test/t/gis.test3
-rw-r--r--mysql-test/t/insert.test6
-rw-r--r--mysql-test/t/mysqldump.test3
-rw-r--r--mysql-test/t/not_partition.test8
-rw-r--r--mysql-test/t/parser.test4
-rw-r--r--mysql-test/t/partition_column.test17
-rw-r--r--mysql-test/t/partition_key_cache.test251
-rw-r--r--mysql-test/t/partition_range.test13
-rw-r--r--mysql-test/t/query_cache.test112
-rw-r--r--mysql-test/t/show_check.test10
-rw-r--r--mysql-test/t/type_decimal.test12
-rw-r--r--mysql-test/t/type_float.test33
-rw-r--r--mysql-test/t/type_newdecimal.test6
-rw-r--r--mysys/hash.c16
-rw-r--r--plugin/semisync/CMakeLists.txt3
-rwxr-xr-xscripts/make_win_bin_dist19
-rw-r--r--sql/field.cc243
-rw-r--r--sql/item.cc13
-rw-r--r--sql/item.h9
-rw-r--r--sql/item_timefunc.h9
-rw-r--r--sql/log_event.cc6
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc67
-rw-r--r--sql/partition_info.cc36
-rw-r--r--sql/partition_info.h1
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/spatial.cc23
-rw-r--r--sql/sql_delete.cc10
-rw-r--r--sql/sql_show.cc5
-rw-r--r--sql/sql_string.cc80
-rw-r--r--sql/sql_yacc.yy118
-rw-r--r--sql/unireg.h1
-rw-r--r--storage/archive/Makefile.am7
-rw-r--r--storage/ibmdb2i/db2i_charsetSupport.cc12
-rw-r--r--storage/ibmdb2i/db2i_constraints.cc10
-rw-r--r--storage/ibmdb2i/ha_ibmdb2i.cc12
-rw-r--r--storage/innobase/CMakeLists.txt8
-rw-r--r--storage/myisam/mi_packrec.c16
-rw-r--r--storage/myisam/mi_static.c1
-rwxr-xr-xstrings/CMakeLists.txt4
-rw-r--r--strings/Makefile.am6
-rw-r--r--strings/decimal.c45
-rw-r--r--strings/dtoa.c2780
-rw-r--r--strings/strtod.c236
-rw-r--r--support-files/mysql.server.sh2
-rw-r--r--support-files/mysql.spec.sh31
-rw-r--r--tests/mysql_client_test.c2
118 files changed, 5128 insertions, 1809 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e8c7db3c2a..4a02a5ca0a9 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -107,6 +107,14 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7")
MESSAGE("Warning: Building MySQL with Visual Studio 2003.NET is no more supported.")
MESSAGE("Please use a newer version of Visual Studio.")
SET(WITHOUT_DYNAMIC_PLUGINS TRUE)
+
+ # VS2003 needs the /Op compiler option to disable floating point optimizations
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Op")
+ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Op")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Op")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Op")
+ SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Op")
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Op")
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7")
# Settings for Visual Studio 7 and above.
diff --git a/client/Makefile.am b/client/Makefile.am
index cfc322c2531..feb71a491e4 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -109,7 +109,7 @@ sql_src=log_event.h mysql_priv.h rpl_constants.h \
log_event_old.h log_event_old.cc \
rpl_record_old.h rpl_record_old.cc \
transaction.h
-strings_src=decimal.c
+strings_src=decimal.c dtoa.c
link_sources:
for f in $(sql_src) ; do \
diff --git a/client/sql_string.cc b/client/sql_string.cc
index 3292bc7e6f2..ccbc8977e7f 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -24,10 +24,6 @@
#include <m_string.h>
#include <m_ctype.h>
#include <mysql_com.h>
-#ifdef HAVE_FCONVERT
-#include <floatingpoint.h>
-#endif
-
/*
The following extern declarations are ok as these are interface functions
required by the string function
@@ -117,82 +113,19 @@ bool String::set(ulonglong num, CHARSET_INFO *cs)
bool String::set(double num,uint decimals, CHARSET_INFO *cs)
{
- char buff[331];
+ char buff[FLOATING_POINT_BUFFER];
uint dummy_errors;
+ size_t len;
str_charset=cs;
if (decimals >= NOT_FIXED_DEC)
{
- uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
+ len= my_gcvt(num, MY_GCVT_ARG_DOUBLE, sizeof(buff) - 1, buff, NULL);
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
}
-#ifdef HAVE_FCONVERT
- int decpt,sign;
- char *pos,*to;
-
- (void) fconvert(num,(int) decimals,&decpt,&sign,buff+1);
- if (!my_isdigit(&my_charset_latin1, buff[1]))
- { // Nan or Inf
- pos=buff+1;
- if (sign)
- {
- buff[0]='-';
- pos=buff;
- }
- uint dummy_errors;
- return copy(pos,(uint32) strlen(pos), &my_charset_latin1, cs, &dummy_errors);
- }
- if (alloc((uint32) ((uint32) decpt+3+decimals)))
- return TRUE;
- to=Ptr;
- if (sign)
- *to++='-';
-
- pos=buff+1;
- if (decpt < 0)
- { /* value is < 0 */
- *to++='0';
- if (!decimals)
- goto end;
- *to++='.';
- if ((uint32) -decpt > decimals)
- decpt= - (int) decimals;
- decimals=(uint32) ((int) decimals+decpt);
- while (decpt++ < 0)
- *to++='0';
- }
- else if (decpt == 0)
- {
- *to++= '0';
- if (!decimals)
- goto end;
- *to++='.';
- }
- else
- {
- while (decpt-- > 0)
- *to++= *pos++;
- if (!decimals)
- goto end;
- *to++='.';
- }
- while (decimals--)
- *to++= *pos++;
-
-end:
- *to=0;
- str_length=(uint32) (to-Ptr);
- return FALSE;
-#else
-#ifdef HAVE_SNPRINTF
- buff[sizeof(buff)-1]=0; // Safety
- snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num);
-#else
- sprintf(buff,"%.*f",(int) decimals,num);
-#endif
- return copy(buff,(uint32) strlen(buff), &my_charset_latin1, cs,
+ len= my_fcvt(num, decimals, buff, NULL);
+ return copy(buff, (uint32) len, &my_charset_latin1, cs,
&dummy_errors);
-#endif
}
@@ -675,7 +608,8 @@ void String::qs_append(const char *str, uint32 len)
void String::qs_append(double d)
{
char *buff = Ptr + str_length;
- str_length+= my_sprintf(buff, (buff, "%.15g", d));
+ str_length+= my_gcvt(d, MY_GCVT_ARG_DOUBLE, FLOATING_POINT_BUFFER - 1, buff,
+ NULL);
}
void String::qs_append(double *d)
diff --git a/configure.in b/configure.in
index 402280392ba..ff6b486defb 100644
--- a/configure.in
+++ b/configure.in
@@ -375,6 +375,21 @@ case "$target_os" in
fi
;;
esac
+
+# The following is required for portable results of floating point calculations
+# on PowerPC. The same must also be done for IA-64, but this options is missing
+# in the IA-64 gcc backend.
+
+if test "$GCC" = "yes"
+then
+ case "$host_cpu" in
+ *ppc* | *powerpc*)
+ CFLAGS="$CFLAGS -mno-fused-madd"
+ CXXFLAGS="$CXXFLAGS -mno-fused-madd"
+ ;;
+ esac
+fi
+
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(CXX)
@@ -2236,7 +2251,7 @@ AC_FUNC_VPRINTF
AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
chsize cuserid fchmod fcntl \
- fconvert fdatasync fesetround finite fpresetsticky fpsetmask fsync ftruncate \
+ fdatasync fesetround finite fpresetsticky fpsetmask fsync ftruncate \
getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \
getpwuid getrlimit getrusage getwd index initgroups isnan \
localtime_r gethrtime gmtime_r \
diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h
index 32839e0a67d..77c32f8d70c 100644
--- a/include/atomic/x86-gcc.h
+++ b/include/atomic/x86-gcc.h
@@ -108,7 +108,7 @@
int32 ebx=(set & 0xFFFFFFFF), ecx=(set >> 32); \
asm volatile ("push %%ebx; movl %3, %%ebx;" \
LOCK_prefix "; cmpxchg8b %0; setz %2; pop %%ebx"\
- : "+m" (*a), "+A" (*cmp), "=q" (ret) \
+ : "+m" (*a), "+A" (*cmp), "=c" (ret) \
:"m" (ebx), "c" (ecx))
#endif
diff --git a/include/m_string.h b/include/m_string.h
index a6a36f32ca4..45801ff85b7 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -92,9 +92,6 @@ extern char *stpcpy(char *, const char *); /* For AIX with gcc 2.95.3 */
extern char NEAR _dig_vec_upper[];
extern char NEAR _dig_vec_lower[];
-/* Defined in strtod.c */
-extern const double log_10[309];
-
#ifdef BAD_STRING_COMPILER
#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
#else
@@ -199,8 +196,42 @@ extern char *strstr(const char *, const char *);
extern int is_prefix(const char *, const char *);
/* Conversion routines */
+typedef enum {
+ MY_GCVT_ARG_FLOAT,
+ MY_GCVT_ARG_DOUBLE
+} my_gcvt_arg_type;
+
double my_strtod(const char *str, char **end, int *error);
double my_atof(const char *nptr);
+size_t my_fcvt(double x, int precision, char *to, my_bool *error);
+size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
+ my_bool *error);
+
+#define NOT_FIXED_DEC 31
+
+/*
+ The longest string my_fcvt can return is 311 + "precision" bytes.
+ Here we assume that we never cal my_fcvt() with precision >= NOT_FIXED_DEC
+ (+ 1 byte for the terminating '\0').
+*/
+#define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
+
+/*
+ We want to use the 'e' format in some cases even if we have enough space
+ for the 'f' one just to mimic sprintf("%.15g") behavior for large integers,
+ and to improve it for numbers < 10^(-4).
+ That is, for |x| < 1 we require |x| >= 10^(-15), and for |x| > 1 we require
+ it to be integer and be <= 10^DBL_DIG for the 'f' format to be used.
+ We don't lose precision, but make cases like "1e200" or "0.00001" look nicer.
+*/
+#define MAX_DECPT_FOR_F_FORMAT DBL_DIG
+
+/*
+ The maximum possible field width for my_gcvt() conversion.
+ (DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
+ MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
+*/
+#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + max(5, MAX_DECPT_FOR_F_FORMAT)) \
extern char *llstr(longlong value,char *buff);
extern char *ullstr(longlong value,char *buff);
diff --git a/include/myisam.h b/include/myisam.h
index e9d1e4ab43e..e6404cb5405 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -260,7 +260,7 @@ extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size;
/* which is normally forbidden */
extern int (*myisam_test_invalid_symlink)(const char *filename);
extern ulonglong myisam_mmap_size, myisam_mmap_used;
-extern pthread_mutex_t THR_LOCK_myisam_mmap;
+extern mysql_mutex_t THR_LOCK_myisam_mmap;
/* Prototypes for myisam-functions */
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 84ad50e03e3..d49ba74d89f 100755
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -69,7 +69,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c
../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c
../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c
- ../mysys/default.c errmsg.c ../mysys/errors.c
+ ../mysys/default.c ../strings/dtoa.c errmsg.c ../mysys/errors.c
../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c
get_password.c ../strings/int2str.c ../strings/is_prefix.c
libmysql.c ../mysys/list.c ../strings/llstr.c
@@ -92,7 +92,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c
../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c
../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c
- ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c
+ ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c
../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/mf_qsort.c
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index b626d3343ce..dbe801ecd17 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -35,7 +35,7 @@ target_sources = libmysql.c password.c \
get_password.c errmsg.c
mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
- strmake.lo strend.lo strtod.lo \
+ strmake.lo strend.lo \
strnlen.lo strfill.lo is_prefix.lo \
int2str.lo str2int.lo strinstr.lo strcont.lo \
strcend.lo bcmp.lo ctype-latin1.lo \
@@ -46,7 +46,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
ctype-win1250ch.lo ctype-utf8.lo ctype-extra.lo \
ctype-ucs2.lo ctype-gb2312.lo ctype-gbk.lo \
ctype-sjis.lo ctype-tis620.lo ctype-ujis.lo \
- ctype-uca.lo xml.lo my_strtoll10.lo str_alloc.lo
+ ctype-uca.lo xml.lo my_strtoll10.lo str_alloc.lo dtoa.lo
mystringsextra= strto.c
dbugobjects = dbug.lo # IT IS IN SAFEMALLOC.C sanity.lo
diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h
index aaec08d1b1e..fa92dfb2687 100644
--- a/libmysql/client_settings.h
+++ b/libmysql/client_settings.h
@@ -27,8 +27,7 @@ extern char * mysql_unix_port;
CLIENT_TRANSACTIONS | \
CLIENT_PROTOCOL_41 | \
CLIENT_SECURE_CONNECTION | \
- CLIENT_MULTI_RESULTS | \
- CLIENT_PS_MULTI_RESULTS)
+ CLIENT_MULTI_RESULTS)
sig_handler my_pipe_sig_handler(int sig);
void read_user_name(char *name);
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 6f5fcd187b7..ec7263e2dd8 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -3372,12 +3372,13 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
param output buffer descriptor
field column metadata
value column data
- width default number of significant digits used when converting
- float/double to string
+ type either MY_GCVT_ARG_FLOAT or MY_GCVT_ARG_DOUBLE.
+ Affects the maximum number of significant digits
+ returned by my_gcvt().
*/
static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
- double value, int width)
+ double value, my_gcvt_arg_type type)
{
char *buffer= (char *)param->buffer;
double val64 = (value < 0 ? -floor(-value) : floor(value));
@@ -3461,39 +3462,24 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
floating point -> string conversion nicely, honor all typecodes
and param->offset possibly set in mysql_stmt_fetch_column
*/
- char buff[MAX_DOUBLE_STRING_REP_LENGTH];
- char *end;
+ char buff[FLOATING_POINT_BUFFER];
+ size_t len;
if (field->decimals >= NOT_FIXED_DEC)
- {
- /*
- DBL_DIG below is to ensure that the server and client has the same
- precisions. This will ensure that on the same machine you get the
- same value as a string independent of the protocol you use.
- */
- sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
- param->buffer_length),
- min(DBL_DIG, width), value);
- end= strcend(buff, ' ');
- *end= 0;
- }
+ len= my_gcvt(value, type,
+ (int) min(sizeof(buff)-1, param->buffer_length),
+ buff, NULL);
else
- {
- sprintf(buff, "%.*f", (int) field->decimals, value);
- end= strend(buff);
- }
+ len= my_fcvt(value, (int) field->decimals, buff, NULL);
+ if (field->flags & ZEROFILL_FLAG && len < field->length &&
+ field->length < MAX_DOUBLE_STRING_REP_LENGTH - 1)
{
- size_t length= end - buff;
- if (field->flags & ZEROFILL_FLAG && length < field->length &&
- field->length < MAX_DOUBLE_STRING_REP_LENGTH - 1)
- {
- bmove_upp((uchar*) buff + field->length, (uchar*) buff + length,
- length);
- bfill((char*) buff, field->length - length, '0');
- length= field->length;
- }
- fetch_string_with_conversion(param, buff, length);
+ bmove_upp((uchar*) buff + field->length, (uchar*) buff + len,
+ len);
+ bfill((char*) buff, field->length - len, '0');
+ len= field->length;
}
+ fetch_string_with_conversion(param, buff, len);
break;
}
@@ -3538,7 +3524,7 @@ static void fetch_datetime_with_conversion(MYSQL_BIND *param,
{
ulonglong value= TIME_to_ulonglong(my_time);
fetch_float_with_conversion(param, field,
- ulonglong2double(value), DBL_DIG);
+ ulonglong2double(value), MY_GCVT_ARG_DOUBLE);
break;
}
case MYSQL_TYPE_TINY:
@@ -3632,7 +3618,7 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
{
float value;
float4get(value,*row);
- fetch_float_with_conversion(param, field, value, FLT_DIG);
+ fetch_float_with_conversion(param, field, value, MY_GCVT_ARG_FLOAT);
*row+= 4;
break;
}
@@ -3640,7 +3626,7 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
{
double value;
float8get(value,*row);
- fetch_float_with_conversion(param, field, value, DBL_DIG);
+ fetch_float_with_conversion(param, field, value, MY_GCVT_ARG_DOUBLE);
*row+= 8;
break;
}
diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def
index d7f98f8b32b..ecfad75b12f 100644
--- a/libmysqld/libmysqld.def
+++ b/libmysqld/libmysqld.def
@@ -104,3 +104,4 @@ EXPORTS
mysql_stmt_attr_get
mysql_stmt_attr_set
mysql_stmt_field_count
+ mysql_stmt_next_result
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
index 7f5faa23c1b..52422f5d140 100644
--- a/mysql-test/collections/default.experimental
+++ b/mysql-test/collections/default.experimental
@@ -12,7 +12,6 @@ main.lock_multi_bug38499 # Bug#47448 2009-09-19 alik main.lock_m
main.lock_multi_bug38691 @solaris # Bug#47792 2009-10-02 alik main.lock_multi_bug38691 times out sporadically on Solaris 10
main.log_tables # Bug#47924 2009-10-08 alik main.log_tables times out sporadically
main.plugin # Bug#47146 Linking problem with example plugin when dtrace enabled
-main.plugin_load # Bug#47146
rpl.rpl_get_master_version_and_clock* # Bug#49191 2009-12-01 Daogang rpl_get_master_version_and_clock failed on PB2: COM_REGISTER_SLAVE failed
rpl.rpl_heartbeat_basic # BUG#43828 2009-10-22 luis fails sporadically
diff --git a/mysql-test/include/check_key_reads.inc b/mysql-test/include/check_key_reads.inc
new file mode 100644
index 00000000000..cfb754bccd4
--- /dev/null
+++ b/mysql-test/include/check_key_reads.inc
@@ -0,0 +1,6 @@
+# include file for checking if variable key_reads is zero
+let $key_reads= query_get_value(SHOW STATUS LIKE 'key_reads',Value,1);
+--disable_query_log
+eval SELECT IF($key_reads = 0, "Yes!", "No!") as 'Zero key reads?';
+FLUSH STATUS;
+--enable_query_log
diff --git a/mysql-test/include/check_key_req.inc b/mysql-test/include/check_key_req.inc
new file mode 100644
index 00000000000..92a81f09d91
--- /dev/null
+++ b/mysql-test/include/check_key_req.inc
@@ -0,0 +1,9 @@
+# include file for checking if variable key_reads = key_read_requests
+let $key_reads= query_get_value(SHOW STATUS LIKE 'key_reads',Value,1);
+let $key_r_req= query_get_value(SHOW STATUS LIKE 'key_read_requests',Value,1);
+let $key_writes= query_get_value(SHOW STATUS LIKE 'key_writes',Value,1);
+let $key_w_req= query_get_value(SHOW STATUS LIKE 'key_write_requests',Value,1);
+--disable_query_log
+eval SELECT IF($key_reads = $key_r_req, "reads == requests", "reads != requests") as 'reads vs requests';
+eval SELECT IF($key_writes = $key_w_req, "writes == requests", "writes != requests") as 'writes vs requests';
+--enable_query_log
diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc
index e16c53bc1ee..715b2c74bf2 100644
--- a/mysql-test/include/handler.inc
+++ b/mysql-test/include/handler.inc
@@ -1491,3 +1491,12 @@ disconnect con1;
--source include/wait_until_disconnected.inc
--echo # -> connection default
connection default;
+
+--echo #
+--echo # A test for Bug#50555 "handler commands crash server in
+--echo # my_hash_first()".
+--echo #
+--error ER_UNKNOWN_TABLE
+handler no_such_table read no_such_index first;
+--error ER_UNKNOWN_TABLE
+handler no_such_table close;
diff --git a/mysql-test/r/archive_gis.result b/mysql-test/r/archive_gis.result
index 178c5716911..ad7bd374629 100644
--- a/mysql-test/r/archive_gis.result
+++ b/mysql-test/r/archive_gis.result
@@ -266,7 +266,7 @@ fid AsText(EndPoint(g))
107 POINT(40 10)
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
fid GLength(g)
-105 24.142135623731
+105 24.14213562373095
106 40
107 30
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
@@ -292,7 +292,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.4166666666667 25.4166666666667)
+109 POINT(25.416666666666668 25.416666666666668)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
@@ -326,8 +326,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
-117 POINT(55.5885277530424 17.426536064114)
-118 POINT(55.5885277530424 17.426536064114)
+117 POINT(55.58852775304245 17.426536064113982)
+118 POINT(55.58852775304245 17.426536064113982)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index c53de220b60..3e1ea824db5 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -342,11 +342,11 @@ INSERT INTO t1 SET f1 = -1.0e+30 ;
INSERT INTO t1 SET f1 = +1.0e+30 ;
SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
double_val cast_val
--1e+30 -9223372036854775808
-1e+30 9223372036854775807
+-1e30 -9223372036854775808
+1e30 9223372036854775807
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1e+30'
-Warning 1292 Truncated incorrect INTEGER value: '1e+30'
+Warning 1292 Truncated incorrect INTEGER value: '-1e30'
+Warning 1292 Truncated incorrect INTEGER value: '1e30'
DROP TABLE t1;
select isnull(date(NULL)), isnull(cast(NULL as DATE));
isnull(date(NULL)) isnull(cast(NULL as DATE))
@@ -363,7 +363,7 @@ cast('1.2' as decimal(3,2))
1.20
select 1e18 * cast('1.2' as decimal(3,2));
1e18 * cast('1.2' as decimal(3,2))
-1.2e+18
+1.2e18
select cast(cast('1.2' as decimal(3,2)) as signed);
cast(cast('1.2' as decimal(3,2)) as signed)
1
diff --git a/mysql-test/r/exampledb.result b/mysql-test/r/exampledb.result
deleted file mode 100644
index 6eea24e2e1f..00000000000
--- a/mysql-test/r/exampledb.result
+++ /dev/null
@@ -1,8 +0,0 @@
-drop database if exists events_test;
-drop database if exists events_test2;
-drop table if exists t1;
-CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
-Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
-) ENGINE=example;
-drop table t1;
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index b36f561578b..6838dcf944c 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -61,7 +61,7 @@ grp sum
NULL NULL
1 7
2 20.25
-3 45.4831632475944
+3 45.48316324759439
create table t2 (grp int, a bigint unsigned, c char(10));
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
replace into t2 select grp, a, c from t1 limit 2,1;
@@ -891,7 +891,7 @@ select 1e8 * sum(distinct df) from t1;
330000000
select 1e8 * min(df) from t1;
1e8 * min(df)
-110000000
+110000000.00000001
create table t3 (ifl int);
insert into t3 values(1), (2);
select cast(min(ifl) as decimal(5,2)) from t3;
@@ -1186,7 +1186,7 @@ std(s1/s2)
0.21325764
select std(o1/o2) from bug22555;
std(o1/o2)
-0.213257635866493
+0.2132576358664934
select std(e1/e2) from bug22555;
std(e1/e2)
0.21325764
@@ -1209,13 +1209,13 @@ i count(*) std(e1/e2)
3 4 0.000000000000000000000000000000
select round(std(s1/s2), 17) from bug22555;
round(std(s1/s2), 17)
-0.21325763586649341
+0.21325763586649340
select std(o1/o2) from bug22555;
std(o1/o2)
-0.213257635866493
+0.2132576358664934
select round(std(e1/e2), 17) from bug22555;
round(std(e1/e2), 17)
-0.21325763586649341
+0.21325763586649340
set div_precision_increment=20;
select i, count(*), std(s1/s2) from bug22555 group by i order by i;
i count(*) std(s1/s2)
@@ -1234,13 +1234,13 @@ i count(*) std(e1/e2)
3 4 0.000000000000000000000000000000
select round(std(s1/s2), 17) from bug22555;
round(std(s1/s2), 17)
-0.21325763586649341
+0.21325763586649340
select std(o1/o2) from bug22555;
std(o1/o2)
-0.213257635866493
+0.2132576358664934
select round(std(e1/e2), 17) from bug22555;
round(std(e1/e2), 17)
-0.21325763586649341
+0.21325763586649340
set @@div_precision_increment=@saved_div_precision_increment;
drop table bug22555;
create table bug22555 (s smallint, o double, e decimal);
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index 063f4d37f4a..537b1db9781 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -44,7 +44,7 @@ Warnings:
Note 1003 select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
-10 10 NULL NULL NULL 2 NULL NULL
+10 10.000000000000002 NULL NULL NULL 2 NULL NULL
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -52,7 +52,7 @@ Warnings:
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
-10 10 NULL NULL NULL
+10 10.000000000000002 NULL NULL NULL
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -60,7 +60,7 @@ Warnings:
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
-3 3.90689059560852 NULL NULL NULL
+3 3.9068905956085187 NULL NULL NULL
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -68,7 +68,7 @@ Warnings:
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
-2 1.25527250510331 NULL NULL NULL
+2 1.255272505103306 NULL NULL NULL
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -85,7 +85,7 @@ Note 1003 select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4
set @@rand_seed1=10000000,@@rand_seed2=1000000;
select rand(999999),rand();
rand(999999) rand()
-0.0142313651873091 0.028870999839968
+0.014231365187309091 0.028870999839968048
explain extended select rand(999999),rand();
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -101,7 +101,7 @@ Warnings:
Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format((1 / tan(1)),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
select degrees(pi()),radians(360);
degrees(pi()) radians(360)
-180 6.28318530717959
+180 6.283185307179586
select format(atan(-2, 2), 6);
format(atan(-2, 2), 6)
-0.785398
@@ -119,7 +119,7 @@ ACOS(1.0)
0
SELECT ASIN(1.0);
ASIN(1.0)
-1.5707963267949
+1.5707963267948966
SELECT ACOS(0.2*5.0);
ACOS(0.2*5.0)
0
@@ -128,10 +128,10 @@ ACOS(0.5*2.0)
0
SELECT ASIN(0.8+0.2);
ASIN(0.8+0.2)
-1.5707963267949
+1.5707963267948966
SELECT ASIN(1.2-0.2);
ASIN(1.2-0.2)
-1.5707963267949
+1.5707963267948966
select format(4.55, 1), format(4.551, 1);
format(4.55, 1) format(4.551, 1)
4.6 4.6
@@ -368,7 +368,7 @@ mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
5 5 1
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
-2.13598703592091e+96 2.13598703592091e+96 -32
+2.13598703592091e96 2.13598703592091e96 -32
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
SELECT a DIV 900 y FROM t1 GROUP BY y;
@@ -437,10 +437,10 @@ a ROUND(a)
2.5 2
-2.9 -3
2.9 3
--1e+16 -10000000000000000
-1e+16 10000000000000000
--1e+16 -10000000000000002
-1e+16 10000000000000002
+-1e16 -10000000000000000
+1e16 10000000000000000
+-1.0000000000000002e16 -10000000000000002
+1.0000000000000002e16 10000000000000002
DROP TABLE t1;
CREATE TABLE t1(f1 LONGTEXT) engine=myisam;
INSERT INTO t1 VALUES ('a');
@@ -475,16 +475,16 @@ NULL
CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a;
SELECT RAND(a) FROM v1;
RAND(a)
-0.155220427694936
+0.15522042769493574
DROP VIEW v1;
SELECT RAND(a) FROM (SELECT NULL AS a) b;
RAND(a)
-0.155220427694936
+0.15522042769493574
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (NULL);
SELECT RAND(i) FROM t1;
RAND(i)
-0.155220427694936
+0.15522042769493574
DROP TABLE t1;
#
select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 64988f9de50..3d43cbbfd76 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -1354,10 +1354,10 @@ cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2))
20.06
select conv("18383815659218730760",10,10) + 0;
conv("18383815659218730760",10,10) + 0
-1.83838156592187e+19
+1.838381565921873e19
select "18383815659218730760" + 0;
"18383815659218730760" + 0
-1.83838156592187e+19
+1.838381565921873e19
CREATE TABLE t1 (code varchar(10));
INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
SELECT ASCII(code), code FROM t1 WHERE code='A12';
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 3e28227d542..60e24819fa5 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -258,7 +258,7 @@ fid AsText(EndPoint(g))
107 POINT(40 10)
SELECT fid, GLength(g) FROM gis_line;
fid GLength(g)
-105 24.142135623731
+105 24.14213562373095
106 40
107 30
SELECT fid, NumPoints(g) FROM gis_line;
@@ -284,7 +284,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.4166666666667 25.4166666666667)
+109 POINT(25.416666666666668 25.416666666666668)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon;
fid Area(g)
@@ -318,8 +318,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
fid AsText(Centroid(g))
-117 POINT(55.5885277530424 17.426536064114)
-118 POINT(55.5885277530424 17.426536064114)
+117 POINT(55.58852775304245 17.426536064113982)
+118 POINT(55.58852775304245 17.426536064113982)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon;
fid Area(g)
@@ -651,11 +651,11 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85998;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
-85998 MULTIPOLYGON 0 POINT(115.318773152032 -36.2374728210215)
+85998 MULTIPOLYGON 0 POINT(115.31877315203187 -36.23747282102153)
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85984;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
-85984 MULTIPOLYGON 0 POINT(-114.877871869233 36.3310176346905)
+85984 MULTIPOLYGON 0 POINT(-114.87787186923313 36.33101763469059)
drop table t1;
create table t1 (fl geometry not null);
insert into t1 values (1);
diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result
index 6ed7b572403..4def5c82df8 100644
--- a/mysql-test/r/handler_innodb.result
+++ b/mysql-test/r/handler_innodb.result
@@ -1456,3 +1456,11 @@ handler t1 close;
drop table t1;
# -> connection con1
# -> connection default
+#
+# A test for Bug#50555 "handler commands crash server in
+# my_hash_first()".
+#
+handler no_such_table read no_such_index first;
+ERROR 42S02: Unknown table 'no_such_table' in HANDLER
+handler no_such_table close;
+ERROR 42S02: Unknown table 'no_such_table' in HANDLER
diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result
index 0dd039eeb23..80f728a4dcd 100644
--- a/mysql-test/r/handler_myisam.result
+++ b/mysql-test/r/handler_myisam.result
@@ -1454,6 +1454,14 @@ drop table t1;
# -> connection con1
# -> connection default
#
+# A test for Bug#50555 "handler commands crash server in
+# my_hash_first()".
+#
+handler no_such_table read no_such_index first;
+ERROR 42S02: Unknown table 'no_such_table' in HANDLER
+handler no_such_table close;
+ERROR 42S02: Unknown table 'no_such_table' in HANDLER
+#
# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash
#
CREATE TABLE t1 AS SELECT 1 AS f1;
diff --git a/mysql-test/r/innodb_gis.result b/mysql-test/r/innodb_gis.result
index c6c775afc9f..0ce1ebe56ad 100644
--- a/mysql-test/r/innodb_gis.result
+++ b/mysql-test/r/innodb_gis.result
@@ -266,7 +266,7 @@ fid AsText(EndPoint(g))
107 POINT(40 10)
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
fid GLength(g)
-105 24.142135623731
+105 24.14213562373095
106 40
107 30
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
@@ -292,7 +292,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.4166666666667 25.4166666666667)
+109 POINT(25.416666666666668 25.416666666666668)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
@@ -326,8 +326,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
-117 POINT(55.5885277530424 17.426536064114)
-118 POINT(55.5885277530424 17.426536064114)
+117 POINT(55.58852775304245 17.426536064113982)
+118 POINT(55.58852775304245 17.426536064113982)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index 36d2b9ef348..b322c5da73a 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -175,12 +175,12 @@ Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
select * from t1 where number =last_insert_id();
number 4
original_value 1e+1111111111a
-f_double 1.79769313486232e+308
-f_float 3.40282e+38
+f_double 1.7976931348623157e308
+f_float 3.40282e38
f_double_7_2 99999.99
f_float_4_3 9.999
-f_double_u 1.79769313486232e+308
-f_float_u 3.40282e+38
+f_double_u 1.7976931348623157e308
+f_float_u 3.40282e38
f_double_15_1_u 99999999999999.9
f_float_3_1_u 99.9
set @value= "-1e+1111111111a";
@@ -204,8 +204,8 @@ Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
select * from t1 where number =last_insert_id();
number 5
original_value -1e+1111111111a
-f_double -1.79769313486232e+308
-f_float -3.40282e+38
+f_double -1.7976931348623157e308
+f_float -3.40282e38
f_double_7_2 -99999.99
f_float_4_3 -9.999
f_double_u 0
@@ -227,13 +227,13 @@ Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
select * from t1 where number =last_insert_id();
number 6
-original_value 1e+111
-f_double 1e+111
-f_float 3.40282e+38
+original_value 1e111
+f_double 1e111
+f_float 3.40282e38
f_double_7_2 99999.99
f_float_4_3 9.999
-f_double_u 1e+111
-f_float_u 3.40282e+38
+f_double_u 1e111
+f_float_u 3.40282e38
f_double_15_1_u 99999999999999.9
f_float_3_1_u 99.9
set @value= -1e+111;
@@ -248,9 +248,9 @@ Warning 1264 Out of range value for column 'f_double_15_1_u' at row 1
Warning 1264 Out of range value for column 'f_float_3_1_u' at row 1
select * from t1 where number =last_insert_id();
number 7
-original_value -1e+111
-f_double -1e+111
-f_float -3.40282e+38
+original_value -1e111
+f_double -1e111
+f_float -3.40282e38
f_double_7_2 -99999.99
f_float_4_3 -9.999
f_double_u 0
@@ -524,42 +524,36 @@ INSERT INTO t1(a,b) VALUES (1.25e-175, 1.25e-175);
INSERT INTO t1(a,c) VALUES (1.225e+0, 1.225e+0);
INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
-Warnings:
-Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
-Warnings:
-Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
-Warnings:
-Warning 1265 Data truncated for column 'c' at row 1
SELECT * FROM t1;
a b c
9.999999 10 10
-1.225e-05 1.2e-05 1e-0
-0.0001225 0.00012 NULL
+0.00001225 1.22e-5 1e-5
+0.0001225 1.22e-4 NULL
0.1225 0.1225 NULL
0.1225877 0.12259 NULL
12.25 12.25 NULL
12.25 12.25 12.2
122500 122500 NULL
-12250000000 1.2e+10 NULL
-1.225e+15 1.2e+15 NULL
+12250000000 1.22e10 NULL
+1.225e15 1.22e15 NULL
5000000 5000000 NULL
-1.25e+78 1.2e+78 NULL
+1.25e78 1.25e78 NULL
1.25e-94 1.2e-94 NULL
-1.25e+203 1e+203 NULL
+1.25e203 1.2e203 NULL
1.25e-175 1e-175 NULL
1.225 NULL 1.23
1.37 NULL 1.37
--1.37 NULL -1.3
-0.00187 NULL 0.00
--0.0187 NULL -0.0
+-1.37 NULL -1.4
+0.00187 NULL 2e-3
+-0.0187 NULL 0
5000 NULL 5000
--5000 NULL -500
+-5000 NULL -5e3
DROP TABLE t1;
CREATE TABLE t1 (
a char(20) NOT NULL,
@@ -586,32 +580,30 @@ INSERT INTO t1(a,c) VALUES (1.37e+0, 1.37e+0);
INSERT INTO t1(a,c) VALUES (-1.37e+0, -1.37e+0);
INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
-Warnings:
-Warning 1265 Data truncated for column 'c' at row 1
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
SELECT * FROM t1;
a b c
9.999999 10 9.999
-1.225e-05 1.2e-05 1e-05
-0.0001225 0.00012 NULL
+0.00001225 1.22e-5 1e-5
+0.0001225 1.22e-4 NULL
0.1225 0.1225 NULL
0.1225877 0.12259 NULL
12.25 12.25 NULL
12.25 12.25 12.25
122500 122500 NULL
-12250000000 1.2e+10 NULL
-1.225e+15 1.2e+15 NULL
+12250000000 1.22e10 NULL
+1.225e15 1.22e15 NULL
5000000 5000000 NULL
-1.25e+78 1.2e+78 NULL
+1.25e78 1.25e78 NULL
1.25e-94 1.2e-94 NULL
-1.25e+203 1e+203 NULL
+1.25e203 1.2e203 NULL
1.25e-175 1e-175 NULL
1.225 NULL 1.225
1.37 NULL 1.37
-1.37 NULL -1.37
0.00187 NULL 0.002
--0.0187 NULL -0.01
+-0.0187 NULL -0.02
5000 NULL 5000
-5000 NULL -5000
DROP TABLE t1;
diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result
index 1e488b320d7..5e25132880f 100644
--- a/mysql-test/r/loaddata.result
+++ b/mysql-test/r/loaddata.result
@@ -251,15 +251,15 @@ CREATE TABLE t1 (c1 INT, c2 TIMESTAMP, c3 REAL, c4 DOUBLE);
INSERT INTO t1 (c1, c2, c3, c4) VALUES (10, '1970-02-01 01:02:03', 1.1E-100, 1.1E+100);
SELECT * FROM t1;
c1 c2 c3 c4
-10 1970-02-01 01:02:03 1.1e-100 1.1e+100
+10 1970-02-01 01:02:03 1.1e-100 1.1e100
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY '-' FROM t1;
--10- -1970\-02\-01 01:02:03- -1.1e\-100- -1.1e+100-
+-10- -1970\-02\-01 01:02:03- -1.1e\-100- -1.1e100-
EOF
TRUNCATE t1;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t1 FIELDS ENCLOSED BY '-';
SELECT * FROM t1;
c1 c2 c3 c4
-10 1970-02-01 01:02:03 1.1e-100 1.1e+100
+10 1970-02-01 01:02:03 1.1e-100 1.1e100
DROP TABLE t1;
# --
diff --git a/mysql-test/r/mysqlbinlog_row_innodb.result b/mysql-test/r/mysqlbinlog_row_innodb.result
index cf59d23bcf1..3eb4774ae4e 100644
--- a/mysql-test/r/mysqlbinlog_row_innodb.result
+++ b/mysql-test/r/mysqlbinlog_row_innodb.result
@@ -495,10 +495,10 @@ c15 0000000000
c16 -9223372036854775808
c17 0
c18 00000000000000000000
-c19 -3.40282e+38
+c19 -3.40282e38
c20 1.17549e-38
c21 000000000000
-c22 -1.7976931348623e+308
+c22 -1.7976931348623e308
c23 2.2250738585072e-308
c24 0000000000000000000000
c25 -9999999999
@@ -574,12 +574,12 @@ c15 4294967295
c16 9223372036854775807
c17 18446744073709551615
c18 18446744073709551615
-c19 3.40282e+38
-c20 3.40282e+38
-c21 03.40282e+38
-c22 1.7976931348623e+308
-c23 1.7976931348623e+308
-c24 001.7976931348623e+308
+c19 3.40282e38
+c20 3.40282e38
+c21 003.40282e38
+c22 1.7976931348623e308
+c23 1.7976931348623e308
+c24 0001.7976931348623e308
c25 9999999999
c26 9999999999
c27 9999999999
@@ -1557,12 +1557,12 @@ c15 4294967295
c16 9223372036854775807
c17 18446744073709551615
c18 18446744073709551615
-c19 3.40282e+38
-c20 3.40282e+38
-c21 03.40282e+38
-c22 1.7976931348623e+308
-c23 1.7976931348623e+308
-c24 001.7976931348623e+308
+c19 3.40282e38
+c20 3.40282e38
+c21 003.40282e38
+c22 1.7976931348623e308
+c23 1.7976931348623e308
+c24 0001.7976931348623e308
c25 9999999999
c26 9999999999
c27 9999999999
@@ -1636,10 +1636,10 @@ c15 0000000000
c16 -9223372036854775808
c17 0
c18 00000000000000000000
-c19 -3.40282e+38
+c19 -3.40282e38
c20 1.17549e-38
c21 000000000000
-c22 -1.7976931348623e+308
+c22 -1.7976931348623e308
c23 2.2250738585072e-308
c24 0000000000000000000000
c25 -9999999999
diff --git a/mysql-test/r/mysqlbinlog_row_myisam.result b/mysql-test/r/mysqlbinlog_row_myisam.result
index 973786d698e..b673d36c452 100644
--- a/mysql-test/r/mysqlbinlog_row_myisam.result
+++ b/mysql-test/r/mysqlbinlog_row_myisam.result
@@ -495,10 +495,10 @@ c15 0000000000
c16 -9223372036854775808
c17 0
c18 00000000000000000000
-c19 -3.40282e+38
+c19 -3.40282e38
c20 1.17549e-38
c21 000000000000
-c22 -1.7976931348623e+308
+c22 -1.7976931348623e308
c23 2.2250738585072e-308
c24 0000000000000000000000
c25 -9999999999
@@ -574,12 +574,12 @@ c15 4294967295
c16 9223372036854775807
c17 18446744073709551615
c18 18446744073709551615
-c19 3.40282e+38
-c20 3.40282e+38
-c21 03.40282e+38
-c22 1.7976931348623e+308
-c23 1.7976931348623e+308
-c24 001.7976931348623e+308
+c19 3.40282e38
+c20 3.40282e38
+c21 003.40282e38
+c22 1.7976931348623e308
+c23 1.7976931348623e308
+c24 0001.7976931348623e308
c25 9999999999
c26 9999999999
c27 9999999999
@@ -1557,12 +1557,12 @@ c15 4294967295
c16 9223372036854775807
c17 18446744073709551615
c18 18446744073709551615
-c19 3.40282e+38
-c20 3.40282e+38
-c21 03.40282e+38
-c22 1.7976931348623e+308
-c23 1.7976931348623e+308
-c24 001.7976931348623e+308
+c19 3.40282e38
+c20 3.40282e38
+c21 003.40282e38
+c22 1.7976931348623e308
+c23 1.7976931348623e308
+c24 0001.7976931348623e308
c25 9999999999
c26 9999999999
c27 9999999999
@@ -1636,10 +1636,10 @@ c15 0000000000
c16 -9223372036854775808
c17 0
c18 00000000000000000000
-c19 -3.40282e+38
+c19 -3.40282e38
c20 1.17549e-38
c21 000000000000
-c22 -1.7976931348623e+308
+c22 -1.7976931348623e308
c23 2.2250738585072e-308
c24 0000000000000000000000
c25 -9999999999
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 13d36fab2f1..4724a111837 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -55,7 +55,7 @@ CREATE TABLE `t1` (
`a` double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
-INSERT INTO `t1` VALUES (RES);
+INSERT INTO `t1` VALUES (-1.7976931348623157e308);
DROP TABLE t1;
#
# Bug#3361 mysqldump quotes DECIMAL values inconsistently
diff --git a/mysql-test/r/not_partition.result b/mysql-test/r/not_partition.result
index f516f8634ce..4ec37ab9fc7 100644
--- a/mysql-test/r/not_partition.result
+++ b/mysql-test/r/not_partition.result
@@ -52,9 +52,9 @@ joined DATE NOT NULL
)
PARTITION BY KEY(joined)
PARTITIONS 6;
-ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-partition' to have it working
+Got one of the listed errors
ALTER TABLE t1 PARTITION BY KEY(joined) PARTITIONS 2;
-ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-partition' to have it working
+Got one of the listed errors
drop table t1;
ERROR 42S02: Unknown table 't1'
CREATE TABLE t1 (
@@ -71,7 +71,7 @@ PARTITION p2 VALUES LESS THAN (1980),
PARTITION p3 VALUES LESS THAN (1990),
PARTITION p4 VALUES LESS THAN MAXVALUE
);
-ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-partition' to have it working
+Got one of the listed errors
drop table t1;
ERROR 42S02: Unknown table 't1'
CREATE TABLE t1 (id INT, purchased DATE)
@@ -82,7 +82,7 @@ PARTITION p0 VALUES LESS THAN (1990),
PARTITION p1 VALUES LESS THAN (2000),
PARTITION p2 VALUES LESS THAN MAXVALUE
);
-ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-partition' to have it working
+Got one of the listed errors
drop table t1;
ERROR 42S02: Unknown table 't1'
create table t1 (a varchar(10) charset latin1 collate latin1_bin);
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result
index 7e703de0876..467bb7c5cb8 100644
--- a/mysql-test/r/parser.result
+++ b/mysql-test/r/parser.result
@@ -522,7 +522,7 @@ select conv(255 AS p1, 10 AS p2, 16 AS p3);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select atan(10);
atan(10)
-1.47112767430373
+1.4711276743037347
select atan(10 AS p1);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 p1);
@@ -533,7 +533,7 @@ select atan(10 "p1");
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10, 20);
atan(10, 20)
-0.463647609000806
+0.4636476090008061
select atan(10 AS p1, 20);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 p1, 20);
diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result
index 784df3045f0..ddc48b635cf 100644
--- a/mysql-test/r/partition_column.result
+++ b/mysql-test/r/partition_column.result
@@ -9,6 +9,30 @@ partition by range columns (a,b,c)
( partition p0 values less than (1, maxvalue, 10),
partition p1 values less than (1, maxvalue, maxvalue));
ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition
+create table t1 (a varchar(5) character set ucs2 collate ucs2_bin)
+partition by range columns (a)
+(partition p0 values less than (0x0041));
+insert into t1 values (0x00410000);
+select hex(a) from t1 where a like 'A_';
+hex(a)
+00410000
+explain partitions select hex(a) from t1 where a like 'A_';
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0 system NULL NULL NULL NULL 1
+alter table t1 remove partitioning;
+select hex(a) from t1 where a like 'A_';
+hex(a)
+00410000
+create index a on t1 (a);
+select hex(a) from t1 where a like 'A_';
+hex(a)
+00410000
+insert into t1 values ('A_');
+select hex(a) from t1;
+hex(a)
+00410000
+0041005F
+drop table t1;
create table t1 (a varchar(1) character set latin1 collate latin1_general_ci)
partition by range columns(a)
( partition p0 values less than ('a'),
@@ -69,7 +93,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(5) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST COLUMNS(a)
+/*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN ('''') ENGINE = MyISAM,
PARTITION p1 VALUES IN ('\\') ENGINE = MyISAM,
PARTITION p2 VALUES IN ('\0') ENGINE = MyISAM) */
@@ -128,7 +152,7 @@ t1 CREATE TABLE `t1` (
`c` varchar(25) DEFAULT NULL,
`d` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY RANGE COLUMNS(a,b,c,d)
+/*!50500 PARTITION BY RANGE COLUMNS(a,b,c,d)
SUBPARTITION BY HASH (to_seconds(d))
SUBPARTITIONS 4
(PARTITION p0 VALUES LESS THAN (1,'0',MAXVALUE,'1900-01-01') ENGINE = MyISAM,
@@ -211,7 +235,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST COLUMNS(a,b)
+/*!50500 PARTITION BY LIST COLUMNS(a,b)
(PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM,
PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM,
PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */
@@ -245,7 +269,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST COLUMNS(a,b)
+/*!50500 PARTITION BY LIST COLUMNS(a,b)
(PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM,
PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM,
PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */
@@ -299,7 +323,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST COLUMNS(a)
+/*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM,
PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */
insert into t1 values (1);
@@ -314,7 +338,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST COLUMNS(a)
+/*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM,
PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */
drop table t1;
@@ -349,7 +373,7 @@ t1 CREATE TABLE `t1` (
`c` varchar(5) DEFAULT NULL,
`d` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY RANGE COLUMNS(a,b,c)
+/*!50500 PARTITION BY RANGE COLUMNS(a,b,c)
SUBPARTITION BY KEY (c,d)
SUBPARTITIONS 3
(PARTITION p0 VALUES LESS THAN (1,'abc','abc') ENGINE = MyISAM,
@@ -382,7 +406,7 @@ t1 CREATE TABLE `t1` (
`b` varchar(2) DEFAULT NULL,
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY RANGE COLUMNS(a,b,c)
+/*!50500 PARTITION BY RANGE COLUMNS(a,b,c)
(PARTITION p0 VALUES LESS THAN (1,'A',1) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (1,'B',1) ENGINE = MyISAM) */
insert into t1 values (1, 'A', 1);
diff --git a/mysql-test/r/partition_key_cache.result b/mysql-test/r/partition_key_cache.result
new file mode 100644
index 00000000000..7fbab34fa41
--- /dev/null
+++ b/mysql-test/r/partition_key_cache.result
@@ -0,0 +1,417 @@
+DROP TABLE IF EXISTS t1, t2, v, x;
+# Actual test of key caches
+# Verifing that reads/writes use the key cache correctly
+SELECT @org_key_cache_buffer_size:= @@global.default.key_buffer_size;
+@org_key_cache_buffer_size:= @@global.default.key_buffer_size
+1048576
+# Minimize default key cache (almost disabled).
+SET @@global.default.key_buffer_size = 1;
+Warnings:
+Warning 1292 Truncated incorrect key_buffer_size value: '1'
+CREATE TABLE t1 (
+a INT,
+b INT,
+c INT NOT NULL,
+PRIMARY KEY (a),
+KEY `inx_b` (b))
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a)
+(PARTITION p0 VALUES LESS THAN (1167602410)
+(SUBPARTITION sp0,
+SUBPARTITION sp1),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+(SUBPARTITION sp2,
+SUBPARTITION sp3));
+CREATE TABLE t2 (
+a INT,
+b INT,
+c INT NOT NULL,
+PRIMARY KEY (a),
+KEY `inx_b` (b));
+FLUSH TABLES;
+FLUSH STATUS;
+SET @a:=1167602400;
+CREATE VIEW v AS SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4;
+CREATE VIEW x AS SELECT 1 FROM v,v a,v b;
+FLUSH STATUS;
+INSERT t1 SELECT @a, @a * (1 - ((@a % 2) * 2)) , 1167612400 - (@a:=@a+1) FROM x, x y;
+reads vs requests
+reads == requests
+writes vs requests
+writes == requests
+# row distribution:
+SELECT PARTITION_NAME, SUBPARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA='test' and TABLE_NAME='t1';
+PARTITION_NAME SUBPARTITION_NAME TABLE_ROWS
+p0 sp0 5
+p0 sp1 5
+p1 sp2 2043
+p1 sp3 2043
+DROP VIEW x;
+DROP VIEW v;
+FLUSH TABLES;
+FLUSH STATUS;
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+No!
+INSERT t2 SELECT a,b,c FROM t1;
+reads vs requests
+reads == requests
+writes vs requests
+writes == requests
+FLUSH STATUS;
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+No!
+FLUSH TABLES;
+# Setting the default key cache to 1M
+SET GLOBAL key_buffer_size = 1024*1024;
+FLUSH STATUS;
+# All these have to read the indexes
+LOAD INDEX INTO CACHE t1 PARTITION (p1);
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+Zero key reads?
+No!
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+No!
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+No!
+# All these should be able to use the key cache
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+Yes!
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+Yes!
+FLUSH TABLES;
+LOAD INDEX INTO CACHE t1 PARTITION (p1,p0);
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+Zero key reads?
+No!
+# should not be zero
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+Yes!
+LOAD INDEX INTO CACHE t2;
+Table Op Msg_type Msg_text
+test.t2 preload_keys status OK
+Zero key reads?
+No!
+# should not be zero
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+Yes!
+FLUSH TABLES;
+LOAD INDEX INTO CACHE t1 PARTITION (p1,p0) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+Zero key reads?
+No!
+# should not be zero
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+No!
+LOAD INDEX INTO CACHE t2 IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t2 preload_keys status OK
+Zero key reads?
+No!
+# should not be zero
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+COUNT(b)
+2048
+Zero key reads?
+No!
+TRUNCATE TABLE t2;
+INSERT t2 SELECT a,b,c FROM t1;
+reads vs requests
+reads != requests
+writes vs requests
+writes != requests
+DROP TABLE t1,t2;
+SET GLOBAL hot_cache.key_buffer_size = 1024*1024;
+SET GLOBAL warm_cache.key_buffer_size = 1024*1024;
+SET @@global.cold_cache.key_buffer_size = 1024*1024;
+SELECT @@global.default.key_buffer_size a, @@global.default.key_cache_block_size b, @@global.default.key_cache_age_threshold c, @@global.default.key_cache_division_limit d;
+a b c d
+1048576 1024 300 100
+SELECT @@global.hot_cache.key_buffer_size a, @@global.hot_cache.key_cache_block_size b, @@global.hot_cache.key_cache_age_threshold c, @@global.hot_cache.key_cache_division_limit d;
+a b c d
+1048576 1024 300 100
+SELECT @@global.warm_cache.key_buffer_size a, @@global.warm_cache.key_cache_block_size b, @@global.warm_cache.key_cache_age_threshold c, @@global.warm_cache.key_cache_division_limit d;
+a b c d
+1048576 1024 300 100
+SELECT @@global.cold_cache.key_buffer_size a, @@global.cold_cache.key_cache_block_size b, @@global.cold_cache.key_cache_age_threshold c, @@global.cold_cache.key_cache_division_limit d;
+a b c d
+1048576 1024 300 100
+CREATE TABLE t1 (
+a INT,
+b VARCHAR(257),
+c INT NOT NULL,
+PRIMARY KEY (a),
+KEY `inx_b` (b),
+KEY `inx_c`(c))
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a)
+(PARTITION p0 VALUES LESS THAN (10)
+(SUBPARTITION sp0,
+SUBPARTITION sp1),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+(SUBPARTITION sp2,
+SUBPARTITION sp3));
+CREATE TABLE t2 (
+a INT,
+b VARCHAR(257),
+c INT NOT NULL,
+PRIMARY KEY (a),
+KEY `inx_b` (b),
+KEY `inx_c`(c));
+SET @a:=1167602400;
+CREATE VIEW v AS SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4;
+CREATE VIEW x AS SELECT 1 FROM v,v a,v b;
+INSERT t1 SELECT @a, CONCAT('X_', @a, ' MySQL'), 1167612400 - (@a:=@a+1) FROM x, x a;
+DROP VIEW x;
+DROP VIEW v;
+INSERT t2 SELECT a, b, c FROM t1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+4096
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+4096
+FLUSH TABLES;
+# Restrict partitioned commands to partitioned tables only
+CACHE INDEX t2 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+ERROR HY000: Partition management on a not partitioned table is not possible
+CACHE INDEX t2 PARTITION (p0,`p1`) INDEX (`PRIMARY`) IN hot_cache;
+ERROR HY000: Partition management on a not partitioned table is not possible
+CACHE INDEX t2 PARTITION (`p1`) INDEX (`PRIMARY`,`inx_b`) IN hot_cache;
+ERROR HY000: Partition management on a not partitioned table is not possible
+CACHE INDEX t2 PARTITION (ALL) KEY (`inx_b`,`PRIMARY`) IN hot_cache;
+ERROR HY000: Partition management on a not partitioned table is not possible
+# Basic key cache testing
+# The manual correctly says: "The syntax of CACHE INDEX enables you to
+# specify that only particular indexes from a table should be assigned
+# to the cache. The current implementation assigns all the table's
+# indexes to the cache, so there is no reason to specify anything
+# other than the table name."
+# So the most of the test only tests the syntax
+CACHE INDEX t2 INDEX (`inx_b`) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+CACHE INDEX t2 KEY (`PRIMARY`) IN warm_cache;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+CACHE INDEX t2 KEY (`PRIMARY`,`inx_b`) IN cold_cache;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+CACHE INDEX t2 INDEX (inx_b,`PRIMARY`) IN default;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+CACHE INDEX t1 PARTITION (p0) KEY (`inx_b`) IN cold_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 PARTITIONS (p0) KEY (`inx_b`) IN cold_cache;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARTITIONS (p0) KEY (`inx_b`) IN cold_cache' at line 1
+# only one table at a time if specifying partitions
+CACHE INDEX t1,t2 PARTITION (p0) KEY (`inx_b`) IN cold_cache;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARTITION (p0) KEY (`inx_b`) IN cold_cache' at line 1
+CACHE INDEX t1 PARTITION (`p0`,p1) INDEX (`PRIMARY`) IN warm_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 PARTITION (`p1`) INDEX (`PRIMARY`,inx_b) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 PARTITION (ALL) KEY (`inx_b`,`PRIMARY`) IN default;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 PARTITION (ALL) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 INDEX (`inx_b`) IN default;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 KEY (`PRIMARY`) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 KEY (`PRIMARY`,`inx_b`) IN warm_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 INDEX (`inx_b`,`PRIMARY`) IN cold_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+CACHE INDEX t1 IN hot_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+# Test of non existent key cache:
+CACHE INDEX t1 IN non_existent_key_cache;
+ERROR HY000: Unknown key cache 'non_existent_key_cache'
+# Basic testing of LOAD INDEX
+LOAD INDEX INTO CACHE t2;
+Table Op Msg_type Msg_text
+test.t2 preload_keys status OK
+# PRIMARY and secondary keys have different block sizes
+LOAD INDEX INTO CACHE t2 ignore leaves;
+Table Op Msg_type Msg_text
+test.t2 preload_keys error Indexes use different block sizes
+test.t2 preload_keys status Operation failed
+# Must have INDEX or KEY before the index list
+LOAD INDEX INTO CACHE t2 (`PRIMARY`);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(`PRIMARY`)' at line 1
+# Test of IGNORE LEAVES
+LOAD INDEX INTO CACHE t2 INDEX (`PRIMARY`);
+Table Op Msg_type Msg_text
+test.t2 preload_keys status OK
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_b`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t2 preload_keys error Indexes use different block sizes
+test.t2 preload_keys status Operation failed
+CACHE INDEX t2 IN warm_cache;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+CACHE INDEX t1 IN cold_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t2 preload_keys error Indexes use different block sizes
+test.t2 preload_keys status Operation failed
+CACHE INDEX t2 INDEX (`inx_b`, `inx_c`) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+LOAD INDEX INTO CACHE t2 KEY (`inx_b`, `inx_c`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t2 preload_keys error Indexes use different block sizes
+test.t2 preload_keys status Operation failed
+CACHE INDEX t2 IN warm_cache;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+CACHE INDEX t2 INDEX (`PRIMARY`, `inx_c`) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_c`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t2 preload_keys error Indexes use different block sizes
+test.t2 preload_keys status Operation failed
+CACHE INDEX t2 INDEX (`inx_b`,`PRIMARY`) IN default;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_b`);
+Table Op Msg_type Msg_text
+test.t2 preload_keys status OK
+CACHE INDEX t2 IN default;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+LOAD INDEX INTO CACHE t2 IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t2 preload_keys error Indexes use different block sizes
+test.t2 preload_keys status Operation failed
+LOAD INDEX INTO CACHE t2 PARTITION (p1) INDEX (`PRIMARY`);
+ERROR HY000: Partition management on a not partitioned table is not possible
+LOAD INDEX INTO CACHE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+test.t2 preload_keys status OK
+# only one table at a time if specifying partitions
+LOAD INDEX INTO CACHE t1 PARTITION (p0), t2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' t2' at line 1
+LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys error Indexes use different block sizes
+test.t1 preload_keys error Subpartition sp2 returned error
+test.t1 preload_keys status Operation failed
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`);
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`,`inx_b`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys error Indexes use different block sizes
+test.t1 preload_keys error Subpartition sp2 returned error
+test.t1 preload_keys status Operation failed
+LOAD INDEX INTO CACHE t1 INDEX (`inx_b`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys error Indexes use different block sizes
+test.t1 preload_keys error Subpartition sp2 returned error
+test.t1 preload_keys status Operation failed
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys error Indexes use different block sizes
+test.t1 preload_keys error Subpartition sp2 returned error
+test.t1 preload_keys status Operation failed
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`,`inx_b`);
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+LOAD INDEX INTO CACHE t1 PARTITION (p1) INDEX (`PRIMARY`);
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+LOAD INDEX INTO CACHE t1 PARTITION (`p1`,p0) KEY (`PRIMARY`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys error Indexes use different block sizes
+test.t1 preload_keys error Subpartition sp2 returned error
+test.t1 preload_keys status Operation failed
+LOAD INDEX INTO CACHE t1 PARTITION (ALL);
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+LOAD INDEX INTO CACHE t1 PARTITIONS ALL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARTITIONS ALL' at line 1
+LOAD INDEX INTO CACHE t1 PARTITION (p1,`p0`) IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys error Indexes use different block sizes
+test.t1 preload_keys error Subpartition sp2 returned error
+test.t1 preload_keys status Operation failed
+DROP INDEX `inx_b` on t1;
+DROP INDEX `inx_b` on t2;
+CACHE INDEX t2 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+ERROR HY000: Partition management on a not partitioned table is not possible
+CACHE INDEX t2 INDEX (`inx_b`) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache Error Key 'inx_b' doesn't exist in table 't2'
+test.t2 assign_to_keycache status Operation failed
+CACHE INDEX t1 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache error Subpartition sp0 returned error
+test.t1 assign_to_keycache Error Key 'inx_b' doesn't exist in table 't1'
+test.t1 assign_to_keycache status Operation failed
+CACHE INDEX t1 INDEX (`inx_b`) IN hot_cache;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache error Subpartition sp0 returned error
+test.t1 assign_to_keycache Error Key 'inx_b' doesn't exist in table 't1'
+test.t1 assign_to_keycache status Operation failed
+DROP TABLE t1,t2;
+SET GLOBAL hot_cache.key_buffer_size = 0;
+SET GLOBAL warm_cache.key_buffer_size = 0;
+SET @@global.cold_cache.key_buffer_size = 0;
+SELECT @@global.default.key_buffer_size a, @@global.default.key_cache_block_size b, @@global.default.key_cache_age_threshold c, @@global.default.key_cache_division_limit d;
+a b c d
+1048576 1024 300 100
+SELECT @@global.hot_cache.key_buffer_size a, @@global.hot_cache.key_cache_block_size b, @@global.hot_cache.key_cache_age_threshold c, @@global.hot_cache.key_cache_division_limit d;
+a b c d
+0 1024 300 100
+SELECT @@global.warm_cache.key_buffer_size a, @@global.warm_cache.key_cache_block_size b, @@global.warm_cache.key_cache_age_threshold c, @@global.warm_cache.key_cache_division_limit d;
+a b c d
+0 1024 300 100
+SELECT @@global.cold_cache.key_buffer_size a, @@global.cold_cache.key_cache_block_size b, @@global.cold_cache.key_cache_age_threshold c, @@global.cold_cache.key_cache_division_limit d;
+a b c d
+0 1024 300 100
+SET @@global.default.key_buffer_size = @org_key_cache_buffer_size;
diff --git a/mysql-test/r/partition_range.result b/mysql-test/r/partition_range.result
index 87cb4fba306..0bd7605a5c8 100644
--- a/mysql-test/r/partition_range.result
+++ b/mysql-test/r/partition_range.result
@@ -1,6 +1,19 @@
drop table if exists t1, t2;
create table t1 (a int)
partition by range (a)
+subpartition by hash(to_seconds(a))
+(partition p0 values less than (1));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50500 PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (to_seconds(a))
+(PARTITION p0 VALUES LESS THAN (1) ENGINE = MyISAM) */
+drop table t1;
+create table t1 (a int)
+partition by range (a)
( partition p0 values less than (NULL),
partition p1 values less than (MAXVALUE));
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
@@ -30,6 +43,14 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t1 where a < '2007-03-07 23:59:59';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` datetime NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50500 PARTITION BY RANGE (TO_SECONDS(a))
+(PARTITION p0 VALUES LESS THAN (63340531200) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (63342604800) ENGINE = MyISAM) */
drop table t1;
create table t1 (a date)
partition by range(to_seconds(a))
@@ -53,6 +74,14 @@ select * from t1 where a <= '2005-01-01';
a
2003-12-30
2004-12-31
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50500 PARTITION BY RANGE (to_seconds(a))
+(PARTITION p0 VALUES LESS THAN (63240134400) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (63271756800) ENGINE = MyISAM) */
drop table t1;
create table t1 (a datetime)
partition by range(to_seconds(a))
@@ -75,6 +104,14 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
select * from t1 where a <= '2005-01-01';
a
2004-01-01 11:59:29
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50500 PARTITION BY RANGE (to_seconds(a))
+(PARTITION p0 VALUES LESS THAN (63240177600) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (63271800000) ENGINE = MyISAM) */
drop table t1;
create table t1 (a int, b char(20))
partition by range columns(a,b)
diff --git a/mysql-test/r/partition_utf8.result b/mysql-test/r/partition_utf8.result
index 0fae7bb16b6..339871f1f4a 100644
--- a/mysql-test/r/partition_utf8.result
+++ b/mysql-test/r/partition_utf8.result
@@ -7,7 +7,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(2) CHARACTER SET cp1250 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST COLUMNS(a)
+/*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN (_cp1250 0x81) ENGINE = MyISAM) */
drop table t1;
create table t1 (a varchar(2) character set cp1250)
@@ -18,7 +18,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(2) CHARACTER SET cp1250 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST COLUMNS(a)
+/*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN ('€') ENGINE = MyISAM) */
drop table t1;
create table t1 (a varchar(1500), b varchar(1570))
@@ -45,7 +45,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST COLUMNS(a)
+/*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN ('†') ENGINE = MyISAM,
PARTITION p1 VALUES IN ('') ENGINE = MyISAM) */
insert into t1 values ('');
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index c51863b73f7..4f9444c1542 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -2585,10 +2585,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= '9223372036854775807' ;
@@ -2608,10 +2608,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= -9223372036854775808 ;
@@ -2631,10 +2631,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= '-9223372036854775808' ;
@@ -2654,10 +2654,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= 1.11111111111111111111e+50 ;
@@ -2679,10 +2679,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= '1.11111111111111111111e+50' ;
@@ -2704,10 +2704,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= -1.11111111111111111111e+50 ;
@@ -2729,10 +2729,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
set @arg00= '-1.11111111111111111111e+50' ;
@@ -2754,10 +2754,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
test_sequence
@@ -2822,10 +2822,10 @@ c1 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30
51 5 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0
52 5 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0
53 5 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0
-54 5 54 54 54.00 54.00 54.00 54.00 54.00 54.00 54.00 54.00
-55 5 55 55 55 55 55 55 55 55 55 55
-56 6 56 56 56.00 56.00 56.00 56.00 56.00 56.00 56.00 56.00
-57 6 57 57 57.00 57.00 57.00 57.00 57.00 57.00 57.00 57.00
+54 5 54 54 54 54 54 54 54 54 54 54
+55 6 55 55 55 55 55 55 55 55 55 55
+56 6 56 56 56 56 56 56 56 56 56 56
+57 6 57 57 57 57 57 57 57 57 57 57
60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
61 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
62 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
@@ -3039,7 +3039,7 @@ c1 c13 c14 c15 c16 c17
42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+51 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index 2670451f24e..772a7462342 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -2568,10 +2568,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= '9223372036854775807' ;
@@ -2591,10 +2591,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= -9223372036854775808 ;
@@ -2614,10 +2614,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= '-9223372036854775808' ;
@@ -2637,10 +2637,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= 1.11111111111111111111e+50 ;
@@ -2662,10 +2662,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= '1.11111111111111111111e+50' ;
@@ -2687,10 +2687,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= -1.11111111111111111111e+50 ;
@@ -2712,10 +2712,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
set @arg00= '-1.11111111111111111111e+50' ;
@@ -2737,10 +2737,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
test_sequence
@@ -2805,10 +2805,10 @@ c1 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30
51 5 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0
52 5 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0
53 5 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0
-54 5 54 54 54.00 54.00 54.00 54.00 54.00 54.00 54.00 54.00
-55 5 55 55 55 55 55 55 55 55 55 55
-56 6 56 56 56.00 56.00 56.00 56.00 56.00 56.00 56.00 56.00
-57 6 57 57 57.00 57.00 57.00 57.00 57.00 57.00 57.00 57.00
+54 5 54 54 54 54 54 54 54 54 54 54
+55 6 55 55 55 55 55 55 55 55 55 55
+56 6 56 56 56 56 56 56 56 56 56 56
+57 6 57 57 57 57 57 57 57 57 57 57
60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
61 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
62 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
@@ -3022,7 +3022,7 @@ c1 c13 c14 c15 c16 c17
42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+51 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index 4372c470b2d..84bf7a6fa00 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -2569,10 +2569,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= '9223372036854775807' ;
@@ -2592,10 +2592,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= -9223372036854775808 ;
@@ -2615,10 +2615,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= '-9223372036854775808' ;
@@ -2638,10 +2638,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= 1.11111111111111111111e+50 ;
@@ -2663,10 +2663,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= '1.11111111111111111111e+50' ;
@@ -2688,10 +2688,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= -1.11111111111111111111e+50 ;
@@ -2713,10 +2713,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
set @arg00= '-1.11111111111111111111e+50' ;
@@ -2738,10 +2738,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
test_sequence
@@ -2807,7 +2807,7 @@ c1 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30
52 5 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0
53 5 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0
54 5 54 54 54 54 54 54 54 54 54 54
-55 5 55 55 55 55 55 55 55 55 55 55
+55 6 55 55 55 55 55 55 55 55 55 55
56 6 56 56 56 56 56 56 56 56 56 56
57 6 57 57 57 57 57 57 57 57 57 57
60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
@@ -3023,7 +3023,7 @@ c1 c13 c14 c15 c16 c17
42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+51 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index 35a43f7c032..61d2822fd5b 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -2505,10 +2505,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= '9223372036854775807' ;
@@ -2528,10 +2528,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= -9223372036854775808 ;
@@ -2551,10 +2551,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= '-9223372036854775808' ;
@@ -2574,10 +2574,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= 1.11111111111111111111e+50 ;
@@ -2599,10 +2599,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= '1.11111111111111111111e+50' ;
@@ -2624,10 +2624,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= -1.11111111111111111111e+50 ;
@@ -2649,10 +2649,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
set @arg00= '-1.11111111111111111111e+50' ;
@@ -2674,10 +2674,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
test_sequence
@@ -2742,10 +2742,10 @@ c1 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30
51 5 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0
52 5 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0
53 5 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0
-54 5 54 54 54.00 54.00 54.00 54.00 54.00 54.00 54.00 54.00
-55 5 55 55 55 55 55 55 55 55 55 55
-56 6 56 56 56.00 56.00 56.00 56.00 56.00 56.00 56.00 56.00
-57 6 57 57 57.00 57.00 57.00 57.00 57.00 57.00 57.00 57.00
+54 5 54 54 54 54 54 54 54 54 54 54
+55 6 55 55 55 55 55 55 55 55 55 55
+56 6 56 56 56 56 56 56 56 56 56 56
+57 6 57 57 57 57 57 57 57 57 57 57
60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
61 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
62 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
@@ -2959,7 +2959,7 @@ c1 c13 c14 c15 c16 c17
42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+51 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
@@ -5527,10 +5527,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= '9223372036854775807' ;
@@ -5550,10 +5550,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= -9223372036854775808 ;
@@ -5573,10 +5573,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= '-9223372036854775808' ;
@@ -5596,10 +5596,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= 1.11111111111111111111e+50 ;
@@ -5621,10 +5621,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= '1.11111111111111111111e+50' ;
@@ -5646,10 +5646,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= -1.11111111111111111111e+50 ;
@@ -5671,10 +5671,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
set @arg00= '-1.11111111111111111111e+50' ;
@@ -5696,10 +5696,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
test_sequence
@@ -5764,10 +5764,10 @@ c1 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30
51 5 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0
52 5 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0
53 5 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0
-54 5 54 54 54.00 54.00 54.00 54.00 54.00 54.00 54.00 54.00
-55 5 55 55 55 55 55 55 55 55 55 55
-56 6 56 56 56.00 56.00 56.00 56.00 56.00 56.00 56.00 56.00
-57 6 57 57 57.00 57.00 57.00 57.00 57.00 57.00 57.00 57.00
+54 5 54 54 54 54 54 54 54 54 54 54
+55 6 55 55 55 55 55 55 55 55 55 55
+56 6 56 56 56 56 56 56 56 56 56 56
+57 6 57 57 57 57 57 57 57 57 57 57
60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
61 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
62 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
@@ -5981,7 +5981,7 @@ c1 c13 c14 c15 c16 c17
42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+51 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index b67fa9322ee..9cde630e4ed 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -176,21 +176,6 @@ a
1
2
3
-select * from t1 union select sql_cache * from t1;
-a
-1
-2
-3
-select * from t1 where a IN (select sql_cache a from t1);
-a
-1
-2
-3
-select * from t1 where a IN (select a from t1 union select sql_cache a from t1);
-a
-1
-2
-3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 4
@@ -207,41 +192,6 @@ a
1
2
3
-select * from t1 union select sql_no_cache * from t1;
-a
-1
-2
-3
-select * from t1 where a IN (select sql_no_cache a from t1);
-a
-1
-2
-3
-select * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
-a
-1
-2
-3
-select sql_cache sql_no_cache * from t1;
-a
-1
-2
-3
-select sql_cache * from t1 union select sql_no_cache * from t1;
-a
-1
-2
-3
-select sql_cache * from t1 where a IN (select sql_no_cache a from t1);
-a
-1
-2
-3
-select sql_cache * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
-a
-1
-2
-3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
@@ -1490,12 +1440,6 @@ insert into t1 values ('c');
a
drop table t1;
set GLOBAL query_cache_size= default;
-set GLOBAL query_cache_size=1000000;
-create table t1 (a char);
-insert into t1 values ('c');
-a
-drop table t1;
-set GLOBAL query_cache_size= default;
SET GLOBAL query_cache_size=64*1024*1024;
CREATE TABLE t1 (id INT);
CREATE PROCEDURE proc29856(IN theUPC TEXT)
@@ -1723,4 +1667,55 @@ SELECT 1 FROM t1 GROUP BY
1
DROP TABLE t1;
SET GLOBAL query_cache_size= default;
+CREATE TABLE t1( a INT );
+SET @v = ( SELECT SQL_CACHE 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SET @v = ( SELECT SQL_NO_CACHE 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT ( SELECT SQL_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT SQL_CACHE * FROM t1;
+a
+SELECT SQL_NO_CACHE * FROM t1;
+a
+SELECT * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+ERROR 42000: Incorrect usage/placement of 'SQL_CACHE'
+SELECT * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+ERROR 42000: Incorrect usage/placement of 'SQL_NO_CACHE'
+SELECT * FROM t1 WHERE a IN (SELECT SQL_CACHE a FROM t1);
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 UNION SELECT SQL_CACHE a FROM t1);
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+ERROR 42000: Incorrect usage/placement of 'SQL_NO_CACHE'
+SELECT * FROM t1 WHERE a IN (SELECT SQL_NO_CACHE a FROM t1);
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT * FROM t1 WHERE a IN
+(SELECT a FROM t1 UNION SELECT SQL_NO_CACHE a FROM t1);
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT SQL_CACHE SQL_NO_CACHE * FROM t1;
+ERROR HY000: Incorrect usage of SQL_CACHE and SQL_NO_CACHE
+SELECT SQL_NO_CACHE SQL_CACHE * FROM t1;
+ERROR HY000: Incorrect usage of SQL_NO_CACHE and SQL_CACHE
+SELECT SQL_CACHE * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+ERROR 42000: Incorrect usage/placement of 'SQL_CACHE'
+SELECT SQL_CACHE * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+ERROR 42000: Incorrect usage/placement of 'SQL_NO_CACHE'
+SELECT SQL_NO_CACHE * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+ERROR 42000: Incorrect usage/placement of 'SQL_CACHE'
+SELECT SQL_NO_CACHE * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+ERROR 42000: Incorrect usage/placement of 'SQL_NO_CACHE'
+SELECT SQL_CACHE * FROM t1 WHERE a IN
+(SELECT SQL_NO_CACHE a FROM t1);
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT SQL_CACHE * FROM t1 WHERE a IN
+(SELECT a FROM t1 UNION SELECT SQL_NO_CACHE a FROM t1);
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index ff2dd49e725..41dd44fc4d0 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2784,26 +2784,26 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select max(key1) from t1 where key1 <= 0.6158;
max(key1)
-0.615800023078918
+0.6158000230789185
select max(key2) from t2 where key2 <= 1.6158;
max(key2)
-1.61580002307892
+1.6158000230789185
select min(key1) from t1 where key1 >= 0.3762;
min(key1)
-0.376199990510941
+0.37619999051094055
select min(key2) from t2 where key2 >= 1.3762;
min(key2)
-1.37619996070862
+1.3761999607086182
select max(key1), min(key2) from t1, t2
where key1 <= 0.6158 and key2 >= 1.3762;
max(key1) min(key2)
-0.615800023078918 1.37619996070862
+0.6158000230789185 1.3761999607086182
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
max(key1)
-0.615800023078918
+0.6158000230789185
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
min(key1)
-0.376199990510941
+0.37619999051094055
DROP TABLE t1,t2;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 4e40c48305d..c6276f319a1 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -737,20 +737,11 @@ View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()` binary binary
DROP VIEW v1;
CREATE VIEW v1 AS SELECT SQL_CACHE SQL_NO_CACHE NOW();
-SHOW CREATE VIEW v1;
-View Create View character_set_client collation_connection
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()` binary binary
-DROP VIEW v1;
+ERROR HY000: Incorrect usage of SQL_CACHE and SQL_NO_CACHE
CREATE VIEW v1 AS SELECT SQL_NO_CACHE SQL_CACHE NOW();
-SHOW CREATE VIEW v1;
-View Create View character_set_client collation_connection
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()` binary binary
-DROP VIEW v1;
+ERROR HY000: Incorrect usage of SQL_NO_CACHE and SQL_CACHE
CREATE VIEW v1 AS SELECT SQL_CACHE SQL_NO_CACHE SQL_CACHE NOW();
-SHOW CREATE VIEW v1;
-View Create View character_set_client collation_connection
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache now() AS `NOW()` binary binary
-DROP VIEW v1;
+ERROR HY000: Incorrect usage of SQL_CACHE and SQL_NO_CACHE
CREATE PROCEDURE p1()
BEGIN
SET @s= 'CREATE VIEW v1 AS SELECT SQL_CACHE 1';
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 662e466d43e..fb5eada9083 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -579,7 +579,7 @@ return 2.7182818284590452354|
set @e = e()|
select e(), @e|
e() @e
-2.71828182845905 2.71828182845905
+2.718281828459045 2.718281828459045
drop function if exists inc|
create function inc(i int) returns int
return i+1|
@@ -616,23 +616,23 @@ create function fun(d double, i int, u int unsigned) returns double
return mul(inc(i), fac(u)) / e()|
select fun(2.3, 3, 5)|
fun(2.3, 3, 5)
-176.582131762292
+176.58213176229233
insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
select * from t2 where s = append("a", "b")|
s i d
-ab 24 1324.36598821719
+ab 24 1324.3659882171924
select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2) order by i|
s i d
-xxxyyy 12 2.71828182845905
-ab 24 1324.36598821719
+xxxyyy 12 2.718281828459045
+ab 24 1324.3659882171924
select * from t2 where d = e()|
s i d
-xxxyyy 12 2.71828182845905
+xxxyyy 12 2.718281828459045
select * from t2 order by i|
s i d
-xxxyyy 12 2.71828182845905
-ab 24 1324.36598821719
+xxxyyy 12 2.718281828459045
+ab 24 1324.3659882171924
delete from t2|
drop function e|
drop function inc|
@@ -5970,9 +5970,9 @@ CREATE TABLE t3 (f1 INT, f2 FLOAT)|
INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)|
SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP|
SUM(f2) bug25373(f1)
-6.30000007152557 1
+6.300000071525574 1
15 2
-21.3000000715256 NULL
+21.300000071525574 NULL
DROP FUNCTION bug25373|
DROP TABLE t3|
DROP DATABASE IF EXISTS mysqltest1|
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index 897c9072203..bdb7576f95e 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -873,14 +873,14 @@ Warning 1264 Out of range value for column 'col2' at row 1
SELECT * FROM t1;
col1 col2
-1.1e-37 0
-3.4e+38 3.4e+38
+3.4e38 3.4e38
-1.1e-37 0
-3.4e+38 3.4e+38
+3.4e38 3.4e38
0 NULL
2 NULL
NULL NULL
-3.40282e+38 0
-3.40282e+38 0
+3.40282e38 0
+3.40282e38 0
DROP TABLE t1;
CREATE TABLE t1 (col1 DOUBLE PRECISION, col2 DOUBLE PRECISION UNSIGNED);
INSERT INTO t1 VALUES (-2.2E-307,0),(2E-307,0),(+1.7E+308,+1.7E+308);
@@ -922,14 +922,14 @@ SELECT * FROM t1;
col1 col2
-2.2e-307 0
1e-303 0
-NULL 1.7e+308
+NULL 1.7e308
-2.2e-307 0
-2e-307 0
-NULL 1.7e+308
+NULL 1.7e308
0 NULL
2 NULL
NULL NULL
-1.79769313486232e+308 0
+1.7976931348623157e308 0
DROP TABLE t1;
CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6));
INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello ', 'hello ');
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index 67898b7f335..d131fa2b4d5 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -796,6 +796,18 @@ SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
ROUND(qty,3) dps ROUND(qty,dps)
1.133 3 1.133000
DROP TABLE t1;
+create table t1 (c1 decimal(10,6));
+insert into t1 (c1) values (9.99e-4);
+insert into t1 (c1) values (9.98e-4);
+insert into t1 (c1) values (0.000999);
+insert into t1 (c1) values (cast(9.99e-4 as decimal(10,6)));
+select * from t1;
+c1
+0.000999
+0.000998
+0.000999
+0.000999
+drop table t1;
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
%
0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index a3a13bb0435..546e281ee67 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -2,9 +2,9 @@ drop table if exists t1,t2;
SELECT 10,10.0,10.,.1e+2,100.0e-1;
10 10.0 10. .1e+2 100.0e-1
10 10.0 10 10 10
-SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
-6e-05 -6e-05 --6e-05 -6e-05+1.000000
-6e-05 -6e-05 6e-05 0.99994
+SELECT 6e-16, -6e-16, --6e-16, -6e-16+1.000000;
+6e-16 -6e-16 --6e-16 -6e-16+1.000000
+6e-16 -6e-16 6e-16 0.9999999999999994
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1
10 10 10 10 10 10 0.1 0.1 0.1
@@ -31,16 +31,16 @@ select * from t1;
f1 f2
10 10
100000 100000
-1.23457e+09 1234567890
-1e+10 10000000000
-1e+15 1e+15
-1e+20 1e+20
-3.40282e+38 1e+50
-3.40282e+38 1e+150
+1234570000 1234567890
+10000000000 10000000000
+1e15 1e15
+1e20 1e20
+3.40282e38 1e50
+3.40282e38 1e150
-10 -10
-1e-05 1e-05
-1e-10 1e-10
-1e-15 1e-15
+0.00001 0.00001
+0.0000000001 0.0000000001
+0.000000000000001 0.000000000000001
1e-20 1e-20
0 1e-50
0 1e-150
@@ -87,7 +87,7 @@ col
create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1;
select * from t2;
col1 col2 col3 col4
-140.36 121.00000 121 3.47850542618522e-07
+140.36 121.00000 121 0.00000034785054261852176
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
@@ -201,9 +201,9 @@ insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
select * from t1;
c
200000
-2e+06
+2e6
0.0002
-2e-05
+2e-5
drop table t1;
CREATE TABLE t1 (
reckey int unsigned NOT NULL,
@@ -267,7 +267,7 @@ select 1e-308, 1.00000001e-300, 100000000e-300;
1e-308 1.00000001e-300 1e-292
select 10e307;
10e307
-1e+308
+1e308
create table t1(a int, b double(8, 2));
insert into t1 values
(1, 28.50), (1, 121.85), (1, 157.23), (1, 1351.00), (1, -1965.35), (1, 81.75),
@@ -369,12 +369,12 @@ Warning 1264 Out of range value for column 'f1' at row 1
Warning 1264 Out of range value for column 'f1' at row 2
select f1 + 0e0 from t1;
f1 + 0e0
-1e+199
--1e+199
-1e+200
--1e+200
-1e+200
--1e+200
+1e199
+-1e199
+1e200
+-1e200
+1e200
+-1e200
drop table t1;
create table t1 (f1 float(30, 0));
insert into t1 values (1e29), (-1e29);
@@ -385,12 +385,36 @@ Warning 1264 Out of range value for column 'f1' at row 1
Warning 1264 Out of range value for column 'f1' at row 2
select f1 + 0e0 from t1;
f1 + 0e0
-1.00000001504747e+29
--1.00000001504747e+29
-1.00000001504747e+30
--1.00000001504747e+30
-1.00000001504747e+30
--1.00000001504747e+30
+1.0000000150474662e29
+-1.0000000150474662e29
+1.0000000150474662e30
+-1.0000000150474662e30
+1.0000000150474662e30
+-1.0000000150474662e30
+drop table t1;
+create table t1 (c char(6));
+insert into t1 values (2e6),(2e-5);
+select * from t1;
+c
+2e6
+2e-5
+drop table t1;
+CREATE TABLE d1 (d DOUBLE);
+INSERT INTO d1 VALUES (1.7976931348623157E+308);
+SELECT * FROM d1;
+d
+1.7976931348623157e308
+INSERT INTO d1 VALUES (1.79769313486232e+308);
+ERROR 22007: Illegal double '1.79769313486232e+308' value found during parsing
+SELECT * FROM d1;
+d
+1.7976931348623157e308
+DROP TABLE d1;
+create table t1 (a char(20));
+insert into t1 values (1.225e-05);
+select a+0 from t1;
+a+0
+0.00001225
drop table t1;
create table t1(d double, u bigint unsigned);
insert into t1(d) values (9.22337203685479e18),
@@ -405,6 +429,6 @@ CREATE TABLE t1 (f1 DOUBLE);
INSERT INTO t1 VALUES(-1.79769313486231e+308);
SELECT f1 FROM t1;
f1
--1.79769313486231e+308
+-1.79769313486231e308
DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 172b343e003..00526597a32 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -917,7 +917,7 @@ cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15))
0.000000000100000
select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
c1 c2 c3
-9.5468126085974 9.547 9.547
+9.546812608597396 9.547 9.547
select convert(ln(14000),decimal(2,3)) c1;
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
select cast(ln(14000) as decimal(2,3)) c1;
@@ -1141,17 +1141,17 @@ my_float my_double my_varchar
1.17549e-18 1.175494345e-18 1.175494345e-18
1.17549e-17 1.175494345e-17 1.175494345e-17
1.17549e-16 1.175494345e-16 1.175494345e-16
-1.17549e-15 1.175494345e-15 1.175494345e-15
-1.17549e-14 1.175494345e-14 1.175494345e-14
-1.17549e-13 1.175494345e-13 1.175494345e-13
-1.17549e-12 1.175494345e-12 1.175494345e-12
-1.17549e-11 1.175494345e-11 1.175494345e-11
-1.17549e-10 1.175494345e-10 1.175494345e-10
-1.17549e-09 1.175494345e-09 1.175494345e-9
-1.17549e-08 1.175494345e-08 1.175494345e-8
-1.17549e-07 1.175494345e-07 1.175494345e-7
-1.17549e-06 1.175494345e-06 1.175494345e-6
-1.17549e-05 1.175494345e-05 1.175494345e-5
+0.00000000000000117549 0.000000000000001175494345 1.175494345e-15
+0.0000000000000117549 0.00000000000001175494345 1.175494345e-14
+0.000000000000117549 0.0000000000001175494345 1.175494345e-13
+0.00000000000117549 0.000000000001175494345 1.175494345e-12
+0.0000000000117549 0.00000000001175494345 1.175494345e-11
+0.000000000117549 0.0000000001175494345 1.175494345e-10
+0.00000000117549 0.000000001175494345 1.175494345e-9
+0.0000000117549 0.00000001175494345 1.175494345e-8
+0.000000117549 0.0000001175494345 1.175494345e-7
+0.00000117549 0.000001175494345 1.175494345e-6
+0.0000117549 0.00001175494345 1.175494345e-5
0.000117549 0.0001175494345 1.175494345e-4
0.00117549 0.001175494345 1.175494345e-3
0.0117549 0.01175494345 1.175494345e-2
@@ -1175,21 +1175,21 @@ CAST(my_float AS DECIMAL(65,30)) my_float
0.000000000000000001175494374380 1.17549e-18
0.000000000000000011754943743802 1.17549e-17
0.000000000000000117549432474939 1.17549e-16
-0.000000000000001175494324749389 1.17549e-15
-0.000000000000011754943671010360 1.17549e-14
-0.000000000000117549429933840000 1.17549e-13
-0.000000000001175494380653563000 1.17549e-12
-0.000000000011754943372854760000 1.17549e-11
-0.000000000117549428524377200000 1.17549e-10
-0.000000001175494368510499000000 1.17549e-09
-0.000000011754943685104990000000 1.17549e-08
-0.000000117549433298336200000000 1.17549e-07
-0.000001175494389826781000000000 1.17549e-06
-0.000011754943443520460000000000 1.17549e-05
+0.000000000000001175494324749389 0.00000000000000117549
+0.000000000000011754943671010362 0.0000000000000117549
+0.000000000000117549429933840040 0.000000000000117549
+0.000000000001175494380653563400 0.00000000000117549
+0.000000000011754943372854765000 0.0000000000117549
+0.000000000117549428524377220000 0.000000000117549
+0.000000001175494368510499000000 0.00000000117549
+0.000000011754943685104990000000 0.0000000117549
+0.000000117549433298336230000000 0.000000117549
+0.000001175494389826781100000000 0.00000117549
+0.000011754943443520460000000000 0.0000117549
0.000117549432616215200000000000 0.000117549
-0.001175494398921728000000000000 0.00117549
-0.011754943057894710000000000000 0.0117549
-0.117549434304237400000000000000 0.117549
+0.001175494398921728100000000000 0.00117549
+0.011754943057894707000000000000 0.0117549
+0.117549434304237370000000000000 0.117549
SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1;
CAST(my_double AS DECIMAL(65,30)) my_double
0.000000000000000000000000000000 1.175494345e-32
@@ -1209,17 +1209,17 @@ CAST(my_double AS DECIMAL(65,30)) my_double
0.000000000000000001175494345000 1.175494345e-18
0.000000000000000011754943450000 1.175494345e-17
0.000000000000000117549434500000 1.175494345e-16
-0.000000000000001175494345000000 1.175494345e-15
-0.000000000000011754943450000000 1.175494345e-14
-0.000000000000117549434500000000 1.175494345e-13
-0.000000000001175494345000000000 1.175494345e-12
-0.000000000011754943450000000000 1.175494345e-11
-0.000000000117549434500000000000 1.175494345e-10
-0.000000001175494345000000000000 1.175494345e-09
-0.000000011754943450000000000000 1.175494345e-08
-0.000000117549434500000000000000 1.175494345e-07
-0.000001175494345000000000000000 1.175494345e-06
-0.000011754943450000000000000000 1.175494345e-05
+0.000000000000001175494345000000 0.000000000000001175494345
+0.000000000000011754943450000000 0.00000000000001175494345
+0.000000000000117549434500000000 0.0000000000001175494345
+0.000000000001175494345000000000 0.000000000001175494345
+0.000000000011754943450000000000 0.00000000001175494345
+0.000000000117549434500000000000 0.0000000001175494345
+0.000000001175494345000000000000 0.000000001175494345
+0.000000011754943450000000000000 0.00000001175494345
+0.000000117549434500000000000000 0.0000001175494345
+0.000001175494345000000000000000 0.000001175494345
+0.000011754943450000000000000000 0.00001175494345
0.000117549434500000000000000000 0.0001175494345
0.001175494345000000000000000000 0.001175494345
0.011754943450000000000000000000 0.01175494345
@@ -1278,21 +1278,21 @@ my_decimal my_float
0.000000000000000001175494374380 1.17549e-18
0.000000000000000011754943743802 1.17549e-17
0.000000000000000117549432474939 1.17549e-16
-0.000000000000001175494324749389 1.17549e-15
-0.000000000000011754943671010360 1.17549e-14
-0.000000000000117549429933840000 1.17549e-13
-0.000000000001175494380653563000 1.17549e-12
-0.000000000011754943372854760000 1.17549e-11
-0.000000000117549428524377200000 1.17549e-10
-0.000000001175494368510499000000 1.17549e-09
-0.000000011754943685104990000000 1.17549e-08
-0.000000117549433298336200000000 1.17549e-07
-0.000001175494389826781000000000 1.17549e-06
-0.000011754943443520460000000000 1.17549e-05
+0.000000000000001175494324749389 0.00000000000000117549
+0.000000000000011754943671010362 0.0000000000000117549
+0.000000000000117549429933840040 0.000000000000117549
+0.000000000001175494380653563400 0.00000000000117549
+0.000000000011754943372854765000 0.0000000000117549
+0.000000000117549428524377220000 0.000000000117549
+0.000000001175494368510499000000 0.00000000117549
+0.000000011754943685104990000000 0.0000000117549
+0.000000117549433298336230000000 0.000000117549
+0.000001175494389826781100000000 0.00000117549
+0.000011754943443520460000000000 0.0000117549
0.000117549432616215200000000000 0.000117549
-0.001175494398921728000000000000 0.00117549
-0.011754943057894710000000000000 0.0117549
-0.117549434304237400000000000000 0.117549
+0.001175494398921728100000000000 0.00117549
+0.011754943057894707000000000000 0.0117549
+0.117549434304237370000000000000 0.117549
UPDATE t1 SET my_decimal = my_double;
SELECT my_decimal, my_double FROM t1;
my_decimal my_double
@@ -1313,17 +1313,17 @@ my_decimal my_double
0.000000000000000001175494345000 1.175494345e-18
0.000000000000000011754943450000 1.175494345e-17
0.000000000000000117549434500000 1.175494345e-16
-0.000000000000001175494345000000 1.175494345e-15
-0.000000000000011754943450000000 1.175494345e-14
-0.000000000000117549434500000000 1.175494345e-13
-0.000000000001175494345000000000 1.175494345e-12
-0.000000000011754943450000000000 1.175494345e-11
-0.000000000117549434500000000000 1.175494345e-10
-0.000000001175494345000000000000 1.175494345e-09
-0.000000011754943450000000000000 1.175494345e-08
-0.000000117549434500000000000000 1.175494345e-07
-0.000001175494345000000000000000 1.175494345e-06
-0.000011754943450000000000000000 1.175494345e-05
+0.000000000000001175494345000000 0.000000000000001175494345
+0.000000000000011754943450000000 0.00000000000001175494345
+0.000000000000117549434500000000 0.0000000000001175494345
+0.000000000001175494345000000000 0.000000000001175494345
+0.000000000011754943450000000000 0.00000000001175494345
+0.000000000117549434500000000000 0.0000000001175494345
+0.000000001175494345000000000000 0.000000001175494345
+0.000000011754943450000000000000 0.00000001175494345
+0.000000117549434500000000000000 0.0000001175494345
+0.000001175494345000000000000000 0.000001175494345
+0.000011754943450000000000000000 0.00001175494345
0.000117549434500000000000000000 0.0001175494345
0.001175494345000000000000000000 0.001175494345
0.011754943450000000000000000000 0.01175494345
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index f98872d93b3..95e374cc384 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -57,7 +57,7 @@ select @`select`,@not_used;
set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
select @test_int,@test_double,@test_string,@test_string2,@select;
@test_int @test_double @test_string @test_string2 @select
-10 1e-10 abcdeghi abcdefghij NULL
+10 0.0000000001 abcdeghi abcdefghij NULL
set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello";
select @test_int,@test_double,@test_string,@test_string2;
@test_int @test_double @test_string @test_string2
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index c66b05c7db7..4c0acc2eb6a 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -2588,7 +2588,7 @@ CREATE VIEW v1 AS SELECT SQRT(a) my_sqrt FROM t1;
SELECT my_sqrt FROM v1 ORDER BY my_sqrt;
my_sqrt
1
-1.4142135623731
+1.4142135623730951
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (id int PRIMARY KEY);
diff --git a/mysql-test/std_data/ndb_backup51_data_be/BACKUP-1-0.1.Data b/mysql-test/std_data/ndb_backup51_data_be/BACKUP-1-0.1.Data
index 2df8080956a..267039d757e 100644
--- a/mysql-test/std_data/ndb_backup51_data_be/BACKUP-1-0.1.Data
+++ b/mysql-test/std_data/ndb_backup51_data_be/BACKUP-1-0.1.Data
Binary files differ
diff --git a/mysql-test/std_data/ndb_backup51_data_le/BACKUP-1-0.2.Data b/mysql-test/std_data/ndb_backup51_data_le/BACKUP-1-0.2.Data
index 2c6f93e93b6..067fc6b716d 100644
--- a/mysql-test/std_data/ndb_backup51_data_le/BACKUP-1-0.2.Data
+++ b/mysql-test/std_data/ndb_backup51_data_le/BACKUP-1-0.2.Data
Binary files differ
diff --git a/mysql-test/suite/funcs_1/r/innodb_func_view.result b/mysql-test/suite/funcs_1/r/innodb_func_view.result
index b19252e4dd7..e788dfd9fc1 100644
--- a/mysql-test/suite/funcs_1/r/innodb_func_view.result
+++ b/mysql-test/suite/funcs_1/r/innodb_func_view.result
@@ -910,13 +910,13 @@ SELECT LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double), my_double, id FROM t
WHERE select_id = 151 OR select_id IS NULL order by id;
LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double) my_double id
NULL NULL 1
- -1.7976931348623e+308 2
-AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e+308 3
+ -1.7976931348623e308 2
+AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e308 3
0 4
-1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö',`t1_values`.`my_double`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -925,13 +925,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 151 OR select_id IS NULL) order by id;
LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double) my_double id
NULL NULL 1
- -1.7976931348623e+308 2
-AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e+308 3
+ -1.7976931348623e308 2
+AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e308 3
0 4
-1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -1354,8 +1354,8 @@ my_double, id FROM t1_values
WHERE select_id = 133 OR select_id IS NULL order by id;
IFNULL(my_double,'IS_NULL') my_double id
IS_NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -1366,8 +1366,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 133 OR select_id IS NULL) order by id;
IFNULL(my_double,'IS_NULL') my_double id
IS_NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
@@ -1682,8 +1682,8 @@ WHERE select_id = 121 OR select_id IS NULL order by id;
IF(my_double IS NULL, 'IS NULL',
'IS NOT NULL') my_double id
IS NULL NULL 1
-IS NOT NULL -1.7976931348623e+308 2
-IS NOT NULL 1.7976931348623e+308 3
+IS NOT NULL -1.7976931348623e308 2
+IS NOT NULL 1.7976931348623e308 3
IS NOT NULL 0 4
IS NOT NULL -1 5
SHOW CREATE VIEW v1;
@@ -1696,8 +1696,8 @@ WHERE select_id = 121 OR select_id IS NULL) order by id;
IF(my_double IS NULL, 'IS NULL',
'IS NOT NULL') my_double id
IS NULL NULL 1
-IS NOT NULL -1.7976931348623e+308 2
-IS NOT NULL 1.7976931348623e+308 3
+IS NOT NULL -1.7976931348623e308 2
+IS NOT NULL 1.7976931348623e308 3
IS NOT NULL 0 4
IS NOT NULL -1 5
DROP VIEW v1;
@@ -2014,8 +2014,8 @@ my_double, id FROM t1_values
WHERE select_id = 109 OR select_id IS NULL order by id;
IF(my_double, 'IS TRUE', 'IS NOT TRUE') my_double id
IS NOT TRUE NULL 1
-IS TRUE -1.7976931348623e+308 2
-IS TRUE 1.7976931348623e+308 3
+IS TRUE -1.7976931348623e308 2
+IS TRUE 1.7976931348623e308 3
IS NOT TRUE 0 4
IS TRUE -1 5
SHOW CREATE VIEW v1;
@@ -2026,8 +2026,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 109 OR select_id IS NULL) order by id;
IF(my_double, 'IS TRUE', 'IS NOT TRUE') my_double id
IS NOT TRUE NULL 1
-IS TRUE -1.7976931348623e+308 2
-IS TRUE 1.7976931348623e+308 3
+IS TRUE -1.7976931348623e308 2
+IS TRUE 1.7976931348623e308 3
IS NOT TRUE 0 4
IS TRUE -1 5
DROP VIEW v1;
@@ -2562,13 +2562,13 @@ my_double, id FROM t1_values
WHERE select_id = 89 OR select_id IS NULL order by id;
CAST(my_double AS UNSIGNED INTEGER) my_double id
NULL NULL 1
-9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
18446744073709551615 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2577,13 +2577,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 89 OR select_id IS NULL) order by id;
CAST(my_double AS UNSIGNED INTEGER) my_double id
NULL NULL 1
-9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
18446744073709551615 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -2930,13 +2930,13 @@ my_double, id FROM t1_values
WHERE select_id = 77 OR select_id IS NULL order by id;
CAST(my_double AS SIGNED INTEGER) my_double id
NULL NULL 1
--9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+-9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
-1 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as signed) AS `CAST(my_double AS SIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2945,13 +2945,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 77 OR select_id IS NULL) order by id;
CAST(my_double AS SIGNED INTEGER) my_double id
NULL NULL 1
--9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+-9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
-1 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -3288,8 +3288,8 @@ my_double, id FROM t1_values
WHERE select_id = 65 OR select_id IS NULL order by id;
CAST(my_double AS DECIMAL(37,2)) my_double id
NULL NULL 1
--99999999999999999999999999999999999.99 -1.7976931348623e+308 2
-99999999999999999999999999999999999.99 1.7976931348623e+308 3
+-99999999999999999999999999999999999.99 -1.7976931348623e308 2
+99999999999999999999999999999999999.99 1.7976931348623e308 3
0.00 0 4
-1.00 -1 5
-3333.33 -3333.3333 30
@@ -3306,8 +3306,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 65 OR select_id IS NULL) order by id;
CAST(my_double AS DECIMAL(37,2)) my_double id
NULL NULL 1
--99999999999999999999999999999999999.99 -1.7976931348623e+308 2
-99999999999999999999999999999999999.99 1.7976931348623e+308 3
+-99999999999999999999999999999999999.99 -1.7976931348623e308 2
+99999999999999999999999999999999999.99 1.7976931348623e308 3
0.00 0 4
-1.00 -1 5
-3333.33 -3333.3333 30
@@ -3680,14 +3680,14 @@ my_double, id FROM t1_values
WHERE select_id = 53 OR select_id IS NULL order by id;
CAST(my_double AS TIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
00:00:00 0 4
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect time value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect time value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as time) AS `CAST(my_double AS TIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3696,14 +3696,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 53 OR select_id IS NULL) order by id;
CAST(my_double AS TIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
00:00:00 0 4
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect time value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect time value: '1.7976931348623e308'
DROP VIEW v1;
@@ -4042,14 +4042,14 @@ my_double, id FROM t1_values
WHERE select_id = 42 OR select_id IS NULL order by id;
CAST(my_double AS DATETIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
Warning 1292 Incorrect datetime value: '200506271758'
@@ -4061,14 +4061,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 42 OR select_id IS NULL) order by id;
CAST(my_double AS DATETIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
Warning 1292 Incorrect datetime value: '200506271758'
@@ -4416,14 +4416,14 @@ my_double, id FROM t1_values
WHERE select_id = 31 OR select_id IS NULL order by id;
CAST(my_double AS DATE) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
SHOW CREATE VIEW v1;
@@ -4434,14 +4434,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 31 OR select_id IS NULL) order by id;
CAST(my_double AS DATE) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
DROP VIEW v1;
@@ -4776,8 +4776,8 @@ my_double, id FROM t1_values
WHERE select_id = 20 OR select_id IS NULL order by id;
CAST(my_double AS CHAR) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -4788,8 +4788,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 20 OR select_id IS NULL) order by id;
CAST(my_double AS CHAR) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
@@ -5088,8 +5088,8 @@ my_double, id FROM t1_values
WHERE select_id = 8 OR select_id IS NULL order by id;
CAST(my_double AS BINARY) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -5100,8 +5100,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 8 OR select_id IS NULL) order by id;
CAST(my_double AS BINARY) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result
index 9511aa973e5..b4bce0b0d1b 100644
--- a/mysql-test/suite/funcs_1/r/innodb_views.result
+++ b/mysql-test/suite/funcs_1/r/innodb_views.result
@@ -22824,7 +22824,7 @@ f1 f2
ABC 3
SELECT * FROM v1 order by 2;
f1 my_sqrt
-ABC 1.73205080756888
+ABC 1.7320508075688772
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
@@ -22842,7 +22842,7 @@ ABC DEF
SELECT * FROM v1 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.73205080756888
+ABC 1.7320508075688772
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
@@ -22865,7 +22865,7 @@ my_sqrt double YES NULL
SELECT * FROM v2 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.73205080756888
+ABC 1.7320508075688772
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
@@ -22876,7 +22876,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v1;
Warnings:
@@ -22885,7 +22885,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v2;
Warnings:
@@ -22894,7 +22894,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t1;
DROP TABLE t2;
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/memory_func_view.result b/mysql-test/suite/funcs_1/r/memory_func_view.result
index eb3d326808f..3b1f1b03728 100644
--- a/mysql-test/suite/funcs_1/r/memory_func_view.result
+++ b/mysql-test/suite/funcs_1/r/memory_func_view.result
@@ -911,13 +911,13 @@ SELECT LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double), my_double, id FROM t
WHERE select_id = 151 OR select_id IS NULL order by id;
LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double) my_double id
NULL NULL 1
- -1.7976931348623e+308 2
-AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e+308 3
+ -1.7976931348623e308 2
+AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e308 3
0 4
-1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö',`t1_values`.`my_double`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -926,13 +926,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 151 OR select_id IS NULL) order by id;
LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double) my_double id
NULL NULL 1
- -1.7976931348623e+308 2
-AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e+308 3
+ -1.7976931348623e308 2
+AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e308 3
0 4
-1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -1355,8 +1355,8 @@ my_double, id FROM t1_values
WHERE select_id = 133 OR select_id IS NULL order by id;
IFNULL(my_double,'IS_NULL') my_double id
IS_NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -1367,8 +1367,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 133 OR select_id IS NULL) order by id;
IFNULL(my_double,'IS_NULL') my_double id
IS_NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
@@ -1683,8 +1683,8 @@ WHERE select_id = 121 OR select_id IS NULL order by id;
IF(my_double IS NULL, 'IS NULL',
'IS NOT NULL') my_double id
IS NULL NULL 1
-IS NOT NULL -1.7976931348623e+308 2
-IS NOT NULL 1.7976931348623e+308 3
+IS NOT NULL -1.7976931348623e308 2
+IS NOT NULL 1.7976931348623e308 3
IS NOT NULL 0 4
IS NOT NULL -1 5
SHOW CREATE VIEW v1;
@@ -1697,8 +1697,8 @@ WHERE select_id = 121 OR select_id IS NULL) order by id;
IF(my_double IS NULL, 'IS NULL',
'IS NOT NULL') my_double id
IS NULL NULL 1
-IS NOT NULL -1.7976931348623e+308 2
-IS NOT NULL 1.7976931348623e+308 3
+IS NOT NULL -1.7976931348623e308 2
+IS NOT NULL 1.7976931348623e308 3
IS NOT NULL 0 4
IS NOT NULL -1 5
DROP VIEW v1;
@@ -2015,8 +2015,8 @@ my_double, id FROM t1_values
WHERE select_id = 109 OR select_id IS NULL order by id;
IF(my_double, 'IS TRUE', 'IS NOT TRUE') my_double id
IS NOT TRUE NULL 1
-IS TRUE -1.7976931348623e+308 2
-IS TRUE 1.7976931348623e+308 3
+IS TRUE -1.7976931348623e308 2
+IS TRUE 1.7976931348623e308 3
IS NOT TRUE 0 4
IS TRUE -1 5
SHOW CREATE VIEW v1;
@@ -2027,8 +2027,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 109 OR select_id IS NULL) order by id;
IF(my_double, 'IS TRUE', 'IS NOT TRUE') my_double id
IS NOT TRUE NULL 1
-IS TRUE -1.7976931348623e+308 2
-IS TRUE 1.7976931348623e+308 3
+IS TRUE -1.7976931348623e308 2
+IS TRUE 1.7976931348623e308 3
IS NOT TRUE 0 4
IS TRUE -1 5
DROP VIEW v1;
@@ -2563,13 +2563,13 @@ my_double, id FROM t1_values
WHERE select_id = 89 OR select_id IS NULL order by id;
CAST(my_double AS UNSIGNED INTEGER) my_double id
NULL NULL 1
-9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
18446744073709551615 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2578,13 +2578,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 89 OR select_id IS NULL) order by id;
CAST(my_double AS UNSIGNED INTEGER) my_double id
NULL NULL 1
-9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
18446744073709551615 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -2931,13 +2931,13 @@ my_double, id FROM t1_values
WHERE select_id = 77 OR select_id IS NULL order by id;
CAST(my_double AS SIGNED INTEGER) my_double id
NULL NULL 1
--9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+-9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
-1 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as signed) AS `CAST(my_double AS SIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2946,13 +2946,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 77 OR select_id IS NULL) order by id;
CAST(my_double AS SIGNED INTEGER) my_double id
NULL NULL 1
--9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+-9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
-1 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -3289,8 +3289,8 @@ my_double, id FROM t1_values
WHERE select_id = 65 OR select_id IS NULL order by id;
CAST(my_double AS DECIMAL(37,2)) my_double id
NULL NULL 1
--99999999999999999999999999999999999.99 -1.7976931348623e+308 2
-99999999999999999999999999999999999.99 1.7976931348623e+308 3
+-99999999999999999999999999999999999.99 -1.7976931348623e308 2
+99999999999999999999999999999999999.99 1.7976931348623e308 3
0.00 0 4
-1.00 -1 5
-3333.33 -3333.3333 30
@@ -3307,8 +3307,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 65 OR select_id IS NULL) order by id;
CAST(my_double AS DECIMAL(37,2)) my_double id
NULL NULL 1
--99999999999999999999999999999999999.99 -1.7976931348623e+308 2
-99999999999999999999999999999999999.99 1.7976931348623e+308 3
+-99999999999999999999999999999999999.99 -1.7976931348623e308 2
+99999999999999999999999999999999999.99 1.7976931348623e308 3
0.00 0 4
-1.00 -1 5
-3333.33 -3333.3333 30
@@ -3681,14 +3681,14 @@ my_double, id FROM t1_values
WHERE select_id = 53 OR select_id IS NULL order by id;
CAST(my_double AS TIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
00:00:00 0 4
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect time value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect time value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as time) AS `CAST(my_double AS TIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3697,14 +3697,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 53 OR select_id IS NULL) order by id;
CAST(my_double AS TIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
00:00:00 0 4
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect time value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect time value: '1.7976931348623e308'
DROP VIEW v1;
@@ -4043,14 +4043,14 @@ my_double, id FROM t1_values
WHERE select_id = 42 OR select_id IS NULL order by id;
CAST(my_double AS DATETIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
Warning 1292 Incorrect datetime value: '200506271758'
@@ -4062,14 +4062,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 42 OR select_id IS NULL) order by id;
CAST(my_double AS DATETIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
Warning 1292 Incorrect datetime value: '200506271758'
@@ -4417,14 +4417,14 @@ my_double, id FROM t1_values
WHERE select_id = 31 OR select_id IS NULL order by id;
CAST(my_double AS DATE) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
SHOW CREATE VIEW v1;
@@ -4435,14 +4435,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 31 OR select_id IS NULL) order by id;
CAST(my_double AS DATE) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
DROP VIEW v1;
@@ -4777,8 +4777,8 @@ my_double, id FROM t1_values
WHERE select_id = 20 OR select_id IS NULL order by id;
CAST(my_double AS CHAR) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -4789,8 +4789,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 20 OR select_id IS NULL) order by id;
CAST(my_double AS CHAR) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
@@ -5089,8 +5089,8 @@ my_double, id FROM t1_values
WHERE select_id = 8 OR select_id IS NULL order by id;
CAST(my_double AS BINARY) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -5101,8 +5101,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 8 OR select_id IS NULL) order by id;
CAST(my_double AS BINARY) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result
index 7f3a0efb8b8..2f7342088f8 100644
--- a/mysql-test/suite/funcs_1/r/memory_views.result
+++ b/mysql-test/suite/funcs_1/r/memory_views.result
@@ -22826,7 +22826,7 @@ f1 f2
ABC 3
SELECT * FROM v1 order by 2;
f1 my_sqrt
-ABC 1.73205080756888
+ABC 1.7320508075688772
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
@@ -22844,7 +22844,7 @@ ABC DEF
SELECT * FROM v1 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.73205080756888
+ABC 1.7320508075688772
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
@@ -22867,7 +22867,7 @@ my_sqrt double YES NULL
SELECT * FROM v2 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.73205080756888
+ABC 1.7320508075688772
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
@@ -22878,7 +22878,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v1;
Warnings:
@@ -22887,7 +22887,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v2;
Warnings:
@@ -22896,7 +22896,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t1;
DROP TABLE t2;
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/myisam_func_view.result b/mysql-test/suite/funcs_1/r/myisam_func_view.result
index eb3d326808f..3b1f1b03728 100644
--- a/mysql-test/suite/funcs_1/r/myisam_func_view.result
+++ b/mysql-test/suite/funcs_1/r/myisam_func_view.result
@@ -911,13 +911,13 @@ SELECT LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double), my_double, id FROM t
WHERE select_id = 151 OR select_id IS NULL order by id;
LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double) my_double id
NULL NULL 1
- -1.7976931348623e+308 2
-AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e+308 3
+ -1.7976931348623e308 2
+AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e308 3
0 4
-1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö',`t1_values`.`my_double`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -926,13 +926,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 151 OR select_id IS NULL) order by id;
LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double) my_double id
NULL NULL 1
- -1.7976931348623e+308 2
-AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e+308 3
+ -1.7976931348623e308 2
+AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e308 3
0 4
-1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -1355,8 +1355,8 @@ my_double, id FROM t1_values
WHERE select_id = 133 OR select_id IS NULL order by id;
IFNULL(my_double,'IS_NULL') my_double id
IS_NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -1367,8 +1367,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 133 OR select_id IS NULL) order by id;
IFNULL(my_double,'IS_NULL') my_double id
IS_NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
@@ -1683,8 +1683,8 @@ WHERE select_id = 121 OR select_id IS NULL order by id;
IF(my_double IS NULL, 'IS NULL',
'IS NOT NULL') my_double id
IS NULL NULL 1
-IS NOT NULL -1.7976931348623e+308 2
-IS NOT NULL 1.7976931348623e+308 3
+IS NOT NULL -1.7976931348623e308 2
+IS NOT NULL 1.7976931348623e308 3
IS NOT NULL 0 4
IS NOT NULL -1 5
SHOW CREATE VIEW v1;
@@ -1697,8 +1697,8 @@ WHERE select_id = 121 OR select_id IS NULL) order by id;
IF(my_double IS NULL, 'IS NULL',
'IS NOT NULL') my_double id
IS NULL NULL 1
-IS NOT NULL -1.7976931348623e+308 2
-IS NOT NULL 1.7976931348623e+308 3
+IS NOT NULL -1.7976931348623e308 2
+IS NOT NULL 1.7976931348623e308 3
IS NOT NULL 0 4
IS NOT NULL -1 5
DROP VIEW v1;
@@ -2015,8 +2015,8 @@ my_double, id FROM t1_values
WHERE select_id = 109 OR select_id IS NULL order by id;
IF(my_double, 'IS TRUE', 'IS NOT TRUE') my_double id
IS NOT TRUE NULL 1
-IS TRUE -1.7976931348623e+308 2
-IS TRUE 1.7976931348623e+308 3
+IS TRUE -1.7976931348623e308 2
+IS TRUE 1.7976931348623e308 3
IS NOT TRUE 0 4
IS TRUE -1 5
SHOW CREATE VIEW v1;
@@ -2027,8 +2027,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 109 OR select_id IS NULL) order by id;
IF(my_double, 'IS TRUE', 'IS NOT TRUE') my_double id
IS NOT TRUE NULL 1
-IS TRUE -1.7976931348623e+308 2
-IS TRUE 1.7976931348623e+308 3
+IS TRUE -1.7976931348623e308 2
+IS TRUE 1.7976931348623e308 3
IS NOT TRUE 0 4
IS TRUE -1 5
DROP VIEW v1;
@@ -2563,13 +2563,13 @@ my_double, id FROM t1_values
WHERE select_id = 89 OR select_id IS NULL order by id;
CAST(my_double AS UNSIGNED INTEGER) my_double id
NULL NULL 1
-9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
18446744073709551615 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2578,13 +2578,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 89 OR select_id IS NULL) order by id;
CAST(my_double AS UNSIGNED INTEGER) my_double id
NULL NULL 1
-9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
18446744073709551615 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -2931,13 +2931,13 @@ my_double, id FROM t1_values
WHERE select_id = 77 OR select_id IS NULL order by id;
CAST(my_double AS SIGNED INTEGER) my_double id
NULL NULL 1
--9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+-9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
-1 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as signed) AS `CAST(my_double AS SIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2946,13 +2946,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 77 OR select_id IS NULL) order by id;
CAST(my_double AS SIGNED INTEGER) my_double id
NULL NULL 1
--9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+-9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
-1 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -3289,8 +3289,8 @@ my_double, id FROM t1_values
WHERE select_id = 65 OR select_id IS NULL order by id;
CAST(my_double AS DECIMAL(37,2)) my_double id
NULL NULL 1
--99999999999999999999999999999999999.99 -1.7976931348623e+308 2
-99999999999999999999999999999999999.99 1.7976931348623e+308 3
+-99999999999999999999999999999999999.99 -1.7976931348623e308 2
+99999999999999999999999999999999999.99 1.7976931348623e308 3
0.00 0 4
-1.00 -1 5
-3333.33 -3333.3333 30
@@ -3307,8 +3307,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 65 OR select_id IS NULL) order by id;
CAST(my_double AS DECIMAL(37,2)) my_double id
NULL NULL 1
--99999999999999999999999999999999999.99 -1.7976931348623e+308 2
-99999999999999999999999999999999999.99 1.7976931348623e+308 3
+-99999999999999999999999999999999999.99 -1.7976931348623e308 2
+99999999999999999999999999999999999.99 1.7976931348623e308 3
0.00 0 4
-1.00 -1 5
-3333.33 -3333.3333 30
@@ -3681,14 +3681,14 @@ my_double, id FROM t1_values
WHERE select_id = 53 OR select_id IS NULL order by id;
CAST(my_double AS TIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
00:00:00 0 4
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect time value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect time value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as time) AS `CAST(my_double AS TIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3697,14 +3697,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 53 OR select_id IS NULL) order by id;
CAST(my_double AS TIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
00:00:00 0 4
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect time value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect time value: '1.7976931348623e308'
DROP VIEW v1;
@@ -4043,14 +4043,14 @@ my_double, id FROM t1_values
WHERE select_id = 42 OR select_id IS NULL order by id;
CAST(my_double AS DATETIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
Warning 1292 Incorrect datetime value: '200506271758'
@@ -4062,14 +4062,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 42 OR select_id IS NULL) order by id;
CAST(my_double AS DATETIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
Warning 1292 Incorrect datetime value: '200506271758'
@@ -4417,14 +4417,14 @@ my_double, id FROM t1_values
WHERE select_id = 31 OR select_id IS NULL order by id;
CAST(my_double AS DATE) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
SHOW CREATE VIEW v1;
@@ -4435,14 +4435,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 31 OR select_id IS NULL) order by id;
CAST(my_double AS DATE) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
DROP VIEW v1;
@@ -4777,8 +4777,8 @@ my_double, id FROM t1_values
WHERE select_id = 20 OR select_id IS NULL order by id;
CAST(my_double AS CHAR) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -4789,8 +4789,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 20 OR select_id IS NULL) order by id;
CAST(my_double AS CHAR) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
@@ -5089,8 +5089,8 @@ my_double, id FROM t1_values
WHERE select_id = 8 OR select_id IS NULL order by id;
CAST(my_double AS BINARY) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -5101,8 +5101,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 8 OR select_id IS NULL) order by id;
CAST(my_double AS BINARY) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/myisam_views.result b/mysql-test/suite/funcs_1/r/myisam_views.result
index 65ad319d642..b77ea8a4bd9 100644
--- a/mysql-test/suite/funcs_1/r/myisam_views.result
+++ b/mysql-test/suite/funcs_1/r/myisam_views.result
@@ -24528,7 +24528,7 @@ f1 f2
ABC 3
SELECT * FROM v1 order by 2;
f1 my_sqrt
-ABC 1.73205080756888
+ABC 1.7320508075688772
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
@@ -24546,7 +24546,7 @@ ABC DEF
SELECT * FROM v1 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.73205080756888
+ABC 1.7320508075688772
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
@@ -24569,7 +24569,7 @@ my_sqrt double YES NULL
SELECT * FROM v2 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.73205080756888
+ABC 1.7320508075688772
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
@@ -24580,7 +24580,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v1;
Warnings:
@@ -24589,7 +24589,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v2;
Warnings:
@@ -24598,7 +24598,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t1;
DROP TABLE t2;
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/ndb_func_view.result b/mysql-test/suite/funcs_1/r/ndb_func_view.result
index b19252e4dd7..e788dfd9fc1 100644
--- a/mysql-test/suite/funcs_1/r/ndb_func_view.result
+++ b/mysql-test/suite/funcs_1/r/ndb_func_view.result
@@ -910,13 +910,13 @@ SELECT LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double), my_double, id FROM t
WHERE select_id = 151 OR select_id IS NULL order by id;
LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double) my_double id
NULL NULL 1
- -1.7976931348623e+308 2
-AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e+308 3
+ -1.7976931348623e308 2
+AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e308 3
0 4
-1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select left('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö',`t1_values`.`my_double`) AS `LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -925,13 +925,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 151 OR select_id IS NULL) order by id;
LEFT('AaBbCcDdEeFfGgHhIiJjÄäÜüÖö', my_double) my_double id
NULL NULL 1
- -1.7976931348623e+308 2
-AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e+308 3
+ -1.7976931348623e308 2
+AaBbCcDdEeFfGgHhIiJjÄäÜüÖö 1.7976931348623e308 3
0 4
-1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -1354,8 +1354,8 @@ my_double, id FROM t1_values
WHERE select_id = 133 OR select_id IS NULL order by id;
IFNULL(my_double,'IS_NULL') my_double id
IS_NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -1366,8 +1366,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 133 OR select_id IS NULL) order by id;
IFNULL(my_double,'IS_NULL') my_double id
IS_NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
@@ -1682,8 +1682,8 @@ WHERE select_id = 121 OR select_id IS NULL order by id;
IF(my_double IS NULL, 'IS NULL',
'IS NOT NULL') my_double id
IS NULL NULL 1
-IS NOT NULL -1.7976931348623e+308 2
-IS NOT NULL 1.7976931348623e+308 3
+IS NOT NULL -1.7976931348623e308 2
+IS NOT NULL 1.7976931348623e308 3
IS NOT NULL 0 4
IS NOT NULL -1 5
SHOW CREATE VIEW v1;
@@ -1696,8 +1696,8 @@ WHERE select_id = 121 OR select_id IS NULL) order by id;
IF(my_double IS NULL, 'IS NULL',
'IS NOT NULL') my_double id
IS NULL NULL 1
-IS NOT NULL -1.7976931348623e+308 2
-IS NOT NULL 1.7976931348623e+308 3
+IS NOT NULL -1.7976931348623e308 2
+IS NOT NULL 1.7976931348623e308 3
IS NOT NULL 0 4
IS NOT NULL -1 5
DROP VIEW v1;
@@ -2014,8 +2014,8 @@ my_double, id FROM t1_values
WHERE select_id = 109 OR select_id IS NULL order by id;
IF(my_double, 'IS TRUE', 'IS NOT TRUE') my_double id
IS NOT TRUE NULL 1
-IS TRUE -1.7976931348623e+308 2
-IS TRUE 1.7976931348623e+308 3
+IS TRUE -1.7976931348623e308 2
+IS TRUE 1.7976931348623e308 3
IS NOT TRUE 0 4
IS TRUE -1 5
SHOW CREATE VIEW v1;
@@ -2026,8 +2026,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 109 OR select_id IS NULL) order by id;
IF(my_double, 'IS TRUE', 'IS NOT TRUE') my_double id
IS NOT TRUE NULL 1
-IS TRUE -1.7976931348623e+308 2
-IS TRUE 1.7976931348623e+308 3
+IS TRUE -1.7976931348623e308 2
+IS TRUE 1.7976931348623e308 3
IS NOT TRUE 0 4
IS TRUE -1 5
DROP VIEW v1;
@@ -2562,13 +2562,13 @@ my_double, id FROM t1_values
WHERE select_id = 89 OR select_id IS NULL order by id;
CAST(my_double AS UNSIGNED INTEGER) my_double id
NULL NULL 1
-9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
18446744073709551615 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as unsigned) AS `CAST(my_double AS UNSIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2577,13 +2577,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 89 OR select_id IS NULL) order by id;
CAST(my_double AS UNSIGNED INTEGER) my_double id
NULL NULL 1
-9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
18446744073709551615 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -2930,13 +2930,13 @@ my_double, id FROM t1_values
WHERE select_id = 77 OR select_id IS NULL order by id;
CAST(my_double AS SIGNED INTEGER) my_double id
NULL NULL 1
--9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+-9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
-1 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as signed) AS `CAST(my_double AS SIGNED INTEGER)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -2945,13 +2945,13 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 77 OR select_id IS NULL) order by id;
CAST(my_double AS SIGNED INTEGER) my_double id
NULL NULL 1
--9223372036854775808 -1.7976931348623e+308 2
-9223372036854775807 1.7976931348623e+308 3
+-9223372036854775808 -1.7976931348623e308 2
+9223372036854775807 1.7976931348623e308 3
0 0 4
-1 -1 5
Warnings:
-Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect INTEGER value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect INTEGER value: '1.7976931348623e308'
DROP VIEW v1;
@@ -3288,8 +3288,8 @@ my_double, id FROM t1_values
WHERE select_id = 65 OR select_id IS NULL order by id;
CAST(my_double AS DECIMAL(37,2)) my_double id
NULL NULL 1
--99999999999999999999999999999999999.99 -1.7976931348623e+308 2
-99999999999999999999999999999999999.99 1.7976931348623e+308 3
+-99999999999999999999999999999999999.99 -1.7976931348623e308 2
+99999999999999999999999999999999999.99 1.7976931348623e308 3
0.00 0 4
-1.00 -1 5
-3333.33 -3333.3333 30
@@ -3306,8 +3306,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 65 OR select_id IS NULL) order by id;
CAST(my_double AS DECIMAL(37,2)) my_double id
NULL NULL 1
--99999999999999999999999999999999999.99 -1.7976931348623e+308 2
-99999999999999999999999999999999999.99 1.7976931348623e+308 3
+-99999999999999999999999999999999999.99 -1.7976931348623e308 2
+99999999999999999999999999999999999.99 1.7976931348623e308 3
0.00 0 4
-1.00 -1 5
-3333.33 -3333.3333 30
@@ -3680,14 +3680,14 @@ my_double, id FROM t1_values
WHERE select_id = 53 OR select_id IS NULL order by id;
CAST(my_double AS TIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
00:00:00 0 4
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect time value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect time value: '1.7976931348623e308'
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_double` as time) AS `CAST(my_double AS TIME)`,`t1_values`.`my_double` AS `my_double`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@@ -3696,14 +3696,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 53 OR select_id IS NULL) order by id;
CAST(my_double AS TIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
00:00:00 0 4
-00:00:01 -1 5
00:17:58 1758 25
Warnings:
-Warning 1292 Truncated incorrect time value: '-1.7976931348623e+308'
-Warning 1292 Truncated incorrect time value: '1.7976931348623e+308'
+Warning 1292 Truncated incorrect time value: '-1.7976931348623e308'
+Warning 1292 Truncated incorrect time value: '1.7976931348623e308'
DROP VIEW v1;
@@ -4042,14 +4042,14 @@ my_double, id FROM t1_values
WHERE select_id = 42 OR select_id IS NULL order by id;
CAST(my_double AS DATETIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
Warning 1292 Incorrect datetime value: '200506271758'
@@ -4061,14 +4061,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 42 OR select_id IS NULL) order by id;
CAST(my_double AS DATETIME) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
NULL 200506271758 19
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
Warning 1292 Incorrect datetime value: '200506271758'
@@ -4416,14 +4416,14 @@ my_double, id FROM t1_values
WHERE select_id = 31 OR select_id IS NULL order by id;
CAST(my_double AS DATE) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
SHOW CREATE VIEW v1;
@@ -4434,14 +4434,14 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 31 OR select_id IS NULL) order by id;
CAST(my_double AS DATE) my_double id
NULL NULL 1
-NULL -1.7976931348623e+308 2
-NULL 1.7976931348623e+308 3
+NULL -1.7976931348623e308 2
+NULL 1.7976931348623e308 3
NULL 0 4
NULL -1 5
2005-06-27 20050627 13
Warnings:
-Warning 1292 Incorrect datetime value: '-1.7976931348623e+308'
-Warning 1292 Incorrect datetime value: '1.7976931348623e+308'
+Warning 1292 Incorrect datetime value: '-1.7976931348623e308'
+Warning 1292 Incorrect datetime value: '1.7976931348623e308'
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '-1'
DROP VIEW v1;
@@ -4776,8 +4776,8 @@ my_double, id FROM t1_values
WHERE select_id = 20 OR select_id IS NULL order by id;
CAST(my_double AS CHAR) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -4788,8 +4788,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 20 OR select_id IS NULL) order by id;
CAST(my_double AS CHAR) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
@@ -5088,8 +5088,8 @@ my_double, id FROM t1_values
WHERE select_id = 8 OR select_id IS NULL order by id;
CAST(my_double AS BINARY) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
SHOW CREATE VIEW v1;
@@ -5100,8 +5100,8 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 8 OR select_id IS NULL) order by id;
CAST(my_double AS BINARY) my_double id
NULL NULL 1
--1.7976931348623e+308 -1.7976931348623e+308 2
-1.7976931348623e+308 1.7976931348623e+308 3
+-1.7976931348623e308 -1.7976931348623e308 2
+1.7976931348623e308 1.7976931348623e308 3
0 0 4
-1 -1 5
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/ndb_views.result b/mysql-test/suite/funcs_1/r/ndb_views.result
index 79020adbc50..10cb7613f47 100644
--- a/mysql-test/suite/funcs_1/r/ndb_views.result
+++ b/mysql-test/suite/funcs_1/r/ndb_views.result
@@ -22824,7 +22824,7 @@ f1 f2
ABC 3
SELECT * FROM v1 order by 2;
f1 my_sqrt
-ABC 1.73205080756888
+ABC 1.7320508075688772
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
@@ -22842,7 +22842,7 @@ ABC DEF
SELECT * FROM v1 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.73205080756888
+ABC 1.7320508075688772
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
@@ -22865,7 +22865,7 @@ my_sqrt double YES NULL
SELECT * FROM v2 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.73205080756888
+ABC 1.7320508075688772
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
Warning 1292 Truncated incorrect DOUBLE value: 'DEF'
@@ -22876,7 +22876,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v1;
Warnings:
@@ -22885,7 +22885,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t2;
CREATE TABLE t2 AS SELECT * FROM v2;
Warnings:
@@ -22894,7 +22894,7 @@ SELECT * FROM t2 order by 2;
f1 ABC
my_sqrt 0
f1 ABC
-my_sqrt 1.73205080756888
+my_sqrt 1.7320508075688772
DROP TABLE t1;
DROP TABLE t2;
DROP VIEW v1;
diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result
index cda55e92ac8..f08c52322f3 100644
--- a/mysql-test/suite/funcs_1/r/storedproc.result
+++ b/mysql-test/suite/funcs_1/r/storedproc.result
@@ -182,12 +182,9 @@ db_storedproc func_1 FUNCTION root@localhost <modified> <created> INVOKER this i
UPDATE t1_aux SET f1 = NULL;
SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux;
UPDATE t1_aux SET f1 = 1.7976931348623157493578e+308;
-ERROR 22007: Illegal double '1.7976931348623157493578e+308' value found during parsing
SELECT f1 INTO @v1_tab FROM t1_aux;
CALL sproc_1(1.7976931348623157493578e+308, @v1_proc);
-ERROR 22007: Illegal double '1.7976931348623157493578e+308' value found during parsing
SET @v1_func = func_1(1.7976931348623157493578e+308);
-ERROR 22007: Illegal double '1.7976931348623157493578e+308' value found during parsing
UPDATE t1_aux SET f1 = NULL;
SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux;
UPDATE t1_aux SET f1 = 0.1234567890987654321e+100;
@@ -17092,7 +17089,7 @@ return f1;
END//
SELECT fn77(1.1);
fn77(1.1)
-1.1
+1.0999999999999996
DROP FUNCTION IF EXISTS fn78;
CREATE FUNCTION fn78( f1 real unsigned) returns real unsigned
BEGIN
@@ -18256,7 +18253,7 @@ SELECT f1;
END//
CALL sp77(1.1);
f1
-1.1
+1.0999999999999996
DROP PROCEDURE IF EXISTS sp78;
CREATE PROCEDURE sp78( f1 real unsigned)
BEGIN
@@ -19457,9 +19454,9 @@ SELECT var1, var2, var3, var4, var5, var6, var7, var8;
END//
CALL spexecute24();
f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
-1.1 1.1 11.1 -9220000000000000000 6744073709551616 6744073709551616 -9220000000000000000 6744073709551616 6744073709551616 -9220000000000000000 6744073709551616 6744073709551616
+1.0999999999999996 1.0999999999999996 11.1 -9220000000000000000 6744073709551616 6744073709551616 -9220000000000000000 6744073709551616 6744073709551616 -9220000000000000000 6744073709551616 6744073709551616
var1 var2 var3 var4 var5 var6 var7 var8
-1.1 11.1 6744073709551616 6744073709551616 6744073709551616 6744073709551616 6744073709551616 6744073709551616
+1.0999999999999996 11.1 6744073709551616 6744073709551616 6744073709551616 6744073709551616 6744073709551616 6744073709551616
DROP PROCEDURE spexecute24;
DROP PROCEDURE sp24;
DROP PROCEDURE IF EXISTS sp25;
diff --git a/mysql-test/suite/ndb/r/ndb_gis.result b/mysql-test/suite/ndb/r/ndb_gis.result
index 61d15b7cb98..54772f596c3 100644
--- a/mysql-test/suite/ndb/r/ndb_gis.result
+++ b/mysql-test/suite/ndb/r/ndb_gis.result
@@ -266,7 +266,7 @@ fid AsText(EndPoint(g))
107 POINT(40 10)
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
fid GLength(g)
-105 24.142135623731
+105 24.14213562373095
106 40
107 30
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
@@ -292,7 +292,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.4166666666667 25.4166666666667)
+109 POINT(25.416666666666668 25.416666666666668)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
@@ -326,8 +326,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
-117 POINT(55.5885277530424 17.426536064114)
-118 POINT(55.5885277530424 17.426536064114)
+117 POINT(55.58852775304245 17.426536064113982)
+118 POINT(55.58852775304245 17.426536064113982)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
@@ -816,7 +816,7 @@ fid AsText(EndPoint(g))
107 POINT(40 10)
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
fid GLength(g)
-105 24.142135623731
+105 24.14213562373095
106 40
107 30
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
@@ -842,7 +842,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.4166666666667 25.4166666666667)
+109 POINT(25.416666666666668 25.416666666666668)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
@@ -876,8 +876,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
-117 POINT(55.5885277530424 17.426536064114)
-118 POINT(55.5885277530424 17.426536064114)
+117 POINT(55.58852775304245 17.426536064113982)
+118 POINT(55.58852775304245 17.426536064113982)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
diff --git a/mysql-test/suite/ndb/r/ndb_restore_different_endian_data.result b/mysql-test/suite/ndb/r/ndb_restore_different_endian_data.result
index e552de8d854..b101c93d156 100644
--- a/mysql-test/suite/ndb/r/ndb_restore_different_endian_data.result
+++ b/mysql-test/suite/ndb/r/ndb_restore_different_endian_data.result
@@ -79,7 +79,7 @@ t_pk t_date t_datetime t_timestamp t_time t_year
1 1998-01-01 2006-08-10 10:11:12 2002-10-29 16:51:06 19:38:34 2155
SELECT t_pk,hex(t_bit),t_tinyint,t_bool,t_smallint,t_mediumint,t_int,t_bigint,t_float,t_double,t_decimal FROM t_num;
t_pk hex(t_bit) t_tinyint t_bool t_smallint t_mediumint t_int t_bigint t_float t_double t_decimal
-1 AAAAAAAAAAAAAAAA 125 1 32765 8388606 2147483647 9223372036854775807 1e+20 1e+150 331.0000000000000000
+1 AAAAAAAAAAAAAAAA 125 1 32765 8388606 2147483647 9223372036854775807 1e20 1e150 331.0000000000000000
SELECT t_pk,t_char,t_varchar,hex(t_binary),hex(t_varbinary) FROM t_string_1;
t_pk t_char t_varchar hex(t_binary) hex(t_varbinary)
1 abcdefghijklmn abcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmn 612020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4100
@@ -178,7 +178,7 @@ t_pk t_date t_datetime t_timestamp t_time t_year
1 1998-01-01 2006-08-10 10:11:12 2002-10-29 16:51:06 19:38:34 2155
SELECT t_pk,hex(t_bit),t_tinyint,t_bool,t_smallint,t_mediumint,t_int,t_bigint,t_float,t_double,t_decimal FROM t_num;
t_pk hex(t_bit) t_tinyint t_bool t_smallint t_mediumint t_int t_bigint t_float t_double t_decimal
-1 AAAAAAAAAAAAAAAA 125 1 32765 8388606 2147483647 9223372036854775807 1e+20 1e+150 331.0000000000000000
+1 AAAAAAAAAAAAAAAA 125 1 32765 8388606 2147483647 9223372036854775807 1e20 1e150 331.0000000000000000
SELECT t_pk,t_char,t_varchar,hex(t_binary),hex(t_varbinary) FROM t_string_1;
t_pk t_char t_varchar hex(t_binary) hex(t_varbinary)
1 abcdefghijklmn abcdefghijklmnabcdefghijklmnabcdefghijklmnabcdefghijklmn 612020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4100
diff --git a/mysql-test/suite/ndb/r/ps_7ndb.result b/mysql-test/suite/ndb/r/ps_7ndb.result
index e57fdcb6df6..fcb2d641cf0 100644
--- a/mysql-test/suite/ndb/r/ps_7ndb.result
+++ b/mysql-test/suite/ndb/r/ps_7ndb.result
@@ -2568,10 +2568,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= '9223372036854775807' ;
@@ -2591,10 +2591,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 9.22337e+18
-c8 9.22337203685478e+18
-c9 9.22337203685478e+18
-c10 9.22337203685478e+18
+c7 9.22337e18
+c8 9.223372036854776e18
+c9 9.223372036854776e18
+c10 9.223372036854776e18
c12 9999.9999
execute my_delete ;
set @arg00= -9223372036854775808 ;
@@ -2614,10 +2614,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= '-9223372036854775808' ;
@@ -2637,10 +2637,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -9.22337e+18
-c8 -9.22337203685478e+18
-c9 -9.22337203685478e+18
-c10 -9.22337203685478e+18
+c7 -9.22337e18
+c8 -9.223372036854776e18
+c9 -9.223372036854776e18
+c10 -9.223372036854776e18
c12 -9999.9999
execute my_delete ;
set @arg00= 1.11111111111111111111e+50 ;
@@ -2662,10 +2662,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= '1.11111111111111111111e+50' ;
@@ -2687,10 +2687,10 @@ c3 8388607
c4 2147483647
c5 2147483647
c6 9223372036854775807
-c7 3.40282e+38
-c8 1.11111111111111e+50
-c9 1.11111111111111e+50
-c10 1.11111111111111e+50
+c7 3.40282e38
+c8 1.111111111111111e50
+c9 1.111111111111111e50
+c10 1.111111111111111e50
c12 9999.9999
execute my_delete ;
set @arg00= -1.11111111111111111111e+50 ;
@@ -2712,10 +2712,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
set @arg00= '-1.11111111111111111111e+50' ;
@@ -2737,10 +2737,10 @@ c3 -8388608
c4 -2147483648
c5 -2147483648
c6 -9223372036854775808
-c7 -3.40282e+38
-c8 -1.11111111111111e+50
-c9 -1.11111111111111e+50
-c10 -1.11111111111111e+50
+c7 -3.40282e38
+c8 -1.111111111111111e50
+c9 -1.111111111111111e50
+c10 -1.111111111111111e50
c12 -9999.9999
execute my_delete ;
test_sequence
@@ -2805,10 +2805,10 @@ c1 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30
51 5 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0
52 5 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0
53 5 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0
-54 5 54 54 54.00 54.00 54.00 54.00 54.00 54.00 54.00 54.00
-55 5 55 55 55 55 55 55 55 55 55 55
-56 6 56 56 56.00 56.00 56.00 56.00 56.00 56.00 56.00 56.00
-57 6 57 57 57.00 57.00 57.00 57.00 57.00 57.00 57.00 57.00
+54 5 54 54 54 54 54 54 54 54 54 54
+55 6 55 55 55 55 55 55 55 55 55 55
+56 6 56 56 56 56 56 56 56 56 56 56
+57 6 57 57 57 57 57 57 57 57 57 57
60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
61 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
62 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
@@ -3022,7 +3022,7 @@ c1 c13 c14 c15 c16 c17
42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
-51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
+51 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000
60 NULL NULL 1991-01-01 01:01:01 NULL NULL
diff --git a/mysql-test/suite/parts/r/partition_float_innodb.result b/mysql-test/suite/parts/r/partition_float_innodb.result
index 917358dc54a..d2f04a68629 100644
--- a/mysql-test/suite/parts/r/partition_float_innodb.result
+++ b/mysql-test/suite/parts/r/partition_float_innodb.result
@@ -18,25 +18,25 @@ t1 CREATE TABLE `t1` (
insert into t1 values (-3.402823466E+38), (3.402823466E+38), (-1.5), (-1), (0), (1), (1.5);
select * from t1;
a
--3.40282e+38
+-3.40282e38
-1.5
-1
0
1
1.5
-3.40282e+38
+3.40282e38
select * from t1 where a=1.5;
a
1.5
delete from t1 where a=1.5;
select * from t1;
a
--3.40282e+38
+-3.40282e38
-1.5
-1
0
1
-3.40282e+38
+3.40282e38
drop table t1;
create table t2 (a float not null, primary key(a)) engine='InnoDB'
partition by key (a) partitions 10;
@@ -51,37 +51,37 @@ PARTITIONS 10 */
insert into t2 values (-3.402823466E+38), (-3.402823466E+37), (-123.456), (0), (1234546.789), (123.456), (1.5);
select * from t2;
a
--3.40282e+38
--3.40282e+37
+-3.40282e38
+-3.40282e37
-123.456
0
1.5
123.456
-1.23455e+06
+1234550
select * from t2 where a=123.456;
a
delete from t2 where a=123.456;
select * from t2;
a
--3.40282e+38
--3.40282e+37
+-3.40282e38
+-3.40282e37
-123.456
0
1.5
123.456
-1.23455e+06
+1234550
select * from t2 where a=1.5;
a
1.5
delete from t2 where a=1.5;
select * from t2;
a
--3.40282e+38
--3.40282e+37
+-3.40282e38
+-3.40282e37
-123.456
0
123.456
-1.23455e+06
+1234550
delete from t2;
1024*3 inserts;
select count(*) from t2;
@@ -108,27 +108,27 @@ t1 CREATE TABLE `t1` (
insert into t1 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
select * from t1;
a
--2.2250738585072e+208
+-2.2250738585072016e208
-1.5
-1
--2.2250738585072e-208
+-2.2250738585072014e-208
0
1.5
1234.567
-2.2250738585072e+208
+2.2250738585072016e208
select * from t1 where a=1.5;
a
1.5
delete from t1 where a=1.5;
select * from t1;
a
--2.2250738585072e+208
+-2.2250738585072016e208
-1.5
-1
--2.2250738585072e-208
+-2.2250738585072014e-208
0
1234.567
-2.2250738585072e+208
+2.2250738585072016e208
drop table t1;
create table t2 (a double not null, primary key(a)) engine='InnoDB'
partition by key (a) partitions 10;
@@ -143,27 +143,27 @@ PARTITIONS 10 */
insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
select * from t2;
a
--2.2250738585072e+208
+-2.2250738585072016e208
-1.5
-1
--2.2250738585072e-208
+-2.2250738585072014e-208
0
1.5
1234.567
-2.2250738585072e+208
+2.2250738585072016e208
select * from t2 where a=1234.567;
a
1234.567
delete from t2 where a=1234.567;
select * from t2;
a
--2.2250738585072e+208
+-2.2250738585072016e208
-1.5
-1
--2.2250738585072e-208
+-2.2250738585072014e-208
0
1.5
-2.2250738585072e+208
+2.2250738585072016e208
delete from t2;
1024*3 inserts;
select count(*) from t2;
diff --git a/mysql-test/suite/parts/r/partition_float_myisam.result b/mysql-test/suite/parts/r/partition_float_myisam.result
index 3f9390f6ba9..2d52d095989 100644
--- a/mysql-test/suite/parts/r/partition_float_myisam.result
+++ b/mysql-test/suite/parts/r/partition_float_myisam.result
@@ -18,25 +18,25 @@ t1 CREATE TABLE `t1` (
insert into t1 values (-3.402823466E+38), (3.402823466E+38), (-1.5), (-1), (0), (1), (1.5);
select * from t1;
a
--3.40282e+38
+-3.40282e38
-1.5
-1
0
1
1.5
-3.40282e+38
+3.40282e38
select * from t1 where a=1.5;
a
1.5
delete from t1 where a=1.5;
select * from t1;
a
--3.40282e+38
+-3.40282e38
-1.5
-1
0
1
-3.40282e+38
+3.40282e38
drop table t1;
create table t2 (a float not null, primary key(a)) engine='MYISAM'
partition by key (a) partitions 10;
@@ -51,37 +51,37 @@ PARTITIONS 10 */
insert into t2 values (-3.402823466E+38), (-3.402823466E+37), (-123.456), (0), (1234546.789), (123.456), (1.5);
select * from t2;
a
--3.40282e+38
--3.40282e+37
+-3.40282e38
+-3.40282e37
-123.456
0
1.5
123.456
-1.23455e+06
+1234550
select * from t2 where a=123.456;
a
delete from t2 where a=123.456;
select * from t2;
a
--3.40282e+38
--3.40282e+37
+-3.40282e38
+-3.40282e37
-123.456
0
1.5
123.456
-1.23455e+06
+1234550
select * from t2 where a=1.5;
a
1.5
delete from t2 where a=1.5;
select * from t2;
a
--3.40282e+38
--3.40282e+37
+-3.40282e38
+-3.40282e37
-123.456
0
123.456
-1.23455e+06
+1234550
delete from t2;
16384*3 inserts;
select count(*) from t2;
@@ -108,27 +108,27 @@ t1 CREATE TABLE `t1` (
insert into t1 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
select * from t1;
a
--2.2250738585072e+208
+-2.2250738585072016e208
-1.5
-1
--2.2250738585072e-208
+-2.2250738585072014e-208
0
1.5
1234.567
-2.2250738585072e+208
+2.2250738585072016e208
select * from t1 where a=1.5;
a
1.5
delete from t1 where a=1.5;
select * from t1;
a
--2.2250738585072e+208
+-2.2250738585072016e208
-1.5
-1
--2.2250738585072e-208
+-2.2250738585072014e-208
0
1234.567
-2.2250738585072e+208
+2.2250738585072016e208
drop table t1;
create table t2 (a double not null, primary key(a)) engine='MYISAM'
partition by key (a) partitions 10;
@@ -143,27 +143,27 @@ PARTITIONS 10 */
insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
select * from t2;
a
--2.2250738585072e+208
+-2.2250738585072016e208
-1.5
-1
--2.2250738585072e-208
+-2.2250738585072014e-208
0
1.5
1234.567
-2.2250738585072e+208
+2.2250738585072016e208
select * from t2 where a=1234.567;
a
1234.567
delete from t2 where a=1234.567;
select * from t2;
a
--2.2250738585072e+208
+-2.2250738585072016e208
-1.5
-1
--2.2250738585072e-208
+-2.2250738585072014e-208
0
1.5
-2.2250738585072e+208
+2.2250738585072016e208
delete from t2;
16384*3 inserts;
select count(*) from t2;
diff --git a/mysql-test/suite/rpl/t/rpl_view_multi.test b/mysql-test/suite/rpl/t/rpl_view_multi.test
index 777ccb2a945..4e06429db32 100644
--- a/mysql-test/suite/rpl/t/rpl_view_multi.test
+++ b/mysql-test/suite/rpl/t/rpl_view_multi.test
@@ -56,7 +56,9 @@ select release_lock("lock_bg25144");
--echo # Switching to connection 'master1'
connection master1;
+--disable_warnings
--reap
+--enable_warnings
select release_lock("lock_bg25144");
--echo # Switching to connection 'master2'
@@ -105,7 +107,9 @@ select release_lock("lock_bg25144");
--echo # Switching to connection 'master1'
connection master1;
+--disable_warnings
--reap
+--enable_warnings
select release_lock("lock_bg25144");
--echo # Switching to connection 'master2'
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index 8e60d548c2f..f5426f8d631 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -177,8 +177,6 @@ select cast(1.0e+300 as signed int);
CREATE TABLE t1 (f1 double);
INSERT INTO t1 SET f1 = -1.0e+30 ;
INSERT INTO t1 SET f1 = +1.0e+30 ;
-# Expected result is +-1e+30, but Windows returns +-1e+030.
---replace_result 1e+030 1e+30
SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
DROP TABLE t1;
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 90b2d1bf202..165988ab89e 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -18,3 +18,4 @@ ssl_compress : SSL certificates expired
ssl_connect : SSL certificates expired
innodb-autoinc : Bug#49267 2009-12-02 test fails on windows because of different case mode
innodb : Bug#49396 2009-12-03 test fails in embedded mode
+plugin_load : Bug#42144 2009-12-21 alik plugin_load fails
diff --git a/mysql-test/t/exampledb.test b/mysql-test/t/exampledb.test
deleted file mode 100644
index fbb2a18f344..00000000000
--- a/mysql-test/t/exampledb.test
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Simple test for the example storage engine
-# Taken fromm the select test
-#
--- source include/have_exampledb.inc
-
---disable_warnings
-# Clean up if event's test fails
-drop database if exists events_test;
-drop database if exists events_test2;
-
-drop table if exists t1;
---enable_warnings
-
-CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
- Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
-) ENGINE=example;
-
-drop table t1;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index bc0695aaa93..70d73234ea8 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -353,6 +353,9 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
36.248666,-115.263639 36.247466,-115.263839 36.252766,-115.261439
36.252666,-115.261439 36.247366,-115.247239 36.247066)))'));
+# Expected result is 115.31877315203187, but IA64 returns 115.31877315203188
+# due to fused multiply-add instructions.
+--replace_result 115.31877315203188 115.31877315203187
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85998;
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index 40d1464b86a..4f918504597 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -422,9 +422,6 @@ INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
-# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and
-# "1.3e+78" due to different rounding rules
---replace_result 12.3 12.2 1.3e+78 1.2e+78
SELECT * FROM t1;
DROP TABLE t1;
@@ -459,9 +456,6 @@ INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
-# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and
-# "1.3e+78" due to different rounding rules
---replace_result 12.3 12.2 1.3e+78 1.2e+78
SELECT * FROM t1;
DROP TABLE t1;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 07ab9cecd28..94b209305f6 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -46,9 +46,6 @@ DROP TABLE t1;
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES ('-9e999999');
-# The following replaces is here because some systems replaces the above
-# double with '-inf' and others with MAX_DOUBLE
---replace_result (-1.79769313486232e+308) (RES) (NULL) (RES)
--exec $MYSQL_DUMP --compact test t1
DROP TABLE t1;
diff --git a/mysql-test/t/not_partition.test b/mysql-test/t/not_partition.test
index 78ca44acf18..63892845de8 100644
--- a/mysql-test/t/not_partition.test
+++ b/mysql-test/t/not_partition.test
@@ -31,7 +31,7 @@ ALTER TABLE t1 ENGINE Memory;
ALTER TABLE t1 ADD (new INT);
DROP TABLE t1;
---error ER_FEATURE_DISABLED
+--error ER_FEATURE_DISABLED,ER_OPTION_PREVENTS_STATEMENT
CREATE TABLE t1 (
firstname VARCHAR(25) NOT NULL,
lastname VARCHAR(25) NOT NULL,
@@ -42,13 +42,13 @@ CREATE TABLE t1 (
PARTITION BY KEY(joined)
PARTITIONS 6;
---error ER_FEATURE_DISABLED
+--error ER_FEATURE_DISABLED,ER_OPTION_PREVENTS_STATEMENT
ALTER TABLE t1 PARTITION BY KEY(joined) PARTITIONS 2;
--error ER_BAD_TABLE_ERROR
drop table t1;
---error ER_FEATURE_DISABLED
+--error ER_FEATURE_DISABLED,ER_OPTION_PREVENTS_STATEMENT
CREATE TABLE t1 (
firstname VARCHAR(25) NOT NULL,
lastname VARCHAR(25) NOT NULL,
@@ -66,7 +66,7 @@ PARTITION BY RANGE( YEAR(joined) ) (
--error ER_BAD_TABLE_ERROR
drop table t1;
---error ER_FEATURE_DISABLED
+--error ER_FEATURE_DISABLED,ER_OPTION_PREVENTS_STATEMENT
CREATE TABLE t1 (id INT, purchased DATE)
PARTITION BY RANGE( YEAR(purchased) )
SUBPARTITION BY HASH( TO_DAYS(purchased) )
diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test
index e579e371184..e6c9c8b423f 100644
--- a/mysql-test/t/parser.test
+++ b/mysql-test/t/parser.test
@@ -646,6 +646,10 @@ select conv(255 AS p1, 10 AS p2, 16 AS p3);
# Native function with a variable number of arguments
+# Bug in libm.so on Solaris:
+# atan(10) from 32-bit version returns 1.4711276743037347
+# atan(10) from 64-bit version returns 1.4711276743037345
+--replace_result 1.4711276743037345 1.4711276743037347
select atan(10);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 AS p1);
diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test
index 9e47b94b036..a0e944ceb09 100644
--- a/mysql-test/t/partition_column.test
+++ b/mysql-test/t/partition_column.test
@@ -24,6 +24,23 @@ partition by range columns (a,b,c)
partition p1 values less than (1, maxvalue, maxvalue));
#
+# BUG#48737, Search fails with ucs2
+#
+create table t1 (a varchar(5) character set ucs2 collate ucs2_bin)
+partition by range columns (a)
+(partition p0 values less than (0x0041));
+insert into t1 values (0x00410000);
+select hex(a) from t1 where a like 'A_';
+explain partitions select hex(a) from t1 where a like 'A_';
+alter table t1 remove partitioning;
+select hex(a) from t1 where a like 'A_';
+create index a on t1 (a);
+select hex(a) from t1 where a like 'A_';
+insert into t1 values ('A_');
+select hex(a) from t1;
+drop table t1;
+
+#
# BUG#48161, Delivering too few records using collate syntax with partitions
#
# Test case from BUG#48447 with some extension
diff --git a/mysql-test/t/partition_key_cache.test b/mysql-test/t/partition_key_cache.test
new file mode 100644
index 00000000000..f6ea974ba96
--- /dev/null
+++ b/mysql-test/t/partition_key_cache.test
@@ -0,0 +1,251 @@
+# Test of key cache with partitions
+--source include/have_partition.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, v, x;
+--enable_warnings
+
+--echo # Actual test of key caches
+--echo # Verifing that reads/writes use the key cache correctly
+SELECT @org_key_cache_buffer_size:= @@global.default.key_buffer_size;
+--echo # Minimize default key cache (almost disabled).
+SET @@global.default.key_buffer_size = 1;
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ c INT NOT NULL,
+ PRIMARY KEY (a),
+ KEY `inx_b` (b))
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a)
+(PARTITION p0 VALUES LESS THAN (1167602410)
+ (SUBPARTITION sp0,
+ SUBPARTITION sp1),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp2,
+ SUBPARTITION sp3));
+CREATE TABLE t2 (
+ a INT,
+ b INT,
+ c INT NOT NULL,
+ PRIMARY KEY (a),
+ KEY `inx_b` (b));
+FLUSH TABLES;
+FLUSH STATUS;
+
+# Genereate 4096 rows. Idea from:
+# http://datacharmer.blogspot.com/2007/12/data-from-nothing-solution-to-pop-quiz.html
+SET @a:=1167602400;
+CREATE VIEW v AS SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4;
+CREATE VIEW x AS SELECT 1 FROM v,v a,v b;
+# due to I_S performance, this was substituted with include files which
+# uses SHOW STATUS
+#DELIMITER |;
+#CREATE PROCEDURE was_zero_reads()
+#BEGIN
+# SELECT IF(VARIABLE_VALUE = 0,"Yes!","No!") as 'Was zero reads?'
+# FROM INFORMATION_SCHEMA.SESSION_STATUS
+# WHERE VARIABLE_NAME = 'KEY_READS';
+# FLUSH STATUS;
+#END|
+#DELIMITER ;|
+
+FLUSH STATUS;
+INSERT t1 SELECT @a, @a * (1 - ((@a % 2) * 2)) , 1167612400 - (@a:=@a+1) FROM x, x y;
+--source include/check_key_req.inc
+--echo # row distribution:
+SELECT PARTITION_NAME, SUBPARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA='test' and TABLE_NAME='t1';
+DROP VIEW x;
+DROP VIEW v;
+FLUSH TABLES;
+FLUSH STATUS;
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+INSERT t2 SELECT a,b,c FROM t1;
+--source include/check_key_req.inc
+FLUSH STATUS;
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+FLUSH TABLES;
+--echo # Setting the default key cache to 1M
+SET GLOBAL key_buffer_size = 1024*1024;
+FLUSH STATUS;
+--echo # All these have to read the indexes
+LOAD INDEX INTO CACHE t1 PARTITION (p1);
+--source include/check_key_reads.inc
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+--echo # All these should be able to use the key cache
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+FLUSH TABLES;
+LOAD INDEX INTO CACHE t1 PARTITION (p1,p0);
+--source include/check_key_reads.inc
+--echo # should not be zero
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+LOAD INDEX INTO CACHE t2;
+--source include/check_key_reads.inc
+--echo # should not be zero
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+FLUSH TABLES;
+LOAD INDEX INTO CACHE t1 PARTITION (p1,p0) IGNORE LEAVES;
+--source include/check_key_reads.inc
+--echo # should not be zero
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+LOAD INDEX INTO CACHE t2 IGNORE LEAVES;
+--source include/check_key_reads.inc
+--echo # should not be zero
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+TRUNCATE TABLE t2;
+INSERT t2 SELECT a,b,c FROM t1;
+--source include/check_key_req.inc
+DROP TABLE t1,t2;
+
+SET GLOBAL hot_cache.key_buffer_size = 1024*1024;
+SET GLOBAL warm_cache.key_buffer_size = 1024*1024;
+SET @@global.cold_cache.key_buffer_size = 1024*1024;
+SELECT @@global.default.key_buffer_size a, @@global.default.key_cache_block_size b, @@global.default.key_cache_age_threshold c, @@global.default.key_cache_division_limit d;
+SELECT @@global.hot_cache.key_buffer_size a, @@global.hot_cache.key_cache_block_size b, @@global.hot_cache.key_cache_age_threshold c, @@global.hot_cache.key_cache_division_limit d;
+SELECT @@global.warm_cache.key_buffer_size a, @@global.warm_cache.key_cache_block_size b, @@global.warm_cache.key_cache_age_threshold c, @@global.warm_cache.key_cache_division_limit d;
+SELECT @@global.cold_cache.key_buffer_size a, @@global.cold_cache.key_cache_block_size b, @@global.cold_cache.key_cache_age_threshold c, @@global.cold_cache.key_cache_division_limit d;
+CREATE TABLE t1 (
+ a INT,
+ b VARCHAR(257),
+ c INT NOT NULL,
+ PRIMARY KEY (a),
+ KEY `inx_b` (b),
+ KEY `inx_c`(c))
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a)
+(PARTITION p0 VALUES LESS THAN (10)
+ (SUBPARTITION sp0,
+ SUBPARTITION sp1),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp2,
+ SUBPARTITION sp3));
+CREATE TABLE t2 (
+ a INT,
+ b VARCHAR(257),
+ c INT NOT NULL,
+ PRIMARY KEY (a),
+ KEY `inx_b` (b),
+ KEY `inx_c`(c));
+SET @a:=1167602400;
+# Genereate 4096 rows. Idea from:
+# http://datacharmer.blogspot.com/2007/12/data-from-nothing-solution-to-pop-quiz.html
+CREATE VIEW v AS SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4;
+CREATE VIEW x AS SELECT 1 FROM v,v a,v b;
+INSERT t1 SELECT @a, CONCAT('X_', @a, ' MySQL'), 1167612400 - (@a:=@a+1) FROM x, x a;
+DROP VIEW x;
+DROP VIEW v;
+INSERT t2 SELECT a, b, c FROM t1;
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t2;
+FLUSH TABLES;
+
+--echo # Restrict partitioned commands to partitioned tables only
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (p0,`p1`) INDEX (`PRIMARY`) IN hot_cache;
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (`p1`) INDEX (`PRIMARY`,`inx_b`) IN hot_cache;
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (ALL) KEY (`inx_b`,`PRIMARY`) IN hot_cache;
+--echo # Basic key cache testing
+--echo # The manual correctly says: "The syntax of CACHE INDEX enables you to
+--echo # specify that only particular indexes from a table should be assigned
+--echo # to the cache. The current implementation assigns all the table's
+--echo # indexes to the cache, so there is no reason to specify anything
+--echo # other than the table name."
+--echo # So the most of the test only tests the syntax
+CACHE INDEX t2 INDEX (`inx_b`) IN hot_cache;
+CACHE INDEX t2 KEY (`PRIMARY`) IN warm_cache;
+CACHE INDEX t2 KEY (`PRIMARY`,`inx_b`) IN cold_cache;
+CACHE INDEX t2 INDEX (inx_b,`PRIMARY`) IN default;
+CACHE INDEX t1 PARTITION (p0) KEY (`inx_b`) IN cold_cache;
+--error ER_PARSE_ERROR
+CACHE INDEX t1 PARTITIONS (p0) KEY (`inx_b`) IN cold_cache;
+--echo # only one table at a time if specifying partitions
+--error ER_PARSE_ERROR
+CACHE INDEX t1,t2 PARTITION (p0) KEY (`inx_b`) IN cold_cache;
+CACHE INDEX t1 PARTITION (`p0`,p1) INDEX (`PRIMARY`) IN warm_cache;
+CACHE INDEX t1 PARTITION (`p1`) INDEX (`PRIMARY`,inx_b) IN hot_cache;
+CACHE INDEX t1 PARTITION (ALL) KEY (`inx_b`,`PRIMARY`) IN default;
+CACHE INDEX t1 PARTITION (ALL) IN hot_cache;
+CACHE INDEX t1 INDEX (`inx_b`) IN default;
+CACHE INDEX t1 KEY (`PRIMARY`) IN hot_cache;
+CACHE INDEX t1 KEY (`PRIMARY`,`inx_b`) IN warm_cache;
+CACHE INDEX t1 INDEX (`inx_b`,`PRIMARY`) IN cold_cache;
+CACHE INDEX t1 IN hot_cache;
+--echo # Test of non existent key cache:
+--error ER_UNKNOWN_KEY_CACHE
+CACHE INDEX t1 IN non_existent_key_cache;
+--echo # Basic testing of LOAD INDEX
+LOAD INDEX INTO CACHE t2;
+--echo # PRIMARY and secondary keys have different block sizes
+LOAD INDEX INTO CACHE t2 ignore leaves;
+--echo # Must have INDEX or KEY before the index list
+--error ER_PARSE_ERROR
+LOAD INDEX INTO CACHE t2 (`PRIMARY`);
+
+--echo # Test of IGNORE LEAVES
+LOAD INDEX INTO CACHE t2 INDEX (`PRIMARY`);
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_b`) IGNORE LEAVES;
+CACHE INDEX t2 IN warm_cache;
+CACHE INDEX t1 IN cold_cache;
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`) IGNORE LEAVES;
+CACHE INDEX t2 INDEX (`inx_b`, `inx_c`) IN hot_cache;
+LOAD INDEX INTO CACHE t2 KEY (`inx_b`, `inx_c`) IGNORE LEAVES;
+CACHE INDEX t2 IN warm_cache;
+CACHE INDEX t2 INDEX (`PRIMARY`, `inx_c`) IN hot_cache;
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_c`) IGNORE LEAVES;
+CACHE INDEX t2 INDEX (`inx_b`,`PRIMARY`) IN default;
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_b`);
+CACHE INDEX t2 IN default;
+LOAD INDEX INTO CACHE t2 IGNORE LEAVES;
+
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+LOAD INDEX INTO CACHE t2 PARTITION (p1) INDEX (`PRIMARY`);
+LOAD INDEX INTO CACHE t1, t2;
+--echo # only one table at a time if specifying partitions
+--error ER_PARSE_ERROR
+LOAD INDEX INTO CACHE t1 PARTITION (p0), t2;
+LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`);
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`,`inx_b`) IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 INDEX (`inx_b`) IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`) IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`,`inx_b`);
+LOAD INDEX INTO CACHE t1 PARTITION (p1) INDEX (`PRIMARY`);
+LOAD INDEX INTO CACHE t1 PARTITION (`p1`,p0) KEY (`PRIMARY`) IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 PARTITION (ALL);
+--error ER_PARSE_ERROR
+LOAD INDEX INTO CACHE t1 PARTITIONS ALL;
+LOAD INDEX INTO CACHE t1 PARTITION (p1,`p0`) IGNORE LEAVES;
+DROP INDEX `inx_b` on t1;
+DROP INDEX `inx_b` on t2;
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+CACHE INDEX t2 INDEX (`inx_b`) IN hot_cache;
+CACHE INDEX t1 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+CACHE INDEX t1 INDEX (`inx_b`) IN hot_cache;
+DROP TABLE t1,t2;
+SET GLOBAL hot_cache.key_buffer_size = 0;
+SET GLOBAL warm_cache.key_buffer_size = 0;
+SET @@global.cold_cache.key_buffer_size = 0;
+SELECT @@global.default.key_buffer_size a, @@global.default.key_cache_block_size b, @@global.default.key_cache_age_threshold c, @@global.default.key_cache_division_limit d;
+SELECT @@global.hot_cache.key_buffer_size a, @@global.hot_cache.key_cache_block_size b, @@global.hot_cache.key_cache_age_threshold c, @@global.hot_cache.key_cache_division_limit d;
+SELECT @@global.warm_cache.key_buffer_size a, @@global.warm_cache.key_cache_block_size b, @@global.warm_cache.key_cache_age_threshold c, @@global.warm_cache.key_cache_division_limit d;
+SELECT @@global.cold_cache.key_buffer_size a, @@global.cold_cache.key_cache_block_size b, @@global.cold_cache.key_cache_age_threshold c, @@global.cold_cache.key_cache_division_limit d;
+--disable_warnings
+SET @@global.default.key_buffer_size = @org_key_cache_buffer_size;
+--enable_warnings
diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test
index 07c345faed5..6c0b5ca77d6 100644
--- a/mysql-test/t/partition_range.test
+++ b/mysql-test/t/partition_range.test
@@ -9,6 +9,16 @@
drop table if exists t1, t2;
--enable_warnings
+#
+#BUG#49591, Add proper version number to SHOW CREATE TABLE
+#
+create table t1 (a int)
+partition by range (a)
+subpartition by hash(to_seconds(a))
+(partition p0 values less than (1));
+show create table t1;
+drop table t1;
+
--error ER_NULL_IN_VALUES_LESS_THAN
create table t1 (a int)
partition by range (a)
@@ -30,6 +40,7 @@ explain partitions select * from t1 where a < '2007-03-08 00:00:01';
explain partitions select * from t1 where a <= '2007-03-08 00:00:00';
explain partitions select * from t1 where a <= '2007-03-07 23:59:59';
explain partitions select * from t1 where a < '2007-03-07 23:59:59';
+show create table t1;
drop table t1;
#
# New test cases for new function to_seconds
@@ -44,6 +55,7 @@ explain partitions select * from t1 where a <= '2003-12-31';
select * from t1 where a <= '2003-12-31';
explain partitions select * from t1 where a <= '2005-01-01';
select * from t1 where a <= '2005-01-01';
+show create table t1;
drop table t1;
create table t1 (a datetime)
@@ -56,6 +68,7 @@ explain partitions select * from t1 where a <= '2004-01-01 11:59.59';
select * from t1 where a <= '2004-01-01 11:59:59';
explain partitions select * from t1 where a <= '2005-01-01';
select * from t1 where a <= '2005-01-01';
+show create table t1;
drop table t1;
#
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 0edc9cca385..d6e73cbc88d 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -94,10 +94,6 @@ select sql_cache * from t1 union select * from t1;
set query_cache_type=2;
select sql_cache * from t1 union select * from t1;
-# all sql_cache statements, except for the first select, are ignored.
-select * from t1 union select sql_cache * from t1;
-select * from t1 where a IN (select sql_cache a from t1);
-select * from t1 where a IN (select a from t1 union select sql_cache a from t1);
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
set query_cache_type=on;
@@ -110,15 +106,6 @@ show status like "Qcache_queries_in_cache";
# SELECT SQL_NO_CACHE
#
select sql_no_cache * from t1;
-# sql_no_cache can occur in any nested select to turn on cacheing for the whole
-# expression and it will always override a sql_cache statement.
-select * from t1 union select sql_no_cache * from t1;
-select * from t1 where a IN (select sql_no_cache a from t1);
-select * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
-select sql_cache sql_no_cache * from t1;
-select sql_cache * from t1 union select sql_no_cache * from t1;
-select sql_cache * from t1 where a IN (select sql_no_cache a from t1);
-select sql_cache * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
show status like "Qcache_queries_in_cache";
drop table t1;
#
@@ -1044,22 +1031,25 @@ set GLOBAL query_cache_size= default;
# Bug #29053 SQL_CACHE in UNION causes non-deterministic functions to be cached
#
-set GLOBAL query_cache_size=1000000;
-
-create table t1 (a char);
-insert into t1 values ('c');
-
-let $q1= `select RAND() from t1 union select sql_cache 1 from t1;`;
-let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`;
-
+# This syntax is no longer allowed, therefore the test case has been commented
+# out.
+# See test for Bug#35020 below.
+#set GLOBAL query_cache_size=1000000;
+#
+#create table t1 (a char);
+#insert into t1 values ('c');
+#
+#let $q1= `select RAND() from t1 union select sql_cache 1 from t1;`;
+#let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`;
+#
# disabling the logging of the query because the times are different each run.
---disable_query_log
-eval select a from t1 where "$q1" = "$q2";
---enable_query_log
-
-drop table t1;
-
-set GLOBAL query_cache_size= default;
+#--disable_query_log
+#eval select a from t1 where "$q1" = "$q2";
+#--enable_query_log
+#
+#drop table t1;
+#
+#set GLOBAL query_cache_size= default;
#
# Bug#29856: Insufficient buffer space led to a server crash.
@@ -1307,5 +1297,69 @@ SELECT 1 FROM t1 GROUP BY
DROP TABLE t1;
SET GLOBAL query_cache_size= default;
---echo End of 5.1 tests
+#
+# Bug#35020: illegal sql_cache select syntax
+#
+CREATE TABLE t1( a INT );
+
+--error ER_PARSE_ERROR
+SET @v = ( SELECT SQL_CACHE 1 );
+--error ER_PARSE_ERROR
+SET @v = ( SELECT SQL_NO_CACHE 1 );
+
+#
+# Keywords 'SQL_CACHE' and 'SQL_NO_CACHE' are allowed as column names.
+# Hence the error messages are not intuitive.
+#
+--error ER_BAD_FIELD_ERROR
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_CACHE a FROM t1 );
+--error ER_BAD_FIELD_ERROR
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_NO_CACHE a FROM t1 );
+--error ER_BAD_FIELD_ERROR
+SELECT ( SELECT SQL_CACHE a FROM t1 );
+--error ER_BAD_FIELD_ERROR
+SELECT ( SELECT SQL_NO_CACHE a FROM t1 );
+
+SELECT SQL_CACHE * FROM t1;
+SELECT SQL_NO_CACHE * FROM t1;
+
+# SQL_CACHE is only allowed once in first top-level select.
+--error ER_CANT_USE_OPTION_HERE
+SELECT * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+--error ER_BAD_FIELD_ERROR
+SELECT * FROM t1 WHERE a IN (SELECT SQL_CACHE a FROM t1);
+--error ER_BAD_FIELD_ERROR
+SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 UNION SELECT SQL_CACHE a FROM t1);
+
+--error ER_CANT_USE_OPTION_HERE
+SELECT * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+--error ER_BAD_FIELD_ERROR
+SELECT * FROM t1 WHERE a IN (SELECT SQL_NO_CACHE a FROM t1);
+--error ER_BAD_FIELD_ERROR
+SELECT * FROM t1 WHERE a IN
+ (SELECT a FROM t1 UNION SELECT SQL_NO_CACHE a FROM t1);
+--error ER_WRONG_USAGE
+SELECT SQL_CACHE SQL_NO_CACHE * FROM t1;
+--error ER_WRONG_USAGE
+SELECT SQL_NO_CACHE SQL_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT SQL_CACHE * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT SQL_CACHE * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT SQL_NO_CACHE * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT SQL_NO_CACHE * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+--error ER_BAD_FIELD_ERROR
+SELECT SQL_CACHE * FROM t1 WHERE a IN
+ (SELECT SQL_NO_CACHE a FROM t1);
+--error ER_BAD_FIELD_ERROR
+SELECT SQL_CACHE * FROM t1 WHERE a IN
+ (SELECT a FROM t1 UNION SELECT SQL_NO_CACHE a FROM t1);
+
+DROP TABLE t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 3d4f5a654c2..9d80650da2f 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -550,18 +550,14 @@ CREATE VIEW v1 AS SELECT SQL_NO_CACHE NOW();
SHOW CREATE VIEW v1;
DROP VIEW v1;
-# Check that SQL_NO_CACHE always wins.
+--error ER_WRONG_USAGE
CREATE VIEW v1 AS SELECT SQL_CACHE SQL_NO_CACHE NOW();
-SHOW CREATE VIEW v1;
-DROP VIEW v1;
+--error ER_WRONG_USAGE
CREATE VIEW v1 AS SELECT SQL_NO_CACHE SQL_CACHE NOW();
-SHOW CREATE VIEW v1;
-DROP VIEW v1;
+--error ER_WRONG_USAGE
CREATE VIEW v1 AS SELECT SQL_CACHE SQL_NO_CACHE SQL_CACHE NOW();
-SHOW CREATE VIEW v1;
-DROP VIEW v1;
# Check CREATE VIEW in a prepared statement in a procedure.
delimiter |;
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index dfe36ed0905..5d9a2aaa5f4 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -410,6 +410,18 @@ SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
DROP TABLE t1;
#
+# Bug #24541: "Data truncated..." on decimal type columns without any good reason
+#
+
+create table t1 (c1 decimal(10,6));
+insert into t1 (c1) values (9.99e-4);
+insert into t1 (c1) values (9.98e-4);
+insert into t1 (c1) values (0.000999);
+insert into t1 (c1) values (cast(9.99e-4 as decimal(10,6)));
+select * from t1;
+drop table t1;
+
+#
# Bug#31019: MOD() function and operator crashes MySQL when
# divisor is very long and < 1
#
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index 3b7b30db6f8..45cf80aab5c 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -7,7 +7,7 @@ drop table if exists t1,t2;
--enable_warnings
SELECT 10,10.0,10.,.1e+2,100.0e-1;
-SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
+SELECT 6e-16, -6e-16, --6e-16, -6e-16+1.000000;
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;
SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0;
@@ -252,6 +252,37 @@ insert into t1 values (2e30), (-2e30);
select f1 + 0e0 from t1;
drop table t1;
+#
+# Bug #12860 "Difference in zero padding of exponent between Unix and Windows"
+#
+
+create table t1 (c char(6));
+insert into t1 values (2e6),(2e-5);
+select * from t1;
+drop table t1;
+
+#
+# Bug #21497 "DOUBLE truncated to unusable value"
+#
+
+CREATE TABLE d1 (d DOUBLE);
+INSERT INTO d1 VALUES (1.7976931348623157E+308);
+SELECT * FROM d1;
+--error ER_ILLEGAL_VALUE_FOR_TYPE
+INSERT INTO d1 VALUES (1.79769313486232e+308);
+SELECT * FROM d1;
+DROP TABLE d1;
+
+#
+# Bug #26788 "mysqld (debug) aborts when inserting specific numbers into char
+# fields"
+#
+
+create table t1 (a char(20));
+insert into t1 values (1.225e-05);
+select a+0 from t1;
+drop table t1;
+
#
# Bug #27483: Casting 'scientific notation type' to 'unsigned bigint' fails on
# windows.
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 2cf7ab8fbdf..8af9d4c263e 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1054,10 +1054,8 @@ while ($max_power)
}
SELECT my_float, my_double, my_varchar FROM t1;
-# Expected result 0.000000000011754943372854760000
-# On windows we get 0.000000000011754943372854770000
-# use replace_result to correct it
---replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000
+# The following statement produces results with garbage past
+# the significant digits. Improving it is a part of the WL#3977.
SELECT CAST(my_float AS DECIMAL(65,30)), my_float FROM t1;
SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1;
SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;
diff --git a/mysys/hash.c b/mysys/hash.c
index 5fa804ce7ce..39f3ad8d31e 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -232,6 +232,8 @@ my_hash_value_type my_calc_hash(const HASH *hash,
{
return calc_hash(hash, key, length ? length : hash->key_length);
}
+
+
/*
Search after a record based on a key
@@ -242,11 +244,17 @@ my_hash_value_type my_calc_hash(const HASH *hash,
uchar* my_hash_first(const HASH *hash, const uchar *key, size_t length,
HASH_SEARCH_STATE *current_record)
{
- return my_hash_first_from_hash_value(hash,
- calc_hash(hash, key, length ? length : hash->key_length),
- key, length, current_record);
+ uchar *res;
+ if (my_hash_inited(hash))
+ res= my_hash_first_from_hash_value(hash,
+ calc_hash(hash, key, length ? length : hash->key_length),
+ key, length, current_record);
+ else
+ res= 0;
+ return res;
}
-
+
+
uchar* my_hash_first_from_hash_value(const HASH *hash,
my_hash_value_type hash_value,
const uchar *key,
diff --git a/plugin/semisync/CMakeLists.txt b/plugin/semisync/CMakeLists.txt
index ad26298b0b7..cf8863e970f 100644
--- a/plugin/semisync/CMakeLists.txt
+++ b/plugin/semisync/CMakeLists.txt
@@ -15,9 +15,6 @@
# This is CMakeLists.txt for semi-sync replication plugins
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-
# Add common include directories
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
${CMAKE_SOURCE_DIR}/sql
diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist
index c5d429c2752..51271a3dad0 100755
--- a/scripts/make_win_bin_dist
+++ b/scripts/make_win_bin_dist
@@ -290,6 +290,11 @@ if [ -d storage/innodb_plugin ]; then
cp storage/innodb_plugin/$TARGET/ha_innodb_plugin.dll \
$DESTDIR/lib/plugin/
fi
+if [ -d plugin/semisync ]; then
+ cp plugin/semisync/$TARGET/semisync_master.dll \
+ plugin/semisync/$TARGET/semisync_slave.dll \
+ $DESTDIR/lib/plugin/
+fi
if [ x"$TARGET" != x"release" ] ; then
cp libmysql/$TARGET/libmysql.pdb \
@@ -302,6 +307,11 @@ if [ x"$TARGET" != x"release" ] ; then
cp storage/innodb_plugin/$TARGET/ha_innodb_plugin.pdb \
$DESTDIR/lib/plugin/
fi
+ if [ -d plugin/semisync ]; then
+ cp plugin/semisync/$TARGET/semisync_master.pdb \
+ plugin/semisync/$TARGET/semisync_slave.pdb \
+ $DESTDIR/lib/plugin/
+ fi
fi
@@ -328,6 +338,15 @@ if [ x"$PACK_DEBUG" = x"" -a -f "libmysql/debug/libmysql.lib" -o \
storage/innodb_plugin/debug/ha_innodb_plugin.pdb \
$DESTDIR/lib/plugin/debug/
fi
+ if [ -d plugin/semisync ]; then
+ cp plugin/semisync/debug/semisync_master.dll \
+ plugin/semisync/debug/semisync_master.lib \
+ plugin/semisync/debug/semisync_master.pdb \
+ plugin/semisync/debug/semisync_slave.dll \
+ plugin/semisync/debug/semisync_slave.lib \
+ plugin/semisync/debug/semisync_slave.pdb \
+ $DESTDIR/lib/plugin/debug/
+ fi
fi
# ----------------------------------------------------------------------
diff --git a/sql/field.cc b/sql/field.cc
index 0934bb04ccd..56da32959f9 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -31,9 +31,6 @@
#include "slave.h" // Pull in rpl_master_has_bug()
#include <m_ctype.h>
#include <errno.h>
-#ifdef HAVE_FCONVERT
-#include <floatingpoint.h>
-#endif
// Maximum allowed exponent value for converting string to decimal
#define MAX_EXPONENT 1024
@@ -50,7 +47,7 @@ template class List_iterator<Create_field>;
uchar Field_null::null[1]={1};
const char field_separator=',';
-#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE 320
+#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE FLOATING_POINT_BUFFER
#define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
#define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
#define BLOB_PACK_LENGTH_TO_MAX_LENGH(arg) \
@@ -2304,13 +2301,7 @@ int Field_decimal::store(double nr)
char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
fyllchar = zerofill ? (char) '0' : (char) ' ';
-#ifdef HAVE_SNPRINTF
- buff[sizeof(buff)-1]=0; // Safety
- snprintf(buff,sizeof(buff)-1, "%.*f",(int) dec,nr);
- length= strlen(buff);
-#else
- length= my_sprintf(buff,(buff,"%.*f",dec,nr));
-#endif
+ length= my_fcvt(nr, dec, buff, NULL);
if (length > field_length)
{
@@ -2723,17 +2714,6 @@ int Field_new_decimal::store(double nr)
err= double2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, nr,
&decimal_value);
- /*
- TODO: fix following when double2my_decimal when double2decimal
- will return E_DEC_TRUNCATED always correctly
- */
- if (!err)
- {
- double nr2;
- my_decimal2double(E_DEC_FATAL_ERROR, &decimal_value, &nr2);
- if (nr2 != nr)
- err= E_DEC_TRUNCATED;
- }
if (err)
{
if (check_overflow(err))
@@ -4231,67 +4211,20 @@ String *Field_float::val_str(String *val_buffer,
uint to_length=max(field_length,70);
val_buffer->alloc(to_length);
char *to=(char*) val_buffer->ptr();
+ size_t len;
if (dec >= NOT_FIXED_DEC)
- {
- sprintf(to,"%-*.*g",(int) field_length,FLT_DIG,nr);
- to=strcend(to,' ');
- *to=0;
- }
+ len= my_gcvt(nr, MY_GCVT_ARG_FLOAT, to_length - 1, to, NULL);
else
{
-#ifdef HAVE_FCONVERT
- char buff[70],*pos=buff;
- int decpt,sign,tmp_dec=dec;
-
- (void) sfconvert(&nr,tmp_dec,&decpt,&sign,buff);
- if (sign)
- {
- *to++='-';
- }
- if (decpt < 0)
- { /* val_buffer is < 0 */
- *to++='0';
- if (!tmp_dec)
- goto end;
- *to++='.';
- if (-decpt > tmp_dec)
- decpt= - (int) tmp_dec;
- tmp_dec=(uint) ((int) tmp_dec+decpt);
- while (decpt++ < 0)
- *to++='0';
- }
- else if (decpt == 0)
- {
- *to++= '0';
- if (!tmp_dec)
- goto end;
- *to++='.';
- }
- else
- {
- while (decpt-- > 0)
- *to++= *pos++;
- if (!tmp_dec)
- goto end;
- *to++='.';
- }
- while (tmp_dec--)
- *to++= *pos++;
-#else
-#ifdef HAVE_SNPRINTF
- to[to_length-1]=0; // Safety
- snprintf(to,to_length-1,"%.*f",dec,nr);
- to=strend(to);
-#else
- to+= my_sprintf(to,(to,"%.*f",dec,nr));
-#endif
-#endif
+ /*
+ We are safe here because the buffer length is >= 70, and
+ fabs(float) < 10^39, dec < NOT_FIXED_DEC. So the resulting string
+ will be not longer than 69 chars + terminating '\0'.
+ */
+ len= my_fcvt(nr, dec, to, NULL);
}
-#ifdef HAVE_FCONVERT
- end:
-#endif
- val_buffer->length((uint) (to-val_buffer->ptr()));
+ val_buffer->length((uint) len);
if (zerofill)
prepend_zeros(val_buffer);
return val_buffer;
@@ -4479,8 +4412,12 @@ int Field_real::truncate(double *nr, double max_value)
max_value*= log_10[order];
max_value-= 1.0 / log_10[dec];
- double tmp= rint((res - floor(res)) * log_10[dec]) / log_10[dec];
- res= floor(res) + tmp;
+ /* Check for infinity so we don't get NaN in calculations */
+ if (!my_isinf(res))
+ {
+ double tmp= rint((res - floor(res)) * log_10[dec]) / log_10[dec];
+ res= floor(res) + tmp;
+ }
}
if (res < -max_value)
@@ -4590,68 +4527,14 @@ String *Field_double::val_str(String *val_buffer,
uint to_length=max(field_length, DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE);
val_buffer->alloc(to_length);
char *to=(char*) val_buffer->ptr();
+ size_t len;
if (dec >= NOT_FIXED_DEC)
- {
- sprintf(to,"%-*.*g",(int) field_length,DBL_DIG,nr);
- to=strcend(to,' ');
- }
+ len= my_gcvt(nr, MY_GCVT_ARG_DOUBLE, to_length - 1, to, NULL);
else
- {
-#ifdef HAVE_FCONVERT
- char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
- char *pos= buff;
- int decpt,sign,tmp_dec=dec;
-
- (void) fconvert(nr,tmp_dec,&decpt,&sign,buff);
- if (sign)
- {
- *to++='-';
- }
- if (decpt < 0)
- { /* val_buffer is < 0 */
- *to++='0';
- if (!tmp_dec)
- goto end;
- *to++='.';
- if (-decpt > tmp_dec)
- decpt= - (int) tmp_dec;
- tmp_dec=(uint) ((int) tmp_dec+decpt);
- while (decpt++ < 0)
- *to++='0';
- }
- else if (decpt == 0)
- {
- *to++= '0';
- if (!tmp_dec)
- goto end;
- *to++='.';
- }
- else
- {
- while (decpt-- > 0)
- *to++= *pos++;
- if (!tmp_dec)
- goto end;
- *to++='.';
- }
- while (tmp_dec--)
- *to++= *pos++;
-#else
-#ifdef HAVE_SNPRINTF
- to[to_length-1]=0; // Safety
- snprintf(to,to_length-1,"%.*f",dec,nr);
- to=strend(to);
-#else
- to+= my_sprintf(to,(to,"%.*f",dec,nr));
-#endif
-#endif
- }
-#ifdef HAVE_FCONVERT
- end:
-#endif
+ len= my_fcvt(nr, dec, to, NULL);
- val_buffer->length((uint) (to-val_buffer->ptr()));
+ val_buffer->length((uint) len);
if (zerofill)
prepend_zeros(val_buffer);
return val_buffer;
@@ -6448,84 +6331,18 @@ int Field_str::store(double nr)
{
ASSERT_COLUMN_MARKED_FOR_WRITE;
char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
- uint length;
uint local_char_length= field_length / charset()->mbmaxlen;
- double anr= fabs(nr);
- bool fractional= (anr != floor(anr));
- int neg= (nr < 0.0) ? 1 : 0;
- uint max_length;
- int exp;
- uint digits;
- uint i;
-
- /* Calculate the exponent from the 'e'-format conversion */
- if (anr < 1.0 && anr > 0)
- {
- for (exp= 0; anr < 1e-100; exp-= 100, anr*= 1e100) ;
- for (; anr < 1e-10; exp-= 10, anr*= 1e10) ;
- for (i= 1; anr < 1 / log_10[i]; exp--, i++) ;
- exp--;
- }
- else
- {
- for (exp= 0; anr > 1e100; exp+= 100, anr/= 1e100) ;
- for (; anr > 1e10; exp+= 10, anr/= 1e10) ;
- for (i= 1; anr > log_10[i]; exp++, i++) ;
- }
-
- max_length= local_char_length - neg;
-
- /*
- Since in sprintf("%g") precision means the number of significant digits,
- calculate the maximum number of significant digits if the 'f'-format
- would be used (+1 for decimal point if the number has a fractional part).
- */
- digits= max(1, (int) max_length - fractional);
- /*
- If the exponent is negative, decrease digits by the number of leading zeros
- after the decimal point that do not count as significant digits.
- */
- if (exp < 0)
- digits= max(1, (int) digits + exp);
- /*
- 'e'-format is used only if the exponent is less than -4 or greater than or
- equal to the precision. In this case we need to adjust the number of
- significant digits to take "e+NN" + decimal point into account (hence -5).
- We also have to reserve one additional character if abs(exp) >= 100.
- */
- if (exp >= (int) digits || exp < -4)
- digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
-
- /* Limit precision to DBL_DIG to avoid garbage past significant digits */
- set_if_smaller(digits, DBL_DIG);
-
- length= (uint) my_sprintf(buff, (buff, "%-.*g", digits, nr));
+ size_t length;
+ my_bool error;
-#ifdef __WIN__
- /*
- Windows always zero-pads the exponent to 3 digits, we want to remove the
- leading 0 to match the sprintf() output on other platforms.
- */
- if ((exp >= (int) digits || exp < -4) && exp > -100 && exp < 100)
+ length= my_gcvt(nr, MY_GCVT_ARG_DOUBLE, local_char_length, buff, &error);
+ if (error)
{
- DBUG_ASSERT(length >= 6); /* 1e+NNN */
- uint tmp= length - 3;
- buff[tmp]= buff[tmp + 1];
- tmp++;
- buff[tmp]= buff[tmp + 1];
- length--;
+ if (table->in_use->abort_on_warning)
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_DATA_TOO_LONG, 1);
+ else
+ set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
}
-#endif
-
- /*
- +1 below is because "precision" in %g above means the
- max. number of significant digits, not the output width.
- Thus the width can be larger than number of significant digits by 1
- (for decimal point)
- the test for local_char_length < 5 is for extreme cases,
- like inserting 500.0 in char(1)
- */
- DBUG_ASSERT(local_char_length < 5 || length <= local_char_length+1);
return store(buff, length, charset());
}
@@ -7601,7 +7418,7 @@ oom_error:
int Field_blob::store(double nr)
{
CHARSET_INFO *cs=charset();
- value.set_real(nr, 2, cs);
+ value.set_real(nr, NOT_FIXED_DEC, cs);
return Field_blob::store(value.ptr(),(uint) value.length(), cs);
}
diff --git a/sql/item.cc b/sql/item.cc
index f4b2e549667..8416f53d77f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -5259,9 +5259,7 @@ int Item_null::save_safe_in_field(Field *field)
int Item::save_in_field(Field *field, bool no_conversions)
{
int error;
- if (result_type() == STRING_RESULT ||
- (result_type() == REAL_RESULT &&
- field->result_type() == STRING_RESULT))
+ if (result_type() == STRING_RESULT)
{
String *result;
CHARSET_INFO *cs= collation.collation;
@@ -5280,6 +5278,15 @@ int Item::save_in_field(Field *field, bool no_conversions)
error=field->store(result->ptr(),result->length(),cs);
str_value.set_quick(0, 0, cs);
}
+ else if (result_type() == REAL_RESULT &&
+ field->result_type() == STRING_RESULT)
+ {
+ double nr= val_real();
+ if (null_value)
+ return set_field_to_null_with_conversions(field, no_conversions);
+ field->set_notnull();
+ error= field->store(nr);
+ }
else if (result_type() == REAL_RESULT)
{
double nr= val_real();
diff --git a/sql/item.h b/sql/item.h
index 44892deb2c2..4dc65c52843 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -894,6 +894,15 @@ public:
(*traverser)(this, arg);
}
+ /*
+ This is used to get the most recent version of any function in
+ an item tree. The version is the version where a MySQL function
+ was introduced in. So any function which is added should use
+ this function and set the int_arg to maximum of the input data
+ and their own version info.
+ */
+ virtual bool intro_version(uchar *int_arg) { return 0; }
+
virtual bool remove_dependence_processor(uchar * arg) { return 0; }
virtual bool remove_fixed(uchar * arg) { fixed= 0; return 0; }
virtual bool cleanup_processor(uchar *arg);
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index b25812299f0..f6c316c15c6 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -91,6 +91,15 @@ public:
enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
+
+ bool intro_version(uchar *int_arg)
+ {
+ int *input_version= (int*)int_arg;
+ /* This function was introduced in 5.5 */
+ int output_version= (*input_version, 50500);
+ *input_version= output_version;
+ return 0;
+ }
};
diff --git a/sql/log_event.cc b/sql/log_event.cc
index bce9c84772d..91debbd65da 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -5363,11 +5363,11 @@ void User_var_log_event::pack_info(Protocol* protocol)
case REAL_RESULT:
double real_val;
float8get(real_val, val);
- if (!(buf= (char*) my_malloc(val_offset + FLOATING_POINT_BUFFER,
+ if (!(buf= (char*) my_malloc(val_offset + MY_GCVT_MAX_FIELD_WIDTH + 1,
MYF(MY_WME))))
return;
- event_len+= my_sprintf(buf + val_offset,
- (buf + val_offset, "%.14g", real_val));
+ event_len+= my_gcvt(real_val, MY_GCVT_ARG_DOUBLE, MY_GCVT_MAX_FIELD_WIDTH,
+ buf + val_offset, NULL);
break;
case INT_RESULT:
if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index a926af0370c..69c7a39afe8 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1932,6 +1932,7 @@ extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
extern char default_logfile_name[FN_REFLEN];
extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
+extern const double log_10[309];
extern ulonglong log_10_int[20];
extern ulonglong keybuff_size;
extern ulonglong thd_startup_options;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index f177d6220f8..26e208d23a7 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -191,6 +191,18 @@ typedef fp_except fp_except_t;
/* for IRIX to use set_fpc_csr() */
#include <sys/fpu.h>
#endif
+#if defined(__i386__) && !defined(HAVE_FPU_CONTROL_H)
+# define fpu_control_t unsigned int
+# define _FPU_EXTENDED 0x300
+# define _FPU_DOUBLE 0x200
+# ifdef __GNUC__
+# define _FPU_GETCW(cw) __asm__ __volatile__("fnstcw %0" : "=m" (*&cw))
+# define _FPU_SETCW(cw) __asm__ __volatile__("fldcw %0" : : "m" (*&cw))
+# else
+# define _FPU_GETCW(cw) (cw= 0)
+# define _FPU_SETCW(cw)
+# endif
+#endif
inline void setup_fpu()
{
@@ -212,7 +224,26 @@ inline void setup_fpu()
/* Set FPU rounding mode to "round-to-nearest" */
fesetround(FE_TONEAREST);
#endif /* HAVE_FESETROUND */
-
+
+ /*
+ x86 (32-bit) requires FPU precision to be explicitly set to 64 bit
+ (double precision) for portable results of floating point operations.
+ However, there is no need to do so if compiler is using SSE2 for floating
+ point, double values will be stored and processed in 64 bits anyway.
+ */
+#if defined(__i386__) && !defined(__SSE2_MATH__)
+#if defined(_WIN32)
+#if !defined(_WIN64)
+ _control87(_PC_53, MCW_PC);
+#endif /* !_WIN64 */
+#else /* !_WIN32 */
+ fpu_control_t cw;
+ _FPU_GETCW(cw);
+ cw= (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;
+ _FPU_SETCW(cw);
+#endif /* _WIN32 && */
+#endif /* __i386__ */
+
#if defined(__sgi) && defined(HAVE_SYS_FPU_H)
/* Enable denormalized DOUBLE values support for IRIX */
union fpc_csr n;
@@ -575,6 +606,40 @@ ulong expire_logs_days = 0;
ulong rpl_recovery_rank=0;
const char *log_output_str= "FILE";
+const double log_10[] = {
+ 1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009,
+ 1e010, 1e011, 1e012, 1e013, 1e014, 1e015, 1e016, 1e017, 1e018, 1e019,
+ 1e020, 1e021, 1e022, 1e023, 1e024, 1e025, 1e026, 1e027, 1e028, 1e029,
+ 1e030, 1e031, 1e032, 1e033, 1e034, 1e035, 1e036, 1e037, 1e038, 1e039,
+ 1e040, 1e041, 1e042, 1e043, 1e044, 1e045, 1e046, 1e047, 1e048, 1e049,
+ 1e050, 1e051, 1e052, 1e053, 1e054, 1e055, 1e056, 1e057, 1e058, 1e059,
+ 1e060, 1e061, 1e062, 1e063, 1e064, 1e065, 1e066, 1e067, 1e068, 1e069,
+ 1e070, 1e071, 1e072, 1e073, 1e074, 1e075, 1e076, 1e077, 1e078, 1e079,
+ 1e080, 1e081, 1e082, 1e083, 1e084, 1e085, 1e086, 1e087, 1e088, 1e089,
+ 1e090, 1e091, 1e092, 1e093, 1e094, 1e095, 1e096, 1e097, 1e098, 1e099,
+ 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109,
+ 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119,
+ 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129,
+ 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139,
+ 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149,
+ 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159,
+ 1e160, 1e161, 1e162, 1e163, 1e164, 1e165, 1e166, 1e167, 1e168, 1e169,
+ 1e170, 1e171, 1e172, 1e173, 1e174, 1e175, 1e176, 1e177, 1e178, 1e179,
+ 1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186, 1e187, 1e188, 1e189,
+ 1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198, 1e199,
+ 1e200, 1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209,
+ 1e210, 1e211, 1e212, 1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219,
+ 1e220, 1e221, 1e222, 1e223, 1e224, 1e225, 1e226, 1e227, 1e228, 1e229,
+ 1e230, 1e231, 1e232, 1e233, 1e234, 1e235, 1e236, 1e237, 1e238, 1e239,
+ 1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246, 1e247, 1e248, 1e249,
+ 1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258, 1e259,
+ 1e260, 1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269,
+ 1e270, 1e271, 1e272, 1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279,
+ 1e280, 1e281, 1e282, 1e283, 1e284, 1e285, 1e286, 1e287, 1e288, 1e289,
+ 1e290, 1e291, 1e292, 1e293, 1e294, 1e295, 1e296, 1e297, 1e298, 1e299,
+ 1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306, 1e307, 1e308
+};
+
time_t server_start_time, flush_status_time;
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30];
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 56d79ac0d45..65029a817de 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -116,6 +116,42 @@ char *partition_info::create_default_partition_names(uint part_no,
/*
+ Generate a version string for partition expression
+ This function must be updated every time there is a possibility for
+ a new function of a higher version number than 5.5.0.
+
+ SYNOPSIS
+ set_show_version_string()
+ RETURN VALUES
+ None
+*/
+void partition_info::set_show_version_string(String *packet)
+{
+ int version= 0;
+ if (column_list)
+ packet->append(STRING_WITH_LEN("\n/*!50500"));
+ else
+ {
+ if (part_expr)
+ part_expr->walk(&Item::intro_version, 0, (uchar*)&version);
+ if (subpart_expr)
+ subpart_expr->walk(&Item::intro_version, 0, (uchar*)&version);
+ if (version == 0)
+ {
+ /* No new functions in partition function */
+ packet->append(STRING_WITH_LEN("\n/*!50100"));
+ }
+ else
+ {
+ char buf[65];
+ char *buf_ptr= longlong10_to_str((longlong)version, buf, 10);
+ packet->append(STRING_WITH_LEN("\n/*!"));
+ packet->append(buf, (size_t)(buf_ptr - buf));
+ }
+ }
+}
+
+/*
Create a unique name for the subpartition as part_name'sp''subpart_no'
SYNOPSIS
create_subpartition_name()
diff --git a/sql/partition_info.h b/sql/partition_info.h
index 0ac8dec4945..479714a3928 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -302,6 +302,7 @@ public:
bool check_partition_field_length();
bool init_column_part();
bool add_column_list_value(THD *thd, Item *item);
+ void set_show_version_string(String *packet);
private:
static int list_part_cmp(const void* a, const void* b);
bool set_up_default_partitions(handler *file, HA_CREATE_INFO *info,
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 5509e1dfc61..c0960df8a4c 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -3553,7 +3553,7 @@ sys_var *intern_find_sys_var(const char *str, uint length, bool no_error)
A lock on LOCK_system_variable_hash should be held
*/
var= (sys_var*) my_hash_search(&system_variable_hash,
- (uchar*) str, length ? length : strlen(str));
+ (uchar*) str, length ? length : strlen(str));
if (!(var || no_error))
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str);
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 9114c81514d..671b8544b8a 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -17,28 +17,7 @@
#ifdef HAVE_SPATIAL
-/*
- exponential notation :
- 1 sign
- 1 number before the decimal point
- 1 decimal point
- 14 number of significant digits (see String::qs_append(double))
- 1 'e' sign
- 1 exponent sign
- 3 exponent digits
- ==
- 22
-
- "f" notation :
- 1 optional 0
- 1 sign
- 14 number significant digits (see String::qs_append(double) )
- 1 decimal point
- ==
- 17
-*/
-
-#define MAX_DIGITS_IN_DOUBLE 22
+#define MAX_DIGITS_IN_DOUBLE MY_GCVT_MAX_FIELD_WIDTH
/***************************** Gis_class_info *******************************/
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index f9f3a586dc6..5979c902f7a 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -1108,6 +1108,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
*/
MDL_ticket *mdl_ticket= NULL;
bool has_mdl_lock= FALSE;
+ bool is_temporary_table= false;
DBUG_ENTER("mysql_truncate");
bzero((char*) &create_info,sizeof(create_info));
@@ -1118,6 +1119,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
/* If it is a temporary table, close and regenerate it */
if (!dont_send_ok && (table= find_temporary_table(thd, table_list)))
{
+ is_temporary_table= true;
handlerton *table_type= table->s->db_type();
TABLE_SHARE *share= table->s;
/* Note that a temporary table cannot be partitioned */
@@ -1250,11 +1252,9 @@ end:
*/
if (!error)
{
- /*
- TRUNCATE must always be statement-based binlogged (not row-based) so
- we don't test current_stmt_binlog_row_based.
- */
- write_bin_log(thd, TRUE, thd->query(), thd->query_length());
+ /* In RBR, the statement is not binlogged if the table is temporary. */
+ if (!is_temporary_table || !thd->current_stmt_binlog_row_based)
+ write_bin_log(thd, TRUE, thd->query(), thd->query_length());
my_ok(thd); // This should return record count
}
if (has_mdl_lock)
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 54d1400e3af..6d9554919ee 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1468,7 +1468,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
show_table_options,
NULL, NULL))))
{
- packet->append(STRING_WITH_LEN("\n/*!50100"));
+ table->part_info->set_show_version_string(packet);
packet->append(part_syntax, part_syntax_len);
packet->append(STRING_WITH_LEN(" */"));
my_free(part_syntax, MYF(0));
@@ -2166,7 +2166,8 @@ static bool show_status_array(THD *thd, const char *wild,
value= ((char *) status_var + (ulong) value);
/* fall through */
case SHOW_DOUBLE:
- end= buff + my_sprintf(buff, (buff, "%f", *(double*) value));
+ /* 6 is the default precision for '%f' in sprintf() */
+ end= buff + my_fcvt(*(double *) value, 6, buff, NULL);
break;
case SHOW_LONG_STATUS:
value= ((char *) status_var + (ulong) value);
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 40040ab0934..e4e51aba622 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -24,10 +24,6 @@
#include <m_string.h>
#include <m_ctype.h>
#include <mysql_com.h>
-#ifdef HAVE_FCONVERT
-#include <floatingpoint.h>
-#endif
-
/*
The following extern declarations are ok as these are interface functions
required by the string function
@@ -107,82 +103,19 @@ bool String::set_int(longlong num, bool unsigned_flag, CHARSET_INFO *cs)
bool String::set_real(double num,uint decimals, CHARSET_INFO *cs)
{
- char buff[331];
+ char buff[FLOATING_POINT_BUFFER];
uint dummy_errors;
+ size_t len;
str_charset=cs;
if (decimals >= NOT_FIXED_DEC)
{
- uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
+ len= my_gcvt(num, MY_GCVT_ARG_DOUBLE, sizeof(buff) - 1, buff, NULL);
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
}
-#ifdef HAVE_FCONVERT
- int decpt,sign;
- char *pos,*to;
-
- (void) fconvert(num,(int) decimals,&decpt,&sign,buff+1);
- if (!my_isdigit(&my_charset_latin1, buff[1]))
- { // Nan or Inf
- pos=buff+1;
- if (sign)
- {
- buff[0]='-';
- pos=buff;
- }
- uint dummy_errors;
- return copy(pos,(uint32) strlen(pos), &my_charset_latin1, cs, &dummy_errors);
- }
- if (alloc((uint32) ((uint32) decpt+3+decimals)))
- return TRUE;
- to=Ptr;
- if (sign)
- *to++='-';
-
- pos=buff+1;
- if (decpt < 0)
- { /* value is < 0 */
- *to++='0';
- if (!decimals)
- goto end;
- *to++='.';
- if ((uint32) -decpt > decimals)
- decpt= - (int) decimals;
- decimals=(uint32) ((int) decimals+decpt);
- while (decpt++ < 0)
- *to++='0';
- }
- else if (decpt == 0)
- {
- *to++= '0';
- if (!decimals)
- goto end;
- *to++='.';
- }
- else
- {
- while (decpt-- > 0)
- *to++= *pos++;
- if (!decimals)
- goto end;
- *to++='.';
- }
- while (decimals--)
- *to++= *pos++;
-
-end:
- *to=0;
- str_length=(uint32) (to-Ptr);
- return FALSE;
-#else
-#ifdef HAVE_SNPRINTF
- buff[sizeof(buff)-1]=0; // Safety
- snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num);
-#else
- sprintf(buff,"%.*f",(int) decimals,num);
-#endif
- return copy(buff,(uint32) strlen(buff), &my_charset_latin1, cs,
+ len= my_fcvt(num, decimals, buff, NULL);
+ return copy(buff, (uint32) len, &my_charset_latin1, cs,
&dummy_errors);
-#endif
}
@@ -661,7 +594,8 @@ void String::qs_append(const char *str, uint32 len)
void String::qs_append(double d)
{
char *buff = Ptr + str_length;
- str_length+= my_sprintf(buff, (buff, "%.15g", d));
+ str_length+= my_gcvt(d, MY_GCVT_ARG_DOUBLE, FLOATING_POINT_BUFFER - 1, buff,
+ NULL);
}
void String::qs_append(double *d)
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b1a740db9a5..e5a07a1ad1b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -764,10 +764,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%pure_parser /* We have threads */
/*
- Currently there are 173 shift/reduce conflicts.
+ Currently there are 172 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
-%expect 173
+%expect 172
/*
Comments for TOKENS.
@@ -7198,50 +7198,63 @@ select_option_list:
;
select_option:
- STRAIGHT_JOIN { Select->options|= SELECT_STRAIGHT_JOIN; }
- | HIGH_PRIORITY
+ query_expression_option
+ | SQL_NO_CACHE_SYM
{
- if (check_simple_select())
+ /*
+ Allow this flag only on the first top-level SELECT statement, if
+ SQL_CACHE wasn't specified, and only once per query.
+ */
+ if (Lex->current_select != &Lex->select_lex)
+ {
+ my_error(ER_CANT_USE_OPTION_HERE, MYF(0), "SQL_NO_CACHE");
MYSQL_YYABORT;
- Lex->lock_option= TL_READ_HIGH_PRIORITY;
- Lex->current_select->lock_option= TL_READ_HIGH_PRIORITY;
- }
- | DISTINCT { Select->options|= SELECT_DISTINCT; }
- | SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
- | SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; }
- | SQL_BUFFER_RESULT
- {
- if (check_simple_select())
+ }
+ else if (Lex->select_lex.sql_cache == SELECT_LEX::SQL_CACHE)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "SQL_CACHE", "SQL_NO_CACHE");
MYSQL_YYABORT;
- Select->options|= OPTION_BUFFER_RESULT;
- }
- | SQL_CALC_FOUND_ROWS
- {
- if (check_simple_select())
+ }
+ else if (Lex->select_lex.sql_cache == SELECT_LEX::SQL_NO_CACHE)
+ {
+ my_error(ER_DUP_ARGUMENT, MYF(0), "SQL_NO_CACHE");
MYSQL_YYABORT;
- Select->options|= OPTION_FOUND_ROWS;
- }
- | SQL_NO_CACHE_SYM
- {
- Lex->safe_to_cache_query=0;
- Lex->select_lex.options&= ~OPTION_TO_QUERY_CACHE;
- Lex->select_lex.sql_cache= SELECT_LEX::SQL_NO_CACHE;
+ }
+ else
+ {
+ Lex->safe_to_cache_query=0;
+ Lex->select_lex.options&= ~OPTION_TO_QUERY_CACHE;
+ Lex->select_lex.sql_cache= SELECT_LEX::SQL_NO_CACHE;
+ }
}
| SQL_CACHE_SYM
{
- /*
- Honor this flag only if SQL_NO_CACHE wasn't specified AND
- we are parsing the outermost SELECT in the query.
- */
- if (Lex->select_lex.sql_cache != SELECT_LEX::SQL_NO_CACHE &&
- Lex->current_select == &Lex->select_lex)
+ /*
+ Allow this flag only on the first top-level SELECT statement, if
+ SQL_NO_CACHE wasn't specified, and only once per query.
+ */
+ if (Lex->current_select != &Lex->select_lex)
+ {
+ my_error(ER_CANT_USE_OPTION_HERE, MYF(0), "SQL_CACHE");
+ MYSQL_YYABORT;
+ }
+ else if (Lex->select_lex.sql_cache == SELECT_LEX::SQL_NO_CACHE)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "SQL_NO_CACHE", "SQL_CACHE");
+ MYSQL_YYABORT;
+ }
+ else if (Lex->select_lex.sql_cache == SELECT_LEX::SQL_CACHE)
+ {
+ my_error(ER_DUP_ARGUMENT, MYF(0), "SQL_CACHE");
+ MYSQL_YYABORT;
+ }
+ else
{
Lex->safe_to_cache_query=1;
Lex->select_lex.options|= OPTION_TO_QUERY_CACHE;
Lex->select_lex.sql_cache= SELECT_LEX::SQL_CACHE;
}
}
- | ALL { Select->options|= SELECT_ALL; }
;
select_lock_type:
@@ -9313,7 +9326,7 @@ select_part2_derived:
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_LIST;
}
- select_options select_item_list
+ opt_query_expression_options select_item_list
{
Select->parsing_place= NO_MATTER;
}
@@ -13662,6 +13675,43 @@ subselect_end:
}
;
+opt_query_expression_options:
+ /* empty */
+ | query_expression_option_list
+ ;
+
+query_expression_option_list:
+ query_expression_option_list query_expression_option
+ | query_expression_option
+ ;
+
+query_expression_option:
+ STRAIGHT_JOIN { Select->options|= SELECT_STRAIGHT_JOIN; }
+ | HIGH_PRIORITY
+ {
+ if (check_simple_select())
+ MYSQL_YYABORT;
+ Lex->lock_option= TL_READ_HIGH_PRIORITY;
+ Lex->current_select->lock_option= TL_READ_HIGH_PRIORITY;
+ }
+ | DISTINCT { Select->options|= SELECT_DISTINCT; }
+ | SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
+ | SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; }
+ | SQL_BUFFER_RESULT
+ {
+ if (check_simple_select())
+ MYSQL_YYABORT;
+ Select->options|= OPTION_BUFFER_RESULT;
+ }
+ | SQL_CALC_FOUND_ROWS
+ {
+ if (check_simple_select())
+ MYSQL_YYABORT;
+ Select->options|= OPTION_FOUND_ROWS;
+ }
+ | ALL { Select->options|= SELECT_ALL; }
+ ;
+
/**************************************************************************
CREATE VIEW | TRIGGER | PROCEDURE statements.
diff --git a/sql/unireg.h b/sql/unireg.h
index 80c6ad23907..b6f81f48987 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -213,7 +213,6 @@
*/
#define BIN_LOG_HEADER_SIZE 4
-#define FLOATING_POINT_BUFFER 331
#define DEFAULT_KEY_CACHE_NAME "default"
diff --git a/storage/archive/Makefile.am b/storage/archive/Makefile.am
index 143d684025e..bb88ff2e8d1 100644
--- a/storage/archive/Makefile.am
+++ b/storage/archive/Makefile.am
@@ -77,9 +77,12 @@ libarchive_a_DEPENDENCIES = probes_mysql.o dtrace_files dtrace_providers
ha_archive_la_LIBADD = probes_sh_mysql.o
ha_archive_la_DEPENDENCIES = probes_sh_mysql.o dtrace_shared_files dtrace_providers
-CLEANFILES = $(DTRACEPROVIDER) dtrace_files dtrace_providers dtrace_shared_files
+CLEANFILES = $(DTRACEPROVIDER) dtrace_files dtrace_providers dtrace_shared_files dtrace_sources
DTRACEFILES = libarchive_a-ha_archive.o
DTRACESHAREDFILES = .libs/ha_archive_la-ha_archive.o
+# Hack: We "depend" on ".libs/" but have no rule for it,
+# but it is created as a byproduct of the ".lo"
+DTRACESHAREDDEPEND = ha_archive_la-ha_archive.lo
DTRACEPROVIDER = probes_mysql.d
dtrace_files:
@@ -93,7 +96,7 @@ probes_mysql.d:
$(CP) $(top_srcdir)/include/probes_mysql.d.base probes_mysql.d
echo timestamp > dtrace_sources
-probes_sh_mysql.o: $(DTRACEPROVIDER) $(DTRACESHAREDFILES)
+probes_sh_mysql.o: $(DTRACEPROVIDER) $(DTRACESHAREDDEPEND)
$(DTRACE) $(DTRACEFLAGS) -G -s $(DTRACEPROVIDER) $(DTRACESHAREDFILES) -o $@
probes_mysql.o: $(DTRACEPROVIDER) $(DTRACEFILES)
diff --git a/storage/ibmdb2i/db2i_charsetSupport.cc b/storage/ibmdb2i/db2i_charsetSupport.cc
index 83bf1b9448b..f5a3a74025e 100644
--- a/storage/ibmdb2i/db2i_charsetSupport.cc
+++ b/storage/ibmdb2i/db2i_charsetSupport.cc
@@ -164,10 +164,10 @@ int32 initCharsetSupport()
}
VOID(pthread_mutex_init(&textDescMapHashMutex,MY_MUTEX_INIT_FAST));
- hash_init(&textDescMapHash, &my_charset_bin, 10, offsetof(TextDescMap, hashKey), sizeof(TextDescMap::hashKey), 0, 0, HASH_UNIQUE);
+ my_hash_init(&textDescMapHash, &my_charset_bin, 10, offsetof(TextDescMap, hashKey), sizeof(TextDescMap::hashKey), 0, 0, HASH_UNIQUE);
VOID(pthread_mutex_init(&iconvMapHashMutex,MY_MUTEX_INIT_FAST));
- hash_init(&iconvMapHash, &my_charset_bin, 10, offsetof(IconvMap, hashKey), sizeof(IconvMap::hashKey), 0, 0, HASH_UNIQUE);
+ my_hash_init(&iconvMapHash, &my_charset_bin, 10, offsetof(IconvMap, hashKey), sizeof(IconvMap::hashKey), 0, 0, HASH_UNIQUE);
init_alloc_root(&textDescMapMemroot, 2048, 0);
init_alloc_root(&iconvMapMemroot, 256, 0);
@@ -191,9 +191,9 @@ void doneCharsetSupport()
free_root(&iconvMapMemroot, 0);
pthread_mutex_destroy(&textDescMapHashMutex);
- hash_free(&textDescMapHash);
+ my_hash_free(&textDescMapHash);
pthread_mutex_destroy(&iconvMapHashMutex);
- hash_free(&iconvMapHash);
+ my_hash_free(&iconvMapHash);
free_aligned(QlgCvtTextDescToDesc_sym);
}
@@ -415,7 +415,7 @@ static int32 convertTextDesc(const int32 inType, const int32 outType, const char
memcpy(hashKey.inDesc, inDescOverride, len);
memset(hashKey.inDesc+len, 0, sizeof(hashKey.inDesc) - len);
- if (!(mapping=(TextDescMap *) hash_search(&textDescMapHash,
+ if (!(mapping=(TextDescMap *) my_hash_search(&textDescMapHash,
(const uchar*)&hashKey,
sizeof(hashKey))))
{
@@ -748,7 +748,7 @@ int32 getConversion(enum_conversionDirection direction, const CHARSET_INFO* cs,
/* Look for the conversion in the cache and add it if it is not there. */
IconvMap *mapping;
- if (!(mapping= (IconvMap *) hash_search(&iconvMapHash,
+ if (!(mapping= (IconvMap *) my_hash_search(&iconvMapHash,
(const uchar*)&hashKey,
sizeof(hashKey))))
{
diff --git a/storage/ibmdb2i/db2i_constraints.cc b/storage/ibmdb2i/db2i_constraints.cc
index 1fde0dd3d14..cc2821238b6 100644
--- a/storage/ibmdb2i/db2i_constraints.cc
+++ b/storage/ibmdb2i/db2i_constraints.cc
@@ -102,7 +102,7 @@ int ha_ibmdb2i::buildDB2ConstraintString(LEX* lex,
Foreign_key* fk = (Foreign_key*)curKey;
char db2LibName[MAX_DB2_SCHEMANAME_LENGTH+1];
- if (fk->name)
+ if (fk->name.str)
{
char db2FKName[MAX_DB2_FILENAME_LENGTH+1];
appendHere.append(STRING_WITH_LEN("CONSTRAINT "));
@@ -120,7 +120,7 @@ int ha_ibmdb2i::buildDB2ConstraintString(LEX* lex,
appendHere.append('.');
- convertMySQLNameToDB2Name(fk->name, db2FKName, sizeof(db2FKName));
+ convertMySQLNameToDB2Name(fk->name.str, db2FKName, sizeof(db2FKName));
appendHere.append(db2FKName);
}
@@ -139,7 +139,7 @@ int ha_ibmdb2i::buildDB2ConstraintString(LEX* lex,
}
firstTime = false;
- convertMySQLNameToDB2Name(curColumn->field_name, colName, sizeof(colName));
+ convertMySQLNameToDB2Name(curColumn->field_name.str, colName, sizeof(colName));
appendHere.append(colName);
// DB2 requires that the sort sequence on the child table match the parent table's
@@ -148,7 +148,7 @@ int ha_ibmdb2i::buildDB2ConstraintString(LEX* lex,
Field** field = fields;
do
{
- if (strcmp((*field)->field_name, curColumn->field_name) == 0)
+ if (strcmp((*field)->field_name, curColumn->field_name.str) == 0)
{
int rc = updateAssociatedSortSequence((*field)->charset(),
fileSortSequenceType,
@@ -199,7 +199,7 @@ int ha_ibmdb2i::buildDB2ConstraintString(LEX* lex,
}
firstTime = false;
- convertMySQLNameToDB2Name(curRef->field_name, colName, sizeof(colName));
+ convertMySQLNameToDB2Name(curRef->field_name.str, colName, sizeof(colName));
appendHere.append(colName);
}
diff --git a/storage/ibmdb2i/ha_ibmdb2i.cc b/storage/ibmdb2i/ha_ibmdb2i.cc
index 39096be7848..81d7e59d8e3 100644
--- a/storage/ibmdb2i/ha_ibmdb2i.cc
+++ b/storage/ibmdb2i/ha_ibmdb2i.cc
@@ -284,8 +284,8 @@ static int ibmdb2i_init_func(void *p)
was_ILE_inited = false;
ibmdb2i_hton= (handlerton *)p;
VOID(pthread_mutex_init(&ibmdb2i_mutex,MY_MUTEX_INIT_FAST));
- (void) hash_init(&ibmdb2i_open_tables,table_alias_charset,32,0,0,
- (hash_get_key) ibmdb2i_get_key,0,0);
+ (void) my_hash_init(&ibmdb2i_open_tables,table_alias_charset,32,0,0,
+ (my_hash_get_key) ibmdb2i_get_key,0,0);
ibmdb2i_hton->state= SHOW_OPTION_YES;
ibmdb2i_hton->create= ibmdb2i_create_handler;
@@ -340,7 +340,7 @@ static int ibmdb2i_done_func(void *p)
doneCharsetSupport();
- hash_free(&ibmdb2i_open_tables);
+ my_hash_free(&ibmdb2i_open_tables);
pthread_mutex_destroy(&ibmdb2i_mutex);
DBUG_RETURN(0);
@@ -356,7 +356,7 @@ IBMDB2I_SHARE *ha_ibmdb2i::get_share(const char *table_name, TABLE *table)
pthread_mutex_lock(&ibmdb2i_mutex);
length=(uint) strlen(table_name);
- if (!(share=(IBMDB2I_SHARE*) hash_search(&ibmdb2i_open_tables,
+ if (!(share=(IBMDB2I_SHARE*) my_hash_search(&ibmdb2i_open_tables,
(uchar*)table_name,
length)))
{
@@ -387,7 +387,7 @@ IBMDB2I_SHARE *ha_ibmdb2i::get_share(const char *table_name, TABLE *table)
if (rc)
{
delete share->db2Table;
- hash_delete(&ibmdb2i_open_tables, (uchar*) share);
+ my_hash_delete(&ibmdb2i_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
my_errno = rc;
goto error;
@@ -420,7 +420,7 @@ int ha_ibmdb2i::free_share(IBMDB2I_SHARE *share)
delete share->db2Table;
db2Table = NULL;
- hash_delete(&ibmdb2i_open_tables, (uchar*) share);
+ my_hash_delete(&ibmdb2i_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
my_free(share, MYF(0));
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 379e6a23301..b63ed840f3c 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -15,7 +15,6 @@
# This is the CMakeLists for InnoDB Plugin
-
# Starting at 5.1.38, MySQL CMake files are simplified. But the plugin
# CMakeLists.txt still needs to work with previous versions of MySQL.
IF (MYSQL_VERSION_ID GREATER "50137")
@@ -87,5 +86,10 @@ IF (MYSQL_VERSION_ID GREATER "50137")
SET_TARGET_PROPERTIES(ha_innobase PROPERTIES OUTPUT_NAME ha_innodb)
ENDIF(LIB_LOCATION)
ELSE (MYSQL_VERSION_ID GREATER "50137")
- MYSQL_STORAGE_ENGINE(INNODB_PLUGIN)
+ IF (NOT SOURCE_SUBLIBS)
+ ADD_DEFINITIONS(-D_WIN32 -DMYSQL_SERVER)
+ ADD_LIBRARY(innobase STATIC ${INNOBASE_SOURCES})
+ # Require mysqld_error.h, which is built as part of the GenError
+ ADD_DEPENDENCIES(innobase GenError)
+ ENDIF (NOT SOURCE_SUBLIBS)
ENDIF (MYSQL_VERSION_ID GREATER "50137")
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index b3a6bf78566..580c58e6ea1 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -1502,11 +1502,11 @@ my_bool _mi_memmap_file(MI_INFO *info)
if (myisam_mmap_size != SIZE_T_MAX)
{
- pthread_mutex_lock(&THR_LOCK_myisam_mmap);
+ mysql_mutex_lock(&THR_LOCK_myisam_mmap);
eom= data_file_length > myisam_mmap_size - myisam_mmap_used - MEMMAP_EXTRA_MARGIN;
if (!eom)
myisam_mmap_used+= data_file_length + MEMMAP_EXTRA_MARGIN;
- pthread_mutex_unlock(&THR_LOCK_myisam_mmap);
+ mysql_mutex_unlock(&THR_LOCK_myisam_mmap);
}
else
eom= data_file_length > myisam_mmap_size - MEMMAP_EXTRA_MARGIN;
@@ -1522,9 +1522,9 @@ my_bool _mi_memmap_file(MI_INFO *info)
DBUG_PRINT("warning",("File isn't extended for memmap"));
if (myisam_mmap_size != SIZE_T_MAX)
{
- pthread_mutex_lock(&THR_LOCK_myisam_mmap);
+ mysql_mutex_lock(&THR_LOCK_myisam_mmap);
myisam_mmap_used-= data_file_length + MEMMAP_EXTRA_MARGIN;
- pthread_mutex_unlock(&THR_LOCK_myisam_mmap);
+ mysql_mutex_unlock(&THR_LOCK_myisam_mmap);
}
DBUG_RETURN(0);
}
@@ -1534,9 +1534,9 @@ my_bool _mi_memmap_file(MI_INFO *info)
{
if (myisam_mmap_size != SIZE_T_MAX)
{
- pthread_mutex_lock(&THR_LOCK_myisam_mmap);
+ mysql_mutex_lock(&THR_LOCK_myisam_mmap);
myisam_mmap_used-= data_file_length + MEMMAP_EXTRA_MARGIN;
- pthread_mutex_unlock(&THR_LOCK_myisam_mmap);
+ mysql_mutex_unlock(&THR_LOCK_myisam_mmap);
}
DBUG_RETURN(0);
}
@@ -1555,9 +1555,9 @@ void _mi_unmap_file(MI_INFO *info)
if (myisam_mmap_size != SIZE_T_MAX)
{
- pthread_mutex_lock(&THR_LOCK_myisam_mmap);
+ mysql_mutex_lock(&THR_LOCK_myisam_mmap);
myisam_mmap_used-= info->s->mmaped_length + MEMMAP_EXTRA_MARGIN;
- pthread_mutex_unlock(&THR_LOCK_myisam_mmap);
+ mysql_mutex_unlock(&THR_LOCK_myisam_mmap);
}
}
diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c
index b763308a4a9..4e597ce32f0 100644
--- a/storage/myisam/mi_static.c
+++ b/storage/myisam/mi_static.c
@@ -41,7 +41,6 @@ my_off_t myisam_max_temp_length= MAX_FILE_SIZE;
ulong myisam_bulk_insert_tree_size=8192*1024;
ulong myisam_data_pointer_size=4;
ulonglong myisam_mmap_size= SIZE_T_MAX, myisam_mmap_used= 0;
-pthread_mutex_t THR_LOCK_myisam_mmap;
static int always_valid(const char *filename __attribute__((unused)))
{
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index 294a129fc1b..572ca076a41 100755
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -18,10 +18,10 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
SET(STRINGS_SOURCES bchange.c bcmp.c bfill.c bmove512.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c
ctype-czech.c ctype-euc_kr.c ctype-eucjpms.c ctype-extra.c ctype-gb2312.c ctype-gbk.c
ctype-latin1.c ctype-mb.c ctype-simple.c ctype-sjis.c ctype-tis620.c ctype-uca.c
- ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c int2str.c
+ ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c dtoa.c int2str.c
is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c r_strinstr.c
str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c
- strtod.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c
+ strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c
my_strchr.c strcont.c strinstr.c strnlen.c)
IF(NOT SOURCE_SUBLIBS)
diff --git a/strings/Makefile.am b/strings/Makefile.am
index 4c34a923d81..8bfd1f27bca 100644
--- a/strings/Makefile.am
+++ b/strings/Makefile.am
@@ -30,19 +30,19 @@ pkglib_LIBRARIES = libmystrings.a
# Exact one of ASSEMBLER_X
if ASSEMBLER_x86
ASRCS = strings-x86.s longlong2str-x86.s my_strtoll10-x86.s
-CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c
+CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c str_alloc.c longlong2str_asm.c my_strchr.c dtoa.c
else
if ASSEMBLER_sparc32
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
-CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c
+CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c
else
#no assembler
ASRCS =
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
-CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c strtod.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c
+CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-ucs2.c ctype-uca.c ctype-win1250ch.c ctype-bin.c ctype-latin1.c my_vsnprintf.c xml.c decimal.c ctype-extra.c my_strtoll10.c str_alloc.c my_strchr.c dtoa.c
endif
endif
diff --git a/strings/decimal.c b/strings/decimal.c
index 282e7cae8ab..42dc33e5ac6 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -137,12 +137,6 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={
900000000, 990000000, 999000000,
999900000, 999990000, 999999000,
999999900, 999999990 };
-static double scaler10[]= {
- 1.0, 1e10, 1e20, 1e30, 1e40, 1e50, 1e60, 1e70, 1e80, 1e90
-};
-static double scaler1[]= {
- 1.0, 10.0, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9
-};
#ifdef HAVE_purify
#define sanity(d) DBUG_ASSERT((d)->len > 0)
@@ -947,33 +941,25 @@ fatal_error:
to - result will be stored there
RETURN VALUE
- E_DEC_OK
+ E_DEC_OK/E_DEC_OVERFLOW/E_DEC_TRUNCATED
*/
int decimal2double(decimal_t *from, double *to)
{
- double result= 0.0;
- int i, exp= 0;
- dec1 *buf= from->buf;
-
- for (i= from->intg; i > 0; i-= DIG_PER_DEC1)
- result= result * DIG_BASE + *buf++;
-
- for (i= from->frac; i > 0; i-= DIG_PER_DEC1) {
- result= result * DIG_BASE + *buf++;
- exp+= DIG_PER_DEC1;
- }
-
- DBUG_PRINT("info", ("interm.: %f %d %f", result, exp,
- scaler10[exp / 10] * scaler1[exp % 10]));
+ char strbuf[FLOATING_POINT_BUFFER], *end;
+ int len= sizeof(strbuf);
+ int rc, error;
- result/= scaler10[exp / 10] * scaler1[exp % 10];
-
- *to= from->sign ? -result : result;
+ rc = decimal2string(from, strbuf, &len, 0, 0, 0);
+ end= strbuf + len;
+
+ DBUG_PRINT("info", ("interm.: %s", strbuf));
+ *to= my_strtod(strbuf, &end, &error);
+
DBUG_PRINT("info", ("result: %f (%lx)", *to, *(ulong *)to));
- return E_DEC_OK;
+ return (rc != E_DEC_OK) ? rc : (error ? E_DEC_OVERFLOW : E_DEC_OK);
}
/*
@@ -990,13 +976,10 @@ int decimal2double(decimal_t *from, double *to)
int double2decimal(double from, decimal_t *to)
{
- /* TODO: fix it, when we'll have dtoa */
- char buff[400], *end;
- int length, res;
+ char buff[FLOATING_POINT_BUFFER], *end;
+ int res;
DBUG_ENTER("double2decimal");
- length= my_sprintf(buff, (buff, "%.16G", from));
- DBUG_PRINT("info",("from: %g from_as_str: %s", from, buff));
- end= buff+length;
+ end= buff + my_gcvt(from, MY_GCVT_ARG_DOUBLE, sizeof(buff) - 1, buff, NULL);
res= string2decimal(buff, to, &end);
DBUG_PRINT("exit", ("res: %d", res));
DBUG_RETURN(res);
diff --git a/strings/dtoa.c b/strings/dtoa.c
new file mode 100644
index 00000000000..88e0d9272a8
--- /dev/null
+++ b/strings/dtoa.c
@@ -0,0 +1,2780 @@
+/* Copyright (C) 2007 MySQL AB
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; version 2
+ of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/****************************************************************
+
+ This file incorporates work covered by the following copyright and
+ permission notice:
+
+ The author of this software is David M. Gay.
+
+ Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
+
+ Permission to use, copy, modify, and distribute this software for any
+ purpose without fee is hereby granted, provided that this entire notice
+ is included in all copies of any software which is or includes a copy
+ or modification of this software and in all copies of the supporting
+ documentation for such software.
+
+ THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
+ REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+
+ ***************************************************************/
+
+#include <my_base.h> /* for EOVERFLOW on Windows */
+#include <my_global.h>
+#include <m_string.h> /* for memcpy and NOT_FIXED_DEC */
+
+/**
+ Appears to suffice to not call malloc() in most cases.
+ @todo
+ see if it is possible to get rid of malloc().
+ this constant is sufficient to avoid malloc() on all inputs I have tried.
+*/
+#define DTOA_BUFF_SIZE (420 * sizeof(void *))
+
+/* Magic value returned by dtoa() to indicate overflow */
+#define DTOA_OVERFLOW 9999
+
+static double my_strtod_int(const char *, char **, int *, char *, size_t);
+static char *dtoa(double, int, int, int *, int *, char **, char *, size_t);
+static void dtoa_free(char *, char *, size_t);
+
+/**
+ @brief
+ Converts a given floating point number to a zero-terminated string
+ representation using the 'f' format.
+
+ @details
+ This function is a wrapper around dtoa() to do the same as
+ sprintf(to, "%-.*f", precision, x), though the conversion is usually more
+ precise. The only difference is in handling [-,+]infinity and nan values,
+ in which case we print '0\0' to the output string and indicate an overflow.
+
+ @param x the input floating point number.
+ @param precision the number of digits after the decimal point.
+ All properties of sprintf() apply:
+ - if the number of significant digits after the decimal
+ point is less than precision, the resulting string is
+ right-padded with zeros
+ - if the precision is 0, no decimal point appears
+ - if a decimal point appears, at least one digit appears
+ before it
+ @param to pointer to the output buffer. The longest string which
+ my_fcvt() can return is FLOATING_POINT_BUFFER bytes
+ (including the terminating '\0').
+ @param error if not NULL, points to a location where the status of
+ conversion is stored upon return.
+ FALSE successful conversion
+ TRUE the input number is [-,+]infinity or nan.
+ The output string in this case is always '0'.
+ @return number of written characters (excluding terminating '\0')
+*/
+
+size_t my_fcvt(double x, int precision, char *to, my_bool *error)
+{
+ int decpt, sign, len, i;
+ char *res, *src, *end, *dst= to;
+ char buf[DTOA_BUFF_SIZE];
+ DBUG_ASSERT(precision >= 0 && precision < NOT_FIXED_DEC && to != NULL);
+
+ res= dtoa(x, 5, precision, &decpt, &sign, &end, buf, sizeof(buf));
+
+ if (decpt == DTOA_OVERFLOW)
+ {
+ dtoa_free(res, buf, sizeof(buf));
+ *to++= '0';
+ *to= '\0';
+ if (error != NULL)
+ *error= TRUE;
+ return 1;
+ }
+
+ src= res;
+ len= end - src;
+
+ if (sign)
+ *dst++= '-';
+
+ if (decpt <= 0)
+ {
+ *dst++= '0';
+ *dst++= '.';
+ for (i= decpt; i < 0; i++)
+ *dst++= '0';
+ }
+
+ for (i= 1; i <= len; i++)
+ {
+ *dst++= *src++;
+ if (i == decpt && i < len)
+ *dst++= '.';
+ }
+ while (i++ <= decpt)
+ *dst++= '0';
+
+ if (precision > 0)
+ {
+ if (len <= decpt)
+ *dst++= '.';
+
+ for (i= precision - max(0, (len - decpt)); i > 0; i--)
+ *dst++= '0';
+ }
+
+ *dst= '\0';
+ if (error != NULL)
+ *error= FALSE;
+
+ dtoa_free(res, buf, sizeof(buf));
+
+ return dst - to;
+}
+
+/**
+ @brief
+ Converts a given floating point number to a zero-terminated string
+ representation with a given field width using the 'e' format
+ (aka scientific notation) or the 'f' one.
+
+ @details
+ The format is chosen automatically to provide the most number of significant
+ digits (and thus, precision) with a given field width. In many cases, the
+ result is similar to that of sprintf(to, "%g", x) with a few notable
+ differences:
+ - the conversion is usually more precise than C library functions.
+ - there is no 'precision' argument. instead, we specify the number of
+ characters available for conversion (i.e. a field width).
+ - the result never exceeds the specified field width. If the field is too
+ short to contain even a rounded decimal representation, my_gcvt()
+ indicates overflow and truncates the output string to the specified width.
+ - float-type arguments are handled differently than double ones. For a
+ float input number (i.e. when the 'type' argument is MY_GCVT_ARG_FLOAT)
+ we deliberately limit the precision of conversion by FLT_DIG digits to
+ avoid garbage past the significant digits.
+ - unlike sprintf(), in cases where the 'e' format is preferred, we don't
+ zero-pad the exponent to save space for significant digits. The '+' sign
+ for a positive exponent does not appear for the same reason.
+
+ @param x the input floating point number.
+ @param type is either MY_GCVT_ARG_FLOAT or MY_GCVT_ARG_DOUBLE.
+ Specifies the type of the input number (see notes above).
+ @param width field width in characters. The minimal field width to
+ hold any number representation (albeit rounded) is 7
+ characters ("-Ne-NNN").
+ @param to pointer to the output buffer. The result is always
+ zero-terminated, and the longest returned string is thus
+ 'width + 1' bytes.
+ @param error if not NULL, points to a location where the status of
+ conversion is stored upon return.
+ FALSE successful conversion
+ TRUE the input number is [-,+]infinity or nan.
+ The output string in this case is always '0'.
+ @return number of written characters (excluding terminating '\0')
+
+ @todo
+ Check if it is possible and makes sense to do our own rounding on top of
+ dtoa() instead of calling dtoa() twice in (rare) cases when the resulting
+ string representation does not fit in the specified field width and we want
+ to re-round the input number with fewer significant digits. Examples:
+
+ my_gcvt(-9e-3, ..., 4, ...);
+ my_gcvt(-9e-3, ..., 2, ...);
+ my_gcvt(1.87e-3, ..., 4, ...);
+ my_gcvt(55, ..., 1, ...);
+
+ We do our best to minimize such cases by:
+
+ - passing to dtoa() the field width as the number of significant digits
+
+ - removing the sign of the number early (and decreasing the width before
+ passing it to dtoa())
+
+ - choosing the proper format to preserve the most number of significant
+ digits.
+*/
+
+size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
+ my_bool *error)
+{
+ int decpt, sign, len, exp_len;
+ char *res, *src, *end, *dst= to, *dend= dst + width;
+ char buf[DTOA_BUFF_SIZE];
+ my_bool have_space, force_e_format;
+ DBUG_ASSERT(width > 0 && to != NULL);
+
+ /* We want to remove '-' from equations early */
+ if (x < 0.)
+ width--;
+
+ res= dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : min(width, FLT_DIG),
+ &decpt, &sign, &end, buf, sizeof(buf));
+ if (decpt == DTOA_OVERFLOW)
+ {
+ dtoa_free(res, buf, sizeof(buf));
+ *to++= '0';
+ *to= '\0';
+ if (error != NULL)
+ *error= TRUE;
+ return 1;
+ }
+
+ if (error != NULL)
+ *error= FALSE;
+
+ src= res;
+ len= end - res;
+
+ /*
+ Number of digits in the exponent from the 'e' conversion.
+ The sign of the exponent is taken into account separetely, we don't need
+ to count it here.
+ */
+ exp_len= 1 + (decpt >= 101 || decpt <= -99) + (decpt >= 11 || decpt <= -9);
+
+ /*
+ Do we have enough space for all digits in the 'f' format?
+ Let 'len' be the number of significant digits returned by dtoa,
+ and F be the length of the resulting decimal representation.
+ Consider the following cases:
+ 1. decpt <= 0, i.e. we have "0.NNN" => F = len - decpt + 2
+ 2. 0 < decpt < len, i.e. we have "NNN.NNN" => F = len + 1
+ 3. len <= decpt, i.e. we have "NNN00" => F = decpt
+ */
+ have_space= (decpt <= 0 ? len - decpt + 2 :
+ decpt > 0 && decpt < len ? len + 1 :
+ decpt) <= width;
+ /*
+ The following is true when no significant digits can be placed with the
+ specified field width using the 'f' format, and the 'e' format
+ will not be truncated.
+ */
+ force_e_format= (decpt <= 0 && width <= 2 - decpt && width >= 3 + exp_len);
+ /*
+ Assume that we don't have enough space to place all significant digits in
+ the 'f' format. We have to choose between the 'e' format and the 'f' one
+ to keep as many significant digits as possible.
+ Let E and F be the lengths of decimal representaion in the 'e' and 'f'
+ formats, respectively. We want to use the 'f' format if, and only if F <= E.
+ Consider the following cases:
+ 1. decpt <= 0.
+ F = len - decpt + 2 (see above)
+ E = len + (len > 1) + 1 + 1 (decpt <= -99) + (decpt <= -9) + 1
+ ("N.NNe-MMM")
+ (F <= E) <=> (len == 1 && decpt >= -1) || (len > 1 && decpt >= -2)
+ We also need to ensure that if the 'f' format is chosen,
+ the field width allows us to place at least one significant digit
+ (i.e. width > 2 - decpt). If not, we prefer the 'e' format.
+ 2. 0 < decpt < len
+ F = len + 1 (see above)
+ E = len + 1 + 1 + ... ("N.NNeMMM")
+ F is always less than E.
+ 3. len <= decpt <= width
+ In this case we have enough space to represent the number in the 'f'
+ format, so we prefer it with some exceptions.
+ 4. width < decpt
+ The number cannot be represented in the 'f' format at all, always use
+ the 'e' 'one.
+ */
+ if ((have_space ||
+ /*
+ Not enough space, let's see if the 'f' format provides the most number
+ of significant digits.
+ */
+ ((decpt <= width && (decpt >= -1 || (decpt == -2 &&
+ (len > 1 || !force_e_format)))) &&
+ !force_e_format)) &&
+
+ /*
+ Use the 'e' format in some cases even if we have enough space for the
+ 'f' one. See comment for MAX_DECPT_FOR_F_FORMAT.
+ */
+ (!have_space || (decpt >= -MAX_DECPT_FOR_F_FORMAT + 1 &&
+ (decpt <= MAX_DECPT_FOR_F_FORMAT || len > decpt))))
+ {
+ /* 'f' format */
+ int i;
+
+ width-= (decpt < len) + (decpt <= 0 ? 1 - decpt : 0);
+
+ /* Do we have to truncate any digits? */
+ if (width < len)
+ {
+ if (width < decpt)
+ {
+ if (error != NULL)
+ *error= TRUE;
+ width= decpt;
+ }
+
+ /*
+ We want to truncate (len - width) least significant digits after the
+ decimal point. For this we are calling dtoa with mode=5, passing the
+ number of significant digits = (len-decpt) - (len-width) = width-decpt
+ */
+ dtoa_free(res, buf, sizeof(buf));
+ res= dtoa(x, 5, width - decpt, &decpt, &sign, &end, buf, sizeof(buf));
+ src= res;
+ len= end - res;
+ }
+
+ if (len == 0)
+ {
+ /* Underflow. Just print '0' and exit */
+ *dst++= '0';
+ goto end;
+ }
+
+ /*
+ At this point we are sure we have enough space to put all digits
+ returned by dtoa
+ */
+ if (sign && dst < dend)
+ *dst++= '-';
+ if (decpt <= 0)
+ {
+ if (dst < dend)
+ *dst++= '0';
+ if (len > 0 && dst < dend)
+ *dst++= '.';
+ for (; decpt < 0 && dst < dend; decpt++)
+ *dst++= '0';
+ }
+
+ for (i= 1; i <= len && dst < dend; i++)
+ {
+ *dst++= *src++;
+ if (i == decpt && i < len && dst < dend)
+ *dst++= '.';
+ }
+ while (i++ <= decpt && dst < dend)
+ *dst++= '0';
+ }
+ else
+ {
+ /* 'e' format */
+ int decpt_sign= 0;
+
+ if (--decpt < 0)
+ {
+ decpt= -decpt;
+ width--;
+ decpt_sign= 1;
+ }
+ width-= 1 + exp_len; /* eNNN */
+
+ if (len > 1)
+ width--;
+
+ if (width <= 0)
+ {
+ /* Overflow */
+ if (error != NULL)
+ *error= TRUE;
+ width= 0;
+ }
+
+ /* Do we have to truncate any digits? */
+ if (width < len)
+ {
+ /* Yes, re-convert with a smaller width */
+ dtoa_free(res, buf, sizeof(buf));
+ res= dtoa(x, 4, width, &decpt, &sign, &end, buf, sizeof(buf));
+ src= res;
+ len= end - res;
+ if (--decpt < 0)
+ decpt= -decpt;
+ }
+ /*
+ At this point we are sure we have enough space to put all digits
+ returned by dtoa
+ */
+ if (sign && dst < dend)
+ *dst++= '-';
+ if (dst < dend)
+ *dst++= *src++;
+ if (len > 1 && dst < dend)
+ {
+ *dst++= '.';
+ while (src < end && dst < dend)
+ *dst++= *src++;
+ }
+ if (dst < dend)
+ *dst++= 'e';
+ if (decpt_sign && dst < dend)
+ *dst++= '-';
+
+ if (decpt >= 100 && dst < dend)
+ {
+ *dst++= decpt / 100 + '0';
+ decpt%= 100;
+ if (dst < dend)
+ *dst++= decpt / 10 + '0';
+ }
+ else if (decpt >= 10 && dst < dend)
+ *dst++= decpt / 10 + '0';
+ if (dst < dend)
+ *dst++= decpt % 10 + '0';
+
+ }
+
+end:
+ dtoa_free(res, buf, sizeof(buf));
+ *dst= '\0';
+
+ return dst - to;
+}
+
+/**
+ @brief
+ Converts string to double (string does not have to be zero-terminated)
+
+ @details
+ This is a wrapper around dtoa's version of strtod().
+
+ @param str input string
+ @param end address of a pointer to the first character after the input
+ string. Upon return the pointer is set to point to the first
+ rejected character.
+ @param error Upon return is set to EOVERFLOW in case of underflow or
+ overflow.
+
+ @return The resulting double value. In case of underflow, 0.0 is
+ returned. In case overflow, signed DBL_MAX is returned.
+*/
+
+double my_strtod(const char *str, char **end, int *error)
+{
+ char buf[DTOA_BUFF_SIZE];
+ double res;
+ DBUG_ASSERT(str != NULL && end != NULL && *end != NULL && error != NULL);
+
+ res= my_strtod_int(str, end, error, buf, sizeof(buf));
+ return (*error == 0) ? res : (res < 0 ? -DBL_MAX : DBL_MAX);
+}
+
+
+double my_atof(const char *nptr)
+{
+ int error;
+ const char *end= nptr+65535; /* Should be enough */
+ return (my_strtod(nptr, (char**) &end, &error));
+}
+
+
+/****************************************************************
+ *
+ * The author of this software is David M. Gay.
+ *
+ * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose without fee is hereby granted, provided that this entire notice
+ * is included in all copies of any software which is or includes a copy
+ * or modification of this software and in all copies of the supporting
+ * documentation for such software.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ *
+ ***************************************************************/
+/* Please send bug reports to David M. Gay (dmg at acm dot org,
+ * with " at " changed at "@" and " dot " changed to "."). */
+
+/*
+ Original copy of the software is located at http://www.netlib.org/fp/dtoa.c
+ It was adjusted to serve MySQL server needs:
+ * strtod() was modified to not expect a zero-terminated string.
+ It now honors 'se' (end of string) argument as the input parameter,
+ not just as the output one.
+ * in dtoa(), in case of overflow/underflow/NaN result string now contains "0";
+ decpt is set to DTOA_OVERFLOW to indicate overflow.
+ * support for VAX, IBM mainframe and 16-bit hardware removed
+ * we always assume that 64-bit integer type is available
+ * support for Kernigan-Ritchie style headers (pre-ANSI compilers)
+ removed
+ * all gcc warnings ironed out
+ * we always assume multithreaded environment, so we had to change
+ memory allocation procedures to use stack in most cases;
+ malloc is used as the last resort.
+ * pow5mult rewritten to use pre-calculated pow5 list instead of
+ the one generated on the fly.
+*/
+
+
+/*
+ On a machine with IEEE extended-precision registers, it is
+ necessary to specify double-precision (53-bit) rounding precision
+ before invoking strtod or dtoa. If the machine uses (the equivalent
+ of) Intel 80x87 arithmetic, the call
+ _control87(PC_53, MCW_PC);
+ does this with many compilers. Whether this or another call is
+ appropriate depends on the compiler; for this to work, it may be
+ necessary to #include "float.h" or another system-dependent header
+ file.
+*/
+
+/*
+ #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
+ and dtoa should round accordingly.
+ #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
+ and Honor_FLT_ROUNDS is not #defined.
+
+ TODO: check if we can get rid of the above two
+*/
+
+typedef int32 Long;
+typedef uint32 ULong;
+typedef int64 LLong;
+typedef uint64 ULLong;
+
+typedef union { double d; ULong L[2]; } U;
+
+#if defined(WORDS_BIGENDIAN) || (defined(__FLOAT_WORD_ORDER) && \
+ (__FLOAT_WORD_ORDER == __BIG_ENDIAN))
+#define word0(x) ((U*)&x)->L[0]
+#define word1(x) ((U*)&x)->L[1]
+#else
+#define word0(x) ((U*)&x)->L[1]
+#define word1(x) ((U*)&x)->L[0]
+#endif
+
+#define dval(x) ((U*)&x)->d
+
+/* #define P DBL_MANT_DIG */
+/* Ten_pmax= floor(P*log(2)/log(5)) */
+/* Bletch= (highest power of 2 < DBL_MAX_10_EXP) / 16 */
+/* Quick_max= floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
+/* Int_max= floor(P*log(FLT_RADIX)/log(10) - 1) */
+
+#define Exp_shift 20
+#define Exp_shift1 20
+#define Exp_msk1 0x100000
+#define Exp_mask 0x7ff00000
+#define P 53
+#define Bias 1023
+#define Emin (-1022)
+#define Exp_1 0x3ff00000
+#define Exp_11 0x3ff00000
+#define Ebits 11
+#define Frac_mask 0xfffff
+#define Frac_mask1 0xfffff
+#define Ten_pmax 22
+#define Bletch 0x10
+#define Bndry_mask 0xfffff
+#define Bndry_mask1 0xfffff
+#define LSB 1
+#define Sign_bit 0x80000000
+#define Log2P 1
+#define Tiny1 1
+#define Quick_max 14
+#define Int_max 14
+
+#ifndef Flt_Rounds
+#ifdef FLT_ROUNDS
+#define Flt_Rounds FLT_ROUNDS
+#else
+#define Flt_Rounds 1
+#endif
+#endif /*Flt_Rounds*/
+
+#ifdef Honor_FLT_ROUNDS
+#define Rounding rounding
+#undef Check_FLT_ROUNDS
+#define Check_FLT_ROUNDS
+#else
+#define Rounding Flt_Rounds
+#endif
+
+#define rounded_product(a,b) a*= b
+#define rounded_quotient(a,b) a/= b
+
+#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
+#define Big1 0xffffffff
+#define FFFFFFFF 0xffffffffUL
+
+/* This is tested to be enough for dtoa */
+
+#define Kmax 15
+
+#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \
+ 2*sizeof(int) + y->wds*sizeof(ULong))
+
+/* Arbitrary-length integer */
+
+typedef struct Bigint
+{
+ union {
+ ULong *x; /* points right after this Bigint object */
+ struct Bigint *next; /* to maintain free lists */
+ } p;
+ int k; /* 2^k = maxwds */
+ int maxwds; /* maximum length in 32-bit words */
+ int sign; /* not zero if number is negative */
+ int wds; /* current length in 32-bit words */
+} Bigint;
+
+
+/* A simple stack-memory based allocator for Bigints */
+
+typedef struct Stack_alloc
+{
+ char *begin;
+ char *free;
+ char *end;
+ /*
+ Having list of free blocks lets us reduce maximum required amount
+ of memory from ~4000 bytes to < 1680 (tested on x86).
+ */
+ Bigint *freelist[Kmax+1];
+} Stack_alloc;
+
+
+/*
+ Try to allocate object on stack, and resort to malloc if all
+ stack memory is used. Ensure allocated objects to be aligned by the pointer
+ size in order to not break the alignment rules when storing a pointer to a
+ Bigint.
+*/
+
+static Bigint *Balloc(int k, Stack_alloc *alloc)
+{
+ Bigint *rv;
+ if (k <= Kmax && alloc->freelist[k])
+ {
+ rv= alloc->freelist[k];
+ alloc->freelist[k]= rv->p.next;
+ }
+ else
+ {
+ int x, len;
+
+ x= 1 << k;
+ len= MY_ALIGN(sizeof(Bigint) + x * sizeof(ULong), SIZEOF_CHARP);
+
+ if (alloc->free + len <= alloc->end)
+ {
+ rv= (Bigint*) alloc->free;
+ alloc->free+= len;
+ }
+ else
+ rv= (Bigint*) malloc(len);
+
+ rv->k= k;
+ rv->maxwds= x;
+ }
+ rv->sign= rv->wds= 0;
+ rv->p.x= (ULong*) (rv + 1);
+ return rv;
+}
+
+
+/*
+ If object was allocated on stack, try putting it to the free
+ list. Otherwise call free().
+*/
+
+static void Bfree(Bigint *v, Stack_alloc *alloc)
+{
+ char *gptr= (char*) v; /* generic pointer */
+ if (gptr < alloc->begin || gptr >= alloc->end)
+ free(gptr);
+ else if (v->k <= Kmax)
+ {
+ /*
+ Maintain free lists only for stack objects: this way we don't
+ have to bother with freeing lists in the end of dtoa;
+ heap should not be used normally anyway.
+ */
+ v->p.next= alloc->freelist[v->k];
+ alloc->freelist[v->k]= v;
+ }
+}
+
+
+/*
+ This is to place return value of dtoa in: tries to use stack
+ as well, but passes by free lists management and just aligns len by
+ the pointer size in order to not break the alignment rules when storing a
+ pointer to a Bigint.
+*/
+
+static char *dtoa_alloc(int i, Stack_alloc *alloc)
+{
+ char *rv;
+ int aligned_size= MY_ALIGN(i, SIZEOF_CHARP);
+ if (alloc->free + aligned_size <= alloc->end)
+ {
+ rv= alloc->free;
+ alloc->free+= aligned_size;
+ }
+ else
+ rv= malloc(i);
+ return rv;
+}
+
+
+/*
+ dtoa_free() must be used to free values s returned by dtoa()
+ This is the counterpart of dtoa_alloc()
+*/
+
+static void dtoa_free(char *gptr, char *buf, size_t buf_size)
+{
+ if (gptr < buf || gptr >= buf + buf_size)
+ free(gptr);
+}
+
+
+/* Bigint arithmetic functions */
+
+/* Multiply by m and add a */
+
+static Bigint *multadd(Bigint *b, int m, int a, Stack_alloc *alloc)
+{
+ int i, wds;
+ ULong *x;
+ ULLong carry, y;
+ Bigint *b1;
+
+ wds= b->wds;
+ x= b->p.x;
+ i= 0;
+ carry= a;
+ do
+ {
+ y= *x * (ULLong)m + carry;
+ carry= y >> 32;
+ *x++= (ULong)(y & FFFFFFFF);
+ }
+ while (++i < wds);
+ if (carry)
+ {
+ if (wds >= b->maxwds)
+ {
+ b1= Balloc(b->k+1, alloc);
+ Bcopy(b1, b);
+ Bfree(b, alloc);
+ b= b1;
+ }
+ b->p.x[wds++]= (ULong) carry;
+ b->wds= wds;
+ }
+ return b;
+}
+
+
+static Bigint *s2b(const char *s, int nd0, int nd, ULong y9, Stack_alloc *alloc)
+{
+ Bigint *b;
+ int i, k;
+ Long x, y;
+
+ x= (nd + 8) / 9;
+ for (k= 0, y= 1; x > y; y <<= 1, k++) ;
+ b= Balloc(k, alloc);
+ b->p.x[0]= y9;
+ b->wds= 1;
+
+ i= 9;
+ if (9 < nd0)
+ {
+ s+= 9;
+ do
+ b= multadd(b, 10, *s++ - '0', alloc);
+ while (++i < nd0);
+ s++;
+ }
+ else
+ s+= 10;
+ for(; i < nd; i++)
+ b= multadd(b, 10, *s++ - '0', alloc);
+ return b;
+}
+
+
+static int hi0bits(register ULong x)
+{
+ register int k= 0;
+
+ if (!(x & 0xffff0000))
+ {
+ k= 16;
+ x<<= 16;
+ }
+ if (!(x & 0xff000000))
+ {
+ k+= 8;
+ x<<= 8;
+ }
+ if (!(x & 0xf0000000))
+ {
+ k+= 4;
+ x<<= 4;
+ }
+ if (!(x & 0xc0000000))
+ {
+ k+= 2;
+ x<<= 2;
+ }
+ if (!(x & 0x80000000))
+ {
+ k++;
+ if (!(x & 0x40000000))
+ return 32;
+ }
+ return k;
+}
+
+
+static int lo0bits(ULong *y)
+{
+ register int k;
+ register ULong x= *y;
+
+ if (x & 7)
+ {
+ if (x & 1)
+ return 0;
+ if (x & 2)
+ {
+ *y= x >> 1;
+ return 1;
+ }
+ *y= x >> 2;
+ return 2;
+ }
+ k= 0;
+ if (!(x & 0xffff))
+ {
+ k= 16;
+ x>>= 16;
+ }
+ if (!(x & 0xff))
+ {
+ k+= 8;
+ x>>= 8;
+ }
+ if (!(x & 0xf))
+ {
+ k+= 4;
+ x>>= 4;
+ }
+ if (!(x & 0x3))
+ {
+ k+= 2;
+ x>>= 2;
+ }
+ if (!(x & 1))
+ {
+ k++;
+ x>>= 1;
+ if (!x)
+ return 32;
+ }
+ *y= x;
+ return k;
+}
+
+
+/* Convert integer to Bigint number */
+
+static Bigint *i2b(int i, Stack_alloc *alloc)
+{
+ Bigint *b;
+
+ b= Balloc(1, alloc);
+ b->p.x[0]= i;
+ b->wds= 1;
+ return b;
+}
+
+
+/* Multiply two Bigint numbers */
+
+static Bigint *mult(Bigint *a, Bigint *b, Stack_alloc *alloc)
+{
+ Bigint *c;
+ int k, wa, wb, wc;
+ ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
+ ULong y;
+ ULLong carry, z;
+
+ if (a->wds < b->wds)
+ {
+ c= a;
+ a= b;
+ b= c;
+ }
+ k= a->k;
+ wa= a->wds;
+ wb= b->wds;
+ wc= wa + wb;
+ if (wc > a->maxwds)
+ k++;
+ c= Balloc(k, alloc);
+ for (x= c->p.x, xa= x + wc; x < xa; x++)
+ *x= 0;
+ xa= a->p.x;
+ xae= xa + wa;
+ xb= b->p.x;
+ xbe= xb + wb;
+ xc0= c->p.x;
+ for (; xb < xbe; xc0++)
+ {
+ if ((y= *xb++))
+ {
+ x= xa;
+ xc= xc0;
+ carry= 0;
+ do
+ {
+ z= *x++ * (ULLong)y + *xc + carry;
+ carry= z >> 32;
+ *xc++= (ULong) (z & FFFFFFFF);
+ }
+ while (x < xae);
+ *xc= (ULong) carry;
+ }
+ }
+ for (xc0= c->p.x, xc= xc0 + wc; wc > 0 && !*--xc; --wc) ;
+ c->wds= wc;
+ return c;
+}
+
+
+/*
+ Precalculated array of powers of 5: tested to be enough for
+ vasting majority of dtoa_r cases.
+*/
+
+static ULong powers5[]=
+{
+ 625UL,
+
+ 390625UL,
+
+ 2264035265UL, 35UL,
+
+ 2242703233UL, 762134875UL, 1262UL,
+
+ 3211403009UL, 1849224548UL, 3668416493UL, 3913284084UL, 1593091UL,
+
+ 781532673UL, 64985353UL, 253049085UL, 594863151UL, 3553621484UL,
+ 3288652808UL, 3167596762UL, 2788392729UL, 3911132675UL, 590UL,
+
+ 2553183233UL, 3201533787UL, 3638140786UL, 303378311UL, 1809731782UL,
+ 3477761648UL, 3583367183UL, 649228654UL, 2915460784UL, 487929380UL,
+ 1011012442UL, 1677677582UL, 3428152256UL, 1710878487UL, 1438394610UL,
+ 2161952759UL, 4100910556UL, 1608314830UL, 349175UL
+};
+
+
+static Bigint p5_a[]=
+{
+ /* { x } - k - maxwds - sign - wds */
+ { { powers5 }, 1, 1, 0, 1 },
+ { { powers5 + 1 }, 1, 1, 0, 1 },
+ { { powers5 + 2 }, 1, 2, 0, 2 },
+ { { powers5 + 4 }, 2, 3, 0, 3 },
+ { { powers5 + 7 }, 3, 5, 0, 5 },
+ { { powers5 + 12 }, 4, 10, 0, 10 },
+ { { powers5 + 22 }, 5, 19, 0, 19 }
+};
+
+#define P5A_MAX (sizeof(p5_a)/sizeof(*p5_a) - 1)
+
+static Bigint *pow5mult(Bigint *b, int k, Stack_alloc *alloc)
+{
+ Bigint *b1, *p5, *p51;
+ int i;
+ static int p05[3]= { 5, 25, 125 };
+
+ if ((i= k & 3))
+ b= multadd(b, p05[i-1], 0, alloc);
+
+ if (!(k>>= 2))
+ return b;
+ p5= p5_a;
+ for (;;)
+ {
+ if (k & 1)
+ {
+ b1= mult(b, p5, alloc);
+ Bfree(b, alloc);
+ b= b1;
+ }
+ if (!(k>>= 1))
+ break;
+ /* Calculate next power of 5 */
+ if (p5 < p5_a + P5A_MAX)
+ ++p5;
+ else if (p5 == p5_a + P5A_MAX)
+ p5= mult(p5, p5, alloc);
+ else
+ {
+ p51= mult(p5, p5, alloc);
+ Bfree(p5, alloc);
+ p5= p51;
+ }
+ }
+ return b;
+}
+
+
+static Bigint *lshift(Bigint *b, int k, Stack_alloc *alloc)
+{
+ int i, k1, n, n1;
+ Bigint *b1;
+ ULong *x, *x1, *xe, z;
+
+ n= k >> 5;
+ k1= b->k;
+ n1= n + b->wds + 1;
+ for (i= b->maxwds; n1 > i; i<<= 1)
+ k1++;
+ b1= Balloc(k1, alloc);
+ x1= b1->p.x;
+ for (i= 0; i < n; i++)
+ *x1++= 0;
+ x= b->p.x;
+ xe= x + b->wds;
+ if (k&= 0x1f)
+ {
+ k1= 32 - k;
+ z= 0;
+ do
+ {
+ *x1++= *x << k | z;
+ z= *x++ >> k1;
+ }
+ while (x < xe);
+ if ((*x1= z))
+ ++n1;
+ }
+ else
+ do
+ *x1++= *x++;
+ while (x < xe);
+ b1->wds= n1 - 1;
+ Bfree(b, alloc);
+ return b1;
+}
+
+
+static int cmp(Bigint *a, Bigint *b)
+{
+ ULong *xa, *xa0, *xb, *xb0;
+ int i, j;
+
+ i= a->wds;
+ j= b->wds;
+ if (i-= j)
+ return i;
+ xa0= a->p.x;
+ xa= xa0 + j;
+ xb0= b->p.x;
+ xb= xb0 + j;
+ for (;;)
+ {
+ if (*--xa != *--xb)
+ return *xa < *xb ? -1 : 1;
+ if (xa <= xa0)
+ break;
+ }
+ return 0;
+}
+
+
+static Bigint *diff(Bigint *a, Bigint *b, Stack_alloc *alloc)
+{
+ Bigint *c;
+ int i, wa, wb;
+ ULong *xa, *xae, *xb, *xbe, *xc;
+ ULLong borrow, y;
+
+ i= cmp(a,b);
+ if (!i)
+ {
+ c= Balloc(0, alloc);
+ c->wds= 1;
+ c->p.x[0]= 0;
+ return c;
+ }
+ if (i < 0)
+ {
+ c= a;
+ a= b;
+ b= c;
+ i= 1;
+ }
+ else
+ i= 0;
+ c= Balloc(a->k, alloc);
+ c->sign= i;
+ wa= a->wds;
+ xa= a->p.x;
+ xae= xa + wa;
+ wb= b->wds;
+ xb= b->p.x;
+ xbe= xb + wb;
+ xc= c->p.x;
+ borrow= 0;
+ do
+ {
+ y= (ULLong)*xa++ - *xb++ - borrow;
+ borrow= y >> 32 & (ULong)1;
+ *xc++= (ULong) (y & FFFFFFFF);
+ }
+ while (xb < xbe);
+ while (xa < xae)
+ {
+ y= *xa++ - borrow;
+ borrow= y >> 32 & (ULong)1;
+ *xc++= (ULong) (y & FFFFFFFF);
+ }
+ while (!*--xc)
+ wa--;
+ c->wds= wa;
+ return c;
+}
+
+
+static double ulp(double x)
+{
+ register Long L;
+ double a;
+
+ L= (word0(x) & Exp_mask) - (P - 1)*Exp_msk1;
+ word0(a) = L;
+ word1(a) = 0;
+ return dval(a);
+}
+
+
+static double b2d(Bigint *a, int *e)
+{
+ ULong *xa, *xa0, w, y, z;
+ int k;
+ double d;
+#define d0 word0(d)
+#define d1 word1(d)
+
+ xa0= a->p.x;
+ xa= xa0 + a->wds;
+ y= *--xa;
+ k= hi0bits(y);
+ *e= 32 - k;
+ if (k < Ebits)
+ {
+ d0= Exp_1 | y >> (Ebits - k);
+ w= xa > xa0 ? *--xa : 0;
+ d1= y << ((32-Ebits) + k) | w >> (Ebits - k);
+ goto ret_d;
+ }
+ z= xa > xa0 ? *--xa : 0;
+ if (k-= Ebits)
+ {
+ d0= Exp_1 | y << k | z >> (32 - k);
+ y= xa > xa0 ? *--xa : 0;
+ d1= z << k | y >> (32 - k);
+ }
+ else
+ {
+ d0= Exp_1 | y;
+ d1= z;
+ }
+ ret_d:
+#undef d0
+#undef d1
+ return dval(d);
+}
+
+
+static Bigint *d2b(double d, int *e, int *bits, Stack_alloc *alloc)
+{
+ Bigint *b;
+ int de, k;
+ ULong *x, y, z;
+ int i;
+#define d0 word0(d)
+#define d1 word1(d)
+
+ b= Balloc(1, alloc);
+ x= b->p.x;
+
+ z= d0 & Frac_mask;
+ d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
+ if ((de= (int)(d0 >> Exp_shift)))
+ z|= Exp_msk1;
+ if ((y= d1))
+ {
+ if ((k= lo0bits(&y)))
+ {
+ x[0]= y | z << (32 - k);
+ z>>= k;
+ }
+ else
+ x[0]= y;
+ i= b->wds= (x[1]= z) ? 2 : 1;
+ }
+ else
+ {
+ k= lo0bits(&z);
+ x[0]= z;
+ i= b->wds= 1;
+ k+= 32;
+ }
+ if (de)
+ {
+ *e= de - Bias - (P-1) + k;
+ *bits= P - k;
+ }
+ else
+ {
+ *e= de - Bias - (P-1) + 1 + k;
+ *bits= 32*i - hi0bits(x[i-1]);
+ }
+ return b;
+#undef d0
+#undef d1
+}
+
+
+static double ratio(Bigint *a, Bigint *b)
+{
+ double da, db;
+ int k, ka, kb;
+
+ dval(da)= b2d(a, &ka);
+ dval(db)= b2d(b, &kb);
+ k= ka - kb + 32*(a->wds - b->wds);
+ if (k > 0)
+ word0(da)+= k*Exp_msk1;
+ else
+ {
+ k= -k;
+ word0(db)+= k*Exp_msk1;
+ }
+ return dval(da) / dval(db);
+}
+
+static const double tens[] =
+{
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+ 1e20, 1e21, 1e22
+};
+
+static const double bigtens[]= { 1e16, 1e32, 1e64, 1e128, 1e256 };
+static const double tinytens[]=
+{ 1e-16, 1e-32, 1e-64, 1e-128,
+ 9007199254740992.*9007199254740992.e-256 /* = 2^106 * 1e-53 */
+};
+/*
+ The factor of 2^53 in tinytens[4] helps us avoid setting the underflow
+ flag unnecessarily. It leads to a song and dance at the end of strtod.
+*/
+#define Scale_Bit 0x10
+#define n_bigtens 5
+
+/*
+ strtod for IEEE--arithmetic machines.
+
+ This strtod returns a nearest machine number to the input decimal
+ string (or sets errno to EOVERFLOW). Ties are broken by the IEEE round-even
+ rule.
+
+ Inspired loosely by William D. Clinger's paper "How to Read Floating
+ Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
+
+ Modifications:
+
+ 1. We only require IEEE (not IEEE double-extended).
+ 2. We get by with floating-point arithmetic in a case that
+ Clinger missed -- when we're computing d * 10^n
+ for a small integer d and the integer n is not too
+ much larger than 22 (the maximum integer k for which
+ we can represent 10^k exactly), we may be able to
+ compute (d*10^k) * 10^(e-k) with just one roundoff.
+ 3. Rather than a bit-at-a-time adjustment of the binary
+ result in the hard case, we use floating-point
+ arithmetic to determine the adjustment to within
+ one bit; only in really hard cases do we need to
+ compute a second residual.
+ 4. Because of 3., we don't need a large table of powers of 10
+ for ten-to-e (just some small tables, e.g. of 10^k
+ for 0 <= k <= 22).
+*/
+
+static double my_strtod_int(const char *s00, char **se, int *error, char *buf, size_t buf_size)
+{
+ int scale;
+ int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
+ e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
+ const char *s, *s0, *s1, *end = *se;
+ double aadj, aadj1, adj, rv, rv0;
+ Long L;
+ ULong y, z;
+ Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
+#ifdef SET_INEXACT
+ int inexact, oldinexact;
+#endif
+#ifdef Honor_FLT_ROUNDS
+ int rounding;
+#endif
+ Stack_alloc alloc;
+ LINT_INIT(c);
+
+ *error= 0;
+
+ alloc.begin= alloc.free= buf;
+ alloc.end= buf + buf_size;
+ memset(alloc.freelist, 0, sizeof(alloc.freelist));
+
+ sign= nz0= nz= 0;
+ dval(rv)= 0.;
+ for (s= s00; s < end; s++)
+ switch (*s) {
+ case '-':
+ sign= 1;
+ /* no break */
+ case '+':
+ s++;
+ goto break2;
+ case '\t':
+ case '\n':
+ case '\v':
+ case '\f':
+ case '\r':
+ case ' ':
+ continue;
+ default:
+ goto break2;
+ }
+ break2:
+ if (s >= end)
+ goto ret0;
+
+ if (*s == '0')
+ {
+ nz0= 1;
+ while (++s < end && *s == '0') ;
+ if (s >= end)
+ goto ret;
+ }
+ s0= s;
+ y= z= 0;
+ for (nd= nf= 0; s < end && (c= *s) >= '0' && c <= '9'; nd++, s++)
+ if (nd < 9)
+ y= 10*y + c - '0';
+ else if (nd < 16)
+ z= 10*z + c - '0';
+ nd0= nd;
+ if (s < end - 1 && c == '.')
+ {
+ c= *++s;
+ if (!nd)
+ {
+ for (; s < end && c == '0'; c= *++s)
+ nz++;
+ if (s < end && c > '0' && c <= '9')
+ {
+ s0= s;
+ nf+= nz;
+ nz= 0;
+ goto have_dig;
+ }
+ goto dig_done;
+ }
+ for (; s < end && c >= '0' && c <= '9'; c = *++s)
+ {
+ have_dig:
+ nz++;
+ if (c-= '0')
+ {
+ nf+= nz;
+ for (i= 1; i < nz; i++)
+ if (nd++ < 9)
+ y*= 10;
+ else if (nd <= DBL_DIG + 1)
+ z*= 10;
+ if (nd++ < 9)
+ y= 10*y + c;
+ else if (nd <= DBL_DIG + 1)
+ z= 10*z + c;
+ nz= 0;
+ }
+ }
+ }
+ dig_done:
+ e= 0;
+ if (s < end && (c == 'e' || c == 'E'))
+ {
+ if (!nd && !nz && !nz0)
+ goto ret0;
+ s00= s;
+ esign= 0;
+ if (++s < end)
+ switch (c= *s) {
+ case '-':
+ esign= 1;
+ case '+':
+ c= *++s;
+ }
+ if (s < end && c >= '0' && c <= '9')
+ {
+ while (s < end && c == '0')
+ c= *++s;
+ if (s < end && c > '0' && c <= '9') {
+ L= c - '0';
+ s1= s;
+ while (++s < end && (c= *s) >= '0' && c <= '9')
+ L= 10*L + c - '0';
+ if (s - s1 > 8 || L > 19999)
+ /* Avoid confusion from exponents
+ * so large that e might overflow.
+ */
+ e= 19999; /* safe for 16 bit ints */
+ else
+ e= (int)L;
+ if (esign)
+ e= -e;
+ }
+ else
+ e= 0;
+ }
+ else
+ s= s00;
+ }
+ if (!nd)
+ {
+ if (!nz && !nz0)
+ {
+ ret0:
+ s= s00;
+ sign= 0;
+ }
+ goto ret;
+ }
+ e1= e -= nf;
+
+ /*
+ Now we have nd0 digits, starting at s0, followed by a
+ decimal point, followed by nd-nd0 digits. The number we're
+ after is the integer represented by those digits times
+ 10**e
+ */
+
+ if (!nd0)
+ nd0= nd;
+ k= nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
+ dval(rv)= y;
+ if (k > 9)
+ {
+#ifdef SET_INEXACT
+ if (k > DBL_DIG)
+ oldinexact = get_inexact();
+#endif
+ dval(rv)= tens[k - 9] * dval(rv) + z;
+ }
+ bd0= 0;
+ if (nd <= DBL_DIG
+#ifndef Honor_FLT_ROUNDS
+ && Flt_Rounds == 1
+#endif
+ )
+ {
+ if (!e)
+ goto ret;
+ if (e > 0)
+ {
+ if (e <= Ten_pmax)
+ {
+#ifdef Honor_FLT_ROUNDS
+ /* round correctly FLT_ROUNDS = 2 or 3 */
+ if (sign)
+ {
+ rv= -rv;
+ sign= 0;
+ }
+#endif
+ /* rv = */ rounded_product(dval(rv), tens[e]);
+ goto ret;
+ }
+ i= DBL_DIG - nd;
+ if (e <= Ten_pmax + i)
+ {
+ /*
+ A fancier test would sometimes let us do
+ this for larger i values.
+ */
+#ifdef Honor_FLT_ROUNDS
+ /* round correctly FLT_ROUNDS = 2 or 3 */
+ if (sign)
+ {
+ rv= -rv;
+ sign= 0;
+ }
+#endif
+ e-= i;
+ dval(rv)*= tens[i];
+ /* rv = */ rounded_product(dval(rv), tens[e]);
+ goto ret;
+ }
+ }
+#ifndef Inaccurate_Divide
+ else if (e >= -Ten_pmax)
+ {
+#ifdef Honor_FLT_ROUNDS
+ /* round correctly FLT_ROUNDS = 2 or 3 */
+ if (sign)
+ {
+ rv= -rv;
+ sign= 0;
+ }
+#endif
+ /* rv = */ rounded_quotient(dval(rv), tens[-e]);
+ goto ret;
+ }
+#endif
+ }
+ e1+= nd - k;
+
+#ifdef SET_INEXACT
+ inexact= 1;
+ if (k <= DBL_DIG)
+ oldinexact= get_inexact();
+#endif
+ scale= 0;
+#ifdef Honor_FLT_ROUNDS
+ if ((rounding= Flt_Rounds) >= 2)
+ {
+ if (sign)
+ rounding= rounding == 2 ? 0 : 2;
+ else
+ if (rounding != 2)
+ rounding= 0;
+ }
+#endif
+
+ /* Get starting approximation = rv * 10**e1 */
+
+ if (e1 > 0)
+ {
+ if ((i= e1 & 15))
+ dval(rv)*= tens[i];
+ if (e1&= ~15)
+ {
+ if (e1 > DBL_MAX_10_EXP)
+ {
+ ovfl:
+ *error= EOVERFLOW;
+ /* Can't trust HUGE_VAL */
+#ifdef Honor_FLT_ROUNDS
+ switch (rounding)
+ {
+ case 0: /* toward 0 */
+ case 3: /* toward -infinity */
+ word0(rv)= Big0;
+ word1(rv)= Big1;
+ break;
+ default:
+ word0(rv)= Exp_mask;
+ word1(rv)= 0;
+ }
+#else /*Honor_FLT_ROUNDS*/
+ word0(rv)= Exp_mask;
+ word1(rv)= 0;
+#endif /*Honor_FLT_ROUNDS*/
+#ifdef SET_INEXACT
+ /* set overflow bit */
+ dval(rv0)= 1e300;
+ dval(rv0)*= dval(rv0);
+#endif
+ if (bd0)
+ goto retfree;
+ goto ret;
+ }
+ e1>>= 4;
+ for(j= 0; e1 > 1; j++, e1>>= 1)
+ if (e1 & 1)
+ dval(rv)*= bigtens[j];
+ /* The last multiplication could overflow. */
+ word0(rv)-= P*Exp_msk1;
+ dval(rv)*= bigtens[j];
+ if ((z= word0(rv) & Exp_mask) > Exp_msk1 * (DBL_MAX_EXP + Bias - P))
+ goto ovfl;
+ if (z > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P))
+ {
+ /* set to largest number (Can't trust DBL_MAX) */
+ word0(rv)= Big0;
+ word1(rv)= Big1;
+ }
+ else
+ word0(rv)+= P*Exp_msk1;
+ }
+ }
+ else if (e1 < 0)
+ {
+ e1= -e1;
+ if ((i= e1 & 15))
+ dval(rv)/= tens[i];
+ if ((e1>>= 4))
+ {
+ if (e1 >= 1 << n_bigtens)
+ goto undfl;
+ if (e1 & Scale_Bit)
+ scale= 2 * P;
+ for(j= 0; e1 > 0; j++, e1>>= 1)
+ if (e1 & 1)
+ dval(rv)*= tinytens[j];
+ if (scale && (j = 2 * P + 1 - ((word0(rv) & Exp_mask) >> Exp_shift)) > 0)
+ {
+ /* scaled rv is denormal; zap j low bits */
+ if (j >= 32)
+ {
+ word1(rv)= 0;
+ if (j >= 53)
+ word0(rv)= (P + 2) * Exp_msk1;
+ else
+ word0(rv)&= 0xffffffff << (j - 32);
+ }
+ else
+ word1(rv)&= 0xffffffff << j;
+ }
+ if (!dval(rv))
+ {
+ undfl:
+ dval(rv)= 0.;
+ if (bd0)
+ goto retfree;
+ goto ret;
+ }
+ }
+ }
+
+ /* Now the hard part -- adjusting rv to the correct value.*/
+
+ /* Put digits into bd: true value = bd * 10^e */
+
+ bd0= s2b(s0, nd0, nd, y, &alloc);
+
+ for(;;)
+ {
+ bd= Balloc(bd0->k, &alloc);
+ Bcopy(bd, bd0);
+ bb= d2b(dval(rv), &bbe, &bbbits, &alloc); /* rv = bb * 2^bbe */
+ bs= i2b(1, &alloc);
+
+ if (e >= 0)
+ {
+ bb2= bb5= 0;
+ bd2= bd5= e;
+ }
+ else
+ {
+ bb2= bb5= -e;
+ bd2= bd5= 0;
+ }
+ if (bbe >= 0)
+ bb2+= bbe;
+ else
+ bd2-= bbe;
+ bs2= bb2;
+#ifdef Honor_FLT_ROUNDS
+ if (rounding != 1)
+ bs2++;
+#endif
+ j= bbe - scale;
+ i= j + bbbits - 1; /* logb(rv) */
+ if (i < Emin) /* denormal */
+ j+= P - Emin;
+ else
+ j= P + 1 - bbbits;
+ bb2+= j;
+ bd2+= j;
+ bd2+= scale;
+ i= bb2 < bd2 ? bb2 : bd2;
+ if (i > bs2)
+ i= bs2;
+ if (i > 0)
+ {
+ bb2-= i;
+ bd2-= i;
+ bs2-= i;
+ }
+ if (bb5 > 0)
+ {
+ bs= pow5mult(bs, bb5, &alloc);
+ bb1= mult(bs, bb, &alloc);
+ Bfree(bb, &alloc);
+ bb= bb1;
+ }
+ if (bb2 > 0)
+ bb= lshift(bb, bb2, &alloc);
+ if (bd5 > 0)
+ bd= pow5mult(bd, bd5, &alloc);
+ if (bd2 > 0)
+ bd= lshift(bd, bd2, &alloc);
+ if (bs2 > 0)
+ bs= lshift(bs, bs2, &alloc);
+ delta= diff(bb, bd, &alloc);
+ dsign= delta->sign;
+ delta->sign= 0;
+ i= cmp(delta, bs);
+#ifdef Honor_FLT_ROUNDS
+ if (rounding != 1)
+ {
+ if (i < 0)
+ {
+ /* Error is less than an ulp */
+ if (!delta->x[0] && delta->wds <= 1)
+ {
+ /* exact */
+#ifdef SET_INEXACT
+ inexact= 0;
+#endif
+ break;
+ }
+ if (rounding)
+ {
+ if (dsign)
+ {
+ adj= 1.;
+ goto apply_adj;
+ }
+ }
+ else if (!dsign)
+ {
+ adj= -1.;
+ if (!word1(rv) && !(word0(rv) & Frac_mask))
+ {
+ y= word0(rv) & Exp_mask;
+ if (!scale || y > 2*P*Exp_msk1)
+ {
+ delta= lshift(delta,Log2P);
+ if (cmp(delta, bs) <= 0)
+ adj= -0.5;
+ }
+ }
+ apply_adj:
+ if (scale && (y= word0(rv) & Exp_mask) <= 2 * P * Exp_msk1)
+ word0(adj)+= (2 * P + 1) * Exp_msk1 - y;
+ dval(rv)+= adj * ulp(dval(rv));
+ }
+ break;
+ }
+ adj= ratio(delta, bs);
+ if (adj < 1.)
+ adj= 1.;
+ if (adj <= 0x7ffffffe)
+ {
+ /* adj = rounding ? ceil(adj) : floor(adj); */
+ y= adj;
+ if (y != adj)
+ {
+ if (!((rounding >> 1) ^ dsign))
+ y++;
+ adj= y;
+ }
+ }
+ if (scale && (y= word0(rv) & Exp_mask) <= 2 * P * Exp_msk1)
+ word0(adj)+= (2 * P + 1) * Exp_msk1 - y;
+ adj*= ulp(dval(rv));
+ if (dsign)
+ dval(rv)+= adj;
+ else
+ dval(rv)-= adj;
+ goto cont;
+ }
+#endif /*Honor_FLT_ROUNDS*/
+
+ if (i < 0)
+ {
+ /*
+ Error is less than half an ulp -- check for special case of mantissa
+ a power of two.
+ */
+ if (dsign || word1(rv) || word0(rv) & Bndry_mask ||
+ (word0(rv) & Exp_mask) <= (2 * P + 1) * Exp_msk1)
+ {
+#ifdef SET_INEXACT
+ if (!delta->x[0] && delta->wds <= 1)
+ inexact= 0;
+#endif
+ break;
+ }
+ if (!delta->p.x[0] && delta->wds <= 1)
+ {
+ /* exact result */
+#ifdef SET_INEXACT
+ inexact= 0;
+#endif
+ break;
+ }
+ delta= lshift(delta, Log2P, &alloc);
+ if (cmp(delta, bs) > 0)
+ goto drop_down;
+ break;
+ }
+ if (i == 0)
+ {
+ /* exactly half-way between */
+ if (dsign)
+ {
+ if ((word0(rv) & Bndry_mask1) == Bndry_mask1 &&
+ word1(rv) ==
+ ((scale && (y = word0(rv) & Exp_mask) <= 2 * P * Exp_msk1) ?
+ (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :
+ 0xffffffff))
+ {
+ /*boundary case -- increment exponent*/
+ word0(rv)= (word0(rv) & Exp_mask) + Exp_msk1;
+ word1(rv) = 0;
+ dsign = 0;
+ break;
+ }
+ }
+ else if (!(word0(rv) & Bndry_mask) && !word1(rv))
+ {
+ drop_down:
+ /* boundary case -- decrement exponent */
+ if (scale)
+ {
+ L= word0(rv) & Exp_mask;
+ if (L <= (2 *P + 1) * Exp_msk1)
+ {
+ if (L > (P + 2) * Exp_msk1)
+ /* round even ==> accept rv */
+ break;
+ /* rv = smallest denormal */
+ goto undfl;
+ }
+ }
+ L= (word0(rv) & Exp_mask) - Exp_msk1;
+ word0(rv)= L | Bndry_mask1;
+ word1(rv)= 0xffffffff;
+ break;
+ }
+ if (!(word1(rv) & LSB))
+ break;
+ if (dsign)
+ dval(rv)+= ulp(dval(rv));
+ else
+ {
+ dval(rv)-= ulp(dval(rv));
+ if (!dval(rv))
+ goto undfl;
+ }
+ dsign= 1 - dsign;
+ break;
+ }
+ if ((aadj= ratio(delta, bs)) <= 2.)
+ {
+ if (dsign)
+ aadj= aadj1= 1.;
+ else if (word1(rv) || word0(rv) & Bndry_mask)
+ {
+ if (word1(rv) == Tiny1 && !word0(rv))
+ goto undfl;
+ aadj= 1.;
+ aadj1= -1.;
+ }
+ else
+ {
+ /* special case -- power of FLT_RADIX to be rounded down... */
+ if (aadj < 2. / FLT_RADIX)
+ aadj= 1. / FLT_RADIX;
+ else
+ aadj*= 0.5;
+ aadj1= -aadj;
+ }
+ }
+ else
+ {
+ aadj*= 0.5;
+ aadj1= dsign ? aadj : -aadj;
+#ifdef Check_FLT_ROUNDS
+ switch (Rounding)
+ {
+ case 2: /* towards +infinity */
+ aadj1-= 0.5;
+ break;
+ case 0: /* towards 0 */
+ case 3: /* towards -infinity */
+ aadj1+= 0.5;
+ }
+#else
+ if (Flt_Rounds == 0)
+ aadj1+= 0.5;
+#endif /*Check_FLT_ROUNDS*/
+ }
+ y= word0(rv) & Exp_mask;
+
+ /* Check for overflow */
+
+ if (y == Exp_msk1 * (DBL_MAX_EXP + Bias - 1))
+ {
+ dval(rv0)= dval(rv);
+ word0(rv)-= P * Exp_msk1;
+ adj= aadj1 * ulp(dval(rv));
+ dval(rv)+= adj;
+ if ((word0(rv) & Exp_mask) >= Exp_msk1 * (DBL_MAX_EXP + Bias - P))
+ {
+ if (word0(rv0) == Big0 && word1(rv0) == Big1)
+ goto ovfl;
+ word0(rv)= Big0;
+ word1(rv)= Big1;
+ goto cont;
+ }
+ else
+ word0(rv)+= P * Exp_msk1;
+ }
+ else
+ {
+ if (scale && y <= 2 * P * Exp_msk1)
+ {
+ if (aadj <= 0x7fffffff)
+ {
+ if ((z= (ULong) aadj) <= 0)
+ z= 1;
+ aadj= z;
+ aadj1= dsign ? aadj : -aadj;
+ }
+ word0(aadj1)+= (2 * P + 1) * Exp_msk1 - y;
+ }
+ adj = aadj1 * ulp(dval(rv));
+ dval(rv) += adj;
+ }
+ z= word0(rv) & Exp_mask;
+#ifndef SET_INEXACT
+ if (!scale)
+ if (y == z)
+ {
+ /* Can we stop now? */
+ L= (Long)aadj;
+ aadj-= L;
+ /* The tolerances below are conservative. */
+ if (dsign || word1(rv) || word0(rv) & Bndry_mask)
+ {
+ if (aadj < .4999999 || aadj > .5000001)
+ break;
+ }
+ else if (aadj < .4999999 / FLT_RADIX)
+ break;
+ }
+#endif
+ cont:
+ Bfree(bb, &alloc);
+ Bfree(bd, &alloc);
+ Bfree(bs, &alloc);
+ Bfree(delta, &alloc);
+ }
+#ifdef SET_INEXACT
+ if (inexact)
+ {
+ if (!oldinexact)
+ {
+ word0(rv0)= Exp_1 + (70 << Exp_shift);
+ word1(rv0)= 0;
+ dval(rv0)+= 1.;
+ }
+ }
+ else if (!oldinexact)
+ clear_inexact();
+#endif
+ if (scale)
+ {
+ word0(rv0)= Exp_1 - 2 * P * Exp_msk1;
+ word1(rv0)= 0;
+ dval(rv)*= dval(rv0);
+ }
+#ifdef SET_INEXACT
+ if (inexact && !(word0(rv) & Exp_mask))
+ {
+ /* set underflow bit */
+ dval(rv0)= 1e-300;
+ dval(rv0)*= dval(rv0);
+ }
+#endif
+ retfree:
+ Bfree(bb, &alloc);
+ Bfree(bd, &alloc);
+ Bfree(bs, &alloc);
+ Bfree(bd0, &alloc);
+ Bfree(delta, &alloc);
+ ret:
+ *se= (char *)s;
+ return sign ? -dval(rv) : dval(rv);
+}
+
+
+static int quorem(Bigint *b, Bigint *S)
+{
+ int n;
+ ULong *bx, *bxe, q, *sx, *sxe;
+ ULLong borrow, carry, y, ys;
+
+ n= S->wds;
+ if (b->wds < n)
+ return 0;
+ sx= S->p.x;
+ sxe= sx + --n;
+ bx= b->p.x;
+ bxe= bx + n;
+ q= *bxe / (*sxe + 1); /* ensure q <= true quotient */
+ if (q)
+ {
+ borrow= 0;
+ carry= 0;
+ do
+ {
+ ys= *sx++ * (ULLong)q + carry;
+ carry= ys >> 32;
+ y= *bx - (ys & FFFFFFFF) - borrow;
+ borrow= y >> 32 & (ULong)1;
+ *bx++= (ULong) (y & FFFFFFFF);
+ }
+ while (sx <= sxe);
+ if (!*bxe)
+ {
+ bx= b->p.x;
+ while (--bxe > bx && !*bxe)
+ --n;
+ b->wds= n;
+ }
+ }
+ if (cmp(b, S) >= 0)
+ {
+ q++;
+ borrow= 0;
+ carry= 0;
+ bx= b->p.x;
+ sx= S->p.x;
+ do
+ {
+ ys= *sx++ + carry;
+ carry= ys >> 32;
+ y= *bx - (ys & FFFFFFFF) - borrow;
+ borrow= y >> 32 & (ULong)1;
+ *bx++= (ULong) (y & FFFFFFFF);
+ }
+ while (sx <= sxe);
+ bx= b->p.x;
+ bxe= bx + n;
+ if (!*bxe)
+ {
+ while (--bxe > bx && !*bxe)
+ --n;
+ b->wds= n;
+ }
+ }
+ return q;
+}
+
+
+/*
+ dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
+
+ Inspired by "How to Print Floating-Point Numbers Accurately" by
+ Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126].
+
+ Modifications:
+ 1. Rather than iterating, we use a simple numeric overestimate
+ to determine k= floor(log10(d)). We scale relevant
+ quantities using O(log2(k)) rather than O(k) multiplications.
+ 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
+ try to generate digits strictly left to right. Instead, we
+ compute with fewer bits and propagate the carry if necessary
+ when rounding the final digit up. This is often faster.
+ 3. Under the assumption that input will be rounded nearest,
+ mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
+ That is, we allow equality in stopping tests when the
+ round-nearest rule will give the same floating-point value
+ as would satisfaction of the stopping test with strict
+ inequality.
+ 4. We remove common factors of powers of 2 from relevant
+ quantities.
+ 5. When converting floating-point integers less than 1e16,
+ we use floating-point arithmetic rather than resorting
+ to multiple-precision integers.
+ 6. When asked to produce fewer than 15 digits, we first try
+ to get by with floating-point arithmetic; we resort to
+ multiple-precision integer arithmetic only if we cannot
+ guarantee that the floating-point calculation has given
+ the correctly rounded result. For k requested digits and
+ "uniformly" distributed input, the probability is
+ something like 10^(k-15) that we must resort to the Long
+ calculation.
+ */
+
+static char *dtoa(double d, int mode, int ndigits, int *decpt, int *sign,
+ char **rve, char *buf, size_t buf_size)
+{
+ /*
+ Arguments ndigits, decpt, sign are similar to those
+ of ecvt and fcvt; trailing zeros are suppressed from
+ the returned string. If not null, *rve is set to point
+ to the end of the return value. If d is +-Infinity or NaN,
+ then *decpt is set to DTOA_OVERFLOW.
+
+ mode:
+ 0 ==> shortest string that yields d when read in
+ and rounded to nearest.
+ 1 ==> like 0, but with Steele & White stopping rule;
+ e.g. with IEEE P754 arithmetic , mode 0 gives
+ 1e23 whereas mode 1 gives 9.999999999999999e22.
+ 2 ==> max(1,ndigits) significant digits. This gives a
+ return value similar to that of ecvt, except
+ that trailing zeros are suppressed.
+ 3 ==> through ndigits past the decimal point. This
+ gives a return value similar to that from fcvt,
+ except that trailing zeros are suppressed, and
+ ndigits can be negative.
+ 4,5 ==> similar to 2 and 3, respectively, but (in
+ round-nearest mode) with the tests of mode 0 to
+ possibly return a shorter string that rounds to d.
+ With IEEE arithmetic and compilation with
+ -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same
+ as modes 2 and 3 when FLT_ROUNDS != 1.
+ 6-9 ==> Debugging modes similar to mode - 4: don't try
+ fast floating-point estimate (if applicable).
+
+ Values of mode other than 0-9 are treated as mode 0.
+
+ Sufficient space is allocated to the return value
+ to hold the suppressed trailing zeros.
+ */
+
+ int bbits, b2, b5, be, dig, i, ieps, UNINIT_VAR(ilim), ilim0,
+ UNINIT_VAR(ilim1), j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
+ spec_case, try_quick;
+ Long L;
+ int denorm;
+ ULong x;
+ Bigint *b, *b1, *delta, *mlo, *mhi, *S;
+ double d2, ds, eps;
+ char *s, *s0;
+#ifdef Honor_FLT_ROUNDS
+ int rounding;
+#endif
+ Stack_alloc alloc;
+
+ alloc.begin= alloc.free= buf;
+ alloc.end= buf + buf_size;
+ memset(alloc.freelist, 0, sizeof(alloc.freelist));
+
+ if (word0(d) & Sign_bit)
+ {
+ /* set sign for everything, including 0's and NaNs */
+ *sign= 1;
+ word0(d) &= ~Sign_bit; /* clear sign bit */
+ }
+ else
+ *sign= 0;
+
+ /* If infinity, set decpt to DTOA_OVERFLOW, if 0 set it to 1 */
+ if (((word0(d) & Exp_mask) == Exp_mask && (*decpt= DTOA_OVERFLOW)) ||
+ (!dval(d) && (*decpt= 1)))
+ {
+ /* Infinity, NaN, 0 */
+ char *res= (char*) dtoa_alloc(2, &alloc);
+ res[0]= '0';
+ res[1]= '\0';
+ if (rve)
+ *rve= res + 1;
+ return res;
+ }
+
+#ifdef Honor_FLT_ROUNDS
+ if ((rounding= Flt_Rounds) >= 2)
+ {
+ if (*sign)
+ rounding= rounding == 2 ? 0 : 2;
+ else
+ if (rounding != 2)
+ rounding= 0;
+ }
+#endif
+
+ b= d2b(dval(d), &be, &bbits, &alloc);
+ if ((i= (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))))
+ {
+ dval(d2)= dval(d);
+ word0(d2) &= Frac_mask1;
+ word0(d2) |= Exp_11;
+
+ /*
+ log(x) ~=~ log(1.5) + (x-1.5)/1.5
+ log10(x) = log(x) / log(10)
+ ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
+ log10(d)= (i-Bias)*log(2)/log(10) + log10(d2)
+
+ This suggests computing an approximation k to log10(d) by
+
+ k= (i - Bias)*0.301029995663981
+ + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
+
+ We want k to be too large rather than too small.
+ The error in the first-order Taylor series approximation
+ is in our favor, so we just round up the constant enough
+ to compensate for any error in the multiplication of
+ (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
+ and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
+ adding 1e-13 to the constant term more than suffices.
+ Hence we adjust the constant term to 0.1760912590558.
+ (We could get a more accurate k by invoking log10,
+ but this is probably not worthwhile.)
+ */
+
+ i-= Bias;
+ denorm= 0;
+ }
+ else
+ {
+ /* d is denormalized */
+
+ i= bbits + be + (Bias + (P-1) - 1);
+ x= i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32)
+ : word1(d) << (32 - i);
+ dval(d2)= x;
+ word0(d2)-= 31*Exp_msk1; /* adjust exponent */
+ i-= (Bias + (P-1) - 1) + 1;
+ denorm= 1;
+ }
+ ds= (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
+ k= (int)ds;
+ if (ds < 0. && ds != k)
+ k--; /* want k= floor(ds) */
+ k_check= 1;
+ if (k >= 0 && k <= Ten_pmax)
+ {
+ if (dval(d) < tens[k])
+ k--;
+ k_check= 0;
+ }
+ j= bbits - i - 1;
+ if (j >= 0)
+ {
+ b2= 0;
+ s2= j;
+ }
+ else
+ {
+ b2= -j;
+ s2= 0;
+ }
+ if (k >= 0)
+ {
+ b5= 0;
+ s5= k;
+ s2+= k;
+ }
+ else
+ {
+ b2-= k;
+ b5= -k;
+ s5= 0;
+ }
+ if (mode < 0 || mode > 9)
+ mode= 0;
+
+#ifdef Check_FLT_ROUNDS
+ try_quick= Rounding == 1;
+#else
+ try_quick= 1;
+#endif
+
+ if (mode > 5)
+ {
+ mode-= 4;
+ try_quick= 0;
+ }
+ leftright= 1;
+ switch (mode) {
+ case 0:
+ case 1:
+ ilim= ilim1= -1;
+ i= 18;
+ ndigits= 0;
+ break;
+ case 2:
+ leftright= 0;
+ /* no break */
+ case 4:
+ if (ndigits <= 0)
+ ndigits= 1;
+ ilim= ilim1= i= ndigits;
+ break;
+ case 3:
+ leftright= 0;
+ /* no break */
+ case 5:
+ i= ndigits + k + 1;
+ ilim= i;
+ ilim1= i - 1;
+ if (i <= 0)
+ i= 1;
+ }
+ s= s0= dtoa_alloc(i, &alloc);
+
+#ifdef Honor_FLT_ROUNDS
+ if (mode > 1 && rounding != 1)
+ leftright= 0;
+#endif
+
+ if (ilim >= 0 && ilim <= Quick_max && try_quick)
+ {
+ /* Try to get by with floating-point arithmetic. */
+ i= 0;
+ dval(d2)= dval(d);
+ k0= k;
+ ilim0= ilim;
+ ieps= 2; /* conservative */
+ if (k > 0)
+ {
+ ds= tens[k&0xf];
+ j= k >> 4;
+ if (j & Bletch)
+ {
+ /* prevent overflows */
+ j&= Bletch - 1;
+ dval(d)/= bigtens[n_bigtens-1];
+ ieps++;
+ }
+ for (; j; j>>= 1, i++)
+ {
+ if (j & 1)
+ {
+ ieps++;
+ ds*= bigtens[i];
+ }
+ }
+ dval(d)/= ds;
+ }
+ else if ((j1= -k))
+ {
+ dval(d)*= tens[j1 & 0xf];
+ for (j= j1 >> 4; j; j>>= 1, i++)
+ {
+ if (j & 1)
+ {
+ ieps++;
+ dval(d)*= bigtens[i];
+ }
+ }
+ }
+ if (k_check && dval(d) < 1. && ilim > 0)
+ {
+ if (ilim1 <= 0)
+ goto fast_failed;
+ ilim= ilim1;
+ k--;
+ dval(d)*= 10.;
+ ieps++;
+ }
+ dval(eps)= ieps*dval(d) + 7.;
+ word0(eps)-= (P-1)*Exp_msk1;
+ if (ilim == 0)
+ {
+ S= mhi= 0;
+ dval(d)-= 5.;
+ if (dval(d) > dval(eps))
+ goto one_digit;
+ if (dval(d) < -dval(eps))
+ goto no_digits;
+ goto fast_failed;
+ }
+ if (leftright)
+ {
+ /* Use Steele & White method of only generating digits needed. */
+ dval(eps)= 0.5/tens[ilim-1] - dval(eps);
+ for (i= 0;;)
+ {
+ L= (Long) dval(d);
+ dval(d)-= L;
+ *s++= '0' + (int)L;
+ if (dval(d) < dval(eps))
+ goto ret1;
+ if (1. - dval(d) < dval(eps))
+ goto bump_up;
+ if (++i >= ilim)
+ break;
+ dval(eps)*= 10.;
+ dval(d)*= 10.;
+ }
+ }
+ else
+ {
+ /* Generate ilim digits, then fix them up. */
+ dval(eps)*= tens[ilim-1];
+ for (i= 1;; i++, dval(d)*= 10.)
+ {
+ L= (Long)(dval(d));
+ if (!(dval(d)-= L))
+ ilim= i;
+ *s++= '0' + (int)L;
+ if (i == ilim)
+ {
+ if (dval(d) > 0.5 + dval(eps))
+ goto bump_up;
+ else if (dval(d) < 0.5 - dval(eps))
+ {
+ while (*--s == '0');
+ s++;
+ goto ret1;
+ }
+ break;
+ }
+ }
+ }
+ fast_failed:
+ s= s0;
+ dval(d)= dval(d2);
+ k= k0;
+ ilim= ilim0;
+ }
+
+ /* Do we have a "small" integer? */
+
+ if (be >= 0 && k <= Int_max)
+ {
+ /* Yes. */
+ ds= tens[k];
+ if (ndigits < 0 && ilim <= 0)
+ {
+ S= mhi= 0;
+ if (ilim < 0 || dval(d) <= 5*ds)
+ goto no_digits;
+ goto one_digit;
+ }
+ for (i= 1;; i++, dval(d)*= 10.)
+ {
+ L= (Long)(dval(d) / ds);
+ dval(d)-= L*ds;
+#ifdef Check_FLT_ROUNDS
+ /* If FLT_ROUNDS == 2, L will usually be high by 1 */
+ if (dval(d) < 0)
+ {
+ L--;
+ dval(d)+= ds;
+ }
+#endif
+ *s++= '0' + (int)L;
+ if (!dval(d))
+ {
+ break;
+ }
+ if (i == ilim)
+ {
+#ifdef Honor_FLT_ROUNDS
+ if (mode > 1)
+ {
+ switch (rounding) {
+ case 0: goto ret1;
+ case 2: goto bump_up;
+ }
+ }
+#endif
+ dval(d)+= dval(d);
+ if (dval(d) > ds || (dval(d) == ds && L & 1))
+ {
+bump_up:
+ while (*--s == '9')
+ if (s == s0)
+ {
+ k++;
+ *s= '0';
+ break;
+ }
+ ++*s++;
+ }
+ break;
+ }
+ }
+ goto ret1;
+ }
+
+ m2= b2;
+ m5= b5;
+ mhi= mlo= 0;
+ if (leftright)
+ {
+ i = denorm ? be + (Bias + (P-1) - 1 + 1) : 1 + P - bbits;
+ b2+= i;
+ s2+= i;
+ mhi= i2b(1, &alloc);
+ }
+ if (m2 > 0 && s2 > 0)
+ {
+ i= m2 < s2 ? m2 : s2;
+ b2-= i;
+ m2-= i;
+ s2-= i;
+ }
+ if (b5 > 0)
+ {
+ if (leftright)
+ {
+ if (m5 > 0)
+ {
+ mhi= pow5mult(mhi, m5, &alloc);
+ b1= mult(mhi, b, &alloc);
+ Bfree(b, &alloc);
+ b= b1;
+ }
+ if ((j= b5 - m5))
+ b= pow5mult(b, j, &alloc);
+ }
+ else
+ b= pow5mult(b, b5, &alloc);
+ }
+ S= i2b(1, &alloc);
+ if (s5 > 0)
+ S= pow5mult(S, s5, &alloc);
+
+ /* Check for special case that d is a normalized power of 2. */
+
+ spec_case= 0;
+ if ((mode < 2 || leftright)
+#ifdef Honor_FLT_ROUNDS
+ && rounding == 1
+#endif
+ )
+ {
+ if (!word1(d) && !(word0(d) & Bndry_mask) &&
+ word0(d) & (Exp_mask & ~Exp_msk1)
+ )
+ {
+ /* The special case */
+ b2+= Log2P;
+ s2+= Log2P;
+ spec_case= 1;
+ }
+ }
+
+ /*
+ Arrange for convenient computation of quotients:
+ shift left if necessary so divisor has 4 leading 0 bits.
+
+ Perhaps we should just compute leading 28 bits of S once
+ a nd for all and pass them and a shift to quorem, so it
+ can do shifts and ors to compute the numerator for q.
+ */
+ if ((i= ((s5 ? 32 - hi0bits(S->p.x[S->wds-1]) : 1) + s2) & 0x1f))
+ i= 32 - i;
+ if (i > 4)
+ {
+ i-= 4;
+ b2+= i;
+ m2+= i;
+ s2+= i;
+ }
+ else if (i < 4)
+ {
+ i+= 28;
+ b2+= i;
+ m2+= i;
+ s2+= i;
+ }
+ if (b2 > 0)
+ b= lshift(b, b2, &alloc);
+ if (s2 > 0)
+ S= lshift(S, s2, &alloc);
+ if (k_check)
+ {
+ if (cmp(b,S) < 0)
+ {
+ k--;
+ /* we botched the k estimate */
+ b= multadd(b, 10, 0, &alloc);
+ if (leftright)
+ mhi= multadd(mhi, 10, 0, &alloc);
+ ilim= ilim1;
+ }
+ }
+ if (ilim <= 0 && (mode == 3 || mode == 5))
+ {
+ if (ilim < 0 || cmp(b,S= multadd(S,5,0, &alloc)) <= 0)
+ {
+ /* no digits, fcvt style */
+no_digits:
+ k= -1 - ndigits;
+ goto ret;
+ }
+one_digit:
+ *s++= '1';
+ k++;
+ goto ret;
+ }
+ if (leftright)
+ {
+ if (m2 > 0)
+ mhi= lshift(mhi, m2, &alloc);
+
+ /*
+ Compute mlo -- check for special case that d is a normalized power of 2.
+ */
+
+ mlo= mhi;
+ if (spec_case)
+ {
+ mhi= Balloc(mhi->k, &alloc);
+ Bcopy(mhi, mlo);
+ mhi= lshift(mhi, Log2P, &alloc);
+ }
+
+ for (i= 1;;i++)
+ {
+ dig= quorem(b,S) + '0';
+ /* Do we yet have the shortest decimal string that will round to d? */
+ j= cmp(b, mlo);
+ delta= diff(S, mhi, &alloc);
+ j1= delta->sign ? 1 : cmp(b, delta);
+ Bfree(delta, &alloc);
+ if (j1 == 0 && mode != 1 && !(word1(d) & 1)
+#ifdef Honor_FLT_ROUNDS
+ && rounding >= 1
+#endif
+ )
+ {
+ if (dig == '9')
+ goto round_9_up;
+ if (j > 0)
+ dig++;
+ *s++= dig;
+ goto ret;
+ }
+ if (j < 0 || (j == 0 && mode != 1 && !(word1(d) & 1)))
+ {
+ if (!b->p.x[0] && b->wds <= 1)
+ {
+ goto accept_dig;
+ }
+#ifdef Honor_FLT_ROUNDS
+ if (mode > 1)
+ switch (rounding) {
+ case 0: goto accept_dig;
+ case 2: goto keep_dig;
+ }
+#endif /*Honor_FLT_ROUNDS*/
+ if (j1 > 0)
+ {
+ b= lshift(b, 1, &alloc);
+ j1= cmp(b, S);
+ if ((j1 > 0 || (j1 == 0 && dig & 1))
+ && dig++ == '9')
+ goto round_9_up;
+ }
+accept_dig:
+ *s++= dig;
+ goto ret;
+ }
+ if (j1 > 0)
+ {
+#ifdef Honor_FLT_ROUNDS
+ if (!rounding)
+ goto accept_dig;
+#endif
+ if (dig == '9')
+ { /* possible if i == 1 */
+round_9_up:
+ *s++= '9';
+ goto roundoff;
+ }
+ *s++= dig + 1;
+ goto ret;
+ }
+#ifdef Honor_FLT_ROUNDS
+keep_dig:
+#endif
+ *s++= dig;
+ if (i == ilim)
+ break;
+ b= multadd(b, 10, 0, &alloc);
+ if (mlo == mhi)
+ mlo= mhi= multadd(mhi, 10, 0, &alloc);
+ else
+ {
+ mlo= multadd(mlo, 10, 0, &alloc);
+ mhi= multadd(mhi, 10, 0, &alloc);
+ }
+ }
+ }
+ else
+ for (i= 1;; i++)
+ {
+ *s++= dig= quorem(b,S) + '0';
+ if (!b->p.x[0] && b->wds <= 1)
+ {
+ goto ret;
+ }
+ if (i >= ilim)
+ break;
+ b= multadd(b, 10, 0, &alloc);
+ }
+
+ /* Round off last digit */
+
+#ifdef Honor_FLT_ROUNDS
+ switch (rounding) {
+ case 0: goto trimzeros;
+ case 2: goto roundoff;
+ }
+#endif
+ b= lshift(b, 1, &alloc);
+ j= cmp(b, S);
+ if (j > 0 || (j == 0 && dig & 1))
+ {
+roundoff:
+ while (*--s == '9')
+ if (s == s0)
+ {
+ k++;
+ *s++= '1';
+ goto ret;
+ }
+ ++*s++;
+ }
+ else
+ {
+#ifdef Honor_FLT_ROUNDS
+trimzeros:
+#endif
+ while (*--s == '0');
+ s++;
+ }
+ret:
+ Bfree(S, &alloc);
+ if (mhi)
+ {
+ if (mlo && mlo != mhi)
+ Bfree(mlo, &alloc);
+ Bfree(mhi, &alloc);
+ }
+ret1:
+ Bfree(b, &alloc);
+ *s= 0;
+ *decpt= k + 1;
+ if (rve)
+ *rve= s;
+ return s0;
+}
diff --git a/strings/strtod.c b/strings/strtod.c
deleted file mode 100644
index 4c9cf931cb3..00000000000
--- a/strings/strtod.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- An alternative implementation of "strtod()" that is both
- simplier, and thread-safe.
-
- Original code from mit-threads as bundled with MySQL 3.23
-
- SQL:2003 specifies a number as
-
-<signed numeric literal> ::= [ <sign> ] <unsigned numeric literal>
-
-<unsigned numeric literal> ::=
- <exact numeric literal>
- | <approximate numeric literal>
-
-<exact numeric literal> ::=
- <unsigned integer> [ <period> [ <unsigned integer> ] ]
- | <period> <unsigned integer>
-
-<approximate numeric literal> ::= <mantissa> E <exponent>
-
-<mantissa> ::= <exact numeric literal>
-
-<exponent> ::= <signed integer>
-
- So do we.
-
- */
-
-#include "my_base.h" /* Includes errno.h + EOVERFLOW */
-#include "m_ctype.h"
-#ifdef HAVE_IEEEFP_H
-#include <ieeefp.h>
-#endif
-
-#define MAX_DBL_EXP 308
-#define MAX_RESULT_FOR_MAX_EXP 1.7976931348623157
-
-const double log_10[] = {
- 1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009,
- 1e010, 1e011, 1e012, 1e013, 1e014, 1e015, 1e016, 1e017, 1e018, 1e019,
- 1e020, 1e021, 1e022, 1e023, 1e024, 1e025, 1e026, 1e027, 1e028, 1e029,
- 1e030, 1e031, 1e032, 1e033, 1e034, 1e035, 1e036, 1e037, 1e038, 1e039,
- 1e040, 1e041, 1e042, 1e043, 1e044, 1e045, 1e046, 1e047, 1e048, 1e049,
- 1e050, 1e051, 1e052, 1e053, 1e054, 1e055, 1e056, 1e057, 1e058, 1e059,
- 1e060, 1e061, 1e062, 1e063, 1e064, 1e065, 1e066, 1e067, 1e068, 1e069,
- 1e070, 1e071, 1e072, 1e073, 1e074, 1e075, 1e076, 1e077, 1e078, 1e079,
- 1e080, 1e081, 1e082, 1e083, 1e084, 1e085, 1e086, 1e087, 1e088, 1e089,
- 1e090, 1e091, 1e092, 1e093, 1e094, 1e095, 1e096, 1e097, 1e098, 1e099,
- 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109,
- 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119,
- 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129,
- 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139,
- 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149,
- 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159,
- 1e160, 1e161, 1e162, 1e163, 1e164, 1e165, 1e166, 1e167, 1e168, 1e169,
- 1e170, 1e171, 1e172, 1e173, 1e174, 1e175, 1e176, 1e177, 1e178, 1e179,
- 1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186, 1e187, 1e188, 1e189,
- 1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198, 1e199,
- 1e200, 1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209,
- 1e210, 1e211, 1e212, 1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219,
- 1e220, 1e221, 1e222, 1e223, 1e224, 1e225, 1e226, 1e227, 1e228, 1e229,
- 1e230, 1e231, 1e232, 1e233, 1e234, 1e235, 1e236, 1e237, 1e238, 1e239,
- 1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246, 1e247, 1e248, 1e249,
- 1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258, 1e259,
- 1e260, 1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269,
- 1e270, 1e271, 1e272, 1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279,
- 1e280, 1e281, 1e282, 1e283, 1e284, 1e285, 1e286, 1e287, 1e288, 1e289,
- 1e290, 1e291, 1e292, 1e293, 1e294, 1e295, 1e296, 1e297, 1e298, 1e299,
- 1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306, 1e307, 1e308
-};
-
-/*
- Convert string to double (string doesn't have to be null terminated)
-
- SYNOPSIS
- my_strtod()
- str String to convert
- end_ptr Pointer to pointer that points to end of string
- Will be updated to point to end of double.
- error Will contain error number in case of error (else 0)
-
- RETURN
- value of str as double
-*/
-
-double my_strtod(const char *str, char **end_ptr, int *error)
-{
- double result= 0.0;
- uint negative= 0, neg_exp= 0;
- size_t ndigits, dec_digits= 0;
- int exponent= 0, digits_after_dec_point= 0, tmp_exp, step;
- const char *old_str, *end= *end_ptr, *start_of_number;
- char next_char;
- my_bool overflow=0;
- double scaler= 1.0;
-
- *error= 0;
- if (str >= end)
- goto done;
-
- while (my_isspace(&my_charset_latin1, *str))
- {
- if (++str == end)
- goto done;
- }
-
- start_of_number= str;
- if ((negative= (*str == '-')) || *str=='+')
- {
- if (++str == end)
- goto done; /* Could be changed to error */
- }
-
- /* Skip pre-zero for easier calculation of overflows */
- while (*str == '0')
- {
- if (++str == end)
- goto done;
- start_of_number= 0; /* Found digit */
- }
-
- old_str= str;
- while ((next_char= *str) >= '0' && next_char <= '9')
- {
- result= result*10.0 + (next_char - '0');
- scaler= scaler*10.0;
- if (++str == end)
- {
- next_char= 0; /* Found end of string */
- break;
- }
- start_of_number= 0; /* Found digit */
- }
- ndigits= (size_t) (str-old_str);
-
- if (next_char == '.' && str < end-1)
- {
- /*
- Continue to add numbers after decimal point to the result, as if there
- was no decimal point. We will later (in the exponent handling) shift
- the number down with the required number of fractions. We do it this
- way to be able to get maximum precision for numbers like 123.45E+02,
- which are normal for some ODBC applications.
- */
- old_str= ++str;
- while (my_isdigit(&my_charset_latin1, (next_char= *str)))
- {
- result= result*10.0 + (next_char - '0');
- digits_after_dec_point++;
- scaler= scaler*10.0;
- if (++str == end)
- {
- next_char= 0;
- break;
- }
- }
- /* If we found just '+.' or '.' then point at first character */
- if (!(dec_digits= (size_t) (str-old_str)) && start_of_number)
- str= start_of_number; /* Point at '+' or '.' */
- }
- if ((next_char == 'e' || next_char == 'E') &&
- dec_digits + ndigits != 0 && str < end-1)
- {
- const char *old_str2= str++;
-
- if ((neg_exp= (*str == '-')) || *str == '+')
- str++;
-
- if (str == end || !my_isdigit(&my_charset_latin1, *str))
- str= old_str2;
- else
- {
- do
- {
- if (exponent < 9999) /* prot. against exp overfl. */
- exponent= exponent*10 + (*str - '0');
- str++;
- } while (str < end && my_isdigit(&my_charset_latin1, *str));
- }
- }
- tmp_exp= (neg_exp ? exponent + digits_after_dec_point :
- exponent - digits_after_dec_point);
- if (tmp_exp)
- {
- int order;
- /*
- Check for underflow/overflow.
- order is such an integer number that f = C * 10 ^ order,
- where f is the resulting floating point number and 1 <= C < 10.
- Here we compute the modulus
- */
- order= exponent + (neg_exp ? -1 : 1) * (ndigits - 1);
- if (order < 0)
- order= -order;
- if (order >= MAX_DBL_EXP && !neg_exp && result)
- {
- double c;
- /* Compute modulus of C (see comment above) */
- c= result / scaler * 10.0;
- if (order > MAX_DBL_EXP || c > MAX_RESULT_FOR_MAX_EXP)
- {
- overflow= 1;
- goto done;
- }
- }
-
- exponent= tmp_exp;
- if (exponent < 0)
- {
- exponent= -exponent;
- neg_exp= 1; /* neg_exp was 0 before */
- }
- step= array_elements(log_10) - 1;
- for (; exponent > step; exponent-= step)
- result= neg_exp ? result / log_10[step] : result * log_10[step];
- result= neg_exp ? result / log_10[exponent] : result * log_10[exponent];
- }
-
-done:
- *end_ptr= (char*) str; /* end of number */
-
- if (overflow || my_isinf(result))
- {
- result= DBL_MAX;
- *error= EOVERFLOW;
- }
-
- return negative ? -result : result;
-}
-
-double my_atof(const char *nptr)
-{
- int error;
- const char *end= nptr+65535; /* Should be enough */
- return (my_strtod(nptr, (char**) &end, &error));
-}
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index ccf4d8ff51d..b5115a5c05e 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -303,7 +303,7 @@ case "$mode" in
then
mysqld_pid=`cat "$mysqld_pid_file_path"`
- if (kill -9 $mysqld_pid 2>/dev/null)
+ if (kill -0 $mysqld_pid 2>/dev/null)
then
echo $echo_n "Shutting down MySQL"
kill $mysqld_pid
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index 239611c0b53..83d4550466b 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -43,6 +43,12 @@
%{?_with_cluster:%define CLUSTER_BUILD 1}
%{!?_with_cluster:%define CLUSTER_BUILD 0}
+# ----------------------------------------------------------------------
+# support optional "tcmalloc" stuff (experimental)
+# ----------------------------------------------------------------------
+%{?malloc_lib_target:%define WITH_TCMALLOC 1}
+%{!?malloc_lib_target:%define WITH_TCMALLOC 0}
+
%if %{STATIC_BUILD}
%define release 0
%else
@@ -448,7 +454,7 @@ $MBD/libtool --mode=execute install -m 755 \
$RPM_BUILD_DIR/mysql-%{mysql_version}/mysql-debug-%{mysql_version}/sql/mysqld \
$RBR%{_sbindir}/mysqld-debug
-%if %{?malloc_lib_target:1}%{!?malloc_lib_target:0}
+%if %{WITH_TCMALLOC}
# Even though this is a shared library, put it under /usr/lib/mysql, so it
# doesn't conflict with possible shared lib by the same name in /usr/lib. See
# `mysql_config --variable=pkglibdir` and mysqld_safe for how this is used.
@@ -709,12 +715,10 @@ fi
%attr(755, root, root) %{_bindir}/resolveip
%attr(755, root, root) %{_libdir}/mysql/plugin/ha_example.so*
-%if %{WITHOUT_INNODB_PLUGIN}
-%else
-%attr(755, root, root) %{_libdir}/mysql/plugin/ha_innodb_plugin.so*
-%endif
+%attr(755, root, root) %{_libdir}/mysql/plugin/libsemisync_master.so*
+%attr(755, root, root) %{_libdir}/mysql/plugin/libsemisync_slave.so*
-%if %{?malloc_lib_target:1}%{!?malloc_lib_target:0}
+%if %{WITH_TCMALLOC}
%attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target}
%endif
@@ -833,6 +837,7 @@ fi
%{_libdir}/mysql/libmysqlclient.la
%{_libdir}/mysql/libmysqlclient_r.a
%{_libdir}/mysql/libmysqlclient_r.la
+%{_libdir}/mysql/libmysqlservices.a
%{_libdir}/mysql/libmystrings.a
%{_libdir}/mysql/libmysys.a
%if %{CLUSTER_BUILD}
@@ -844,11 +849,10 @@ fi
%{_libdir}/mysql/libz.la
%{_libdir}/mysql/plugin/ha_example.a
%{_libdir}/mysql/plugin/ha_example.la
-%if %{WITHOUT_INNODB_PLUGIN}
-%else
-%{_libdir}/mysql/plugin/ha_innodb_plugin.a
-%{_libdir}/mysql/plugin/ha_innodb_plugin.la
-%endif
+%{_libdir}/mysql/plugin/libsemisync_master.a
+%{_libdir}/mysql/plugin/libsemisync_master.la
+%{_libdir}/mysql/plugin/libsemisync_slave.a
+%{_libdir}/mysql/plugin/libsemisync_slave.la
%files shared
%defattr(-, root, root, 0755)
@@ -878,6 +882,11 @@ fi
# itself - note that they must be ordered by date (important when
# merging BK trees)
%changelog
+* Mon Nov 16 2009 Joerg Bruehe <joerg.bruehe@sun.com>
+
+- Fix some problems with the directives around "tcmalloc" (experimental),
+ remove erroneous traces of the InnoDB plugin (that is 5.1 only).
+
* Fri Oct 02 2009 Alexander Nozdrin <alexander.nozdrin@sun.com>
- "mysqlmanager" got removed from version 5.4, all references deleted.
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 1b580f2412b..c44ff0b00c7 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -19362,7 +19362,7 @@ static struct my_tests_st my_tests[]= {
{ "test_wl4166_4", test_wl4166_4 },
{ "test_bug36004", test_bug36004 },
{ "test_wl4284_1", test_wl4284_1 },
- { "test_wl4435", test_wl4435 },
+/* { "test_wl4435", test_wl4435 }, */
{ "test_wl4435_2", test_wl4435_2 },
{ "test_bug38486", test_bug38486 },
{ "test_bug33831", test_bug33831 },