summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBUILD/check-cpu2
-rw-r--r--VC++Files/sql/mysqld.dsp2
-rw-r--r--client/client_priv.h3
-rw-r--r--client/mysqladmin.cc2
-rw-r--r--client/mysqlbinlog.cc4
-rw-r--r--client/mysqlcheck.c2
-rw-r--r--client/mysqldump.c16
-rw-r--r--client/mysqlimport.c2
-rw-r--r--client/mysqlshow.c2
-rw-r--r--client/mysqltest.c2
-rw-r--r--config/ac-macros/yassl.m412
-rw-r--r--configure.in2
-rw-r--r--extra/innochecksum.c2
-rw-r--r--extra/yassl/src/Makefile.am4
-rw-r--r--extra/yassl/taocrypt/src/Makefile.am12
-rw-r--r--include/config-win.h8
-rw-r--r--include/my_base.h51
-rw-r--r--libmysql/Makefile.am4
-rw-r--r--libmysqld/examples/Makefile.am4
-rw-r--r--mysql-test/r/alter_table.result6
-rw-r--r--mysql-test/r/create.result19
-rw-r--r--mysql-test/r/ctype_recoding.result9
-rw-r--r--mysql-test/r/ctype_utf8.result10
-rw-r--r--mysql-test/r/fulltext.result3
-rw-r--r--mysql-test/r/grant.result21
-rw-r--r--mysql-test/r/group_min_max.result10
-rw-r--r--mysql-test/r/join.result301
-rw-r--r--mysql-test/r/join_nested.result2
-rw-r--r--mysql-test/r/mysqldump.result40
-rw-r--r--mysql-test/r/ndb_alter_table.result2
-rw-r--r--mysql-test/r/ndb_basic.result8
-rw-r--r--mysql-test/r/ps.result26
-rw-r--r--mysql-test/r/select.result54
-rw-r--r--mysql-test/r/sp.result179
-rw-r--r--mysql-test/r/sp_trans.result56
-rw-r--r--mysql-test/r/type_ranges.result2
-rw-r--r--mysql-test/r/union.result26
-rw-r--r--mysql-test/t/alter_table.test14
-rw-r--r--mysql-test/t/create.test14
-rw-r--r--mysql-test/t/ctype_recoding.test11
-rw-r--r--mysql-test/t/ctype_utf8.test6
-rw-r--r--mysql-test/t/disabled.def4
-rw-r--r--mysql-test/t/fulltext.test1
-rw-r--r--mysql-test/t/grant.test12
-rw-r--r--mysql-test/t/group_min_max.test10
-rw-r--r--mysql-test/t/join.test207
-rw-r--r--mysql-test/t/join_nested.test2
-rw-r--r--mysql-test/t/mysqldump.test16
-rw-r--r--mysql-test/t/ndb_alter_table.test2
-rw-r--r--mysql-test/t/ndb_basic.test17
-rw-r--r--mysql-test/t/ps.test40
-rw-r--r--mysql-test/t/select.test56
-rw-r--r--mysql-test/t/sp.test132
-rw-r--r--mysql-test/t/sp_trans.test64
-rw-r--r--mysql-test/t/union.test18
-rw-r--r--mysys/my_open.c6
-rw-r--r--scripts/mysqlhotcopy.sh1
-rw-r--r--sql-common/client.c7
-rw-r--r--sql/authors.h9
-rw-r--r--sql/examples/ha_example.cc2
-rw-r--r--sql/ha_ndbcluster.cc21
-rw-r--r--sql/handler.h2
-rw-r--r--sql/item.cc57
-rw-r--r--sql/item.h4
-rw-r--r--sql/item_cmpfunc.cc2
-rw-r--r--sql/item_strfunc.cc65
-rw-r--r--sql/item_strfunc.h35
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc3
-rw-r--r--sql/opt_range.cc21
-rw-r--r--sql/sp_head.cc20
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_class.h6
-rw-r--r--sql/sql_parse.cc12
-rw-r--r--sql/sql_show.cc1
-rw-r--r--sql/sql_table.cc34
-rw-r--r--sql/sql_update.cc14
-rw-r--r--sql/table.cc14
-rw-r--r--storage/myisam/ft_parser.c4
-rw-r--r--storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp9
-rw-r--r--storage/ndb/src/mgmapi/mgmapi.cpp8
-rw-r--r--vio/vio.c2
-rw-r--r--vio/vio_priv.h1
-rw-r--r--vio/viossl.c19
-rw-r--r--vio/viosslfactories.c21
85 files changed, 1680 insertions, 259 deletions
diff --git a/BUILD/check-cpu b/BUILD/check-cpu
index dc894c91cbd..583e31ee389 100755
--- a/BUILD/check-cpu
+++ b/BUILD/check-cpu
@@ -59,7 +59,7 @@ case "$cpu_family--$model_name" in
;;
# Intel ia32
- *Xeon*)
+ *X[eE][oO][nN]*)
# a Xeon is just another pentium4 ...
# ... unless it has the "lm" (long-mode) flag set,
# in that case it's a Xeon with EM64T support
diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp
index db0ba956c41..ce8e36fde56 100644
--- a/VC++Files/sql/mysqld.dsp
+++ b/VC++Files/sql/mysqld.dsp
@@ -456,7 +456,7 @@ SOURCE=.\gstream.cpp
# End Source File
# Begin Source File
-SOURCE=.\examples\ha_archive.cpp
+SOURCE=.\ha_archive.cpp
# End Source File
# Begin Source File
diff --git a/client/client_priv.h b/client/client_priv.h
index a9d5364df49..7d836189e2e 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -51,5 +51,6 @@ enum options_client
#endif
OPT_TRIGGERS,
OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE,
- OPT_TZ_UTC, OPT_AUTO_CLOSE
+ OPT_TZ_UTC, OPT_AUTO_CLOSE,
+ OPT_MYSQL_REPLACE_INTO
};
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 53bf59af67a..8d2e040b21f 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -161,7 +161,7 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port,
- (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0},
+ (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"relative", 'r',
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 7eb26d30cf9..ae482a155d5 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -67,7 +67,7 @@ static const char* database= 0;
static my_bool force_opt= 0, short_form= 0, remote_opt= 0;
static ulonglong offset = 0;
static const char* host = 0;
-static int port = MYSQL_PORT;
+static int port= 0;
static const char* sock= 0;
static const char* user = 0;
static char* pass = 0;
@@ -688,7 +688,7 @@ static struct my_option my_long_options[] =
{"password", 'p', "Password to connect to remote server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Use port to connect to the remote server.",
- (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, MYSQL_PORT, 0, 0,
+ (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
0, 0, 0},
{"position", 'j', "Deprecated. Use --start-position instead.",
(gptr*) &start_position, (gptr*) &start_position, 0, GET_ULL,
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 1324060eb55..2ad35098c33 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -122,7 +122,7 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
- (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
+ (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 47ec9a72108..cce5cf49d43 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -92,6 +92,7 @@ static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1,
opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0,
opt_complete_insert= 0, opt_drop_database= 0,
+ opt_replace_into= 0,
opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1;
static ulong opt_max_allowed_packet, opt_net_buffer_length;
static MYSQL mysql_connection,*sock=0;
@@ -330,7 +331,7 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
- (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
+ (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -339,6 +340,9 @@ static struct my_option my_long_options[] =
{"quote-names",'Q', "Quote table and column names with backticks (`).",
(gptr*) &opt_quoted, (gptr*) &opt_quoted, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
0, 0},
+ {"replace", OPT_MYSQL_REPLACE_INTO, "Use REPLACE INTO instead of INSERT INTO.",
+ (gptr*) &opt_replace_into, (gptr*) &opt_replace_into, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
+ 0, 0},
{"result-file", 'r',
"Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -1515,7 +1519,10 @@ static uint get_table_structure(char *table, char *db, char *table_type,
*/
if (write_data)
{
- dynstr_append_mem(&insert_pat, "INSERT ", 7);
+ if (opt_replace_into)
+ dynstr_append_mem(&insert_pat, "REPLACE ", 8);
+ else
+ dynstr_append_mem(&insert_pat, "INSERT ", 7);
dynstr_append(&insert_pat, insert_option);
dynstr_append_mem(&insert_pat, "INTO ", 5);
dynstr_append(&insert_pat, opt_quoted_table);
@@ -1592,7 +1599,10 @@ static uint get_table_structure(char *table, char *db, char *table_type,
if (write_data)
{
- dynstr_append_mem(&insert_pat, "INSERT ", 7);
+ if (opt_replace_into)
+ dynstr_append_mem(&insert_pat, "REPLACE ", 8);
+ else
+ dynstr_append_mem(&insert_pat, "INSERT ", 7);
dynstr_append(&insert_pat, insert_option);
dynstr_append_mem(&insert_pat, "INTO ", 5);
dynstr_append(&insert_pat, result_table);
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 958f987d16b..8694093f06b 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -121,7 +121,7 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
- (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
+ (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 8369d918d6f..504f0d9844b 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -188,7 +188,7 @@ static struct my_option my_long_options[] =
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
- (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
+ (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
#ifdef __WIN__
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
diff --git a/client/mysqltest.c b/client/mysqltest.c
index f6d28101fa0..ba1b92b31a3 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -2763,7 +2763,7 @@ static struct my_option my_long_options[] =
{"password", 'p', "Password to use when connecting to server.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &port,
- (gptr*) &port, 0, GET_INT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0},
+ (gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"ps-protocol", OPT_PS_PROTOCOL, "Use prepared statements protocol for communication",
(gptr*) &ps_protocol, (gptr*) &ps_protocol, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
diff --git a/config/ac-macros/yassl.m4 b/config/ac-macros/yassl.m4
index 9d9a4d55000..77208faee0c 100644
--- a/config/ac-macros/yassl.m4
+++ b/config/ac-macros/yassl.m4
@@ -16,28 +16,28 @@ AC_DEFUN([MYSQL_CHECK_YASSL], [
AC_MSG_RESULT([using bundled yaSSL])
yassl_dir="extra/yassl"
yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt"
- yassl_libs_with_path="\$(top_srcdir)/extra/yassl/src/libyassl.a \$(top_srcdir)/extra/yassl/taocrypt/src/libtaocrypt.a"
yassl_includes="-I\$(top_srcdir)/extra/yassl/include"
+ yassl_libs_with_path="\$(top_srcdir)/extra/yassl/src/libyassl.la \$(top_srcdir)/extra/yassl/taocrypt/src/libtaocrypt.la"
AC_DEFINE([HAVE_OPENSSL], [1], [Defined by configure. Using yaSSL for OpenSSL emulation.])
AC_DEFINE([HAVE_YASSL], [1], [Defined by configure. Using yaSSL for OpenSSL emulation.])
# System specific checks
yassl_integer_extra_cxxflags=""
case $host_cpu--$CXX_VERSION in
sparc*--*Sun*C++*5.6*)
- # Disable inlining when compiling taocrypt/src/integer.cpp
- yassl_integer_extra_cxxflags="+d"
- AC_MSG_NOTICE([disabling inlining for yassl/taocrypt/src/integer.cpp])
+ # Disable inlining when compiling taocrypt/src/
+ yassl_taocrypt_extra_cxxflags="+d"
+ AC_MSG_NOTICE([disabling inlining for yassl/taocrypt/src/])
;;
esac
- AC_SUBST([yassl_integer_extra_cxxflags])
+ AC_SUBST([yassl_taocrypt_extra_cxxflags])
else
yassl_dir=""
AC_MSG_RESULT(no)
fi
AC_SUBST(yassl_libs)
+ AC_SUBST(yassl_libs_with_path)
AC_SUBST(yassl_includes)
AC_SUBST(yassl_dir)
- AC_SUBST(yassl_libs_with_path)
AM_CONDITIONAL([HAVE_YASSL], [ test "with_yassl" = "yes" ])
])
diff --git a/configure.in b/configure.in
index efcaf82934d..ed57fa0c72b 100644
--- a/configure.in
+++ b/configure.in
@@ -6,7 +6,7 @@ AC_PREREQ(2.52)dnl Minimum Autoconf version required.
AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line!
-AM_INIT_AUTOMAKE(mysql, 5.1.3-alpha)
+AM_INIT_AUTOMAKE(mysql, 5.1.4-alpha)
AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
diff --git a/extra/innochecksum.c b/extra/innochecksum.c
index 739953298af..bae5f3e8821 100644
--- a/extra/innochecksum.c
+++ b/extra/innochecksum.c
@@ -28,6 +28,8 @@
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
+#define _XOPEN_SOURCE /* needed to include getopt.h on some platforms. */
+
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
diff --git a/extra/yassl/src/Makefile.am b/extra/yassl/src/Makefile.am
index df96018e1cf..a852ca4019b 100644
--- a/extra/yassl/src/Makefile.am
+++ b/extra/yassl/src/Makefile.am
@@ -1,7 +1,7 @@
INCLUDES = -I../include -I../taocrypt/include -I../mySTL
-noinst_LIBRARIES = libyassl.a
-libyassl_a_SOURCES = buffer.cpp cert_wrapper.cpp crypto_wrapper.cpp \
+noinst_LTLIBRARIES = libyassl.la
+libyassl_la_SOURCES = buffer.cpp cert_wrapper.cpp crypto_wrapper.cpp \
handshake.cpp lock.cpp log.cpp socket_wrapper.cpp ssl.cpp \
template_instnt.cpp timer.cpp yassl_imp.cpp yassl_error.cpp yassl_int.cpp
EXTRA_DIST = $(wildcard ../include/*.hpp) $(wildcard ../include/openssl/*.h)
diff --git a/extra/yassl/taocrypt/src/Makefile.am b/extra/yassl/taocrypt/src/Makefile.am
index 0319fc6057b..d89fa95a940 100644
--- a/extra/yassl/taocrypt/src/Makefile.am
+++ b/extra/yassl/taocrypt/src/Makefile.am
@@ -1,15 +1,11 @@
INCLUDES = -I../include -I../../mySTL
-noinst_LIBRARIES = libtaoint.a libtaocrypt.a
+noinst_LTLIBRARIES = libtaocrypt.la
-libtaoint_a_SOURCES = integer.cpp
-libtaoint_a_CXXFLAGS = @yassl_integer_extra_cxxflags@
-
-libtaocrypt_a_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp asn.cpp \
+libtaocrypt_la_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp asn.cpp \
coding.cpp dh.cpp des.cpp dsa.cpp file.cpp hash.cpp \
md2.cpp md5.cpp misc.cpp random.cpp ripemd.cpp rsa.cpp sha.cpp \
- template_instnt.cpp
-libtaocrypt_a_LIBADD = libtaoint_a-integer.o
+ template_instnt.cpp integer.cpp
+libtaocrypt_la_CXXFLAGS = @yassl_taocrypt_extra_cxxflags@ -DYASSL_PURE_C
EXTRA_DIST = $(wildcard ../include/*.hpp)
-AM_CXXFLAGS = -DYASSL_PURE_C
diff --git a/include/config-win.h b/include/config-win.h
index 5c2f8e00e86..edfb4ecc5c7 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -279,10 +279,10 @@ inline double ulonglong2double(ulonglong value)
*((T)+4)=(uchar) (((A) >> 32)); }
#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A)
-#define doubleget(V,M) { *((long *) &V) = *((long*) M); \
- *(((long *) &V)+1) = *(((long*) M)+1); }
-#define doublestore(T,V) { *((long *) T) = *((long*) &V); \
- *(((long *) T)+1) = *(((long*) &V)+1); }
+#define doubleget(V,M) do { *((long *) &V) = *((long*) M); \
+ *(((long *) &V)+1) = *(((long*) M)+1); } while(0)
+#define doublestore(T,V) do { *((long *) T) = *((long*) &V); \
+ *(((long *) T)+1) = *(((long*) &V)+1); } while(0)
#define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float))
#define floatget(V,M) memcpy((byte*)(&V), (byte*)(M), sizeof(float))
diff --git a/include/my_base.h b/include/my_base.h
index c11e52fb996..ebe1c6ab722 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -244,7 +244,7 @@ enum ha_base_keytype {
#define HA_OPTION_CHECKSUM 32
#define HA_OPTION_DELAY_KEY_WRITE 64
#define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */
-#define HA_OPTION_CREATE_FROM_ENGINE 256
+#define HA_OPTION_CREATE_FROM_ENGINE 256
#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint) 16384) /* set by isamchk */
#define HA_OPTION_READ_ONLY_DATA ((uint) 32768) /* Set by isamchk */
@@ -256,15 +256,48 @@ enum ha_base_keytype {
#define HA_CREATE_CHECKSUM 8
#define HA_CREATE_DELAY_KEY_WRITE 64
- /* Bits in flag to _status */
+/*
+ The following flags (OR-ed) are passed to handler::info() method.
+ The method copies misc handler information out of the storage engine
+ to data structures accessible from MySQL
+
+ Same flags are also passed down to mi_status, myrg_status, etc.
+*/
-#define HA_STATUS_POS 1 /* Return position */
-#define HA_STATUS_NO_LOCK 2 /* Don't use external lock */
-#define HA_STATUS_TIME 4 /* Return update time */
-#define HA_STATUS_CONST 8 /* Return constants values */
-#define HA_STATUS_VARIABLE 16
-#define HA_STATUS_ERRKEY 32
-#define HA_STATUS_AUTO 64
+/* this one is not used */
+#define HA_STATUS_POS 1
+/*
+ assuming the table keeps shared actual copy of the 'info' and
+ local, possibly outdated copy, the following flag means that
+ it should not try to get the actual data (locking the shared structure)
+ slightly outdated version will suffice
+*/
+#define HA_STATUS_NO_LOCK 2
+/* update the time of the last modification (in handler::update_time) */
+#define HA_STATUS_TIME 4
+/*
+ update the 'constant' part of the info:
+ handler::max_data_file_length, max_index_file_length, create_time
+ sortkey, ref_length, block_size, data_file_name, index_file_name.
+ handler::table->s->keys_in_use, keys_for_keyread, rec_per_key
+*/
+#define HA_STATUS_CONST 8
+/*
+ update the 'variable' part of the info:
+ handler::records, deleted, data_file_length, index_file_length,
+ delete_length, check_time, mean_rec_length
+*/
+#define HA_STATUS_VARIABLE 16
+/*
+ get the information about the key that caused last duplicate value error
+ update handler::errkey and handler::dupp_ref
+ see handler::get_dup_key()
+*/
+#define HA_STATUS_ERRKEY 32
+/*
+ update handler::auto_increment_value
+*/
+#define HA_STATUS_AUTO 64
/* Errorcodes given by functions */
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am
index 319a9913255..a3e16b521a9 100644
--- a/libmysql/Makefile.am
+++ b/libmysql/Makefile.am
@@ -22,14 +22,14 @@
target = libmysqlclient.la
target_defs = -DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@
-LIBS = @CLIENT_LIBS@ @yassl_libs@
+LIBS = @CLIENT_LIBS@
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
$(openssl_includes) $(yassl_includes) @ZLIB_INCLUDES@
include $(srcdir)/Makefile.shared
libmysqlclient_la_SOURCES = $(target_sources)
-libmysqlclient_la_LIBADD = $(target_libadd)
+libmysqlclient_la_LIBADD = $(target_libadd) $(yassl_libs_with_path)
libmysqlclient_la_LDFLAGS = $(target_ldflags)
EXTRA_DIST = Makefile.shared libmysql.def
noinst_HEADERS = client_settings.h
diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am
index bbfa4d87181..7ee8adfef80 100644
--- a/libmysqld/examples/Makefile.am
+++ b/libmysqld/examples/Makefile.am
@@ -34,8 +34,8 @@ link_sources:
DEFS = -DEMBEDDED_LIBRARY
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir) \
-I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir)/regex \
- $(openssl_includes)
-LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@
+ $(openssl_includes) $(yassl_includes)
+LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @LIBDL@ $(CXXLDFLAGS)
mysqltest_embedded_LINK = $(CXXLINK)
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index e3e9dab78bd..5b40b250786 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -556,6 +556,12 @@ ERROR 3D000: No database selected
alter table test.t1 rename test.t1;
use test;
drop table t1;
+create table t1 (mycol int(10) not null);
+alter table t1 alter column mycol set default 0;
+desc t1;
+Field Type Null Key Default Extra
+mycol int(10) NO 0
+drop table t1;
create table t1 (v varchar(32));
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
select * from t1;
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index a201af78518..c981d3092a7 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -743,3 +743,22 @@ t2 CREATE TABLE `t2` (
`a2` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1, t2;
+create table t1 (i int) engine=myisam max_rows=100000000000;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
+alter table t1 max_rows=100;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=100
+alter table t1 max_rows=100000000000;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
+drop table t1;
diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result
index da0007fdfbe..1b92da2a7a3 100644
--- a/mysql-test/r/ctype_recoding.result
+++ b/mysql-test/r/ctype_recoding.result
@@ -181,11 +181,18 @@ select * from t1 where a=_koi8r'×ÁÓÑ';
a
×ÁÓÑ
select * from t1 where a=concat(_koi8r'×ÁÓÑ');
-ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (koi8r_general_ci,COERCIBLE) for operation '='
+a
+×ÁÓÑ
select * from t1 where a=_latin1'×ÁÓÑ';
ERROR HY000: Illegal mix of collations (cp1251_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='
drop table t1;
set names latin1;
+create table t1 (a char(10) character set utf8 collate utf8_bin);
+insert into t1 values (' xxx');
+select * from t1 where a=lpad('xxx',10,' ');
+a
+ xxx
+drop table t1;
set names koi8r;
create table t1 (c1 char(10) character set cp1251);
insert into t1 values ('ß');
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 874983daff2..c57b06f4895 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -1095,6 +1095,11 @@ char(0xff,0x8f using utf8)
ÿ
Warnings:
Warning 1300 Invalid utf8 character string: 'FF8F'
+select convert(char(0xff,0x8f) using utf8);
+convert(char(0xff,0x8f) using utf8)
+ÿ
+Warnings:
+Warning 1300 Invalid utf8 character string: 'FF8F'
set sql_mode=traditional;
select char(0xff,0x8f using utf8);
char(0xff,0x8f using utf8)
@@ -1116,6 +1121,11 @@ char(2557 using utf8)
NULL
Warnings:
Error 1300 Invalid utf8 character string: 'FD'
+select convert(char(0xff,0x8f) using utf8);
+convert(char(0xff,0x8f) using utf8)
+NULL
+Warnings:
+Error 1300 Invalid utf8 character string: 'FF8F'
select hex(convert(char(2557 using latin1) using utf8));
hex(convert(char(2557 using latin1) using utf8))
09C3BD
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index f0d323670e0..7e2e0a56212 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -433,4 +433,7 @@ INSERT INTO t1 VALUES('testword\'\'');
SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE);
a
testword''
+SELECT a FROM t1 WHERE MATCH a AGAINST('testword\'\'' IN BOOLEAN MODE);
+a
+testword''
DROP TABLE t1;
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index a9f90e24556..448847bc919 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -594,3 +594,24 @@ flush privileges;
set @user123="non-existent";
select * from mysql.db where user=@user123;
Host Db User Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Grant_priv References_priv Index_priv Alter_priv Create_tmp_table_priv Lock_tables_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Execute_priv
+set names koi8r;
+create database ÂÄ;
+grant select on ÂÄ.* to root@localhost;
+select hex(Db) from mysql.db where Db='ÂÄ';
+hex(Db)
+D0B1D0B4
+show grants for root@localhost;
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+GRANT SELECT ON `ÂÄ`.* TO 'root'@'localhost'
+flush privileges;
+show grants for root@localhost;
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+GRANT SELECT ON `ÂÄ`.* TO 'root'@'localhost'
+drop database ÂÄ;
+revoke all privileges on ÂÄ.* from root@localhost;
+show grants for root@localhost;
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+set names latin1;
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index 038d0c75f74..91f7eaeea2c 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -2002,3 +2002,13 @@ a count(a)
1 1
NULL 1
drop table t1;
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb;
+insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
+alter table t1 drop primary key, add primary key (f2, f1);
+explain select distinct f1 a, f1 b from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 5 NULL 4 Using index; Using temporary
+explain select distinct f1, f2 from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary
+drop table t1;
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index c887dc9d6a7..724d1b1e39f 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -391,3 +391,304 @@ i i i
2 NULL 4
2 2 2
drop table t1,t2,t3;
+create table t1 (c int, b int);
+create table t2 (a int, b int);
+create table t3 (b int, c int);
+create table t4 (y int, c int);
+create table t5 (y int, z int);
+create table t6 (a int, c int);
+insert into t1 values (10,1);
+insert into t1 values (3 ,1);
+insert into t1 values (3 ,2);
+insert into t2 values (2, 1);
+insert into t3 values (1, 3);
+insert into t3 values (1,10);
+insert into t4 values (11,3);
+insert into t4 values (2, 3);
+insert into t5 values (11,4);
+insert into t6 values (2, 3);
+create algorithm=merge view v1a as
+select * from t1 natural join t2;
+create algorithm=merge view v1b(a,b,c) as
+select * from t1 natural join t2;
+create algorithm=merge view v1c as
+select b as a, c as b, a as c from t1 natural join t2;
+create algorithm=merge view v1d(b, a, c) as
+select a as c, c as b, b as a from t1 natural join t2;
+create algorithm=merge view v2a as
+select t1.c, t1.b, t2.a from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
+create algorithm=merge view v2b as
+select t1.c as b, t1.b as a, t2.a as c
+from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
+create algorithm=merge view v3a as
+select * from t1 natural join t2 natural join t3;
+create algorithm=merge view v3b as
+select * from t1 natural join (t2 natural join t3);
+create algorithm=merge view v4 as
+select * from v2a natural join v3a;
+select * from (t1 natural join t2) natural join (t3 natural join t4);
+b c a y
+1 3 2 11
+1 3 2 2
+select * from (t1 natural join t2) natural left join (t3 natural join t4);
+b c a y
+1 10 2 NULL
+1 3 2 11
+1 3 2 2
+select * from (t3 natural join t4) natural right join (t1 natural join t2);
+b c a y
+1 10 2 NULL
+1 3 2 11
+1 3 2 2
+select * from (t1 natural left join t2) natural left join (t3 natural left join t4);
+b c a y
+1 10 2 NULL
+1 3 2 11
+1 3 2 2
+2 3 NULL NULL
+select * from (t4 natural right join t3) natural right join (t2 natural right join t1);
+b c a y
+1 10 2 NULL
+1 3 2 11
+1 3 2 2
+2 3 NULL NULL
+select * from t1 natural join t2 natural join t3 natural join t4;
+c b a y
+3 1 2 11
+3 1 2 2
+select * from ((t1 natural join t2) natural join t3) natural join t4;
+c b a y
+3 1 2 11
+3 1 2 2
+select * from t1 natural join (t2 natural join (t3 natural join t4));
+c b a y
+3 1 2 11
+3 1 2 2
+select * from t5 natural right join (t4 natural right join ((t2 natural right join t1) natural right join t3));
+y c b a z
+11 3 1 2 4
+2 3 1 2 NULL
+NULL 10 1 2 NULL
+select * from (t1 natural join t2), (t3 natural join t4);
+b c a c b y
+1 10 2 3 1 11
+1 10 2 3 1 2
+1 3 2 3 1 11
+1 3 2 3 1 2
+select * from (t1 join t2 using (b)) join (t3 join t4 using (c)) using (c);
+c b a b y
+3 1 2 1 11
+3 1 2 1 2
+select * from (t1 join t2 using (b)) natural join (t3 join t4 using (c));
+b c a y
+1 3 2 11
+1 3 2 2
+select a,b,c from (t1 natural join t2) natural join (t3 natural join t4)
+where b + 1 = y or b + 10 = y group by b,c,a having min(b) < max(y) order by a;
+a b c
+2 1 3
+select * from (t1 natural join t2) natural left join (t3 natural join t4)
+where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y;
+b c a y
+1 3 2 2
+1 3 2 11
+select * from (t3 natural join t4) natural right join (t1 natural join t2)
+where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y;
+b c a y
+1 3 2 2
+1 3 2 11
+select * from t1 natural join t2 where t1.c > t2.a;
+b c a
+1 10 2
+1 3 2
+select * from t1 natural join t2 where t1.b > t2.b;
+b c a
+select * from t1 natural left join (t4 natural join t5) where t5.z is not NULL;
+c b y z
+3 1 11 4
+3 2 11 4
+select * from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
+c b a b y c
+3 1 2 1 2 3
+3 2 2 1 2 3
+select * from (t2 join t4 on b + 1 = y) join t1 on t1.c = t4.c;
+a b y c c b
+2 1 2 3 3 1
+2 1 2 3 3 2
+select * from t1 natural join (t2 join t4 on b + 1 = y);
+c b a y
+3 1 2 2
+select * from (t1 cross join t2) join (t3 cross join t4) on (a < y and t2.b < t3.c);
+c b a b b c y c
+10 1 2 1 1 3 11 3
+10 1 2 1 1 10 11 3
+3 1 2 1 1 3 11 3
+3 1 2 1 1 10 11 3
+3 2 2 1 1 3 11 3
+3 2 2 1 1 10 11 3
+select * from (t1, t2) join (t3, t4) on (a < y and t2.b < t3.c);
+c b a b b c y c
+10 1 2 1 1 3 11 3
+10 1 2 1 1 10 11 3
+3 1 2 1 1 3 11 3
+3 1 2 1 1 10 11 3
+3 2 2 1 1 3 11 3
+3 2 2 1 1 10 11 3
+select * from (t1 natural join t2) join (t3 natural join t4) on a = y;
+b c a c b y
+1 10 2 3 1 2
+1 3 2 3 1 2
+select * from ((t3 join (t1 join t2 on c > a) on t3.b < t2.a) join t4 on y > t1.c) join t5 on z = t1.b + 3;
+b c c b a b y c y z
+1 3 10 1 2 1 11 3 11 4
+1 10 10 1 2 1 11 3 11 4
+1 3 3 1 2 1 11 3 11 4
+1 10 3 1 2 1 11 3 11 4
+select * from t1 natural join t2 where t1.b > 0;
+b c a
+1 10 2
+1 3 2
+select * from t1 natural join (t4 natural join t5) where t4.y > 7;
+c b y z
+3 1 11 4
+3 2 11 4
+select * from (t4 natural join t5) natural join t1 where t4.y > 7;
+c y z b
+3 11 4 1
+3 11 4 2
+select * from t1 natural left join (t4 natural join t5) where t4.y > 7;
+c b y z
+3 1 11 4
+3 2 11 4
+select * from (t4 natural join t5) natural right join t1 where t4.y > 7;
+c b y z
+3 1 11 4
+3 2 11 4
+select * from (t1 natural join t2) join (t3 natural join t4) on t1.b = t3.b;
+b c a c b y
+1 10 2 3 1 11
+1 10 2 3 1 2
+1 3 2 3 1 11
+1 3 2 3 1 2
+select t1.*, t2.* from t1 natural join t2;
+c b a b
+10 1 2 1
+3 1 2 1
+select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) natural join (t3 natural join t4);
+c b a b b c y c
+3 1 2 1 1 3 11 3
+3 1 2 1 1 3 2 3
+select * from (select * from t1 natural join t2) as t12
+natural join
+(select * from t3 natural join t4) as t34;
+b c a y
+1 3 2 11
+1 3 2 2
+select * from (select * from t1 natural join t2) as t12
+natural left join
+(select * from t3 natural join t4) as t34;
+b c a y
+1 10 2 NULL
+1 3 2 11
+1 3 2 2
+select * from (select * from t3 natural join t4) as t34
+natural right join
+(select * from t1 natural join t2) as t12;
+b c a y
+1 10 2 NULL
+1 3 2 11
+1 3 2 2
+select * from v1a;
+b c a
+1 10 2
+1 3 2
+select * from v1b;
+a b c
+1 10 2
+1 3 2
+select * from v1c;
+a b c
+1 10 2
+1 3 2
+select * from v1d;
+b a c
+2 10 1
+2 3 1
+select * from v2a;
+c b a
+3 1 2
+3 2 2
+select * from v2b;
+b a c
+3 1 2
+3 2 2
+select * from v3a;
+b c a
+1 10 2
+1 3 2
+select * from v3b;
+c b a
+10 1 2
+3 1 2
+select * from v4;
+c b a
+3 1 2
+select * from v1a natural join v2a;
+b c a
+1 3 2
+select v2a.* from v1a natural join v2a;
+c b a
+3 1 2
+select * from v1b join v2a on v1b.b = v2a.c;
+a b c c b a
+1 3 2 3 1 2
+1 3 2 3 2 2
+select * from v1c join v2a on v1c.b = v2a.c;
+a b c c b a
+1 3 2 3 1 2
+1 3 2 3 2 2
+select * from v1d join v2a on v1d.a = v2a.c;
+b a c c b a
+2 3 1 3 1 2
+2 3 1 3 2 2
+select * from v1a join (t3 natural join t4) on a = y;
+b c a c b y
+1 10 2 3 1 2
+1 3 2 3 1 2
+select * from t1 natural join (t3 cross join t4);
+ERROR 23000: Column 'c' in from clause is ambiguous
+select * from (t3 cross join t4) natural join t1;
+ERROR 23000: Column 'c' in from clause is ambiguous
+select * from t1 join (t2, t3) using (b);
+ERROR 23000: Column 'b' in from clause is ambiguous
+select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
+ERROR 23000: Column 'c' in from clause is ambiguous
+select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
+ERROR 23000: Column 'c' in from clause is ambiguous
+select * from (t1 join t2 on t1.b=t2.b) natural join (t3 natural join t4);
+ERROR 23000: Column 'b' in from clause is ambiguous
+select * from (t3 natural join t4) natural join (t1 join t2 on t1.b=t2.b);
+ERROR 23000: Column 'b' in from clause is ambiguous
+select * from (t3 join (t4 natural join t5) on (b < z))
+natural join
+(t1 natural join t2);
+ERROR 23000: Column 'c' in from clause is ambiguous
+select t1.b from v1a;
+ERROR 42S22: Unknown column 't1.b' in 'field list'
+select * from v1a join v1b on t1.b = t2.b;
+ERROR 42S22: Unknown column 't1.b' in 'on clause'
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+drop table t5;
+drop table t6;
+drop view v1a;
+drop view v1b;
+drop view v1c;
+drop view v1d;
+drop view v2a;
+drop view v2b;
+drop view v3a;
+drop view v3b;
+drop view v4;
diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result
index c4dd6cf9a86..6b7293d46bc 100644
--- a/mysql-test/r/join_nested.result
+++ b/mysql-test/r/join_nested.result
@@ -1466,4 +1466,4 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ref a a 5 test.t3.b X
1 SIMPLE t6 ref a a 5 test.t4.b X
1 SIMPLE t5 ref a a 5 test.t3.b X
-drop table t0, t1, t2, t4, t5, t6;
+drop table t0, t1, t2, t3, t4, t5, t6, t7;
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index bb89ff29b8a..d1dce9cd49f 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -2494,6 +2494,45 @@ drop view v2;
drop view v0;
drop view v1;
drop table t1;
+drop table if exists t1;
+CREATE TABLE t1(a int, b int);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (2,3);
+INSERT INTO t1 VALUES (3,4), (4,5);
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+ `a` int(11) default NULL,
+ `b` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
+LOCK TABLES `t1` WRITE;
+REPLACE INTO `t1` VALUES (1,1),(2,3),(3,4),(4,5);
+UNLOCK TABLES;
+/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+DROP TABLE t1;
SET @old_sql_mode = @@SQL_MODE;
SET SQL_MODE = IGNORE_SPACE;
CREATE TABLE t1 (a INT);
@@ -2549,4 +2588,3 @@ DELIMITER ;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TRIGGER tr1;
-DROP TABLE t1;
diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result
index ee88b7c8007..7526e7348d6 100644
--- a/mysql-test/r/ndb_alter_table.result
+++ b/mysql-test/r/ndb_alter_table.result
@@ -179,7 +179,7 @@ a b c
2 two two
alter table t1 drop index c;
select * from t1 where b = 'two';
-ERROR HY000: Table definition has changed, please retry transaction
+ERROR HY000: Can't lock file (errno: 159)
select * from t1 where b = 'two';
a b c
2 two two
diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result
index 23022378d60..993afcc5860 100644
--- a/mysql-test/r/ndb_basic.result
+++ b/mysql-test/r/ndb_basic.result
@@ -667,13 +667,13 @@ counter datavalue
57 newval
58 newval
drop table t1;
+CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb;
+select * from t1;
+b
+drop table t1;
create table atablewithareallylongandirritatingname (a int);
insert into atablewithareallylongandirritatingname values (2);
select * from atablewithareallylongandirritatingname;
a
2
drop table atablewithareallylongandirritatingname;
-CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb;
-select * from t1;
-b
-drop table t1;
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index f1c3672083d..994c375da83 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -806,3 +806,29 @@ execute stmt;
@@tx_isolation
REPEATABLE-READ
deallocate prepare stmt;
+prepare stmt from "create temporary table t1 (letter enum('','a','b','c')
+not null)";
+execute stmt;
+drop table t1;
+execute stmt;
+drop table t1;
+execute stmt;
+drop table t1;
+set names latin1;
+prepare stmt from "create table t1 (a enum('test') default 'test')
+ character set utf8";
+execute stmt;
+drop table t1;
+execute stmt;
+drop table t1;
+execute stmt;
+drop table t1;
+set names default;
+deallocate prepare stmt;
+create table t1 (id int);
+prepare ins_call from "insert into t1 (id) values (1)";
+execute ins_call;
+select row_count();
+row_count()
+1
+drop table t1;
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 8a126b7ddfb..598ea2b10d1 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2708,6 +2708,14 @@ select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1;
count(f2) >0
1
drop table t1,t2;
+create table t1 (f1 int,f2 int);
+insert into t1 values(1,1);
+create table t2 (f3 int, f4 int, primary key(f3,f4));
+insert into t2 values(1,1);
+select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2));
+f1 f2
+1 1
+drop table t1,t2;
CREATE TABLE t1 ( city char(30) );
INSERT INTO t1 VALUES ('London');
INSERT INTO t1 VALUES ('Paris');
@@ -3283,3 +3291,49 @@ f1 f2 x1
30 1 30
drop table t1;
drop view v1, v2, v3;
+CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a));
+CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a));
+CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32),
+PRIMARY KEY(key_a,key_b));
+INSERT INTO t1 VALUES (0,'');
+INSERT INTO t1 VALUES (1,'i');
+INSERT INTO t1 VALUES (2,'j');
+INSERT INTO t1 VALUES (3,'k');
+INSERT INTO t2 VALUES (1,'r');
+INSERT INTO t2 VALUES (2,'s');
+INSERT INTO t2 VALUES (3,'t');
+INSERT INTO t3 VALUES (1,5,'x');
+INSERT INTO t3 VALUES (1,6,'y');
+INSERT INTO t3 VALUES (2,5,'xx');
+INSERT INTO t3 VALUES (2,6,'yy');
+INSERT INTO t3 VALUES (2,7,'zz');
+INSERT INTO t3 VALUES (3,5,'xxx');
+SELECT t2.key_a,foo
+FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a
+INNER JOIN t3 ON t1.key_a = t3.key_a
+WHERE t2.key_a=2 and key_b=5;
+key_a foo
+2 xx
+EXPLAIN SELECT t2.key_a,foo
+FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a
+INNER JOIN t3 ON t1.key_a = t3.key_a
+WHERE t2.key_a=2 and key_b=5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
+1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index
+1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1
+SELECT t2.key_a,foo
+FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a
+INNER JOIN t3 ON t1.key_a = t3.key_a
+WHERE t2.key_a=2 and key_b=5;
+key_a foo
+2 xx
+EXPLAIN SELECT t2.key_a,foo
+FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a
+INNER JOIN t3 ON t1.key_a = t3.key_a
+WHERE t2.key_a=2 and key_b=5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
+1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index
+1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index c3b4039d12d..694cf903d35 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -988,6 +988,10 @@ end|
select f5(1)|
f5(1)
1
+select f5(2)|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+select f5(3)|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
create function f6() returns int
begin
declare n int;
@@ -1035,6 +1039,12 @@ select * from v1|
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
create function f1() returns int
return (select sum(data) from t1) + (select sum(data) from v1)|
+select f1()|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+select * from v1|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+select * from v2|
+ERROR HY000: Recursive stored functions and triggers are not allowed.
drop function f1|
create function f1() returns int
return (select sum(data) from t1)|
@@ -1053,7 +1063,7 @@ f0()
select *, f0() from v0|
f0() f0()
100 100
-lock tables t1 read, t1 as t11 read, mysql.proc read|
+lock tables t1 read, t1 as t11 read|
select f3()|
f3()
1
@@ -1251,6 +1261,62 @@ drop procedure opp|
drop procedure ip|
show procedure status like '%p%'|
Db Name Type Definer Modified Created Security_type Comment
+drop table if exists fib|
+create table fib ( f bigint unsigned not null )|
+drop procedure if exists fib|
+create procedure fib(n int unsigned)
+begin
+if n > 1 then
+begin
+declare x, y bigint unsigned;
+declare c cursor for select f from fib order by f desc limit 2;
+open c;
+fetch c into y;
+fetch c into x;
+close c;
+insert into fib values (x+y);
+call fib(n-1);
+end;
+end if;
+end|
+set @@max_sp_recursion_depth= 20|
+insert into fib values (0), (1)|
+call fib(3)|
+select * from fib order by f asc|
+f
+0
+1
+1
+2
+delete from fib|
+insert into fib values (0), (1)|
+call fib(20)|
+select * from fib order by f asc|
+f
+0
+1
+1
+2
+3
+5
+8
+13
+21
+34
+55
+89
+144
+233
+377
+610
+987
+1597
+2584
+4181
+6765
+drop table fib|
+drop procedure fib|
+set @@max_sp_recursion_depth= 0|
drop procedure if exists bar|
create procedure bar(x char(16), y int)
comment "111111111111" sql security invoker
@@ -1479,6 +1545,52 @@ select @x2|
@x2
2
drop procedure bug2260|
+drop procedure if exists bug2267_1|
+create procedure bug2267_1()
+begin
+show procedure status;
+end|
+drop procedure if exists bug2267_2|
+create procedure bug2267_2()
+begin
+show function status;
+end|
+drop procedure if exists bug2267_3|
+create procedure bug2267_3()
+begin
+show create procedure bug2267_1;
+end|
+drop procedure if exists bug2267_4|
+drop function if exists bug2267_4|
+create procedure bug2267_4()
+begin
+show create function bug2267_4;
+end|
+create function bug2267_4() returns int return 100|
+call bug2267_1()|
+Db Name Type Definer Modified Created Security_type Comment
+test bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+call bug2267_2()|
+Db Name Type Definer Modified Created Security_type Comment
+test bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
+call bug2267_3()|
+Procedure sql_mode Create Procedure
+bug2267_1 CREATE PROCEDURE `bug2267_1`()
+begin
+show procedure status;
+end
+call bug2267_4()|
+Function sql_mode Create Function
+bug2267_4 CREATE FUNCTION `bug2267_4`() RETURNS int(11)
+return 100
+drop procedure bug2267_1|
+drop procedure bug2267_2|
+drop procedure bug2267_3|
+drop procedure bug2267_4|
+drop function bug2267_4|
drop procedure if exists bug2227|
create procedure bug2227(x int)
begin
@@ -1490,6 +1602,18 @@ call bug2227(9)|
1.3 x y 42 z
1.3 9 2.6 42 zzz
drop procedure bug2227|
+drop procedure if exists bug2614|
+create procedure bug2614()
+begin
+drop table if exists t3;
+create table t3 (id int default '0' not null);
+insert into t3 select 12;
+insert into t3 select * from t3;
+end|
+call bug2614()|
+call bug2614()|
+drop table t3|
+drop procedure bug2614|
drop function if exists bug2674|
create function bug2674() returns int
return @@sort_buffer_size|
@@ -3868,5 +3992,58 @@ drop procedure bug10100pv|
drop procedure bug10100pd|
drop procedure bug10100pc|
drop view v1|
+drop procedure if exists bug13729|
+drop table if exists t3|
+create table t3 (s1 int, primary key (s1))|
+insert into t3 values (1),(2)|
+create procedure bug13729()
+begin
+declare continue handler for sqlexception select 55;
+update t3 set s1 = 1;
+end|
+call bug13729()|
+55
+55
+select * from t3|
+s1
+1
+2
+drop procedure bug13729|
drop table t3|
+drop procedure if exists bug14643_1|
+drop procedure if exists bug14643_2|
+create procedure bug14643_1()
+begin
+declare continue handler for sqlexception select 'boo' as 'Handler';
+begin
+declare v int default x;
+if v = 1 then
+select 1;
+else
+select 2;
+end if;
+end;
+end|
+create procedure bug14643_2()
+begin
+declare continue handler for sqlexception select 'boo' as 'Handler';
+case x
+when 1 then
+select 1;
+else
+select 2;
+end case;
+end|
+call bug14643_1()|
+Handler
+boo
+2
+2
+call bug14643_2()|
+Handler
+boo
+2
+2
+drop procedure bug14643_1|
+drop procedure bug14643_2|
drop table t1,t2;
diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result
index bb742d0d3d7..8f2bd9985fc 100644
--- a/mysql-test/r/sp_trans.result
+++ b/mysql-test/r/sp_trans.result
@@ -369,3 +369,59 @@ drop procedure bug13825_0|
drop procedure bug13825_1|
drop procedure bug13825_2|
drop table t1, t2|
+drop table if exists t3|
+drop procedure if exists bug14840_1|
+drop procedure if exists bug14840_2|
+create table t3
+(
+x int,
+y int,
+primary key (x)
+) engine=InnoDB|
+create procedure bug14840_1()
+begin
+declare err int default 0;
+declare continue handler for sqlexception
+set err = err + 1;
+start transaction;
+update t3 set x = 1, y = 42 where x = 2;
+insert into t3 values (3, 4711);
+if err > 0 then
+rollback;
+else
+commit;
+end if;
+select * from t3;
+end|
+create procedure bug14840_2()
+begin
+declare err int default 0;
+declare continue handler for sqlexception
+begin
+set err = err + 1;
+select err as 'Ping';
+end;
+update t3 set x = 1, y = 42 where x = 2;
+update t3 set x = 1, y = 42 where x = 2;
+insert into t3 values (3, 4711);
+select * from t3;
+end|
+insert into t3 values (1, 3), (2, 5)|
+call bug14840_1()|
+x y
+1 3
+2 5
+delete from t3|
+insert into t3 values (1, 3), (2, 5)|
+call bug14840_2()|
+Ping
+1
+Ping
+2
+x y
+1 3
+2 5
+3 4711
+drop procedure bug14840_1|
+drop procedure bug14840_2|
+drop table t3|
diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result
index ff07dcca106..bcdba3dca76 100644
--- a/mysql-test/r/type_ranges.result
+++ b/mysql-test/r/type_ranges.result
@@ -215,7 +215,7 @@ Field Type Collation Null Key Default Extra Privileges Comment
auto int(5) unsigned NULL NO MUL NULL auto_increment #
string char(10) latin1_swedish_ci YES newdefault #
tiny tinyint(4) NULL NO MUL 0 #
-short smallint(6) NULL NO MUL 0 #
+short smallint(6) NULL NO MUL #
medium mediumint(8) NULL NO MUL 0 #
long_int int(11) NULL NO 0 #
longlong bigint(13) NULL NO MUL 0 #
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 042dfb5ad8d..f2708a50c77 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1220,6 +1220,32 @@ show columns from t2;
Field Type Null Key Default Extra
a varchar(3) YES NULL
drop table t2, t1;
+create table t1 (f1 decimal(60,25), f2 decimal(60,25));
+insert into t1 values (0.0,0.0);
+select f1 from t1 union all select f2 from t1;
+f1
+0.0000000000000000000000000
+0.0000000000000000000000000
+select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
+union all
+select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
+description f1
+XXXXXXXXXXXXXXXXXXXX 0.0000000000000000000000000
+YYYYYYYYYYYYYYYYYYYY 0.0000000000000000000000000
+drop table t1;
+create table t1 (f1 decimal(60,24), f2 decimal(60,24));
+insert into t1 values (0.0,0.0);
+select f1 from t1 union all select f2 from t1;
+f1
+0.000000000000000000000000
+0.000000000000000000000000
+select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
+union all
+select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
+description f1
+XXXXXXXXXXXXXXXXXXXX 0.000000000000000000000000
+YYYYYYYYYYYYYYYYYYYY 0.000000000000000000000000
+drop table t1;
create table t1 (a varchar(5));
create table t2 select * from t1 union select 'abcdefghijkl';
show create table t2;
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index 6a9e482a12b..90109c17b62 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -405,9 +405,17 @@ drop table t1;
# End of 4.1 tests
#
-# Some additional tests for new, faster alter table.
-# Note that most of the whole alter table code is being
-# tested all around the test suite already.
+# Bug #14693 (ALTER SET DEFAULT doesn't work)
+#
+
+create table t1 (mycol int(10) not null);
+alter table t1 alter column mycol set default 0;
+desc t1;
+drop table t1;
+
+#
+# Some additional tests for new, faster alter table. Note that most of the
+# whole alter table code is being tested all around the test suite already.
#
create table t1 (v varchar(32));
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 470a7bcbb59..6f3bc67cb30 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -631,3 +631,17 @@ show create table t2;
drop table t1, t2;
# End of 4.1 tests
+
+#
+# Bug #14155: Maximum value of MAX_ROWS handled incorrectly on 64-bit
+# platforms
+#
+create table t1 (i int) engine=myisam max_rows=100000000000;
+show create table t1;
+alter table t1 max_rows=100;
+show create table t1;
+alter table t1 max_rows=100000000000;
+show create table t1;
+drop table t1;
+
+# End of 5.0 tests
diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test
index 9949ef88da4..5648cea7fd3 100644
--- a/mysql-test/t/ctype_recoding.test
+++ b/mysql-test/t/ctype_recoding.test
@@ -144,8 +144,7 @@ create table t1 (a char(10) character set cp1251);
insert into t1 values (_koi8r'×ÁÓÑ');
# this is possible:
select * from t1 where a=_koi8r'×ÁÓÑ';
-# this is not possible, because we have a function, not just a constant:
---error 1267
+# this is possible, because we have a function with constant arguments:
select * from t1 where a=concat(_koi8r'×ÁÓÑ');
# this is not posible, cannot convert _latin1'×ÁÓÑ' into cp1251:
--error 1267
@@ -154,6 +153,14 @@ drop table t1;
set names latin1;
#
+# Bug#10446 Illegal mix of collations
+#
+create table t1 (a char(10) character set utf8 collate utf8_bin);
+insert into t1 values (' xxx');
+select * from t1 where a=lpad('xxx',10,' ');
+drop table t1;
+
+#
# Check more automatic conversion
#
set names koi8r;
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 5670e9efbf9..a96564f4e76 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -884,7 +884,9 @@ SELECT DISTINCT id FROM t1 ORDER BY id;
DROP TABLE t1;
#
-# Bugs#10504: Character set does not support traditional mode
+# Bug#10504: Character set does not support traditional mode
+# Bug#14146: CHAR(...USING ...) and CONVERT(CHAR(...) USING...)
+# produce different results
#
set names utf8;
# correct value
@@ -894,12 +896,14 @@ select char(0xd18f using utf8);
select char(53647 using utf8);
# incorrect value: return with warning
select char(0xff,0x8f using utf8);
+select convert(char(0xff,0x8f) using utf8);
# incorrect value in strict mode: return NULL with "Error" level warning
set sql_mode=traditional;
select char(0xff,0x8f using utf8);
select char(195 using utf8);
select char(196 using utf8);
select char(2557 using utf8);
+select convert(char(0xff,0x8f) using utf8);
#
# Check convert + char + using
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index fe95a543fb5..47e46e7938d 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -1,6 +1,6 @@
##############################################################################
#
-# List the test cases that are to be disabled temporarely.
+# List the test cases that are to be disabled temporarily.
#
# Separate the test case name and the comment with ':'.
#
@@ -15,3 +15,5 @@ rpl_relayrotate : Unstable test case, bug#12429
rpl_until : Unstable test case, bug#12429
rpl_deadlock : Unstable test case, bug#12429
kill : Unstable test case, bug#9712
+ndb_cache2 : Bug #15004
+ndb_cache_multi2: Bug #15004
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index b52c5d0ec08..ea92ec944ed 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -354,6 +354,7 @@ SET myisam_repair_threads=@@global.myisam_repair_threads;
#
INSERT INTO t1 VALUES('testword\'\'');
SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE);
+SELECT a FROM t1 WHERE MATCH a AGAINST('testword\'\'' IN BOOLEAN MODE);
DROP TABLE t1;
# End of 4.1 tests
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index 635c7a3f4e7..e806df5e91c 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -487,4 +487,16 @@ flush privileges;
set @user123="non-existent";
select * from mysql.db where user=@user123;
+set names koi8r;
+create database ÂÄ;
+grant select on ÂÄ.* to root@localhost;
+select hex(Db) from mysql.db where Db='ÂÄ';
+show grants for root@localhost;
+flush privileges;
+show grants for root@localhost;
+drop database ÂÄ;
+revoke all privileges on ÂÄ.* from root@localhost;
+show grants for root@localhost;
+set names latin1;
+
# End of 4.1 tests
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index 3d751f4a571..9738bbcca49 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -693,3 +693,13 @@ create table t1(a int, key(a)) engine=innodb;
insert into t1 values(1);
select a, count(a) from t1 group by a with rollup;
drop table t1;
+
+#
+# Bug #13293 Wrongly used index results in endless loop.
+#
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb;
+insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
+alter table t1 drop primary key, add primary key (f2, f1);
+explain select distinct f1 a, f1 b from t1;
+explain select distinct f1, f2 from t1;
+drop table t1;
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index bb82a93c6c4..553aaf987bb 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -334,3 +334,210 @@ select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i
drop table t1,t2,t3;
# End of 4.1 tests
+
+#
+# Tests for WL#2486 Natural/using join according to SQL:2003.
+#
+# NOTICE:
+# - The tests are designed so that all statements, except MySQL
+# extensions run on any SQL server. Please do no change.
+# - Tests marked with TODO will be submitted as bugs.
+#
+
+create table t1 (c int, b int);
+create table t2 (a int, b int);
+create table t3 (b int, c int);
+create table t4 (y int, c int);
+create table t5 (y int, z int);
+create table t6 (a int, c int);
+
+insert into t1 values (10,1);
+insert into t1 values (3 ,1);
+insert into t1 values (3 ,2);
+insert into t2 values (2, 1);
+insert into t3 values (1, 3);
+insert into t3 values (1,10);
+insert into t4 values (11,3);
+insert into t4 values (2, 3);
+insert into t5 values (11,4);
+insert into t6 values (2, 3);
+
+-- Views with simple natural join.
+create algorithm=merge view v1a as
+select * from t1 natural join t2;
+-- as above, but column names are cross-renamed: a->c, c->b, b->a
+create algorithm=merge view v1b(a,b,c) as
+select * from t1 natural join t2;
+-- as above, but column names are aliased: a->c, c->b, b->a
+create algorithm=merge view v1c as
+select b as a, c as b, a as c from t1 natural join t2;
+-- as above, but column names are cross-renamed, and aliased
+-- a->c->b, c->b->a, b->a->c
+create algorithm=merge view v1d(b, a, c) as
+select a as c, c as b, b as a from t1 natural join t2;
+
+-- Views with JOIN ... ON
+create algorithm=merge view v2a as
+select t1.c, t1.b, t2.a from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
+create algorithm=merge view v2b as
+select t1.c as b, t1.b as a, t2.a as c
+from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
+
+-- Views with bigger natural join
+create algorithm=merge view v3a as
+select * from t1 natural join t2 natural join t3;
+create algorithm=merge view v3b as
+select * from t1 natural join (t2 natural join t3);
+
+-- View over views with mixed natural join and join ... on
+create algorithm=merge view v4 as
+select * from v2a natural join v3a;
+
+-- Nested natural/using joins.
+select * from (t1 natural join t2) natural join (t3 natural join t4);
+select * from (t1 natural join t2) natural left join (t3 natural join t4);
+select * from (t3 natural join t4) natural right join (t1 natural join t2);
+select * from (t1 natural left join t2) natural left join (t3 natural left join t4);
+select * from (t4 natural right join t3) natural right join (t2 natural right join t1);
+select * from t1 natural join t2 natural join t3 natural join t4;
+select * from ((t1 natural join t2) natural join t3) natural join t4;
+select * from t1 natural join (t2 natural join (t3 natural join t4));
+-- BUG#15355: this query fails in 'prepared statements' mode
+-- select * from ((t3 natural join (t1 natural join t2)) natural join t4) natural join t5;
+-- select * from ((t3 natural left join (t1 natural left join t2)) natural left join t4) natural left join t5;
+select * from t5 natural right join (t4 natural right join ((t2 natural right join t1) natural right join t3));
+select * from (t1 natural join t2), (t3 natural join t4);
+-- MySQL extension - nested comma ',' operator instead of cross join.
+-- BUG#15357 - natural join with nested cross-join results in incorrect columns
+-- select * from t5 natural join ((t1 natural join t2), (t3 natural join t4));
+-- select * from ((t1 natural join t2), (t3 natural join t4)) natural join t5;
+-- select * from t5 natural join ((t1 natural join t2) cross join (t3 natural join t4));
+-- select * from ((t1 natural join t2) cross join (t3 natural join t4)) natural join t5;
+
+select * from (t1 join t2 using (b)) join (t3 join t4 using (c)) using (c);
+select * from (t1 join t2 using (b)) natural join (t3 join t4 using (c));
+
+
+-- Other clauses refer to NJ columns.
+select a,b,c from (t1 natural join t2) natural join (t3 natural join t4)
+where b + 1 = y or b + 10 = y group by b,c,a having min(b) < max(y) order by a;
+select * from (t1 natural join t2) natural left join (t3 natural join t4)
+where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y;
+select * from (t3 natural join t4) natural right join (t1 natural join t2)
+where b + 1 = y or b + 10 = y group by b,c,a,y having min(b) < max(y) order by a, y;
+
+-- Qualified column references to NJ columns.
+select * from t1 natural join t2 where t1.c > t2.a;
+select * from t1 natural join t2 where t1.b > t2.b;
+select * from t1 natural left join (t4 natural join t5) where t5.z is not NULL;
+
+-- Nested 'join ... on' - name resolution of ON conditions
+select * from t1 join (t2 join t4 on b + 1 = y) on t1.c = t4.c;
+select * from (t2 join t4 on b + 1 = y) join t1 on t1.c = t4.c;
+select * from t1 natural join (t2 join t4 on b + 1 = y);
+select * from (t1 cross join t2) join (t3 cross join t4) on (a < y and t2.b < t3.c);
+
+-- MySQL extension - 'join ... on' over nested comma operator
+select * from (t1, t2) join (t3, t4) on (a < y and t2.b < t3.c);
+select * from (t1 natural join t2) join (t3 natural join t4) on a = y;
+select * from ((t3 join (t1 join t2 on c > a) on t3.b < t2.a) join t4 on y > t1.c) join t5 on z = t1.b + 3;
+
+-- MySQL extension - refererence qualified coalesced columns
+select * from t1 natural join t2 where t1.b > 0;
+select * from t1 natural join (t4 natural join t5) where t4.y > 7;
+select * from (t4 natural join t5) natural join t1 where t4.y > 7;
+select * from t1 natural left join (t4 natural join t5) where t4.y > 7;
+select * from (t4 natural join t5) natural right join t1 where t4.y > 7;
+select * from (t1 natural join t2) join (t3 natural join t4) on t1.b = t3.b;
+
+-- MySQL extension - select qualified columns of NJ columns
+select t1.*, t2.* from t1 natural join t2;
+select t1.*, t2.*, t3.*, t4.* from (t1 natural join t2) natural join (t3 natural join t4);
+
+-- Queries over subselects in the FROM clause
+select * from (select * from t1 natural join t2) as t12
+ natural join
+ (select * from t3 natural join t4) as t34;
+select * from (select * from t1 natural join t2) as t12
+ natural left join
+ (select * from t3 natural join t4) as t34;
+select * from (select * from t3 natural join t4) as t34
+ natural right join
+ (select * from t1 natural join t2) as t12;
+
+-- Queries over views
+select * from v1a;
+select * from v1b;
+select * from v1c;
+select * from v1d;
+select * from v2a;
+select * from v2b;
+select * from v3a;
+select * from v3b;
+select * from v4;
+select * from v1a natural join v2a;
+select v2a.* from v1a natural join v2a;
+select * from v1b join v2a on v1b.b = v2a.c;
+select * from v1c join v2a on v1c.b = v2a.c;
+select * from v1d join v2a on v1d.a = v2a.c;
+select * from v1a join (t3 natural join t4) on a = y;
+
+-- TODO: add tests with correlated subqueries for natural join/join on.
+-- related to BUG#15269
+
+
+----------------------------------------------------------------------
+-- Negative tests (tests for errors)
+----------------------------------------------------------------------
+-- error 1052
+select * from t1 natural join (t3 cross join t4); -- works in Oracle - bug
+-- error 1052
+select * from (t3 cross join t4) natural join t1; -- works in Oracle - bug
+-- error 1052
+select * from t1 join (t2, t3) using (b);
+-- error 1052
+select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
+-- error 1052
+select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
+-- error 1052
+-- BUG#15357: doesn't detect non-unique column 'c', as in the above query.
+-- select * from t6 natural join ((t1 natural join t2), (t3 natural join t4));
+-- error 1052
+select * from (t1 join t2 on t1.b=t2.b) natural join (t3 natural join t4);
+-- error 1052
+select * from (t3 natural join t4) natural join (t1 join t2 on t1.b=t2.b);
+-- this one is OK, the next equivalent one is incorrect (bug in Oracle)
+-- error 1052
+select * from (t3 join (t4 natural join t5) on (b < z))
+ natural join
+ (t1 natural join t2);
+-- error 1052
+-- BUG#15357: this query should return an ambiguous column error
+-- Expected result: the query must return error with duplicate column 'c'
+--select * from (t1 natural join t2)
+-- natural join
+-- (t3 join (t4 natural join t5) on (b < z));
+
+-- error 1054
+select t1.b from v1a;
+-- error 1054
+select * from v1a join v1b on t1.b = t2.b;
+
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+drop table t5;
+drop table t6;
+
+drop view v1a;
+drop view v1b;
+drop view v1c;
+drop view v1d;
+drop view v2a;
+drop view v2b;
+drop view v3a;
+drop view v3b;
+drop view v4;
+
+# End of tests for WL#2486 - natural/using join
diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test
index 9dbf153ec55..9f23e2d0e2f 100644
--- a/mysql-test/t/join_nested.test
+++ b/mysql-test/t/join_nested.test
@@ -899,4 +899,4 @@ explain select * from t2 left join
(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b
join t5 on t5.a=t3.b) on t3.a=t2.b;
-drop table t0, t1, t2, t4, t5, t6;
+drop table t0, t1, t2, t3, t4, t5, t6, t7;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 5666f23f5aa..24b17496266 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -994,12 +994,25 @@ create view v2 as select * from v0;
select * from v2;
--exec $MYSQL_DUMP -x --skip-comments --databases test
-
drop view v2;
drop view v0;
drop view v1;
drop table t1;
+# Check new --replace option
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1(a int, b int);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (2,3);
+INSERT INTO t1 VALUES (3,4), (4,5);
+--exec $MYSQL_DUMP --replace --skip-comments test t1
+DROP TABLE t1;
+
+
#
# BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
# for tables with trigger created in the IGNORE_SPACE sql mode.
@@ -1022,4 +1035,3 @@ SET SQL_MODE = @old_sql_mode;
--exec $MYSQL_DUMP --skip-comments --databases test
DROP TRIGGER tr1;
-DROP TABLE t1;
diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test
index 58e3e002b2a..77ec6c5e066 100644
--- a/mysql-test/t/ndb_alter_table.test
+++ b/mysql-test/t/ndb_alter_table.test
@@ -153,7 +153,7 @@ connection server1;
alter table t1 drop index c;
connection server2;
# This should fail since index information is not automatically refreshed
---error 1412
+--error 1015
select * from t1 where b = 'two';
select * from t1 where b = 'two';
connection server1;
diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test
index 1a351018b8d..0510651a417 100644
--- a/mysql-test/t/ndb_basic.test
+++ b/mysql-test/t/ndb_basic.test
@@ -606,6 +606,14 @@ select * from t1 order by counter;
drop table t1;
+#
+# BUG#14514 Creating table with packed key fails silently
+#
+
+CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb;
+select * from t1;
+drop table t1;
+
# End of 4.1 tests
#
@@ -615,12 +623,3 @@ create table atablewithareallylongandirritatingname (a int);
insert into atablewithareallylongandirritatingname values (2);
select * from atablewithareallylongandirritatingname;
drop table atablewithareallylongandirritatingname;
-
-
-#
-# BUG#14514
-#
-
-CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb;
-select * from t1;
-drop table t1;
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 94ee2b1ca39..22d0abf645e 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -842,4 +842,44 @@ set @@tx_isolation=default;
execute stmt;
deallocate prepare stmt;
+#
+# Bug#14410 "Crash in Enum or Set type in CREATE TABLE and PS/SP"
+#
+# Part I. Make sure the typelib for ENUM is created in the statement memory
+# root.
+prepare stmt from "create temporary table t1 (letter enum('','a','b','c')
+not null)";
+execute stmt;
+drop table t1;
+execute stmt;
+drop table t1;
+execute stmt;
+drop table t1;
+# Part II. Make sure that when the default value is converted to UTF-8,
+# the new item is # created in the statement memory root.
+set names latin1;
+prepare stmt from "create table t1 (a enum('test') default 'test')
+ character set utf8";
+execute stmt;
+drop table t1;
+execute stmt;
+drop table t1;
+execute stmt;
+drop table t1;
+# Cleanup
+set names default;
+deallocate prepare stmt;
+
# End of 4.1 tests
+
+#
+# Bug #14956: ROW_COUNT() returns incorrect result after EXECUTE of prepared
+# statement
+#
+create table t1 (id int);
+prepare ins_call from "insert into t1 (id) values (1)";
+execute ins_call;
+select row_count();
+drop table t1;
+
+# End of 5.0 tests
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 33a3ff578f8..a73d08f5f18 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2253,6 +2253,17 @@ insert into t1 values (1,1);
insert into t2 values (1,1),(1,2);
select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1;
drop table t1,t2;
+
+#
+# Bug #14482 Server crash when subselecting from the same table
+#
+create table t1 (f1 int,f2 int);
+insert into t1 values(1,1);
+create table t2 (f3 int, f4 int, primary key(f3,f4));
+insert into t2 values(1,1);
+select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 from t2));
+drop table t1,t2;
+
# End of 4.1 tests
#
@@ -2749,3 +2760,48 @@ select f1, f2, v2.f1 as x1 from v2 order by v2.f1;
select f1, f2, v3.f1 as x1 from v3 order by v3.f1;
drop table t1;
drop view v1, v2, v3;
+
+#
+# Bug #15106: lost equality predicate of the form field=const in a join query
+#
+
+CREATE TABLE t1(key_a int4 NOT NULL, optimus varchar(32), PRIMARY KEY(key_a));
+CREATE TABLE t2(key_a int4 NOT NULL, prime varchar(32), PRIMARY KEY(key_a));
+CREATE table t3(key_a int4 NOT NULL, key_b int4 NOT NULL, foo varchar(32),
+ PRIMARY KEY(key_a,key_b));
+
+INSERT INTO t1 VALUES (0,'');
+INSERT INTO t1 VALUES (1,'i');
+INSERT INTO t1 VALUES (2,'j');
+INSERT INTO t1 VALUES (3,'k');
+
+INSERT INTO t2 VALUES (1,'r');
+INSERT INTO t2 VALUES (2,'s');
+INSERT INTO t2 VALUES (3,'t');
+
+INSERT INTO t3 VALUES (1,5,'x');
+INSERT INTO t3 VALUES (1,6,'y');
+INSERT INTO t3 VALUES (2,5,'xx');
+INSERT INTO t3 VALUES (2,6,'yy');
+INSERT INTO t3 VALUES (2,7,'zz');
+INSERT INTO t3 VALUES (3,5,'xxx');
+
+SELECT t2.key_a,foo
+ FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a
+ INNER JOIN t3 ON t1.key_a = t3.key_a
+ WHERE t2.key_a=2 and key_b=5;
+EXPLAIN SELECT t2.key_a,foo
+ FROM t1 INNER JOIN t2 ON t1.key_a = t2.key_a
+ INNER JOIN t3 ON t1.key_a = t3.key_a
+ WHERE t2.key_a=2 and key_b=5;
+
+SELECT t2.key_a,foo
+ FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a
+ INNER JOIN t3 ON t1.key_a = t3.key_a
+ WHERE t2.key_a=2 and key_b=5;
+EXPLAIN SELECT t2.key_a,foo
+ FROM t1 INNER JOIN t2 ON t2.key_a = t1.key_a
+ INNER JOIN t3 ON t1.key_a = t3.key_a
+ WHERE t2.key_a=2 and key_b=5;
+
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index def6afc000e..5bbe9258461 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -1211,15 +1211,13 @@ begin
end if;
end|
select f5(1)|
-# This should generate an error about insuficient number of tables locked
-# Now this crash server
---disable_parsing # until bug#11394 fix
---error 1100
+# Since currently recursive functions are disallowed ER_SP_NO_RECURSION
+# error will be returned, once we will allow them error about
+# insufficient number of locked tables will be returned instead.
+--error ER_SP_NO_RECURSION
select f5(2)|
-# But now it simply miserably fails because we are trying to use the same
-# lex on the next iteration :/ It should generate some error too...
+--error ER_SP_NO_RECURSION
select f5(3)|
---enable_parsing
# OTOH this should work
create function f6() returns int
@@ -1265,13 +1263,12 @@ select * from v1|
# views and functions ?
create function f1() returns int
return (select sum(data) from t1) + (select sum(data) from v1)|
-# This queries will crash server because we can't use LEX in
-# reenterable fashion yet. Patch disabling recursion will heal this.
---disable_parsing
+--error ER_SP_NO_RECURSION
select f1()|
+--error ER_SP_NO_RECURSION
select * from v1|
+--error ER_SP_NO_RECURSION
select * from v2|
---enable_parsing
# Back to the normal cases
drop function f1|
create function f1() returns int
@@ -1289,9 +1286,7 @@ select *, f0() from v0|
#
# Let us test how well prelocking works with explicit LOCK TABLES.
#
-# Nowdays we have to lock mysql.proc to be able to read SP definitions.
-# But Monty was going to fix this.
-lock tables t1 read, t1 as t11 read, mysql.proc read|
+lock tables t1 read, t1 as t11 read|
# These should work well
select f3()|
select id, f3() from t1 as t11|
@@ -1481,9 +1476,6 @@ show procedure status like '%p%'|
# Fibonacci, for recursion test. (Yet Another Numerical series :)
#
-# This part of test is disabled until we implement support for
-# recursive stored procedures.
---disable_parsing
--disable_warnings
drop table if exists fib|
--enable_warnings
@@ -1512,6 +1504,9 @@ begin
end if;
end|
+# Enable recursion
+set @@max_sp_recursion_depth= 20|
+
# Minimum test: recursion of 3 levels
insert into fib values (0), (1)|
@@ -1531,7 +1526,7 @@ call fib(20)|
select * from fib order by f asc|
drop table fib|
drop procedure fib|
---enable_parsing
+set @@max_sp_recursion_depth= 0|
#
# Comment & suid
@@ -1800,16 +1795,8 @@ select @x2|
drop procedure bug2260|
#
-# BUG#2267
+# BUG#2267 "Lost connect if stored procedure has SHOW FUNCTION STATUS"
#
-# NOTE: This test case will be fixed as soon as Monty
-# will allow to open mysql.proc table under LOCK TABLES
-# without mentioning in lock list.
-#
-# FIXME: Other solution would be to use preopened proc table
-# instead of opening it anew.
-#
---disable_parsing
--disable_warnings
drop procedure if exists bug2267_1|
--enable_warnings
@@ -1836,11 +1823,13 @@ end|
--disable_warnings
drop procedure if exists bug2267_4|
+drop function if exists bug2267_4|
--enable_warnings
create procedure bug2267_4()
begin
- show create function fac;
+ show create function bug2267_4;
end|
+create function bug2267_4() returns int return 100|
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
call bug2267_1()|
@@ -1853,7 +1842,7 @@ drop procedure bug2267_1|
drop procedure bug2267_2|
drop procedure bug2267_3|
drop procedure bug2267_4|
---enable_parsing
+drop function bug2267_4|
#
# BUG#2227
@@ -1873,23 +1862,16 @@ call bug2227(9)|
drop procedure bug2227|
#
-# BUG#2614
+# BUG#2614 "Stored procedure with INSERT ... SELECT that does not
+# contain any tables crashes server"
#
-# QQ The second insert doesn't work with temporary tables (it was an
-# QQ ordinary table before we changed the locking scheme). It results
-# QQ in an error: 1137: Can't reopen table: 't3'
-# QQ which is a known limit with temporary tables.
-# QQ For this reason we can't run this test any more (i.e., if we modify
-# QQ it, it's no longer a test case for the bug), but we keep it here
-# QQ anyway, for tracability.
---disable_parsing
--disable_warnings
drop procedure if exists bug2614|
--enable_warnings
create procedure bug2614()
begin
- drop temporary table if exists t3;
- create temporary table t3 (id int default '0' not null);
+ drop table if exists t3;
+ create table t3 (id int default '0' not null);
insert into t3 select 12;
insert into t3 select * from t3;
end|
@@ -1898,9 +1880,8 @@ end|
call bug2614()|
--enable_warnings
call bug2614()|
-drop temporary table t3|
+drop table t3|
drop procedure bug2614|
---enable_parsing
#
# BUG#2674
@@ -4773,8 +4754,75 @@ drop procedure bug10100pv|
drop procedure bug10100pd|
drop procedure bug10100pc|
drop view v1|
+
+#
+# BUG#13729: Stored procedures: packet error after exception handled
+#
+--disable_warnings
+drop procedure if exists bug13729|
+drop table if exists t3|
+--enable_warnings
+
+create table t3 (s1 int, primary key (s1))|
+
+insert into t3 values (1),(2)|
+
+create procedure bug13729()
+begin
+ declare continue handler for sqlexception select 55;
+
+ update t3 set s1 = 1;
+end|
+
+call bug13729()|
+# Used to cause Packets out of order
+select * from t3|
+
+drop procedure bug13729|
drop table t3|
+#
+# BUG#14643: Stored Procedure: Continuing after failed var. initialization
+# crashes server.
+#
+--disable_warnings
+drop procedure if exists bug14643_1|
+drop procedure if exists bug14643_2|
+--enable_warnings
+
+create procedure bug14643_1()
+begin
+ declare continue handler for sqlexception select 'boo' as 'Handler';
+
+ begin
+ declare v int default x;
+
+ if v = 1 then
+ select 1;
+ else
+ select 2;
+ end if;
+ end;
+end|
+
+create procedure bug14643_2()
+begin
+ declare continue handler for sqlexception select 'boo' as 'Handler';
+
+ case x
+ when 1 then
+ select 1;
+ else
+ select 2;
+ end case;
+end|
+
+call bug14643_1()|
+call bug14643_2()|
+
+drop procedure bug14643_1|
+drop procedure bug14643_2|
+
#
# BUG#NNNN: New bug synopsis
diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test
index d72eaf5dca0..308d4ad5c33 100644
--- a/mysql-test/t/sp_trans.test
+++ b/mysql-test/t/sp_trans.test
@@ -356,6 +356,70 @@ drop table t1, t2|
#
+# BUG#14840: CONTINUE handler problem
+#
+--disable_warnings
+drop table if exists t3|
+drop procedure if exists bug14840_1|
+drop procedure if exists bug14840_2|
+--enable_warnings
+
+create table t3
+(
+ x int,
+ y int,
+ primary key (x)
+) engine=InnoDB|
+
+# This used to hang the client since the insert returned with an
+# error status (left over from the update) even though it succeeded,
+# which caused the execution to end at that point.
+create procedure bug14840_1()
+begin
+ declare err int default 0;
+ declare continue handler for sqlexception
+ set err = err + 1;
+
+ start transaction;
+ update t3 set x = 1, y = 42 where x = 2;
+ insert into t3 values (3, 4711);
+ if err > 0 then
+ rollback;
+ else
+ commit;
+ end if;
+ select * from t3;
+end|
+
+# A simpler (non-transactional) case: insert at select should be done
+create procedure bug14840_2()
+begin
+ declare err int default 0;
+ declare continue handler for sqlexception
+ begin
+ set err = err + 1;
+ select err as 'Ping';
+ end;
+
+ update t3 set x = 1, y = 42 where x = 2;
+ update t3 set x = 1, y = 42 where x = 2;
+ insert into t3 values (3, 4711);
+ select * from t3;
+end|
+
+insert into t3 values (1, 3), (2, 5)|
+call bug14840_1()|
+
+delete from t3|
+insert into t3 values (1, 3), (2, 5)|
+call bug14840_2()|
+
+drop procedure bug14840_1|
+drop procedure bug14840_2|
+drop table t3|
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index daa83ef0fa4..6de90dd446d 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -753,6 +753,24 @@ create table t2 select a from t1 union select b from t1;
show columns from t2;
drop table t2, t1;
+#
+# Bug #14216: UNION + DECIMAL wrong values in result
+#
+create table t1 (f1 decimal(60,25), f2 decimal(60,25));
+insert into t1 values (0.0,0.0);
+select f1 from t1 union all select f2 from t1;
+select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
+union all
+select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
+drop table t1;
+create table t1 (f1 decimal(60,24), f2 decimal(60,24));
+insert into t1 values (0.0,0.0);
+select f1 from t1 union all select f2 from t1;
+select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
+union all
+select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
+drop table t1;
+
#
# Test that union with VARCHAR produces dynamic row tables
#
diff --git a/mysys/my_open.c b/mysys/my_open.c
index baca97450b7..6ed3cb5becf 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -267,7 +267,7 @@ File my_sopen(const char *path, int oflag, int shflag, int pmode)
*/
switch (oflag & (_O_CREAT | _O_EXCL | _O_TRUNC)) {
case 0:
- case _O_EXCL: // ignore EXCL w/o CREAT
+ case _O_EXCL: /* ignore EXCL w/o CREAT */
filecreate= OPEN_EXISTING;
break;
@@ -281,7 +281,7 @@ File my_sopen(const char *path, int oflag, int shflag, int pmode)
break;
case _O_TRUNC:
- case _O_TRUNC | _O_EXCL: // ignore EXCL w/o CREAT
+ case _O_TRUNC | _O_EXCL: /* ignore EXCL w/o CREAT */
filecreate= TRUNCATE_EXISTING;
break;
@@ -290,7 +290,7 @@ File my_sopen(const char *path, int oflag, int shflag, int pmode)
break;
default:
- // this can't happen ... all cases are covered
+ /* this can't happen ... all cases are covered */
errno= EINVAL;
_doserrno= 0L;
return -1;
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh
index 1c5cd6a4faf..bf53aa78e15 100644
--- a/scripts/mysqlhotcopy.sh
+++ b/scripts/mysqlhotcopy.sh
@@ -252,6 +252,7 @@ if ( defined $opt{regexp} ) {
my $sth_dbs = $dbh->prepare("show databases");
$sth_dbs->execute;
while ( my ($db_name) = $sth_dbs->fetchrow_array ) {
+ next if $db_name =~ m/^information_schema$/i;
push @db_desc, { 'src' => $db_name, 't_regex' => $t_regex } if ( $db_name =~ m/$opt{regexp}/o );
}
}
diff --git a/sql-common/client.c b/sql-common/client.c
index cc90b2a105a..976d59d83a4 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1495,12 +1495,17 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
static void
mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
{
+ struct st_VioSSLConnectorFd *st=
+ (struct st_VioSSLConnectorFd*) mysql->connector_fd;
DBUG_ENTER("mysql_ssl_free");
+
my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
- my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
+ if (st)
+ SSL_CTX_free(st->ssl_context);
my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR));
mysql->options.ssl_key = 0;
mysql->options.ssl_cert = 0;
diff --git a/sql/authors.h b/sql/authors.h
index fa68b20c7a1..1c6e1d468c4 100644
--- a/sql/authors.h
+++ b/sql/authors.h
@@ -44,8 +44,7 @@ struct show_table_authors_st show_table_authors[]= {
"Unicode and character sets (4.1)" },
{ "Omer BarNir", "Sunnyvale, CA, USA",
"Testing (sometimes) and general QA stuff" },
- { "Guilhem Bichot", "Salles, France",
- "Replication, backup, mysql_tableinfo" },
+ { "Guilhem Bichot", "Bordeaux, France", "Replication (since 4.0)" },
{ "John Birrell", "", "Emulation of pthread_mutex() for OS/2" },
{ "Andreas F. Bobak", "", "AGGREGATE extension to user-defined functions" },
{ "Alexey Botchkov (Holyfoot)", "Izhevsk, Russia",
@@ -72,9 +71,12 @@ struct show_table_authors_st show_table_authors[]= {
{ "Nikolay Grishakin", "Austin, TX, USA", "Testing - Server" },
{ "Wei He", "", "Chinese (GBK) character set" },
{ "Eric Herman", "Amsterdam, Netherlands", "Bug fixing - federated" },
+ { "Alexander (Alexi) Ivanov", "St. Petersburg, Russia", "Replication" },
{ "Alexander (Salle) Keremidarski", "Sofia, Bulgaria",
"Bug fixing" },
+ { "Mats Kindahl", "Storvreta, Sweden", "Replication" },
{ "Serge Kozlov", "Velikie Luki, Russia", "Testing - Cluster" },
+ { "Greg (Groggy) Lehey", "Uchunga, SA, Australia", "Backup" },
{ "Matthias Leich", "Berlin, Germany", "Testing - Server" },
{ "Dmitri Lenev", "Moscow, Russia",
"Time zones support (4.1), Triggers (5.0)" },
@@ -86,6 +88,7 @@ struct show_table_authors_st show_table_authors[]= {
"UNION (4.0), Subqueries in FROM clause (4.1), many other features" },
{ "Jonathan (Jeb) Miller", "Kyle, TX, USA",
"Testing - Cluster, Replication" },
+ { "Elliot Murphy", "Cocoa, FL, USA", "Replication and backup" },
{ "Kristian Nielsen", "Copenhagen, Denmark",
"General build stuff" },
{ "Pekka Nouisiainen", "Stockholm, Sweden",
@@ -97,7 +100,7 @@ struct show_table_authors_st show_table_authors[]= {
"NDB Cluster, Online Backup, lots of other things" },
{ "Konstantin Osipov", "Moscow, Russia",
"Prepared statements (4.1), Cursors (5.0)" },
- { "Sasha Pachev", "",
+ { "Alexander (Sasha) Pachev", "Provo, UT, USA",
"Statement-based replication, SHOW CREATE TABLE, mysql-bench" },
{ "Irena Pancirov", "", "Port to Windows with Borland compiler" },
{ "Jan Pazdziora", "", "Czech sorting order" },
diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc
index 38e0171774e..5b32b549e8d 100644
--- a/sql/examples/ha_example.cc
+++ b/sql/examples/ha_example.cc
@@ -495,6 +495,8 @@ int ha_example::rnd_pos(byte * buf, byte *pos)
/*
::info() is used to return information to the optimizer.
+ see my_base.h for the complete description
+
Currently this table handler doesn't implement most of the fields
really needed. SHOW also makes use of this data
Another note, you will probably want to have the following in your
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 09bd48a3cd7..75ee136c916 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -3435,17 +3435,20 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
DBUG_PRINT("info", ("Table schema version: %d",
tab->getObjectVersion()));
}
- if (m_table != (void *)tab)
- {
- m_table= (void *)tab;
- m_table_version = tab->getObjectVersion();
- }
- else if (m_table_version < tab->getObjectVersion())
+ if (m_table_version < tab->getObjectVersion())
{
/*
The table has been altered, caller has to retry
*/
- DBUG_RETURN(my_errno= HA_ERR_TABLE_DEF_CHANGED);
+ NdbError err= ndb->getNdbError(NDB_INVALID_SCHEMA_OBJECT);
+ DBUG_RETURN(ndb_to_mysql_error(&err));
+ }
+ if (m_table != (void *)tab)
+ {
+ m_table= (void *)tab;
+ m_table_version = tab->getObjectVersion();
+ if (!(my_errno= build_index_list(ndb, table, ILBP_OPEN)))
+ DBUG_RETURN(my_errno);
}
m_table_info= tab_info;
}
@@ -3936,8 +3939,8 @@ int ha_ndbcluster::create(const char *name,
uint pack_length, length, i, pk_length= 0;
const void *data, *pack_data;
char name2[FN_HEADLEN];
- bool create_from_engine= test(info->table_options &
- HA_OPTION_CREATE_FROM_ENGINE);
+ bool create_from_engine= (info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
+
DBUG_ENTER("ha_ndbcluster::create");
DBUG_PRINT("enter", ("name: %s", name));
diff --git a/sql/handler.h b/sql/handler.h
index dc6e3edc40c..b4b90cbfaa8 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1174,7 +1174,7 @@ public:
key_range *max_key)
{ return (ha_rows) 10; }
virtual void position(const byte *record)=0;
- virtual void info(uint)=0;
+ virtual void info(uint)=0; // see my_base.h for full description
virtual int extra(enum ha_extra_function operation)
{ return 0; }
virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
diff --git a/sql/item.cc b/sql/item.cc
index 1c2016049ad..438741581bb 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -601,16 +601,8 @@ bool Item::eq(const Item *item, bool binary_cmp) const
Item *Item::safe_charset_converter(CHARSET_INFO *tocs)
{
- /*
- Allow conversion from and to "binary".
- Don't allow automatic conversion to non-Unicode charsets,
- as it potentially loses data.
- */
- if (collation.collation != &my_charset_bin &&
- tocs != &my_charset_bin &&
- !(tocs->state & MY_CS_UNICODE))
- return NULL; // safe conversion is not possible
- return new Item_func_conv_charset(this, tocs);
+ Item_func_conv_charset *conv= new Item_func_conv_charset(this, tocs, 1);
+ return conv->safe ? conv : NULL;
}
@@ -700,23 +692,15 @@ Item *Item_param::safe_charset_converter(CHARSET_INFO *tocs)
{
if (const_item())
{
- Item_string *conv;
uint cnv_errors;
- char buf[MAX_FIELD_WIDTH];
- String tmp(buf, sizeof(buf), &my_charset_bin);
- String cstr, *ostr= val_str(&tmp);
- /*
- As safe_charset_converter is not executed for
- a parameter bound to NULL, ostr should never be 0.
- */
- cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &cnv_errors);
- if (cnv_errors || !(conv= new Item_string(cstr.ptr(), cstr.length(),
- cstr.charset(),
- collation.derivation)))
- return NULL;
- conv->str_value.copy();
- conv->str_value.mark_as_const();
- return conv;
+ String *ostr= val_str(&cnvstr);
+ cnvitem->str_value.copy(ostr->ptr(), ostr->length(),
+ ostr->charset(), tocs, &cnv_errors);
+ if (cnv_errors)
+ return NULL;
+ cnvitem->str_value.mark_as_const();
+ cnvitem->max_length= cnvitem->str_value.numchars() * tocs->mbmaxlen;
+ return cnvitem;
}
return NULL;
}
@@ -2105,6 +2089,8 @@ Item_param::Item_param(unsigned pos_in_query_arg) :
value is set.
*/
maybe_null= 1;
+ cnvitem= new Item_string("", 0, &my_charset_bin, DERIVATION_COERCIBLE);
+ cnvstr.set(cnvbuf, sizeof(cnvbuf), &my_charset_bin);
}
@@ -5302,7 +5288,7 @@ Item_result item_cmp_type(Item_result a,Item_result b)
void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
{
Item *item= *ref;
- Item *new_item;
+ Item *new_item= NULL;
if (item->basic_const_item())
return; // Can't be better
Item_result res_type=item_cmp_type(comp_item->result_type(),
@@ -5335,7 +5321,16 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
break;
}
case ROW_RESULT:
+ if (item->type() == Item::ROW_ITEM && comp_item->type() == Item::ROW_ITEM)
{
+ /*
+ Substitute constants only in Item_rows. Don't affect other Items
+ with ROW_RESULT (eg Item_singlerow_subselect).
+
+ For such Items more optimal is to detect if it is constant and replace
+ it with Item_row. This would optimize queries like this:
+ SELECT * FROM t1 WHERE (a,b) = (SELECT a,b FROM t2 LIMIT 1);
+ */
Item_row *item_row= (Item_row*) item;
Item_row *comp_item_row= (Item_row*) comp_item;
uint col;
@@ -5353,6 +5348,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
resolve_const_item(thd, item_row->addr(col), comp_item_row->el(col));
break;
}
+ /* Fallthrough */
case REAL_RESULT:
{ // It must REAL_RESULT
double result= item->val_real();
@@ -5858,8 +5854,11 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
{
int delta1= max_length_orig - decimals_orig;
int delta2= item->max_length - item->decimals;
- max_length= min(max(delta1, delta2) + decimals,
- (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7);
+ if (fld_type == MYSQL_TYPE_DECIMAL)
+ max_length= max(delta1, delta2) + decimals;
+ else
+ max_length= min(max(delta1, delta2) + decimals,
+ (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7);
}
else
max_length= (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7;
diff --git a/sql/item.h b/sql/item.h
index 711050395de..4f06d75675c 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1084,7 +1084,11 @@ public:
class Item_param :public Item
{
+ char cnvbuf[MAX_FIELD_WIDTH];
+ String cnvstr;
+ Item *cnvitem;
public:
+
enum enum_item_param_state
{
NO_VALUE, NULL_VALUE, INT_VALUE, REAL_VALUE,
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index a8ccc8771c9..51d19a385ec 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -3662,7 +3662,7 @@ void Item_equal::merge(Item_equal *item)
the multiple equality already contains a constant and its
value is not equal to the value of c.
*/
- add(const_item);
+ add(c);
}
cond_false|= item->cond_false;
}
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index a8c51bb6662..8c0dea4efb2 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -48,6 +48,38 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
}
+String *Item_str_func::check_well_formed_result(String *str)
+{
+ /* Check whether we got a well-formed string */
+ CHARSET_INFO *cs= str->charset();
+ int well_formed_error;
+ uint wlen= cs->cset->well_formed_len(cs,
+ str->ptr(), str->ptr() + str->length(),
+ str->length(), &well_formed_error);
+ if (wlen < str->length())
+ {
+ THD *thd= current_thd;
+ char hexbuf[7];
+ enum MYSQL_ERROR::enum_warning_level level;
+ uint diff= str->length() - wlen;
+ set_if_smaller(diff, 3);
+ octet2hex(hexbuf, str->ptr() + wlen, diff);
+ if (thd->variables.sql_mode &
+ (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))
+ {
+ level= MYSQL_ERROR::WARN_LEVEL_ERROR;
+ null_value= 1;
+ str= 0;
+ }
+ else
+ level= MYSQL_ERROR::WARN_LEVEL_WARN;
+ push_warning_printf(thd, level, ER_INVALID_CHARACTER_STRING,
+ ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf);
+ }
+ return str;
+}
+
+
double Item_str_func::val_real()
{
DBUG_ASSERT(fixed == 1);
@@ -1984,34 +2016,7 @@ String *Item_func_char::val_str(String *str)
}
str->set_charset(collation.collation);
str->realloc(str->length()); // Add end 0 (for Purify)
-
- /* Check whether we got a well-formed string */
- CHARSET_INFO *cs= collation.collation;
- int well_formed_error;
- uint wlen= cs->cset->well_formed_len(cs,
- str->ptr(), str->ptr() + str->length(),
- str->length(), &well_formed_error);
- if (wlen < str->length())
- {
- THD *thd= current_thd;
- char hexbuf[7];
- enum MYSQL_ERROR::enum_warning_level level;
- uint diff= str->length() - wlen;
- set_if_smaller(diff, 3);
- octet2hex(hexbuf, str->ptr() + wlen, diff);
- if (thd->variables.sql_mode &
- (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))
- {
- level= MYSQL_ERROR::WARN_LEVEL_ERROR;
- null_value= 1;
- str= 0;
- }
- else
- level= MYSQL_ERROR::WARN_LEVEL_WARN;
- push_warning_printf(thd, level, ER_INVALID_CHARACTER_STRING,
- ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf);
- }
- return str;
+ return check_well_formed_result(str);
}
@@ -2311,6 +2316,8 @@ String *Item_func_conv::val_str(String *str)
String *Item_func_conv_charset::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
+ if (use_cached_value)
+ return null_value ? 0 : &str_value;
String *arg= args[0]->val_str(str);
uint dummy_errors;
if (!arg)
@@ -2320,7 +2327,7 @@ String *Item_func_conv_charset::val_str(String *str)
}
null_value= str_value.copy(arg->ptr(),arg->length(),arg->charset(),
conv_charset, &dummy_errors);
- return null_value ? 0 : &str_value;
+ return null_value ? 0 : check_well_formed_result(&str_value);
}
void Item_func_conv_charset::fix_length_and_dec()
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 81f809d2b67..50ec0b36ce8 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -35,6 +35,7 @@ public:
double val_real();
enum Item_result result_type () const { return STRING_RESULT; }
void left_right_max_length();
+ String *check_well_formed_result(String *str);
};
class Item_func_md5 :public Item_str_func
@@ -651,10 +652,40 @@ public:
class Item_func_conv_charset :public Item_str_func
{
+ bool use_cached_value;
public:
+ bool safe;
CHARSET_INFO *conv_charset; // keep it public
- Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a)
- { conv_charset=cs; }
+ Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a)
+ { conv_charset= cs; use_cached_value= 0; safe= 0; }
+ Item_func_conv_charset(Item *a, CHARSET_INFO *cs, bool cache_if_const)
+ :Item_str_func(a)
+ {
+ DBUG_ASSERT(args[0]->fixed);
+ conv_charset= cs;
+ if (cache_if_const && args[0]->const_item())
+ {
+ uint errors= 0;
+ String tmp, *str= args[0]->val_str(&tmp);
+ if (!str || str_value.copy(str->ptr(), str->length(),
+ str->charset(), conv_charset, &errors))
+ null_value= 1;
+ use_cached_value= 1;
+ safe= (errors == 0);
+ }
+ else
+ {
+ use_cached_value= 0;
+ /*
+ Conversion from and to "binary" is safe.
+ Conversion to Unicode is safe.
+ Other kind of conversions are potentially lossy.
+ */
+ safe= (args[0]->collation.collation == &my_charset_bin ||
+ cs == &my_charset_bin ||
+ (cs->state & MY_CS_UNICODE));
+ }
+ }
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "convert"; }
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 33e6ac8bb39..4b7a1fc00a8 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1463,7 +1463,7 @@ int calc_weekday(long daynr,bool sunday_first_day_of_week);
uint calc_week(TIME *l_time, uint week_behaviour, uint *year);
void find_date(char *pos,uint *vek,uint flag);
TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end);
-TYPELIB *typelib(List<String> &strings);
+TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
const char *newname);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 8b92e953062..f344becffde 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1647,6 +1647,7 @@ void end_thread(THD *thd, bool put_in_cache)
wake_thread--;
thd=thread_cache.get();
thd->real_id=pthread_self();
+ thd->thread_stack= (char *) &thd;
(void) thd->store_globals();
thd->thr_create_time= time(NULL);
threads.append(thd);
@@ -7003,10 +7004,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case OPT_MYISAM_STATS_METHOD:
{
ulong method_conv;
+ int method;
LINT_INIT(method_conv);
myisam_stats_method_str= argument;
- int method;
if ((method=find_type(argument, &myisam_stats_method_typelib, 2)) <= 0)
{
fprintf(stderr, "Invalid value of myisam_stats_method: %s.\n", argument);
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 2645a798896..625a956eea2 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3142,10 +3142,10 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
/* F=F-covered by first(I) */
bitmap_union(&covered_fields, &(*ror_scan_mark)->covered_fields);
all_covered= bitmap_is_subset(&param->needed_fields, &covered_fields);
- } while (!all_covered && (++ror_scan_mark < ror_scans_end));
-
- if (!all_covered)
- DBUG_RETURN(NULL); /* should not happen actually */
+ } while ((++ror_scan_mark < ror_scans_end) && !all_covered);
+
+ if (!all_covered || (ror_scan_mark - tree->ror_scans) == 1)
+ DBUG_RETURN(NULL);
/*
Ok, [tree->ror_scans .. ror_scan) holds covering index_intersection with
@@ -7211,6 +7211,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
{
select_items_it.rewind();
cur_used_key_parts.clear_all();
+ uint max_key_part= 0;
while ((item= select_items_it++))
{
item_field= (Item_field*) item; /* (SA5) already checked above. */
@@ -7228,7 +7229,19 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
cur_group_prefix_len+= cur_part->store_length;
cur_used_key_parts.set_bit(key_part_nr);
++cur_group_key_parts;
+ max_key_part= max(max_key_part,key_part_nr);
}
+ /*
+ Check that used key parts forms a prefix of the index.
+ To check this we compare bits in all_parts and cur_parts.
+ all_parts have all bits set from 0 to (max_key_part-1).
+ cur_parts have bits set for only used keyparts.
+ */
+ ulonglong all_parts, cur_parts;
+ all_parts= (1<<max_key_part) - 1;
+ cur_parts= cur_used_key_parts.to_ulonglong() >> 1;
+ if (all_parts != cur_parts)
+ goto next_index;
}
else
DBUG_ASSERT(FALSE);
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 0800089209c..8b176b03756 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -2215,6 +2215,26 @@ sp_instr_set::exec_core(THD *thd, uint *nextp)
{
int res= thd->spcont->set_item_eval(thd, m_offset, &m_value, m_type);
+ if (res < 0 &&
+ thd->spcont->get_item(m_offset) == NULL &&
+ thd->spcont->found_handler_here())
+ {
+ /*
+ Failed to evaluate the value, the variable is still not initialized,
+ and a handler has been found. Set to null so we can continue.
+ */
+ Item *it= new Item_null();
+
+ if (!it || thd->spcont->set_item_eval(thd, m_offset, &it, m_type) < 0)
+ { /* If this also failed, we have to abort */
+ sp_rcontext *spcont= thd->spcont;
+
+ thd->spcont= 0; /* Avoid handlers */
+ my_error(ER_OUT_OF_RESOURCES, MYF(0));
+ spcont->clear_handler();
+ thd->spcont= spcont;
+ }
+ }
*nextp = m_ip+1;
return res;
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 38bed255215..fc86bd473e5 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -183,6 +183,7 @@ THD::THD()
spcont(NULL)
{
stmt_arena= this;
+ thread_stack= 0;
db= 0;
catalog= (char*)"std"; // the only catalog we have for now
main_security_ctx.init();
diff --git a/sql/sql_class.h b/sql/sql_class.h
index e075e46fb03..3ac95bc1ad8 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1241,14 +1241,16 @@ public:
free_root(&mem_root,MYF(MY_KEEP_PREALLOC));
#endif
}
-#ifdef USING_TRANSACTIONS
st_transactions()
{
+#ifdef USING_TRANSACTIONS
bzero((char*)this, sizeof(*this));
xid_state.xid.null();
init_sql_alloc(&mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
- }
+#else
+ xid_state.xa_state= XA_NOTR;
#endif
+ }
} transaction;
Field *dupp_field;
#ifndef __WIN__
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 57d7059dd8f..2e2a6f4d1b1 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4844,11 +4844,15 @@ end_with_restore_list:
/*
- The return value for ROW_COUNT() is "implementation dependent" if
- the statement is not DELETE, INSERT or UPDATE (or a CALL executing
- such a statement), but -1 is what JDBC and ODBC wants.
+ The return value for ROW_COUNT() is "implementation dependent" if the
+ statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC
+ wants.
+
+ We do not change the value for a CALL or EXECUTE statement, so the value
+ generated by the last called (or executed) statement is preserved.
*/
- if (lex->sql_command != SQLCOM_CALL && uc_update_queries[lex->sql_command]<2)
+ if (lex->sql_command != SQLCOM_CALL && lex->sql_command != SQLCOM_EXECUTE &&
+ uc_update_queries[lex->sql_command]<2)
thd->row_count_func= -1;
goto cleanup;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index e33fc2e1c56..eaf10a3b074 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -911,7 +911,6 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
}
key_info= table->key_info;
- file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME);
bzero((char*) &create_info, sizeof(create_info));
file->update_create_info(&create_info);
primary_key= share->primary_key;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index c8775ebc923..ff562cf2a39 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -799,7 +799,14 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (!interval)
{
- interval= sql_field->interval= typelib(sql_field->interval_list);
+ /*
+ Create the typelib in prepared statement memory if we're
+ executing one.
+ */
+ MEM_ROOT *stmt_root= thd->stmt_arena->mem_root;
+
+ interval= sql_field->interval= typelib(stmt_root,
+ sql_field->interval_list);
List_iterator<String> it(sql_field->interval_list);
String conv, *tmp;
for (uint i= 0; (tmp= it++); i++)
@@ -810,7 +817,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{
uint cnv_errs;
conv.copy(tmp->ptr(), tmp->length(), tmp->charset(), cs, &cnv_errs);
- interval->type_names[i]= strmake_root(thd->mem_root, conv.ptr(),
+ interval->type_names[i]= strmake_root(stmt_root, conv.ptr(),
conv.length());
interval->type_lengths[i]= conv.length();
}
@@ -830,8 +837,22 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (sql_field->def && cs != sql_field->def->collation.collation)
{
- if (!(sql_field->def=
- sql_field->def->safe_charset_converter(cs)))
+ Query_arena backup_arena;
+ bool need_to_change_arena= !thd->stmt_arena->is_conventional();
+ if (need_to_change_arena)
+ {
+ /* Asser that we don't do that at every PS execute */
+ DBUG_ASSERT(thd->stmt_arena->is_first_stmt_execute() ||
+ thd->stmt_arena->is_first_sp_execute());
+ thd->set_n_backup_active_arena(thd->stmt_arena, &backup_arena);
+ }
+
+ sql_field->def= sql_field->def->safe_charset_converter(cs);
+
+ if (need_to_change_arena)
+ thd->restore_active_arena(thd->stmt_arena, &backup_arena);
+
+ if (! sql_field->def)
{
/* Could not convert */
my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
@@ -4132,7 +4153,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), def->change);
DBUG_RETURN(TRUE);
}
- def->def=alter->def; // Use new default
+ if ((def->def=alter->def)) // Use new default
+ def->flags&= ~NO_DEFAULT_VALUE_FLAG;
+ else
+ def->flags|= NO_DEFAULT_VALUE_FLAG;
alter_it.remove();
}
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index b0d35407eef..79e6a4766a5 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -516,7 +516,12 @@ int mysql_update(THD *thd,
}
else if (!ignore || error != HA_ERR_FOUND_DUPP_KEY)
{
- thd->fatal_error(); // Force error message
+ /*
+ If (ignore && error == HA_ERR_FOUND_DUPP_KEY) we don't have to
+ do anything; otherwise...
+ */
+ if (error != HA_ERR_FOUND_DUPP_KEY)
+ thd->fatal_error(); /* Other handler errors are fatal */
table->file->print_error(error,MYF(0));
error= 1;
break;
@@ -1365,7 +1370,12 @@ bool multi_update::send_data(List<Item> &not_used_values)
updated--;
if (!ignore || error != HA_ERR_FOUND_DUPP_KEY)
{
- thd->fatal_error(); // Force error message
+ /*
+ If (ignore && error == HA_ERR_FOUND_DUPP_KEY) we don't have to
+ do anything; otherwise...
+ */
+ if (error != HA_ERR_FOUND_DUPP_KEY)
+ thd->fatal_error(); /* Other handler errors are fatal */
table->file->print_error(error,MYF(0));
DBUG_RETURN(1);
}
diff --git a/sql/table.cc b/sql/table.cc
index d2e22ffd5f7..ff29a33ef03 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1721,15 +1721,15 @@ fix_type_pointers(const char ***array, TYPELIB *point_to_type, uint types,
} /* fix_type_pointers */
-TYPELIB *typelib(List<String> &strings)
+TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings)
{
- TYPELIB *result=(TYPELIB*) sql_alloc(sizeof(TYPELIB));
+ TYPELIB *result= (TYPELIB*) alloc_root(mem_root, sizeof(TYPELIB));
if (!result)
return 0;
result->count=strings.elements;
result->name="";
uint nbytes= (sizeof(char*) + sizeof(uint)) * (result->count + 1);
- if (!(result->type_names= (const char**) sql_alloc(nbytes)))
+ if (!(result->type_names= (const char**) alloc_root(mem_root, nbytes)))
return 0;
result->type_lengths= (uint*) (result->type_names + result->count + 1);
List_iterator<String> it(strings);
@@ -1879,10 +1879,10 @@ File create_frm(THD *thd, const char *name, const char *db,
#if SIZEOF_OFF_T > 4
/* Fix this when we have new .frm files; Current limit is 4G rows (QQ) */
- if (create_info->max_rows > ~(ulong) 0)
- create_info->max_rows= ~(ulong) 0;
- if (create_info->min_rows > ~(ulong) 0)
- create_info->min_rows= ~(ulong) 0;
+ if (create_info->max_rows > UINT_MAX32)
+ create_info->max_rows= UINT_MAX32;
+ if (create_info->min_rows > UINT_MAX32)
+ create_info->min_rows= UINT_MAX32;
#endif
/*
Ensure that raid_chunks can't be larger than 255, as this would cause
diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c
index a348b9fe38f..fb2ace0fa07 100644
--- a/storage/myisam/ft_parser.c
+++ b/storage/myisam/ft_parser.c
@@ -160,8 +160,10 @@ byte ft_get_word(CHARSET_INFO *cs, byte **start, byte *end,
for (word->pos=doc; doc<end; length++, mbl=my_mbcharlen(cs, *(uchar *)doc), doc+=(mbl ? mbl : 1))
if (true_word_char(cs,*doc))
mwc=0;
- else if (!misc_word_char(*doc) || mwc++)
+ else if (!misc_word_char(*doc) || mwc)
break;
+ else
+ mwc++;
param->prev='A'; /* be sure *prev is true_word_char */
word->len= (uint)(doc-word->pos) - mwc;
diff --git a/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
index 1f23bd7543c..3b843b6708b 100644
--- a/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
+++ b/storage/ndb/src/common/mgmcommon/ConfigRetriever.cpp
@@ -342,14 +342,21 @@ ConfigRetriever::setNodeId(Uint32 nodeid)
Uint32
ConfigRetriever::allocNodeId(int no_retries, int retry_delay_in_seconds)
{
+ int res;
_ownNodeId= 0;
if(m_handle != 0)
{
while (1)
{
- int res= ndb_mgm_alloc_nodeid(m_handle, m_version, m_node_type);
+ if(!ndb_mgm_is_connected(m_handle))
+ if(!ndb_mgm_connect(m_handle, 0, 0, 0))
+ goto next;
+
+ res= ndb_mgm_alloc_nodeid(m_handle, m_version, m_node_type);
if(res >= 0)
return _ownNodeId= (Uint32)res;
+
+ next:
if (no_retries == 0)
break;
no_retries--;
diff --git a/storage/ndb/src/mgmapi/mgmapi.cpp b/storage/ndb/src/mgmapi/mgmapi.cpp
index 2b31f0e638d..79284964186 100644
--- a/storage/ndb/src/mgmapi/mgmapi.cpp
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp
@@ -336,10 +336,16 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
const Properties* p = parser.parse(ctx, session);
if (p == NULL){
if(!ndb_mgm_is_connected(handle)) {
- return NULL;
+ DBUG_RETURN(NULL);
}
else
{
+ if(ctx.m_status==Parser_t::Eof
+ || ctx.m_status==Parser_t::NoLine)
+ {
+ ndb_mgm_disconnect(handle);
+ DBUG_RETURN(NULL);
+ }
/**
* Print some info about why the parser returns NULL
*/
diff --git a/vio/vio.c b/vio/vio.c
index ff93cff959f..bc286b2d2bb 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -87,7 +87,7 @@ static void vio_init(Vio* vio, enum enum_vio_type type,
#ifdef HAVE_OPENSSL
if (type == VIO_TYPE_SSL)
{
- vio->viodelete =vio_ssl_delete;
+ vio->viodelete =vio_delete;
vio->vioerrno =vio_ssl_errno;
vio->read =vio_ssl_read;
vio->write =vio_ssl_write;
diff --git a/vio/vio_priv.h b/vio/vio_priv.h
index c1c78cc6efa..eb495025ddd 100644
--- a/vio/vio_priv.h
+++ b/vio/vio_priv.h
@@ -28,7 +28,6 @@ void vio_ignore_timeout(Vio *vio, uint which, uint timeout);
#ifdef HAVE_OPENSSL
#include "my_net.h" /* needed because of struct in_addr */
-void vio_ssl_delete(Vio* vio);
int vio_ssl_read(Vio *vio,gptr buf, int size);
int vio_ssl_write(Vio *vio,const gptr buf,int size);
void vio_ssl_timeout(Vio *vio, uint which, uint timeout);
diff --git a/vio/viossl.c b/vio/viossl.c
index e6af07c4b0b..1273814c551 100644
--- a/vio/viossl.c
+++ b/vio/viossl.c
@@ -69,25 +69,6 @@ report_errors()
DBUG_VOID_RETURN;
}
-/*
- Delete a vio object
-
- SYNPOSIS
- vio_ssl_delete()
- vio Vio object. May be 0.
-*/
-
-
-void vio_ssl_delete(Vio * vio)
-{
- if (vio)
- {
- if (vio->type != VIO_CLOSED)
- vio_close(vio);
- my_free((gptr) vio,MYF(0));
- }
-}
-
int vio_ssl_errno(Vio *vio __attribute__((unused)))
{
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index 766d835d2c0..4ee27f1e491 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -191,9 +191,6 @@ void netware_ssl_cleanup()
/* NetWare SSL initialization */
static void netware_ssl_init()
{
- /* initialize OpenSSL library */
- SSL_library_init();
-
/* cleanup OpenSSL library */
NXVmRegisterExitHandler(netware_ssl_cleanup, NULL);
}
@@ -228,16 +225,17 @@ new_VioSSLConnectorFd(const char* key_file,
ptr->ssl_method= 0;
/* FIXME: constants! */
-#ifdef __NETWARE__
- netware_ssl_init();
-#endif
-
if (!ssl_algorithms_added)
{
DBUG_PRINT("info", ("todo: OpenSSL_add_all_algorithms()"));
ssl_algorithms_added = TRUE;
+ SSL_library_init();
OpenSSL_add_all_algorithms();
}
+#ifdef __NETWARE__
+ netware_ssl_init();
+#endif
+
if (!ssl_error_strings_loaded)
{
DBUG_PRINT("info", ("todo:SSL_load_error_strings()"));
@@ -319,17 +317,18 @@ new_VioSSLAcceptorFd(const char *key_file,
/* FIXME: constants! */
ptr->session_id_context= ptr;
-#ifdef __NETWARE__
- netware_ssl_init();
-#endif
-
if (!ssl_algorithms_added)
{
DBUG_PRINT("info", ("todo: OpenSSL_add_all_algorithms()"));
ssl_algorithms_added = TRUE;
+ SSL_library_init();
OpenSSL_add_all_algorithms();
}
+#ifdef __NETWARE__
+ netware_ssl_init();
+#endif
+
if (!ssl_error_strings_loaded)
{
DBUG_PRINT("info", ("todo: SSL_load_error_strings()"));