summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitKeeper/etc/collapsed1
-rw-r--r--Makefile.am40
-rw-r--r--client/mysqlbinlog.cc19
-rw-r--r--client/mysqltest.c19
-rw-r--r--extra/yassl/src/ssl.cpp4
-rw-r--r--include/config-win.h1
-rw-r--r--include/my_global.h36
-rw-r--r--include/my_pthread.h81
-rw-r--r--include/mysql.h2
-rw-r--r--include/mysql_h.ic19
-rw-r--r--include/typelib.h3
-rw-r--r--mysql-test/lib/mtr_cases.pl7
-rw-r--r--mysql-test/lib/mtr_process.pl3
-rwxr-xr-xmysql-test/mysql-test-run.pl51
-rw-r--r--mysql-test/r/archive.result6
-rw-r--r--mysql-test/r/ctype_hebrew.result11
-rw-r--r--mysql-test/r/func_group.result267
-rw-r--r--mysql-test/r/func_in.result4
-rw-r--r--mysql-test/r/myisam.result15
-rw-r--r--mysql-test/r/sp.result16
-rw-r--r--mysql-test/r/symlink.result23
-rw-r--r--mysql-test/r/windows.result6
-rw-r--r--mysql-test/t/archive.test10
-rw-r--r--mysql-test/t/ctype_hebrew.test16
-rw-r--r--mysql-test/t/func_group.test92
-rw-r--r--mysql-test/t/func_in.test7
-rw-r--r--mysql-test/t/information_schema_chmod.test4
-rw-r--r--mysql-test/t/kill.test5
-rw-r--r--mysql-test/t/myisam.test40
-rw-r--r--mysql-test/t/mysqltest.test3
-rw-r--r--mysql-test/t/rpl_rotate_logs.test8
-rw-r--r--mysql-test/t/sp.test24
-rw-r--r--mysql-test/t/symlink.test41
-rw-r--r--mysql-test/t/trigger.test14
-rw-r--r--mysql-test/t/varbinary.test4
-rw-r--r--mysql-test/t/windows.test9
-rw-r--r--mysys/default.c10
-rw-r--r--mysys/my_wincond.c35
-rw-r--r--mysys/typelib.c51
-rw-r--r--scripts/make_binary_distribution.sh2
-rw-r--r--scripts/mysqlbug.sh8
-rw-r--r--scripts/mysqld_multi.sh18
-rw-r--r--scripts/mysqld_safe.sh1
-rw-r--r--scripts/mysqldumpslow.sh10
-rw-r--r--server-tools/instance-manager/guardian.cc5
-rw-r--r--server-tools/instance-manager/instance.cc5
-rw-r--r--sql/field.cc10
-rw-r--r--sql/field.h1
-rw-r--r--sql/item_sum.cc358
-rw-r--r--sql/item_sum.h20
-rw-r--r--sql/net_serv.cc5
-rw-r--r--sql/opt_range.cc3
-rw-r--r--sql/share/charsets/hebrew.xml4
-rw-r--r--sql/sql_parse.cc6
-rw-r--r--strings/conf_to_src.c9
-rw-r--r--strings/ctype-extra.c16
-rw-r--r--vio/viossl.c14
57 files changed, 1069 insertions, 433 deletions
diff --git a/BitKeeper/etc/collapsed b/BitKeeper/etc/collapsed
index 5ff033b2163..951d894c5b6 100644
--- a/BitKeeper/etc/collapsed
+++ b/BitKeeper/etc/collapsed
@@ -29,3 +29,4 @@
4554a95d7txO1DuO9G3nAizI3SkFAA
4554b3722d71SbPiI2Gx-RhbZjmuIQ
4558b3d73Cxjlb7Wv1oytdSTthxDfw
+45771031yRCoM_ZfONdYchPvVEgLRg
diff --git a/Makefile.am b/Makefile.am
index 53fac803498..5c6c6c9cfa6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -108,7 +108,11 @@ dist-hook:
tags:
support-files/build-tags
-.PHONY: init-db bin-dist
+
+.PHONY: init-db bin-dist \
+ test test-force test-full test-force-full test-force-mem \
+ test-pl test-force-pl test-full-pl test-force-full-pl test-force-pl-mem \
+ test-ps test-ns
# Target 'test' will run the regression test suite using the built server.
#
@@ -118,21 +122,33 @@ tags:
# will then calculate the various port numbers it needs from this,
# making sure each user use different ports.
-test:
+test-ps:
+ cd mysql-test ; \
+ @PERL@ ./mysql-test-run.pl $(force) --ps-protocol
+
+test-ns:
cd mysql-test ; \
- ./mysql-test-run && \
- ./mysql-test-run --ps-protocol
+ @PERL@ ./mysql-test-run.pl $(force)
+
+test: test-ns test-ps
+
+# To ease script-writing, although in 5.0 it is identical to 'test'
+test-full: test
test-force:
- cd mysql-test; \
- ./mysql-test-run --force && \
- ./mysql-test-run --ps-protocol --force
+ $(MAKE) force=--force test
-test-force-mem:
- cd mysql-test; \
- ./mysql-test-run --force --mem && \
- ./mysql-test-run --ps-protocol --force --mem
+test-force-full:
+ $(MAKE) force=--force test-full
#used by autopush.pl to run memory based tests
-
+test-force-mem:
+ $(MAKE) 'force=--force --mem' test
+
+# Keep these for a while
+test-pl: test
+test-full-pl: test-full
+test-force-pl: test-force
+test-force-pl-mem: test-force-mem
+test-force-full-pl: test-force-full
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index d4887f8c762..5c3377cdb65 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -1309,6 +1309,25 @@ static int dump_local_log_entries(const char* logname)
}
else // reading from stdin;
{
+ /*
+ Bug fix: #23735
+ Author: Chuck Bell
+ Description:
+ Windows opens stdin in text mode by default. Certain characters
+ such as CTRL-Z are interpeted as events and the read() method
+ will stop. CTRL-Z is the EOF marker in Windows. to get past this
+ you have to open stdin in binary mode. Setmode() is used to set
+ stdin in binary mode. Errors on setting this mode result in
+ halting the function and printing an error message to stderr.
+ */
+#if defined (__WIN__) || (_WIN64)
+ if (_setmode(fileno(stdin), O_BINARY) == -1)
+ {
+ fprintf(stderr, "Could not set binary mode on stdin.\n");
+ return 1;
+ }
+#endif
+
if (init_io_cache(file, fileno(stdin), 0, READ_CACHE, (my_off_t) 0,
0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE)))
return 1;
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 1ab063acaea..820606f9e3e 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -1245,7 +1245,9 @@ void var_set(const char *var_name, const char *var_name_end,
v->int_dirty= 0;
v->str_val_len= strlen(v->str_val);
}
- strxmov(buf, v->name, "=", v->str_val, NullS);
+ my_snprintf(buf, sizeof(buf), "%.*s=%.*s",
+ v->name_len, v->name,
+ v->str_val_len, v->str_val);
if (!(v->env_s= my_strdup(buf, MYF(MY_WME))))
die("Out of memory");
putenv(v->env_s);
@@ -2973,7 +2975,12 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host,
if ((mysql_errno(mysql) == CR_CONN_HOST_ERROR ||
mysql_errno(mysql) == CR_CONNECTION_ERROR) &&
failed_attempts < opt_max_connect_retries)
+ {
+ verbose_msg("Connect attempt %d/%d failed: %d: %s", failed_attempts,
+ opt_max_connect_retries, mysql_errno(mysql),
+ mysql_error(mysql));
my_sleep(connection_retry_sleep);
+ }
else
{
if (failed_attempts > 0)
@@ -4684,10 +4691,9 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
}
/*
- Store the result. If res is NULL, use mysql_field_count to
- determine if that was expected
+ Store the result of the query if it will return any fields
*/
- if (!(res= mysql_store_result(mysql)) && mysql_field_count(mysql))
+ if (mysql_field_count(mysql) && ((res= mysql_store_result(mysql)) == 0))
{
handle_error(command, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), ds);
@@ -4739,7 +4745,10 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
}
if (res)
+ {
mysql_free_result(res);
+ res= 0;
+ }
counter++;
} while (!(err= mysql_next_result(mysql)));
if (err > 0)
@@ -4806,7 +4815,7 @@ void handle_error(struct st_command *command,
err_errno, err_error);
/* Abort the run of this test, pass the failed query as reason */
- abort_not_supported_test("Query '%s' failed, required functionality" \
+ abort_not_supported_test("Query '%s' failed, required functionality " \
"not supported", command->query);
}
diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp
index ec2e99adecb..aa98465069c 100644
--- a/extra/yassl/src/ssl.cpp
+++ b/extra/yassl/src/ssl.cpp
@@ -122,7 +122,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password,
passwordSz, 1, key, iv);
- STL::auto_ptr<BulkCipher> cipher;
+ mySTL::auto_ptr<BulkCipher> cipher;
if (strncmp(info.name, "DES-CBC", 7) == 0)
cipher.reset(NEW_YS DES);
else if (strncmp(info.name, "DES-EDE3-CBC", 13) == 0)
@@ -138,7 +138,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
return SSL_BAD_FILE;
}
cipher->set_decryptKey(key, info.iv);
- STL::auto_ptr<x509> newx(NEW_YS x509(x->get_length()));
+ mySTL::auto_ptr<x509> newx(NEW_YS x509(x->get_length()));
cipher->decrypt(newx->use_buffer(), x->get_buffer(),
x->get_length());
ysDelete(x);
diff --git a/include/config-win.h b/include/config-win.h
index a9977ec955a..34e828e01e8 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -248,7 +248,6 @@ inline double ulonglong2double(ulonglong value)
#define tell(A) _telli64(A)
#endif
-#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; }
#define STACK_DIRECTION -1
diff --git a/include/my_global.h b/include/my_global.h
index 19ba37fd58b..b4b9908c97f 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1009,41 +1009,7 @@ typedef char bool; /* Ordinary boolean values 0 1 */
#define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
-#ifdef HAVE_TIMESPEC_TS_SEC
-#ifndef set_timespec
-#define set_timespec(ABSTIME,SEC) \
-{ \
- (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \
- (ABSTIME).ts_nsec=0; \
-}
-#endif /* !set_timespec */
-#ifndef set_timespec_nsec
-#define set_timespec_nsec(ABSTIME,NSEC) \
-{ \
- ulonglong now= my_getsystime() + (NSEC/100); \
- (ABSTIME).ts_sec= (now / ULL(10000000)); \
- (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
-}
-#endif /* !set_timespec_nsec */
-#else
-#ifndef set_timespec
-#define set_timespec(ABSTIME,SEC) \
-{\
- struct timeval tv;\
- gettimeofday(&tv,0);\
- (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
- (ABSTIME).tv_nsec=tv.tv_usec*1000;\
-}
-#endif /* !set_timespec */
-#ifndef set_timespec_nsec
-#define set_timespec_nsec(ABSTIME,NSEC) \
-{\
- ulonglong now= my_getsystime() + (NSEC/100); \
- (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \
- (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
-}
-#endif /* !set_timespec_nsec */
-#endif /* HAVE_TIMESPEC_TS_SEC */
+
/*
Define-funktions for reading and storing in machine independent format
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 90e1a758915..0922b3a35f1 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -68,14 +68,6 @@ typedef struct {
#endif
} pthread_cond_t;
-
-#ifndef OS2
-struct timespec { /* For pthread_cond_timedwait() */
- time_t tv_sec;
- long tv_nsec;
-};
-#endif
-
typedef int pthread_mutexattr_t;
#define win_pthread_self my_thread_var->pthread_self
#ifdef OS2
@@ -86,6 +78,36 @@ typedef void * (_Optlink *pthread_handler)(void *);
typedef void * (__cdecl *pthread_handler)(void *);
#endif
+/*
+ Struct and macros to be used in combination with the
+ windows implementation of pthread_cond_timedwait
+*/
+
+/*
+ Declare a union to make sure FILETIME is properly aligned
+ so it can be used directly as a 64 bit value. The value
+ stored is in 100ns units.
+ */
+ union ft64 {
+ FILETIME ft;
+ __int64 i64;
+ };
+struct timespec {
+ union ft64 tv;
+ /* The max timeout value in millisecond for pthread_cond_timedwait */
+ long max_timeout_msec;
+};
+#define set_timespec(ABSTIME,SEC) { \
+ GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \
+ (ABSTIME).tv.i64+= (__int64)(SEC)*10000000; \
+ (ABSTIME).max_timeout_msec= (long)((SEC)*1000); \
+}
+#define set_timespec_nsec(ABSTIME,NSEC) { \
+ GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \
+ (ABSTIME).tv.i64+= (__int64)(NSEC)/100; \
+ (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \
+}
+
void win_pthread_init(void);
int win_pthread_setspecific(void *A,void *B,uint length);
int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
@@ -163,8 +185,6 @@ extern int pthread_mutex_destroy (pthread_mutex_t *);
#define pthread_condattr_init(A)
#define pthread_condattr_destroy(A)
-/*Irena: compiler does not like this: */
-/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */
#define my_pthread_getprio(thread_id) pthread_dummy(0)
#elif defined(HAVE_UNIXWARE7_THREADS)
@@ -472,6 +492,47 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif
+/*
+ The defines set_timespec and set_timespec_nsec should be used
+ for calculating an absolute time at which
+ pthread_cond_timedwait should timeout
+*/
+#ifdef HAVE_TIMESPEC_TS_SEC
+#ifndef set_timespec
+#define set_timespec(ABSTIME,SEC) \
+{ \
+ (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \
+ (ABSTIME).ts_nsec=0; \
+}
+#endif /* !set_timespec */
+#ifndef set_timespec_nsec
+#define set_timespec_nsec(ABSTIME,NSEC) \
+{ \
+ ulonglong now= my_getsystime() + (NSEC/100); \
+ (ABSTIME).ts_sec= (now / ULL(10000000)); \
+ (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
+}
+#endif /* !set_timespec_nsec */
+#else
+#ifndef set_timespec
+#define set_timespec(ABSTIME,SEC) \
+{\
+ struct timeval tv;\
+ gettimeofday(&tv,0);\
+ (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
+ (ABSTIME).tv_nsec=tv.tv_usec*1000;\
+}
+#endif /* !set_timespec */
+#ifndef set_timespec_nsec
+#define set_timespec_nsec(ABSTIME,NSEC) \
+{\
+ ulonglong now= my_getsystime() + (NSEC/100); \
+ (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \
+ (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
+}
+#endif /* !set_timespec_nsec */
+#endif /* HAVE_TIMESPEC_TS_SEC */
+
/* safe_mutex adds checking to mutex for easier debugging */
#if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY)
diff --git a/include/mysql.h b/include/mysql.h
index fb2e4319b4c..c612bdf175a 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -64,9 +64,9 @@ typedef int my_socket;
#endif /* my_socket_defined */
#endif /* _global_h */
+#include "mysql_version.h"
#include "mysql_com.h"
#include "mysql_time.h"
-#include "mysql_version.h"
#include "typelib.h"
#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
diff --git a/include/mysql_h.ic b/include/mysql_h.ic
index 0e546acef92..5a9daee6f9f 100644
--- a/include/mysql_h.ic
+++ b/include/mysql_h.ic
@@ -36,6 +36,8 @@ enum mysql_status;
typedef struct st_mysql_rows MYSQL_ROWS;
# 24 "my_list.h"
typedef struct st_list LIST;
+# 35 "my_alloc.h"
+typedef struct st_mem_root MEM_ROOT;
# 251 "mysql.h"
typedef struct st_mysql MYSQL;
# 653 "mysql.h"
@@ -60,7 +62,7 @@ typedef struct st_mysql_stmt MYSQL_STMT;
typedef struct character_set MY_CHARSET_INFO;
# 180 "mysql_com.h"
typedef struct st_net NET;
-# 21 "typelib.h"
+# 23 "typelib.h"
typedef struct st_typelib TYPELIB;
# 170 "mysql_com.h"
typedef struct st_vio Vio;
@@ -76,8 +78,6 @@ typedef int my_socket;
typedef unsigned long long int my_ulonglong;
# 144 "mysql.h"
typedef struct embedded_query_result EMBEDDED_QUERY_RESULT;
-# 35 "my_alloc.h"
-typedef struct st_mem_root MEM_ROOT;
# 145 "mysql.h"
typedef struct st_mysql_data MYSQL_DATA;
# 750 "mysql.h"
@@ -419,7 +419,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
my_bool report_error;
my_bool return_errno;
};
-# 21 "typelib.h"
+# 23 "typelib.h"
struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_typelib
{
unsigned int count;
@@ -575,6 +575,7 @@ enum mysql_enum_shutdown_level
SHUTDOWN_WAIT_UPDATES = (unsigned char)((1 << 3)),
SHUTDOWN_WAIT_ALL_BUFFERS = ((unsigned char)((1 << 3)) << 1),
SHUTDOWN_WAIT_CRITICAL_BUFFERS = (((unsigned char)((1 << 3)) << 1) + 1),
+ KILL_QUERY = 254,
KILL_CONNECTION = 255,
};
# 154 "mysql.h"
@@ -630,9 +631,11 @@ enum mysql_status
extern my_bool check_scramble(char const * reply, char const * message, unsigned char const * hash_stage2);
# 416 "mysql_com.h"
extern my_bool check_scramble_323(char const *, char const * message, unsigned long int * salt);
+# 33 "typelib.h"
+extern TYPELIB * copy_typelib(MEM_ROOT * root, TYPELIB * from);
# 411 "mysql_com.h"
extern void create_random_string(char * to, unsigned int, struct rand_struct * rand_st);
-# 28 "typelib.h"
+# 30 "typelib.h"
extern int find_type(char * x, TYPELIB * typelib, unsigned int);
# 425 "mysql_com.h"
extern void get_salt_from_password(unsigned char * res, char const * password);
@@ -640,7 +643,7 @@ extern void get_salt_from_password(unsigned char * res, char const * password);
extern void get_salt_from_password_323(unsigned long int * res, char const * password);
# 431 "mysql_com.h"
extern char * get_tty_password(char * opt_message);
-# 30 "typelib.h"
+# 32 "typelib.h"
extern char const * get_type(TYPELIB * typelib, unsigned int);
# 413 "mysql_com.h"
extern void hash_password(unsigned long int * to, char const * password, unsigned int);
@@ -668,7 +671,7 @@ extern void make_password_from_salt_323(char * to, unsigned long int const * sal
extern void make_scrambled_password(char * to, char const * password);
# 414 "mysql_com.h"
extern void make_scrambled_password_323(char * to, char const * password);
-# 29 "typelib.h"
+# 31 "typelib.h"
extern void make_type(char * to, unsigned int, TYPELIB * typelib);
# 437 "mysql_com.h"
extern int modify_defaults_file(char const * file_location, char const * option, char const * option_value, char const * section_name, int);
@@ -962,5 +965,5 @@ extern void randominit(struct rand_struct *, unsigned long int, unsigned long in
extern void scramble(char * to, char const * message, char const * password);
# 415 "mysql_com.h"
extern void scramble_323(char * to, char const * message, char const * password);
-# 32 "typelib.h"
+# 35 "typelib.h"
extern TYPELIB sql_protocol_typelib;
diff --git a/include/typelib.h b/include/typelib.h
index 28554f739d3..75d170e59d3 100644
--- a/include/typelib.h
+++ b/include/typelib.h
@@ -17,6 +17,8 @@
#ifndef _typelib_h
#define _typelib_h
+#include "my_alloc.h"
+
typedef struct st_typelib { /* Different types saved here */
unsigned int count; /* How many types */
const char *name; /* Name of typelib */
@@ -27,6 +29,7 @@ typedef struct st_typelib { /* Different types saved here */
extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name);
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
+extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
extern TYPELIB sql_protocol_typelib;
diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
index 9e943fec9ef..a00d06d2e60 100644
--- a/mysql-test/lib/mtr_cases.pl
+++ b/mysql-test/lib/mtr_cases.pl
@@ -288,6 +288,7 @@ sub collect_one_test_case($$$$$$$) {
$tinfo->{'timezone'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work
$tinfo->{'slave_num'}= 0; # Default, no slave
+ $tinfo->{'master_num'}= 1; # Default, 1 master
if ( defined mtr_match_prefix($tname,"rpl") )
{
if ( $::opt_skip_rpl )
@@ -297,13 +298,8 @@ sub collect_one_test_case($$$$$$$) {
return;
}
-
$tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave
- if ( $tname eq 'rpl_failsafe' or $tname eq 'rpl_chain_temp_table' )
- {
- # $tinfo->{'slave_num'}= 3; # Not 3 ? Check old code, strange
- }
}
if ( defined mtr_match_prefix($tname,"federated") )
@@ -582,6 +578,7 @@ our @tags=
["include/have_debug.inc", "need_debug", 1],
["include/have_ndb.inc", "ndb_test", 1],
["include/have_ndb_extra.inc", "ndb_extra", 1],
+ ["include/have_multi_ndb.inc", "master_num", 2],
["require_manager", "require_manager", 1],
);
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index 330dfddf1d3..cf0e4c214ed 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -220,7 +220,8 @@ sub spawn_parent_impl {
my $ret_pid= waitpid($pid,0);
if ( $ret_pid != $pid )
{
- mtr_error("$path ($pid) got lost somehow");
+ mtr_error("waitpid($pid, 0) returned $ret_pid " .
+ "when waiting for '$path'");
}
return mtr_process_exit_status($?);
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 36f5b0a776f..41377982af5 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -231,10 +231,12 @@ our $opt_ndbconnectstring_slave;
our $opt_record;
my $opt_report_features;
our $opt_check_testcases;
+our $opt_mark_progress;
our $opt_skip;
our $opt_skip_rpl;
our $max_slave_num= 0;
+our $max_master_num= 1;
our $use_innodb;
our $opt_skip_test;
our $opt_skip_im;
@@ -413,6 +415,15 @@ sub main () {
$max_slave_num= $test->{slave_num};
mtr_error("Too many slaves") if $max_slave_num > 3;
}
+
+ # Count max number of masters used by a test case
+ if ( $test->{master_num} > $max_master_num)
+ {
+ $max_master_num= $test->{master_num};
+ mtr_error("Too many masters") if $max_master_num > 2;
+ mtr_error("Too few masters") if $max_master_num < 1;
+ }
+
$use_innodb||= $test->{'innodb_test'};
}
@@ -536,6 +547,7 @@ sub command_line_setup () {
# Test case authoring
'record' => \$opt_record,
'check-testcases' => \$opt_check_testcases,
+ 'mark-progress' => \$opt_mark_progress,
# Extra options used when starting mysqld
'mysqld=s' => \@opt_extra_mysqld_opt,
@@ -1211,6 +1223,19 @@ sub command_line_setup () {
$path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
$path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
+
+ if ( $opt_valgrind and $opt_debug )
+ {
+ # When both --valgrind and --debug is selected, send
+ # all output to the trace file, making it possible to
+ # see the exact location where valgrind complains
+ foreach my $mysqld (@{$master}, @{$slave})
+ {
+ my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : "";
+ $mysqld->{path_myerr}=
+ "$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace";
+ }
+ }
}
#
@@ -1259,9 +1284,10 @@ sub set_mtr_build_thread_ports($) {
sub datadir_list_setup () {
# Make a list of all data_dirs
- @data_dir_lst = (
- $master->[0]->{'path_myddir'},
- $master->[1]->{'path_myddir'});
+ for (my $idx= 0; $idx < $max_master_num; $idx++)
+ {
+ push(@data_dir_lst, $master->[$idx]->{'path_myddir'});
+ }
for (my $idx= 0; $idx < $max_slave_num; $idx++)
{
@@ -2730,8 +2756,10 @@ sub mysql_install_db () {
install_db('master', $master->[0]->{'path_myddir'});
- # FIXME check if testcase really is using second master
- copy_install_db('master', $master->[1]->{'path_myddir'});
+ if ($max_master_num)
+ {
+ copy_install_db('master', $master->[1]->{'path_myddir'});
+ }
# Install the number of slave databses needed
for (my $idx= 0; $idx < $max_slave_num; $idx++)
@@ -3533,11 +3561,10 @@ sub mysqld_arguments ($$$$$) {
if ( $glob_use_embedded_server )
{
$prefix= "--server-arg=";
- } else {
- # We can't pass embedded server --no-defaults
- mtr_add_arg($args, "--no-defaults");
}
+ mtr_add_arg($args, "%s--no-defaults", $prefix);
+
mtr_add_arg($args, "%s--console", $prefix);
mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir);
mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir);
@@ -4266,7 +4293,8 @@ sub run_testcase_start_servers($) {
}
- if ( $clusters->[0]->{'pid'} and ! $master->[1]->{'pid'} )
+ if ( $clusters->[0]->{'pid'} and ! $master->[1]->{'pid'} and
+ $tinfo->{'master_num'} > 1 )
{
# Test needs cluster, start an extra mysqld connected to cluster
@@ -4477,6 +4505,10 @@ sub run_mysqltest ($) {
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
+ # Log line number and time for each line in .test file
+ mtr_add_arg($args, "--mark-progress")
+ if $opt_mark_progress;
+
if ($tinfo->{'component_id'} eq 'im')
{
mtr_add_arg($args, "--socket=%s", $instance_manager->{'path_sock'});
@@ -4932,6 +4964,7 @@ Options for test case authoring
record TESTNAME (Re)genereate the result file for TESTNAME
check-testcases Check testcases for sideeffects
+ mark-progress Log line number and elapsed time to <testname>.progress
Options that pass on options
diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result
index 3be1cdcf15a..f73a80dde65 100644
--- a/mysql-test/r/archive.result
+++ b/mysql-test/r/archive.result
@@ -11120,7 +11120,13 @@ auto fld1 companynr fld3 fld4 fld5 fld6
2 011401 37 breaking dreaded Steinberg W
3 011402 37 Romans scholastics jarring
4 011403 37 intercepted audiology tinily
+SELECT COUNT(auto) FROM t2;
+COUNT(auto)
+1213
INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily','');
+SELECT COUNT(auto) FROM t2;
+COUNT(auto)
+1214
ALTER TABLE t2 DROP COLUMN fld6;
SHOW CREATE TABLE t2;
Table Create Table
diff --git a/mysql-test/r/ctype_hebrew.result b/mysql-test/r/ctype_hebrew.result
new file mode 100644
index 00000000000..d938b2e47f3
--- /dev/null
+++ b/mysql-test/r/ctype_hebrew.result
@@ -0,0 +1,11 @@
+DROP TABLE IF EXISTS t1;
+SET NAMES hebrew;
+CREATE TABLE t1 (a char(1)) DEFAULT CHARSET=hebrew;
+INSERT INTO t1 VALUES (0xFD),(0xFE);
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SELECT HEX(a) FROM t1;
+HEX(a)
+E2808E
+E2808F
+DROP TABLE t1;
+End of 4.1 tests
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 23517f7b603..d18837aed41 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -1029,6 +1029,273 @@ t1 CREATE TABLE `t1` (
`stddev(0)` double(8,4) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+create table bug22555 (i smallint primary key auto_increment, s1 smallint, s2 smallint, e decimal(30,10), o double);
+insert into bug22555 (s1, s2, e, o) values (53, 78, 11.4276528, 6.828112), (17, 78, 5.916793, 1.8502951), (18, 76, 2.679231, 9.17975591), (31, 62, 6.07831, 0.1), (19, 41, 5.37463, 15.1), (83, 73, 14.567426, 7.959222), (92, 53, 6.10151, 13.1856852), (7, 12, 13.92272, 3.442007), (92, 35, 11.95358909, 6.01376678), (38, 84, 2.572, 7.904571);
+select std(s1/s2) from bug22555 group by i;
+std(s1/s2)
+0.00000000
+0.00000000
+0.00000000
+0.00000000
+0.00000000
+0.00000000
+0.00000000
+0.00000000
+0.00000000
+0.00000000
+select std(e) from bug22555 group by i;
+std(e)
+0.00000000000000
+0.00000000000000
+0.00000000000000
+0.00000000000000
+0.00000000000000
+0.00000000000000
+0.00000000000000
+0.00000000000000
+0.00000000000000
+0.00000000000000
+select std(o) from bug22555 group by i;
+std(o)
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+drop table bug22555;
+create table bug22555 (i smallint, s1 smallint, s2 smallint, o1 double, o2 double, e1 decimal, e2 decimal);
+insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76);
+select i, count(*) from bug22555 group by i;
+i count(*)
+1 1
+2 1
+3 1
+select std(s1/s2) from bug22555 where i=1;
+std(s1/s2)
+0.00000000
+select std(s1/s2) from bug22555 where i=2;
+std(s1/s2)
+0.00000000
+select std(s1/s2) from bug22555 where i=3;
+std(s1/s2)
+0.00000000
+select std(s1/s2) from bug22555 where i=1 group by i;
+std(s1/s2)
+0.00000000
+select std(s1/s2) from bug22555 where i=2 group by i;
+std(s1/s2)
+0.00000000
+select std(s1/s2) from bug22555 where i=3 group by i;
+std(s1/s2)
+0.00000000
+select std(s1/s2) from bug22555 group by i order by i;
+std(s1/s2)
+0.00000000
+0.00000000
+0.00000000
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+i count(*) std(o1/o2)
+1 1 0
+2 1 0
+3 1 0
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+i count(*) std(e1/e2)
+1 1 0.00000000
+2 1 0.00000000
+3 1 0.00000000
+set @saved_div_precision_increment=@@div_precision_increment;
+set div_precision_increment=19;
+select i, count(*), variance(s1/s2) from bug22555 group by i order by i;
+i count(*) variance(s1/s2)
+1 1 0.000000000000000000000000000000
+2 1 0.000000000000000000000000000000
+3 1 0.000000000000000000000000000000
+select i, count(*), variance(o1/o2) from bug22555 group by i order by i;
+i count(*) variance(o1/o2)
+1 1 0
+2 1 0
+3 1 0
+select i, count(*), variance(e1/e2) from bug22555 group by i order by i;
+i count(*) variance(e1/e2)
+1 1 0.000000000000000000000000000000
+2 1 0.000000000000000000000000000000
+3 1 0.000000000000000000000000000000
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+i count(*) std(s1/s2)
+1 1 0.000000000000000000000000000000
+2 1 0.000000000000000000000000000000
+3 1 0.000000000000000000000000000000
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+i count(*) std(o1/o2)
+1 1 0
+2 1 0
+3 1 0
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+i count(*) std(e1/e2)
+1 1 0.000000000000000000000000000000
+2 1 0.000000000000000000000000000000
+3 1 0.000000000000000000000000000000
+set div_precision_increment=20;
+select i, count(*), variance(s1/s2) from bug22555 group by i order by i;
+i count(*) variance(s1/s2)
+1 1 0.000000000000000000000000000000
+2 1 0.000000000000000000000000000000
+3 1 0.000000000000000000000000000000
+select i, count(*), variance(o1/o2) from bug22555 group by i order by i;
+i count(*) variance(o1/o2)
+1 1 0
+2 1 0
+3 1 0
+select i, count(*), variance(e1/e2) from bug22555 group by i order by i;
+i count(*) variance(e1/e2)
+1 1 0.000000000000000000000000000000
+2 1 0.000000000000000000000000000000
+3 1 0.000000000000000000000000000000
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+i count(*) std(s1/s2)
+1 1 0.000000000000000000000000000000
+2 1 0.000000000000000000000000000000
+3 1 0.000000000000000000000000000000
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+i count(*) std(o1/o2)
+1 1 0
+2 1 0
+3 1 0
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+i count(*) std(e1/e2)
+1 1 0.000000000000000000000000000000
+2 1 0.000000000000000000000000000000
+3 1 0.000000000000000000000000000000
+set @@div_precision_increment=@saved_div_precision_increment;
+insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76);
+insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76);
+insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76);
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+i count(*) std(s1/s2)
+1 4 0.00000000
+2 4 0.00000000
+3 4 0.00000000
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+i count(*) std(o1/o2)
+1 4 0
+2 4 0
+3 4 0
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+i count(*) std(e1/e2)
+1 4 0.00000000
+2 4 0.00000000
+3 4 0.00000000
+select std(s1/s2) from bug22555;
+std(s1/s2)
+0.21325764
+select std(o1/o2) from bug22555;
+std(o1/o2)
+0.21325763586649
+select std(e1/e2) from bug22555;
+std(e1/e2)
+0.21325764
+set @saved_div_precision_increment=@@div_precision_increment;
+set div_precision_increment=19;
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+i count(*) std(s1/s2)
+1 4 0.000000000000000000000000000000
+2 4 0.000000000000000000000000000000
+3 4 0.000000000000000000000000000000
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+i count(*) std(o1/o2)
+1 4 0
+2 4 0
+3 4 0
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+i count(*) std(e1/e2)
+1 4 0.000000000000000000000000000000
+2 4 0.000000000000000000000000000000
+3 4 0.000000000000000000000000000000
+select round(std(s1/s2), 17) from bug22555;
+round(std(s1/s2), 17)
+0.21325763586649341
+select std(o1/o2) from bug22555;
+std(o1/o2)
+0.21325763586649
+select round(std(e1/e2), 17) from bug22555;
+round(std(e1/e2), 17)
+0.21325763586649341
+set div_precision_increment=20;
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+i count(*) std(s1/s2)
+1 4 0.000000000000000000000000000000
+2 4 0.000000000000000000000000000000
+3 4 0.000000000000000000000000000000
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+i count(*) std(o1/o2)
+1 4 0
+2 4 0
+3 4 0
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+i count(*) std(e1/e2)
+1 4 0.000000000000000000000000000000
+2 4 0.000000000000000000000000000000
+3 4 0.000000000000000000000000000000
+select round(std(s1/s2), 17) from bug22555;
+round(std(s1/s2), 17)
+0.21325763586649341
+select std(o1/o2) from bug22555;
+std(o1/o2)
+0.21325763586649
+select round(std(e1/e2), 17) from bug22555;
+round(std(e1/e2), 17)
+0.21325763586649341
+set @@div_precision_increment=@saved_div_precision_increment;
+drop table bug22555;
+create table bug22555 (s smallint, o double, e decimal);
+insert into bug22555 values (1,1,1),(2,2,2),(3,3,3),(6,6,6),(7,7,7);
+select var_samp(s), var_pop(s) from bug22555;
+var_samp(s) var_pop(s)
+6.7000 5.3600
+select var_samp(o), var_pop(o) from bug22555;
+var_samp(o) var_pop(o)
+6.7 5.36
+select var_samp(e), var_pop(e) from bug22555;
+var_samp(e) var_pop(e)
+6.7000 5.3600
+drop table bug22555;
+create table bug22555 (s smallint, o double, e decimal);
+insert into bug22555 values (null,null,null),(null,null,null);
+select var_samp(s) as 'null', var_pop(s) as 'null' from bug22555;
+null null
+NULL NULL
+select var_samp(o) as 'null', var_pop(o) as 'null' from bug22555;
+null null
+NULL NULL
+select var_samp(e) as 'null', var_pop(e) as 'null' from bug22555;
+null null
+NULL NULL
+insert into bug22555 values (1,1,1);
+select var_samp(s) as 'null', var_pop(s) as '0' from bug22555;
+null 0
+NULL 0.0000
+select var_samp(o) as 'null', var_pop(o) as '0' from bug22555;
+null 0
+NULL 0
+select var_samp(e) as 'null', var_pop(e) as '0' from bug22555;
+null 0
+NULL 0.0000
+insert into bug22555 values (2,2,2);
+select var_samp(s) as '0.5', var_pop(s) as '0.25' from bug22555;
+0.5 0.25
+0.5000 0.2500
+select var_samp(o) as '0.5', var_pop(o) as '0.25' from bug22555;
+0.5 0.25
+0.5 0.25
+select var_samp(e) as '0.5', var_pop(e) as '0.25' from bug22555;
+0.5 0.25
+0.5000 0.2500
+drop table bug22555;
CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
INSERT INTO t1 SELECT a, b+8 FROM t1;
diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result
index a172d04d880..38250173dd1 100644
--- a/mysql-test/r/func_in.result
+++ b/mysql-test/r/func_in.result
@@ -350,5 +350,9 @@ select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
some_id
1
2
+select some_id from t1 where some_id not in('-1', '0');
+some_id
+1
+2
drop table t1;
End of 5.0 tests
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 2ea317754ec..3ed2d10c9c9 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -922,6 +922,7 @@ SET @@myisam_repair_threads=1;
SHOW VARIABLES LIKE 'myisam_repair%';
Variable_name Value
myisam_repair_threads 1
+End of 4.1 tests
set storage_engine=MyISAM;
drop table if exists t1,t2,t3;
--- Testing varchar ---
@@ -1608,16 +1609,4 @@ create table t3 (c1 int) engine=myisam pack_keys=default;
create table t4 (c1 int) engine=myisam pack_keys=2;
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 '2' at line 1
drop table t1, t2, t3;
-show create table t1;
-show create table t1;
-create table t1 (a int) engine=myisam select 42 a;
-select * from t1;
-a
-9
-select * from t1;
-a
-99
-select * from t1;
-a
-42
-drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 9db4325aea2..793abb417fb 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -5708,4 +5708,20 @@ DROP TABLE bug23760, bug23760_log|
DROP PROCEDURE bug23760_update_log|
DROP PROCEDURE bug23760_test_row_count|
DROP FUNCTION bug23760_rc_test|
+DROP PROCEDURE IF EXISTS bug24117|
+DROP TABLE IF EXISTS t3|
+CREATE TABLE t3(c1 ENUM('abc'))|
+INSERT INTO t3 VALUES('abc')|
+CREATE PROCEDURE bug24117()
+BEGIN
+DECLARE t3c1 ENUM('abc');
+DECLARE mycursor CURSOR FOR SELECT c1 FROM t3;
+OPEN mycursor;
+FLUSH TABLES;
+FETCH mycursor INTO t3c1;
+CLOSE mycursor;
+END|
+CALL bug24117()|
+DROP PROCEDURE bug24117|
+DROP TABLE t3|
drop table t1,t2;
diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result
index 272836c450a..4725bcc0ac9 100644
--- a/mysql-test/r/symlink.result
+++ b/mysql-test/r/symlink.result
@@ -111,3 +111,26 @@ t1 CREATE TABLE `t1` (
`i` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+show create table t1;
+Table Create Table
+t1 CREATE TEMPORARY TABLE `t1` (
+ `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/'
+show create table t1;
+Table Create Table
+t1 CREATE TEMPORARY TABLE `t1` (
+ `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/'
+create table t1 (a int) engine=myisam select 42 a;
+select * from t1;
+a
+9
+select * from t1;
+a
+99
+select * from t1;
+a
+42
+drop table t1;
+End of 4.1 tests
+End of 5.0 tests
diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result
index 039c5b1476e..1702fd28c18 100644
--- a/mysql-test/r/windows.result
+++ b/mysql-test/r/windows.result
@@ -6,3 +6,9 @@ use prn;
ERROR 42000: Unknown database 'prn'
create table nu (a int);
drop table nu;
+drop table if exists t1;
+CREATE TABLE t1 ( `ID` int(6) ) data directory 'c:/tmp/' index directory 'c:/tmp/' engine=MyISAM;
+Warnings:
+Warning 0 DATA DIRECTORY option ignored
+Warning 0 INDEX DIRECTORY option ignored
+drop table t1;
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index f712a770712..80533f21311 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -1345,10 +1345,14 @@ SELECT * FROM t2;
CHECK TABLE t2;
SELECT * FROM t2;
-
-# Just test syntax, we will never know if the output is right or wrong
-# Must be the last test
+# Test INSERT DELAYED and wait until the table has one more record
+SELECT COUNT(auto) FROM t2;
INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily','');
+while (`SELECT COUNT(auto)!=1214 FROM t2`)
+{
+ sleep 0.1;
+}
+SELECT COUNT(auto) FROM t2;
# Adding test for alter table
ALTER TABLE t2 DROP COLUMN fld6;
diff --git a/mysql-test/t/ctype_hebrew.test b/mysql-test/t/ctype_hebrew.test
new file mode 100644
index 00000000000..f786d05141d
--- /dev/null
+++ b/mysql-test/t/ctype_hebrew.test
@@ -0,0 +1,16 @@
+#
+# BUG #24037: Lossy Hebrew to Unicode conversion
+#
+# Test if LRM and RLM characters are correctly converted to UTF-8
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+SET NAMES hebrew;
+CREATE TABLE t1 (a char(1)) DEFAULT CHARSET=hebrew;
+INSERT INTO t1 VALUES (0xFD),(0xFE);
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+--echo End of 4.1 tests
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index bccd4d9e762..a3b3fceaec5 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -702,6 +702,97 @@ create table t1 select stddev(0);
show create table t1;
drop table t1;
+
+#
+# Bug#22555: STDDEV yields positive result for groups with only one row
+#
+
+create table bug22555 (i smallint primary key auto_increment, s1 smallint, s2 smallint, e decimal(30,10), o double);
+insert into bug22555 (s1, s2, e, o) values (53, 78, 11.4276528, 6.828112), (17, 78, 5.916793, 1.8502951), (18, 76, 2.679231, 9.17975591), (31, 62, 6.07831, 0.1), (19, 41, 5.37463, 15.1), (83, 73, 14.567426, 7.959222), (92, 53, 6.10151, 13.1856852), (7, 12, 13.92272, 3.442007), (92, 35, 11.95358909, 6.01376678), (38, 84, 2.572, 7.904571);
+select std(s1/s2) from bug22555 group by i;
+select std(e) from bug22555 group by i;
+select std(o) from bug22555 group by i;
+drop table bug22555;
+
+create table bug22555 (i smallint, s1 smallint, s2 smallint, o1 double, o2 double, e1 decimal, e2 decimal);
+insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76);
+select i, count(*) from bug22555 group by i;
+select std(s1/s2) from bug22555 where i=1;
+select std(s1/s2) from bug22555 where i=2;
+select std(s1/s2) from bug22555 where i=3;
+select std(s1/s2) from bug22555 where i=1 group by i;
+select std(s1/s2) from bug22555 where i=2 group by i;
+select std(s1/s2) from bug22555 where i=3 group by i;
+select std(s1/s2) from bug22555 group by i order by i;
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+set @saved_div_precision_increment=@@div_precision_increment;
+set div_precision_increment=19;
+select i, count(*), variance(s1/s2) from bug22555 group by i order by i;
+select i, count(*), variance(o1/o2) from bug22555 group by i order by i;
+select i, count(*), variance(e1/e2) from bug22555 group by i order by i;
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+set div_precision_increment=20;
+select i, count(*), variance(s1/s2) from bug22555 group by i order by i;
+select i, count(*), variance(o1/o2) from bug22555 group by i order by i;
+select i, count(*), variance(e1/e2) from bug22555 group by i order by i;
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+set @@div_precision_increment=@saved_div_precision_increment;
+insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76);
+insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76);
+insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76);
+
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+select std(s1/s2) from bug22555;
+select std(o1/o2) from bug22555;
+select std(e1/e2) from bug22555;
+set @saved_div_precision_increment=@@div_precision_increment;
+set div_precision_increment=19;
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+select round(std(s1/s2), 17) from bug22555;
+select std(o1/o2) from bug22555;
+select round(std(e1/e2), 17) from bug22555;
+set div_precision_increment=20;
+select i, count(*), std(s1/s2) from bug22555 group by i order by i;
+select i, count(*), std(o1/o2) from bug22555 group by i order by i;
+select i, count(*), std(e1/e2) from bug22555 group by i order by i;
+select round(std(s1/s2), 17) from bug22555;
+select std(o1/o2) from bug22555;
+select round(std(e1/e2), 17) from bug22555;
+set @@div_precision_increment=@saved_div_precision_increment;
+drop table bug22555;
+
+create table bug22555 (s smallint, o double, e decimal);
+insert into bug22555 values (1,1,1),(2,2,2),(3,3,3),(6,6,6),(7,7,7);
+select var_samp(s), var_pop(s) from bug22555;
+select var_samp(o), var_pop(o) from bug22555;
+select var_samp(e), var_pop(e) from bug22555;
+drop table bug22555;
+
+create table bug22555 (s smallint, o double, e decimal);
+insert into bug22555 values (null,null,null),(null,null,null);
+select var_samp(s) as 'null', var_pop(s) as 'null' from bug22555;
+select var_samp(o) as 'null', var_pop(o) as 'null' from bug22555;
+select var_samp(e) as 'null', var_pop(e) as 'null' from bug22555;
+insert into bug22555 values (1,1,1);
+select var_samp(s) as 'null', var_pop(s) as '0' from bug22555;
+select var_samp(o) as 'null', var_pop(o) as '0' from bug22555;
+select var_samp(e) as 'null', var_pop(e) as '0' from bug22555;
+insert into bug22555 values (2,2,2);
+select var_samp(s) as '0.5', var_pop(s) as '0.25' from bug22555;
+select var_samp(o) as '0.5', var_pop(o) as '0.25' from bug22555;
+select var_samp(e) as '0.5', var_pop(e) as '0.25' from bug22555;
+drop table bug22555;
+
+
#
# Bug #23184: SELECT causes server crash
#
@@ -726,4 +817,5 @@ SELECT a,AVG(DISTINCT b) AS average FROM t1 GROUP BY a HAVING average > 50;
DROP TABLE t1;
+###
--echo End of 5.0 tests
diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test
index d48606ac6e6..86b0268f008 100644
--- a/mysql-test/t/func_in.test
+++ b/mysql-test/t/func_in.test
@@ -252,6 +252,13 @@ insert into t1 values (1),(2);
select some_id from t1 where some_id not in(2,-1);
select some_id from t1 where some_id not in(-4,-1,-4);
select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
+
+#
+# BUG#24261: crash when WHERE contains NOT IN ('<negative value>') for unsigned column type
+#
+
+select some_id from t1 where some_id not in('-1', '0');
+
drop table t1;
diff --git a/mysql-test/t/information_schema_chmod.test b/mysql-test/t/information_schema_chmod.test
index c7ea2b03890..38586ab8b67 100644
--- a/mysql-test/t/information_schema_chmod.test
+++ b/mysql-test/t/information_schema_chmod.test
@@ -17,7 +17,7 @@
#
create database mysqltest;
create table mysqltest.t1(a int);
---exec chmod -r $MYSQLTEST_VARDIR/master-data/mysqltest
+chmod 0000 $MYSQLTEST_VARDIR/master-data/mysqltest;
select table_schema from information_schema.tables where table_schema='mysqltest';
---exec chmod +r $MYSQLTEST_VARDIR/master-data/mysqltest
+exec chmod 0777 $MYSQLTEST_VARDIR/master-data/mysqltest;
drop database mysqltest;
diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test
index f8ba649b3eb..1e99911a7e3 100644
--- a/mysql-test/t/kill.test
+++ b/mysql-test/t/kill.test
@@ -76,11 +76,14 @@ insert into t2 select id from t1;
create table t3 (kill_id int);
insert into t3 values(connection_id());
+connect (conn2, localhost, root,,);
+connection conn2;
+
+connection conn1;
-- disable_result_log
send select id from t1 where id in (select distinct id from t2);
-- enable_result_log
-connect (conn2, localhost, root,,);
connection conn2;
select ((@id := kill_id) - kill_id) from t3;
-- sleep 1
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index d785002abdd..2b498704512 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -846,6 +846,10 @@ DROP TABLE t1;
#
SET @@myisam_repair_threads=1;
SHOW VARIABLES LIKE 'myisam_repair%';
+
+--echo End of 4.1 tests
+
+
# Test varchar
#
@@ -969,39 +973,5 @@ create table t3 (c1 int) engine=myisam pack_keys=default;
--error 1064
create table t4 (c1 int) engine=myisam pack_keys=2;
drop table t1, t2, t3;
-#
-# Bug#8706 - temporary table with data directory option fails
-#
-connect (session1,localhost,root,,);
-connect (session2,localhost,root,,);
-
-connection session1;
-disable_query_log;
-eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" select 9 a;
-enable_query_log;
-disable_result_log;
-show create table t1;
-enable_result_log;
-
-connection session2;
-disable_query_log;
-eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" select 99 a;
-enable_query_log;
-disable_result_log;
-show create table t1;
-enable_result_log;
-
-connection default;
-create table t1 (a int) engine=myisam select 42 a;
-
-connection session1;
-select * from t1;
-disconnect session1;
-connection session2;
-select * from t1;
-disconnect session2;
-connection default;
-select * from t1;
-drop table t1;
-# End of 4.1 tests
+--echo End of 5.0 tests
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index c06d51d9d49..7da84543e6d 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -1,6 +1,9 @@
# This test should work in embedded server after mysqltest is fixed
-- source include/not_embedded.inc
+# This test uses chmod, can't be run with root permissions
+-- source include/not_as_root.inc
+
# ============================================================================
#
# Test of mysqltest itself
diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test
index ee49f92910a..39a810aa021 100644
--- a/mysql-test/t/rpl_rotate_logs.test
+++ b/mysql-test/t/rpl_rotate_logs.test
@@ -17,8 +17,10 @@ connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
drop table if exists t1, t2, t3, t4;
--enable_warnings
connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
-system cat /dev/null > $MYSQLTEST_VARDIR/slave-data/master.info;
-system chmod 000 $MYSQLTEST_VARDIR/slave-data/master.info;
+# Create empty file
+write_file $MYSQLTEST_VARDIR/slave-data/master.info;
+EOF
+chmod 0000 $MYSQLTEST_VARDIR/slave-data/master.info;
connection slave;
--disable_warnings
drop table if exists t1, t2, t3, t4;
@@ -29,7 +31,7 @@ drop table if exists t1, t2, t3, t4;
--replace_result $MYSQL_TEST_DIR TESTDIR
--error 1105,1105,29
start slave;
-system chmod 600 $MYSQLTEST_VARDIR/slave-data/master.info;
+chmod 0600 $MYSQLTEST_VARDIR/slave-data/master.info;
# It will fail again because the file is empty so the slave cannot get valuable
# info about how to connect to the master from it (failure in
# init_strvar_from_file() in init_master_info()).
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 524ee9cf66c..95bb9f7c376 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -6663,6 +6663,30 @@ DROP PROCEDURE bug23760_test_row_count|
DROP FUNCTION bug23760_rc_test|
#
+# BUG#24117: server crash on a FETCH with a cursor on a table which is not in
+# the table cache
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug24117|
+DROP TABLE IF EXISTS t3|
+--enable_warnings
+CREATE TABLE t3(c1 ENUM('abc'))|
+INSERT INTO t3 VALUES('abc')|
+CREATE PROCEDURE bug24117()
+BEGIN
+ DECLARE t3c1 ENUM('abc');
+ DECLARE mycursor CURSOR FOR SELECT c1 FROM t3;
+ OPEN mycursor;
+ FLUSH TABLES;
+ FETCH mycursor INTO t3c1;
+ CLOSE mycursor;
+END|
+CALL bug24117()|
+DROP PROCEDURE bug24117|
+DROP TABLE t3|
+
+#
# NOTE: The delimiter is `|`, and not `;`. It is changed to `;`
# at the end of the file!
#
diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test
index 19a720a4fb8..d79b6905224 100644
--- a/mysql-test/t/symlink.test
+++ b/mysql-test/t/symlink.test
@@ -139,4 +139,43 @@ enable_query_log;
show create table t1;
drop table t1;
-# End of 4.1 tests
+#
+# Bug#8706 - temporary table with data directory option fails
+#
+connect (session1,localhost,root,,);
+connect (session2,localhost,root,,);
+
+connection session1;
+disable_query_log;
+eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 9 a;
+enable_query_log;
+# If running test suite with a non standard tmp dir, the "show create table"
+# will print "DATA_DIRECTORY=". Use replace_result to mask it out
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+show create table t1;
+
+connection session2;
+disable_query_log;
+eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 99 a;
+enable_query_log;
+# If running test suite with a non standard tmp dir, the "show create table"
+# will print "DATA_DIRECTORY=". Use replace_result to mask it out
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+show create table t1;
+
+connection default;
+create table t1 (a int) engine=myisam select 42 a;
+
+connection session1;
+select * from t1;
+disconnect session1;
+connection session2;
+select * from t1;
+disconnect session2;
+connection default;
+select * from t1;
+drop table t1;
+
+--echo End of 4.1 tests
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index a9395c12a63..2bb2292e5b8 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -1,3 +1,7 @@
+# This test uses chmod, can't be run with root permissions
+-- source include/not_as_root.inc
+
+
#
# Basic triggers test
#
@@ -1138,8 +1142,10 @@ select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
# Trick which makes update of second .TRN file impossible
-system echo dummy >$MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
-system chmod 000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
+write_file $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
+dummy
+EOF
+chmod 0000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
--error 1
rename table t1 to t2;
# 't1' should be still there and triggers should work correctly
@@ -1148,8 +1154,8 @@ select @a, @b;
select trigger_schema, trigger_name, event_object_schema,
event_object_table, action_statement from information_schema.triggers
where event_object_schema = 'test';
-system chmod 600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
+chmod 0600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
+remove_file $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~;
# Let us check that updates to .TRN files were rolled back too
drop trigger t1_bi;
drop trigger t1_ai;
diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test
index 0e45bfb5e1b..2f0c1c83e84 100644
--- a/mysql-test/t/varbinary.test
+++ b/mysql-test/t/varbinary.test
@@ -1,3 +1,7 @@
+# This test uses chmod, can't be run with root permissions
+-- source include/not_as_root.inc
+
+
# Initialise
--disable_warnings
drop table if exists t1;
diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test
index d6bcfeb8cb3..b5377a9b9b0 100644
--- a/mysql-test/t/windows.test
+++ b/mysql-test/t/windows.test
@@ -17,4 +17,13 @@ use prn;
create table nu (a int);
drop table nu;
+#
+# Bug17489: ailed to put data file in custom directory use "data directory" option
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+CREATE TABLE t1 ( `ID` int(6) ) data directory 'c:/tmp/' index directory 'c:/tmp/' engine=MyISAM;
+drop table t1;
+
# End of 4.1 tests
diff --git a/mysys/default.c b/mysys/default.c
index 97c52d01031..12cd1713c31 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -978,10 +978,11 @@ static uint my_get_system_windows_directory(char *buffer, uint size)
Everywhere else, this is:
1. /etc/
- 2. getenv(DEFAULT_HOME_ENV)
- 3. ""
- 4. "~/"
- 5. --sysconfdir=<path>
+ 2. /etc/mysql/
+ 3. getenv(DEFAULT_HOME_ENV)
+ 4. ""
+ 5. "~/"
+ 6. --sysconfdir=<path>
*/
@@ -1007,6 +1008,7 @@ static void init_default_directories()
*ptr++= env;
#endif
*ptr++= "/etc/";
+ *ptr++= "/etc/mysql/";
#endif
if ((env= getenv(STRINGIFY_ARG(DEFAULT_HOME_ENV))))
*ptr++= env;
diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c
index 560d1788ae0..ed8b715cb85 100644
--- a/mysys/my_wincond.c
+++ b/mysys/my_wincond.c
@@ -36,7 +36,7 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
int pthread_cond_destroy(pthread_cond_t *cond)
{
- return CloseHandle(cond->semaphore) ? 0 : EINVAL;
+ return CloseHandle(cond->semaphore) ? 0 : EINVAL;
}
@@ -50,20 +50,37 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
return 0 ;
}
+
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
struct timespec *abstime)
{
- struct _timeb curtime;
int result;
- long timeout;
- _ftime(&curtime);
- timeout= ((long) (abstime->tv_sec - curtime.time)*1000L +
- (long)((abstime->tv_nsec/1000) - curtime.millitm)/1000L);
- if (timeout < 0) /* Some safety */
- timeout = 0L;
+ long timeout;
+ union ft64 now;
+
+ GetSystemTimeAsFileTime(&now.ft);
+
+ /*
+ Calculate time left to abstime
+ - subtract start time from current time(values are in 100ns units)
+ - convert to millisec by dividing with 10000
+ */
+ timeout= (long)((abstime->tv.i64 - now.i64) / 10000);
+
+ /* Don't allow the timeout to be negative */
+ if (timeout < 0)
+ timeout= 0L;
+
+ /*
+ Make sure the calucated timeout does not exceed original timeout
+ value which could cause "wait for ever" if system time changes
+ */
+ if (timeout > abstime->max_timeout_msec)
+ timeout= abstime->max_timeout_msec;
+
InterlockedIncrement(&cond->waiting);
LeaveCriticalSection(mutex);
- result=WaitForSingleObject(cond->semaphore,timeout);
+ result= WaitForSingleObject(cond->semaphore,timeout);
InterlockedDecrement(&cond->waiting);
EnterCriticalSection(mutex);
diff --git a/mysys/typelib.c b/mysys/typelib.c
index 95bd16cfefd..4fab6f20493 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -118,3 +118,54 @@ const char *get_type(TYPELIB *typelib, uint nr)
return(typelib->type_names[nr]);
return "?";
}
+
+
+/*
+ Create a copy of a specified TYPELIB structure.
+
+ SYNOPSIS
+ copy_typelib()
+ root pointer to a MEM_ROOT object for allocations
+ from pointer to a source TYPELIB structure
+
+ RETURN
+ pointer to the new TYPELIB structure on successful copy, or
+ NULL otherwise
+*/
+
+TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from)
+{
+ TYPELIB *to;
+ uint i;
+
+ if (!from)
+ return NULL;
+
+ if (!(to= (TYPELIB*) alloc_root(root, sizeof(TYPELIB))))
+ return NULL;
+
+ if (!(to->type_names= (const char **)
+ alloc_root(root, (sizeof(char *) + sizeof(int)) * (from->count + 1))))
+ return NULL;
+ to->type_lengths= (unsigned int *)(to->type_names + from->count + 1);
+ to->count= from->count;
+ if (from->name)
+ {
+ if (!(to->name= strdup_root(root, from->name)))
+ return NULL;
+ }
+ else
+ to->name= NULL;
+
+ for (i= 0; i < from->count; i++)
+ {
+ if (!(to->type_names[i]= strmake_root(root, from->type_names[i],
+ from->type_lengths[i])))
+ return NULL;
+ to->type_lengths[i]= from->type_lengths[i];
+ }
+ to->type_names[to->count]= NULL;
+ to->type_lengths[to->count]= 0;
+
+ return to;
+}
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index 9469cca875d..90ce1c6269f 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -246,7 +246,7 @@ $CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
mysql-test/std_data/*.MYD mysql-test/std_data/*.MYI \
mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \
mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \
- mysql-test/std_data/*.cnf \
+ mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \
$BASE/mysql-test/std_data
$CP mysql-test/t/*.test mysql-test/t/*.imtest \
mysql-test/t/*.disabled mysql-test/t/*.opt \
diff --git a/scripts/mysqlbug.sh b/scripts/mysqlbug.sh
index 6aed140b79d..880ab248a90 100644
--- a/scripts/mysqlbug.sh
+++ b/scripts/mysqlbug.sh
@@ -132,7 +132,13 @@ if test -z "$VISUAL"
then
if test -z "$EDITOR"
then
- EDIT=emacs
+ # Honor debian sensible-editor
+ if test -x "/usr/bin/sensible-editor"
+ then
+ EDIT=/usr/bin/sensible-editor
+ else
+ EDIT=emacs
+ fi
else
EDIT="$EDITOR"
fi
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index 12758ae8290..91afe49b46b 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -472,6 +472,14 @@ sub find_groups
{
$data[$i] = $line;
}
+ if (-f "/etc/mysql/my.cnf" && -r "/etc/mysql/my.cnf")
+ {
+ open(MY_CNF, "</etc/mysql/my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
+ }
+ for (; ($line = shift @tmp); $i++)
+ {
+ $data[$i] = $line;
+ }
if (defined($ENV{MYSQL_HOME}) && -f "$ENV{MYSQL_HOME}/my.cnf" &&
-r "$ENV{MYSQL_HOME}/my.cnf")
{
@@ -482,6 +490,14 @@ sub find_groups
{
$data[$i] = $line;
}
+ if (-f "/etc/mysql/my.cnf" && -r "/etc/mysql/my.cnf")
+ {
+ open(MY_CNF, "</etc/mysql/my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
+ }
+ for (; ($line = shift @tmp); $i++)
+ {
+ $data[$i] = $line;
+ }
if (-f "$homedir/.my.cnf" && -r "$homedir/.my.cnf")
{
open(MY_CNF, "<$homedir/.my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
@@ -491,7 +507,7 @@ sub find_groups
$data[$i] = $line;
}
}
- chop @data;
+ chomp @data;
# Make a list of the wanted group ids
if (defined($raw_gids))
{
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index 02a961dc3ec..52fe282f916 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -211,6 +211,7 @@ if [ ! -d $mysql_unix_port_dir ]
then
mkdir $mysql_unix_port_dir
chown $user $mysql_unix_port_dir
+ chmod 755 $mysql_unix_port_dir
fi
# Use the mysqld-max binary by default if the user doesn't specify a binary
diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh
index ccb006f692d..ff82a35ec3f 100644
--- a/scripts/mysqldumpslow.sh
+++ b/scripts/mysqldumpslow.sh
@@ -40,6 +40,7 @@ unless (@ARGV) {
warn "basedir=$basedir\n" if $opt{v};
my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
+ my $slowlog = ($defaults =~ m/--log-slow-queries=(.*)/)[0];
if (!$datadir or $opt{i}) {
# determine the datadir from the instances section of /etc/my.cnf, if any
my $instances = `my_print_defaults instances`;
@@ -55,8 +56,13 @@ unless (@ARGV) {
warn "datadir=$datadir\n" if $opt{v};
}
- @ARGV = <$datadir/$opt{h}-slow.log>;
- die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV;
+ if ( -f $slowlog ) {
+ @ARGV = ($slowlog);
+ die "Can't find '$slowlog'\n" unless @ARGV;
+ } else {
+ @ARGV = <$datadir/$opt{h}-slow.log>;
+ die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV;
+ }
}
warn "\nReading mysql slow query log from @ARGV\n";
diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc
index c4bcc2b6f51..cc3ff06256f 100644
--- a/server-tools/instance-manager/guardian.cc
+++ b/server-tools/instance-manager/guardian.cc
@@ -227,9 +227,8 @@ void Guardian_thread::run()
node= node->next;
}
- timeout.tv_sec= time(NULL) + monitoring_interval;
- timeout.tv_nsec= 0;
-
+ set_timespec(timeout, monitoring_interval);
+
/* check the loop predicate before sleeping */
if (!(shutdown_requested && (!(guarded_instances))))
thread_registry.cond_timedwait(&thread_info, &COND_guardian,
diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
index 7633d4da4d2..58fe7569db7 100644
--- a/server-tools/instance-manager/instance.cc
+++ b/server-tools/instance-manager/instance.cc
@@ -475,10 +475,9 @@ int Instance::stop()
waitchild= options.shutdown_delay_val;
kill_instance(SIGTERM);
- /* sleep on condition to wait for SIGCHLD */
- timeout.tv_sec= time(NULL) + waitchild;
- timeout.tv_nsec= 0;
+ /* sleep on condition to wait for SIGCHLD */
+ set_timespec(timeout, waitchild);
if (pthread_mutex_lock(&LOCK_instance))
return ER_STOP_INSTANCE;
diff --git a/sql/field.cc b/sql/field.cc
index 8e2588c67f1..445f207ec17 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7834,6 +7834,16 @@ void Field_enum::sql_type(String &res) const
}
+Field *Field_enum::new_field(MEM_ROOT *root, struct st_table *new_table,
+ bool keep_type)
+{
+ Field_enum *res= (Field_enum*) Field::new_field(root, new_table, keep_type);
+ if (res)
+ res->typelib= copy_typelib(root, typelib);
+ return res;
+}
+
+
/*
set type.
This is a string which can have a collection of different values.
diff --git a/sql/field.h b/sql/field.h
index 5a7c45d34c5..8214848c169 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1297,6 +1297,7 @@ public:
{
flags|=ENUM_FLAG;
}
+ Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type);
enum_field_types type() const { return FIELD_TYPE_STRING; }
enum Item_result cmp_type () const { return INT_RESULT; }
enum Item_result cast_to_int_type () const { return INT_RESULT; }
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 708d07b3b18..8bfac058936 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1113,7 +1113,7 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table,
{
/*
We must store both value and counter in the temporary table in one field.
- The easyest way is to do this is to store both value in a string
+ The easiest way is to do this is to store both value in a string
and unpack on access.
*/
return new Field_string(((hybrid_type == DECIMAL_RESULT) ?
@@ -1187,8 +1187,9 @@ String *Item_sum_avg::val_str(String *str)
double Item_sum_std::val_real()
{
DBUG_ASSERT(fixed == 1);
- double tmp= Item_sum_variance::val_real();
- return tmp <= 0.0 ? 0.0 : sqrt(tmp);
+ double nr= Item_sum_variance::val_real();
+ DBUG_ASSERT(nr >= 0.0);
+ return sqrt(nr);
}
Item *Item_sum_std::copy_or_same(THD* thd)
@@ -1202,40 +1203,77 @@ Item *Item_sum_std::copy_or_same(THD* thd)
*/
-Item_sum_variance::Item_sum_variance(THD *thd, Item_sum_variance *item):
- Item_sum_num(thd, item), hybrid_type(item->hybrid_type),
- cur_dec(item->cur_dec), count(item->count), sample(item->sample),
- prec_increment(item->prec_increment)
+/**
+ Variance implementation for floating-point implementations, without
+ catastrophic cancellation, from Knuth's _TAoCP_, 3rd ed, volume 2, pg232.
+ This alters the value at m, s, and increments count.
+*/
+
+/*
+ These two functions are used by the Item_sum_variance and the
+ Item_variance_field classes, which are unrelated, and each need to calculate
+ variance. The difference between the two classes is that the first is used
+ for a mundane SELECT, while the latter is used in a GROUPing SELECT.
+*/
+static void variance_fp_recurrence_next(double *m, double *s, ulonglong *count, double nr)
{
- if (hybrid_type == DECIMAL_RESULT)
+ *count += 1;
+
+ if (*count == 1)
{
- memcpy(dec_sum, item->dec_sum, sizeof(item->dec_sum));
- memcpy(dec_sqr, item->dec_sqr, sizeof(item->dec_sqr));
- for (int i=0; i<2; i++)
- {
- dec_sum[i].fix_buffer_pointer();
- dec_sqr[i].fix_buffer_pointer();
- }
+ *m= nr;
+ *s= 0;
}
else
{
- sum= item->sum;
- sum_sqr= item->sum_sqr;
+ double m_kminusone= *m;
+ *m= m_kminusone + (nr - m_kminusone) / (double) *count;
+ *s= *s + (nr - m_kminusone) * (nr - *m);
}
}
+static double variance_fp_recurrence_result(double s, ulonglong count, bool is_sample_variance)
+{
+ if (count == 1)
+ return 0.0;
+
+ if (is_sample_variance)
+ return s / (count - 1);
+
+ /* else, is a population variance */
+ return s / count;
+}
+
+
+Item_sum_variance::Item_sum_variance(THD *thd, Item_sum_variance *item):
+ Item_sum_num(thd, item), hybrid_type(item->hybrid_type),
+ count(item->count), sample(item->sample),
+ prec_increment(item->prec_increment)
+{
+ recurrence_m= item->recurrence_m;
+ recurrence_s= item->recurrence_s;
+}
+
+
void Item_sum_variance::fix_length_and_dec()
{
DBUG_ENTER("Item_sum_variance::fix_length_and_dec");
maybe_null= null_value= 1;
prec_increment= current_thd->variables.div_precincrement;
+
+ /*
+ According to the SQL2003 standard (Part 2, Foundations; sec 10.9,
+ aggregate function; paragraph 7h of Syntax Rules), "the declared
+ type of the result is an implementation-defined aproximate numeric
+ type.
+ */
+ hybrid_type= REAL_RESULT;
+
switch (args[0]->result_type()) {
case REAL_RESULT:
case STRING_RESULT:
decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC);
- hybrid_type= REAL_RESULT;
- sum= 0.0;
break;
case INT_RESULT:
case DECIMAL_RESULT:
@@ -1244,37 +1282,14 @@ void Item_sum_variance::fix_length_and_dec()
decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
max_length= my_decimal_precision_to_length(precision, decimals,
unsigned_flag);
- cur_dec= 0;
- hybrid_type= DECIMAL_RESULT;
- my_decimal_set_zero(dec_sum);
- my_decimal_set_zero(dec_sqr);
- /*
- The maxium value to usable for variance is DECIMAL_MAX_LENGTH/2
- becasue we need to be able to calculate in dec_bin_size1
- column_value * column_value
- */
- f_scale0= args[0]->decimals;
- f_precision0= min(args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_PRECISION);
- f_scale1= min(args[0]->decimals * 2, DECIMAL_MAX_SCALE);
- f_precision1= min(args[0]->decimal_precision()*2 + DECIMAL_LONGLONG_DIGITS,
- DECIMAL_MAX_PRECISION);
- dec_bin_size0= my_decimal_get_binary_size(f_precision0, f_scale0);
- dec_bin_size1= my_decimal_get_binary_size(f_precision1, f_scale1);
break;
}
case ROW_RESULT:
default:
DBUG_ASSERT(0);
}
- DBUG_PRINT("info", ("Type: %s (%d, %d)",
- (hybrid_type == REAL_RESULT ? "REAL_RESULT" :
- hybrid_type == DECIMAL_RESULT ? "DECIMAL_RESULT" :
- hybrid_type == INT_RESULT ? "INT_RESULT" :
- "--ILLEGAL!!!--"),
- max_length,
- (int)decimals));
+ DBUG_PRINT("info", ("Type: REAL_RESULT (%d, %d)", max_length, (int)decimals));
DBUG_VOID_RETURN;
}
@@ -1285,6 +1300,11 @@ Item *Item_sum_variance::copy_or_same(THD* thd)
}
+/**
+ Create a new field to match the type of value we're expected to yield.
+ If we're grouping, then we need some space to serialize variables into, to
+ pass around.
+*/
Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table,
uint convert_blob_len)
{
@@ -1292,13 +1312,10 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table,
{
/*
We must store both value and counter in the temporary table in one field.
- The easyest way is to do this is to store both value in a string
+ The easiest way is to do this is to store both value in a string
and unpack on access.
*/
- return new Field_string(((hybrid_type == DECIMAL_RESULT) ?
- dec_bin_size0 + dec_bin_size1 :
- sizeof(double)*2) + sizeof(longlong),
- 0, name, table, &my_charset_bin);
+ return new Field_string(sizeof(double)*2 + sizeof(longlong), 0, name, table, &my_charset_bin);
}
return new Field_double(max_length, maybe_null,name,table,decimals);
}
@@ -1306,90 +1323,51 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table,
void Item_sum_variance::clear()
{
- if (hybrid_type == DECIMAL_RESULT)
- {
- my_decimal_set_zero(dec_sum);
- my_decimal_set_zero(dec_sqr);
- cur_dec= 0;
- }
- else
- sum=sum_sqr=0.0;
- count=0;
+ count= 0;
}
bool Item_sum_variance::add()
{
- if (hybrid_type == DECIMAL_RESULT)
- {
- my_decimal dec_buf, *dec= args[0]->val_decimal(&dec_buf);
- my_decimal sqr_buf;
- if (!args[0]->null_value)
- {
- count++;
- int next_dec= cur_dec ^ 1;
- my_decimal_mul(E_DEC_FATAL_ERROR, &sqr_buf, dec, dec);
- my_decimal_add(E_DEC_FATAL_ERROR, dec_sqr+next_dec,
- dec_sqr+cur_dec, &sqr_buf);
- my_decimal_add(E_DEC_FATAL_ERROR, dec_sum+next_dec,
- dec_sum+cur_dec, dec);
- cur_dec= next_dec;
- }
- }
- else
- {
- double nr= args[0]->val_real();
- if (!args[0]->null_value)
- {
- sum+=nr;
- sum_sqr+=nr*nr;
- count++;
- }
- }
+ /*
+ Why use a temporary variable? We don't know if it is null until we
+ evaluate it, which has the side-effect of setting null_value .
+ */
+ double nr= args[0]->val_real();
+
+ if (!args[0]->null_value)
+ variance_fp_recurrence_next(&recurrence_m, &recurrence_s, &count, nr);
return 0;
}
double Item_sum_variance::val_real()
{
DBUG_ASSERT(fixed == 1);
- if (hybrid_type == DECIMAL_RESULT)
- return val_real_from_decimal();
+ /*
+ 'sample' is a 1/0 boolean value. If it is 1/true, id est this is a sample
+ variance call, then we should set nullness when the count of the items
+ is one or zero. If it's zero, i.e. a population variance, then we only
+ set nullness when the count is zero.
+
+ Another way to read it is that 'sample' is the numerical threshhold, at and
+ below which a 'count' number of items is called NULL.
+ */
+ DBUG_ASSERT((sample == 0) || (sample == 1));
if (count <= sample)
{
null_value=1;
return 0.0;
}
+
null_value=0;
- /* Avoid problems when the precision isn't good enough */
- double tmp=ulonglong2double(count);
- double tmp2= (sum_sqr - sum*sum/tmp)/(tmp - (double)sample);
- return tmp2 <= 0.0 ? 0.0 : tmp2;
+ return variance_fp_recurrence_result(recurrence_s, count, sample);
}
my_decimal *Item_sum_variance::val_decimal(my_decimal *dec_buf)
{
- my_decimal count_buf, count1_buf, sum_sqr_buf;
- DBUG_ASSERT(fixed ==1 );
- if (hybrid_type == REAL_RESULT)
- return val_decimal_from_real(dec_buf);
-
- if (count <= sample)
- {
- null_value= 1;
- return 0;
- }
- null_value= 0;
- int2my_decimal(E_DEC_FATAL_ERROR, count, 0, &count_buf);
- int2my_decimal(E_DEC_FATAL_ERROR, count-sample, 0, &count1_buf);
- my_decimal_mul(E_DEC_FATAL_ERROR, &sum_sqr_buf,
- dec_sum+cur_dec, dec_sum+cur_dec);
- my_decimal_div(E_DEC_FATAL_ERROR, dec_buf,
- &sum_sqr_buf, &count_buf, prec_increment);
- my_decimal_sub(E_DEC_FATAL_ERROR, &sum_sqr_buf, dec_sqr+cur_dec, dec_buf);
- my_decimal_div(E_DEC_FATAL_ERROR, dec_buf,
- &sum_sqr_buf, &count1_buf, prec_increment);
- return dec_buf;
+ DBUG_ASSERT(fixed == 1);
+ return val_decimal_from_real(dec_buf);
}
@@ -1398,89 +1376,44 @@ void Item_sum_variance::reset_field()
double nr;
char *res= result_field->ptr;
- if (hybrid_type == DECIMAL_RESULT)
- {
- my_decimal value, *arg_dec, *arg2_dec;
- longlong tmp;
-
- arg_dec= args[0]->val_decimal(&value);
- if (args[0]->null_value)
- {
- arg_dec= arg2_dec= &decimal_zero;
- tmp= 0;
- }
- else
- {
- my_decimal_mul(E_DEC_FATAL_ERROR, dec_sum, arg_dec, arg_dec);
- arg2_dec= dec_sum;
- tmp= 1;
- }
- my_decimal2binary(E_DEC_FATAL_ERROR, arg_dec,
- res, f_precision0, f_scale0);
- my_decimal2binary(E_DEC_FATAL_ERROR, arg2_dec,
- res+dec_bin_size0, f_precision1, f_scale1);
- res+= dec_bin_size0 + dec_bin_size1;
- int8store(res,tmp);
- return;
- }
- nr= args[0]->val_real();
+ nr= args[0]->val_real(); /* sets null_value as side-effect */
if (args[0]->null_value)
bzero(res,sizeof(double)*2+sizeof(longlong));
else
{
- longlong tmp;
- float8store(res,nr);
- nr*=nr;
- float8store(res+sizeof(double),nr);
- tmp= 1;
- int8store(res+sizeof(double)*2,tmp);
+ /* Serialize format is (double)m, (double)s, (longlong)count */
+ ulonglong tmp_count;
+ double tmp_s;
+ float8store(res, nr); /* recurrence variable m */
+ tmp_s= 0.0;
+ float8store(res + sizeof(double), tmp_s);
+ tmp_count= 1;
+ int8store(res + sizeof(double)*2, tmp_count);
}
}
void Item_sum_variance::update_field()
{
- longlong field_count;
+ ulonglong field_count;
char *res=result_field->ptr;
- if (hybrid_type == DECIMAL_RESULT)
- {
- my_decimal value, *arg_val= args[0]->val_decimal(&value);
- if (!args[0]->null_value)
- {
- binary2my_decimal(E_DEC_FATAL_ERROR, res,
- dec_sum+1, f_precision0, f_scale0);
- binary2my_decimal(E_DEC_FATAL_ERROR, res+dec_bin_size0,
- dec_sqr+1, f_precision1, f_scale1);
- field_count= sint8korr(res + (dec_bin_size0 + dec_bin_size1));
- my_decimal_add(E_DEC_FATAL_ERROR, dec_sum, arg_val, dec_sum+1);
- my_decimal_mul(E_DEC_FATAL_ERROR, dec_sum+1, arg_val, arg_val);
- my_decimal_add(E_DEC_FATAL_ERROR, dec_sqr, dec_sqr+1, dec_sum+1);
- field_count++;
- my_decimal2binary(E_DEC_FATAL_ERROR, dec_sum,
- res, f_precision0, f_scale0);
- my_decimal2binary(E_DEC_FATAL_ERROR, dec_sqr,
- res+dec_bin_size0, f_precision1, f_scale1);
- res+= dec_bin_size0 + dec_bin_size1;
- int8store(res, field_count);
- }
+
+ double nr= args[0]->val_real(); /* sets null_value as side-effect */
+
+ if (args[0]->null_value)
return;
- }
- double nr,old_nr,old_sqr;
- float8get(old_nr, res);
- float8get(old_sqr, res+sizeof(double));
+ /* Serialize format is (double)m, (double)s, (longlong)count */
+ double field_recurrence_m, field_recurrence_s;
+ float8get(field_recurrence_m, res);
+ float8get(field_recurrence_s, res + sizeof(double));
field_count=sint8korr(res+sizeof(double)*2);
- nr= args[0]->val_real();
- if (!args[0]->null_value)
- {
- old_nr+=nr;
- old_sqr+=nr*nr;
- field_count++;
- }
- float8store(res,old_nr);
- float8store(res+sizeof(double),old_sqr);
+ variance_fp_recurrence_next(&field_recurrence_m, &field_recurrence_s, &field_count, nr);
+
+ float8store(res, field_recurrence_m);
+ float8store(res + sizeof(double), field_recurrence_s);
res+= sizeof(double)*2;
int8store(res,field_count);
}
@@ -2310,25 +2243,9 @@ double Item_std_field::val_real()
{
double nr;
// fix_fields() never calls for this Item
- if (hybrid_type == REAL_RESULT)
- {
- /*
- We can't call Item_variance_field::val_real() on a DECIMAL_RESULT
- as this would call Item_std_field::val_decimal() and we would
- calculate sqrt() twice
- */
- nr= Item_variance_field::val_real();
- }
- else
- {
- my_decimal dec_buf,*dec;
- dec= Item_variance_field::val_decimal(&dec_buf);
- if (!dec)
- nr= 0.0; // NULL; Return 0.0
- else
- my_decimal2double(E_DEC_FATAL_ERROR, dec, &nr);
- }
- return nr <= 0.0 ? 0.0 : sqrt(nr);
+ nr= Item_variance_field::val_real();
+ DBUG_ASSERT(nr >= 0.0);
+ return sqrt(nr);
}
@@ -2342,11 +2259,13 @@ my_decimal *Item_std_field::val_decimal(my_decimal *dec_buf)
double nr;
if (hybrid_type == REAL_RESULT)
return val_decimal_from_real(dec_buf);
+
dec= Item_variance_field::val_decimal(dec_buf);
if (!dec)
return 0;
my_decimal2double(E_DEC_FATAL_ERROR, dec, &nr);
- nr= nr <= 0.0 ? 0.0 : sqrt(nr);
+ DBUG_ASSERT(nr >= 0.0);
+ nr= sqrt(nr);
double2my_decimal(E_DEC_FATAL_ERROR, nr, &tmp_dec);
my_decimal_round(E_DEC_FATAL_ERROR, &tmp_dec, decimals, FALSE, dec_buf);
return dec_buf;
@@ -2381,52 +2300,15 @@ double Item_variance_field::val_real()
if (hybrid_type == DECIMAL_RESULT)
return val_real_from_decimal();
- double sum,sum_sqr;
- longlong count;
- float8get(sum,field->ptr);
- float8get(sum_sqr,(field->ptr+sizeof(double)));
+ double recurrence_s;
+ ulonglong count;
+ float8get(recurrence_s, (field->ptr + sizeof(double)));
count=sint8korr(field->ptr+sizeof(double)*2);
if ((null_value= (count <= sample)))
return 0.0;
- double tmp= (double) count;
- double tmp2= (sum_sqr - sum*sum/tmp)/(tmp - (double)sample);
- return tmp2 <= 0.0 ? 0.0 : tmp2;
-}
-
-
-String *Item_variance_field::val_str(String *str)
-{
- if (hybrid_type == DECIMAL_RESULT)
- return val_string_from_decimal(str);
- return val_string_from_real(str);
-}
-
-
-my_decimal *Item_variance_field::val_decimal(my_decimal *dec_buf)
-{
- // fix_fields() never calls for this Item
- if (hybrid_type == REAL_RESULT)
- return val_decimal_from_real(dec_buf);
-
- longlong count= sint8korr(field->ptr+dec_bin_size0+dec_bin_size1);
- if ((null_value= (count <= sample)))
- return 0;
-
- my_decimal dec_count, dec1_count, dec_sum, dec_sqr, tmp;
- int2my_decimal(E_DEC_FATAL_ERROR, count, 0, &dec_count);
- int2my_decimal(E_DEC_FATAL_ERROR, count-sample, 0, &dec1_count);
- binary2my_decimal(E_DEC_FATAL_ERROR, field->ptr,
- &dec_sum, f_precision0, f_scale0);
- binary2my_decimal(E_DEC_FATAL_ERROR, field->ptr+dec_bin_size0,
- &dec_sqr, f_precision1, f_scale1);
- my_decimal_mul(E_DEC_FATAL_ERROR, &tmp, &dec_sum, &dec_sum);
- my_decimal_div(E_DEC_FATAL_ERROR, dec_buf, &tmp, &dec_count, prec_increment);
- my_decimal_sub(E_DEC_FATAL_ERROR, &dec_sum, &dec_sqr, dec_buf);
- my_decimal_div(E_DEC_FATAL_ERROR, dec_buf,
- &dec_sum, &dec1_count, prec_increment);
- return dec_buf;
+ return variance_fp_recurrence_result(recurrence_s, count, sample);
}
diff --git a/sql/item_sum.h b/sql/item_sum.h
index b9b670d4817..edddf11c660 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -682,8 +682,10 @@ public:
double val_real();
longlong val_int()
{ /* can't be fix_fields()ed */ return (longlong) rint(val_real()); }
- String *val_str(String*);
- my_decimal *val_decimal(my_decimal *);
+ String *val_str(String *str)
+ { return val_string_from_real(str); }
+ my_decimal *val_decimal(my_decimal *dec_buf)
+ { return val_decimal_from_real(dec_buf); }
bool is_null() { update_null_value(); return null_value; }
enum_field_types field_type() const
{
@@ -705,6 +707,14 @@ public:
= (sum(ai^2) - 2*sum(a)*sum(a)/count(a) + count(a)*sum(a)^2/count(a)^2 )/count(a) =
= (sum(ai^2) - 2*sum(a)^2/count(a) + sum(a)^2/count(a) )/count(a) =
= (sum(ai^2) - sum(a)^2/count(a))/count(a)
+
+But, this falls prey to catastrophic cancellation. Instead, use the recurrence formulas
+
+ M_{1} = x_{1}, ~ M_{k} = M_{k-1} + (x_{k} - M_{k-1}) / k newline
+ S_{1} = 0, ~ S_{k} = S_{k-1} + (x_{k} - M_{k-1}) times (x_{k} - M_{k}) newline
+ for 2 <= k <= n newline
+ ital variance = S_{n} / (n-1)
+
*/
class Item_sum_variance : public Item_sum_num
@@ -713,9 +723,8 @@ class Item_sum_variance : public Item_sum_num
public:
Item_result hybrid_type;
- double sum, sum_sqr;
- my_decimal dec_sum[2], dec_sqr[2];
int cur_dec;
+ double recurrence_m, recurrence_s; /* Used in recurrence relation. */
ulonglong count;
uint f_precision0, f_scale0;
uint f_precision1, f_scale1;
@@ -724,7 +733,7 @@ public:
uint prec_increment;
Item_sum_variance(Item *item_par, uint sample_arg) :Item_sum_num(item_par),
- hybrid_type(REAL_RESULT), cur_dec(0), count(0), sample(sample_arg)
+ hybrid_type(REAL_RESULT), count(0), sample(sample_arg)
{}
Item_sum_variance(THD *thd, Item_sum_variance *item);
enum Sumfunctype sum_func () const { return VARIANCE_FUNC; }
@@ -744,7 +753,6 @@ public:
enum Item_result result_type () const { return REAL_RESULT; }
void cleanup()
{
- cur_dec= 0;
count= 0;
Item_sum_num::cleanup();
}
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index b53195da3b1..df042ada79f 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -596,7 +596,10 @@ net_real_write(NET *net,const char *packet,ulong len)
}
#endif /* HAVE_COMPRESS */
- /* DBUG_DUMP("net",packet,len); */
+#ifdef DEBUG_DATA_PACKETS
+ DBUG_DUMP("data",packet,len);
+#endif
+
#ifndef NO_ALARM
thr_alarm_init(&alarmed);
if (net_blocking)
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 4e4f6345d9c..8df3e82cb63 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3713,7 +3713,8 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
for (uint idx= 0; idx < param->keys; idx++)
{
SEL_ARG *new_interval, *last_val;
- if (((new_interval= tree2->keys[idx])) &&
+ if (((new_interval= tree2->keys[idx])) &&
+ (tree->keys[idx]) &&
((last_val= tree->keys[idx]->last())))
{
new_interval->min_value= last_val->max_value;
diff --git a/sql/share/charsets/hebrew.xml b/sql/share/charsets/hebrew.xml
index bdfa82bb791..20d68487301 100644
--- a/sql/share/charsets/hebrew.xml
+++ b/sql/share/charsets/hebrew.xml
@@ -39,7 +39,7 @@
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
- 02 02 02 02 02 02 02 02 02 02 02 00 00 00 00 00
+ 02 02 02 02 02 02 02 02 02 02 02 00 00 20 20 00
</map>
</ctype>
@@ -105,7 +105,7 @@
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 2017
05D0 05D1 05D2 05D3 05D4 05D5 05D6 05D7 05D8 05D9 05DA 05DB 05DC 05DD 05DE 05DF
-05E0 05E1 05E2 05E3 05E4 05E5 05E6 05E7 05E8 05E9 05EA 0000 0000 0000 0000 0000
+05E0 05E1 05E2 05E3 05E4 05E5 05E6 05E7 05E8 05E9 05EA 0000 0000 200E 200F 0000
</map>
</unicode>
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 007c5edd673..6576324c16e 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2899,6 +2899,12 @@ mysql_execute_command(THD *thd)
goto end_with_restore_list;
#ifndef HAVE_READLINK
+ if (lex->create_info.data_file_name)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
+ "DATA DIRECTORY option ignored");
+ if (lex->create_info.index_file_name)
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
+ "INDEX DIRECTORY option ignored");
lex->create_info.data_file_name=lex->create_info.index_file_name=0;
#else
/* Fix names if symlinked tables */
diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c
index 1ec7b360f03..e2ac9846c85 100644
--- a/strings/conf_to_src.c
+++ b/strings/conf_to_src.c
@@ -275,7 +275,14 @@ main(int argc, char **argv __attribute__((unused)))
}
}
-
+ fprintf(f, "/*\n");
+ fprintf(f, " This file was generated by the conf_to_src utility. "
+ "Do not edit it directly,\n");
+ fprintf(f, " edit the XML definitions in sql/share/charsets/ instead.\n\n");
+ fprintf(f, " To re-generate, run the following in the strings/ "
+ "directory:\n");
+ fprintf(f, " ./conf_to_src ../sql/share/charsets/ > FILE\n");
+ fprintf(f, "*/\n\n");
fprintf(f,"#include <my_global.h>\n");
fprintf(f,"#include <m_ctype.h>\n\n");
diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c
index ea6fe68e973..187950c07d2 100644
--- a/strings/ctype-extra.c
+++ b/strings/ctype-extra.c
@@ -1,3 +1,11 @@
+/*
+ This file was generated by the conf_to_src utility. Do not edit it directly,
+ edit the XML definitions in sql/share/charsets/ instead.
+
+ To re-generate, run the following in the strings/ directory:
+ ./conf_to_src ../sql/share/charsets/ > FILE
+*/
+
#include <my_global.h>
#include <m_ctype.h>
@@ -1169,7 +1177,7 @@ uchar ctype_hebrew_general_ci[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
-0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x20,0x20,0x00
};
uchar to_lower_hebrew_general_ci[] = {
@@ -1261,7 +1269,7 @@ uint16 to_uni_hebrew_general_ci[] = {
0x05D0,0x05D1,0x05D2,0x05D3,0x05D4,0x05D5,0x05D6,0x05D7,
0x05D8,0x05D9,0x05DA,0x05DB,0x05DC,0x05DD,0x05DE,0x05DF,
0x05E0,0x05E1,0x05E2,0x05E3,0x05E4,0x05E5,0x05E6,0x05E7,
-0x05E8,0x05E9,0x05EA,0x0000,0x0000,0x0000,0x0000,0x0000
+0x05E8,0x05E9,0x05EA,0x0000,0x0000,0x200E,0x200F,0x0000
};
#endif
@@ -5100,7 +5108,7 @@ uchar ctype_hebrew_bin[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
-0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00
+0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x20,0x20,0x00
};
uchar to_lower_hebrew_bin[] = {
@@ -5173,7 +5181,7 @@ uint16 to_uni_hebrew_bin[] = {
0x05D0,0x05D1,0x05D2,0x05D3,0x05D4,0x05D5,0x05D6,0x05D7,
0x05D8,0x05D9,0x05DA,0x05DB,0x05DC,0x05DD,0x05DE,0x05DF,
0x05E0,0x05E1,0x05E2,0x05E3,0x05E4,0x05E5,0x05E6,0x05E7,
-0x05E8,0x05E9,0x05EA,0x0000,0x0000,0x0000,0x0000,0x0000
+0x05E8,0x05E9,0x05EA,0x0000,0x0000,0x200E,0x200F,0x0000
};
#endif
diff --git a/vio/viossl.c b/vio/viossl.c
index 6686e63de0e..4267486112f 100644
--- a/vio/viossl.c
+++ b/vio/viossl.c
@@ -125,12 +125,16 @@ int vio_ssl_close(Vio *vio)
{
switch ((r= SSL_shutdown(ssl)))
{
- case 1: /* Shutdown successful */
+ case 1:
+ /* Shutdown successful */
+ break;
+ case 0:
+ /*
+ Shutdown not yet finished - since the socket is going to
+ be closed there is no need to call SSL_shutdown() a second
+ time to wait for the other side to respond
+ */
break;
- case 0: /* Shutdown not yet finished, call it again */
- if ((r= SSL_shutdown(ssl) >= 0))
- break;
- /* Fallthrough */
default: /* Shutdown failed */
DBUG_PRINT("vio_error", ("SSL_shutdown() failed, error: %d",
SSL_get_error(ssl, r)));