summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBUILD/SETUP.sh4
-rw-r--r--client/mysqltest.c16
-rw-r--r--configure.in44
-rw-r--r--include/config-win.h15
-rw-r--r--include/m_ctype.h23
-rw-r--r--mysql-test/include/have_latin2_ch.inc4
-rw-r--r--mysql-test/include/have_udf.inc12
-rw-r--r--mysql-test/include/wait_slave_status.inc158
-rwxr-xr-xmysql-test/mysql-test-run.pl34
-rw-r--r--mysql-test/r/ctype_big5.result3
-rw-r--r--mysql-test/r/ctype_cp932_binlog.result29
-rwxr-xr-xmysql-test/r/ctype_eucjpms.result6
-rw-r--r--mysql-test/r/ctype_gbk.result3
-rw-r--r--mysql-test/r/ctype_latin2_ch.result30
-rw-r--r--mysql-test/r/ctype_ucs2_def.result6
-rw-r--r--mysql-test/r/ctype_ujis.result6
-rw-r--r--mysql-test/r/fulltext.result10
-rw-r--r--mysql-test/r/have_latin2_ch.require2
-rw-r--r--mysql-test/r/have_udf.require1
-rw-r--r--mysql-test/r/subselect.result6
-rw-r--r--mysql-test/r/udf.result87
-rw-r--r--mysql-test/t/ctype_big5.test10
-rw-r--r--mysql-test/t/ctype_cp932_binlog.test23
-rw-r--r--mysql-test/t/ctype_eucjpms.test17
-rw-r--r--mysql-test/t/ctype_gbk.test10
-rw-r--r--mysql-test/t/ctype_latin2_ch.test30
-rw-r--r--mysql-test/t/ctype_ucs2_def-master.opt1
-rw-r--r--mysql-test/t/ctype_ucs2_def.test9
-rw-r--r--mysql-test/t/ctype_ujis.test15
-rw-r--r--mysql-test/t/fulltext.test2
-rw-r--r--mysql-test/t/subselect.test11
-rw-r--r--mysql-test/t/type_float.test5
-rw-r--r--mysql-test/t/type_newdecimal.test10
-rw-r--r--mysql-test/t/udf.test108
-rw-r--r--mysql-test/t/variables.test2
-rw-r--r--sql-common/client.c13
-rw-r--r--sql/Makefile.am9
-rw-r--r--sql/item.cc19
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/log_event.cc31
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/opt_range.cc15
-rw-r--r--sql/parse_file.cc1
-rw-r--r--sql/share/errmsg.txt76
-rw-r--r--sql/sp_head.cc10
-rw-r--r--sql/sql_string.cc12
-rw-r--r--sql/sql_udf.cc1
-rw-r--r--sql/table.cc6
-rw-r--r--sql/udf_example.cc12
-rw-r--r--strings/ctype-big5.c6
-rw-r--r--strings/ctype-bin.c10
-rw-r--r--strings/ctype-cp932.c6
-rw-r--r--strings/ctype-czech.c4
-rw-r--r--strings/ctype-euc_kr.c8
-rw-r--r--strings/ctype-eucjpms.c26
-rw-r--r--strings/ctype-gb2312.c8
-rw-r--r--strings/ctype-gbk.c8
-rw-r--r--strings/ctype-latin1.c4
-rw-r--r--strings/ctype-simple.c4
-rw-r--r--strings/ctype-sjis.c8
-rw-r--r--strings/ctype-tis620.c4
-rw-r--r--strings/ctype-ucs2.c4
-rw-r--r--strings/ctype-ujis.c26
-rw-r--r--strings/ctype-utf8.c14
64 files changed, 920 insertions, 181 deletions
diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh
index 4f2065657d5..57061f3dbff 100755
--- a/BUILD/SETUP.sh
+++ b/BUILD/SETUP.sh
@@ -44,8 +44,8 @@ set -e
export AM_MAKEFLAGS
AM_MAKEFLAGS="-j 4"
-# SSL library to use. Should be changed to --with-yassl
-SSL_LIBRARY=--with-openssl
+# SSL library to use.
+SSL_LIBRARY=--with-yassl
# If you are not using codefusion add "-Wpointer-arith" to WARNINGS
# The following warning flag will give too many warnings:
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 0de63ccd329..37f7418e0ef 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -373,8 +373,10 @@ const char *command_names[]=
"enable_rpl_parse",
"disable_rpl_parse",
"eval_result",
+ /* Enable/disable that the _query_ is logged to result file */
"enable_query_log",
"disable_query_log",
+ /* Enable/disable that the _result_ from a query is logged to result file */
"enable_result_log",
"disable_result_log",
"server_start",
@@ -760,8 +762,8 @@ err:
check_result
ds - content to be checked
fname - name of file to check against
- require_option - if set and check fails, the test will be aborted with the special
- exit code "not supported test"
+ require_option - if set and check fails, the test will be aborted
+ with the special exit code "not supported test"
RETURN VALUES
error - the function will not return
@@ -3716,7 +3718,17 @@ static void handle_error(const char *query, struct st_query *q,
DBUG_ENTER("handle_error");
if (q->require_file)
+ {
+ /*
+ The query after a "--require" failed. This is fine as long the server
+ returned a valid reponse. Don't allow 2013 or 2006 to trigger an
+ abort_not_supported_test
+ */
+ if (err_errno == CR_SERVER_LOST ||
+ err_errno == CR_SERVER_GONE_ERROR)
+ die("require query '%s' failed: %d: %s", query, err_errno, err_error);
abort_not_supported_test();
+ }
if (q->abort_on_error)
die("query '%s' failed: %d: %s", query, err_errno, err_error);
diff --git a/configure.in b/configure.in
index 4ff90bb39bb..60e34eeb9f5 100644
--- a/configure.in
+++ b/configure.in
@@ -1547,16 +1547,37 @@ else
fi
#---END:
-# Check for dlopen, needed for user definable functions
-# This must be checked after threads on AIX
-# We only need this for mysqld, not for the clients.
+# dlopen, dlerror
+case "$with_mysqld_ldflags " in
+
+ *"-static "*)
+ # No need to check for dlopen when mysqld is linked with
+ # -all-static or -static as it won't be able to load any functions.
+ # NOTE! It would be better if it was possible to test if dlopen
+ # can be used, but a good way to test it couldn't be found
+
+ ;;
+
+ *)
+ # Check for dlopen, needed for user definable functions
+ # This must be checked after threads on AIX
+ # We only need this for mysqld, not for the clients.
+
+ my_save_LIBS="$LIBS"
+ LIBS=""
+ AC_CHECK_LIB(dl,dlopen)
+ LIBDL=$LIBS
+ LIBS="$my_save_LIBS"
+ AC_SUBST(LIBDL)
+
+ my_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBDL"
+ AC_CHECK_FUNCS(dlopen dlerror)
+ LIBS="$my_save_LIBS"
+
+ ;;
+esac
-my_save_LIBS="$LIBS"
-LIBS=""
-AC_CHECK_LIB(dl,dlopen)
-LIBDL=$LIBS
-LIBS="$my_save_LIBS"
-AC_SUBST(LIBDL)
# System characteristics
case $SYSTEM_TYPE in
@@ -1925,11 +1946,6 @@ then
fi]
)
-my_save_LIBS="$LIBS"
-LIBS="$LIBS $LIBDL"
-AC_CHECK_FUNCS(dlopen dlerror)
-LIBS="$my_save_LIBS"
-
# Check definition of gethostbyaddr_r (glibc2 defines this with 8 arguments)
ac_save_CXXFLAGS="$CXXFLAGS"
AC_CACHE_CHECK([style of gethost* routines], mysql_cv_gethost_style,
diff --git a/include/config-win.h b/include/config-win.h
index 6dbfae1716e..d335ad38feb 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -407,8 +407,15 @@ inline double ulonglong2double(ulonglong value)
#define shared_memory_buffer_length 16000
#define default_shared_memory_base_name "MYSQL"
+
+#ifdef CYBOZU
+#define MYSQL_DEFAULT_CHARSET_NAME "utf8"
+#define MYSQL_DEFAULT_COLLATION_NAME "utf8_general_cs"
+#define HAVE_UTF8_GENERAL_CS 1
+#else
#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
+#enfif
#define HAVE_SPATIAL 1
#define HAVE_RTREE_KEYS 1
@@ -419,8 +426,10 @@ inline double ulonglong2double(ulonglong value)
/* Define charsets you want */
/* #undef HAVE_CHARSET_armscii8 */
/* #undef HAVE_CHARSET_ascii */
+#ifndef CYBOZU
#define HAVE_CHARSET_big5 1
#define HAVE_CHARSET_cp1250 1
+#endif
/* #undef HAVE_CHARSET_cp1251 */
/* #undef HAVE_CHARSET_cp1256 */
/* #undef HAVE_CHARSET_cp1257 */
@@ -429,27 +438,33 @@ inline double ulonglong2double(ulonglong value)
/* #undef HAVE_CHARSET_cp866 */
#define HAVE_CHARSET_cp932 1
/* #undef HAVE_CHARSET_dec8 */
+#ifndef CYBOZU
#define HAVE_CHARSET_eucjpms 1
#define HAVE_CHARSET_euckr 1
#define HAVE_CHARSET_gb2312 1
#define HAVE_CHARSET_gbk 1
+#endif
/* #undef HAVE_CHARSET_greek */
/* #undef HAVE_CHARSET_hebrew */
/* #undef HAVE_CHARSET_hp8 */
/* #undef HAVE_CHARSET_keybcs2 */
/* #undef HAVE_CHARSET_koi8r */
/* #undef HAVE_CHARSET_koi8u */
+#ifndef CYBOZU
#define HAVE_CHARSET_latin1 1
#define HAVE_CHARSET_latin2 1
+#endif
/* #undef HAVE_CHARSET_latin5 */
/* #undef HAVE_CHARSET_latin7 */
/* #undef HAVE_CHARSET_macce */
/* #undef HAVE_CHARSET_macroman */
#define HAVE_CHARSET_sjis 1
/* #undef HAVE_CHARSET_swe7 */
+#ifndef CYBOZU
#define HAVE_CHARSET_tis620 1
#define HAVE_CHARSET_ucs2 1
#define HAVE_CHARSET_ujis 1
+#endif
#define HAVE_CHARSET_utf8 1
#define HAVE_UCA_COLLATIONS 1
diff --git a/include/m_ctype.h b/include/m_ctype.h
index b7361cb7d7b..54ae41bf2e0 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -44,13 +44,23 @@ typedef struct unicase_info_st
uint16 sort;
} MY_UNICASE_INFO;
+
extern MY_UNICASE_INFO *my_unicase_default[256];
extern MY_UNICASE_INFO *my_unicase_turkish[256];
-#define MY_CS_ILSEQ 0
-#define MY_CS_ILUNI 0
-#define MY_CS_TOOSMALL -1
-#define MY_CS_TOOFEW(n) (-1-(n))
+
+/* wm_wc and wc_mb return codes */
+#define MY_CS_ILSEQ 0 /* Wrong by sequence: wb_wc */
+#define MY_CS_ILUNI 0 /* Cannot encode Unicode to charset: wc_mb */
+#define MY_CS_TOOSMALL -101 /* Need at least one byte: wc_mb and mb_wc */
+#define MY_CS_TOOSMALL2 -102 /* Need at least two bytes: wc_mb and mb_wc */
+#define MY_CS_TOOSMALL3 -103 /* Need at least three bytes: wc_mb and mb_wc */
+/* These following three are currently not really used */
+#define MY_CS_TOOSMALL4 -104 /* Need at least 4 bytes: wc_mb and mb_wc */
+#define MY_CS_TOOSMALL5 -105 /* Need at least 5 bytes: wc_mb and mb_wc */
+#define MY_CS_TOOSMALL6 -106 /* Need at least 6 bytes: wc_mb and mb_wc */
+/* A helper macros for "need at least n bytes" */
+#define MY_CS_TOOSMALLN(n) (-100-(n))
#define MY_SEQ_INTTAIL 1
#define MY_SEQ_SPACES 2
@@ -360,6 +370,11 @@ int my_wildcmp_8bit(CHARSET_INFO *,
const char *wildstr,const char *wildend,
int escape, int w_one, int w_many);
+int my_wildcmp_bin(CHARSET_INFO *,
+ const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,
+ int escape, int w_one, int w_many);
+
uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e);
uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e);
uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos);
diff --git a/mysql-test/include/have_latin2_ch.inc b/mysql-test/include/have_latin2_ch.inc
new file mode 100644
index 00000000000..9d3ee6b341c
--- /dev/null
+++ b/mysql-test/include/have_latin2_ch.inc
@@ -0,0 +1,4 @@
+-- require r/have_latin2_ch.require
+disable_query_log;
+show collation like "latin2_czech_cs";
+enable_query_log;
diff --git a/mysql-test/include/have_udf.inc b/mysql-test/include/have_udf.inc
new file mode 100644
index 00000000000..a22b2a52e61
--- /dev/null
+++ b/mysql-test/include/have_udf.inc
@@ -0,0 +1,12 @@
+#
+# To check if the udf_example.so is available,
+# try to load one function from it.
+#
+#
+--require r/have_udf.require
+--disable_abort_on_error
+CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so';
+--disable_query_log
+DROP FUNCTION metaphon;
+--enable_query_log
+--enable_abort_on_error
diff --git a/mysql-test/include/wait_slave_status.inc b/mysql-test/include/wait_slave_status.inc
new file mode 100644
index 00000000000..7d3636e673c
--- /dev/null
+++ b/mysql-test/include/wait_slave_status.inc
@@ -0,0 +1,158 @@
+# include/wait_slave_status.inc
+#
+# Created by Matthias Leich
+#
+# SUMMARY
+#
+# Waits until slave has reached certain state or maximum time reached.
+#
+# (This script will not work, when the SHOW command delivers more than one
+# result record, because only the first record will be caught.)
+#
+# USAGE
+#
+# Set $result_pattern in test file and source this file:
+#
+# let $result_pattern= <pattern used for LIKE on the result of
+# SHOW STATUS SLAVE>
+# --include wait_slave_status.inc
+#
+# EXAMPLE
+#
+# The script rpl_until.test:
+# ...
+# --replace_result $MASTER_MYPORT MASTER_MYPORT
+# --replace_column 1 # 9 # 23 # 33 #
+# --vertical_results show slave status;
+#
+# outputs
+# show slave status;
+# Slave_IO_State #
+# Master_Host 127.0.0.1
+# Master_User root
+# Master_Port MASTER_MYPORT
+# Connect_Retry 1
+# Master_Log_File master-bin.000001
+# Read_Master_Log_Pos 776
+# Relay_Log_File slave-relay-bin.000004
+# Relay_Log_Pos #
+# Relay_Master_Log_File master-bin.000001
+# Slave_IO_Running Yes
+# Slave_SQL_Running No
+# Replicate_Do_DB
+# Replicate_Ignore_DB
+# Replicate_Do_Table
+# Replicate_Ignore_Table
+# Replicate_Wild_Do_Table
+# Replicate_Wild_Ignore_Table
+# Last_Errno 0
+# Last_Error
+# Skip_Counter 0
+# Exec_Master_Log_Pos 319
+# Relay_Log_Space #
+# Until_Condition Master
+# Until_Log_File master-bin.000001
+# Until_Log_Pos 319
+# Master_SSL_Allowed No
+# Master_SSL_CA_File
+# Master_SSL_CA_Path
+# Master_SSL_Cert
+# Master_SSL_Cipher
+# Master_SSL_Key
+# Seconds_Behind_Master #
+#
+# The main problem with the "show slave status;" in rpl_until is, that
+# depending on the total test engine power and the current load caused by
+# other processes, the expected slave status might be not reached though
+# it will happen in maybe some seconds.
+#
+# The typical problem with rpl_until is that Slave_IO_Running is "No"
+# instead of "Yes".
+#
+# The expected result follows the LIKE pattern:
+#
+# let $result_pattern= '%127.0.0.1%root%1%master-bin.000001%776%slave-relay-bin.000004%master-bin.000001%Yes%No%0%0%319%Master%master-bin.000001%319%No%';
+#
+# The Slave_IO_Running value is the "Yes" just after the "master-bin.000001".
+#
+# How to get this pattern ?
+#
+# Any lines "--replace_result ..." and "--replace_colum ..." just before
+# the SHOW TABLE STATUS and of course the expected result itself
+# show us columns where the content must be unified, because it is non
+# deterministic or it depends on the current test environment.
+#
+# Unfortunately "--replace_result ..." and "--replace_colum ..." do not
+# affect the result of our assignment let $my_val= `SHOW SLAVE STATUS`;
+# Therefore such content must be covered by '%'.
+#
+# Please be careful. A more simple pattern might be dangerous, because we
+# might get "wrong" matches. Example: There might be several "Yes" and "No"
+# within one result row.
+#
+###############################################################################
+
+# We do not want to print the auxiliary commands, because they are not of
+# interest and their amount will vary depending how fast we get the
+# desired state.
+--disable_query_log
+
+# The protocol should show
+# - the setting of $result_pattern and
+# - that this file is sourced ,
+# because this increases the chance to use the protocol as replay script.
+eval SELECT "let \$result_pattern= $result_pattern ;" AS "";
+SELECT '--source include/wait_slave_status.inc' AS "";
+
+# We accept to wait maximum 30 seconds (0.2 sec/loop).
+let $max_wait= 150;
+while ($max_wait)
+{
+ let $my_val= `SHOW SLAVE STATUS`;
+ # Now we have the first record of the SHOW result set as one fat string
+ # within the variable $my_val.
+
+ eval SET @my_val = '$my_val';
+ # DEBUG eval SELECT @my_val AS "response to SHOW SLAVE STATUS";
+
+ eval SELECT @my_val LIKE $result_pattern INTO @success;
+ # @success is '1' if we have a match
+ # '0' if we have no match
+ # DEBUG SELECT @success;
+
+ let $success= `SELECT @success`;
+ let $no_success= `SELECT @success = 0`;
+ if ($success)
+ {
+ # We reached the expected result and want to jump out of the loop
+ # without unneeded sleeps.
+ # Attention: Do not set $max_wait to 0, because "while" with negative value
+ # does not work.
+ let $max_wait= 1;
+ }
+ if ($no_success)
+ {
+ # We did not reach the expected result and will have to sleep again
+ # or jump out of the loop, when max_wait is exhausted.
+ real_sleep 0.2;
+ }
+ dec $max_wait;
+}
+--enable_query_log
+if ($no_success)
+{
+let $message= ! Attention: Timeout in wait_slave_status.inc.
+ | Possible reasons with decreasing probability:
+ | - The LIKE pattern ($result_pattern) is wrong, because the
+ | testcase was altered or the layout of the
+ | SHOW SLAVE STATUS result set changed.
+ | - There is a new bug within the replication.
+ | - We met an extreme testing environment and $max_wait is
+ | too small.;
+--source include/show_msg80.inc
+--echo DEBUG INFO START (wait_slave_status.inc):
+--echo $result_pattern
+--vertical_results
+show slave status;
+--echo DEBUG INFO END
+}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index a9bbe3bc7e1..94ca0ae6924 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -1129,6 +1129,14 @@ sub environment_setup () {
}
# --------------------------------------------------------------------------
+ # Add the path where mysqld will find udf_example.so
+ # --------------------------------------------------------------------------
+ $ENV{'LD_LIBRARY_PATH'}=
+ "$glob_basedir/sql/.libs" .
+ ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : "");
+
+
+ # --------------------------------------------------------------------------
# Also command lines in .opt files may contain env vars
# --------------------------------------------------------------------------
@@ -2099,11 +2107,32 @@ sub save_installed_db () {
}
}
+
+#
+# Save any interesting files in the data_dir
+# before the data dir is removed.
+#
+sub save_files_before_restore($$) {
+ my $test_name= shift;
+ my $data_dir= shift;
+ my $save_name= "$opt_vardir/log/$test_name";
+
+ # Look for core files
+ foreach my $core_file ( glob("$data_dir/core*") )
+ {
+ my $core_name= basename($core_file);
+ mtr_report("Saving $core_name");
+ mkdir($save_name) if ! -d $save_name;
+ rename("$core_file", "$save_name/$core_name");
+ }
+}
+
#
# Restore snapshot of the installed test db(s)
# if the snapshot exists
#
-sub restore_installed_db () {
+sub restore_installed_db ($) {
+ my $test_name= shift;
if ( -d $path_snapshot)
{
@@ -2114,6 +2143,7 @@ sub restore_installed_db () {
foreach my $data_dir (@data_dir_lst)
{
my $name= basename($data_dir);
+ save_files_before_restore($test_name, $data_dir);
rmtree("$data_dir");
copy_dir("$path_snapshot/$name", "$data_dir");
}
@@ -2141,7 +2171,7 @@ sub report_failure_and_restart ($) {
if ( $opt_force )
{
# Restore the snapshot of the installed test db
- restore_installed_db();
+ restore_installed_db($tinfo->{'name'});
print "Resuming Tests\n\n";
return;
}
diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result
index 4c5832a57e9..6574908101c 100644
--- a/mysql-test/r/ctype_big5.result
+++ b/mysql-test/r/ctype_big5.result
@@ -189,3 +189,6 @@ select hex(a) from t1 where a = _big5 0xF9DC;
hex(a)
E5ABBA
drop table t1;
+select hex(convert(_big5 0xC84041 using ucs2));
+hex(convert(_big5 0xC84041 using ucs2))
+003F0041
diff --git a/mysql-test/r/ctype_cp932_binlog.result b/mysql-test/r/ctype_cp932_binlog.result
index d04fce7738c..6d742f3d464 100644
--- a/mysql-test/r/ctype_cp932_binlog.result
+++ b/mysql-test/r/ctype_cp932_binlog.result
@@ -15,3 +15,32 @@ SELECT HEX(f1) FROM t1;
HEX(f1)
8300
DROP table t1;
+CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
+s2 CHAR(50) CHARACTER SET cp932,
+d DECIMAL(10,2))|
+CREATE PROCEDURE bug18293 (IN ins1 CHAR(50),
+IN ins2 CHAR(50) CHARACTER SET cp932,
+IN ind DECIMAL(10,2))
+BEGIN
+INSERT INTO t4 VALUES (ins1, ins2, ind);
+END|
+CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)|
+SELECT HEX(s1),HEX(s2),d FROM t4|
+HEX(s1) HEX(s2) d
+466F6F2773206120426172 ED40ED41ED42 47.93
+DROP PROCEDURE bug18293|
+DROP TABLE t4|
+SHOW BINLOG EVENTS FROM 393|
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 393 Query 1 556 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
+s2 CHAR(50) CHARACTER SET cp932,
+d DECIMAL(10,2))
+master-bin.000001 556 Query 1 801 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50),
+IN ins2 CHAR(50) CHARACTER SET cp932,
+IN ind DECIMAL(10,2))
+BEGIN
+INSERT INTO t4 VALUES (ins1, ins2, ind);
+END
+master-bin.000001 801 Query 1 1006 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1'Foo\'s a Bar'), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
+master-bin.000001 1006 Query 1 1092 use `test`; DROP PROCEDURE bug18293
+master-bin.000001 1092 Query 1 1168 use `test`; DROP TABLE t4
diff --git a/mysql-test/r/ctype_eucjpms.result b/mysql-test/r/ctype_eucjpms.result
index cdb28cd0fdd..ad9666d0c86 100755
--- a/mysql-test/r/ctype_eucjpms.result
+++ b/mysql-test/r/ctype_eucjpms.result
@@ -9819,3 +9819,9 @@ eucjpms_bin 6109
eucjpms_bin 61
eucjpms_bin 6120
drop table t1;
+select hex(convert(_eucjpms 0xA5FE41 using ucs2));
+hex(convert(_eucjpms 0xA5FE41 using ucs2))
+003F0041
+select hex(convert(_eucjpms 0x8FABF841 using ucs2));
+hex(convert(_eucjpms 0x8FABF841 using ucs2))
+003F0041
diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result
index aaffe692126..241539ecf42 100644
--- a/mysql-test/r/ctype_gbk.result
+++ b/mysql-test/r/ctype_gbk.result
@@ -165,3 +165,6 @@ hex(a)
A1A1
A3A0
DROP TABLE t1;
+select hex(convert(_gbk 0xA14041 using ucs2));
+hex(convert(_gbk 0xA14041 using ucs2))
+003F0041
diff --git a/mysql-test/r/ctype_latin2_ch.result b/mysql-test/r/ctype_latin2_ch.result
new file mode 100644
index 00000000000..2b3765c07c4
--- /dev/null
+++ b/mysql-test/r/ctype_latin2_ch.result
@@ -0,0 +1,30 @@
+drop table if exists t1;
+set names latin2;
+select 'A' = 'a' collate latin2_czech_cs;
+'A' = 'a' collate latin2_czech_cs
+0
+create table t1 (
+id int(5) not null,
+tt char(255) not null
+) character set latin2 collate latin2_czech_cs;
+insert into t1 values (1,'Aa');
+insert into t1 values (2,'Aas');
+alter table t1 add primary key aaa(tt);
+select * from t1 where tt like 'Aa%';
+id tt
+1 Aa
+2 Aas
+select * from t1 ignore index (primary) where tt like 'Aa%';
+id tt
+1 Aa
+2 Aas
+select * from t1 where tt like '%Aa%';
+id tt
+1 Aa
+2 Aas
+select * from t1 where tt like 'AA%';
+id tt
+select * from t1 ignore index (primary) where tt like 'AA%';
+id tt
+select * from t1 where tt like '%AA%';
+id tt
diff --git a/mysql-test/r/ctype_ucs2_def.result b/mysql-test/r/ctype_ucs2_def.result
new file mode 100644
index 00000000000..897dbac251c
--- /dev/null
+++ b/mysql-test/r/ctype_ucs2_def.result
@@ -0,0 +1,6 @@
+show variables like "%character_set_ser%";
+Variable_name Value
+character_set_server ucs2
+DROP TABLE IF EXISTS t1;
+create table t1 (a int);
+drop table t1;
diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result
index 2e14fe34430..091d96c56d3 100644
--- a/mysql-test/r/ctype_ujis.result
+++ b/mysql-test/r/ctype_ujis.result
@@ -2307,6 +2307,12 @@ select c1 as c2h from t1 where c1 like 'ab#_def' escape '#';
c2h
ab_def
drop table t1;
+select hex(convert(_ujis 0xA5FE41 using ucs2));
+hex(convert(_ujis 0xA5FE41 using ucs2))
+003F0041
+select hex(convert(_ujis 0x8FABF841 using ucs2));
+hex(convert(_ujis 0x8FABF841 using ucs2))
+003F0041
DROP TABLE IF EXISTS t1, t2;
DROP PROCEDURE IF EXISTS sp1;
set names ujis;
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index d683fcfa3ff..85894d5cb0e 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -447,12 +447,12 @@ t1 CREATE TABLE `t1` (
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a));
INSERT INTO t1 VALUES('test'),('test1'),('test');
-PREPARE stmt from "SELECT a, MATCH(a) AGAINST('test1 test') FROM t1 WHERE MATCH(a) AGAINST('test1 test')";
+PREPARE stmt from "SELECT a, FORMAT(MATCH(a) AGAINST('test1 test'),6) FROM t1 WHERE MATCH(a) AGAINST('test1 test')";
EXECUTE stmt;
-a MATCH(a) AGAINST('test1 test')
-test1 0.68526661396027
+a FORMAT(MATCH(a) AGAINST('test1 test'),6)
+test1 0.685267
EXECUTE stmt;
-a MATCH(a) AGAINST('test1 test')
-test1 0.68526661396027
+a FORMAT(MATCH(a) AGAINST('test1 test'),6)
+test1 0.685267
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
diff --git a/mysql-test/r/have_latin2_ch.require b/mysql-test/r/have_latin2_ch.require
new file mode 100644
index 00000000000..352401bbfe8
--- /dev/null
+++ b/mysql-test/r/have_latin2_ch.require
@@ -0,0 +1,2 @@
+Collation Charset Id Default Compiled Sortlen
+latin2_czech_cs latin2 2 Yes 4
diff --git a/mysql-test/r/have_udf.require b/mysql-test/r/have_udf.require
new file mode 100644
index 00000000000..869d1b254fd
--- /dev/null
+++ b/mysql-test/r/have_udf.require
@@ -0,0 +1 @@
+CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so';
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index d605e81aa93..d8561915564 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -3163,3 +3163,9 @@ t
crash1
crash1
drop table t1;
+create table t1 (c int, key(c));
+insert into t1 values (1142477582), (1142455969);
+create table t2 (a int, b int);
+insert into t2 values (2, 1), (1, 0);
+delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
+drop table t1, t2;
diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result
new file mode 100644
index 00000000000..ce9271224dc
--- /dev/null
+++ b/mysql-test/r/udf.result
@@ -0,0 +1,87 @@
+drop table if exists t1;
+CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so';
+CREATE FUNCTION myfunc_double RETURNS REAL SONAME 'udf_example.so';
+CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME 'udf_example.so';
+ERROR HY000: Can't find function 'myfunc_nonexist' in library
+CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME 'udf_example.so';
+CREATE FUNCTION sequence RETURNS INTEGER SONAME "udf_example.so";
+CREATE FUNCTION lookup RETURNS STRING SONAME 'udf_example.so';
+CREATE FUNCTION reverse_lookup
+RETURNS STRING SONAME 'udf_example.so';
+CREATE AGGREGATE FUNCTION avgcost
+RETURNS REAL SONAME 'udf_example.so';
+select myfunc_double();
+ERROR HY000: myfunc_double must have at least one argument
+select myfunc_double(1);
+myfunc_double(1)
+49.00
+select myfunc_double(78654);
+myfunc_double(78654)
+54.00
+select myfunc_nonexist();
+ERROR 42000: FUNCTION test.myfunc_nonexist does not exist
+select myfunc_int();
+myfunc_int()
+0
+select lookup();
+ERROR HY000: Wrong arguments to lookup; Use the source
+select lookup("127.0.0.1");
+lookup("127.0.0.1")
+127.0.0.1
+select lookup(127,0,0,1);
+ERROR HY000: Wrong arguments to lookup; Use the source
+select lookup("localhost");
+lookup("localhost")
+127.0.0.1
+select reverse_lookup();
+ERROR HY000: Wrong number of arguments to reverse_lookup; Use the source
+select reverse_lookup("127.0.0.1");
+select reverse_lookup(127,0,0,1);
+select reverse_lookup("localhost");
+reverse_lookup("localhost")
+NULL
+select avgcost();
+ERROR HY000: wrong number of arguments: AVGCOST() requires two arguments
+select avgcost(100,23.76);
+ERROR HY000: wrong argument type: AVGCOST() requires an INT and a REAL
+create table t1(sum int, price float(24));
+insert into t1 values(100, 50.00), (100, 100.00);
+select avgcost(sum, price) from t1;
+avgcost(sum, price)
+75.0000
+delete from t1;
+insert into t1 values(100, 54.33), (200, 199.99);
+select avgcost(sum, price) from t1;
+avgcost(sum, price)
+151.4367
+drop table t1;
+select metaphon('hello');
+metaphon('hello')
+HL
+CREATE PROCEDURE `XXX1`(in testval varchar(10))
+begin
+select metaphon(testval);
+end//
+call XXX1('hello');
+metaphon(testval)
+HL
+drop procedure xxx1;
+CREATE PROCEDURE `XXX2`()
+begin
+declare testval varchar(10);
+set testval = 'hello';
+select metaphon(testval);
+end//
+call XXX2();
+metaphon(testval)
+HL
+drop procedure xxx2;
+DROP FUNCTION metaphon;
+DROP FUNCTION myfunc_double;
+DROP FUNCTION myfunc_nonexist;
+ERROR 42000: FUNCTION test.myfunc_nonexist does not exist
+DROP FUNCTION myfunc_int;
+DROP FUNCTION sequence;
+DROP FUNCTION lookup;
+DROP FUNCTION reverse_lookup;
+DROP FUNCTION avgcost;
diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test
index ffe2a12234e..200002cd235 100644
--- a/mysql-test/t/ctype_big5.test
+++ b/mysql-test/t/ctype_big5.test
@@ -53,4 +53,14 @@ alter table t1 convert to character set utf8;
select hex(a) from t1 where a = _big5 0xF9DC;
drop table t1;
+#
+# Bugs#15375: Unassigned multibyte codes are broken
+# into parts when converting to Unicode.
+# This query should return 0x003F0041. I.e. it should
+# scan unassigned double-byte character 0xC840, convert
+# it as QUESTION MARK 0x003F and then scan the next
+# character, which is a single byte character 0x41.
+#
+select hex(convert(_big5 0xC84041 using ucs2));
+
# End of 4.1 tests
diff --git a/mysql-test/t/ctype_cp932_binlog.test b/mysql-test/t/ctype_cp932_binlog.test
index 270e27cf27f..3bbbe94f0e3 100644
--- a/mysql-test/t/ctype_cp932_binlog.test
+++ b/mysql-test/t/ctype_cp932_binlog.test
@@ -32,3 +32,26 @@ DROP table t1;
# end test for bug#11338
# End of 4.1 tests
+
+#
+# Bug#18293: Values in stored procedure written to binlog unescaped
+#
+
+delimiter |;
+CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
+ s2 CHAR(50) CHARACTER SET cp932,
+ d DECIMAL(10,2))|
+CREATE PROCEDURE bug18293 (IN ins1 CHAR(50),
+ IN ins2 CHAR(50) CHARACTER SET cp932,
+ IN ind DECIMAL(10,2))
+ BEGIN
+ INSERT INTO t4 VALUES (ins1, ins2, ind);
+ END|
+CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)|
+SELECT HEX(s1),HEX(s2),d FROM t4|
+DROP PROCEDURE bug18293|
+DROP TABLE t4|
+SHOW BINLOG EVENTS FROM 393|
+delimiter ;|
+
+# End of 5.0 tests
diff --git a/mysql-test/t/ctype_eucjpms.test b/mysql-test/t/ctype_eucjpms.test
index 3609407fe96..8f813fbd82b 100644
--- a/mysql-test/t/ctype_eucjpms.test
+++ b/mysql-test/t/ctype_eucjpms.test
@@ -363,3 +363,20 @@ SET collation_connection='eucjpms_japanese_ci';
-- source include/ctype_filesort.inc
SET collation_connection='eucjpms_bin';
-- source include/ctype_filesort.inc
+
+
+#
+# Bugs#15375: Unassigned multibyte codes are broken
+# into parts when converting to Unicode.
+# This query should return 0x003F0041. I.e. it should
+# scan unassigned double-byte character 0xA5FE, convert
+# it as QUESTION MARK 0x003F and then scan the next
+# character, which is a single byte character 0x41.
+#
+select hex(convert(_eucjpms 0xA5FE41 using ucs2));
+# This one should return 0x003F0041:
+# scan unassigned three-byte character 0x8FABF8,
+# convert it as QUESTION MARK 0x003F and then scan
+# the next character, which is a single byte character 0x41.
+select hex(convert(_eucjpms 0x8FABF841 using ucs2));
+
diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test
index 5eeade96186..7aec48586d8 100644
--- a/mysql-test/t/ctype_gbk.test
+++ b/mysql-test/t/ctype_gbk.test
@@ -31,4 +31,14 @@ INSERT INTO t1 VALUES (0xA3A0),(0xA1A1);
SELECT hex(a) FROM t1 ORDER BY a;
DROP TABLE t1;
+#
+# Bugs#15375: Unassigned multibyte codes are broken
+# into parts when converting to Unicode.
+# This query should return 0x003F0041. I.e. it should
+# scan unassigned double-byte character 0xA140, convert
+# it as QUESTION MARK 0x003F and then scan the next
+# character, which is a single byte character 0x41.
+#
+select hex(convert(_gbk 0xA14041 using ucs2));
+
# End of 4.1 tests
diff --git a/mysql-test/t/ctype_latin2_ch.test b/mysql-test/t/ctype_latin2_ch.test
new file mode 100644
index 00000000000..626d83fa17d
--- /dev/null
+++ b/mysql-test/t/ctype_latin2_ch.test
@@ -0,0 +1,30 @@
+-- source include/have_latin2_ch.inc
+
+#
+# Tests with latin2_czech_cs
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Bug#17374: select ... like 'A%' operator fails
+# to find value on columuns with key
+#
+set names latin2;
+select 'A' = 'a' collate latin2_czech_cs;
+create table t1 (
+ id int(5) not null,
+ tt char(255) not null
+) character set latin2 collate latin2_czech_cs;
+insert into t1 values (1,'Aa');
+insert into t1 values (2,'Aas');
+alter table t1 add primary key aaa(tt);
+select * from t1 where tt like 'Aa%';
+select * from t1 ignore index (primary) where tt like 'Aa%';
+select * from t1 where tt like '%Aa%';
+select * from t1 where tt like 'AA%';
+select * from t1 ignore index (primary) where tt like 'AA%';
+select * from t1 where tt like '%AA%';
+
+# End of 4.1 tests
diff --git a/mysql-test/t/ctype_ucs2_def-master.opt b/mysql-test/t/ctype_ucs2_def-master.opt
new file mode 100644
index 00000000000..1f884ff1d67
--- /dev/null
+++ b/mysql-test/t/ctype_ucs2_def-master.opt
@@ -0,0 +1 @@
+--default-character-set=ucs2 --default-collation=ucs2_unicode_ci
diff --git a/mysql-test/t/ctype_ucs2_def.test b/mysql-test/t/ctype_ucs2_def.test
new file mode 100644
index 00000000000..fb174d551cf
--- /dev/null
+++ b/mysql-test/t/ctype_ucs2_def.test
@@ -0,0 +1,9 @@
+#
+# Bug#18004 Connecting crashes server when default charset is UCS2
+#
+show variables like "%character_set_ser%";
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+create table t1 (a int);
+drop table t1;
diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test
index 77d250b5c45..14b37569b11 100644
--- a/mysql-test/t/ctype_ujis.test
+++ b/mysql-test/t/ctype_ujis.test
@@ -1152,6 +1152,21 @@ SET collation_connection='ujis_bin';
-- source include/ctype_innodb_like.inc
-- source include/ctype_like_escape.inc
+#
+# Bugs#15375: Unassigned multibyte codes are broken
+# into parts when converting to Unicode.
+# This query should return 0x003F0041. I.e. it should
+# scan unassigned double-byte character 0xA5FE, convert
+# it as QUESTION MARK 0x003F and then scan the next
+# character, which is a single byte character 0x41.
+#
+select hex(convert(_ujis 0xA5FE41 using ucs2));
+# This one should return 0x003F0041:
+# scan unassigned three-byte character 0x8FABF8,
+# convert it as QUESTION MARK 0x003F and then scan
+# the next character, which is a single byte character 0x41.
+select hex(convert(_ujis 0x8FABF841 using ucs2));
+
# End of 4.1 tests
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 91033fe2ba9..0f7835e9e7e 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -371,7 +371,7 @@ DROP TABLE t1;
#
CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a));
INSERT INTO t1 VALUES('test'),('test1'),('test');
-PREPARE stmt from "SELECT a, MATCH(a) AGAINST('test1 test') FROM t1 WHERE MATCH(a) AGAINST('test1 test')";
+PREPARE stmt from "SELECT a, FORMAT(MATCH(a) AGAINST('test1 test'),6) FROM t1 WHERE MATCH(a) AGAINST('test1 test')";
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 368020dd721..1ef80bdd7ac 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -2074,3 +2074,14 @@ create table t1( f1 int,f2 int);
insert into t1 values (1,1),(2,2);
select tt.t from (select 'crash1' as t, f2 from t1) as tt left join t1 on tt.t = 'crash2' and tt.f2 = t1.f2 where tt.t = 'crash1';
drop table t1;
+
+#
+# Bug #18306: server crash on delete using subquery.
+#
+
+create table t1 (c int, key(c));
+insert into t1 values (1142477582), (1142455969);
+create table t2 (a int, b int);
+insert into t2 values (2, 1), (1, 0);
+delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
+drop table t1, t2;
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index d223c315735..5bfd744e4a8 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -116,10 +116,15 @@ drop table if exists t1;
# Check conversion of floats to character field (Bug #7774)
create table t1 (c char(20));
insert into t1 values (5e-28);
+# Expected result is "5e-28", but windows returns "5e-028"
+--replace_result 5e-028 5e-28
select * from t1;
drop table t1;
create table t1 (c char(6));
insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
+# Expected result is "2e+06", but windows returns "2e+006"
+# Expected result is "2e-05", but windows returns "2e-005"
+--replace_result 2e+006 2e+06 2e-005 2e-05
select * from t1;
drop table t1;
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index e2fe9767432..74782a5bddb 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1050,6 +1050,10 @@ while ($max_power)
}
SELECT my_float, my_double, my_varchar FROM t1;
+# Expected result 0.000000000011754943372854760000
+# On windows we get 0.000000000011754943372854770000
+# use replace_result to correct it
+--replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000
SELECT CAST(my_float AS DECIMAL(65,30)), my_float FROM t1;
SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1;
SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;
@@ -1061,7 +1065,13 @@ SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;
--disable_warnings
UPDATE t1 SET my_decimal = my_float;
+
+# Expected result 0.000000000011754943372854760000
+# On windows we get 0.000000000011754943372854770000
+# use replace_result to correct it
+--replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000
SELECT my_decimal, my_float FROM t1;
+
UPDATE t1 SET my_decimal = my_double;
SELECT my_decimal, my_double FROM t1;
--enable_warnings
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
new file mode 100644
index 00000000000..c9f22cf410b
--- /dev/null
+++ b/mysql-test/t/udf.test
@@ -0,0 +1,108 @@
+--source include/have_udf.inc
+#
+# To run this tests the "sql/udf_example.cc" need to be compiled into
+# udf_example.so and LD_LIBRARY_PATH should be setup to point out where
+# the library are.
+#
+
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Create the example functions from udf_example
+#
+
+CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so';
+CREATE FUNCTION myfunc_double RETURNS REAL SONAME 'udf_example.so';
+
+--error ER_CANT_FIND_DL_ENTRY
+CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME 'udf_example.so';
+CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME 'udf_example.so';
+CREATE FUNCTION sequence RETURNS INTEGER SONAME "udf_example.so";
+CREATE FUNCTION lookup RETURNS STRING SONAME 'udf_example.so';
+CREATE FUNCTION reverse_lookup
+ RETURNS STRING SONAME 'udf_example.so';
+CREATE AGGREGATE FUNCTION avgcost
+ RETURNS REAL SONAME 'udf_example.so';
+
+--error 0
+select myfunc_double();
+select myfunc_double(1);
+select myfunc_double(78654);
+--error 1305
+select myfunc_nonexist();
+select myfunc_int();
+--error 0
+select lookup();
+select lookup("127.0.0.1");
+--error 0
+select lookup(127,0,0,1);
+select lookup("localhost");
+--error 0
+select reverse_lookup();
+
+# These two functions should return "localhost", but it's
+# depending on configuration, so just call them and don't log the result
+--disable_result_log
+select reverse_lookup("127.0.0.1");
+select reverse_lookup(127,0,0,1);
+--enable_result_log
+
+select reverse_lookup("localhost");
+--error 0
+select avgcost();
+--error 0
+select avgcost(100,23.76);
+create table t1(sum int, price float(24));
+insert into t1 values(100, 50.00), (100, 100.00);
+select avgcost(sum, price) from t1;
+delete from t1;
+insert into t1 values(100, 54.33), (200, 199.99);
+select avgcost(sum, price) from t1;
+drop table t1;
+
+#------------------------------------------------------------------------
+# BUG#17261 Passing a variable from a stored procedure to UDF crashes mysqld
+#------------------------------------------------------------------------
+
+select metaphon('hello');
+
+delimiter //;
+CREATE PROCEDURE `XXX1`(in testval varchar(10))
+begin
+select metaphon(testval);
+end//
+delimiter ;//
+
+call XXX1('hello');
+drop procedure xxx1;
+
+delimiter //;
+CREATE PROCEDURE `XXX2`()
+begin
+declare testval varchar(10);
+set testval = 'hello';
+select metaphon(testval);
+end//
+delimiter ;//
+
+call XXX2();
+drop procedure xxx2;
+
+
+#
+# Drop the example functions from udf_example
+#
+
+DROP FUNCTION metaphon;
+DROP FUNCTION myfunc_double;
+--error ER_SP_DOES_NOT_EXIST
+DROP FUNCTION myfunc_nonexist;
+DROP FUNCTION myfunc_int;
+DROP FUNCTION sequence;
+DROP FUNCTION lookup;
+DROP FUNCTION reverse_lookup;
+DROP FUNCTION avgcost;
+
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 8df1d34ea5e..8d8dc7896df 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -20,6 +20,8 @@ select @test, @`test`, @TEST, @`TEST`, @"teSt";
set @select=2,@t5=1.23456;
select @`select`,@not_used;
set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
+# Expected result "1e-10", windows returns "1e-010"
+--replace_result 1e-010 1e-10
select @test_int,@test_double,@test_string,@test_string2,@select;
set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello";
select @test_int,@test_double,@test_string,@test_string2;
diff --git a/sql-common/client.c b/sql-common/client.c
index 2d826df0662..4c7ef3fcd03 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1428,7 +1428,13 @@ mysql_init(MYSQL *mysql)
mysql->free_me=1;
}
else
- bzero((char*) (mysql),sizeof(*(mysql)));
+ {
+#if defined(EMBEDDED_LIBRARY) || MYSQL_VERSION_ID >= 50100
+ bzero((char*) (mysql), sizeof(*(mysql)));
+#else
+ bzero((char*) (mysql), offsetof(MYSQL, info_buffer));
+#endif
+ }
mysql->options.connect_timeout= CONNECT_TIMEOUT;
mysql->last_used_con= mysql->next_slave= mysql->master = mysql;
mysql->charset=default_charset_info;
@@ -2341,9 +2347,12 @@ static void mysql_close_free(MYSQL *mysql)
my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
+#if defined(EMBEDDED_LIBRARY) || MYSQL_VERSION_ID >= 50100
my_free(mysql->info_buffer,MYF(MY_ALLOW_ZERO_PTR));
+ mysql->info_buffer= 0;
+#endif
/* Clear pointers for better safety */
- mysql->info_buffer=mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
+ mysql->host_info= mysql->user= mysql->passwd= mysql->db= 0;
}
diff --git a/sql/Makefile.am b/sql/Makefile.am
index d701c18a4d7..1597ad2c4a8 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -153,10 +153,11 @@ sql_yacc.o: sql_yacc.cc sql_yacc.h $(HEADERS)
lex_hash.h: gen_lex_hash$(EXEEXT)
./gen_lex_hash$(EXEEXT) > $@
-# For testing of udf_example.so; Works on platforms with gcc
-# (This is not part of our build process but only provided as an example)
-udf_example.so: udf_example.cc
- $(CXXCOMPILE) -shared -o $@ $<
+# For testing of udf_example.so
+noinst_LTLIBRARIES= udf_example.la
+udf_example_la_SOURCES= udf_example.cc
+udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
+
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/sql/item.cc b/sql/item.cc
index 808271fe256..c48bf19a88b 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2642,25 +2642,8 @@ const String *Item_param::query_val_str(String* str) const
case STRING_VALUE:
case LONG_DATA_VALUE:
{
- char *buf, *ptr;
str->length(0);
- if (str->reserve(str_value.length()*2+3))
- break;
-
- buf= str->c_ptr_quick();
- ptr= buf;
- if (value.cs_info.character_set_client->escape_with_backslash_is_dangerous)
- {
- ptr= str_to_hex(ptr, str_value.ptr(), str_value.length());
- }
- else
- {
- *ptr++= '\'';
- ptr+= escape_string_for_mysql(str_value.charset(), ptr, 0,
- str_value.ptr(), str_value.length());
- *ptr++='\'';
- }
- str->length((uint32) (ptr - buf));
+ append_query_string(value.cs_info.character_set_client, &str_value, str);
break;
}
case NULL_VALUE:
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ccfb71e9d0c..7511b2af8c4 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2606,7 +2606,7 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func,
switch(arguments[i]->type()) {
case Item::STRING_ITEM: // Constant string !
{
- String *res=arguments[i]->val_str((String *) 0);
+ String *res=arguments[i]->val_str(&buffers[i]);
if (arguments[i]->null_value)
continue;
f_args.args[i]= (char*) res->ptr();
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 5ca7c00ee8f..266d6b064bd 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -240,6 +240,37 @@ char *str_to_hex(char *to, const char *from, uint len)
}
/*
+ Append a version of the 'from' string suitable for use in a query to
+ the 'to' string. To generate a correct escaping, the character set
+ information in 'csinfo' is used.
+ */
+#ifndef MYSQL_CLIENT
+int
+append_query_string(CHARSET_INFO *csinfo,
+ String const *from, String *to)
+{
+ char *beg, *ptr;
+ uint32 const orig_len= to->length();
+ if (to->reserve(orig_len + from->length()*2+3))
+ return 1;
+
+ beg= to->c_ptr_quick() + to->length();
+ ptr= beg;
+ if (csinfo->escape_with_backslash_is_dangerous)
+ ptr= str_to_hex(ptr, from->ptr(), from->length());
+ else
+ {
+ *ptr++= '\'';
+ ptr+= escape_string_for_mysql(from->charset(), ptr, 0,
+ from->ptr(), from->length());
+ *ptr++='\'';
+ }
+ to->length(orig_len + ptr - beg);
+ return 0;
+}
+#endif
+
+/*
Prints a "session_var=value" string. Used by mysqlbinlog to print some SET
commands just before it prints a query.
*/
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 32262b3afb2..9c9d8115402 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -529,6 +529,8 @@ bool delete_precheck(THD *thd, TABLE_LIST *tables);
bool insert_precheck(THD *thd, TABLE_LIST *tables);
bool create_table_precheck(THD *thd, TABLE_LIST *tables,
TABLE_LIST *create_table);
+int append_query_string(CHARSET_INFO *csinfo,
+ String const *from, String *to);
void get_default_definer(THD *thd, LEX_USER *definer);
LEX_USER *create_default_definer(THD *thd);
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 04cc0baa0aa..634c9db18a8 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3604,9 +3604,18 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
/* Here when simple cond */
if (cond->const_item())
{
- if (cond->val_int())
- DBUG_RETURN(new SEL_TREE(SEL_TREE::ALWAYS));
- DBUG_RETURN(new SEL_TREE(SEL_TREE::IMPOSSIBLE));
+ /*
+ During the cond->val_int() evaluation we can come across a subselect
+ item which may allocate memory on the thd->mem_root and assumes
+ all the memory allocated has the same life span as the subselect
+ item itself. So we have to restore the thread's mem_root here.
+ */
+ MEM_ROOT *tmp_root= param->mem_root;
+ param->thd->mem_root= param->old_root;
+ tree= cond->val_int() ? new(tmp_root) SEL_TREE(SEL_TREE::ALWAYS) :
+ new(tmp_root) SEL_TREE(SEL_TREE::IMPOSSIBLE);
+ param->thd->mem_root= tmp_root;
+ DBUG_RETURN(tree);
}
table_map ref_tables= 0;
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index 041b770ac0b..a57c6c02904 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -746,7 +746,6 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
char *eol;
LEX_STRING *str;
List<LEX_STRING> *list;
- ulonglong *num;
DBUG_ENTER("File_parser::parse");
while (ptr < end && found < required)
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index a860796f02d..37487c245a9 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -2978,23 +2978,23 @@ ER_UDF_EXISTS
swe "Funktionen '%-.64s' finns redan"
ukr "æ '%-.64s' դ"
ER_CANT_OPEN_LIBRARY
- cze "Nemohu otev-Bt sdlenou knihovnu '%-.64s' (errno: %d %s)"
- dan "Kan ikke bne delt bibliotek '%-.64s' (errno: %d %s)"
- nla "Kan shared library '%-.64s' niet openen (Errcode: %d %s)"
- eng "Can't open shared library '%-.64s' (errno: %d %-.64s)"
- jps "shared library '%-.64s' Jł܂ (errno: %d %s)",
- est "Ei suuda avada jagatud teeki '%-.64s' (veakood: %d %-.64s)"
- fre "Impossible d'ouvrir la bibliothque partage '%-.64s' (errno: %d %s)"
- ger "Kann Shared Library '%-.64s' nicht ffnen (Fehler: %d %-.64s)"
- greek " shared library '%-.64s' ( : %d %s)"
- hun "A(z) '%-.64s' megosztott konyvtar nem hasznalhato (hibakod: %d %s)"
- ita "Impossibile aprire la libreria condivisa '%-.64s' (errno: %d %s)"
- jpn "shared library '%-.64s' 򳫤Ǥޤ (errno: %d %s)"
- kor "'%-.64s' ̹ ϴ.(ȣ: %d %s)"
- nor "Can't open shared library '%-.64s' (errno: %d %s)"
- norwegian-ny "Can't open shared library '%-.64s' (errno: %d %s)"
- pol "Can't open shared library '%-.64s' (errno: %d %s)"
- por "No pode abrir biblioteca compartilhada '%-.64s' (erro no. '%d' - '%-.64s')"
+ cze "Nemohu otev-Bt sdlenou knihovnu '%-.64s' (errno: %d %-.128s)"
+ dan "Kan ikke bne delt bibliotek '%-.64s' (errno: %d %-.128s)"
+ nla "Kan shared library '%-.64s' niet openen (Errcode: %d %-.128s)"
+ eng "Can't open shared library '%-.64s' (errno: %d %-.128s)"
+ jps "shared library '%-.64s' Jł܂ (errno: %d %-.128s)",
+ est "Ei suuda avada jagatud teeki '%-.64s' (veakood: %d %-.128s)"
+ fre "Impossible d'ouvrir la bibliothque partage '%-.64s' (errno: %d %-.128s)"
+ ger "Kann Shared Library '%-.64s' nicht ffnen (Fehler: %d %-.128s)"
+ greek " shared library '%-.64s' ( : %d %-.128s)"
+ hun "A(z) '%-.64s' megosztott konyvtar nem hasznalhato (hibakod: %d %-.128s)"
+ ita "Impossibile aprire la libreria condivisa '%-.64s' (errno: %d %-.128s)"
+ jpn "shared library '%-.64s' 򳫤Ǥޤ (errno: %d %-.128s)"
+ kor "'%-.64s' ̹ ϴ.(ȣ: %d %-.128s)"
+ nor "Can't open shared library '%-.64s' (errno: %d %-.128s)"
+ norwegian-ny "Can't open shared library '%-.64s' (errno: %d %-.128s)"
+ pol "Can't open shared library '%-.64s' (errno: %d %-.128s)"
+ por "No pode abrir biblioteca compartilhada '%-.64s' (erro no. '%d' - '%-.128s')"
rum "Nu pot deschide libraria shared '%-.64s' (Eroare: %d %-.64s)"
rus " '%-.64s' (: %d %-.64s)"
serbian "Ne mogu da otvorim share-ovanu biblioteku '%-.64s' (errno: %d %-.64s)"
@@ -3003,27 +3003,27 @@ ER_CANT_OPEN_LIBRARY
swe "Kan inte ppna det dynamiska biblioteket '%-.64s' (Felkod: %d %s)"
ukr " צ Ħ ¦̦ '%-.64s' (: %d %-.64s)"
ER_CANT_FIND_DL_ENTRY
- cze "Nemohu naj-Bt funkci '%-.64s' v knihovn"
- dan "Kan ikke finde funktionen '%-.64s' i bibliotek"
- nla "Kan functie '%-.64s' niet in library vinden"
- eng "Can't find function '%-.64s' in library"
- jps "function '%-.64s' Cu[Ɍt鎖ł܂",
- est "Ei leia funktsiooni '%-.64s' antud teegis"
- fre "Impossible de trouver la fonction '%-.64s' dans la bibliothque"
- ger "Kann Funktion '%-.64s' in der Library nicht finden"
- greek " '%-.64s' "
- hun "A(z) '%-.64s' fuggveny nem talalhato a konyvtarban"
- ita "Impossibile trovare la funzione '%-.64s' nella libreria"
- jpn "function '%-.64s' 饤֥꡼˸դǤޤ"
- kor "̹ '%-.64s' Լ ã ϴ."
- por "No pode encontrar a funo '%-.64s' na biblioteca"
- rum "Nu pot gasi functia '%-.64s' in libraria"
- rus " '%-.64s' "
- serbian "Ne mogu da pronadjem funkciju '%-.64s' u biblioteci"
- slo "Nemem njs funkciu '%-.64s' v kninici"
- spa "No puedo encontrar funcin '%-.64s' en libraria"
- swe "Hittar inte funktionen '%-.64s' in det dynamiska biblioteket"
- ukr " æ '%-.64s' ¦̦æ"
+ cze "Nemohu naj-Bt funkci '%-.128s' v knihovn"
+ dan "Kan ikke finde funktionen '%-.128s' i bibliotek"
+ nla "Kan functie '%-.128s' niet in library vinden"
+ eng "Can't find function '%-.128s' in library"
+ jps "function '%-.128s' Cu[Ɍt鎖ł܂",
+ est "Ei leia funktsiooni '%-.128s' antud teegis"
+ fre "Impossible de trouver la fonction '%-.128s' dans la bibliothque"
+ ger "Kann Funktion '%-.128s' in der Library nicht finden"
+ greek " '%-.128s' "
+ hun "A(z) '%-.128s' fuggveny nem talalhato a konyvtarban"
+ ita "Impossibile trovare la funzione '%-.128s' nella libreria"
+ jpn "function '%-.128s' 饤֥꡼˸դǤޤ"
+ kor "̹ '%-.128s' Լ ã ϴ."
+ por "No pode encontrar a funo '%-.128s' na biblioteca"
+ rum "Nu pot gasi functia '%-.128s' in libraria"
+ rus " '%-.128s' "
+ serbian "Ne mogu da pronadjem funkciju '%-.128s' u biblioteci"
+ slo "Nemem njs funkciu '%-.128s' v kninici"
+ spa "No puedo encontrar funcin '%-.128s' en libraria"
+ swe "Hittar inte funktionen '%-.128s' in det dynamiska biblioteket"
+ ukr " æ '%-.128s' ¦̦æ"
ER_FUNCTION_NOT_DEFINED
cze "Funkce '%-.64s' nen-B definovna"
dan "Funktionen '%-.64s' er ikke defineret"
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index c0b566f9b9b..bba9479c8f3 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -80,8 +80,8 @@ sp_map_item_type(enum enum_field_types type)
/*
Return a string representation of the Item value.
- NOTE: this is a legacy-compatible implementation. It fails if the value
- contains non-ordinary symbols, which should be escaped.
+ NOTE: If the item has a string result type, the string is escaped
+ according to its character set.
SYNOPSIS
item a pointer to the Item
@@ -119,9 +119,9 @@ sp_get_item_value(Item *item, String *str)
buf.append('_');
buf.append(result->charset()->csname);
- buf.append('\'');
- buf.append(*result);
- buf.append('\'');
+ if (result->charset()->escape_with_backslash_is_dangerous)
+ buf.append(' ');
+ append_query_string(result->charset(), result, &buf);
str->copy(buf);
return str;
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index fd7bca7ec21..79228be8a76 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -819,8 +819,18 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
from++;
wc= '?';
}
+ else if (cnvres > MY_CS_TOOSMALL)
+ {
+ /*
+ A correct multibyte sequence detected
+ But it doesn't have Unicode mapping.
+ */
+ error_count++;
+ from+= (-cnvres);
+ wc= '?';
+ }
else
- break; // Impossible char.
+ break; // Not enough characters
outp:
if ((cnvres= (*wc_mb)(to_cs, wc, (uchar*) to, to_end)) > 0)
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 3f8a4e346f9..6269c0a2eb3 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -439,6 +439,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
}
if (!(dl = find_udf_dl(udf->dl)))
{
+ DBUG_PRINT("info", ("Calling dlopen, udf->dl: %s", udf->dl));
if (!(dl = dlopen(udf->dl, RTLD_NOW)))
{
DBUG_PRINT("error",("dlopen of %s failed, error: %d (%s)",
diff --git a/sql/table.cc b/sql/table.cc
index 64ef8aa1e4b..8e23bea2540 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1597,7 +1597,7 @@ bool check_db_name(char *name)
while (*name)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
- last_char_is_space= my_isspace(default_charset_info, *name);
+ last_char_is_space= my_isspace(system_charset_info, *name);
if (use_mb(system_charset_info))
{
int len=my_ismbchar(system_charset_info, name,
@@ -1643,7 +1643,7 @@ bool check_table_name(const char *name, uint length)
while (name != end)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
- last_char_is_space= my_isspace(default_charset_info, *name);
+ last_char_is_space= my_isspace(system_charset_info, *name);
if (use_mb(system_charset_info))
{
int len=my_ismbchar(system_charset_info, name, end);
@@ -1674,7 +1674,7 @@ bool check_column_name(const char *name)
while (*name)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
- last_char_is_space= my_isspace(default_charset_info, *name);
+ last_char_is_space= my_isspace(system_charset_info, *name);
if (use_mb(system_charset_info))
{
int len=my_ismbchar(system_charset_info, name,
diff --git a/sql/udf_example.cc b/sql/udf_example.cc
index 35833e63fab..e6d272d9085 100644
--- a/sql/udf_example.cc
+++ b/sql/udf_example.cc
@@ -113,6 +113,8 @@
*/
#ifdef STANDARD
+/* STANDARD is defined, don't use any mysql functions */
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef __WIN__
@@ -125,10 +127,10 @@ typedef long long longlong;
#else
#include <my_global.h>
#include <my_sys.h>
+#include <m_string.h> // To get strmov()
#endif
#include <mysql.h>
-#include <m_ctype.h>
-#include <m_string.h> // To get strmov()
+#include <ctype.h>
static pthread_mutex_t LOCK_hostname;
@@ -290,8 +292,8 @@ char *metaphon(UDF_INIT *initid, UDF_ARGS *args, char *result,
for (n = ntrans + 1, n_end = ntrans + sizeof(ntrans)-2;
word != w_end && n < n_end; word++ )
- if ( my_isalpha ( &my_charset_latin1, *word ))
- *n++ = my_toupper ( &my_charset_latin1, *word );
+ if ( isalpha ( *word ))
+ *n++ = toupper ( *word );
if ( n == ntrans + 1 ) /* return empty string if 0 bytes */
{
@@ -519,7 +521,7 @@ my_bool myfunc_double_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if (!args->arg_count)
{
- strcpy(message,"myfunc_double must have at least on argument");
+ strcpy(message,"myfunc_double must have at least one argument");
return 1;
}
/*
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 460215418f8..0ca1cf21129 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -6275,7 +6275,7 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
int hi=s[0];
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
if (hi<0x80)
{
@@ -6284,10 +6284,10 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
}
if (s+2>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
if (!(pwc[0]=func_big5_uni_onechar((hi<<8)+s[1])))
- return MY_CS_ILSEQ;
+ return -2;
return 2;
}
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c
index 973a6ebf12a..54c35c82652 100644
--- a/strings/ctype-bin.c
+++ b/strings/ctype-bin.c
@@ -246,7 +246,7 @@ static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)),
const unsigned char *end __attribute__((unused)))
{
if (str >= end)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
*wc=str[0];
return 1;
@@ -295,10 +295,10 @@ void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)),
#define INC_PTR(cs,A,B) (A)++
-static int my_wildcmp_bin(CHARSET_INFO *cs,
- const char *str,const char *str_end,
- const char *wildstr,const char *wildend,
- int escape, int w_one, int w_many)
+int my_wildcmp_bin(CHARSET_INFO *cs,
+ const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,
+ int escape, int w_one, int w_many)
{
int result= -1; /* Not found, using wildcards */
diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c
index 1e3126865f3..5f8a93b1c2b 100644
--- a/strings/ctype-cp932.c
+++ b/strings/ctype-cp932.c
@@ -5355,7 +5355,7 @@ my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)),
int hi=s[0];
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
if (hi < 0x80)
{
@@ -5370,10 +5370,10 @@ my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)),
}
if (s+2>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
if (!(pwc[0]=func_cp932_uni_onechar((hi<<8)+s[1])))
- return MY_CS_ILSEQ;
+ return -2;
return 2;
}
diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c
index fa3a3bf53fe..d9f95868d6d 100644
--- a/strings/ctype-czech.c
+++ b/strings/ctype-czech.c
@@ -356,7 +356,7 @@ static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)),
#ifdef REAL_MYSQL
-#define min_sort_char 0
+#define min_sort_char ' '
#define max_sort_char '9'
#define EXAMPLE
@@ -595,7 +595,7 @@ static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler =
my_strnxfrm_czech,
my_strnxfrmlen_simple,
my_like_range_czech,
- my_wildcmp_8bit,
+ my_wildcmp_bin,
my_strcasecmp_8bit,
my_instr_simple,
my_hash_sort_simple,
diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c
index 5e357e0b65c..d6df46f7e05 100644
--- a/strings/ctype-euc_kr.c
+++ b/strings/ctype-euc_kr.c
@@ -8601,7 +8601,7 @@ my_wc_mb_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
return MY_CS_ILUNI;
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
s[0]=code>>8;
s[1]=code&0xFF;
@@ -8617,7 +8617,7 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
int hi=s[0];
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
if (hi<0x80)
{
@@ -8626,10 +8626,10 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
}
if (s+2>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
if (!(pwc[0]=func_ksc5601_uni_onechar((hi<<8)+s[1])))
- return MY_CS_ILSEQ;
+ return -2;
return 2;
}
diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c
index f9210fcb10e..348eb2f6e87 100644
--- a/strings/ctype-eucjpms.c
+++ b/strings/ctype-eucjpms.c
@@ -243,7 +243,7 @@ my_mb_wc_jisx0201(CHARSET_INFO *cs __attribute__((unused)),
const uchar *e __attribute__((unused)))
{
wc[0]=tab_jisx0201_uni[*s];
- return (!wc[0] && s[0]) ? MY_CS_ILSEQ : 1;
+ return (!wc[0] && s[0]) ? -1 : 1;
}
@@ -8473,7 +8473,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
int c1,c2,c3;
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
c1=s[0];
@@ -8485,7 +8485,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
}
if (s+2>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
c2=s[1];
@@ -8500,7 +8500,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
{
pwc[0]=my_jisx0208_uni_onechar( ((c1-0x80) << 8) + (c2-0x80));
if (!pwc[0])
- return MY_CS_ILSEQ;
+ return -2;
}
else
{
@@ -8520,7 +8520,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
ret = my_mb_wc_jisx0201(cs,pwc,s+1,e);
if (ret!=1)
- return ret;
+ return -2;
return 2;
}
@@ -8531,7 +8531,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
return MY_CS_ILSEQ;
if (s+3>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL3;
c3=s[2];
if (c3 < 0xA1 || c3>=0xFF)
@@ -8540,8 +8540,8 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
if (c2<0xF5)
{
pwc[0]=my_jisx0212_uni_onechar((c2-0x80)*256 + (c3-0x80));
- if (!pwc)
- return MY_CS_ILSEQ;
+ if (!pwc[0])
+ return -3;
}
else
{
@@ -8572,7 +8572,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if ((jp=my_uni_jisx0208_onechar(wc)))
{
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
jp+=0x8080;
s[0]=jp>>8;
@@ -8584,7 +8584,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if (my_wc_mb_jisx0201(c,wc,s,e) == 1)
{
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
s[1]= s[0];
s[0]= 0x8E;
return 2;
@@ -8594,7 +8594,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if ((jp=my_uni_jisx0212_onechar(wc)))
{
if (s+3>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL3;
jp+=0x8080;
s[0]=0x8F;
@@ -8608,7 +8608,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if (wc>=0xE000 && wc<0xE3AC)
{
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
c1=((unsigned)(wc-0xE000)/94)+0xF5;
s[0]=c1;
@@ -8622,7 +8622,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if (wc>=0xE3AC && wc<0xE758)
{
if (s+3>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL3;
s[0]=0x8F;
c1=((unsigned)(wc-0xE3AC)/94)+0xF5;
diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c
index f3938cc27ba..29ecafc3527 100644
--- a/strings/ctype-gb2312.c
+++ b/strings/ctype-gb2312.c
@@ -5651,7 +5651,7 @@ my_wc_mb_gb2312(CHARSET_INFO *cs __attribute__((unused)),
return MY_CS_ILUNI;
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
code|=0x8080;
s[0]=code>>8;
@@ -5668,7 +5668,7 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)),
hi=(int) s[0];
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
if (hi<0x80)
{
@@ -5677,10 +5677,10 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)),
}
if (s+2>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
if (!(pwc[0]=func_gb2312_uni_onechar(((hi<<8)+s[1])&0x7F7F)))
- return MY_CS_ILSEQ;
+ return -2;
return 2;
}
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index edc595875d7..ef1b33fd82c 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -9902,7 +9902,7 @@ my_wc_mb_gbk(CHARSET_INFO *cs __attribute__((unused)),
return MY_CS_ILUNI;
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
s[0]=code>>8;
s[1]=code&0xFF;
@@ -9916,7 +9916,7 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)),
int hi;
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
hi=s[0];
@@ -9927,10 +9927,10 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)),
}
if (s+2>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
if (!(pwc[0]=func_gbk_uni_onechar( (hi<<8) + s[1])))
- return MY_CS_ILSEQ;
+ return -2;
return 2;
diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c
index 746cb5a4003..a3f5aec9605 100644
--- a/strings/ctype-latin1.c
+++ b/strings/ctype-latin1.c
@@ -363,10 +363,10 @@ int my_mb_wc_latin1(CHARSET_INFO *cs __attribute__((unused)),
const unsigned char *end __attribute__((unused)))
{
if (str >= end)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
*wc=cs_to_uni[*str];
- return (!wc[0] && str[0]) ? MY_CS_ILSEQ : 1;
+ return (!wc[0] && str[0]) ? -1 : 1;
}
static
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index d6f2f0e5fe5..12ef77c59b1 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -239,10 +239,10 @@ int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc,
const unsigned char *end __attribute__((unused)))
{
if (str >= end)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
*wc=cs->tab_to_uni[*str];
- return (!wc[0] && str[0]) ? MY_CS_ILSEQ : 1;
+ return (!wc[0] && str[0]) ? -1 : 1;
}
int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc,
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index 398aea08b05..57d6d8bae2b 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -4516,7 +4516,7 @@ my_wc_mb_sjis(CHARSET_INFO *cs __attribute__((unused)),
mb:
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
s[0]=code>>8;
s[1]=code&0xFF;
@@ -4530,7 +4530,7 @@ my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)),
int hi=s[0];
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
if (hi < 0x80)
{
@@ -4545,10 +4545,10 @@ my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)),
}
if (s+2>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
if (!(pwc[0]=func_sjis_uni_onechar((hi<<8)+s[1])))
- return MY_CS_ILSEQ;
+ return -2;
return 2;
}
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index 1200644de3c..dc4f18b516b 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -827,10 +827,10 @@ int my_mb_wc_tis620(CHARSET_INFO *cs __attribute__((unused)),
const unsigned char *end __attribute__((unused)))
{
if (str >= end)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
*wc=cs_to_uni[*str];
- return (!wc[0] && str[0]) ? MY_CS_ILSEQ : 1;
+ return (!wc[0] && str[0]) ? -1 : 1;
}
static
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index e2629f445cb..97dca79e84b 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -94,7 +94,7 @@ static int my_ucs2_uni(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t * pwc, const uchar *s, const uchar *e)
{
if (s+2 > e) /* Need 2 characters */
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
*pwc= ((unsigned char)s[0]) * 256 + ((unsigned char)s[1]);
return 2;
@@ -104,7 +104,7 @@ static int my_uni_ucs2(CHARSET_INFO *cs __attribute__((unused)) ,
my_wc_t wc, uchar *r, uchar *e)
{
if ( r+2 > e )
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
r[0]= (uchar) (wc >> 8);
r[1]= (uchar) (wc & 0xFF);
diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c
index 696eecaa794..ca27b4bef6b 100644
--- a/strings/ctype-ujis.c
+++ b/strings/ctype-ujis.c
@@ -242,7 +242,7 @@ my_mb_wc_jisx0201(CHARSET_INFO *cs __attribute__((unused)),
const uchar *e __attribute__((unused)))
{
wc[0]=tab_jisx0201_uni[*s];
- return (!wc[0] && s[0]) ? MY_CS_ILSEQ : 1;
+ return (!wc[0] && s[0]) ? -1 : 1;
}
@@ -8341,7 +8341,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
int c1,c2,c3;
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
c1=s[0];
@@ -8353,7 +8353,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
}
if (s+2>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
c2=s[1];
@@ -8368,7 +8368,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
{
pwc[0]=my_jisx0208_uni_onechar( ((c1-0x80) << 8) + (c2-0x80));
if (!pwc[0])
- return MY_CS_ILSEQ;
+ return -2;
}
else
{
@@ -8388,7 +8388,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
ret = my_mb_wc_jisx0201(cs,pwc,s+1,e);
if (ret!=1)
- return ret;
+ return -2;
return 2;
}
@@ -8399,7 +8399,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
return MY_CS_ILSEQ;
if (s+3>e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL3;
c3=s[2];
if (c3 < 0xA1 || c3>=0xFF)
@@ -8408,8 +8408,8 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
if (c2<0xF5)
{
pwc[0]=my_jisx0212_uni_onechar((c2-0x80)*256 + (c3-0x80));
- if (!pwc)
- return MY_CS_ILSEQ;
+ if (!pwc[0])
+ return -3;
}
else
{
@@ -8440,7 +8440,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if ((jp=my_uni_jisx0208_onechar(wc)))
{
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
jp+=0x8080;
s[0]=jp>>8;
@@ -8452,7 +8452,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if (my_wc_mb_jisx0201(c,wc,s,e) == 1)
{
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
s[1]= s[0];
s[0]= 0x8E;
return 2;
@@ -8462,7 +8462,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if ((jp=my_uni_jisx0212_onechar(wc)))
{
if (s+3>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL3;
jp+=0x8080;
s[0]=0x8F;
@@ -8476,7 +8476,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if (wc>=0xE000 && wc<0xE3AC)
{
if (s+2>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL2;
c1=((unsigned)(wc-0xE000)/94)+0xF5;
s[0]=c1;
@@ -8490,7 +8490,7 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
if (wc>=0xE3AC && wc<0xE758)
{
if (s+3>e)
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALL3;
s[0]=0x8F;
c1=((unsigned)(wc-0xE3AC)/94)+0xF5;
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index e1bb746fd9a..3594ab954c6 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -1947,7 +1947,7 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)),
unsigned char c;
if (s >= e)
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL;
c= s[0];
if (c < 0x80)
@@ -1960,7 +1960,7 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)),
else if (c < 0xe0)
{
if (s+2 > e) /* We need 2 characters */
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL2;
if (!((s[1] ^ 0x80) < 0x40))
return MY_CS_ILSEQ;
@@ -1971,7 +1971,7 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)),
else if (c < 0xf0)
{
if (s+3 > e) /* We need 3 characters */
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL3;
if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (c >= 0xe1 || s[1] >= 0xa0)))
return MY_CS_ILSEQ;
@@ -1986,7 +1986,7 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)),
else if (c < 0xf8 && sizeof(my_wc_t)*8 >= 32)
{
if (s+4 > e) /* We need 4 characters */
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL4;
if (!((s[1] ^ 0x80) < 0x40 &&
(s[2] ^ 0x80) < 0x40 &&
@@ -2004,7 +2004,7 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)),
else if (c < 0xfc && sizeof(my_wc_t)*8 >= 32)
{
if (s+5 >e) /* We need 5 characters */
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL5;
if (!((s[1] ^ 0x80) < 0x40 &&
(s[2] ^ 0x80) < 0x40 &&
@@ -2023,7 +2023,7 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)),
else if (c < 0xfe && sizeof(my_wc_t)*8 >= 32)
{
if ( s+6 >e ) /* We need 6 characters */
- return MY_CS_TOOFEW(0);
+ return MY_CS_TOOSMALL6;
if (!((s[1] ^ 0x80) < 0x40 &&
(s[2] ^ 0x80) < 0x40 &&
@@ -2074,7 +2074,7 @@ static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) ,
Because of it (r+count > e), not (r+count-1 >e )
*/
if ( r+count > e )
- return MY_CS_TOOSMALL;
+ return MY_CS_TOOSMALLN(count);
switch (count) {
/* Fall through all cases!!! */