From e3c1c83a16204f1966c68303ecb93973e6a025f2 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Thu, 4 Feb 2010 13:39:42 +0100 Subject: [PATCH 01/96] Recommit of Bug#49447. --- client/mysql.cc | 44 ++--- client/mysql_upgrade.c | 22 +-- client/mysqladmin.cc | 14 +- client/mysqlbinlog.cc | 18 +- client/mysqlcheck.c | 22 +-- client/mysqldump.c | 100 +++++++----- client/mysqlimport.c | 33 ++-- client/mysqlshow.c | 27 +-- client/mysqlslap.c | 12 +- client/mysqltest.cc | 23 +-- mysys/default.c | 8 +- server-tools/instance-manager/options.cc | 30 ++-- sql/mysqld.cc | 199 +++++++++++++---------- 13 files changed, 303 insertions(+), 249 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 82a29816b8e..9618c049f3d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1338,7 +1338,7 @@ static struct my_option my_long_options[] = {"help", 'I', "Synonym for -?", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Automatically close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"auto-rehash", OPT_AUTO_REHASH, @@ -1349,15 +1349,15 @@ static struct my_option my_long_options[] = "No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"batch", 'B', - "Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + "Don't use history file. Disable interactive behavior. (Enables --silent.)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (uchar**) &charsets_dir, + "Directory for character set files.", (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"column-type-info", OPT_COLUMN_TYPES, "Display column type information.", (uchar**) &column_types_flag, (uchar**) &column_types_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"comments", 'c', "Preserve comments. Send comments to the server." - " The default is --skip-comments (discard comments), enable with --comments", + " The default is --skip-comments (discard comments), enable with --comments.", (uchar**) &preserve_comments, (uchar**) &preserve_comments, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", @@ -1365,10 +1365,10 @@ static struct my_option my_long_options[] = 0, 0, 0}, #ifdef DBUG_OFF - {"debug", '#', "This is a non-debug version. Catch this and exit", + {"debug", '#', "This is a non-debug version. Catch this and exit.", 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, + {"debug", '#', "Output debug log.", (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", @@ -1383,12 +1383,12 @@ static struct my_option my_long_options[] = (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"delimiter", OPT_DELIMITER, "Delimiter to be used.", (uchar**) &delimiter_str, (uchar**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"execute", 'e', "Execute command and quit. (Disables --force and history file)", 0, + {"execute", 'e', "Execute command and quit. (Disables --force and history file.)", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"vertical", 'E', "Print the output of a query (rows) vertically.", (uchar**) &vertical, (uchar**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"force", 'f', "Continue even if we get an sql error.", + {"force", 'f', "Continue even if we get an SQL error.", (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"named-commands", 'G', @@ -1396,7 +1396,11 @@ static struct my_option my_long_options[] = (uchar**) &named_cmds, (uchar**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-named-commands", 'g', - "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.", + "Named commands are disabled. Use \\* form only, or use named commands " + "only in the beginning of a line ending with a semicolon (;). Since " + "version 10.9, the client now starts with this option ENABLED by default. " + "Disable with '-G'. Long format commands still work from the first line. " + "WARNING: option deprecated; use --disable-named-commands instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"ignore-spaces", 'i', "Ignore space after function names.", (uchar**) &ignore_spaces, (uchar**) &ignore_spaces, 0, GET_BOOL, NO_ARG, 0, 0, @@ -1410,7 +1414,7 @@ static struct my_option my_long_options[] = (uchar**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"html", 'H', "Produce HTML output.", (uchar**) &opt_html, (uchar**) &opt_html, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"xml", 'X', "Produce XML output", (uchar**) &opt_xml, (uchar**) &opt_xml, 0, + {"xml", 'X', "Produce XML output.", (uchar**) &opt_xml, (uchar**) &opt_xml, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.", (uchar**) &line_numbers, (uchar**) &line_numbers, 0, GET_BOOL, @@ -1428,7 +1432,7 @@ static struct my_option my_long_options[] = {"set-variable", 'O', "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C)", + {"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C).", (uchar**) &opt_sigint_ignore, (uchar**) &opt_sigint_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"one-database", 'o', @@ -1436,7 +1440,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef USE_POPEN {"pager", OPT_PAGER, - "Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default.", + "Pager to use to display results. If you don't supply an option, the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"no-pager", OPT_NOPAGER, "Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead.", @@ -1460,7 +1464,7 @@ static struct my_option my_long_options[] = {"prompt", OPT_PROMPT, "Set the mysql prompt to this value.", (uchar**) ¤t_prompt, (uchar**) ¤t_prompt, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', "Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.", @@ -1477,7 +1481,7 @@ static struct my_option my_long_options[] = "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include "sslopt-longopts.h" @@ -1486,7 +1490,7 @@ static struct my_option my_long_options[] = {"tee", OPT_TEE, "Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead", 0, 0, 0, GET_NO_ARG, + {"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: Option deprecated; use --disable-tee instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE {"user", 'u', "User for login if not current user.", (uchar**) ¤t_user, @@ -1510,26 +1514,26 @@ static struct my_option my_long_options[] = (uchar**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0, 0, 0}, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, - "Max packet length to send to, or receive from server", + "The maximum packet length to send to or receive from server.", (uchar**) &opt_max_allowed_packet, (uchar**) &opt_max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, {"net_buffer_length", OPT_NET_BUFFER_LENGTH, - "Buffer for TCP/IP and socket communication", + "The buffer size for TCP/IP and socket communication.", (uchar**) &opt_net_buffer_length, (uchar**) &opt_net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0}, {"select_limit", OPT_SELECT_LIMIT, - "Automatic limit for SELECT when using --safe-updates", + "Automatic limit for SELECT when using --safe-updates.", (uchar**) &select_limit, (uchar**) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX, 0, 1, 0}, {"max_join_size", OPT_MAX_JOIN_SIZE, - "Automatic limit for rows in a join when using --safe-updates", + "Automatic limit for rows in a join when using --safe-updates.", (uchar**) &max_join_size, (uchar**) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX, 0, 1, 0}, {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" - " uses old (pre-4.1.1) protocol", (uchar**) &opt_secure_auth, + " uses old (pre-4.1.1) protocol.", (uchar**) &opt_secure_auth, (uchar**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 81dcdaa71f1..689a2c82571 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -62,21 +62,21 @@ static struct my_option my_long_options[]= { {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibilty", + {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibility.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", 0, + "Directory for character set files.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", (uchar**)¬_used, (uchar**)¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"datadir", 'd', - "Not used by mysql_upgrade. Only for backward compatibilty", + "Not used by mysql_upgrade. Only for backward compatibility.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF - {"debug", '#', "This is a non-debug version. Catch this and exit", + {"debug", '#', "This is a non-debug version. Catch this and exit.", 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (uchar* *) & default_dbug_option, + {"debug", '#', "Output debug log.", (uchar* *) & default_dbug_option, (uchar* *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", @@ -94,7 +94,7 @@ static struct my_option my_long_options[]= {"host",'h', "Connect to host.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', - "Password to use when connecting to server. If password is not given" + "Password to use when connecting to server. If password is not given," " it's solicited on the tty.", (uchar**) &opt_password,(uchar**) &opt_password, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __WIN__ @@ -109,21 +109,21 @@ static struct my_option my_long_options[]= "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, - "The protocol of connection (tcp,socket,pipe,memory).", + "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include - {"tmpdir", 't', "Directory for temporary files", + {"tmpdir", 't', "Directory for temporary files.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"user", 'u', "User for login if not current user.", (uchar**) &opt_user, (uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Display more output about the process", + {"verbose", 'v', "Display more output about the process.", (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"write-binlog", OPT_WRITE_BINLOG, @@ -228,7 +228,7 @@ get_one_option(int optid, const struct my_option *opt, case '?': printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); - puts("MySQL utility for upgrading databases to new MySQL versions\n"); + puts("MySQL utility for upgrading databases to new MySQL versions.\n"); my_print_help(my_long_options); exit(0); break; diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 04e25fcf1ff..8a8e8ec2db5 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -117,7 +117,7 @@ static TYPELIB command_typelib= static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Automatically close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"count", 'c', @@ -128,7 +128,7 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .", + {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", @@ -142,7 +142,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (uchar**) &charsets_dir, + "Directory for character set files.", (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (uchar**) &default_charset, @@ -168,10 +168,10 @@ static struct my_option my_long_options[] = "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", (uchar**) &tcp_port, (uchar**) &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).", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"relative", 'r', - "Show difference between current and previous values when used with -i. Currently works only with extended-status.", + "Show difference between current and previous values when used with -i. Currently only works with extended-status.", (uchar**) &opt_relative, (uchar**) &opt_relative, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"set-variable", 'O', @@ -184,10 +184,10 @@ static struct my_option my_long_options[] = #endif {"silent", 's', "Silently exit if one can't connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", (uchar**) &unix_port, (uchar**) &unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"sleep", 'i', "Execute commands again and again with a sleep between.", + {"sleep", 'i', "Execute commands repeatedly with a sleep between.", (uchar**) &interval, (uchar**) &interval, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 1c0f6e5f96a..8b78fc252fe 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -989,7 +989,7 @@ static struct my_option my_long_options[] = {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Automatically close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"base64-output", OPT_BASE64_OUTPUT_MODE, @@ -1013,7 +1013,7 @@ static struct my_option my_long_options[] = SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`; */ {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (uchar**) &charsets_dir, + "Directory for character set files.", (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"database", 'd', "List entries for just this database (local log only).", (uchar**) &database, (uchar**) &database, 0, GET_STR_ALLOC, REQUIRED_ARG, @@ -1067,9 +1067,9 @@ static struct my_option my_long_options[] = /* COM_BINLOG_DUMP accepts only 4 bytes for the position */ (ulonglong)(~(uint32)0), 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, - "The protocol of connection (tcp,socket,pipe,memory).", + "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"read-from-remote-server", 'R', "Read binary logs from a MySQL server", + {"read-from-remote-server", 'R', "Read binary logs from a MySQL server.", (uchar**) &remote_opt, (uchar**) &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR, @@ -1093,7 +1093,7 @@ static struct my_option my_long_options[] = "using --base64-output=never instead.", (uchar**) &short_form, (uchar**) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", (uchar**) &sock, (uchar**) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"start-datetime", OPT_START_DATETIME, @@ -1135,12 +1135,12 @@ that may lead to an endless loop.", (uchar**) &user, (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Reconstruct SQL statements out of row events. " - "-v -v adds comments on column data types", + "-v -v adds comments on column data types.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"open_files_limit", OPT_OPEN_FILES_LIMIT, - "Used to reserve file descriptors for usage by this program", + "Used to reserve file descriptors for use by this program.", (uchar**) &open_files_limit, (uchar**) &open_files_limit, 0, GET_ULONG, REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} @@ -1239,11 +1239,11 @@ static void usage() print_version(); puts("By Monty and Sasha, for your professional use\n\ This software comes with NO WARRANTY: This is free software,\n\ -and you are welcome to modify and redistribute it under the GPL license\n"); +and you are welcome to modify and redistribute it under the GPL license.\n"); printf("\ Dumps a MySQL binary log in a format usable for viewing or for piping to\n\ -the mysql command line client\n\n"); +the mysql command line client.\n\n"); printf("Usage: %s [options] log-files\n", my_progname); my_print_help(my_long_options); my_print_variables(my_long_options); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1533e602639..d88fa6e46c2 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -53,7 +53,7 @@ enum operations { DO_CHECK, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE }; static struct my_option my_long_options[] = { {"all-databases", 'A', - "Check all the databases. This will be same as --databases with all databases selected.", + "Check all the databases. This is the same as --databases with all databases selected.", (uchar**) &opt_alldbs, (uchar**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"analyze", 'a', "Analyze given tables.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, @@ -63,7 +63,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_all_in_1, (uchar**) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Automatically close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"auto-repair", OPT_AUTO_REPAIR, @@ -71,7 +71,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_auto_repair, (uchar**) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (uchar**) &charsets_dir, + "Directory for character set files.", (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -85,7 +85,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"databases", 'B', - "To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames.", + "Check several databases. Note the difference in usage; in this case no tables are given. All name arguments are regarded as database names.", (uchar**) &opt_databases, (uchar**) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF @@ -113,7 +113,7 @@ static struct my_option my_long_options[] = {"fix-table-names", OPT_FIX_TABLE_NAMES, "Fix table names.", (uchar**) &opt_fix_table_names, (uchar**) &opt_fix_table_names, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"force", 'f', "Continue even if we get an sql-error.", + {"force", 'f', "Continue even if we get an SQL error.", (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"extended", 'e', @@ -134,7 +134,7 @@ static struct my_option my_long_options[] = {"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', - "Password to use when connecting to server. If password is not given it's solicited on the tty.", + "Password to use when connecting to server. If password is not given, it's solicited on the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __WIN__ {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, @@ -149,7 +149,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_mysql_port, (uchar**) &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).", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', "If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.", @@ -165,7 +165,7 @@ static struct my_option my_long_options[] = #endif {"silent", 's', "Print only error messages.", (uchar**) &opt_silent, (uchar**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include @@ -221,14 +221,14 @@ static void print_version(void) static void usage(void) { print_version(); - puts("By Jani Tolonen, 2001-04-20, MySQL Development Team\n"); + puts("By Jani Tolonen, 2001-04-20, MySQL Development Team.\n"); puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n"); puts("and you are welcome to modify and redistribute it under the GPL license.\n"); - puts("This program can be used to CHECK (-c,-m,-C), REPAIR (-r), ANALYZE (-a)"); + puts("This program can be used to CHECK (-c, -m, -C), REPAIR (-r), ANALYZE (-a),"); puts("or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be"); puts("used at the same time. Not all options are supported by all storage engines."); puts("Please consult the MySQL manual for latest information about the"); - puts("above. The options -c,-r,-a and -o are exclusive to each other, which"); + puts("above. The options -c, -r, -a, and -o are exclusive to each other, which"); puts("means that the last option will be used, if several was specified.\n"); puts("The option -c will be used by default, if none was specified. You"); puts("can change the default behavior by making a symbolic link, or"); diff --git a/client/mysqldump.c b/client/mysqldump.c index 40e3e75cca2..dca8ecb7dfb 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -194,24 +194,24 @@ static struct my_option my_long_options[] = "Do not dump any tablespace information.", (uchar**) &opt_notspcs, (uchar**) &opt_notspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"add-drop-database", OPT_DROP_DATABASE, "Add a 'DROP DATABASE' before each create.", + {"add-drop-database", OPT_DROP_DATABASE, "Add a DROP DATABASE before each create.", (uchar**) &opt_drop_database, (uchar**) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"add-drop-table", OPT_DROP, "Add a 'drop table' before each create.", + {"add-drop-table", OPT_DROP, "Add a DROP TABLE before each create.", (uchar**) &opt_drop, (uchar**) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, - {"add-locks", OPT_LOCKS, "Add locks around insert statements.", + {"add-locks", OPT_LOCKS, "Add locks around INSERT statements.", (uchar**) &opt_lock, (uchar**) &opt_lock, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"allow-keywords", OPT_KEYWORDS, "Allow creation of column names that are keywords.", (uchar**) &opt_keywords, (uchar**) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ - {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Automatically close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (uchar**) &charsets_dir, + "Directory for character set files.", (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"comments", 'i', "Write additional information.", (uchar**) &opt_comments, (uchar**) &opt_comments, 0, GET_BOOL, NO_ARG, @@ -221,7 +221,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_compatible_mode_str, (uchar**) &opt_compatible_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compact", OPT_COMPACT, - "Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset", + "Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset.", (uchar**) &opt_compact, (uchar**) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"complete-insert", 'c', "Use complete insert statements.", @@ -235,14 +235,14 @@ static struct my_option my_long_options[] = (uchar**) &create_options, (uchar**) &create_options, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"databases", 'B', - "To dump several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames. 'USE db_name;' will be included in the output.", + "Dump several databases. Note the difference in usage; in this case no tables are given. All name arguments are regarded as database names. 'USE db_name;' will be included in the output.", (uchar**) &opt_databases, (uchar**) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF - {"debug", '#', "This is a non-debug version. Catch this and exit", + {"debug", '#', "This is a non-debug version. Catch this and exit.", 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, + {"debug", '#', "Output debug log.", (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.", @@ -254,7 +254,7 @@ static struct my_option my_long_options[] = {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (uchar**) &default_charset, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; ", + {"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED.", (uchar**) &opt_delayed, (uchar**) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"delete-master-logs", OPT_DELETE_MASTER_LOGS, @@ -272,16 +272,21 @@ static struct my_option my_long_options[] = (uchar**) &extended_insert, (uchar**) &extended_insert, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"fields-terminated-by", OPT_FTB, - "Fields in the textfile are terminated by ...", (uchar**) &fields_terminated, - (uchar**) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Fields in the output file are terminated by the given string.", + (uchar**) &fields_terminated, (uchar**) &fields_terminated, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"fields-enclosed-by", OPT_ENC, - "Fields in the importfile are enclosed by ...", (uchar**) &enclosed, - (uchar**) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, + "Fields in the output file are enclosed by the given character.", + (uchar**) &enclosed, (uchar**) &enclosed, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, {"fields-optionally-enclosed-by", OPT_O_ENC, - "Fields in the i.file are opt. enclosed by ...", (uchar**) &opt_enclosed, - (uchar**) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, - {"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...", - (uchar**) &escaped, (uchar**) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Fields in the output file are optionally enclosed by the given character.", + (uchar**) &opt_enclosed, (uchar**) &opt_enclosed, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, + {"fields-escaped-by", OPT_ESC, + "Fields in the output file are escaped by the given character.", + (uchar**) &escaped, (uchar**) &escaped, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"first-slave", OPT_FIRST_SLAVE, "Deprecated, renamed to --lock-all-tables.", (uchar**) &opt_lock_all_tables, (uchar**) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -293,7 +298,7 @@ static struct my_option my_long_options[] = "in this case the logs will be flushed only once, corresponding " "to the moment all tables are locked. So if you want your dump and " "the log flush to happen at the same exact moment you should use " - "--lock-all-tables or --master-data with --flush-logs", + "--lock-all-tables or --master-data with --flush-logs.", (uchar**) &flush_logs, (uchar**) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"flush-privileges", OPT_ESC, "Emit a FLUSH PRIVILEGES statement " @@ -302,7 +307,7 @@ static struct my_option my_long_options[] = "that depends on the data in the mysql database for proper restore. ", (uchar**) &flush_privileges, (uchar**) &flush_privileges, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"force", 'f', "Continue even if we get an sql-error.", + {"force", 'f', "Continue even if we get an SQL error.", (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, @@ -315,12 +320,14 @@ static struct my_option my_long_options[] = {"ignore-table", OPT_IGNORE_TABLE, "Do not dump the specified table. To specify more than one table to ignore, " "use the directive multiple times, once for each table. Each table must " - "be specified with both database and table names, e.g. --ignore-table=database.table", + "be specified with both database and table names, e.g., " + "--ignore-table=database.table.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.", (uchar**) &opt_ignore, (uchar**) &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", + {"lines-terminated-by", OPT_LTB, + "Lines in the output file are terminated by the given string.", (uchar**) &lines_terminated, (uchar**) &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"lock-all-tables", 'x', "Locks all tables across all databases. This " @@ -339,17 +346,19 @@ static struct my_option my_long_options[] = " to 2, that command will be prefixed with a comment symbol. " "This option will turn --lock-all-tables on, unless " "--single-transaction is specified too (in which case a " - "global read lock is only taken a short time at the beginning of the dump " - "- don't forget to read about --single-transaction below). In all cases " - "any action on logs will happen at the exact moment of the dump." + "global read lock is only taken a short time at the beginning of the dump; " + "don't forget to read about --single-transaction below). In all cases, " + "any action on logs will happen at the exact moment of the dump. " "Option automatically turns --lock-tables off.", (uchar**) &opt_master_data, (uchar**) &opt_master_data, 0, GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0}, - {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "", + {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, + "The maximum packet length to send to or receive from server.", (uchar**) &opt_max_allowed_packet, (uchar**) &opt_max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, (longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, - {"net_buffer_length", OPT_NET_BUFFER_LENGTH, "", + {"net_buffer_length", OPT_NET_BUFFER_LENGTH, + "The buffer size for TCP/IP and socket communication.", (uchar**) &opt_net_buffer_length, (uchar**) &opt_net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L-1025, 4096, 16*1024L*1024L, MALLOC_OVERHEAD-1024, 1024, 0}, @@ -358,9 +367,11 @@ static struct my_option my_long_options[] = (uchar**) &opt_autocommit, (uchar**) &opt_autocommit, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-create-db", 'n', - "'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the output. The above line will be added otherwise, if --databases or --all-databases option was given.}.", - (uchar**) &opt_create_db, (uchar**) &opt_create_db, 0, GET_BOOL, NO_ARG, 0, 0, - 0, 0, 0, 0}, + "Suppress the CREATE DATABASE ... IF EXISTS statement that normally is " + "output for each dumped database if --all-databases or --databases is " + "given.", + (uchar**) &opt_create_db, (uchar**) &opt_create_db, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-create-info", 't', "Don't write table creation info.", (uchar**) &opt_no_create_info, (uchar**) &opt_no_create_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -384,8 +395,9 @@ static struct my_option my_long_options[] = {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port, (uchar**) &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}, + {"protocol", OPT_MYSQL_PROTOCOL, + "The protocol to use for connection (tcp, socket, pipe, memory).", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', "Don't buffer query, dump directly to stdout.", (uchar**) &quick, (uchar**) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"quote-names",'Q', "Quote table and column names with backticks (`).", @@ -435,18 +447,20 @@ static struct my_option my_long_options[] = {"skip-opt", OPT_SKIP_OPTIMIZATION, "Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection.", - (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, - REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"socket", 'S', "The socket file to use for connection.", + (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include {"tab",'T', - "Creates tab separated textfile for each table to given path. (creates .sql and .txt files). NOTE: This only works if mysqldump is run on the same machine as the mysqld daemon.", + "Create tab-separated textfile for each table to given path. (Create .sql " + "and .txt files.) NOTE: This only works if mysqldump is run on the same " + "machine as the mysqld server.", (uchar**) &path, (uchar**) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"triggers", OPT_TRIGGERS, "Dump triggers for each dumped table", - (uchar**) &opt_dump_triggers, (uchar**) &opt_dump_triggers, 0, GET_BOOL, - NO_ARG, 1, 0, 0, 0, 0, 0}, + {"triggers", OPT_TRIGGERS, "Dump triggers for each dumped table.", + (uchar**) &opt_dump_triggers, (uchar**) &opt_dump_triggers, 0, GET_BOOL, + NO_ARG, 1, 0, 0, 0, 0, 0}, {"tz-utc", OPT_TZ_UTC, "SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones.", (uchar**) &opt_tz_utc, (uchar**) &opt_tz_utc, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, @@ -459,7 +473,7 @@ static struct my_option my_long_options[] = (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version",'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"where", 'w', "Dump only selected records; QUOTES mandatory!", + {"where", 'w', "Dump only selected records. Quotes are mandatory.", (uchar**) &where, (uchar**) &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -553,9 +567,9 @@ static void short_usage_sub(void) static void usage(void) { print_version(); - puts("By Igor Romanenko, Monty, Jani & Sinisa"); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"); - puts("Dumping definition and data mysql database or table"); + puts("By Igor Romanenko, Monty, Jani & Sinisa."); + puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n"); + puts("Dumping structure and contents of MySQL databases and tables."); short_usage_sub(); print_defaults("my",load_default_groups); my_print_help(my_long_options); diff --git a/client/mysqlimport.c b/client/mysqlimport.c index ef38d760e5d..d346cd567e7 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -69,11 +69,11 @@ static char *shared_memory_base_name=0; static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Automatically close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (uchar**) &charsets_dir, + "Directory for character set files.", (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (uchar**) &default_charset, @@ -96,18 +96,22 @@ static struct my_option my_long_options[] = {"delete", 'd', "First delete all rows from table.", (uchar**) &opt_delete, (uchar**) &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"fields-terminated-by", OPT_FTB, - "Fields in the textfile are terminated by ...", (uchar**) &fields_terminated, - (uchar**) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Fields in the input file are terminated by the given string.", + (uchar**) &fields_terminated, (uchar**) &fields_terminated, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"fields-enclosed-by", OPT_ENC, - "Fields in the importfile are enclosed by ...", (uchar**) &enclosed, - (uchar**) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Fields in the import file are enclosed by the given character.", + (uchar**) &enclosed, (uchar**) &enclosed, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"fields-optionally-enclosed-by", OPT_O_ENC, - "Fields in the i.file are opt. enclosed by ...", (uchar**) &opt_enclosed, - (uchar**) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...", + "Fields in the input file are optionally enclosed by the given character.", + (uchar**) &opt_enclosed, (uchar**) &opt_enclosed, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"fields-escaped-by", OPT_ESC, + "Fields in the input file are escaped by the given character.", (uchar**) &escaped, (uchar**) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"force", 'f', "Continue even if we get an sql-error.", + {"force", 'f', "Continue even if we get an SQL error.", (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, @@ -119,7 +123,8 @@ static struct my_option my_long_options[] = {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.", (uchar**) &opt_ignore_lines, (uchar**) &opt_ignore_lines, 0, GET_LL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", + {"lines-terminated-by", OPT_LTB, + "Lines in the input file are terminated by the given string.", (uchar**) &lines_terminated, (uchar**) &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"local", 'L', "Read all files through the client.", (uchar**) &opt_local_file, @@ -146,7 +151,7 @@ static struct my_option my_long_options[] = (uchar**) &opt_mysql_port, (uchar**) &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).", + {"protocol", OPT_MYSQL_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"replace", 'r', "If duplicate unique key was found, replace old row.", (uchar**) &replace, (uchar**) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -157,7 +162,7 @@ static struct my_option my_long_options[] = #endif {"silent", 's', "Be more silent.", (uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include @@ -194,7 +199,7 @@ static void usage(void) { print_version(); puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc."); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"); + puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n"); printf("\ Loads tables from text files in various formats. The base name of the\n\ text file must be the name of the table that should be used.\n\ diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 15f791ca8fb..370efe83f10 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -160,17 +160,17 @@ int main(int argc, char **argv) static struct my_option my_long_options[] = { #ifdef __NETWARE__ - {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", + {"autoclose", OPT_AUTO_CLOSE, "Automatically close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"character-sets-dir", 'c', "Directory where character sets are.", + {"character-sets-dir", 'c', "Directory for character set files.", (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", (uchar**) &default_charset, (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"count", OPT_COUNT, - "Show number of rows per table (may be slow for not MyISAM tables)", + "Show number of rows per table (may be slow for non-MyISAM tables).", (uchar**) &opt_count, (uchar**) &opt_count, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", @@ -194,7 +194,8 @@ static struct my_option my_long_options[] = {"keys", 'k', "Show keys for table.", (uchar**) &opt_show_keys, (uchar**) &opt_show_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', - "Password to use when connecting to server. If password is not given it's asked from the tty.", + "Password to use when connecting to server. If password is not given, it's " + "solicited on the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection or 0 for default to, in " "order of preference, my.cnf, $MYSQL_TCP_PORT, " @@ -209,7 +210,8 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", + {"protocol", OPT_MYSQL_PROTOCOL, + "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, @@ -219,7 +221,7 @@ static struct my_option my_long_options[] = {"show-table-type", 't', "Show table type column.", (uchar**) &opt_table_type, (uchar**) &opt_table_type, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include @@ -228,7 +230,8 @@ static struct my_option my_long_options[] = (uchar**) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"verbose", 'v', - "More verbose output; You can use this multiple times to get even more verbose output.", + "More verbose output; you can use this multiple times to get even more " + "verbose output.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -250,16 +253,16 @@ static void usage(void) { print_version(); puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc."); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"); - puts("Shows the structure of a mysql database (databases,tables and columns)\n"); + puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n"); + puts("Shows the structure of a MySQL database (databases, tables, and columns).\n"); printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname); puts("\n\ If last argument contains a shell or SQL wildcard (*,?,% or _) then only\n\ what\'s matched by the wildcard is shown.\n\ If no database is given then all matching databases are shown.\n\ -If no table is given then all matching tables in database are shown\n\ -If no column is given then all matching columns and columntypes in table\n\ -are shown"); +If no table is given, then all matching tables in database are shown.\n\ +If no column is given, then all matching columns and column types in table\n\ +are shown."); print_defaults("my",load_default_groups); my_print_help(my_long_options); my_print_variables(my_long_options); diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 5983b911866..a9681528943 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -612,8 +612,8 @@ static struct my_option my_long_options[] = (uchar**) &num_of_query, (uchar**) &num_of_query, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"only-print", OPT_MYSQL_ONLY_PRINT, - "This causes mysqlslap to not connect to the databases, but instead print " - "out what it would have done instead.", + "Do not connect to the databases, but instead print out what would have " + "been done.", (uchar**) &opt_only_print, (uchar**) &opt_only_print, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', @@ -647,7 +647,7 @@ static struct my_option my_long_options[] = (uchar**) &pre_system, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, - "The protocol of connection (tcp,socket,pipe,memory).", + "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"query", 'q', "Query to run or file containing query to run.", (uchar**) &user_supplied_query, (uchar**) &user_supplied_query, @@ -661,7 +661,7 @@ static struct my_option my_long_options[] = {"silent", 's', "Run program in silent mode - no output.", (uchar**) &opt_silent, (uchar**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include @@ -692,8 +692,8 @@ static void usage(void) { print_version(); puts("Copyright (C) 2005 MySQL AB"); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"); - puts("Run a query multiple times against the server\n"); + puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n"); + puts("Run a query multiple times against the server.\n"); printf("Usage: %s [OPTIONS]\n",my_progname); print_defaults("my",load_default_groups); my_print_help(my_long_options); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index e0cdec42a60..b345e755483 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5709,7 +5709,7 @@ static struct my_option my_long_options[] = {"basedir", 'b', "Basedir for tests.", (uchar**) &opt_basedir, (uchar**) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (uchar**) &opt_charsets_dir, + "Directory for character set files.", (uchar**) &opt_charsets_dir, (uchar**) &opt_charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use the compressed server/client protocol.", (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, @@ -5739,11 +5739,11 @@ static struct my_option my_long_options[] = {"logdir", OPT_LOG_DIR, "Directory for log files", (uchar**) &opt_logdir, (uchar**) &opt_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"mark-progress", OPT_MARK_PROGRESS, - "Write linenumber and elapsed time to .progress ", + "Write line number and elapsed time to .progress.", (uchar**) &opt_mark_progress, (uchar**) &opt_mark_progress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"max-connect-retries", OPT_MAX_CONNECT_RETRIES, - "Max number of connection attempts when connecting to server", + "Maximum number of attempts to connect to server.", (uchar**) &opt_max_connect_retries, (uchar**) &opt_max_connect_retries, 0, GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", @@ -5756,14 +5756,15 @@ static struct my_option my_long_options[] = "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", (uchar**) &opt_port, (uchar**) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"ps-protocol", OPT_PS_PROTOCOL, "Use prepared statements protocol for communication", + {"ps-protocol", OPT_PS_PROTOCOL, + "Use prepared-statement protocol for communication.", (uchar**) &ps_protocol, (uchar**) &ps_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"quiet", 's', "Suppress all normal output.", (uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"record", 'r', "Record output of test_file into result file.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"result-file", 'R', "Read/Store result from/in this file.", + {"result-file", 'R', "Read/store result from/in this file.", (uchar**) &result_file_name, (uchar**) &result_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-arg", 'A', "Send option value to embedded server as a parameter.", @@ -5781,23 +5782,23 @@ static struct my_option my_long_options[] = {"skip-safemalloc", OPT_SKIP_SAFEMALLOC, "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"sleep", 'T', "Sleep always this many seconds on sleep commands.", + {"sleep", 'T', "Always sleep this many seconds on sleep commands.", (uchar**) &opt_sleep, (uchar**) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection.", + {"socket", 'S', "The socket file to use for connection.", (uchar**) &unix_sock, (uchar**) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select", + {"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select.", (uchar**) &sp_protocol, (uchar**) &sp_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #include "sslopt-longopts.h" {"tail-lines", OPT_TAIL_LINES, - "Number of lines of the resul to include in a failure report", + "Number of lines of the result to include in a failure report.", (uchar**) &opt_tail_lines, (uchar**) &opt_tail_lines, 0, GET_INT, REQUIRED_ARG, 0, 0, 10000, 0, 0, 0}, {"test-file", 'x', "Read test from/in this file (default stdin).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"timer-file", 'm', "File where the timing in micro seconds is stored.", + {"timer-file", 'm', "File where the timing in microseconds is stored.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', "Temporary directory where sockets are put.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -5807,7 +5808,7 @@ static struct my_option my_long_options[] = GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"view-protocol", OPT_VIEW_PROTOCOL, "Use views for select", + {"view-protocol", OPT_VIEW_PROTOCOL, "Use views for select.", (uchar**) &view_protocol, (uchar**) &view_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} diff --git a/mysys/default.c b/mysys/default.c index 4e9d4faae91..63f9445dbdc 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -995,10 +995,10 @@ void print_defaults(const char *conf_file, const char **groups) } } puts("\nThe following options may be given as the first argument:\n\ ---print-defaults Print the program argument list and exit\n\ ---no-defaults Don't read default options from any options file\n\ ---defaults-file=# Only read default options from the given file #\n\ ---defaults-extra-file=# Read this file after the global files are read"); +--print-defaults Print the program argument list and exit.\n\ +--no-defaults Don't read default options from any option file.\n\ +--defaults-file=# Only read default options from the given file #.\n\ +--defaults-extra-file=# Read this file after the global files are read."); } #include diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index 6e401bf3ffe..75a18c5b43a 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -148,7 +148,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "add-user", OPT_ADD_USER, - "Add a user to the password file", + "Add a user to the password file.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, #ifndef __WIN__ @@ -164,11 +164,11 @@ static struct my_option my_long_options[] = 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "check-password-file", OPT_CHECK_PASSWORD_FILE, - "Check the password file for consistency", + "Check the password file for consistency.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "clean-password-file", OPT_CLEAN_PASSWORD_FILE, - "Clean the password file", + "Clean the password file.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, #ifndef DBUG_OFF @@ -185,11 +185,11 @@ static struct my_option my_long_options[] = 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, { "drop-user", OPT_DROP_USER, - "Drop existing user from the password file", + "Drop existing user from the password file.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "edit-user", OPT_EDIT_USER, - "Edit existing user in the password file", + "Edit existing user in the password file.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, #ifdef __WIN__ @@ -200,7 +200,7 @@ static struct my_option my_long_options[] = #endif { "list-users", OPT_LIST_USERS, - "Print out a list of registered users", + "Print out a list of registered users.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, #ifndef __WIN__ @@ -218,7 +218,7 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0 }, { "mysqld-safe-compatible", OPT_MYSQLD_SAFE_COMPATIBLE, - "Start Instance Manager in mysqld_safe compatible manner", + "Start Instance Manager in mysqld_safe-compatible manner.", (uchar* *) &Options::Main::mysqld_safe_compatible, (uchar* *) &Options::Main::mysqld_safe_compatible, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 }, @@ -227,7 +227,7 @@ static struct my_option my_long_options[] = "Print out a user entry as a line for the password file and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, - { "password", OPT_PASSWORD, "Password to update the password file", + { "password", OPT_PASSWORD, "Password to update the password file.", (uchar* *) &Options::User_management::password, (uchar* *) &Options::User_management::password, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, @@ -243,7 +243,7 @@ static struct my_option my_long_options[] = (uchar* *) &Options::Main::pid_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - { "port", OPT_PORT, "Port number to use for connections", + { "port", OPT_PORT, "Port number to use for connections.", (uchar* *) &Options::Main::port_number, (uchar* *) &Options::Main::port_number, 0, GET_UINT, REQUIRED_ARG, DEFAULT_PORT, 0, 0, 0, 0, 0 }, @@ -273,14 +273,14 @@ static struct my_option my_long_options[] = (uchar* *) &Options::Service::stand_alone, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0}, #else - { "user", OPT_USER, "Username to start mysqlmanager", + { "user", OPT_USER, "Username to start mysqlmanager.", (uchar* *) &Options::Daemon::user, (uchar* *) &Options::Daemon::user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, #endif { "username", OPT_USERNAME, - "Username to update the password file", + "Username to update the password file.", (uchar* *) &Options::User_management::user_name, (uchar* *) &Options::User_management::user_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, @@ -312,16 +312,16 @@ static void usage() { version(); - printf("Copyright (C) 2003, 2004 MySQL AB\n" + printf("Copyright (C) 2003, 2004 MySQL AB.\n" "This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n" - "and you are welcome to modify and redistribute it under the GPL license\n"); + "and you are welcome to modify and redistribute it under the GPL license.\n"); printf("Usage: %s [OPTIONS] \n", my_progname); my_print_help(my_long_options); printf("\nThe following options may be given as the first argument:\n" - "--print-defaults Print the program argument list and exit\n" + "--print-defaults Print the program argument list and exit.\n" "--defaults-file=# Only read manager configuration and instance\n" - " setings from the given file #. The same file\n" + " settings from the given file #. The same file\n" " will be used to modify configuration of instances\n" " with SET commands.\n"); my_print_variables(my_long_options); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ca20299b36e..7c45fda1e02 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5761,12 +5761,12 @@ struct my_option my_long_options[] = {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode will also set transaction isolation level 'serializable'.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"auto-increment-increment", OPT_AUTO_INCREMENT, - "Auto-increment columns are incremented by this", + "Auto-increment columns are incremented by this.", (uchar**) &global_system_variables.auto_increment_increment, (uchar**) &max_system_variables.auto_increment_increment, 0, GET_ULONG, OPT_ARG, 1, 1, 65535, 0, 1, 0 }, {"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET, - "Offset added to Auto-increment columns. Used when auto-increment-increment != 1", + "Offset added to Auto-increment columns. Used when auto-increment-increment != 1.", (uchar**) &global_system_variables.auto_increment_offset, (uchar**) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG, 1, 1, 65535, 0, 1, 0 }, @@ -5779,7 +5779,7 @@ struct my_option my_long_options[] = (uchar**) &mysql_home_ptr, (uchar**) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"big-tables", OPT_BIG_TABLES, - "Allow big result sets by saving all temporary sets on file (Solves most 'table full' errors).", + "Allow big result sets by saving all temporary sets on file (solves most 'table full' errors).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.", (uchar**) &my_bind_addr_str, (uchar**) &my_bind_addr_str, 0, GET_STR, @@ -5787,11 +5787,10 @@ struct my_option my_long_options[] = {"binlog_format", OPT_BINLOG_FORMAT, "Does not have any effect without '--log-bin'. " "Tell the master the form of binary logging to use: either 'row' for " - "row-based binary logging, or 'statement' for statement-based binary " + "row-based binary logging, 'statement' for statement-based binary " "logging, or 'mixed'. 'mixed' is statement-based binary logging except " - "for those statements where only row-based is correct: those which " - "involve user-defined functions (i.e. UDFs) or the UUID() function; for " - "those, row-based binary logging is automatically used. " + "for statements where only row-based is correct: Statements that involve " + "user-defined functions (i.e., UDFs) or the UUID() function." #ifdef HAVE_NDB_BINLOG "If ndbcluster is enabled and binlog_format is `mixed', the format switches" " to 'row' and back implicitly per each query accessing a NDB table." @@ -5802,7 +5801,7 @@ struct my_option my_long_options[] = "Tells the master it should log updates for the specified database, and exclude all others not explicitly mentioned.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"binlog-ignore-db", OPT_BINLOG_IGNORE_DB, - "Tells the master that updates to the given database should not be logged tothe binary log.", + "Tells the master that updates to the given database should not be logged to the binary log.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"binlog-row-event-max-size", OPT_BINLOG_ROWS_EVENT_MAX_SIZE, "The maximum size of a row-based binary log event in bytes. Rows will be " @@ -5846,10 +5845,10 @@ struct my_option my_long_options[] = (uchar**) &max_system_variables.completion_type, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 2, 0, 1, 0}, {"concurrent-insert", OPT_CONCURRENT_INSERT, - "Use concurrent insert with MyISAM. Disable with --concurrent-insert=0", + "Use concurrent insert with MyISAM. Disable with --concurrent-insert=0.", (uchar**) &myisam_concurrent_insert, (uchar**) &myisam_concurrent_insert, 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0}, - {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.", + {"console", OPT_CONSOLE, "Write error output on screen; don't remove the console window on windows.", (uchar**) &opt_console, (uchar**) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, 0, GET_NO_ARG, @@ -5881,7 +5880,7 @@ struct my_option my_long_options[] = {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE.", 0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"delay-key-write-for-all-tables", OPT_DELAY_KEY_WRITE_ALL, - "Don't flush key buffers between writes for any MyISAM table (Deprecated option, use --delay-key-write=all instead).", + "Don't flush key buffers between writes for any MyISAM table. (Deprecated option, use --delay-key-write=all instead.)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_OPENSSL {"des-key-file", OPT_DES_KEY_FILE, @@ -5919,7 +5918,7 @@ struct my_option my_long_options[] = /* See how it's handled in get_one_option() */ {"event-scheduler", OPT_EVENT_SCHEDULER, "Enable/disable the event scheduler.", NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"exit-info", 'T', "Used for debugging; Use at your own risk!", 0, 0, 0, + {"exit-info", 'T', "Used for debugging. Use at your own risk.", 0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"external-locking", OPT_USE_LOCKING, "Use system (external) locking (disabled by default). With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running. Disable with --skip-external-locking.", (uchar**) &opt_external_locking, (uchar**) &opt_external_locking, @@ -5929,11 +5928,11 @@ struct my_option my_long_options[] = /* We must always support the next option to make scripts like mysqltest easier to do */ {"gdb", OPT_DEBUGGING, - "Set up signals usable for debugging", + "Set up signals usable for debugging.", (uchar**) &opt_debugging, (uchar**) &opt_debugging, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"general_log", OPT_GENERAL_LOG, - "Enable|disable general log", (uchar**) &opt_log, + "Enable/disable general log.", (uchar**) &opt_log, (uchar**) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_LARGE_PAGES {"large-pages", OPT_ENABLE_LARGE_PAGES, "Enable support for large pages. \ @@ -5942,9 +5941,10 @@ Disable with --skip-large-pages.", 0, 0, 0}, #endif {"ignore-builtin-innodb", OPT_IGNORE_BUILTIN_INNODB , - "Disable initialization of builtin InnoDB plugin", + "Disable initialization of builtin InnoDB plugin.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new connection", + {"init-connect", OPT_INIT_CONNECT, + "Command(s) that are executed for each new connection.", (uchar**) &opt_init_connect, (uchar**) &opt_init_connect, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DISABLE_GRANT_OPTIONS @@ -5968,7 +5968,7 @@ each time the SQL thread starts.", (uchar**) &lc_time_names_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"local-infile", OPT_LOCAL_INFILE, - "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0).", + "Enable/disable LOAD DATA LOCAL INFILE (takes values 1 or 0).", (uchar**) &opt_local_infile, (uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, @@ -6006,8 +6006,9 @@ each time the SQL thread starts.", */ {"log-bin-trust-function-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS, "If equal to 0 (the default), then when --log-bin is used, creation of " - "a stored function (or trigger) is allowed only to users having the SUPER privilege " - "and only if this stored function (trigger) may not break binary logging." + "a stored function (or trigger) is allowed only to users having the SUPER " + "privilege, and only if this stored function (trigger) may not break " + "binary logging." "Note that if ALL connections to this server ALWAYS use row-based binary " "logging, the security issues do not exist and the binary logging cannot " "break, so you can safely set this to 1." @@ -6064,7 +6065,7 @@ each time the SQL thread starts.", REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"log-tc", OPT_LOG_TC, "Path to transaction coordinator log (used for transactions that affect " - "more than one storage engine, when binary log is disabled)", + "more than one storage engine, when binary log is disabled).", (uchar**) &opt_tc_log_file, (uchar**) &opt_tc_log_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_MMAP @@ -6088,7 +6089,9 @@ log and this option justs turns on --log-bin instead.", (uchar**) &max_system_variables.low_priority_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"master-connect-retry", OPT_MASTER_CONNECT_RETRY, - "The number of seconds the slave thread will sleep before retrying to connect to the master in case the master goes down or the connection is lost.", + "The number of seconds the slave thread will sleep before retrying to " + "connect to the master, in case the master goes down or the connection " + "is lost.", (uchar**) &master_connect_retry, (uchar**) &master_connect_retry, 0, GET_UINT, REQUIRED_ARG, 60, 0, 0, 0, 0, 0}, {"master-host", OPT_MASTER_HOST, @@ -6101,7 +6104,9 @@ thread is in the master's binlogs.", (uchar**) &master_info_file, (uchar**) &master_info_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-password", OPT_MASTER_PASSWORD, - "The password the slave thread will authenticate with when connecting to the master. If not set, an empty password is assumed.The value in master.info will take precedence if it can be read.", + "The password the slave thread will authenticate with when connecting to " + "the master. If not set, an empty password is assumed. The value in " + "master.info will take precedence if it can be read.", (uchar**)&master_password, (uchar**)&master_password, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-port", OPT_MASTER_PORT, @@ -6125,8 +6130,8 @@ thread is in the master's binlogs.", (uchar**) &master_ssl_capath, (uchar**) &master_ssl_capath, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-cert", OPT_MASTER_SSL_CERT, - "Master SSL certificate file name. Only applies if you have enabled \ -master-ssl", + "Master SSL certificate file name. Only applies if you have enabled " + "master-ssl.", (uchar**) &master_ssl_cert, (uchar**) &master_ssl_cert, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-cipher", OPT_MASTER_SSL_CIPHER, @@ -6193,14 +6198,14 @@ master-ssl", #ifdef HAVE_NDB_BINLOG {"ndb-report-thresh-binlog-epoch-slip", OPT_NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP, "Threshold on number of epochs to be behind before reporting binlog status. " - "E.g. 3 means that if the difference between what epoch has been received " + "E.g., 3 means that if the difference between what epoch has been received " "from the storage nodes and what has been applied to the binlog is 3 or more, " "a status message will be sent to the cluster log.", (uchar**) &ndb_report_thresh_binlog_epoch_slip, (uchar**) &ndb_report_thresh_binlog_epoch_slip, 0, GET_ULONG, REQUIRED_ARG, 3, 0, 256, 0, 0, 0}, {"ndb-report-thresh-binlog-mem-usage", OPT_NDB_REPORT_THRESH_BINLOG_MEM_USAGE, - "Threshold on percentage of free memory before reporting binlog status. E.g. " + "Threshold on percentage of free memory before reporting binlog status. E.g., " "10 means that if amount of available memory for receiving binlog data from " "the storage nodes goes below 10%, " "a status message will be sent to the cluster log.", @@ -6215,7 +6220,7 @@ master-ssl", (uchar**) &global_system_variables.ndb_use_exact_count, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"ndb_use_exact_count", OPT_NDB_USE_EXACT_COUNT, - "same as --ndb-use-exact-count.", + "Same as --ndb-use-exact-count.", (uchar**) &global_system_variables.ndb_use_exact_count, (uchar**) &global_system_variables.ndb_use_exact_count, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, @@ -6226,7 +6231,7 @@ master-ssl", (uchar**) &global_system_variables.ndb_use_transactions, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"ndb_use_transactions", OPT_NDB_USE_TRANSACTIONS, - "same as --ndb-use-transactions.", + "Same as --ndb-use-transactions.", (uchar**) &global_system_variables.ndb_use_transactions, (uchar**) &global_system_variables.ndb_use_transactions, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, @@ -6241,7 +6246,9 @@ master-ssl", (uchar**) &opt_ndb_optimized_node_selection, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, { "ndb-cache-check-time", OPT_NDB_CACHE_CHECK_TIME, - "A dedicated thread is created to, at the given millisecons interval, invalidate the query cache if another MySQL server in the cluster has changed the data in the database.", + "A dedicated thread is created to, at the given milliseconds interval, " + "invalidate the query cache if another MySQL server in the cluster has " + "changed the data in the database.", (uchar**) &opt_ndb_cache_check_time, (uchar**) &opt_ndb_cache_check_time, 0, GET_ULONG, REQUIRED_ARG, 0, 0, LONG_TIMEOUT, 0, 1, 0}, {"ndb-index-stat-enable", OPT_NDB_INDEX_STAT_ENABLE, @@ -6256,12 +6263,13 @@ master-ssl", (uchar**) &global_system_variables.ndb_use_copying_alter_table, (uchar**) &global_system_variables.ndb_use_copying_alter_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"new", 'n', "Use very new possible 'unsafe' functions.", + {"new", 'n', "Use very new, possibly 'unsafe', functions.", (uchar**) &global_system_variables.new_mode, (uchar**) &max_system_variables.new_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef NOT_YET - {"no-mix-table-types", OPT_NO_MIX_TYPE, "Don't allow commands with uses two different table types.", + {"no-mix-table-types", OPT_NO_MIX_TYPE, + "Don't allow commands that use two different table types.", (uchar**) &opt_no_mix_types, (uchar**) &opt_no_mix_types, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -6275,10 +6283,12 @@ master-ssl", (uchar**) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"one-thread", OPT_ONE_THREAD, - "(deprecated): Only use one thread (for debugging under Linux). Use thread-handling=no-threads instead", + "(Deprecated): Only use one thread (for debugging under Linux). Use " + "thread-handling=no-threads instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS, - "Enable old-style user limits (before 5.0.3 user resources were counted per each user+host vs. per account)", + "Enable old-style user limits (before 5.0.3, user resources were counted " + "per each user+host vs. per account).", (uchar**) &opt_old_style_user_limits, (uchar**) &opt_old_style_user_limits, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.", @@ -6294,10 +6304,10 @@ master-ssl", (uchar**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT, "Maximum time in seconds to wait for the port to become free. " - "(Default: no wait)", (uchar**) &mysqld_port_timeout, + "(Default: No wait).", (uchar**) &mysqld_port_timeout, (uchar**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER) - {"profiling_history_size", OPT_PROFILING, "Limit of query profiling memory", + {"profiling_history_size", OPT_PROFILING, "Limit of query profiling memory.", (uchar**) &global_system_variables.profiling_history_size, (uchar**) &max_system_variables.profiling_history_size, 0, GET_ULONG, REQUIRED_ARG, 15, 0, 100, 0, 0, 0}, @@ -6367,7 +6377,7 @@ Can't be set to 1 if --log-slave-updates is used.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef TO_BE_DELETED {"safe-show-database", OPT_SAFE_SHOW_DB, - "Deprecated option; use GRANT SHOW DATABASES instead...", + "Deprecated option; use GRANT SHOW DATABASES instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"safe-user-create", OPT_SAFE_USER_CREATE, @@ -6381,7 +6391,7 @@ Can't be set to 1 if --log-slave-updates is used.", (uchar**) &opt_secure_auth, (uchar**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, my_bool(0), 0, 0, 0, 0, 0}, {"secure-file-priv", OPT_SECURE_FILE_PRIV, - "Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files within specified directory", + "Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files within specified directory.", (uchar**) &opt_secure_file_priv, (uchar**) &opt_secure_file_priv, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-id", OPT_SERVER_ID, @@ -6389,7 +6399,8 @@ Can't be set to 1 if --log-slave-updates is used.", (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, UINT_MAX32, 0, 0, 0}, {"set-variable", 'O', - "Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.", + "Change the value of a variable. Please note that this option is deprecated; " + "you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory", OPT_ENABLE_SHARED_MEMORY, @@ -6402,12 +6413,12 @@ Can't be set to 1 if --log-slave-updates is used.", 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO, - "Show user and password in SHOW SLAVE HOSTS on this master", + "Show user and password in SHOW SLAVE HOSTS on this master.", (uchar**) &opt_show_slave_auth_info, (uchar**) &opt_show_slave_auth_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DISABLE_GRANT_OPTIONS {"skip-grant-tables", OPT_SKIP_GRANT, - "Start without grant tables. This gives all users FULL ACCESS to all tables!", + "Start without grant tables. This gives all users FULL ACCESS to all tables.", (uchar**) &opt_noacl, (uchar**) &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -6422,7 +6433,7 @@ Can't be set to 1 if --log-slave-updates is used.", {"skip-networking", OPT_SKIP_NETWORKING, "Don't allow connection with TCP/IP.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-new", OPT_SKIP_NEW, "Don't use new, possible wrong routines.", + {"skip-new", OPT_SKIP_NEW, "Don't use new, possibly wrong routines.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DBUG_OFF #ifdef SAFEMALLOC @@ -6440,7 +6451,7 @@ Can't be set to 1 if --log-slave-updates is used.", {"skip-stack-trace", OPT_SKIP_STACK_TRACE, "Don't print a stack trace on failure.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Deprecated option. Use --skip-symbolic-links instead.", + {"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Deprecated option. Use --skip-symbolic-links instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-thread-priority", OPT_SKIP_PRIOR, "Don't give threads different priorities. Deprecated option.", 0, 0, 0, GET_NO_ARG, NO_ARG, @@ -6455,11 +6466,11 @@ replicating a LOAD DATA INFILE command.", "Tells the slave thread to continue replication when a query event returns an error from the provided list.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"slave-exec-mode", OPT_SLAVE_EXEC_MODE, - "Modes for how replication events should be executed. Legal values are STRICT (default) and IDEMPOTENT. In IDEMPOTENT mode, replication will not stop for operations that are idempotent. In STRICT mode, replication will stop on any unexpected difference between the master and the slave.", + "Modes for how replication events should be executed. Legal values are STRICT (default) and IDEMPOTENT. In IDEMPOTENT mode, replication will not stop for operations that are idempotent. In STRICT mode, replication will stop on any unexpected difference between the master and the slave.", (uchar**) &slave_exec_mode_str, (uchar**) &slave_exec_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"slow-query-log", OPT_SLOW_LOG, - "Enable|disable slow query log", (uchar**) &opt_slow_log, + "Enable/disable slow query log.", (uchar**) &opt_slow_log, (uchar**) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"socket", OPT_SOCKET, "Socket file to use for connection.", (uchar**) &mysqld_unix_port, (uchar**) &mysqld_unix_port, 0, GET_STR, @@ -6521,7 +6532,7 @@ log and this option does nothing anymore.", 0, 0, 0, 0, 0}, {"timed_mutexes", OPT_TIMED_MUTEXES, - "Specify whether to time mutexes (only InnoDB mutexes are currently supported)", + "Specify whether to time mutexes (only InnoDB mutexes are currently supported).", (uchar**) &timed_mutexes, (uchar**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', @@ -6542,7 +6553,7 @@ log and this option does nothing anymore.", IF_PURIFY(0,1), 0, 0, 0, 0, 0}, {"user", 'u', "Run mysqld daemon as user.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Used with --help option for detailed help", + {"verbose", 'v', "Used with --help option for detailed help.", (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, @@ -6560,7 +6571,7 @@ log and this option does nothing anymore.", (uchar**) &binlog_cache_size, (uchar**) &binlog_cache_size, 0, GET_ULONG, REQUIRED_ARG, 32*1024L, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0}, {"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE, - "Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!", + "Size of tree cache used in bulk insert optimization. Note that this is a limit per thread.", (uchar**) &global_system_variables.bulk_insert_buff_size, (uchar**) &max_system_variables.bulk_insert_buff_size, 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0}, @@ -6569,7 +6580,7 @@ log and this option does nothing anymore.", (uchar**) &connect_timeout, (uchar**) &connect_timeout, 0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 }, { "date_format", OPT_DATE_FORMAT, - "The DATE format (For future).", + "The DATE format (for future).", (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE], (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE], 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -6611,7 +6622,7 @@ log and this option does nothing anymore.", (uchar**) &flush_time, (uchar**) &flush_time, 0, GET_ULONG, REQUIRED_ARG, FLUSH_TIME, 0, LONG_TIMEOUT, 0, 1, 0}, { "ft_boolean_syntax", OPT_FT_BOOLEAN_SYNTAX, - "List of operators for MATCH ... AGAINST ( ... IN BOOLEAN MODE)", + "List of operators for MATCH ... AGAINST ( ... IN BOOLEAN MODE).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, @@ -6623,7 +6634,7 @@ log and this option does nothing anymore.", (uchar**) &ft_min_word_len, (uchar**) &ft_min_word_len, 0, GET_ULONG, REQUIRED_ARG, 4, 1, HA_FT_MAXCHARLEN, 0, 1, 0}, { "ft_query_expansion_limit", OPT_FT_QUERY_EXPANSION_LIMIT, - "Number of best matches to use for query expansion", + "Number of best matches to use for query expansion.", (uchar**) &ft_query_expansion_limit, (uchar**) &ft_query_expansion_limit, 0, GET_ULONG, REQUIRED_ARG, 20, 0, 1000, 0, 1, 0}, { "ft_stopword_file", OPT_FT_STOPWORD_FILE, @@ -6631,7 +6642,7 @@ log and this option does nothing anymore.", (uchar**) &ft_stopword_file, (uchar**) &ft_stopword_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN, - "The maximum length of the result of function group_concat.", + "The maximum length of the result of function group_concat.", (uchar**) &global_system_variables.group_concat_max_len, (uchar**) &max_system_variables.group_concat_max_len, 0, GET_ULONG, REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0}, @@ -6659,30 +6670,36 @@ log and this option does nothing anymore.", REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, SIZE_T_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, - "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", + "This characterizes the number of hits a hot block has to be untouched " + "until it is considered aged enough to be downgraded to a warm block. " + "This specifies the percentage ratio of that number of hits to the total " + "number of blocks in key cache.", (uchar**) &dflt_key_cache_var.param_age_threshold, (uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 300, 100, ULONG_MAX, 0, 100, 0}, {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, - "The default size of key cache blocks", + "The default size of key cache blocks.", (uchar**) &dflt_key_cache_var.param_block_size, (uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_BLOCK_SIZE, 512, 1024 * 16, 0, 512, 0}, {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, - "The minimum percentage of warm blocks in key cache", + "The minimum percentage of warm blocks in key cache.", (uchar**) &dflt_key_cache_var.param_division_limit, (uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 1, 100, 0, 1, 0}, {"long_query_time", OPT_LONG_QUERY_TIME, - "Log all queries that have taken more than long_query_time seconds to execute to file. " - "The argument will be treated as a decimal value with microsecond precission.", + "Log all queries that have taken more than long_query_time seconds to " + "execute. The argument will be treated as a decimal value with " + "microsecond precision.", (uchar**) &long_query_time, (uchar**) &long_query_time, 0, GET_DOUBLE, REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0}, {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES, - "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system", + "If set to 1, table names are stored in lowercase on disk and table names " + "will be case-insensitive. Should be set to 2 if you are using a case-" + "insensitive file system.", (uchar**) &lower_case_table_names, (uchar**) &lower_case_table_names, 0, GET_UINT, OPT_ARG, #ifdef FN_NO_CASE_SENCE @@ -6692,7 +6709,7 @@ log and this option does nothing anymore.", #endif , 0, 2, 0, 1, 0}, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, - "Max packetlength to send/receive from to server.", + "The maximum packet length to send to or receive from server.", (uchar**) &global_system_variables.max_allowed_packet, (uchar**) &max_system_variables.max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, @@ -6751,7 +6768,7 @@ The minimum value for this variable is 4096.", (uchar**) &max_relay_log_size, (uchar**) &max_relay_log_size, 0, GET_ULONG, REQUIRED_ARG, 0L, 0L, 1024*1024L*1024L, 0, IO_SIZE, 0}, { "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY, - "Limit assumed max number of seeks when looking up rows based on a key", + "Limit assumed max number of seeks when looking up rows based on a key.", (uchar**) &global_system_variables.max_seeks_for_key, (uchar**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG, REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 }, @@ -6827,7 +6844,7 @@ The minimum value for this variable is 4096.", (uchar**) &max_system_variables.myisam_sort_buff_size, 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0}, {"myisam_use_mmap", OPT_MYISAM_USE_MMAP, - "Use memory mapping for reading and writing MyISAM tables", + "Use memory mapping for reading and writing MyISAM tables.", (uchar**) &opt_myisam_use_mmap, (uchar**) &opt_myisam_use_mmap, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -6853,7 +6870,8 @@ The minimum value for this variable is 4096.", (uchar**) &max_system_variables.net_retry_count,0, GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0}, {"net_write_timeout", OPT_NET_WRITE_TIMEOUT, - "Number of seconds to wait for a block to be written to a connection before aborting the write.", + "Number of seconds to wait for a block to be written to a connection before " + "aborting the write.", (uchar**) &global_system_variables.net_write_timeout, (uchar**) &max_system_variables.net_write_timeout, 0, GET_ULONG, REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, @@ -6893,12 +6911,12 @@ The minimum value for this variable is 4096.", (uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE, - "The size of the buffer that is allocated when preloading indexes", + "The size of the buffer that is allocated when preloading indexes.", (uchar**) &global_system_variables.preload_buff_size, (uchar**) &max_system_variables.preload_buff_size, 0, GET_ULONG, REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0}, {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE, - "Allocation block size for query parsing and execution", + "Allocation block size for query parsing and execution.", (uchar**) &global_system_variables.query_alloc_block_size, (uchar**) &max_system_variables.query_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0}, @@ -6908,7 +6926,8 @@ The minimum value for this variable is 4096.", (uchar**) &query_cache_limit, (uchar**) &query_cache_limit, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L, 0, ULONG_MAX, 0, 1, 0}, {"query_cache_min_res_unit", OPT_QUERY_CACHE_MIN_RES_UNIT, - "minimal size of unit in wich space for results is allocated (last unit will be trimed after writing all result data.", + "Minimal size of unit in which space for results is allocated (last unit " + "will be trimmed after writing all result data).", (uchar**) &query_cache_min_res_unit, (uchar**) &query_cache_min_res_unit, 0, GET_ULONG, REQUIRED_ARG, QUERY_CACHE_MIN_RESULT_DATA_SIZE, 0, ULONG_MAX, 0, 1, 0}, @@ -6924,19 +6943,19 @@ The minimum value for this variable is 4096.", (uchar**) &max_system_variables.query_cache_type, 0, GET_ULONG, REQUIRED_ARG, 1, 0, 2, 0, 1, 0}, {"query_cache_wlock_invalidate", OPT_QUERY_CACHE_WLOCK_INVALIDATE, - "Invalidate queries in query cache on LOCK for write", + "Invalidate queries in query cache on LOCK for write.", (uchar**) &global_system_variables.query_cache_wlock_invalidate, (uchar**) &max_system_variables.query_cache_wlock_invalidate, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, #endif /*HAVE_QUERY_CACHE*/ {"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE, - "Persistent buffer for query parsing and execution", + "Persistent buffer for query parsing and execution.", (uchar**) &global_system_variables.query_prealloc_size, (uchar**) &max_system_variables.query_prealloc_size, 0, GET_ULONG, REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE, ULONG_MAX, 0, 1024, 0}, {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE, - "Allocation block size for storing ranges during optimization", + "Allocation block size for storing ranges during optimization.", (uchar**) &global_system_variables.range_alloc_block_size, (uchar**) &max_system_variables.range_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, ULONG_MAX, @@ -6948,12 +6967,15 @@ The minimum value for this variable is 4096.", 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, INT_MAX32, MALLOC_OVERHEAD, IO_SIZE, 0}, {"read_only", OPT_READONLY, - "Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege", + "Make all non-temporary tables read-only, with the exception of replication " + "(slave) threads and users with the SUPER privilege.", (uchar**) &opt_readonly, (uchar**) &opt_readonly, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, {"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER, - "When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks. If not set, then it's set to the value of record_buffer.", + "When reading rows in sorted order after a sort, the rows are read through " + "this buffer to avoid disk seeks. If not set, then it's set to the value of " + "record_buffer.", (uchar**) &global_system_variables.read_rnd_buff_size, (uchar**) &max_system_variables.read_rnd_buff_size, 0, GET_ULONG, REQUIRED_ARG, 256*1024L, IO_SIZE*2+MALLOC_OVERHEAD, @@ -7036,7 +7058,8 @@ The minimum value for this variable is 4096.", DEFAULT_CONCURRENCY, 1, 512, 0, 1, 0}, #if HAVE_POOL_OF_THREADS == 1 {"thread_pool_size", OPT_THREAD_CACHE_SIZE, - "How many threads we should create to handle query requests in case of 'thread_handling=pool-of-threads'", + "How many threads we should create to handle query requests in case of " + "'thread_handling=pool-of-threads'.", (uchar**) &thread_pool_size, (uchar**) &thread_pool_size, 0, GET_ULONG, REQUIRED_ARG, 20, 1, 16384, 0, 1, 0}, #endif @@ -7056,18 +7079,18 @@ The minimum value for this variable is 4096.", (uchar**) &max_system_variables.tmp_table_size, 0, GET_ULL, REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0}, {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, - "Allocation block size for transactions to be stored in binary log", + "Allocation block size for transactions to be stored in binary log.", (uchar**) &global_system_variables.trans_alloc_block_size, (uchar**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0}, {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE, - "Persistent buffer for transactions to be stored in binary log", + "Persistent buffer for transactions to be stored in binary log.", (uchar**) &global_system_variables.trans_prealloc_size, (uchar**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG, REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0}, {"thread_handling", OPT_THREAD_HANDLING, - "Define threads usage for handling queries: " - "one-thread-per-connection or no-threads", 0, 0, + "Define threads usage for handling queries: " + "one-thread-per-connection or no-threads.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"updatable_views_with_limit", OPT_UPDATABLE_VIEWS_WITH_LIMIT, "1 = YES = Don't issue an error message (warning only) if a VIEW without presence of a key of the underlying table is used in queries with a LIMIT clause for updating. 0 = NO = Prohibit update of a VIEW, which does not contain a key of the underlying table and the query uses a LIMIT clause (usually get from GUI tools).", @@ -7081,7 +7104,11 @@ The minimum value for this variable is 4096.", REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT), 0, 1, 0}, {"binlog-direct-non-transactional-updates", OPT_BINLOG_DIRECT_NON_TRANS_UPDATE, - "Causes updates to non-transactional engines using statement format to be written directly to binary log. Before using this option make sure that there are no dependencies between transactional and non-transactional tables such as in the statement INSERT INTO t_myisam SELECT * FROM t_innodb; otherwise, slaves may diverge from the master.", + "Causes updates to non-transactional engines using statement format to be " + "written directly to binary log. Before using this option, make sure that " + "there are no dependencies between transactional and non-transactional " + "tables such as in the statement INSERT INTO t_myisam SELECT * FROM " + "t_innodb; otherwise, slaves may diverge from the master.", (uchar**) &global_system_variables.binlog_direct_non_trans_update, (uchar**) &max_system_variables.binlog_direct_non_trans_update, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} @@ -7597,27 +7624,27 @@ static void usage(void) default_collation_name= (char*) default_charset_info->name; print_version(); puts("\ -Copyright (C) 2000-2008 MySQL AB, by Monty and others\n\ +Copyright (C) 2000-2008 MySQL AB, by Monty and others.\n\ Copyright (C) 2008 Sun Microsystems, Inc.\n\ This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ and you are welcome to modify and redistribute it under the GPL license\n\n\ -Starts the MySQL database server\n"); +Starts the MySQL database server.\n"); printf("Usage: %s [OPTIONS]\n", my_progname); if (!opt_verbose) - puts("\nFor more help options (several pages), use mysqld --verbose --help"); + puts("\nFor more help options (several pages), use mysqld --verbose --help."); else { #ifdef __WIN__ puts("NT and Win32 specific options:\n\ - --install Install the default service (NT)\n\ - --install-manual Install the default service started manually (NT)\n\ - --install service_name Install an optional service (NT)\n\ - --install-manual service_name Install an optional service started manually (NT)\n\ - --remove Remove the default service from the service list (NT)\n\ - --remove service_name Remove the service_name from the service list (NT)\n\ - --enable-named-pipe Only to be used for the default server (NT)\n\ - --standalone Dummy option to start as a standalone server (NT)\ + --install Install the default service (NT).\n\ + --install-manual Install the default service started manually (NT).\n\ + --install service_name Install an optional service (NT).\n\ + --install-manual service_name Install an optional service started manually (NT).\n\ + --remove Remove the default service from the service list (NT).\n\ + --remove service_name Remove the service_name from the service list (NT).\n\ + --enable-named-pipe Only to be used for the default server (NT).\n\ + --standalone Dummy option to start as a standalone server (NT).\ "); puts(""); #endif From 0569a827ea322fc0cd391b7086d1d98e745d1924 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 2 Feb 2010 18:30:23 +0200 Subject: [PATCH 02/96] Bug #45989 take 2 : memory leak after explain encounters an error in the query. Fixes a leak after materializing a GROUP BY subquery to a temp table when the subquery has a blob column in the SELECT list. Fixed by correctly destructing temporary buffers for re-usable queries --- mysql-test/r/subselect.result | 12 ++++++++++++ mysql-test/t/subselect.test | 17 +++++++++++++++++ sql/sql_select.cc | 12 ++++++++++++ sql/sql_select.h | 20 +++++++++++++++++++- 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index dc3cff68731..2dc26bfb048 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4615,4 +4615,16 @@ FROM t1,t1 a ); 1 DROP TABLE t1; +# +# Bug #45989 take 2 : memory leak after explain encounters an +# error in the query +# +CREATE TABLE t1(a LONGTEXT); +INSERT INTO t1 VALUES (repeat('a',@@global.max_allowed_packet)); +INSERT INTO t1 VALUES (repeat('b',@@global.max_allowed_packet)); +EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1, +(SELECT DISTINCTROW a AS away FROM t1 GROUP BY a WITH ROLLUP) AS d1 +WHERE t1.a = d1.a; +ERROR 42S22: Unknown column 'd1.a' in 'where clause' +DROP TABLE t1; End of 5.1 tests. diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 027578fc6bd..09a7ca22e44 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3600,4 +3600,21 @@ SELECT 1 FROM t1 WHERE a <> SOME ); DROP TABLE t1; +--echo # +--echo # Bug #45989 take 2 : memory leak after explain encounters an +--echo # error in the query +--echo # + +CREATE TABLE t1(a LONGTEXT); +INSERT INTO t1 VALUES (repeat('a',@@global.max_allowed_packet)); +INSERT INTO t1 VALUES (repeat('b',@@global.max_allowed_packet)); + +--error ER_BAD_FIELD_ERROR +EXPLAIN EXTENDED SELECT DISTINCT 1 FROM t1, +(SELECT DISTINCTROW a AS away FROM t1 GROUP BY a WITH ROLLUP) AS d1 +WHERE t1.a = d1.a; + +DROP TABLE t1; + + --echo End of 5.1 tests. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index da85ca27339..0a3c61d2b97 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2313,6 +2313,12 @@ JOIN::destroy() tab->cleanup(); } tmp_join->tmp_join= 0; + /* + We need to clean up tmp_table_param for reusable JOINs (having non-zero + and different from self tmp_join) because it's not being cleaned up + anywhere else (as we need to keep the join is reusable). + */ + tmp_table_param.cleanup(); tmp_table_param.copy_field= 0; DBUG_RETURN(tmp_join->destroy()); } @@ -5838,6 +5844,12 @@ JOIN::make_simple_join(JOIN *parent, TABLE *tmp_table) const_table_map= 0; tmp_table_param.field_count= tmp_table_param.sum_func_count= tmp_table_param.func_count= 0; + /* + We need to destruct the copy_field (allocated in create_tmp_table()) + before setting it to 0 if the join is not "reusable". + */ + if (!tmp_join || tmp_join != this) + tmp_table_param.cleanup(); tmp_table_param.copy_field= tmp_table_param.copy_field_end=0; first_record= sort_and_group=0; send_records= (ha_rows) 0; diff --git a/sql/sql_select.h b/sql/sql_select.h index dd99d358bac..bfff0a0ffa2 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -354,7 +354,25 @@ public: */ bool no_const_tables; - JOIN *tmp_join; ///< copy of this JOIN to be used with temporary tables + /** + Copy of this JOIN to be used with temporary tables. + + tmp_join is used when the JOIN needs to be "reusable" (e.g. in a subquery + that gets re-executed several times) and we know will use temporary tables + for materialization. The materialization to a temporary table overwrites the + JOIN structure to point to the temporary table after the materialization is + done. This is where tmp_join is used : it's a copy of the JOIN before the + materialization and is used in restoring before re-execution by overwriting + the current JOIN structure with the saved copy. + Because of this we should pay extra care of not freeing up helper structures + that are referenced by the original contents of the JOIN. We can check for + this by making sure the "current" join is not the temporary copy, e.g. + !tmp_join || tmp_join != join + + We should free these sub-structures at JOIN::destroy() if the "current" join + has a copy is not that copy. + */ + JOIN *tmp_join; ROLLUP rollup; ///< Used with rollup bool select_distinct; ///< Set if SELECT DISTINCT From c9df74c802c6440d30344f83d490d7f6e4b0a9bd Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 4 Feb 2010 18:51:55 +0200 Subject: [PATCH 03/96] Addendum to the fix for bug #45989 Need to make sure the tmp join doesn't point to the structure already freed by the cleanup() for the "base" join, as this can lead to double free, because sometimes both tmp_join and join point to the same tmp_table_params.copy_field array. --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0a3c61d2b97..9136b2e57e3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2319,7 +2319,7 @@ JOIN::destroy() anywhere else (as we need to keep the join is reusable). */ tmp_table_param.cleanup(); - tmp_table_param.copy_field= 0; + tmp_table_param.copy_field= tmp_join->tmp_table_param.copy_field= 0; DBUG_RETURN(tmp_join->destroy()); } cond_equal= 0; From 3429b198b2632349ce64ee64799833f043b7aac9 Mon Sep 17 00:00:00 2001 From: Kent Boortz Date: Thu, 4 Feb 2010 19:27:09 +0100 Subject: [PATCH 04/96] LT_INIT and LT_PREREQ was added in libtool 2.2 2008, a bit too recent, switched back to the older AC_PROG_LIBTOOL --- configure.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configure.in b/configure.in index f2e83abc60c..960b45b7d00 100644 --- a/configure.in +++ b/configure.in @@ -14,8 +14,7 @@ AC_CANONICAL_SYSTEM # TAR files, the path name is split into two parts, a 155 chacater # first part and a 100 character second part. AM_INIT_AUTOMAKE([1.9 tar-ustar]) -LT_INIT -LT_PREREQ([1.5.6]) +AC_PROG_LIBTOOL AM_CONFIG_HEADER([include/config.h]) From 31348b438de93dec22dcd351e29193c68b9bf03b Mon Sep 17 00:00:00 2001 From: Date: Fri, 5 Feb 2010 14:49:01 +0800 Subject: [PATCH 05/96] Bug #50061 Test "rpl_loaddata_symlink" uses a Unix-specific "run-slave" script Bug #49984 Test 'rpl_loaddata_symlink' fails with "Could not find target log" Sometimes the symbolic link is available on Windows if you have some Unix (emulation) layer installed like Cygwin, MKS or other. But symbolic link is not always available. It depends on versions, file volume and system environment of Windows. And the symbolic link is not typically used on Windows, at least not in the degree and style they are used on Unix. We can not change the test case to do without symbolic link, because the test case is used to test that if the symbolic link works fine. To fix the problem, skip the test on windows. --- mysql-test/suite/rpl/t/rpl_loaddata_symlink.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test b/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test index d3ee2766314..63e65834e5b 100644 --- a/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test +++ b/mysql-test/suite/rpl/t/rpl_loaddata_symlink.test @@ -4,6 +4,7 @@ # if the path of the load data file is a symbolic link. # --source include/master-slave.inc +--source include/not_windows.inc --source include/have_binlog_format_statement.inc create table t1(a int not null auto_increment, b int, primary key(a) ); From 271f418ca7625f595c8d611f0bfe2a05a1e8f7f4 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 5 Feb 2010 13:39:46 +0400 Subject: [PATCH 06/96] Bug#47736 killing a select from a view when the view is processing a function, asserts hide_view_error() does not take into account that thread query may be killed. Added a check for thd->killed. Addon: backported bug32140 fix from 6.0 --- mysql-test/r/sp_notembedded.result | 11 +++++++++ mysql-test/t/sp_notembedded.test | 37 ++++++++++++++++++++++++++++++ sql/sp.cc | 4 ++++ sql/table.cc | 2 +- 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result index 831616f491b..7e9ccf01d23 100644 --- a/mysql-test/r/sp_notembedded.result +++ b/mysql-test/r/sp_notembedded.result @@ -268,6 +268,17 @@ SELECT RELEASE_LOCK('Bug44521'); RELEASE_LOCK('Bug44521') 1 DROP PROCEDURE p; +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (1); +CREATE FUNCTION f1 (inp TEXT) RETURNS INT NO SQL RETURN sleep(60); +CREATE VIEW v1 AS SELECT f1('a') FROM t1; +SELECT * FROM v1;; +SELECT * FROM v1; +ERROR 70100: Query execution was interrupted +ERROR 70100: Query execution was interrupted +DROP VIEW v1; +DROP TABLE t1; +DROP FUNCTION f1; # ------------------------------------------------------------------ # -- End of 5.1 tests # ------------------------------------------------------------------ diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index f593e184ad2..326cc22f1cd 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -413,6 +413,43 @@ let $wait_condition= --source include/wait_condition.inc DROP PROCEDURE p; +# +# Bug#47736 killing a select from a view when the view is processing a function, asserts +# +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (1); +CREATE FUNCTION f1 (inp TEXT) RETURNS INT NO SQL RETURN sleep(60); +CREATE VIEW v1 AS SELECT f1('a') FROM t1; + +--connect (con1, localhost, root,,) +--let $ID_1= `SELECT connection_id()` +--send SELECT * FROM v1; + +--connect (con2, localhost, root,,) +--let $ID_2= `SELECT connection_id()` +--send SELECT * FROM v1 + +--connection default +--disable_query_log +--eval KILL QUERY $ID_2 +--eval KILL QUERY $ID_1 +--enable_query_log + +--connection con1 +--error ER_QUERY_INTERRUPTED +--reap +--connection con2 +--error ER_QUERY_INTERRUPTED +--reap + +--connection default +DROP VIEW v1; +DROP TABLE t1; +DROP FUNCTION f1; +--disconnect con1 +--disconnect con2 + + --echo # ------------------------------------------------------------------ --echo # -- End of 5.1 tests --echo # ------------------------------------------------------------------ diff --git a/sql/sp.cc b/sql/sp.cc index f0508142557..ef69edb96c6 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1898,6 +1898,10 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex, ret= SP_OK; break; default: + /* Query might have been killed, don't set error. */ + if (thd->killed) + break; + /* Any error when loading an existing routine is either some problem with the mysql.proc table, or a parse error because the contents diff --git a/sql/table.cc b/sql/table.cc index c06ecf99926..8a8228b9954 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3365,7 +3365,7 @@ bool TABLE_LIST::prep_check_option(THD *thd, uint8 check_opt_type) void TABLE_LIST::hide_view_error(THD *thd) { - if (thd->get_internal_handler()) + if (thd->killed || thd->get_internal_handler()) return; /* Hide "Unknown column" or "Unknown function" error */ DBUG_ASSERT(thd->is_error()); From 24ab16096bdcb64cde5693d6141b8df74fbe80fc Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 23 Dec 2009 12:45:18 +0200 Subject: [PATCH 07/96] Bug #39022: Mysql randomly crashing in lock_sec_rec_cons_read_sees flush_cached_records() was not correctly checking for errors after calling Item::val_xxx() methods. The expressions may contain subqueries or stored procedures that cause errors that should stop the statement. Fixed by correctly checking for errors and propagating them up the call stack. --- mysql-test/r/bug39022.result | 32 ++++++++++++++++++++ mysql-test/t/bug39022.test | 58 ++++++++++++++++++++++++++++++++++++ sql/sql_select.cc | 46 +++++++++++++++++++++------- 3 files changed, 125 insertions(+), 11 deletions(-) create mode 100644 mysql-test/r/bug39022.result create mode 100644 mysql-test/t/bug39022.test diff --git a/mysql-test/r/bug39022.result b/mysql-test/r/bug39022.result new file mode 100644 index 00000000000..1c02d7873e4 --- /dev/null +++ b/mysql-test/r/bug39022.result @@ -0,0 +1,32 @@ +# +# Bug #39022: Mysql randomly crashing in lock_sec_rec_cons_read_sees +# +CREATE TABLE t1(a TINYINT NOT NULL,b TINYINT,PRIMARY KEY(b)) ENGINE=innodb; +CREATE TABLE t2(d TINYINT NOT NULL,UNIQUE KEY(d)) ENGINE=innodb; +INSERT INTO t1 VALUES (13,0),(8,1),(9,2),(6,3), +(11,5),(11,6),(7,7),(7,8),(4,9),(6,10),(3,11),(11,12), +(12,13),(7,14); +INSERT INTO t2 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10), +(11),(12),(13),(14); +# in thread1 +START TRANSACTION; +# in thread2 +REPLACE INTO t2 VALUES (-17); +SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); +d +# in thread1 +REPLACE INTO t1(a,b) VALUES (67,20); +# in thread2 +COMMIT; +START TRANSACTION; +REPLACE INTO t1(a,b) VALUES (65,-50); +REPLACE INTO t2 VALUES (-91); +SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); +# in thread1 +# should not crash +SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +# in thread2 +d +# in default +DROP TABLE t1,t2; diff --git a/mysql-test/t/bug39022.test b/mysql-test/t/bug39022.test new file mode 100644 index 00000000000..1a1d10f5592 --- /dev/null +++ b/mysql-test/t/bug39022.test @@ -0,0 +1,58 @@ +-- source include/have_log_bin.inc +-- source include/have_innodb.inc + +--echo # +--echo # Bug #39022: Mysql randomly crashing in lock_sec_rec_cons_read_sees +--echo # + +CREATE TABLE t1(a TINYINT NOT NULL,b TINYINT,PRIMARY KEY(b)) ENGINE=innodb; +CREATE TABLE t2(d TINYINT NOT NULL,UNIQUE KEY(d)) ENGINE=innodb; +INSERT INTO t1 VALUES (13,0),(8,1),(9,2),(6,3), +(11,5),(11,6),(7,7),(7,8),(4,9),(6,10),(3,11),(11,12), +(12,13),(7,14); +INSERT INTO t2 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10), +(11),(12),(13),(14); + +connect (thread1, localhost, root,,); +connect (thread2, localhost, root,,); + +connection thread1; +--echo # in thread1 +START TRANSACTION; + +connection thread2; +--echo # in thread2 +REPLACE INTO t2 VALUES (-17); +SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); + +connection thread1; +--echo # in thread1 +REPLACE INTO t1(a,b) VALUES (67,20); + +connection thread2; +--echo # in thread2 +COMMIT; +START TRANSACTION; +REPLACE INTO t1(a,b) VALUES (65,-50); +REPLACE INTO t2 VALUES (-91); +send; +SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); #waits + +connection thread1; +--echo # in thread1 + +--echo # should not crash +--error ER_LOCK_DEADLOCK +SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); #crashes + +connection thread2; +--echo # in thread2 +REAP; + +connection default; +--echo # in default + +disconnect thread1; +disconnect thread2; + +DROP TABLE t1,t2; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9136b2e57e3..bdd139edafc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11521,21 +11521,45 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skip_last) return NESTED_LOOP_KILLED; // Aborted by user /* purecov: inspected */ } SQL_SELECT *select=join_tab->select; - if (rc == NESTED_LOOP_OK && - (!join_tab->cache.select || !join_tab->cache.select->skip_record())) + if (rc == NESTED_LOOP_OK) { - uint i; - reset_cache_read(&join_tab->cache); - for (i=(join_tab->cache.records- (skip_last ? 1 : 0)) ; i-- > 0 ;) + bool consider_record= !join_tab->cache.select || + !join_tab->cache.select->skip_record(); + + /* + Check for error: skip_record() can execute code by calling + Item_subselect::val_*. We need to check for errors (if any) + after such call. + */ + if (join->thd->is_error()) { - read_cached_record(join_tab); - if (!select || !select->skip_record()) + reset_cache_write(&join_tab->cache); + return NESTED_LOOP_ERROR; + } + + if (consider_record) + { + uint i; + reset_cache_read(&join_tab->cache); + for (i=(join_tab->cache.records- (skip_last ? 1 : 0)) ; i-- > 0 ;) { - rc= (join_tab->next_select)(join,join_tab+1,0); - if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) + read_cached_record(join_tab); + if (!select || !select->skip_record()) { - reset_cache_write(&join_tab->cache); - return rc; + /* + Check for error: skip_record() can execute code by calling + Item_subselect::val_*. We need to check for errors (if any) + after such call. + */ + if (join->thd->is_error()) + rc= NESTED_LOOP_ERROR; + else + rc= (join_tab->next_select)(join,join_tab+1,0); + if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) + { + reset_cache_write(&join_tab->cache); + return rc; + } } } } From 2a22dc2e01202a04f8e1cb6e787d3ef5e35977d2 Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Wed, 10 Feb 2010 15:37:34 +0100 Subject: [PATCH 08/96] Bug#49534: multitable IGNORE update with sql_safe_updates error causes debug assertion The IGNORE option of the multiple-table UPDATE command was not intended to suppress errors caused by the sql_safe_updates mode. This flag will raise an error if the execution of UPDATE does not use a key for row retrieval, and should continue do so regardless of the IGNORE option. However the implementation of IGNORE does not support exceptions to the rule; it always converts errors to warnings and cannot be extended. The Internal_error_handler interface offers the infrastructure to handle individual errors, making sure that the error raised by sql_safe_updates is not silenced. Fixed by implementing an Internal_error_handler and using it for UPDATE IGNORE commands. --- mysql-test/r/multi_update.result | 11 ++++ mysql-test/t/multi_update.test | 12 +++++ sql/sql_class.cc | 4 +- sql/sql_class.h | 2 +- sql/sql_update.cc | 87 ++++++++++++++++++++++++++++---- 5 files changed, 104 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 449333a4ae6..04bf7720c43 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -634,4 +634,15 @@ select count(*) from t3 /* must be 1 */; count(*) 1 drop table t1, t2, t3; +# +# Bug#49534: multitable IGNORE update with sql_safe_updates error +# causes debug assertion +# +CREATE TABLE t1( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (1), (2), (3); +SET SESSION sql_safe_updates = 1; +# Must not cause failed assertion +UPDATE IGNORE t1, t1 t1a SET t1.a = 1 WHERE t1a.a = 1; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column +DROP TABLE t1; end of tests diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index fc37fd6a27d..3c33a3dde35 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -637,5 +637,17 @@ drop table t1, t2, t3; # Add further tests from here # +--echo # +--echo # Bug#49534: multitable IGNORE update with sql_safe_updates error +--echo # causes debug assertion +--echo # +CREATE TABLE t1( a INT, KEY( a ) ); +INSERT INTO t1 VALUES (1), (2), (3); +SET SESSION sql_safe_updates = 1; +--echo # Must not cause failed assertion +--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE +UPDATE IGNORE t1, t1 t1a SET t1.a = 1 WHERE t1a.a = 1; +DROP TABLE t1; + --echo end of tests diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7b37a3f6e93..b22aa41b40a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -740,10 +740,12 @@ bool THD::handle_error(uint sql_errno, const char *message, } -void THD::pop_internal_handler() +Internal_error_handler *THD::pop_internal_handler() { DBUG_ASSERT(m_internal_handler != NULL); + Internal_error_handler *popped_handler= m_internal_handler; m_internal_handler= m_internal_handler->m_prev_internal_handler; + return popped_handler; } extern "C" diff --git a/sql/sql_class.h b/sql/sql_class.h index 77b4aa6c1d0..032985dc44e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2313,7 +2313,7 @@ public: /** Remove the error handler last pushed. */ - void pop_internal_handler(); + Internal_error_handler *pop_internal_handler(); /** Overloaded to guard query/query_length fields */ virtual void set_statement(Statement *stmt); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 32add8679ef..84610630d62 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1188,6 +1188,56 @@ reopen_tables: } +/** + Implementation of the safe update options during UPDATE IGNORE. This syntax + causes an UPDATE statement to ignore all errors. In safe update mode, + however, we must never ignore the ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE. There + is a special hook in my_message_sql that will otherwise delete all errors + when the IGNORE option is specified. + + In the future, all IGNORE handling should be used with this class and all + traces of the hack outlined below should be removed. + + - The parser detects IGNORE option and sets thd->lex->ignore= 1 + + - In JOIN::optimize, if this is set, then + thd->lex->current_select->no_error gets set. + + - In my_message_sql(), if the flag above is set then any error is + unconditionally converted to a warning. + + We are moving in the direction of using Internal_error_handler subclasses + to do all such error tweaking, please continue this effort if new bugs + appear. + */ +class Safe_dml_handler : public Internal_error_handler { + +private: + bool m_handled_error; + +public: + explicit Safe_dml_handler() : m_handled_error(FALSE) {} + + bool handle_error(uint sql_errno, + const char *message, + MYSQL_ERROR::enum_warning_level level, + THD *thd) + { + if (level == MYSQL_ERROR::WARN_LEVEL_ERROR && + sql_errno == ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE) + + { + thd->main_da.set_error_status(thd, sql_errno, message); + m_handled_error= TRUE; + return TRUE; + } + return FALSE; + } + + bool handled_error() { return m_handled_error; } + +}; + /* Setup multi-update handling and call SELECT to do the join */ @@ -1216,18 +1266,35 @@ bool mysql_multi_update(THD *thd, MODE_STRICT_ALL_TABLES)); List total_list; + + Safe_dml_handler handler; + bool using_handler= thd->options & OPTION_SAFE_UPDATES; + if (using_handler) + thd->push_internal_handler(&handler); + res= mysql_select(thd, &select_lex->ref_pointer_array, - table_list, select_lex->with_wild, - total_list, - conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, - (ORDER *)NULL, - options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | - OPTION_SETUP_TABLES_DONE, - result, unit, select_lex); - DBUG_PRINT("info",("res: %d report_error: %d", res, - (int) thd->is_error())); + table_list, select_lex->with_wild, + total_list, + conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, + (ORDER *)NULL, + options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | + OPTION_SETUP_TABLES_DONE, + result, unit, select_lex); + + if (using_handler) + { + Internal_error_handler *top_handler= thd->pop_internal_handler(); + DBUG_ASSERT(&handler == top_handler); + } + + DBUG_PRINT("info",("res: %d report_error: %d", res, (int) thd->is_error())); res|= thd->is_error(); - if (unlikely(res)) + /* + Todo: remove below code and make Safe_dml_handler do error processing + instead. That way we can return the actual error instead of + ER_UNKNOWN_ERROR. + */ + if (unlikely(res) && (!using_handler || !handler.handled_error())) { /* If we had a another error reported earlier then this will be ignored */ result->send_error(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR)); From c1a6dc5084cd91bfbaa7d0bb68d5a3a5b98dc031 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Thu, 11 Feb 2010 21:10:13 +0100 Subject: [PATCH 09/96] Bug #47905 stored procedures with conditional statements not being logged to slow query log The problem is that the execution time for a multi-statement stored procedure as a whole may not be accurate, and thus not be entered into the slow query log even if the total time exceeds long_query_time. The reason for this is that THD::utime_after_lock used for time calculation may be reset at the start of each new statement, possibly leaving the total SP execution equal to the time spent executing the last statement in the SP. This patch stores the utime on start of SP execution, and restores it on exit of SP execution. A test is added. --- .../sys_vars/r/slow_query_log_func.result | 16 ++++++++++++++ .../suite/sys_vars/t/slow_query_log_func.test | 21 +++++++++++++++++++ sql/sp_head.cc | 3 +++ 3 files changed, 40 insertions(+) diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_func.result b/mysql-test/suite/sys_vars/r/slow_query_log_func.result index d5485e2e6d7..eb7efe4a004 100644 --- a/mysql-test/suite/sys_vars/r/slow_query_log_func.result +++ b/mysql-test/suite/sys_vars/r/slow_query_log_func.result @@ -20,5 +20,21 @@ sleep(2) SELECT count(*) > 0 FROM mysql.slow_log; count(*) > 0 1 +'Bug#47905 stored procedures not logged correctly to slow query log' +TRUNCATE mysql.slow_log; +CREATE PROCEDURE p_test() +BEGIN +select sleep(2); +select 1; +END// +CALL p_test(); +sleep(2) +0 +1 +1 +SELECT count(*) > 0 FROM mysql.slow_log; +count(*) > 0 +1 +DROP PROCEDURE p_test; SET @@global.log_output = @global_log_output; SET @global.slow_query_log = @global_slow_query_log; diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_func.test b/mysql-test/suite/sys_vars/t/slow_query_log_func.test index d2653f89de4..250d5210c46 100644 --- a/mysql-test/suite/sys_vars/t/slow_query_log_func.test +++ b/mysql-test/suite/sys_vars/t/slow_query_log_func.test @@ -31,6 +31,27 @@ SELECT sleep(2); SELECT count(*) > 0 FROM mysql.slow_log; + +#========================================================================== +--echo 'Bug#47905 stored procedures not logged correctly to slow query log' +#========================================================================== +# assumes logging to table turned on with long_query_time=1 as above + +TRUNCATE mysql.slow_log; + +DELIMITER //; +CREATE PROCEDURE p_test() +BEGIN + select sleep(2); + select 1; +END// +DELIMITER ;// + +CALL p_test(); +SELECT count(*) > 0 FROM mysql.slow_log; +DROP PROCEDURE p_test; + + #restore SET @@global.log_output = @global_log_output; SET @global.slow_query_log = @global_slow_query_log; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 45cb4eebb09..8a626cabd90 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1848,6 +1848,8 @@ sp_head::execute_procedure(THD *thd, List *args) { bool err_status= FALSE; uint params = m_pcont->context_var_count(); + /* Query start time may be reset in a multi-stmt SP; keep this for later. */ + ulonglong utime_before_sp_exec= thd->utime_after_lock; sp_rcontext *save_spcont, *octx; sp_rcontext *nctx = NULL; bool save_enable_slow_log= false; @@ -2040,6 +2042,7 @@ sp_head::execute_procedure(THD *thd, List *args) delete nctx; thd->spcont= save_spcont; + thd->utime_after_lock= utime_before_sp_exec; DBUG_RETURN(err_status); } From 3990858bc7545cb9311e49a31c8e96ed88a4a7cd Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 27 Jan 2010 11:10:53 -0200 Subject: [PATCH 10/96] Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer The problem was that a failure to open a view wasn't being properly handled. When opening a view with unknown definer, the open procedure would be treated as successful and would later crash when attempting to lock the view (which wasn't opened to begin with). The solution is to skip further processing when opening a table if it fails with a fatal error. --- mysql-test/r/view.result | 10 ++++++++++ mysql-test/t/view.test | 12 ++++++++++++ sql/sql_base.cc | 13 +++++++++++++ 3 files changed, 35 insertions(+) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 613939bfdf6..10bbe3d9865 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3844,6 +3844,16 @@ CREATE VIEW v1 AS SELECT a FROM t1; ALTER TABLE v1; DROP VIEW v1; DROP TABLE t1; +# +# Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer +# +DROP VIEW IF EXISTS v1; +CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; +Warnings: +Note 1449 The user specified as a definer ('unknown'@'unknown') does not exist +LOCK TABLES v1 READ; +ERROR HY000: The user specified as a definer ('unknown'@'unknown') does not exist +DROP VIEW v1; # ----------------------------------------------------------------- # -- End of 5.1 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index a788b5ab41e..c0cdd40ddb6 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3869,6 +3869,18 @@ ALTER TABLE v1; DROP VIEW v1; DROP TABLE t1; +--echo # +--echo # Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer +--echo # + +--disable_warnings +DROP VIEW IF EXISTS v1; +--enable_warnings + +CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; +--error ER_NO_SUCH_USER +LOCK TABLES v1 READ; +DROP VIEW v1; --echo # ----------------------------------------------------------------- --echo # -- End of 5.1 tests. diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a1f34f6a770..06e4b1d3e63 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4591,7 +4591,20 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) safe_to_ignore_table= prelock_handler.safely_trapped_errors(); } else + { tables->table= open_table(thd, tables, &new_frm_mem, &refresh, flags); + + /* + Skip further processing if there has been a fatal error while + trying to open a table. For example, this might happen due to + stack shortage, unknown definer in views, etc. + */ + if (!tables->table && thd->is_error()) + { + result= -1; + goto err; + } + } } else DBUG_PRINT("tcache", ("referenced table: '%s'.'%s' 0x%lx", From be632a2f5a41f9c0268ec0fc44cd43588056cbbf Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Wed, 10 Feb 2010 16:11:08 -0200 Subject: [PATCH 11/96] Bug#48449: hang on show create view after upgrading when view contains function of view SHOW CREATE TABLE on a view (v1) that contains a function whose statement uses another view (v2), could trigger a infinite loop if the view referenced within the function causes a warning to be raised while opening the said view (v2). The problem was a infinite loop over the stack of internal error handlers. The problem would be triggered if the stack contained two or more handlers and the first two handlers didn't handle the raised condition. In this case, the loop variable would always point to the second handler in the stack. The solution is to correct the loop variable assignment so that the loop is able to iterate over all handlers in the stack. --- mysql-test/r/view.result | 24 ++++++++++++++++++++++ mysql-test/std_data/bug48449.frm | 12 +++++++++++ mysql-test/t/view.test | 34 ++++++++++++++++++++++++++++++++ sql/sql_class.cc | 7 ++----- 4 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 mysql-test/std_data/bug48449.frm diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 10bbe3d9865..70580b82c93 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3854,6 +3854,30 @@ Note 1449 The user specified as a definer ('unknown'@'unknown') does not exist LOCK TABLES v1 READ; ERROR HY000: The user specified as a definer ('unknown'@'unknown') does not exist DROP VIEW v1; +# +# Bug#48449: hang on show create view after upgrading when +# view contains function of view +# +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +DROP FUNCTION IF EXISTS f1; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +CREATE FUNCTION f1() RETURNS INT +BEGIN +SELECT a FROM v2 INTO @a; +RETURN @a; +END// +# Trigger pre-locking when opening v2. +CREATE VIEW v1 AS SELECT f1() FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `f1`() AS `f1()` from `t1` latin1 latin1_swedish_ci +Warnings: +Note 1599 View `test`.`v2` has no creation context +DROP VIEW v1,v2; +DROP TABLE t1,t2; +DROP FUNCTION f1; # ----------------------------------------------------------------- # -- End of 5.1 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/std_data/bug48449.frm b/mysql-test/std_data/bug48449.frm new file mode 100644 index 00000000000..b6a717427aa --- /dev/null +++ b/mysql-test/std_data/bug48449.frm @@ -0,0 +1,12 @@ +TYPE=VIEW +query=select `test`.`t2`.`a` AS `a` from `test`.`t2` +md5=5e6eaf216e7b016fcedfd4e1113517af +updatable=1 +algorithm=0 +definer_user=root +definer_host=localhost +suid=2 +with_check_option=0 +timestamp=2010-01-01 15:00:00 +create-version=1 +source=select * from t2 diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index c0cdd40ddb6..01fa5bc53df 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3882,6 +3882,40 @@ CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; LOCK TABLES v1 READ; DROP VIEW v1; +--echo # +--echo # Bug#48449: hang on show create view after upgrading when +--echo # view contains function of view +--echo # + +--disable_warnings +DROP VIEW IF EXISTS v1,v2; +DROP TABLE IF EXISTS t1,t2; +DROP FUNCTION IF EXISTS f1; +--enable_warnings + +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); + +delimiter //; +CREATE FUNCTION f1() RETURNS INT +BEGIN + SELECT a FROM v2 INTO @a; + RETURN @a; +END// +delimiter ;// + +--echo # Trigger pre-locking when opening v2. +CREATE VIEW v1 AS SELECT f1() FROM t1; + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +copy_file std_data/bug48449.frm $MYSQLD_DATADIR/test/v2.frm; + +SHOW CREATE VIEW v1; + +DROP VIEW v1,v2; +DROP TABLE t1,t2; +DROP FUNCTION f1; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.1 tests. --echo # ----------------------------------------------------------------- diff --git a/sql/sql_class.cc b/sql/sql_class.cc index b22aa41b40a..673fc9b78e6 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -725,15 +725,12 @@ void THD::push_internal_handler(Internal_error_handler *handler) bool THD::handle_error(uint sql_errno, const char *message, MYSQL_ERROR::enum_warning_level level) { - if (!m_internal_handler) - return FALSE; - for (Internal_error_handler *error_handler= m_internal_handler; error_handler; - error_handler= m_internal_handler->m_prev_internal_handler) + error_handler= error_handler->m_prev_internal_handler) { if (error_handler->handle_error(sql_errno, message, level, this)) - return TRUE; + return TRUE; } return FALSE; From 5107f6b9b47e41c03d2c75f9d4d70b25dc0aab08 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 11 Feb 2010 19:41:53 +0200 Subject: [PATCH 12/96] Addendum to bug #46175 : use and check for the correct error values when converting to a enumerated type. --- sql/item.cc | 2 +- sql/sql_select.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index c967a1a0feb..df266434f72 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5157,7 +5157,7 @@ int Item::save_in_field(Field *field, bool no_conversions) field->set_notnull(); error=field->store(nr, unsigned_flag); } - return error ? error : (field->table->in_use->is_error() ? 2 : 0); + return error ? error : (field->table->in_use->is_error() ? 1 : 0); } diff --git a/sql/sql_select.h b/sql/sql_select.h index ef43f9b049c..8d3520bf9c8 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -736,10 +736,11 @@ public: we need to check for errors executing it and react accordingly */ if (!res && table->in_use->is_error()) - res= 2; + res= 1; /* STORE_KEY_FATAL */ dbug_tmp_restore_column_map(table->write_set, old_map); null_key= to_field->is_null() || item->null_value; - return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res); + return ((err != 0 || res < 0 || res > 2) ? STORE_KEY_FATAL : + (store_key_result) res); } }; @@ -775,10 +776,10 @@ protected: we need to check for errors executing it and react accordingly */ if (!err && to_field->table->in_use->is_error()) - err= 2; + err= 1; /* STORE_KEY_FATAL */ } null_key= to_field->is_null() || item->null_value; - return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err); + return ((err < 0 || err > 2) ? STORE_KEY_FATAL : (store_key_result) err); } }; From 0ee625fa1f2cbd9d26aa5945446102f7dd9ec7f3 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 12 Feb 2010 00:54:14 -0200 Subject: [PATCH 13/96] Move test case. Embedded server does not support privilege related bits. --- mysql-test/r/view.result | 10 ---------- mysql-test/r/view_grant.result | 11 +++++++++++ mysql-test/t/view.test | 13 ------------- mysql-test/t/view_grant.test | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 70580b82c93..11457e88eb7 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3845,16 +3845,6 @@ ALTER TABLE v1; DROP VIEW v1; DROP TABLE t1; # -# Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer -# -DROP VIEW IF EXISTS v1; -CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; -Warnings: -Note 1449 The user specified as a definer ('unknown'@'unknown') does not exist -LOCK TABLES v1 READ; -ERROR HY000: The user specified as a definer ('unknown'@'unknown') does not exist -DROP VIEW v1; -# # Bug#48449: hang on show create view after upgrading when # view contains function of view # diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 2d5c515d0b5..52c8bc8a3d5 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -1237,3 +1237,14 @@ SELECT a FROM v2; a DROP USER mysqluser1; DROP DATABASE mysqltest1; +USE test; +# +# Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer +# +DROP VIEW IF EXISTS v1; +CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; +Warnings: +Note 1449 The user specified as a definer ('unknown'@'unknown') does not exist +LOCK TABLES v1 READ; +ERROR HY000: The user specified as a definer ('unknown'@'unknown') does not exist +DROP VIEW v1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 01fa5bc53df..1165c68494b 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3869,19 +3869,6 @@ ALTER TABLE v1; DROP VIEW v1; DROP TABLE t1; ---echo # ---echo # Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer ---echo # - ---disable_warnings -DROP VIEW IF EXISTS v1; ---enable_warnings - -CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; ---error ER_NO_SUCH_USER -LOCK TABLES v1 READ; -DROP VIEW v1; - --echo # --echo # Bug#48449: hang on show create view after upgrading when --echo # view contains function of view diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index 175468db702..ba603bde7f8 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -1532,3 +1532,17 @@ SELECT a FROM v2; --disconnect mysqluser1 DROP USER mysqluser1; DROP DATABASE mysqltest1; +USE test; + +--echo # +--echo # Bug#47734: Assertion failed: ! is_set() when locking a view with non-existing definer +--echo # + +--disable_warnings +DROP VIEW IF EXISTS v1; +--enable_warnings + +CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; +--error ER_NO_SUCH_USER +LOCK TABLES v1 READ; +DROP VIEW v1; From 18303b70c6ea06292d1c3f604f1afdc722e85329 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 12 Feb 2010 13:44:20 +0400 Subject: [PATCH 14/96] Bug#48294 assertion when creating a view based on some row() construct in select query In case of 'CREATE VIEW' subselect transformation does not happen(see JOIN::prepare). During fix_fields Item_row may call is_null() method for its arugmens which leads to item calculation(wrong subselect in our case as transformation did not happen before). This is_null() call does not make sence for 'CREATE VIEW'. Note: Only Item_row is affected because other items don't call is_null() during fix_fields() for arguments. --- mysql-test/r/view.result | 6 ++++++ mysql-test/t/view.test | 13 +++++++++++++ sql/item_row.cc | 7 ++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 11457e88eb7..f12c9d6a31d 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3868,6 +3868,12 @@ Note 1599 View `test`.`v2` has no creation context DROP VIEW v1,v2; DROP TABLE t1,t2; DROP FUNCTION f1; +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (); +CREATE VIEW v1 AS SELECT 1 FROM t1 WHERE +ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' ))); +DROP VIEW v1; +DROP TABLE t1; # ----------------------------------------------------------------- # -- End of 5.1 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 1165c68494b..1d0796469f2 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3903,6 +3903,19 @@ DROP VIEW v1,v2; DROP TABLE t1,t2; DROP FUNCTION f1; + +# +# Bug#48294 assertion when creating a view based on some row() construct in select query +# +CREATE TABLE t1(f1 INT); +INSERT INTO t1 VALUES (); + +CREATE VIEW v1 AS SELECT 1 FROM t1 WHERE +ROW(1,1) >= ROW(1, (SELECT 1 FROM t1 WHERE f1 >= ANY ( SELECT '1' ))); + +DROP VIEW v1; +DROP TABLE t1; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.1 tests. --echo # ----------------------------------------------------------------- diff --git a/sql/item_row.cc b/sql/item_row.cc index 28de03bf049..29b37eb2bc0 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -71,7 +71,12 @@ bool Item_row::fix_fields(THD *thd, Item **ref) Item *item= *arg; used_tables_cache |= item->used_tables(); const_item_cache&= item->const_item() && !with_null; - if (const_item_cache) + /* + Some subqueries transformations aren't done in the view_prepare_mode thus + is_null() will fail. So we skip is_null() calculation for CREATE VIEW as + not necessary. + */ + if (const_item_cache && !thd->lex->view_prepare_mode) { if (item->cols() > 1) with_null|= item->null_inside(); From e766c177bbc67cabdc964917eb890094040e1f06 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 12 Feb 2010 15:28:38 +0400 Subject: [PATCH 15/96] BUG#48438 - crash with error in unioned query against merge table and view... Invalid memory reads after a query referencing MyISAM table multiple times with write lock. Invalid memory reads may lead to server crash, valgrind warnings, incorrect values in INFORMATION_SCHEMA.TABLES.{TABLE_ROWS, DATA_LENGTH, INDEX_LENGTH, ...}. This may happen when one of the table instances gets closed after a query, e.g. out of slots in open tables cache. UNION, MERGE and VIEW are irrelevant. The problem was that MyISAM didn't restore state info pointer to default value. --- myisam/mi_locking.c | 2 +- mysql-test/r/myisam.result | 13 +++++++++++++ mysql-test/t/myisam.test | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 42c21b915a5..b9a8e679fc0 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -306,8 +306,8 @@ void mi_update_status(void* param) (long) info->s->state.state.data_file_length)); #endif info->s->state.state= *info->state; - info->state= &info->s->state.state; } + info->state= &info->s->state.state; info->append_insert_at_end= 0; /* diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 9c8e5c2863d..49c09010c58 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1898,4 +1898,17 @@ CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 467455460 DROP TABLE t1; +# +# BUG#48438 - crash with error in unioned query against merge table and view... +# +SET GLOBAL table_cache=3; +CREATE TABLE t1(a INT); +SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4 FOR UPDATE; +1 +SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES +WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; +TABLE_ROWS DATA_LENGTH +0 0 +DROP TABLE t1; +SET GLOBAL table_cache=DEFAULT; End of 5.0 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index d0a480348a3..936c47a6d08 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1239,4 +1239,15 @@ CHECKSUM TABLE t1 EXTENDED; DROP TABLE t1; +--echo # +--echo # BUG#48438 - crash with error in unioned query against merge table and view... +--echo # +SET GLOBAL table_cache=3; +CREATE TABLE t1(a INT); +SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4 FOR UPDATE; +SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; +DROP TABLE t1; +SET GLOBAL table_cache=DEFAULT; + --echo End of 5.0 tests From 55a3e3a0b0fb37db51bad838e9cdf6f4c6b86bb4 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 12 Feb 2010 16:30:04 +0400 Subject: [PATCH 16/96] BUG#49628 - corrupt table after legal SQL, LONGTEXT column Bulk REPLACE or bulk INSERT ... ON DUPLICATE KEY UPDATE may break dynamic record MyISAM table. The problem is limited to bulk REPLACE and INSERT ... ON DUPLICATE KEY UPDATE, because only these operations may be done via UPDATE internally and may request write cache. When flushing write cache, MyISAM may write remaining cached data at wrong position. Fixed by requesting write cache to seek to a correct position. --- mysql-test/r/myisam.result | 13 +++++++++++++ mysql-test/t/myisam.test | 13 +++++++++++++ storage/myisam/mi_dynrec.c | 8 ++++++++ 3 files changed, 34 insertions(+) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index c68bc91aa41..15fce66cff1 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -2313,4 +2313,17 @@ CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; +# +# BUG#49628 - corrupt table after legal SQL, LONGTEXT column +# +CREATE TABLE t1(a INT, b LONGTEXT, UNIQUE(a)); +REPLACE INTO t1 VALUES +(1, REPEAT('a', 129015)),(1, NULL), +(2, NULL),(3, NULL),(4, NULL),(5, NULL),(6, NULL),(7, NULL), +(1, REPEAT('b', 129016)),(1, NULL), +(1, REPEAT('c', 129015)),(1, REPEAT('d', 129015)); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 351027ab246..568eadb5e39 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1563,5 +1563,18 @@ SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; CHECK TABLE t1; DROP TABLE t1; + +--echo # +--echo # BUG#49628 - corrupt table after legal SQL, LONGTEXT column +--echo # +CREATE TABLE t1(a INT, b LONGTEXT, UNIQUE(a)); +REPLACE INTO t1 VALUES +(1, REPEAT('a', 129015)),(1, NULL), +(2, NULL),(3, NULL),(4, NULL),(5, NULL),(6, NULL),(7, NULL), +(1, REPEAT('b', 129016)),(1, NULL), +(1, REPEAT('c', 129015)),(1, REPEAT('d', 129015)); +CHECK TABLE t1; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 696b9ff93df..6518d874f4f 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -933,8 +933,16 @@ static int update_dynamic_record(MI_INFO *info, my_off_t filepos, uchar *record, } if (block_info.next_filepos != HA_OFFSET_ERROR) + { + /* + delete_dynamic_record() may change data file position. + IO cache must be notified as it may still have cached + data, which has to be flushed later. + */ + info->rec_cache.seek_not_done= 1; if (delete_dynamic_record(info,block_info.next_filepos,1)) goto err; + } DBUG_RETURN(0); err: DBUG_RETURN(1); From d605ba0306acb5a3d7c361167c6f8290a7a8542c Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 12 Feb 2010 16:33:03 +0400 Subject: [PATCH 17/96] BUG#48757 - missing .ARZ file causes server crash Server crashes when accessing ARCHIVE table with missing .ARZ file. When opening a table, ARCHIVE didn't properly pass through error code from lower level azopen() to higher level open() method. --- mysql-test/r/archive.result | 9 +++++++++ mysql-test/t/archive.test | 11 +++++++++++ storage/archive/ha_archive.cc | 21 +++++++++++++-------- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index c620eb97cab..f14f6a39386 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -12728,3 +12728,12 @@ Table Op Msg_type Msg_text test.t1 repair Error Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it! test.t1 repair error Corrupt DROP TABLE t1; +# +# BUG#48757 - missing .ARZ file causes server crash +# +CREATE TABLE t1(a INT) ENGINE=ARCHIVE; +FLUSH TABLE t1; +SELECT * FROM t1; +ERROR HY000: Can't find file: 't1' (errno: 2) +DROP TABLE t1; +ERROR 42S02: Unknown table 't1' diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 90f5b1b0b53..67ad0517ed2 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1644,3 +1644,14 @@ INSERT INTO t1 (col1, col2) VALUES (1, "value"); REPAIR TABLE t1; DROP TABLE t1; remove_file $MYSQLD_DATADIR/test/t1.ARM; + +--echo # +--echo # BUG#48757 - missing .ARZ file causes server crash +--echo # +CREATE TABLE t1(a INT) ENGINE=ARCHIVE; +FLUSH TABLE t1; +--remove_file $MYSQLD_DATADIR/test/t1.ARZ +--error ER_FILE_NOT_FOUND +SELECT * FROM t1; +--error ER_BAD_TABLE_ERROR +DROP TABLE t1; diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 42ff9daa77e..364ffba0f6c 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -355,6 +355,9 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) */ if (!(azopen(&archive_tmp, share->data_file_name, O_RDONLY|O_BINARY))) { + *rc= my_errno ? my_errno : -1; + pthread_mutex_unlock(&archive_mutex); + my_free(share, MYF(0)); DBUG_RETURN(NULL); } stats.auto_increment_value= archive_tmp.auto_increment + 1; @@ -504,16 +507,18 @@ int ha_archive::open(const char *name, int mode, uint open_options) For now we have to refuse to open such table to avoid potential data loss. */ - if ((rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR)) - || rc == HA_ERR_TABLE_NEEDS_UPGRADE) + switch (rc) { - /* purecov: begin inspected */ + case 0: + break; + case HA_ERR_CRASHED_ON_USAGE: + if (open_options & HA_OPEN_FOR_REPAIR) + break; + /* fall through */ + case HA_ERR_TABLE_NEEDS_UPGRADE: free_share(); - DBUG_RETURN(rc); - /* purecov: end */ - } - else if (rc == HA_ERR_OUT_OF_MEM) - { + /* fall through */ + default: DBUG_RETURN(rc); } From d7797f51ecb1c841ba0779887bfc04a873be3a34 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Thu, 28 Jan 2010 12:41:14 -0200 Subject: [PATCH 18/96] Bug#50423: Crash on second call of a procedure dropping a trigger The problem was that a DROP TRIGGER statement inside a stored procedure could cause a crash in subsequent invocations. This was due to the addition, on the first execution, of a temporary table reference to the stored procedure query table list. In a subsequent invocation, there would be a attempt to reinitialize the temporary table reference, which by then was already gone. The solution is to backup and reset the query table list each time a trigger needs to be dropped. This ensures that any temp changes to the query table list are discarded. It is safe to do so at this time as drop trigger is restricted from more complicated scenarios (ie, not allowed within stored functions, etc). --- mysql-test/r/sp-bugs.result | 15 +++++++++++++++ mysql-test/t/sp-bugs.test | 22 ++++++++++++++++++++++ sql/sql_trigger.cc | 15 +++++++++++---- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/sp-bugs.result b/mysql-test/r/sp-bugs.result index 14c5311bbe5..38ddab52b8a 100644 --- a/mysql-test/r/sp-bugs.result +++ b/mysql-test/r/sp-bugs.result @@ -44,4 +44,19 @@ SELECT f2 (); f2 () NULL DROP SCHEMA testdb; +USE test; +# +# Bug#50423: Crash on second call of a procedure dropping a trigger +# +DROP TABLE IF EXISTS t1; +DROP TRIGGER IF EXISTS tr1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1 (f1 INTEGER); +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1; +CREATE PROCEDURE p1 () DROP TRIGGER tr1; +CALL p1 (); +CALL p1 (); +ERROR HY000: Trigger does not exist +DROP TABLE t1; +DROP PROCEDURE p1; End of 5.1 tests diff --git a/mysql-test/t/sp-bugs.test b/mysql-test/t/sp-bugs.test index 7b94e65a5e9..1eb283f7874 100644 --- a/mysql-test/t/sp-bugs.test +++ b/mysql-test/t/sp-bugs.test @@ -57,5 +57,27 @@ SELECT f2 (); DROP SCHEMA testdb; +USE test; + +--echo # +--echo # Bug#50423: Crash on second call of a procedure dropping a trigger +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TRIGGER IF EXISTS tr1; +DROP PROCEDURE IF EXISTS p1; +--enable_warnings + +CREATE TABLE t1 (f1 INTEGER); +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1; +CREATE PROCEDURE p1 () DROP TRIGGER tr1; + +CALL p1 (); +--error ER_TRG_DOES_NOT_EXIST +CALL p1 (); + +DROP TABLE t1; +DROP PROCEDURE p1; --echo End of 5.1 tests diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index ba0515d38ad..aafb25013f6 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -327,6 +327,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) TABLE *table; bool result= TRUE; String stmt_query; + Query_tables_list backup; bool need_start_waiting= FALSE; DBUG_ENTER("mysql_create_or_drop_trigger"); @@ -393,6 +394,12 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) { bool if_exists= thd->lex->drop_if_exists; + /* + Protect the query table list from the temporary and potentially + destructive changes necessary to open the trigger's table. + */ + thd->lex->reset_n_backup_query_tables_list(&backup); + if (add_table_for_trigger(thd, thd->lex->spname, if_exists, & tables)) goto end; @@ -512,6 +519,10 @@ end: VOID(pthread_mutex_unlock(&LOCK_open)); + /* Restore the query table list. Used only for drop trigger. */ + if (!create) + thd->lex->restore_backup_query_tables_list(&backup); + if (need_start_waiting) start_waiting_global_read_lock(thd); @@ -1625,10 +1636,6 @@ bool add_table_for_trigger(THD *thd, if (load_table_name_for_trigger(thd, trg_name, &trn_path, &tbl_name)) DBUG_RETURN(TRUE); - /* We need to reset statement table list to be PS/SP friendly. */ - lex->query_tables= 0; - lex->query_tables_last= &lex->query_tables; - *table= sp_add_to_query_tables(thd, lex, trg_name->m_db.str, tbl_name.str, TL_IGNORE); From 82b30bbed513f1fcd7b3ef805bda2f053280f456 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 5 Feb 2010 10:55:20 -0200 Subject: [PATCH 19/96] Bug#49025: mysqld-debug: missing DBUG_RETURN or DBUG_VOID_RETURN macro in function "?func" The problem was that the dbug facility was being used after the per-thread dbug state had already been finalized. The was present in a few functions which invoked decrement_handler_count, which in turn invokes my_thread_end on Windows. In my_thread_end, the per-thread dbug state is finalized. Any use after the state is finalized ends up creating a new state. The solution is to process the exit of a function before the decrement_handler_count function is called. --- sql/mysqld.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7c45fda1e02..a483b9e2381 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5213,9 +5213,9 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused))) create_new_thread(thd); } - + DBUG_LEAVE; decrement_handler_count(); - DBUG_RETURN(0); + return 0; } @@ -5311,8 +5311,9 @@ pthread_handler_t handle_connections_namedpipes(void *arg) create_new_thread(thd); } CloseHandle(connectOverlapped.hEvent); + DBUG_LEAVE; decrement_handler_count(); - DBUG_RETURN(0); + return 0; } #endif /* __NT__ */ @@ -5548,9 +5549,9 @@ error: if (handle_connect_file_map) CloseHandle(handle_connect_file_map); if (event_connect_answer) CloseHandle(event_connect_answer); if (smem_event_connect_request) CloseHandle(smem_event_connect_request); - + DBUG_LEAVE; decrement_handler_count(); - DBUG_RETURN(0); + return 0; } #endif /* HAVE_SMEM */ #endif /* EMBEDDED_LIBRARY */ From f11861c284aa60379e91d1c147b711220326726e Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 29 Jan 2010 17:04:37 +0200 Subject: [PATCH 20/96] Bug #49324: more valgrind errors in test_if_skip_sort_order Fixed 2 problems : 1. test_if_order_by_key() was continuing on the primary key as if it has a primary key suffix (as the secondary keys do). This leads to crashes in ORDER BY ,. Fixed by not treating the primary key as the secondary one and not depending on it being clustered with a primary key. 2. The cost calculation was trying to read the records per key when operating on ORDER BYs that order on all of the secondary key + some of the primary key. This leads to crashes because of out-of-bounds array access. Fixed by assuming we'll find 1 record per key in such cases. --- mysql-test/r/innodb_mysql.result | 8 ++++++++ mysql-test/t/innodb_mysql.test | 10 ++++++++++ sql/sql_select.cc | 22 +++++++++++++++------- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 402ab3c1b16..b54fb90b412 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -2273,4 +2273,12 @@ END| DROP PROCEDURE p1; DROP VIEW v1; DROP TABLE t1,t2; +# +# Bug #49324: more valgrind errors in test_if_skip_sort_order +# +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; +#should not cause valgrind warnings +SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; +1 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index a2a1113598d..d9fecccfbdc 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -536,4 +536,14 @@ DROP PROCEDURE p1; DROP VIEW v1; DROP TABLE t1,t2; + +--echo # +--echo # Bug #49324: more valgrind errors in test_if_skip_sort_order +--echo # +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; +--echo #should not cause valgrind warnings +SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; +DROP TABLE t1; + + --echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bdd139edafc..8744f77d6b1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12813,7 +12813,7 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx, key_part_end=key_part+table->key_info[idx].key_parts; key_part_map const_key_parts=table->const_key_parts[idx]; int reverse=0; - my_bool on_primary_key= FALSE; + my_bool on_pk_suffix= FALSE; DBUG_ENTER("test_if_order_by_key"); for (; order ; order=order->next, const_key_parts>>=1) @@ -12835,11 +12835,12 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx, key as a suffix to the secondary keys. If it has continue to check the primary key as a suffix. */ - if (!on_primary_key && + if (!on_pk_suffix && (table->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) && - table->s->primary_key != MAX_KEY) + table->s->primary_key != MAX_KEY && + table->s->primary_key != idx) { - on_primary_key= TRUE; + on_pk_suffix= TRUE; key_part= table->key_info[table->s->primary_key].key_part; key_part_end=key_part+table->key_info[table->s->primary_key].key_parts; const_key_parts=table->const_key_parts[table->s->primary_key]; @@ -12871,7 +12872,7 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx, reverse=flag; // Remember if reverse key_part++; } - if (on_primary_key) + if (on_pk_suffix) { uint used_key_parts_secondary= table->key_info[idx].key_parts; uint used_key_parts_pk= @@ -13360,8 +13361,15 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, select_limit= table_records; if (group) { - rec_per_key= used_key_parts ? keyinfo->rec_per_key[used_key_parts-1] - : 1; + /* + Used_key_parts can be larger than keyinfo->key_parts + when using a secondary index clustered with a primary + key (e.g. as in Innodb). + See Bug #28591 for details. + */ + rec_per_key= used_key_parts && + used_key_parts <= keyinfo->key_parts ? + keyinfo->rec_per_key[used_key_parts-1] : 1; set_if_bigger(rec_per_key, 1); /* With a grouping query each group containing on average From 54c076e98471b2593c16e15c6aa8779f5962ed85 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 1 Feb 2010 16:07:00 +0100 Subject: [PATCH 21/96] Bug#42438: Crash ha_partition::change_table_ptr There was two problems: The first was the symptom, caused by bad error handling in ha_partition. It did not handle print_error etc. when having no partitions (when used by dummy handler). The second was the real problem that when dropping tables it reused the table type (storage engine) from when the lock was asked for, not the table type that it had when gaining the exclusive name lock. So that it tried to delete tables from wrong storage engines. Solutions for the first problem was to accept some handler calls to the partitioning handler even if it was not setup with any partitions, and also if possible fallback to use the base handler's default functions. Solution for the second problem was to remove the optimization to reuse the definition from the cache, instead always check the frm-file when holding the LOCK_open mutex (updated with a fix for a debug print crash and better comments as required by reviewer, and removed optimization to avoid reading the frm-file). --- mysql-test/r/partition_debug_sync.result | 57 +++++++++++++++++ mysql-test/t/partition_debug_sync.test | 81 ++++++++++++++++++++++++ sql/ha_partition.cc | 33 ++++++++-- sql/sql_base.cc | 1 + sql/sql_table.cc | 63 +++++++++--------- 5 files changed, 198 insertions(+), 37 deletions(-) create mode 100644 mysql-test/r/partition_debug_sync.result create mode 100644 mysql-test/t/partition_debug_sync.test diff --git a/mysql-test/r/partition_debug_sync.result b/mysql-test/r/partition_debug_sync.result new file mode 100644 index 00000000000..5eb19f42395 --- /dev/null +++ b/mysql-test/r/partition_debug_sync.result @@ -0,0 +1,57 @@ +DROP TABLE IF EXISTS t1, t2; +SET DEBUG_SYNC= 'RESET'; +# +# Bug#42438: Crash ha_partition::change_table_ptr +# Test when remove partitioning is done while drop table is waiting +# for the table. +# Con 1 +SET DEBUG_SYNC= 'RESET'; +CREATE TABLE t1 +(a INTEGER, +b INTEGER NOT NULL, +KEY (b)) +ENGINE = MYISAM +/*!50100 PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (2), +PARTITION p1 VALUES LESS THAN (20), +PARTITION p2 VALUES LESS THAN (100), +PARTITION p3 VALUES LESS THAN MAXVALUE ) */; +SET DEBUG_SYNC= 'alter_table_before_create_table_no_lock SIGNAL removing_partitioning WAIT_FOR waiting_for_alter'; +SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL partitioning_removed'; +ALTER TABLE t1 REMOVE PARTITIONING; +# Con default +SET DEBUG_SYNC= 'now WAIT_FOR removing_partitioning'; +SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter'; +SET DEBUG_SYNC= 'rm_table_part2_before_delete_table WAIT_FOR partitioning_removed'; +DROP TABLE IF EXISTS t1; +# Con 1 +SET DEBUG_SYNC= 'RESET'; +SET DEBUG_SYNC= 'RESET'; +# +# Bug#42438: Crash ha_partition::change_table_ptr +# Test when remove partitioning is failing due to drop table is already +# in progress. +CREATE TABLE t2 +(a INTEGER, +b INTEGER NOT NULL, +KEY (b)) +ENGINE = MYISAM +/*!50100 PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (2), +PARTITION p1 VALUES LESS THAN (20), +PARTITION p2 VALUES LESS THAN (100), +PARTITION p3 VALUES LESS THAN MAXVALUE ) */; +SET DEBUG_SYNC= 'before_lock_tables_takes_lock SIGNAL removing_partitions WAIT_FOR waiting_for_alter'; +SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done'; +ALTER TABLE t2 REMOVE PARTITIONING; +# Con default +SET DEBUG_SYNC= 'now WAIT_FOR removing_partitions'; +SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter'; +SET DEBUG_SYNC= 'rm_table_part2_before_binlog SIGNAL delete_done'; +DROP TABLE IF EXISTS t2; +# Con 1 +ERROR 42S02: Table 'test.t2' doesn't exist +SET DEBUG_SYNC= 'RESET'; +# Con default +SET DEBUG_SYNC= 'RESET'; +End of 5.1 tests diff --git a/mysql-test/t/partition_debug_sync.test b/mysql-test/t/partition_debug_sync.test new file mode 100644 index 00000000000..69bc86a8bb7 --- /dev/null +++ b/mysql-test/t/partition_debug_sync.test @@ -0,0 +1,81 @@ +#--disable_abort_on_error +# +# Test for the partition storage engine which require DEBUG_SYNC feature to +# Created by Mattias Jonsson +# +--source include/have_partition.inc +--source include/have_debug_sync.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +SET DEBUG_SYNC= 'RESET'; +--enable_warnings + +--echo # +--echo # Bug#42438: Crash ha_partition::change_table_ptr +--echo # Test when remove partitioning is done while drop table is waiting +--echo # for the table. +connect(con1, localhost, root,,); +--echo # Con 1 +SET DEBUG_SYNC= 'RESET'; +CREATE TABLE t1 +(a INTEGER, + b INTEGER NOT NULL, + KEY (b)) +ENGINE = MYISAM +/*!50100 PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (2), + PARTITION p1 VALUES LESS THAN (20), + PARTITION p2 VALUES LESS THAN (100), + PARTITION p3 VALUES LESS THAN MAXVALUE ) */; +SET DEBUG_SYNC= 'alter_table_before_create_table_no_lock SIGNAL removing_partitioning WAIT_FOR waiting_for_alter'; +SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL partitioning_removed'; +--send ALTER TABLE t1 REMOVE PARTITIONING +connection default; +--echo # Con default +SET DEBUG_SYNC= 'now WAIT_FOR removing_partitioning'; +SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter'; +SET DEBUG_SYNC= 'rm_table_part2_before_delete_table WAIT_FOR partitioning_removed'; +DROP TABLE IF EXISTS t1; +--echo # Con 1 +connection con1; +--reap +connection default; +SET DEBUG_SYNC= 'RESET'; +connection con1; +SET DEBUG_SYNC= 'RESET'; + +--echo # +--echo # Bug#42438: Crash ha_partition::change_table_ptr +--echo # Test when remove partitioning is failing due to drop table is already +--echo # in progress. +CREATE TABLE t2 +(a INTEGER, + b INTEGER NOT NULL, + KEY (b)) +ENGINE = MYISAM +/*!50100 PARTITION BY RANGE (a) +(PARTITION p0 VALUES LESS THAN (2), + PARTITION p1 VALUES LESS THAN (20), + PARTITION p2 VALUES LESS THAN (100), + PARTITION p3 VALUES LESS THAN MAXVALUE ) */; +SET DEBUG_SYNC= 'before_lock_tables_takes_lock SIGNAL removing_partitions WAIT_FOR waiting_for_alter'; +SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done'; +--send ALTER TABLE t2 REMOVE PARTITIONING +connection default; +--echo # Con default +SET DEBUG_SYNC= 'now WAIT_FOR removing_partitions'; +SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter'; +SET DEBUG_SYNC= 'rm_table_part2_before_binlog SIGNAL delete_done'; +DROP TABLE IF EXISTS t2; +--echo # Con 1 +connection con1; +--error ER_NO_SUCH_TABLE +--reap +SET DEBUG_SYNC= 'RESET'; +disconnect con1; +connection default; +--echo # Con default +SET DEBUG_SYNC= 'RESET'; + +--echo End of 5.1 tests diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 451631ff373..099b663f5c2 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1719,13 +1719,23 @@ void ha_partition::update_create_info(HA_CREATE_INFO *create_info) void ha_partition::change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) { - handler **file_array= m_file; + handler **file_array; table= table_arg; table_share= share; - do + /* + m_file can be NULL when using an old cached table in DROP TABLE, when the + table just has REMOVED PARTITIONING, see Bug#42438 + */ + if (m_file) { - (*file_array)->change_table_ptr(table_arg, share); - } while (*(++file_array)); + file_array= m_file; + DBUG_ASSERT(*file_array); + do + { + (*file_array)->change_table_ptr(table_arg, share); + } while (*(++file_array)); + } + if (m_added_file && m_added_file[0]) { /* if in middle of a drop/rename etc */ @@ -5986,7 +5996,13 @@ void ha_partition::print_error(int error, myf errflag) if (error == HA_ERR_NO_PARTITION_FOUND) m_part_info->print_no_partition_found(table); else - m_file[m_last_part]->print_error(error, errflag); + { + /* In case m_file has not been initialized, like in bug#42438 */ + if (m_file) + m_file[m_last_part]->print_error(error, errflag); + else + handler::print_error(error, errflag); + } DBUG_VOID_RETURN; } @@ -5996,7 +6012,12 @@ bool ha_partition::get_error_message(int error, String *buf) DBUG_ENTER("ha_partition::get_error_message"); /* Should probably look for my own errors first */ - DBUG_RETURN(m_file[m_last_part]->get_error_message(error, buf)); + + /* In case m_file has not been initialized, like in bug#42438 */ + if (m_file) + DBUG_RETURN(m_file[m_last_part]->get_error_message(error, buf)); + DBUG_RETURN(handler::get_error_message(error, buf)); + } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index cf8a0b32764..b13a067bfd7 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2165,6 +2165,7 @@ void wait_for_condition(THD *thd, pthread_mutex_t *mutex, pthread_cond_t *cond) proc_info=thd->proc_info; thd_proc_info(thd, "Waiting for table"); DBUG_ENTER("wait_for_condition"); + DEBUG_SYNC(thd, "waiting_for_table"); if (!thd->killed) (void) pthread_cond_wait(cond, mutex); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 869ae42c98c..5097c0b4945 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -22,6 +22,9 @@ #include "sp_head.h" #include "sql_trigger.h" #include "sql_show.h" +#if defined(ENABLED_DEBUG_SYNC) +#include "debug_sync.h" +#endif #ifdef __WIN__ #include @@ -1870,30 +1873,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, pthread_mutex_lock(&LOCK_open); - /* - If we have the table in the definition cache, we don't have to check the - .frm file to find if the table is a normal table (not view) and what - engine to use. - */ - - for (table= tables; table; table= table->next_local) - { - TABLE_SHARE *share; - table->db_type= NULL; - if ((share= get_cached_table_share(table->db, table->table_name))) - table->db_type= share->db_type(); - - /* Disable drop of enabled log tables */ - if (share && (share->table_category == TABLE_CATEGORY_PERFORMANCE) && - check_if_log_table(table->db_length, table->db, - table->table_name_length, table->table_name, 1)) - { - my_error(ER_BAD_LOG_STATEMENT, MYF(0), "DROP"); - pthread_mutex_unlock(&LOCK_open); - DBUG_RETURN(1); - } - } - if (!drop_temporary && lock_table_names_exclusively(thd, tables)) { pthread_mutex_unlock(&LOCK_open); @@ -1904,7 +1883,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, { char *db=table->db; handlerton *table_type; - enum legacy_db_type frm_db_type; + enum legacy_db_type frm_db_type= DB_TYPE_UNKNOWN; DBUG_PRINT("table", ("table_l: '%s'.'%s' table: 0x%lx s: 0x%lx", table->db, table->table_name, (long) table->table, @@ -1945,6 +1924,15 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, error= 0; } + /* Disable drop of enabled log tables */ + if (check_if_log_table(table->db_length, table->db, + table->table_name_length, table->table_name, 1)) + { + my_error(ER_BAD_LOG_STATEMENT, MYF(0), "DROP"); + pthread_mutex_unlock(&LOCK_open); + DBUG_RETURN(1); + } + /* If row-based replication is used and the table is not a temporary table, we add the table name to the drop statement @@ -1969,7 +1957,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, built_query.append("`,"); } - table_type= table->db_type; if (!drop_temporary) { TABLE *locked_table; @@ -1996,9 +1983,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, table->internal_tmp_table ? FN_IS_TMP : 0); } + DEBUG_SYNC(thd, "rm_table_part2_before_delete_table"); if (drop_temporary || - ((table_type == NULL && - access(path, F_OK) && + ((access(path, F_OK) && ha_create_table_from_engine(thd, db, alias)) || (!drop_view && mysql_frm_type(thd, path, &frm_db_type) != FRMTYPE_TABLE))) @@ -2014,15 +2001,25 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, else { char *end; - if (table_type == NULL) + /* + Cannot use the db_type from the table, since that might have changed + while waiting for the exclusive name lock. We are under LOCK_open, + so reading from the frm-file is safe. + */ + if (frm_db_type == DB_TYPE_UNKNOWN) { - mysql_frm_type(thd, path, &frm_db_type); - table_type= ha_resolve_by_legacy_type(thd, frm_db_type); + mysql_frm_type(thd, path, &frm_db_type); + DBUG_PRINT("info", ("frm_db_type %d from %s", frm_db_type, path)); } + table_type= ha_resolve_by_legacy_type(thd, frm_db_type); // Remove extension for delete *(end= path + path_length - reg_ext_length)= '\0'; + DBUG_PRINT("info", ("deleting table of type %d", + (table_type ? table_type->db_type : 0))); error= ha_delete_table(thd, table_type, path, db, table->table_name, !dont_log_query); + + /* No error if non existent table and 'IF EXIST' clause or view */ if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && (if_exists || table_type == NULL)) { @@ -2062,6 +2059,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, on the table name. */ pthread_mutex_unlock(&LOCK_open); + DEBUG_SYNC(thd, "rm_table_part2_before_binlog"); thd->thread_specific_used|= tmp_table_deleted; error= 0; if (wrong_tables.length()) @@ -7097,6 +7095,7 @@ view_err: else create_info->data_file_name=create_info->index_file_name=0; + DEBUG_SYNC(thd, "alter_table_before_create_table_no_lock"); /* Create a table with a temporary name. With create_info->frm_only == 1 this creates a .frm file only. @@ -7296,6 +7295,7 @@ view_err: intern_close_table(new_table); my_free(new_table,MYF(0)); } + DEBUG_SYNC(thd, "alter_table_before_rename_result_table"); VOID(pthread_mutex_lock(&LOCK_open)); if (error) { @@ -7438,6 +7438,7 @@ view_err: thd_proc_info(thd, "end"); DBUG_EXECUTE_IF("sleep_alter_before_main_binlog", my_sleep(6000000);); + DEBUG_SYNC(thd, "alter_table_before_main_binlog"); ha_binlog_log_query(thd, create_info->db_type, LOGCOM_ALTER_TABLE, thd->query(), thd->query_length(), From 37934f862ec7952f6baeb5c5c323e37b151aa298 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 2 Feb 2010 15:08:49 +0400 Subject: [PATCH 22/96] BUG#50351 - ft_min_word_len=2 Causes query to hang Performing fulltext prefix search (a word with truncation operator) may cause a dead-loop. ft_min_word_len value doesn't matter actually. The problem was introduced along with "smarter index merge" optimization. --- mysql-test/r/fulltext.result | 20 ++++++++++++++++++++ mysql-test/t/fulltext.test | 21 +++++++++++++++++++++ storage/myisam/ft_boolean_search.c | 12 +++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 1ef6656e7a4..cebe2ee4746 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -603,4 +603,24 @@ WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE) count(*) 0 DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a VARCHAR(4), FULLTEXT(a)); +INSERT INTO t1 VALUES +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('awrd'),('cwrd'), +('awrd'); +SELECT COUNT(*) FROM t1 WHERE MATCH(a) AGAINST("+awrd bwrd* +cwrd*" IN BOOLEAN MODE); +COUNT(*) +0 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 3853a224fd5..705d6478fed 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -544,5 +544,26 @@ SELECT count(*) FROM t1 WHERE DROP TABLE t1,t2,t3; +# +# BUG#50351 - ft_min_word_len=2 Causes query to hang +# +CREATE TABLE t1 (a VARCHAR(4), FULLTEXT(a)); +INSERT INTO t1 VALUES +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('awrd'),('cwrd'), +('awrd'); +SELECT COUNT(*) FROM t1 WHERE MATCH(a) AGAINST("+awrd bwrd* +cwrd*" IN BOOLEAN MODE); +DROP TABLE t1; --echo End of 5.1 tests diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 492261c5efc..52ad6b11aa1 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -437,8 +437,18 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) return 0; } - /* going up to the first-level tree to continue search there */ + /* + Going up to the first-level tree to continue search there. + Only done when performing prefix search. + + Key buffer data pointer as well as docid[0] may be smaller + than values we got while searching first-level tree. Thus + they must be restored to original values to avoid dead-loop, + when subsequent search for a bigger value eventually ends up + in this same second-level tree. + */ _mi_dpointer(info, (uchar*) (lastkey_buf+HA_FT_WLEN), ftbw->key_root); + ftbw->docid[0]= ftbw->key_root; ftbw->key_root=info->s->state.key_root[ftb->keynr]; ftbw->keyinfo=info->s->keyinfo+ftb->keynr; ftbw->off=0; From 31bd845f42e5881f91334572a61782778f1c196c Mon Sep 17 00:00:00 2001 From: "sunanda.menon@sun.com" <> Date: Tue, 2 Feb 2010 13:09:05 +0100 Subject: [PATCH 23/96] Set version number for mysql-5.0.87sp1 release --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index f2d95ff826c..a68193588d3 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.87) +AM_INIT_AUTOMAKE(mysql, 5.0.87sp1) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 From f448c14b83fccdbfa244654d753eb25d428d541e Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:23:26 +0100 Subject: [PATCH 24/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.4 > revision-id: ramil@mysql.com-20091021090408-208mvwwrcroi2j8c > parent: azundris@mysql.com-20091021033856-ydodp4q42o58e7ka > committer: Ramil Kalimullin > branch nick: b47019-5.0-bugteam > timestamp: Wed 2009-10-21 14:04:08 +0500 > message: > Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c, > line 138 when forcing a spatial index > > Problem: "Spatial indexes can be involved in the search > for queries that use a function such as MBRContains() > or MBRWithin() in the WHERE clause". > Using spatial indexes for JOINs with =, <=> etc. > predicates is incorrect. > > Fix: disable spatial indexes for such queries. --- mysql-test/r/select.result | 29 +++++++++++++++++++++++++++++ mysql-test/t/select.test | 16 ++++++++++++++++ sql/sql_select.cc | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index c9dd65108da..4bb62fbfa70 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4401,4 +4401,33 @@ id select_type table type possible_keys key key_len ref rows Extra Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 DROP TABLE t1; +# +# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +# forcing a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 +1 SIMPLE t2 ALL a NULL NULL NULL 2 +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +1 +1 +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 +1 SIMPLE t2 ALL a NULL NULL NULL 2 +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +1 +1 +1 +1 +1 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 60f2f191e0b..d57163dfef6 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3750,5 +3750,21 @@ EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; DROP TABLE t1; + + +--echo # +--echo # Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when +--echo # forcing a spatial index +--echo # +CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a)); +INSERT INTO t1 VALUES + (GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), + (GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2; +EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 76d6833de5c..3bf67299d58 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3447,7 +3447,7 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field) { if (!(form->keys_in_use_for_query.is_set(key))) continue; - if (form->key_info[key].flags & HA_FULLTEXT) + if (form->key_info[key].flags & (HA_FULLTEXT | HA_SPATIAL)) continue; // ToDo: ft-keys in non-ft queries. SerG uint key_parts= (uint) form->key_info[key].key_parts; From a0336e90dcbf033ce041d9a132f4b0d6448c63ea Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:25:25 +0100 Subject: [PATCH 25/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.5 > revision-id: ramil@mysql.com-20091023112648-gie6o3odj57cxh1e > parent: ramil@mysql.com-20091021090408-208mvwwrcroi2j8c > committer: Ramil Kalimullin > branch nick: b48258-5.0-bugteam > timestamp: Fri 2009-10-23 16:26:48 +0500 > message: > Fix for bug#48258: Assertion failed when using a spatial index > > Problem: involving a spatial index for "non-spatial" queries > (that don't containt MBRXXX() functions) may lead to failed assert. > > Fix: don't use spatial indexes in such cases. --- mysql-test/r/gis-rtree.result | 39 +++++++++++++++++++++++++++++++++++ mysql-test/t/gis-rtree.test | 21 +++++++++++++++++++ sql/opt_range.cc | 21 +++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index a4fa929c32e..165db882892 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -1487,4 +1487,43 @@ MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') ); COUNT(*) 2 DROP TABLE t1; +# +# Bug #48258: Assertion failed when using a spatial index +# +CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a)); +INSERT INTO t1 VALUES +(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), +(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 WHERE a = GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 2 Using where +SELECT 1 FROM t1 WHERE a = GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE a < GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 2 Using where +SELECT 1 FROM t1 WHERE a < GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +1 +EXPLAIN SELECT 1 FROM t1 WHERE a <= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 2 Using where +SELECT 1 FROM t1 WHERE a <= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +1 +1 +1 +EXPLAIN SELECT 1 FROM t1 WHERE a > GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 2 Using where +SELECT 1 FROM t1 WHERE a > GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +1 +EXPLAIN SELECT 1 FROM t1 WHERE a >= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 2 Using where +SELECT 1 FROM t1 WHERE a >= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +1 +1 +1 +DROP TABLE t1; End of 5.0 tests. diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index 2c1632f8d40..b5de1ccf248 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -881,4 +881,25 @@ SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE DROP TABLE t1; + +--echo # +--echo # Bug #48258: Assertion failed when using a spatial index +--echo # +CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a)); +INSERT INTO t1 VALUES + (GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')), + (GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')); +EXPLAIN SELECT 1 FROM t1 WHERE a = GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +SELECT 1 FROM t1 WHERE a = GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +EXPLAIN SELECT 1 FROM t1 WHERE a < GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +SELECT 1 FROM t1 WHERE a < GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +EXPLAIN SELECT 1 FROM t1 WHERE a <= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +SELECT 1 FROM t1 WHERE a <= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +EXPLAIN SELECT 1 FROM t1 WHERE a > GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +SELECT 1 FROM t1 WHERE a > GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +EXPLAIN SELECT 1 FROM t1 WHERE a >= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +SELECT 1 FROM t1 WHERE a >= GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'); +DROP TABLE t1; + + --echo End of 5.0 tests. diff --git a/sql/opt_range.cc b/sql/opt_range.cc index fdf6cc03a44..c882437e6ae 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -4377,6 +4377,27 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, !(conf_func->compare_collation()->state & MY_CS_BINSORT)) goto end; + if (key_part->image_type == Field::itMBR) + { + switch (type) { + case Item_func::SP_EQUALS_FUNC: + case Item_func::SP_DISJOINT_FUNC: + case Item_func::SP_INTERSECTS_FUNC: + case Item_func::SP_TOUCHES_FUNC: + case Item_func::SP_CROSSES_FUNC: + case Item_func::SP_WITHIN_FUNC: + case Item_func::SP_CONTAINS_FUNC: + case Item_func::SP_OVERLAPS_FUNC: + break; + default: + /* + We cannot involve spatial indexes for queries that + don't use MBREQUALS(), MBRDISJOINT(), etc. functions. + */ + goto end; + } + } + optimize_range= field->optimize_range(param->real_keynr[key_part->key], key_part->part); From 0c4a2e9ca0349c344cff7f9901566f4d07d8a5b7 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:26:24 +0100 Subject: [PATCH 26/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.6 > revision-id: joro@sun.com-20091021084345-iki6z0uceieoupey > parent: ramil@mysql.com-20091023112648-gie6o3odj57cxh1e > committer: Georgi Kodinov > branch nick: B47780-5.0-bugteam > timestamp: Wed 2009-10-21 11:43:45 +0300 > message: > Bug #47780: crash when comparing GIS items from subquery > > If the first argument to GeomFromWKB function is a geometry > field then the function just returns its value. > However in doing so it's not preserving first argument's > null_value flag and this causes unexpected null value to > be returned to the calling function. > > Fixed by updating the null_value of the GeomFromWKB function > in such cases (and all other cases that return a NULL e.g. > because of not enough memory for the return buffer). --- mysql-test/r/gis.result | 12 ++++++++++++ mysql-test/t/gis.test | 16 ++++++++++++++++ sql/item_geofunc.cc | 9 +++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 5b7a58add06..140c133d75f 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -971,4 +971,16 @@ select min(`col002`) from t1 union select `col002` from t1; min(`col002`) NULL drop table t1; +# +# Bug #47780: crash when comparing GIS items from subquery +# +CREATE TABLE t1(a INT, b MULTIPOLYGON); +INSERT INTO t1 VALUES +(0, +GEOMFROMTEXT( +'multipolygon(((1 2,3 4,5 6,7 8,9 8),(7 6,5 4,3 2,1 2,3 4)))')); +# must not crash +SELECT 1 FROM t1 WHERE a <> (SELECT GEOMETRYCOLLECTIONFROMWKB(b) FROM t1); +1 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index c01fa205349..701a6cef6be 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -654,4 +654,20 @@ insert into t1 values (),(),(); select min(`col002`) from t1 union select `col002` from t1; drop table t1; +--echo # +--echo # Bug #47780: crash when comparing GIS items from subquery +--echo # + +CREATE TABLE t1(a INT, b MULTIPOLYGON); +INSERT INTO t1 VALUES + (0, + GEOMFROMTEXT( + 'multipolygon(((1 2,3 4,5 6,7 8,9 8),(7 6,5 4,3 2,1 2,3 4)))')); + +--echo # must not crash +SELECT 1 FROM t1 WHERE a <> (SELECT GEOMETRYCOLLECTIONFROMWKB(b) FROM t1); + +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 71bd1347f6e..d3e7096a0bd 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -76,7 +76,9 @@ String *Item_func_geometry_from_wkb::val_str(String *str) if (args[0]->field_type() == MYSQL_TYPE_GEOMETRY) { - return args[0]->val_str(str); + String *str_ret= args[0]->val_str(str); + null_value= args[0]->null_value; + return str_ret; } wkb= args[0]->val_str(&arg_val); @@ -86,7 +88,10 @@ String *Item_func_geometry_from_wkb::val_str(String *str) str->set_charset(&my_charset_bin); if (str->reserve(SRID_SIZE, 512)) - return 0; + { + null_value= TRUE; /* purecov: inspected */ + return 0; /* purecov: inspected */ + } str->length(0); str->q_append(srid); if ((null_value= From 98b429c6718b18b1f34447c63437ae4f4efc1e14 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:27:27 +0100 Subject: [PATCH 27/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.12 > revision-id: joro@sun.com-20091030094044-quadg0bwjy7cwqzw > parent: joro@sun.com-20091029152429-ks55fhrp4lhknyij > committer: Georgi Kodinov > branch nick: B48293-5.0-bugteam > timestamp: Fri 2009-10-30 11:40:44 +0200 > message: > Bug #48293: crash with procedure analyse, view with > 10 columns, > having clause... > > The fix for bug 46184 was not very complete. It was not covering > views using temporary tables and multiple tables in a FROM clause. > Fixed by reverting the fix for 46184 and making a more general > check that is checking at the right execution stage and for all > of the non-supported cases. > Now PROCEDURE ANALYZE on non-top level SELECT is also forbidden. > Updated the analyse.test and subselect.test accordingly. --- mysql-test/r/analyse.result | 112 ++++++++++++---------------------- mysql-test/r/subselect.result | 2 +- mysql-test/t/analyse.test | 70 +++++++++++++-------- mysql-test/t/subselect.test | 2 +- sql/sql_select.cc | 12 ++++ sql/sql_yacc.yy | 3 +- 6 files changed, 99 insertions(+), 102 deletions(-) diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result index 1e3a2985f74..1820782d2f8 100644 --- a/mysql-test/r/analyse.result +++ b/mysql-test/r/analyse.result @@ -19,81 +19,10 @@ test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL create table t2 select * from t1 procedure analyse(); -select * from t2; -Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype -test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL -test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL -test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL -test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL -test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL -drop table t1,t2; +ERROR HY000: Incorrect usage of PROCEDURE and non-SELECT +drop table t1; EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); ERROR HY000: Incorrect usage of PROCEDURE and subquery -create table t1 (a int not null); -create table t2 select * from t1 where 0=1 procedure analyse(); -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `Field_name` varbinary(255) NOT NULL default '', - `Min_value` varbinary(255) default NULL, - `Max_value` varbinary(255) default NULL, - `Min_length` bigint(11) NOT NULL default '0', - `Max_length` bigint(11) NOT NULL default '0', - `Empties_or_zeros` bigint(11) NOT NULL default '0', - `Nulls` bigint(11) NOT NULL default '0', - `Avg_value_or_avg_length` varbinary(255) NOT NULL default '', - `Std` varbinary(255) default NULL, - `Optimal_fieldtype` varbinary(64) NOT NULL default '' -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -select * from t1 where 0=1 procedure analyse(); -Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype -insert into t1 values(1); -drop table t2; -create table t2 select * from t1 where 0=1 procedure analyse(); -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `Field_name` varbinary(255) NOT NULL default '', - `Min_value` varbinary(255) default NULL, - `Max_value` varbinary(255) default NULL, - `Min_length` bigint(11) NOT NULL default '0', - `Max_length` bigint(11) NOT NULL default '0', - `Empties_or_zeros` bigint(11) NOT NULL default '0', - `Nulls` bigint(11) NOT NULL default '0', - `Avg_value_or_avg_length` varbinary(255) NOT NULL default '', - `Std` varbinary(255) default NULL, - `Optimal_fieldtype` varbinary(64) NOT NULL default '' -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -select * from t2; -Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype -insert into t2 select * from t1 procedure analyse(); -select * from t2; -Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype -test.t1.a 1 1 1 1 0 0 1.0000 0.0000 ENUM('1') NOT NULL -insert into t1 values(2); -drop table t2; -create table t2 select * from t1 where 0=1 procedure analyse(); -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `Field_name` varbinary(255) NOT NULL default '', - `Min_value` varbinary(255) default NULL, - `Max_value` varbinary(255) default NULL, - `Min_length` bigint(11) NOT NULL default '0', - `Max_length` bigint(11) NOT NULL default '0', - `Empties_or_zeros` bigint(11) NOT NULL default '0', - `Nulls` bigint(11) NOT NULL default '0', - `Avg_value_or_avg_length` varbinary(255) NOT NULL default '', - `Std` varbinary(255) default NULL, - `Optimal_fieldtype` varbinary(64) NOT NULL default '' -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -select * from t2; -Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype -insert into t2 select * from t1 procedure analyse(); -select * from t2; -Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype -test.t1.a 1 2 1 1 0 0 1.5000 0.5000 ENUM('1','2') NOT NULL -drop table t1,t2; create table t1 (v varchar(128)); insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),('a\0'),('b\''),('c\"'),('d\\'),('\'b'),('\"c'),('\\d'),('a\0\0\0b'),('a\'\'\'\'b'),('a\"\"\"\"b'),('a\\\\\\\\b'),('\'\0\\\"'),('\'\''),('\"\"'),('\\\\'),('The\ZEnd'); select * from t1 procedure analyse(); @@ -157,3 +86,40 @@ SELECT * FROM (SELECT * FROM t1) d PROCEDURE ANALYSE(); ERROR HY000: Incorrect usage of PROCEDURE and subquery DROP TABLE t1; End of 4.1 tests +# +# Bug #48293: crash with procedure analyse, view with > 10 columns, +# having clause... +# +CREATE TABLE t1(a INT, b INT, c INT, d INT, e INT, +f INT, g INT, h INT, i INT, j INT,k INT); +INSERT INTO t1 VALUES (),(); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +#should have a derived table +EXPLAIN SELECT * FROM v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 +#should not crash +SELECT * FROM v1 PROCEDURE analyse(); +ERROR HY000: Incorrect usage of PROCEDURE and view +#should not crash +SELECT * FROM t1 a, v1, t1 b PROCEDURE analyse(); +ERROR HY000: Incorrect usage of PROCEDURE and view +#should not crash +SELECT * FROM (SELECT * FROM t1 having a > 1) x PROCEDURE analyse(); +ERROR HY000: Incorrect usage of PROCEDURE and subquery +#should not crash +SELECT * FROM t1 a, (SELECT * FROM t1 having a > 1) x, t1 b PROCEDURE analyse(); +ERROR HY000: Incorrect usage of PROCEDURE and subquery +#should not crash +SELECT 1 FROM t1 group by a having a > 1 order by 1 PROCEDURE analyse(); +ERROR HY000: Can't use ORDER clause with this procedure +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2); +# should not crash +CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 GROUP BY t3.a PROCEDURE ANALYSE(); +ERROR HY000: Incorrect usage of PROCEDURE and non-SELECT +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index eacde19ab1c..8c239d5c349 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -75,7 +75,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); ERROR HY000: Incorrect usage of PROCEDURE and subquery SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -ERROR HY000: Incorrect usage of PROCEDURE and subquery +ERROR HY000: Incorrect parameters to procedure 'ANALYSE' SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; ERROR 42S22: Unknown column 'a' in 'field list' SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test index d8466df14bf..05f739bfd69 100644 --- a/mysql-test/t/analyse.test +++ b/mysql-test/t/analyse.test @@ -10,36 +10,13 @@ insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6 select count(*) from t1 procedure analyse(); select * from t1 procedure analyse(); select * from t1 procedure analyse(2); +--error ER_WRONG_USAGE create table t2 select * from t1 procedure analyse(); -select * from t2; -drop table t1,t2; +drop table t1; --error ER_WRONG_USAGE EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); -# -# Test with impossible where -# -create table t1 (a int not null); -create table t2 select * from t1 where 0=1 procedure analyse(); -show create table t2; -select * from t1 where 0=1 procedure analyse(); -insert into t1 values(1); -drop table t2; -create table t2 select * from t1 where 0=1 procedure analyse(); -show create table t2; -select * from t2; -insert into t2 select * from t1 procedure analyse(); -select * from t2; -insert into t1 values(2); -drop table t2; -create table t2 select * from t1 where 0=1 procedure analyse(); -show create table t2; -select * from t2; -insert into t2 select * from t1 procedure analyse(); -select * from t2; -drop table t1,t2; - # # Bug#2813 - analyse does not quote string values in enums from string # @@ -113,3 +90,46 @@ SELECT * FROM (SELECT * FROM t1) d PROCEDURE ANALYSE(); DROP TABLE t1; --echo End of 4.1 tests + +--echo # +--echo # Bug #48293: crash with procedure analyse, view with > 10 columns, +--echo # having clause... +--echo # + +CREATE TABLE t1(a INT, b INT, c INT, d INT, e INT, + f INT, g INT, h INT, i INT, j INT,k INT); +INSERT INTO t1 VALUES (),(); + +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +--echo #should have a derived table +EXPLAIN SELECT * FROM v1; +--echo #should not crash +--error ER_WRONG_USAGE +SELECT * FROM v1 PROCEDURE analyse(); +--echo #should not crash +--error ER_WRONG_USAGE +SELECT * FROM t1 a, v1, t1 b PROCEDURE analyse(); +--echo #should not crash +--error ER_WRONG_USAGE +SELECT * FROM (SELECT * FROM t1 having a > 1) x PROCEDURE analyse(); +--echo #should not crash +--error ER_WRONG_USAGE +SELECT * FROM t1 a, (SELECT * FROM t1 having a > 1) x, t1 b PROCEDURE analyse(); +--echo #should not crash +--error ER_ORDER_WITH_PROC +SELECT 1 FROM t1 group by a having a > 1 order by 1 PROCEDURE analyse(); + +DROP VIEW v1; +DROP TABLE t1; + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2); + +--echo # should not crash +--error ER_WRONG_USAGE +CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 GROUP BY t3.a PROCEDURE ANALYSE(); + +DROP TABLE t1; + + +--echo End of 5.0 tests diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 79918ca78a2..2b5d36da796 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -30,7 +30,7 @@ SELECT 1 IN (SELECT 1); SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); -- error ER_WRONG_USAGE select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); --- error ER_WRONG_USAGE +-- error ER_WRONG_PARAMETERS_TO_PROCEDURE SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); -- error ER_BAD_FIELD_ERROR SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3bf67299d58..1b5be97b1d3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -622,6 +622,18 @@ JOIN::prepare(Item ***rref_pointer_array, MYF(0)); /* purecov: inspected */ goto err; /* purecov: inspected */ } + if (thd->lex->derived_tables) + { + my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", + thd->lex->derived_tables & DERIVED_VIEW ? + "view" : "subquery"); + goto err; + } + if (thd->lex->sql_command != SQLCOM_SELECT) + { + my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "non-SELECT"); + goto err; + } } if (!procedure && result && result->prepare(fields_list, unit_arg)) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c0247fd8d56..2fc85b4bda7 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7334,8 +7334,7 @@ procedure_clause: MYSQL_YYABORT; } - if (&lex->select_lex != lex->current_select || - lex->select_lex.get_table_list()->derived) + if (&lex->select_lex != lex->current_select) { my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "subquery"); MYSQL_YYABORT; From 1083c85294332ecfbdb061dd4e0cf9bbc3449c7f Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:28:51 +0100 Subject: [PATCH 28/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.13 > revision-id: joro@sun.com-20091030131543-2b23fnqckgbzvete > parent: joro@sun.com-20091030094044-quadg0bwjy7cwqzw > committer: Georgi Kodinov > branch nick: B48291-5.0-bugteam > timestamp: Fri 2009-10-30 15:15:43 +0200 > message: > Bug #48291 : crash with row() operator,select into @var, and > subquery returning multiple rows > > Error handling was missing when handling subqueires in WHERE > and when assigning a SELECT result to a @variable. > This caused crash(es). > > Fixed by adding error handling code to both the WHERE > condition evaluation and to assignment to an @variable. --- mysql-test/r/select.result | 12 ++++++++++++ mysql-test/t/select.test | 17 +++++++++++++++++ sql/sql_class.cc | 6 ++++-- sql/sql_select.cc | 13 ++++++++++++- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 4bb62fbfa70..5d07c97149f 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4430,4 +4430,16 @@ SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); 1 1 DROP TABLE t1; +# +# Bug #48291 : crash with row() operator,select into @var, and +# subquery returning multiple rows +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); +# Should not crash +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1)) +INTO @var0; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index d57163dfef6..ceb67215614 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3766,5 +3766,22 @@ EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a); DROP TABLE t1; + +--echo # +--echo # Bug #48291 : crash with row() operator,select into @var, and +--echo # subquery returning multiple rows +--echo # + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (2),(3); + +--echo # Should not crash +--error ER_SUBQUERY_NO_1_ROW +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1)) +INTO @var0; + +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7d26759cb16..06f2229a050 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2068,9 +2068,11 @@ bool select_dumpvar::send_data(List &items) else { Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item); - suv->fix_fields(thd, 0); + if (suv->fix_fields(thd, 0)) + DBUG_RETURN (1); suv->save_item_result(item); - suv->update(); + if (suv->update()) + DBUG_RETURN (1); } } DBUG_RETURN(0); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1b5be97b1d3..4e97836e5ec 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10819,6 +10819,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, bool not_used_in_distinct=join_tab->not_used_in_distinct; ha_rows found_records=join->found_records; COND *select_cond= join_tab->select_cond; + bool select_cond_result= TRUE; if (error > 0 || (*report_error)) // Fatal error return NESTED_LOOP_ERROR; @@ -10830,7 +10831,17 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, return NESTED_LOOP_KILLED; /* purecov: inspected */ } DBUG_PRINT("info", ("select cond 0x%lx", (ulong)select_cond)); - if (!select_cond || select_cond->val_int()) + + if (select_cond) + { + select_cond_result= test(select_cond->val_int()); + + /* check for errors evaluating the condition */ + if (join->thd->net.report_error) + return NESTED_LOOP_ERROR; + } + + if (!select_cond || select_cond_result) { /* There is no select condition or the attached pushed down From 931644120313d607f51e9e1fd2183604c841bd23 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:29:49 +0100 Subject: [PATCH 29/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.4.1 > revision-id: alexey.kopytov@sun.com-20091030155453-0vlfwki805h9os62 > parent: joerg@mysql.com-20091016122941-rf6z0keqvmlgjfto > committer: Alexey Kopytov > branch nick: my50-bug48131 > timestamp: Fri 2009-10-30 18:54:53 +0300 > message: > Bug #48131: crash group by with rollup, distinct, filesort, > with temporary tables > > There were two problems the test case from this bug was > triggering: > > 1. JOIN::rollup_init() was supposed to wrap all constant Items > into another object for queries with the WITH ROLLUP modifier > to ensure they are never considered as constants and therefore > are written into temporary tables if the optimizer chooses to > employ them for DISTINCT/GROUP BY handling. > > However, JOIN::rollup_init() was called before > make_join_statistics(), so Items corresponding to fields in > const tables could not be handled as intended, which was > causing all kinds of problems later in the query execution. In > particular, create_tmp_table() assumed all constant items > except "hidden" ones to be removed earlier by remove_const() > which led to improperly initialized Field objects for the > temporary table being created. This is what was causing crashes > and valgrind errors in storage engines. > > 2. Even when the above problem had been fixed, the query from > the test case produced incorrect results due to some > DISTINCT/GROUP BY optimizations being performed by the > optimizer that are inapplicable in the WITH ROLLUP case. > > Fixed by disabling inapplicable DISTINCT/GROUP BY optimizations > when the WITH ROLLUP modifier is present, and splitting the > const-wrapping part of JOIN::rollup_init() into a separate > method which is now invoked after make_join_statistics() when > the const tables are already known. --- mysql-test/r/olap.result | 20 +++++++++ mysql-test/t/olap.test | 15 +++++++ sql/sql_select.cc | 92 ++++++++++++++++++++++++++++------------ sql/sql_select.h | 1 + 4 files changed, 100 insertions(+), 28 deletions(-) diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index ad04e7304c9..56e06f03378 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -733,4 +733,24 @@ SELECT 1 FROM t1 GROUP BY (DATE(NULL)) WITH ROLLUP; 1 1 DROP TABLE t1; +# +# Bug #48131: crash group by with rollup, distinct, +# filesort, with temporary tables +# +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY); +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (100); +SELECT a, b FROM t1, t2 GROUP BY a, b WITH ROLLUP; +a b +1 100 +1 NULL +2 100 +2 NULL +NULL NULL +SELECT DISTINCT b FROM t1, t2 GROUP BY a, b WITH ROLLUP; +b +100 +NULL +DROP TABLE t1, t2; End of 5.0 tests diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index d1e40024733..8f672af40a3 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -375,4 +375,19 @@ INSERT INTO t1 VALUES(0); SELECT 1 FROM t1 GROUP BY (DATE(NULL)) WITH ROLLUP; DROP TABLE t1; +--echo # +--echo # Bug #48131: crash group by with rollup, distinct, +--echo # filesort, with temporary tables +--echo # + +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY); +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (100); + +SELECT a, b FROM t1, t2 GROUP BY a, b WITH ROLLUP; +SELECT DISTINCT b FROM t1, t2 GROUP BY a, b WITH ROLLUP; + +DROP TABLE t1, t2; + --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4e97836e5ec..ca7f20f5b21 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -928,6 +928,12 @@ JOIN::optimize() DBUG_RETURN(1); } + if (select_lex->olap == ROLLUP_TYPE && rollup_process_const_fields()) + { + DBUG_PRINT("error", ("Error: rollup_process_fields() failed")); + DBUG_RETURN(1); + } + /* Remove distinct if only const tables */ select_distinct= select_distinct && (const_tables != tables); thd_proc_info(thd, "preparing"); @@ -1055,7 +1061,7 @@ JOIN::optimize() join_tab[const_tables].select->quick->get_type() != QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) { - if (group_list && + if (group_list && rollup.state == ROLLUP::STATE_NONE && list_contains_unique_index(join_tab[const_tables].table, find_field_in_order_list, (void *) group_list)) @@ -1093,7 +1099,8 @@ JOIN::optimize() if (! hidden_group_fields && rollup.state == ROLLUP::STATE_NONE) select_distinct=0; } - else if (select_distinct && tables - const_tables == 1) + else if (select_distinct && tables - const_tables == 1 && + rollup.state == ROLLUP::STATE_NONE) { /* We are only using one table. In this case we change DISTINCT to a @@ -9870,6 +9877,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, for (; cur_group ; cur_group= cur_group->next, key_part_info++) { Field *field=(*cur_group->item)->get_tmp_table_field(); + DBUG_ASSERT(field->table == table); bool maybe_null=(*cur_group->item)->maybe_null; key_part_info->null_bit=0; key_part_info->field= field; @@ -15015,32 +15023,7 @@ bool JOIN::rollup_init() { item->maybe_null= 1; found_in_group= 1; - if (item->const_item()) - { - /* - For ROLLUP queries each constant item referenced in GROUP BY list - is wrapped up into an Item_func object yielding the same value - as the constant item. The objects of the wrapper class are never - considered as constant items and besides they inherit all - properties of the Item_result_field class. - This wrapping allows us to ensure writing constant items - into temporary tables whenever the result of the ROLLUP - operation has to be written into a temporary table, e.g. when - ROLLUP is used together with DISTINCT in the SELECT list. - Usually when creating temporary tables for a intermidiate - result we do not include fields for constant expressions. - */ - Item* new_item= new Item_func_rollup_const(item); - if (!new_item) - return 1; - new_item->fix_fields(thd, (Item **) 0); - thd->change_item_tree(it.ref(), new_item); - for (ORDER *tmp= group_tmp; tmp; tmp= tmp->next) - { - if (*tmp->item == item) - thd->change_item_tree(tmp->item, new_item); - } - } + break; } } if (item->type() == Item::FUNC_ITEM && !found_in_group) @@ -15059,6 +15042,59 @@ bool JOIN::rollup_init() } return 0; } + +/** + Wrap all constant Items in GROUP BY list. + + For ROLLUP queries each constant item referenced in GROUP BY list + is wrapped up into an Item_func object yielding the same value + as the constant item. The objects of the wrapper class are never + considered as constant items and besides they inherit all + properties of the Item_result_field class. + This wrapping allows us to ensure writing constant items + into temporary tables whenever the result of the ROLLUP + operation has to be written into a temporary table, e.g. when + ROLLUP is used together with DISTINCT in the SELECT list. + Usually when creating temporary tables for a intermidiate + result we do not include fields for constant expressions. + + @retval + 0 if ok + @retval + 1 on error +*/ + +bool JOIN::rollup_process_const_fields() +{ + ORDER *group_tmp; + Item *item; + List_iterator it(all_fields); + + for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next) + { + if (!(*group_tmp->item)->const_item()) + continue; + while ((item= it++)) + { + if (*group_tmp->item == item) + { + Item* new_item= new Item_func_rollup_const(item); + if (!new_item) + return 1; + new_item->fix_fields(thd, (Item **) 0); + thd->change_item_tree(it.ref(), new_item); + for (ORDER *tmp= group_tmp; tmp; tmp= tmp->next) + { + if (*tmp->item == item) + thd->change_item_tree(tmp->item, new_item); + } + break; + } + } + it.rewind(); + } + return 0; +} /* diff --git a/sql/sql_select.h b/sql/sql_select.h index c328737c1c6..a217d199a30 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -452,6 +452,7 @@ public: } bool rollup_init(); + bool rollup_process_const_fields(); bool rollup_make_fields(List &all_fields, List &fields, Item_sum ***func); int rollup_send_data(uint idx); From 147f5335324c035b79ca8d106491fca562720596 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:31:14 +0100 Subject: [PATCH 30/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.18 > revision-id: li-bing.song@sun.com-20091103090041-zj7nedx6ok5jgges > parent: davi.arnaut@sun.com-20091102201021-1brn7cjb1kvqg9gr > committer: > branch nick: mysql-5.0-bugteam > timestamp: Tue 2009-11-03 17:00:41 +0800 > message: > BUG#48216 Replication fails on all slaves after upgrade to 5.0.86 on master > > When a sessione is closed, all temporary tables of the session are automatically > dropped and are binlogged. But it will be binlogged with wrong database names when > the length of the temporary tables' database names are greater than the > length of the current database name or the current database is not set. > > Query_log_event's db_len is forgot to set when Query_log_event's db is set. > This patch wrote code to set db_len immediately after db has set. --- mysql-test/r/drop_temp_table.result | 1 + mysql-test/t/drop_temp_table.test | 11 +++++++++++ sql/sql_base.cc | 1 + 3 files changed, 13 insertions(+) diff --git a/mysql-test/r/drop_temp_table.result b/mysql-test/r/drop_temp_table.result index ff200d09de4..6a566aa646e 100644 --- a/mysql-test/r/drop_temp_table.result +++ b/mysql-test/r/drop_temp_table.result @@ -8,6 +8,7 @@ create temporary table shortn2 (a int); select get_lock("a",10); get_lock("a",10) 1 +USE test; select get_lock("a",10); get_lock("a",10) 1 diff --git a/mysql-test/t/drop_temp_table.test b/mysql-test/t/drop_temp_table.test index b456e75576b..6c99d566d77 100644 --- a/mysql-test/t/drop_temp_table.test +++ b/mysql-test/t/drop_temp_table.test @@ -14,6 +14,17 @@ create temporary table shortn1 (a int); create temporary table `table:name` (a int); create temporary table shortn2 (a int); select get_lock("a",10); + +# +# BUG48216 Replication fails on all slaves after upgrade to 5.0.86 on master +# +# When the session is closed, any temporary tables of the session are dropped +# and are binlogged. But it will be binlogged with a wrong database name when +# the length of the database name('drop-temp-table-test') is greater than the +# current database name('test'). +# +USE test; + disconnect con1; connection con2; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index db4ab29d6de..178c3e12e23 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -798,6 +798,7 @@ void close_temporary_tables(THD *thd) s_query.length() - 1 /* to remove trailing ',' */, 0, FALSE, THD::NOT_KILLED); qinfo.db= db.ptr(); + qinfo.db_len= db.length(); thd->variables.character_set_client= cs_save; DBUG_ASSERT(qinfo.error_code == 0); mysql_bin_log.write(&qinfo); From 3ee3ee709282fb392afe6300af77c438c7c29255 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:32:15 +0100 Subject: [PATCH 31/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.19 > revision-id: kostja@sun.com-20091103165854-7di545xruez8w207 > parent: li-bing.song@sun.com-20091103090041-zj7nedx6ok5jgges > committer: Konstantin Osipov > branch nick: 5.0-41756 > timestamp: Tue 2009-11-03 19:58:54 +0300 > message: > A fix and a test case for > Bug#41756 "Strange error messages about locks from InnoDB". > > In JT_EQ_REF (join_read_key()) access method, > don't try to unlock rows in the handler, unless certain that > a) they were locked > b) they are not used. > > Unlocking of rows is done by the logic of the nested join loop, > and is unaware of the possible caching that the access method may > have. This could lead to double unlocking, when a row > was unlocked first after reading into the cache, and then > when taken from cache, as well as to unlocking of rows which > were actually used (but taken from cache). > > Delegate part of the unlocking logic to the access method, > and in JT_EQ_REF count how many times a record was actually > used in the join. Unlock it only if it's usage count is 0. > > Implemented review comments. --- sql/item_subselect.cc | 1 + sql/records.cc | 2 ++ sql/sql_select.cc | 61 +++++++++++++++++++++++++++++++++++++++++-- sql/sql_select.h | 8 +++++- sql/structs.h | 14 +++++++--- 5 files changed, 79 insertions(+), 7 deletions(-) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 805669b3cfa..80fbc2c74d3 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1869,6 +1869,7 @@ int subselect_single_select_engine::exec() tab->read_record.record= tab->table->record[0]; tab->read_record.thd= join->thd; tab->read_record.ref_length= tab->table->file->ref_length; + tab->read_record.unlock_row= rr_unlock_row; *(last_changed_tab++)= tab; break; } diff --git a/sql/records.cc b/sql/records.cc index d5c3a421cd9..e0219fac06e 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -60,6 +60,7 @@ void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, info->file= table->file; info->record= table->record[0]; info->print_error= print_error; + info->unlock_row= rr_unlock_row; table->status=0; /* And it's always found */ if (!table->file->inited) @@ -134,6 +135,7 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, } info->select=select; info->print_error=print_error; + info->unlock_row= rr_unlock_row; info->ignore_not_found_rows= 0; table->status=0; /* And it's always found */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ca7f20f5b21..c3cd1f41a41 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -140,6 +140,7 @@ static int join_read_const_table(JOIN_TAB *tab, POSITION *pos); static int join_read_system(JOIN_TAB *tab); static int join_read_const(JOIN_TAB *tab); static int join_read_key(JOIN_TAB *tab); +static void join_read_key_unlock_row(st_join_table *tab); static int join_read_always_key(JOIN_TAB *tab); static int join_read_last_key(JOIN_TAB *tab); static int join_no_more_records(READ_RECORD *info); @@ -5376,7 +5377,9 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, } j->ref.key_buff2=j->ref.key_buff+ALIGN_SIZE(length); j->ref.key_err=1; + j->ref.has_record= FALSE; j->ref.null_rejecting= 0; + j->ref.use_count= 0; keyuse=org_keyuse; store_key **ref_key= j->ref.key_copy; @@ -6176,6 +6179,20 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) DBUG_RETURN(0); } + +/** + The default implementation of unlock-row method of READ_RECORD, + used in all access methods. +*/ + +void rr_unlock_row(st_join_table *tab) +{ + READ_RECORD *info= &tab->read_record; + info->file->unlock_row(); +} + + + static void make_join_readinfo(JOIN *join, ulonglong options) { @@ -6191,6 +6208,7 @@ make_join_readinfo(JOIN *join, ulonglong options) TABLE *table=tab->table; tab->read_record.table= table; tab->read_record.file=table->file; + tab->read_record.unlock_row= rr_unlock_row; tab->next_select=sub_select; /* normal select */ /* @@ -6234,6 +6252,7 @@ make_join_readinfo(JOIN *join, ulonglong options) delete tab->quick; tab->quick=0; tab->read_first_record= join_read_key; + tab->read_record.unlock_row= join_read_key_unlock_row; tab->read_record.read_record= join_no_more_records; if (table->used_keys.is_set(tab->ref.key) && !table->no_keyread) @@ -10933,7 +10952,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, return NESTED_LOOP_NO_MORE_ROWS; } else - join_tab->read_record.file->unlock_row(); + join_tab->read_record.unlock_row(join_tab); } else { @@ -10943,7 +10962,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, */ join->examined_rows++; join->thd->row_count++; - join_tab->read_record.file->unlock_row(); + join_tab->read_record.unlock_row(join_tab); } return NESTED_LOOP_OK; } @@ -11296,17 +11315,55 @@ join_read_key(JOIN_TAB *tab) table->status=STATUS_NOT_FOUND; return -1; } + /* + Moving away from the current record. Unlock the row + in the handler if it did not match the partial WHERE. + */ + if (tab->ref.has_record && tab->ref.use_count == 0) + { + tab->read_record.file->unlock_row(); + tab->ref.has_record= FALSE; + } + error=table->file->index_read(table->record[0], tab->ref.key_buff, tab->ref.key_length,HA_READ_KEY_EXACT); if (error && error != HA_ERR_KEY_NOT_FOUND) return report_error(table, error); + + if (! error) + { + tab->ref.has_record= TRUE; + tab->ref.use_count= 1; + } + } + else if (table->status == 0) + { + DBUG_ASSERT(tab->ref.has_record); + tab->ref.use_count++; } table->null_row=0; return table->status ? -1 : 0; } +/** + Since join_read_key may buffer a record, do not unlock + it if it was not used in this invocation of join_read_key(). + Only count locks, thus remembering if the record was left unused, + and unlock already when pruning the current value of + TABLE_REF buffer. + @sa join_read_key() +*/ + +static void +join_read_key_unlock_row(st_join_table *tab) +{ + DBUG_ASSERT(tab->ref.use_count); + if (tab->ref.use_count) + tab->ref.use_count--; +} + /* ref access method implementation: "read_first" function diff --git a/sql/sql_select.h b/sql/sql_select.h index a217d199a30..346d98aae58 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -53,6 +53,8 @@ class store_key; typedef struct st_table_ref { bool key_err; + /** True if something was read into buffer in join_read_key. */ + bool has_record; uint key_parts; // num of ... uint key_length; // length of key_buff int key; // key no @@ -79,7 +81,11 @@ typedef struct st_table_ref key_part_map null_rejecting; table_map depend_map; // Table depends on these tables. byte *null_ref_key; // null byte position in the key_buf. - // used for REF_OR_NULL optimization. + /* + The number of times the record associated with this key was used + in the join. + */ + ha_rows use_count; } TABLE_REF; /* diff --git a/sql/structs.h b/sql/structs.h index be55527eaa0..3a7b2f49b2a 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -117,16 +117,22 @@ typedef struct st_reginfo { /* Extra info about reg */ } REGINFO; -struct st_read_record; /* For referense later */ class SQL_SELECT; class THD; class handler; +struct st_join_table; -typedef struct st_read_record { /* Parameter to read_record */ +void rr_unlock_row(st_join_table *tab); + +struct READ_RECORD { /* Parameter to read_record */ + typedef int (*Read_func)(READ_RECORD*); + typedef void (*Unlock_row_func)(st_join_table *); struct st_table *table; /* Head-form */ handler *file; struct st_table **forms; /* head and ref forms */ - int (*read_record)(struct st_read_record *); + + Read_func read_record; + Unlock_row_func unlock_row; THD *thd; SQL_SELECT *select; uint cache_records; @@ -138,7 +144,7 @@ typedef struct st_read_record { /* Parameter to read_record */ byte *cache,*cache_pos,*cache_end,*read_positions; IO_CACHE *io_cache; bool print_error, ignore_not_found_rows; -} READ_RECORD; +}; /* From 90582e5e4e120d154d2e46b21966d8906bb7e8e0 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:33:14 +0100 Subject: [PATCH 32/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.26 > revision-id: joro@sun.com-20091109140946-07wao5od7l1vn4x1 > parent: joro@sun.com-20091110082141-ldr8p6s1joczve2j > committer: Georgi Kodinov > branch nick: B48458-5.0-bugteam > timestamp: Mon 2009-11-09 16:09:46 +0200 > message: > Bug #48458: simple query tries to allocate enormous amount of > memory > > The server was doing a bad class typecast causing setting of > wrong value for the maximum number of items in an internal > structure used in equality propagation. > Fixed by not doing the wrong typecast and asserting the type > of the Item where it should be done. --- mysql-test/r/select.result | 14 ++++++++++++++ mysql-test/t/select.test | 13 +++++++++++++ sql/sql_select.cc | 10 +++++----- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 5d07c97149f..ff59eadab0c 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -4442,4 +4442,18 @@ ROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1)) INTO @var0; ERROR 21000: Subquery returns more than 1 row DROP TABLE t1; +# +# Bug #48458: simple query tries to allocate enormous amount of +# memory +# +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +CREATE TABLE t2(c INT); +# Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 +WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +1 +DROP TABLE t1,t2; End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index ceb67215614..a4d3056b66e 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3783,5 +3783,18 @@ INTO @var0; DROP TABLE t1; +--echo # +--echo # Bug #48458: simple query tries to allocate enormous amount of +--echo # memory +--echo # + +CREATE TABLE t1(a INT NOT NULL, b YEAR); +INSERT INTO t1 VALUES (); +CREATE TABLE t2(c INT); +--echo # Should not err out because of out-of-memory +SELECT 1 FROM t2 JOIN t1 ON 1=1 + WHERE a != '1' AND NOT a >= b OR NOT ROW(b,a )<> ROW(a,a); +DROP TABLE t1,t2; + --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c3cd1f41a41..0b4b88ba3df 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7517,12 +7517,12 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond, { item_equal->fix_length_and_dec(); item_equal->update_used_tables(); + set_if_bigger(thd->lex->current_select->max_equal_elems, + item_equal->members()); + return item_equal; } - else - item_equal= (Item_equal *) eq_list.pop(); - set_if_bigger(thd->lex->current_select->max_equal_elems, - item_equal->members()); - return item_equal; + + return eq_list.pop(); } else { From f5feec0d98a364eefb01bef102e8335521f4521a Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:34:46 +0100 Subject: [PATCH 33/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.29 > revision-id: joro@sun.com-20091118152410-j4tv22vf9xkb6sdz > parent: kent.boortz@sun.com-20091117164924-rscth12t9a2qog1b > committer: Georgi Kodinov > branch nick: test-5.0-bugteam > timestamp: Wed 2009-11-18 17:24:10 +0200 > message: > Bug#48864: MySQL fails to compile on 64 bit Fedora 12 > > Fixed 2 errors in comp_err executable : > 1. Wrong (off by 1) length passed to my_checksum() > 2. strmov() was used on overlapping strings. This is > not legal according to the docs in stpcpy(). Used > the overlap safe memmove() instead. --- extra/comp_err.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extra/comp_err.c b/extra/comp_err.c index 8814a045f36..342085b64d6 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -660,7 +660,7 @@ static ha_checksum checksum_format_specifier(const char* msg) case 'u': case 'x': case 's': - chksum= my_checksum(chksum, start, (uint) (p - start)); + chksum= my_checksum(chksum, start, (uint) (p + 1 - start)); start= 0; /* Not in format specifier anymore */ break; @@ -1030,8 +1030,10 @@ static char *parse_text_line(char *pos) { int i, nr; char *row= pos; + size_t len; DBUG_ENTER("parse_text_line"); + len= strlen (pos); while (*pos) { if (*pos == '\\') @@ -1039,11 +1041,11 @@ static char *parse_text_line(char *pos) switch (*++pos) { case '\\': case '"': - VOID(strmov(pos - 1, pos)); + VOID(memmove (pos - 1, pos, len - (row - pos))); break; case 'n': pos[-1]= '\n'; - VOID(strmov(pos, pos + 1)); + VOID(memmove (pos, pos + 1, len - (row - pos))); break; default: if (*pos >= '0' && *pos < '8') @@ -1053,10 +1055,10 @@ static char *parse_text_line(char *pos) nr= nr * 8 + (*(pos++) - '0'); pos -= i; pos[-1]= nr; - VOID(strmov(pos, pos + i)); + VOID(memmove (pos, pos + i, len - (row - pos))); } else if (*pos) - VOID(strmov(pos - 1, pos)); /* Remove '\' */ + VOID(memmove (pos - 1, pos, len - (row - pos))); /* Remove '\' */ } } else From d3ecc66c58be5da15955e91a2dee9ea0a858ddb9 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:36:20 +0100 Subject: [PATCH 34/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.35 > revision-id: joro@sun.com-20091127095944-autr58itccge4z9l > parent: satya.bn@sun.com-20091125095925-871384fcnwwa2yqt > committer: Georgi Kodinov > branch nick: B48872-5.0-bugteam > timestamp: Fri 2009-11-27 11:59:44 +0200 > message: > Bug #48872 : Privileges for stored functions ignored if function name > is mixed case > > Transcode the procedure name to lowercase when searching for it in the > hash. This is the missing part of the fix for bug #41049. --- mysql-test/r/sp-security.result | 61 +++++++++++++++++++++++++++++++++ mysql-test/t/sp-security.test | 57 ++++++++++++++++++++++++++++++ sql/sql_acl.cc | 13 ++++--- 3 files changed, 126 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result index 106d08c8c12..17758218e35 100644 --- a/mysql-test/r/sp-security.result +++ b/mysql-test/r/sp-security.result @@ -519,4 +519,65 @@ DROP USER mysqltest_u1@localhost; DROP PROCEDURE p_suid; DROP FUNCTION f_suid; DROP TABLE t1; +# +# Bug #48872 : Privileges for stored functions ignored if function name +# is mixed case +# +CREATE DATABASE B48872; +USE B48872; +CREATE TABLE `TestTab` (id INT); +INSERT INTO `TestTab` VALUES (1),(2); +CREATE FUNCTION `f_Test`() RETURNS INT RETURN 123; +CREATE FUNCTION `f_Test_denied`() RETURNS INT RETURN 123; +CREATE USER 'tester'; +CREATE USER 'Tester'; +GRANT SELECT ON TABLE `TestTab` TO 'tester'; +GRANT EXECUTE ON FUNCTION `f_Test` TO 'tester'; +GRANT EXECUTE ON FUNCTION `f_Test_denied` TO 'Tester'; +SELECT f_Test(); +f_Test() +123 +SELECT * FROM TestTab; +id +1 +2 +SELECT * FROM TestTab; +id +1 +2 +SELECT `f_Test`(); +`f_Test`() +123 +SELECT `F_TEST`(); +`F_TEST`() +123 +SELECT f_Test(); +f_Test() +123 +SELECT F_TEST(); +F_TEST() +123 +SELECT * FROM TestTab; +ERROR 42000: SELECT command denied to user 'Tester'@'localhost' for table 'TestTab' +SELECT `f_Test`(); +ERROR 42000: execute command denied to user 'Tester'@'%' for routine 'B48872.f_Test' +SELECT `F_TEST`(); +ERROR 42000: execute command denied to user 'Tester'@'%' for routine 'B48872.f_Test' +SELECT f_Test(); +ERROR 42000: execute command denied to user 'Tester'@'%' for routine 'B48872.f_Test' +SELECT F_TEST(); +ERROR 42000: execute command denied to user 'Tester'@'%' for routine 'B48872.f_Test' +SELECT `f_Test_denied`(); +`f_Test_denied`() +123 +SELECT `F_TEST_DENIED`(); +`F_TEST_DENIED`() +123 +DROP TABLE `TestTab`; +DROP FUNCTION `f_Test`; +DROP FUNCTION `f_Test_denied`; +USE test; +DROP USER 'tester'; +DROP USER 'Tester'; +DROP DATABASE B48872; End of 5.0 tests. diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test index b8181fcb89b..42c8ecd85ec 100644 --- a/mysql-test/t/sp-security.test +++ b/mysql-test/t/sp-security.test @@ -889,6 +889,63 @@ DROP PROCEDURE p_suid; DROP FUNCTION f_suid; DROP TABLE t1; +--echo # +--echo # Bug #48872 : Privileges for stored functions ignored if function name +--echo # is mixed case +--echo # + +CREATE DATABASE B48872; +USE B48872; +CREATE TABLE `TestTab` (id INT); +INSERT INTO `TestTab` VALUES (1),(2); +CREATE FUNCTION `f_Test`() RETURNS INT RETURN 123; +CREATE FUNCTION `f_Test_denied`() RETURNS INT RETURN 123; +CREATE USER 'tester'; +CREATE USER 'Tester'; +GRANT SELECT ON TABLE `TestTab` TO 'tester'; +GRANT EXECUTE ON FUNCTION `f_Test` TO 'tester'; +GRANT EXECUTE ON FUNCTION `f_Test_denied` TO 'Tester'; + +SELECT f_Test(); +SELECT * FROM TestTab; + +CONNECT (con_tester,localhost,tester,,B48872); +CONNECT (con_tester_denied,localhost,Tester,,B48872); +CONNECTION con_tester; + +SELECT * FROM TestTab; +SELECT `f_Test`(); +SELECT `F_TEST`(); +SELECT f_Test(); +SELECT F_TEST(); + +CONNECTION con_tester_denied; + +--error ER_TABLEACCESS_DENIED_ERROR +SELECT * FROM TestTab; +--error ER_PROCACCESS_DENIED_ERROR +SELECT `f_Test`(); +--error ER_PROCACCESS_DENIED_ERROR +SELECT `F_TEST`(); +--error ER_PROCACCESS_DENIED_ERROR +SELECT f_Test(); +--error ER_PROCACCESS_DENIED_ERROR +SELECT F_TEST(); +SELECT `f_Test_denied`(); +SELECT `F_TEST_DENIED`(); + +CONNECTION default; +DISCONNECT con_tester; +DISCONNECT con_tester_denied; +DROP TABLE `TestTab`; +DROP FUNCTION `f_Test`; +DROP FUNCTION `f_Test_denied`; + +USE test; +DROP USER 'tester'; +DROP USER 'Tester'; +DROP DATABASE B48872; + --echo End of 5.0 tests. # Wait till all disconnects are completed diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index ea17a4227ef..29ea7c80d74 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2265,14 +2265,17 @@ static GRANT_NAME *name_hash_search(HASH *name_hash, const char *host,const char* ip, const char *db, const char *user, const char *tname, - bool exact) + bool exact, bool name_tolower) { - char helping [NAME_LEN*2+USERNAME_LENGTH+3]; + char helping [NAME_LEN*2+USERNAME_LENGTH+3], *name_ptr; uint len; GRANT_NAME *grant_name,*found=0; HASH_SEARCH_STATE state; - len = (uint) (strmov(strmov(strmov(helping,user)+1,db)+1,tname)-helping)+ 1; + name_ptr= strmov(strmov(helping, user) + 1, db) + 1; + len = (uint) (strmov(name_ptr, tname) - helping) + 1; + if (name_tolower) + my_casedn_str(files_charset_info, name_ptr); for (grant_name= (GRANT_NAME*) hash_first(name_hash, (byte*) helping, len, &state); grant_name ; @@ -2305,7 +2308,7 @@ routine_hash_search(const char *host, const char *ip, const char *db, { return (GRANT_TABLE*) name_hash_search(proc ? &proc_priv_hash : &func_priv_hash, - host, ip, db, user, tname, exact); + host, ip, db, user, tname, exact, TRUE); } @@ -2314,7 +2317,7 @@ table_hash_search(const char *host, const char *ip, const char *db, const char *user, const char *tname, bool exact) { return (GRANT_TABLE*) name_hash_search(&column_priv_hash, host, ip, db, - user, tname, exact); + user, tname, exact, FALSE); } From 18332268c2dc3a29f92bf3e94f2a345243aa4ae0 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:37:47 +0100 Subject: [PATCH 35/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.38 > revision-id: joro@sun.com-20091127160731-6h2fahbh4409i841 > parent: joro@sun.com-20091127143622-bqfsmhhr2pqodsm2 > committer: Georgi Kodinov > branch nick: fix-5.0-bugteam > timestamp: Fri 2009-11-27 18:07:31 +0200 > message: > Addendum to bug #48872: disable output in the test case because errors are > dependent on the case mode --- mysql-test/r/sp-security.result | 5 ----- mysql-test/t/sp-security.test | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result index 17758218e35..1451f8e88fd 100644 --- a/mysql-test/r/sp-security.result +++ b/mysql-test/r/sp-security.result @@ -558,15 +558,10 @@ SELECT F_TEST(); F_TEST() 123 SELECT * FROM TestTab; -ERROR 42000: SELECT command denied to user 'Tester'@'localhost' for table 'TestTab' SELECT `f_Test`(); -ERROR 42000: execute command denied to user 'Tester'@'%' for routine 'B48872.f_Test' SELECT `F_TEST`(); -ERROR 42000: execute command denied to user 'Tester'@'%' for routine 'B48872.f_Test' SELECT f_Test(); -ERROR 42000: execute command denied to user 'Tester'@'%' for routine 'B48872.f_Test' SELECT F_TEST(); -ERROR 42000: execute command denied to user 'Tester'@'%' for routine 'B48872.f_Test' SELECT `f_Test_denied`(); `f_Test_denied`() 123 diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test index 42c8ecd85ec..3d41d90404d 100644 --- a/mysql-test/t/sp-security.test +++ b/mysql-test/t/sp-security.test @@ -921,6 +921,7 @@ SELECT F_TEST(); CONNECTION con_tester_denied; +--disable_result_log --error ER_TABLEACCESS_DENIED_ERROR SELECT * FROM TestTab; --error ER_PROCACCESS_DENIED_ERROR @@ -931,6 +932,7 @@ SELECT `F_TEST`(); SELECT f_Test(); --error ER_PROCACCESS_DENIED_ERROR SELECT F_TEST(); +--enable_result_log SELECT `f_Test_denied`(); SELECT `F_TEST_DENIED`(); From 5c04b4374d7fbf3f0170c10081da1804359b19cd Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:38:46 +0100 Subject: [PATCH 36/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.39 > revision-id: gshchepa@mysql.com-20091201102444-yw166t3audrojo9s > parent: joro@sun.com-20091127160731-6h2fahbh4409i841 > committer: Gleb Shchepa > branch nick: mysql-5.0-bugteam > timestamp: Tue 2009-12-01 14:24:44 +0400 > message: > Bug #38883 (reopened): thd_security_context is not thread safe, crashes? > > The bug 38816 changed the lock that protects THD::query from > LOCK_thread_count to LOCK_thd_data, but didn't update the associated > InnoDB functions. > > 1. The innobase_mysql_prepare_print_arbitrary_thd and the > innobase_mysql_end_print_arbitrary_thd InnoDB functions have been > removed, since now we have a per-thread mutex: now we don't need to wrap > several inter-thread access tries to THD::query with a single global > LOCK_thread_count lock, so we can simplify the code. > > 2. The innobase_mysql_print_thd function has been modified to lock > LOCK_thd_data in direct way. --- innobase/include/trx0trx.h | 4 +--- innobase/lock/lock0lock.c | 33 -------------------------------- innobase/trx/trx0trx.c | 4 +--- sql/ha_innodb.cc | 39 ++++++++------------------------------ 4 files changed, 10 insertions(+), 70 deletions(-) diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h index cf9d1788ad8..5ed9f0b8c97 100644 --- a/innobase/include/trx0trx.h +++ b/innobase/include/trx0trx.h @@ -348,9 +348,7 @@ trx_commit_step( /************************************************************************** Prints info about a transaction to the given file. The caller must own the -kernel mutex and must have called -innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL -or InnoDB cannot meanwhile change the info printed here. */ +kernel mutex. */ void trx_print( diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index e0f3f58f737..acf76a08f16 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -18,31 +18,6 @@ Created 5/7/1996 Heikki Tuuri #include "trx0sys.h" -/* 2 function prototypes copied from ha_innodb.cc: */ - -/***************************************************************** -If you want to print a thd that is not associated with the current thread, -you must call this function before reserving the InnoDB kernel_mutex, to -protect MySQL from setting thd->query NULL. If you print a thd of the current -thread, we know that MySQL cannot modify thd->query, and it is not necessary -to call this. Call innobase_mysql_end_print_arbitrary_thd() after you release -the kernel_mutex. -NOTE that /mysql/innobase/lock/lock0lock.c must contain the prototype for this -function! */ - -void -innobase_mysql_prepare_print_arbitrary_thd(void); -/*============================================*/ - -/***************************************************************** -Relases the mutex reserved by innobase_mysql_prepare_print_arbitrary_thd(). -NOTE that /mysql/innobase/lock/lock0lock.c must contain the prototype for this -function! */ - -void -innobase_mysql_end_print_arbitrary_thd(void); -/*========================================*/ - /* Restricts the length of search we will do in the waits-for graph of transactions */ #define LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK 1000000 @@ -4231,11 +4206,6 @@ lock_print_info_summary( /*====================*/ FILE* file) /* in: file where to print */ { - /* We must protect the MySQL thd->query field with a MySQL mutex, and - because the MySQL mutex must be reserved before the kernel_mutex of - InnoDB, we call innobase_mysql_prepare_print_arbitrary_thd() here. */ - - innobase_mysql_prepare_print_arbitrary_thd(); lock_mutex_enter_kernel(); if (lock_deadlock_found) { @@ -4322,7 +4292,6 @@ loop: if (trx == NULL) { lock_mutex_exit_kernel(); - innobase_mysql_end_print_arbitrary_thd(); ut_ad(lock_validate()); @@ -4387,7 +4356,6 @@ loop: if (load_page_first) { lock_mutex_exit_kernel(); - innobase_mysql_end_print_arbitrary_thd(); mtr_start(&mtr); @@ -4397,7 +4365,6 @@ loop: load_page_first = FALSE; - innobase_mysql_prepare_print_arbitrary_thd(); lock_mutex_enter_kernel(); goto loop; diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index 70fd73f2488..d0e64b84eeb 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -1701,9 +1701,7 @@ trx_mark_sql_stat_end( /************************************************************************** Prints info about a transaction to the given file. The caller must own the -kernel mutex and must have called -innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL -or InnoDB cannot meanwhile change the info printed here. */ +kernel mutex. */ void trx_print( diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 4bd54805a95..1b614629288 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -536,35 +536,6 @@ convert_error_code_to_mysql( } } -/***************************************************************** -If you want to print a thd that is not associated with the current thread, -you must call this function before reserving the InnoDB kernel_mutex, to -protect MySQL from setting thd->query NULL. If you print a thd of the current -thread, we know that MySQL cannot modify thd->query, and it is not necessary -to call this. Call innobase_mysql_end_print_arbitrary_thd() after you release -the kernel_mutex. -NOTE that /mysql/innobase/lock/lock0lock.c must contain the prototype for this -function! */ -extern "C" -void -innobase_mysql_prepare_print_arbitrary_thd(void) -/*============================================*/ -{ - VOID(pthread_mutex_lock(&LOCK_thread_count)); -} - -/***************************************************************** -Releases the mutex reserved by innobase_mysql_prepare_print_arbitrary_thd(). -NOTE that /mysql/innobase/lock/lock0lock.c must contain the prototype for this -function! */ -extern "C" -void -innobase_mysql_end_print_arbitrary_thd(void) -/*========================================*/ -{ - VOID(pthread_mutex_unlock(&LOCK_thread_count)); -} - /***************************************************************** Prints info of a THD object (== user session thread) to the given file. NOTE that /mysql/innobase/trx/trx0trx.c must contain the prototype for @@ -578,11 +549,11 @@ innobase_mysql_print_thd( uint max_query_len) /* in: max query length to print, or 0 to use the default max length */ { - const THD* thd; + THD* thd; const Security_context *sctx; const char* s; - thd = (const THD*) input_thd; + thd = (THD*) input_thd; /* We probably want to have original user as part of debug output. */ sctx = &thd->main_security_ctx; @@ -609,6 +580,10 @@ innobase_mysql_print_thd( fputs(s, f); } + /* We have to quarantine an access to thd->query and + thd->query_length with thd->LOCK_thd_data mutex. */ + VOID(pthread_mutex_lock(&thd->LOCK_thd_data)); + if ((s = thd->query)) { /* 3100 is chosen because currently 3000 is the maximum max_query_len we ever give this. */ @@ -653,6 +628,8 @@ innobase_mysql_print_thd( } } + VOID(pthread_mutex_unlock(&thd->LOCK_thd_data)); + putc('\n', f); } From cb6780d296f18b87b4132bdfe0ad6519f9a416ac Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:40:24 +0100 Subject: [PATCH 37/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.40 [merge] > revision-id: epotemkin@mysql.com-20091202134712-4muwnr152xqkcwm7 > parent: gshchepa@mysql.com-20091201102444-yw166t3audrojo9s > parent: epotemkin@mysql.com-20091201182845-aw0uawt6c6gwi98c > committer: Evgeny Potemkin > branch nick: mysql-5.0-bugteam > timestamp: Wed 2009-12-02 16:47:12 +0300 > message: > Auto-merged fix for the bug#48508. > ------------------------------------------------------------ > Use --include-merges or -n0 to see merged revisions. --- mysql-test/r/ps.result | 23 +++++++++++++++++++++++ mysql-test/t/ps.test | 21 +++++++++++++++++++++ sql/item_cmpfunc.cc | 2 +- sql/sql_base.cc | 3 ++- sql/sql_class.h | 2 ++ 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 43c50998e20..e7894388494 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1891,4 +1891,27 @@ execute stmt using @arg; ? -12345.5432100000 deallocate prepare stmt; +# +# Bug#48508: Crash on prepared statement re-execution. +# +create table t1(b int); +insert into t1 values (0); +create view v1 AS select 1 as a from t1 where b; +prepare stmt from "select * from v1 where a"; +execute stmt; +a +execute stmt; +a +drop table t1; +drop view v1; +create table t1(a bigint); +create table t2(b tinyint); +insert into t2 values (null); +prepare stmt from "select 1 from t1 join t2 on a xor b where b > 1 and a =1"; +execute stmt; +1 +execute stmt; +1 +drop table t1,t2; +# End of 5.0 tests. diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index d9e593fd76f..6134efb5c5c 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1973,4 +1973,25 @@ select @arg; execute stmt using @arg; deallocate prepare stmt; +--echo # +--echo # Bug#48508: Crash on prepared statement re-execution. +--echo # +create table t1(b int); +insert into t1 values (0); +create view v1 AS select 1 as a from t1 where b; +prepare stmt from "select * from v1 where a"; +execute stmt; +execute stmt; +drop table t1; +drop view v1; + +create table t1(a bigint); +create table t2(b tinyint); +insert into t2 values (null); +prepare stmt from "select 1 from t1 join t2 on a xor b where b > 1 and a =1"; +execute stmt; +execute stmt; +drop table t1,t2; +--echo # + --echo End of 5.0 tests. diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8c655cdc369..d03c68b3560 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -3907,7 +3907,7 @@ Item *Item_cond::compile(Item_analyzer analyzer, byte **arg_p, byte *arg_v= *arg_p; Item *new_item= item->compile(analyzer, &arg_v, transformer, arg_t); if (new_item && new_item != item) - li.replace(new_item); + current_thd->change_item_tree(li.ref(), new_item); } return Item_func::transform(transformer, arg_t); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 178c3e12e23..88d1e8879d1 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3481,7 +3481,8 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list, if (!my_strcasecmp(system_charset_info, field_it.name(), name)) { // in PS use own arena or data will be freed after prepare - if (register_tree_change && thd->stmt_arena->is_stmt_prepare_or_first_sp_execute()) + if (register_tree_change && + thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute()) arena= thd->activate_stmt_arena_if_needed(&backup); /* create_item() may, or may not create a new Item, depending on diff --git a/sql/sql_class.h b/sql/sql_class.h index 7c747e459a4..45d345d0ced 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -757,6 +757,8 @@ public: { return state == INITIALIZED_FOR_SP; } inline bool is_stmt_prepare_or_first_sp_execute() const { return (int)state < (int)PREPARED; } + inline bool is_stmt_prepare_or_first_stmt_execute() const + { return (int)state <= (int)PREPARED; } inline bool is_first_stmt_execute() const { return state == PREPARED; } inline bool is_stmt_execute() const { return state == PREPARED || state == EXECUTED; } From 7da5dc14d96cb2f6f09f630142f29fdda9bdd281 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:41:24 +0100 Subject: [PATCH 38/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.41 [merge] > revision-id: epotemkin@mysql.com-20091203132153-k8xwk3nh02n8npg4 > parent: epotemkin@mysql.com-20091202134712-4muwnr152xqkcwm7 > parent: epotemkin@mysql.com-20091203131520-93uiop1a81o9z8mb > committer: Evgeny Potemkin > branch nick: mysql-5.0-bugteam > timestamp: Thu 2009-12-03 16:21:53 +0300 > message: > Auto-merged. > ------------------------------------------------------------ > Use --include-merges or -n0 to see merged revisions. --- mysql-test/r/ps.result | 2 ++ mysql-test/t/ps.test | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index e7894388494..8a19b9b17e1 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1902,6 +1902,7 @@ execute stmt; a execute stmt; a +deallocate prepare stmt; drop table t1; drop view v1; create table t1(a bigint); @@ -1912,6 +1913,7 @@ execute stmt; 1 execute stmt; 1 +deallocate prepare stmt; drop table t1,t2; # End of 5.0 tests. diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 6134efb5c5c..8f8e943913f 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1982,6 +1982,7 @@ create view v1 AS select 1 as a from t1 where b; prepare stmt from "select * from v1 where a"; execute stmt; execute stmt; +deallocate prepare stmt; drop table t1; drop view v1; @@ -1991,6 +1992,7 @@ insert into t2 values (null); prepare stmt from "select 1 from t1 join t2 on a xor b where b > 1 and a =1"; execute stmt; execute stmt; +deallocate prepare stmt; drop table t1,t2; --echo # From cab2b49617ca105aa1950483ee7d9f7c4692cfbb Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:42:25 +0100 Subject: [PATCH 39/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2818.1.48 > revision-id: joro@sun.com-20091210092838-zbz9ugqay1tn7rxm > parent: joro@sun.com-20091207143856-ojmmqr0bm1haxvca > committer: Georgi Kodinov > branch nick: B49250-5.0-bugteaam > timestamp: Thu 2009-12-10 11:28:38 +0200 > message: > Bug #49250 : spatial btree index corruption and crash > > SPATIAL and FULLTEXT indexes don't support algorithm > selection. > Disabled by creating a special grammar rule for these > in the parser. > Added some encasulation of duplicate parser code. --- mysql-test/r/fulltext.result | 14 +++++ mysql-test/r/gis.result | 13 +++++ mysql-test/t/fulltext.test | 17 ++++++ mysql-test/t/gis.test | 15 +++++ sql/sql_yacc.yy | 110 +++++++++++++++++++++-------------- 5 files changed, 126 insertions(+), 43 deletions(-) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index b0197e0aec2..c27915811d6 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -518,3 +518,17 @@ EXECUTE s; MATCH (col) AGAINST('findme') DEALLOCATE PREPARE s; DROP TABLE t1; +# +# Bug #49250 : spatial btree index corruption and crash +# Part two : fulltext syntax check +# +CREATE TABLE t1(col1 TEXT, +FULLTEXT INDEX USING BTREE (col1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1))' at line 2 +CREATE TABLE t2(col1 TEXT); +CREATE FULLTEXT INDEX USING BTREE ON t2(col); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE ON t2(col)' at line 1 +ALTER TABLE t2 ADD FULLTEXT INDEX USING BTREE (col1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1)' at line 1 +DROP TABLE t2; +End of 5.0 tests diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 140c133d75f..158fdb69c10 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -983,4 +983,17 @@ GEOMFROMTEXT( SELECT 1 FROM t1 WHERE a <> (SELECT GEOMETRYCOLLECTIONFROMWKB(b) FROM t1); 1 DROP TABLE t1; +# +# Bug #49250 : spatial btree index corruption and crash +# Part one : spatial syntax check +# +CREATE TABLE t1(col1 MULTIPOLYGON NOT NULL, +SPATIAL INDEX USING BTREE (col1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1))' at line 2 +CREATE TABLE t2(col1 MULTIPOLYGON NOT NULL); +CREATE SPATIAL INDEX USING BTREE ON t2(col); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE ON t2(col)' at line 1 +ALTER TABLE t2 ADD SPATIAL INDEX USING BTREE (col1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1)' at line 1 +DROP TABLE t2; End of 5.0 tests diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 9551c98f143..bcd27e51f24 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -455,3 +455,20 @@ EXECUTE s; DEALLOCATE PREPARE s; DROP TABLE t1; +--echo # +--echo # Bug #49250 : spatial btree index corruption and crash +--echo # Part two : fulltext syntax check +--echo # + +--error ER_PARSE_ERROR +CREATE TABLE t1(col1 TEXT, + FULLTEXT INDEX USING BTREE (col1)); +CREATE TABLE t2(col1 TEXT); +--error ER_PARSE_ERROR +CREATE FULLTEXT INDEX USING BTREE ON t2(col); +--error ER_PARSE_ERROR +ALTER TABLE t2 ADD FULLTEXT INDEX USING BTREE (col1); + +DROP TABLE t2; + +--echo End of 5.0 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 701a6cef6be..d2bfe7d90d4 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -669,5 +669,20 @@ SELECT 1 FROM t1 WHERE a <> (SELECT GEOMETRYCOLLECTIONFROMWKB(b) FROM t1); DROP TABLE t1; +--echo # +--echo # Bug #49250 : spatial btree index corruption and crash +--echo # Part one : spatial syntax check +--echo # + +--error ER_PARSE_ERROR +CREATE TABLE t1(col1 MULTIPOLYGON NOT NULL, + SPATIAL INDEX USING BTREE (col1)); +CREATE TABLE t2(col1 MULTIPOLYGON NOT NULL); +--error ER_PARSE_ERROR +CREATE SPATIAL INDEX USING BTREE ON t2(col); +--error ER_PARSE_ERROR +ALTER TABLE t2 ADD SPATIAL INDEX USING BTREE (col1); + +DROP TABLE t2; --echo End of 5.0 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2fc85b4bda7..3cd61605033 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -418,6 +418,34 @@ Item* handle_sql2003_note184_exception(THD *thd, Item* left, bool equal, DBUG_RETURN(result); } + +static bool add_create_index_prepare (LEX *lex, Table_ident *table) +{ + lex->sql_command= SQLCOM_CREATE_INDEX; + if (!lex->current_select->add_table_to_list(lex->thd, table, NULL, + TL_OPTION_UPDATING)) + return TRUE; + lex->alter_info.reset(); + lex->alter_info.flags= ALTER_ADD_INDEX; + lex->col_list.empty(); + lex->change= NullS; + return FALSE; +} + + +static bool add_create_index (LEX *lex, + Key::Keytype type, const char *name, enum ha_key_alg key_alg, + bool generated= 0) +{ + Key *key= new Key(type, name, key_alg, generated, lex->col_list); + if (key == NULL) + return TRUE; + + lex->alter_info.key_list.push_back(key); + lex->col_list.empty(); + return FALSE; +} + %} %union { int num; @@ -1110,7 +1138,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); option_type opt_var_type opt_var_ident_type %type - key_type opt_unique_or_fulltext constraint_key_type + key_type opt_unique fulltext_or_spatial constraint_key_type + key_type_fulltext_or_spatial %type key_alg opt_btree_or_rtree @@ -1543,27 +1572,25 @@ create: } create2 { Lex->current_select= &Lex->select_lex; } - | CREATE opt_unique_or_fulltext INDEX_SYM ident key_alg ON table_ident + | CREATE opt_unique INDEX_SYM ident key_alg ON table_ident { - LEX *lex=Lex; - lex->sql_command= SQLCOM_CREATE_INDEX; - if (!lex->current_select->add_table_to_list(lex->thd, $7, NULL, - TL_OPTION_UPDATING)) - MYSQL_YYABORT; - lex->alter_info.reset(); - lex->alter_info.flags= ALTER_ADD_INDEX; - lex->col_list.empty(); - lex->change=NullS; - } - '(' key_list ')' - { - LEX *lex=Lex; - Key *key= new Key($2, $4.str, $5, 0, lex->col_list); - if (key == NULL) + if (add_create_index_prepare (Lex, $7)) + MYSQL_YYABORT; + } + '(' key_list ')' + { + if (add_create_index (Lex, $2, $4.str, $5)) + MYSQL_YYABORT; + } + | CREATE fulltext_or_spatial INDEX_SYM ident ON table_ident + { + if (add_create_index_prepare (Lex, $6)) + MYSQL_YYABORT; + } + '(' key_list ')' + { + if (add_create_index (Lex, $2, $4.str, HA_KEY_ALG_UNDEF)) MYSQL_YYABORT; - - lex->alter_info.key_list.push_back(key); - lex->col_list.empty(); } | CREATE DATABASE opt_if_not_exists ident { @@ -3133,23 +3160,18 @@ column_def: key_def: key_type opt_ident key_alg '(' key_list ')' key_alg { - LEX *lex=Lex; - Key *key= new Key($1, $2, $7 ? $7 : $3, 0, lex->col_list); - if (key == NULL) + if (add_create_index (Lex, $1, $2, $7 ? $7 : $3)) + MYSQL_YYABORT; + } + | key_type_fulltext_or_spatial opt_ident '(' key_list ')' + { + if (add_create_index (Lex, $1, $2, HA_KEY_ALG_UNDEF)) MYSQL_YYABORT; - lex->alter_info.key_list.push_back(key); - - lex->col_list.empty(); /* Alloced by sql_alloc */ } | opt_constraint constraint_key_type opt_ident key_alg '(' key_list ')' key_alg { - LEX *lex=Lex; - const char *key_name= $3 ? $3:$1; - Key *key= new Key($2, key_name, $4, 0, lex->col_list); - if (key == NULL) + if (add_create_index (Lex, $2, $3 ? $3:$1, $4)) MYSQL_YYABORT; - lex->alter_info.key_list.push_back(key); - lex->col_list.empty(); /* Alloced by sql_alloc */ } | opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references { @@ -3164,13 +3186,9 @@ key_def: if (key == NULL) MYSQL_YYABORT; lex->alter_info.key_list.push_back(key); - key= new Key(Key::MULTIPLE, key_name, - HA_KEY_ALG_UNDEF, 1, - lex->col_list); - if (key == NULL) + if (add_create_index (lex, Key::MULTIPLE, key_name, + HA_KEY_ALG_UNDEF, 1)) MYSQL_YYABORT; - lex->alter_info.key_list.push_back(key); - lex->col_list.empty(); /* Alloced by sql_alloc */ } | constraint opt_check_constraint { @@ -3630,7 +3648,10 @@ delete_option: key_type: key_or_index { $$= Key::MULTIPLE; } - | FULLTEXT_SYM opt_key_or_index { $$= Key::FULLTEXT; } + ; + +key_type_fulltext_or_spatial: + FULLTEXT_SYM opt_key_or_index { $$= Key::FULLTEXT; } | SPATIAL_SYM opt_key_or_index { #ifdef HAVE_SPATIAL @@ -3660,10 +3681,8 @@ keys_or_index: | INDEX_SYM {} | INDEXES {}; -opt_unique_or_fulltext: - /* empty */ { $$= Key::MULTIPLE; } - | UNIQUE_SYM { $$= Key::UNIQUE; } - | FULLTEXT_SYM { $$= Key::FULLTEXT;} +fulltext_or_spatial: + FULLTEXT_SYM { $$= Key::FULLTEXT;} | SPATIAL_SYM { #ifdef HAVE_SPATIAL @@ -3676,6 +3695,11 @@ opt_unique_or_fulltext: } ; +opt_unique: + /* empty */ { $$= Key::MULTIPLE; } + | UNIQUE_SYM { $$= Key::UNIQUE; } + ; + key_alg: /* empty */ { $$= HA_KEY_ALG_UNDEF; } | USING opt_btree_or_rtree { $$= $2; } From d3c17518991c63e68edeec1df3072a42aa734756 Mon Sep 17 00:00:00 2001 From: MySQL Build Team Date: Wed, 3 Feb 2010 16:43:18 +0100 Subject: [PATCH 40/96] Backport into build-201002030816-5.0.87sp1 > ------------------------------------------------------------ > revno: 2840 [merge] > revision-id: ramil@mysql.com-20100113101142-pda4phrsyh1rjp85 > parent: joerg@mysql.com-20100112114118-zfpofgcu0j49j839 > parent: ramil@mysql.com-20100113052045-een35iazzk8023w2 > committer: Ramil Kalimullin > branch nick: mysql-5.0-bugteam > timestamp: Wed 2010-01-13 14:11:42 +0400 > message: > Auto-merge. > ------------------------------------------------------------ > Use --include-merges or -n0 to see merged revisions. --- extra/yassl/taocrypt/include/asn.hpp | 1 + extra/yassl/taocrypt/src/asn.cpp | 123 +++++++++++++++------------ 2 files changed, 69 insertions(+), 55 deletions(-) diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index 1c1850cb47e..168b8a8c755 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -305,6 +305,7 @@ private: bool ValidateSignature(SignerList*); bool ConfirmSignature(Source&); void GetKey(); + char* AddTag(char*, const char*, const char*, word32, word32); void GetName(NameType); void GetValidity(); void GetDate(DateType); diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index 78200841bda..f87b466502e 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -652,6 +652,23 @@ word32 CertDecoder::GetDigest() } +char *CertDecoder::AddTag(char *ptr, const char *buf_end, + const char *tag_name, word32 tag_name_length, + word32 tag_value_length) +{ + if (ptr + tag_name_length + tag_value_length > buf_end) + return 0; + + memcpy(ptr, tag_name, tag_name_length); + ptr+= tag_name_length; + + memcpy(ptr, source_.get_current(), tag_value_length); + ptr+= tag_value_length; + + return ptr; +} + + // process NAME, either issuer or subject void CertDecoder::GetName(NameType nt) { @@ -659,11 +676,21 @@ void CertDecoder::GetName(NameType nt) SHA sha; word32 length = GetSequence(); // length of all distinguished names - assert (length < ASN_NAME_MAX); + + if (length >= ASN_NAME_MAX) + goto err; length += source_.get_index(); - char* ptr = (nt == ISSUER) ? issuer_ : subject_; - word32 idx = 0; + char *ptr, *buf_end; + + if (nt == ISSUER) { + ptr= issuer_; + buf_end= ptr + sizeof(issuer_) - 1; // 1 byte for trailing 0 + } + else { + ptr= subject_; + buf_end= ptr + sizeof(subject_) - 1; // 1 byte for trailing 0 + } while (source_.get_index() < length) { GetSet(); @@ -685,47 +712,36 @@ void CertDecoder::GetName(NameType nt) byte id = source_.next(); b = source_.next(); // strType word32 strLen = GetLength(source_); - bool copy = false; - if (id == COMMON_NAME) { - memcpy(&ptr[idx], "/CN=", 4); - idx += 4; - copy = true; - } - else if (id == SUR_NAME) { - memcpy(&ptr[idx], "/SN=", 4); - idx += 4; - copy = true; - } - else if (id == COUNTRY_NAME) { - memcpy(&ptr[idx], "/C=", 3); - idx += 3; - copy = true; - } - else if (id == LOCALITY_NAME) { - memcpy(&ptr[idx], "/L=", 3); - idx += 3; - copy = true; - } - else if (id == STATE_NAME) { - memcpy(&ptr[idx], "/ST=", 4); - idx += 4; - copy = true; - } - else if (id == ORG_NAME) { - memcpy(&ptr[idx], "/O=", 3); - idx += 3; - copy = true; - } - else if (id == ORGUNIT_NAME) { - memcpy(&ptr[idx], "/OU=", 4); - idx += 4; - copy = true; - } - - if (copy) { - memcpy(&ptr[idx], source_.get_current(), strLen); - idx += strLen; + switch (id) { + case COMMON_NAME: + if (!(ptr= AddTag(ptr, buf_end, "/CN=", 4, strLen))) + goto err; + break; + case SUR_NAME: + if (!(ptr= AddTag(ptr, buf_end, "/SN=", 4, strLen))) + goto err; + break; + case COUNTRY_NAME: + if (!(ptr= AddTag(ptr, buf_end, "/C=", 3, strLen))) + goto err; + break; + case LOCALITY_NAME: + if (!(ptr= AddTag(ptr, buf_end, "/L=", 3, strLen))) + goto err; + break; + case STATE_NAME: + if (!(ptr= AddTag(ptr, buf_end, "/ST=", 4, strLen))) + goto err; + break; + case ORG_NAME: + if (!(ptr= AddTag(ptr, buf_end, "/O=", 3, strLen))) + goto err; + break; + case ORGUNIT_NAME: + if (!(ptr= AddTag(ptr, buf_end, "/OU=", 4, strLen))) + goto err; + break; } sha.Update(source_.get_current(), strLen); @@ -739,23 +755,20 @@ void CertDecoder::GetName(NameType nt) source_.advance(oidSz + 1); word32 length = GetLength(source_); - if (email) { - memcpy(&ptr[idx], "/emailAddress=", 14); - idx += 14; - - memcpy(&ptr[idx], source_.get_current(), length); - idx += length; - } + if (email && !(ptr= AddTag(ptr, buf_end, "/emailAddress=", 14, length))) + goto err; source_.advance(length); } } - ptr[idx++] = 0; + *ptr= 0; - if (nt == ISSUER) - sha.Final(issuerHash_); - else - sha.Final(subjectHash_); + sha.Final(nt == ISSUER ? issuerHash_ : subjectHash_); + + return; + +err: + source_.SetError(CONTENT_E); } From 635a83cc03ea45df1b739316ccff9edaf9032356 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Thu, 4 Feb 2010 11:26:36 +0000 Subject: [PATCH 41/96] BUG#50451: rpl_loaddata_concurrent fails sporadically When using MyIsam tables and processing concurrent DML statements, the server may be sending back an OK to the client before actually finishing the transaction commit procedure. This has been reported before in BUG@37521 and BUG@29334. This particular test case gets affected, because it performs the following sequence: connect (conn2, ...) connection conn2; LOAD DATA CONCURRENT ... disconnect (conn2, ...) connection master; sync_slave_with_master diff_tables At this point diff_tables may report difference in the table content (the master seems to be missing the conn2 rows). To workaround this MyISAM concurrent DML statements issue and make this test case deterministic, we wait on conn2 until the rows inserted show up in the table. After this the test case proceeds as normally would before this patch. --- mysql-test/extra/rpl_tests/rpl_loaddata.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test index 3f3c3624fa6..1ae17398596 100644 --- a/mysql-test/extra/rpl_tests/rpl_loaddata.test +++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test @@ -219,6 +219,19 @@ connect (conn2,localhost,root,,*NO-ONE*); -- echo ### assertion: works without stating the default database -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -- eval $UPPER_STMT_HEAD LOCAL INFILE '$MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE $db1.t1 + +# We cannot disconnect right away because when inserting +# concurrently in a MyISAM table, the server is sending an OK +# to the client before updating the table state (where the +# number of records is kept). See: BUG#37521 and BUG#29334. +# So we need to wait, otherwise we would be having sporadic +# failures as reported here: BUG#50451. + +# 12 = 3 rows per each LOAD DATA executed x 4 +-- let $count= 12 +-- let $table= $db1.t1 +--source include/wait_until_rows_count.inc + -- echo ### disconnect and switch back to master connection -- disconnect conn2 -- connection master From 1458896dca020ac0b8d8a857e4bb45b051660ee6 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Fri, 5 Feb 2010 17:01:09 +0000 Subject: [PATCH 42/96] BUG#48632: Fix for Bug #23300 Has Not Been Backported To 5.x Release Notes ===== This is a backport of BUG#23300 into 5.1 GA. Original cset revid (in betony): luis.soares@sun.com-20090929140901-s4kjtl3iiyy4ls2h Description =========== When using replication, the slave will not log any slow query logs queries replicated from the master, even if the option "--log-slow-slave-statements" is set and these take more than "log_query_time" to execute. In order to log slow queries in replicated thread one needs to set the --log-slow-slave-statements, so that the SQL thread is initialized with the correct switch. Although setting this flag correctly configures the slave thread option to log slow queries, there is an issue with the condition that is used to check whether to log the slow query or not. When replaying binlog events the statement contains the SET TIMESTAMP clause which will force the slow logging condition check to fail. Consequently, the slow query logging will not take place. This patch addresses this issue by removing the second condition from the log_slow_statements as it prevents slow queries to be binlogged and seems to be deprecated. --- .../suite/rpl/r/rpl_slow_query_log.result | 48 +++++ .../suite/rpl/t/rpl_slow_query_log-slave.opt | 1 + .../suite/rpl/t/rpl_slow_query_log.test | 193 ++++++++++++++++++ sql/log.cc | 1 + sql/sql_parse.cc | 4 +- 5 files changed, 245 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_slow_query_log.result create mode 100644 mysql-test/suite/rpl/t/rpl_slow_query_log-slave.opt create mode 100644 mysql-test/suite/rpl/t/rpl_slow_query_log.test diff --git a/mysql-test/suite/rpl/r/rpl_slow_query_log.result b/mysql-test/suite/rpl/r/rpl_slow_query_log.result new file mode 100644 index 00000000000..fd6a2c5d7c4 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_slow_query_log.result @@ -0,0 +1,48 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +CALL mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT"); +include/stop_slave.inc +SET @old_log_output= @@log_output; +SET GLOBAL log_output= 'TABLE'; +SET @old_long_query_time= @@long_query_time; +SET GLOBAL long_query_time= 2; +TRUNCATE mysql.slow_log; +include/start_slave.inc +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 values(1, 1); +INSERT INTO t1 values(1, sleep(3)); +TRUNCATE mysql.slow_log; +SELECT 1, sleep(3); +1 sleep(3) +1 0 +SELECT 1; +1 +1 +TRUNCATE mysql.slow_log; +SET TIMESTAMP= 1; +SELECT 2, sleep(3); +2 sleep(3) +2 0 +SELECT 2; +2 +2 +TRUNCATE mysql.slow_log; +SET @old_slow_query_log= @@slow_query_log; +SET GLOBAL slow_query_log= 'OFF'; +SELECT 3, sleep(3); +3 sleep(3) +3 0 +SELECT 3; +3 +3 +TRUNCATE mysql.slow_log; +SET GLOBAL slow_query_log= @old_slow_query_log; +DROP TABLE t1; +include/stop_slave.inc +SET GLOBAL long_query_time= @old_long_query_time; +SET GLOBAL log_output= @old_log_output; +include/start_slave.inc diff --git a/mysql-test/suite/rpl/t/rpl_slow_query_log-slave.opt b/mysql-test/suite/rpl/t/rpl_slow_query_log-slave.opt new file mode 100644 index 00000000000..a27d3a0f5a7 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_slow_query_log-slave.opt @@ -0,0 +1 @@ +--force-restart --log-slow-slave-statements --log-slow-queries diff --git a/mysql-test/suite/rpl/t/rpl_slow_query_log.test b/mysql-test/suite/rpl/t/rpl_slow_query_log.test new file mode 100644 index 00000000000..c310d6a8a4f --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_slow_query_log.test @@ -0,0 +1,193 @@ +# +# BUG#23300: Slow query log on slave does not log slow replicated statements +# +# Description: +# The slave should log slow queries replicated from master when +# --log-slow-slave-statements is used. +# +# Test is implemented as follows: +# i) stop slave +# ii) On slave, set long_query_time to a small value. +# ii) start slave so that long_query_time variable is picked by sql thread +# iii) On master, do one short time query and one long time query, on slave +# and check that slow query is logged to slow query log but fast query +# is not. +# iv) On slave, check that slow queries go into the slow log and fast dont, +# when issued through a regular client connection +# v) On slave, check that slow queries go into the slow log and fast dont +# when we use SET TIMESTAMP= 1 on a regular client connection. +# vi) check that when setting slow_query_log= OFF in a connection 'extra2' +# prevents logging slow queries in a connection 'extra' +# +# OBS: +# This test only runs for statement binlogging format because on row format +# slow queries do not get slow query logged. +# Note that due to the sleep() command the insert is written to the binary +# log in row format. + +source include/master-slave.inc; +source include/have_binlog_format_statement.inc; + +CALL mtr.add_suppression("Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT"); + + +# Prepare slave for different long_query_time we need to stop the slave +# and restart it as long_query_time variable is dynamic and, after +# setting it, it only takes effect on new connections. +# +# Reference: +# http://dev.mysql.com/doc/refman/6.0/en/set-option.html +connection slave; + +source include/stop_slave.inc; + +SET @old_log_output= @@log_output; +SET GLOBAL log_output= 'TABLE'; +SET @old_long_query_time= @@long_query_time; +SET GLOBAL long_query_time= 2; +TRUNCATE mysql.slow_log; + +source include/start_slave.inc; + +connection master; +CREATE TABLE t1 (a int, b int); + +# test: +# check that slave logs the slow query to the slow log, but not the fast one. + +let $slow_query= INSERT INTO t1 values(1, sleep(3)); +let $fast_query= INSERT INTO t1 values(1, 1); + +eval $fast_query; +--disable_warnings +eval $slow_query; +--enable_warnings +sync_slave_with_master; + +let $found_fast_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$fast_query'`; +let $found_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`; + +if ($found_fast_query) +{ + SELECT * FROM mysql.slow_log; + die "Assertion failed! Fast query FOUND in slow query log. Bailing out!"; +} + +if (!$found_slow_query) +{ + SELECT * FROM mysql.slow_log; + die "Assertion failed! Slow query NOT FOUND in slow query log. Bailing out!"; +} +TRUNCATE mysql.slow_log; + +# regular checks for slow query log (using a new connection - 'extra' - to slave) + +# test: +# when using direct connections to the slave, check that slow query is logged +# but not the fast one. + +connect(extra,127.0.0.1,root,,test,$SLAVE_MYPORT); +connection extra; + +let $fast_query= SELECT 1; +let $slow_query= SELECT 1, sleep(3); + +eval $slow_query; +eval $fast_query; + +let $found_fast_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$fast_query'`; +let $found_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`; + +if ($found_fast_query) +{ + SELECT * FROM mysql.slow_log; + die "Assertion failed! Fast query FOUND in slow query log. Bailing out!"; +} + +if (!$found_slow_query) +{ + SELECT * FROM mysql.slow_log; + die "Assertion failed! Slow query NOT FOUND in slow query log. Bailing out!"; +} +TRUNCATE mysql.slow_log; + +# test: +# when using direct connections to the slave, check that when setting timestamp to 1 the +# slow query is logged but the fast one is not. + +let $fast_query= SELECT 2; +let $slow_query= SELECT 2, sleep(3); + +SET TIMESTAMP= 1; +eval $slow_query; +eval $fast_query; + +let $found_fast_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$fast_query'`; +let $found_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`; + +if ($found_fast_query) +{ + SELECT * FROM mysql.slow_log; + die "Assertion failed! Fast query FOUND in slow query log. Bailing out!"; +} + +if (!$found_slow_query) +{ + SELECT * FROM mysql.slow_log; + die "Assertion failed! Slow query NOT FOUND in slow query log. Bailing out!"; +} +TRUNCATE mysql.slow_log; + +# test: +# check that when setting the slow_query_log= OFF on connection 'extra2' +# prevents connection 'extra' from logging to slow query log. + +let $fast_query= SELECT 3; +let $slow_query= SELECT 3, sleep(3); + +connect(extra2,127.0.0.1,root,,test,$SLAVE_MYPORT); +connection extra2; + +SET @old_slow_query_log= @@slow_query_log; +SET GLOBAL slow_query_log= 'OFF'; + +connection extra; + +eval $slow_query; +eval $fast_query; + +let $found_fast_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$fast_query'`; +let $found_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`; + +if ($found_fast_query) +{ + SELECT * FROM mysql.slow_log; + die "Assertion failed! Fast query FOUND in slow query log when slow_query_log= OFF. Bailing out!"; +} + +if ($found_slow_query) +{ + SELECT * FROM mysql.slow_log; + die "Assertion failed! Slow query FOUND in slow query log when slow_query_log= OFF. Bailing out!"; +} +TRUNCATE mysql.slow_log; + +# clean up: drop tables, reset the variables back to the previous value, +# disconnect extra connections +connection extra2; + +SET GLOBAL slow_query_log= @old_slow_query_log; + +connection master; +DROP TABLE t1; +sync_slave_with_master; + +source include/stop_slave.inc; + +SET GLOBAL long_query_time= @old_long_query_time; +SET GLOBAL log_output= @old_log_output; + +source include/start_slave.inc; + +disconnect extra; +disconnect extra2; diff --git a/sql/log.cc b/sql/log.cc index 5544d0010ef..b7313a988c4 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -964,6 +964,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, uint user_host_len= 0; ulonglong query_utime, lock_utime; + DBUG_ASSERT(thd->enable_slow_log); /* Print the message to the buffer if we have slow log enabled */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index df2c1854914..168b16c61bf 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1656,9 +1656,9 @@ void log_slow_statement(THD *thd) /* Do not log administrative statements unless the appropriate option is - set; do not log into slow log if reading from backup. + set. */ - if (thd->enable_slow_log && !thd->user_time) + if (thd->enable_slow_log) { ulonglong end_utime_of_query= thd->current_utime(); thd_proc_info(thd, "logging slow query"); From d0c74a61b220bb67431d0f9804ff44c93f7971bd Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Fri, 5 Feb 2010 17:48:01 +0000 Subject: [PATCH 43/96] BUG#50620: Adding an index to a table prevents slave from logging into slow log While processing a statement, down the mysql_parse execution stack, the thd->enable_slow_log can be assigned to opt_log_slow_admin_statements, depending whether one is executing administrative statements, such as ALTER TABLE, OPTIMIZE, ANALYZE, etc, or not. This can have an impact on slow logging for statements that are executed after an administrative statement execution is completed. When executing statements directly from the user this is fine because, the thd->enable_slow_log is reset right at the beginning of the dispatch_command function, ie, everytime a new statement is set is set to execute. On the other hand, for slave SQL thread (sql_thd) the story is a bit different. When in SBR the sql_thd applies statements by calling mysql_parse. Right after, it calls log_slow_statement function to log them if they take too long. Calling mysql_parse directly is fine, but also means that dispatch_command function is bypassed. As a consequence, thd->enable_slow_log does not get a chance to be reset before the next statement to be executed by the sql_thd. If the statement just executed by the sql_thd was an administrative statement and logging of admin statements was disabled, this means that sql_thd->enable_slow_log will be set to 0 (disabled) from that moment on. End result: sql_thd stops logging slow statements. We fix this by resetting the value of sql_thd->enable_slow_log to the value of opt_log_slow_slave_statements right after log_slow_stement is called by the sql_thd. --- .../suite/rpl/r/rpl_slow_query_log.result | 43 +++++++ .../suite/rpl/t/rpl_slow_query_log.test | 117 +++++++++++++++++- sql/log_event.cc | 12 ++ 3 files changed, 171 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/r/rpl_slow_query_log.result b/mysql-test/suite/rpl/r/rpl_slow_query_log.result index fd6a2c5d7c4..a4479f0c544 100644 --- a/mysql-test/suite/rpl/r/rpl_slow_query_log.result +++ b/mysql-test/suite/rpl/r/rpl_slow_query_log.result @@ -46,3 +46,46 @@ include/stop_slave.inc SET GLOBAL long_query_time= @old_long_query_time; SET GLOBAL log_output= @old_log_output; include/start_slave.inc +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +SET @old_log_output= @@log_output; +SET GLOBAL log_output= 'TABLE'; +SET GLOBAL long_query_time= 2; +SET @old_long_query_time= @@long_query_time; +SET SESSION long_query_time= 2; +TRUNCATE mysql.slow_log; +include/stop_slave.inc +SET @old_log_output= @@log_output; +SET GLOBAL log_output= 'TABLE'; +SET @old_long_query_time= @@long_query_time; +SET GLOBAL long_query_time= 2; +TRUNCATE mysql.slow_log; +include/start_slave.inc +CREATE TABLE t1 (a int, b int); +******************************************************************** +**** INSERT one row that exceeds long_query_time +**** Outcome: query ends up in both master and slave slow log +******************************************************************** +INSERT INTO t1 values(1, sleep(3)); +### Assertion is good. Both Master and Slave exhibit the +### same number of queries in slow log: 1 +TRUNCATE mysql.slow_log; +TRUNCATE mysql.slow_log; +******************************************************************** +**** Now do inserts again, but first add an index to the table. +**** Outcome: Note that the slave contains the same one entry (as +**** the master does) whereas before the patch it did not. +******************************************************************** +ALTER TABLE t1 ADD INDEX id1(a); +INSERT INTO t1 values(1, sleep(3)); +### Assertion is good. Both Master and Slave exhibit the +### same number of queries in slow log: 1 +SET @@global.log_output= @old_log_output; +SET @@global.long_query_time= @old_long_query_time; +DROP TABLE t1; +SET @@global.log_output= @old_log_output; +SET @@global.long_query_time= @old_long_query_time; diff --git a/mysql-test/suite/rpl/t/rpl_slow_query_log.test b/mysql-test/suite/rpl/t/rpl_slow_query_log.test index c310d6a8a4f..ced4859ebe7 100644 --- a/mysql-test/suite/rpl/t/rpl_slow_query_log.test +++ b/mysql-test/suite/rpl/t/rpl_slow_query_log.test @@ -175,7 +175,6 @@ TRUNCATE mysql.slow_log; # clean up: drop tables, reset the variables back to the previous value, # disconnect extra connections connection extra2; - SET GLOBAL slow_query_log= @old_slow_query_log; connection master; @@ -191,3 +190,119 @@ source include/start_slave.inc; disconnect extra; disconnect extra2; + +# +# BUG#50620: Adding an index to a table prevents slave from logging into slow log +# + +-- source include/master-slave-reset.inc + +-- connection master +SET @old_log_output= @@log_output; +SET GLOBAL log_output= 'TABLE'; +SET GLOBAL long_query_time= 2; +SET @old_long_query_time= @@long_query_time; +SET SESSION long_query_time= 2; +TRUNCATE mysql.slow_log; +-- connection slave + +-- source include/stop_slave.inc +SET @old_log_output= @@log_output; +SET GLOBAL log_output= 'TABLE'; +SET @old_long_query_time= @@long_query_time; +SET GLOBAL long_query_time= 2; +TRUNCATE mysql.slow_log; +-- source include/start_slave.inc + +let $slow_query= INSERT INTO t1 values(1, sleep(3)); + +-- connection master +CREATE TABLE t1 (a int, b int); + +-- echo ******************************************************************** +-- echo **** INSERT one row that exceeds long_query_time +-- echo **** Outcome: query ends up in both master and slave slow log +-- echo ******************************************************************** + +-- disable_warnings +-- eval $slow_query +-- enable_warnings + +let $master_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`; +-- sync_slave_with_master +let $slave_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`; + +if (`SELECT $master_slow_query != $slave_slow_query`) +{ + -- connection master + -- echo *********************************************** + -- echo ** DUMPING MASTER SLOW LOG CONTENTS + -- echo *********************************************** + SELECT * FROM mysql.slow_log; + + -- connection slave + -- echo *********************************************** + -- echo ** DUMPING SLAVE SLOW LOG CONTENTS + -- echo *********************************************** + SELECT * FROM mysql.slow_log; + + -- die "Assertion failed! Master and slave slow log contents differ. Bailing out!" +} + +if (`SELECT $master_slow_query = $slave_slow_query`) +{ + -- echo ### Assertion is good. Both Master and Slave exhibit the + -- echo ### same number of queries in slow log: $master_slow_query +} + +TRUNCATE mysql.slow_log; +-- connection master +TRUNCATE mysql.slow_log; + +-- echo ******************************************************************** +-- echo **** Now do inserts again, but first add an index to the table. +-- echo **** Outcome: Note that the slave contains the same one entry (as +-- echo **** the master does) whereas before the patch it did not. +-- echo ******************************************************************** + +ALTER TABLE t1 ADD INDEX id1(a); + +-- disable_warnings +-- eval $slow_query +-- enable_warnings + +let $master_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`; +-- sync_slave_with_master +let $slave_slow_query= `SELECT count(*) = 1 FROM mysql.slow_log WHERE sql_text like '$slow_query'`; + +if (`SELECT $master_slow_query != $slave_slow_query`) +{ + -- connection master + -- echo *********************************************** + -- echo ** DUMPING MASTER SLOW LOG CONTENTS + -- echo *********************************************** + SELECT * FROM mysql.slow_log; + + -- connection slave + -- echo *********************************************** + -- echo ** DUMPING SLAVE SLOW LOG CONTENTS + -- echo *********************************************** + SELECT * FROM mysql.slow_log; + + -- die "Assertion failed! Master and slave slow log contents differ. Bailing out!" +} + +if (`SELECT $master_slow_query = $slave_slow_query`) +{ + -- echo ### Assertion is good. Both Master and Slave exhibit the + -- echo ### same number of queries in slow log: $master_slow_query +} + +-- connection master +SET @@global.log_output= @old_log_output; +SET @@global.long_query_time= @old_long_query_time; +DROP TABLE t1; + +-- sync_slave_with_master +SET @@global.log_output= @old_log_output; +SET @@global.long_query_time= @old_long_query_time; diff --git a/sql/log_event.cc b/sql/log_event.cc index 2da825e63ce..de395f3d4c7 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -3170,6 +3170,18 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, const char* found_semicolon= NULL; mysql_parse(thd, thd->query(), thd->query_length(), &found_semicolon); log_slow_statement(thd); + + /* + Resetting the enable_slow_log thd variable. + + We need to reset it back to the opt_log_slow_slave_statements + value after the statement execution (and slow logging + is done). It might have changed if the statement was an + admin statement (in which case, down in mysql_parse execution + thd->enable_slow_log is set to the value of + opt_log_slow_admin_statements). + */ + thd->enable_slow_log= opt_log_slow_slave_statements; } else { From a26ab94eb27827b3961464b97b50e63d98135c1e Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Fri, 5 Feb 2010 17:51:55 +0000 Subject: [PATCH 44/96] BUG#50780: 'show binary logs' debug assertion when binary logging is disabled The server would hit an assertion because of a DBUG violation. There was a missing DBUG_RETURN and instead a plain return was used. This patch replaces the return with DBUG_RETURN. --- mysql-test/r/no_binlog.result | 2 ++ mysql-test/t/no_binlog.test | 4 ++++ sql/sql_repl.cc | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/no_binlog.result create mode 100644 mysql-test/t/no_binlog.test diff --git a/mysql-test/r/no_binlog.result b/mysql-test/r/no_binlog.result new file mode 100644 index 00000000000..6ae267664fd --- /dev/null +++ b/mysql-test/r/no_binlog.result @@ -0,0 +1,2 @@ +SHOW BINARY LOGS; +ERROR HY000: You are not using binary logging diff --git a/mysql-test/t/no_binlog.test b/mysql-test/t/no_binlog.test new file mode 100644 index 00000000000..628a4ab8351 --- /dev/null +++ b/mysql-test/t/no_binlog.test @@ -0,0 +1,4 @@ +# BUG#50780: 'show binary logs' debug assertion when binary logging is disabled + +-- error ER_NO_BINARY_LOGGING +SHOW BINARY LOGS; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 4b10d284611..ae995ea5ed3 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1606,7 +1606,7 @@ bool show_binlogs(THD* thd) if (!mysql_bin_log.is_open()) { my_message(ER_NO_BINARY_LOGGING, ER(ER_NO_BINARY_LOGGING), MYF(0)); - return 1; + DBUG_RETURN(TRUE); } field_list.push_back(new Item_empty_string("Log_name", 255)); From 57e5f8487f011b5ec7395acd75759d9061439f1b Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Sat, 6 Feb 2010 23:54:30 +0400 Subject: [PATCH 45/96] Bug #45640: optimizer bug produces wrong results Grouping by a subquery in a query with a distinct aggregate function lead to a wrong result (wrong and unordered grouping values). There are two related problems: 1) The query like this: SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) c FROM t1 GROUP BY aa returned wrong result, because the outer reference "t1.a" in the subquery was substituted with the Item_ref item. The Item_ref item obtains data from the result_field object that refreshes once after the end of each group. This data is not applicable to filesort since filesort() doesn't care about groups (and doesn't update result_field objects with copy_fields() and so on). Also that data is not applicable to group separation algorithm: end_send_group() checks every record with test_if_group_changed() that evaluates Item_ref items, but it refreshes those Item_ref-s only after the end of group, that is a vicious circle and the grouped column values in the output are shifted. Fix: if a) we grouping by a subquery and b) that subquery has outer references to FROM list of the grouping query, then we substitute these outer references with Item_direct_ref like references under aggregate functions: Item_direct_ref obtains data directly from the current record. 2) The query with a non-trivial grouping expression like: SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) c FROM t1 GROUP BY aa+0 also returned wrong result, since JOIN::exec() substitutes references to top-level aliases in SELECT list with Item_copy caching items. Item_copy items have same refreshing policy as Item_ref items, so the whole groping expression with Item_copy inside returns wrong result in filesort() and end_send_group(). Fix: include aliased items into GROUP BY item tree instead of Item_ref references to them. --- mysql-test/r/group_by.result | 88 ++++++++++++++++++++++++++++++++++++ mysql-test/t/group_by.test | 50 ++++++++++++++++++++ sql/item.cc | 28 +++++++++--- sql/item.h | 6 ++- sql/mysql_priv.h | 2 +- sql/sql_lex.cc | 1 + sql/sql_lex.h | 2 + sql/sql_select.cc | 46 +++++++++++++++++-- 8 files changed, 211 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 742d4b90807..6ca08df40ea 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1703,3 +1703,91 @@ COUNT(i) 1 DROP TABLE t1; SET @@sql_mode = @old_sql_mode; +# +# Bug #45640: optimizer bug produces wrong results +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (4, 40), (1, 10), (2, 20), (2, 20), (3, 30); +# should return 4 ordered records: +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +SELECT (SELECT (SELECT t1.a)) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0; +aa COUNT(DISTINCT b) +1 1 +2 1 +3 1 +4 1 +# should return the same result in a reverse order: +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; +aa COUNT(DISTINCT b) +4 1 +3 1 +2 1 +1 1 +# execution plan should not use temporary table: +EXPLAIN EXTENDED +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 Using filesort +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 select (select `test`.`t1`.`a` AS `a`) AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by ((select `test`.`t1`.`a` AS `a`) + 0) +EXPLAIN EXTENDED +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 Using filesort +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 select (select `test`.`t1`.`a` AS `a`) AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by -((select `test`.`t1`.`a` AS `a`)) +# should return only one record +SELECT (SELECT tt.a FROM t1 tt LIMIT 1) aa, COUNT(DISTINCT b) FROM t1 +GROUP BY aa; +aa COUNT(DISTINCT b) +4 4 +CREATE TABLE t2 SELECT DISTINCT a FROM t1; +# originally reported queries (1st two columns of next two query +# results should be same): +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b) +FROM t1 GROUP BY aa, b; +aa b COUNT(DISTINCT b) +1 10 1 +2 20 1 +3 30 1 +4 40 1 +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b) +FROM t1 GROUP BY aa, b; +aa b COUNT( b) +1 10 1 +2 20 2 +3 30 1 +4 40 1 +# ORDER BY for sure: +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b) +FROM t1 GROUP BY aa, b ORDER BY -aa, -b; +aa b COUNT(DISTINCT b) +4 40 1 +3 30 1 +2 20 1 +1 10 1 +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b) +FROM t1 GROUP BY aa, b ORDER BY -aa, -b; +aa b COUNT( b) +4 40 1 +3 30 1 +2 20 2 +1 10 1 +DROP TABLE t1, t2; +# +# End of 5.1 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 5b96213034a..e6ea5ecc7f6 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1158,3 +1158,53 @@ SELECT COUNT(i) FROM t1 WHERE i > 1; DROP TABLE t1; SET @@sql_mode = @old_sql_mode; +--echo # +--echo # Bug #45640: optimizer bug produces wrong results +--echo # + +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (4, 40), (1, 10), (2, 20), (2, 20), (3, 30); + +--echo # should return 4 ordered records: +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; + +SELECT (SELECT (SELECT t1.a)) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; + +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0; + +--echo # should return the same result in a reverse order: +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; + +--echo # execution plan should not use temporary table: +EXPLAIN EXTENDED +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa+0; + +EXPLAIN EXTENDED +SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; + +--echo # should return only one record +SELECT (SELECT tt.a FROM t1 tt LIMIT 1) aa, COUNT(DISTINCT b) FROM t1 + GROUP BY aa; + +CREATE TABLE t2 SELECT DISTINCT a FROM t1; + +--echo # originally reported queries (1st two columns of next two query +--echo # results should be same): + +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b) + FROM t1 GROUP BY aa, b; +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b) + FROM t1 GROUP BY aa, b; + +--echo # ORDER BY for sure: + +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT(DISTINCT b) + FROM t1 GROUP BY aa, b ORDER BY -aa, -b; +SELECT (SELECT t2.a FROM t2 WHERE t2.a = t1.a) aa, b, COUNT( b) + FROM t1 GROUP BY aa, b ORDER BY -aa, -b; + +DROP TABLE t1, t2; + +--echo # + +--echo # End of 5.1 tests diff --git a/sql/item.cc b/sql/item.cc index 68c10c32b50..c967a1a0feb 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4300,17 +4300,33 @@ bool Item_field::fix_fields(THD *thd, Item **reference) It's not an Item_field in the select list so we must make a new Item_ref to point to the Item in the select list and replace the Item_field created by the parser with the new Item_ref. + + NOTE: If we are fixing an alias reference inside ORDER/GROUP BY + item tree, then we use new Item_ref as an intermediate value + to resolve referenced item only. + In this case the new Item_ref item is unused. */ Item_ref *rf= new Item_ref(context, db_name,table_name,field_name); if (!rf) return 1; - thd->change_item_tree(reference, rf); + + bool save_group_fix_field= thd->lex->current_select->group_fix_field; /* - Because Item_ref never substitutes itself with other items - in Item_ref::fix_fields(), we can safely use the original - pointer to it even after fix_fields() - */ - return rf->fix_fields(thd, reference) || rf->check_cols(1); + No need for recursive resolving of aliases. + */ + thd->lex->current_select->group_fix_field= 0; + + bool ret= rf->fix_fields(thd, (Item **) &rf) || rf->check_cols(1); + thd->lex->current_select->group_fix_field= save_group_fix_field; + if (ret) + return TRUE; + + if (save_group_fix_field && alias_name_used) + thd->change_item_tree(reference, *rf->ref); + else + thd->change_item_tree(reference, rf); + + return FALSE; } } } diff --git a/sql/item.h b/sql/item.h index 88e90924fcc..d2e8382023b 100644 --- a/sql/item.h +++ b/sql/item.h @@ -901,6 +901,7 @@ public: virtual bool change_context_processor(uchar *context) { return 0; } virtual bool reset_query_id_processor(uchar *query_id_arg) { return 0; } virtual bool is_expensive_processor(uchar *arg) { return 0; } + virtual bool find_item_processor(uchar *arg) { return this == (void *) arg; } virtual bool register_field_in_read_map(uchar *arg) { return 0; } /* Check if a partition function is allowed @@ -2275,7 +2276,10 @@ public: return ref ? (*ref)->real_item() : this; } bool walk(Item_processor processor, bool walk_subquery, uchar *arg) - { return (*ref)->walk(processor, walk_subquery, arg); } + { + return (*ref)->walk(processor, walk_subquery, arg) || + (this->*processor)(arg); + } virtual void print(String *str, enum_query_type query_type); bool result_as_longlong() { diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 34f29e7c458..1b775e658f1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1192,7 +1192,7 @@ int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, List &fields, List &all_fields, ORDER *order, bool *hidden_group_fields); bool fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select, - Item **ref_pointer_array); + Item **ref_pointer_array, ORDER *group_list= NULL); bool handle_select(THD *thd, LEX *lex, select_result *result, ulong setup_tables_done_option); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2adbc44eb12..5097ca2ad5b 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1592,6 +1592,7 @@ void st_select_lex::init_query() having= prep_having= where= prep_where= 0; olap= UNSPECIFIED_OLAP_TYPE; having_fix_field= 0; + group_fix_field= 0; context.select_lex= this; context.init(); /* diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 4e4794ef2cf..459878c03fc 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -647,6 +647,8 @@ public: bool braces; /* SELECT ... UNION (SELECT ... ) <- this braces */ /* TRUE when having fix field called in processing of this SELECT */ bool having_fix_field; + /* TRUE when GROUP BY fix field called in processing of this SELECT */ + bool group_fix_field; /* List of references to fields referenced from inner selects */ List inner_refs_list; /* Number of Item_sum-derived objects in this SELECT */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8744f77d6b1..ec880f3703e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -287,6 +287,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, all_fields List of all fields used in select select Current select ref_pointer_array Array of references to Items used in current select + group_list GROUP BY list (is NULL by default) DESCRIPTION The function serves 3 purposes - adds fields referenced from inner @@ -305,6 +306,8 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, function is aggregated in the select where the outer field was resolved or in some more inner select then the Item_direct_ref class should be used. + Also it should be used if we are grouping by a subquery containing + the outer field. The resolution is done here and not at the fix_fields() stage as it can be done only after sum functions are fixed and pulled up to selects where they are have to be aggregated. @@ -321,7 +324,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, bool fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select, - Item **ref_pointer_array) + Item **ref_pointer_array, ORDER *group_list) { Item_outer_ref *ref; bool res= FALSE; @@ -371,6 +374,22 @@ fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select, } } } + else + { + /* + Check if GROUP BY item trees contain the outer ref: + in this case we have to use Item_direct_ref instead of Item_ref. + */ + for (ORDER *group= group_list; group; group= group->next) + { + if ((*group->item)->walk(&Item::find_item_processor, TRUE, + (uchar *) ref)) + { + direct_ref= TRUE; + break; + } + } + } new_ref= direct_ref ? new Item_direct_ref(ref->context, item_ref, ref->table_name, ref->field_name, ref->alias_name_used) : @@ -577,7 +596,8 @@ JOIN::prepare(Item ***rref_pointer_array, } if (select_lex->inner_refs_list.elements && - fix_inner_refs(thd, all_fields, select_lex, ref_pointer_array)) + fix_inner_refs(thd, all_fields, select_lex, ref_pointer_array, + group_list)) DBUG_RETURN(-1); if (group_list) @@ -14547,11 +14567,29 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, We check order_item->fixed because Item_func_group_concat can put arguments for which fix_fields already was called. + + group_fix_field= TRUE is to resolve aliases from the SELECT list + without creating of Item_ref-s: JOIN::exec() wraps aliased items + in SELECT list with Item_copy items. To re-evaluate such a tree + that includes Item_copy items we have to refresh Item_copy caches, + but: + - filesort() never refresh Item_copy items, + - end_send_group() checks every record for group boundary by the + test_if_group_changed function that obtain data from these + Item_copy items, but the copy_fields function that + refreshes Item copy items is called after group boundaries only - + that is a vicious circle. + So we prevent inclusion of Item_copy items. */ - if (!order_item->fixed && + bool save_group_fix_field= thd->lex->current_select->group_fix_field; + if (is_group_field) + thd->lex->current_select->group_fix_field= TRUE; + bool ret= (!order_item->fixed && (order_item->fix_fields(thd, order->item) || (order_item= *order->item)->check_cols(1) || - thd->is_fatal_error)) + thd->is_fatal_error)); + thd->lex->current_select->group_fix_field= save_group_fix_field; + if (ret) return TRUE; /* Wrong field. */ uint el= all_fields.elements; From 29b733873670a2938497b5c6bdb4ec3d1d4eb4f0 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Sun, 7 Feb 2010 00:12:04 +0000 Subject: [PATCH 46/96] BUG#50780: 'show binary logs' debug assertion when binary logging is disabled Post-push fix: disabling test when running mysqld in embedded mode. --- mysql-test/t/no_binlog.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/t/no_binlog.test b/mysql-test/t/no_binlog.test index 628a4ab8351..fa9c87079de 100644 --- a/mysql-test/t/no_binlog.test +++ b/mysql-test/t/no_binlog.test @@ -1,3 +1,5 @@ +-- source include/not_embedded.inc + # BUG#50780: 'show binary logs' debug assertion when binary logging is disabled -- error ER_NO_BINARY_LOGGING From 06fb46a02939199e45eb4e064c394906e90cabfc Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 9 Feb 2010 12:53:13 +0400 Subject: [PATCH 47/96] BUG#49902 - SELECT returns incorrect results Queries optimized with GROUP_MIN_MAX didn't cleanup KEYREAD optimization properly. As a result subsequent queries may return incomplete rows (fields are initialized to default values). --- mysql-test/r/group_min_max.result | 13 ++++++ mysql-test/t/group_min_max.test | 10 +++++ sql/opt_range.cc | 15 ++----- sql/opt_sum.cc | 17 ++------ sql/sql_select.cc | 66 +++++++------------------------ sql/sql_update.cc | 9 +---- sql/table.cc | 5 +-- sql/table.h | 14 +++++++ 8 files changed, 62 insertions(+), 87 deletions(-) diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 662cc5be034..745fe11704c 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2524,4 +2524,17 @@ SELECT a, MAX(b) FROM t WHERE b GROUP BY a; a MAX(b) 2 1 DROP TABLE t; +CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b)); +INSERT INTO t1 VALUES(1,1),(2,1); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b; +c b +1 1 +SELECT a FROM t1 WHERE b=1; +a +1 +2 +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index f623df372fa..df385dfa7d2 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -1044,4 +1044,14 @@ SELECT a, MAX(b) FROM t WHERE b GROUP BY a; DROP TABLE t; +# +# BUG#49902 - SELECT returns incorrect results +# +CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL, KEY (b)); +INSERT INTO t1 VALUES(1,1),(2,1); +ANALYZE TABLE t1; +SELECT 1 AS c, b FROM t1 WHERE b IN (1,2) GROUP BY c, b; +SELECT a FROM t1 WHERE b=1; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 94204962345..34757a44c2f 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1171,11 +1171,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() if (file) { range_end(); - if (head->key_read) - { - head->key_read= 0; - file->extra(HA_EXTRA_NO_KEYREAD); - } + head->set_keyread(FALSE); if (free_file) { DBUG_PRINT("info", ("Freeing separate handler 0x%lx (free: %d)", (long) file, @@ -1377,10 +1373,7 @@ end: head->file= file; /* We don't have to set 'head->keyread' here as the 'file' is unique */ if (!head->no_keyread) - { - head->key_read= 1; head->mark_columns_used_by_index(index); - } head->prepare_for_position(); head->file= org_file; bitmap_copy(&column_bitmap, head->read_set); @@ -8165,7 +8158,7 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::read_keys_and_merge"); /* We're going to just read rowids. */ - file->extra(HA_EXTRA_KEYREAD); + head->set_keyread(TRUE); head->prepare_for_position(); cur_quick_it.rewind(); @@ -8241,7 +8234,7 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() delete unique; doing_pk_scan= FALSE; /* index_merge currently doesn't support "using index" at all */ - file->extra(HA_EXTRA_NO_KEYREAD); + head->set_keyread(FALSE); init_read_record(&read_record, thd, head, (SQL_SELECT*) 0, 1 , 1, TRUE); DBUG_RETURN(result); } @@ -10628,7 +10621,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void) int result; DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::reset"); - file->extra(HA_EXTRA_KEYREAD); /* We need only the key attributes */ + head->set_keyread(TRUE); /* We need only the key attributes */ if ((result= file->ha_index_init(index,1))) DBUG_RETURN(result); if (quick_prefix_select && quick_prefix_select->reset()) diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index e009cf1ca9f..70d6d0a5b17 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -326,11 +326,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) if (!error && reckey_in_range(0, &ref, item_field->field, conds, range_fl, prefix_len)) error= HA_ERR_KEY_NOT_FOUND; - if (table->key_read) - { - table->key_read= 0; - table->file->extra(HA_EXTRA_NO_KEYREAD); - } + table->set_keyread(FALSE); table->file->ha_index_end(); if (error) { @@ -413,11 +409,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) if (!error && reckey_in_range(1, &ref, item_field->field, conds, range_fl, prefix_len)) error= HA_ERR_KEY_NOT_FOUND; - if (table->key_read) - { - table->key_read=0; - table->file->extra(HA_EXTRA_NO_KEYREAD); - } + table->set_keyread(FALSE); table->file->ha_index_end(); if (error) { @@ -876,10 +868,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, converted (for example to upper case) */ if (field->part_of_key.is_set(idx)) - { - table->key_read= 1; - table->file->extra(HA_EXTRA_KEYREAD); - } + table->set_keyread(TRUE); return 1; } } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d5ce32902c4..ab8b65b5cc7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6594,10 +6594,7 @@ make_join_readinfo(JOIN *join, ulonglong options) case JT_CONST: // Only happens with left join if (table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) - { - table->key_read=1; - table->file->extra(HA_EXTRA_KEYREAD); - } + table->set_keyread(TRUE); break; case JT_ALL: /* @@ -6658,10 +6655,7 @@ make_join_readinfo(JOIN *join, ulonglong options) if (tab->select && tab->select->quick && tab->select->quick->index != MAX_KEY && //not index_merge table->covering_keys.is_set(tab->select->quick->index)) - { - table->key_read=1; - table->file->extra(HA_EXTRA_KEYREAD); - } + table->set_keyread(TRUE); else if (!table->covering_keys.is_clear_all() && !(tab->select && tab->select->quick)) { // Only read index tree @@ -6745,11 +6739,7 @@ void JOIN_TAB::cleanup() limit= 0; if (table) { - if (table->key_read) - { - table->key_read= 0; - table->file->extra(HA_EXTRA_NO_KEYREAD); - } + table->set_keyread(FALSE); table->file->ha_index_or_rnd_end(); /* We need to reset this for next select @@ -11595,16 +11585,11 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos) !table->no_keyread && (int) table->reginfo.lock_type <= (int) TL_READ_HIGH_PRIORITY) { - table->key_read=1; - table->file->extra(HA_EXTRA_KEYREAD); + table->set_keyread(TRUE); tab->index= tab->ref.key; } error=join_read_const(tab); - if (table->key_read) - { - table->key_read=0; - table->file->extra(HA_EXTRA_NO_KEYREAD); - } + table->set_keyread(FALSE); if (error) { tab->info="unique row not found"; @@ -11959,12 +11944,8 @@ join_read_first(JOIN_TAB *tab) { int error; TABLE *table=tab->table; - if (!table->key_read && table->covering_keys.is_set(tab->index) && - !table->no_keyread) - { - table->key_read=1; - table->file->extra(HA_EXTRA_KEYREAD); - } + if (table->covering_keys.is_set(tab->index) && !table->no_keyread) + table->set_keyread(TRUE); tab->table->status=0; tab->read_record.read_record=join_read_next; tab->read_record.table=table; @@ -11998,12 +11979,8 @@ join_read_last(JOIN_TAB *tab) { TABLE *table=tab->table; int error; - if (!table->key_read && table->covering_keys.is_set(tab->index) && - !table->no_keyread) - { - table->key_read=1; - table->file->extra(HA_EXTRA_KEYREAD); - } + if (table->covering_keys.is_set(tab->index) && !table->no_keyread) + table->set_keyread(TRUE); tab->table->status=0; tab->read_record.read_record=join_read_prev; tab->read_record.table=table; @@ -13413,11 +13390,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, If ref_key used index tree reading only ('Using index' in EXPLAIN), and best_key doesn't, then revert the decision. */ - if (!table->covering_keys.is_set(best_key) && table->key_read) - { - table->key_read= 0; - table->file->extra(HA_EXTRA_NO_KEYREAD); - } + if (!table->covering_keys.is_set(best_key)) + table->set_keyread(FALSE); if (!quick_created) { tab->index= best_key; @@ -13430,10 +13404,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, select->quick= 0; } if (table->covering_keys.is_set(best_key)) - { - table->key_read=1; - table->file->extra(HA_EXTRA_KEYREAD); - } + table->set_keyread(TRUE); table->file->ha_index_or_rnd_end(); if (join->select_options & SELECT_DESCRIBE) { @@ -13607,11 +13578,8 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, We can only use 'Only index' if quick key is same as ref_key and in index_merge 'Only index' cannot be used */ - if (table->key_read && ((uint) tab->ref.key != select->quick->index)) - { - table->key_read=0; - table->file->extra(HA_EXTRA_NO_KEYREAD); - } + if (((uint) tab->ref.key != select->quick->index)) + table->set_keyread(FALSE); } else { @@ -13667,11 +13635,7 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, tab->type=JT_ALL; // Read with normal read_record tab->read_first_record= join_init_read_record; tab->join->examined_rows+=examined_rows; - if (table->key_read) // Restore if we used indexes - { - table->key_read=0; - table->file->extra(HA_EXTRA_NO_KEYREAD); - } + table->set_keyread(FALSE); // Restore if we used indexes DBUG_RETURN(table->sort.found_records == HA_POS_ERROR); err: DBUG_RETURN(-1); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 433e2619aca..32add8679ef 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -397,10 +397,7 @@ int mysql_update(THD *thd, matching rows before updating the table! */ if (used_index < MAX_KEY && old_covering_keys.is_set(used_index)) - { - table->key_read=1; table->mark_columns_used_by_index(used_index); - } else { table->use_all_columns(); @@ -844,11 +841,7 @@ int mysql_update(THD *thd, err: delete select; free_underlaid_joins(thd, select_lex); - if (table->key_read) - { - table->key_read=0; - table->file->extra(HA_EXTRA_NO_KEYREAD); - } + table->set_keyread(FALSE); thd->abort_on_warning= 0; DBUG_RETURN(1); } diff --git a/sql/table.cc b/sql/table.cc index c06ecf99926..9561e5fcc4b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4374,7 +4374,7 @@ void st_table::mark_columns_used_by_index(uint index) MY_BITMAP *bitmap= &tmp_set; DBUG_ENTER("st_table::mark_columns_used_by_index"); - (void) file->extra(HA_EXTRA_KEYREAD); + set_keyread(TRUE); bitmap_clear_all(bitmap); mark_columns_used_by_index_no_reset(index, bitmap); column_bitmaps_set(bitmap, bitmap); @@ -4397,8 +4397,7 @@ void st_table::restore_column_maps_after_mark_index() { DBUG_ENTER("st_table::restore_column_maps_after_mark_index"); - key_read= 0; - (void) file->extra(HA_EXTRA_NO_KEYREAD); + set_keyread(FALSE); default_column_bitmaps(); file->column_bitmaps_signal(); DBUG_VOID_RETURN; diff --git a/sql/table.h b/sql/table.h index eae261cc97d..e797ef2b2de 100644 --- a/sql/table.h +++ b/sql/table.h @@ -902,6 +902,20 @@ struct st_table { inline bool needs_reopen_or_name_lock() { return s->version != refresh_version; } bool is_children_attached(void); + inline void set_keyread(bool flag) + { + DBUG_ASSERT(file); + if (flag && !key_read) + { + key_read= 1; + file->extra(HA_EXTRA_KEYREAD); + } + else if (!flag && key_read) + { + key_read= 0; + file->extra(HA_EXTRA_NO_KEYREAD); + } + } }; enum enum_schema_table_state From a1e10b01f90b9695d46604dfff47f2f5193ec571 Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Tue, 9 Feb 2010 11:30:50 +0100 Subject: [PATCH 48/96] Bug#47974 'TYPE=storage_engine' is deprecated and will be removed in MySQL 6.0 CREATE TABLE... TYPE= returns the warning "The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 6.0. Please use 'ENGINE=storage_engine' instead" This syntax is deprecated already from version 5.4.4, so the message has been changed. In addition, the deprecation macro was changed to reflect the ServerPT decision not to include version number in the warning message. A number of test result files have been changed as a consequence of the change in the deprecation macro. --- mysql-test/r/backup.result | 26 +++++++++++++------------- mysql-test/r/func_time.result | 10 +++++----- mysql-test/r/log_state.result | 12 ++++++------ mysql-test/r/show_check.result | 2 +- mysql-test/r/sp-error.result | 2 +- mysql-test/r/sp.result | 4 ++-- mysql-test/r/sp_trans.result | 2 +- mysql-test/r/type_blob.result | 4 ++-- mysql-test/r/type_timestamp.result | 14 +++++++------- mysql-test/r/warnings.result | 2 +- mysql-test/suite/rpl/r/rpl_sp.result | 6 +++--- sql/mysql_priv.h | 12 +++++++----- sql/share/errmsg.txt | 2 +- sql/sql_yacc.yy | 2 +- 14 files changed, 51 insertions(+), 49 deletions(-) diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result index bab2c83448c..89be20aee70 100644 --- a/mysql-test/r/backup.result +++ b/mysql-test/r/backup.result @@ -4,23 +4,23 @@ create table t4(n int); backup table t4 to '../../bogus'; Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) -test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t4 backup Warning 'BACKUP TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X) test.t4 backup status Operation failed backup table t4 to '../../tmp'; Table Op Msg_type Msg_text -test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t4 backup Warning 'BACKUP TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t4 backup status OK backup table t4 to '../../tmp'; Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) -test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t4 backup Warning 'BACKUP TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X) test.t4 backup status Operation failed drop table t4; restore table t4 from '../../tmp'; Table Op Msg_type Msg_text -test.t4 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t4 restore Warning 'RESTORE TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t4 restore status OK select count(*) from t4; count(*) @@ -29,18 +29,18 @@ create table t1(n int); insert into t1 values (23),(45),(67); backup table t1 to '../../tmp'; Table Op Msg_type Msg_text -test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t1 backup Warning 'BACKUP TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 backup status OK drop table t1; restore table t1 from '../../bogus'; Table Op Msg_type Msg_text t1 restore error Failed copying .frm file Warnings: -Warning 1287 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +Warning 1287 'RESTORE TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead Error 29 File 'MYSQLTEST_VARDIR/bogus/t1.frm' not found (Errcode: X) restore table t1 from '../../tmp'; Table Op Msg_type Msg_text -test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t1 restore Warning 'RESTORE TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 restore status OK select n from t1; n @@ -53,13 +53,13 @@ insert into t2 values (123),(145),(167); insert into t3 values (223),(245),(267); backup table t2,t3 to '../../tmp'; Table Op Msg_type Msg_text -test.t2 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t2 backup Warning 'BACKUP TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t2 backup status OK test.t3 backup status OK drop table t1,t2,t3; restore table t1,t2,t3 from '../../tmp'; Table Op Msg_type Msg_text -test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t1 restore Warning 'RESTORE TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 restore status OK test.t2 restore status OK test.t3 restore status OK @@ -81,14 +81,14 @@ k drop table t1,t2,t3,t4; restore table t1 from '../../tmp'; Table Op Msg_type Msg_text -test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t1 restore Warning 'RESTORE TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 restore status OK rename table t1 to t5; lock tables t5 write; backup table t5 to '../../tmp'; unlock tables; Table Op Msg_type Msg_text -test.t5 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t5 backup Warning 'BACKUP TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t5 backup status OK drop table t5; DROP TABLE IF EXISTS `t+1`; @@ -96,12 +96,12 @@ CREATE TABLE `t+1` (c1 INT); INSERT INTO `t+1` VALUES (1), (2), (3); BACKUP TABLE `t+1` TO '../../tmp'; Table Op Msg_type Msg_text -test.t+1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t+1 backup Warning 'BACKUP TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t+1 backup status OK DROP TABLE `t+1`; RESTORE TABLE `t+1` FROM '../../tmp'; Table Op Msg_type Msg_text -test.t+1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t+1 restore Warning 'RESTORE TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t+1 restore status OK SELECT * FROM `t+1`; c1 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 2ac549a5abd..93317020c5b 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -682,7 +682,7 @@ select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1; timestampadd(SQL_TSI_FRAC_SECOND, 1, date) 2003-01-02 00:00:00.000001 Warnings: -Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 5.6. Please use MICROSECOND instead +Warning 1287 'FRAC_SECOND' is deprecated and will be removed in a future release. Please use MICROSECOND instead select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a; a 3 @@ -717,7 +717,7 @@ select timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05 a 7689538999999 Warnings: -Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 5.6. Please use MICROSECOND instead +Warning 1287 'FRAC_SECOND' is deprecated and will be removed in a future release. Please use MICROSECOND instead select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1, timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2, timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3, @@ -1088,7 +1088,7 @@ timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12: id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 5.6. Please use MICROSECOND instead +Warning 1287 'FRAC_SECOND' is deprecated and will be removed in a future release. Please use MICROSECOND instead Note 1003 select timestampdiff(WEEK,'2001-02-01','2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,'2001-02-01 12:59:59.120000','2001-05-01 12:58:58.119999') AS `a2` select time_format('100:00:00', '%H %k %h %I %l'); time_format('100:00:00', '%H %k %h %I %l') @@ -1287,12 +1287,12 @@ SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18'); TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18') 2008-02-18 00:00:00.000001 Warnings: -Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 5.6. Please use MICROSECOND instead +Warning 1287 'FRAC_SECOND' is deprecated and will be removed in a future release. Please use MICROSECOND instead SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18'); TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18') 86400000000 Warnings: -Warning 1287 The syntax 'FRAC_SECOND' is deprecated and will be removed in MySQL 5.6. Please use MICROSECOND instead +Warning 1287 'FRAC_SECOND' is deprecated and will be removed in a future release. Please use MICROSECOND instead SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND)' at line 1 SELECT DATE_SUB('2008-02-18', INTERVAL 1 FRAC_SECOND); diff --git a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result index 5c3e3d789a1..4ce678e37aa 100644 --- a/mysql-test/r/log_state.result +++ b/mysql-test/r/log_state.result @@ -199,7 +199,7 @@ SELECT @@general_log, @@log; 1 1 SET GLOBAL log = 0; Warnings: -Warning 1287 The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead +Warning 1287 '@@log' is deprecated and will be removed in a future release. Please use '@@general_log' instead SHOW VARIABLES LIKE 'general_log'; Variable_name Value general_log OFF @@ -230,7 +230,7 @@ SELECT @@slow_query_log, @@log_slow_queries; 0 0 SET GLOBAL log_slow_queries = 0; Warnings: -Warning 1287 The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead +Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead SHOW VARIABLES LIKE 'slow_query_log'; Variable_name Value slow_query_log OFF @@ -283,16 +283,16 @@ SET GLOBAL slow_query_log_file = @old_slow_query_log_file; deprecated: SET GLOBAL log = 0; Warnings: -Warning 1287 The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead +Warning 1287 '@@log' is deprecated and will be removed in a future release. Please use '@@general_log' instead SET GLOBAL log_slow_queries = 0; Warnings: -Warning 1287 The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead +Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead SET GLOBAL log = DEFAULT; Warnings: -Warning 1287 The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead +Warning 1287 '@@log' is deprecated and will be removed in a future release. Please use '@@general_log' instead SET GLOBAL log_slow_queries = DEFAULT; Warnings: -Warning 1287 The syntax '@@log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '@@slow_query_log' instead +Warning 1287 '@@log_slow_queries' is deprecated and will be removed in a future release. Please use '@@slow_query_log' instead not deprecated: SELECT @@global.general_log_file INTO @my_glf; SELECT @@global.slow_query_log_file INTO @my_sqlf; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index ec0a70ff581..08b9211bd31 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -1295,7 +1295,7 @@ drop database mysqltest; show full plugin; show warnings; Level Code Message -Warning 1287 The syntax 'SHOW PLUGIN' is deprecated and will be removed in MySQL 6.0. Please use 'SHOW PLUGINS' instead +Warning 1287 'SHOW PLUGIN' is deprecated and will be removed in a future release. Please use 'SHOW PLUGINS' instead show plugin; show plugins; create database `mysqlttest\1`; diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index b3968ea7eb6..ec2ba5747c3 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1643,7 +1643,7 @@ create table t1 (a int) type=MyISAM; drop table t1; end| Warnings: -Warning 1287 The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 6.0. Please use 'ENGINE=storage_engine' instead +Warning 1287 'TYPE=storage_engine' is deprecated and will be removed in a future release. Please use 'ENGINE=storage_engine' instead call p1(); call p1(); drop procedure p1; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 1e6227e7380..2180a23b91a 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4304,10 +4304,10 @@ call bug13012()| Table Op Msg_type Msg_text test.t1 repair status OK Table Op Msg_type Msg_text -test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t1 backup Warning 'BACKUP TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 backup status OK Table Op Msg_type Msg_text -test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead +test.t1 restore Warning 'RESTORE TABLE' is deprecated and will be removed in a future release. Please use MySQL Administrator (mysqldump, mysql) instead test.t1 restore status OK drop procedure bug13012| create view v1 as select * from t1| diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index 3cc251bc0a6..a64f53efde7 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -535,7 +535,7 @@ use db_bug7787| CREATE PROCEDURE p1() SHOW INNODB STATUS; | Warnings: -Warning 1287 The syntax 'SHOW INNODB STATUS' is deprecated and will be removed in MySQL 6.0. Please use 'SHOW ENGINE INNODB STATUS' instead +Warning 1287 'SHOW INNODB STATUS' is deprecated and will be removed in a future release. Please use 'SHOW ENGINE INNODB STATUS' instead GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost| DROP DATABASE db_bug7787| drop user user_bug7787@localhost| diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index d11ab236c34..08c30d884fd 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -891,11 +891,11 @@ CREATE TABLE b15776 (a year(-2)); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1 CREATE TABLE b15776 (a timestamp(4294967294)); Warnings: -Warning 1287 The syntax 'TIMESTAMP(4294967294)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(4294967294)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead DROP TABLE b15776; CREATE TABLE b15776 (a timestamp(4294967295)); Warnings: -Warning 1287 The syntax 'TIMESTAMP(4294967295)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(4294967295)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead DROP TABLE b15776; CREATE TABLE b15776 (a timestamp(4294967296)); ERROR 42000: Display width out of range for column 'a' (max = 4294967295) diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index 24cb725de9f..e26c2e68775 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -101,13 +101,13 @@ create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6), t8 timestamp(8), t10 timestamp(10), t12 timestamp(12), t14 timestamp(14)); Warnings: -Warning 1287 The syntax 'TIMESTAMP(2)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead -Warning 1287 The syntax 'TIMESTAMP(4)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead -Warning 1287 The syntax 'TIMESTAMP(6)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead -Warning 1287 The syntax 'TIMESTAMP(8)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead -Warning 1287 The syntax 'TIMESTAMP(10)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead -Warning 1287 The syntax 'TIMESTAMP(12)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead -Warning 1287 The syntax 'TIMESTAMP(14)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(2)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(4)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(6)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(8)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(10)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(12)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead +Warning 1287 'TIMESTAMP(14)' is deprecated and will be removed in a future release. Please use 'TIMESTAMP' instead insert t1 values (0,0,0,0,0,0,0), ("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59", diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index 8a87852d582..302942bd6a0 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -168,7 +168,7 @@ max_error_count 10 drop table t1; set table_type=MYISAM; Warnings: -Warning 1287 The syntax '@@table_type' is deprecated and will be removed in MySQL 6.0. Please use '@@storage_engine' instead +Warning 1287 '@@table_type' is deprecated and will be removed in a future release. Please use '@@storage_engine' instead create table t1 (a int); insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); update t1 set a='abc'; diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result index 7fedaf4c1ef..631369b2b74 100644 --- a/mysql-test/suite/rpl/r/rpl_sp.result +++ b/mysql-test/suite/rpl/r/rpl_sp.result @@ -195,7 +195,7 @@ set @old_log_bin_trust_routine_creators= @@global.log_bin_trust_routine_creators set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; set global log_bin_trust_routine_creators=1; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.6. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=1; set @old_log_bin_trust_routine_creators= @@global.log_bin_trust_routine_creators; @@ -559,11 +559,11 @@ end master-bin.000001 # Query 1 # use `mysqltest`; SELECT `mysqltest2`.`f1`() set @@global.log_bin_trust_routine_creators= @old_log_bin_trust_routine_creators; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.6. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; set @@global.log_bin_trust_routine_creators= @old_log_bin_trust_routine_creators; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.6. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators; drop database mysqltest; drop database mysqltest2; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 1b775e658f1..90b02f5337a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -118,13 +118,15 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); #define WARN_DEPRECATED(Thd,Ver,Old,New) \ do { \ DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0); \ - if (((uchar*)Thd) != NULL) \ + if (((uchar*)Thd) != NULL) \ push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \ - ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX_WITH_VER), \ - (Old), (Ver), (New)); \ + ER_WARN_DEPRECATED_SYNTAX, \ + ER(ER_WARN_DEPRECATED_SYNTAX), \ + (Old), (New)); \ else \ - sql_print_warning("The syntax '%s' is deprecated and will be removed " \ - "in a future release. Please use %s instead.", (Old), (New)); \ + sql_print_warning("'%s' is deprecated and will be removed " \ + "in a future release. Please use '%s' instead.", \ + (Old), (New)); \ } while(0) extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info; diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 06ce848399b..bbae17c4327 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5027,7 +5027,7 @@ ER_UNKNOWN_STORAGE_ENGINE 42000 # When using this error code, use ER(ER_WARN_DEPRECATED_SYNTAX_WITH_VER) # for the message string. See, for example, code in mysql_priv.h. ER_WARN_DEPRECATED_SYNTAX - eng "'%s' is deprecated; use '%s' instead" + eng "'%s' is deprecated and will be removed in a future release. Please use %s instead" ger "'%s' ist veraltet. Bitte benutzen Sie '%s'" por "'%s' é desatualizado. Use '%s' em seu lugar" spa "'%s' está desaprobado, use '%s' en su lugar" diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 8dc08f8425f..37150bf835d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4596,7 +4596,7 @@ create_table_option: | TYPE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; - WARN_DEPRECATED(yythd, "6.0", "TYPE=storage_engine", + WARN_DEPRECATED(yythd, "5.4.4", "TYPE=storage_engine", "'ENGINE=storage_engine'"); Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; } From e5a38da7ff68b174b254fb18d4f16977cebe1617 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 10 Feb 2010 18:56:47 +0400 Subject: [PATCH 49/96] Bug#45195 valgrind warnings about uninitialized values in store_record_in_cache() The problem becomes apparent only if HAVE_purify is undefined. It related to the part of code placed in open_table_from_share() fuction where we initialize record buffer only if HAVE_purify is enabled. So in case of HAVE_purify=OFF record buffer is not initialized on open table stage. Next we read key, find NULL value and update appropriate null bit but do not update record buffer. After that the record is stored in the join cache(store_record_in_cache). For CHAR fields we strip trailing spaces and in our case this procedure uses uninitialized record buffer. The fix is to skip stripping space procedure in case of null values for CHAR fields(partially based on 6.0 JOIN_CACHE implementation). --- mysql-test/r/join.result | 17 ++++++++++++++ mysql-test/t/join.test | 12 ++++++++++ sql/field.cc | 11 ++++----- sql/sql_select.cc | 51 +++++++++++++++++++++++----------------- sql/sql_select.h | 8 +++++-- 5 files changed, 69 insertions(+), 30 deletions(-) diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index baabf48cb2f..8691eb27220 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1128,3 +1128,20 @@ EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP VIEW v1; DROP TABLE t1, t2; +CREATE TABLE t1(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM; +CREATE TABLE t2(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('1',null),(null,null); +INSERT INTO t2 VALUES ('1',null),(null,null); +CREATE TABLE mm1(a CHAR(9),b INT,KEY(b),KEY(a)) +ENGINE=MERGE UNION=(t1,t2); +SELECT t1.a FROM mm1,t1; +a +NULL +1 +NULL +1 +NULL +1 +NULL +1 +DROP TABLE t1, t2, mm1; diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index dbf36dedec8..645321a3a5e 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -804,3 +804,15 @@ DEALLOCATE PREPARE stmt; DROP VIEW v1; DROP TABLE t1, t2; + +# +# Bug#45195 valgrind warnings about uninitialized values in store_record_in_cache() +# +CREATE TABLE t1(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM; +CREATE TABLE t2(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MYISAM; +INSERT INTO t1 VALUES ('1',null),(null,null); +INSERT INTO t2 VALUES ('1',null),(null,null); +CREATE TABLE mm1(a CHAR(9),b INT,KEY(b),KEY(a)) +ENGINE=MERGE UNION=(t1,t2); +SELECT t1.a FROM mm1,t1; +DROP TABLE t1, t2, mm1; diff --git a/sql/field.cc b/sql/field.cc index d8db3fdbae4..15ee9c4a86c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1705,11 +1705,10 @@ uint Field::fill_cache_field(CACHE_FIELD *copy) uint store_length; copy->str=ptr; copy->length=pack_length(); - copy->blob_field=0; + copy->field= this; if (flags & BLOB_FLAG) { - copy->blob_field=(Field_blob*) this; - copy->strip=0; + copy->type= CACHE_BLOB; copy->length-= table->s->blob_ptr_size; return copy->length; } @@ -1717,15 +1716,15 @@ uint Field::fill_cache_field(CACHE_FIELD *copy) (type() == MYSQL_TYPE_STRING && copy->length >= 4 && copy->length < 256)) { - copy->strip=1; /* Remove end space */ + copy->type= CACHE_STRIPPED; store_length= 2; } else { - copy->strip=0; + copy->type= 0; store_length= 0; } - return copy->length+ store_length; + return copy->length + store_length; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b1efaf67b9b..a3ce50fe4ee 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14149,7 +14149,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) { used_fields--; length+=field->fill_cache_field(copy); - if (copy->blob_field) + if (copy->type == CACHE_BLOB) (*blob_ptr++)=copy; if (field->real_maybe_null()) null_fields++; @@ -14164,8 +14164,8 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) { /* must copy null bits */ copy->str= tables[i].table->null_flags; copy->length= tables[i].table->s->null_bytes; - copy->strip=0; - copy->blob_field=0; + copy->type=0; + copy->field=0; length+=copy->length; copy++; cache->fields++; @@ -14175,8 +14175,8 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) { copy->str= (uchar*) &tables[i].table->null_row; copy->length=sizeof(tables[i].table->null_row); - copy->strip=0; - copy->blob_field=0; + copy->type=0; + copy->field=0; length+=copy->length; copy++; cache->fields++; @@ -14201,9 +14201,10 @@ used_blob_length(CACHE_FIELD **ptr) uint length,blob_length; for (length=0 ; *ptr ; ptr++) { - (*ptr)->blob_length=blob_length=(*ptr)->blob_field->get_length(); + Field_blob *field_blob= (Field_blob *) (*ptr)->field; + (*ptr)->blob_length=blob_length= field_blob->get_length(); length+=blob_length; - (*ptr)->blob_field->get_ptr(&(*ptr)->str); + field_blob->get_ptr(&(*ptr)->str); } return length; } @@ -14232,30 +14233,35 @@ store_record_in_cache(JOIN_CACHE *cache) cache->records++; for (copy=cache->field ; copy < end_field; copy++) { - if (copy->blob_field) + if (copy->type == CACHE_BLOB) { + Field_blob *blob_field= (Field_blob *) copy->field; if (last_record) { - copy->blob_field->get_image(pos, copy->length+sizeof(char*), - copy->blob_field->charset()); + blob_field->get_image(pos, copy->length+sizeof(char*), + blob_field->charset()); pos+=copy->length+sizeof(char*); } else { - copy->blob_field->get_image(pos, copy->length, // blob length - copy->blob_field->charset()); + blob_field->get_image(pos, copy->length, // blob length + blob_field->charset()); memcpy(pos+copy->length,copy->str,copy->blob_length); // Blob data pos+=copy->length+copy->blob_length; } } else { - if (copy->strip) + if (copy->type == CACHE_STRIPPED) { uchar *str,*end; - for (str=copy->str,end= str+copy->length; - end > str && end[-1] == ' ' ; - end--) ; + Field *field= copy->field; + if (field && field->maybe_null() && field->is_null()) + end= str= copy->str; + else + for (str=copy->str,end= str+copy->length; + end > str && end[-1] == ' ' ; + end--) ; length=(uint) (end-str); memcpy(pos+2, str, length); int2store(pos, length); @@ -14304,23 +14310,24 @@ read_cached_record(JOIN_TAB *tab) copy < end_field; copy++) { - if (copy->blob_field) + if (copy->type == CACHE_BLOB) { + Field_blob *blob_field= (Field_blob *) copy->field; if (last_record) { - copy->blob_field->set_image(pos, copy->length+sizeof(char*), - copy->blob_field->charset()); + blob_field->set_image(pos, copy->length+sizeof(char*), + blob_field->charset()); pos+=copy->length+sizeof(char*); } else { - copy->blob_field->set_ptr(pos, pos+copy->length); - pos+=copy->length+copy->blob_field->get_length(); + blob_field->set_ptr(pos, pos+copy->length); + pos+=copy->length + blob_field->get_length(); } } else { - if (copy->strip) + if (copy->type == CACHE_STRIPPED) { length= uint2korr(pos); memcpy(copy->str, pos+2, length); diff --git a/sql/sql_select.h b/sql/sql_select.h index bfff0a0ffa2..ef43f9b049c 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -95,6 +95,10 @@ typedef struct st_table_ref } TABLE_REF; + +#define CACHE_BLOB 1 /* blob field */ +#define CACHE_STRIPPED 2 /* field stripped of trailing spaces */ + /** CACHE_FIELD and JOIN_CACHE is used on full join to cache records in outer table @@ -103,8 +107,8 @@ typedef struct st_table_ref typedef struct st_cache_field { uchar *str; uint length, blob_length; - Field_blob *blob_field; - bool strip; + Field *field; + uint type; /**< category of the of the copied field (CACHE_BLOB et al.) */ } CACHE_FIELD; From 1094ffd572ebd533aa9b61d42ceaccc957f8e6c2 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 11 Feb 2010 08:17:25 +0400 Subject: [PATCH 50/96] WL#2649 Number-to-string conversions added: include/ctype_numconv.inc mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/t/ctype_binary.test Adding tests modified: mysql-test/r/bigint.result mysql-test/r/case.result mysql-test/r/create.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result mysql-test/r/func_gconcat.result mysql-test/r/func_str.result mysql-test/r/metadata.result mysql-test/r/ps_1general.result mysql-test/r/ps_2myisam.result mysql-test/r/ps_3innodb.result mysql-test/r/ps_4heap.result mysql-test/r/ps_5merge.result mysql-test/r/show_check.result mysql-test/r/type_datetime.result mysql-test/r/type_ranges.result mysql-test/r/union.result mysql-test/suite/ndb/r/ps_7ndb.result mysql-test/t/ctype_cp1251.test mysql-test/t/ctype_latin1.test mysql-test/t/ctype_ucs.test mysql-test/t/func_str.test Fixing tests @ sql/field.cc - Return str result using my_charset_numeric. - Using real multi-byte aware str_to_XXX functions to handle tricky charset values propely (e.g. UCS2) @ sql/field.h - Changing derivation of non-string field types to DERIVATION_NUMERIC. - Changing binary() for numeric/datetime fields to always return TRUE even if charset is not my_charset_bin. We need this to keep ha_base_keytype() return HA_KEYTYPE_BINARY. - Adding BINARY_FLAG into some fields, because it's not being set automatically anymore with "my_charset_bin to my_charset_numeric" change. - Changing derivation for numeric/datetime datatypes to a weaker value, to make "SELECT concat('string', field)" use character set of the string literal for the result of the function. @ sql/item.cc - Implementing generic val_str_ascii(). - Using max_char_length() instead of direct read of max_length to make "tricky" charsets like UCS2 work. NOTE: in the future we'll possibly remove all direct reads of max_length - Fixing Item_num::safe_charset_converter(). Previously it alligned binary string to character string (for example by adding leading 0x00 when doing binary->UCS2 conversion). Now it just converts from my_charset_numbner to "tocs". - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work. - Other misc changes @ sql/item.h - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to bit operations instead of hard-coded bit masks. - Addding new method DTCollation.set_numeric(). - Adding new methods to Item. - Adding helper functions to make code look nicer: agg_item_charsets_for_string_result() agg_item_charsets_for_comparison() - Changing charset for Item_num-derived items from my_charset_bin to my_charset_numeric (which is an alias for latin1). @ sql/item_cmpfunc.cc - Using new helper functions - Other misc changes @ sql/item_cmpfunc.h - Fixing strcmp() to return max_length=2. Previously it returned 1, which was wrong, because it did not fit '-1'. @ sql/item_func.cc - Using new helper functions - Other minor changes @ sql/item_func.h - Removing unused functions - Adding helper functions agg_arg_charsets_for_string_result() agg_arg_charsets_for_comparison() - Adding set_numeric() into constructors of numeric items. - Using fix_length_and_charset() and fix_char_length() instead of direct write to max_length. @ sql/item_geofunc.cc - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when character_set_connection=ucs2). @ sql/item_geofunc.h - Changing class for Item_func_geometry_type and Item_func_as_wkt from Item_str_func to Item_str_ascii_func, to make them return UCS2 result properly (when @@character_set_connection=ucs2). @ sql/item_strfunc.cc - Implementing Item_str_func::val_str(). - Renaming val_str to val_str_ascii for some items, to make them work with UCS2 properly. - Using new helper functions - All single-argument functions that expect string result now call this method: agg_arg_charsets_for_string_result(collation, args, 1); This enables character set conversion to @@character_set_connection in case of pure numeric input. @ sql/item_strfunc.h - Introducing Item_str_ascii_func - for functions which return pure ASCII data, for performance purposes, as well as for the cases when the old implementation of val_str() was heavily 8-bit oriented and implementing a UCS2-aware version is tricky. @ sql/item_sum.cc - Using new helper functions. @ sql/item_timefunc.cc - Using my_charset_numeric instead of my_charset_bin. - Using fix_char_length(), fix_length_and_charset() and fix_length_and_charset_datetime() instead of direct write to max_length. - Using tricky-charset aware function str_to_time_with_warn() @ sql/item_timefunc.h - Using new helper functions for charset and length initialization. - Changing base class for Item_func_get_format() to make it return UCS2 properly (when character_set_connection=ucs2). @ sql/item_xmlfunc.cc - Using new helper function @ sql/my_decimal.cc - Adding a new DECIMAL to CHAR converter with real multibyte support (e.g. UCS2) @ sql/mysql_priv.h - Introducing a new derivation level for numeric/datetime data types. - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC. - Adding prototypes for str_set_decimal() - Adding prototypes for character-set aware str_to_xxx() functions. @ sql/protocol.cc - Changing charsetnr to "binary" client-side metadata for numeric/datetime data types. @ sql/time.cc - Adding to_ascii() helper function, to convert a string in any character set to ascii representation. In the future can be extended to understand digits written in various non-Latin word scripts. - Adding real multy-byte character set aware versions for str_to_XXXX, to make these these type of queries work correct: INSERT INTO t1 SET datetime_column=ucs2_expression; @ strings/ctype-ucs2.c - endptr was not calculated correctly. INSERTing of UCS2 values into numeric columns returned warnings about truncated wrong data. --- mysql-test/include/ctype_numconv.inc | 1605 +++++++++++++++ mysql-test/r/case.result | 14 +- mysql-test/r/create.result | 4 +- mysql-test/r/ctype_binary.result | 2581 ++++++++++++++++++++++++ mysql-test/r/ctype_cp1251.result | 2580 ++++++++++++++++++++++++ mysql-test/r/ctype_latin1.result | 2580 ++++++++++++++++++++++++ mysql-test/r/ctype_ucs.result | 2591 ++++++++++++++++++++++++- mysql-test/r/func_gconcat.result | 4 +- mysql-test/r/func_str.result | 8 +- mysql-test/r/metadata.result | 2 +- mysql-test/r/ps_2myisam.result | 72 +- mysql-test/r/ps_3innodb.result | 72 +- mysql-test/r/ps_4heap.result | 72 +- mysql-test/r/ps_5merge.result | 144 +- mysql-test/r/type_datetime.result | 4 +- mysql-test/r/type_ranges.result | 2 +- mysql-test/r/union.result | 12 +- mysql-test/suite/ndb/r/ps_7ndb.result | 72 +- mysql-test/t/ctype_binary.test | 12 + mysql-test/t/ctype_cp1251.test | 10 + mysql-test/t/ctype_latin1.test | 11 + mysql-test/t/ctype_ucs.test | 14 + mysql-test/t/func_str.test | 2 +- sql/field.cc | 64 +- sql/field.h | 42 +- sql/item.cc | 97 +- sql/item.h | 131 +- sql/item_cmpfunc.cc | 34 +- sql/item_cmpfunc.h | 5 + sql/item_func.cc | 101 +- sql/item_func.h | 67 +- sql/item_geofunc.cc | 7 +- sql/item_geofunc.h | 17 +- sql/item_strfunc.cc | 112 +- sql/item_strfunc.h | 74 +- sql/item_sum.cc | 8 +- sql/item_timefunc.cc | 49 +- sql/item_timefunc.h | 73 +- sql/item_xmlfunc.cc | 2 +- sql/my_decimal.cc | 53 + sql/mysql_priv.h | 28 +- sql/protocol.cc | 4 +- sql/time.cc | 77 +- strings/ctype-ucs2.c | 2 +- 44 files changed, 12968 insertions(+), 547 deletions(-) create mode 100644 mysql-test/include/ctype_numconv.inc create mode 100644 mysql-test/r/ctype_binary.result create mode 100644 mysql-test/t/ctype_binary.test diff --git a/mysql-test/include/ctype_numconv.inc b/mysql-test/include/ctype_numconv.inc new file mode 100644 index 00000000000..1d393f530f9 --- /dev/null +++ b/mysql-test/include/ctype_numconv.inc @@ -0,0 +1,1605 @@ +--echo # +--echo # Start of WL#2649 Number-to-string conversions +--echo # +# +# Basic constants +# +select hex(concat(1)); +create table t1 as select concat(1) as c1; +show create table t1; +select hex(c1) from t1; +drop table t1; + +select hex(concat(18446744073709551615)); +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +select hex(c1) from t1; +drop table t1; + +select hex(concat(1.1)); +create table t1 as select concat(1.1) as c1; +show create table t1; +select hex(c1) from t1; +drop table t1; + + +# +# Arithmetic operators +# + +select hex(concat('a', 1+2)), charset(concat(1+2)); +create table t1 as select concat(1+2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1-2)); +create table t1 as select concat(1-2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1*2)); +create table t1 as select concat(1*2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1/2)); +create table t1 as select concat(1/2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1 div 2)); +create table t1 as select concat(1 div 2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1 % 2)); +create table t1 as select concat(1 % 2) as c1; +show create table t1; +drop table t1; + +select hex(concat(-1)); +create table t1 as select concat(-1) as c1; +show create table t1; +drop table t1; + +select hex(concat(-(1+2))); +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +drop table t1; + + +# +# Bit functions +# + +select hex(concat(1|2)); +create table t1 as select concat(1|2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1&2)); +create table t1 as select concat(1&2) as c1; +show create table t1; +drop table t1; + +select hex(concat(bit_count(12))); +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +drop table t1; + +select hex(concat(2<<1)); +create table t1 as select concat(2<<1) as c1; +show create table t1; +drop table t1; + +select hex(concat(2>>1)); +create table t1 as select concat(2>>1) as c1; +show create table t1; +drop table t1; + +select hex(concat(~0)); +create table t1 as select concat(~0) as c1; +show create table t1; +drop table t1; + +select hex(concat(3^2)); +create table t1 as select concat(3^2) as c1; +show create table t1; +drop table t1; + + + +# +# Math functions +# +# Note, some tests use LEFT(func(),1) to avoid +# non-deterministic results on various platforms. +# + +select hex(concat(abs(-2))); +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(exp(2)),1)); +create table t1 as select concat(exp(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(log(2)),1)); +create table t1 as select concat(log(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(log2(2)),1)); +create table t1 as select concat(log2(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(log10(2)),1)); +create table t1 as select concat(log10(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(sqrt(2)),1)); +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(pow(2,2)),1)); +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(acos(0.5)),1)); +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(asin(0.5)),1)); +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(atan(0.5)),1)); +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(cos(0.5)),1)); +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(sin(0.5)),1)); +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(tan(0.5)),1)); +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(concat(degrees(0))); +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +drop table t1; + +select hex(concat(radians(0))); +create table t1 as select concat(radians(0)) as c1; +show create table t1; +drop table t1; + +select hex(concat(ceiling(0.5))); +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(concat(floor(0.5))); +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(concat(round(0.5))); +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(concat(sign(0.5))); +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(rand()) as c1; +show create table t1; +drop table t1; + + +# +# String functions +# + +select hex(concat(length('a'))); +create table t1 as select concat(length('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(char_length('a'))); +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(bit_length('a'))); +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(coercibility('a'))); +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(locate('a','a'))); +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(field('c','a','b','c'))); +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +drop table t1; + +select hex(concat(ascii(61))); +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +drop table t1; + +select hex(concat(ord(61))); +create table t1 as select concat(ord(61)) as c1; +show create table t1; +drop table t1; + +select hex(concat(find_in_set('b','a,b,c,d'))); +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +drop table t1; + + +# +# String hash functions +# + +select md5('a'), hex(md5('a')); +create table t1 as select md5('a') as c1; +show create table t1; +drop table t1; + +select old_password('a'), hex(old_password('a')); +create table t1 as select old_password('a') as c1; +show create table t1; +drop table t1; + +select password('a'), hex(password('a')); +create table t1 as select password('a') as c1; +show create table t1; +drop table t1; + +select sha('a'), hex(sha('a')); +create table t1 as select sha('a') as c1; +show create table t1; +drop table t1; + +select sha1('a'), hex(sha1('a')); +create table t1 as select sha1('a') as c1; +show create table t1; +drop table t1; + +#select sha2('a',224), hex(sha2('a',224)); +#create table t1 as select sha2('a',224) as c1; +#show create table t1; +#drop table t1; + + + +# +# CAST +# + +select hex(concat(cast('-1' as signed))); +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +drop table t1; + +select hex(concat(cast('1' as unsigned))); +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +drop table t1; + +select hex(concat(cast(1/2 as decimal(5,5)))); +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +drop table t1; + +select hex(concat(cast('2001-01-02 03:04:05' as date))); +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +select * from t1; +drop table t1; + +select hex(concat(cast('2001-01-02 03:04:05' as time))); +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +select * from t1; +drop table t1; + +select hex(concat(cast('2001-01-02' as datetime))); +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +select * from t1; +drop table t1; + + +# +# Aggregation: LEAST, GREATEST +# +select hex(concat(least(1,2))); +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +drop table t1; + +select hex(concat(greatest(1,2))); +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +drop table t1; + + +# +# Aggregation: CASE +# +select hex(concat(case when 11 then 22 else 33 end)); +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +drop table t1; + + +# +# Aggregation: COALESCE +# +select hex(concat(coalesce(1,2))); +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +drop table t1; + + +# +# Aggregation: CONCAT_WS, GROUP_CONCAT +# +select hex(concat_ws(1,2,3)); +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +drop table t1; + +select hex(group_concat(1,2,3)); +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +drop table t1; + +# +# Aggregation: UNION +# +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +select hex(c1) from t1 order by c1; +drop table t1; + + +# +# Miscelaneous functions +# + +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +drop table t1; + +select hex(concat(benchmark(0,0))); +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +drop table t1; + +select hex(concat(sleep(0))); +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +drop table t1; + +select hex(concat(get_lock('a',0))); +select hex(concat(release_lock('a'))); +create table t1 as select concat(get_lock('a',0)) as c1; +show create table t1; +drop table t1; + +select hex(concat(is_free_lock('xxxx'))); +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(crc32(''))); +create table t1 as select concat(crc32('')) as c1; +show create table t1; +drop table t1; + +select hex(concat(uncompressed_length(''))); +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(connection_id()) as c1; +show create table t1; +drop table t1; + +select hex(concat(inet_aton('127.1.1.1'))); +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +drop table t1; + +select hex(concat(inet_ntoa(2130772225))); +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +show create table t1; +drop table t1; + +select hex(concat(row_count())); +create table t1 as select concat(row_count()) as c1; +show create table t1; +drop table t1; + +select hex(concat(found_rows())); +create table t1 as select concat(found_rows()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(uuid()) as c1; +show create table t1; +drop table t1; + +# +# Make sure we can mix uuid() to a latin1 object +# with DERIVATION_IMPLICIT (and higher): +# (DERIVATION_COERCIBLE + MY_REPERTOIRE_ASCII allow to do so) +# +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +select charset(concat(uuid(), cast('a' as char character set latin1))); +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +drop table t1; + + +# +# User and system variable functions +# + +# User variables: INT +select hex(concat(@a1:=1)); +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +set @a2=1; +select hex(concat(@a2)); +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +# User variables: REAL +select hex(concat(@a1:=sqrt(1))); +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +set @a2=sqrt(1); +select hex(concat(@a2)); +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +# User variables: DECIMAL +select hex(concat(@a1:=1.1)); +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +set @a2=1.1; +select hex(concat(@a2)); +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + + +select hex(concat(@@ft_max_word_len)); +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +show create table t1; +drop table t1; + +# +# Comparison functions +# + +select hex(concat('a'='a' IS TRUE)); +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +drop table t1; + +select hex(concat('a'='a' IS NOT TRUE)); +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +drop table t1; + +select hex(concat(NOT 'a'='a')); +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +drop table t1; + +select hex(concat('a' IS NULL)); +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +drop table t1; + +select hex(concat('a' IS NOT NULL)); +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +drop table t1; + +select hex(concat('a' rlike 'a')); +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +drop table t1; + +select hex(concat(strcmp('a','b'))); +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +drop table t1; + +select hex(concat('a' like 'a')); +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +drop table t1; + +select hex(concat('a' between 'b' and 'c')); +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +drop table t1; + +select hex(concat('a' in ('a','b'))); +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +drop table t1; + +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +drop table t1; + +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +drop table t1, t2; + +select hex(ifnull(1,'a')); +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +drop table t1; + +select hex(concat(ifnull(1,1))); +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +drop table t1; + +select hex(concat(ifnull(1.1,1.1))); +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +drop table t1; + +select hex(if(1,'b',1)); +create table t1 as select if(1,'b',1) as c1; +show create table t1; +drop table t1; + +select hex(if(1,1,'b')); +create table t1 as select if(1,1,'b') as c1; +show create table t1; +drop table t1; + +select hex(concat(if(1,1,1))); +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +drop table t1; + +select hex(concat(nullif(1,2))); +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +drop table t1; + +# +# GIS functions +# + +select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))); +create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))); +create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))); +create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(IsSimple(GeomFromText('POINT(1 1)')))); +create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))); +create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))); +create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1; +drop table t1; + +select hex(concat(x(GeomFromText('Point(1 2)')))); +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(y(GeomFromText('Point(1 2)')))); +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))); +create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(GeometryType(GeomFromText('Point(1 2)')))); +create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(AsText(GeomFromText('Point(1 2)')))); +create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +drop table t1; + + + +# +# Date/Time functions +# + +select hex(concat(period_add(200902, 2))); +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +drop table t1; + +select hex(concat(period_diff(200902, 200802))); +create table t1 as select concat(period_add(200902, 200802)) as c1; +show create table t1; +drop table t1; + +select hex(concat(to_days(20090224))); +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(dayofmonth(20090224))); +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(dayofyear(20090224))); +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(hour('10:11:12'))); +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +drop table t1; + +select hex(concat(minute('10:11:12'))); +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +drop table t1; + +select hex(concat(second('10:11:12'))); +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +drop table t1; + +select hex(concat(quarter(20090224))); +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(week(20090224))); +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(yearweek(20090224))); +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(year(20090224))); +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(weekday(20090224))); +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(dayofweek(20090224))); +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(unix_timestamp(20090224))); +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(time_to_sec('10:11:12'))); +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +drop table t1; + +select hex(concat(extract(year from 20090702))); +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +drop table t1; + +select hex(concat(microsecond('12:00:00.123456'))); +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +drop table t1; + +select hex(concat(month(20090224))); +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +drop table t1; + + +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +select c1, hex(c1) from t1; +drop table t1; + +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +select c1, hex(c1) from t1; +drop table t1; + +create table t1 as select concat(curdate()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(utc_date()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(curtime()) as c1; +show create table t1; +drop table t1; + +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +drop table t1; + +create table t1 as select concat(utc_time()) as c1; +show create table t1; +drop table t1; + +select hex(concat(sec_to_time(2378))); +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +drop table t1; + +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +drop table t1; + +select hex(concat(maketime(10,11,12))); +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +drop table t1; + +select hex(get_format(DATE,'USA')); +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +drop table t1; + +select hex(left(concat(from_unixtime(1111885200)),4)); +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +drop table t1; + +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +drop table t1; + +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +select * from t1; +drop table t1; + +select hex(concat(makedate(2009,1))); +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +select * from t1; +drop table t1; + +create table t1 as select concat(now()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(sysdate()) as c1; +show create table t1; +drop table t1; + +select hex(concat(addtime('00:00:00','11:22:33'))); +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +drop table t1; + +select hex(concat(subtime('23:59:59','11:22:33'))); +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +drop table t1; + + +# +# Other string functions with numeric input +# +select hex(elt(1,2,3)); +create table t1 as select elt(1,2,3) as c1; +show create table t1; +drop table t1; + +select hex(export_set(1,2,3,4,2)); +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +drop table t1; + +select hex(insert(1133,3,0,22)); +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +drop table t1; + +select hex(lcase(123)); +create table t1 as select lcase(123) as c1; +show create table t1; +drop table t1; + +select hex(left(123,1)); +create table t1 as select left(123,1) as c1; +show create table t1; +drop table t1; + +select hex(lower(123)); +create table t1 as select lower(123) as c1; +show create table t1; +drop table t1; + +select hex(lpad(1,2,0)); +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +drop table t1; + +select hex(ltrim(1)); +create table t1 as select ltrim(1) as c1; +show create table t1; +drop table t1; + +select hex(mid(1,1,1)); +create table t1 as select mid(1,1,1) as c1; +show create table t1; +drop table t1; + +select hex(repeat(1,2)); +create table t1 as select repeat(1,2) as c1; +show create table t1; +drop table t1; + +select hex(replace(1,1,2)); +create table t1 as select replace(1,1,2) as c1; +show create table t1; +drop table t1; + +select hex(reverse(12)); +create table t1 as select reverse(12) as c1; +show create table t1; +drop table t1; + +select hex(right(123,1)); +create table t1 as select right(123,1) as c1; +show create table t1; +drop table t1; + +select hex(rpad(1,2,0)); +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +drop table t1; + +select hex(rtrim(1)); +create table t1 as select rtrim(1) as c1; +show create table t1; +drop table t1; + +select hex(soundex(1)); +create table t1 as select soundex(1) as c1; +show create table t1; +drop table t1; + +select hex(substring(1,1,1)); +create table t1 as select substring(1,1,1) as c1; +show create table t1; +drop table t1; + +select hex(trim(1)); +create table t1 as select trim(1) as c1; +show create table t1; +drop table t1; + +select hex(ucase(1)); +create table t1 as select ucase(1) as c1; +show create table t1; +drop table t1; + +select hex(upper(1)); +create table t1 as select upper(1) as c1; +show create table t1; +drop table t1; + + +# +# Bug#8204 +# +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +update t1 set a= a + 0.1; +select a, hex(a) from t1; +drop table t1; + + +# +# Columns +# +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +select concat(a) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +select concat(a) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a year(2)); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a bit(64)); +# BIT is always BINARY +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +select concat(a) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +select concat(a) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + + +# +# create view with string functions with numeric input +# +# Switched off in ucs tests due to bug#50716 +if ($not_ucs) +{ +create view v1 as select concat(1,2,3) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select concat_ws(',',1,2,3) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select elt(1,2,3) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select export_set(1,2,3,4,2) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select insert(1133,3,0,22) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select lcase(123) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select left(123,1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select lower(123) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select lpad(1,2,0) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select ltrim(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select mid(1,1,1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select repeat(1,2) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select replace(1,1,2) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select reverse(12) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select right(123,1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select rpad(1,2,0) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select rtrim(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select soundex(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select substring(1,1,1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select trim(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select ucase(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select upper(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; +} + + +# +# Views from tables with numeric columns +# +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a year(2)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a bit(64)); +# BIT is always BINARY +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +# +# User defined function returning numeric result +# +delimiter |; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +delimiter ;| + +set @a= f1(1); +select hex(@a); +select hex(concat(f1(1))); +create table t1 as select f1(1) as c1; +show create table t1; +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +drop table t1; +drop view v1; +drop function f1; + +delimiter |; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +delimiter ;| + +set @a= f1(123.45); +select hex(@a); +select hex(concat(f1(123.45))); +create table t1 as select f1(123.45) as c1; +show create table t1; +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +drop table t1; +drop view v1; +drop function f1; + +delimiter |; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +delimiter ;| + +set @a= f1(123.45); +select hex(@a); +select hex(concat(f1(123.45))); +create table t1 as select f1(123.45) as c1; +show create table t1; +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +drop table t1; +drop view v1; +drop function f1; + +delimiter |; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +delimiter ;| + +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +select hex(concat(f1(cast('2001-01-02' as date)))); +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +drop table t1; +drop view v1; +drop function f1; + + +--echo # +--echo # End of WL#2649 Number-to-string conversions +--echo # + diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 0c0e2d623c8..fcbf5812312 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -101,16 +101,16 @@ Table Create Table t1 CREATE TABLE `t1` ( `c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '', `c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '', - `c3` varbinary(1) NOT NULL DEFAULT '', - `c4` varbinary(1) NOT NULL DEFAULT '', - `c5` varbinary(4) NOT NULL DEFAULT '', - `c6` varbinary(4) NOT NULL DEFAULT '', + `c3` varchar(1) NOT NULL DEFAULT '', + `c4` varchar(1) NOT NULL DEFAULT '', + `c5` varchar(4) NOT NULL DEFAULT '', + `c6` varchar(4) NOT NULL DEFAULT '', `c7` decimal(2,1) NOT NULL DEFAULT '0.0', `c8` decimal(2,1) NOT NULL DEFAULT '0.0', `c9` decimal(2,1) DEFAULT NULL, `c10` double NOT NULL DEFAULT '0', `c11` double NOT NULL DEFAULT '0', - `c12` varbinary(5) NOT NULL DEFAULT '' + `c12` varchar(5) NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; SELECT CASE @@ -155,8 +155,8 @@ t1 CREATE TABLE `t1` ( `COALESCE(1.0)` decimal(2,1) NOT NULL DEFAULT '0.0', `COALESCE('a')` varchar(1) NOT NULL DEFAULT '', `COALESCE(1,1.0)` decimal(2,1) NOT NULL DEFAULT '0.0', - `COALESCE(1,'1')` varbinary(1) NOT NULL DEFAULT '', - `COALESCE(1.1,'1')` varbinary(4) NOT NULL DEFAULT '', + `COALESCE(1,'1')` varchar(1) NOT NULL DEFAULT '', + `COALESCE(1.1,'1')` varchar(4) NOT NULL DEFAULT '', `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 55e8e15b6a9..ae04aeb9921 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -438,7 +438,7 @@ explain t2; Field Type Null Key Default Extra a int(11) YES NULL b bigint(11) NO 0 -c bigint(11) unsigned NO 0 +c bigint(10) unsigned NO 0 d date YES NULL e varchar(1) NO f datetime YES NULL @@ -457,7 +457,7 @@ Table Create Table t2 CREATE TABLE `t2` ( `ifnull(a,a)` tinyint(4) DEFAULT NULL, `ifnull(b,b)` smallint(6) DEFAULT NULL, - `ifnull(c,c)` mediumint(8) DEFAULT NULL, + `ifnull(c,c)` mediumint(9) DEFAULT NULL, `ifnull(d,d)` int(11) DEFAULT NULL, `ifnull(e,e)` bigint(20) DEFAULT NULL, `ifnull(f,f)` float(3,2) DEFAULT NULL, diff --git a/mysql-test/r/ctype_binary.result b/mysql-test/r/ctype_binary.result new file mode 100644 index 00000000000..e7d1eb1b492 --- /dev/null +++ b/mysql-test/r/ctype_binary.result @@ -0,0 +1,2581 @@ +set names binary; +# +# Start of 5.5 tests +# +# +# Start of WL#2649 Number-to-string conversions +# +select hex(concat(1)); +hex(concat(1)) +31 +create table t1 as select concat(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +31 +drop table t1; +select hex(concat(18446744073709551615)); +hex(concat(18446744073709551615)) +3138343436373434303733373039353531363135 +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(20) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +3138343436373434303733373039353531363135 +drop table t1; +select hex(concat(1.1)); +hex(concat(1.1)) +312E31 +create table t1 as select concat(1.1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +312E31 +drop table t1; +select hex(concat('a', 1+2)), charset(concat(1+2)); +hex(concat('a', 1+2)) charset(concat(1+2)) +6133 binary +create table t1 as select concat(1+2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1-2)); +hex(concat(1-2)) +2D31 +create table t1 as select concat(1-2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1*2)); +hex(concat(1*2)) +32 +create table t1 as select concat(1*2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1/2)); +hex(concat(1/2)) +302E35303030 +create table t1 as select concat(1/2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(7) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1 div 2)); +hex(concat(1 div 2)) +30 +create table t1 as select concat(1 div 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1 % 2)); +hex(concat(1 % 2)) +31 +create table t1 as select concat(1 % 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(-1)); +hex(concat(-1)) +2D31 +create table t1 as select concat(-1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(-(1+2))); +hex(concat(-(1+2))) +2D33 +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1|2)); +hex(concat(1|2)) +33 +create table t1 as select concat(1|2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1&2)); +hex(concat(1&2)) +30 +create table t1 as select concat(1&2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(bit_count(12))); +hex(concat(bit_count(12))) +32 +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(2<<1)); +hex(concat(2<<1)) +34 +create table t1 as select concat(2<<1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(2>>1)); +hex(concat(2>>1)) +31 +create table t1 as select concat(2>>1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(~0)); +hex(concat(~0)) +3138343436373434303733373039353531363135 +create table t1 as select concat(~0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(3^2)); +hex(concat(3^2)) +31 +create table t1 as select concat(3^2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(abs(-2))); +hex(concat(abs(-2))) +32 +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(exp(2)),1)); +hex(left(concat(exp(2)),1)) +37 +create table t1 as select concat(exp(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log(2)),1)); +hex(left(concat(log(2)),1)) +30 +create table t1 as select concat(log(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log2(2)),1)); +hex(left(concat(log2(2)),1)) +31 +create table t1 as select concat(log2(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log10(2)),1)); +hex(left(concat(log10(2)),1)) +30 +create table t1 as select concat(log10(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(sqrt(2)),1)); +hex(left(concat(sqrt(2)),1)) +31 +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(pow(2,2)),1)); +hex(left(concat(pow(2,2)),1)) +34 +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(acos(0.5)),1)); +hex(left(concat(acos(0.5)),1)) +31 +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(asin(0.5)),1)); +hex(left(concat(asin(0.5)),1)) +30 +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(atan(0.5)),1)); +hex(left(concat(atan(0.5)),1)) +30 +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(cos(0.5)),1)); +hex(left(concat(cos(0.5)),1)) +30 +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(sin(0.5)),1)); +hex(left(concat(sin(0.5)),1)) +30 +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(tan(0.5)),1)); +hex(left(concat(tan(0.5)),1)) +30 +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(degrees(0))); +hex(concat(degrees(0))) +30 +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(radians(0))); +hex(concat(radians(0))) +30 +create table t1 as select concat(radians(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ceiling(0.5))); +hex(concat(ceiling(0.5))) +31 +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(floor(0.5))); +hex(concat(floor(0.5))) +30 +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(round(0.5))); +hex(concat(round(0.5))) +31 +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sign(0.5))); +hex(concat(sign(0.5))) +31 +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(rand()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(length('a'))); +hex(concat(length('a'))) +31 +create table t1 as select concat(length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(char_length('a'))); +hex(concat(char_length('a'))) +31 +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(bit_length('a'))); +hex(concat(bit_length('a'))) +38 +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(coercibility('a'))); +hex(concat(coercibility('a'))) +34 +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(locate('a','a'))); +hex(concat(locate('a','a'))) +31 +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(11) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(field('c','a','b','c'))); +hex(concat(field('c','a','b','c'))) +33 +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ascii(61))); +hex(concat(ascii(61))) +3534 +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ord(61))); +hex(concat(ord(61))) +3534 +create table t1 as select concat(ord(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(find_in_set('b','a,b,c,d'))); +hex(concat(find_in_set('b','a,b,c,d'))) +32 +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select md5('a'), hex(md5('a')); +md5('a') hex(md5('a')) +0cc175b9c0f1b6a831c399e269772661 3063633137356239633066316236613833316333393965323639373732363631 +create table t1 as select md5('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(32) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select old_password('a'), hex(old_password('a')); +old_password('a') hex(old_password('a')) +60671c896665c3fa 36303637316338393636363563336661 +create table t1 as select old_password('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(16) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select password('a'), hex(password('a')); +password('a') hex(password('a')) +*667F407DE7C6AD07358FA38DAED7828A72014B4E 2A36363746343037444537433641443037333538464133384441454437383238413732303134423445 +create table t1 as select password('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(41) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select sha('a'), hex(sha('a')); +sha('a') hex(sha('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(40) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select sha1('a'), hex(sha1('a')); +sha1('a') hex(sha1('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha1('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(40) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('-1' as signed))); +hex(concat(cast('-1' as signed))) +2D31 +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('1' as unsigned))); +hex(concat(cast('1' as unsigned))) +31 +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast(1/2 as decimal(5,5)))); +hex(concat(cast(1/2 as decimal(5,5)))) +302E3530303030 +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(7) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as date))); +hex(concat(cast('2001-01-02 03:04:05' as date))) +323030312D30312D3032 +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2001-01-02 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as time))); +hex(concat(cast('2001-01-02 03:04:05' as time))) +30333A30343A3035 +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +03:04:05 +drop table t1; +select hex(concat(cast('2001-01-02' as datetime))); +hex(concat(cast('2001-01-02' as datetime))) +323030312D30312D30322030303A30303A3030 +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(29) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2001-01-02 00:00:00 +drop table t1; +select hex(concat(least(1,2))); +hex(concat(least(1,2))) +31 +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(greatest(1,2))); +hex(concat(greatest(1,2))) +32 +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(case when 11 then 22 else 33 end)); +hex(concat(case when 11 then 22 else 33 end)) +3232 +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(coalesce(1,2))); +hex(concat(coalesce(1,2))) +31 +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat_ws(1,2,3)); +hex(concat_ws(1,2,3)) +323133 +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(group_concat(1,2,3)); +hex(group_concat(1,2,3)) +313233 +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` blob +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1 order by c1; +hex(c1) +31 +61 +drop table t1; +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(benchmark(0,0))); +hex(concat(benchmark(0,0))) +30 +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sleep(0))); +hex(concat(sleep(0))) +30 +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(get_lock('a',0))); +hex(concat(get_lock('a',0))) +31 +select hex(concat(release_lock('a'))); +hex(concat(release_lock('a'))) +31 +create table t1 as select concat(get_lock('a',0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(is_free_lock('xxxx'))); +hex(concat(is_free_lock('xxxx'))) +31 +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(crc32(''))); +hex(concat(crc32(''))) +30 +create table t1 as select concat(crc32('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(uncompressed_length(''))); +hex(concat(uncompressed_length(''))) +30 +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(connection_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(inet_aton('127.1.1.1'))); +hex(concat(inet_aton('127.1.1.1'))) +32313330373732323235 +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(inet_ntoa(2130772225))); +hex(concat(inet_ntoa(2130772225))) +3132372E312E312E31 +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +c1 +127.1.1.1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(31) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(row_count())); +hex(concat(row_count())) +2D31 +create table t1 as select concat(row_count()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(found_rows())); +hex(concat(found_rows())) +30 +create table t1 as select concat(found_rows()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(uuid()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +coercibility(uuid()) coercibility(cast('a' as char character set latin1)) +4 2 +select charset(concat(uuid(), cast('a' as char character set latin1))); +charset(concat(uuid(), cast('a' as char character set latin1))) +latin1 +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(37) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=1)); +hex(concat(@a1:=1)) +31 +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +select hex(c1) from t1; +hex(c1) +32 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '', + `c2` int(1) NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=1; +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(20) DEFAULT NULL, + `c2` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=sqrt(1))); +hex(concat(@a1:=sqrt(1))) +31 +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=sqrt(1); +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=1.1)); +hex(concat(@a1:=1.1)) +312E31 +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) NOT NULL DEFAULT '', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=1.1; +select hex(concat(@a2)); +hex(concat(@a2)) +312E31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(83) DEFAULT NULL, + `c2` decimal(65,30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@@ft_max_word_len)); +hex(concat(@@ft_max_word_len)) +3834 +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +hex(c1) +3834 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a'='a' IS TRUE)); +hex(concat('a'='a' IS TRUE)) +31 +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a'='a' IS NOT TRUE)); +hex(concat('a'='a' IS NOT TRUE)) +30 +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NOT 'a'='a')); +hex(concat(NOT 'a'='a')) +30 +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' IS NULL)); +hex(concat('a' IS NULL)) +30 +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' IS NOT NULL)); +hex(concat('a' IS NOT NULL)) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' rlike 'a')); +hex(concat('a' rlike 'a')) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(strcmp('a','b'))); +hex(concat(strcmp('a','b'))) +2D31 +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' like 'a')); +hex(concat('a' like 'a')) +31 +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' between 'b' and 'c')); +hex(concat('a' between 'b' and 'c')) +30 +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' in ('a','b'))); +hex(concat('a' in ('a','b'))) +31 +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +hex(concat(interval(23, 1, 15, 17, 30, 44, 200))) +33 +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +hex(concat(match (a) against ('a'))) +30 +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +select hex(ifnull(1,'a')); +hex(ifnull(1,'a')) +31 +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ifnull(1,1))); +hex(concat(ifnull(1,1))) +31 +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ifnull(1.1,1.1))); +hex(concat(ifnull(1.1,1.1))) +312E31 +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(if(1,'b',1)); +hex(if(1,'b',1)) +62 +create table t1 as select if(1,'b',1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(if(1,1,'b')); +hex(if(1,1,'b')) +31 +create table t1 as select if(1,1,'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(if(1,1,1))); +hex(concat(if(1,1,1))) +31 +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(nullif(1,2))); +hex(concat(nullif(1,2))) +31 +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))); +hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))) +31 +create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +32 +create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))); +hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))) +32 +create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +30 +create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))) +31 +create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))); +hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))) +30 +create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsSimple(GeomFromText('POINT(1 1)')))); +hex(concat(IsSimple(GeomFromText('POINT(1 1)')))) +30 +create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))); +hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))) +30 +create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))); +hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))) +31 +create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1; +drop table t1; +select hex(concat(x(GeomFromText('Point(1 2)')))); +hex(concat(x(GeomFromText('Point(1 2)')))) +31 +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(y(GeomFromText('Point(1 2)')))); +hex(concat(y(GeomFromText('Point(1 2)')))) +32 +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))); +hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))) +31 +create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))) +31 +create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(GeometryType(GeomFromText('Point(1 2)')))); +hex(concat(GeometryType(GeomFromText('Point(1 2)')))) +504F494E54 +create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(AsText(GeomFromText('Point(1 2)')))); +hex(concat(AsText(GeomFromText('Point(1 2)')))) +504F494E542831203229 +create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` longblob +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(period_add(200902, 2))); +hex(concat(period_add(200902, 2))) +323030393034 +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(6) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(period_diff(200902, 200802))); +hex(concat(period_diff(200902, 200802))) +3132 +create table t1 as select concat(period_add(200902, 200802)) as c1; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(6) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(to_days(20090224))); +hex(concat(to_days(20090224))) +373333383237 +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofmonth(20090224))); +hex(concat(dayofmonth(20090224))) +3234 +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofyear(20090224))); +hex(concat(dayofyear(20090224))) +3535 +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(hour('10:11:12'))); +hex(concat(hour('10:11:12'))) +3130 +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(minute('10:11:12'))); +hex(concat(minute('10:11:12'))) +3131 +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(second('10:11:12'))); +hex(concat(second('10:11:12'))) +3132 +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(quarter(20090224))); +hex(concat(quarter(20090224))) +31 +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(week(20090224))); +hex(concat(week(20090224))) +38 +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(yearweek(20090224))); +hex(concat(yearweek(20090224))) +323030393038 +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(year(20090224))); +hex(concat(year(20090224))) +32303039 +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(weekday(20090224))); +hex(concat(weekday(20090224))) +31 +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofweek(20090224))); +hex(concat(dayofweek(20090224))) +33 +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(unix_timestamp(20090224))); +hex(concat(unix_timestamp(20090224))) +31323335343232383030 +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(time_to_sec('10:11:12'))); +hex(concat(time_to_sec('10:11:12'))) +3336363732 +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(extract(year from 20090702))); +hex(concat(extract(year from 20090702))) +32303039 +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(microsecond('12:00:00.123456'))); +hex(concat(microsecond('12:00:00.123456'))) +313233343536 +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(month(20090224))); +hex(concat(month(20090224))) +32 +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select c1, hex(c1) from t1; +c1 hex(c1) +2003-02-28 323030332D30322D3238 +drop table t1; +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select c1, hex(c1) from t1; +c1 hex(c1) +2000-07-03 323030302D30372D3033 +drop table t1; +create table t1 as select concat(curdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(utc_date()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(curtime()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(8) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +c1 hex(c1) +2008-07-18 323030382D30372D3138 +08:42:04 30383A34323A3034 +drop table t1; +create table t1 as select concat(utc_time()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(8) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sec_to_time(2378))); +hex(concat(sec_to_time(2378))) +30303A33393A3338 +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))) +32343A30303A3030 +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(maketime(10,11,12))); +hex(concat(maketime(10,11,12))) +31303A31313A3132 +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(get_format(DATE,'USA')); +hex(get_format(DATE,'USA')) +256D2E25642E2559 +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(17) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(from_unixtime(1111885200)),4)); +hex(left(concat(from_unixtime(1111885200)),4)) +32303035 +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))) +323030332D31322D33312032303A30303A3030 +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))) +323030342D30312D30322031323A30303A3030 +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(29) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2004-01-02 12:00:00 +drop table t1; +select hex(concat(makedate(2009,1))); +hex(concat(makedate(2009,1))) +323030392D30312D3031 +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2009-01-01 +drop table t1; +create table t1 as select concat(now()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(sysdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(addtime('00:00:00','11:22:33'))); +hex(concat(addtime('00:00:00','11:22:33'))) +31313A32323A3333 +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(29) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(subtime('23:59:59','11:22:33'))); +hex(concat(subtime('23:59:59','11:22:33'))) +31323A33373A3236 +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(29) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(elt(1,2,3)); +hex(elt(1,2,3)) +32 +create table t1 as select elt(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(export_set(1,2,3,4,2)); +hex(export_set(1,2,3,4,2)) +323433 +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(127) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(insert(1133,3,0,22)); +hex(insert(1133,3,0,22)) +313132323333 +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(6) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lcase(123)); +hex(lcase(123)) +313233 +create table t1 as select lcase(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(123,1)); +hex(left(123,1)) +31 +create table t1 as select left(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lower(123)); +hex(lower(123)) +313233 +create table t1 as select lower(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lpad(1,2,0)); +hex(lpad(1,2,0)) +3031 +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(ltrim(1)); +hex(ltrim(1)) +31 +create table t1 as select ltrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(mid(1,1,1)); +hex(mid(1,1,1)) +31 +create table t1 as select mid(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(repeat(1,2)); +hex(repeat(1,2)) +3131 +create table t1 as select repeat(1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(replace(1,1,2)); +hex(replace(1,1,2)) +32 +create table t1 as select replace(1,1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(reverse(12)); +hex(reverse(12)) +3231 +create table t1 as select reverse(12) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(right(123,1)); +hex(right(123,1)) +33 +create table t1 as select right(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(rpad(1,2,0)); +hex(rpad(1,2,0)) +3130 +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(rtrim(1)); +hex(rtrim(1)) +31 +create table t1 as select rtrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(soundex(1)); +hex(soundex(1)) + +create table t1 as select soundex(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(substring(1,1,1)); +hex(substring(1,1,1)) +31 +create table t1 as select substring(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(trim(1)); +hex(trim(1)) +31 +create table t1 as select trim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(ucase(1)); +hex(ucase(1)) +31 +create table t1 as select ucase(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(upper(1)); +hex(upper(1)) +31 +create table t1 as select upper(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varbinary(64) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +a hex(a) +1.1 312E31 +2.1 322E31 +update t1 set a= a + 0.1; +select a, hex(a) from t1; +a hex(a) +1.2000000000000002 312E32303030303030303030303030303032 +2.2 322E32 +drop table t1; +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303031 001 +303130 010 +313030 100 +drop table t1; +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303030303030303030303030303030303030303030303030303030303031 000000000000000000000000000001 +303030303030303030303030303030303030303030303030303030303130 000000000000000000000000000010 +303030303030303030303030303030303030303030303030303030313030 000000000000000000000000000100 +drop table t1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E3435 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303031 00001 +3030303130 00010 +3030313030 00100 +3031303030 01000 +3130303030 10000 +drop table t1; +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303031 00000001 +3030303030303130 00000010 +3030303030313030 00000100 +3030303031303030 00001000 +3030303130303030 00010000 +drop table t1; +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303031 0000000001 +30303030303030303130 0000000010 +30303030303030313030 0000000100 +30303030303031303030 0000001000 +30303030303130303030 0000010000 +drop table t1; +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303030303030303030303030303031 00000000000000000001 +3030303030303030303030303030303030303130 00000000000000000010 +3030303030303030303030303030303030313030 00000000000000000100 +3030303030303030303030303030303031303030 00000000000000001000 +3030303030303030303030303030303130303030 00000000000000010000 +drop table t1; +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303030303030303030312E31 0000000001.1 +303030303030303031302E31 0000000010.1 +303030303030303130302E31 0000000100.1 +303030303030313030302E31 0000001000.1 +303030303031303030302E31 0000010000.1 +drop table t1; +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(22) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303030303030303030303030312E31 00000000000000000001.1 +30303030303030303030303030303030303031302E31 00000000000000000010.1 +30303030303030303030303030303030303130302E31 00000000000000000100.1 +30303030303030303030303030303030313030302E31 00000000000000001000.1 +30303030303030303030303030303031303030302E31 00000000000000010000.1 +drop table t1; +create table t1 (a year(2)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +3031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +32303031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a bit(64)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0000000000000001 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +hex(concat(a)) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +select concat(a) from t1; +concat(a) +0000-00-00 00:00:00 +2001-02-03 04:05:06 +1980-02-03 04:05:06 +2001-02-03 04:05:06 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D3033 +323030312D30322D3033 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +hex(concat(a)) +30303A30303A3031 +30313A30323A3033 +select concat(a) from t1; +concat(a) +00:00:01 +01:02:03 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(8) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(19) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(4) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(3) YES NULL +select hex(a) from v1; +hex(a) +303031 +303130 +313030 +drop table t1; +drop view v1; +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(30) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030303030303030303030303030303030303030303031 +303030303030303030303030303030303030303030303030303030303130 +303030303030303030303030303030303030303030303030303030313030 +drop table t1; +drop view v1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E3435 +drop table t1; +drop view v1; +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(6) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(5) YES NULL +select hex(a) from v1; +hex(a) +3030303031 +3030303130 +3030313030 +3031303030 +3130303030 +drop table t1; +drop view v1; +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(9) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(8) YES NULL +select hex(a) from v1; +hex(a) +3030303030303031 +3030303030303130 +3030303030313030 +3030303031303030 +3030303130303030 +drop table t1; +drop view v1; +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(11) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(10) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303031 +30303030303030303130 +30303030303030313030 +30303030303031303030 +30303030303130303030 +drop table t1; +drop view v1; +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(20) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(20) YES NULL +select hex(a) from v1; +hex(a) +3030303030303030303030303030303030303031 +3030303030303030303030303030303030303130 +3030303030303030303030303030303030313030 +3030303030303030303030303030303031303030 +3030303030303030303030303030303130303030 +drop table t1; +drop view v1; +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(12) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030312E31 +303030303030303031302E31 +303030303030303130302E31 +303030303030313030302E31 +303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +concat(a) +123.456 +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(22) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(22) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303030303030303030303030312E31 +30303030303030303030303030303030303031302E31 +30303030303030303030303030303030303130302E31 +30303030303030303030303030303030313030302E31 +30303030303030303030303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a year(2)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(2) YES NULL +select hex(a) from v1; +hex(a) +3031 +drop table t1; +drop view v1; +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(4) YES NULL +select hex(a) from v1; +hex(a) +32303031 +drop table t1; +drop view v1; +create table t1 (a bit(64)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(64) YES NULL +select hex(a) from v1; +hex(a) +0000000000000001 +drop table t1; +drop view v1; +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(19) NO +select hex(a) from v1; +hex(a) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(10) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D3033 +323030312D30322D3033 +drop table t1; +drop view v1; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(8) YES NULL +select hex(a) from v1; +hex(a) +30303A30303A3031 +30313A30323A3033 +drop table t1; +drop view v1; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(19) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +set @a= f1(1); +select hex(@a); +hex(@a) +1 +select hex(concat(f1(1))); +hex(concat(f1(1))) +31 +create table t1 as select f1(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(11) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` decimal(18,2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(20) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` float DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(12) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +hex(@a) +323030312D30312D3032 +select hex(concat(f1(cast('2001-01-02' as date)))); +hex(concat(f1(cast('2001-01-02' as date)))) +323030312D30312D3032 +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(10) YES NULL +drop table t1; +drop view v1; +drop function f1; +# +# End of WL#2649 Number-to-string conversions +# +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index bf0bc07c50e..f2e7c43a3ce 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -81,3 +81,2583 @@ t1 CREATE TABLE `t1` ( `e2` enum('ěë˙ęî') DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 DROP TABLE t1; +# +# Start of 5.5 tests +# +# +# Start of WL#2649 Number-to-string conversions +# +select hex(concat(1)); +hex(concat(1)) +31 +create table t1 as select concat(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +31 +drop table t1; +select hex(concat(18446744073709551615)); +hex(concat(18446744073709551615)) +3138343436373434303733373039353531363135 +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +3138343436373434303733373039353531363135 +drop table t1; +select hex(concat(1.1)); +hex(concat(1.1)) +312E31 +create table t1 as select concat(1.1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +312E31 +drop table t1; +select hex(concat('a', 1+2)), charset(concat(1+2)); +hex(concat('a', 1+2)) charset(concat(1+2)) +6133 cp1251 +create table t1 as select concat(1+2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1-2)); +hex(concat(1-2)) +2D31 +create table t1 as select concat(1-2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1*2)); +hex(concat(1*2)) +32 +create table t1 as select concat(1*2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1/2)); +hex(concat(1/2)) +302E35303030 +create table t1 as select concat(1/2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1 div 2)); +hex(concat(1 div 2)) +30 +create table t1 as select concat(1 div 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1 % 2)); +hex(concat(1 % 2)) +31 +create table t1 as select concat(1 % 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(-1)); +hex(concat(-1)) +2D31 +create table t1 as select concat(-1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(-(1+2))); +hex(concat(-(1+2))) +2D33 +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1|2)); +hex(concat(1|2)) +33 +create table t1 as select concat(1|2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1&2)); +hex(concat(1&2)) +30 +create table t1 as select concat(1&2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(bit_count(12))); +hex(concat(bit_count(12))) +32 +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(2<<1)); +hex(concat(2<<1)) +34 +create table t1 as select concat(2<<1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(2>>1)); +hex(concat(2>>1)) +31 +create table t1 as select concat(2>>1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(~0)); +hex(concat(~0)) +3138343436373434303733373039353531363135 +create table t1 as select concat(~0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(3^2)); +hex(concat(3^2)) +31 +create table t1 as select concat(3^2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(abs(-2))); +hex(concat(abs(-2))) +32 +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(exp(2)),1)); +hex(left(concat(exp(2)),1)) +37 +create table t1 as select concat(exp(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log(2)),1)); +hex(left(concat(log(2)),1)) +30 +create table t1 as select concat(log(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log2(2)),1)); +hex(left(concat(log2(2)),1)) +31 +create table t1 as select concat(log2(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log10(2)),1)); +hex(left(concat(log10(2)),1)) +30 +create table t1 as select concat(log10(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(sqrt(2)),1)); +hex(left(concat(sqrt(2)),1)) +31 +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(pow(2,2)),1)); +hex(left(concat(pow(2,2)),1)) +34 +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(acos(0.5)),1)); +hex(left(concat(acos(0.5)),1)) +31 +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(asin(0.5)),1)); +hex(left(concat(asin(0.5)),1)) +30 +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(atan(0.5)),1)); +hex(left(concat(atan(0.5)),1)) +30 +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(cos(0.5)),1)); +hex(left(concat(cos(0.5)),1)) +30 +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(sin(0.5)),1)); +hex(left(concat(sin(0.5)),1)) +30 +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(tan(0.5)),1)); +hex(left(concat(tan(0.5)),1)) +30 +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(degrees(0))); +hex(concat(degrees(0))) +30 +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(radians(0))); +hex(concat(radians(0))) +30 +create table t1 as select concat(radians(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ceiling(0.5))); +hex(concat(ceiling(0.5))) +31 +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(floor(0.5))); +hex(concat(floor(0.5))) +30 +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(round(0.5))); +hex(concat(round(0.5))) +31 +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sign(0.5))); +hex(concat(sign(0.5))) +31 +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(rand()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(length('a'))); +hex(concat(length('a'))) +31 +create table t1 as select concat(length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(char_length('a'))); +hex(concat(char_length('a'))) +31 +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(bit_length('a'))); +hex(concat(bit_length('a'))) +38 +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(coercibility('a'))); +hex(concat(coercibility('a'))) +34 +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(locate('a','a'))); +hex(concat(locate('a','a'))) +31 +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(field('c','a','b','c'))); +hex(concat(field('c','a','b','c'))) +33 +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ascii(61))); +hex(concat(ascii(61))) +3534 +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ord(61))); +hex(concat(ord(61))) +3534 +create table t1 as select concat(ord(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(find_in_set('b','a,b,c,d'))); +hex(concat(find_in_set('b','a,b,c,d'))) +32 +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select md5('a'), hex(md5('a')); +md5('a') hex(md5('a')) +0cc175b9c0f1b6a831c399e269772661 3063633137356239633066316236613833316333393965323639373732363631 +create table t1 as select md5('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(32) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select old_password('a'), hex(old_password('a')); +old_password('a') hex(old_password('a')) +60671c896665c3fa 36303637316338393636363563336661 +create table t1 as select old_password('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(16) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select password('a'), hex(password('a')); +password('a') hex(password('a')) +*667F407DE7C6AD07358FA38DAED7828A72014B4E 2A36363746343037444537433641443037333538464133384441454437383238413732303134423445 +create table t1 as select password('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(41) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select sha('a'), hex(sha('a')); +sha('a') hex(sha('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select sha1('a'), hex(sha1('a')); +sha1('a') hex(sha1('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha1('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('-1' as signed))); +hex(concat(cast('-1' as signed))) +2D31 +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('1' as unsigned))); +hex(concat(cast('1' as unsigned))) +31 +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast(1/2 as decimal(5,5)))); +hex(concat(cast(1/2 as decimal(5,5)))) +302E3530303030 +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as date))); +hex(concat(cast('2001-01-02 03:04:05' as date))) +323030312D30312D3032 +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2001-01-02 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as time))); +hex(concat(cast('2001-01-02 03:04:05' as time))) +30333A30343A3035 +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +03:04:05 +drop table t1; +select hex(concat(cast('2001-01-02' as datetime))); +hex(concat(cast('2001-01-02' as datetime))) +323030312D30312D30322030303A30303A3030 +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2001-01-02 00:00:00 +drop table t1; +select hex(concat(least(1,2))); +hex(concat(least(1,2))) +31 +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(greatest(1,2))); +hex(concat(greatest(1,2))) +32 +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(case when 11 then 22 else 33 end)); +hex(concat(case when 11 then 22 else 33 end)) +3232 +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(coalesce(1,2))); +hex(concat(coalesce(1,2))) +31 +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat_ws(1,2,3)); +hex(concat_ws(1,2,3)) +323133 +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(group_concat(1,2,3)); +hex(group_concat(1,2,3)) +313233 +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` text CHARACTER SET cp1251 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1 order by c1; +hex(c1) +31 +61 +drop table t1; +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(benchmark(0,0))); +hex(concat(benchmark(0,0))) +30 +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sleep(0))); +hex(concat(sleep(0))) +30 +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(get_lock('a',0))); +hex(concat(get_lock('a',0))) +31 +select hex(concat(release_lock('a'))); +hex(concat(release_lock('a'))) +31 +create table t1 as select concat(get_lock('a',0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(is_free_lock('xxxx'))); +hex(concat(is_free_lock('xxxx'))) +31 +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(crc32(''))); +hex(concat(crc32(''))) +30 +create table t1 as select concat(crc32('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(uncompressed_length(''))); +hex(concat(uncompressed_length(''))) +30 +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(connection_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(inet_aton('127.1.1.1'))); +hex(concat(inet_aton('127.1.1.1'))) +32313330373732323235 +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(inet_ntoa(2130772225))); +hex(concat(inet_ntoa(2130772225))) +3132372E312E312E31 +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +c1 +127.1.1.1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(31) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(row_count())); +hex(concat(row_count())) +2D31 +create table t1 as select concat(row_count()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(found_rows())); +hex(concat(found_rows())) +30 +create table t1 as select concat(found_rows()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(uuid()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +coercibility(uuid()) coercibility(cast('a' as char character set latin1)) +4 2 +select charset(concat(uuid(), cast('a' as char character set latin1))); +charset(concat(uuid(), cast('a' as char character set latin1))) +latin1 +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(37) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=1)); +hex(concat(@a1:=1)) +31 +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +select hex(c1) from t1; +hex(c1) +32 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '', + `c2` int(1) NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=1; +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET cp1251 DEFAULT NULL, + `c2` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=sqrt(1))); +hex(concat(@a1:=sqrt(1))) +31 +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=sqrt(1); +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=1.1)); +hex(concat(@a1:=1.1)) +312E31 +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT '', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=1.1; +select hex(concat(@a2)); +hex(concat(@a2)) +312E31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(83) CHARACTER SET cp1251 DEFAULT NULL, + `c2` decimal(65,30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@@ft_max_word_len)); +hex(concat(@@ft_max_word_len)) +3834 +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +hex(c1) +3834 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a'='a' IS TRUE)); +hex(concat('a'='a' IS TRUE)) +31 +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a'='a' IS NOT TRUE)); +hex(concat('a'='a' IS NOT TRUE)) +30 +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NOT 'a'='a')); +hex(concat(NOT 'a'='a')) +30 +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' IS NULL)); +hex(concat('a' IS NULL)) +30 +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' IS NOT NULL)); +hex(concat('a' IS NOT NULL)) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' rlike 'a')); +hex(concat('a' rlike 'a')) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(strcmp('a','b'))); +hex(concat(strcmp('a','b'))) +2D31 +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' like 'a')); +hex(concat('a' like 'a')) +31 +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' between 'b' and 'c')); +hex(concat('a' between 'b' and 'c')) +30 +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' in ('a','b'))); +hex(concat('a' in ('a','b'))) +31 +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +hex(concat(interval(23, 1, 15, 17, 30, 44, 200))) +33 +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +hex(concat(match (a) against ('a'))) +30 +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +select hex(ifnull(1,'a')); +hex(ifnull(1,'a')) +31 +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ifnull(1,1))); +hex(concat(ifnull(1,1))) +31 +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ifnull(1.1,1.1))); +hex(concat(ifnull(1.1,1.1))) +312E31 +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(if(1,'b',1)); +hex(if(1,'b',1)) +62 +create table t1 as select if(1,'b',1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(if(1,1,'b')); +hex(if(1,1,'b')) +31 +create table t1 as select if(1,1,'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(if(1,1,1))); +hex(concat(if(1,1,1))) +31 +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(nullif(1,2))); +hex(concat(nullif(1,2))) +31 +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))); +hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))) +31 +create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +32 +create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))); +hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))) +32 +create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +30 +create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))) +31 +create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))); +hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))) +30 +create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsSimple(GeomFromText('POINT(1 1)')))); +hex(concat(IsSimple(GeomFromText('POINT(1 1)')))) +30 +create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))); +hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))) +30 +create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))); +hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))) +31 +create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1; +drop table t1; +select hex(concat(x(GeomFromText('Point(1 2)')))); +hex(concat(x(GeomFromText('Point(1 2)')))) +31 +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(y(GeomFromText('Point(1 2)')))); +hex(concat(y(GeomFromText('Point(1 2)')))) +32 +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))); +hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))) +31 +create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))) +31 +create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(GeometryType(GeomFromText('Point(1 2)')))); +hex(concat(GeometryType(GeomFromText('Point(1 2)')))) +504F494E54 +create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(AsText(GeomFromText('Point(1 2)')))); +hex(concat(AsText(GeomFromText('Point(1 2)')))) +504F494E542831203229 +create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` longtext CHARACTER SET cp1251 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(period_add(200902, 2))); +hex(concat(period_add(200902, 2))) +323030393034 +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(period_diff(200902, 200802))); +hex(concat(period_diff(200902, 200802))) +3132 +create table t1 as select concat(period_add(200902, 200802)) as c1; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(to_days(20090224))); +hex(concat(to_days(20090224))) +373333383237 +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofmonth(20090224))); +hex(concat(dayofmonth(20090224))) +3234 +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofyear(20090224))); +hex(concat(dayofyear(20090224))) +3535 +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(hour('10:11:12'))); +hex(concat(hour('10:11:12'))) +3130 +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(minute('10:11:12'))); +hex(concat(minute('10:11:12'))) +3131 +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(second('10:11:12'))); +hex(concat(second('10:11:12'))) +3132 +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(quarter(20090224))); +hex(concat(quarter(20090224))) +31 +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(week(20090224))); +hex(concat(week(20090224))) +38 +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(yearweek(20090224))); +hex(concat(yearweek(20090224))) +323030393038 +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(year(20090224))); +hex(concat(year(20090224))) +32303039 +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(weekday(20090224))); +hex(concat(weekday(20090224))) +31 +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofweek(20090224))); +hex(concat(dayofweek(20090224))) +33 +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(unix_timestamp(20090224))); +hex(concat(unix_timestamp(20090224))) +31323335343232383030 +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(time_to_sec('10:11:12'))); +hex(concat(time_to_sec('10:11:12'))) +3336363732 +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(extract(year from 20090702))); +hex(concat(extract(year from 20090702))) +32303039 +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(microsecond('12:00:00.123456'))); +hex(concat(microsecond('12:00:00.123456'))) +313233343536 +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(month(20090224))); +hex(concat(month(20090224))) +32 +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select c1, hex(c1) from t1; +c1 hex(c1) +2003-02-28 323030332D30322D3238 +drop table t1; +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select c1, hex(c1) from t1; +c1 hex(c1) +2000-07-03 323030302D30372D3033 +drop table t1; +create table t1 as select concat(curdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(utc_date()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(curtime()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +c1 hex(c1) +2008-07-18 323030382D30372D3138 +08:42:04 30383A34323A3034 +drop table t1; +create table t1 as select concat(utc_time()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sec_to_time(2378))); +hex(concat(sec_to_time(2378))) +30303A33393A3338 +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))) +32343A30303A3030 +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(maketime(10,11,12))); +hex(concat(maketime(10,11,12))) +31303A31313A3132 +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(get_format(DATE,'USA')); +hex(get_format(DATE,'USA')) +256D2E25642E2559 +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(17) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(from_unixtime(1111885200)),4)); +hex(left(concat(from_unixtime(1111885200)),4)) +32303035 +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))) +323030332D31322D33312032303A30303A3030 +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))) +323030342D30312D30322031323A30303A3030 +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2004-01-02 12:00:00 +drop table t1; +select hex(concat(makedate(2009,1))); +hex(concat(makedate(2009,1))) +323030392D30312D3031 +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2009-01-01 +drop table t1; +create table t1 as select concat(now()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(sysdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(addtime('00:00:00','11:22:33'))); +hex(concat(addtime('00:00:00','11:22:33'))) +31313A32323A3333 +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(subtime('23:59:59','11:22:33'))); +hex(concat(subtime('23:59:59','11:22:33'))) +31323A33373A3236 +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(elt(1,2,3)); +hex(elt(1,2,3)) +32 +create table t1 as select elt(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(export_set(1,2,3,4,2)); +hex(export_set(1,2,3,4,2)) +323433 +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(127) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(insert(1133,3,0,22)); +hex(insert(1133,3,0,22)) +313132323333 +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lcase(123)); +hex(lcase(123)) +313233 +create table t1 as select lcase(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(123,1)); +hex(left(123,1)) +31 +create table t1 as select left(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lower(123)); +hex(lower(123)) +313233 +create table t1 as select lower(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lpad(1,2,0)); +hex(lpad(1,2,0)) +3031 +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(ltrim(1)); +hex(ltrim(1)) +31 +create table t1 as select ltrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(mid(1,1,1)); +hex(mid(1,1,1)) +31 +create table t1 as select mid(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(repeat(1,2)); +hex(repeat(1,2)) +3131 +create table t1 as select repeat(1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(replace(1,1,2)); +hex(replace(1,1,2)) +32 +create table t1 as select replace(1,1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(reverse(12)); +hex(reverse(12)) +3231 +create table t1 as select reverse(12) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(right(123,1)); +hex(right(123,1)) +33 +create table t1 as select right(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(rpad(1,2,0)); +hex(rpad(1,2,0)) +3130 +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(rtrim(1)); +hex(rtrim(1)) +31 +create table t1 as select rtrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(soundex(1)); +hex(soundex(1)) + +create table t1 as select soundex(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(substring(1,1,1)); +hex(substring(1,1,1)) +31 +create table t1 as select substring(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(trim(1)); +hex(trim(1)) +31 +create table t1 as select trim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(ucase(1)); +hex(ucase(1)) +31 +create table t1 as select ucase(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(upper(1)); +hex(upper(1)) +31 +create table t1 as select upper(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(64) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +a hex(a) +1.1 312E31 +2.1 322E31 +update t1 set a= a + 0.1; +select a, hex(a) from t1; +a hex(a) +1.2000000000000002 312E32303030303030303030303030303032 +2.2 322E32 +drop table t1; +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303031 001 +303130 010 +313030 100 +drop table t1; +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303030303030303030303030303030303030303030303030303030303031 000000000000000000000000000001 +303030303030303030303030303030303030303030303030303030303130 000000000000000000000000000010 +303030303030303030303030303030303030303030303030303030313030 000000000000000000000000000100 +drop table t1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E3435 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(6) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303031 00001 +3030303130 00010 +3030313030 00100 +3031303030 01000 +3130303030 10000 +drop table t1; +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(9) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303031 00000001 +3030303030303130 00000010 +3030303030313030 00000100 +3030303031303030 00001000 +3030303130303030 00010000 +drop table t1; +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(11) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303031 0000000001 +30303030303030303130 0000000010 +30303030303030313030 0000000100 +30303030303031303030 0000001000 +30303030303130303030 0000010000 +drop table t1; +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(20) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303030303030303030303030303031 00000000000000000001 +3030303030303030303030303030303030303130 00000000000000000010 +3030303030303030303030303030303030313030 00000000000000000100 +3030303030303030303030303030303031303030 00000000000000001000 +3030303030303030303030303030303130303030 00000000000000010000 +drop table t1; +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303030303030303030312E31 0000000001.1 +303030303030303031302E31 0000000010.1 +303030303030303130302E31 0000000100.1 +303030303030313030302E31 0000001000.1 +303030303031303030302E31 0000010000.1 +drop table t1; +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(22) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303030303030303030303030312E31 00000000000000000001.1 +30303030303030303030303030303030303031302E31 00000000000000000010.1 +30303030303030303030303030303030303130302E31 00000000000000000100.1 +30303030303030303030303030303030313030302E31 00000000000000001000.1 +30303030303030303030303030303031303030302E31 00000000000000010000.1 +drop table t1; +create table t1 (a year(2)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +3031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(2) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +32303031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a bit(64)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0000000000000001 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +hex(concat(a)) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +select concat(a) from t1; +concat(a) +0000-00-00 00:00:00 +2001-02-03 04:05:06 +1980-02-03 04:05:06 +2001-02-03 04:05:06 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) CHARACTER SET cp1251 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D3033 +323030312D30322D3033 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(10) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +hex(concat(a)) +30303A30303A3031 +30313A30323A3033 +select concat(a) from t1; +concat(a) +00:00:01 +01:02:03 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(8) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) CHARACTER SET cp1251 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(3) YES NULL +select hex(a) from v1; +hex(a) +303031 +303130 +313030 +drop table t1; +drop view v1; +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(30) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030303030303030303030303030303030303030303031 +303030303030303030303030303030303030303030303030303030303130 +303030303030303030303030303030303030303030303030303030313030 +drop table t1; +drop view v1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E3435 +drop table t1; +drop view v1; +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(6) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(5) YES NULL +select hex(a) from v1; +hex(a) +3030303031 +3030303130 +3030313030 +3031303030 +3130303030 +drop table t1; +drop view v1; +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(9) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(8) YES NULL +select hex(a) from v1; +hex(a) +3030303030303031 +3030303030303130 +3030303030313030 +3030303031303030 +3030303130303030 +drop table t1; +drop view v1; +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(11) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303031 +30303030303030303130 +30303030303030313030 +30303030303031303030 +30303030303130303030 +drop table t1; +drop view v1; +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +3030303030303030303030303030303030303031 +3030303030303030303030303030303030303130 +3030303030303030303030303030303030313030 +3030303030303030303030303030303031303030 +3030303030303030303030303030303130303030 +drop table t1; +drop view v1; +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030312E31 +303030303030303031302E31 +303030303030303130302E31 +303030303030313030302E31 +303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +concat(a) +123.456 +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303030303030303030303030312E31 +30303030303030303030303030303030303031302E31 +30303030303030303030303030303030303130302E31 +30303030303030303030303030303030313030302E31 +30303030303030303030303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a year(2)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(2) YES NULL +select hex(a) from v1; +hex(a) +3031 +drop table t1; +drop view v1; +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +32303031 +drop table t1; +drop view v1; +create table t1 (a bit(64)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(64) YES NULL +select hex(a) from v1; +hex(a) +0000000000000001 +drop table t1; +drop view v1; +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) NO +select hex(a) from v1; +hex(a) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D3033 +323030312D30322D3033 +drop table t1; +drop view v1; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(8) YES NULL +select hex(a) from v1; +hex(a) +30303A30303A3031 +30313A30323A3033 +drop table t1; +drop view v1; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +set @a= f1(1); +select hex(@a); +hex(@a) +1 +select hex(concat(f1(1))); +hex(concat(f1(1))) +31 +create table t1 as select f1(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(11) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` decimal(18,2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(20) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` float DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(12) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +hex(@a) +323030312D30312D3032 +select hex(concat(f1(cast('2001-01-02' as date)))); +hex(concat(f1(cast('2001-01-02' as date)))) +323030312D30312D3032 +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(10) YES NULL +drop table t1; +drop view v1; +drop function f1; +# +# End of WL#2649 Number-to-string conversions +# +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 763acd0fea0..61d663b7e76 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -409,3 +409,2583 @@ select hex(cast(_ascii 0x7f as char(1) character set latin1)); hex(cast(_ascii 0x7f as char(1) character set latin1)) 7F End of 5.0 tests +# +# Start of 5.5 tests +# +# +# Start of WL#2649 Number-to-string conversions +# +select hex(concat(1)); +hex(concat(1)) +31 +create table t1 as select concat(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +31 +drop table t1; +select hex(concat(18446744073709551615)); +hex(concat(18446744073709551615)) +3138343436373434303733373039353531363135 +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +3138343436373434303733373039353531363135 +drop table t1; +select hex(concat(1.1)); +hex(concat(1.1)) +312E31 +create table t1 as select concat(1.1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +312E31 +drop table t1; +select hex(concat('a', 1+2)), charset(concat(1+2)); +hex(concat('a', 1+2)) charset(concat(1+2)) +6133 latin1 +create table t1 as select concat(1+2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1-2)); +hex(concat(1-2)) +2D31 +create table t1 as select concat(1-2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1*2)); +hex(concat(1*2)) +32 +create table t1 as select concat(1*2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1/2)); +hex(concat(1/2)) +302E35303030 +create table t1 as select concat(1/2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1 div 2)); +hex(concat(1 div 2)) +30 +create table t1 as select concat(1 div 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1 % 2)); +hex(concat(1 % 2)) +31 +create table t1 as select concat(1 % 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(-1)); +hex(concat(-1)) +2D31 +create table t1 as select concat(-1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(-(1+2))); +hex(concat(-(1+2))) +2D33 +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1|2)); +hex(concat(1|2)) +33 +create table t1 as select concat(1|2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1&2)); +hex(concat(1&2)) +30 +create table t1 as select concat(1&2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(bit_count(12))); +hex(concat(bit_count(12))) +32 +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(2<<1)); +hex(concat(2<<1)) +34 +create table t1 as select concat(2<<1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(2>>1)); +hex(concat(2>>1)) +31 +create table t1 as select concat(2>>1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(~0)); +hex(concat(~0)) +3138343436373434303733373039353531363135 +create table t1 as select concat(~0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(3^2)); +hex(concat(3^2)) +31 +create table t1 as select concat(3^2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(abs(-2))); +hex(concat(abs(-2))) +32 +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(exp(2)),1)); +hex(left(concat(exp(2)),1)) +37 +create table t1 as select concat(exp(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log(2)),1)); +hex(left(concat(log(2)),1)) +30 +create table t1 as select concat(log(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log2(2)),1)); +hex(left(concat(log2(2)),1)) +31 +create table t1 as select concat(log2(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log10(2)),1)); +hex(left(concat(log10(2)),1)) +30 +create table t1 as select concat(log10(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(sqrt(2)),1)); +hex(left(concat(sqrt(2)),1)) +31 +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(pow(2,2)),1)); +hex(left(concat(pow(2,2)),1)) +34 +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(acos(0.5)),1)); +hex(left(concat(acos(0.5)),1)) +31 +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(asin(0.5)),1)); +hex(left(concat(asin(0.5)),1)) +30 +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(atan(0.5)),1)); +hex(left(concat(atan(0.5)),1)) +30 +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(cos(0.5)),1)); +hex(left(concat(cos(0.5)),1)) +30 +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(sin(0.5)),1)); +hex(left(concat(sin(0.5)),1)) +30 +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(tan(0.5)),1)); +hex(left(concat(tan(0.5)),1)) +30 +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(degrees(0))); +hex(concat(degrees(0))) +30 +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(radians(0))); +hex(concat(radians(0))) +30 +create table t1 as select concat(radians(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ceiling(0.5))); +hex(concat(ceiling(0.5))) +31 +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(floor(0.5))); +hex(concat(floor(0.5))) +30 +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(round(0.5))); +hex(concat(round(0.5))) +31 +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sign(0.5))); +hex(concat(sign(0.5))) +31 +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(rand()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(length('a'))); +hex(concat(length('a'))) +31 +create table t1 as select concat(length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(char_length('a'))); +hex(concat(char_length('a'))) +31 +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(bit_length('a'))); +hex(concat(bit_length('a'))) +38 +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(coercibility('a'))); +hex(concat(coercibility('a'))) +34 +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(locate('a','a'))); +hex(concat(locate('a','a'))) +31 +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(field('c','a','b','c'))); +hex(concat(field('c','a','b','c'))) +33 +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ascii(61))); +hex(concat(ascii(61))) +3534 +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ord(61))); +hex(concat(ord(61))) +3534 +create table t1 as select concat(ord(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(find_in_set('b','a,b,c,d'))); +hex(concat(find_in_set('b','a,b,c,d'))) +32 +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select md5('a'), hex(md5('a')); +md5('a') hex(md5('a')) +0cc175b9c0f1b6a831c399e269772661 3063633137356239633066316236613833316333393965323639373732363631 +create table t1 as select md5('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(32) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select old_password('a'), hex(old_password('a')); +old_password('a') hex(old_password('a')) +60671c896665c3fa 36303637316338393636363563336661 +create table t1 as select old_password('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(16) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select password('a'), hex(password('a')); +password('a') hex(password('a')) +*667F407DE7C6AD07358FA38DAED7828A72014B4E 2A36363746343037444537433641443037333538464133384441454437383238413732303134423445 +create table t1 as select password('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(41) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select sha('a'), hex(sha('a')); +sha('a') hex(sha('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select sha1('a'), hex(sha1('a')); +sha1('a') hex(sha1('a')) +86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 38366637653433376661613561376663653135643164646362396561656165613337373636376238 +create table t1 as select sha1('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('-1' as signed))); +hex(concat(cast('-1' as signed))) +2D31 +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('1' as unsigned))); +hex(concat(cast('1' as unsigned))) +31 +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast(1/2 as decimal(5,5)))); +hex(concat(cast(1/2 as decimal(5,5)))) +302E3530303030 +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as date))); +hex(concat(cast('2001-01-02 03:04:05' as date))) +323030312D30312D3032 +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2001-01-02 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as time))); +hex(concat(cast('2001-01-02 03:04:05' as time))) +30333A30343A3035 +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +03:04:05 +drop table t1; +select hex(concat(cast('2001-01-02' as datetime))); +hex(concat(cast('2001-01-02' as datetime))) +323030312D30312D30322030303A30303A3030 +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2001-01-02 00:00:00 +drop table t1; +select hex(concat(least(1,2))); +hex(concat(least(1,2))) +31 +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(greatest(1,2))); +hex(concat(greatest(1,2))) +32 +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(case when 11 then 22 else 33 end)); +hex(concat(case when 11 then 22 else 33 end)) +3232 +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(coalesce(1,2))); +hex(concat(coalesce(1,2))) +31 +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat_ws(1,2,3)); +hex(concat_ws(1,2,3)) +323133 +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(group_concat(1,2,3)); +hex(group_concat(1,2,3)) +313233 +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` text +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1 order by c1; +hex(c1) +31 +61 +drop table t1; +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(benchmark(0,0))); +hex(concat(benchmark(0,0))) +30 +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sleep(0))); +hex(concat(sleep(0))) +30 +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(get_lock('a',0))); +hex(concat(get_lock('a',0))) +31 +select hex(concat(release_lock('a'))); +hex(concat(release_lock('a'))) +31 +create table t1 as select concat(get_lock('a',0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(is_free_lock('xxxx'))); +hex(concat(is_free_lock('xxxx'))) +31 +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(crc32(''))); +hex(concat(crc32(''))) +30 +create table t1 as select concat(crc32('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(uncompressed_length(''))); +hex(concat(uncompressed_length(''))) +30 +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(connection_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(inet_aton('127.1.1.1'))); +hex(concat(inet_aton('127.1.1.1'))) +32313330373732323235 +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(inet_ntoa(2130772225))); +hex(concat(inet_ntoa(2130772225))) +3132372E312E312E31 +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +c1 +127.1.1.1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(31) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(row_count())); +hex(concat(row_count())) +2D31 +create table t1 as select concat(row_count()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(found_rows())); +hex(concat(found_rows())) +30 +create table t1 as select concat(found_rows()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(uuid()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +coercibility(uuid()) coercibility(cast('a' as char character set latin1)) +4 2 +select charset(concat(uuid(), cast('a' as char character set latin1))); +charset(concat(uuid(), cast('a' as char character set latin1))) +latin1 +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(37) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=1)); +hex(concat(@a1:=1)) +31 +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +select hex(c1) from t1; +hex(c1) +32 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '', + `c2` int(1) NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=1; +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) DEFAULT NULL, + `c2` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=sqrt(1))); +hex(concat(@a1:=sqrt(1))) +31 +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=sqrt(1); +select hex(concat(@a2)); +hex(concat(@a2)) +31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=1.1)); +hex(concat(@a1:=1.1)) +312E31 +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) NOT NULL DEFAULT '', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=1.1; +select hex(concat(@a2)); +hex(concat(@a2)) +312E31 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +312E31 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(83) DEFAULT NULL, + `c2` decimal(65,30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@@ft_max_word_len)); +hex(concat(@@ft_max_word_len)) +3834 +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +hex(c1) +3834 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a'='a' IS TRUE)); +hex(concat('a'='a' IS TRUE)) +31 +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a'='a' IS NOT TRUE)); +hex(concat('a'='a' IS NOT TRUE)) +30 +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NOT 'a'='a')); +hex(concat(NOT 'a'='a')) +30 +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' IS NULL)); +hex(concat('a' IS NULL)) +30 +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' IS NOT NULL)); +hex(concat('a' IS NOT NULL)) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' rlike 'a')); +hex(concat('a' rlike 'a')) +31 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(strcmp('a','b'))); +hex(concat(strcmp('a','b'))) +2D31 +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' like 'a')); +hex(concat('a' like 'a')) +31 +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' between 'b' and 'c')); +hex(concat('a' between 'b' and 'c')) +30 +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' in ('a','b'))); +hex(concat('a' in ('a','b'))) +31 +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +hex(concat(interval(23, 1, 15, 17, 30, 44, 200))) +33 +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +hex(concat(match (a) against ('a'))) +30 +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +select hex(ifnull(1,'a')); +hex(ifnull(1,'a')) +31 +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ifnull(1,1))); +hex(concat(ifnull(1,1))) +31 +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ifnull(1.1,1.1))); +hex(concat(ifnull(1.1,1.1))) +312E31 +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(if(1,'b',1)); +hex(if(1,'b',1)) +62 +create table t1 as select if(1,'b',1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(if(1,1,'b')); +hex(if(1,1,'b')) +31 +create table t1 as select if(1,1,'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(if(1,1,1))); +hex(concat(if(1,1,1))) +31 +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(nullif(1,2))); +hex(concat(nullif(1,2))) +31 +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))); +hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))) +31 +create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +32 +create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))); +hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))) +32 +create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +30 +create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))) +31 +create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))); +hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))) +30 +create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsSimple(GeomFromText('POINT(1 1)')))); +hex(concat(IsSimple(GeomFromText('POINT(1 1)')))) +30 +create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))); +hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))) +30 +create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))); +hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))) +31 +create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1; +drop table t1; +select hex(concat(x(GeomFromText('Point(1 2)')))); +hex(concat(x(GeomFromText('Point(1 2)')))) +31 +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(y(GeomFromText('Point(1 2)')))); +hex(concat(y(GeomFromText('Point(1 2)')))) +32 +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))); +hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))) +31 +create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))) +31 +create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(GeometryType(GeomFromText('Point(1 2)')))); +hex(concat(GeometryType(GeomFromText('Point(1 2)')))) +504F494E54 +create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(AsText(GeomFromText('Point(1 2)')))); +hex(concat(AsText(GeomFromText('Point(1 2)')))) +504F494E542831203229 +create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` longtext +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(period_add(200902, 2))); +hex(concat(period_add(200902, 2))) +323030393034 +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(period_diff(200902, 200802))); +hex(concat(period_diff(200902, 200802))) +3132 +create table t1 as select concat(period_add(200902, 200802)) as c1; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(to_days(20090224))); +hex(concat(to_days(20090224))) +373333383237 +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofmonth(20090224))); +hex(concat(dayofmonth(20090224))) +3234 +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofyear(20090224))); +hex(concat(dayofyear(20090224))) +3535 +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(hour('10:11:12'))); +hex(concat(hour('10:11:12'))) +3130 +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(minute('10:11:12'))); +hex(concat(minute('10:11:12'))) +3131 +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(second('10:11:12'))); +hex(concat(second('10:11:12'))) +3132 +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(quarter(20090224))); +hex(concat(quarter(20090224))) +31 +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(week(20090224))); +hex(concat(week(20090224))) +38 +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(yearweek(20090224))); +hex(concat(yearweek(20090224))) +323030393038 +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(year(20090224))); +hex(concat(year(20090224))) +32303039 +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(weekday(20090224))); +hex(concat(weekday(20090224))) +31 +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofweek(20090224))); +hex(concat(dayofweek(20090224))) +33 +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(unix_timestamp(20090224))); +hex(concat(unix_timestamp(20090224))) +31323335343232383030 +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(time_to_sec('10:11:12'))); +hex(concat(time_to_sec('10:11:12'))) +3336363732 +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(extract(year from 20090702))); +hex(concat(extract(year from 20090702))) +32303039 +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(microsecond('12:00:00.123456'))); +hex(concat(microsecond('12:00:00.123456'))) +313233343536 +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(month(20090224))); +hex(concat(month(20090224))) +32 +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select c1, hex(c1) from t1; +c1 hex(c1) +2003-02-28 323030332D30322D3238 +drop table t1; +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select c1, hex(c1) from t1; +c1 hex(c1) +2000-07-03 323030302D30372D3033 +drop table t1; +create table t1 as select concat(curdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(utc_date()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(curtime()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +c1 hex(c1) +2008-07-18 323030382D30372D3138 +08:42:04 30383A34323A3034 +drop table t1; +create table t1 as select concat(utc_time()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sec_to_time(2378))); +hex(concat(sec_to_time(2378))) +30303A33393A3338 +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))) +32343A30303A3030 +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(maketime(10,11,12))); +hex(concat(maketime(10,11,12))) +31303A31313A3132 +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(get_format(DATE,'USA')); +hex(get_format(DATE,'USA')) +256D2E25642E2559 +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(17) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(from_unixtime(1111885200)),4)); +hex(left(concat(from_unixtime(1111885200)),4)) +32303035 +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))) +323030332D31322D33312032303A30303A3030 +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))) +323030342D30312D30322031323A30303A3030 +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2004-01-02 12:00:00 +drop table t1; +select hex(concat(makedate(2009,1))); +hex(concat(makedate(2009,1))) +323030392D30312D3031 +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2009-01-01 +drop table t1; +create table t1 as select concat(now()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(sysdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(addtime('00:00:00','11:22:33'))); +hex(concat(addtime('00:00:00','11:22:33'))) +31313A32323A3333 +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(subtime('23:59:59','11:22:33'))); +hex(concat(subtime('23:59:59','11:22:33'))) +31323A33373A3236 +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(elt(1,2,3)); +hex(elt(1,2,3)) +32 +create table t1 as select elt(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(export_set(1,2,3,4,2)); +hex(export_set(1,2,3,4,2)) +323433 +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(127) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(insert(1133,3,0,22)); +hex(insert(1133,3,0,22)) +313132323333 +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lcase(123)); +hex(lcase(123)) +313233 +create table t1 as select lcase(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(123,1)); +hex(left(123,1)) +31 +create table t1 as select left(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lower(123)); +hex(lower(123)) +313233 +create table t1 as select lower(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lpad(1,2,0)); +hex(lpad(1,2,0)) +3031 +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(ltrim(1)); +hex(ltrim(1)) +31 +create table t1 as select ltrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(mid(1,1,1)); +hex(mid(1,1,1)) +31 +create table t1 as select mid(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(repeat(1,2)); +hex(repeat(1,2)) +3131 +create table t1 as select repeat(1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(replace(1,1,2)); +hex(replace(1,1,2)) +32 +create table t1 as select replace(1,1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(reverse(12)); +hex(reverse(12)) +3231 +create table t1 as select reverse(12) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(right(123,1)); +hex(right(123,1)) +33 +create table t1 as select right(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(rpad(1,2,0)); +hex(rpad(1,2,0)) +3130 +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(rtrim(1)); +hex(rtrim(1)) +31 +create table t1 as select rtrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(soundex(1)); +hex(soundex(1)) + +create table t1 as select soundex(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(substring(1,1,1)); +hex(substring(1,1,1)) +31 +create table t1 as select substring(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(trim(1)); +hex(trim(1)) +31 +create table t1 as select trim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(ucase(1)); +hex(ucase(1)) +31 +create table t1 as select ucase(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(upper(1)); +hex(upper(1)) +31 +create table t1 as select upper(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(64) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +a hex(a) +1.1 312E31 +2.1 322E31 +update t1 set a= a + 0.1; +select a, hex(a) from t1; +a hex(a) +1.2000000000000002 312E32303030303030303030303030303032 +2.2 322E32 +drop table t1; +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303031 001 +303130 010 +313030 100 +drop table t1; +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303030303030303030303030303030303030303030303030303030303031 000000000000000000000000000001 +303030303030303030303030303030303030303030303030303030303130 000000000000000000000000000010 +303030303030303030303030303030303030303030303030303030313030 000000000000000000000000000100 +drop table t1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E3435 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(6) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303031 00001 +3030303130 00010 +3030313030 00100 +3031303030 01000 +3130303030 10000 +drop table t1; +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(9) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303031 00000001 +3030303030303130 00000010 +3030303030313030 00000100 +3030303031303030 00001000 +3030303130303030 00010000 +drop table t1; +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303031 0000000001 +30303030303030303130 0000000010 +30303030303030313030 0000000100 +30303030303031303030 0000001000 +30303030303130303030 0000010000 +drop table t1; +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +31 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +3030303030303030303030303030303030303031 00000000000000000001 +3030303030303030303030303030303030303130 00000000000000000010 +3030303030303030303030303030303030313030 00000000000000000100 +3030303030303030303030303030303031303030 00000000000000001000 +3030303030303030303030303030303130303030 00000000000000010000 +drop table t1; +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +303030303030303030312E31 0000000001.1 +303030303030303031302E31 0000000010.1 +303030303030303130302E31 0000000100.1 +303030303030313030302E31 0000001000.1 +303030303031303030302E31 0000010000.1 +drop table t1; +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +3132332E343536 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(22) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +30303030303030303030303030303030303030312E31 00000000000000000001.1 +30303030303030303030303030303030303031302E31 00000000000000000010.1 +30303030303030303030303030303030303130302E31 00000000000000000100.1 +30303030303030303030303030303030313030302E31 00000000000000001000.1 +30303030303030303030303030303031303030302E31 00000000000000010000.1 +drop table t1; +create table t1 (a year(2)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +3031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +32303031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a bit(64)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0000000000000001 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +hex(concat(a)) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +select concat(a) from t1; +concat(a) +0000-00-00 00:00:00 +2001-02-03 04:05:06 +1980-02-03 04:05:06 +2001-02-03 04:05:06 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D3033 +323030312D30322D3033 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +hex(concat(a)) +30303A30303A3031 +30313A30323A3033 +select concat(a) from t1; +concat(a) +00:00:01 +01:02:03 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(8) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +hex(concat(a)) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(3) YES NULL +select hex(a) from v1; +hex(a) +303031 +303130 +313030 +drop table t1; +drop view v1; +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(30) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030303030303030303030303030303030303030303031 +303030303030303030303030303030303030303030303030303030303130 +303030303030303030303030303030303030303030303030303030313030 +drop table t1; +drop view v1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E3435 +drop table t1; +drop view v1; +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(6) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(5) YES NULL +select hex(a) from v1; +hex(a) +3030303031 +3030303130 +3030313030 +3031303030 +3130303030 +drop table t1; +drop view v1; +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(9) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(8) YES NULL +select hex(a) from v1; +hex(a) +3030303030303031 +3030303030303130 +3030303030313030 +3030303031303030 +3030303130303030 +drop table t1; +drop view v1; +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(11) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303031 +30303030303030303130 +30303030303030313030 +30303030303031303030 +30303030303130303030 +drop table t1; +drop view v1; +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +31 +drop table t1; +drop view v1; +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +3030303030303030303030303030303030303031 +3030303030303030303030303030303030303130 +3030303030303030303030303030303030313030 +3030303030303030303030303030303031303030 +3030303030303030303030303030303130303030 +drop table t1; +drop view v1; +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +303030303030303030312E31 +303030303030303031302E31 +303030303030303130302E31 +303030303030313030302E31 +303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +concat(a) +123.456 +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +3132332E343536 +drop table t1; +drop view v1; +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +30303030303030303030303030303030303030312E31 +30303030303030303030303030303030303031302E31 +30303030303030303030303030303030303130302E31 +30303030303030303030303030303030313030302E31 +30303030303030303030303030303031303030302E31 +drop table t1; +drop view v1; +create table t1 (a year(2)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(2) YES NULL +select hex(a) from v1; +hex(a) +3031 +drop table t1; +drop view v1; +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +32303031 +drop table t1; +drop view v1; +create table t1 (a bit(64)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(64) YES NULL +select hex(a) from v1; +hex(a) +0000000000000001 +drop table t1; +drop view v1; +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) NO +select hex(a) from v1; +hex(a) +303030302D30302D30302030303A30303A3030 +323030312D30322D30332030343A30353A3036 +313938302D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D3033 +323030312D30322D3033 +drop table t1; +drop view v1; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(8) YES NULL +select hex(a) from v1; +hex(a) +30303A30303A3031 +30313A30323A3033 +drop table t1; +drop view v1; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) YES NULL +select hex(a) from v1; +hex(a) +323030312D30322D30332030343A30353A3036 +323030312D30322D30332030343A30353A3036 +drop table t1; +drop view v1; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +set @a= f1(1); +select hex(@a); +hex(@a) +1 +select hex(concat(f1(1))); +hex(concat(f1(1))) +31 +create table t1 as select f1(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(11) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` decimal(18,2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(20) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` float DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(12) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +hex(@a) +323030312D30312D3032 +select hex(concat(f1(cast('2001-01-02' as date)))); +hex(concat(f1(cast('2001-01-02' as date)))) +323030312D30312D3032 +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(10) YES NULL +drop table t1; +drop view v1; +drop function f1; +# +# End of WL#2649 Number-to-string conversions +# +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index abb21b7cee7..f547c4e8b8c 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -982,12 +982,12 @@ ALTER TABLE t2 ADD a int NOT NULL AFTER status; DROP TABLE t1,t2; select password(name) from bug20536; password(name) -???????????????????? -???????????????????? +*286C12C0F32248BD65B30EE65F3ECFB2AA3F7849 +*947A5674312754578F132655C74A11533B105FF6 select old_password(name) from bug20536; old_password(name) -???????? -???????? +10e155cb44e2adb5 +14e500b131773991 select quote(name) from bug20536; quote(name) ???????? @@ -1231,3 +1231,2586 @@ HEX(DAYNAME(19700101)) 0427043504420432043504400433 SET character_set_connection=latin1; End of 5.0 tests +# +# Start of 5.5 tests +# +SET NAMES latin1; +SET collation_connection=ucs2_general_ci; +# +# Start of WL#2649 Number-to-string conversions +# +select hex(concat(1)); +hex(concat(1)) +0031 +create table t1 as select concat(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +0031 +drop table t1; +select hex(concat(18446744073709551615)); +hex(concat(18446744073709551615)) +00310038003400340036003700340034003000370033003700300039003500350031003600310035 +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +00310038003400340036003700340034003000370033003700300039003500350031003600310035 +drop table t1; +select hex(concat(1.1)); +hex(concat(1.1)) +0031002E0031 +create table t1 as select concat(1.1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1; +hex(c1) +0031002E0031 +drop table t1; +select hex(concat('a', 1+2)), charset(concat(1+2)); +hex(concat('a', 1+2)) charset(concat(1+2)) +00610033 ucs2 +create table t1 as select concat(1+2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1-2)); +hex(concat(1-2)) +002D0031 +create table t1 as select concat(1-2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1*2)); +hex(concat(1*2)) +0032 +create table t1 as select concat(1*2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1/2)); +hex(concat(1/2)) +0030002E0035003000300030 +create table t1 as select concat(1/2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1 div 2)); +hex(concat(1 div 2)) +0030 +create table t1 as select concat(1 div 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1 % 2)); +hex(concat(1 % 2)) +0031 +create table t1 as select concat(1 % 2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(-1)); +hex(concat(-1)) +002D0031 +create table t1 as select concat(-1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(-(1+2))); +hex(concat(-(1+2))) +002D0033 +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1|2)); +hex(concat(1|2)) +0033 +create table t1 as select concat(1|2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(1&2)); +hex(concat(1&2)) +0030 +create table t1 as select concat(1&2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(bit_count(12))); +hex(concat(bit_count(12))) +0032 +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(2<<1)); +hex(concat(2<<1)) +0034 +create table t1 as select concat(2<<1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(2>>1)); +hex(concat(2>>1)) +0031 +create table t1 as select concat(2>>1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(~0)); +hex(concat(~0)) +00310038003400340036003700340034003000370033003700300039003500350031003600310035 +create table t1 as select concat(~0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(3^2)); +hex(concat(3^2)) +0031 +create table t1 as select concat(3^2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(abs(-2))); +hex(concat(abs(-2))) +0032 +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(exp(2)),1)); +hex(left(concat(exp(2)),1)) +0037 +create table t1 as select concat(exp(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log(2)),1)); +hex(left(concat(log(2)),1)) +0030 +create table t1 as select concat(log(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log2(2)),1)); +hex(left(concat(log2(2)),1)) +0031 +create table t1 as select concat(log2(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(log10(2)),1)); +hex(left(concat(log10(2)),1)) +0030 +create table t1 as select concat(log10(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(sqrt(2)),1)); +hex(left(concat(sqrt(2)),1)) +0031 +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(pow(2,2)),1)); +hex(left(concat(pow(2,2)),1)) +0034 +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(acos(0.5)),1)); +hex(left(concat(acos(0.5)),1)) +0031 +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(asin(0.5)),1)); +hex(left(concat(asin(0.5)),1)) +0030 +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(atan(0.5)),1)); +hex(left(concat(atan(0.5)),1)) +0030 +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(cos(0.5)),1)); +hex(left(concat(cos(0.5)),1)) +0030 +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(sin(0.5)),1)); +hex(left(concat(sin(0.5)),1)) +0030 +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(tan(0.5)),1)); +hex(left(concat(tan(0.5)),1)) +0030 +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(degrees(0))); +hex(concat(degrees(0))) +0030 +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(radians(0))); +hex(concat(radians(0))) +0030 +create table t1 as select concat(radians(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ceiling(0.5))); +hex(concat(ceiling(0.5))) +0031 +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(floor(0.5))); +hex(concat(floor(0.5))) +0030 +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(round(0.5))); +hex(concat(round(0.5))) +0031 +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sign(0.5))); +hex(concat(sign(0.5))) +0031 +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(rand()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(length('a'))); +hex(concat(length('a'))) +0032 +create table t1 as select concat(length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(char_length('a'))); +hex(concat(char_length('a'))) +0031 +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(bit_length('a'))); +hex(concat(bit_length('a'))) +00310036 +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(coercibility('a'))); +hex(concat(coercibility('a'))) +0034 +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(locate('a','a'))); +hex(concat(locate('a','a'))) +0031 +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(field('c','a','b','c'))); +hex(concat(field('c','a','b','c'))) +0033 +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ascii(61))); +hex(concat(ascii(61))) +00350034 +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ord(61))); +hex(concat(ord(61))) +00350034 +create table t1 as select concat(ord(61)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(find_in_set('b','a,b,c,d'))); +hex(concat(find_in_set('b','a,b,c,d'))) +0032 +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select md5('a'), hex(md5('a')); +md5('a') hex(md5('a')) +760f753576f2955b0074758acb4d5fa6 00370036003000660037003500330035003700360066003200390035003500620030003000370034003700350038006100630062003400640035006600610036 +create table t1 as select md5('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(32) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select old_password('a'), hex(old_password('a')); +old_password('a') hex(old_password('a')) +0705298948d1f92f 0030003700300035003200390038003900340038006400310066003900320066 +create table t1 as select old_password('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(16) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select password('a'), hex(password('a')); +password('a') hex(password('a')) +*9A48A662559C49521B25C43077059DD109FBD84A 002A0039004100340038004100360036003200350035003900430034003900350032003100420032003500430034003300300037003700300035003900440044003100300039004600420044003800340041 +create table t1 as select password('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(41) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select sha('a'), hex(sha('a')); +sha('a') hex(sha('a')) +3106600e0327ca77371f2526df794ed84322585c 0033003100300036003600300030006500300033003200370063006100370037003300370031006600320035003200360064006600370039003400650064003800340033003200320035003800350063 +create table t1 as select sha('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select sha1('a'), hex(sha1('a')); +sha1('a') hex(sha1('a')) +3106600e0327ca77371f2526df794ed84322585c 0033003100300036003600300030006500300033003200370063006100370037003300370031006600320035003200360064006600370039003400650064003800340033003200320035003800350063 +create table t1 as select sha1('a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(40) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('-1' as signed))); +hex(concat(cast('-1' as signed))) +002D0031 +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('1' as unsigned))); +hex(concat(cast('1' as unsigned))) +0031 +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast(1/2 as decimal(5,5)))); +hex(concat(cast(1/2 as decimal(5,5)))) +0030002E00350030003000300030 +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(7) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as date))); +hex(concat(cast('2001-01-02 03:04:05' as date))) +0032003000300031002D00300031002D00300032 +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2001-01-02 +drop table t1; +select hex(concat(cast('2001-01-02 03:04:05' as time))); +hex(concat(cast('2001-01-02 03:04:05' as time))) +00300033003A00300034003A00300035 +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +03:04:05 +drop table t1; +select hex(concat(cast('2001-01-02' as datetime))); +hex(concat(cast('2001-01-02' as datetime))) +0032003000300031002D00300031002D00300032002000300030003A00300030003A00300030 +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2001-01-02 00:00:00 +drop table t1; +select hex(concat(least(1,2))); +hex(concat(least(1,2))) +0031 +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(greatest(1,2))); +hex(concat(greatest(1,2))) +0032 +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(case when 11 then 22 else 33 end)); +hex(concat(case when 11 then 22 else 33 end)) +00320032 +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(coalesce(1,2))); +hex(concat(coalesce(1,2))) +0031 +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat_ws(1,2,3)); +hex(concat_ws(1,2,3)) +003200310033 +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(group_concat(1,2,3)); +hex(group_concat(1,2,3)) +003100320033 +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(512) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(c1) from t1 order by c1; +hex(c1) +0031 +0061 +drop table t1; +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(benchmark(0,0))); +hex(concat(benchmark(0,0))) +0030 +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sleep(0))); +hex(concat(sleep(0))) +0030 +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(get_lock('a',0))); +hex(concat(get_lock('a',0))) +0031 +select hex(concat(release_lock('a'))); +hex(concat(release_lock('a'))) +0031 +create table t1 as select concat(get_lock('a',0)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(is_free_lock('xxxx'))); +hex(concat(is_free_lock('xxxx'))) +0031 +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(crc32(''))); +hex(concat(crc32(''))) +0030 +create table t1 as select concat(crc32('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(uncompressed_length(''))); +hex(concat(uncompressed_length(''))) +0030 +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(connection_id()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(inet_aton('127.1.1.1'))); +hex(concat(inet_aton('127.1.1.1'))) +0032003100330030003700370032003200320035 +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(inet_ntoa(2130772225))); +hex(concat(inet_ntoa(2130772225))) +003100320037002E0031002E0031002E0031 +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +c1 +127.1.1.1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(31) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(row_count())); +hex(concat(row_count())) +002D0031 +create table t1 as select concat(row_count()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(found_rows())); +hex(concat(found_rows())) +0030 +create table t1 as select concat(found_rows()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(uuid()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +coercibility(uuid()) coercibility(cast('a' as char character set latin1)) +4 2 +select charset(concat(uuid(), cast('a' as char character set latin1))); +charset(concat(uuid(), cast('a' as char character set latin1))) +latin1 +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(37) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=1)); +hex(concat(@a1:=1)) +0031 +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +select hex(c1) from t1; +hex(c1) +0032 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '', + `c2` int(1) NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=1; +select hex(concat(@a2)); +hex(concat(@a2)) +0031 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET ucs2 DEFAULT NULL, + `c2` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=sqrt(1))); +hex(concat(@a1:=sqrt(1))) +0031 +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +select hex(c1) from t1; +hex(c1) +0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=sqrt(1); +select hex(concat(@a2)); +hex(concat(@a2)) +0031 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL, + `c2` double DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@a1:=1.1)); +hex(concat(@a1:=1.1)) +0031002E0031 +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +select hex(c1) from t1; +hex(c1) +0031002E0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT '', + `c2` decimal(2,1) NOT NULL DEFAULT '0.0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +set @a2=1.1; +select hex(concat(@a2)); +hex(concat(@a2)) +0031002E0031 +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +hex(c1) +0031002E0031 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(83) CHARACTER SET ucs2 DEFAULT NULL, + `c2` decimal(65,30) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(@@ft_max_word_len)); +hex(concat(@@ft_max_word_len)) +00380034 +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +hex(c1) +00380034 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a'='a' IS TRUE)); +hex(concat('a'='a' IS TRUE)) +0031 +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a'='a' IS NOT TRUE)); +hex(concat('a'='a' IS NOT TRUE)) +0030 +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NOT 'a'='a')); +hex(concat(NOT 'a'='a')) +0030 +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' IS NULL)); +hex(concat('a' IS NULL)) +0030 +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' IS NOT NULL)); +hex(concat('a' IS NOT NULL)) +0031 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' rlike 'a')); +hex(concat('a' rlike 'a')) +0031 +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(strcmp('a','b'))); +hex(concat(strcmp('a','b'))) +002D0031 +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' like 'a')); +hex(concat('a' like 'a')) +0031 +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' between 'b' and 'c')); +hex(concat('a' between 'b' and 'c')) +0030 +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat('a' in ('a','b'))); +hex(concat('a' in ('a','b'))) +0031 +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +hex(concat(interval(23, 1, 15, 17, 30, 44, 200))) +0033 +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +hex(concat(match (a) against ('a'))) +0030 +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +select hex(ifnull(1,'a')); +hex(ifnull(1,'a')) +0031 +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ifnull(1,1))); +hex(concat(ifnull(1,1))) +0031 +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(ifnull(1.1,1.1))); +hex(concat(ifnull(1.1,1.1))) +0031002E0031 +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(if(1,'b',1)); +hex(if(1,'b',1)) +0062 +create table t1 as select if(1,'b',1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(if(1,1,'b')); +hex(if(1,1,'b')) +0031 +create table t1 as select if(1,1,'b') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(if(1,1,1))); +hex(concat(if(1,1,1))) +0031 +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(nullif(1,2))); +hex(concat(nullif(1,2))) +0031 +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))); +hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))) +0031 +create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +0032 +create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))); +hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))) +0032 +create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))) +0030 +create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))) +0031 +create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))); +hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))) +0030 +create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsSimple(GeomFromText('POINT(1 1)')))); +hex(concat(IsSimple(GeomFromText('POINT(1 1)')))) +0030 +create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))); +hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))) +0030 +create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))); +hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))) +0031 +create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1; +drop table t1; +select hex(concat(x(GeomFromText('Point(1 2)')))); +hex(concat(x(GeomFromText('Point(1 2)')))) +0031 +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(y(GeomFromText('Point(1 2)')))); +hex(concat(y(GeomFromText('Point(1 2)')))) +0032 +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))); +hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))) +0031 +create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))) +0031 +create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(GeometryType(GeomFromText('Point(1 2)')))); +hex(concat(GeometryType(GeomFromText('Point(1 2)')))) +0050004F0049004E0054 +create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(AsText(GeomFromText('Point(1 2)')))); +hex(concat(AsText(GeomFromText('Point(1 2)')))) +0050004F0049004E005400280031002000320029 +create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` longtext CHARACTER SET ucs2 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(period_add(200902, 2))); +hex(concat(period_add(200902, 2))) +003200300030003900300034 +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(period_diff(200902, 200802))); +hex(concat(period_diff(200902, 200802))) +00310032 +create table t1 as select concat(period_add(200902, 200802)) as c1; +Warnings: +Warning 1265 Data truncated for column 'c1' at row 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(to_days(20090224))); +hex(concat(to_days(20090224))) +003700330033003800320037 +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofmonth(20090224))); +hex(concat(dayofmonth(20090224))) +00320034 +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofyear(20090224))); +hex(concat(dayofyear(20090224))) +00350035 +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(hour('10:11:12'))); +hex(concat(hour('10:11:12'))) +00310030 +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(minute('10:11:12'))); +hex(concat(minute('10:11:12'))) +00310031 +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(second('10:11:12'))); +hex(concat(second('10:11:12'))) +00310032 +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(quarter(20090224))); +hex(concat(quarter(20090224))) +0031 +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(week(20090224))); +hex(concat(week(20090224))) +0038 +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(yearweek(20090224))); +hex(concat(yearweek(20090224))) +003200300030003900300038 +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(year(20090224))); +hex(concat(year(20090224))) +0032003000300039 +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(weekday(20090224))); +hex(concat(weekday(20090224))) +0031 +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(dayofweek(20090224))); +hex(concat(dayofweek(20090224))) +0033 +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(unix_timestamp(20090224))); +hex(concat(unix_timestamp(20090224))) +0031003200330035003400320032003800300030 +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(time_to_sec('10:11:12'))); +hex(concat(time_to_sec('10:11:12'))) +00330036003600370032 +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(extract(year from 20090702))); +hex(concat(extract(year from 20090702))) +0032003000300039 +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(microsecond('12:00:00.123456'))); +hex(concat(microsecond('12:00:00.123456'))) +003100320033003400350036 +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(21) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(month(20090224))); +hex(concat(month(20090224))) +0032 +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select c1, hex(c1) from t1; +c1 hex(c1) +2003-02-28 0032003000300033002D00300032002D00320038 +drop table t1; +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select c1, hex(c1) from t1; +c1 hex(c1) +2000-07-03 0032003000300030002D00300037002D00300033 +drop table t1; +create table t1 as select concat(curdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(utc_date()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(curtime()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +c1 hex(c1) +2008-07-18 0032003000300038002D00300037002D00310038 +08:42:04 00300038003A00340032003A00300034 +drop table t1; +create table t1 as select concat(utc_time()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(8) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(sec_to_time(2378))); +hex(concat(sec_to_time(2378))) +00300030003A00330039003A00330038 +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))) +00320034003A00300030003A00300030 +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(maketime(10,11,12))); +hex(concat(maketime(10,11,12))) +00310030003A00310031003A00310032 +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(23) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(get_format(DATE,'USA')); +hex(get_format(DATE,'USA')) +0025006D002E00250064002E00250059 +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(17) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(concat(from_unixtime(1111885200)),4)); +hex(left(concat(from_unixtime(1111885200)),4)) +0032003000300035 +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))) +0032003000300033002D00310032002D00330031002000320030003A00300030003A00300030 +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))) +0032003000300034002D00300031002D00300032002000310032003A00300030003A00300030 +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2004-01-02 12:00:00 +drop table t1; +select hex(concat(makedate(2009,1))); +hex(concat(makedate(2009,1))) +0032003000300039002D00300031002D00300031 +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +c1 +2009-01-01 +drop table t1; +create table t1 as select concat(now()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(sysdate()) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(19) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(addtime('00:00:00','11:22:33'))); +hex(concat(addtime('00:00:00','11:22:33'))) +00310031003A00320032003A00330033 +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(concat(subtime('23:59:59','11:22:33'))); +hex(concat(subtime('23:59:59','11:22:33'))) +00310032003A00330037003A00320036 +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(29) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(elt(1,2,3)); +hex(elt(1,2,3)) +0032 +create table t1 as select elt(1,2,3) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(export_set(1,2,3,4,2)); +hex(export_set(1,2,3,4,2)) +003200340033 +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(127) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(insert(1133,3,0,22)); +hex(insert(1133,3,0,22)) +003100310032003200330033 +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(6) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lcase(123)); +hex(lcase(123)) +003100320033 +create table t1 as select lcase(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(left(123,1)); +hex(left(123,1)) +0031 +create table t1 as select left(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lower(123)); +hex(lower(123)) +003100320033 +create table t1 as select lower(123) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(3) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(lpad(1,2,0)); +hex(lpad(1,2,0)) +00300031 +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(ltrim(1)); +hex(ltrim(1)) +0031 +create table t1 as select ltrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(mid(1,1,1)); +hex(mid(1,1,1)) +0031 +create table t1 as select mid(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(repeat(1,2)); +hex(repeat(1,2)) +00310031 +create table t1 as select repeat(1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(replace(1,1,2)); +hex(replace(1,1,2)) +0032 +create table t1 as select replace(1,1,2) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(reverse(12)); +hex(reverse(12)) +00320031 +create table t1 as select reverse(12) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(right(123,1)); +hex(right(123,1)) +0033 +create table t1 as select right(123,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(rpad(1,2,0)); +hex(rpad(1,2,0)) +00310030 +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(2) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(rtrim(1)); +hex(rtrim(1)) +0031 +create table t1 as select rtrim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(soundex(1)); +hex(soundex(1)) + +create table t1 as select soundex(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(4) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(substring(1,1,1)); +hex(substring(1,1,1)) +0031 +create table t1 as select substring(1,1,1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(trim(1)); +hex(trim(1)) +0031 +create table t1 as select trim(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(ucase(1)); +hex(ucase(1)) +0031 +create table t1 as select ucase(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select hex(upper(1)); +hex(upper(1)) +0031 +create table t1 as select upper(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(1) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(64) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +a hex(a) +1.1 0031002E0031 +2.1 0032002E0031 +update t1 set a= a + 0.1; +select a, hex(a) from t1; +a hex(a) +1.2000000000000002 0031002E0032003000300030003000300030003000300030003000300030003000300032 +2.2 0032002E0032 +drop table t1; +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +003000300031 001 +003000310030 010 +003100300030 100 +drop table t1; +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +hex(concat(a)) a +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300031 000000000000000000000000000001 +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000310030 000000000000000000000000000010 +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003100300030 000000000000000000000000000100 +drop table t1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +hex(concat(a)) +003100320033002E00340035 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(6) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +00300030003000300031 00001 +00300030003000310030 00010 +00300030003100300030 00100 +00300031003000300030 01000 +00310030003000300030 10000 +drop table t1; +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(9) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +00300030003000300030003000300031 00000001 +00300030003000300030003000310030 00000010 +00300030003000300030003100300030 00000100 +00300030003000300031003000300030 00001000 +00300030003000310030003000300030 00010000 +drop table t1; +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(11) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +0030003000300030003000300030003000300031 0000000001 +0030003000300030003000300030003000310030 0000000010 +0030003000300030003000300030003100300030 0000000100 +0030003000300030003000300031003000300030 0000001000 +0030003000300030003000310030003000300030 0000010000 +drop table t1; +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(20) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +hex(concat(a)) a +00300030003000300030003000300030003000300030003000300030003000300030003000300031 00000000000000000001 +00300030003000300030003000300030003000300030003000300030003000300030003000310030 00000000000000000010 +00300030003000300030003000300030003000300030003000300030003000300030003100300030 00000000000000000100 +00300030003000300030003000300030003000300030003000300030003000300031003000300030 00000000000000001000 +00300030003000300030003000300030003000300030003000300030003000310030003000300030 00000000000000010000 +drop table t1; +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +003100320033002E003400350036 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(12) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +0030003000300030003000300030003000300031002E0031 0000000001.1 +0030003000300030003000300030003000310030002E0031 0000000010.1 +0030003000300030003000300030003100300030002E0031 0000000100.1 +0030003000300030003000300031003000300030002E0031 0000001000.1 +0030003000300030003000310030003000300030002E0031 0000010000.1 +drop table t1; +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +hex(concat(a)) +003100320033002E003400350036 +select concat(a) from t1; +concat(a) +123.456 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(22) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +hex(concat(a)) a +00300030003000300030003000300030003000300030003000300030003000300030003000300031002E0031 00000000000000000001.1 +00300030003000300030003000300030003000300030003000300030003000300030003000310030002E0031 00000000000000000010.1 +00300030003000300030003000300030003000300030003000300030003000300030003100300030002E0031 00000000000000000100.1 +00300030003000300030003000300030003000300030003000300030003000300031003000300030002E0031 00000000000000001000.1 +00300030003000300030003000300030003000300030003000300030003000310030003000300030002E0031 00000000000000010000.1 +drop table t1; +create table t1 (a year(2)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +00300031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(2) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0032003000300031 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(4) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a bit(64)); +insert into t1 values (1); +select hex(concat(a)) from t1; +hex(concat(a)) +0000000000000001 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varbinary(64) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +hex(concat(a)) +0030003000300030002D00300030002D00300030002000300030003A00300030003A00300030 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +0031003900380030002D00300032002D00300033002000300034003A00300035003A00300036 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +select concat(a) from t1; +concat(a) +0000-00-00 00:00:00 +2001-02-03 04:05:06 +1980-02-03 04:05:06 +2001-02-03 04:05:06 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) CHARACTER SET ucs2 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +hex(concat(a)) +0032003000300031002D00300032002D00300033 +0032003000300031002D00300032002D00300033 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(10) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +hex(concat(a)) +00300030003A00300030003A00300031 +00300031003A00300032003A00300033 +select concat(a) from t1; +concat(a) +00:00:01 +01:02:03 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(8) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +hex(concat(a)) +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +create table t2 as select concat(a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `concat(a)` varchar(19) CHARACTER SET ucs2 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1, t2; +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(3) YES NULL +select hex(a) from v1; +hex(a) +003000300031 +003000310030 +003100300030 +drop table t1; +drop view v1; +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(30) YES NULL +select hex(a) from v1; +hex(a) +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300031 +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000310030 +003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003100300030 +drop table t1; +drop view v1; +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +003100320033002E00340035 +drop table t1; +drop view v1; +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(6) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(5) YES NULL +select hex(a) from v1; +hex(a) +00300030003000300031 +00300030003000310030 +00300030003100300030 +00300031003000300030 +00310030003000300030 +drop table t1; +drop view v1; +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(9) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(8) YES NULL +select hex(a) from v1; +hex(a) +00300030003000300030003000300031 +00300030003000300030003000310030 +00300030003000300030003100300030 +00300030003000300031003000300030 +00300030003000310030003000300030 +drop table t1; +drop view v1; +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(11) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +0030003000300030003000300030003000300031 +0030003000300030003000300030003000310030 +0030003000300030003000300030003100300030 +0030003000300030003000300031003000300030 +0030003000300030003000310030003000300030 +drop table t1; +drop view v1; +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +0031 +drop table t1; +drop view v1; +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(20) YES NULL +select hex(a) from v1; +hex(a) +00300030003000300030003000300030003000300030003000300030003000300030003000300031 +00300030003000300030003000300030003000300030003000300030003000300030003000310030 +00300030003000300030003000300030003000300030003000300030003000300030003100300030 +00300030003000300030003000300030003000300030003000300030003000300031003000300030 +00300030003000300030003000300030003000300030003000300030003000310030003000300030 +drop table t1; +drop view v1; +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +003100320033002E003400350036 +drop table t1; +drop view v1; +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(12) YES NULL +select hex(a) from v1; +hex(a) +0030003000300030003000300030003000300031002E0031 +0030003000300030003000300030003000310030002E0031 +0030003000300030003000300030003100300030002E0031 +0030003000300030003000300031003000300030002E0031 +0030003000300030003000310030003000300030002E0031 +drop table t1; +drop view v1; +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +concat(a) +123.456 +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +003100320033002E003400350036 +drop table t1; +drop view v1; +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(22) YES NULL +select hex(a) from v1; +hex(a) +00300030003000300030003000300030003000300030003000300030003000300030003000300031002E0031 +00300030003000300030003000300030003000300030003000300030003000300030003000310030002E0031 +00300030003000300030003000300030003000300030003000300030003000300030003100300030002E0031 +00300030003000300030003000300030003000300030003000300030003000300031003000300030002E0031 +00300030003000300030003000300030003000300030003000300030003000310030003000300030002E0031 +drop table t1; +drop view v1; +create table t1 (a year(2)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(2) YES NULL +select hex(a) from v1; +hex(a) +00300031 +drop table t1; +drop view v1; +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(4) YES NULL +select hex(a) from v1; +hex(a) +0032003000300031 +drop table t1; +drop view v1; +create table t1 (a bit(64)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varbinary(64) YES NULL +select hex(a) from v1; +hex(a) +0000000000000001 +drop table t1; +drop view v1; +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) NO +select hex(a) from v1; +hex(a) +0030003000300030002D00300030002D00300030002000300030003A00300030003A00300030 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +0031003900380030002D00300032002D00300033002000300034003A00300035003A00300036 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +drop table t1; +drop view v1; +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(10) YES NULL +select hex(a) from v1; +hex(a) +0032003000300031002D00300032002D00300033 +0032003000300031002D00300032002D00300033 +drop table t1; +drop view v1; +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(8) YES NULL +select hex(a) from v1; +hex(a) +00300030003A00300030003A00300031 +00300031003A00300032003A00300033 +drop table t1; +drop view v1; +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +Field Type Null Key Default Extra +a varchar(19) YES NULL +select hex(a) from v1; +hex(a) +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +0032003000300031002D00300032002D00300033002000300034003A00300035003A00300036 +drop table t1; +drop view v1; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +set @a= f1(1); +select hex(@a); +hex(@a) +1 +select hex(concat(f1(1))); +hex(concat(f1(1))) +31 +create table t1 as select f1(1) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(11) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` decimal(18,2) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(20) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +set @a= f1(123.45); +select hex(@a); +hex(@a) +7B +select hex(concat(f1(123.45))); +hex(concat(f1(123.45))) +3132332E3435 +create table t1 as select f1(123.45) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` float DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(12) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(12) YES NULL +drop table t1; +drop view v1; +drop function f1; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +hex(@a) +323030312D30312D3032 +select hex(concat(f1(cast('2001-01-02' as date)))); +hex(concat(f1(cast('2001-01-02' as date)))) +323030312D30312D3032 +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varchar(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +Field Type Null Key Default Extra +c1 varchar(10) YES NULL +drop table t1; +drop view v1; +drop function f1; +# +# End of WL#2649 Number-to-string conversions +# +SET NAMES latin1; +# +# End of 5.5 tests +# diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index ebec186591d..4ef9cfb9fe6 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -625,7 +625,7 @@ insert into t1 values (1,repeat('a',255)),(2,repeat('b',255)); select f2,group_concat(f1) from t1 group by f2; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t1 t1 f2 f2 253 255 255 Y 0 0 8 -def group_concat(f1) 253 400 1 Y 128 0 63 +def group_concat(f1) 253 400 1 Y 0 0 8 f2 group_concat(f1) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2 @@ -737,7 +737,7 @@ insert into t1 values (1,repeat('a',255)),(2,repeat('b',255)); select f2,group_concat(f1) from t1 group by f2; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def test t1 t1 f2 f2 253 255 255 Y 0 0 8 -def group_concat(f1) 252 1024 1 Y 128 0 63 +def group_concat(f1) 252 1024 1 Y 0 0 8 f2 group_concat(f1) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2 diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 3d43cbbfd76..72cf1473594 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -761,7 +761,7 @@ latin2 latin2_general_ci 2 drop table t1; select charset(null), collation(null), coercibility(null); charset(null) collation(null) coercibility(null) -binary binary 5 +binary binary 6 CREATE TABLE t1 (a int, b int); CREATE TABLE t2 (a int, b int); INSERT INTO t1 VALUES (1,1),(2,2); @@ -777,7 +777,7 @@ a b a b 1 1 NULL NULL 2 2 2 2 select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b) -where coercibility(t2.a) = 2 order by t1.a,t2.a; +where coercibility(t2.a) = 5 order by t1.a,t2.a; a b a b 1 1 NULL NULL 2 2 2 2 @@ -1230,13 +1230,13 @@ create table t1 (i int); insert into t1 values (1000000000),(1); select lpad(i, 7, ' ') as t from t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def t 253 7 7 Y 128 31 63 +def t 253 7 7 Y 0 31 8 t 1000000 1 select rpad(i, 7, ' ') as t from t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def t 253 7 7 Y 128 31 63 +def t 253 7 7 Y 0 31 8 t 1000000 1 diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result index 58dd97ee9f3..5a200bb4783 100644 --- a/mysql-test/r/metadata.result +++ b/mysql-test/r/metadata.result @@ -126,7 +126,7 @@ renamed 1 select * from v3 where renamed=1 group by renamed; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def v3 v3 renamed renamed 8 12 0 Y 32896 0 63 +def v3 v3 renamed renamed 8 11 0 Y 32896 0 63 renamed drop table t1; drop view v1,v2,v3; diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index 4f9444c1542..1eaa2e0d256 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1788,11 +1788,11 @@ t5 CREATE TABLE `t5` ( `const06` varchar(10) NOT NULL DEFAULT '', `param06` longtext, `const07` date DEFAULT NULL, - `param07` longblob, + `param07` longtext, `const08` varchar(19) NOT NULL DEFAULT '', `param08` longtext, `const09` datetime DEFAULT NULL, - `param09` longblob, + `param09` longtext, `const10` int(10) NOT NULL DEFAULT '0', `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, @@ -1818,11 +1818,11 @@ def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63 def test t5 t5 const06 const06 253 10 10 N 1 0 8 def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8 def test t5 t5 const07 const07 10 10 10 Y 128 0 63 -def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63 +def test t5 t5 param07 param07 252 4294967295 10 Y 16 0 8 def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 -def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 +def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8 def test t5 t5 const10 const10 3 10 9 N 32769 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 @@ -1929,10 +1929,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -1976,10 +1976,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2026,10 +2026,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2066,10 +2066,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2114,10 +2114,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2158,10 +2158,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2204,10 +2204,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2242,10 +2242,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 772a7462342..06e232fd9b0 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1771,11 +1771,11 @@ t5 CREATE TABLE `t5` ( `const06` varchar(10) NOT NULL DEFAULT '', `param06` longtext, `const07` date DEFAULT NULL, - `param07` longblob, + `param07` longtext, `const08` varchar(19) NOT NULL DEFAULT '', `param08` longtext, `const09` datetime DEFAULT NULL, - `param09` longblob, + `param09` longtext, `const10` int(10) NOT NULL DEFAULT '0', `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, @@ -1801,11 +1801,11 @@ def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63 def test t5 t5 const06 const06 253 10 10 N 1 0 8 def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8 def test t5 t5 const07 const07 10 10 10 Y 128 0 63 -def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63 +def test t5 t5 param07 param07 252 4294967295 10 Y 16 0 8 def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 -def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 +def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8 def test t5 t5 const10 const10 3 10 9 N 32769 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 @@ -1912,10 +1912,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -1959,10 +1959,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2009,10 +2009,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2049,10 +2049,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2097,10 +2097,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2141,10 +2141,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2187,10 +2187,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2225,10 +2225,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 84bf7a6fa00..1458f7d4514 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1772,11 +1772,11 @@ t5 CREATE TABLE `t5` ( `const06` varchar(10) NOT NULL DEFAULT '', `param06` longtext, `const07` date DEFAULT NULL, - `param07` longblob, + `param07` longtext, `const08` varchar(19) NOT NULL DEFAULT '', `param08` longtext, `const09` datetime DEFAULT NULL, - `param09` longblob, + `param09` longtext, `const10` int(10) NOT NULL DEFAULT '0', `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, @@ -1802,11 +1802,11 @@ def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63 def test t5 t5 const06 const06 253 10 10 N 1 0 8 def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8 def test t5 t5 const07 const07 10 10 10 Y 128 0 63 -def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63 +def test t5 t5 param07 param07 252 4294967295 10 Y 16 0 8 def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 -def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 +def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8 def test t5 t5 const10 const10 3 10 9 N 32769 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 @@ -1913,10 +1913,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -1960,10 +1960,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2010,10 +2010,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2050,10 +2050,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2098,10 +2098,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2142,10 +2142,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2188,10 +2188,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2226,10 +2226,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 61d2822fd5b..ad750cccd52 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1708,11 +1708,11 @@ t5 CREATE TABLE `t5` ( `const06` varchar(10) NOT NULL DEFAULT '', `param06` longtext, `const07` date DEFAULT NULL, - `param07` longblob, + `param07` longtext, `const08` varchar(19) NOT NULL DEFAULT '', `param08` longtext, `const09` datetime DEFAULT NULL, - `param09` longblob, + `param09` longtext, `const10` int(10) NOT NULL DEFAULT '0', `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, @@ -1738,11 +1738,11 @@ def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63 def test t5 t5 const06 const06 253 10 10 N 1 0 8 def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8 def test t5 t5 const07 const07 10 10 10 Y 128 0 63 -def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63 +def test t5 t5 param07 param07 252 4294967295 10 Y 16 0 8 def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 -def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 +def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8 def test t5 t5 const10 const10 3 10 9 N 32769 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 @@ -1849,10 +1849,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -1896,10 +1896,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -1946,10 +1946,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -1986,10 +1986,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2034,10 +2034,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2078,10 +2078,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2124,10 +2124,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2162,10 +2162,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -4730,11 +4730,11 @@ t5 CREATE TABLE `t5` ( `const06` varchar(10) NOT NULL DEFAULT '', `param06` longtext, `const07` date DEFAULT NULL, - `param07` longblob, + `param07` longtext, `const08` varchar(19) NOT NULL DEFAULT '', `param08` longtext, `const09` datetime DEFAULT NULL, - `param09` longblob, + `param09` longtext, `const10` int(10) NOT NULL DEFAULT '0', `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, @@ -4760,11 +4760,11 @@ def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63 def test t5 t5 const06 const06 253 10 10 N 1 0 8 def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8 def test t5 t5 const07 const07 10 10 10 Y 128 0 63 -def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63 +def test t5 t5 param07 param07 252 4294967295 10 Y 16 0 8 def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 -def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 +def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8 def test t5 t5 const10 const10 3 10 9 N 32769 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 @@ -4871,10 +4871,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -4918,10 +4918,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -4968,10 +4968,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -5008,10 +5008,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -5056,10 +5056,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -5100,10 +5100,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -5146,10 +5146,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -5184,10 +5184,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 054fda90c02..b5d16316c92 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -449,11 +449,11 @@ f4 datetime YES NULL create table t5 as select coalesce(f1,f3) as f4 from t1; desc t5; Field Type Null Key Default Extra -f4 varbinary(20) YES NULL +f4 varchar(20) YES NULL create table t6 as select coalesce(f2,f3) as f4 from t1; desc t6; Field Type Null Key Default Extra -f4 varbinary(20) YES NULL +f4 varchar(20) YES NULL create table t7 as select coalesce(makedate(1997,1),f2) as f4 from t1; desc t7; Field Type Null Key Default Extra diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index 5e915fbfa2d..7cacaf7cc92 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -271,7 +271,7 @@ drop table t2; create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1; show full columns from t2; Field Type Collation Null Key Default Extra Privileges Comment -auto bigint(12) unsigned NULL NO PRI 0 # +auto int(6) unsigned NULL NO PRI 0 # t1 int(1) NULL NO 0 # t2 varchar(1) latin1_swedish_ci NO # t3 varchar(256) latin1_swedish_ci NO # diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 71f7547386f..2d0914474a4 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -554,7 +554,7 @@ aa show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` varbinary(2) NOT NULL DEFAULT '' + `a` varchar(2) NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT 12 as a UNION select 12.2 as a; @@ -655,7 +655,7 @@ f show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `f` varbinary(12) DEFAULT NULL + `f` varchar(12) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT y from t2 UNION select da from t2; @@ -666,7 +666,7 @@ y show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `y` varbinary(10) DEFAULT NULL + `y` varchar(10) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT y from t2 UNION select dt from t2; @@ -677,7 +677,7 @@ y show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `y` varbinary(19) DEFAULT NULL + `y` varchar(19) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT da from t2 UNION select dt from t2; @@ -699,7 +699,7 @@ testc show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `dt` varbinary(19) DEFAULT NULL + `dt` varchar(19) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT dt from t2 UNION select sv from t2; @@ -710,7 +710,7 @@ testv show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `dt` varbinary(19) DEFAULT NULL + `dt` varchar(19) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 SELECT sc from t2 UNION select sv from t2; diff --git a/mysql-test/suite/ndb/r/ps_7ndb.result b/mysql-test/suite/ndb/r/ps_7ndb.result index fcb2d641cf0..cab660e391c 100644 --- a/mysql-test/suite/ndb/r/ps_7ndb.result +++ b/mysql-test/suite/ndb/r/ps_7ndb.result @@ -1771,11 +1771,11 @@ t5 CREATE TABLE `t5` ( `const06` varchar(10) NOT NULL DEFAULT '', `param06` longtext, `const07` date DEFAULT NULL, - `param07` longblob, + `param07` longtext, `const08` varchar(19) NOT NULL DEFAULT '', `param08` longtext, `const09` datetime DEFAULT NULL, - `param09` longblob, + `param09` longtext, `const10` int(10) NOT NULL DEFAULT '0', `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, @@ -1801,11 +1801,11 @@ def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63 def test t5 t5 const06 const06 253 10 10 N 1 0 8 def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8 def test t5 t5 const07 const07 10 10 10 Y 128 0 63 -def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63 +def test t5 t5 param07 param07 252 4294967295 10 Y 16 0 8 def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 -def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 +def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8 def test t5 t5 const10 const10 3 10 9 N 32769 0 63 def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 @@ -1912,10 +1912,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -1959,10 +1959,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2009,10 +2009,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2049,10 +2049,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2097,10 +2097,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2141,10 +2141,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 @@ -2187,10 +2187,10 @@ def @arg09 5 23 1 Y 32896 31 63 def @arg10 5 23 1 Y 32896 31 63 def @arg11 246 83 6 Y 32896 30 63 def @arg12 246 83 6 Y 32896 30 63 -def @arg13 251 16777216 10 Y 128 31 63 -def @arg14 251 16777216 19 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 8 Y 128 31 63 +def @arg13 251 16777216 10 Y 0 31 8 +def @arg14 251 16777216 19 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 8 Y 0 31 8 def @arg17 8 20 4 Y 32928 0 63 def @arg18 8 20 1 Y 32896 0 63 def @arg19 8 20 1 Y 32896 0 63 @@ -2225,10 +2225,10 @@ def @arg09 5 23 0 Y 32896 31 63 def @arg10 5 23 0 Y 32896 31 63 def @arg11 246 83 0 Y 32896 30 63 def @arg12 246 83 0 Y 32896 30 63 -def @arg13 251 16777216 0 Y 128 31 63 -def @arg14 251 16777216 0 Y 128 31 63 -def @arg15 251 16777216 19 Y 128 31 63 -def @arg16 251 16777216 0 Y 128 31 63 +def @arg13 251 16777216 0 Y 0 31 8 +def @arg14 251 16777216 0 Y 0 31 8 +def @arg15 251 16777216 19 Y 0 31 8 +def @arg16 251 16777216 0 Y 0 31 8 def @arg17 8 20 0 Y 32928 0 63 def @arg18 8 20 0 Y 32896 0 63 def @arg19 8 20 0 Y 32896 0 63 diff --git a/mysql-test/t/ctype_binary.test b/mysql-test/t/ctype_binary.test new file mode 100644 index 00000000000..8b57854de83 --- /dev/null +++ b/mysql-test/t/ctype_binary.test @@ -0,0 +1,12 @@ + +set names binary; + +--echo # +--echo # Start of 5.5 tests +--echo # + +--source include/ctype_numconv.inc + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test index b6a1cfc3f98..4dfb0be3892 100644 --- a/mysql-test/t/ctype_cp1251.test +++ b/mysql-test/t/ctype_cp1251.test @@ -58,3 +58,13 @@ SHOW CREATE TABLE t1; DROP TABLE t1; # End of 4.1 tests + +--echo # +--echo # Start of 5.5 tests +--echo # + +--source include/ctype_numconv.inc + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index b12436f77ba..1733ee299d1 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -127,3 +127,14 @@ DROP TABLE `abc select hex(cast(_ascii 0x7f as char(1) character set latin1)); --echo End of 5.0 tests + + +--echo # +--echo # Start of 5.5 tests +--echo # + +--source include/ctype_numconv.inc + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 310576b9478..8d4b478e68d 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -733,3 +733,17 @@ SELECT HEX(DAYNAME(19700101)); SET character_set_connection=latin1; --echo End of 5.0 tests + + +--echo # +--echo # Start of 5.5 tests +--echo # + +SET NAMES latin1; +SET collation_connection=ucs2_general_ci; +--source include/ctype_numconv.inc +SET NAMES latin1; + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index a570e70d81d..556a19efce5 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -442,7 +442,7 @@ where collation(t2.a) = _utf8'binary' order by t1.a,t2.a; select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b) where charset(t2.a) = _utf8'binary' order by t1.a,t2.a; select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b) -where coercibility(t2.a) = 2 order by t1.a,t2.a; +where coercibility(t2.a) = 5 order by t1.a,t2.a; DROP TABLE t1, t2; # diff --git a/sql/field.cc b/sql/field.cc index 51bb527fc85..8b48831dc57 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1808,7 +1808,7 @@ bool Field::get_date(MYSQL_TIME *ltime,uint fuzzydate) char buff[40]; String tmp(buff,sizeof(buff),&my_charset_bin),*res; if (!(res=val_str(&tmp)) || - str_to_datetime_with_warn(res->ptr(), res->length(), + str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(), ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) return 1; return 0; @@ -1819,7 +1819,7 @@ bool Field::get_time(MYSQL_TIME *ltime) char buff[40]; String tmp(buff,sizeof(buff),&my_charset_bin),*res; if (!(res=val_str(&tmp)) || - str_to_time_with_warn(res->ptr(), res->length(), ltime)) + str_to_time_with_warn(res->charset(), res->ptr(), res->length(), ltime)) return 1; return 0; } @@ -1836,7 +1836,9 @@ int Field::store_time(MYSQL_TIME *ltime, timestamp_type type_arg) ASSERT_COLUMN_MARKED_FOR_WRITE; char buff[MAX_DATE_STRING_REP_LENGTH]; uint length= (uint) my_TIME_to_str(ltime, buff); - return store(buff, length, &my_charset_bin); + /* Avoid conversion when field character set is ASCII compatible */ + return store(buff, length, (charset()->state & MY_CS_NONASCII) ? + &my_charset_latin1 : charset()); } @@ -2428,7 +2430,7 @@ String *Field_decimal::val_str(String *val_buffer __attribute__((unused)), size_t tmp_length; for (str=ptr ; *str == ' ' ; str++) ; - val_ptr->set_charset(&my_charset_bin); + val_ptr->set_charset(&my_charset_numeric); tmp_length= (size_t) (str-ptr); if (field_length < tmp_length) // Error in data val_ptr->length(0); @@ -2558,7 +2560,7 @@ Field *Field_new_decimal::create_from_item (Item *item) { uint8 dec= item->decimals; uint8 intg= item->decimal_precision() - dec; - uint32 len= item->max_length; + uint32 len= item->max_char_length(); DBUG_ASSERT (item->result_type() == DECIMAL_RESULT); @@ -2850,6 +2852,7 @@ String *Field_new_decimal::val_str(String *val_buffer, uint fixed_precision= zerofill ? precision : 0; my_decimal2string(E_DEC_FATAL_ERROR, val_decimal(&decimal_value), fixed_precision, dec, '0', val_buffer); + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -3121,7 +3124,7 @@ String *Field_tiny::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { ASSERT_COLUMN_MARKED_FOR_READ; - CHARSET_INFO *cs= &my_charset_bin; + CHARSET_INFO *cs= &my_charset_numeric; uint length; uint mlength=max(field_length+1,5*cs->mbmaxlen); val_buffer->alloc(mlength); @@ -3137,6 +3140,7 @@ String *Field_tiny::val_str(String *val_buffer, val_buffer->length(length); if (zerofill) prepend_zeros(val_buffer); + val_buffer->set_charset(cs); return val_buffer; } @@ -3333,7 +3337,7 @@ String *Field_short::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { ASSERT_COLUMN_MARKED_FOR_READ; - CHARSET_INFO *cs= &my_charset_bin; + CHARSET_INFO *cs= &my_charset_numeric; uint length; uint mlength=max(field_length+1,7*cs->mbmaxlen); val_buffer->alloc(mlength); @@ -3354,6 +3358,7 @@ String *Field_short::val_str(String *val_buffer, val_buffer->length(length); if (zerofill) prepend_zeros(val_buffer); + val_buffer->set_charset(cs); return val_buffer; } @@ -3550,7 +3555,7 @@ String *Field_medium::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { ASSERT_COLUMN_MARKED_FOR_READ; - CHARSET_INFO *cs= &my_charset_bin; + CHARSET_INFO *cs= &my_charset_numeric; uint length; uint mlength=max(field_length+1,10*cs->mbmaxlen); val_buffer->alloc(mlength); @@ -3561,6 +3566,7 @@ String *Field_medium::val_str(String *val_buffer, val_buffer->length(length); if (zerofill) prepend_zeros(val_buffer); /* purecov: inspected */ + val_buffer->set_charset(cs); return val_buffer; } @@ -3769,7 +3775,7 @@ String *Field_long::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { ASSERT_COLUMN_MARKED_FOR_READ; - CHARSET_INFO *cs= &my_charset_bin; + CHARSET_INFO *cs= &my_charset_numeric; uint length; uint mlength=max(field_length+1,12*cs->mbmaxlen); val_buffer->alloc(mlength); @@ -3789,6 +3795,7 @@ String *Field_long::val_str(String *val_buffer, val_buffer->length(length); if (zerofill) prepend_zeros(val_buffer); + val_buffer->set_charset(cs); return val_buffer; } @@ -4010,7 +4017,7 @@ longlong Field_longlong::val_int(void) String *Field_longlong::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { - CHARSET_INFO *cs= &my_charset_bin; + CHARSET_INFO *cs= &my_charset_numeric; uint length; uint mlength=max(field_length+1,22*cs->mbmaxlen); val_buffer->alloc(mlength); @@ -4028,6 +4035,7 @@ String *Field_longlong::val_str(String *val_buffer, val_buffer->length(length); if (zerofill) prepend_zeros(val_buffer); + val_buffer->set_charset(cs); return val_buffer; } @@ -4254,6 +4262,7 @@ String *Field_float::val_str(String *val_buffer, val_buffer->length((uint) len); if (zerofill) prepend_zeros(val_buffer); + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -4564,6 +4573,7 @@ String *Field_double::val_str(String *val_buffer, val_buffer->length((uint) len); if (zerofill) prepend_zeros(val_buffer); + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -4698,7 +4708,7 @@ Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg, unireg_check_arg, field_name_arg, cs) { /* For 4.0 MYD and 4.0 InnoDB compatibility */ - flags|= ZEROFILL_FLAG | UNSIGNED_FLAG; + flags|= ZEROFILL_FLAG | UNSIGNED_FLAG | BINARY_FLAG; if (!share->timestamp_field && unireg_check != NONE) { /* This timestamp has auto-update */ @@ -4718,7 +4728,7 @@ Field_timestamp::Field_timestamp(bool maybe_null_arg, NONE, field_name_arg, cs) { /* For 4.0 MYD and 4.0 InnoDB compatibility */ - flags|= ZEROFILL_FLAG | UNSIGNED_FLAG; + flags|= ZEROFILL_FLAG | UNSIGNED_FLAG | BINARY_FLAG; if (unireg_check != TIMESTAMP_DN_FIELD) flags|= ON_UPDATE_NOW_FLAG; } @@ -4770,7 +4780,7 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) THD *thd= table ? table->in_use : current_thd; /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */ - have_smth_to_conv= (str_to_datetime(from, len, &l_time, + have_smth_to_conv= (str_to_datetime(cs, from, len, &l_time, (thd->variables.sql_mode & MODE_NO_ZERO_DATE) | MODE_NO_ZERO_IN_DATE, &error) > @@ -4919,10 +4929,10 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) if (temp == 0L) { /* Zero time is "000000" */ - val_ptr->set(STRING_WITH_LEN("0000-00-00 00:00:00"), &my_charset_bin); + val_ptr->set(STRING_WITH_LEN("0000-00-00 00:00:00"), &my_charset_numeric); return val_ptr; } - val_buffer->set_charset(&my_charset_bin); // Safety + val_buffer->set_charset(&my_charset_numeric); // Safety thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp); @@ -4966,6 +4976,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) *to++= (char) ('0'+(char) (temp2)); *to++= (char) ('0'+(char) (temp)); *to= 0; + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -5076,7 +5087,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) int error= 0; int warning; - if (str_to_time(from, len, <ime, &warning)) + if (str_to_time(cs, from, len, <ime, &warning)) { tmp=0L; error= 2; @@ -5235,6 +5246,7 @@ String *Field_time::val_str(String *val_buffer, ltime.minute= (uint) (tmp/100 % 100); ltime.second= (uint) (tmp % 100); make_time((DATE_TIME_FORMAT*) 0, <ime, val_buffer); + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -5432,6 +5444,7 @@ String *Field_year::val_str(String *val_buffer, val_buffer->length(field_length); char *to=(char*) val_buffer->ptr(); sprintf(to,field_length == 2 ? "%02d" : "%04d",(int) Field_year::val_int()); + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -5459,7 +5472,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) int error; THD *thd= table ? table->in_use : current_thd; - if (str_to_datetime(from, len, &l_time, TIME_FUZZY_DATE | + if (str_to_datetime(cs, from, len, &l_time, TIME_FUZZY_DATE | (thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)), @@ -5606,6 +5619,7 @@ String *Field_date::val_str(String *val_buffer, ltime.month= (int) ((uint32) tmp/100 % 100); ltime.day= (int) ((uint32) tmp % 100); make_date((DATE_TIME_FORMAT *) 0, <ime, val_buffer); + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -5695,7 +5709,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) int error; THD *thd= table ? table->in_use : current_thd; enum enum_mysql_timestamp_type ret; - if ((ret= str_to_datetime(from, len, &l_time, + if ((ret= str_to_datetime(cs, from, len, &l_time, (TIME_FUZZY_DATE | (thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | @@ -5867,6 +5881,7 @@ String *Field_newdate::val_str(String *val_buffer, *pos--= (char) ('0'+part%10); part/=10; *pos--= (char) ('0'+part%10); part/=10; *pos= (char) ('0'+part); + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -5929,7 +5944,7 @@ int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs) enum enum_mysql_timestamp_type func_res; THD *thd= table ? table->in_use : current_thd; - func_res= str_to_datetime(from, len, &time_tmp, + func_res= str_to_datetime(cs, from, len, &time_tmp, (TIME_FUZZY_DATE | (thd->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | @@ -6129,6 +6144,7 @@ String *Field_datetime::val_str(String *val_buffer, *pos--= (char) ('0'+(char) (part3%10)); part3/=10; *pos--= (char) ('0'+(char) (part3%10)); part3/=10; *pos=(char) ('0'+(char) part3); + val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -6370,7 +6386,7 @@ int Field_str::store(double nr) else set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } - return store(buff, length, charset()); + return store(buff, length, &my_charset_numeric); } @@ -6405,7 +6421,7 @@ int Field_string::store(longlong nr, bool unsigned_val) int Field_longstr::store_decimal(const my_decimal *d) { char buff[DECIMAL_MAX_STR_LENGTH+1]; - String str(buff, sizeof(buff), &my_charset_bin); + String str(buff, sizeof(buff), &my_charset_numeric); my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str); return store(str.ptr(), str.length(), str.charset()); } @@ -9565,8 +9581,8 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, case MYSQL_TYPE_TIME: case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_TIMESTAMP: - charset= &my_charset_bin; - flags|= BINCMP_FLAG; + charset= &my_charset_numeric; + flags|= BINARY_FLAG; default: break; } @@ -9682,7 +9698,7 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, case MYSQL_TYPE_TIME: case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_TIMESTAMP: - field_charset= &my_charset_bin; + field_charset= &my_charset_numeric; default: break; } diff --git a/sql/field.h b/sql/field.h index c30bbfae879..08ffdbf5987 100644 --- a/sql/field.h +++ b/sql/field.h @@ -414,11 +414,14 @@ public: virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate); virtual bool get_time(MYSQL_TIME *ltime); virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; } + virtual CHARSET_INFO *charset_for_protocol(void) const + { return binary() ? &my_charset_bin : charset(); } virtual CHARSET_INFO *sort_charset(void) const { return charset(); } virtual bool has_charset(void) const { return FALSE; } virtual void set_charset(CHARSET_INFO *charset_arg) { } virtual enum Derivation derivation(void) const { return DERIVATION_IMPLICIT; } + virtual uint repertoire(void) const { return MY_REPERTOIRE_UNICODE30; } virtual void set_derivation(enum Derivation derivation_arg) { } bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code, int cuted_increment); @@ -600,6 +603,9 @@ public: const char *field_name_arg, uint8 dec_arg, bool zero_arg, bool unsigned_arg); Item_result result_type () const { return REAL_RESULT; } + enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } + uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } + CHARSET_INFO *charset(void) const { return &my_charset_numeric; } void prepend_zeros(String *value); void add_zerofill_and_unsigned(String &res) const; friend class Create_field; @@ -1170,6 +1176,10 @@ public: enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } enum Item_result cmp_type () const { return INT_RESULT; } + enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } + uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } + CHARSET_INFO *charset(void) const { return &my_charset_numeric; } + bool binary() const { return 1; } int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); @@ -1262,14 +1272,18 @@ public: CHARSET_INFO *cs) :Field_str(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, cs) - {} + { flags|= BINARY_FLAG; } Field_date(bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str((uchar*) 0, MAX_DATE_WIDTH, maybe_null_arg ? (uchar*) "": 0,0, - NONE, field_name_arg, cs) {} + NONE, field_name_arg, cs) { flags|= BINARY_FLAG; } enum_field_types type() const { return MYSQL_TYPE_DATE;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } enum Item_result cmp_type () const { return INT_RESULT; } + enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } + uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } + CHARSET_INFO *charset(void) const { return &my_charset_numeric; } + bool binary() const { return 1; } int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); @@ -1306,15 +1320,19 @@ public: CHARSET_INFO *cs) :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, cs) - {} + { flags|= BINARY_FLAG; } Field_newdate(bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str((uchar*) 0,10, maybe_null_arg ? (uchar*) "": 0,0, - NONE, field_name_arg, cs) {} + NONE, field_name_arg, cs) { flags|= BINARY_FLAG; } enum_field_types type() const { return MYSQL_TYPE_DATE;} enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; } enum Item_result cmp_type () const { return INT_RESULT; } + enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } + uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } + CHARSET_INFO *charset(void) const { return &my_charset_numeric; } + bool binary() const { return 1; } int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr, bool unsigned_val); @@ -1342,14 +1360,18 @@ public: CHARSET_INFO *cs) :Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, cs) - {} + { flags|= BINARY_FLAG; } Field_time(bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str((uchar*) 0,8, maybe_null_arg ? (uchar*) "": 0,0, - NONE, field_name_arg, cs) {} + NONE, field_name_arg, cs) { flags|= BINARY_FLAG; } enum_field_types type() const { return MYSQL_TYPE_TIME;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; } enum Item_result cmp_type () const { return INT_RESULT; } + enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } + uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } + CHARSET_INFO *charset(void) const { return &my_charset_numeric; } + bool binary() const { return 1; } int store_time(MYSQL_TIME *ltime, timestamp_type type); int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); @@ -1377,16 +1399,20 @@ public: CHARSET_INFO *cs) :Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, cs) - {} + { flags|= BINARY_FLAG; } Field_datetime(bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str((uchar*) 0, MAX_DATETIME_WIDTH, maybe_null_arg ? (uchar*) "": 0,0, - NONE, field_name_arg, cs) {} + NONE, field_name_arg, cs) { flags|= BINARY_FLAG; } enum_field_types type() const { return MYSQL_TYPE_DATETIME;} #ifdef HAVE_LONG_LONG enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; } #endif enum Item_result cmp_type () const { return INT_RESULT; } + enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } + uint repertoire(void) const { return MY_REPERTOIRE_NUMERIC; } + CHARSET_INFO *charset(void) const { return &my_charset_numeric; } + bool binary() const { return 1; } uint decimals() const { return DATETIME_DEC; } int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); diff --git a/sql/item.cc b/sql/item.cc index e785f0addde..f7643db57cd 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -201,6 +201,37 @@ bool Item::val_bool() } +/* + For the items which don't have its own fast val_str_ascii() + implementation we provide a generic slower version, + which converts from the Item character set to ASCII. + For better performance conversion happens only in + case of a "tricky" Item character set (e.g. UCS2). + Normally conversion does not happen. +*/ +String *Item::val_str_ascii(String *str) +{ + DBUG_ASSERT(fixed == 1); + + if (!(collation.collation->state & MY_CS_NONASCII)) + return val_str(str); + + DBUG_ASSERT(str != &str_value); + + uint errors; + String *res= val_str(&str_value); + if (!res) + return 0; + + if ((null_value= str->copy(res->ptr(), res->length(), + collation.collation, &my_charset_latin1, + &errors))) + return 0; + + return str; +} + + String *Item::val_string_from_real(String *str) { double nr= val_real(); @@ -443,10 +474,11 @@ uint Item::decimal_precision() const if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT)) { uint prec= - my_decimal_length_to_precision(max_length, decimals, unsigned_flag); + my_decimal_length_to_precision(max_char_length(), decimals, + unsigned_flag); return min(prec, DECIMAL_MAX_PRECISION); } - return min(max_length, DECIMAL_MAX_PRECISION); + return min(max_char_length(), DECIMAL_MAX_PRECISION); } @@ -783,15 +815,40 @@ Item *Item::safe_charset_converter(CHARSET_INFO *tocs) */ Item *Item_num::safe_charset_converter(CHARSET_INFO *tocs) { + /* + Item_num returns pure ASCII result, + so conversion is needed only in case of "tricky" character + sets like UCS2. If tocs is not "tricky", return the item itself. + */ + if (!(tocs->state & MY_CS_NONASCII)) + return this; + Item_string *conv; - char buf[64]; - String *s, tmp(buf, sizeof(buf), &my_charset_bin); - s= val_str(&tmp); - if ((conv= new Item_string(s->ptr(), s->length(), s->charset()))) + uint conv_errors; + char buf[64], buf2[64]; + String tmp(buf, sizeof(buf), &my_charset_bin); + String cstr(buf2, sizeof(buf2), &my_charset_bin); + String *ostr= val_str(&tmp); + char *ptr; + cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors); + if (conv_errors || !(conv= new Item_string(cstr.ptr(), cstr.length(), + cstr.charset(), + collation.derivation))) { - conv->str_value.copy(); - conv->str_value.mark_as_const(); + /* + Safe conversion is not possible (or EOM). + We could not convert a string into the requested character set + without data loss. The target charset does not cover all the + characters from the string. Operation cannot be done correctly. + */ + return NULL; } + if (!(ptr= current_thd->strmake(cstr.ptr(), cstr.length()))) + return NULL; + conv->str_value.set(ptr, cstr.length(), cstr.charset()); + /* Ensure that no one is going to change the result string */ + conv->str_value.mark_as_const(); + conv->fix_char_length(max_char_length()); return conv; } @@ -910,7 +967,7 @@ bool Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) char buff[40]; String tmp(buff,sizeof(buff), &my_charset_bin),*res; if (!(res=val_str(&tmp)) || - str_to_datetime_with_warn(res->ptr(), res->length(), + str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(), ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR) goto err; } @@ -945,8 +1002,8 @@ bool Item::get_time(MYSQL_TIME *ltime) { char buff[40]; String tmp(buff,sizeof(buff),&my_charset_bin),*res; - if (!(res=val_str(&tmp)) || - str_to_time_with_warn(res->ptr(), res->length(), ltime)) + if (!(res=val_str_ascii(&tmp)) || + str_to_time_with_warn(res->charset(), res->ptr(), res->length(), ltime)) { bzero((char*) ltime,sizeof(*ltime)); return 1; @@ -1650,6 +1707,11 @@ bool agg_item_collations(DTCollation &c, const char *fname, my_coll_agg_error(av, count, fname, item_sep); return TRUE; } + + /* If all arguments where numbers, reset to @@collation_connection */ + if (c.derivation == DERIVATION_NUMERIC) + c.set(Item::default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_NUMERIC); + return FALSE; } @@ -1895,13 +1957,14 @@ void Item_field::set_field(Field *field_par) field=result_field=field_par; // for easy coding with fields maybe_null=field->maybe_null(); decimals= field->decimals(); - max_length= field_par->max_display_length(); table_name= *field_par->table_name; field_name= field_par->field_name; db_name= field_par->table->s->db.str; alias_name_used= field_par->table->alias_name_used; unsigned_flag=test(field_par->flags & UNSIGNED_FLAG); - collation.set(field_par->charset(), field_par->derivation()); + collation.set(field_par->charset(), field_par->derivation(), + field_par->repertoire()); + fix_char_length(field_par->char_length()); fixed= 1; if (field->table->s->tmp_table == SYSTEM_TMP_TABLE) any_privileges= 0; @@ -2210,7 +2273,7 @@ String *Item_int::val_str(String *str) { // following assert is redundant, because fixed=1 assigned in constructor DBUG_ASSERT(fixed == 1); - str->set(value, &my_charset_bin); + str->set(value, collation.collation); return str; } @@ -2240,7 +2303,7 @@ String *Item_uint::val_str(String *str) { // following assert is redundant, because fixed=1 assigned in constructor DBUG_ASSERT(fixed == 1); - str->set((ulonglong) value, &my_charset_bin); + str->set((ulonglong) value, collation.collation); return str; } @@ -2340,7 +2403,7 @@ double Item_decimal::val_real() String *Item_decimal::val_str(String *result) { - result->set_charset(&my_charset_bin); + result->set_charset(&my_charset_numeric); my_decimal2string(E_DEC_FATAL_ERROR, &decimal_value, 0, 0, 0, result); return result; } @@ -4866,7 +4929,7 @@ void Item::init_make_field(Send_field *tmp_field, tmp_field->col_name= name; tmp_field->charsetnr= collation.collation->number; tmp_field->flags= (maybe_null ? 0 : NOT_NULL_FLAG) | - (my_binary_compare(collation.collation) ? + (my_binary_compare(charset_for_protocol()) ? BINARY_FLAG : 0); tmp_field->type= field_type_arg; tmp_field->length=max_length; diff --git a/sql/item.h b/sql/item.h index b7e6cc6c204..0bfb2673121 100644 --- a/sql/item.h +++ b/sql/item.h @@ -44,9 +44,10 @@ class Item_field; #define MY_COLL_ALLOW_SUPERSET_CONV 1 #define MY_COLL_ALLOW_COERCIBLE_CONV 2 -#define MY_COLL_ALLOW_CONV 3 #define MY_COLL_DISALLOW_NONE 4 -#define MY_COLL_CMP_CONV 7 + +#define MY_COLL_ALLOW_CONV (MY_COLL_ALLOW_SUPERSET_CONV | MY_COLL_ALLOW_COERCIBLE_CONV) +#define MY_COLL_CMP_CONV (MY_COLL_ALLOW_CONV | MY_COLL_DISALLOW_NONE) class DTCollation { public: @@ -91,6 +92,12 @@ public: derivation= derivation_arg; repertoire= repertoire_arg; } + void set_numeric() + { + collation= &my_charset_numeric; + derivation= DERIVATION_NUMERIC; + repertoire= MY_REPERTOIRE_NUMERIC; + } void set(CHARSET_INFO *collation_arg) { collation= collation_arg; @@ -105,6 +112,7 @@ public: { switch(derivation) { + case DERIVATION_NUMERIC: return "NUMERIC"; case DERIVATION_IGNORABLE: return "IGNORABLE"; case DERIVATION_COERCIBLE: return "COERCIBLE"; case DERIVATION_IMPLICIT: return "IMPLICIT"; @@ -690,6 +698,77 @@ public: If value is not null null_value flag will be reset to FALSE. */ virtual String *val_str(String *str)=0; + + /* + Returns string representation of this item in ASCII format. + + SYNOPSIS + val_str_ascii() + str - similar to val_str(); + + NOTE + This method is introduced for performance optimization purposes. + + 1. val_str() result of some Items in string context + depends on @@character_set_results. + @@character_set_results can be set to a "real multibyte" character + set like UCS2, UTF16, UTF32. (We'll use only UTF32 in the examples + below for convenience.) + + So the default string result of such functions + in these circumstances is real multi-byte character set, like UTF32. + + For example, all numbers in string context + return result in @@character_set_results: + + SELECT CONCAT(20010101); -> UTF32 + + We do sprintf() first (to get ASCII representation) + and then convert to UTF32; + + So these kind "data sources" can use ASCII representation + internally, but return multi-byte data only because + @@character_set_results wants so. + Therefore, conversion from ASCII to UTF32 is applied internally. + + + 2. Some other functions need in fact ASCII input. + + For example, + inet_aton(), GeometryFromText(), Convert_TZ(), GET_FORMAT(). + + Similar, fields of certain type, like DATE, TIME, + when you insert string data into them, expect in fact ASCII input. + If they get non-ASCII input, for example UTF32, they + convert input from UTF32 to ASCII, and then use ASCII + representation to do further processing. + + + 3. Now imagine we pass result of a data source of the first type + to a data destination of the second type. + + What happens: + a. data source converts data from ASCII to UTF32, because + @@character_set_results wants so and passes the result to + data destination. + b. data destination gets UTF32 string. + c. data destination converts UTF32 string to ASCII, + because it needs ASCII representation to be able to handle data + correctly. + + As a result we get two steps of unnecessary conversion: + From ASCII to UTF32, then from UTF32 to ASCII. + + A better way to handle these situations is to pass ASCII + representation directly from the source to the destination. + + This is why val_str_ascii() introduced. + + RETURN + Similar to val_str() + */ + virtual String *val_str_ascii(String *str); + /* Return decimal representation of item with fixed point. @@ -864,6 +943,16 @@ public: static CHARSET_INFO *default_charset(); virtual CHARSET_INFO *compare_collation() { return NULL; } + /* + For backward compatibility, to make numeric + data types return "binary" charset in client-side metadata. + */ + virtual CHARSET_INFO *charset_for_protocol(void) const + { + return result_type() == STRING_RESULT ? collation.collation : + &my_charset_bin; + }; + virtual bool walk(Item_processor processor, bool walk_subquery, uchar *arg) { return (this->*processor)(arg); @@ -1069,6 +1158,20 @@ public: { return Field::GEOM_GEOMETRY; }; String *check_well_formed_result(String *str, bool send_error= 0); bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs); + uint32 max_char_length() const + { return max_length / collation.collation->mbmaxlen; } + void fix_length_and_charset(uint32 max_char_length_arg, CHARSET_INFO *cs) + { + max_length= max_char_length_arg * cs->mbmaxlen; + collation.collation= cs; + } + void fix_char_length(uint32 max_char_length_arg) + { max_length= max_char_length_arg * collation.collation->mbmaxlen; } + void fix_length_and_charset_datetime(uint32 max_char_length_arg) + { + collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII); + fix_char_length(max_char_length_arg); + } }; @@ -1371,12 +1474,30 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname, Item **args, uint nargs, uint flags, int item_sep); bool agg_item_charsets(DTCollation &c, const char *name, Item **items, uint nitems, uint flags, int item_sep); - +inline bool +agg_item_charsets_for_string_result(DTCollation &c, const char *name, + Item **items, uint nitems, + int item_sep= 1) +{ + uint flags= MY_COLL_ALLOW_SUPERSET_CONV | + MY_COLL_ALLOW_COERCIBLE_CONV; + return agg_item_charsets(c, name, items, nitems, flags, item_sep); +} +inline bool +agg_item_charsets_for_comparison(DTCollation &c, const char *name, + Item **items, uint nitems, + int item_sep= 1) +{ + uint flags= MY_COLL_ALLOW_SUPERSET_CONV | + MY_COLL_ALLOW_COERCIBLE_CONV | + MY_COLL_DISALLOW_NONE; + return agg_item_charsets(c, name, items, nitems, flags, item_sep); +} class Item_num: public Item_basic_constant { public: - Item_num() {} /* Remove gcc warning */ + Item_num() { collation.set_numeric(); } /* Remove gcc warning */ virtual Item_num *neg()= 0; Item *safe_charset_converter(CHARSET_INFO *tocs); bool check_partition_func_processor(uchar *int_arg) { return FALSE;} @@ -1561,6 +1682,8 @@ public: DBUG_ASSERT(field_type() == MYSQL_TYPE_GEOMETRY); return field->get_geometry_type(); } + CHARSET_INFO *charset_for_protocol(void) const + { return field->charset_for_protocol(); } friend class Item_default_value; friend class Item_insert_value; friend class st_select_lex_unit; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 1da383ce3e9..db4a55bbcd0 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -483,7 +483,7 @@ void Item_bool_func2::fix_length_and_dec() DTCollation coll; if (args[0]->result_type() == STRING_RESULT && args[1]->result_type() == STRING_RESULT && - agg_arg_charsets(coll, args, 2, MY_COLL_CMP_CONV, 1)) + agg_arg_charsets_for_comparison(coll, args, 2)) return; args[0]->cmp_context= args[1]->cmp_context= @@ -934,6 +934,7 @@ int Arg_comparator::set_cmp_func(Item_result_field *owner_arg, func= &Arg_comparator::compare_datetime; get_value_a_func= &get_datetime_value; get_value_b_func= &get_datetime_value; + cmp_collation.set(&my_charset_numeric); return 0; } else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME && @@ -2173,7 +2174,7 @@ void Item_func_between::fix_length_and_dec() if ( agg_cmp_type(&cmp_type, args, 3)) return; if (cmp_type == STRING_RESULT && - agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV, 1)) + agg_arg_charsets_for_comparison(cmp_collation, args, 3)) return; /* @@ -2374,7 +2375,7 @@ Item_func_ifnull::fix_length_and_dec() switch (hybrid_type) { case STRING_RESULT: - agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1); + agg_arg_charsets_for_comparison(collation, args, arg_count); break; case DECIMAL_RESULT: case REAL_RESULT: @@ -2549,12 +2550,12 @@ Item_func_if::fix_length_and_dec() agg_result_type(&cached_result_type, args+1, 2); if (cached_result_type == STRING_RESULT) { - if (agg_arg_charsets(collation, args+1, 2, MY_COLL_ALLOW_CONV, 1)) + if (agg_arg_charsets_for_string_result(collation, args + 1, 2)) return; } else { - collation.set(&my_charset_bin); // Number + collation.set_numeric(); // Number } cached_field_type= agg_field_type(args + 1, 2); } @@ -2640,7 +2641,7 @@ Item_func_nullif::fix_length_and_dec() unsigned_flag= args[0]->unsigned_flag; cached_result_type= args[0]->result_type(); if (cached_result_type == STRING_RESULT && - agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1)) + agg_arg_charsets_for_comparison(collation, args, arg_count)) return; } } @@ -2917,9 +2918,13 @@ void Item_func_case::fix_length_and_dec() agg[nagg++]= args[else_expr_num]; agg_result_type(&cached_result_type, agg, nagg); - if ((cached_result_type == STRING_RESULT) && - agg_arg_charsets(collation, agg, nagg, MY_COLL_ALLOW_CONV, 1)) - return; + if (cached_result_type == STRING_RESULT) + { + if (agg_arg_charsets_for_string_result(collation, agg, nagg)) + return; + } + else + collation.set_numeric(); cached_field_type= agg_field_type(agg, nagg); /* @@ -2944,7 +2949,7 @@ void Item_func_case::fix_length_and_dec() { DBUG_ASSERT((Item_result)i != ROW_RESULT); if ((Item_result)i == STRING_RESULT && - agg_arg_charsets(cmp_collation, agg, nagg, MY_COLL_CMP_CONV, 1)) + agg_arg_charsets_for_comparison(cmp_collation, agg, nagg)) return; if (!(cmp_items[i]= cmp_item::get_comparator((Item_result)i, @@ -3107,7 +3112,7 @@ void Item_func_coalesce::fix_length_and_dec() case STRING_RESULT: count_only_length(); decimals= NOT_FIXED_DEC; - agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV, 1); + agg_arg_charsets_for_string_result(collation, args, arg_count); break; case DECIMAL_RESULT: count_decimal_length(); @@ -3752,7 +3757,7 @@ void Item_func_in::fix_length_and_dec() if (type_cnt == 1) { if (cmp_type == STRING_RESULT && - agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV, 1)) + agg_arg_charsets_for_comparison(cmp_collation, args, arg_count)) return; arg_types_compatible= TRUE; } @@ -3930,8 +3935,7 @@ void Item_func_in::fix_length_and_dec() if (found_types & (1 << i) && !cmp_items[i]) { if ((Item_result)i == STRING_RESULT && - agg_arg_charsets(cmp_collation, args, arg_count, - MY_COLL_CMP_CONV, 1)) + agg_arg_charsets_for_comparison(cmp_collation, args, arg_count)) return; if (!cmp_items[i] && !(cmp_items[i]= cmp_item::get_comparator((Item_result)i, @@ -4762,7 +4766,7 @@ Item_func_regex::fix_fields(THD *thd, Item **ref) max_length= 1; decimals= 0; - if (agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1)) + if (agg_arg_charsets_for_comparison(cmp_collation, args, 2)) return TRUE; regex_lib_flags= (cmp_collation.collation->state & diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index ef4eef3276c..b9a3860acb6 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -637,6 +637,11 @@ public: { Item_func::print(str, query_type); } + void fix_length_and_dec() + { + Item_bool_func2::fix_length_and_dec(); + fix_char_length(2); // returns "1" or "0" or "-1" + } }; diff --git a/sql/item_func.cc b/sql/item_func.cc index 75f8b2045b5..0a572a8f3e3 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -440,13 +440,15 @@ Field *Item_func::tmp_table_field(TABLE *table) switch (result_type()) { case INT_RESULT: - if (max_length > MY_INT32_NUM_DECIMAL_DIGITS) - field= new Field_longlong(max_length, maybe_null, name, unsigned_flag); + if (max_char_length() > MY_INT32_NUM_DECIMAL_DIGITS) + field= new Field_longlong(max_char_length(), maybe_null, name, + unsigned_flag); else - field= new Field_long(max_length, maybe_null, name, unsigned_flag); + field= new Field_long(max_char_length(), maybe_null, name, + unsigned_flag); break; case REAL_RESULT: - field= new Field_double(max_length, maybe_null, name, decimals); + field= new Field_double(max_char_length(), maybe_null, name, decimals); break; case STRING_RESULT: return make_string_field(table); @@ -487,7 +489,7 @@ String *Item_real_func::val_str(String *str) double nr= val_real(); if (null_value) return 0; /* purecov: inspected */ - str->set_real(nr,decimals, &my_charset_bin); + str->set_real(nr, decimals, collation.collation); return str; } @@ -626,7 +628,7 @@ String *Item_int_func::val_str(String *str) longlong nr=val_int(); if (null_value) return 0; - str->set_int(nr, unsigned_flag, &my_charset_bin); + str->set_int(nr, unsigned_flag, collation.collation); return str; } @@ -746,6 +748,7 @@ String *Item_func_numhybrid::val_str(String *str) if (!(val= decimal_op(&decimal_value))) return 0; // null is set my_decimal_round(E_DEC_FATAL_ERROR, val, decimals, FALSE, val); + str->set_charset(collation.collation); my_decimal2string(E_DEC_FATAL_ERROR, val, 0, 0, 0, str); break; } @@ -754,7 +757,7 @@ String *Item_func_numhybrid::val_str(String *str) longlong nr= int_op(); if (null_value) return 0; /* purecov: inspected */ - str->set_int(nr, unsigned_flag, &my_charset_bin); + str->set_int(nr, unsigned_flag, collation.collation); break; } case REAL_RESULT: @@ -762,7 +765,7 @@ String *Item_func_numhybrid::val_str(String *str) double nr= real_op(); if (null_value) return 0; /* purecov: inspected */ - str->set_real(nr,decimals,&my_charset_bin); + str->set_real(nr, decimals, collation.collation); break; } case STRING_RESULT: @@ -897,6 +900,7 @@ longlong Item_func_signed::val_int_from_str(int *error) uint32 length; String tmp(buff,sizeof(buff), &my_charset_bin), *res; longlong value; + CHARSET_INFO *cs; /* For a string result, we must first get the string and then convert it @@ -912,9 +916,10 @@ longlong Item_func_signed::val_int_from_str(int *error) null_value= 0; start= (char *)res->ptr(); length= res->length(); + cs= res->charset(); end= start + length; - value= my_strtoll10(start, &end, error); + value= cs->cset->strtoll10(cs, start, &end, error); if (*error > 0 || end != start+ length) { char err_buff[128]; @@ -2265,7 +2270,7 @@ void Item_func_min_max::fix_length_and_dec() } if (cmp_type == STRING_RESULT) { - agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1); + agg_arg_charsets_for_comparison(collation, args, arg_count); if (datetime_found) { thd= current_thd; @@ -2273,9 +2278,13 @@ void Item_func_min_max::fix_length_and_dec() } } else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT)) - max_length= my_decimal_precision_to_length_no_truncation(max_int_part + - decimals, decimals, - unsigned_flag); + { + collation.set_numeric(); + fix_char_length(my_decimal_precision_to_length_no_truncation(max_int_part + + decimals, + decimals, + unsigned_flag)); + } cached_field_type= agg_field_type(args, arg_count); } @@ -2345,7 +2354,7 @@ String *Item_func_min_max::val_str(String *str) longlong nr=val_int(); if (null_value) return 0; - str->set_int(nr, unsigned_flag, &my_charset_bin); + str->set_int(nr, unsigned_flag, collation.collation); return str; } case DECIMAL_RESULT: @@ -2361,7 +2370,7 @@ String *Item_func_min_max::val_str(String *str) double nr= val_real(); if (null_value) return 0; /* purecov: inspected */ - str->set_real(nr,decimals,&my_charset_bin); + str->set_real(nr, decimals, collation.collation); return str; } case STRING_RESULT: @@ -2532,7 +2541,7 @@ longlong Item_func_coercibility::val_int() void Item_func_locate::fix_length_and_dec() { max_length= MY_INT32_NUM_DECIMAL_DIGITS; - agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1); + agg_arg_charsets_for_comparison(cmp_collation, args, 2); } @@ -2656,7 +2665,7 @@ void Item_func_field::fix_length_and_dec() for (uint i=1; i < arg_count ; i++) cmp_type= item_cmp_type(cmp_type, args[i]->result_type()); if (cmp_type == STRING_RESULT) - agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV, 1); + agg_arg_charsets_for_comparison(cmp_collation, args, arg_count); } @@ -2723,7 +2732,7 @@ void Item_func_find_in_set::fix_length_and_dec() } } } - agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1); + agg_arg_charsets_for_comparison(cmp_collation, args, 2); } static const char separator=','; @@ -3964,7 +3973,9 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref) */ null_item= (args[0]->type() == NULL_ITEM); if (!entry->collation.collation || !null_item) - entry->collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT); + entry->collation.set(args[0]->collation.derivation == DERIVATION_NUMERIC ? + default_charset() : args[0]->collation.collation, + DERIVATION_IMPLICIT); collation.set(entry->collation.collation, DERIVATION_IMPLICIT); cached_result_type= args[0]->result_type(); return FALSE; @@ -3975,9 +3986,15 @@ void Item_func_set_user_var::fix_length_and_dec() { maybe_null=args[0]->maybe_null; - max_length=args[0]->max_length; decimals=args[0]->decimals; - collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT); + collation.set(DERIVATION_IMPLICIT); + if (args[0]->collation.derivation == DERIVATION_NUMERIC) + fix_length_and_charset(args[0]->max_char_length(), default_charset()); + else + { + fix_length_and_charset(args[0]->max_char_length(), + args[0]->collation.collation); + } } @@ -4172,16 +4189,16 @@ String *user_var_entry::val_str(my_bool *null_value, String *str, switch (type) { case REAL_RESULT: - str->set_real(*(double*) value, decimals, &my_charset_bin); + str->set_real(*(double*) value, decimals, collation.collation); break; case INT_RESULT: if (!unsigned_flag) - str->set(*(longlong*) value, &my_charset_bin); + str->set(*(longlong*) value, collation.collation); else - str->set(*(ulonglong*) value, &my_charset_bin); + str->set(*(ulonglong*) value, collation.collation); break; case DECIMAL_RESULT: - my_decimal2string(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, 0, 0, str); + str_set_decimal((my_decimal *) value, str, collation.collation); break; case STRING_RESULT: if (str->copy(value, length, collation.collation)) @@ -4339,13 +4356,13 @@ Item_func_set_user_var::update() case REAL_RESULT: { res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal), - REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 0); + REAL_RESULT, default_charset(), DERIVATION_IMPLICIT, 0); break; } case INT_RESULT: { res= update_hash((void*) &save_result.vint, sizeof(save_result.vint), - INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, + INT_RESULT, default_charset(), DERIVATION_IMPLICIT, unsigned_flag); break; } @@ -4369,7 +4386,7 @@ Item_func_set_user_var::update() else res= update_hash((void*) save_result.vdec, sizeof(my_decimal), DECIMAL_RESULT, - &my_charset_bin, DERIVATION_IMPLICIT, 0); + default_charset(), DERIVATION_IMPLICIT, 0); break; } case ROW_RESULT: @@ -4802,17 +4819,17 @@ void Item_func_get_user_var::fix_length_and_dec() collation.set(var_entry->collation); switch(m_cached_result_type) { case REAL_RESULT: - max_length= DBL_DIG + 8; + fix_char_length(DBL_DIG + 8); break; case INT_RESULT: - max_length= MAX_BIGINT_WIDTH; + fix_char_length(MAX_BIGINT_WIDTH); decimals=0; break; case STRING_RESULT: max_length= MAX_BLOB_WIDTH; break; case DECIMAL_RESULT: - max_length= DECIMAL_MAX_STR_LENGTH; + fix_char_length(DECIMAL_MAX_STR_LENGTH); decimals= DECIMAL_MAX_SCALE; break; case ROW_RESULT: // Keep compiler happy @@ -4998,12 +5015,14 @@ void Item_func_get_system_var::fix_length_and_dec() case SHOW_INT: case SHOW_HA_ROWS: unsigned_flag= TRUE; - max_length= MY_INT64_NUM_DECIMAL_DIGITS; + collation.set_numeric(); + fix_char_length(MY_INT64_NUM_DECIMAL_DIGITS); decimals=0; break; case SHOW_LONGLONG: unsigned_flag= TRUE; - max_length= MY_INT64_NUM_DECIMAL_DIGITS; + collation.set_numeric(); + fix_char_length(MY_INT64_NUM_DECIMAL_DIGITS); decimals=0; break; case SHOW_CHAR: @@ -5037,13 +5056,15 @@ void Item_func_get_system_var::fix_length_and_dec() case SHOW_BOOL: case SHOW_MY_BOOL: unsigned_flag= FALSE; - max_length= 1; + collation.set_numeric(); + fix_char_length(1); decimals=0; break; case SHOW_DOUBLE: unsigned_flag= FALSE; decimals= 6; - max_length= DBL_DIG + 6; + collation.set_numeric(); + fix_char_length(DBL_DIG + 6); break; default: my_error(ER_VAR_CANT_BE_READ, MYF(0), var->name.str); @@ -5405,8 +5426,8 @@ longlong Item_func_inet_aton::val_int() char buff[36]; int dot_count= 0; - String *s,tmp(buff,sizeof(buff),&my_charset_bin); - if (!(s = args[0]->val_str(&tmp))) // If null value + String *s, tmp(buff, sizeof(buff), &my_charset_latin1); + if (!(s = args[0]->val_str_ascii(&tmp))) // If null value goto err; null_value=0; @@ -5414,7 +5435,7 @@ longlong Item_func_inet_aton::val_int() while (p < end) { c = *p++; - int digit = (int) (c - '0'); // Assume ascii + int digit = (int) (c - '0'); if (digit >= 0 && digit <= 9) { if ((byte_result = byte_result * 10 + digit) > 255) @@ -5564,8 +5585,8 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref) return 1; } table->fulltext_searched=1; - return agg_arg_collations_for_comparison(cmp_collation, - args+1, arg_count-1, 0); + return agg_item_collations_for_comparison(cmp_collation, func_name(), + args+1, arg_count-1, 0); } bool Item_func_match::fix_index() diff --git a/sql/item_func.h b/sql/item_func.h index 6bfdae8d56d..fc7f8708a45 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -160,23 +160,25 @@ public: my_decimal *val_decimal(my_decimal *); - bool agg_arg_collations(DTCollation &c, Item **items, uint nitems, - uint flags) - { - return agg_item_collations(c, func_name(), items, nitems, flags, 1); - } - bool agg_arg_collations_for_comparison(DTCollation &c, - Item **items, uint nitems, - uint flags) - { - return agg_item_collations_for_comparison(c, func_name(), - items, nitems, flags); - } bool agg_arg_charsets(DTCollation &c, Item **items, uint nitems, uint flags, int item_sep) { return agg_item_charsets(c, func_name(), items, nitems, flags, item_sep); } + bool agg_arg_charsets_for_string_result(DTCollation &c, + Item **items, uint nitems, + int item_sep= 1) + { + return agg_item_charsets_for_string_result(c, func_name(), + items, nitems, item_sep); + } + bool agg_arg_charsets_for_comparison(DTCollation &c, + Item **items, uint nitems, + int item_sep= 1) + { + return agg_item_charsets_for_comparison(c, func_name(), + items, nitems, item_sep); + } bool walk(Item_processor processor, bool walk_subquery, uchar *arg); Item *transform(Item_transformer transformer, uchar *arg); Item* compile(Item_analyzer analyzer, uchar **arg_p, @@ -226,10 +228,10 @@ public: class Item_real_func :public Item_func { public: - Item_real_func() :Item_func() {} - Item_real_func(Item *a) :Item_func(a) {} - Item_real_func(Item *a,Item *b) :Item_func(a,b) {} - Item_real_func(List &list) :Item_func(list) {} + Item_real_func() :Item_func() { collation.set_numeric(); } + Item_real_func(Item *a) :Item_func(a) { collation.set_numeric(); } + Item_real_func(Item *a,Item *b) :Item_func(a,b) { collation.set_numeric(); } + Item_real_func(List &list) :Item_func(list) { collation.set_numeric(); } String *val_str(String*str); my_decimal *val_decimal(my_decimal *decimal_value); longlong val_int() @@ -246,13 +248,13 @@ protected: Item_result hybrid_type; public: Item_func_numhybrid(Item *a) :Item_func(a), hybrid_type(REAL_RESULT) - {} + { collation.set_numeric(); } Item_func_numhybrid(Item *a,Item *b) :Item_func(a,b), hybrid_type(REAL_RESULT) - {} + { collation.set_numeric(); } Item_func_numhybrid(List &list) :Item_func(list), hybrid_type(REAL_RESULT) - {} + { collation.set_numeric(); } enum Item_result result_type () const { return hybrid_type; } void fix_length_and_dec(); @@ -335,13 +337,18 @@ class Item_num_op :public Item_func_numhybrid class Item_int_func :public Item_func { public: - Item_int_func() :Item_func() { max_length= 21; } - Item_int_func(Item *a) :Item_func(a) { max_length= 21; } - Item_int_func(Item *a,Item *b) :Item_func(a,b) { max_length= 21; } + Item_int_func() :Item_func() + { collation.set_numeric(); fix_char_length(21); } + Item_int_func(Item *a) :Item_func(a) + { collation.set_numeric(); fix_char_length(21); } + Item_int_func(Item *a,Item *b) :Item_func(a,b) + { collation.set_numeric(); fix_char_length(21); } Item_int_func(Item *a,Item *b,Item *c) :Item_func(a,b,c) - { max_length= 21; } - Item_int_func(List &list) :Item_func(list) { max_length= 21; } - Item_int_func(THD *thd, Item_int_func *item) :Item_func(thd, item) {} + { collation.set_numeric(); fix_char_length(21); } + Item_int_func(List &list) :Item_func(list) + { collation.set_numeric(); fix_char_length(21); } + Item_int_func(THD *thd, Item_int_func *item) :Item_func(thd, item) + { collation.set_numeric(); } double val_real(); String *val_str(String*str); enum Item_result result_type () const { return INT_RESULT; } @@ -370,7 +377,7 @@ public: longlong val_int(); longlong val_int_from_str(int *error); void fix_length_and_dec() - { max_length=args[0]->max_length; unsigned_flag=0; } + { fix_char_length(args[0]->max_char_length()); unsigned_flag=0; } virtual void print(String *str, enum_query_type query_type); uint decimal_precision() const { return args[0]->decimal_precision(); } }; @@ -383,7 +390,8 @@ public: const char *func_name() const { return "cast_as_unsigned"; } void fix_length_and_dec() { - max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2); + fix_char_length(min(args[0]->max_char_length(), + DECIMAL_MAX_PRECISION + 2)); unsigned_flag=1; } longlong val_int(); @@ -398,8 +406,9 @@ public: Item_decimal_typecast(Item *a, int len, int dec) :Item_func(a) { decimals= dec; - max_length= my_decimal_precision_to_length_no_truncation(len, dec, - unsigned_flag); + collation.set_numeric(); + fix_char_length(my_decimal_precision_to_length_no_truncation(len, dec, + unsigned_flag)); } String *val_str(String *str); double val_real(); diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 8c38cb2a859..c5554265fbe 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -52,7 +52,7 @@ String *Item_func_geometry_from_text::val_str(String *str) DBUG_ASSERT(fixed == 1); Geometry_buffer buffer; String arg_val; - String *wkt= args[0]->val_str(&arg_val); + String *wkt= args[0]->val_str_ascii(&arg_val); if ((null_value= args[0]->null_value)) return 0; @@ -110,7 +110,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str) } -String *Item_func_as_wkt::val_str(String *str) +String *Item_func_as_wkt::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); String arg_val; @@ -134,6 +134,7 @@ String *Item_func_as_wkt::val_str(String *str) void Item_func_as_wkt::fix_length_and_dec() { + collation.set(default_charset(), DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); max_length=MAX_BLOB_WIDTH; maybe_null= 1; } @@ -157,7 +158,7 @@ String *Item_func_as_wkb::val_str(String *str) } -String *Item_func_geometry_type::val_str(String *str) +String *Item_func_geometry_type::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); String *swkb= args[0]->val_str(str); diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index 9a55ea7d5b1..25755de1e2c 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -57,12 +57,12 @@ public: String *val_str(String *); }; -class Item_func_as_wkt: public Item_str_func +class Item_func_as_wkt: public Item_str_ascii_func { public: - Item_func_as_wkt(Item *a): Item_str_func(a) {} + Item_func_as_wkt(Item *a): Item_str_ascii_func(a) {} const char *func_name() const { return "astext"; } - String *val_str(String *); + String *val_str_ascii(String *); void fix_length_and_dec(); }; @@ -75,16 +75,17 @@ public: enum_field_types field_type() const { return MYSQL_TYPE_BLOB; } }; -class Item_func_geometry_type: public Item_str_func +class Item_func_geometry_type: public Item_str_ascii_func { public: - Item_func_geometry_type(Item *a): Item_str_func(a) {} - String *val_str(String *); + Item_func_geometry_type(Item *a): Item_str_ascii_func(a) {} + String *val_str_ascii(String *); const char *func_name() const { return "geometrytype"; } void fix_length_and_dec() { - max_length=20; // "GeometryCollection" is the most long - maybe_null= 1; + // "GeometryCollection" is the longest + fix_length_and_charset(20, default_charset()); + maybe_null= 1; }; }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c33e0f4c6fb..7bb2d358abf 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -41,6 +41,38 @@ C_MODE_END String my_empty_string("",default_charset_info); +/* + For the Items which have only val_str_ascii() method + and don't have their own "native" val_str(), + we provide a "wrapper" method to convert from ASCII + to Item character set when it's necessary. + Conversion happens only in case of "tricky" Item character set (e.g. UCS2). + Normally conversion does not happen, and val_str_ascii() is immediately + returned instead. +*/ +String *Item_str_ascii_func::val_str(String *str) +{ + DBUG_ASSERT(fixed == 1); + + if (!(collation.collation->state & MY_CS_NONASCII)) + return val_str_ascii(str); + + DBUG_ASSERT(str != &ascii_buf); + + uint errors; + String *res= val_str_ascii(&ascii_buf); + if (!res) + return 0; + + if ((null_value= str->copy(res->ptr(), res->length(), + &my_charset_latin1, collation.collation, + &errors))) + return 0; + + return str; +} + + /* Convert an array of bytes to a hexadecimal representation. @@ -112,7 +144,7 @@ longlong Item_str_func::val_int() } -String *Item_func_md5::val_str(String *str) +String *Item_func_md5::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); String * sptr= args[0]->val_str(str); @@ -139,7 +171,6 @@ String *Item_func_md5::val_str(String *str) void Item_func_md5::fix_length_and_dec() { - max_length=32; /* The MD5() function treats its parameter as being a case sensitive. Thus we set binary collation on it so different instances of MD5() will be @@ -148,10 +179,11 @@ void Item_func_md5::fix_length_and_dec() args[0]->collation.set( get_charset_by_csname(args[0]->collation.collation->csname, MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE); + fix_length_and_charset(32, default_charset()); } -String *Item_func_sha::val_str(String *str) +String *Item_func_sha::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); String * sptr= args[0]->val_str(str); @@ -181,7 +213,6 @@ String *Item_func_sha::val_str(String *str) void Item_func_sha::fix_length_and_dec() { - max_length=SHA1_HASH_SIZE*2; // size of hex representation of hash /* The SHA() function treats its parameter as being a case sensitive. Thus we set binary collation on it so different instances of MD5() will be @@ -190,6 +221,8 @@ void Item_func_sha::fix_length_and_dec() args[0]->collation.set( get_charset_by_csname(args[0]->collation.collation->csname, MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE); + // size of hex representation of hash + fix_length_and_charset(SHA1_HASH_SIZE * 2, default_charset()); } @@ -414,7 +447,7 @@ void Item_func_concat::fix_length_and_dec() { ulonglong max_result_length= 0; - if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV, 1)) + if (agg_arg_charsets_for_string_result(collation, args, arg_count)) return; for (uint i=0 ; i < arg_count ; i++) @@ -772,7 +805,7 @@ void Item_func_concat_ws::fix_length_and_dec() { ulonglong max_result_length; - if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV, 1)) + if (agg_arg_charsets_for_string_result(collation, args, arg_count)) return; /* @@ -843,8 +876,8 @@ String *Item_func_reverse::val_str(String *str) void Item_func_reverse::fix_length_and_dec() { - collation.set(args[0]->collation); - max_length = args[0]->max_length; + agg_arg_charsets_for_string_result(collation, args, 1); + fix_char_length(args[0]->max_char_length()); } /** @@ -987,7 +1020,7 @@ void Item_func_replace::fix_length_and_dec() } max_length= (ulong) max_result_length; - if (agg_arg_charsets(collation, args, 3, MY_COLL_CMP_CONV, 1)) + if (agg_arg_charsets_for_comparison(collation, args, 3)) return; } @@ -1046,7 +1079,7 @@ void Item_func_insert::fix_length_and_dec() ulonglong max_result_length; // Handle character set for args[0] and args[3]. - if (agg_arg_charsets(collation, &args[0], 2, MY_COLL_ALLOW_CONV, 3)) + if (agg_arg_charsets_for_string_result(collation, args, 2, 3)) return; max_result_length= ((ulonglong) args[0]->max_length+ (ulonglong) args[3]->max_length); @@ -1094,7 +1127,7 @@ String *Item_str_conv::val_str(String *str) void Item_func_lcase::fix_length_and_dec() { - collation.set(args[0]->collation); + agg_arg_charsets_for_string_result(collation, args, 1); multiply= collation.collation->casedn_multiply; converter= collation.collation->cset->casedn; max_length= args[0]->max_length * multiply; @@ -1102,7 +1135,7 @@ void Item_func_lcase::fix_length_and_dec() void Item_func_ucase::fix_length_and_dec() { - collation.set(args[0]->collation); + agg_arg_charsets_for_string_result(collation, args, 1); multiply= collation.collation->caseup_multiply; converter= collation.collation->cset->caseup; max_length= args[0]->max_length * multiply; @@ -1150,7 +1183,7 @@ void Item_str_func::left_right_max_length() void Item_func_left::fix_length_and_dec() { - collation.set(args[0]->collation); + agg_arg_charsets_for_string_result(collation, args, 1); left_right_max_length(); } @@ -1183,7 +1216,7 @@ String *Item_func_right::val_str(String *str) void Item_func_right::fix_length_and_dec() { - collation.set(args[0]->collation); + agg_arg_charsets_for_string_result(collation, args, 1); left_right_max_length(); } @@ -1239,7 +1272,7 @@ void Item_func_substr::fix_length_and_dec() { max_length=args[0]->max_length; - collation.set(args[0]->collation); + agg_arg_charsets_for_string_result(collation, args, 1); if (args[1]->const_item()) { int32 start= (int32) args[1]->val_int(); @@ -1264,7 +1297,7 @@ void Item_func_substr_index::fix_length_and_dec() { max_length= args[0]->max_length; - if (agg_arg_charsets(collation, args, 2, MY_COLL_CMP_CONV, 1)) + if (agg_arg_charsets_for_comparison(collation, args, 2)) return; } @@ -1594,7 +1627,7 @@ void Item_func_trim::fix_length_and_dec() max_length= args[0]->max_length; if (arg_count == 1) { - collation.set(args[0]->collation); + agg_arg_charsets_for_string_result(collation, args, 1); remove.set_charset(collation.collation); remove.set_ascii(" ",1); } @@ -1602,7 +1635,7 @@ void Item_func_trim::fix_length_and_dec() { // Handle character set for args[1] and args[0]. // Note that we pass args[1] as the first item, and args[0] as the second. - if (agg_arg_charsets(collation, &args[1], 2, MY_COLL_CMP_CONV, -1)) + if (agg_arg_charsets_for_comparison(collation, &args[1], 2, -1)) return; } } @@ -1627,7 +1660,7 @@ void Item_func_trim::print(String *str, enum_query_type query_type) /* Item_func_password */ -String *Item_func_password::val_str(String *str) +String *Item_func_password::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); String *res= args[0]->val_str(str); @@ -1636,7 +1669,7 @@ String *Item_func_password::val_str(String *str) if (res->length() == 0) return &my_empty_string; my_make_scrambled_password(tmp_value, res->ptr(), res->length()); - str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH, res->charset()); + str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH, &my_charset_latin1); return str; } @@ -1651,7 +1684,7 @@ char *Item_func_password::alloc(THD *thd, const char *password, /* Item_func_old_password */ -String *Item_func_old_password::val_str(String *str) +String *Item_func_old_password::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); String *res= args[0]->val_str(str); @@ -1660,7 +1693,7 @@ String *Item_func_old_password::val_str(String *str) if (res->length() == 0) return &my_empty_string; my_make_scrambled_password_323(tmp_value, res->ptr(), res->length()); - str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH_323, res->charset()); + str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH_323, &my_charset_latin1); return str; } @@ -1880,7 +1913,7 @@ bool Item_func_current_user::fix_fields(THD *thd, Item **ref) void Item_func_soundex::fix_length_and_dec() { - collation.set(args[0]->collation); + agg_arg_charsets_for_string_result(collation, args, 1); max_length=args[0]->max_length; set_if_bigger(max_length, 4 * collation.collation->mbminlen); tmp_value.set_charset(collation.collation); @@ -2186,7 +2219,7 @@ void Item_func_elt::fix_length_and_dec() max_length=0; decimals=0; - if (agg_arg_charsets(collation, args+1, arg_count-1, MY_COLL_ALLOW_CONV, 1)) + if (agg_arg_charsets_for_string_result(collation, args + 1, arg_count - 1)) return; for (uint i= 1 ; i < arg_count ; i++) @@ -2253,7 +2286,7 @@ void Item_func_make_set::fix_length_and_dec() { max_length=arg_count-1; - if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV, 1)) + if (agg_arg_charsets_for_string_result(collation, args, arg_count)) return; for (uint i=0 ; i < arg_count ; i++) @@ -2413,7 +2446,7 @@ inline String* alloc_buffer(String *res,String *str,String *tmp_value, void Item_func_repeat::fix_length_and_dec() { - collation.set(args[0]->collation); + agg_arg_charsets_for_string_result(collation, args, 1); if (args[1]->const_item()) { /* must be longlong to avoid truncation */ @@ -2497,7 +2530,7 @@ err: void Item_func_rpad::fix_length_and_dec() { // Handle character set for args[0] and args[2]. - if (agg_arg_charsets(collation, &args[0], 2, MY_COLL_ALLOW_CONV, 2)) + if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2)) return; if (args[1]->const_item()) { @@ -2599,7 +2632,7 @@ String *Item_func_rpad::val_str(String *str) void Item_func_lpad::fix_length_and_dec() { // Handle character set for args[0] and args[2]. - if (agg_arg_charsets(collation, &args[0], 2, MY_COLL_ALLOW_CONV, 2)) + if (agg_arg_charsets_for_string_result(collation, &args[0], 2, 2)) return; if (args[1]->const_item()) @@ -2769,7 +2802,7 @@ String *Item_func_conv_charset::val_str(String *str) void Item_func_conv_charset::fix_length_and_dec() { collation.set(conv_charset, DERIVATION_IMPLICIT); - max_length = args[0]->max_length*conv_charset->mbmaxlen; + fix_char_length(args[0]->max_char_length()); } void Item_func_conv_charset::print(String *str, enum_query_type query_type) @@ -2859,7 +2892,7 @@ String *Item_func_charset::val_str(String *str) DBUG_ASSERT(fixed == 1); uint dummy_errors; - CHARSET_INFO *cs= args[0]->collation.collation; + CHARSET_INFO *cs= args[0]->charset_for_protocol(); null_value= 0; str->copy(cs->csname, (uint) strlen(cs->csname), &my_charset_latin1, collation.collation, &dummy_errors); @@ -2870,7 +2903,7 @@ String *Item_func_collation::val_str(String *str) { DBUG_ASSERT(fixed == 1); uint dummy_errors; - CHARSET_INFO *cs= args[0]->collation.collation; + CHARSET_INFO *cs= args[0]->charset_for_protocol(); null_value= 0; str->copy(cs->name, (uint) strlen(cs->name), @@ -2904,7 +2937,7 @@ String *Item_func_hex::val_str(String *str) if ((null_value= args[0]->null_value)) return 0; ptr= longlong2str(dec,ans,16); - if (str->copy(ans,(uint32) (ptr-ans),default_charset())) + if (str->copy(ans,(uint32) (ptr-ans), &my_charset_numeric)) return &my_empty_string; // End of memory return str; } @@ -3109,11 +3142,11 @@ void Item_func_export_set::fix_length_and_dec() { uint length=max(args[1]->max_length,args[2]->max_length); uint sep_length=(arg_count > 3 ? args[3]->max_length : 1); - max_length=length*64+sep_length*63; - if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1, - MY_COLL_ALLOW_CONV, 1)) + if (agg_arg_charsets_for_string_result(collation, + args + 1, min(4, arg_count) - 1)) return; + fix_char_length(length * 64 + sep_length * 63); } String* Item_func_inet_ntoa::val_str(String* str) @@ -3132,6 +3165,7 @@ String* Item_func_inet_ntoa::val_str(String* str) if ((null_value= (args[0]->null_value || n > (ulonglong) LL(4294967295)))) return 0; // Null value + str->set_charset(collation.collation); str->length(0); int4store(buf,n); @@ -3149,11 +3183,11 @@ String* Item_func_inet_ntoa::val_str(String* str) num[0]=(char) n1+'0'; num[1]=(char) n2+'0'; num[2]=(char) c+'0'; - uint length=(n1 ? 4 : n2 ? 3 : 2); // Remove pre-zero - - (void) str->append(num+4-length,length); + uint length= (n1 ? 4 : n2 ? 3 : 2); // Remove pre-zero + uint dot_length= (p <= buf) ? 1 : 0; + (void) str->append(num + 4 - length, length - dot_length, + &my_charset_latin1); } - str->length(str->length()-1); // Remove last '.'; return str; } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 09a7da021c0..c9d62ac1052 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -41,28 +41,41 @@ public: bool fix_fields(THD *thd, Item **ref); }; -class Item_func_md5 :public Item_str_func + + +/* + Functions that return values with ASCII repertoire +*/ +class Item_str_ascii_func :public Item_str_func +{ + String ascii_buf; +public: + Item_str_ascii_func() :Item_str_func() {} + Item_str_ascii_func(Item *a) :Item_str_func(a) {} + Item_str_ascii_func(Item *a,Item *b) :Item_str_func(a,b) {} + Item_str_ascii_func(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {} + String *val_str_convert_from_ascii(String *str, String *ascii_buf); + String *val_str(String *str); + virtual String *val_str_ascii(String *)= 0; +}; + + +class Item_func_md5 :public Item_str_ascii_func { String tmp_value; public: - Item_func_md5(Item *a) :Item_str_func(a) - { - collation.set(&my_charset_bin); - } - String *val_str(String *); + Item_func_md5(Item *a) :Item_str_ascii_func(a) {} + String *val_str_ascii(String *); void fix_length_and_dec(); const char *func_name() const { return "md5"; } }; -class Item_func_sha :public Item_str_func +class Item_func_sha :public Item_str_ascii_func { public: - Item_func_sha(Item *a) :Item_str_func(a) - { - collation.set(&my_charset_bin); - } - String *val_str(String *); + Item_func_sha(Item *a) :Item_str_ascii_func(a) {} + String *val_str_ascii(String *); void fix_length_and_dec(); const char *func_name() const { return "sha"; } }; @@ -263,13 +276,16 @@ public: authentication procedure works, see comments in password.c. */ -class Item_func_password :public Item_str_func +class Item_func_password :public Item_str_ascii_func { char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]; public: - Item_func_password(Item *a) :Item_str_func(a) {} - String *val_str(String *str); - void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; } + Item_func_password(Item *a) :Item_str_ascii_func(a) {} + String *val_str_ascii(String *str); + void fix_length_and_dec() + { + fix_length_and_charset(SCRAMBLED_PASSWORD_CHAR_LENGTH, default_charset()); + } const char *func_name() const { return "password"; } static char *alloc(THD *thd, const char *password, size_t pass_len); }; @@ -282,13 +298,16 @@ public: function. */ -class Item_func_old_password :public Item_str_func +class Item_func_old_password :public Item_str_ascii_func { char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1]; public: - Item_func_old_password(Item *a) :Item_str_func(a) {} - String *val_str(String *str); - void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; } + Item_func_old_password(Item *a) :Item_str_ascii_func(a) {} + String *val_str_ascii(String *str); + void fix_length_and_dec() + { + fix_length_and_charset(SCRAMBLED_PASSWORD_CHAR_LENGTH_323, default_charset()); + } const char *func_name() const { return "old_password"; } static char *alloc(THD *thd, const char *password, size_t pass_len); }; @@ -688,7 +707,7 @@ public: void fix_length_and_dec() { decimals= 0; - max_length= 3 * 8 + 7; + fix_length_and_charset(3 * 8 + 7, default_charset()); maybe_null= 1; } }; @@ -848,14 +867,11 @@ class Item_func_uuid: public Item_str_func { public: Item_func_uuid(): Item_str_func() {} - void fix_length_and_dec() { - collation.set(system_charset_info); - /* - NOTE! uuid() should be changed to use 'ascii' - charset when hex(), format(), md5(), etc, and implicit - number-to-string conversion will use 'ascii' - */ - max_length= UUID_LENGTH * system_charset_info->mbmaxlen; + void fix_length_and_dec() + { + collation.set(system_charset_info, + DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); + fix_char_length(UUID_LENGTH); } const char *func_name() const{ return "uuid"; } String *val_str(String *); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a61c5d59d67..3d83c7ee513 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3202,11 +3202,9 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref) return TRUE; } - if (agg_item_charsets(collation, func_name(), - args, - /* skip charset aggregation for order columns */ - arg_count - arg_count_order, - MY_COLL_ALLOW_CONV, 1)) + /* skip charset aggregation for order columns */ + if (agg_item_charsets_for_string_result(collation, func_name(), + args, arg_count - arg_count_order)) return 1; result.set_charset(collation.collation); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 392bc936f17..49d31bf1252 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -57,7 +57,7 @@ static bool make_datetime(date_time_format_types format, MYSQL_TIME *ltime, String *str) { char *buff; - CHARSET_INFO *cs= &my_charset_bin; + CHARSET_INFO *cs= &my_charset_numeric; uint length= MAX_DATE_STRING_REP_LENGTH; if (str->alloc(length)) @@ -1586,9 +1586,7 @@ bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date) void Item_func_curdate::fix_length_and_dec() { - collation.set(&my_charset_bin); - decimals=0; - max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + Item_date::fix_length_and_dec(); store_now_in_TIME(<ime); @@ -1649,7 +1647,7 @@ bool Item_func_curdate::get_date(MYSQL_TIME *res, String *Item_func_curtime::val_str(String *str) { DBUG_ASSERT(fixed == 1); - str_value.set(buff, buff_length, &my_charset_bin); + str_value.set(buff, buff_length, &my_charset_latin1); return &str_value; } @@ -1659,11 +1657,10 @@ void Item_func_curtime::fix_length_and_dec() MYSQL_TIME ltime; decimals= DATETIME_DEC; - collation.set(&my_charset_bin); store_now_in_TIME(<ime); value= TIME_to_ulonglong_time(<ime); buff_length= (uint) my_time_to_str(<ime, buff); - max_length= buff_length; + fix_length_and_charset_datetime(buff_length); } @@ -1698,7 +1695,7 @@ void Item_func_curtime_utc::store_now_in_TIME(MYSQL_TIME *now_time) String *Item_func_now::val_str(String *str) { DBUG_ASSERT(fixed == 1); - str_value.set(buff,buff_length, &my_charset_bin); + str_value.set(buff, buff_length, &my_charset_numeric); return &str_value; } @@ -1706,13 +1703,12 @@ String *Item_func_now::val_str(String *str) void Item_func_now::fix_length_and_dec() { decimals= DATETIME_DEC; - collation.set(&my_charset_bin); store_now_in_TIME(<ime); value= (longlong) TIME_to_ulonglong_datetime(<ime); buff_length= (uint) my_datetime_to_str(<ime, buff); - max_length= buff_length; + fix_length_and_charset_datetime(buff_length); } @@ -1776,7 +1772,7 @@ String *Item_func_sysdate_local::val_str(String *str) DBUG_ASSERT(fixed == 1); store_now_in_TIME(<ime); buff_length= (uint) my_datetime_to_str(<ime, buff); - str_value.set(buff, buff_length, &my_charset_bin); + str_value.set(buff, buff_length, &my_charset_numeric); return &str_value; } @@ -1800,8 +1796,7 @@ double Item_func_sysdate_local::val_real() void Item_func_sysdate_local::fix_length_and_dec() { decimals= 0; - collation.set(&my_charset_bin); - max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset_datetime(MAX_DATETIME_WIDTH); } @@ -2005,7 +2000,8 @@ String *Item_func_date_format::val_str(String *str) { String *res; if (!(res=args[0]->val_str(str)) || - (str_to_time_with_warn(res->ptr(), res->length(), &l_time))) + (str_to_time_with_warn(res->charset(), res->ptr(), res->length(), + &l_time))) goto null_date; l_time.year=l_time.month=l_time.day=0; @@ -2049,9 +2045,8 @@ null_date: void Item_func_from_unixtime::fix_length_and_dec() { thd= current_thd; - collation.set(&my_charset_bin); decimals= DATETIME_DEC; - max_length=MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset_datetime(MAX_DATETIME_WIDTH); maybe_null= 1; thd->time_zone_used= 1; } @@ -2109,9 +2104,8 @@ bool Item_func_from_unixtime::get_date(MYSQL_TIME *ltime, void Item_func_convert_tz::fix_length_and_dec() { - collation.set(&my_charset_bin); decimals= 0; - max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset_datetime(MAX_DATETIME_WIDTH); maybe_null= 1; } @@ -2155,13 +2149,13 @@ bool Item_func_convert_tz::get_date(MYSQL_TIME *ltime, if (!from_tz_cached) { - from_tz= my_tz_find(thd, args[1]->val_str(&str)); + from_tz= my_tz_find(thd, args[1]->val_str_ascii(&str)); from_tz_cached= args[1]->const_item(); } if (!to_tz_cached) { - to_tz= my_tz_find(thd, args[2]->val_str(&str)); + to_tz= my_tz_find(thd, args[2]->val_str_ascii(&str)); to_tz_cached= args[2]->const_item(); } @@ -2195,9 +2189,8 @@ void Item_date_add_interval::fix_length_and_dec() { enum_field_types arg0_field_type; - collation.set(&my_charset_bin); maybe_null=1; - max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset_datetime(MAX_DATETIME_FULL_WIDTH); value.alloc(max_length); /* @@ -2375,7 +2368,9 @@ longlong Item_extract::val_int() else { String *res= args[0]->val_str(&value); - if (!res || str_to_time_with_warn(res->ptr(), res->length(), <ime)) + if (!res || + str_to_time_with_warn(res->charset(), res->ptr(), res->length(), + <ime)) { null_value=1; return 0; @@ -2814,7 +2809,7 @@ void Item_func_add_time::fix_length_and_dec() { enum_field_types arg0_field_type; decimals=0; - max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset_datetime(MAX_DATETIME_FULL_WIDTH); maybe_null= 1; /* @@ -3225,12 +3220,12 @@ void Item_func_timestamp_diff::print(String *str, enum_query_type query_type) } -String *Item_func_get_format::val_str(String *str) +String *Item_func_get_format::val_str_ascii(String *str) { DBUG_ASSERT(fixed == 1); const char *format_name; KNOWN_DATE_TIME_FORMAT *format; - String *val= args[0]->val_str(str); + String *val= args[0]->val_str_ascii(str); ulong val_len; if ((null_value= args[0]->null_value)) @@ -3249,7 +3244,7 @@ String *Item_func_get_format::val_str(String *str) (const uchar *) format_name, val_len)) { const char *format_str= get_date_time_format_str(format, type); - str->set(format_str, (uint) strlen(format_str), &my_charset_bin); + str->set(format_str, (uint) strlen(format_str), &my_charset_numeric); return str; } } diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 860bd983184..20e4d6488d6 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -122,23 +122,22 @@ public: class Item_func_month :public Item_func { public: - Item_func_month(Item *a) :Item_func(a) {} + Item_func_month(Item *a) :Item_func(a) { collation.set_numeric(); } longlong val_int(); double val_real() { DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); } String *val_str(String *str) { - str->set(val_int(), &my_charset_bin); + str->set(val_int(), collation.collation); return null_value ? 0 : str; } const char *func_name() const { return "month"; } enum Item_result result_type () const { return INT_RESULT; } void fix_length_and_dec() { - collation.set(&my_charset_bin); - decimals=0; - max_length=2*MY_CHARSET_BIN_MB_MAXLEN; - maybe_null=1; + decimals= 0; + fix_char_length(2); + maybe_null= 1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -165,9 +164,9 @@ public: const char *func_name() const { return "dayofyear"; } void fix_length_and_dec() { - decimals=0; - max_length=3*MY_CHARSET_BIN_MB_MAXLEN; - maybe_null=1; + decimals= 0; + fix_char_length(3); + maybe_null= 1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -290,7 +289,7 @@ class Item_func_weekday :public Item_func bool odbc_type; public: Item_func_weekday(Item *a,bool type_arg) - :Item_func(a), odbc_type(type_arg) {} + :Item_func(a), odbc_type(type_arg) { collation.set_numeric(); } longlong val_int(); double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); } String *val_str(String *str) @@ -306,10 +305,9 @@ public: enum Item_result result_type () const { return INT_RESULT; } void fix_length_and_dec() { - collation.set(&my_charset_bin); - decimals=0; - max_length=1*MY_CHARSET_BIN_MB_MAXLEN; - maybe_null=1; + decimals= 0; + fix_char_length(1); + maybe_null= 1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -379,15 +377,15 @@ public: Item_date(Item *a) :Item_func(a) {} enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } + CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } String *val_str(String *str); longlong val_int(); double val_real() { return val_real_from_decimal(); } const char *func_name() const { return "date"; } void fix_length_and_dec() { - collation.set(&my_charset_bin); - decimals=0; - max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + decimals= 0; + fix_length_and_charset_datetime(MAX_DATE_WIDTH); } Field *tmp_table_field(TABLE *table) { @@ -414,6 +412,7 @@ public: Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {} Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {} enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } + CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } Field *tmp_table_field(TABLE *table) { return tmp_table_field_from_field_type(table, 0); @@ -440,10 +439,11 @@ public: Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {} Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {} enum_field_types field_type() const { return MYSQL_TYPE_TIME; } + CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } void fix_length_and_dec() { decimals= DATETIME_DEC; - max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset_datetime(MAX_TIME_WIDTH); } Field *tmp_table_field(TABLE *table) { @@ -701,7 +701,6 @@ public: void fix_length_and_dec() { Item_str_timefunc::fix_length_and_dec(); - collation.set(&my_charset_bin); maybe_null=1; } const char *func_name() const { return "sec_to_time"; } @@ -774,13 +773,7 @@ public: class Item_typecast_maybe_null :public Item_typecast { public: - Item_typecast_maybe_null(Item *a) :Item_typecast(a) {} - void fix_length_and_dec() - { - collation.set(&my_charset_bin); - max_length=args[0]->max_length; - maybe_null= 1; - } + Item_typecast_maybe_null(Item *a) :Item_typecast(a) { maybe_null= 1; } }; @@ -813,16 +806,12 @@ public: bool get_time(MYSQL_TIME *ltime); const char *cast_type() const { return "date"; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } + CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } Field *tmp_table_field(TABLE *table) { return tmp_table_field_from_field_type(table, 0); - } - void fix_length_and_dec() - { - collation.set(&my_charset_bin); - max_length= 10; - maybe_null= 1; } + void fix_length_and_dec() { fix_length_and_charset_datetime(10); } bool result_as_longlong() { return TRUE; } longlong val_int(); double val_real() { return (double) val_int(); } @@ -847,6 +836,7 @@ public: bool get_time(MYSQL_TIME *ltime); const char *cast_type() const { return "time"; } enum_field_types field_type() const { return MYSQL_TYPE_TIME; } + CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } Field *tmp_table_field(TABLE *table) { return tmp_table_field_from_field_type(table, 0); @@ -863,6 +853,8 @@ public: { return save_time_in_field(field); } + void fix_length_and_dec() + { fix_length_and_charset_datetime(args[0]->max_char_length()); } }; @@ -874,15 +866,14 @@ public: String *val_str(String *str); const char *cast_type() const { return "datetime"; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } + CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } Field *tmp_table_field(TABLE *table) { return tmp_table_field_from_field_type(table, 0); } void fix_length_and_dec() { - collation.set(&my_charset_bin); - maybe_null= 1; - max_length= MAX_DATETIME_FULL_WIDTH * MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset_datetime(MAX_DATETIME_FULL_WIDTH); decimals= DATETIME_DEC; } bool result_as_longlong() { return TRUE; } @@ -907,10 +898,11 @@ public: String *val_str(String *str); const char *func_name() const { return "makedate"; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } + CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } void fix_length_and_dec() { decimals=0; - max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset_datetime(MAX_DATE_WIDTH); maybe_null= 1; } longlong val_int(); @@ -929,6 +921,7 @@ public: String *val_str(String *str); enum_field_types field_type() const { return cached_field_type; } void fix_length_and_dec(); + CHARSET_INFO *charset_for_protocol(void) const { return &my_charset_bin; } Field *tmp_table_field(TABLE *table) { @@ -1019,20 +1012,20 @@ enum date_time_format USA_FORMAT, JIS_FORMAT, ISO_FORMAT, EUR_FORMAT, INTERNAL_FORMAT }; -class Item_func_get_format :public Item_str_func +class Item_func_get_format :public Item_str_ascii_func { public: const timestamp_type type; // keep it public Item_func_get_format(timestamp_type type_arg, Item *a) - :Item_str_func(a), type(type_arg) + :Item_str_ascii_func(a), type(type_arg) {} - String *val_str(String *str); + String *val_str_ascii(String *str); const char *func_name() const { return "get_format"; } void fix_length_and_dec() { maybe_null= 1; decimals=0; - max_length=17*MY_CHARSET_BIN_MB_MAXLEN; + fix_length_and_charset(17, default_charset()); } virtual void print(String *str, enum_query_type query_type); }; diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 3e20b90e68e..3621733f456 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2569,7 +2569,7 @@ void Item_xml_str_func::fix_length_and_dec() nodeset_func= 0; - if (agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1)) + if (agg_arg_charsets_for_comparison(collation, args, arg_count)) return; if (collation.collation->mbminlen > 1) diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 16d07526a0f..234a0a98782 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -110,10 +110,63 @@ int my_decimal2string(uint mask, const my_decimal *d, &length, (int)fixed_prec, fixed_dec, filler); str->length(length); + str->set_charset(&my_charset_numeric); return check_result(mask, result); } +/** + @brief Converting decimal to string with character set conversion + + @details Convert given my_decimal to String; allocate buffer as needed. + + @param[in] mask what problems to warn on (mask of E_DEC_* values) + @param[in] val the decimal to print + @param[in] fixed_prec overall number of digits if ZEROFILL, 0 otherwise + @param[in] fixed_dec number of decimal places (if fixed_prec != 0) + @param[in] filler what char to pad with (ZEROFILL et al.) + @param[out] *str where to store the resulting string + @param[in] cs character set + + @return error coce + @retval E_DEC_OK + @retval E_DEC_TRUNCATED + @retval E_DEC_OVERFLOW + @retval E_DEC_OOM + + Would be great to make it a method of the String class, + but this would need to include + my_decimal.h from sql_string.h and sql_string.cc, which is not desirable. +*/ +bool +str_set_decimal(uint mask, const my_decimal *val, + uint fixed_prec, uint fixed_dec, char filler, + String *str, CHARSET_INFO *cs) +{ + if (!(cs->state & MY_CS_NONASCII)) + { + /* For ASCII-compatible character sets we can use my_decimal2string */ + my_decimal2string(mask, val, fixed_prec, fixed_dec, filler, str); + str->set_charset(cs); + return FALSE; + } + else + { + /* + For ASCII-incompatible character sets (like UCS2) we + call my_decimal2string() on a temporary buffer first, + and then convert the result to the target character + with help of str->copy(). + */ + uint errors; + char buf[DECIMAL_MAX_STR_LENGTH]; + String tmp(buf, sizeof(buf), &my_charset_latin1); + my_decimal2string(mask, val, fixed_prec, fixed_dec, filler, &tmp); + return str->copy(tmp.ptr(), tmp.length(), &my_charset_latin1, cs, &errors); + } +} + + /* Convert from decimal to binary representation diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 944bc9d4cdd..b4b871e68ba 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -218,7 +218,8 @@ extern CHARSET_INFO *error_message_charset_info; enum Derivation { - DERIVATION_IGNORABLE= 5, + DERIVATION_IGNORABLE= 6, + DERIVATION_NUMERIC= 5, DERIVATION_COERCIBLE= 4, DERIVATION_SYSCONST= 3, DERIVATION_IMPLICIT= 2, @@ -226,6 +227,8 @@ enum Derivation DERIVATION_EXPLICIT= 0 }; +#define my_charset_numeric my_charset_latin1 +#define MY_REPERTOIRE_NUMERIC MY_REPERTOIRE_ASCII typedef struct my_locale_errmsgs { @@ -869,6 +872,16 @@ typedef Comp_creator* (*chooser_compare_func_creator)(bool invert); #include "item.h" extern my_decimal decimal_zero; +/* my_decimal.cc */ +bool str_set_decimal(uint mask, const my_decimal *val, uint fixed_prec, + uint fixed_dec, char filler, String *str, + CHARSET_INFO *cs); +inline bool str_set_decimal(const my_decimal *val, String *str, + CHARSET_INFO *cs) +{ + return str_set_decimal(E_DEC_FATAL_ERROR, val, 0, 0, 0, str, cs); +} + /* sql_parse.cc */ void free_items(Item *item); void cleanup_items(Item *item); @@ -2233,8 +2246,17 @@ ulong convert_month_to_period(ulong month); void get_date_from_daynr(long daynr,uint *year, uint *month, uint *day); my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist); -bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time); -timestamp_type str_to_datetime_with_warn(const char *str, uint length, +/* Character set-aware version of str_to_time() */ +bool str_to_time(CHARSET_INFO *cs, const char *str,uint length, + MYSQL_TIME *l_time, int *warning); +/* Character set-aware version of str_to_datetime() */ +timestamp_type str_to_datetime(CHARSET_INFO *cs, + const char *str, uint length, + MYSQL_TIME *l_time, uint flags, int *was_cut); +bool str_to_time_with_warn(CHARSET_INFO *cs, const char *str,uint length, + MYSQL_TIME *l_time); +timestamp_type str_to_datetime_with_warn(CHARSET_INFO *cs, + const char *str, uint length, MYSQL_TIME *l_time, uint flags); void localtime_to_TIME(MYSQL_TIME *to, struct tm *from); void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds); diff --git a/sql/protocol.cc b/sql/protocol.cc index 855a6842f1f..fd943c98bd6 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -736,10 +736,10 @@ bool Protocol::send_result_set_metadata(List *list, uint flags) /* Store fixed length fields */ pos= (char*) local_packet->ptr()+local_packet->length(); *pos++= 12; // Length of packed fields - if (item->collation.collation == &my_charset_bin || thd_charset == NULL) + if (item->charset_for_protocol() == &my_charset_bin || thd_charset == NULL) { /* No conversion */ - int2store(pos, field.charsetnr); + int2store(pos, item->charset_for_protocol()->number); int4store(pos+2, field.length); } else diff --git a/sql/time.cc b/sql/time.cc index 5f804072eb0..2db7812b9ef 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -213,6 +213,69 @@ ulong convert_month_to_period(ulong month) } +/* + Convert a string to 8-bit representation, + for use in str_to_time/str_to_date/str_to_date. + + In the future to_ascii() can be extended to convert + non-ASCII digits to ASCII digits + (for example, ARABIC-INDIC, DEVANAGARI, BENGALI, and so on) + so DATE/TIME/DATETIME values understand digits in the + respected scripts. +*/ +static uint +to_ascii(CHARSET_INFO *cs, + const char *src, uint src_length, + char *dst, uint dst_length) + +{ + int cnvres; + my_wc_t wc; + const char *srcend= src + src_length; + char *dst0= dst, *dstend= dst + dst_length - 1; + while (dst < dstend && + (cnvres= (cs->cset->mb_wc)(cs, &wc, + (const uchar*) src, + (const uchar*) srcend)) > 0 && + wc < 128) + { + src+= cnvres; + *dst++= wc; + } + *dst= '\0'; + return dst - dst0; +} + + +/* Character set-aware version of str_to_time() */ +bool str_to_time(CHARSET_INFO *cs, const char *str,uint length, + MYSQL_TIME *l_time, int *warning) +{ + char cnv[32]; + if ((cs->state & MY_CS_NONASCII) != 0) + { + length= to_ascii(cs, str, length, cnv, sizeof(cnv)); + str= cnv; + } + return str_to_time(str, length, l_time, warning); +} + + +/* Character set-aware version of str_to_datetime() */ +timestamp_type str_to_datetime(CHARSET_INFO *cs, + const char *str, uint length, + MYSQL_TIME *l_time, uint flags, int *was_cut) +{ + char cnv[32]; + if ((cs->state & MY_CS_NONASCII) != 0) + { + length= to_ascii(cs, str, length, cnv, sizeof(cnv)); + str= cnv; + } + return str_to_datetime(str, length, l_time, flags, was_cut); +} + + /* Convert a timestamp string to a MYSQL_TIME value and produce a warning if string was truncated during conversion. @@ -222,14 +285,15 @@ ulong convert_month_to_period(ulong month) */ timestamp_type -str_to_datetime_with_warn(const char *str, uint length, MYSQL_TIME *l_time, +str_to_datetime_with_warn(CHARSET_INFO *cs, + const char *str, uint length, MYSQL_TIME *l_time, uint flags) { int was_cut; THD *thd= current_thd; timestamp_type ts_type; - ts_type= str_to_datetime(str, length, l_time, + ts_type= str_to_datetime(cs, str, length, l_time, (flags | (thd->variables.sql_mode & (MODE_INVALID_DATES | MODE_NO_ZERO_DATE))), @@ -284,7 +348,8 @@ my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_ See str_to_time() for more info. */ bool -str_to_time_with_warn(const char *str, uint length, MYSQL_TIME *l_time) +str_to_time_with_warn(CHARSET_INFO *cs, + const char *str, uint length, MYSQL_TIME *l_time) { int warning; bool ret_val= str_to_time(str, length, l_time, &warning); @@ -697,7 +762,7 @@ void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)), { uint length= (uint) my_time_to_str(l_time, (char*) str->ptr()); str->length(length); - str->set_charset(&my_charset_bin); + str->set_charset(&my_charset_numeric); } @@ -706,7 +771,7 @@ void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)), { uint length= (uint) my_date_to_str(l_time, (char*) str->ptr()); str->length(length); - str->set_charset(&my_charset_bin); + str->set_charset(&my_charset_numeric); } @@ -715,7 +780,7 @@ void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)), { uint length= (uint) my_datetime_to_str(l_time, (char*) str->ptr()); str->length(length); - str->set_charset(&my_charset_bin); + str->set_charset(&my_charset_numeric); } diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 069131ba354..2fe9601f892 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -970,7 +970,7 @@ double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), *endptr= b; res= my_strtod(buf, endptr, err); - *endptr= nptr + (size_t) (*endptr- buf); + *endptr= nptr + cs->mbminlen * (size_t) (*endptr- buf); return res; } From d59c06d96c7d4ab75bad474ec6b7d02e72a3a87e Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 11 Feb 2010 18:28:28 +0400 Subject: [PATCH 51/96] A post-fix for WL#2649 Number-to-string conversion Fixing problems discovered by "mtr --embedded" and "mtr --ps" @ libmysqld/lib_sql.cc "mtr --embedded --do-test=ps" failed. Applying a similar change to the one previously done in protocol.cc, to make embedded version work the same with client/server version. (a bug in the WL#2649 patch) @ mysql-test/include/ctype_numconv.inc @ mysql-test/r/ctype_binary.result @ mysql-test/r/ctype_cp1251.result @ mysql-test/r/ctype_latin1.result @ mysql-test/r/ctype_ucs.result - Changing tinyint(30) to tinyint(4) due to problems with "mtr --ps" Possibly a bug in libmysql.cc, in function fetch_long_with_conversion(). Zerofill buffer is to short. - Commenting tests with get_lock/release_lock "mtr --ps" failed for some reasons in ctype_cp1251. --- libmysqld/lib_sql.cc | 4 ++-- mysql-test/include/ctype_numconv.inc | 13 +++++++------ mysql-test/r/ctype_binary.result | 21 ++++----------------- mysql-test/r/ctype_cp1251.result | 21 ++++----------------- mysql-test/r/ctype_latin1.result | 21 ++++----------------- mysql-test/r/ctype_ucs.result | 21 ++++----------------- 6 files changed, 25 insertions(+), 76 deletions(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index d56ada00266..78e07110d7b 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -941,10 +941,10 @@ bool Protocol::send_result_set_metadata(List *list, uint flags) strlen(server_field.org_table_name), cs, thd_cs); client_field->org_name= dup_str_aux(field_alloc, server_field.org_col_name, strlen(server_field.org_col_name), cs, thd_cs); - if (item->collation.collation == &my_charset_bin || thd_cs == NULL) + if (item->charset_for_protocol() == &my_charset_bin || thd_cs == NULL) { /* No conversion */ - client_field->charsetnr= server_field.charsetnr; + client_field->charsetnr= item->charset_for_protocol()->number; client_field->length= server_field.length; } else diff --git a/mysql-test/include/ctype_numconv.inc b/mysql-test/include/ctype_numconv.inc index 1d393f530f9..959ca7dfeea 100644 --- a/mysql-test/include/ctype_numconv.inc +++ b/mysql-test/include/ctype_numconv.inc @@ -412,11 +412,12 @@ create table t1 as select concat(sleep(0)) as c1; show create table t1; drop table t1; -select hex(concat(get_lock('a',0))); -select hex(concat(release_lock('a'))); -create table t1 as select concat(get_lock('a',0)) as c1; -show create table t1; -drop table t1; +# Fails with "mtr --ps-protocol" for some reasons. +#select hex(concat(get_lock('a',0))); +#select hex(concat(release_lock('a'))); +#create table t1 as select concat(get_lock('a',0)) as c1; +#show create table t1; +#drop table t1; select hex(concat(is_free_lock('xxxx'))); create table t1 as select concat(is_free_lock('xxxx')) as c1; @@ -1053,7 +1054,7 @@ insert into t1 values (1), (10), (100); select hex(concat(a)), a from t1; drop table t1; -create table t1 (a tinyint(30) zerofill); +create table t1 (a tinyint(4) zerofill); insert into t1 values (1), (10), (100); select hex(concat(a)), a from t1; drop table t1; diff --git a/mysql-test/r/ctype_binary.result b/mysql-test/r/ctype_binary.result index e7d1eb1b492..55faa72c6ab 100644 --- a/mysql-test/r/ctype_binary.result +++ b/mysql-test/r/ctype_binary.result @@ -698,19 +698,6 @@ t1 CREATE TABLE `t1` ( `c1` varbinary(21) NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -select hex(concat(get_lock('a',0))); -hex(concat(get_lock('a',0))) -31 -select hex(concat(release_lock('a'))); -hex(concat(release_lock('a'))) -31 -create table t1 as select concat(get_lock('a',0)) as c1; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` varbinary(1) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1; select hex(concat(is_free_lock('xxxx'))); hex(concat(is_free_lock('xxxx'))) 31 @@ -1889,13 +1876,13 @@ hex(concat(a)) a 303130 010 313030 100 drop table t1; -create table t1 (a tinyint(30) zerofill); +create table t1 (a tinyint(4) zerofill); insert into t1 values (1), (10), (100); select hex(concat(a)), a from t1; hex(concat(a)) a -303030303030303030303030303030303030303030303030303030303031 000000000000000000000000000001 -303030303030303030303030303030303030303030303030303030303130 000000000000000000000000000010 -303030303030303030303030303030303030303030303030303030313030 000000000000000000000000000100 +30303031 0001 +30303130 0010 +30313030 0100 drop table t1; create table t1 (a decimal(10,2)); insert into t1 values (123.45); diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index f2e7c43a3ce..cb932c38a27 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -780,19 +780,6 @@ t1 CREATE TABLE `t1` ( `c1` varchar(21) CHARACTER SET cp1251 NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -select hex(concat(get_lock('a',0))); -hex(concat(get_lock('a',0))) -31 -select hex(concat(release_lock('a'))); -hex(concat(release_lock('a'))) -31 -create table t1 as select concat(get_lock('a',0)) as c1; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1; select hex(concat(is_free_lock('xxxx'))); hex(concat(is_free_lock('xxxx'))) 31 @@ -1971,13 +1958,13 @@ hex(concat(a)) a 303130 010 313030 100 drop table t1; -create table t1 (a tinyint(30) zerofill); +create table t1 (a tinyint(4) zerofill); insert into t1 values (1), (10), (100); select hex(concat(a)), a from t1; hex(concat(a)) a -303030303030303030303030303030303030303030303030303030303031 000000000000000000000000000001 -303030303030303030303030303030303030303030303030303030303130 000000000000000000000000000010 -303030303030303030303030303030303030303030303030303030313030 000000000000000000000000000100 +30303031 0001 +30303130 0010 +30313030 0100 drop table t1; create table t1 (a decimal(10,2)); insert into t1 values (123.45); diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 61d663b7e76..4944db677a6 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -1108,19 +1108,6 @@ t1 CREATE TABLE `t1` ( `c1` varchar(21) NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -select hex(concat(get_lock('a',0))); -hex(concat(get_lock('a',0))) -31 -select hex(concat(release_lock('a'))); -hex(concat(release_lock('a'))) -31 -create table t1 as select concat(get_lock('a',0)) as c1; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` varchar(1) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1; select hex(concat(is_free_lock('xxxx'))); hex(concat(is_free_lock('xxxx'))) 31 @@ -2299,13 +2286,13 @@ hex(concat(a)) a 303130 010 313030 100 drop table t1; -create table t1 (a tinyint(30) zerofill); +create table t1 (a tinyint(4) zerofill); insert into t1 values (1), (10), (100); select hex(concat(a)), a from t1; hex(concat(a)) a -303030303030303030303030303030303030303030303030303030303031 000000000000000000000000000001 -303030303030303030303030303030303030303030303030303030303130 000000000000000000000000000010 -303030303030303030303030303030303030303030303030303030313030 000000000000000000000000000100 +30303031 0001 +30303130 0010 +30313030 0100 drop table t1; create table t1 (a decimal(10,2)); insert into t1 values (123.45); diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index f547c4e8b8c..533dfa4db34 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -1932,19 +1932,6 @@ t1 CREATE TABLE `t1` ( `c1` varchar(21) CHARACTER SET ucs2 NOT NULL DEFAULT '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; -select hex(concat(get_lock('a',0))); -hex(concat(get_lock('a',0))) -0031 -select hex(concat(release_lock('a'))); -hex(concat(release_lock('a'))) -0031 -create table t1 as select concat(get_lock('a',0)) as c1; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1; select hex(concat(is_free_lock('xxxx'))); hex(concat(is_free_lock('xxxx'))) 0031 @@ -3123,13 +3110,13 @@ hex(concat(a)) a 003000310030 010 003100300030 100 drop table t1; -create table t1 (a tinyint(30) zerofill); +create table t1 (a tinyint(4) zerofill); insert into t1 values (1), (10), (100); select hex(concat(a)), a from t1; hex(concat(a)) a -003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300031 000000000000000000000000000001 -003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000310030 000000000000000000000000000010 -003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003000300030003100300030 000000000000000000000000000100 +0030003000300031 0001 +0030003000310030 0010 +0030003100300030 0100 drop table t1; create table t1 (a decimal(10,2)); insert into t1 values (123.45); From 9947636bbaede8996ac81b37f84c779c7fadd5df Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 12 Feb 2010 18:28:35 +0200 Subject: [PATCH 52/96] Bug #35250: readline check breaks when doing vpath build Fixed several (obvious) places that don't work with vpath build. --- configure.in | 2 +- mysql-test/Makefile.am | 4 ++-- scripts/Makefile.am | 5 +++-- sql/share/Makefile.am | 8 ++++---- storage/ndb/src/common/util/Makefile.am | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index 88e0ebf1faa..45f86677a86 100644 --- a/configure.in +++ b/configure.in @@ -2711,7 +2711,7 @@ case $SYSTEM_TYPE in fi # if there is no readline, but we want to build with readline, we fail - if [test "$want_to_use_readline" = "yes"] && [test ! -d "./cmd-line-utils/readline"] + if [test "$want_to_use_readline" = "yes"] && [test ! -d "$srcdir/cmd-line-utils/readline"] then AC_MSG_ERROR([This commercially licensed MySQL source package can't be built with libreadline. Please use --with-libedit to use diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index b1d0e85c70e..31770592d53 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -130,12 +130,12 @@ uninstall-local: # mtr - a shortcut for executing mysql-test-run.pl mtr: $(RM) -f mtr - $(LN_S) mysql-test-run.pl mtr + $(LN_S) $(srcdir)/mysql-test-run.pl mtr # mysql-test-run - a shortcut for executing mysql-test-run.pl mysql-test-run: $(RM) -f mysql-test-run - $(LN_S) mysql-test-run.pl mysql-test-run + $(LN_S) $(srcdir)/mysql-test-run.pl mysql-test-run # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 0292617c7a5..1aa24c5d432 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -110,7 +110,8 @@ mysqlbug: ${top_builddir}/config.status mysqlbug.sh mysql_fix_privilege_tables.sql: mysql_system_tables.sql \ mysql_system_tables_fix.sql @echo "Building $@"; - @cat mysql_system_tables.sql mysql_system_tables_fix.sql > $@ + @cat $(srcdir)/mysql_system_tables.sql \ + $(srcdir)/mysql_system_tables_fix.sql > $@ # # Build mysql_fix_privilege_tables_sql.c from @@ -123,7 +124,7 @@ mysql_fix_privilege_tables_sql.c: comp_sql.c mysql_fix_privilege_tables.sql sleep 2 $(top_builddir)/scripts/comp_sql$(EXEEXT) \ mysql_fix_privilege_tables \ - $(top_srcdir)/scripts/mysql_fix_privilege_tables.sql $@ + $(top_builddir)/scripts/mysql_fix_privilege_tables.sql $@ SUFFIXES = .sh diff --git a/sql/share/Makefile.am b/sql/share/Makefile.am index 68b393e619f..357f9ac0876 100644 --- a/sql/share/Makefile.am +++ b/sql/share/Makefile.am @@ -22,7 +22,7 @@ dist-hook: test -d $(distdir)/$$dir || mkdir $(distdir)/$$dir; \ $(INSTALL_DATA) $(srcdir)/$$dir/*.* $(distdir)/$$dir; \ done; \ - sleep 1 ; touch $(srcdir)/*/errmsg.sys + sleep 1 ; touch $(builddir)/*/errmsg.sys $(INSTALL_DATA) $(srcdir)/charsets/README $(distdir)/charsets $(INSTALL_DATA) $(srcdir)/charsets/Index.xml $(distdir)/charsets @@ -39,11 +39,11 @@ install-data-local: for lang in @AVAILABLE_LANGUAGES@; \ do \ $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/$$lang; \ - $(INSTALL_DATA) $(srcdir)/$$lang/errmsg.sys \ + $(INSTALL_DATA) $(builddir)/$$lang/errmsg.sys \ $(DESTDIR)$(pkgdatadir)/$$lang/errmsg.sys; \ done $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/charsets - $(INSTALL_DATA) $(srcdir)/errmsg.txt \ + $(INSTALL_DATA) $(builddir)/errmsg.txt \ $(DESTDIR)$(pkgdatadir)/errmsg.txt; \ $(INSTALL_DATA) $(srcdir)/charsets/README $(DESTDIR)$(pkgdatadir)/charsets/README $(INSTALL_DATA) $(srcdir)/charsets/*.xml $(DESTDIR)$(pkgdatadir)/charsets @@ -53,7 +53,7 @@ uninstall-local: @RM@ -f -r $(DESTDIR)$(pkgdatadir) distclean-local: - @RM@ -f */errmsg.sys + @RM@ -f $(builddir)/*/errmsg.sys # Do nothing link_sources: diff --git a/storage/ndb/src/common/util/Makefile.am b/storage/ndb/src/common/util/Makefile.am index 5379a425c49..5cf02fed12f 100644 --- a/storage/ndb/src/common/util/Makefile.am +++ b/storage/ndb/src/common/util/Makefile.am @@ -37,7 +37,7 @@ testBitmask_LDFLAGS = @ndb_bin_am_ldflags@ \ testBitmask.cpp : Bitmask.cpp rm -f testBitmask.cpp - @LN_CP_F@ Bitmask.cpp testBitmask.cpp + @LN_CP_F@ $(srcdir)/Bitmask.cpp testBitmask.cpp testBitmask.o: $(testBitmask_SOURCES) $(CXXCOMPILE) -c $(INCLUDES) -D__TEST_BITMASK__ $< From a4dd7f95c8a355009f317cff214568f220f0b6db Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Sat, 13 Feb 2010 08:35:14 -0200 Subject: [PATCH 53/96] Bug#50624: crash in check_table_access during call procedure This bug is just one facet of stored routines not being able to detect changes in meta-data (WL#4179). This particular problem can be triggered within a single session due to the improper management of the pre-locking list if the view is expanded after the pre-locking list is calculated. Since the overall solution for the meta-data detection issue is planned for a later release, for now a workaround is used to fix this particular aspect that only involves a single session. The workaround is to flush the thread-local stored routine cache every time a view is created or modified, causing locally cached routines to be re-evaluated upon invocation. --- mysql-test/r/sp-bugs.result | 14 ++++++++++++++ mysql-test/t/sp-bugs.test | 21 +++++++++++++++++++++ sql/sp_cache.cc | 5 +++-- sql/sql_view.cc | 13 +++++-------- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/sp-bugs.result b/mysql-test/r/sp-bugs.result index 38ddab52b8a..2374b433fba 100644 --- a/mysql-test/r/sp-bugs.result +++ b/mysql-test/r/sp-bugs.result @@ -59,4 +59,18 @@ CALL p1 (); ERROR HY000: Trigger does not exist DROP TABLE t1; DROP PROCEDURE p1; +# +# Bug#50423: Crash on second call of a procedure dropping a trigger +# +DROP TABLE IF EXISTS t1; +DROP TRIGGER IF EXISTS tr1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1 (f1 INTEGER); +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1; +CREATE PROCEDURE p1 () DROP TRIGGER tr1; +CALL p1 (); +CALL p1 (); +ERROR HY000: Trigger does not exist +DROP TABLE t1; +DROP PROCEDURE p1; End of 5.1 tests diff --git a/mysql-test/t/sp-bugs.test b/mysql-test/t/sp-bugs.test index 1eb283f7874..8aa0791e265 100644 --- a/mysql-test/t/sp-bugs.test +++ b/mysql-test/t/sp-bugs.test @@ -80,4 +80,25 @@ CALL p1 (); DROP TABLE t1; DROP PROCEDURE p1; +--echo # +--echo # Bug#50423: Crash on second call of a procedure dropping a trigger +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TRIGGER IF EXISTS tr1; +DROP PROCEDURE IF EXISTS p1; +--enable_warnings + +CREATE TABLE t1 (f1 INTEGER); +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1; +CREATE PROCEDURE p1 () DROP TRIGGER tr1; + +CALL p1 (); +--error ER_TRG_DOES_NOT_EXIST +CALL p1 (); + +DROP TABLE t1; +DROP PROCEDURE p1; + --echo End of 5.1 tests diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index b8209a373a2..12d21aee22c 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -175,8 +175,9 @@ sp_head *sp_cache_lookup(sp_cache **cp, sp_name *name) sp_cache_invalidate() NOTE - This is called when a VIEW definition is modifed. We can't destroy sp_head - objects here as one may modify VIEW definitions from prelocking-free SPs. + This is called when a VIEW definition is created or modified (and in some + other contexts). We can't destroy sp_head objects here as one may modify + VIEW definitions from prelocking-free SPs. */ void sp_cache_invalidate() diff --git a/sql/sql_view.cc b/sql/sql_view.cc index c6d412112c2..c66990c54c6 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -400,17 +400,14 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, DBUG_ASSERT(!lex->proc_list.first && !lex->result && !lex->param_list.elements); - if (mode != VIEW_CREATE_NEW) + if (mode == VIEW_ALTER && fill_defined_view_parts(thd, view)) { - if (mode == VIEW_ALTER && - fill_defined_view_parts(thd, view)) - { - res= TRUE; - goto err; - } - sp_cache_invalidate(); + res= TRUE; + goto err; } + sp_cache_invalidate(); + if (!lex->definer) { /* From 780566d4c5491f51cd9d058a8a2294462e3c5bbe Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 15 Feb 2010 10:54:27 +0200 Subject: [PATCH 54/96] Addendum 2 for bug #46175: NULL read_view and consistent read assertion Fixed a compilation warning. --- sql/sql_select.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.h b/sql/sql_select.h index 8d3520bf9c8..b39827ef61b 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -769,7 +769,7 @@ protected: if ((res= item->save_in_field(to_field, 1))) { if (!err) - err= res; + err= res < 0 ? 1 : res; /* 1=STORE_KEY_FATAL */ } /* Item::save_in_field() may call Item::val_xxx(). And if this is a subquery @@ -779,7 +779,7 @@ protected: err= 1; /* STORE_KEY_FATAL */ } null_key= to_field->is_null() || item->null_value; - return ((err < 0 || err > 2) ? STORE_KEY_FATAL : (store_key_result) err); + return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err); } }; From d2bdeb8cc4ed402e66e1a56ea78877b42bb539c3 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 16 Feb 2010 13:13:49 +0400 Subject: [PATCH 55/96] Bug#50591 bit(31) causes Duplicate entry '1-NULL' for key 'group_key' The problem is that during temporary table creation uneven bits are not taken into account for hidden fields. It leads to incorrect calculation&allocation of null bytes size for table record. And if grouped value is null we set wrong bit for this value(see end_update()). Fixed by adding separate calculation of uneven bit for hidden fields. --- mysql-test/r/type_bit.result | 15 +++++++++++++++ mysql-test/t/type_bit.test | 13 +++++++++++++ sql/sql_select.cc | 17 +++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 51feab0a421..9f32a10a3fb 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -785,4 +785,19 @@ t1 CREATE TABLE `t1` ( KEY `a` (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +# +# Bug#50591 bit(31) causes Duplicate entry '1-NULL' for key 'group_key' +# +CREATE TABLE t1(a INT, b BIT(7) NOT NULL); +INSERT INTO t1 VALUES (NULL, 0),(NULL, 0); +SELECT SUM(a) FROM t1 GROUP BY b, a; +SUM(a) +NULL +DROP TABLE t1; +CREATE TABLE t1(a INT, b BIT(7) NOT NULL, c BIT(8) NOT NULL); +INSERT INTO t1 VALUES (NULL, 0, 0),(NULL, 0, 0); +SELECT SUM(a) FROM t1 GROUP BY c, b, a; +SUM(a) +NULL +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 530389b3ab9..8bedf9357ef 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -425,4 +425,17 @@ select hex(a) from t1; show create table t1; drop table t1; +--echo # +--echo # Bug#50591 bit(31) causes Duplicate entry '1-NULL' for key 'group_key' +--echo # +CREATE TABLE t1(a INT, b BIT(7) NOT NULL); +INSERT INTO t1 VALUES (NULL, 0),(NULL, 0); +SELECT SUM(a) FROM t1 GROUP BY b, a; +DROP TABLE t1; + +CREATE TABLE t1(a INT, b BIT(7) NOT NULL, c BIT(8) NOT NULL); +INSERT INTO t1 VALUES (NULL, 0, 0),(NULL, 0, 0); +SELECT SUM(a) FROM t1 GROUP BY c, b, a; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a3ce50fe4ee..52f9aae7a0c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9822,7 +9822,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, KEY_PART_INFO *key_part_info; Item **copy_func; MI_COLUMNDEF *recinfo; - uint total_uneven_bit_length= 0; + /* + total_uneven_bit_length is uneven bit length for visible fields + hidden_uneven_bit_length is uneven bit length for hidden fields + */ + uint total_uneven_bit_length= 0, hidden_uneven_bit_length= 0; bool force_copy_fields= param->force_copy_fields; /* Treat sum functions as normal ones when loose index scan is used. */ save_sum_fields|= param->precomputed_group_by; @@ -10099,6 +10103,14 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, */ param->hidden_field_count= fieldnr; null_count= 0; + /* + On last hidden field we store uneven bit length in + hidden_uneven_bit_length and proceed calculation of + uneven bits for visible fields into + total_uneven_bit_length variable. + */ + hidden_uneven_bit_length= total_uneven_bit_length; + total_uneven_bit_length= 0; } } DBUG_ASSERT(fieldnr == (uint) (reg_field - table->field)); @@ -10144,7 +10156,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, else null_count++; } - hidden_null_pack_length=(hidden_null_count+7)/8; + hidden_null_pack_length= (hidden_null_count + 7 + + hidden_uneven_bit_length) / 8; null_pack_length= (hidden_null_pack_length + (null_count + total_uneven_bit_length + 7) / 8); reclength+=null_pack_length; From 1e7700b8b8d3e0f5514355dc11451def8aba0287 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 16 Feb 2010 11:42:22 +0100 Subject: [PATCH 56/96] post push fix for bug#42438, did not compile on non debug, due to ifdef of include file --- sql/sql_table.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b201fbc3d3e..871b2f2d552 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -22,9 +22,7 @@ #include "sp_head.h" #include "sql_trigger.h" #include "sql_show.h" -#if defined(ENABLED_DEBUG_SYNC) #include "debug_sync.h" -#endif #ifdef __WIN__ #include From 1c2e33b1fc7abd19128031160c4cb58dd8eb768f Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Wed, 17 Feb 2010 11:13:15 +0100 Subject: [PATCH 57/96] Fix a bug in the RPM spec file: A "%define" is no shell command, so it must not be the only line in the "then" or "else" branch of an "if". Add a ':' line to make the branch non-empty. --- support-files/mysql.spec.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 905919f053a..18e55d7a06a 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -535,6 +535,7 @@ fi if expr "$CC" : ".*icc.*" > /dev/null ; then %define WITH_LIBGCC 0 + : elif expr "$CC" : ".*gcc.*" > /dev/null ; then libgcc=`$CC $CFLAGS --print-libgcc-file` @@ -544,9 +545,11 @@ then install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a else %define WITH_LIBGCC 0 + : fi else %define WITH_LIBGCC 0 + : fi ############################################################################## From c8f278485bdadbd3fdc1382ea27d6e35a8627fb4 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Wed, 17 Feb 2010 16:13:42 +0400 Subject: [PATCH 58/96] Bug#33717 INSERT...(default) fails for enum. Crashes CSV tables, loads spaces for MyISAM Table corruption happens during table reading in ha_tina::find_current_row() func. Field::store() method returns error(true) if stored value is 0. The fix: added special case for enum type which correctly processes 0 value. Additional fix: INSERT...(default) and INSERT...() have the same behaviour now for enum type. --- mysql-test/r/csv.result | 31 +++++++++++++++++++------------ mysql-test/r/default.result | 3 +-- mysql-test/t/csv.test | 18 +++++++++--------- sql/item.cc | 3 ++- storage/csv/ha_tina.cc | 16 ++++++++++++++-- 5 files changed, 45 insertions(+), 26 deletions(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 4b96f5a5ed0..e2eebdfc992 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5394,17 +5394,24 @@ select * from t1; ERROR HY000: File 'MYSQLD_DATADIR/test/t1.CSV' not found (Errcode: 2) unlock tables; drop table t1; -create table t1(a enum ('a') not null) engine=csv; -insert into t1 values (2); +CREATE TABLE t1 (e enum('foo','bar') NOT NULL) ENGINE = CSV; +INSERT INTO t1 VALUES(); +INSERT INTO t1 VALUES(default); +INSERT INTO t1 VALUES(0); Warnings: -Warning 1265 Data truncated for column 'a' at row 1 -select * from t1 limit 1; -ERROR HY000: Table 't1' is marked as crashed and should be repaired -repair table t1; -Table Op Msg_type Msg_text -test.t1 repair Warning Data truncated for column 'a' at row 1 -test.t1 repair status OK -select * from t1 limit 1; -a -drop table t1; +Warning 1265 Data truncated for column 'e' at row 1 +INSERT INTO t1 VALUES(3); +Warnings: +Warning 1265 Data truncated for column 'e' at row 1 +INSERT INTO t1 VALUES(-1); +Warnings: +Warning 1265 Data truncated for column 'e' at row 1 +SELECT * FROM t1; +e +foo +foo + + + +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/r/default.result b/mysql-test/r/default.result index 5b0d82407a2..9afffe4c3bc 100644 --- a/mysql-test/r/default.result +++ b/mysql-test/r/default.result @@ -180,7 +180,6 @@ insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:0 insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, 4); Warnings: Warning 1364 Field 'a' doesn't have a default value -Warning 1364 Field 'b' doesn't have a default value Warning 1364 Field 'c' doesn't have a default value Warning 1364 Field 'd' doesn't have a default value Warning 1364 Field 'e' doesn't have a default value @@ -193,7 +192,7 @@ a b c d e f g h i x two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 1 small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 2 two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 3 - 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 4 + small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 4 drop table bug20691; create table t1 (id int not null); insert into t1 values(default); diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index cdf274190dd..b31fa83588b 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1807,16 +1807,16 @@ unlock tables; drop table t1; # -# Bug#41441 repair csv table crashes debug server +# Bug#33717 INSERT...(default) fails for enum. Crashes CSV tables, loads spaces for MyISAM # -# Note: The test should be removed after Bug#33717 is fixed +CREATE TABLE t1 (e enum('foo','bar') NOT NULL) ENGINE = CSV; +INSERT INTO t1 VALUES(); +INSERT INTO t1 VALUES(default); +INSERT INTO t1 VALUES(0); +INSERT INTO t1 VALUES(3); +INSERT INTO t1 VALUES(-1); +SELECT * FROM t1; +DROP TABLE t1; -create table t1(a enum ('a') not null) engine=csv; -insert into t1 values (2); ---error ER_CRASHED_ON_USAGE -select * from t1 limit 1; -repair table t1; -select * from t1 limit 1; -drop table t1; --echo End of 5.1 tests diff --git a/sql/item.cc b/sql/item.cc index df266434f72..f8cca3a0667 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6488,7 +6488,8 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions) { if (!arg) { - if (field_arg->flags & NO_DEFAULT_VALUE_FLAG) + if (field_arg->flags & NO_DEFAULT_VALUE_FLAG && + field_arg->real_type() != MYSQL_TYPE_ENUM) { if (field_arg->reset()) { diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index ca9d5215310..e3bc7f55dd2 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -679,9 +679,21 @@ int ha_tina::find_current_row(uchar *buf) if (read_all || bitmap_is_set(table->read_set, (*field)->field_index)) { + bool is_enum= ((*field)->real_type() == MYSQL_TYPE_ENUM); + /* + Here CHECK_FIELD_WARN checks that all values in the csv file are valid + which is normally the case, if they were written by + INSERT -> ha_tina::write_row. '0' values on ENUM fields are considered + invalid by Field_enum::store() but it can store them on INSERT anyway. + Thus, for enums we silence the warning, as it doesn't really mean + an invalid value. + */ if ((*field)->store(buffer.ptr(), buffer.length(), buffer.charset(), - CHECK_FIELD_WARN)) - goto err; + is_enum ? CHECK_FIELD_IGNORE : CHECK_FIELD_WARN)) + { + if (!is_enum) + goto err; + } if ((*field)->flags & BLOB_FLAG) { Field_blob *blob= *(Field_blob**) field; From 6a27e29f4061ed5333f4402c3c5d04c500ce66af Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 17 Feb 2010 12:00:18 -0700 Subject: [PATCH 59/96] Request that internals mailing list be notified if the MySQL version formatting changes --- configure.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index c2ee247397a..8df17c99614 100644 --- a/configure.in +++ b/configure.in @@ -5,9 +5,15 @@ AC_PREREQ(2.52)dnl Minimum Autoconf version required. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM -# The Docs Makefile.am parses this line! -# remember to also change ndb version below and update version.c in ndb + +dnl Various people throughout the community may parse configure.in to +dnl get the MySQL version from the source branch. If the formatting +dnl of this line is going to be changed, please announce the change to +dnl internals@lists.mysql.com in advance of pushing the change. +dnl +dnl Remember to also change NDB_VERSION_* below and update version.c in ndb AM_INIT_AUTOMAKE(mysql, 5.0.91) + AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 From ae12a723605f5059d73ee9284fd78ecc7583fac2 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 18 Feb 2010 10:48:15 +0200 Subject: [PATCH 60/96] Bug #51049: main.bug39022 fails in mysql-trunk-merge Fixed the test to behave correctly with ps-protocol and binlog format row. --- mysql-test/include/not_binlog_format_row.inc | 4 ++++ mysql-test/r/bug39022.result | 2 +- mysql-test/t/bug39022.test | 13 +++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 mysql-test/include/not_binlog_format_row.inc diff --git a/mysql-test/include/not_binlog_format_row.inc b/mysql-test/include/not_binlog_format_row.inc new file mode 100644 index 00000000000..f9354e7cd33 --- /dev/null +++ b/mysql-test/include/not_binlog_format_row.inc @@ -0,0 +1,4 @@ +if (`SELECT @@binlog_format = 'ROW'`) +{ + skip Test cannot run with binlog_format row; +} diff --git a/mysql-test/r/bug39022.result b/mysql-test/r/bug39022.result index 1c02d7873e4..5963709aa2a 100644 --- a/mysql-test/r/bug39022.result +++ b/mysql-test/r/bug39022.result @@ -28,5 +28,5 @@ SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d); ERROR 40001: Deadlock found when trying to get lock; try restarting transaction # in thread2 d -# in default +# in thread1; DROP TABLE t1,t2; diff --git a/mysql-test/t/bug39022.test b/mysql-test/t/bug39022.test index 1a1d10f5592..268b207e0e5 100644 --- a/mysql-test/t/bug39022.test +++ b/mysql-test/t/bug39022.test @@ -1,5 +1,6 @@ -- source include/have_log_bin.inc -- source include/have_innodb.inc +-- source include/not_binlog_format_row.inc --echo # --echo # Bug #39022: Mysql randomly crashing in lock_sec_rec_cons_read_sees @@ -49,10 +50,14 @@ connection thread2; --echo # in thread2 REAP; -connection default; ---echo # in default - -disconnect thread1; disconnect thread2; +--source include/wait_until_disconnected.inc + +connection thread1; +--echo # in thread1; +disconnect thread1; +--source include/wait_until_disconnected.inc + +connection default; DROP TABLE t1,t2; From c55ba71ec10a3158776c2a54f08350d28bff1037 Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Thu, 18 Feb 2010 17:02:17 +0000 Subject: [PATCH 61/96] Bug#48525: trigger changes "Column 'id' cannot be null" behaviour CHECK_FIELD_IGNORE was treated as CHECK_FIELD_ERROR_FOR_NULL; UPDATE...SET...NULL on NOT NULL fields behaved differently after a trigger. Now distinguishes between IGNORE and ERROR_FOR_NULL and save/restores check-field options. --- mysql-test/r/trigger.result | 17 +++++++++++++++++ mysql-test/t/trigger.test | 13 +++++++++++++ sql/field_conv.cc | 26 ++++++++++++++++++-------- sql/sp_head.cc | 1 + sql/sql_class.cc | 4 ++++ sql/sql_class.h | 1 + sql/sql_insert.cc | 2 +- 7 files changed, 55 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 4476735735c..6255e5fcceb 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -2087,4 +2087,21 @@ ERROR 42S02: Table 'test.a_nonextisting_table' doesn't exist SELECT * FROM t2; a b DROP TABLE t1, t2; +CREATE TABLE t1 (id INT NOT NULL); +CREATE TABLE t2 (id INT NOT NULL); +INSERT t1 VALUES (1),(2),(3); +UPDATE t1 SET id=NULL; +Warnings: +Warning 1048 Column 'id' cannot be null +Warning 1048 Column 'id' cannot be null +Warning 1048 Column 'id' cannot be null +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW +INSERT INTO t2 VALUES (3); +UPDATE t1 SET id=NULL; +Warnings: +Warning 1048 Column 'id' cannot be null +Warning 1048 Column 'id' cannot be null +Warning 1048 Column 'id' cannot be null +DROP TRIGGER t1_bu; +DROP TABLE t1,t2; End of 5.1 tests. diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 1e55f9d5993..db41a12a9ac 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2396,4 +2396,17 @@ SELECT * FROM t2; DROP TABLE t1, t2; +# +# Bug #48525: trigger changes "Column 'id' cannot be null" behaviour +# +CREATE TABLE t1 (id INT NOT NULL); +CREATE TABLE t2 (id INT NOT NULL); +INSERT t1 VALUES (1),(2),(3); +UPDATE t1 SET id=NULL; +CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW + INSERT INTO t2 VALUES (3); +UPDATE t1 SET id=NULL; +DROP TRIGGER t1_bu; +DROP TABLE t1,t2; + --echo End of 5.1 tests. diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 3574534722e..0bffde9671a 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -122,13 +122,18 @@ set_field_to_null(Field *field) return 0; } field->reset(); - if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN) - { + switch (field->table->in_use->count_cuted_fields) { + case CHECK_FIELD_WARN: field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + /* fall through */ + case CHECK_FIELD_IGNORE: return 0; + case CHECK_FIELD_ERROR_FOR_NULL: + if (!field->table->in_use->no_errors) + my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); + return -1; } - if (!field->table->in_use->no_errors) - my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); + DBUG_ASSERT(0); // impossible return -1; } @@ -178,13 +183,18 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions) field->table->auto_increment_field_not_null= FALSE; return 0; // field is set in fill_record() } - if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN) - { + switch (field->table->in_use->count_cuted_fields) { + case CHECK_FIELD_WARN: field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_BAD_NULL_ERROR, 1); + /* fall through */ + case CHECK_FIELD_IGNORE: return 0; + case CHECK_FIELD_ERROR_FOR_NULL: + if (!field->table->in_use->no_errors) + my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); + return -1; } - if (!field->table->in_use->no_errors) - my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); + DBUG_ASSERT(0); // impossible return -1; } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 8a626cabd90..11d5e5f830b 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -3009,6 +3009,7 @@ int sp_instr_set_trigger_field::execute(THD *thd, uint *nextp) { DBUG_ENTER("sp_instr_set_trigger_field::execute"); + thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; DBUG_RETURN(m_lex_keeper.reset_lex_and_exec_core(thd, nextp, TRUE, this)); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 673fc9b78e6..266064f9f08 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3100,6 +3100,7 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup, } #endif + backup->count_cuted_fields= count_cuted_fields; backup->options= options; backup->in_sub_stmt= in_sub_stmt; backup->enable_slow_log= enable_slow_log; @@ -3137,6 +3138,7 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup, void THD::restore_sub_statement_state(Sub_statement_state *backup) { + DBUG_ENTER("THD::restore_sub_statement_state"); #ifndef EMBEDDED_LIBRARY /* BUG#33029, if we are replicating from a buggy master, restore auto_inc_intervals_forced so that the top statement can use the @@ -3163,6 +3165,7 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) /* ha_release_savepoint() never returns error. */ (void)ha_release_savepoint(this, sv); } + count_cuted_fields= backup->count_cuted_fields; transaction.savepoints= backup->savepoints; options= backup->options; in_sub_stmt= backup->in_sub_stmt; @@ -3192,6 +3195,7 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) */ examined_row_count+= backup->examined_row_count; cuted_fields+= backup->cuted_fields; + DBUG_VOID_RETURN; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 032985dc44e..2ddd9358382 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -995,6 +995,7 @@ public: bool enable_slow_log; bool last_insert_id_used; SAVEPOINT *savepoints; + enum enum_check_fields count_cuted_fields; }; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 1f4ca90157f..35c24e7571e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3158,7 +3158,7 @@ bool select_insert::send_data(List &values) thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields store_values(values); - thd->count_cuted_fields= CHECK_FIELD_IGNORE; + thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; if (thd->is_error()) { table->auto_increment_field_not_null= FALSE; From 13d7179a1921baa9a233d936b09087f40f38fe8d Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Fri, 19 Feb 2010 13:45:25 +0100 Subject: [PATCH 62/96] Fixed incomplete merge of 48878, embedded tests fail on Windows --- mysql-test/lib/My/ConfigFactory.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm index c4d68e7127c..41b595c80e8 100644 --- a/mysql-test/lib/My/ConfigFactory.pm +++ b/mysql-test/lib/My/ConfigFactory.pm @@ -357,11 +357,14 @@ sub post_check_client_group { if (IS_WINDOWS) { - # Shared memory base may or may not be defined (e.g not defined in embedded) - my $shm = $group_to_copy_from->option("shared-memory-base-name"); - if (defined $shm) + if (! $self->{ARGS}->{embedded}) { - $config->insert($client_group_name,"shared-memory-base-name", $shm->value()); + # Shared memory base may or may not be defined (e.g not defined in embedded) + my $shm = $group_to_copy_from->option("shared-memory-base-name"); + if (defined $shm) + { + $config->insert($client_group_name,"shared-memory-base-name", $shm->value()); + } } } } From 3678457d3c707b341a7461d4d2c0e4d71e75e4f9 Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Fri, 19 Feb 2010 15:16:43 +0000 Subject: [PATCH 63/96] Bug#49487: crash with explain extended and group_concat in a derived table When EXPLAIN EXTENDED tries to print column names, it checks whether the referenced table is CONST (in which case, the column's value rather than its name will be printed). If no proper table is reference (i.e. because a derived table was used that has since gone out of scope), this will fail spectacularly. This ports an equivalent of the fix for Bug 43354. --- mysql-test/r/func_gconcat.result | 17 +++++++++++++++++ mysql-test/t/func_gconcat.test | 15 +++++++++++++++ sql/item_sum.cc | 4 +++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 4dddc35e8a8..d69a340cddb 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -972,4 +972,21 @@ GROUP BY t1.a 1 1 DROP TABLE t1, t2; +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (),(); +EXPLAIN EXTENDED SELECT 1 FROM +(SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY system NULL NULL NULL NULL 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort; Distinct +2 DERIVED td ALL NULL NULL NULL NULL 2 Distinct +Warnings: +Note 1003 select 1 AS `1` from (select distinct group_concat(`test`.`td`.`f1` separator ',') AS `GROUP_CONCAT(td.f1)` from `test`.`t1` join `test`.`t1` `td` group by `test`.`td`.`f1`) `d` join `test`.`t1` +SELECT 1 FROM +(SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1; +1 +1 +1 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 816ac9c2959..1cbf045e95d 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -693,4 +693,19 @@ SELECT 1 FROM t1 WHERE t1.a NOT IN DROP TABLE t1, t2; +# +# Bug #49487: crash with explain extended and group_concat in a derived table +# + +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (),(); + +EXPLAIN EXTENDED SELECT 1 FROM + (SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1; + +SELECT 1 FROM + (SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1; + +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index dde8fe29e5a..4c2bde90100 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3538,6 +3538,8 @@ String* Item_func_group_concat::val_str(String* str) void Item_func_group_concat::print(String *str) { + /* orig_args is not filled with valid values until fix_fields() */ + Item **pargs= fixed ? orig_args : args; str->append(STRING_WITH_LEN("group_concat(")); if (distinct) str->append(STRING_WITH_LEN("distinct ")); @@ -3545,7 +3547,7 @@ void Item_func_group_concat::print(String *str) { if (i) str->append(','); - args[i]->print(str); + pargs[i]->print(str); } if (arg_count_order) { From 5181551dee3306bcee410a31738e1a3ee9c2c501 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Mon, 22 Feb 2010 14:23:47 +0100 Subject: [PATCH 64/96] Bug #43414 Parenthesis (and other) warnings compiling MySQL with gcc 4.3.2 This is the final patch in the context of this bug. --- cmd-line-utils/readline/rlmbutil.h | 4 ++-- cmd-line-utils/readline/text.c | 2 +- extra/yassl/include/yassl_error.hpp | 2 +- extra/yassl/src/ssl.cpp | 2 +- extra/yassl/src/yassl_error.cpp | 2 +- sql/log_event.cc | 2 +- sql/log_event_old.cc | 2 +- sql/sql_update.cc | 3 ++- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cmd-line-utils/readline/rlmbutil.h b/cmd-line-utils/readline/rlmbutil.h index dd317e2a090..6ca8fdde92b 100644 --- a/cmd-line-utils/readline/rlmbutil.h +++ b/cmd-line-utils/readline/rlmbutil.h @@ -109,8 +109,8 @@ extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int)); extern wchar_t _rl_char_value PARAMS((char *, int)); extern int _rl_walphabetic PARAMS((wchar_t)); -#define _rl_to_wupper(wc) (iswlower (wc) ? towupper (wc) : (wc)) -#define _rl_to_wlower(wc) (iswupper (wc) ? towlower (wc) : (wc)) +#define _rl_to_wupper(wc) (iswlower (wc) ? (wchar_t)towupper (wc) : (wc)) +#define _rl_to_wlower(wc) (iswupper (wc) ? (wchar_t)towlower (wc) : (wc)) #define MB_NEXTCHAR(b,s,c,f) \ ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) \ diff --git a/cmd-line-utils/readline/text.c b/cmd-line-utils/readline/text.c index 272848c798c..bb0f5d97160 100644 --- a/cmd-line-utils/readline/text.c +++ b/cmd-line-utils/readline/text.c @@ -614,7 +614,7 @@ rl_arrow_keys (count, c) #ifdef HANDLE_MULTIBYTE static char pending_bytes[MB_LEN_MAX]; static int pending_bytes_length = 0; -static mbstate_t ps = {0}; +static mbstate_t ps; #endif /* Insert the character C at the current location, moving point forward. diff --git a/extra/yassl/include/yassl_error.hpp b/extra/yassl/include/yassl_error.hpp index 63fa9a761ba..d2473fb3e2b 100644 --- a/extra/yassl/include/yassl_error.hpp +++ b/extra/yassl/include/yassl_error.hpp @@ -64,7 +64,7 @@ enum YasslError { enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib }; enum { MAX_ERROR_SZ = 80 }; -void SetErrorString(YasslError, char*); +void SetErrorString(unsigned long, char*); /* remove for now, if go back to exceptions use this wrapper // Base class for all yaSSL exceptions diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 29aa034f885..4d8b6ac69b8 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -991,7 +991,7 @@ char* ERR_error_string(unsigned long errNumber, char* buffer) static char* msg = (char*)"Please supply a buffer for error string"; if (buffer) { - SetErrorString(YasslError(errNumber), buffer); + SetErrorString(errNumber, buffer); return buffer; } diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index a1ef8578da6..dd30348cd93 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -55,7 +55,7 @@ Library Error::get_lib() const */ -void SetErrorString(YasslError error, char* buffer) +void SetErrorString(unsigned long error, char* buffer) { using namespace TaoCrypt; const int max = MAX_ERROR_SZ; // shorthand diff --git a/sql/log_event.cc b/sql/log_event.cc index de395f3d4c7..7de986b325b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -8753,7 +8753,7 @@ static bool record_compare(TABLE *table) DBUG_DUMP("record[1]", table->record[1], table->s->reclength); bool result= FALSE; - uchar saved_x[2], saved_filler[2]; + uchar saved_x[2]= {0, 0}, saved_filler[2]= {0, 0}; if (table->s->null_bytes > 0) { diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 313916c9818..0f501fd1514 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -337,7 +337,7 @@ static bool record_compare(TABLE *table) */ bool result= FALSE; - uchar saved_x[2], saved_filler[2]; + uchar saved_x[2]= {0, 0}, saved_filler[2]= {0, 0}; if (table->s->null_bytes > 0) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 84610630d62..63af275cef3 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1283,7 +1283,8 @@ bool mysql_multi_update(THD *thd, if (using_handler) { - Internal_error_handler *top_handler= thd->pop_internal_handler(); + Internal_error_handler *top_handler; + top_handler= thd->pop_internal_handler(); DBUG_ASSERT(&handler == top_handler); } From 51e47e13173c01174c4e367c7ca2640a6a9dd699 Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Mon, 22 Feb 2010 16:58:56 +0000 Subject: [PATCH 65/96] revert 48525 --- mysql-test/r/trigger.result | 17 ----------------- mysql-test/t/trigger.test | 13 ------------- sql/field_conv.cc | 26 ++++++++------------------ sql/sp_head.cc | 1 - sql/sql_class.cc | 4 ---- sql/sql_class.h | 1 - sql/sql_insert.cc | 2 +- 7 files changed, 9 insertions(+), 55 deletions(-) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 6255e5fcceb..4476735735c 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -2087,21 +2087,4 @@ ERROR 42S02: Table 'test.a_nonextisting_table' doesn't exist SELECT * FROM t2; a b DROP TABLE t1, t2; -CREATE TABLE t1 (id INT NOT NULL); -CREATE TABLE t2 (id INT NOT NULL); -INSERT t1 VALUES (1),(2),(3); -UPDATE t1 SET id=NULL; -Warnings: -Warning 1048 Column 'id' cannot be null -Warning 1048 Column 'id' cannot be null -Warning 1048 Column 'id' cannot be null -CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW -INSERT INTO t2 VALUES (3); -UPDATE t1 SET id=NULL; -Warnings: -Warning 1048 Column 'id' cannot be null -Warning 1048 Column 'id' cannot be null -Warning 1048 Column 'id' cannot be null -DROP TRIGGER t1_bu; -DROP TABLE t1,t2; End of 5.1 tests. diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index db41a12a9ac..1e55f9d5993 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2396,17 +2396,4 @@ SELECT * FROM t2; DROP TABLE t1, t2; -# -# Bug #48525: trigger changes "Column 'id' cannot be null" behaviour -# -CREATE TABLE t1 (id INT NOT NULL); -CREATE TABLE t2 (id INT NOT NULL); -INSERT t1 VALUES (1),(2),(3); -UPDATE t1 SET id=NULL; -CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW - INSERT INTO t2 VALUES (3); -UPDATE t1 SET id=NULL; -DROP TRIGGER t1_bu; -DROP TABLE t1,t2; - --echo End of 5.1 tests. diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 0bffde9671a..3574534722e 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -122,18 +122,13 @@ set_field_to_null(Field *field) return 0; } field->reset(); - switch (field->table->in_use->count_cuted_fields) { - case CHECK_FIELD_WARN: + if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN) + { field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); - /* fall through */ - case CHECK_FIELD_IGNORE: return 0; - case CHECK_FIELD_ERROR_FOR_NULL: - if (!field->table->in_use->no_errors) - my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); - return -1; } - DBUG_ASSERT(0); // impossible + if (!field->table->in_use->no_errors) + my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); return -1; } @@ -183,18 +178,13 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions) field->table->auto_increment_field_not_null= FALSE; return 0; // field is set in fill_record() } - switch (field->table->in_use->count_cuted_fields) { - case CHECK_FIELD_WARN: + if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN) + { field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_BAD_NULL_ERROR, 1); - /* fall through */ - case CHECK_FIELD_IGNORE: return 0; - case CHECK_FIELD_ERROR_FOR_NULL: - if (!field->table->in_use->no_errors) - my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); - return -1; } - DBUG_ASSERT(0); // impossible + if (!field->table->in_use->no_errors) + my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); return -1; } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 11d5e5f830b..8a626cabd90 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -3009,7 +3009,6 @@ int sp_instr_set_trigger_field::execute(THD *thd, uint *nextp) { DBUG_ENTER("sp_instr_set_trigger_field::execute"); - thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; DBUG_RETURN(m_lex_keeper.reset_lex_and_exec_core(thd, nextp, TRUE, this)); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 266064f9f08..673fc9b78e6 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3100,7 +3100,6 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup, } #endif - backup->count_cuted_fields= count_cuted_fields; backup->options= options; backup->in_sub_stmt= in_sub_stmt; backup->enable_slow_log= enable_slow_log; @@ -3138,7 +3137,6 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup, void THD::restore_sub_statement_state(Sub_statement_state *backup) { - DBUG_ENTER("THD::restore_sub_statement_state"); #ifndef EMBEDDED_LIBRARY /* BUG#33029, if we are replicating from a buggy master, restore auto_inc_intervals_forced so that the top statement can use the @@ -3165,7 +3163,6 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) /* ha_release_savepoint() never returns error. */ (void)ha_release_savepoint(this, sv); } - count_cuted_fields= backup->count_cuted_fields; transaction.savepoints= backup->savepoints; options= backup->options; in_sub_stmt= backup->in_sub_stmt; @@ -3195,7 +3192,6 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) */ examined_row_count+= backup->examined_row_count; cuted_fields+= backup->cuted_fields; - DBUG_VOID_RETURN; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 2ddd9358382..032985dc44e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -995,7 +995,6 @@ public: bool enable_slow_log; bool last_insert_id_used; SAVEPOINT *savepoints; - enum enum_check_fields count_cuted_fields; }; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 35c24e7571e..1f4ca90157f 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3158,7 +3158,7 @@ bool select_insert::send_data(List &values) thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields store_values(values); - thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; + thd->count_cuted_fields= CHECK_FIELD_IGNORE; if (thd->is_error()) { table->auto_increment_field_not_null= FALSE; From 0d41207c591921345b4b2a00d0da8379de69ab50 Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Tue, 23 Feb 2010 12:17:20 +0100 Subject: [PATCH 66/96] Revert of a change introduced by Bug#47974 "TYPE=storage_engine" is deprecated, and will be removed in the Celosia release of MySQL. Since the option is present in the Betony release and the version number of Celosia is still not decided, we need to bump the deprecation version number back up to "6.0". --- sql/sql_yacc.yy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 37150bf835d..8dc08f8425f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4596,7 +4596,7 @@ create_table_option: | TYPE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; - WARN_DEPRECATED(yythd, "5.4.4", "TYPE=storage_engine", + WARN_DEPRECATED(yythd, "6.0", "TYPE=storage_engine", "'ENGINE=storage_engine'"); Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; } From a341ec7400500e14f9d8aa8343698b6f70090172 Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Tue, 23 Feb 2010 12:33:20 +0100 Subject: [PATCH 67/96] Clean-up in the sys_vars test suite after WL#5154 and WL5182 Two result files in the sys_vars suite wasn't properly updated after the change in deprecation text --- mysql-test/suite/sys_vars/r/log_basic.result | 2 +- ...og_bin_trust_routine_creators_basic.result | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/log_basic.result b/mysql-test/suite/sys_vars/r/log_basic.result index 18a12b72437..e7696d4f115 100644 --- a/mysql-test/suite/sys_vars/r/log_basic.result +++ b/mysql-test/suite/sys_vars/r/log_basic.result @@ -18,4 +18,4 @@ VARIABLE_VALUE OFF SET @@global.log= @start_log; Warnings: -Warning 1287 The syntax '@@log' is deprecated and will be removed in MySQL 7.0. Please use '@@general_log' instead +Warning 1287 '@@log' is deprecated and will be removed in a future release. Please use '@@general_log' instead diff --git a/mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result b/mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result index 66e253645b1..3360d4384ff 100644 --- a/mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result +++ b/mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result @@ -5,17 +5,17 @@ SELECT @start_global_value; '#--------------------FN_DYNVARS_064_01-------------------------#' SET @@global.log_bin_trust_routine_creators = TRUE; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SET @@global.log_bin_trust_routine_creators = DEFAULT; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 '#--------------------FN_DYNVARS_064_02-------------------------#' SET @@global.log_bin_trust_routine_creators = DEFAULT; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators = 'FALSE'; @@global.log_bin_trust_routine_creators = 'FALSE' 1 @@ -24,37 +24,37 @@ Warning 1292 Truncated incorrect DOUBLE value: 'FALSE' '#--------------------FN_DYNVARS_064_03-------------------------#' SET @@global.log_bin_trust_routine_creators = ON; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 1 SET @@global.log_bin_trust_routine_creators = OFF; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 SET @@global.log_bin_trust_routine_creators = 0; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 SET @@global.log_bin_trust_routine_creators = 1; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 1 SET @@global.log_bin_trust_routine_creators = TRUE; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 1 SET @@global.log_bin_trust_routine_creators = FALSE; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 @@ -70,7 +70,7 @@ SET @@global.log_bin_trust_routine_creators = "OFFF"; ERROR 42000: Variable 'log_bin_trust_routine_creators' can't be set to the value of 'OFFF' SET @@global.log_bin_trust_routine_creators = OF; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 0 @@ -96,14 +96,14 @@ ERROR HY000: Variable 'log_bin_trust_routine_creators' is a GLOBAL variable '#---------------------FN_DYNVARS_064_07----------------------#' SET @@global.log_bin_trust_routine_creators = TRUE; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@log_bin_trust_routine_creators = @@global.log_bin_trust_routine_creators; @@log_bin_trust_routine_creators = @@global.log_bin_trust_routine_creators 1 '#---------------------FN_DYNVARS_064_08----------------------#' SET @@global.log_bin_trust_routine_creators = TRUE; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@log_bin_trust_routine_creators; @@log_bin_trust_routine_creators 1 @@ -115,7 +115,7 @@ SELECT log_bin_trust_routine_creators = @@session.log_bin_trust_routine_creators ERROR 42S22: Unknown column 'log_bin_trust_routine_creators' in 'field list' SET @@global.log_bin_trust_routine_creators = @start_global_value; Warnings: -Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead +Warning 1287 '@@log_bin_trust_routine_creators' is deprecated and will be removed in a future release. Please use '@@log_bin_trust_function_creators' instead SELECT @@global.log_bin_trust_routine_creators; @@global.log_bin_trust_routine_creators 1 From 13c32771e7e46573c3e39973f5af20cb9560867a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 24 Feb 2010 13:15:34 +0400 Subject: [PATCH 68/96] Backporting WL#1213 --- config/ac-macros/character_sets.m4 | 65 +- include/config-win.h | 3 + include/m_ctype.h | 62 +- mysql-test/include/ctype_datetime.inc | 11 + mysql-test/include/ctype_like.inc | 50 + mysql-test/include/have_utf16.inc | 4 + mysql-test/include/have_utf32.inc | 4 + mysql-test/include/have_utf8mb4.inc | 7 + mysql-test/r/ctype_ldml.result | 33 + mysql-test/r/ctype_many.result | 56 + mysql-test/r/ctype_utf16.result | 1038 +++++ mysql-test/r/ctype_utf16_uca.result | 2373 ++++++++++ mysql-test/r/ctype_utf32.result | 1052 +++++ mysql-test/r/ctype_utf32_uca.result | 2373 ++++++++++ mysql-test/r/ctype_utf8.result | 14 + mysql-test/r/ctype_utf8mb4.result | 2250 ++++++++++ mysql-test/r/have_utf16.require | 2 + mysql-test/r/have_utf32.require | 2 + mysql-test/r/have_utf8mb4.require | 2 + mysql-test/std_data/Index.xml | 30 + .../r/character_set_client_basic.result | 10 +- .../r/character_set_connection_basic.result | 2 +- .../r/character_set_database_basic.result | 2 +- .../r/character_set_filesystem_basic.result | 2 +- .../r/character_set_results_basic.result | Bin 16478 -> 16478 bytes .../t/character_set_client_basic.test | 9 + .../t/character_set_connection_basic.test | 3 + .../t/character_set_database_basic.test | 3 + .../t/character_set_filesystem_basic.test | 3 + .../t/character_set_results_basic.test | 3 + mysql-test/t/ctype_ldml.test | 21 + mysql-test/t/ctype_many.test | 73 + mysql-test/t/ctype_utf16.test | 731 +++ mysql-test/t/ctype_utf16_uca.test | 290 ++ mysql-test/t/ctype_utf32.test | 784 ++++ mysql-test/t/ctype_utf32_uca.test | 291 ++ mysql-test/t/ctype_utf8.test | 11 + mysql-test/t/ctype_utf8mb4.test | 1670 +++++++ mysys/charset-def.c | 155 +- mysys/charset.c | 73 +- sql/field.cc | 4 +- sql/item.cc | 11 +- sql/item_strfunc.cc | 33 +- sql/sql_string.cc | 38 +- sql/sql_table.cc | 2 +- strings/ctype-mb.c | 38 +- strings/ctype-uca.c | 1986 +++++++++ strings/ctype-ucs2.c | 3916 ++++++++++++----- strings/ctype-utf8.c | 1054 ++++- 49 files changed, 19441 insertions(+), 1208 deletions(-) create mode 100644 mysql-test/include/ctype_datetime.inc create mode 100644 mysql-test/include/ctype_like.inc create mode 100644 mysql-test/include/have_utf16.inc create mode 100644 mysql-test/include/have_utf32.inc create mode 100644 mysql-test/include/have_utf8mb4.inc create mode 100644 mysql-test/r/ctype_utf16.result create mode 100644 mysql-test/r/ctype_utf16_uca.result create mode 100644 mysql-test/r/ctype_utf32.result create mode 100644 mysql-test/r/ctype_utf32_uca.result create mode 100644 mysql-test/r/ctype_utf8mb4.result create mode 100644 mysql-test/r/have_utf16.require create mode 100644 mysql-test/r/have_utf32.require create mode 100644 mysql-test/r/have_utf8mb4.require create mode 100644 mysql-test/t/ctype_utf16.test create mode 100644 mysql-test/t/ctype_utf16_uca.test create mode 100644 mysql-test/t/ctype_utf32.test create mode 100644 mysql-test/t/ctype_utf32_uca.test create mode 100644 mysql-test/t/ctype_utf8mb4.test diff --git a/config/ac-macros/character_sets.m4 b/config/ac-macros/character_sets.m4 index 24bdd92b083..81967d383ec 100644 --- a/config/ac-macros/character_sets.m4 +++ b/config/ac-macros/character_sets.m4 @@ -13,11 +13,11 @@ define(CHARSETS_AVAILABLE1,armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257) define(CHARSETS_AVAILABLE2,cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8) define(CHARSETS_AVAILABLE3,greek hebrew hp8 keybcs2 koi8r koi8u) define(CHARSETS_AVAILABLE4,latin1 latin2 latin5 latin7 macce macroman) -define(CHARSETS_AVAILABLE5,sjis swe7 tis620 ucs2 ujis utf8) +define(CHARSETS_AVAILABLE5,sjis swe7 tis620 ucs2 ujis utf8mb4 utf8 utf16 utf32) DEFAULT_CHARSET=latin1 CHARSETS_AVAILABLE="CHARSETS_AVAILABLE0 CHARSETS_AVAILABLE1 CHARSETS_AVAILABLE2 CHARSETS_AVAILABLE3 CHARSETS_AVAILABLE4 CHARSETS_AVAILABLE5" -CHARSETS_COMPLEX="big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2 sjis tis620 ucs2 ujis utf8" +CHARSETS_COMPLEX="big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2 sjis tis620 ucs2 ujis utf8mb4 utf8 utf16 utf32" AC_DIVERT_POP @@ -50,7 +50,7 @@ AC_ARG_WITH(extra-charsets, AC_MSG_CHECKING("character sets") -CHARSETS="$default_charset latin1 utf8" +CHARSETS="$default_charset latin1 utf8mb4 utf8" if test "$extra_charsets" = no; then CHARSETS="$CHARSETS" @@ -195,8 +195,23 @@ do AC_DEFINE([USE_MB], [1], [Use multi-byte character routines]) AC_DEFINE(USE_MB_IDENT, 1) ;; + utf8mb4) + AC_DEFINE(HAVE_CHARSET_utf8mb4, 1, [Define to enable utf8mb4]) + AC_DEFINE([USE_MB], 1, [Use multi-byte character routines]) + AC_DEFINE(USE_MB_IDENT, 1) + ;; utf8) - AC_DEFINE(HAVE_CHARSET_utf8, 1, [Define to enable ut8]) + AC_DEFINE(HAVE_CHARSET_utf8, 1, [Define to enable utf8]) + AC_DEFINE([USE_MB], 1, [Use multi-byte character routines]) + AC_DEFINE(USE_MB_IDENT, 1) + ;; + utf16) + AC_DEFINE(HAVE_CHARSET_utf16, 1, [Define to enable utf16]) + AC_DEFINE([USE_MB], 1, [Use multi-byte character routines]) + AC_DEFINE(USE_MB_IDENT, 1) + ;; + utf32) + AC_DEFINE(HAVE_CHARSET_utf32, 1, [Define to enable utf32]) AC_DEFINE([USE_MB], 1, [Use multi-byte character routines]) AC_DEFINE(USE_MB_IDENT, 1) ;; @@ -381,6 +396,48 @@ case $default_charset in fi default_charset_collations="$UTFC" ;; + utf8mb4) + default_charset_default_collation="utf8mb4_general_ci" + define(UTFC1, utf8mb4_general_ci utf8mb4_bin) + define(UTFC2, utf8mb4_czech_ci utf8mb4_danish_ci) + define(UTFC3, utf8mb4_esperanto_ci utf8mb4_estonian_ci utf8mb4_hungarian_ci) + define(UTFC4, utf8mb4_icelandic_ci utf8mb4_latvian_ci utf8mb4_lithuanian_ci) + define(UTFC5, utf8mb4_persian_ci utf8mb4_polish_ci utf8mb4_romanian_ci) + define(UTFC6, utf8mb4_sinhala_ci utf8mb4_slovak_ci utf8mb4_slovenian_ci) + define(UTFC7, utf8mb4_spanish2_ci utf8mb4_spanish_ci) + define(UTFC8, utf8mb4_swedish_ci utf8mb4_turkish_ci) + define(UTFC9, utf8mb4_unicode_ci) + UTFC="UTFC1 UTFC2 UTFC3 UTFC4 UTFC5 UTFC6 UTFC7 UTFC8 UTFC9" + default_charset_collations="$UTFC" + ;; + utf16) + default_charset_default_collation="utf16_general_ci" + define(UTFC1, utf16_general_ci utf16_bin) + define(UTFC2, utf16_czech_ci utf16_danish_ci) + define(UTFC3, utf16_esperanto_ci utf16_estonian_ci utf16_hungarian_ci) + define(UTFC4, utf16_icelandic_ci utf16_latvian_ci utf16_lithuanian_ci) + define(UTFC5, utf16_persian_ci utf16_polish_ci utf16_romanian_ci) + define(UTFC6, utf16_sinhala_ci utf16_slovak_ci utf16_slovenian_ci) + define(UTFC7, utf16_spanish2_ci utf16_spanish_ci) + define(UTFC8, utf16_swedish_ci utf16_turkish_ci) + define(UTFC9, utf16_unicode_ci) + UTFC="UTFC1 UTFC2 UTFC3 UTFC4 UTFC5 UTFC6 UTFC7 UTFC8 UTFC9" + default_charset_collations="$UTFC" + ;; + utf32) + default_charset_default_collation="utf32_general_ci" + define(UTFC1, utf32_general_ci utf32_bin) + define(UTFC2, utf32_czech_ci utf32_danish_ci) + define(UTFC3, utf32_esperanto_ci utf32_estonian_ci utf32_hungarian_ci) + define(UTFC4, utf32_icelandic_ci utf32_latvian_ci utf32_lithuanian_ci) + define(UTFC5, utf32_persian_ci utf32_polish_ci utf32_romanian_ci) + define(UTFC6, utf32_sinhala_ci utf32_slovak_ci utf32_slovenian_ci) + define(UTFC7, utf32_spanish2_ci utf32_spanish_ci) + define(UTFC8, utf32_swedish_ci utf32_turkish_ci) + define(UTFC9, utf32_unicode_ci) + UTFC="UTFC1 UTFC2 UTFC3 UTFC4 UTFC5 UTFC6 UTFC7 UTFC8 UTFC9" + default_charset_collations="$UTFC" + ;; *) AC_MSG_ERROR([Charset $cs not available. (Available are: $CHARSETS_AVAILABLE). See the Installation chapter in the Reference Manual.]) diff --git a/include/config-win.h b/include/config-win.h index 57d4ed26307..269ec0e925a 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -432,6 +432,9 @@ inline ulonglong double2ulonglong(double d) #define HAVE_CHARSET_ucs2 1 #define HAVE_CHARSET_ujis 1 #define HAVE_CHARSET_utf8 1 +#define HAVE_CHARSET_utf8mb4 1 +#define HAVE_CHARSET_utf16 1 +#define HAVE_CHARSET_utf32 1 #define HAVE_UCA_COLLATIONS 1 #define HAVE_BOOL 1 diff --git a/include/m_ctype.h b/include/m_ctype.h index 7cf5ce113f8..d97c0c87b6e 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -98,13 +98,14 @@ extern MY_UNI_CTYPE my_uni_ctype[256]; #define MY_CS_BINSORT 16 /* if binary sort order */ #define MY_CS_PRIMARY 32 /* if primary collation */ #define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */ -#define MY_CS_UNICODE 128 /* is a charset is full unicode */ +#define MY_CS_UNICODE 128 /* is a charset is BMP Unicode */ #define MY_CS_READY 256 /* if a charset is initialized */ #define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/ #define MY_CS_CSSORT 1024 /* if case sensitive sort order */ #define MY_CS_HIDDEN 2048 /* don't display in SHOW */ #define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */ #define MY_CS_NONASCII 8192 /* if not ASCII-compatible */ +#define MY_CS_UNICODE_SUPPLEMENT 16384 /* Non-BMP Unicode characters */ #define MY_CHARSET_UNDEFINED 0 /* Character repertoire flags */ @@ -112,7 +113,6 @@ extern MY_UNI_CTYPE my_uni_ctype[256]; #define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */ #define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */ - typedef struct my_uni_idx_st { uint16 from; @@ -304,10 +304,14 @@ typedef struct charset_info_st extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_bin; +extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1; +extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename; + extern CHARSET_INFO my_charset_big5_chinese_ci; extern CHARSET_INFO my_charset_big5_bin; extern CHARSET_INFO my_charset_cp932_japanese_ci; extern CHARSET_INFO my_charset_cp932_bin; +extern CHARSET_INFO my_charset_cp1250_czech_ci; extern CHARSET_INFO my_charset_eucjpms_japanese_ci; extern CHARSET_INFO my_charset_eucjpms_bin; extern CHARSET_INFO my_charset_euckr_korean_ci; @@ -316,7 +320,6 @@ extern CHARSET_INFO my_charset_gb2312_chinese_ci; extern CHARSET_INFO my_charset_gb2312_bin; extern CHARSET_INFO my_charset_gbk_chinese_ci; extern CHARSET_INFO my_charset_gbk_bin; -extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1; extern CHARSET_INFO my_charset_latin1_german2_ci; extern CHARSET_INFO my_charset_latin1_bin; extern CHARSET_INFO my_charset_latin2_czech_ci; @@ -329,11 +332,22 @@ extern CHARSET_INFO my_charset_ucs2_bin; extern CHARSET_INFO my_charset_ucs2_unicode_ci; extern CHARSET_INFO my_charset_ujis_japanese_ci; extern CHARSET_INFO my_charset_ujis_bin; +extern CHARSET_INFO my_charset_utf16_bin; +extern CHARSET_INFO my_charset_utf16_general_ci; +extern CHARSET_INFO my_charset_utf16_unicode_ci; +extern CHARSET_INFO my_charset_utf32_bin; +extern CHARSET_INFO my_charset_utf32_general_ci; +extern CHARSET_INFO my_charset_utf32_unicode_ci; + extern CHARSET_INFO my_charset_utf8_general_ci; extern CHARSET_INFO my_charset_utf8_unicode_ci; extern CHARSET_INFO my_charset_utf8_bin; -extern CHARSET_INFO my_charset_cp1250_czech_ci; -extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename; +extern CHARSET_INFO my_charset_utf8mb4_bin; +extern CHARSET_INFO my_charset_utf8mb4_general_ci; +extern CHARSET_INFO my_charset_utf8mb4_unicode_ci; +#define MY_UTF8MB3 "utf8" +#define MY_UTF8MB4 "utf8mb4" + /* declarations for simple charsets */ extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t, @@ -430,6 +444,19 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, char *min_str, char *max_str, size_t *min_length, size_t *max_length); +my_bool my_like_range_utf16(CHARSET_INFO *cs, + const char *ptr, size_t ptr_length, + pbool escape, pbool w_one, pbool w_many, + size_t res_length, + char *min_str, char *max_str, + size_t *min_length, size_t *max_length); + +my_bool my_like_range_utf32(CHARSET_INFO *cs, + const char *ptr, size_t ptr_length, + pbool escape, pbool w_one, pbool w_many, + size_t res_length, + char *min_str, char *max_str, + size_t *min_length, size_t *max_length); int my_wildcmp_8bit(CHARSET_INFO *, const char *str,const char *str_end, @@ -480,6 +507,31 @@ uint my_instr_mb(struct charset_info_st *, const char *s, size_t s_length, my_match_t *match, uint nmatch); +int my_strnncoll_mb_bin(CHARSET_INFO * cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool t_is_prefix); + +int my_strnncollsp_mb_bin(CHARSET_INFO *cs, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, + my_bool diff_if_only_endspace_difference); + +int my_wildcmp_mb_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_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), + const char *s, const char *t); + +void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), + const uchar *key, size_t len,ulong *nr1, ulong *nr2); + +size_t my_strnxfrm_unicode(CHARSET_INFO *, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen); + int my_wildcmp_unicode(CHARSET_INFO *cs, const char *str, const char *str_end, const char *wildstr, const char *wildend, diff --git a/mysql-test/include/ctype_datetime.inc b/mysql-test/include/ctype_datetime.inc new file mode 100644 index 00000000000..dc70f1f38a9 --- /dev/null +++ b/mysql-test/include/ctype_datetime.inc @@ -0,0 +1,11 @@ +# +# Bug#32390 Character sets: casting utf32 to/from date doesn't work +# +CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0; +SET timestamp=1216359724; +INSERT INTO t1 VALUES (current_date); +INSERT INTO t1 VALUES (current_time); +INSERT INTO t1 VALUES (current_timestamp); +SELECT s1, hex(s1) FROM t1; +DROP TABLE t1; +SET timestamp=0; diff --git a/mysql-test/include/ctype_like.inc b/mysql-test/include/ctype_like.inc new file mode 100644 index 00000000000..38de0bf2671 --- /dev/null +++ b/mysql-test/include/ctype_like.inc @@ -0,0 +1,50 @@ +select @@collation_connection; + +# +# Create a table with a nullable varchar(10) column +# using currect character_set_connection. +create table t1 as select repeat(' ',10) as a union select null; +alter table t1 add key(a); +show create table t1; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +explain select * from t1 where a like 'abc%'; +explain select * from t1 where a like concat('abc','%'); +select * from t1 where a like "abc%"; +select * from t1 where a like concat("abc","%"); +select * from t1 where a like "ABC%"; +select * from t1 where a like "test%"; +select * from t1 where a like "te_t"; +select * from t1 where a like "%a%"; +select * from t1 where a like "%abcd%"; +select * from t1 where a like "%abc\d%"; +drop table t1; + +# +# Bug #2619 ucs2 LIKE comparison fails in some cases +# + +select 'AA' like 'AA'; +select 'AA' like 'A%A'; +select 'AA' like 'A%%A'; +select 'AA' like 'AA%'; +select 'AA' like '%AA%'; +select 'AA' like '%A'; +select 'AA' like '%AA'; +select 'AA' like 'A%A%'; +select 'AA' like '_%_%'; +select 'AA' like '%A%A'; +select 'AAA'like 'A%A%A'; + +select 'AZ' like 'AZ'; +select 'AZ' like 'A%Z'; +select 'AZ' like 'A%%Z'; +select 'AZ' like 'AZ%'; +select 'AZ' like '%AZ%'; +select 'AZ' like '%Z'; +select 'AZ' like '%AZ'; +select 'AZ' like 'A%Z%'; +select 'AZ' like '_%_%'; +select 'AZ' like '%A%Z'; +select 'AZ' like 'A_'; +select 'AZ' like '_Z'; +select 'AMZ'like 'A%M%Z'; diff --git a/mysql-test/include/have_utf16.inc b/mysql-test/include/have_utf16.inc new file mode 100644 index 00000000000..ab22c255c88 --- /dev/null +++ b/mysql-test/include/have_utf16.inc @@ -0,0 +1,4 @@ +-- require r/have_utf16.require +disable_query_log; +show collation like 'utf16_general_ci'; +enable_query_log; diff --git a/mysql-test/include/have_utf32.inc b/mysql-test/include/have_utf32.inc new file mode 100644 index 00000000000..f5b5353c9fd --- /dev/null +++ b/mysql-test/include/have_utf32.inc @@ -0,0 +1,4 @@ +-- require r/have_utf32.require +disable_query_log; +show collation like 'utf32_general_ci'; +enable_query_log; diff --git a/mysql-test/include/have_utf8mb4.inc b/mysql-test/include/have_utf8mb4.inc new file mode 100644 index 00000000000..6eb91b1c23c --- /dev/null +++ b/mysql-test/include/have_utf8mb4.inc @@ -0,0 +1,7 @@ +--require r/have_utf8mb4.require + +--disable_query_log + +SHOW COLLATION LIKE 'utf8mb4_general_ci'; + +--enable_query_log diff --git a/mysql-test/r/ctype_ldml.result b/mysql-test/r/ctype_ldml.result index 3373e31539f..433078a2a07 100644 --- a/mysql-test/r/ctype_ldml.result +++ b/mysql-test/r/ctype_ldml.result @@ -53,6 +53,33 @@ select * from t1 where c1='b'; c1 a drop table t1; +show collation like 'utf8mb4_test_ci'; +Collation Charset Id Default Compiled Sortlen +utf8mb4_test_ci utf8mb4 326 8 +create table t1 (c1 char(1) character set utf8mb4 collate utf8mb4_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +c1 +a +drop table t1; +show collation like 'utf16_test_ci'; +Collation Charset Id Default Compiled Sortlen +utf16_test_ci utf16 327 8 +create table t1 (c1 char(1) character set utf16 collate utf16_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +c1 +a +drop table t1; +show collation like 'utf32_test_ci'; +Collation Charset Id Default Compiled Sortlen +utf32_test_ci utf32 391 8 +create table t1 (c1 char(1) character set utf32 collate utf32_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +c1 +a +drop table t1; CREATE TABLE t1 ( col1 varchar(100) character set utf8 collate utf8_test_ci ); @@ -373,16 +400,22 @@ select "foo" = "foo " collate latin1_test; The following tests check that two-byte collation IDs work select * from information_schema.collations where id>256 order by id; COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN +utf8mb4_test_ci utf8mb4 326 8 +utf16_test_ci utf16 327 8 utf8_phone_ci utf8 352 8 utf8_test_ci utf8 353 8 ucs2_test_ci ucs2 358 8 ucs2_vn_ci ucs2 359 8 +utf32_test_ci utf32 391 8 utf8_maxuserid_ci utf8 2047 8 show collation like '%test%'; Collation Charset Id Default Compiled Sortlen latin1_test latin1 99 Yes 1 utf8_test_ci utf8 353 8 ucs2_test_ci ucs2 358 8 +utf8mb4_test_ci utf8mb4 326 8 +utf16_test_ci utf16 327 8 +utf32_test_ci utf32 391 8 show collation like 'ucs2_vn_ci'; Collation Charset Id Default Compiled Sortlen ucs2_vn_ci ucs2 359 8 diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result index 89e05bf4484..4730b4df668 100644 --- a/mysql-test/r/ctype_many.result +++ b/mysql-test/r/ctype_many.result @@ -1683,3 +1683,59 @@ ARMENIAN CAPIT DA 2 ARMENIAN CAPIT ECH 2 ARMENIAN CAPIT ZA 2 DROP TABLE t1; +# +# WL#1213 Implement 4-byte UTF8, UTF16 and UTF32 +# Testing that only utf8mb4 is superset for utf8 +# No other Unicode character set pairs have superset/subset relations +# +CREATE TABLE t1 ( +utf8 CHAR CHARACTER SET utf8, +utf8mb4 CHAR CHARACTER SET utf8mb4, +ucs2 CHAR CHARACTER SET ucs2, +utf16 CHAR CHARACTER SET utf16, +utf32 CHAR CHARACTER SET utf32 +); +INSERT INTO t1 VALUES ('','','','',''); +SELECT CHARSET(CONCAT(utf8, utf8mb4)) FROM t1; +CHARSET(CONCAT(utf8, utf8mb4)) +utf8mb4 +SELECT CHARSET(CONCAT(utf8, ucs2)) FROM t1; +ERROR HY000: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (ucs2_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf8, utf16)) FROM t1; +ERROR HY000: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf16_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf8, utf32)) FROM t1; +ERROR HY000: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf32_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf8mb4, utf8)) FROM t1; +CHARSET(CONCAT(utf8mb4, utf8)) +utf8mb4 +SELECT CHARSET(CONCAT(utf8mb4, ucs2)) FROM t1; +ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (ucs2_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf8mb4, utf16)) FROM t1; +ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf16_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf8mb4, utf32)) FROM t1; +ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf32_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(ucs2, utf8)) FROM t1; +ERROR HY000: Illegal mix of collations (ucs2_general_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(ucs2, utf8mb4)) FROM t1; +ERROR HY000: Illegal mix of collations (ucs2_general_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(ucs2, utf16)) FROM t1; +ERROR HY000: Illegal mix of collations (ucs2_general_ci,IMPLICIT) and (utf16_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(ucs2, utf32)) FROM t1; +ERROR HY000: Illegal mix of collations (ucs2_general_ci,IMPLICIT) and (utf32_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf16, utf8)) FROM t1; +ERROR HY000: Illegal mix of collations (utf16_general_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf16, ucs2)) FROM t1; +ERROR HY000: Illegal mix of collations (utf16_general_ci,IMPLICIT) and (ucs2_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf16, utf8mb4)) FROM t1; +ERROR HY000: Illegal mix of collations (utf16_general_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf16, utf32)) FROM t1; +ERROR HY000: Illegal mix of collations (utf16_general_ci,IMPLICIT) and (utf32_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf32, utf8)) FROM t1; +ERROR HY000: Illegal mix of collations (utf32_general_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf32, ucs2)) FROM t1; +ERROR HY000: Illegal mix of collations (utf32_general_ci,IMPLICIT) and (ucs2_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf32, utf8mb4)) FROM t1; +ERROR HY000: Illegal mix of collations (utf32_general_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation 'concat' +SELECT CHARSET(CONCAT(utf32, utf16)) FROM t1; +ERROR HY000: Illegal mix of collations (utf32_general_ci,IMPLICIT) and (utf16_general_ci,IMPLICIT) for operation 'concat' +DROP TABLE t1; diff --git a/mysql-test/r/ctype_utf16.result b/mysql-test/r/ctype_utf16.result new file mode 100644 index 00000000000..3c2fe316d71 --- /dev/null +++ b/mysql-test/r/ctype_utf16.result @@ -0,0 +1,1038 @@ +DROP TABLE IF EXISTS t1; +# +# Start of 5.5 tests +# +SET NAMES latin1; +SET character_set_connection=utf16; +select hex('a'), hex('a '); +hex('a') hex('a ') +0061 00610020 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +0 1 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +0 0 1 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +0 1 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +0 0 1 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 1 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +select hex(_utf16 0x44); +hex(_utf16 0x44) +00000044 +select hex(_utf16 0x3344); +hex(_utf16 0x3344) +3344 +select hex(_utf16 0x113344); +hex(_utf16 0x113344) +000000113344 +CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf16; +INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (X'2004',X'2004'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +0420 +2004 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +0420 +2004 +DELETE FROM t1; +INSERT INTO t1 VALUES (X'042000200020',X'042000200020'), (X'200400200020', X'200400200020'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +042000200020 +200400200020 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +0420 +2004 +DROP TABLE t1; +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'0421')); +hex(LPAD(_utf16 X'0420',10,_utf16 X'0421')) +0421042104210421042104210421042104210420 +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'04210422')); +hex(LPAD(_utf16 X'0420',10,_utf16 X'04210422')) +0421042204210422042104220421042204210420 +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'042104220423')); +hex(LPAD(_utf16 X'0420',10,_utf16 X'042104220423')) +0421042204230421042204230421042204230420 +SELECT hex(LPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')); +hex(LPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')) +0420042104220423042404250426042704280429 +SELECT hex(LPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')); +hex(LPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')) +042104210421042104210421042104210421D800DC00 +SELECT hex(LPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')); +hex(LPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')) +D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC000421 +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'0421')); +hex(RPAD(_utf16 X'0420',10,_utf16 X'0421')) +0420042104210421042104210421042104210421 +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'04210422')); +hex(RPAD(_utf16 X'0420',10,_utf16 X'04210422')) +0420042104220421042204210422042104220421 +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'042104220423')); +hex(RPAD(_utf16 X'0420',10,_utf16 X'042104220423')) +0420042104220423042104220423042104220423 +SELECT hex(RPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')); +hex(RPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')) +0420042104220423042404250426042704280429 +SELECT hex(RPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')); +hex(RPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')) +D800DC00042104210421042104210421042104210421 +SELECT hex(RPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')); +hex(RPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')) +0421D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00D800DC00 +CREATE TABLE t1 SELECT +LPAD(_utf16 X'0420',10,_utf16 X'0421') l, +RPAD(_utf16 X'0420',10,_utf16 X'0421') r; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `l` varchar(10) CHARACTER SET utf16 NOT NULL DEFAULT '', + `r` varchar(10) CHARACTER SET utf16 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(l), hex(r) from t1; +hex(l) hex(r) +0421042104210421042104210421042104210420 0420042104210421042104210421042104210421 +DROP TABLE t1; +create table t1 (f1 char(30)); +insert into t1 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t1; +lpad(f1, 12, "-o-/") +-o-/-o103000 +-o-/22720000 +-o-/-3401200 +-o-/-o-78000 +drop table t1; +SET NAMES latin1; +SET character_set_connection=utf16; +select @@collation_connection; +@@collation_connection +utf16_general_ci +create table t1 as select repeat(' ',10) as a union select null; +alter table t1 add key(a); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf16 DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +explain select * from t1 where a like 'abc%'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index +explain select * from t1 where a like concat('abc','%'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +select 'AA' like 'AA'; +'AA' like 'AA' +1 +select 'AA' like 'A%A'; +'AA' like 'A%A' +1 +select 'AA' like 'A%%A'; +'AA' like 'A%%A' +1 +select 'AA' like 'AA%'; +'AA' like 'AA%' +1 +select 'AA' like '%AA%'; +'AA' like '%AA%' +1 +select 'AA' like '%A'; +'AA' like '%A' +1 +select 'AA' like '%AA'; +'AA' like '%AA' +1 +select 'AA' like 'A%A%'; +'AA' like 'A%A%' +1 +select 'AA' like '_%_%'; +'AA' like '_%_%' +1 +select 'AA' like '%A%A'; +'AA' like '%A%A' +1 +select 'AAA'like 'A%A%A'; +'AAA'like 'A%A%A' +1 +select 'AZ' like 'AZ'; +'AZ' like 'AZ' +1 +select 'AZ' like 'A%Z'; +'AZ' like 'A%Z' +1 +select 'AZ' like 'A%%Z'; +'AZ' like 'A%%Z' +1 +select 'AZ' like 'AZ%'; +'AZ' like 'AZ%' +1 +select 'AZ' like '%AZ%'; +'AZ' like '%AZ%' +1 +select 'AZ' like '%Z'; +'AZ' like '%Z' +1 +select 'AZ' like '%AZ'; +'AZ' like '%AZ' +1 +select 'AZ' like 'A%Z%'; +'AZ' like 'A%Z%' +1 +select 'AZ' like '_%_%'; +'AZ' like '_%_%' +1 +select 'AZ' like '%A%Z'; +'AZ' like '%A%Z' +1 +select 'AZ' like 'A_'; +'AZ' like 'A_' +1 +select 'AZ' like '_Z'; +'AZ' like '_Z' +1 +select 'AMZ'like 'A%M%Z'; +'AMZ'like 'A%M%Z' +1 +SET NAMES utf8; +SET character_set_connection=utf16; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16); +INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывĐ'),('ФЫВĐ'); +INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж'); +INSERT INTO t1 VALUES ('фывĐпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж'); +INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВĐПРОЛДЖ'); +SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a; +a +ФЫВР+ФЫВĐПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывР+фывĐпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a; +a +ФЫВР+ФЫВĐПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывР+фывĐпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a; +a +ФЫВР+ФЫВĐПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывР+фывĐпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf16_bin ORDER BY BINARY a; +a +фЫва +фЫвапролдж +DROP TABLE t1; +CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word)) +ENGINE=MyISAM CHARACTER SET utf16; +INSERT INTO t1 (word) VALUES ("cat"); +SELECT * FROM t1 WHERE word LIKE "c%"; +word +cat +SELECT * FROM t1 WHERE word LIKE "ca_"; +word +cat +SELECT * FROM t1 WHERE word LIKE "cat"; +word +cat +SELECT * FROM t1 WHERE word LIKE _utf16 x'00630025'; +word +cat +SELECT * FROM t1 WHERE word LIKE _utf16 x'00630061005F'; +word +cat +DROP TABLE t1; +select insert(_utf16 0x006100620063,10,2,_utf16 0x006400650066); +insert(_utf16 0x006100620063,10,2,_utf16 0x006400650066) +abc +select insert(_utf16 0x006100620063,1,2,_utf16 0x006400650066); +insert(_utf16 0x006100620063,1,2,_utf16 0x006400650066) +defc +SET NAMES latin1; +CREATE TABLE t1 ( +word VARCHAR(64), +bar INT(11) default 0, +PRIMARY KEY (word)) +ENGINE=MyISAM +CHARSET utf16 +COLLATE utf16_general_ci ; +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a"); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY word; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort +SELECT * FROM t1 ORDER BY word; +word bar +a 0 +aar 0 +aardvar 0 +aardvara 0 +aardvark 0 +aardvarz 0 +EXPLAIN SELECT word FROM t1 ORDER BY word; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 258 NULL 6 Using index +SELECT word FROM t1 ORDER by word; +word +a +aar +aardvar +aardvara +aardvark +aardvarz +DROP TABLE t1; +CREATE TABLE t1 ( +word VARCHAR(64) , +PRIMARY KEY (word)) +ENGINE=MyISAM +CHARSET utf16 +COLLATE utf16_general_ci; +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a"); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY WORD; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 258 NULL 6 Using index +SELECT * FROM t1 ORDER BY word; +word +a +aar +aardvar +aardvara +aardvark +aardvarz +DROP TABLE t1; +CREATE TABLE t1 ( +word TEXT, +bar INT(11) AUTO_INCREMENT, +PRIMARY KEY (bar)) +ENGINE=MyISAM +CHARSET utf16 +COLLATE utf16_general_ci ; +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a" ); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY word; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort +SELECT * FROM t1 ORDER BY word; +word bar +a 2 +aar 1 +aardvar 3 +aardvara 5 +aardvark 4 +aardvarz 6 +EXPLAIN SELECT word FROM t1 ORDER BY word; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort +SELECT word FROM t1 ORDER BY word; +word +a +aar +aardvar +aardvara +aardvark +aardvarz +DROP TABLE t1; +SELECT hex(cast(0xAA as char character set utf16)); +hex(cast(0xAA as char character set utf16)) +000000AA +SELECT hex(convert(0xAA using utf16)); +hex(convert(0xAA using utf16)) +000000AA +CREATE TABLE t1 (a char(10) character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a varchar(10) character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a text character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a mediumtext character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a longtext character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +0001 +0011 +0111 +1111 +00011111 +DROP TABLE t1; +create table t1(a char(1)) default charset utf16; +insert into t1 values ('a'),('b'),('c'); +alter table t1 modify a char(5); +select a, hex(a) from t1; +a hex(a) +a 0061 +b 0062 +c 0063 +drop table t1; +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using utf16); +prepare stmt1 from @str2; +execute stmt1 using @ivar; +? +1234 +set names utf8; +create table t1 (a enum('x','y','z') character set utf16); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z') CHARACTER SET utf16 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +z 007A +alter table t1 change a a enum('x','y','z','d','e','ä','ö','ĂĽ') character set utf16; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z','d','e','ä','ö','ĂĽ') CHARACTER SET utf16 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('D'); +insert into t1 values ('E '); +insert into t1 values ('ä'); +insert into t1 values ('ö'); +insert into t1 values ('ĂĽ'); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +z 007A +d 0064 +e 0065 +ä 00E4 +ö 00F6 +ĂĽ 00FC +drop table t1; +create table t1 (a set ('x','y','z','ä','ö','ĂĽ') character set utf16); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` set('x','y','z','ä','ö','ĂĽ') CHARACTER SET utf16 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +insert into t1 values ('x,y'); +insert into t1 values ('x,y,z,ä,ö,ĂĽ'); +select a, hex(a) from t1 order by a; +a hex(a) +x 0078 +y 0079 +x,y 0078002C0079 +z 007A +x,y,z,ä,ö,ĂĽ 0078002C0079002C007A002C00E4002C00F6002C00FC +drop table t1; +create table t1(a enum('a','b','c')) default character set utf16; +insert into t1 values('a'),('b'),('c'); +alter table t1 add b char(1); +show warnings; +Level Code Message +select * from t1 order by a; +a b +a NULL +b NULL +c NULL +drop table t1; +SET NAMES latin1; +SET collation_connection='utf16_general_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf16_general_ci 00610009 +utf16_general_ci 0061 +utf16_general_ci 00610020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf16_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +SET NAMES latin1; +SET collation_connection='utf16_bin'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf16_bin 00610009 +utf16_bin 0061 +utf16_bin 00610020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf16_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +select hex(substr(_utf16 0x00e400e50068,1)); +hex(substr(_utf16 0x00e400e50068,1)) +00E400E50068 +select hex(substr(_utf16 0x00e400e50068,2)); +hex(substr(_utf16 0x00e400e50068,2)) +00E50068 +select hex(substr(_utf16 0x00e400e50068,3)); +hex(substr(_utf16 0x00e400e50068,3)) +0068 +select hex(substr(_utf16 0x00e400e50068,-1)); +hex(substr(_utf16 0x00e400e50068,-1)) +0068 +select hex(substr(_utf16 0x00e400e50068,-2)); +hex(substr(_utf16 0x00e400e50068,-2)) +00E50068 +select hex(substr(_utf16 0x00e400e50068,-3)); +hex(substr(_utf16 0x00e400e50068,-3)) +00E400E50068 +select hex(substr(_utf16 0x00e400e5D800DC00,1)); +hex(substr(_utf16 0x00e400e5D800DC00,1)) +00E400E5D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,2)); +hex(substr(_utf16 0x00e400e5D800DC00,2)) +00E5D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,3)); +hex(substr(_utf16 0x00e400e5D800DC00,3)) +D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,-1)); +hex(substr(_utf16 0x00e400e5D800DC00,-1)) +D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,-2)); +hex(substr(_utf16 0x00e400e5D800DC00,-2)) +00E5D800DC00 +select hex(substr(_utf16 0x00e400e5D800DC00,-3)); +hex(substr(_utf16 0x00e400e5D800DC00,-3)) +00E400E5D800DC00 +SET NAMES latin1; +create table t1 (utext varchar(20) character set utf16); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +create table t1 ( +a char(10) character set utf16 not null, +index a (a) +) engine=myisam; +insert into t1 values (repeat(0x201f, 10)); +insert into t1 values (repeat(0x2020, 10)); +insert into t1 values (repeat(0x2021, 10)); +explain select hex(a) from t1 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 40 NULL 3 Using index +select hex(a) from t1 order by a; +hex(a) +201F201F201F201F201F201F201F201F201F201F +2020202020202020202020202020202020202020 +2021202120212021202120212021202120212021 +alter table t1 drop index a; +select hex(a) from t1 order by a; +hex(a) +201F201F201F201F201F201F201F201F201F201F +2020202020202020202020202020202020202020 +2021202120212021202120212021202120212021 +drop table t1; +CREATE TABLE t1 ( +status enum('active','passive') character set utf16 collate utf16_general_ci +NOT NULL default 'passive' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf16 NOT NULL DEFAULT 'passive' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD a int NOT NULL AFTER status; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf16 NOT NULL DEFAULT 'passive', + `a` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a varchar(64) character set utf16, b decimal(10,3)); +INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); +update t1 set b=a; +SELECT *, hex(a) FROM t1; +a b hex(a) +1.1 1.100 0031002E0031 +2.1 2.100 0032002E0031 +DROP TABLE t1; +create table t1 (utext varchar(20) character set utf16); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +set names latin1; +set character_set_connection=utf16; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb') + H000 H4142 I51231 +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +hex(soundex('')) hex(soundex('he')) hex(soundex('hello all folks')) hex(soundex('#3556 in bugdb')) + 0048003000300030 00480034003100340032 004900350031003200330031 +select 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +select hex(soundex(_utf16 0x041004110412)); +hex(soundex(_utf16 0x041004110412)) +0410003000300030 +select hex(soundex(_utf16 0x00BF00C0)); +hex(soundex(_utf16 0x00BF00C0)) +00C0003000300030 +set names latin1; +create table t1(a blob, b text charset utf16); +select data_type, character_octet_length, character_maximum_length +from information_schema.columns where table_name='t1'; +data_type character_octet_length character_maximum_length +blob 65535 65535 +text 65535 32767 +drop table t1; +set names latin1; +set collation_connection=utf16_general_ci; +select position('bb' in 'abba'); +position('bb' in 'abba') +2 +create table t1 (a varchar(10) character set utf16) engine=heap; +insert into t1 values ('a'),('A'),('b'),('B'); +select * from t1 where a='a' order by binary a; +a +A +a +select hex(min(binary a)),count(*) from t1 group by a; +hex(min(binary a)) count(*) +0041 2 +0042 2 +drop table t1; +select char_length('abcd'), octet_length('abcd'); +char_length('abcd') octet_length('abcd') +4 8 +select char_length(_utf16 0xD800DC00), octet_length(_utf16 0xD800DC00); +char_length(_utf16 0xD800DC00) octet_length(_utf16 0xD800DC00) +1 4 +select char_length(_utf16 0xD87FDFFF), octet_length(_utf16 0xD87FDFFF); +char_length(_utf16 0xD87FDFFF) octet_length(_utf16 0xD87FDFFF) +1 4 +select left('abcd',2); +left('abcd',2) +ab +select hex(left(_utf16 0xD800DC00D87FDFFF, 1)); +hex(left(_utf16 0xD800DC00D87FDFFF, 1)) +D800DC00 +select hex(right(_utf16 0xD800DC00D87FDFFF, 1)); +hex(right(_utf16 0xD800DC00D87FDFFF, 1)) +D87FDFFF +create table t1 (a varchar(10) character set utf16); +insert into t1 values (_utf16 0xD800); +ERROR HY000: Invalid utf16 character string: 'D800' +insert into t1 values (_utf16 0xDC00); +ERROR HY000: Invalid utf16 character string: 'DC00' +insert into t1 values (_utf16 0xD800D800); +ERROR HY000: Invalid utf16 character string: 'D800D8' +insert into t1 values (_utf16 0xD800E800); +ERROR HY000: Invalid utf16 character string: 'D800E8' +insert into t1 values (_utf16 0xD8000800); +ERROR HY000: Invalid utf16 character string: 'D80008' +insert into t1 values (_utf16 0xD800DC00); +insert into t1 values (_utf16 0xD800DCFF); +insert into t1 values (_utf16 0xDBFFDC00); +insert into t1 values (_utf16 0xDBFFDCFF); +select hex(a) from t1; +hex(a) +D800DC00 +D800DCFF +DBFFDC00 +DBFFDCFF +drop table t1; +create table t1 (s1 varchar(50) character set ucs2); +insert into t1 values (0xdf84); +alter table t1 modify column s1 varchar(50) character set utf16; +Warnings: +Warning 1366 Incorrect string value: '\xDF\x84' for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +003F +drop table t1; +create table t1 (s1 varchar(5) character set ucs2, s2 varchar(5) character set utf16); +insert into t1 (s1) values (0xdf84); +update t1 set s2 = s1; +Warnings: +Warning 1366 Incorrect string value: '\xDF\x84' for column 's2' at row 1 +select hex(s2) from t1; +hex(s2) +003F +drop table t1; +create table t1 (a char(10)) character set utf16; +insert into t1 values ('a '); +select hex(a) from t1; +hex(a) +0061 +drop table t1; +select upper('abcd'), lower('ABCD'); +upper('abcd') lower('ABCD') +ABCD abcd +create table t1 (a varchar(10) character set utf16); +insert into t1 values (123456); +select a, hex(a) from t1; +a hex(a) +123456 003100320033003400350036 +drop table t1; +select hex(soundex('a')); +hex(soundex('a')) +0041003000300030 +create table t1 (a enum ('a','b','c')) character set utf16; +insert into t1 values ('1'); +select * from t1; +a +a +drop table t1; +set names latin1; +select hex(conv(convert('123' using utf16), -10, 16)); +hex(conv(convert('123' using utf16), -10, 16)) +3742 +select hex(conv(convert('123' using utf16), 10, 16)); +hex(conv(convert('123' using utf16), 10, 16)) +3742 +set names latin1; +set character_set_connection=utf16; +select 1.1 + '1.2'; +1.1 + '1.2' +2.3 +select 1.1 + '1.2xxx'; +1.1 + '1.2xxx' +2.3 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '' +select left('aaa','1'); +left('aaa','1') +a +create table t1 (a int); +insert into t1 values ('-1234.1e2'); +insert into t1 values ('-1234.1e2xxxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +insert into t1 values ('-1234.1e2 '); +select * from t1; +a +-123410 +-123410 +-123410 +drop table t1; +create table t1 (a int); +insert into t1 values ('1 '); +insert into t1 values ('1 x'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +1 +1 +drop table t1; +create table t1 (a varchar(17000) character set utf16); +Warnings: +Note 1246 Converting column 'a' from VARCHAR to TEXT +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext CHARACTER SET utf16 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a varchar(250) character set utf16 primary key); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(250) CHARACTER SET utf16 NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a varchar(334) character set utf16 primary key); +ERROR 42000: Specified key was too long; max key length is 1000 bytes +create table t1 (a char(1) character set utf16); +insert into t1 values (0xD800DC00),(0xD800DCFF),(0xDB7FDC00),(0xDB7FDCFF); +insert into t1 values (0x00C0), (0x00FF),(0xE000), (0xFFFF); +select hex(a), hex(@a:=convert(a using utf8mb4)), hex(convert(@a using utf16)) from t1; +hex(a) hex(@a:=convert(a using utf8mb4)) hex(convert(@a using utf16)) +D800DC00 F0908080 D800DC00 +D800DCFF F09083BF D800DCFF +DB7FDC00 F3AFB080 DB7FDC00 +DB7FDCFF F3AFB3BF DB7FDCFF +00C0 C380 00C0 +00FF C3BF 00FF +E000 EE8080 E000 +FFFF EFBFBF FFFF +drop table t1; +set collation_connection=utf16_general_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf16 DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf16 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +insert into t1 values('ghi','ghi['); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +NULL +drop table t1; +set names latin1; +SET collation_connection=utf16_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0; +SET timestamp=1216359724; +INSERT INTO t1 VALUES (current_date); +INSERT INTO t1 VALUES (current_time); +INSERT INTO t1 VALUES (current_timestamp); +SELECT s1, hex(s1) FROM t1; +s1 hex(s1) +2008-07-18 0032003000300038002D00300037002D00310038 +08:42:04 00300038003A00340032003A00300034 +2008-07-18 08:42:04 0032003000300038002D00300037002D00310038002000300038003A00340032003A00300034 +DROP TABLE t1; +SET timestamp=0; +SET NAMES latin1; +SET collation_connection=utf16_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(2) CHARACTER SET utf16 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE'); +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +SET max_sort_length=4; +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +DROP TABLE t1; +SET max_sort_length=DEFAULT; +SET NAMES latin1; +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_utf16_uca.result b/mysql-test/r/ctype_utf16_uca.result new file mode 100644 index 00000000000..d83ef2af09e --- /dev/null +++ b/mysql-test/r/ctype_utf16_uca.result @@ -0,0 +1,2373 @@ +DROP TABLE IF EXISTS t1; +# +# Start of 5.5 tests +# +set names utf8; +set collation_connection=utf16_unicode_ci; +select hex('a'), hex('a '); +hex('a') hex('a ') +0061 00610020 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +1 0 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +1 0 0 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +1 0 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +1 0 0 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 0 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +select 'c' like '\_' as want0; +want0 +0 +CREATE TABLE t ( +c char(20) NOT NULL +) ENGINE=MyISAM DEFAULT CHARACTER SET utf16 COLLATE utf16_unicode_ci; +INSERT INTO t VALUES ('a'),('ab'),('aba'); +ALTER TABLE t ADD INDEX (c); +SELECT c FROM t WHERE c LIKE 'a%'; +c +a +ab +aba +DROP TABLE t; +create table t1 (c1 char(10) character set utf16 collate utf16_bin); +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); +insert into t1 values (0x00e0),(0x00c0); +insert into t1 values (0x00e1),(0x00c1); +insert into t1 values (0x00e2),(0x00c2); +insert into t1 values (0x00e3),(0x00c3); +insert into t1 values (0x00e4),(0x00c4); +insert into t1 values (0x00e5),(0x00c5); +insert into t1 values (0x00e6),(0x00c6); +insert into t1 values (0x00e7),(0x00c7); +insert into t1 values (0x00e8),(0x00c8); +insert into t1 values (0x00e9),(0x00c9); +insert into t1 values (0x00ea),(0x00ca); +insert into t1 values (0x00eb),(0x00cb); +insert into t1 values (0x00ec),(0x00cc); +insert into t1 values (0x00ed),(0x00cd); +insert into t1 values (0x00ee),(0x00ce); +insert into t1 values (0x00ef),(0x00cf); +insert into t1 values (0x00f0),(0x00d0); +insert into t1 values (0x00f1),(0x00d1); +insert into t1 values (0x00f2),(0x00d2); +insert into t1 values (0x00f3),(0x00d3); +insert into t1 values (0x00f4),(0x00d4); +insert into t1 values (0x00f5),(0x00d5); +insert into t1 values (0x00f6),(0x00d6); +insert into t1 values (0x00f7),(0x00d7); +insert into t1 values (0x00f8),(0x00d8); +insert into t1 values (0x00f9),(0x00d9); +insert into t1 values (0x00fa),(0x00da); +insert into t1 values (0x00fb),(0x00db); +insert into t1 values (0x00fc),(0x00dc); +insert into t1 values (0x00fd),(0x00dd); +insert into t1 values (0x00fe),(0x00de); +insert into t1 values (0x00ff),(0x00df); +insert into t1 values (0x0100),(0x0101),(0x0102),(0x0103); +insert into t1 values (0x0104),(0x0105),(0x0106),(0x0107); +insert into t1 values (0x0108),(0x0109),(0x010a),(0x010b); +insert into t1 values (0x010c),(0x010d),(0x010e),(0x010f); +insert into t1 values (0x0110),(0x0111),(0x0112),(0x0113); +insert into t1 values (0x0114),(0x0115),(0x0116),(0x0117); +insert into t1 values (0x0118),(0x0119),(0x011a),(0x011b); +insert into t1 values (0x011c),(0x011d),(0x011e),(0x011f); +insert into t1 values (0x0120),(0x0121),(0x0122),(0x0123); +insert into t1 values (0x0124),(0x0125),(0x0126),(0x0127); +insert into t1 values (0x0128),(0x0129),(0x012a),(0x012b); +insert into t1 values (0x012c),(0x012d),(0x012e),(0x012f); +insert into t1 values (0x0130),(0x0131),(0x0132),(0x0133); +insert into t1 values (0x0134),(0x0135),(0x0136),(0x0137); +insert into t1 values (0x0138),(0x0139),(0x013a),(0x013b); +insert into t1 values (0x013c),(0x013d),(0x013e),(0x013f); +insert into t1 values (0x0140),(0x0141),(0x0142),(0x0143); +insert into t1 values (0x0144),(0x0145),(0x0146),(0x0147); +insert into t1 values (0x0148),(0x0149),(0x014a),(0x014b); +insert into t1 values (0x014c),(0x014d),(0x014e),(0x014f); +insert into t1 values (0x0150),(0x0151),(0x0152),(0x0153); +insert into t1 values (0x0154),(0x0155),(0x0156),(0x0157); +insert into t1 values (0x0158),(0x0159),(0x015a),(0x015b); +insert into t1 values (0x015c),(0x015d),(0x015e),(0x015f); +insert into t1 values (0x0160),(0x0161),(0x0162),(0x0163); +insert into t1 values (0x0164),(0x0165),(0x0166),(0x0167); +insert into t1 values (0x0168),(0x0169),(0x016a),(0x016b); +insert into t1 values (0x016c),(0x016d),(0x016e),(0x016f); +insert into t1 values (0x0170),(0x0171),(0x0172),(0x0173); +insert into t1 values (0x0174),(0x0175),(0x0176),(0x0177); +insert into t1 values (0x0178),(0x0179),(0x017a),(0x017b); +insert into t1 values (0x017c),(0x017d),(0x017e),(0x017f); +insert into t1 values (0x0180),(0x0181),(0x0182),(0x0183); +insert into t1 values (0x0184),(0x0185),(0x0186),(0x0187); +insert into t1 values (0x0188),(0x0189),(0x018a),(0x018b); +insert into t1 values (0x018c),(0x018d),(0x018e),(0x018f); +insert into t1 values (0x0190),(0x0191),(0x0192),(0x0193); +insert into t1 values (0x0194),(0x0195),(0x0196),(0x0197); +insert into t1 values (0x0198),(0x0199),(0x019a),(0x019b); +insert into t1 values (0x019c),(0x019d),(0x019e),(0x019f); +insert into t1 values (0x01a0),(0x01a1),(0x01a2),(0x01a3); +insert into t1 values (0x01a4),(0x01a5),(0x01a6),(0x01a7); +insert into t1 values (0x01a8),(0x01a9),(0x01aa),(0x01ab); +insert into t1 values (0x01ac),(0x01ad),(0x01ae),(0x01af); +insert into t1 values (0x01b0),(0x01b1),(0x01b2),(0x01b3); +insert into t1 values (0x01b4),(0x01b5),(0x01b6),(0x01b7); +insert into t1 values (0x01b8),(0x01b9),(0x01ba),(0x01bb); +insert into t1 values (0x01bc),(0x01bd),(0x01be),(0x01bf); +insert into t1 values (0x01c0),(0x01c1),(0x01c2),(0x01c3); +insert into t1 values (0x01c4),(0x01c5),(0x01c6),(0x01c7); +insert into t1 values (0x01c8),(0x01c9),(0x01ca),(0x01cb); +insert into t1 values (0x01cc),(0x01cd),(0x01ce),(0x01cf); +insert into t1 values (0x01d0),(0x01d1),(0x01d2),(0x01d3); +insert into t1 values (0x01d4),(0x01d5),(0x01d6),(0x01d7); +insert into t1 values (0x01d8),(0x01d9),(0x01da),(0x01db); +insert into t1 values (0x01dc),(0x01dd),(0x01de),(0x01df); +insert into t1 values (0x01e0),(0x01e1),(0x01e2),(0x01e3); +insert into t1 values (0x01e4),(0x01e5),(0x01e6),(0x01e7); +insert into t1 values (0x01e8),(0x01e9),(0x01ea),(0x01eb); +insert into t1 values (0x01ec),(0x01ed),(0x01ee),(0x01ef); +insert into t1 values (0x01f0),(0x01f1),(0x01f2),(0x01f3); +insert into t1 values (0x01f4),(0x01f5),(0x01f6),(0x01f7); +insert into t1 values (0x01f8),(0x01f9),(0x01fa),(0x01fb); +insert into t1 values (0x01fc),(0x01fd),(0x01fe),(0x01ff); +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_unicode_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_icelandic_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaÀÂĂàâãĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +Ăá +ǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +Ăð +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +EeĂÊËèêëĒēĔĕĖėÄęĚě +Éé +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŽĂŹĂ¬Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ĂŤĂ­ +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÔÕòôõŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Óó +Ǿǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÛÜùûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Úú +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÿŶŷŸ +Ýý +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Þþ +ÄÆäæ +Ă–Ăöø +Ă…ĂĄ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_latvian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċ +CHChcHch +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġǦǧǴǵ +Ģģ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +Yy +ı +Ć— +Ć– +JjĴĵǰ +KkǨǩ +Ķķ +ĆĆ™ +LlĹ弾 +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +Ļļ +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŇĹǸǹ +NJNjnJnjNJNjnj +Ņņ +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕĹĹ™ +RRRrrRrr +Ĺ–Ĺ— +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +ÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_romanian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂÄÅàáãäåĀÄĄąǍǎǞǟǠǡǺǻ +AAAaaAaa +Ä‚Ä +Ââ +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŹĂ¬Ă­ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ĂŽĂ® +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŠšſ +SSSssSssĂź +Şş +Ć© +ĆŞ +TtŤť +Ćľ +Ţţ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_slovenian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċ +CHChcHch +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_polish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄÄ‚ÄǍǎǞǟǠǡǺǻ +AAAaaAaa +Ąą +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçÄĉĊċČč +CHChcHch +Ćć +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėĚě +ÄÄ™ +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñŅņŇĹǸǹ +NJNjnJnjNJNjnj +ĹĹ„ +Ćť +Ćž +ĹŠĹ‹ +OoÒÔÕÖòôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Óó +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŜŝŞşŠšſ +SSSssSssĂź +Śś +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŽž +ĆŤ +Źź +Żż +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_estonian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÅàáâãåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdz +DŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔòóôŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Zz +Žž +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Õõ +Ää +Öö +Üü +Xx +YyÝýÿŶŷŸ +Ƴƴ +ŹźŻż +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_spanish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ññ +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_swedish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂàáâãĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕòóôõŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Ǿǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÜÝüýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ă…ĂĄ +ÄÆäæ +Ă–Ăöø +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_turkish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcĆćÄĉĊċČč +CHChcHch +Çç +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĠġĢģǦǧǴǵ +Ğğ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +Iı +IJIj +ƕǶ +Ħħ +iĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +iJijIJij +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕòóôõŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Öö +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŠšſ +SSSssSssĂź +Şş +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Üü +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_czech_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċ +cH +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +CHChch +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗ +RRRrrRrr +ĹĹ™ +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_danish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂàáâãĀÄĂĥąǍǎǞǟǠǡǺǻ +aA +ǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕòóôõŌōŎŏƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Ǿǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÜÝüýÿŰűŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +ÄÆäæ +Ă–ĂöøĹĹ‘ +AAAaaaĂ…ĂĄ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_lithuanian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CCHChcchÇçĆćÄĉĊċ +cH +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IYiyĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +ÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_slovak_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÅàáâãåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +Ää +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċ +cH +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +CHChch +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÕÖòóõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Ôô +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_spanish2_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +cH +CHChch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +lL +LLLlll +ĹĹ‚ +Ćš +Ć› +Mm +NnĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ññ +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_roman_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IJijĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJij +IJij +ı +Ć— +Ć– +Ĵĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJlj +LJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnj +NJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +ÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +UVuv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_esperanto_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćĊċČč +CHChcHch +Äĉ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĞğĠġĢģǦǧǴǵ +Ĝĝ +Ǥǥ +Ć“ +Ć” +Ƣƣ +Hh +Ĥĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +Jjǰ +Ĵĵ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŞşŠšſ +SSSssSssĂź +Ŝŝ +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ŭŭ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_hungarian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕòóôõŌōŎŏƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ÖöĹĹ‘ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŲųƯưǓǔǕǖǗÇǙǚǛǜ +ÜüŰű +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +drop table t1; +SET NAMES utf8; +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_general_ci; +c +ÎśĎ‰Î´Î±á˝·Ě +INSERT INTO t1 VALUES (0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_general_ci ORDER BY c; +c +Μωδ +ÎśĎ‰Î´Î±á˝·Ě +DROP TABLE t1; +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_unicode_ci; +c +ÎśĎ‰Î´Î±á˝·Ě +INSERT INTO t1 VALUES (0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_unicode_ci ORDER BY c; +c +Μωδ +ÎśĎ‰Î´Î±á˝·Ě +DROP TABLE t1; +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_unicode_ci; +c +ÎśĎ‰Î´Î±á˝·Ě +INSERT INTO t1 VALUES (0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_unicode_ci ORDER BY c; +c +Μωδ +ÎśĎ‰Î´Î±á˝·Ě +DROP TABLE t1; +SET NAMES utf8; +SET @test_character_set='utf16'; +SET @test_collation='utf16_swedish_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) utf16_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) utf16_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) COLLATE utf16_swedish_ci DEFAULT NULL, + `level` smallint(5) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf16 COLLATE=utf16_swedish_ci +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; +SET collation_connection='utf16_unicode_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf16_unicode_ci 00610009 +utf16_unicode_ci 0061 +utf16_unicode_ci 00610020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf16_unicode_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +End of 4.1 tests +CREATE TABLE t1 (id int, a varchar(30) character set utf16); +INSERT INTO t1 VALUES (1, 0x01310069), (2, 0x01310131); +INSERT INTO t1 VALUES (3, 0x00690069), (4, 0x01300049); +INSERT INTO t1 VALUES (5, 0x01300130), (6, 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 4 ıi 4 II 4 +ıı 4 ıı 4 II 4 +ii 4 ii 4 II 4 +İI 4 ii 4 İI 4 +İİ 4 ii 4 İİ 4 +II 4 ii 4 II 4 +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf16 collate utf16_turkish_ci; +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 4 ıi 4 Iİ 4 +ıı 4 ıı 4 II 4 +ii 4 ii 4 İİ 4 +İI 4 iı 4 İI 4 +İİ 4 ii 4 İİ 4 +II 4 ıı 4 II 4 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 text character set utf16 collate utf16_polish_ci NOT NULL +) ENGINE=MyISAM; +insert into t1 values (''),('a'); +SELECT COUNT(*), c1 FROM t1 GROUP BY c1; +COUNT(*) c1 +1 +1 a +DROP TABLE IF EXISTS t1; +set collation_connection=utf16_unicode_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf16 COLLATE utf16_unicode_ci DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf16 COLLATE utf16_unicode_ci DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +insert into t1 values('ghi','ghi['); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +NULL +drop table t1; +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_utf32.result b/mysql-test/r/ctype_utf32.result new file mode 100644 index 00000000000..f0f10be9743 --- /dev/null +++ b/mysql-test/r/ctype_utf32.result @@ -0,0 +1,1052 @@ +DROP TABLE IF EXISTS t1; +# +# Start of 5.5 tests +# +SET NAMES latin1; +SET character_set_connection=utf32; +select hex('a'), hex('a '); +hex('a') hex('a ') +00000061 0000006100000020 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +0 1 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +0 0 1 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +0 1 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +0 0 1 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 1 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +select hex(_utf32 0x44); +hex(_utf32 0x44) +00000044 +select hex(_utf32 0x3344); +hex(_utf32 0x3344) +00003344 +select hex(_utf32 0x103344); +hex(_utf32 0x103344) +00103344 +select hex(_utf32 X'44'); +hex(_utf32 X'44') +00000044 +select hex(_utf32 X'3344'); +hex(_utf32 X'3344') +00003344 +select hex(_utf32 X'103344'); +hex(_utf32 X'103344') +00103344 +CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf32; +INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (X'2004',X'2004'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +00000420 +00002004 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +00000420 +00002004 +DELETE FROM t1; +INSERT INTO t1 VALUES +(X'000004200000002000000020',X'000004200000002000000020'), +(X'000020040000002000000020',X'000020040000002000000020'); +SELECT hex(word) FROM t1 ORDER BY word; +hex(word) +000004200000002000000020 +000020040000002000000020 +SELECT hex(word2) FROM t1 ORDER BY word2; +hex(word2) +00000420 +00002004 +DROP TABLE t1; +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'0421')); +hex(LPAD(_utf32 X'0420',10,_utf32 X'0421')) +00000421000004210000042100000421000004210000042100000421000004210000042100000420 +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')); +hex(LPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')) +00000421000004220000042100000422000004210000042200000421000004220000042100000420 +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')); +hex(LPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')) +00000421000004220000042300000421000004220000042300000421000004220000042300000420 +SELECT hex(LPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')); +hex(LPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')) +00000420000004210000042200000423000004240000042500000426000004270000042800000429 +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'0421')); +hex(RPAD(_utf32 X'0420',10,_utf32 X'0421')) +00000420000004210000042100000421000004210000042100000421000004210000042100000421 +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')); +hex(RPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')) +00000420000004210000042200000421000004220000042100000422000004210000042200000421 +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')); +hex(RPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')) +00000420000004210000042200000423000004210000042200000423000004210000042200000423 +SELECT hex(RPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')); +hex(RPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')) +00000420000004210000042200000423000004240000042500000426000004270000042800000429 +CREATE TABLE t1 SELECT +LPAD(_utf32 X'0420',10,_utf32 X'0421') l, +RPAD(_utf32 X'0420',10,_utf32 X'0421') r; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `l` varchar(10) CHARACTER SET utf32 NOT NULL DEFAULT '', + `r` varchar(10) CHARACTER SET utf32 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select hex(l), hex(r) from t1; +hex(l) hex(r) +00000421000004210000042100000421000004210000042100000421000004210000042100000420 00000420000004210000042100000421000004210000042100000421000004210000042100000421 +DROP TABLE t1; +create table t1 (f1 char(30)); +insert into t1 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t1; +lpad(f1, 12, "-o-/") +-o-/-o103000 +-o-/22720000 +-o-/-3401200 +-o-/-o-78000 +drop table t1; +SET NAMES latin1; +SET character_set_connection=utf32; +select @@collation_connection; +@@collation_connection +utf32_general_ci +create table t1 as select repeat(' ',10) as a union select null; +alter table t1 add key(a); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf32 DEFAULT NULL, + KEY `a` (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +explain select * from t1 where a like 'abc%'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index +explain select * from t1 where a like concat('abc','%'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 43 NULL 1 Using where; Using index +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +select 'AA' like 'AA'; +'AA' like 'AA' +1 +select 'AA' like 'A%A'; +'AA' like 'A%A' +1 +select 'AA' like 'A%%A'; +'AA' like 'A%%A' +1 +select 'AA' like 'AA%'; +'AA' like 'AA%' +1 +select 'AA' like '%AA%'; +'AA' like '%AA%' +1 +select 'AA' like '%A'; +'AA' like '%A' +1 +select 'AA' like '%AA'; +'AA' like '%AA' +1 +select 'AA' like 'A%A%'; +'AA' like 'A%A%' +1 +select 'AA' like '_%_%'; +'AA' like '_%_%' +1 +select 'AA' like '%A%A'; +'AA' like '%A%A' +1 +select 'AAA'like 'A%A%A'; +'AAA'like 'A%A%A' +1 +select 'AZ' like 'AZ'; +'AZ' like 'AZ' +1 +select 'AZ' like 'A%Z'; +'AZ' like 'A%Z' +1 +select 'AZ' like 'A%%Z'; +'AZ' like 'A%%Z' +1 +select 'AZ' like 'AZ%'; +'AZ' like 'AZ%' +1 +select 'AZ' like '%AZ%'; +'AZ' like '%AZ%' +1 +select 'AZ' like '%Z'; +'AZ' like '%Z' +1 +select 'AZ' like '%AZ'; +'AZ' like '%AZ' +1 +select 'AZ' like 'A%Z%'; +'AZ' like 'A%Z%' +1 +select 'AZ' like '_%_%'; +'AZ' like '_%_%' +1 +select 'AZ' like '%A%Z'; +'AZ' like '%A%Z' +1 +select 'AZ' like 'A_'; +'AZ' like 'A_' +1 +select 'AZ' like '_Z'; +'AZ' like '_Z' +1 +select 'AMZ'like 'A%M%Z'; +'AMZ'like 'A%M%Z' +1 +SET NAMES utf8; +SET character_set_connection=utf32; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32); +INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывĐ'),('ФЫВĐ'); +INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж'); +INSERT INTO t1 VALUES ('фывĐпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж'); +INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВĐПРОЛДЖ'); +SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a; +a +ФЫВР+ФЫВĐПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывР+фывĐпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a; +a +ФЫВР+ФЫВĐПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывР+фывĐпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a; +a +ФЫВР+ФЫВĐПРОЛДЖ +Фыва +Фывапролдж +фЫва +фЫвапролдж +фыВа +фыВапролдж +фывР+фывĐпролдж +фыва +фываПролдж +фывапРолдж +фывапрОлдж +фывапроЛдж +фывапролДж +фывапролдЖ +фывапролдж +SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf32_bin ORDER BY BINARY a; +a +фЫва +фЫвапролдж +DROP TABLE t1; +CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word)) +ENGINE=MyISAM CHARACTER SET utf32; +INSERT INTO t1 (word) VALUES ("cat"); +SELECT * FROM t1 WHERE word LIKE "c%"; +word +cat +SELECT * FROM t1 WHERE word LIKE "ca_"; +word +cat +SELECT * FROM t1 WHERE word LIKE "cat"; +word +cat +SELECT * FROM t1 WHERE word LIKE _utf32 x'0000006300000025'; +word +cat +SELECT * FROM t1 WHERE word LIKE _utf32 x'00000063000000610000005F'; +word +cat +DROP TABLE t1; +select insert(_utf32 0x000000610000006200000063,10,2,_utf32 0x000000640000006500000066); +insert(_utf32 0x000000610000006200000063,10,2,_utf32 0x000000640000006500000066) +abc +select insert(_utf32 0x000000610000006200000063,1,2,_utf32 0x000000640000006500000066); +insert(_utf32 0x000000610000006200000063,1,2,_utf32 0x000000640000006500000066) +defc +SET NAMES latin1; +CREATE TABLE t1 ( +word VARCHAR(64), +bar INT(11) default 0, +PRIMARY KEY (word)) +ENGINE=MyISAM +CHARSET utf32 +COLLATE utf32_general_ci ; +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a"); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY word; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort +SELECT * FROM t1 ORDER BY word; +word bar +a 0 +aar 0 +aardvar 0 +aardvara 0 +aardvark 0 +aardvarz 0 +EXPLAIN SELECT word FROM t1 ORDER BY word; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 258 NULL 6 Using index +SELECT word FROM t1 ORDER by word; +word +a +aar +aardvar +aardvara +aardvark +aardvarz +DROP TABLE t1; +CREATE TABLE t1 ( +word VARCHAR(64) , +PRIMARY KEY (word)) +ENGINE=MyISAM +CHARSET utf32 +COLLATE utf32_general_ci; +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a"); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY WORD; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 258 NULL 6 Using index +SELECT * FROM t1 ORDER BY word; +word +a +aar +aardvar +aardvara +aardvark +aardvarz +DROP TABLE t1; +CREATE TABLE t1 ( +word TEXT, +bar INT(11) AUTO_INCREMENT, +PRIMARY KEY (bar)) +ENGINE=MyISAM +CHARSET utf32 +COLLATE utf32_general_ci ; +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a" ); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY word; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort +SELECT * FROM t1 ORDER BY word; +word bar +a 2 +aar 1 +aardvar 3 +aardvara 5 +aardvark 4 +aardvarz 6 +EXPLAIN SELECT word FROM t1 ORDER BY word; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort +SELECT word FROM t1 ORDER BY word; +word +a +aar +aardvar +aardvara +aardvark +aardvarz +DROP TABLE t1; +SELECT hex(cast(0xAA as char character set utf32)); +hex(cast(0xAA as char character set utf32)) +000000AA +SELECT hex(convert(0xAA using utf32)); +hex(convert(0xAA using utf32)) +000000AA +CREATE TABLE t1 (a char(10) character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a varchar(10) character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a text character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a mediumtext character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +CREATE TABLE t1 (a longtext character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +HEX(a) +00000001 +00000011 +00000111 +00001111 +00011111 +DROP TABLE t1; +create table t1(a char(1)) default charset utf32; +insert into t1 values ('a'),('b'),('c'); +alter table t1 modify a char(5); +select a, hex(a) from t1; +a hex(a) +a 00000061 +b 00000062 +c 00000063 +drop table t1; +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using utf32); +prepare stmt1 from @str2; +execute stmt1 using @ivar; +? +1234 +set names utf8; +create table t1 (a enum('x','y','z') character set utf32); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z') CHARACTER SET utf32 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +select a, hex(a) from t1 order by a; +a hex(a) +x 00000078 +y 00000079 +z 0000007A +alter table t1 change a a enum('x','y','z','d','e','ä','ö','ĂĽ') character set utf32; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x','y','z','d','e','ä','ö','ĂĽ') CHARACTER SET utf32 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('D'); +insert into t1 values ('E '); +insert into t1 values ('ä'); +insert into t1 values ('ö'); +insert into t1 values ('ĂĽ'); +select a, hex(a) from t1 order by a; +a hex(a) +x 00000078 +y 00000079 +z 0000007A +d 00000064 +e 00000065 +ä 000000E4 +ö 000000F6 +ĂĽ 000000FC +drop table t1; +create table t1 (a set ('x','y','z','ä','ö','ĂĽ') character set utf32); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` set('x','y','z','ä','ö','ĂĽ') CHARACTER SET utf32 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +insert into t1 values ('x,y'); +insert into t1 values ('x,y,z,ä,ö,ĂĽ'); +select a, hex(a) from t1 order by a; +a hex(a) +x 00000078 +y 00000079 +x,y 000000780000002C00000079 +z 0000007A +x,y,z,ä,ö,ĂĽ 000000780000002C000000790000002C0000007A0000002C000000E40000002C000000F60000002C000000FC +drop table t1; +create table t1(a enum('a','b','c')) default character set utf32; +insert into t1 values('a'),('b'),('c'); +alter table t1 add b char(1); +show warnings; +Level Code Message +select * from t1 order by a; +a b +a NULL +b NULL +c NULL +drop table t1; +SET NAMES latin1; +SET collation_connection='utf32_general_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf32_general_ci 0000006100000009 +utf32_general_ci 00000061 +utf32_general_ci 0000006100000020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf32_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +SET NAMES latin1; +SET collation_connection='utf32_bin'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf32_bin 0000006100000009 +utf32_bin 00000061 +utf32_bin 0000006100000020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf32_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +select hex(substr(_utf32 0x000000e4000000e500000068,1)); +hex(substr(_utf32 0x000000e4000000e500000068,1)) +000000E4000000E500000068 +select hex(substr(_utf32 0x000000e4000000e500000068,2)); +hex(substr(_utf32 0x000000e4000000e500000068,2)) +000000E500000068 +select hex(substr(_utf32 0x000000e4000000e500000068,3)); +hex(substr(_utf32 0x000000e4000000e500000068,3)) +00000068 +select hex(substr(_utf32 0x000000e4000000e500000068,-1)); +hex(substr(_utf32 0x000000e4000000e500000068,-1)) +00000068 +select hex(substr(_utf32 0x000000e4000000e500000068,-2)); +hex(substr(_utf32 0x000000e4000000e500000068,-2)) +000000E500000068 +select hex(substr(_utf32 0x000000e4000000e500000068,-3)); +hex(substr(_utf32 0x000000e4000000e500000068,-3)) +000000E4000000E500000068 +CREATE TABLE t1 ( +a varchar(250) NOT NULL default '', +KEY a (a) +) ENGINE=MyISAM DEFAULT CHARSET=utf32 COLLATE utf32_general_ci; +insert into t1 values (0x803d); +insert into t1 values (0x005b); +select hex(a) from t1; +hex(a) +0000005B +0000803D +drop table t1; +create table t1 (utext varchar(20) character set utf32); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +create table t1 ( +a char(10) character set utf32 not null, +index a (a) +) engine=myisam; +insert into t1 values (repeat(0x0000201f, 10)); +insert into t1 values (repeat(0x00002020, 10)); +insert into t1 values (repeat(0x00002021, 10)); +explain select hex(a) from t1 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 40 NULL 3 Using index +select hex(a) from t1 order by a; +hex(a) +0000201F0000201F0000201F0000201F0000201F0000201F0000201F0000201F0000201F0000201F +00002020000020200000202000002020000020200000202000002020000020200000202000002020 +00002021000020210000202100002021000020210000202100002021000020210000202100002021 +alter table t1 drop index a; +select hex(a) from t1 order by a; +hex(a) +0000201F0000201F0000201F0000201F0000201F0000201F0000201F0000201F0000201F0000201F +00002020000020200000202000002020000020200000202000002020000020200000202000002020 +00002021000020210000202100002021000020210000202100002021000020210000202100002021 +drop table t1; +CREATE TABLE t1 ( +status enum('active','passive') character set utf32 collate utf32_general_ci +NOT NULL default 'passive' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf32 NOT NULL DEFAULT 'passive' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 ADD a int NOT NULL AFTER status; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `status` enum('active','passive') CHARACTER SET utf32 NOT NULL DEFAULT 'passive', + `a` int(11) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +End of 4.1 tests +CREATE TABLE t1 (a varchar(64) character set utf32, b decimal(10,3)); +INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); +update t1 set b=a; +SELECT *, hex(a) FROM t1; +a b hex(a) +1.1 1.100 000000310000002E00000031 +2.1 2.100 000000320000002E00000031 +DROP TABLE t1; +create table t1 (utext varchar(20) character set utf32); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +utext +lily +river +execute stmt using @param1; +utext +lily +river +select utext from t1 where utext like '%%'; +utext +lily +river +drop table t1; +deallocate prepare stmt; +set names latin1; +set character_set_connection=utf32; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb') + H000 H4142 I51231 +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +hex(soundex('')) hex(soundex('he')) hex(soundex('hello all folks')) hex(soundex('#3556 in bugdb')) + 00000048000000300000003000000030 0000004800000034000000310000003400000032 000000490000003500000031000000320000003300000031 +select 'mood' sounds like 'mud'; +'mood' sounds like 'mud' +1 +select hex(soundex(_utf32 0x000004100000041100000412)); +hex(soundex(_utf32 0x000004100000041100000412)) +00000410000000300000003000000030 +select hex(soundex(_utf32 0x000000BF000000C0)); +hex(soundex(_utf32 0x000000BF000000C0)) +000000C0000000300000003000000030 +set names latin1; +create table t1(a blob, b text charset utf32); +select data_type, character_octet_length, character_maximum_length +from information_schema.columns where table_name='t1'; +data_type character_octet_length character_maximum_length +blob 65535 65535 +text 65535 16383 +drop table t1; +set names latin1; +set collation_connection=utf32_general_ci; +select position('bb' in 'abba'); +position('bb' in 'abba') +2 +create table t1 (a varchar(10) character set utf32) engine=heap; +insert into t1 values ('a'),('A'),('b'),('B'); +select * from t1 where a='a' order by binary a; +a +A +a +select hex(min(binary a)),count(*) from t1 group by a; +hex(min(binary a)) count(*) +00000041 2 +00000042 2 +drop table t1; +select char_length('abcd'), octet_length('abcd'); +char_length('abcd') octet_length('abcd') +4 16 +select left('abcd',2); +left('abcd',2) +ab +create table t1 (a varchar(10) character set utf32); +insert into t1 values (_utf32 0x0010FFFF); +insert into t1 values (_utf32 0x00110000); +ERROR HY000: Invalid utf32 character string: '001100' +insert into t1 values (_utf32 0x00110101); +ERROR HY000: Invalid utf32 character string: '001101' +insert into t1 values (_utf32 0x01000101); +ERROR HY000: Invalid utf32 character string: '010001' +insert into t1 values (_utf32 0x11000101); +ERROR HY000: Invalid utf32 character string: '110001' +select hex(a) from t1; +hex(a) +0010FFFF +drop table t1; +create table t1 (utf32 varchar(2) character set utf32); +Wrong character with pad +insert into t1 values (0x110000); +Warnings: +Warning 1366 Incorrect string value: '\x11\x00\x00' for column 'utf32' at row 1 +Wrong chsaracter without pad +insert into t1 values (0x00110000); +Warnings: +Warning 1366 Incorrect string value: '\x00\x11\x00\x00' for column 'utf32' at row 1 +Wrong character with pad followed by another wrong character +insert into t1 values (0x11000000110000); +Warnings: +Warning 1366 Incorrect string value: '\x11\x00\x00\x00\x11\x00...' for column 'utf32' at row 1 +Good character with pad followed by bad character +insert into t1 values (0x10000000110000); +Warnings: +Warning 1366 Incorrect string value: '\x00\x11\x00\x00' for column 'utf32' at row 1 +Good character without pad followed by bad character +insert into t1 values (0x0010000000110000); +Warnings: +Warning 1366 Incorrect string value: '\x00\x11\x00\x00' for column 'utf32' at row 1 +Wrong character with the second byte higher than 0x10 +insert into t1 values (0x00800037); +Warnings: +Warning 1366 Incorrect string value: '\x00\x80\x007' for column 'utf32' at row 1 +Wrong character with pad with the second byte higher than 0x10 +insert into t1 values (0x00800037); +Warnings: +Warning 1366 Incorrect string value: '\x00\x80\x007' for column 'utf32' at row 1 +drop table t1; +select _utf32'a' collate utf32_general_ci = 0xfffd; +_utf32'a' collate utf32_general_ci = 0xfffd +0 +select hex(concat(_utf32 0x0410 collate utf32_general_ci, 0x61)); +hex(concat(_utf32 0x0410 collate utf32_general_ci, 0x61)) +0000041000000061 +create table t1 (s1 varchar(5) character set utf32); +insert into t1 values (0xfffd); +select case when s1 = 0xfffd then 1 else 0 end from t1; +case when s1 = 0xfffd then 1 else 0 end +1 +select hex(s1) from t1 where s1 = 0xfffd; +hex(s1) +0000FFFD +drop table t1; +create table t1 (a char(10)) character set utf32; +insert into t1 values ('a '); +select hex(a) from t1; +hex(a) +00000061 +drop table t1; +select upper('abcd'), lower('ABCD'); +upper('abcd') lower('ABCD') +ABCD abcd +create table t1 (a varchar(10) character set utf32); +insert into t1 values (123456); +select a, hex(a) from t1; +a hex(a) +123456 000000310000003200000033000000340000003500000036 +drop table t1; +select hex(soundex('a')); +hex(soundex('a')) +00000041000000300000003000000030 +create table t1 (a enum ('a','b','c')) character set utf32; +insert into t1 values ('1'); +select * from t1; +a +a +drop table t1; +set names latin1; +select hex(conv(convert('123' using utf32), -10, 16)); +hex(conv(convert('123' using utf32), -10, 16)) +3742 +select hex(conv(convert('123' using utf32), 10, 16)); +hex(conv(convert('123' using utf32), 10, 16)) +3742 +set names latin1; +set character_set_connection=utf32; +select 1.1 + '1.2'; +1.1 + '1.2' +2.3 +select 1.1 + '1.2xxx'; +1.1 + '1.2xxx' +2.3 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '' +select left('aaa','1'); +left('aaa','1') +a +create table t1 (a int); +insert into t1 values ('-1234.1e2'); +insert into t1 values ('-1234.1e2xxxx'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +insert into t1 values ('-1234.1e2 '); +select * from t1; +a +-123410 +-123410 +-123410 +drop table t1; +create table t1 (a int); +insert into t1 values ('1 '); +insert into t1 values ('1 x'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +1 +1 +drop table t1; +create table t1 (a varchar(17000) character set utf32); +Warnings: +Note 1246 Converting column 'a' from VARCHAR to TEXT +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` mediumtext CHARACTER SET utf32 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a varchar(250) character set utf32 primary key); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(250) CHARACTER SET utf32 NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a varchar(334) character set utf32 primary key); +ERROR 42000: Specified key was too long; max key length is 1000 bytes +create table t1 (a varchar(333) character set utf32, key(a)); +Warnings: +Warning 1071 Specified key was too long; max key length is 1000 bytes +insert into t1 values (repeat('a',333)), (repeat('b',333)); +flush tables; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +SET collation_connection=utf32_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0; +SET timestamp=1216359724; +INSERT INTO t1 VALUES (current_date); +INSERT INTO t1 VALUES (current_time); +INSERT INTO t1 VALUES (current_timestamp); +SELECT s1, hex(s1) FROM t1; +s1 hex(s1) +2008-07-18 000000320000003000000030000000380000002D00000030000000370000002D0000003100000038 +08:42:04 00000030000000380000003A00000034000000320000003A0000003000000034 +2008-07-18 08:42:04 000000320000003000000030000000380000002D00000030000000370000002D00000031000000380000002000000030000000380000003A00000034000000320000003A0000003000000034 +DROP TABLE t1; +SET timestamp=0; +SET NAMES latin1; +set collation_connection=utf32_general_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf32 DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf32 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +insert into t1 values('ghi','ghi['); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +NULL +drop table t1; +set names latin1; +select hex(char(0x01 using utf32)); +hex(char(0x01 using utf32)) +00000001 +select hex(char(0x0102 using utf32)); +hex(char(0x0102 using utf32)) +00000102 +select hex(char(0x010203 using utf32)); +hex(char(0x010203 using utf32)) +00010203 +select hex(char(0x01020304 using utf32)); +hex(char(0x01020304 using utf32)) + +Warnings: +Warning 1300 Invalid utf32 character string: '010203' +create table t1 (s1 varchar(1) character set utf32, s2 text character set utf32); +create index i on t1 (s1); +insert into t1 values (char(256 using utf32), char(256 using utf32)); +select hex(s1), hex(s2) from t1; +hex(s1) hex(s2) +00000100 00000100 +drop table t1; +SET collation_connection=utf32_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(2) CHARACTER SET utf32 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE'); +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +SET max_sort_length=4; +SELECT * FROM t1 ORDER BY s1; +s1 +ab +ab +AE +AE +DROP TABLE t1; +SET max_sort_length=DEFAULT; +SET NAMES latin1; +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_utf32_uca.result b/mysql-test/r/ctype_utf32_uca.result new file mode 100644 index 00000000000..5006009fc9c --- /dev/null +++ b/mysql-test/r/ctype_utf32_uca.result @@ -0,0 +1,2373 @@ +DROP TABLE IF EXISTS t1; +# +# Start of 5.5 tests +# +set names utf8; +set collation_connection=utf32_unicode_ci; +select hex('a'), hex('a '); +hex('a') hex('a ') +00000061 0000006100000020 +select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; +'a' = 'a' 'a' = 'a ' 'a ' = 'a' +1 1 1 +select 'a\0' = 'a', 'a\0' < 'a', 'a\0' > 'a'; +'a\0' = 'a' 'a\0' < 'a' 'a\0' > 'a' +1 0 0 +select 'a' = 'a\0', 'a' < 'a\0', 'a' > 'a\0'; +'a' = 'a\0' 'a' < 'a\0' 'a' > 'a\0' +1 0 0 +select 'a\0' = 'a ', 'a\0' < 'a ', 'a\0' > 'a '; +'a\0' = 'a ' 'a\0' < 'a ' 'a\0' > 'a ' +1 0 0 +select 'a ' = 'a\0', 'a ' < 'a\0', 'a ' > 'a\0'; +'a ' = 'a\0' 'a ' < 'a\0' 'a ' > 'a\0' +1 0 0 +select 'a a' > 'a', 'a \0' < 'a'; +'a a' > 'a' 'a \0' < 'a' +1 0 +select binary 'a a' > 'a', binary 'a \0' > 'a', binary 'a\0' > 'a'; +binary 'a a' > 'a' binary 'a \0' > 'a' binary 'a\0' > 'a' +1 1 1 +select 'c' like '\_' as want0; +want0 +0 +CREATE TABLE t ( +c char(20) NOT NULL +) ENGINE=MyISAM DEFAULT CHARACTER SET utf32 COLLATE=utf32_unicode_ci; +INSERT INTO t VALUES ('a'),('ab'),('aba'); +ALTER TABLE t ADD INDEX (c); +SELECT c FROM t WHERE c LIKE 'a%'; +c +a +ab +aba +DROP TABLE t; +create table t1 (c1 char(10) character set utf32 collate utf32_bin); +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); +insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0); +insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1); +insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2); +insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3); +insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4); +insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5); +insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6); +insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7); +insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8); +insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9); +insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca); +insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb); +insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc); +insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd); +insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce); +insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf); +insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0); +insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1); +insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2); +insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3); +insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4); +insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5); +insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6); +insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7); +insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8); +insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9); +insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da); +insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db); +insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc); +insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd); +insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de); +insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df); +insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103); +insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107); +insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b); +insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f); +insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113); +insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117); +insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b); +insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f); +insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123); +insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127); +insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b); +insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f); +insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133); +insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137); +insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b); +insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f); +insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143); +insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147); +insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b); +insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f); +insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153); +insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157); +insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b); +insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f); +insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163); +insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167); +insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b); +insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f); +insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173); +insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177); +insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b); +insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f); +insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183); +insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187); +insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b); +insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f); +insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193); +insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197); +insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b); +insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f); +insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3); +insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7); +insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab); +insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af); +insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3); +insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7); +insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb); +insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf); +insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3); +insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7); +insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb); +insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf); +insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3); +insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7); +insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db); +insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df); +insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3); +insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7); +insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb); +insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef); +insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3); +insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7); +insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb); +insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff); +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_unicode_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_icelandic_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaÀÂĂàâãĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +Ăá +ǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +Ăð +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +EeĂÊËèêëĒēĔĕĖėÄęĚě +Éé +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŽĂŹĂ¬Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ĂŤĂ­ +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÔÕòôõŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Óó +Ǿǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÛÜùûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Úú +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÿŶŷŸ +Ýý +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Þþ +ÄÆäæ +Ă–Ăöø +Ă…ĂĄ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_latvian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċ +CHChcHch +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġǦǧǴǵ +Ģģ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +Yy +ı +Ć— +Ć– +JjĴĵǰ +KkǨǩ +Ķķ +ĆĆ™ +LlĹ弾 +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +Ļļ +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŇĹǸǹ +NJNjnJnjNJNjnj +Ņņ +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕĹĹ™ +RRRrrRrr +Ĺ–Ĺ— +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +ÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_romanian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂÄÅàáãäåĀÄĄąǍǎǞǟǠǡǺǻ +AAAaaAaa +Ä‚Ä +Ââ +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŹĂ¬Ă­ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ĂŽĂ® +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŠšſ +SSSssSssĂź +Şş +Ć© +ĆŞ +TtŤť +Ćľ +Ţţ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_slovenian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċ +CHChcHch +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_polish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄÄ‚ÄǍǎǞǟǠǡǺǻ +AAAaaAaa +Ąą +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçÄĉĊċČč +CHChcHch +Ćć +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėĚě +ÄÄ™ +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñŅņŇĹǸǹ +NJNjnJnjNJNjnj +ĹĹ„ +Ćť +Ćž +ĹŠĹ‹ +OoÒÔÕÖòôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Óó +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŜŝŞşŠšſ +SSSssSssĂź +Śś +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŽž +ĆŤ +Źź +Żż +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_estonian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÅàáâãåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdz +DŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔòóôŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Zz +Žž +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Õõ +Ää +Öö +Üü +Xx +YyÝýÿŶŷŸ +Ƴƴ +ŹźŻż +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_spanish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ññ +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_swedish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂàáâãĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕòóôõŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Ǿǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÜÝüýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ă…ĂĄ +ÄÆäæ +Ă–Ăöø +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_turkish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcĆćÄĉĊċČč +CHChcHch +Çç +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĠġĢģǦǧǴǵ +Ğğ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +Iı +IJIj +ƕǶ +Ħħ +iĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +iJijIJij +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕòóôõŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Öö +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŠšſ +SSSssSssĂź +Şş +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Üü +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_czech_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċ +cH +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +CHChch +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗ +RRRrrRrr +ĹĹ™ +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_danish_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂàáâãĀÄĂĥąǍǎǞǟǠǡǺǻ +aA +ǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕòóôõŌōŎŏƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Ǿǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÜÝüýÿŰűŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +ÄÆäæ +Ă–ĂöøĹĹ‘ +AAAaaaĂ…ĂĄ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_lithuanian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CCHChcchÇçĆćÄĉĊċ +cH +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IYiyĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +ÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_slovak_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÅàáâãåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +Ää +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċ +cH +ÄŚÄŤ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +CHChch +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÕÖòóõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +Ôô +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşſ +SSSssSssĂź +Šš +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻż +ĆŤ +Žž +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_spanish2_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +cH +CHChch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +lL +LLLlll +ĹĹ‚ +Ćš +Ć› +Mm +NnĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ññ +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_roman_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IJijĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJij +IJij +ı +Ć— +Ć– +Ĵĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJlj +LJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnj +NJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +ÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ćś +Ʊ +UVuv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_esperanto_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćĊċČč +CHChcHch +Äĉ +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĞğĠġĢģǦǧǴǵ +Ĝĝ +Ǥǥ +Ć“ +Ć” +Ƣƣ +Hh +Ĥĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +Jjǰ +Ĵĵ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕÖòóôõöŌōŎŏĹőƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŞşŠšſ +SSSssSssĂź +Ŝŝ +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛÜùúûüŨũŪūŮůŰűŲųƯưǓǔǕǖǗÇǙǚǛǜ +Ŭŭ +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_hungarian_ci; +group_concat(c1 order by binary c1 separator '') +Ă· +Ă— +AaĂ€ĂĂ‚ĂÄÅàáâãäåĀÄĂĥąǍǎǞǟǠǡǺǻ +AAAaaAaa +ÆæǢǣǼǽ +Bb +Ć€ +Ć +Âà +CcÇçĆćÄĉĊċČč +CHChcHch +Çà +DdÄŽÄŹ +DZDzdZdzDŽDždžDZDzdz +ÄÄ‘ +Ɖ +ĆŠ +Ƌƌ +Ăð +EeĂÉÊËèéêëĒēĔĕĖėÄęĚě +ĆŽÇť +ĆŹ +Ć +Ff +Ƒƒ +GgĜĝĞğĠġĢģǦǧǴǵ +Ǥǥ +Ć“ +Ć” +Ƣƣ +HhĤĥ +ƕǶ +Ħħ +IiĂŚĂŤĂŽĂŹĂ¬Ă­Ă®ĂŻÄ¨Ä©ÄŞÄ«Ä¬Ä­Ä®ÄŻÄ°ÇŹÇ +IJIjiJijIJij +ı +Ć— +Ć– +JjĴĵǰ +KkĶķǨǩ +ĆĆ™ +LlĹĺĻļĽľ +Ŀŀ +LJLjlJljLJÇlj +LLLllLll +ĹĹ‚ +Ćš +Ć› +Mm +NnÑñĹńŅņŇĹǸǹ +NJNjnJnjNJNjnj +Ćť +Ćž +ĹŠĹ‹ +OoÒÓÔÕòóôõŌōŎŏƠơǑǒǪǫǬǭ +OEOeoEoeĹ’Ĺ“ +ÖöĹĹ‘ +ĂøǾǿ +Ɔ +Ćź +Pp +Ƥƥ +Qq +ĸ +RrŔŕŖŗĹĹ™ +RRRrrRrr +Ʀ +SsŚśŜŝŞşŠšſ +SSSssSssĂź +Ć© +ĆŞ +TtŢţŤť +Ćľ +Ŧŧ +Ć« +Ƭƭ +Ć® +UuÙÚÛùúûŨũŪūŬŭŮůŲųƯưǓǔǕǖǗÇǙǚǛǜ +ÜüŰű +Ćś +Ʊ +Vv +Ʋ +WwŴŵ +Xx +YyÝýÿŶŷŸ +Ƴƴ +ZzŹźŻżŽž +ĆŤ +Ƶƶ +ƷǮǯ +Ƹƹ +Ćş +Þþ +ƿǷ +Ć» +Ƨƨ +ĆĽĆ˝ +Ƅƅ +ʼn +Ç€ +Ç +Ç‚ +Ç +drop table t1; +SET NAMES utf8; +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 COLLATE utf32_general_ci; +c +ÎśĎ‰Î´Î±á˝·Ě +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 +COLLATE utf32_general_ci ORDER BY c; +c +Μωδ +ÎśĎ‰Î´Î±á˝·Ě +DROP TABLE t1; +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 COLLATE utf32_unicode_ci; +c +ÎśĎ‰Î´Î±á˝·Ě +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B4); +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 +COLLATE utf32_unicode_ci ORDER BY c; +c +Μωδ +ÎśĎ‰Î´Î±á˝·Ě +DROP TABLE t1; +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf32) COLLATE utf32_unicode_ci; +c +ÎśĎ‰Î´Î±á˝·Ě +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf32) +COLLATE utf32_unicode_ci ORDER BY c; +c +Μωδ +ÎśĎ‰Î´Î±á˝·Ě +DROP TABLE t1; +SET NAMES utf8; +SET @test_character_set='utf32'; +SET @test_collation='utf32_swedish_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) utf32_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) utf32_swedish_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) COLLATE utf32_swedish_ci DEFAULT NULL, + `level` smallint(5) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf32 COLLATE=utf32_swedish_ci +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; +SET collation_connection='utf32_unicode_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf32_unicode_ci 0000006100000009 +utf32_unicode_ci 00000061 +utf32_unicode_ci 0000006100000020 +drop table t1; +select @@collation_connection; +@@collation_connection +utf32_unicode_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +End of 4.1 tests +CREATE TABLE t1 (id int, a varchar(30) character set utf32); +INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131); +INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049); +INSERT INTO t1 VALUES (5, _ucs2 0x01300130), (6, _ucs2 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 8 ıi 8 II 8 +ıı 8 ıı 8 II 8 +ii 8 ii 8 II 8 +İI 8 ii 8 İI 8 +İİ 8 ii 8 İİ 8 +II 8 ii 8 II 8 +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf32 collate utf32_turkish_ci; +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 8 ıi 8 Iİ 8 +ıı 8 ıı 8 II 8 +ii 8 ii 8 İİ 8 +İI 8 iı 8 İI 8 +İİ 8 ii 8 İİ 8 +II 8 ıı 8 II 8 +DROP TABLE t1; +CREATE TABLE t1 ( +c1 text character set utf32 collate utf32_polish_ci NOT NULL +) ENGINE=MyISAM; +insert into t1 values (''),('a'); +SELECT COUNT(*), c1 FROM t1 GROUP BY c1; +COUNT(*) c1 +1 +1 a +DROP TABLE IF EXISTS t1; +set collation_connection=utf32_unicode_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf32 COLLATE utf32_unicode_ci DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf32 COLLATE utf32_unicode_ci DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +insert into t1 values('ghi','ghi['); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +NULL +drop table t1; +# +# End of 5.5 tests +# diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 55c32c6a1d4..03040d1676c 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1899,6 +1899,20 @@ CONVERT(a, CHAR) CONVERT(b, CHAR) DROP TABLE t1; End of 5.0 tests Start of 5.4 tests +SET NAMES utf8mb3; +SHOW VARIABLES LIKE 'character_set_results%'; +Variable_name Value +character_set_results utf8 +CREATE TABLE t1 (a CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +SELECT _utf8mb3'test'; +test +test CREATE TABLE t1 ( clipid INT NOT NULL, Tape TINYTEXT, diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result new file mode 100644 index 00000000000..5eae2c3bc1a --- /dev/null +++ b/mysql-test/r/ctype_utf8mb4.result @@ -0,0 +1,2250 @@ +drop table if exists t1,t2; +# +# Start of 5.5 tests +# +set names utf8mb4; +select left(_utf8mb4 0xD0B0D0B1D0B2,1); +left(_utf8mb4 0xD0B0D0B1D0B2,1) +а +select right(_utf8mb4 0xD0B0D0B2D0B2,1); +right(_utf8mb4 0xD0B0D0B2D0B2,1) +в +select locate('he','hello'); +locate('he','hello') +1 +select locate('he','hello',2); +locate('he','hello',2) +0 +select locate('lo','hello',2); +locate('lo','hello',2) +4 +select locate('HE','hello'); +locate('HE','hello') +1 +select locate('HE','hello',2); +locate('HE','hello',2) +0 +select locate('LO','hello',2); +locate('LO','hello',2) +4 +select locate('HE','hello' collate utf8mb4_bin); +locate('HE','hello' collate utf8mb4_bin) +0 +select locate('HE','hello' collate utf8mb4_bin,2); +locate('HE','hello' collate utf8mb4_bin,2) +0 +select locate('LO','hello' collate utf8mb4_bin,2); +locate('LO','hello' collate utf8mb4_bin,2) +0 +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2); +locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2) +2 +select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2); +locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2) +2 +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2); +locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2) +2 +select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin); +locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin) +0 +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin); +locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin) +0 +select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1); +length(_utf8mb4 0xD0B1) bit_length(_utf8mb4 0xD0B1) char_length(_utf8mb4 0xD0B1) +2 16 1 +select 'a' like 'a'; +'a' like 'a' +1 +select 'A' like 'a'; +'A' like 'a' +1 +select 'A' like 'a' collate utf8mb4_bin; +'A' like 'a' collate utf8mb4_bin +0 +select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%'); +_utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%') +1 +select convert(_latin1'Günter André' using utf8mb4) like CONVERT(_latin1'GÜNTER%' USING utf8mb4); +convert(_latin1'G?nter Andr?' using utf8mb4) like CONVERT(_latin1'G?NTER%' USING utf8mb4) +1 +select CONVERT(_koi8r'×ÁÓŃ' USING utf8mb4) LIKE CONVERT(_koi8r'÷áóń' USING utf8mb4); +CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4) +1 +select CONVERT(_koi8r'÷áóń' USING utf8mb4) LIKE CONVERT(_koi8r'×ÁÓŃ' USING utf8mb4); +CONVERT(_koi8r'????' USING utf8mb4) LIKE CONVERT(_koi8r'????' USING utf8mb4) +1 +SELECT 'a' = 'a '; +'a' = 'a ' +1 +SELECT 'a\0' < 'a'; +'a\0' < 'a' +1 +SELECT 'a\0' < 'a '; +'a\0' < 'a ' +1 +SELECT 'a\t' < 'a'; +'a\t' < 'a' +1 +SELECT 'a\t' < 'a '; +'a\t' < 'a ' +1 +SELECT 'a' = 'a ' collate utf8mb4_bin; +'a' = 'a ' collate utf8mb4_bin +1 +SELECT 'a\0' < 'a' collate utf8mb4_bin; +'a\0' < 'a' collate utf8mb4_bin +1 +SELECT 'a\0' < 'a ' collate utf8mb4_bin; +'a\0' < 'a ' collate utf8mb4_bin +1 +SELECT 'a\t' < 'a' collate utf8mb4_bin; +'a\t' < 'a' collate utf8mb4_bin +1 +SELECT 'a\t' < 'a ' collate utf8mb4_bin; +'a\t' < 'a ' collate utf8mb4_bin +1 +CREATE TABLE t1 (a char(10) character set utf8mb4 not null); +INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a '); +SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1; +hex(a) STRCMP(a,'a') STRCMP(a,'a ') +61 0 0 +6100 -1 -1 +6109 -1 -1 +61 0 0 +DROP TABLE t1; +select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); +insert('txs',2,1,'hi') insert('is ',4,0,'a') insert('txxxxt',2,4,'es') +this is a test +select insert("aa",100,1,"b"),insert("aa",1,3,"b"); +insert("aa",100,1,"b") insert("aa",1,3,"b") +aa b +select char_length(left(@a:='теŃŃ‚',5)), length(@a), @a; +char_length(left(@a:='теŃŃ‚',5)) length(@a) @a +4 8 теŃŃ‚ +create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d"); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `date_format("2004-01-19 10:10:10", "%Y-%m-%d")` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t1; +date_format("2004-01-19 10:10:10", "%Y-%m-%d") +2004-01-19 +drop table t1; +set names utf8mb4; +set LC_TIME_NAMES='fr_FR'; +create table t1 (s1 char(20) character set latin1); +insert into t1 values (date_format('2004-02-02','%M')); +select hex(s1) from t1; +hex(s1) +66E97672696572 +drop table t1; +create table t1 (s1 char(20) character set koi8r); +set LC_TIME_NAMES='ru_RU'; +insert into t1 values (date_format('2004-02-02','%M')); +insert into t1 values (date_format('2004-02-02','%b')); +insert into t1 values (date_format('2004-02-02','%W')); +insert into t1 values (date_format('2004-02-02','%a')); +select hex(s1), s1 from t1; +hex(s1) s1 +E6C5D7D2C1CCD1 Февраля +E6C5D7 Фев +F0CFCEC5C4C5CCD8CEC9CB Понедельник +F0CEC4 Пнд +drop table t1; +set LC_TIME_NAMES='en_US'; +set names koi8r; +create table t1 (s1 char(1) character set utf8mb4); +insert into t1 values (_koi8r'ÁÂ'); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +select s1,hex(s1),char_length(s1),octet_length(s1) from t1; +s1 hex(s1) char_length(s1) octet_length(s1) +Á D0B0 1 2 +drop table t1; +create table t1 (s1 tinytext character set utf8mb4); +insert into t1 select repeat('a',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('Ń',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('aŃ',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('Ńa',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('ŃŃ',300); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 +D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F +61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F +D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61D18F61 +D18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18FD18F +select length(s1),char_length(s1) from t1; +length(s1) char_length(s1) +255 255 +254 127 +255 170 +255 170 +254 127 +drop table t1; +create table t1 (s1 text character set utf8mb4); +insert into t1 select repeat('a',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('Ń',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('aŃ',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('Ńa',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +insert into t1 select repeat('ŃŃ',66000); +Warnings: +Warning 1265 Data truncated for column 's1' at row 1 +select length(s1),char_length(s1) from t1; +length(s1) char_length(s1) +65535 65535 +65534 32767 +65535 43690 +65535 43690 +65534 32767 +drop table t1; +create table t1 (s1 char(10) character set utf8mb4); +insert into t1 values (0x41FF); +Warnings: +Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +41 +drop table t1; +create table t1 (s1 varchar(10) character set utf8mb4); +insert into t1 values (0x41FF); +Warnings: +Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +41 +drop table t1; +create table t1 (s1 text character set utf8mb4); +insert into t1 values (0x41FF); +Warnings: +Warning 1366 Incorrect string value: '\xFF' for column 's1' at row 1 +select hex(s1) from t1; +hex(s1) +41 +drop table t1; +create table t1 (a text character set utf8mb4, primary key(a(371))); +ERROR 42000: Specified key was too long; max key length is 1000 bytes +CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4; +INSERT INTO t1 VALUES ( 'test' ); +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a; +a a +test test +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test'; +a a +test test +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test'; +a a +test test +DROP TABLE t1; +create table t1 (a char(255) character set utf8mb4); +insert into t1 values('b'),('b'); +select * from t1 where a = 'b'; +a +b +b +select * from t1 where a = 'b' and a = 'b'; +a +b +b +select * from t1 where a = 'b' and a != 'b'; +a +drop table t1; +set collation_connection=utf8mb4_general_ci; +drop table if exists t1; +create table t1 as +select repeat(' ', 64) as s1, repeat(' ',64) as s2 +union +select null, null; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `s1` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL, + `s2` varchar(64) CHARACTER SET utf8mb4 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +delete from t1; +insert into t1 values('aaa','aaa'); +insert into t1 values('aaa|qqq','qqq'); +insert into t1 values('gheis','^[^a-dXYZ]+$'); +insert into t1 values('aab','^aa?b'); +insert into t1 values('Baaan','^Ba*n'); +insert into t1 values('aaa','qqq|aaa'); +insert into t1 values('qqq','qqq|aaa'); +insert into t1 values('bbb','qqq|aaa'); +insert into t1 values('bbb','qqq'); +insert into t1 values('aaa','aba'); +insert into t1 values(null,'abc'); +insert into t1 values('def',null); +insert into t1 values(null,null); +insert into t1 values('ghi','ghi['); +select HIGH_PRIORITY s1 regexp s2 from t1; +s1 regexp s2 +1 +1 +1 +1 +1 +1 +1 +0 +0 +0 +NULL +NULL +NULL +NULL +drop table t1; +set names utf8mb4; +set names utf8mb4; +select 'ваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +'ваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]' +1 +select 'ваŃŃŹ ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +'ваŃŃŹ ' rlike '[[:<:]]ваŃŃŹ[[:>:]]' +1 +select ' ваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +' ваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]' +1 +select ' ваŃŃŹ ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +' ваŃŃŹ ' rlike '[[:<:]]ваŃŃŹ[[:>:]]' +1 +select 'ваŃŃŹz' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +'ваŃŃŹz' rlike '[[:<:]]ваŃŃŹ[[:>:]]' +0 +select 'zваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +'zваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]' +0 +select 'zваŃŃŹz' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +'zваŃŃŹz' rlike '[[:<:]]ваŃŃŹ[[:>:]]' +0 +CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci); +ALTER TABLE t1 ADD COLUMN b CHAR(20); +DROP TABLE t1; +set names utf8mb4; +create table t1 (a enum('aaaa','проба') character set utf8mb4); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('aaaa','проба') CHARACTER SET utf8mb4 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values ('проба'); +select * from t1; +a +проба +create table t2 select ifnull(a,a) from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ifnull(a,a)` varchar(5) CHARACTER SET utf8mb4 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t2; +ifnull(a,a) +проба +drop table t1; +drop table t2; +create table t1 (c varchar(30) character set utf8mb4, unique(c(10))); +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +insert into t1 values ('aaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c' +insert into t1 values ('aaaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c' +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +c1 +1 +select c c2 from t1 where c='2'; +c2 +2 +select c c3 from t1 where c='3'; +c3 +3 +select c cx from t1 where c='x'; +cx +x +select c cy from t1 where c='y'; +cy +y +select c cz from t1 where c='z'; +cz +z +select c ca10 from t1 where c='aaaaaaaaaa'; +ca10 +aaaaaaaaaa +select c cb20 from t1 where c=repeat('b',20); +cb20 +bbbbbbbbbbbbbbbbbbbb +drop table t1; +create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=innodb; +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +insert into t1 values ('aaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c' +insert into t1 values ('aaaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c' +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +c1 +1 +select c c2 from t1 where c='2'; +c2 +2 +select c c3 from t1 where c='3'; +c3 +3 +select c cx from t1 where c='x'; +cx +x +select c cy from t1 where c='y'; +cy +y +select c cz from t1 where c='z'; +cz +z +select c ca10 from t1 where c='aaaaaaaaaa'; +ca10 +aaaaaaaaaa +select c cb20 from t1 where c=repeat('b',20); +cb20 +bbbbbbbbbbbbbbbbbbbb +drop table t1; +create table t1 (c char(3) character set utf8mb4, unique (c(2))); +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'aa' for key 'c' +insert into t1 values ('b'); +insert into t1 values ('bb'); +insert into t1 values ('bbb'); +ERROR 23000: Duplicate entry 'bb' for key 'c' +insert into t1 values ('а'); +insert into t1 values ('аа'); +insert into t1 values ('ааа'); +ERROR 23000: Duplicate entry 'аа' for key 'c' +insert into t1 values ('б'); +insert into t1 values ('бб'); +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'бб' for key 'c' +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +insert into t1 values ('ꪪꪪꪪ'); +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c' +drop table t1; +create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=innodb; +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'aa' for key 'c' +insert into t1 values ('b'); +insert into t1 values ('bb'); +insert into t1 values ('bbb'); +ERROR 23000: Duplicate entry 'bb' for key 'c' +insert into t1 values ('а'); +insert into t1 values ('аа'); +insert into t1 values ('ааа'); +ERROR 23000: Duplicate entry 'аа' for key 'c' +insert into t1 values ('б'); +insert into t1 values ('бб'); +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'бб' for key 'c' +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +insert into t1 values ('ꪪꪪꪪ'); +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c' +drop table t1; +create table t1 ( +c char(10) character set utf8mb4, +unique key a using hash (c(1)) +) engine=heap; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) USING HASH +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4, +unique key a using btree (c(1)) +) engine=heap; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) USING BTREE +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4, +unique key a (c(1)) +) engine=innodb; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10))); +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +insert into t1 values ('aaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c' +insert into t1 values ('aaaaaaaaaaaa'); +ERROR 23000: Duplicate entry 'aaaaaaaaaa' for key 'c' +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +c1 +1 +select c c2 from t1 where c='2'; +c2 +2 +select c c3 from t1 where c='3'; +c3 +3 +select c cx from t1 where c='x'; +cx +x +select c cy from t1 where c='y'; +cy +y +select c cz from t1 where c='z'; +cz +z +select c ca10 from t1 where c='aaaaaaaaaa'; +ca10 +aaaaaaaaaa +select c cb20 from t1 where c=repeat('b',20); +cb20 +bbbbbbbbbbbbbbbbbbbb +drop table t1; +create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2))); +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'aa' for key 'c' +insert into t1 values ('b'); +insert into t1 values ('bb'); +insert into t1 values ('bbb'); +ERROR 23000: Duplicate entry 'bb' for key 'c' +insert into t1 values ('а'); +insert into t1 values ('аа'); +insert into t1 values ('ааа'); +ERROR 23000: Duplicate entry 'аа' for key 'c' +insert into t1 values ('б'); +insert into t1 values ('бб'); +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'бб' for key 'c' +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +insert into t1 values ('ꪪꪪꪪ'); +ERROR 23000: Duplicate entry 'ꪪꪪ' for key 'c' +drop table t1; +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a using hash (c(1)) +) engine=heap; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) USING HASH +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a using btree (c(1)) +) engine=heap; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + UNIQUE KEY `a` (`c`(1)) USING BTREE +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a (c(1)) +) engine=innodb; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +insert into t1 values ('aa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('aaa'); +ERROR 23000: Duplicate entry 'a' for key 'a' +insert into t1 values ('б'); +insert into t1 values ('бб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +insert into t1 values ('ббб'); +ERROR 23000: Duplicate entry 'б' for key 'a' +select c as c_all from t1 order by c; +c_all +a +b +c +d +e +f +б +select c as c_a from t1 where c='a'; +c_a +a +select c as c_a from t1 where c='б'; +c_a +б +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str (str(2)) +) engine=myisam; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str (str(2)) +) engine=innodb; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str using btree (str(2)) +) engine=heap; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str using hash (str(2)) +) engine=heap; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +create table t1 ( +str varchar(255) character set utf8mb4 not null, +key str (str(2)) +) engine=innodb; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +str +str +drop table t1; +CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4; +INSERT INTO t1 VALUES ('test'); +SELECT a FROM t1 WHERE a LIKE '%te'; +a +DROP TABLE t1; +SET NAMES utf8mb4; +CREATE TABLE t1 ( +subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci, +p varchar(15) character set utf8mb4 +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('谷川俊二ă¨ç”łă—ăľă™ăŚă€ă‚¤ăłă‚żăĽăŤăăäşç´„ă®äĽšĺ“ˇç™»éŚ˛ă‚’ă—ăľă—ăźă¨ă“ろă€ăˇăĽă«ă‚˘ă‰ă¬ă‚ąă‚’é–“é•ăă¦ă—ăľă„会員IDăŚĺŹ—ă‘取るă“ă¨ăŚĺ‡şćťĄăľă›ă‚“ă§ă—ăźă€‚é–“é•ăアă‰ă¬ă‚ąăŻtani-shun@n.vodafone.ne.jpを書ăŤčľĽăżăľă—ăźă€‚ă©ă†ă™ă‚Śă°ă‚ă„ă§ă™ă‹ďĽź ăťă®ä»–ă€ä˝Źć‰€ç­‰ăŻé–“é•ăă‚りăľă›ă‚“。連絡ăŹă ă•ă„。ă‚ろă—ăŹăŠéˇă„ă—ăľă™ă€‚m(__)m','040312-000057'); +INSERT INTO t1 VALUES ('aaa','bbb'); +SELECT length(subject) FROM t1; +length(subject) +432 +3 +SELECT length(subject) FROM t1 ORDER BY 1; +length(subject) +3 +432 +DROP TABLE t1; +CREATE TABLE t1 ( +id int unsigned NOT NULL auto_increment, +list_id smallint unsigned NOT NULL, +term TEXT NOT NULL, +PRIMARY KEY(id), +INDEX(list_id, term(4)) +) ENGINE=MYISAM CHARSET=utf8mb4; +INSERT INTO t1 SET list_id = 1, term = "letterc"; +INSERT INTO t1 SET list_id = 1, term = "letterb"; +INSERT INTO t1 SET list_id = 1, term = "lettera"; +INSERT INTO t1 SET list_id = 1, term = "letterd"; +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc"); +id +1 +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb"); +id +2 +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera"); +id +3 +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd"); +id +4 +DROP TABLE t1; +SET NAMES latin1; +CREATE TABLE t1 ( +id int unsigned NOT NULL auto_increment, +list_id smallint unsigned NOT NULL, +term text NOT NULL, +PRIMARY KEY(id), +INDEX(list_id, term(19)) +) ENGINE=MyISAM CHARSET=utf8mb4; +INSERT INTO t1 set list_id = 1, term = "testétest"; +INSERT INTO t1 set list_id = 1, term = "testetest"; +INSERT INTO t1 set list_id = 1, term = "testčtest"; +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testétest"); +id term +1 testétest +2 testetest +3 testčtest +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest"); +id term +1 testétest +2 testetest +3 testčtest +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testčtest"); +id term +1 testétest +2 testetest +3 testčtest +DROP TABLE t1; +set names utf8mb4; +create table t1 ( +a int primary key, +b varchar(6), +index b3(b(3)) +) engine=innodb character set=utf8mb4; +insert into t1 values(1,'foo'),(2,'foobar'); +select * from t1 where b like 'foob%'; +a b +2 foobar +alter table t1 engine=innodb; +select * from t1 where b like 'foob%'; +a b +2 foobar +drop table t1; +create table t1 ( +a enum('петя','ваŃŃŹ','анюта') character set utf8mb4 not null default 'анюта', +b set('петя','ваŃŃŹ','анюта') character set utf8mb4 not null default 'анюта' +); +create table t2 select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(5) CHARACTER SET utf8mb4 NOT NULL DEFAULT '', + `b` varchar(15) CHARACTER SET utf8mb4 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t2; +drop table t1; +select 'c' like '\_' as want0; +want0 +0 +SELECT SUBSTR('ваŃŃŹ',-2); +SUBSTR('ваŃŃŹ',-2) +ŃŃŹ +create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci); +insert into t1 values (1, 'Test'); +select * from t1 where soundex(a) = soundex('Test'); +id a +1 Test +select * from t1 where soundex(a) = soundex('TEST'); +id a +1 Test +select * from t1 where soundex(a) = soundex('test'); +id a +1 Test +drop table t1; +select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB); +soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB) +é…000 +select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)); +hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)) +E99885303030 +select soundex(_utf8mb4 0xD091D092D093); +soundex(_utf8mb4 0xD091D092D093) +Đ‘000 +select hex(soundex(_utf8mb4 0xD091D092D093)); +hex(soundex(_utf8mb4 0xD091D092D093)) +D091303030 +SET collation_connection='utf8mb4_general_ci'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf8mb4_general_ci 6109 +utf8mb4_general_ci 61 +utf8mb4_general_ci 6120 +drop table t1; +select @@collation_connection; +@@collation_connection +utf8mb4_general_ci +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +drop table if exists t1; +create table t1 as select repeat(' ', 64) as s1; +select collation(s1) from t1; +collation(s1) +utf8mb4_general_ci +delete from t1; +insert into t1 values ('a'),('ae'),(_latin1 0xE4); +insert into t1 values ('o'),('oe'),(_latin1 0xF6); +insert into t1 values ('s'),('ss'),(_latin1 0xDF); +insert into t1 values ('u'),('ue'),(_latin1 0xFC); +select s1, hex(s1) from t1 order by s1, binary s1; +s1 hex(s1) +a 61 +ä C3A4 +ae 6165 +o 6F +ö C3B6 +oe 6F65 +s 73 +Ăź C39F +ss 7373 +u 75 +ĂĽ C3BC +ue 7565 +select group_concat(s1 order by binary s1) from t1 group by s1; +group_concat(s1 order by binary s1) +a,ä +ae +o,ö +oe +s,Ăź +ss +u,ĂĽ +ue +drop table t1; +SET collation_connection='utf8mb4_bin'; +create table t1 select repeat('a',4000) a; +delete from t1; +insert into t1 values ('a'), ('a '), ('a\t'); +select collation(a),hex(a) from t1 order by a; +collation(a) hex(a) +utf8mb4_bin 6109 +utf8mb4_bin 61 +utf8mb4_bin 6120 +drop table t1; +select @@collation_connection; +@@collation_connection +utf8mb4_bin +create table t1 ROW_FORMAT=DYNAMIC select repeat('a',50) as c1 ; +insert into t1 values('abcdef'); +insert into t1 values('_bcdef'); +insert into t1 values('a_cdef'); +insert into t1 values('ab_def'); +insert into t1 values('abc_ef'); +insert into t1 values('abcd_f'); +insert into t1 values('abcde_'); +select c1 as c1u from t1 where c1 like 'ab\_def'; +c1u +ab_def +select c1 as c2h from t1 where c1 like 'ab#_def' escape '#'; +c2h +ab_def +drop table t1; +CREATE TABLE t1 ( +user varchar(255) NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('one'),('two'); +SELECT CHARSET('a'); +CHARSET('a') +utf8mb4 +SELECT user, CONCAT('<', user, '>') AS c FROM t1; +user c +one +two +DROP TABLE t1; +create table t1 (f1 varchar(1) not null) default charset utf8mb4; +insert into t1 values (''), (''); +select concat(concat(_latin1'->',f1),_latin1'<-') from t1; +concat(concat(_latin1'->',f1),_latin1'<-') +-><- +-><- +drop table t1; +select convert(_koi8r'É' using utf8mb4) < convert(_koi8r'Ę' using utf8mb4); +convert(_koi8r'?' using utf8mb4) < convert(_koi8r'?' using utf8mb4) +1 +set names latin1; +create table t1 (a varchar(10)) character set utf8mb4; +insert into t1 values ('test'); +select ifnull(a,'') from t1; +ifnull(a,'') +test +drop table t1; +select repeat(_utf8mb4'+',3) as h union select NULL; +h ++++ +NULL +select ifnull(NULL, _utf8mb4'string'); +ifnull(NULL, _utf8mb4'string') +string +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci); +insert into t1 values ('I'),('K'),('Y'); +select * from t1 where s1 < 'K' and s1 = 'Y'; +s1 +I +Y +select * from t1 where 'K' > s1 and s1 = 'Y'; +s1 +I +Y +drop table t1; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci); +insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i'); +select * from t1 where s1 > 'd' and s1 = 'CH'; +s1 +ch +CH +Ch +select * from t1 where 'd' < s1 and s1 = 'CH'; +s1 +ch +CH +Ch +select * from t1 where s1 = 'cH' and s1 <> 'ch'; +s1 +cH +select * from t1 where 'cH' = s1 and s1 <> 'ch'; +s1 +cH +drop table t1; +create table t1 (a varchar(255)) default character set utf8mb4; +insert into t1 values (1.0); +drop table t1; +create table t1 ( +id int not null, +city varchar(20) not null, +key (city(7),id) +) character set=utf8mb4; +insert into t1 values (1,'Durban North'); +insert into t1 values (2,'Durban'); +select * from t1 where city = 'Durban'; +id city +2 Durban +select * from t1 where city = 'Durban '; +id city +2 Durban +drop table t1; +create table t1 (x set('A', 'B') default 0) character set utf8mb4; +ERROR 42000: Invalid default value for 'x' +create table t1 (x enum('A', 'B') default 0) character set utf8mb4; +ERROR 42000: Invalid default value for 'x' +SET NAMES UTF8; +CREATE TABLE t1 ( +`id` int(20) NOT NULL auto_increment, +`country` varchar(100) NOT NULL default '', +`shortcode` varchar(100) NOT NULL default '', +`operator` varchar(100) NOT NULL default '', +`momid` varchar(30) NOT NULL default '', +`keyword` varchar(160) NOT NULL default '', +`content` varchar(160) NOT NULL default '', +`second_token` varchar(160) default NULL, +`gateway_id` int(11) NOT NULL default '0', +`created` datetime NOT NULL default '0000-00-00 00:00:00', +`msisdn` varchar(15) NOT NULL default '', +PRIMARY KEY (`id`), +UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`), +KEY `IX_mobile_originated_message_keyword` (`keyword`), +KEY `IX_mobile_originated_message_created` (`created`), +KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; +INSERT INTO t1 VALUES +(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Đмри.Đфимим.Đеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.ĐĐ´.Đ” имдимримрад.Đдимримримрмдиримримримр ĐĽ.ДадимфŃьмримд им.Đдимимрн имадми','ĐМРĐ.ĐФĐĐśĐĐś.ĐĐ•ĐĐśĐМРĐМДМРĐМРМРĐРОР',3,'2005-06-01 17:30:43','1234567890'), +(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890'); +CREATE TABLE t2 ( +`msisdn` varchar(15) NOT NULL default '', +`operator_id` int(11) NOT NULL default '0', +`created` datetime NOT NULL default '0000-00-00 00:00:00', +UNIQUE KEY `PK_user` (`msisdn`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25'); +SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890'; +content msisdn +ERR Đмри.Đфимим.Đеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.ĐĐ´.Đ” имдимримрад.Đдимримримрмдиримримримр ĐĽ.ДадимфŃьмримд им.Đдимимрн имадми 1234567890 +11 g 1234567890 +DROP TABLE t1,t2; +create table t1 (a char(20) character set utf8mb4); +insert into t1 values ('123456'),('андрей'); +alter table t1 modify a char(2) character set utf8mb4; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +select char_length(a), length(a), a from t1 order by a; +char_length(a) length(a) a +2 2 12 +2 4 ан +drop table t1; +set names utf8mb4; +select 'andre%' like 'andreñ%' escape 'ñ'; +'andre%' like 'andreñ%' escape 'ñ' +1 +set names utf8mb4; +select 'a\\' like 'a\\'; +'a\\' like 'a\\' +1 +select 'aa\\' like 'a%\\'; +'aa\\' like 'a%\\' +1 +create table t1 (a char(10), key(a)) character set utf8mb4; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like concat("abc","%"); +a +abc +abcd +select * from t1 where a like "ABC%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where a like "%a%"; +a +a +abc +abcd +select * from t1 where a like "%abcd%"; +a +abcd +select * from t1 where a like "%abc\d%"; +a +abcd +drop table t1; +CREATE TABLE t1 ( +a varchar(255) NOT NULL default '', +KEY a (a) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; +Warnings: +Warning 1071 Specified key was too long; max key length is 1000 bytes +insert into t1 values (_utf8mb4 0xe880bd); +insert into t1 values (_utf8mb4 0x5b); +select hex(a) from t1; +hex(a) +E880BD +5B +drop table t1; +set names 'latin1'; +create table t1 (a varchar(255)) default charset=utf8mb4; +select * from t1 where find_in_set('-1', a); +a +drop table t1; +create table t1 (a int); +insert into t1 values (48),(49),(50); +set names utf8mb4; +select distinct char(a) from t1; +char(a) +0 +1 +2 +drop table t1; +CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4); +INSERT INTO t1 VALUES(REPEAT('a', 100)); +CREATE TEMPORARY TABLE t2 SELECT COALESCE(t) AS bug FROM t1; +SELECT LENGTH(bug) FROM t2; +LENGTH(bug) +100 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 (item varchar(255)) default character set utf8mb4; +INSERT INTO t1 VALUES (N'\\'); +INSERT INTO t1 VALUES (_utf8mb4'\\'); +INSERT INTO t1 VALUES (N'Cote d\'Ivoire'); +INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire'); +SELECT item FROM t1 ORDER BY item; +item +Cote d'Ivoire +Cote d'Ivoire +\ +\ +DROP TABLE t1; +SET NAMES utf8mb4; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; +Warnings: +Warning 1071 Specified key was too long; max key length is 1000 bytes +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t1 VALUES('uu'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uU'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uu'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uuABC'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('UuABC'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uuABC'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +alter table t1 add b int; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1); +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2); +delete from t1 where b=1; +INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3); +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4); +delete from t1 where b=3; +INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4); +insert into t1 values +('a'),('b'),(null),('ăšă†ă«ă‚°ă«'),('ĂĽ'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_general_ci from t1 where s1 like 'ăšă†%'; +before_delete_general_ci +ăšă†ă«ă‚°ă« +delete from t1 where s1 = 'Y'; +select s1 as after_delete_general_ci from t1 where s1 like 'ăšă†%'; +after_delete_general_ci +ăšă†ă«ă‚°ă« +drop table t1; +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci); +insert into t1 values +('a'),('b'),(null),('ăšă†ă«ă‚°ă«'),('ĂĽ'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_unicode_ci from t1 where s1 like 'ăšă†%'; +before_delete_unicode_ci +ăšă†ă«ă‚°ă« +delete from t1 where s1 = 'Y'; +select s1 as after_delete_unicode_ci from t1 where s1 like 'ăšă†%'; +after_delete_unicode_ci +ăšă†ă«ă‚°ă« +drop table t1; +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin); +insert into t1 values +('a'),('b'),(null),('ăšă†ă«ă‚°ă«'),('ĂĽ'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_bin from t1 where s1 like 'ăšă†%'; +before_delete_bin +ăšă†ă«ă‚°ă« +delete from t1 where s1 = 'Y'; +select s1 as after_delete_bin from t1 where s1 like 'ăšă†%'; +after_delete_bin +ăšă†ă«ă‚°ă« +drop table t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_general_ci; +insert into t1 values ('ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'); +insert into t1 values ('ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ'); +select a as gci1 from t1 where a like 'ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ%'; +gci1 +ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ă㊠+select a as gci2 from t1 where a like 'ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'; +gci2 +ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť +drop table t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_unicode_ci; +insert into t1 values ('ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'); +insert into t1 values ('ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ'); +select a as uci1 from t1 where a like 'ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ%'; +uci1 +ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ă㊠+select a as uci2 from t1 where a like 'ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'; +uci2 +ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť +drop table t1; +set names utf8mb4; +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_bin; +insert into t1 values ('ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'); +insert into t1 values ('ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ'); +select a as bin1 from t1 where a like 'ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ%'; +bin1 +ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ă㊠+select a as bin2 from t1 where a like 'ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'; +bin2 +ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť +drop table t1; +SET NAMES utf8mb4; +CREATE TABLE t1 (id int PRIMARY KEY, +a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '', +b int, +f varchar(128) default 'XXX', +INDEX (a(4)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +INSERT INTO t1(id, a, b) VALUES +(1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30), +(4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40), +(7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50), +(10, 'eeeee', 40), (11, 'bbbbbb', 60); +SELECT id, a, b FROM t1; +id a b +1 cccc 50 +2 cccc 70 +3 cccc 30 +4 cccc 30 +5 cccc 20 +6 bbbbbb 40 +7 dddd 30 +8 aaaa 10 +9 aaaa 50 +10 eeeee 40 +11 bbbbbb 60 +SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb'; +id a b +8 aaaa 10 +9 aaaa 50 +6 bbbbbb 40 +11 bbbbbb 60 +SELECT id, a FROM t1 WHERE a='bbbbbb'; +id a +6 bbbbbb +11 bbbbbb +SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b; +id a +6 bbbbbb +11 bbbbbb +DROP TABLE t1; +SET NAMES utf8mb4; +CREATE TABLE t1 ( +a CHAR(13) DEFAULT '', +INDEX(a) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES +('Käli Käli 2-4'), ('Käli Käli 2-4'), +('Käli Käli 2+4'), ('Käli Käli 2+4'), +('Käli Käli 2-6'), ('Käli Käli 2-6'); +INSERT INTO t1 SELECT * FROM t1; +CREATE TABLE t2 ( +a CHAR(13) DEFAULT '', +INDEX(a) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +INSERT INTO t2 VALUES +('Kali Kali 2-4'), ('Kali Kali 2-4'), +('Kali Kali 2+4'), ('Kali Kali 2+4'), +('Kali Kali 2-6'), ('Kali Kali 2-6'); +INSERT INTO t2 SELECT * FROM t2; +SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +a +Käli Käli 2+4 +Käli Käli 2+4 +Käli Käli 2+4 +Käli Käli 2+4 +SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +a +Kali Kali 2+4 +Kali Kali 2+4 +Kali Kali 2+4 +Kali Kali 2+4 +EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 53 NULL 4 Using where; Using index +EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 53 const 4 Using where; Using index +EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range a a 14 NULL 4 Using where; Using index +EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref a a 14 const 4 Using where; Using index +DROP TABLE t1,t2; +CREATE TABLE t1 ( +a char(255) DEFAULT '', +KEY(a(10)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +DROP TABLE t1; +CREATE TABLE t1 ( +a char(255) DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +ALTER TABLE t1 ADD KEY (a(10)); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +a +Käli Käli 2-4 +Käli Käli 2-4 +DROP TABLE t1; +SET NAMES latin2; +CREATE TABLE t1 ( +id int(11) NOT NULL default '0', +tid int(11) NOT NULL default '0', +val text NOT NULL, +INDEX idx(tid, val(10)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; +INSERT INTO t1 VALUES +(40988,72,'VOLNÝ ADSL'),(41009,72,'VOLNÝ ADSL'), +(41032,72,'VOLNÝ ADSL'),(41038,72,'VOLNÝ ADSL'), +(41063,72,'VOLNÝ ADSL'),(41537,72,'VOLNÝ ADSL Office'), +(42141,72,'VOLNÝ ADSL'),(42565,72,'VOLNÝ ADSL Combi'), +(42749,72,'VOLNÝ ADSL'),(44205,72,'VOLNÝ ADSL'); +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL'; +id tid val +40988 72 VOLNÝ ADSL +41009 72 VOLNÝ ADSL +41032 72 VOLNÝ ADSL +41038 72 VOLNÝ ADSL +41063 72 VOLNÝ ADSL +42141 72 VOLNÝ ADSL +42749 72 VOLNÝ ADSL +44205 72 VOLNÝ ADSL +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; +id tid val +40988 72 VOLNÝ ADSL +41009 72 VOLNÝ ADSL +41032 72 VOLNÝ ADSL +41038 72 VOLNÝ ADSL +41063 72 VOLNÝ ADSL +42141 72 VOLNÝ ADSL +42749 72 VOLNÝ ADSL +44205 72 VOLNÝ ADSL +SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLNÝ ADSL'; +id tid val +40988 72 VOLNÝ ADSL +41009 72 VOLNÝ ADSL +41032 72 VOLNÝ ADSL +41038 72 VOLNÝ ADSL +41063 72 VOLNÝ ADSL +42141 72 VOLNÝ ADSL +42749 72 VOLNÝ ADSL +44205 72 VOLNÝ ADSL +ALTER TABLE t1 DROP KEY idx; +ALTER TABLE t1 ADD KEY idx (tid,val(11)); +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; +id tid val +40988 72 VOLNÝ ADSL +41009 72 VOLNÝ ADSL +41032 72 VOLNÝ ADSL +41038 72 VOLNÝ ADSL +41063 72 VOLNÝ ADSL +42141 72 VOLNÝ ADSL +42749 72 VOLNÝ ADSL +44205 72 VOLNÝ ADSL +DROP TABLE t1; +create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '') +default charset=utf8mb4 collate=utf8mb4_unicode_ci; +insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65')); +explain select distinct a from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary +select distinct a from t1; +a +e +explain select a from t1 group by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort +select a from t1 group by a; +a +e +drop table t1; +create table t1(a char(10)) default charset utf8mb4; +insert into t1 values ('123'), ('456'); +explain +select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE Y ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +1 SIMPLE Z ALL NULL NULL NULL NULL 2 Using where; Using join buffer +select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1; +substr(Z.a,-1) a +3 123 +6 456 +drop table t1; +SET CHARACTER SET utf8mb4; +SHOW VARIABLES LIKE 'character\_set\_%'; +Variable_name Value +character_set_client utf8mb4 +character_set_connection latin1 +character_set_database latin1 +character_set_filesystem binary +character_set_results utf8mb4 +character_set_server latin1 +character_set_system utf8 +CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; +USE crashtest; +CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4; +INSERT INTO crashtest VALUES ('35'), ('36'), ('37'); +SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +crash +35 +36 +37 +INSERT INTO crashtest VALUES ('-1000'); +EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE crashtest ALL NULL NULL NULL NULL 4 Using filesort +SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +crash +-1000 +35 +36 +37 +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FFFFFC' +DROP TABLE crashtest; +DROP DATABASE crashtest; +USE test; +SET CHARACTER SET default; +CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4; +INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa'); +SELECT id FROM t1; +id +xxx +aa +yyy +aa +SELECT DISTINCT id FROM t1; +id +xxx +aa +yyy +SELECT DISTINCT id FROM t1 ORDER BY id; +id +aa +xxx +yyy +DROP TABLE t1; +create table t1 ( +a varchar(26) not null +) default character set utf8mb4; +insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz'); +select * from t1; +a +abcdefghijklmnopqrstuvwxyz +alter table t1 change a a varchar(20) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +abcdefghijklmnopqrst +alter table t1 change a a char(15) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +abcdefghijklmno +alter table t1 change a a char(10) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +abcdefghij +alter table t1 change a a varchar(5) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select * from t1; +a +abcde +drop table t1; +create table t1 ( +a varchar(4000) not null +) default character set utf8mb4; +insert into t1 values (repeat('a',4000)); +alter table t1 change a a varchar(3000) character set utf8mb4 not null; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +select length(a) from t1; +length(a) +3000 +drop table t1; +set names utf8mb4; +select hex(char(1 using utf8mb4)); +hex(char(1 using utf8mb4)) +01 +select char(0xd1,0x8f using utf8mb4); +char(0xd1,0x8f using utf8mb4) +ŃŹ +select char(0xd18f using utf8mb4); +char(0xd18f using utf8mb4) +ŃŹ +select char(53647 using utf8mb4); +char(53647 using utf8mb4) +ŃŹ +select char(0xff,0x8f using utf8mb4); +char(0xff,0x8f using utf8mb4) + +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF8F' +select convert(char(0xff,0x8f) using utf8mb4); +convert(char(0xff,0x8f) using utf8mb4) + +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF8F' +set sql_mode=traditional; +select char(0xff,0x8f using utf8mb4); +char(0xff,0x8f using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF8F' +select char(195 using utf8mb4); +char(195 using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'C3' +select char(196 using utf8mb4); +char(196 using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'C4' +select char(2557 using utf8mb4); +char(2557 using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FD' +select convert(char(0xff,0x8f) using utf8mb4); +convert(char(0xff,0x8f) using utf8mb4) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF8F' +select hex(convert(char(2557 using latin1) using utf8mb4)); +hex(convert(char(2557 using latin1) using utf8mb4)) +09C3BD +select hex(char(195)); +hex(char(195)) +C3 +select hex(char(196)); +hex(char(196)) +C4 +select hex(char(2557)); +hex(char(2557)) +09FD +set names utf8mb4; +create table t1 (a char(1)) default character set utf8mb4; +create table t2 (a char(1)) default character set utf8mb4; +insert into t1 values('a'),('a'),(0xE38182),(0xE38182); +insert into t1 values('i'),('i'),(0xE38184),(0xE38184); +select * from t1 union distinct select * from t2; +a +a +ă‚ +i +ă„ +drop table t1,t2; +set names utf8mb4; +create table t1 (a char(10), b varchar(10)); +insert into t1 values ('bar','kostja'); +insert into t1 values ('kostja','bar'); +prepare my_stmt from "select * from t1 where a=?"; +set @a:='bar'; +execute my_stmt using @a; +a b +bar kostja +set @a:='kostja'; +execute my_stmt using @a; +a b +kostja bar +set @a:=null; +execute my_stmt using @a; +a b +drop table if exists t1; +drop table if exists t1; +drop view if exists v1, v2; +set names utf8mb4; +create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci); +insert into t1 values('t1_val'); +create view v1 as select 'v1_val' as col1; +select coercibility(col1), collation(col1) from v1; +coercibility(col1) collation(col1) +4 utf8mb4_general_ci +create view v2 as select col1 from v1 union select col1 from t1; +select coercibility(col1), collation(col1)from v2; +coercibility(col1) collation(col1) +2 utf8mb4_unicode_ci +2 utf8mb4_unicode_ci +drop view v1, v2; +create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1; +select coercibility(col1), collation(col1) from v1; +coercibility(col1) collation(col1) +0 utf8mb4_swedish_ci +create view v2 as select col1 from v1 union select col1 from t1; +select coercibility(col1), collation(col1) from v2; +coercibility(col1) collation(col1) +0 utf8mb4_swedish_ci +0 utf8mb4_swedish_ci +drop view v1, v2; +drop table t1; +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, N'x', N'y')) from t1; +concat(a, if(b>10, N'x', N'y')) +ay +select concat(a, if(b>10, N'æ', N'Ăź')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1; +concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) +ay +select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'Ăź')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1; +concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) +ay +select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat' +drop table t1; +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1; +concat(a, if(b>10, 'x' 'x', 'y' 'y')) +ayy +select concat(a, if(b>10, 'x' 'æ', 'y' 'Ăź')) from t1; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat' +drop table t1; +SHOW ENGINES; +Engine Support Comment Transactions XA Savepoints +ndbcluster NO Clustered, fault-tolerant tables NULL NULL NULL +MRG_MYISAM YES Collection of identical MyISAM tables NO NO NO +MEMORY YES Hash based, stored in memory, useful for temporary tables NO NO NO +BLACKHOLE YES /dev/null storage engine (anything you write to it disappears) NO NO NO +CSV YES CSV storage engine NO NO NO +MyISAM DEFAULT Default engine as of MySQL 3.23 with great performance NO NO NO +ARCHIVE YES Archive storage engine NO NO NO +FEDERATED NO Federated MySQL storage engine NULL NULL NULL +PERFORMANCE_SCHEMA YES Performance Schema NO NO NO +InnoDB YES Supports transactions, row-level locking, and foreign keys YES YES YES +CREATE TABLE t1 ( +colA int(11) NOT NULL, +colB varchar(255) character set utf8mb4 NOT NULL, +PRIMARY KEY (colA) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar'); +CREATE TABLE t2 ( +colA int(11) NOT NULL, +colB varchar(255) character set utf8mb4 NOT NULL, +KEY bad (colA,colB(3)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); +SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB +WHERE t1.colA < 3; +colA colB colA colB +1 foo 1 foo +2 foo bar 2 foo bar +DROP TABLE t1, t2; +SELECT 'Đ˝1234567890' UNION SELECT _binary '1'; +Đ˝1234567890 +Đ˝1234567890 +1 +SELECT 'Đ˝1234567890' UNION SELECT 1; +Đ˝1234567890 +Đ˝1234567890 +1 +SELECT '1' UNION SELECT 'Đ˝1234567890'; +1 +1 +Đ˝1234567890 +SELECT 1 UNION SELECT 'Đ˝1234567890'; +1 +1 +Đ˝1234567890 +CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4; +CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT); +INSERT INTO t1 (c) VALUES ('Đ˝1234567890'); +INSERT INTO t2 (b, i) VALUES ('1', 1); +SELECT c FROM t1 UNION SELECT b FROM t2; +c +Đ˝1234567890 +1 +SELECT c FROM t1 UNION SELECT i FROM t2; +c +Đ˝1234567890 +1 +SELECT b FROM t2 UNION SELECT c FROM t1; +b +1 +Đ˝1234567890 +SELECT i FROM t2 UNION SELECT c FROM t1; +i +1 +Đ˝1234567890 +DROP TABLE t1, t2; +set sql_mode=traditional; +select hex(char(0xFF using utf8mb4)); +hex(char(0xFF using utf8mb4)) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF' +select hex(convert(0xFF using utf8mb4)); +hex(convert(0xFF using utf8mb4)) +NULL +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 0x616263FF); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 X'616263FF'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 B'001111111111'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select (_utf8mb4 X'616263FF'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +set sql_mode=default; +select hex(char(0xFF using utf8mb4)); +hex(char(0xFF using utf8mb4)) + +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF' +select hex(convert(0xFF using utf8mb4)); +hex(convert(0xFF using utf8mb4)) + +Warnings: +Warning 1300 Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 0x616263FF); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 X'616263FF'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select hex(_utf8mb4 B'001111111111'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +select (_utf8mb4 X'616263FF'); +ERROR HY000: Invalid utf8mb4 character string: 'FF' +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL); +INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70002 1065 +70001 1085 +70000 1092 +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70000 1092 +70001 1085 +70002 1065 +ALTER TABLE t1 ADD UNIQUE (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70002 1065 +70001 1085 +70000 1092 +DROP INDEX b ON t1; +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70002 1065 +70001 1085 +70000 1092 +ALTER TABLE t1 ADD INDEX (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b; +CONVERT(a, CHAR) CONVERT(b, CHAR) +70002 1065 +70001 1085 +70000 1092 +DROP TABLE t1; +# +# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +predicted_order int NOT NULL, +utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4; +INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682'); +SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci; +predicted_order hex(utf8mb4_encoding) +1 E0B7B4 +2 E0B685 +3 E0B686 +4 E0B687 +5 E0B688 +6 E0B689 +7 E0B68A +8 E0B68B +9 E0B68C +10 E0B68D +11 E0B68E +12 E0B68F +13 E0B690 +14 E0B691 +15 E0B692 +16 E0B693 +17 E0B694 +18 E0B695 +19 E0B696 +20 E0B682 +21 E0B683 +22 E0B69A +23 E0B69AE0B78F +24 E0B69AE0B790 +25 E0B69AE0B791 +26 E0B69AE0B792 +27 E0B69AE0B793 +28 E0B69AE0B794 +29 E0B69AE0B796 +30 E0B69AE0B798 +31 E0B69AE0B7B2 +32 E0B69AE0B79F +33 E0B69AE0B7B3 +34 E0B69AE0B799 +35 E0B69AE0B79A +36 E0B69AE0B79B +37 E0B69AE0B79C +38 E0B69AE0B79D +39 E0B69AE0B79E +40 E0B69AE0B78A +41 E0B69B +42 E0B69C +43 E0B69D +44 E0B69E +45 E0B69F +46 E0B6A0 +47 E0B6A1 +48 E0B6A2 +49 E0B6A3 +50 E0B6A5 +51 E0B6A4 +52 E0B6A6 +53 E0B6A7 +54 E0B6A8 +55 E0B6A9 +56 E0B6AA +57 E0B6AB +58 E0B6AC +59 E0B6AD +60 E0B6AE +61 E0B6AF +62 E0B6B0 +63 E0B6B1 +64 E0B6B3 +65 E0B6B4 +66 E0B6B5 +67 E0B6B6 +68 E0B6B7 +69 E0B6B8 +70 E0B6B9 +71 E0B6BA +72 E0B6BB +73 E0B6BBE0B78AE2808D +74 E0B6BD +75 E0B780 +76 E0B781 +77 E0B782 +78 E0B783 +79 E0B784 +80 E0B785 +81 E0B786 +82 E0B78F +83 E0B790 +84 E0B791 +85 E0B792 +86 E0B793 +87 E0B794 +88 E0B796 +89 E0B798 +90 E0B7B2 +91 E0B79F +92 E0B7B3 +93 E0B799 +94 E0B79A +95 E0B79B +96 E0B79C +97 E0B79D +98 E0B79E +99 E0B78A +100 E0B78AE2808DE0B6BA +101 E0B78AE2808DE0B6BB +DROP TABLE t1; +# +# Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns +# +create table t1 (utf8mb4 char(1) character set utf8mb4); +Testing [F0][90..BF][80..BF][80..BF] +insert into t1 values (0xF0908080); +insert into t1 values (0xF0BFBFBF); +insert into t1 values (0xF08F8080); +Warnings: +Warning 1366 Incorrect string value: '\xF0\x8F\x80\x80' for column 'utf8mb4' at row 1 +select hex(utf8mb4) from t1; +hex(utf8mb4) +F0908080 +F0BFBFBF + +delete from t1; +Testing [F2..F3][80..BF][80..BF][80..BF] +insert into t1 values (0xF2808080); +insert into t1 values (0xF2BFBFBF); +select hex(utf8mb4) from t1; +hex(utf8mb4) +F2808080 +F2BFBFBF +delete from t1; +Testing [F4][80..8F][80..BF][80..BF] +insert into t1 values (0xF4808080); +insert into t1 values (0xF48F8080); +insert into t1 values (0xF4908080); +Warnings: +Warning 1366 Incorrect string value: '\xF4\x90\x80\x80' for column 'utf8mb4' at row 1 +select hex(utf8mb4) from t1; +hex(utf8mb4) +F4808080 +F48F8080 + +drop table t1; +# +# Check strnxfrm() with odd length +# +set max_sort_length=5; +select @@max_sort_length; +@@max_sort_length +5 +create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci); +insert into t1 values ('a'),('b'),('c'); +select * from t1 order by a; +a +a +b +c +alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin; +select * from t1 order by a; +a +a +b +c +drop table t1; +set max_sort_length=default; +# +# Bug#26180: Can't add columns to tables created with utf8mb4 text indexes +# +CREATE TABLE t1 ( +clipid INT NOT NULL, +Tape TINYTEXT, +PRIMARY KEY (clipid), +KEY tape(Tape(255)) +) CHARACTER SET=utf8mb4; +Warnings: +Warning 1071 Specified key was too long; max key length is 1000 bytes +ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `clipid` int(11) NOT NULL, + `mos` tinyint(4) DEFAULT '0', + `Tape` tinytext, + PRIMARY KEY (`clipid`), + KEY `tape` (`Tape`(250)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 +DROP TABLE t1; +# +# Testing 4-byte values. +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +u_decimal int NOT NULL, +utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4; +INSERT INTO t1 VALUES (119040, x'f09d8480'), +# G CLEF +(119070, x'f09d849e'), +# HALF NOTE +(119134, x'f09d859e'), +# MUSICAL SYMBOL CROIX +(119247, x'f09d878f'), +# MATHEMATICAL BOLD ITALIC CAPITAL DELTA +(120607, x'f09d9c9f'), +# SANS-SERIF BOLD ITALIC CAPITAL PI +(120735, x'f09d9e9f'), +# (last 4 byte character) +(1114111, x'f48fbfbf'), +# VARIATION SELECTOR-256 +(917999, x'f3a087af'); +INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480'); +INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab'); +INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0'); +Warnings: +Warning 1265 Data truncated for column 'utf8mb4_encoding' at row 1 +SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding; +u_decimal hex(utf8mb4_encoding) +65131 EFB9ABF09D849EF09D859EF09D859EF09D8480F09D859FEFB9ABEFB9ABF09D85A0EFB9AB +119040 F09D8480 +119070 F09D849E +119134 F09D859E +119247 F09D878F +120607 F09D9C9F +120735 F09D9E9F +917999 F3A087AF +1114111 F48FBFBF +119070 F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480 +119070 F09D849EF09D859EF09D859EF09D8480F09D859FF09D859FF09D859FF09D85A0F09D85A0F09D8480 +INSERT INTO t1 VALUES (1114111, x'f5808080'); +Warnings: +Warning 1366 Incorrect string value: '\xF5\x80\x80\x80' for column 'utf8mb4_encoding' at row 1 +DROP TABLE IF EXISTS t2; +CREATE TABLE t2 ( +u_decimal int NOT NULL, +utf8mb3_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb3; +INSERT INTO t2 VALUES (42856, x'ea9da8'); +INSERT INTO t2 VALUES (65131, x'efb9ab'); +INSERT INTO t2 VALUES (1114111, x'f48fbfbf'); +Warnings: +Warning 1366 Incorrect string value: '\xF4\x8F\xBF\xBF' for column 'utf8mb3_encoding' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `u_decimal` int(11) NOT NULL, + `utf8mb4_encoding` varchar(10) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `u_decimal` int(11) NOT NULL, + `utf8mb3_encoding` varchar(10) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +DROP TABLE t1; +DROP TABLE t2; +# +# Testing that mixing utf8 and utf8mb4 collations returns utf8mb4 +# +SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b')); +CHARSET(CONCAT(_utf8mb4'a',_utf8'b')) +utf8mb4 +CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL); +INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf'); +SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0; +CONCAT(utf8mb4, _utf8 x'ea9da8') +CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL); +INSERT INTO t2 VALUES (x'ea9da8'); +SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1; +HEX(CONCAT(utf8mb4, utf8mb3)) +EA9DA8EA9DA8 +F48FBFBFEA9DA8 +SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1; +CHARSET(CONCAT(utf8mb4, utf8mb3)) +utf8mb4 +CREATE TEMPORARY TABLE t3 AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2; +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TEMPORARY TABLE `t3` ( + `utf8mb4` varchar(10) CHARACTER SET utf8mb4 NOT NULL, + `utf8mb3` varchar(10) CHARACTER SET utf8 NOT NULL, + `concat(utf8mb4,utf8mb3)` varchar(20) CHARACTER SET utf8mb4 NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TEMPORARY TABLE t3; +SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3; +utf8mb4 utf8mb3 +ôŹżż Ꝩ +SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3; +utf8mb4 utf8mb3 +Ꝩ Ꝩ +SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3; +utf8mb4 utf8mb3 +DROP TABLE t1; +DROP TABLE t2; +# +# Check that mixing utf8mb4 with an invalid utf8 constant returns error +# +CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4); +INSERT INTO t1 VALUES (x'f48fbfbf'); +SELECT CONCAT(utf8mb4, _utf8 'ż') FROM t1; +ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'concat' +SELECT CONCAT('a', _utf8 'ż') FROM t1; +ERROR HY000: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (utf8_general_ci,COERCIBLE) for operation 'concat' +DROP TABLE t1; +# +# End of 5.5 tests +# +# +# End of tests +# diff --git a/mysql-test/r/have_utf16.require b/mysql-test/r/have_utf16.require new file mode 100644 index 00000000000..a1b5469cad7 --- /dev/null +++ b/mysql-test/r/have_utf16.require @@ -0,0 +1,2 @@ +Collation Charset Id Default Compiled Sortlen +utf16_general_ci utf16 54 Yes Yes 1 diff --git a/mysql-test/r/have_utf32.require b/mysql-test/r/have_utf32.require new file mode 100644 index 00000000000..710ddb8090c --- /dev/null +++ b/mysql-test/r/have_utf32.require @@ -0,0 +1,2 @@ +Collation Charset Id Default Compiled Sortlen +utf32_general_ci utf32 60 Yes Yes 1 diff --git a/mysql-test/r/have_utf8mb4.require b/mysql-test/r/have_utf8mb4.require new file mode 100644 index 00000000000..1669b332d0d --- /dev/null +++ b/mysql-test/r/have_utf8mb4.require @@ -0,0 +1,2 @@ +Collation Charset Id Default Compiled Sortlen +utf8mb4_general_ci utf8mb4 45 Yes Yes 1 diff --git a/mysql-test/std_data/Index.xml b/mysql-test/std_data/Index.xml index e4964a33419..27358fefd54 100644 --- a/mysql-test/std_data/Index.xml +++ b/mysql-test/std_data/Index.xml @@ -33,6 +33,36 @@ + + + + + a + b + + + + + + + + a + b + + + + + + + + + a + b + + + + + diff --git a/mysql-test/suite/sys_vars/r/character_set_client_basic.result b/mysql-test/suite/sys_vars/r/character_set_client_basic.result index 78993015a24..ed3612627e6 100644 --- a/mysql-test/suite/sys_vars/r/character_set_client_basic.result +++ b/mysql-test/suite/sys_vars/r/character_set_client_basic.result @@ -162,8 +162,16 @@ SET @@character_set_client = utf8; SELECT @@character_set_client; @@character_set_client utf8 +SET @@character_set_client = utf8mb4; +SELECT @@character_set_client; +@@character_set_client +utf8mb4 SET @@character_set_client = ucs2; ERROR 42000: Variable 'character_set_client' can't be set to the value of 'ucs2' +SET @@character_set_client = utf16; +ERROR 42000: Variable 'character_set_client' can't be set to the value of 'utf16' +SET @@character_set_client = utf32; +ERROR 42000: Variable 'character_set_client' can't be set to the value of 'utf32' SET @@character_set_client = cp866; SELECT @@character_set_client; @@character_set_client @@ -422,7 +430,7 @@ ERROR 42000: Unknown character set: '100' SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS); SELECT @total_charset; @total_charset -36 +39 '#--------------------FN_DYNVARS_010_10-------------------------#' SET @@character_set_client = abc; ERROR 42000: Unknown character set: 'abc' diff --git a/mysql-test/suite/sys_vars/r/character_set_connection_basic.result b/mysql-test/suite/sys_vars/r/character_set_connection_basic.result index dd1052d27ef..feb9073e175 100644 --- a/mysql-test/suite/sys_vars/r/character_set_connection_basic.result +++ b/mysql-test/suite/sys_vars/r/character_set_connection_basic.result @@ -424,7 +424,7 @@ ERROR 42000: Unknown character set: '100' SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS); SELECT @total_charset; @total_charset -36 +39 '#--------------------FN_DYNVARS_011_10-------------------------#' SET @@character_set_connection = abc; ERROR 42000: Unknown character set: 'abc' diff --git a/mysql-test/suite/sys_vars/r/character_set_database_basic.result b/mysql-test/suite/sys_vars/r/character_set_database_basic.result index 9aa449816f5..669af6a610c 100644 --- a/mysql-test/suite/sys_vars/r/character_set_database_basic.result +++ b/mysql-test/suite/sys_vars/r/character_set_database_basic.result @@ -424,7 +424,7 @@ ERROR 42000: Unknown character set: '100' SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS); SELECT @total_charset; @total_charset -36 +39 '#--------------------FN_DYNVARS_012_10-------------------------#' SET @@character_set_database = "grek"; ERROR 42000: Unknown character set: 'grek' diff --git a/mysql-test/suite/sys_vars/r/character_set_filesystem_basic.result b/mysql-test/suite/sys_vars/r/character_set_filesystem_basic.result index e33df353c74..e8d41d99437 100644 --- a/mysql-test/suite/sys_vars/r/character_set_filesystem_basic.result +++ b/mysql-test/suite/sys_vars/r/character_set_filesystem_basic.result @@ -402,7 +402,7 @@ ERROR 42000: Unknown character set: '100' SET @total_charset = (SELECT count(*) FROM INFORMATION_SCHEMA.CHARACTER_SETS); SELECT @total_charset; @total_charset -36 +39 '#--------------------FN_DYNVARS_008_10-------------------------#' SET @@character_set_filesystem = abc; ERROR 42000: Unknown character set: 'abc' diff --git a/mysql-test/suite/sys_vars/r/character_set_results_basic.result b/mysql-test/suite/sys_vars/r/character_set_results_basic.result index 0b59f60cd45857a1ed981af75672baf3920de017..6b50f128af83b2cc70d9705aba19eae1e4c7a523 100644 GIT binary patch delta 16 XcmccDz<95Laf7-Eqvd7|6EhwFH$DYb delta 16 XcmccDz<95Laf7-EquFK+6EhwFH!KBG diff --git a/mysql-test/suite/sys_vars/t/character_set_client_basic.test b/mysql-test/suite/sys_vars/t/character_set_client_basic.test index 26912e89509..7b3d36fb16f 100644 --- a/mysql-test/suite/sys_vars/t/character_set_client_basic.test +++ b/mysql-test/suite/sys_vars/t/character_set_client_basic.test @@ -27,6 +27,9 @@ --source include/have_sjis.inc --source include/have_utf8.inc --source include/have_ucs2.inc +--source include/have_utf8mb4.inc +--source include/have_utf16.inc +--source include/have_utf32.inc --source include/load_sysvars.inc ################################################### @@ -163,9 +166,15 @@ SET @@character_set_client = armscii8; SELECT @@character_set_client; SET @@character_set_client = utf8; SELECT @@character_set_client; +SET @@character_set_client = utf8mb4; +SELECT @@character_set_client; --error ER_WRONG_VALUE_FOR_VAR SET @@character_set_client = ucs2; +--error ER_WRONG_VALUE_FOR_VAR +SET @@character_set_client = utf16; +--error ER_WRONG_VALUE_FOR_VAR +SET @@character_set_client = utf32; SET @@character_set_client = cp866; SELECT @@character_set_client; diff --git a/mysql-test/suite/sys_vars/t/character_set_connection_basic.test b/mysql-test/suite/sys_vars/t/character_set_connection_basic.test index 1a51843e0e8..e402dbb0ff5 100644 --- a/mysql-test/suite/sys_vars/t/character_set_connection_basic.test +++ b/mysql-test/suite/sys_vars/t/character_set_connection_basic.test @@ -27,6 +27,9 @@ --source include/have_sjis.inc --source include/have_utf8.inc --source include/have_ucs2.inc +--source include/have_utf8mb4.inc +--source include/have_utf16.inc +--source include/have_utf32.inc --source include/load_sysvars.inc ################################################### diff --git a/mysql-test/suite/sys_vars/t/character_set_database_basic.test b/mysql-test/suite/sys_vars/t/character_set_database_basic.test index 07b4b31b25c..4e650dc6139 100644 --- a/mysql-test/suite/sys_vars/t/character_set_database_basic.test +++ b/mysql-test/suite/sys_vars/t/character_set_database_basic.test @@ -27,6 +27,9 @@ --source include/have_sjis.inc --source include/have_utf8.inc --source include/have_ucs2.inc +--source include/have_utf8mb4.inc +--source include/have_utf16.inc +--source include/have_utf32.inc --source include/load_sysvars.inc ################################################### diff --git a/mysql-test/suite/sys_vars/t/character_set_filesystem_basic.test b/mysql-test/suite/sys_vars/t/character_set_filesystem_basic.test index 928d02ee46b..6bb2de35429 100644 --- a/mysql-test/suite/sys_vars/t/character_set_filesystem_basic.test +++ b/mysql-test/suite/sys_vars/t/character_set_filesystem_basic.test @@ -27,6 +27,9 @@ --source include/have_sjis.inc --source include/have_utf8.inc --source include/have_ucs2.inc +--source include/have_utf8mb4.inc +--source include/have_utf16.inc +--source include/have_utf32.inc --source include/load_sysvars.inc diff --git a/mysql-test/suite/sys_vars/t/character_set_results_basic.test b/mysql-test/suite/sys_vars/t/character_set_results_basic.test index 98635c00287..1bede9e493c 100644 --- a/mysql-test/suite/sys_vars/t/character_set_results_basic.test +++ b/mysql-test/suite/sys_vars/t/character_set_results_basic.test @@ -27,6 +27,9 @@ --source include/have_sjis.inc --source include/have_utf8.inc --source include/have_ucs2.inc +--source include/have_utf8mb4.inc +--source include/have_utf16.inc +--source include/have_utf32.inc --source include/load_sysvars.inc ################################################ diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test index 99d9cd5a866..d2f06a84a8c 100644 --- a/mysql-test/t/ctype_ldml.test +++ b/mysql-test/t/ctype_ldml.test @@ -1,4 +1,7 @@ --source include/have_ucs2.inc +--source include/have_utf8mb4.inc +--source include/have_utf16.inc +--source include/have_utf32.inc --disable_warnings drop table if exists t1; @@ -40,6 +43,24 @@ insert into t1 values ('a'); select * from t1 where c1='b'; drop table t1; +show collation like 'utf8mb4_test_ci'; +create table t1 (c1 char(1) character set utf8mb4 collate utf8mb4_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +drop table t1; + +show collation like 'utf16_test_ci'; +create table t1 (c1 char(1) character set utf16 collate utf16_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +drop table t1; + +show collation like 'utf32_test_ci'; +create table t1 (c1 char(1) character set utf32 collate utf32_test_ci); +insert into t1 values ('a'); +select * from t1 where c1='b'; +drop table t1; + # # Bug#41084 full-text index added to custom UCA collation not working diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test index 0903c3dd7fa..67726c53585 100644 --- a/mysql-test/t/ctype_many.test +++ b/mysql-test/t/ctype_many.test @@ -1,4 +1,7 @@ -- source include/have_ucs2.inc +-- source include/have_utf8mb4.inc +-- source include/have_utf16.inc +-- source include/have_utf32.inc --disable_warnings DROP TABLE IF EXISTS t1; @@ -211,3 +214,73 @@ SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f; DROP TABLE t1; # End of 4.1 tests + + +--echo # +--echo # WL#1213 Implement 4-byte UTF8, UTF16 and UTF32 +--echo # Testing that only utf8mb4 is superset for utf8 +--echo # No other Unicode character set pairs have superset/subset relations +--echo # + +CREATE TABLE t1 ( + utf8 CHAR CHARACTER SET utf8, + utf8mb4 CHAR CHARACTER SET utf8mb4, + ucs2 CHAR CHARACTER SET ucs2, + utf16 CHAR CHARACTER SET utf16, + utf32 CHAR CHARACTER SET utf32 +); +INSERT INTO t1 VALUES ('','','','',''); + +# utf8mb4 is superset only for utf8 +SELECT CHARSET(CONCAT(utf8, utf8mb4)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf8, ucs2)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf8, utf16)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf8, utf32)) FROM t1; + + +# utf8mb4 is superset only for utf8 +SELECT CHARSET(CONCAT(utf8mb4, utf8)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf8mb4, ucs2)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf8mb4, utf16)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf8mb4, utf32)) FROM t1; + + +# ucs2 is not a superset for the other Unicode character sets +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(ucs2, utf8)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(ucs2, utf8mb4)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(ucs2, utf16)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(ucs2, utf32)) FROM t1; + + +# utf16 is not a superset for the other Unicode character sets +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf16, utf8)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf16, ucs2)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf16, utf8mb4)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf16, utf32)) FROM t1; + + +# utf32 is not a superset for the other Unicode character sets +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf32, utf8)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf32, ucs2)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf32, utf8mb4)) FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CHARSET(CONCAT(utf32, utf16)) FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/t/ctype_utf16.test b/mysql-test/t/ctype_utf16.test new file mode 100644 index 00000000000..2e0a9e644b1 --- /dev/null +++ b/mysql-test/t/ctype_utf16.test @@ -0,0 +1,731 @@ +-- source include/have_utf16.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # +--echo # Start of 5.5 tests +--echo # + +SET NAMES latin1; +SET character_set_connection=utf16; +select hex('a'), hex('a '); +-- source include/endspace.inc + + +# Check that incomplete utf16 characters in HEX notation +# are left-padded with zeros +# +select hex(_utf16 0x44); +select hex(_utf16 0x3344); +select hex(_utf16 0x113344); + + +# Check that 0x20 is only trimmed when it is +# a part of real SPACE character, not just a part +# of a multibyte sequence. +# Note, CYRILLIC LETTER ER is used as an example, which +# is stored as 0x0420 in utf16, thus contains 0x20 in the +# low byte. The second character is THREE-PER-M, U+2004, +# which contains 0x20 in the high byte. + +CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf16; +INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (X'2004',X'2004'); +SELECT hex(word) FROM t1 ORDER BY word; +SELECT hex(word2) FROM t1 ORDER BY word2; +DELETE FROM t1; + +# +# Check that real spaces are correctly trimmed. +# +INSERT INTO t1 VALUES (X'042000200020',X'042000200020'), (X'200400200020', X'200400200020'); +SELECT hex(word) FROM t1 ORDER BY word; +SELECT hex(word2) FROM t1 ORDER BY word2; +DROP TABLE t1; + + +# +# Check LPAD/RPAD +# +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'0421')); +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'04210422')); +SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'042104220423')); +SELECT hex(LPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')); +SELECT hex(LPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')); +SELECT hex(LPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')); + +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'0421')); +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'04210422')); +SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'042104220423')); +SELECT hex(RPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423')); +SELECT hex(RPAD(_utf16 X'D800DC00', 10, _utf16 X'0421')); +SELECT hex(RPAD(_utf16 X'0421', 10, _utf16 X'D800DC00')); + +CREATE TABLE t1 SELECT +LPAD(_utf16 X'0420',10,_utf16 X'0421') l, +RPAD(_utf16 X'0420',10,_utf16 X'0421') r; +SHOW CREATE TABLE t1; +select hex(l), hex(r) from t1; +DROP TABLE t1; + +create table t1 (f1 char(30)); +insert into t1 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t1; +drop table t1; + +###################################################### +# +# Test of like +# + +SET NAMES latin1; +SET character_set_connection=utf16; +--source include/ctype_like.inc + +SET NAMES utf8; +SET character_set_connection=utf16; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16); +INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывĐ'),('ФЫВĐ'); +INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж'); +INSERT INTO t1 VALUES ('фывĐпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж'); +INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВĐПРОЛДЖ'); +SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a; +SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a; +SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a; +SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf16_bin ORDER BY BINARY a; +DROP TABLE t1; + +CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word)) +ENGINE=MyISAM CHARACTER SET utf16; +INSERT INTO t1 (word) VALUES ("cat"); +SELECT * FROM t1 WHERE word LIKE "c%"; +SELECT * FROM t1 WHERE word LIKE "ca_"; +SELECT * FROM t1 WHERE word LIKE "cat"; +SELECT * FROM t1 WHERE word LIKE _utf16 x'00630025'; # "c%" +SELECT * FROM t1 WHERE word LIKE _utf16 x'00630061005F'; # "ca_" +DROP TABLE t1; + + +# +# Check that INSERT() works fine. +# This invokes charpos() function. +select insert(_utf16 0x006100620063,10,2,_utf16 0x006400650066); +select insert(_utf16 0x006100620063,1,2,_utf16 0x006400650066); + +######################################################## +# +# Bug 1264 +# +# Description: +# +# When using a ucs2 table in MySQL, +# either with ucs2_general_ci or ucs2_bin collation, +# words are returned in an incorrect order when using ORDER BY +# on an _indexed_ CHAR or VARCHAR column. They are sorted with +# the longest word *first* instead of last. I.E. The word "aardvark" +# is in the results before the word "a". +# +# If there is no index for the column, the problem does not occur. +# +# Interestingly, if there is no second column, the words are returned +# in the correct order. +# +# According to EXPLAIN, it looks like when the output includes columns that +# are not part of the index sorted on, it does a filesort, which fails. +# Using a straight index yields correct results. + +SET NAMES latin1; + +# +# Two fields, index +# + +CREATE TABLE t1 ( + word VARCHAR(64), + bar INT(11) default 0, + PRIMARY KEY (word)) + ENGINE=MyISAM + CHARSET utf16 + COLLATE utf16_general_ci ; + +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a"); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY word; +SELECT * FROM t1 ORDER BY word; +EXPLAIN SELECT word FROM t1 ORDER BY word; +SELECT word FROM t1 ORDER by word; +DROP TABLE t1; + + +# +# One field, index +# + +CREATE TABLE t1 ( + word VARCHAR(64) , + PRIMARY KEY (word)) + ENGINE=MyISAM + CHARSET utf16 + COLLATE utf16_general_ci; + +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a"); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY WORD; +SELECT * FROM t1 ORDER BY word; +DROP TABLE t1; + + +# +# Two fields, no index +# + +CREATE TABLE t1 ( + word TEXT, + bar INT(11) AUTO_INCREMENT, + PRIMARY KEY (bar)) + ENGINE=MyISAM + CHARSET utf16 + COLLATE utf16_general_ci ; +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a" ); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY word; +SELECT * FROM t1 ORDER BY word; +EXPLAIN SELECT word FROM t1 ORDER BY word; +SELECT word FROM t1 ORDER BY word; +DROP TABLE t1; + +# +# END OF Bug 1264 test +# +######################################################## + + +# +# Check alignment for from-binary-conversion with CAST and CONVERT +# +SELECT hex(cast(0xAA as char character set utf16)); +SELECT hex(convert(0xAA using utf16)); + +# +# Check alignment for string types +# +CREATE TABLE t1 (a char(10) character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a varchar(10) character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a text character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a mediumtext character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a longtext character set utf16); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +## +## Bug #5024 Server crashes with queries on fields +## with certain charset/collation settings +## +## +#create table t1 (s1 char character set utf16 collate utf16_czech_ci); +#insert into t1 values ('0'),('1'),('2'),('a'),('b'),('c'); +#select s1 from t1 where s1 > 'a' order by s1; +#drop table t1; +# + +# +# Bug #5081 : UCS2 fields are filled with '0x2020' +# after extending field length +# +create table t1(a char(1)) default charset utf16; +insert into t1 values ('a'),('b'),('c'); +alter table t1 modify a char(5); +select a, hex(a) from t1; +drop table t1; + +# +# Check prepare statement from an UTF16 string +# +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using utf16); +prepare stmt1 from @str2; +execute stmt1 using @ivar; + +# +# Check that utf16 works with ENUM and SET type +# +set names utf8; +create table t1 (a enum('x','y','z') character set utf16); +show create table t1; +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +select a, hex(a) from t1 order by a; +alter table t1 change a a enum('x','y','z','d','e','ä','ö','ĂĽ') character set utf16; +show create table t1; +insert into t1 values ('D'); +insert into t1 values ('E '); +insert into t1 values ('ä'); +insert into t1 values ('ö'); +insert into t1 values ('ĂĽ'); +select a, hex(a) from t1 order by a; +drop table t1; + +create table t1 (a set ('x','y','z','ä','ö','ĂĽ') character set utf16); +show create table t1; +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +insert into t1 values ('x,y'); +insert into t1 values ('x,y,z,ä,ö,ĂĽ'); +select a, hex(a) from t1 order by a; +drop table t1; + +# +# Bug#7302 UCS2 data in ENUM fields get truncated when new column is added +# +create table t1(a enum('a','b','c')) default character set utf16; +insert into t1 values('a'),('b'),('c'); +alter table t1 add b char(1); +show warnings; +select * from t1 order by a; +drop table t1; + +SET NAMES latin1; +SET collation_connection='utf16_general_ci'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc +SET NAMES latin1; +SET collation_connection='utf16_bin'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc + +# +# Bug#10344 Some string functions fail for UCS2 +# +select hex(substr(_utf16 0x00e400e50068,1)); +select hex(substr(_utf16 0x00e400e50068,2)); +select hex(substr(_utf16 0x00e400e50068,3)); +select hex(substr(_utf16 0x00e400e50068,-1)); +select hex(substr(_utf16 0x00e400e50068,-2)); +select hex(substr(_utf16 0x00e400e50068,-3)); +select hex(substr(_utf16 0x00e400e5D800DC00,1)); +select hex(substr(_utf16 0x00e400e5D800DC00,2)); +select hex(substr(_utf16 0x00e400e5D800DC00,3)); +select hex(substr(_utf16 0x00e400e5D800DC00,-1)); +select hex(substr(_utf16 0x00e400e5D800DC00,-2)); +select hex(substr(_utf16 0x00e400e5D800DC00,-3)); + +SET NAMES latin1; + +## +## Bug#8235 +## +## This bug also helped to find another problem that +## INSERT of a UCS2 string containing a negative number +## into a unsigned int column didn't produce warnings. +## This test covers both problems. +## +##SET collation_connection='ucs2_swedish_ci'; +##CREATE TABLE t1 (Field1 int(10) default '0'); +### no warnings, negative numbers are allowed +##INSERT INTO t1 VALUES ('-1'); +##SELECT * FROM t1; +##DROP TABLE t1; +##CREATE TABLE t1 (Field1 int(10) unsigned default '0'); +### this should generate a "Data truncated" warning +##INSERT INTO t1 VALUES ('-1'); +##DROP TABLE t1; +##SET NAMES latin1; + +### +### Bug #14583 Bug on query using a LIKE on indexed field with ucs2_bin collation +### +##--disable_warnings +##create table t1(f1 varchar(5) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL) engine=InnoDB; +##--enable_warnings +##insert into t1 values('a'); +##create index t1f1 on t1(f1); +##select f1 from t1 where f1 like 'a%'; +##drop table t1; + +# +# Bug#9442 Set parameter make query fail if column character set is UCS2 +# +create table t1 (utext varchar(20) character set utf16); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +execute stmt using @param1; +select utext from t1 where utext like '%%'; +drop table t1; +deallocate prepare stmt; + +# +# Bug#22052 Trailing spaces are not removed from UNICODE fields in an index +# +create table t1 ( + a char(10) character set utf16 not null, + index a (a) +) engine=myisam; +insert into t1 values (repeat(0x201f, 10)); +insert into t1 values (repeat(0x2020, 10)); +insert into t1 values (repeat(0x2021, 10)); +# make sure "index read" is used +explain select hex(a) from t1 order by a; +select hex(a) from t1 order by a; +alter table t1 drop index a; +select hex(a) from t1 order by a; +drop table t1; + +## +## Bug #20076: server crashes for a query with GROUP BY if MIN/MAX aggregation +## over a 'ucs2' field uses a temporary table +## +##CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci); +##INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ'); +##SELECT id, MIN(s) FROM t1 GROUP BY id; +##DROP TABLE t1; + +### +### Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb +### +## +##--disable_warnings +##drop table if exists bug20536; +##--enable_warnings +## +##set names latin1; +##create table bug20536 (id bigint not null auto_increment primary key, name +##varchar(255) character set ucs2 not null); +##insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'"); +##select md5(name) from bug20536; +##select sha1(name) from bug20536; +##select make_set(3, name, upper(name)) from bug20536; +##select export_set(5, name, upper(name)) from bug20536; +##select export_set(5, name, upper(name), ",", 5) from bug20536; + +# +# Bug #20108: corrupted default enum value for a ucs2 field +# + +CREATE TABLE t1 ( + status enum('active','passive') character set utf16 collate utf16_general_ci + NOT NULL default 'passive' +); +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD a int NOT NULL AFTER status; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +##CREATE TABLE t2 ( +## status enum('active','passive') collate ucs2_turkish_ci +## NOT NULL default 'passive' +##); +##SHOW CREATE TABLE t2; +##ALTER TABLE t2 ADD a int NOT NULL AFTER status; +##DROP TABLE t2; + + +--echo End of 4.1 tests + +# +# Conversion from an UTF16 string to a decimal column +# +CREATE TABLE t1 (a varchar(64) character set utf16, b decimal(10,3)); +INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); +update t1 set b=a; +SELECT *, hex(a) FROM t1; +DROP TABLE t1; + +# +# Bug#9442 Set parameter make query fail if column character set is UCS2 +# +create table t1 (utext varchar(20) character set utf16); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +execute stmt using @param1; +select utext from t1 where utext like '%%'; +drop table t1; +deallocate prepare stmt; + +# +# Bug#22638 SOUNDEX broken for international characters +# +set names latin1; +set character_set_connection=utf16; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +select 'mood' sounds like 'mud'; +# Cyrillic A, BE, VE +select hex(soundex(_utf16 0x041004110412)); +# Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter +select hex(soundex(_utf16 0x00BF00C0)); +set names latin1; + +# +# Bug #14290: character_maximum_length for text fields +# +create table t1(a blob, b text charset utf16); +select data_type, character_octet_length, character_maximum_length + from information_schema.columns where table_name='t1'; +drop table t1; + + +set names latin1; +set collation_connection=utf16_general_ci; +# +# Testing cs->coll->instr() +# +select position('bb' in 'abba'); + +# +# Testing cs->coll->hash_sort() +# +create table t1 (a varchar(10) character set utf16) engine=heap; +insert into t1 values ('a'),('A'),('b'),('B'); +select * from t1 where a='a' order by binary a; +select hex(min(binary a)),count(*) from t1 group by a; +drop table t1; + +# +# Testing cs->cset->numchars() +# +select char_length('abcd'), octet_length('abcd'); +select char_length(_utf16 0xD800DC00), octet_length(_utf16 0xD800DC00); +select char_length(_utf16 0xD87FDFFF), octet_length(_utf16 0xD87FDFFF); + +# +# Testing cs->cset->charpos() +# +select left('abcd',2); +select hex(left(_utf16 0xD800DC00D87FDFFF, 1)); +select hex(right(_utf16 0xD800DC00D87FDFFF, 1)); + +# +# Testing cs->cset->well_formed_length() +# +create table t1 (a varchar(10) character set utf16); +# Bad sequences +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf16 0xD800); +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf16 0xDC00); +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf16 0xD800D800); +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf16 0xD800E800); +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf16 0xD8000800); +# Good sequences +insert into t1 values (_utf16 0xD800DC00); +insert into t1 values (_utf16 0xD800DCFF); +insert into t1 values (_utf16 0xDBFFDC00); +insert into t1 values (_utf16 0xDBFFDCFF); +select hex(a) from t1; +drop table t1; + +# +# Bug#32393 Character sets: illegal characters in utf16 columns +# +# Tests that cs->cset->wc_mb() doesn't accept surrogate parts +# +# via alter +# +create table t1 (s1 varchar(50) character set ucs2); +insert into t1 values (0xdf84); +alter table t1 modify column s1 varchar(50) character set utf16; +select hex(s1) from t1; +drop table t1; +# +# via update +# +create table t1 (s1 varchar(5) character set ucs2, s2 varchar(5) character set utf16); +insert into t1 (s1) values (0xdf84); +update t1 set s2 = s1; +select hex(s2) from t1; +drop table t1; + + + +# +# Testing cs->cset->lengthsp() +# +create table t1 (a char(10)) character set utf16; +insert into t1 values ('a '); +select hex(a) from t1; +drop table t1; + +# +# Testing cs->cset->caseup() and cs->cset->casedn() +# +select upper('abcd'), lower('ABCD'); + +# +# TODO: str_to_datetime() is broken and doesn't work with ucs2 and utf16 +# Testing cs->cset->snprintf() +# +#create table t1 (a date); +#insert into t1 values ('2007-09-16'); +#select * from t1; +#drop table t1; + +# +# Testing cs->cset->l10tostr +# !!! Not used in the code + +# +# Testing cs->cset->ll10tostr +# +create table t1 (a varchar(10) character set utf16); +insert into t1 values (123456); +select a, hex(a) from t1; +drop table t1; + + +# Testing cs->cset->fill +# SOUNDEX fills strings with DIGIT ZERO up to four characters +select hex(soundex('a')); + +# +# Testing cs->cset->strntol +# !!! Not used in the code + +# +# Testing cs->cset->strntoul +# +create table t1 (a enum ('a','b','c')) character set utf16; +insert into t1 values ('1'); +select * from t1; +drop table t1; + +# +# Testing cs->cset->strntoll and cs->cset->strntoull +# +set names latin1; +select hex(conv(convert('123' using utf16), -10, 16)); +select hex(conv(convert('123' using utf16), 10, 16)); + +# +# Testing cs->cset->strntod +# +set names latin1; +set character_set_connection=utf16; +select 1.1 + '1.2'; +select 1.1 + '1.2xxx'; + +# Testing strntoll10_utf16 +# Testing cs->cset->strtoll10 +select left('aaa','1'); + +# +# Testing cs->cset->strntoull10rnd +# +create table t1 (a int); +insert into t1 values ('-1234.1e2'); +insert into t1 values ('-1234.1e2xxxx'); +insert into t1 values ('-1234.1e2 '); +select * from t1; +drop table t1; + +# +# Testing cs->cset->scan +# +create table t1 (a int); +insert into t1 values ('1 '); +insert into t1 values ('1 x'); +select * from t1; +drop table t1; + +# +# Testing auto-conversion to TEXT +# +create table t1 (a varchar(17000) character set utf16); +show create table t1; +drop table t1; + +# +# Testing that maximim possible key length is 1000 bytes +# +create table t1 (a varchar(250) character set utf16 primary key); +show create table t1; +drop table t1; +--error ER_TOO_LONG_KEY +create table t1 (a varchar(334) character set utf16 primary key); + +# +# Conversion to utf8 +# +create table t1 (a char(1) character set utf16); +insert into t1 values (0xD800DC00),(0xD800DCFF),(0xDB7FDC00),(0xDB7FDCFF); +insert into t1 values (0x00C0), (0x00FF),(0xE000), (0xFFFF); +select hex(a), hex(@a:=convert(a using utf8mb4)), hex(convert(@a using utf16)) from t1; +drop table t1; + +# +# Test basic regex functionality +# +set collation_connection=utf16_general_ci; +--source include/ctype_regex.inc +set names latin1; + +# +# Test how character set works with date/time +# +SET collation_connection=utf16_general_ci; +--source include/ctype_datetime.inc +SET NAMES latin1; + +# +# Bug#33073 Character sets: ordering fails with utf32 +# +SET collation_connection=utf16_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE'); +SELECT * FROM t1 ORDER BY s1; +SET max_sort_length=4; +SELECT * FROM t1 ORDER BY s1; +DROP TABLE t1; +SET max_sort_length=DEFAULT; +SET NAMES latin1; + + +# +## TODO: add tests for all engines +# + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/ctype_utf16_uca.test b/mysql-test/t/ctype_utf16_uca.test new file mode 100644 index 00000000000..5314777c6f4 --- /dev/null +++ b/mysql-test/t/ctype_utf16_uca.test @@ -0,0 +1,290 @@ +-- source include/have_utf16.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # +--echo # Start of 5.5 tests +--echo # + +set names utf8; +set collation_connection=utf16_unicode_ci; +select hex('a'), hex('a '); +-- source include/endspace.inc + +# +# Bug #6787 LIKE not working properly with _ and utf8 data +# +select 'c' like '\_' as want0; + +# +# Bug #5679 utf8_unicode_ci LIKE--trailing % doesn't equal zero characters +# +CREATE TABLE t ( + c char(20) NOT NULL +) ENGINE=MyISAM DEFAULT CHARACTER SET utf16 COLLATE utf16_unicode_ci; +INSERT INTO t VALUES ('a'),('ab'),('aba'); +ALTER TABLE t ADD INDEX (c); +SELECT c FROM t WHERE c LIKE 'a%'; +DROP TABLE t; + + +create table t1 (c1 char(10) character set utf16 collate utf16_bin); + +# +# Basic Latin +# +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); + +# +# Latin1 suppliment +# +insert into t1 values (0x00e0),(0x00c0); +insert into t1 values (0x00e1),(0x00c1); +insert into t1 values (0x00e2),(0x00c2); +insert into t1 values (0x00e3),(0x00c3); +insert into t1 values (0x00e4),(0x00c4); +insert into t1 values (0x00e5),(0x00c5); +insert into t1 values (0x00e6),(0x00c6); +insert into t1 values (0x00e7),(0x00c7); +insert into t1 values (0x00e8),(0x00c8); +insert into t1 values (0x00e9),(0x00c9); +insert into t1 values (0x00ea),(0x00ca); +insert into t1 values (0x00eb),(0x00cb); +insert into t1 values (0x00ec),(0x00cc); +insert into t1 values (0x00ed),(0x00cd); +insert into t1 values (0x00ee),(0x00ce); +insert into t1 values (0x00ef),(0x00cf); + +insert into t1 values (0x00f0),(0x00d0); +insert into t1 values (0x00f1),(0x00d1); +insert into t1 values (0x00f2),(0x00d2); +insert into t1 values (0x00f3),(0x00d3); +insert into t1 values (0x00f4),(0x00d4); +insert into t1 values (0x00f5),(0x00d5); +insert into t1 values (0x00f6),(0x00d6); +insert into t1 values (0x00f7),(0x00d7); +insert into t1 values (0x00f8),(0x00d8); +insert into t1 values (0x00f9),(0x00d9); +insert into t1 values (0x00fa),(0x00da); +insert into t1 values (0x00fb),(0x00db); +insert into t1 values (0x00fc),(0x00dc); +insert into t1 values (0x00fd),(0x00dd); +insert into t1 values (0x00fe),(0x00de); +insert into t1 values (0x00ff),(0x00df); + +# +# Latin extended-A, 0100-017F +# +insert into t1 values (0x0100),(0x0101),(0x0102),(0x0103); +insert into t1 values (0x0104),(0x0105),(0x0106),(0x0107); +insert into t1 values (0x0108),(0x0109),(0x010a),(0x010b); +insert into t1 values (0x010c),(0x010d),(0x010e),(0x010f); +insert into t1 values (0x0110),(0x0111),(0x0112),(0x0113); +insert into t1 values (0x0114),(0x0115),(0x0116),(0x0117); +insert into t1 values (0x0118),(0x0119),(0x011a),(0x011b); +insert into t1 values (0x011c),(0x011d),(0x011e),(0x011f); +insert into t1 values (0x0120),(0x0121),(0x0122),(0x0123); +insert into t1 values (0x0124),(0x0125),(0x0126),(0x0127); +insert into t1 values (0x0128),(0x0129),(0x012a),(0x012b); +insert into t1 values (0x012c),(0x012d),(0x012e),(0x012f); +insert into t1 values (0x0130),(0x0131),(0x0132),(0x0133); +insert into t1 values (0x0134),(0x0135),(0x0136),(0x0137); +insert into t1 values (0x0138),(0x0139),(0x013a),(0x013b); +insert into t1 values (0x013c),(0x013d),(0x013e),(0x013f); +insert into t1 values (0x0140),(0x0141),(0x0142),(0x0143); +insert into t1 values (0x0144),(0x0145),(0x0146),(0x0147); +insert into t1 values (0x0148),(0x0149),(0x014a),(0x014b); +insert into t1 values (0x014c),(0x014d),(0x014e),(0x014f); +insert into t1 values (0x0150),(0x0151),(0x0152),(0x0153); +insert into t1 values (0x0154),(0x0155),(0x0156),(0x0157); +insert into t1 values (0x0158),(0x0159),(0x015a),(0x015b); +insert into t1 values (0x015c),(0x015d),(0x015e),(0x015f); +insert into t1 values (0x0160),(0x0161),(0x0162),(0x0163); +insert into t1 values (0x0164),(0x0165),(0x0166),(0x0167); +insert into t1 values (0x0168),(0x0169),(0x016a),(0x016b); +insert into t1 values (0x016c),(0x016d),(0x016e),(0x016f); +insert into t1 values (0x0170),(0x0171),(0x0172),(0x0173); +insert into t1 values (0x0174),(0x0175),(0x0176),(0x0177); +insert into t1 values (0x0178),(0x0179),(0x017a),(0x017b); +insert into t1 values (0x017c),(0x017d),(0x017e),(0x017f); + +# +# Latin extended-B, 0180-024F +# +insert into t1 values (0x0180),(0x0181),(0x0182),(0x0183); +insert into t1 values (0x0184),(0x0185),(0x0186),(0x0187); +insert into t1 values (0x0188),(0x0189),(0x018a),(0x018b); +insert into t1 values (0x018c),(0x018d),(0x018e),(0x018f); +insert into t1 values (0x0190),(0x0191),(0x0192),(0x0193); +insert into t1 values (0x0194),(0x0195),(0x0196),(0x0197); +insert into t1 values (0x0198),(0x0199),(0x019a),(0x019b); +insert into t1 values (0x019c),(0x019d),(0x019e),(0x019f); +insert into t1 values (0x01a0),(0x01a1),(0x01a2),(0x01a3); +insert into t1 values (0x01a4),(0x01a5),(0x01a6),(0x01a7); +insert into t1 values (0x01a8),(0x01a9),(0x01aa),(0x01ab); +insert into t1 values (0x01ac),(0x01ad),(0x01ae),(0x01af); +insert into t1 values (0x01b0),(0x01b1),(0x01b2),(0x01b3); +insert into t1 values (0x01b4),(0x01b5),(0x01b6),(0x01b7); +insert into t1 values (0x01b8),(0x01b9),(0x01ba),(0x01bb); +insert into t1 values (0x01bc),(0x01bd),(0x01be),(0x01bf); +insert into t1 values (0x01c0),(0x01c1),(0x01c2),(0x01c3); +insert into t1 values (0x01c4),(0x01c5),(0x01c6),(0x01c7); +insert into t1 values (0x01c8),(0x01c9),(0x01ca),(0x01cb); +insert into t1 values (0x01cc),(0x01cd),(0x01ce),(0x01cf); +insert into t1 values (0x01d0),(0x01d1),(0x01d2),(0x01d3); +insert into t1 values (0x01d4),(0x01d5),(0x01d6),(0x01d7); +insert into t1 values (0x01d8),(0x01d9),(0x01da),(0x01db); +insert into t1 values (0x01dc),(0x01dd),(0x01de),(0x01df); +insert into t1 values (0x01e0),(0x01e1),(0x01e2),(0x01e3); +insert into t1 values (0x01e4),(0x01e5),(0x01e6),(0x01e7); +insert into t1 values (0x01e8),(0x01e9),(0x01ea),(0x01eb); +insert into t1 values (0x01ec),(0x01ed),(0x01ee),(0x01ef); +insert into t1 values (0x01f0),(0x01f1),(0x01f2),(0x01f3); +insert into t1 values (0x01f4),(0x01f5),(0x01f6),(0x01f7); +insert into t1 values (0x01f8),(0x01f9),(0x01fa),(0x01fb); +insert into t1 values (0x01fc),(0x01fd),(0x01fe),(0x01ff); + + +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); + +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_unicode_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_icelandic_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_latvian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_romanian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_slovenian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_polish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_estonian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_spanish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_swedish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_turkish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_czech_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_danish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_lithuanian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_slovak_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_spanish2_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_roman_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_esperanto_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_hungarian_ci; + +drop table t1; + +# +# Bug#5324 +# +SET NAMES utf8; + +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +#Check one row +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_general_ci; +INSERT INTO t1 VALUES (0x039C03C903B4); +#Check two rows +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_general_ci ORDER BY c; +DROP TABLE t1; + +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +#Check one row +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_unicode_ci; +INSERT INTO t1 VALUES (0x039C03C903B4); +#Check two rows +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_unicode_ci ORDER BY c; +DROP TABLE t1; + +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (0x039C03C903B403B11F770308); +#Check one row row +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_unicode_ci; +INSERT INTO t1 VALUES (0x039C03C903B4); +#Check two rows +SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 +COLLATE utf16_unicode_ci ORDER BY c; +DROP TABLE t1; + + +SET NAMES utf8; +SET @test_character_set='utf16'; +SET @test_collation='utf16_swedish_ci'; +-- source include/ctype_common.inc + + +SET collation_connection='utf16_unicode_ci'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc + +--echo End of 4.1 tests + +# +# Check UPPER/LOWER changing length +# +# Result shorter than argument +CREATE TABLE t1 (id int, a varchar(30) character set utf16); +INSERT INTO t1 VALUES (1, 0x01310069), (2, 0x01310131); +INSERT INTO t1 VALUES (3, 0x00690069), (4, 0x01300049); +INSERT INTO t1 VALUES (5, 0x01300130), (6, 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf16 collate utf16_turkish_ci; +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +DROP TABLE t1; + +# +# Bug #27079 Crash while grouping empty ucs2 strings +# +CREATE TABLE t1 ( + c1 text character set utf16 collate utf16_polish_ci NOT NULL +) ENGINE=MyISAM; +insert into t1 values (''),('a'); +SELECT COUNT(*), c1 FROM t1 GROUP BY c1; +DROP TABLE IF EXISTS t1; + + +# +# Test basic regex functionality +# +set collation_connection=utf16_unicode_ci; +--source include/ctype_regex.inc + + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/ctype_utf32.test b/mysql-test/t/ctype_utf32.test new file mode 100644 index 00000000000..f1e17532b88 --- /dev/null +++ b/mysql-test/t/ctype_utf32.test @@ -0,0 +1,784 @@ +-- source include/have_utf32.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # +--echo # Start of 5.5 tests +--echo # + +SET NAMES latin1; +SET character_set_connection=utf32; +select hex('a'), hex('a '); +-- source include/endspace.inc + +# +# Check that incomplete utf32 characters in HEX notation +# are left-padded with zeros +# +select hex(_utf32 0x44); +select hex(_utf32 0x3344); +select hex(_utf32 0x103344); + +select hex(_utf32 X'44'); +select hex(_utf32 X'3344'); +select hex(_utf32 X'103344'); + + +# +# Check that 0x20 is only trimmed when it is +# a part of real SPACE character, not just a part +# of a multibyte sequence. +# Note, CYRILLIC LETTER ER is used as an example, which +# is stored as 0x0420 in UCS2, thus contains 0x20 in the +# low byte. The second character is THREE-PER-M, U+2004, +# which contains 0x20 in the high byte. +# + +CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf32; +INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (X'2004',X'2004'); +SELECT hex(word) FROM t1 ORDER BY word; +SELECT hex(word2) FROM t1 ORDER BY word2; +DELETE FROM t1; + +# +# Check that real spaces are correctly trimmed. +# + +INSERT INTO t1 VALUES + (X'000004200000002000000020',X'000004200000002000000020'), + (X'000020040000002000000020',X'000020040000002000000020'); +SELECT hex(word) FROM t1 ORDER BY word; +SELECT hex(word2) FROM t1 ORDER BY word2; +DROP TABLE t1; + +# +# Check LPAD/RPAD +# +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'0421')); +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')); +SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')); +SELECT hex(LPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')); + +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'0421')); +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'0000042100000422')); +SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423')); +SELECT hex(RPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423')); + +CREATE TABLE t1 SELECT +LPAD(_utf32 X'0420',10,_utf32 X'0421') l, +RPAD(_utf32 X'0420',10,_utf32 X'0421') r; +SHOW CREATE TABLE t1; +select hex(l), hex(r) from t1; +DROP TABLE t1; + +create table t1 (f1 char(30)); +insert into t1 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t1; +drop table t1; + +###################################################### +# +# Test of like +# + +SET NAMES latin1; +SET character_set_connection=utf32; +--source include/ctype_like.inc + +SET NAMES utf8; +SET character_set_connection=utf32; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32); +INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывĐ'),('ФЫВĐ'); +INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж'); +INSERT INTO t1 VALUES ('фывĐпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж'); +INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВĐПРОЛДЖ'); +SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a; +SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a; +SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a; +SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf32_bin ORDER BY BINARY a; +DROP TABLE t1; + +CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word)) +ENGINE=MyISAM CHARACTER SET utf32; +INSERT INTO t1 (word) VALUES ("cat"); +SELECT * FROM t1 WHERE word LIKE "c%"; +SELECT * FROM t1 WHERE word LIKE "ca_"; +SELECT * FROM t1 WHERE word LIKE "cat"; +SELECT * FROM t1 WHERE word LIKE _utf32 x'0000006300000025'; # "c%" +SELECT * FROM t1 WHERE word LIKE _utf32 x'00000063000000610000005F'; # "ca_" +DROP TABLE t1; + + +# +# Check that INSERT() works fine. +# This invokes charpos() function. +select insert(_utf32 0x000000610000006200000063,10,2,_utf32 0x000000640000006500000066); +select insert(_utf32 0x000000610000006200000063,1,2,_utf32 0x000000640000006500000066); + +####################################################### + +# +# Bug 1264 +# +# Description: +# +# When using a ucs2 table in MySQL, +# either with ucs2_general_ci or ucs2_bin collation, +# words are returned in an incorrect order when using ORDER BY +# on an _indexed_ CHAR or VARCHAR column. They are sorted with +# the longest word *first* instead of last. I.E. The word "aardvark" +# is in the results before the word "a". +# +# If there is no index for the column, the problem does not occur. +# +# Interestingly, if there is no second column, the words are returned +# in the correct order. +# +# According to EXPLAIN, it looks like when the output includes columns that +# are not part of the index sorted on, it does a filesort, which fails. +# Using a straight index yields correct results. + +SET NAMES latin1; + +# +# Two fields, index +# + +CREATE TABLE t1 ( + word VARCHAR(64), + bar INT(11) default 0, + PRIMARY KEY (word)) + ENGINE=MyISAM + CHARSET utf32 + COLLATE utf32_general_ci ; + +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a"); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY word; +SELECT * FROM t1 ORDER BY word; +EXPLAIN SELECT word FROM t1 ORDER BY word; +SELECT word FROM t1 ORDER by word; +DROP TABLE t1; + + +# +# One field, index +# + +CREATE TABLE t1 ( + word VARCHAR(64) , + PRIMARY KEY (word)) + ENGINE=MyISAM + CHARSET utf32 + COLLATE utf32_general_ci; + +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a"); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY WORD; +SELECT * FROM t1 ORDER BY word; +DROP TABLE t1; + + +# +# Two fields, no index +# + +CREATE TABLE t1 ( + word TEXT, + bar INT(11) AUTO_INCREMENT, + PRIMARY KEY (bar)) + ENGINE=MyISAM + CHARSET utf32 + COLLATE utf32_general_ci ; +INSERT INTO t1 (word) VALUES ("aar"); +INSERT INTO t1 (word) VALUES ("a" ); +INSERT INTO t1 (word) VALUES ("aardvar"); +INSERT INTO t1 (word) VALUES ("aardvark"); +INSERT INTO t1 (word) VALUES ("aardvara"); +INSERT INTO t1 (word) VALUES ("aardvarz"); +EXPLAIN SELECT * FROM t1 ORDER BY word; +SELECT * FROM t1 ORDER BY word; +EXPLAIN SELECT word FROM t1 ORDER BY word; +SELECT word FROM t1 ORDER BY word; +DROP TABLE t1; + +# +# END OF Bug 1264 test +# +######################################################## + + +# +# Check alignment for from-binary-conversion with CAST and CONVERT +# +SELECT hex(cast(0xAA as char character set utf32)); +SELECT hex(convert(0xAA using utf32)); + +# +# Check alignment for string types +# +CREATE TABLE t1 (a char(10) character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a varchar(10) character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a text character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a mediumtext character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a longtext character set utf32); +INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111); +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +## +## Bug #5024 Server crashes with queries on fields +## with certain charset/collation settings +## +# +#create table t1 (s1 char character set `ucs2` collate `ucs2_czech_ci`); +#insert into t1 values ('0'),('1'),('2'),('a'),('b'),('c'); +#select s1 from t1 where s1 > 'a' order by s1; +#drop table t1; + +# +# Bug #5081 : UCS2 fields are filled with '0x2020' +# after extending field length +# +create table t1(a char(1)) default charset utf32; +insert into t1 values ('a'),('b'),('c'); +alter table t1 modify a char(5); +select a, hex(a) from t1; +drop table t1; + +# +# Check prepare statement from an UTF32 string +# +set @ivar= 1234; +set @str1 = 'select ?'; +set @str2 = convert(@str1 using utf32); +prepare stmt1 from @str2; +execute stmt1 using @ivar; + +# +# Check that utf32 works with ENUM and SET type +# +set names utf8; +create table t1 (a enum('x','y','z') character set utf32); +show create table t1; +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +select a, hex(a) from t1 order by a; +alter table t1 change a a enum('x','y','z','d','e','ä','ö','ĂĽ') character set utf32; +show create table t1; +insert into t1 values ('D'); +insert into t1 values ('E '); +insert into t1 values ('ä'); +insert into t1 values ('ö'); +insert into t1 values ('ĂĽ'); +select a, hex(a) from t1 order by a; +drop table t1; + +create table t1 (a set ('x','y','z','ä','ö','ĂĽ') character set utf32); +show create table t1; +insert into t1 values ('x'); +insert into t1 values ('y'); +insert into t1 values ('z'); +insert into t1 values ('x,y'); +insert into t1 values ('x,y,z,ä,ö,ĂĽ'); +select a, hex(a) from t1 order by a; +drop table t1; + +# +# Bug#7302 UCS2 data in ENUM fields get truncated when new column is added +# +create table t1(a enum('a','b','c')) default character set utf32; +insert into t1 values('a'),('b'),('c'); +alter table t1 add b char(1); +show warnings; +select * from t1 order by a; +drop table t1; + +SET NAMES latin1; +SET collation_connection='utf32_general_ci'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc +SET NAMES latin1; +SET collation_connection='utf32_bin'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc + +# +# Bug#10344 Some string functions fail for UCS2 +# +select hex(substr(_utf32 0x000000e4000000e500000068,1)); +select hex(substr(_utf32 0x000000e4000000e500000068,2)); +select hex(substr(_utf32 0x000000e4000000e500000068,3)); +select hex(substr(_utf32 0x000000e4000000e500000068,-1)); +select hex(substr(_utf32 0x000000e4000000e500000068,-2)); +select hex(substr(_utf32 0x000000e4000000e500000068,-3)); + +#SET NAMES latin1; +# +# Bug#8235 +# +# This bug also helped to find another problem that +# INSERT of a UCS2 string containing a negative number +# into a unsigned int column didn't produce warnings. +# This test covers both problems. +# +#SET collation_connection='ucs2_swedish_ci'; +#CREATE TABLE t1 (Field1 int(10) default '0'); +## no warnings, negative numbers are allowed +#INSERT INTO t1 VALUES ('-1'); +#SELECT * FROM t1; +#DROP TABLE t1; +#CREATE TABLE t1 (Field1 int(10) unsigned default '0'); +## this should generate a "Data truncated" warning +#INSERT INTO t1 VALUES ('-1'); +#DROP TABLE t1; +#SET NAMES latin1; + +# +## +## Bug#18691 Converting number to UNICODE string returns invalid result +## +#SELECT CONVERT(103, CHAR(50) UNICODE); +#SELECT CONVERT(103.0, CHAR(50) UNICODE); +#SELECT CONVERT(-103, CHAR(50) UNICODE); +#SELECT CONVERT(-103.0, CHAR(50) UNICODE); + +# +# Bug#9557 MyISAM utf8 table crash +# +CREATE TABLE t1 ( + a varchar(250) NOT NULL default '', + KEY a (a) +) ENGINE=MyISAM DEFAULT CHARSET=utf32 COLLATE utf32_general_ci; +insert into t1 values (0x803d); +insert into t1 values (0x005b); +select hex(a) from t1; +drop table t1; + +## +## Bug #14583 Bug on query using a LIKE on indexed field with ucs2_bin collation +## +#--disable_warnings +#create table t1(f1 varchar(5) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL) engine=InnoDB; +#--enable_warnings +#insert into t1 values('a'); +#create index t1f1 on t1(f1); +#select f1 from t1 where f1 like 'a%'; +#drop table t1; + +# +# Bug#9442 Set parameter make query fail if column character set is UCS2 +# +create table t1 (utext varchar(20) character set utf32); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +execute stmt using @param1; +select utext from t1 where utext like '%%'; +drop table t1; +deallocate prepare stmt; + +# +# Bug#22052 Trailing spaces are not removed from UNICODE fields in an index +# +create table t1 ( + a char(10) character set utf32 not null, + index a (a) +) engine=myisam; +insert into t1 values (repeat(0x0000201f, 10)); +insert into t1 values (repeat(0x00002020, 10)); +insert into t1 values (repeat(0x00002021, 10)); +# make sure "index read" is used +explain select hex(a) from t1 order by a; +select hex(a) from t1 order by a; +alter table t1 drop index a; +select hex(a) from t1 order by a; +drop table t1; + +# +# Bug #20076: server crashes for a query with GROUP BY if MIN/MAX aggregation +# over a 'ucs2' field uses a temporary table +# +#CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci); +#INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ'); +#SELECT id, MIN(s) FROM t1 GROUP BY id; +#DROP TABLE t1; + +## +## Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb +## +# +#--disable_warnings +#drop table if exists bug20536; +#--enable_warnings +# +#set names latin1; +#create table bug20536 (id bigint not null auto_increment primary key, name +#varchar(255) character set ucs2 not null); +#insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'"); +#select md5(name) from bug20536; +#select sha1(name) from bug20536; +#select make_set(3, name, upper(name)) from bug20536; +#select export_set(5, name, upper(name)) from bug20536; +#select export_set(5, name, upper(name), ",", 5) from bug20536; + +# +# Bug #20108: corrupted default enum value for a ucs2 field +# + +CREATE TABLE t1 ( + status enum('active','passive') character set utf32 collate utf32_general_ci + NOT NULL default 'passive' +); +SHOW CREATE TABLE t1; +ALTER TABLE t1 ADD a int NOT NULL AFTER status; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +#CREATE TABLE t2 ( +# status enum('active','passive') collate ucs2_turkish_ci +# NOT NULL default 'passive' +#); +#SHOW CREATE TABLE t2; +#ALTER TABLE t2 ADD a int NOT NULL AFTER status; +#DROP TABLE t2; + + +## Some broken functions: add these tests just to document current behavior. +# +## PASSWORD and OLD_PASSWORD don't work with UCS2 strings, but to fix it would +## not be backwards compatible in all cases, so it's best to leave it alone +#select password(name) from bug20536; +#select old_password(name) from bug20536; +# +## Disable test case as encrypt relies on 'crypt' function. +## "decrypt" is noramlly tested in func_crypt.test which have a +## "have_crypt.inc" test +#--disable_parsing +## ENCRYPT relies on OS function crypt() which takes a NUL-terminated string; it +## doesn't return good results for strings with embedded 0 bytes. It won't be +## fixed unless we choose to re-implement the crypt() function ourselves to take +## an extra size_t string_length argument. +#select encrypt(name, 'SALT') from bug20536; +#--enable_parsing +# +## QUOTE doesn't work with UCS2 data. It would require a total rewrite +## of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is +## supported fully as a client character set. +#select quote(name) from bug20536; +# +#drop table bug20536; +# +--echo End of 4.1 tests + + +# +# Conversion from an UTF32 string to a decimal column +# +CREATE TABLE t1 (a varchar(64) character set utf32, b decimal(10,3)); +INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); +update t1 set b=a; +SELECT *, hex(a) FROM t1; +DROP TABLE t1; + +# +# Bug#9442 Set parameter make query fail if column character set is UCS2 +# +create table t1 (utext varchar(20) character set utf32); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +execute stmt using @param1; +select utext from t1 where utext like '%%'; +drop table t1; +deallocate prepare stmt; + +# +# Bug#22638 SOUNDEX broken for international characters +# +set names latin1; +set character_set_connection=utf32; +select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); +select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb')); +select 'mood' sounds like 'mud'; +# Cyrillic A, BE, VE +select hex(soundex(_utf32 0x000004100000041100000412)); +# Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter +select hex(soundex(_utf32 0x000000BF000000C0)); +set names latin1; + +# +# Bug #14290: character_maximum_length for text fields +# +create table t1(a blob, b text charset utf32); +select data_type, character_octet_length, character_maximum_length + from information_schema.columns where table_name='t1'; +drop table t1; + + +set names latin1; +set collation_connection=utf32_general_ci; +# +# Testing cs->coll->instr() +# +select position('bb' in 'abba'); + +# +# Testing cs->coll->hash_sort() +# +create table t1 (a varchar(10) character set utf32) engine=heap; +insert into t1 values ('a'),('A'),('b'),('B'); +select * from t1 where a='a' order by binary a; +select hex(min(binary a)),count(*) from t1 group by a; +drop table t1; + +# +# Testing cs->cset->numchars() +# +select char_length('abcd'), octet_length('abcd'); + +# +# Testing cs->cset->charpos() +# +select left('abcd',2); + +# +# Testing cs->cset->well_formed_length() +# +create table t1 (a varchar(10) character set utf32); +insert into t1 values (_utf32 0x0010FFFF); +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf32 0x00110000); +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf32 0x00110101); +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf32 0x01000101); +--error ER_INVALID_CHARACTER_STRING +insert into t1 values (_utf32 0x11000101); +select hex(a) from t1; +drop table t1; + +# +# Bug#32914 Character sets: illegal characters in utf8 and utf32 columns +# +create table t1 (utf32 varchar(2) character set utf32); +--echo Wrong character with pad +insert into t1 values (0x110000); +--echo Wrong chsaracter without pad +insert into t1 values (0x00110000); +--echo Wrong character with pad followed by another wrong character +insert into t1 values (0x11000000110000); +--echo Good character with pad followed by bad character +insert into t1 values (0x10000000110000); +--echo Good character without pad followed by bad character +insert into t1 values (0x0010000000110000); +--echo Wrong character with the second byte higher than 0x10 +insert into t1 values (0x00800037); +--echo Wrong character with pad with the second byte higher than 0x10 +insert into t1 values (0x00800037); +drop table t1; + +# +# Bug#32394 Character sets: crash if comparison with 0xfffd +# +select _utf32'a' collate utf32_general_ci = 0xfffd; +select hex(concat(_utf32 0x0410 collate utf32_general_ci, 0x61)); +create table t1 (s1 varchar(5) character set utf32); +insert into t1 values (0xfffd); +select case when s1 = 0xfffd then 1 else 0 end from t1; +select hex(s1) from t1 where s1 = 0xfffd; +drop table t1; + +# +# Testing cs->cset->lengthsp() +# +create table t1 (a char(10)) character set utf32; +insert into t1 values ('a '); +select hex(a) from t1; +drop table t1; + +# +# Testing cs->cset->caseup() and cs->cset->casedn() +# +select upper('abcd'), lower('ABCD'); + +# +# TODO: str_to_datetime() is broken and doesn't work with ucs2 and utf32 +# Testing cs->cset->snprintf() +# +#create table t1 (a date); +#insert into t1 values ('2007-09-16'); +#select * from t1; +#drop table t1; + +# +# Testing cs->cset->l10tostr +# !!! Not used in the code + +# +# Testing cs->cset->ll10tostr +# +create table t1 (a varchar(10) character set utf32); +insert into t1 values (123456); +select a, hex(a) from t1; +drop table t1; + +# +# Testing cs->cset->fill +# SOUNDEX fills strings with DIGIT ZERO up to four characters +select hex(soundex('a')); + +# +# Testing cs->cset->strntol +# !!! Not used in the code + +# +# Testing cs->cset->strntoul +# +create table t1 (a enum ('a','b','c')) character set utf32; +insert into t1 values ('1'); +select * from t1; +drop table t1; + +# +# Testing cs->cset->strntoll and cs->cset->strntoull +# +set names latin1; +select hex(conv(convert('123' using utf32), -10, 16)); +select hex(conv(convert('123' using utf32), 10, 16)); + +# +# Testing cs->cset->strntod +# +set names latin1; +set character_set_connection=utf32; +select 1.1 + '1.2'; +select 1.1 + '1.2xxx'; + +# Testing strntoll10_utf32 +# Testing cs->cset->strtoll10 +select left('aaa','1'); + +# +# Testing cs->cset->strntoull10rnd +# +create table t1 (a int); +insert into t1 values ('-1234.1e2'); +insert into t1 values ('-1234.1e2xxxx'); +insert into t1 values ('-1234.1e2 '); +select * from t1; +drop table t1; + +# +# Testing cs->cset->scan +# +create table t1 (a int); +insert into t1 values ('1 '); +insert into t1 values ('1 x'); +select * from t1; +drop table t1; + +# +# Testing auto-conversion to TEXT +# +create table t1 (a varchar(17000) character set utf32); +show create table t1; +drop table t1; + +# +# Testing that maximim possible key length is 1332 bytes +# +create table t1 (a varchar(250) character set utf32 primary key); +show create table t1; +drop table t1; +--error ER_TOO_LONG_KEY +create table t1 (a varchar(334) character set utf32 primary key); + +# +# Testing mi_check with long key values +# +create table t1 (a varchar(333) character set utf32, key(a)); +insert into t1 values (repeat('a',333)), (repeat('b',333)); +flush tables; +check table t1; +drop table t1; + +# +# Test how character set works with date/time +# +SET collation_connection=utf32_general_ci; +--source include/ctype_datetime.inc +SET NAMES latin1; + +# +# Test basic regex functionality +# +set collation_connection=utf32_general_ci; +--source include/ctype_regex.inc +set names latin1; + + +# TODO: add tests for all engines + +# +# Bug #36418 Character sets: crash if char(256 using utf32) +# +select hex(char(0x01 using utf32)); +select hex(char(0x0102 using utf32)); +select hex(char(0x010203 using utf32)); +select hex(char(0x01020304 using utf32)); +create table t1 (s1 varchar(1) character set utf32, s2 text character set utf32); +create index i on t1 (s1); +insert into t1 values (char(256 using utf32), char(256 using utf32)); +select hex(s1), hex(s2) from t1; +drop table t1; + + +# +# Bug#33073 Character sets: ordering fails with utf32 +# +SET collation_connection=utf32_general_ci; +CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0; +SHOW CREATE TABLE t1; +INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE'); +SELECT * FROM t1 ORDER BY s1; +SET max_sort_length=4; +SELECT * FROM t1 ORDER BY s1; +DROP TABLE t1; +SET max_sort_length=DEFAULT; +SET NAMES latin1; + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/ctype_utf32_uca.test b/mysql-test/t/ctype_utf32_uca.test new file mode 100644 index 00000000000..9386cc9e65e --- /dev/null +++ b/mysql-test/t/ctype_utf32_uca.test @@ -0,0 +1,291 @@ +-- source include/have_ucs2.inc +-- source include/have_utf32.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +--echo # +--echo # Start of 5.5 tests +--echo # + +set names utf8; +set collation_connection=utf32_unicode_ci; +select hex('a'), hex('a '); +-- source include/endspace.inc + +# +# Bug #6787 LIKE not working properly with _ and utf8 data +# +select 'c' like '\_' as want0; + +# +# Bug #5679 utf8_unicode_ci LIKE--trailing % doesn't equal zero characters +# +CREATE TABLE t ( + c char(20) NOT NULL +) ENGINE=MyISAM DEFAULT CHARACTER SET utf32 COLLATE=utf32_unicode_ci; +INSERT INTO t VALUES ('a'),('ab'),('aba'); +ALTER TABLE t ADD INDEX (c); +SELECT c FROM t WHERE c LIKE 'a%'; +DROP TABLE t; + + +create table t1 (c1 char(10) character set utf32 collate utf32_bin); + +# +# Basic Latin +# +insert into t1 values ('A'),('a'); +insert into t1 values ('B'),('b'); +insert into t1 values ('C'),('c'); +insert into t1 values ('D'),('d'); +insert into t1 values ('E'),('e'); +insert into t1 values ('F'),('f'); +insert into t1 values ('G'),('g'); +insert into t1 values ('H'),('h'); +insert into t1 values ('I'),('i'); +insert into t1 values ('J'),('j'); +insert into t1 values ('K'),('k'); +insert into t1 values ('L'),('l'); +insert into t1 values ('M'),('m'); +insert into t1 values ('N'),('n'); +insert into t1 values ('O'),('o'); +insert into t1 values ('P'),('p'); +insert into t1 values ('Q'),('q'); +insert into t1 values ('R'),('r'); +insert into t1 values ('S'),('s'); +insert into t1 values ('T'),('t'); +insert into t1 values ('U'),('u'); +insert into t1 values ('V'),('v'); +insert into t1 values ('W'),('w'); +insert into t1 values ('X'),('x'); +insert into t1 values ('Y'),('y'); +insert into t1 values ('Z'),('z'); + +# +# Latin1 suppliment +# +insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0); +insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1); +insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2); +insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3); +insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4); +insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5); +insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6); +insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7); +insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8); +insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9); +insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca); +insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb); +insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc); +insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd); +insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce); +insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf); + +insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0); +insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1); +insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2); +insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3); +insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4); +insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5); +insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6); +insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7); +insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8); +insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9); +insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da); +insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db); +insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc); +insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd); +insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de); +insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df); + +# +# Latin extended-A, 0100-017F +# +insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103); +insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107); +insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b); +insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f); +insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113); +insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117); +insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b); +insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f); +insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123); +insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127); +insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b); +insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f); +insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133); +insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137); +insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b); +insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f); +insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143); +insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147); +insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b); +insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f); +insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153); +insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157); +insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b); +insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f); +insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163); +insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167); +insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b); +insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f); +insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173); +insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177); +insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b); +insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f); + +# +# Latin extended-B, 0180-024F +# +insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183); +insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187); +insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b); +insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f); +insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193); +insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197); +insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b); +insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f); +insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3); +insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7); +insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab); +insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af); +insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3); +insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7); +insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb); +insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf); +insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3); +insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7); +insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb); +insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf); +insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3); +insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7); +insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db); +insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df); +insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3); +insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7); +insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb); +insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef); +insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3); +insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7); +insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb); +insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff); + + +insert into t1 values ('AA'),('Aa'),('aa'),('aA'); +insert into t1 values ('CH'),('Ch'),('ch'),('cH'); +insert into t1 values ('DZ'),('Dz'),('dz'),('dZ'); +insert into t1 values ('IJ'),('Ij'),('ij'),('iJ'); +insert into t1 values ('LJ'),('Lj'),('lj'),('lJ'); +insert into t1 values ('LL'),('Ll'),('ll'),('lL'); +insert into t1 values ('NJ'),('Nj'),('nj'),('nJ'); +insert into t1 values ('OE'),('Oe'),('oe'),('oE'); +insert into t1 values ('SS'),('Ss'),('ss'),('sS'); +insert into t1 values ('RR'),('Rr'),('rr'),('rR'); + +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_unicode_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_icelandic_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_latvian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_romanian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_slovenian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_polish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_estonian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_spanish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_swedish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_turkish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_czech_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_danish_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_lithuanian_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_slovak_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_spanish2_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_roman_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_esperanto_ci; +select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_hungarian_ci; + +drop table t1; + +# +# Bug#5324 +# +SET NAMES utf8; +#test1 +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +#Check one row +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 COLLATE utf32_general_ci; +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +#Check two rows +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 +COLLATE utf32_general_ci ORDER BY c; +DROP TABLE t1; +#test2 +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +#Check one row +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 COLLATE utf32_unicode_ci; +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B4); +#Check two rows +SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 +COLLATE utf32_unicode_ci ORDER BY c; +DROP TABLE t1; +#test 3 +CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL, INDEX (c)); +INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308); +#Check one row row +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf32) COLLATE utf32_unicode_ci; +INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8)); +#Check two rows +SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf32) +COLLATE utf32_unicode_ci ORDER BY c; +DROP TABLE t1; + + +SET NAMES utf8; +SET @test_character_set='utf32'; +SET @test_collation='utf32_swedish_ci'; +-- source include/ctype_common.inc + + +SET collation_connection='utf32_unicode_ci'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc + +--echo End of 4.1 tests + +# +# Check UPPER/LOWER changing length +# +# Result shorter than argument +CREATE TABLE t1 (id int, a varchar(30) character set utf32); +INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131); +INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049); +INSERT INTO t1 VALUES (5, _ucs2 0x01300130), (6, _ucs2 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf32 collate utf32_turkish_ci; +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +DROP TABLE t1; + +# +# Bug #27079 Crash while grouping empty ucs2 strings +# +CREATE TABLE t1 ( + c1 text character set utf32 collate utf32_polish_ci NOT NULL +) ENGINE=MyISAM; +insert into t1 values (''),('a'); +SELECT COUNT(*), c1 FROM t1 GROUP BY c1; +DROP TABLE IF EXISTS t1; + + +# +# Test basic regex functionality +# +set collation_connection=utf32_unicode_ci; +--source include/ctype_regex.inc + + +--echo # +--echo # End of 5.5 tests +--echo # diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 1a560554d3d..201e96b0b09 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1440,6 +1440,17 @@ DROP TABLE t1; --echo Start of 5.4 tests + +# +# WL#1213: utf8mb3 is an alias for utf8 +# +SET NAMES utf8mb3; +SHOW VARIABLES LIKE 'character_set_results%'; +CREATE TABLE t1 (a CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin); +SHOW CREATE TABLE t1; +DROP TABLE t1; +SELECT _utf8mb3'test'; + # # Bug#26180: Can't add columns to tables created with utf8 text indexes # diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test new file mode 100644 index 00000000000..2c166364b1a --- /dev/null +++ b/mysql-test/t/ctype_utf8mb4.test @@ -0,0 +1,1670 @@ +# +# Tests with the utf8mb4 character set +# + +--source include/have_innodb.inc + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +--echo # +--echo # Start of 5.5 tests +--echo # + +set names utf8mb4; + +select left(_utf8mb4 0xD0B0D0B1D0B2,1); +select right(_utf8mb4 0xD0B0D0B2D0B2,1); + +select locate('he','hello'); +select locate('he','hello',2); +select locate('lo','hello',2); +select locate('HE','hello'); +select locate('HE','hello',2); +select locate('LO','hello',2); +select locate('HE','hello' collate utf8mb4_bin); +select locate('HE','hello' collate utf8mb4_bin,2); +select locate('LO','hello' collate utf8mb4_bin,2); + +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2); +select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2); +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2); +select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin); +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin); + +select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1); + +select 'a' like 'a'; +select 'A' like 'a'; +select 'A' like 'a' collate utf8mb4_bin; +select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%'); + +# Bug #6040: can't retrieve records with umlaut +# characters in case insensitive manner. +# Case insensitive search LIKE comparison +# was broken for multibyte characters: +select convert(_latin1'Günter André' using utf8mb4) like CONVERT(_latin1'GÜNTER%' USING utf8mb4); +select CONVERT(_koi8r'×ÁÓŃ' USING utf8mb4) LIKE CONVERT(_koi8r'÷áóń' USING utf8mb4); +select CONVERT(_koi8r'÷áóń' USING utf8mb4) LIKE CONVERT(_koi8r'×ÁÓŃ' USING utf8mb4); + +# +# Check the following: +# "a" == "a " +# "a\0" < "a" +# "a\0" < "a " + +SELECT 'a' = 'a '; +SELECT 'a\0' < 'a'; +SELECT 'a\0' < 'a '; +SELECT 'a\t' < 'a'; +SELECT 'a\t' < 'a '; + +# +# The same for binary collation +# +SELECT 'a' = 'a ' collate utf8mb4_bin; +SELECT 'a\0' < 'a' collate utf8mb4_bin; +SELECT 'a\0' < 'a ' collate utf8mb4_bin; +SELECT 'a\t' < 'a' collate utf8mb4_bin; +SELECT 'a\t' < 'a ' collate utf8mb4_bin; + +CREATE TABLE t1 (a char(10) character set utf8mb4 not null); +INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a '); +SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1; +DROP TABLE t1; + +# +# Fix this, it should return 1: +# +#select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD091,_utf8mb4 '%'); +# + +# +# Bug 2367: INSERT() behaviour is different for different charsets. +# +select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); +select insert("aa",100,1,"b"),insert("aa",1,3,"b"); + +# +# LELF() didn't work well with utf8mb4 in some cases too. +# +select char_length(left(@a:='теŃŃ‚',5)), length(@a), @a; + + +# +# CREATE ... SELECT +# +create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d"); +show create table t1; +select * from t1; +drop table t1; + +# +# Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails +# +set names utf8mb4; +set LC_TIME_NAMES='fr_FR'; +create table t1 (s1 char(20) character set latin1); +insert into t1 values (date_format('2004-02-02','%M')); +select hex(s1) from t1; +drop table t1; +create table t1 (s1 char(20) character set koi8r); +set LC_TIME_NAMES='ru_RU'; +insert into t1 values (date_format('2004-02-02','%M')); +insert into t1 values (date_format('2004-02-02','%b')); +insert into t1 values (date_format('2004-02-02','%W')); +insert into t1 values (date_format('2004-02-02','%a')); +select hex(s1), s1 from t1; +drop table t1; +set LC_TIME_NAMES='en_US'; + + +# +# Bug #2366 Wrong utf8mb4 behaviour when data is truncated +# +set names koi8r; +create table t1 (s1 char(1) character set utf8mb4); +insert into t1 values (_koi8r'ÁÂ'); +select s1,hex(s1),char_length(s1),octet_length(s1) from t1; +drop table t1; + +create table t1 (s1 tinytext character set utf8mb4); +insert into t1 select repeat('a',300); +insert into t1 select repeat('Ń',300); +insert into t1 select repeat('aŃ',300); +insert into t1 select repeat('Ńa',300); +insert into t1 select repeat('ŃŃ',300); +select hex(s1) from t1; +select length(s1),char_length(s1) from t1; +drop table t1; + +create table t1 (s1 text character set utf8mb4); +insert into t1 select repeat('a',66000); +insert into t1 select repeat('Ń',66000); +insert into t1 select repeat('aŃ',66000); +insert into t1 select repeat('Ńa',66000); +insert into t1 select repeat('ŃŃ',66000); +select length(s1),char_length(s1) from t1; +drop table t1; + +# +# Bug #2368 Multibyte charsets do not check that incoming data is well-formed +# +create table t1 (s1 char(10) character set utf8mb4); +insert into t1 values (0x41FF); +select hex(s1) from t1; +drop table t1; + +create table t1 (s1 varchar(10) character set utf8mb4); +insert into t1 values (0x41FF); +select hex(s1) from t1; +drop table t1; + +create table t1 (s1 text character set utf8mb4); +insert into t1 values (0x41FF); +select hex(s1) from t1; +drop table t1; + +# +# Bug 2699 +# UTF8 breaks primary keys for cols > 333 characters +# +--error 1071 +create table t1 (a text character set utf8mb4, primary key(a(371))); + + +# +# Bug 2959 +# UTF8 charset breaks joins with mixed column/string constant +# +CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4; +INSERT INTO t1 VALUES ( 'test' ); +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a; +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test'; +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test'; +DROP TABLE t1; + +create table t1 (a char(255) character set utf8mb4); +insert into t1 values('b'),('b'); +select * from t1 where a = 'b'; +select * from t1 where a = 'b' and a = 'b'; +select * from t1 where a = 'b' and a != 'b'; +drop table t1; + +# +# Testing regexp +# +set collation_connection=utf8mb4_general_ci; +--source include/ctype_regex.inc +set names utf8mb4; + +# +# Bug #3928 regexp [[:>:]] and UTF-8 +# +set names utf8mb4; + +# This should return TRUE +select 'ваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +select 'ваŃŃŹ ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +select ' ваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +select ' ваŃŃŹ ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; + +# This should return FALSE +select 'ваŃŃŹz' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +select 'zваŃŃŹ' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; +select 'zваŃŃŹz' rlike '[[:<:]]ваŃŃŹ[[:>:]]'; + +# +# Bug #4555 +# ALTER TABLE crashes mysqld with enum column collated utf8mb4_unicode_ci +# +CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci); +ALTER TABLE t1 ADD COLUMN b CHAR(20); +DROP TABLE t1; + +# Customer Support Center issue # 3299 +# ENUM and SET multibyte fields computed their length wronly +# when converted into a char field +set names utf8mb4; +create table t1 (a enum('aaaa','проба') character set utf8mb4); +show create table t1; +insert into t1 values ('проба'); +select * from t1; +create table t2 select ifnull(a,a) from t1; +show create table t2; +select * from t2; +drop table t1; +drop table t2; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# MYISAM: keys with prefix compression, case insensitive collation. +# +create table t1 (c varchar(30) character set utf8mb4, unique(c(10))); +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaaa'); +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +select c c2 from t1 where c='2'; +select c c3 from t1 where c='3'; +select c cx from t1 where c='x'; +select c cy from t1 where c='y'; +select c cz from t1 where c='z'; +select c ca10 from t1 where c='aaaaaaaaaa'; +select c cb20 from t1 where c=repeat('b',20); +drop table t1; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# InnoDB: keys with prefix compression, case insensitive collation. +# +--disable_warnings +create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=innodb; +--enable_warnings +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaaa'); +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +select c c2 from t1 where c='2'; +select c c3 from t1 where c='3'; +select c cx from t1 where c='x'; +select c cy from t1 where c='y'; +select c cz from t1 where c='z'; +select c ca10 from t1 where c='aaaaaaaaaa'; +select c cb20 from t1 where c=repeat('b',20); +drop table t1; +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# MYISAM: fixed length keys, case insensitive collation +# +create table t1 (c char(3) character set utf8mb4, unique (c(2))); +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('b'); +insert into t1 values ('bb'); +--error ER_DUP_ENTRY +insert into t1 values ('bbb'); +insert into t1 values ('а'); +insert into t1 values ('аа'); +--error ER_DUP_ENTRY +insert into t1 values ('ааа'); +insert into t1 values ('б'); +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +--error ER_DUP_ENTRY +insert into t1 values ('ꪪꪪꪪ'); +drop table t1; +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# InnoDB: fixed length keys, case insensitive collation +# +--disable_warnings +create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=innodb; +--enable_warnings +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('b'); +insert into t1 values ('bb'); +--error ER_DUP_ENTRY +insert into t1 values ('bbb'); +insert into t1 values ('а'); +insert into t1 values ('аа'); +--error ER_DUP_ENTRY +insert into t1 values ('ааа'); +insert into t1 values ('б'); +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +--error ER_DUP_ENTRY +insert into t1 values ('ꪪꪪꪪ'); +drop table t1; +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check HEAP+HASH, case insensitive collation +# +create table t1 ( +c char(10) character set utf8mb4, +unique key a using hash (c(1)) +) engine=heap; +show create table t1; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check HEAP+BTREE, case insensitive collation +# +create table t1 ( +c char(10) character set utf8mb4, +unique key a using btree (c(1)) +) engine=heap; +show create table t1; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check BDB, case insensitive collation +# +--disable_warnings +create table t1 ( +c char(10) character set utf8mb4, +unique key a (c(1)) +) engine=innodb; +--enable_warnings +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# MYISAM: keys with prefix compression, binary collation. +# +create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10))); +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaaa'); +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +select c c2 from t1 where c='2'; +select c c3 from t1 where c='3'; +select c cx from t1 where c='x'; +select c cy from t1 where c='y'; +select c cz from t1 where c='z'; +select c ca10 from t1 where c='aaaaaaaaaa'; +select c cb20 from t1 where c=repeat('b',20); +drop table t1; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# MYISAM: fixed length keys, binary collation +# +create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2))); +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('b'); +insert into t1 values ('bb'); +--error ER_DUP_ENTRY +insert into t1 values ('bbb'); +insert into t1 values ('а'); +insert into t1 values ('аа'); +--error ER_DUP_ENTRY +insert into t1 values ('ааа'); +insert into t1 values ('б'); +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +--error ER_DUP_ENTRY +insert into t1 values ('ꪪꪪꪪ'); +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check HEAP+HASH, binary collation +# +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a using hash (c(1)) +) engine=heap; +show create table t1; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check HEAP+BTREE, binary collation +# +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a using btree (c(1)) +) engine=heap; +show create table t1; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check BDB, binary collation +# +--disable_warnings +create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a (c(1)) +) engine=innodb; +--enable_warnings +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + + +# Bug#4594: column index make = failed for gbk, but like works +# Check MYISAM +# +create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str (str(2)) +) engine=myisam; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# Bug#4594: column index make = failed for gbk, but like works +# Check InnoDB +# +--disable_warnings +create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str (str(2)) +) engine=innodb; +--enable_warnings +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# the same for HEAP+BTREE +# + +create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str using btree (str(2)) +) engine=heap; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# the same for HEAP+HASH +# + +create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str using hash (str(2)) +) engine=heap; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# the same for BDB +# + +--disable_warnings +create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str (str(2)) +) engine=innodb; +--enable_warnings +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# +# Bug #5397: Crash with varchar binary and LIKE +# +CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4; +INSERT INTO t1 VALUES ('test'); +SELECT a FROM t1 WHERE a LIKE '%te'; +DROP TABLE t1; + +# +# Bug #5723: length() returns varying results +# +--disable_warnings +SET NAMES utf8mb4; +--disable_warnings +CREATE TABLE t1 ( + subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci, + p varchar(15) character set utf8mb4 +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t1 VALUES ('谷川俊二ă¨ç”łă—ăľă™ăŚă€ă‚¤ăłă‚żăĽăŤăăäşç´„ă®äĽšĺ“ˇç™»éŚ˛ă‚’ă—ăľă—ăźă¨ă“ろă€ăˇăĽă«ă‚˘ă‰ă¬ă‚ąă‚’é–“é•ăă¦ă—ăľă„会員IDăŚĺŹ—ă‘取るă“ă¨ăŚĺ‡şćťĄăľă›ă‚“ă§ă—ăźă€‚é–“é•ăアă‰ă¬ă‚ąăŻtani-shun@n.vodafone.ne.jpを書ăŤčľĽăżăľă—ăźă€‚ă©ă†ă™ă‚Śă°ă‚ă„ă§ă™ă‹ďĽź ăťă®ä»–ă€ä˝Źć‰€ç­‰ăŻé–“é•ăă‚りăľă›ă‚“。連絡ăŹă ă•ă„。ă‚ろă—ăŹăŠéˇă„ă—ăľă™ă€‚m(__)m','040312-000057'); +INSERT INTO t1 VALUES ('aaa','bbb'); +SELECT length(subject) FROM t1; +SELECT length(subject) FROM t1 ORDER BY 1; +DROP TABLE t1; + +# +# Bug #5832 SELECT doesn't return records in some cases +# +CREATE TABLE t1 ( + id int unsigned NOT NULL auto_increment, + list_id smallint unsigned NOT NULL, + term TEXT NOT NULL, + PRIMARY KEY(id), + INDEX(list_id, term(4)) +) ENGINE=MYISAM CHARSET=utf8mb4; +INSERT INTO t1 SET list_id = 1, term = "letterc"; +INSERT INTO t1 SET list_id = 1, term = "letterb"; +INSERT INTO t1 SET list_id = 1, term = "lettera"; +INSERT INTO t1 SET list_id = 1, term = "letterd"; +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc"); +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb"); +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera"); +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd"); +DROP TABLE t1; + + +# +# Bug #6043 erratic searching for diacriticals in indexed MyISAM UTF-8 table +# +SET NAMES latin1; +CREATE TABLE t1 ( + id int unsigned NOT NULL auto_increment, + list_id smallint unsigned NOT NULL, + term text NOT NULL, + PRIMARY KEY(id), + INDEX(list_id, term(19)) +) ENGINE=MyISAM CHARSET=utf8mb4; +INSERT INTO t1 set list_id = 1, term = "testétest"; +INSERT INTO t1 set list_id = 1, term = "testetest"; +INSERT INTO t1 set list_id = 1, term = "testčtest"; +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testétest"); +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest"); +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testčtest"); +DROP TABLE t1; + +# +# Bug #6019 SELECT tries to use too short prefix index on utf8mb4 data +# +set names utf8mb4; +--disable_warnings +create table t1 ( + a int primary key, + b varchar(6), + index b3(b(3)) +) engine=innodb character set=utf8mb4; +--enable_warnings +insert into t1 values(1,'foo'),(2,'foobar'); +select * from t1 where b like 'foob%'; +--disable_warnings +alter table t1 engine=innodb; +--enable_warnings +select * from t1 where b like 'foob%'; +drop table t1; + +# +# Test for calculate_interval_lengths() function +# +create table t1 ( + a enum('петя','ваŃŃŹ','анюта') character set utf8mb4 not null default 'анюта', + b set('петя','ваŃŃŹ','анюта') character set utf8mb4 not null default 'анюта' +); +create table t2 select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1; +show create table t2; +drop table t2; +drop table t1; + +# +# Bug #6787 LIKE not working properly with _ and utf8mb4 data +# +select 'c' like '\_' as want0; + +# +# SUBSTR with negative offset didn't work with multi-byte strings +# +SELECT SUBSTR('ваŃŃŹ',-2); + + +# +# Bug #7730 Server crash using soundex on an utf8mb4 table +# +create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci); +insert into t1 values (1, 'Test'); +select * from t1 where soundex(a) = soundex('Test'); +select * from t1 where soundex(a) = soundex('TEST'); +select * from t1 where soundex(a) = soundex('test'); +drop table t1; + +# +# Bug#22638 SOUNDEX broken for international characters +# +select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB); +select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)); +select soundex(_utf8mb4 0xD091D092D093); +select hex(soundex(_utf8mb4 0xD091D092D093)); + + +SET collation_connection='utf8mb4_general_ci'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc +-- source include/ctype_german.inc +SET collation_connection='utf8mb4_bin'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc + +# +# Bug #7874 CONCAT() gives wrong results mixing +# latin1 field and utf8mb4 string literals +# +CREATE TABLE t1 ( + user varchar(255) NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('one'),('two'); +SELECT CHARSET('a'); +SELECT user, CONCAT('<', user, '>') AS c FROM t1; +DROP TABLE t1; + +# +# Bug#8785 +# the same problem with the above, but with nested CONCATs +# +create table t1 (f1 varchar(1) not null) default charset utf8mb4; +insert into t1 values (''), (''); +select concat(concat(_latin1'->',f1),_latin1'<-') from t1; +drop table t1; + +# +# Bug#8385: utf8mb4_general_ci treats Cyrillic letters I and SHORT I as the same +# +select convert(_koi8r'É' using utf8mb4) < convert(_koi8r'Ę' using utf8mb4); + +# +# Bugs#5980: NULL requires a characterset in a union +# +set names latin1; +create table t1 (a varchar(10)) character set utf8mb4; +insert into t1 values ('test'); +select ifnull(a,'') from t1; +drop table t1; +select repeat(_utf8mb4'+',3) as h union select NULL; +select ifnull(NULL, _utf8mb4'string'); + +# +# Bug#9509 Optimizer: wrong result after AND with comparisons +# +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci); +insert into t1 values ('I'),('K'),('Y'); +select * from t1 where s1 < 'K' and s1 = 'Y'; +select * from t1 where 'K' > s1 and s1 = 'Y'; +drop table t1; + +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci); +insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i'); +select * from t1 where s1 > 'd' and s1 = 'CH'; +select * from t1 where 'd' < s1 and s1 = 'CH'; +select * from t1 where s1 = 'cH' and s1 <> 'ch'; +select * from t1 where 'cH' = s1 and s1 <> 'ch'; +drop table t1; + +# +# Bug#10714: Inserting double value into utf8mb4 column crashes server +# +create table t1 (a varchar(255)) default character set utf8mb4; +insert into t1 values (1.0); +drop table t1; + +# +# Bug#10253 compound index length and utf8mb4 char set +# produces invalid query results +# +create table t1 ( + id int not null, + city varchar(20) not null, + key (city(7),id) +) character set=utf8mb4; +insert into t1 values (1,'Durban North'); +insert into t1 values (2,'Durban'); +select * from t1 where city = 'Durban'; +select * from t1 where city = 'Durban '; +drop table t1; + +# +# Bug #11819 CREATE TABLE with a SET DEFAULT 0 and UTF8 crashes server. +# +--error 1067 +create table t1 (x set('A', 'B') default 0) character set utf8mb4; +--error 1067 +create table t1 (x enum('A', 'B') default 0) character set utf8mb4; + + +# +# Test for bug #11167: join for utf8mb4 varchar value longer than 255 bytes +# + +SET NAMES UTF8; + +CREATE TABLE t1 ( + `id` int(20) NOT NULL auto_increment, + `country` varchar(100) NOT NULL default '', + `shortcode` varchar(100) NOT NULL default '', + `operator` varchar(100) NOT NULL default '', + `momid` varchar(30) NOT NULL default '', + `keyword` varchar(160) NOT NULL default '', + `content` varchar(160) NOT NULL default '', + `second_token` varchar(160) default NULL, + `gateway_id` int(11) NOT NULL default '0', + `created` datetime NOT NULL default '0000-00-00 00:00:00', + `msisdn` varchar(15) NOT NULL default '', + PRIMARY KEY (`id`), + UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`), + KEY `IX_mobile_originated_message_keyword` (`keyword`), + KEY `IX_mobile_originated_message_created` (`created`), + KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; + +INSERT INTO t1 VALUES +(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Đмри.Đфимим.Đеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.ĐĐ´.Đ” имдимримрад.Đдимримримрмдиримримримр ĐĽ.ДадимфŃьмримд им.Đдимимрн имадми','ĐМРĐ.ĐФĐĐśĐĐś.ĐĐ•ĐĐśĐМРĐМДМРĐМРМРĐРОР',3,'2005-06-01 17:30:43','1234567890'), +(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890'); + +--disable_warnings +CREATE TABLE t2 ( + `msisdn` varchar(15) NOT NULL default '', + `operator_id` int(11) NOT NULL default '0', + `created` datetime NOT NULL default '0000-00-00 00:00:00', + UNIQUE KEY `PK_user` (`msisdn`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +--enable_warnings + +INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25'); + +SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890'; + +DROP TABLE t1,t2; + +# +# Bug#11591: CHAR column with utf8mb4 does not work properly +# (more chars than expected) +# +create table t1 (a char(20) character set utf8mb4); +insert into t1 values ('123456'),('андрей'); +alter table t1 modify a char(2) character set utf8mb4; +select char_length(a), length(a), a from t1 order by a; +drop table t1; + +# +# Bugs#12611 +# ESCAPE + LIKE do not work when the escape char is a multibyte one +# +set names utf8mb4; +select 'andre%' like 'andreñ%' escape 'ñ'; + +# +# Bugs#11754: SET NAMES utf8mb4 followed by SELECT "A\\" LIKE "A\\" returns 0 +# +set names utf8mb4; +select 'a\\' like 'a\\'; +select 'aa\\' like 'a%\\'; + +create table t1 (a char(10), key(a)) character set utf8mb4; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +select * from t1 where a like "abc%"; +select * from t1 where a like concat("abc","%"); +select * from t1 where a like "ABC%"; +select * from t1 where a like "test%"; +select * from t1 where a like "te_t"; +select * from t1 where a like "%a%"; +select * from t1 where a like "%abcd%"; +select * from t1 where a like "%abc\d%"; +drop table t1; + + +# +# Bug#9557 MyISAM utf8mb4 table crash +# +CREATE TABLE t1 ( + a varchar(255) NOT NULL default '', + KEY a (a) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; +insert into t1 values (_utf8mb4 0xe880bd); +insert into t1 values (_utf8mb4 0x5b); +select hex(a) from t1; +drop table t1; + +# +# Bug#13751 find_in_set: Illegal mix of collations +# +set names 'latin1'; +create table t1 (a varchar(255)) default charset=utf8mb4; +select * from t1 where find_in_set('-1', a); +drop table t1; + +# +# Bug#13233: select distinct char(column) fails with utf8mb4 +# +create table t1 (a int); +insert into t1 values (48),(49),(50); +set names utf8mb4; +select distinct char(a) from t1; +drop table t1; + +# +# Bug#15581: COALESCE function truncates mutli-byte TINYTEXT values +# +CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4); +INSERT INTO t1 VALUES(REPEAT('a', 100)); +CREATE TEMPORARY TABLE t2 SELECT COALESCE(t) AS bug FROM t1; +SELECT LENGTH(bug) FROM t2; +DROP TABLE t2; +DROP TABLE t1; + +# +# Bug#17313: N'xxx' and _utf8mb4'xxx' are not equivalent +# +CREATE TABLE t1 (item varchar(255)) default character set utf8mb4; +INSERT INTO t1 VALUES (N'\\'); +INSERT INTO t1 VALUES (_utf8mb4'\\'); +INSERT INTO t1 VALUES (N'Cote d\'Ivoire'); +INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire'); +SELECT item FROM t1 ORDER BY item; +DROP TABLE t1; + +# +# Bug#17705: Corruption of compressed index when index length changes between +# 254 and 256 +# + +SET NAMES utf8mb4; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t1 VALUES('uu'); +check table t1; +INSERT INTO t1 VALUES('uU'); +check table t1; +INSERT INTO t1 VALUES('uu'); +check table t1; +INSERT INTO t1 VALUES('uuABC'); +check table t1; +INSERT INTO t1 VALUES('UuABC'); +check table t1; +INSERT INTO t1 VALUES('uuABC'); +check table t1; +alter table t1 add b int; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1); +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2); +delete from t1 where b=1; +INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1); +check table t1; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3); +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4); +delete from t1 where b=3; +INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZĚbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3); +check table t1; +drop table t1; + +# +# Bug#20471 LIKE search fails with indexed utf8mb4 char column +# +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4); +insert into t1 values +('a'),('b'),(null),('ăšă†ă«ă‚°ă«'),('ĂĽ'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_general_ci from t1 where s1 like 'ăšă†%'; +delete from t1 where s1 = 'Y'; +select s1 as after_delete_general_ci from t1 where s1 like 'ăšă†%'; +drop table t1; + +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci); +insert into t1 values +('a'),('b'),(null),('ăšă†ă«ă‚°ă«'),('ĂĽ'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_unicode_ci from t1 where s1 like 'ăšă†%'; +delete from t1 where s1 = 'Y'; +select s1 as after_delete_unicode_ci from t1 where s1 like 'ăšă†%'; +drop table t1; + +set names utf8mb4; +create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin); +insert into t1 values +('a'),('b'),(null),('ăšă†ă«ă‚°ă«'),('ĂĽ'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_bin from t1 where s1 like 'ăšă†%'; +delete from t1 where s1 = 'Y'; +select s1 as after_delete_bin from t1 where s1 like 'ăšă†%'; +drop table t1; + +# additional tests from duplicate bug#20744 MySQL return no result + +set names utf8mb4; +--disable_warnings +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_general_ci; +--enable_warnings +insert into t1 values ('ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'); +insert into t1 values ('ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ'); +select a as gci1 from t1 where a like 'ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ%'; +select a as gci2 from t1 where a like 'ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'; +drop table t1; + +set names utf8mb4; +--disable_warnings +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_unicode_ci; +--enable_warnings +insert into t1 values ('ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'); +insert into t1 values ('ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ'); +select a as uci1 from t1 where a like 'ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ%'; +select a as uci2 from t1 where a like 'ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'; +drop table t1; + +set names utf8mb4; +--disable_warnings +create table t1 (a varchar(30) not null primary key) +engine=innodb default character set utf8mb4 collate utf8mb4_bin; +--enable_warnings +insert into t1 values ('ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'); +insert into t1 values ('ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ'); +select a as bin1 from t1 where a like 'ă•ă—ă™ă›ăťă‹ăŤăŹă‘ă“ă‚ă„ă†ăăŠ%'; +select a as bin2 from t1 where a like 'ă‚ă„ă†ăăŠă‹ăŤăŹă‘ă“ă•ă—ă™ă›ăť'; +drop table t1; + + + +# +# Bug#14896: Comparison with a key in a partial index over mb chararacter field +# + +SET NAMES utf8mb4; +CREATE TABLE t1 (id int PRIMARY KEY, + a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '', + b int, + f varchar(128) default 'XXX', + INDEX (a(4)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +INSERT INTO t1(id, a, b) VALUES + (1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30), + (4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40), + (7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50), + (10, 'eeeee', 40), (11, 'bbbbbb', 60); + +SELECT id, a, b FROM t1; + +SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb'; + +SELECT id, a FROM t1 WHERE a='bbbbbb'; +SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b; + +DROP TABLE t1; + +# +# Bug#16674: LIKE predicate for a utf8mb4 character set column +# + +SET NAMES utf8mb4; + +CREATE TABLE t1 ( + a CHAR(13) DEFAULT '', + INDEX(a) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES + ('Käli Käli 2-4'), ('Käli Käli 2-4'), + ('Käli Käli 2+4'), ('Käli Käli 2+4'), + ('Käli Käli 2-6'), ('Käli Käli 2-6'); +INSERT INTO t1 SELECT * FROM t1; + +CREATE TABLE t2 ( + a CHAR(13) DEFAULT '', + INDEX(a) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; + +INSERT INTO t2 VALUES + ('Kali Kali 2-4'), ('Kali Kali 2-4'), + ('Kali Kali 2+4'), ('Kali Kali 2+4'), + ('Kali Kali 2-6'), ('Kali Kali 2-6'); +INSERT INTO t2 SELECT * FROM t2; + +SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; + +EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4'; +EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4'; + +DROP TABLE t1,t2; + +CREATE TABLE t1 ( + a char(255) DEFAULT '', + KEY(a(10)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +DROP TABLE t1; + +CREATE TABLE t1 ( + a char(255) DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +ALTER TABLE t1 ADD KEY (a(10)); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +DROP TABLE t1; + +# +# Bug#18359: LIKE predicate for a 'utf8mb4' text column with a partial index +# (see bug #16674 as well) +# + +SET NAMES latin2; + +CREATE TABLE t1 ( + id int(11) NOT NULL default '0', + tid int(11) NOT NULL default '0', + val text NOT NULL, + INDEX idx(tid, val(10)) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; + +INSERT INTO t1 VALUES + (40988,72,'VOLNÝ ADSL'),(41009,72,'VOLNÝ ADSL'), + (41032,72,'VOLNÝ ADSL'),(41038,72,'VOLNÝ ADSL'), + (41063,72,'VOLNÝ ADSL'),(41537,72,'VOLNÝ ADSL Office'), + (42141,72,'VOLNÝ ADSL'),(42565,72,'VOLNÝ ADSL Combi'), + (42749,72,'VOLNÝ ADSL'),(44205,72,'VOLNÝ ADSL'); + +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL'; +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; +SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLNÝ ADSL'; + +ALTER TABLE t1 DROP KEY idx; +ALTER TABLE t1 ADD KEY idx (tid,val(11)); + +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; + +DROP TABLE t1; + +# +# Bug 20709: problem with utf8mb4 fields in temporary tables +# + +create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '') + default charset=utf8mb4 collate=utf8mb4_unicode_ci; +insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65')); +explain select distinct a from t1; +select distinct a from t1; +explain select a from t1 group by a; +select a from t1 group by a; +drop table t1; + +# +# Bug #20204: "order by" changes the results returned +# + +create table t1(a char(10)) default charset utf8mb4; +insert into t1 values ('123'), ('456'); +explain + select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1; +select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1; +drop table t1; + +# +# Bug #34349: Passing invalid parameter to CHAR() in an ORDER BY causes +# MySQL to hang +# + +SET CHARACTER SET utf8mb4; +SHOW VARIABLES LIKE 'character\_set\_%'; +CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; +USE crashtest; +CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4; +INSERT INTO crashtest VALUES ('35'), ('36'), ('37'); +SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +INSERT INTO crashtest VALUES ('-1000'); +EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +DROP TABLE crashtest; +DROP DATABASE crashtest; +USE test; +SET CHARACTER SET default; + +# End of 4.1 tests + +# +# Test for bug #11484: wrong results for a DISTINCT varchar column in uft8. +# + +CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4; +INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa'); + +SELECT id FROM t1; +SELECT DISTINCT id FROM t1; +SELECT DISTINCT id FROM t1 ORDER BY id; + +DROP TABLE t1; + +# +# Bug#20095 Changing length of VARCHAR field with UTF8 +# collation does not truncate values +# +create table t1 ( + a varchar(26) not null +) default character set utf8mb4; +insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz'); +select * from t1; +# varchar to varchar +alter table t1 change a a varchar(20) character set utf8mb4 not null; +select * from t1; +# varchar to char +alter table t1 change a a char(15) character set utf8mb4 not null; +select * from t1; +# char to char +alter table t1 change a a char(10) character set utf8mb4 not null; +select * from t1; +# char to varchar +alter table t1 change a a varchar(5) character set utf8mb4 not null; +select * from t1; +drop table t1; + +# +# Check that do_varstring2_mb produces a warning +# +create table t1 ( + a varchar(4000) not null +) default character set utf8mb4; +insert into t1 values (repeat('a',4000)); +alter table t1 change a a varchar(3000) character set utf8mb4 not null; +select length(a) from t1; +drop table t1; + + +# +# Bug#10504: Character set does not support traditional mode +# Bug#14146: CHAR(...USING ...) and CONVERT(CHAR(...) USING...) +# produce different results +# +set names utf8mb4; +# correct value +select hex(char(1 using utf8mb4)); +select char(0xd1,0x8f using utf8mb4); +select char(0xd18f using utf8mb4); +select char(53647 using utf8mb4); +# incorrect value: return with warning +select char(0xff,0x8f using utf8mb4); +select convert(char(0xff,0x8f) using utf8mb4); +# incorrect value in strict mode: return NULL with "Error" level warning +set sql_mode=traditional; +select char(0xff,0x8f using utf8mb4); +select char(195 using utf8mb4); +select char(196 using utf8mb4); +select char(2557 using utf8mb4); +select convert(char(0xff,0x8f) using utf8mb4); + +# +# Check convert + char + using +# +select hex(convert(char(2557 using latin1) using utf8mb4)); + +# +# char() without USING returns "binary" by default, any argument is ok +# +select hex(char(195)); +select hex(char(196)); +select hex(char(2557)); + + + +# +# Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters +# +set names utf8mb4; +create table t1 (a char(1)) default character set utf8mb4; +create table t2 (a char(1)) default character set utf8mb4; +insert into t1 values('a'),('a'),(0xE38182),(0xE38182); +insert into t1 values('i'),('i'),(0xE38184),(0xE38184); +select * from t1 union distinct select * from t2; +drop table t1,t2; + + +# +# Bug#12371: executing prepared statement fails (illegal mix of collations) +# +set names utf8mb4; +create table t1 (a char(10), b varchar(10)); +insert into t1 values ('bar','kostja'); +insert into t1 values ('kostja','bar'); +prepare my_stmt from "select * from t1 where a=?"; +set @a:='bar'; +execute my_stmt using @a; +set @a:='kostja'; +execute my_stmt using @a; +set @a:=null; +execute my_stmt using @a; +drop table if exists t1; + + +# +# Bug#21505 Create view - illegal mix of collation for operation 'UNION' +# +--disable_warnings +drop table if exists t1; +drop view if exists v1, v2; +--enable_warnings +set names utf8mb4; +create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci); +insert into t1 values('t1_val'); +create view v1 as select 'v1_val' as col1; +select coercibility(col1), collation(col1) from v1; +create view v2 as select col1 from v1 union select col1 from t1; +select coercibility(col1), collation(col1)from v2; +drop view v1, v2; +create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1; +select coercibility(col1), collation(col1) from v1; +create view v2 as select col1 from v1 union select col1 from t1; +select coercibility(col1), collation(col1) from v2; +drop view v1, v2; +drop table t1; + +# +# Check conversion of NCHAR strings to subset (e.g. latin1). +# Conversion is possible if string repertoire is ASCII. +# Conversion is not possible if the string have extended characters +# +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, N'x', N'y')) from t1; +--error 1267 +select concat(a, if(b>10, N'æ', N'Ăź')) from t1; +drop table t1; + +# Conversion tests for character set introducers +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1; +--error 1267 +select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'Ăź')) from t1; +drop table t1; + +# Conversion tests for introducer + HEX string +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1; +--error 1267 +select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1; +drop table t1; + +# Conversion tests for "text_literal TEXT_STRING_literal" syntax structure +set names utf8mb4; +create table t1 (a varchar(10) character set latin1, b int); +insert into t1 values ('a',1); +select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1; +--error 1267 +select concat(a, if(b>10, 'x' 'æ', 'y' 'Ăź')) from t1; +drop table t1; + + +# +# Bug#19960: Inconsistent results when joining +# InnoDB tables using partial UTF8 indexes +# +SHOW ENGINES; +--disable_warnings +CREATE TABLE t1 ( + colA int(11) NOT NULL, + colB varchar(255) character set utf8mb4 NOT NULL, + PRIMARY KEY (colA) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar'); +--disable_warnings +CREATE TABLE t2 ( + colA int(11) NOT NULL, + colB varchar(255) character set utf8mb4 NOT NULL, + KEY bad (colA,colB(3)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); +SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB +WHERE t1.colA < 3; +DROP TABLE t1, t2; + +# +# Bug#29205: truncation of UTF8 values when the UNION statement +# forces collation to the binary charset +# + +SELECT 'Đ˝1234567890' UNION SELECT _binary '1'; +SELECT 'Đ˝1234567890' UNION SELECT 1; + +SELECT '1' UNION SELECT 'Đ˝1234567890'; +SELECT 1 UNION SELECT 'Đ˝1234567890'; + +CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4; +CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT); + +INSERT INTO t1 (c) VALUES ('Đ˝1234567890'); +INSERT INTO t2 (b, i) VALUES ('1', 1); + +SELECT c FROM t1 UNION SELECT b FROM t2; +SELECT c FROM t1 UNION SELECT i FROM t2; + +SELECT b FROM t2 UNION SELECT c FROM t1; +SELECT i FROM t2 UNION SELECT c FROM t1; + +DROP TABLE t1, t2; + +# +# Bug#30982: CHAR(..USING..) can return a not-well-formed string +# Bug #30986: Character set introducer followed by a HEX string can return bad result +# +set sql_mode=traditional; +select hex(char(0xFF using utf8mb4)); +select hex(convert(0xFF using utf8mb4)); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 0x616263FF); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 X'616263FF'); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 B'001111111111'); +--error ER_INVALID_CHARACTER_STRING +select (_utf8mb4 X'616263FF'); +set sql_mode=default; +select hex(char(0xFF using utf8mb4)); +select hex(convert(0xFF using utf8mb4)); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 0x616263FF); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 X'616263FF'); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 B'001111111111'); +--error ER_INVALID_CHARACTER_STRING +select (_utf8mb4 X'616263FF'); + +# +# Bug #36772: When using UTF8, CONVERT with GROUP BY returns truncated results +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL); +INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1; +ALTER TABLE t1 ADD UNIQUE (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +DROP INDEX b ON t1; +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +ALTER TABLE t1 ADD INDEX (b); +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b; +DROP TABLE t1; + +--echo # +--echo # Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL +--echo # +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 ( + predicted_order int NOT NULL, + utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4; +INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682'); +SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci; +DROP TABLE t1; + +--echo # +--echo # Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns +--echo # +create table t1 (utf8mb4 char(1) character set utf8mb4); +--echo Testing [F0][90..BF][80..BF][80..BF] +insert into t1 values (0xF0908080); +insert into t1 values (0xF0BFBFBF); +insert into t1 values (0xF08F8080); +select hex(utf8mb4) from t1; +delete from t1; + +--echo Testing [F2..F3][80..BF][80..BF][80..BF] +insert into t1 values (0xF2808080); +insert into t1 values (0xF2BFBFBF); +select hex(utf8mb4) from t1; +delete from t1; + +--echo Testing [F4][80..8F][80..BF][80..BF] +insert into t1 values (0xF4808080); +insert into t1 values (0xF48F8080); +insert into t1 values (0xF4908080); +select hex(utf8mb4) from t1; +drop table t1; + + +--echo # +--echo # Check strnxfrm() with odd length +--echo # +set max_sort_length=5; +select @@max_sort_length; +create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci); +insert into t1 values ('a'),('b'),('c'); +select * from t1 order by a; +alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin; +select * from t1 order by a; +drop table t1; +set max_sort_length=default; + +--echo # +--echo # Bug#26180: Can't add columns to tables created with utf8mb4 text indexes +--echo # +CREATE TABLE t1 ( + clipid INT NOT NULL, + Tape TINYTEXT, + PRIMARY KEY (clipid), + KEY tape(Tape(255)) +) CHARACTER SET=utf8mb4; +ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid; +SHOW CREATE TABLE t1; +DROP TABLE t1; + + +#--echo # +#--echo # Check that supplementary characters are not allowed in identifiers +#--echo # +# TODO: activate this when system_charset_info is changed to utf8mb4 +#--error 1300 +#CREATE DATABASE `đ€€`; +#--error 1300 +#CREATE TABLE `đ€€` (a int); +#--error 1166 +#CREATE TABLE test.t1 SELECT 'đ€€'; +#--error 1300 +#CREATE USER `đ€€`; + +--echo # +--echo # Testing 4-byte values. +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 ( + u_decimal int NOT NULL, + utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4; +# Source of the following values: http://www.fileformat.info/info/unicode/block/index.htm +# SINGLE BARLINE +INSERT INTO t1 VALUES (119040, x'f09d8480'), +# G CLEF + (119070, x'f09d849e'), +# HALF NOTE + (119134, x'f09d859e'), +# MUSICAL SYMBOL CROIX + (119247, x'f09d878f'), +# MATHEMATICAL BOLD ITALIC CAPITAL DELTA + (120607, x'f09d9c9f'), +# SANS-SERIF BOLD ITALIC CAPITAL PI + (120735, x'f09d9e9f'), +# (last 4 byte character) + (1114111, x'f48fbfbf'), +# VARIATION SELECTOR-256 + (917999, x'f3a087af'); +# All from musical chars +INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480'); +# Mix of 3-byte and 4-byte chars +INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab'); +# All from musical chars, but 11 instead of 10 chars. truncated +INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0'); + +SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding; + +# First invalid 4 byte value +INSERT INTO t1 VALUES (1114111, x'f5808080'); + + +--disable_warnings +DROP TABLE IF EXISTS t2; +--enable_warnings +CREATE TABLE t2 ( + u_decimal int NOT NULL, + utf8mb3_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb3; +# LATIN CAPITAL LETTER VEND +INSERT INTO t2 VALUES (42856, x'ea9da8'); +# SMALL COMMERCIAL AT +INSERT INTO t2 VALUES (65131, x'efb9ab'); +# (last 4 byte character) +INSERT INTO t2 VALUES (1114111, x'f48fbfbf'); + +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; + +DROP TABLE t1; +DROP TABLE t2; + +--echo # +--echo # Testing that mixing utf8 and utf8mb4 collations returns utf8mb4 +--echo # +SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b')); + +CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL); +INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf'); +SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0; + +CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL); +INSERT INTO t2 VALUES (x'ea9da8'); + +SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1; +SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1; + +CREATE TEMPORARY TABLE t3 AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2; +SHOW CREATE TABLE t3; +DROP TEMPORARY TABLE t3; + +SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3; +SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3; +SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3; + +DROP TABLE t1; +DROP TABLE t2; + +--echo # +--echo # Check that mixing utf8mb4 with an invalid utf8 constant returns error +--echo # +# This should perhaps be changed to return ER_INVALID_CHARACTER_STRING +CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4); +INSERT INTO t1 VALUES (x'f48fbfbf'); +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CONCAT(utf8mb4, _utf8 'ż') FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CONCAT('a', _utf8 'ż') FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 5.5 tests +--echo # + +--echo # +--echo # End of tests +--echo # diff --git a/mysys/charset-def.c b/mysys/charset-def.c index bf2576621ce..9089347f002 100644 --- a/mysys/charset-def.c +++ b/mysys/charset-def.c @@ -45,6 +45,53 @@ extern CHARSET_INFO my_charset_ucs2_hungarian_uca_ci; extern CHARSET_INFO my_charset_ucs2_sinhala_uca_ci; #endif + +#ifdef HAVE_CHARSET_utf32 +extern CHARSET_INFO my_charset_utf32_icelandic_uca_ci; +extern CHARSET_INFO my_charset_utf32_latvian_uca_ci; +extern CHARSET_INFO my_charset_utf32_romanian_uca_ci; +extern CHARSET_INFO my_charset_utf32_slovenian_uca_ci; +extern CHARSET_INFO my_charset_utf32_polish_uca_ci; +extern CHARSET_INFO my_charset_utf32_estonian_uca_ci; +extern CHARSET_INFO my_charset_utf32_spanish_uca_ci; +extern CHARSET_INFO my_charset_utf32_swedish_uca_ci; +extern CHARSET_INFO my_charset_utf32_turkish_uca_ci; +extern CHARSET_INFO my_charset_utf32_czech_uca_ci; +extern CHARSET_INFO my_charset_utf32_danish_uca_ci; +extern CHARSET_INFO my_charset_utf32_lithuanian_uca_ci; +extern CHARSET_INFO my_charset_utf32_slovak_uca_ci; +extern CHARSET_INFO my_charset_utf32_spanish2_uca_ci; +extern CHARSET_INFO my_charset_utf32_roman_uca_ci; +extern CHARSET_INFO my_charset_utf32_persian_uca_ci; +extern CHARSET_INFO my_charset_utf32_esperanto_uca_ci; +extern CHARSET_INFO my_charset_utf32_hungarian_uca_ci; +extern CHARSET_INFO my_charset_utf32_sinhala_uca_ci; +#endif /* HAVE_CHARSET_utf32 */ + + +#ifdef HAVE_CHARSET_utf16 +extern CHARSET_INFO my_charset_utf16_icelandic_uca_ci; +extern CHARSET_INFO my_charset_utf16_latvian_uca_ci; +extern CHARSET_INFO my_charset_utf16_romanian_uca_ci; +extern CHARSET_INFO my_charset_utf16_slovenian_uca_ci; +extern CHARSET_INFO my_charset_utf16_polish_uca_ci; +extern CHARSET_INFO my_charset_utf16_estonian_uca_ci; +extern CHARSET_INFO my_charset_utf16_spanish_uca_ci; +extern CHARSET_INFO my_charset_utf16_swedish_uca_ci; +extern CHARSET_INFO my_charset_utf16_turkish_uca_ci; +extern CHARSET_INFO my_charset_utf16_czech_uca_ci; +extern CHARSET_INFO my_charset_utf16_danish_uca_ci; +extern CHARSET_INFO my_charset_utf16_lithuanian_uca_ci; +extern CHARSET_INFO my_charset_utf16_slovak_uca_ci; +extern CHARSET_INFO my_charset_utf16_spanish2_uca_ci; +extern CHARSET_INFO my_charset_utf16_roman_uca_ci; +extern CHARSET_INFO my_charset_utf16_persian_uca_ci; +extern CHARSET_INFO my_charset_utf16_esperanto_uca_ci; +extern CHARSET_INFO my_charset_utf16_hungarian_uca_ci; +extern CHARSET_INFO my_charset_utf16_sinhala_uca_ci; +#endif /* HAVE_CHARSET_utf16 */ + + #ifdef HAVE_CHARSET_utf8 extern CHARSET_INFO my_charset_utf8_icelandic_uca_ci; extern CHARSET_INFO my_charset_utf8_latvian_uca_ci; @@ -70,6 +117,28 @@ extern CHARSET_INFO my_charset_utf8_general_cs; #endif #endif +#ifdef HAVE_CHARSET_utf8mb4 +extern CHARSET_INFO my_charset_utf8mb4_icelandic_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_latvian_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_romanian_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_slovenian_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_polish_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_estonian_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_spanish_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_swedish_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_turkish_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_czech_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_danish_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_lithuanian_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_slovak_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_spanish2_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_roman_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_persian_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_esperanto_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_hungarian_uca_ci; +extern CHARSET_INFO my_charset_utf8mb4_sinhala_uca_ci; +#endif /* HAVE_CHARSET_utf8mb4 */ + #endif /* HAVE_UCA_COLLATIONS */ my_bool init_compiled_charsets(myf flags __attribute__((unused))) @@ -191,7 +260,91 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused))) add_compiled_collation(&my_charset_utf8_hungarian_uca_ci); add_compiled_collation(&my_charset_utf8_sinhala_uca_ci); #endif -#endif +#endif /* HAVE_CHARSET_utf8 */ + + +#ifdef HAVE_CHARSET_utf8mb4 + add_compiled_collation(&my_charset_utf8mb4_general_ci); + add_compiled_collation(&my_charset_utf8mb4_bin); +#ifdef HAVE_UCA_COLLATIONS + add_compiled_collation(&my_charset_utf8mb4_unicode_ci); + add_compiled_collation(&my_charset_utf8mb4_icelandic_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_latvian_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_romanian_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_slovenian_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_polish_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_estonian_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_spanish_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_swedish_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_turkish_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_czech_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_danish_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_lithuanian_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_slovak_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_spanish2_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_roman_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_persian_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_esperanto_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_hungarian_uca_ci); + add_compiled_collation(&my_charset_utf8mb4_sinhala_uca_ci); +#endif /* HAVE_UCA_COLLATIONS */ +#endif /* HAVE_CHARSET_utf8mb4 */ + + +#ifdef HAVE_CHARSET_utf16 + add_compiled_collation(&my_charset_utf16_general_ci); + add_compiled_collation(&my_charset_utf16_bin); +#ifdef HAVE_UCA_COLLATIONS + add_compiled_collation(&my_charset_utf16_unicode_ci); + add_compiled_collation(&my_charset_utf16_icelandic_uca_ci); + add_compiled_collation(&my_charset_utf16_latvian_uca_ci); + add_compiled_collation(&my_charset_utf16_romanian_uca_ci); + add_compiled_collation(&my_charset_utf16_slovenian_uca_ci); + add_compiled_collation(&my_charset_utf16_polish_uca_ci); + add_compiled_collation(&my_charset_utf16_estonian_uca_ci); + add_compiled_collation(&my_charset_utf16_spanish_uca_ci); + add_compiled_collation(&my_charset_utf16_swedish_uca_ci); + add_compiled_collation(&my_charset_utf16_turkish_uca_ci); + add_compiled_collation(&my_charset_utf16_czech_uca_ci); + add_compiled_collation(&my_charset_utf16_danish_uca_ci); + add_compiled_collation(&my_charset_utf16_lithuanian_uca_ci); + add_compiled_collation(&my_charset_utf16_slovak_uca_ci); + add_compiled_collation(&my_charset_utf16_spanish2_uca_ci); + add_compiled_collation(&my_charset_utf16_roman_uca_ci); + add_compiled_collation(&my_charset_utf16_persian_uca_ci); + add_compiled_collation(&my_charset_utf16_esperanto_uca_ci); + add_compiled_collation(&my_charset_utf16_hungarian_uca_ci); + add_compiled_collation(&my_charset_utf16_sinhala_uca_ci); +#endif /* HAVE_UCA_COLLATIOINS */ +#endif /* HAVE_CHARSET_utf16 */ + + +#ifdef HAVE_CHARSET_utf32 + add_compiled_collation(&my_charset_utf32_general_ci); + add_compiled_collation(&my_charset_utf32_bin); +#ifdef HAVE_UCA_COLLATIONS + add_compiled_collation(&my_charset_utf32_unicode_ci); + add_compiled_collation(&my_charset_utf32_icelandic_uca_ci); + add_compiled_collation(&my_charset_utf32_latvian_uca_ci); + add_compiled_collation(&my_charset_utf32_romanian_uca_ci); + add_compiled_collation(&my_charset_utf32_slovenian_uca_ci); + add_compiled_collation(&my_charset_utf32_polish_uca_ci); + add_compiled_collation(&my_charset_utf32_estonian_uca_ci); + add_compiled_collation(&my_charset_utf32_spanish_uca_ci); + add_compiled_collation(&my_charset_utf32_swedish_uca_ci); + add_compiled_collation(&my_charset_utf32_turkish_uca_ci); + add_compiled_collation(&my_charset_utf32_czech_uca_ci); + add_compiled_collation(&my_charset_utf32_danish_uca_ci); + add_compiled_collation(&my_charset_utf32_lithuanian_uca_ci); + add_compiled_collation(&my_charset_utf32_slovak_uca_ci); + add_compiled_collation(&my_charset_utf32_spanish2_uca_ci); + add_compiled_collation(&my_charset_utf32_roman_uca_ci); + add_compiled_collation(&my_charset_utf32_persian_uca_ci); + add_compiled_collation(&my_charset_utf32_esperanto_uca_ci); + add_compiled_collation(&my_charset_utf32_hungarian_uca_ci); + add_compiled_collation(&my_charset_utf32_sinhala_uca_ci); +#endif /* HAVE_UCA_COLLATIONS */ +#endif /* HAVE_CHARSET_utf32 */ /* Copy compiled charsets */ for (cs=compiled_charsets; cs->name; cs++) diff --git a/mysys/charset.c b/mysys/charset.c index 0cd4fcff56c..b4991555263 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -252,13 +252,35 @@ static int add_collation(CHARSET_INFO *cs) newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED | MY_CS_NONASCII; #endif } - else if (!strcmp(cs->csname, "utf8")) + else if (!strcmp(cs->csname, "utf8") || !strcmp(cs->csname, "utf8mb3")) { #if defined (HAVE_CHARSET_utf8) && defined(HAVE_UCA_COLLATIONS) copy_uca_collation(newcs, &my_charset_utf8_unicode_ci); newcs->ctype= my_charset_utf8_unicode_ci.ctype; if (init_state_maps(newcs)) return MY_XML_ERROR; +#endif + } + else if (!strcmp(cs->csname, "utf8mb4")) + { +#if defined (HAVE_CHARSET_utf8mb4) && defined(HAVE_UCA_COLLATIONS) + copy_uca_collation(newcs, &my_charset_utf8mb4_unicode_ci); + newcs->ctype= my_charset_utf8mb4_unicode_ci.ctype; + newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED; +#endif + } + else if (!strcmp(cs->csname, "utf16")) + { +#if defined (HAVE_CHARSET_utf16) && defined(HAVE_UCA_COLLATIONS) + copy_uca_collation(newcs, &my_charset_utf16_unicode_ci); + newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED | MY_CS_NONASCII; +#endif + } + else if (!strcmp(cs->csname, "utf32")) + { +#if defined (HAVE_CHARSET_utf32) && defined(HAVE_UCA_COLLATIONS) + copy_uca_collation(newcs, &my_charset_utf32_unicode_ci); + newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED | MY_CS_NONASCII; #endif } else @@ -433,17 +455,35 @@ static void init_available_charsets(void) } -uint get_collation_number(const char *name) +static const char* +get_collation_name_alias(const char *name, char *buf, size_t bufsize) { - my_pthread_once(&charsets_initialized, init_available_charsets); - return get_collation_number_internal(name); + if (!strncasecmp(name, "utf8mb3_", 8)) + { + my_snprintf(buf, bufsize, "utf8_%s", name + 8); + return buf; + } + return NULL; } -uint get_charset_number(const char *charset_name, uint cs_flags) +uint get_collation_number(const char *name) +{ + uint id; + char alias[64]; + my_pthread_once(&charsets_initialized, init_available_charsets); + if ((id= get_collation_number_internal(name))) + return id; + if ((name= get_collation_name_alias(name, alias, sizeof(alias)))) + return get_collation_number_internal(name); + return 0; +} + + +static uint +get_charset_number_internal(const char *charset_name, uint cs_flags) { CHARSET_INFO **cs; - my_pthread_once(&charsets_initialized, init_available_charsets); for (cs= all_charsets; cs < all_charsets + array_elements(all_charsets); @@ -457,6 +497,27 @@ uint get_charset_number(const char *charset_name, uint cs_flags) } +static const char* +get_charset_name_alias(const char *name) +{ + if (!my_strcasecmp(&my_charset_latin1, name, "utf8mb3")) + return "utf8"; + return NULL; +} + + +uint get_charset_number(const char *charset_name, uint cs_flags) +{ + uint id; + my_pthread_once(&charsets_initialized, init_available_charsets); + if ((id= get_charset_number_internal(charset_name, cs_flags))) + return id; + if ((charset_name= get_charset_name_alias(charset_name))) + return get_charset_number_internal(charset_name, cs_flags); + return 0; +} + + const char *get_charset_name(uint charset_number) { CHARSET_INFO *cs; diff --git a/sql/field.cc b/sql/field.cc index 51bb527fc85..766aaba9ce1 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1836,7 +1836,9 @@ int Field::store_time(MYSQL_TIME *ltime, timestamp_type type_arg) ASSERT_COLUMN_MARKED_FOR_WRITE; char buff[MAX_DATE_STRING_REP_LENGTH]; uint length= (uint) my_TIME_to_str(ltime, buff); - return store(buff, length, &my_charset_bin); + return store(buff, length, + (charset()->state & MY_CS_NONASCII) ? + &my_charset_latin1 : &my_charset_bin); } diff --git a/sql/item.cc b/sql/item.cc index e785f0addde..e9ac44eeba8 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -854,7 +854,7 @@ Item *Item_param::safe_charset_converter(CHARSET_INFO *tocs) cnvitem->max_length= cnvitem->str_value.numchars() * tocs->mbmaxlen; return cnvitem; } - return NULL; + return Item::safe_charset_converter(tocs); } @@ -1436,7 +1436,12 @@ left_is_superset(DTCollation *left, DTCollation *right) if (left->collation->state & MY_CS_UNICODE && (left->derivation < right->derivation || (left->derivation == right->derivation && - !(right->collation->state & MY_CS_UNICODE)))) + (!(right->collation->state & MY_CS_UNICODE) || + /* The code below makes 4-byte utf8 a superset over 3-byte utf8 */ + (left->collation->state & MY_CS_UNICODE_SUPPLEMENT && + !(right->collation->state & MY_CS_UNICODE_SUPPLEMENT) && + left->collation->mbmaxlen > right->collation->mbmaxlen && + left->collation->mbminlen == right->collation->mbminlen))))) return TRUE; /* Allow convert from ASCII */ if (right->repertoire == MY_REPERTOIRE_ASCII && @@ -1695,7 +1700,7 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname, { Item* conv; uint32 dummy_offset; - if (!String::needs_conversion(0, (*arg)->collation.collation, + if (!String::needs_conversion(1, (*arg)->collation.collation, coll.collation, &dummy_offset)) continue; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c33e0f4c6fb..1130e4c9ffc 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2371,17 +2371,27 @@ String *Item_func_char::val_str(String *str) int32 num=(int32) args[i]->val_int(); if (!args[i]->null_value) { - char char_num= (char) num; - if (num&0xFF000000L) { - str->append((char)(num>>24)); - goto b2; - } else if (num&0xFF0000L) { - b2: str->append((char)(num>>16)); - goto b1; - } else if (num&0xFF00L) { - b1: str->append((char)(num>>8)); + char tmp[4]; + if (num & 0xFF000000L) + { + mi_int4store(tmp, num); + str->append(tmp, 4, &my_charset_bin); + } + else if (num & 0xFF0000L) + { + mi_int3store(tmp, num); + str->append(tmp, 3, &my_charset_bin); + } + else if (num & 0xFF00L) + { + mi_int2store(tmp, num); + str->append(tmp, 2, &my_charset_bin); + } + else + { + tmp[0]= (char) num; + str->append(tmp, 1, &my_charset_bin); } - str->append(&char_num, 1); } } str->realloc(str->length()); // Add end 0 (for Purify) @@ -2769,7 +2779,8 @@ String *Item_func_conv_charset::val_str(String *str) void Item_func_conv_charset::fix_length_and_dec() { collation.set(conv_charset, DERIVATION_IMPLICIT); - max_length = args[0]->max_length*conv_charset->mbmaxlen; + max_length = args[0]->max_length / args[0]->collation.collation->mbmaxlen * + conv_charset->mbmaxlen; } void Item_func_conv_charset::print(String *str, enum_query_type query_type) diff --git a/sql/sql_string.cc b/sql/sql_string.cc index e4e51aba622..75e8ca30cf0 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -412,11 +412,25 @@ bool String::append(const char *s) bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs) { - uint32 dummy_offset; + uint32 offset; - if (needs_conversion(arg_length, cs, str_charset, &dummy_offset)) + if (needs_conversion(arg_length, cs, str_charset, &offset)) { - uint32 add_length= arg_length / cs->mbminlen * str_charset->mbmaxlen; + uint32 add_length; + if ((cs == &my_charset_bin) && offset) + { + DBUG_ASSERT(str_charset->mbminlen > offset); + offset= str_charset->mbminlen - offset; // How many characters to pad + add_length= arg_length + offset; + if (realloc(str_length + add_length)) + return TRUE; + bzero((char*) Ptr + str_length, offset); + memcpy(Ptr + str_length + offset, s, arg_length); + str_length+= add_length; + return FALSE; + } + + add_length= arg_length / cs->mbminlen * str_charset->mbmaxlen; uint dummy_errors; if (realloc(str_length + add_length)) return TRUE; @@ -966,6 +980,24 @@ well_formed_copy_nchars(CHARSET_INFO *to_cs, uint pad_length= to_cs->mbminlen - from_offset; bzero(to, pad_length); memmove(to + pad_length, from, from_offset); + /* + In some cases left zero-padding can create an incorrect character. + For example: + INSERT INTO t1 (utf32_column) VALUES (0x110000); + We'll pad the value to 0x00110000, which is a wrong UTF32 sequence! + The valid characters range is limited to 0x00000000..0x0010FFFF. + + Make sure we didn't pad to an incorrect character. + */ + if (to_cs->cset->well_formed_len(to_cs, + to, to + to_cs->mbminlen, 1, + &well_formed_error) != + to_cs->mbminlen) + { + *from_end_pos= *well_formed_error_pos= from; + *cannot_convert_error_pos= NULL; + return 0; + } nchars--; from+= from_offset; from_length-= from_offset; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2e057d6a731..d154c238229 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2776,7 +2776,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->interval_list); List_iterator int_it(sql_field->interval_list); String conv, *tmp; - char comma_buf[2]; + char comma_buf[4]; /* 4 bytes for utf32 */ int comma_length= cs->cset->wc_mb(cs, ',', (uchar*) comma_buf, (uchar*) comma_buf + sizeof(comma_buf)); diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 252c5a08b8c..98b598c3c2c 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -467,10 +467,11 @@ uint my_instr_mb(CHARSET_INFO *cs, /* BINARY collations handlers for MB charsets */ -static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, size_t slen, - const uchar *t, size_t tlen, - my_bool t_is_prefix) +int +my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool t_is_prefix) { size_t len=min(slen,tlen); int cmp= memcmp(s,t,len); @@ -503,10 +504,11 @@ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), 0 if strings are equal */ -static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, size_t a_length, - const uchar *b, size_t b_length, - my_bool diff_if_only_endspace_difference) +int +my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, + my_bool diff_if_only_endspace_difference) { const uchar *end; size_t length; @@ -562,14 +564,17 @@ static size_t my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)), } -static int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), - const char *s, const char *t) +int +my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), + const char *s, const char *t) { return strcmp(s,t); } -static void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, size_t len,ulong *nr1, ulong *nr2) + +void +my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), + const uchar *key, size_t len,ulong *nr1, ulong *nr2) { const uchar *pos = key; @@ -787,10 +792,11 @@ fill_max_and_min: } -static int my_wildcmp_mb_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_mb_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-uca.c b/strings/ctype-uca.c index 56f3ddccae4..7dbec5a1321 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -9464,4 +9464,1990 @@ CHARSET_INFO my_charset_utf8_sinhala_uca_ci= #endif /* HAVE_CHARSET_utf8 */ + +#ifdef HAVE_CHARSET_utf8mb4 + +extern MY_CHARSET_HANDLER my_charset_utf8mb4_handler; + +#define MY_CS_UTF8MB4_UCA_FLAGS (MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_UNICODE_SUPPLEMENT) + +CHARSET_INFO my_charset_utf8mb4_unicode_ci= +{ + 224,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_unicode_ci",/* name */ + "", /* comment */ + "", /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + uca_length, /* sort_order */ + NULL, /* contractions */ + uca_weight, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + + +CHARSET_INFO my_charset_utf8mb4_icelandic_uca_ci= +{ + 225,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_icelandic_ci",/* name */ + "", /* comment */ + icelandic, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_latvian_uca_ci= +{ + 226,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_latvian_ci", /* name */ + "", /* comment */ + latvian, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_romanian_uca_ci= +{ + 227,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_romanian_ci", /* name */ + "", /* comment */ + romanian, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_slovenian_uca_ci= +{ + 228,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_slovenian_ci",/* name */ + "", /* comment */ + slovenian, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_polish_uca_ci= +{ + 229,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_polish_ci", /* name */ + "", /* comment */ + polish, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_estonian_uca_ci= +{ + 230,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_estonian_ci", /* name */ + "", /* comment */ + estonian, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_spanish_uca_ci= +{ + 231,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_spanish_ci", /* name */ + "", /* comment */ + spanish, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_swedish_uca_ci= +{ + 232,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_swedish_ci", /* name */ + "", /* comment */ + swedish, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_turkish_uca_ci= +{ + 233,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_turkish_ci", /* name */ + "", /* comment */ + turkish, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_turkish, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 2, /* caseup_multiply */ + 2, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_czech_uca_ci= +{ + 234,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_czech_ci", /* name */ + "", /* comment */ + czech, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + + +CHARSET_INFO my_charset_utf8mb4_danish_uca_ci= +{ + 235,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_danish_ci", /* name */ + "", /* comment */ + danish, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_lithuanian_uca_ci= +{ + 236,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_lithuanian_ci",/* name */ + "", /* comment */ + lithuanian, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_slovak_uca_ci= +{ + 237,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_slovak_ci", /* name */ + "", /* comment */ + slovak, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_spanish2_uca_ci= +{ + 238,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_spanish2_ci", /* name */ + "", /* comment */ + spanish2, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_roman_uca_ci= +{ + 239,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_roman_ci", /* name */ + "", /* comment */ + roman, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_persian_uca_ci= +{ + 240,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_persian_ci", /* name */ + "", /* comment */ + persian, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_esperanto_uca_ci= +{ + 241,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_esperanto_ci",/* name */ + "", /* comment */ + esperanto, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_hungarian_uca_ci= +{ + 242,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_hungarian_ci",/* name */ + "", /* comment */ + hungarian, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +CHARSET_INFO my_charset_utf8mb4_sinhala_uca_ci= +{ + 243,0,0, /* number */ + MY_CS_UTF8MB4_UCA_FLAGS,/* state */ + MY_UTF8MB4, /* csname */ + MY_UTF8MB4 "_sinhala_ci",/* name */ + "", /* comment */ + sinhala, /* tailoring */ + ctype_utf8, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_any_uca_handler +}; + +#endif /* HAVE_CHARSET_utf8mb4 */ + + +#ifdef HAVE_CHARSET_utf32 + +MY_COLLATION_HANDLER my_collation_utf32_uca_handler = +{ + my_coll_init_uca, /* init */ + my_strnncoll_any_uca, + my_strnncollsp_any_uca, + my_strnxfrm_any_uca, + my_strnxfrmlen_simple, + my_like_range_utf32, + my_wildcmp_uca, + NULL, + my_instr_mb, + my_hash_sort_any_uca, + my_propagate_complex +}; + +extern MY_CHARSET_HANDLER my_charset_utf32_handler; + +#define MY_CS_UTF32_UCA_FLAGS (MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII) + +CHARSET_INFO my_charset_utf32_unicode_ci= +{ + 160,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_unicode_ci", /* name */ + "", /* comment */ + "", /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + uca_length, /* sort_order */ + NULL, /* contractions */ + uca_weight, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + + +CHARSET_INFO my_charset_utf32_icelandic_uca_ci= +{ + 161,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_icelandic_ci",/* name */ + "", /* comment */ + icelandic, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_latvian_uca_ci= +{ + 162,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_latvian_ci", /* name */ + "", /* comment */ + latvian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_romanian_uca_ci= +{ + 163,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_romanian_ci", /* name */ + "", /* comment */ + romanian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_slovenian_uca_ci= +{ + 164,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_slovenian_ci",/* name */ + "", /* comment */ + slovenian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_polish_uca_ci= +{ + 165,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_polish_ci", /* name */ + "", /* comment */ + polish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_estonian_uca_ci= +{ + 166,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_estonian_ci", /* name */ + "", /* comment */ + estonian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_spanish_uca_ci= +{ + 167,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_spanish_ci", /* name */ + "", /* comment */ + spanish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_swedish_uca_ci= +{ + 168,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_swedish_ci", /* name */ + "", /* comment */ + swedish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_turkish_uca_ci= +{ + 169,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_turkish_ci", /* name */ + "", /* comment */ + turkish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_turkish, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_czech_uca_ci= +{ + 170,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_czech_ci", /* name */ + "", /* comment */ + czech, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + + +CHARSET_INFO my_charset_utf32_danish_uca_ci= +{ + 171,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_danish_ci", /* name */ + "", /* comment */ + danish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_lithuanian_uca_ci= +{ + 172,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_lithuanian_ci",/* name */ + "", /* comment */ + lithuanian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_slovak_uca_ci= +{ + 173,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_slovak_ci", /* name */ + "", /* comment */ + slovak, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_spanish2_uca_ci= +{ + 174,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_spanish2_ci", /* name */ + "", /* comment */ + spanish2, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_roman_uca_ci= +{ + 175,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_roman_ci", /* name */ + "", /* comment */ + roman, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_persian_uca_ci= +{ + 176,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_persian_ci", /* name */ + "", /* comment */ + persian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_esperanto_uca_ci= +{ + 177,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_esperanto_ci",/* name */ + "", /* comment */ + esperanto, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_hungarian_uca_ci= +{ + 178,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_hungarian_ci",/* name */ + "", /* comment */ + hungarian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +CHARSET_INFO my_charset_utf32_sinhala_uca_ci= +{ + 179,0,0, /* number */ + MY_CS_UTF32_UCA_FLAGS,/* state */ + "utf32", /* csname */ + "utf32_sinhala_ci", /* name */ + "", /* comment */ + sinhala, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_uca_handler +}; + +#endif /* HAVE_CHARSET_utf32 */ + + +#ifdef HAVE_CHARSET_utf16 + + +MY_COLLATION_HANDLER my_collation_utf16_uca_handler = +{ + my_coll_init_uca, /* init */ + my_strnncoll_any_uca, + my_strnncollsp_any_uca, + my_strnxfrm_any_uca, + my_strnxfrmlen_simple, + my_like_range_utf16, + my_wildcmp_uca, + NULL, + my_instr_mb, + my_hash_sort_any_uca, + my_propagate_complex +}; + +extern MY_CHARSET_HANDLER my_charset_utf16_handler; + +#define MY_CS_UTF16_UCA_FLAGS (MY_CS_COMPILED|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII) + +CHARSET_INFO my_charset_utf16_unicode_ci= +{ + 101,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* csname */ + "utf16_unicode_ci", /* name */ + "", /* comment */ + "", /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + uca_length, /* sort_order */ + NULL, /* contractions */ + uca_weight, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + + +CHARSET_INFO my_charset_utf16_icelandic_uca_ci= +{ + 102,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* csname */ + "utf16_icelandic_ci",/* name */ + "", /* comment */ + icelandic, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_latvian_uca_ci= +{ + 103,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_latvian_ci", /* name */ + "", /* comment */ + latvian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_romanian_uca_ci= +{ + 104,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_romanian_ci", /* name */ + "", /* comment */ + romanian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_slovenian_uca_ci= +{ + 105,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_slovenian_ci",/* name */ + "", /* comment */ + slovenian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_polish_uca_ci= +{ + 106,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_polish_ci", /* name */ + "", /* comment */ + polish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_estonian_uca_ci= +{ + 107,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_estonian_ci", /* name */ + "", /* comment */ + estonian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_spanish_uca_ci= +{ + 108,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_spanish_ci", /* name */ + "", /* comment */ + spanish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_swedish_uca_ci= +{ + 109,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_swedish_ci", /* name */ + "", /* comment */ + swedish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_turkish_uca_ci= +{ + 110,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_turkish_ci", /* name */ + "", /* comment */ + turkish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_turkish, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_czech_uca_ci= +{ + 111,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_czech_ci", /* name */ + "", /* comment */ + czech, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + + +CHARSET_INFO my_charset_utf16_danish_uca_ci= +{ + 112,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_danish_ci", /* name */ + "", /* comment */ + danish, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_lithuanian_uca_ci= +{ + 113,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_lithuanian_ci",/* name */ + "", /* comment */ + lithuanian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_slovak_uca_ci= +{ + 114,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_slovak_ci", /* name */ + "", /* comment */ + slovak, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_spanish2_uca_ci= +{ + 115,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_spanish2_ci",/* name */ + "", /* comment */ + spanish2, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_roman_uca_ci= +{ + 116,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_roman_ci", /* name */ + "", /* comment */ + roman, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_persian_uca_ci= +{ + 117,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_persian_ci", /* name */ + "", /* comment */ + persian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_esperanto_uca_ci= +{ + 118,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_esperanto_ci",/* name */ + "", /* comment */ + esperanto, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_hungarian_uca_ci= +{ + 119,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_hungarian_ci",/* name */ + "", /* comment */ + hungarian, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default,/* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +CHARSET_INFO my_charset_utf16_sinhala_uca_ci= +{ + 120,0,0, /* number */ + MY_CS_UTF16_UCA_FLAGS,/* state */ + "utf16", /* cs name */ + "utf16_sinhala_ci",/* name */ + "", /* comment */ + sinhala, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default,/* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 8, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 9, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_uca_handler +}; + +#endif /* HAVE_CHARSET_utf16 */ + + + #endif /* HAVE_UCA_COLLATIONS */ diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 069131ba354..6de0ea8f7e8 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -25,12 +25,2833 @@ #include -#ifdef HAVE_CHARSET_ucs2 +#if defined(HAVE_CHARSET_utf16) || defined(HAVE_CHARSET_ucs2) +#define HAVE_CHARSET_mb2 +#endif + + +#if defined(HAVE_CHARSET_mb2) || defined(HAVE_CHARSET_utf32) +#define HAVE_CHARSET_mb2_or_mb4 +#endif + #ifndef EILSEQ #define EILSEQ ENOENT #endif +#undef ULONGLONG_MAX +#define ULONGLONG_MAX (~(ulonglong) 0) +#define MAX_NEGATIVE_NUMBER ((ulonglong) LL(0x8000000000000000)) +#define INIT_CNT 9 +#define LFACTOR ULL(1000000000) +#define LFACTOR1 ULL(10000000000) +#define LFACTOR2 ULL(100000000000) + +static unsigned long lfactor[9]= +{ 1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L }; + +#define REPLACEMENT_CHAR 0xFFFD; + + + +#ifdef HAVE_CHARSET_mb2_or_mb4 +static inline int +my_bincmp(const uchar *s, const uchar *se, + const uchar *t, const uchar *te) +{ + int slen= (int) (se - s), tlen= (int) (te - t); + int len= min(slen, tlen); + int cmp= memcmp(s, t, len); + return cmp ? cmp : slen - tlen; +} + + +static size_t +my_caseup_str_mb2_or_mb4(CHARSET_INFO * cs __attribute__((unused)), + char * s __attribute__((unused))) +{ + DBUG_ASSERT(0); + return 0; +} + + +static size_t +my_casedn_str_mb2_or_mb4(CHARSET_INFO *cs __attribute__((unused)), + char * s __attribute__((unused))) +{ + DBUG_ASSERT(0); + return 0; +} + + +static int +my_strcasecmp_mb2_or_mb4(CHARSET_INFO *cs __attribute__((unused)), + const char *s __attribute__((unused)), + const char *t __attribute__((unused))) +{ + DBUG_ASSERT(0); + return 0; +} + + +static long +my_strntol_mb2_or_mb4(CHARSET_INFO *cs, + const char *nptr, size_t l, int base, + char **endptr, int *err) +{ + int negative= 0; + int overflow; + int cnv; + my_wc_t wc; + register unsigned int cutlim; + register uint32 cutoff; + register uint32 res; + register const uchar *s= (const uchar*) nptr; + register const uchar *e= (const uchar*) nptr+l; + const uchar *save; + + *err= 0; + do + { + if ((cnv= cs->cset->mb_wc(cs, &wc, s, e))>0) + { + switch (wc) + { + case ' ' : break; + case '\t': break; + case '-' : negative= !negative; break; + case '+' : break; + default : goto bs; + } + } + else /* No more characters or bad multibyte sequence */ + { + if (endptr != NULL ) + *endptr= (char*) s; + err[0]= (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM; + return 0; + } + s+= cnv; + } while (1); + +bs: + +#ifdef NOT_USED + if (base <= 0 || base == 1 || base > 36) + base = 10; +#endif + + overflow= 0; + res= 0; + save= s; + cutoff= ((uint32)~0L) / (uint32) base; + cutlim= (uint) (((uint32)~0L) % (uint32) base); + + do { + if ((cnv= cs->cset->mb_wc(cs, &wc, s, e)) > 0) + { + s+= cnv; + if (wc >= '0' && wc <= '9') + wc-= '0'; + else if (wc >= 'A' && wc <= 'Z') + wc= wc - 'A' + 10; + else if (wc >= 'a' && wc <= 'z') + wc= wc - 'a' + 10; + else + break; + if ((int)wc >= base) + break; + if (res > cutoff || (res == cutoff && wc > cutlim)) + overflow= 1; + else + { + res*= (uint32) base; + res+= wc; + } + } + else if (cnv == MY_CS_ILSEQ) + { + if (endptr !=NULL ) + *endptr = (char*) s; + err[0]= EILSEQ; + return 0; + } + else + { + /* No more characters */ + break; + } + } while(1); + + if (endptr != NULL) + *endptr = (char *) s; + + if (s == save) + { + err[0]= EDOM; + return 0L; + } + + if (negative) + { + if (res > (uint32) INT_MIN32) + overflow= 1; + } + else if (res > INT_MAX32) + overflow= 1; + + if (overflow) + { + err[0]= ERANGE; + return negative ? INT_MIN32 : INT_MAX32; + } + + return (negative ? -((long) res) : (long) res); +} + + +static ulong +my_strntoul_mb2_or_mb4(CHARSET_INFO *cs, + const char *nptr, size_t l, int base, + char **endptr, int *err) +{ + int negative= 0; + int overflow; + int cnv; + my_wc_t wc; + register unsigned int cutlim; + register uint32 cutoff; + register uint32 res; + register const uchar *s= (const uchar*) nptr; + register const uchar *e= (const uchar*) nptr + l; + const uchar *save; + + *err= 0; + do + { + if ((cnv= cs->cset->mb_wc(cs, &wc, s, e)) > 0) + { + switch (wc) + { + case ' ' : break; + case '\t': break; + case '-' : negative= !negative; break; + case '+' : break; + default : goto bs; + } + } + else /* No more characters or bad multibyte sequence */ + { + if (endptr !=NULL ) + *endptr= (char*)s; + err[0]= (cnv == MY_CS_ILSEQ) ? EILSEQ : EDOM; + return 0; + } + s+= cnv; + } while (1); + +bs: + +#ifdef NOT_USED + if (base <= 0 || base == 1 || base > 36) + base = 10; +#endif + + overflow= 0; + res= 0; + save= s; + cutoff= ((uint32)~0L) / (uint32) base; + cutlim= (uint) (((uint32)~0L) % (uint32) base); + + do + { + if ((cnv= cs->cset->mb_wc(cs, &wc, s, e)) > 0) + { + s+= cnv; + if (wc >= '0' && wc <= '9') + wc-= '0'; + else if (wc >= 'A' && wc <= 'Z') + wc= wc - 'A' + 10; + else if (wc >= 'a' && wc <= 'z') + wc= wc - 'a' + 10; + else + break; + if ((int) wc >= base) + break; + if (res > cutoff || (res == cutoff && wc > cutlim)) + overflow = 1; + else + { + res*= (uint32) base; + res+= wc; + } + } + else if (cnv == MY_CS_ILSEQ) + { + if (endptr != NULL ) + *endptr= (char*)s; + err[0]= EILSEQ; + return 0; + } + else + { + /* No more characters */ + break; + } + } while(1); + + if (endptr != NULL) + *endptr= (char *) s; + + if (s == save) + { + err[0]= EDOM; + return 0L; + } + + if (overflow) + { + err[0]= (ERANGE); + return (~(uint32) 0); + } + + return (negative ? -((long) res) : (long) res); +} + + +static longlong +my_strntoll_mb2_or_mb4(CHARSET_INFO *cs, + const char *nptr, size_t l, int base, + char **endptr, int *err) +{ + int negative=0; + int overflow; + int cnv; + my_wc_t wc; + register ulonglong cutoff; + register unsigned int cutlim; + register ulonglong res; + register const uchar *s= (const uchar*) nptr; + register const uchar *e= (const uchar*) nptr+l; + const uchar *save; + + *err= 0; + do + { + if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) + { + switch (wc) + { + case ' ' : break; + case '\t': break; + case '-' : negative= !negative; break; + case '+' : break; + default : goto bs; + } + } + else /* No more characters or bad multibyte sequence */ + { + if (endptr !=NULL ) + *endptr = (char*)s; + err[0] = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM; + return 0; + } + s+=cnv; + } while (1); + +bs: + +#ifdef NOT_USED + if (base <= 0 || base == 1 || base > 36) + base = 10; +#endif + + overflow = 0; + res = 0; + save = s; + cutoff = (~(ulonglong) 0) / (unsigned long int) base; + cutlim = (uint) ((~(ulonglong) 0) % (unsigned long int) base); + + do { + if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) + { + s+=cnv; + if ( wc>='0' && wc<='9') + wc -= '0'; + else if ( wc>='A' && wc<='Z') + wc = wc - 'A' + 10; + else if ( wc>='a' && wc<='z') + wc = wc - 'a' + 10; + else + break; + if ((int)wc >= base) + break; + if (res > cutoff || (res == cutoff && wc > cutlim)) + overflow = 1; + else + { + res *= (ulonglong) base; + res += wc; + } + } + else if (cnv==MY_CS_ILSEQ) + { + if (endptr !=NULL ) + *endptr = (char*)s; + err[0]=EILSEQ; + return 0; + } + else + { + /* No more characters */ + break; + } + } while(1); + + if (endptr != NULL) + *endptr = (char *) s; + + if (s == save) + { + err[0]=EDOM; + return 0L; + } + + if (negative) + { + if (res > (ulonglong) LONGLONG_MIN) + overflow = 1; + } + else if (res > (ulonglong) LONGLONG_MAX) + overflow = 1; + + if (overflow) + { + err[0]=ERANGE; + return negative ? LONGLONG_MIN : LONGLONG_MAX; + } + + return (negative ? -((longlong)res) : (longlong)res); +} + + +static ulonglong +my_strntoull_mb2_or_mb4(CHARSET_INFO *cs, + const char *nptr, size_t l, int base, + char **endptr, int *err) +{ + int negative= 0; + int overflow; + int cnv; + my_wc_t wc; + register ulonglong cutoff; + register unsigned int cutlim; + register ulonglong res; + register const uchar *s= (const uchar*) nptr; + register const uchar *e= (const uchar*) nptr + l; + const uchar *save; + + *err= 0; + do + { + if ((cnv= cs->cset->mb_wc(cs,&wc,s,e)) > 0) + { + switch (wc) + { + case ' ' : break; + case '\t': break; + case '-' : negative= !negative; break; + case '+' : break; + default : goto bs; + } + } + else /* No more characters or bad multibyte sequence */ + { + if (endptr !=NULL ) + *endptr = (char*)s; + err[0]= (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM; + return 0; + } + s+=cnv; + } while (1); + +bs: + +#ifdef NOT_USED + if (base <= 0 || base == 1 || base > 36) + base = 10; +#endif + + overflow = 0; + res = 0; + save = s; + cutoff = (~(ulonglong) 0) / (unsigned long int) base; + cutlim = (uint) ((~(ulonglong) 0) % (unsigned long int) base); + + do + { + if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) + { + s+=cnv; + if ( wc>='0' && wc<='9') + wc -= '0'; + else if ( wc>='A' && wc<='Z') + wc = wc - 'A' + 10; + else if ( wc>='a' && wc<='z') + wc = wc - 'a' + 10; + else + break; + if ((int)wc >= base) + break; + if (res > cutoff || (res == cutoff && wc > cutlim)) + overflow = 1; + else + { + res *= (ulonglong) base; + res += wc; + } + } + else if (cnv==MY_CS_ILSEQ) + { + if (endptr !=NULL ) + *endptr = (char*)s; + err[0]= EILSEQ; + return 0; + } + else + { + /* No more characters */ + break; + } + } while(1); + + if (endptr != NULL) + *endptr = (char *) s; + + if (s == save) + { + err[0]= EDOM; + return 0L; + } + + if (overflow) + { + err[0]= ERANGE; + return (~(ulonglong) 0); + } + + return (negative ? -((longlong) res) : (longlong) res); +} + + +static double +my_strntod_mb2_or_mb4(CHARSET_INFO *cs, + char *nptr, size_t length, + char **endptr, int *err) +{ + char buf[256]; + double res; + register char *b= buf; + register const uchar *s= (const uchar*) nptr; + const uchar *end; + my_wc_t wc; + int cnv; + + *err= 0; + /* Cut too long strings */ + if (length >= sizeof(buf)) + length= sizeof(buf) - 1; + end= s + length; + + while ((cnv= cs->cset->mb_wc(cs,&wc,s,end)) > 0) + { + s+= cnv; + if (wc > (int) (uchar) 'e' || !wc) + break; /* Can't be part of double */ + *b++= (char) wc; + } + + *endptr= b; + res= my_strtod(buf, endptr, err); + *endptr= nptr + cs->mbminlen * (size_t) (*endptr - buf); + return res; +} + + +static ulonglong +my_strntoull10rnd_mb2_or_mb4(CHARSET_INFO *cs, + const char *nptr, size_t length, + int unsign_fl, + char **endptr, int *err) +{ + char buf[256], *b= buf; + ulonglong res; + const uchar *end, *s= (const uchar*) nptr; + my_wc_t wc; + int cnv; + + /* Cut too long strings */ + if (length >= sizeof(buf)) + length= sizeof(buf)-1; + end= s + length; + + while ((cnv= cs->cset->mb_wc(cs,&wc,s,end)) > 0) + { + s+= cnv; + if (wc > (int) (uchar) 'e' || !wc) + break; /* Can't be a number part */ + *b++= (char) wc; + } + + res= my_strntoull10rnd_8bit(cs, buf, b - buf, unsign_fl, endptr, err); + *endptr= (char*) nptr + cs->mbminlen * (size_t) (*endptr - buf); + return res; +} + + +/* + This is a fast version optimized for the case of radix 10 / -10 +*/ + +static size_t +my_l10tostr_mb2_or_mb4(CHARSET_INFO *cs, + char *dst, size_t len, int radix, long int val) +{ + char buffer[66]; + register char *p, *db, *de; + long int new_val; + int sl= 0; + unsigned long int uval = (unsigned long int) val; + + p= &buffer[sizeof(buffer) - 1]; + *p= '\0'; + + if (radix < 0) + { + if (val < 0) + { + sl= 1; + /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */ + uval = (unsigned long int)0 - uval; + } + } + + new_val = (long) (uval / 10); + *--p = '0'+ (char) (uval - (unsigned long) new_val * 10); + val= new_val; + + while (val != 0) + { + new_val= val / 10; + *--p= '0' + (char) (val - new_val * 10); + val= new_val; + } + + if (sl) + { + *--p= '-'; + } + + for ( db= dst, de= dst + len ; (dst < de) && *p ; p++) + { + int cnvres= cs->cset->wc_mb(cs,(my_wc_t)p[0],(uchar*) dst, (uchar*) de); + if (cnvres > 0) + dst+= cnvres; + else + break; + } + return (int) (dst - db); +} + + +static size_t +my_ll10tostr_mb2_or_mb4(CHARSET_INFO *cs, + char *dst, size_t len, int radix, longlong val) +{ + char buffer[65]; + register char *p, *db, *de; + long long_val; + int sl= 0; + ulonglong uval= (ulonglong) val; + + if (radix < 0) + { + if (val < 0) + { + sl= 1; + /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */ + uval = (ulonglong)0 - uval; + } + } + + p= &buffer[sizeof(buffer)-1]; + *p='\0'; + + if (uval == 0) + { + *--p= '0'; + goto cnv; + } + + while (uval > (ulonglong) LONG_MAX) + { + ulonglong quo= uval/(uint) 10; + uint rem= (uint) (uval- quo* (uint) 10); + *--p= '0' + rem; + uval= quo; + } + + long_val= (long) uval; + while (long_val != 0) + { + long quo= long_val/10; + *--p= (char) ('0' + (long_val - quo*10)); + long_val= quo; + } + +cnv: + if (sl) + { + *--p= '-'; + } + + for ( db= dst, de= dst + len ; (dst < de) && *p ; p++) + { + int cnvres= cs->cset->wc_mb(cs, (my_wc_t) p[0], (uchar*) dst, (uchar*) de); + if (cnvres > 0) + dst+= cnvres; + else + break; + } + return (int) (dst -db); +} + +#endif /* HAVE_CHARSET_mb2_or_mb4 */ + + +#ifdef HAVE_CHARSET_mb2 +static longlong +my_strtoll10_mb2(CHARSET_INFO *cs __attribute__((unused)), + const char *nptr, char **endptr, int *error) +{ + const char *s, *end, *start, *n_end, *true_end; + uchar c; + unsigned long i, j, k; + ulonglong li; + int negative; + ulong cutoff, cutoff2, cutoff3; + + s= nptr; + /* If fixed length string */ + if (endptr) + { + /* Make sure string length is even */ + end= s + ((*endptr - s) / 2) * 2; + while (s < end && !s[0] && (s[1] == ' ' || s[1] == '\t')) + s+= 2; + if (s == end) + goto no_conv; + } + else + { + /* We don't support null terminated strings in UCS2 */ + goto no_conv; + } + + /* Check for a sign. */ + negative= 0; + if (!s[0] && s[1] == '-') + { + *error= -1; /* Mark as negative number */ + negative= 1; + s+= 2; + if (s == end) + goto no_conv; + cutoff= MAX_NEGATIVE_NUMBER / LFACTOR2; + cutoff2= (MAX_NEGATIVE_NUMBER % LFACTOR2) / 100; + cutoff3= MAX_NEGATIVE_NUMBER % 100; + } + else + { + *error= 0; + if (!s[0] && s[1] == '+') + { + s+= 2; + if (s == end) + goto no_conv; + } + cutoff= ULONGLONG_MAX / LFACTOR2; + cutoff2= ULONGLONG_MAX % LFACTOR2 / 100; + cutoff3= ULONGLONG_MAX % 100; + } + + /* Handle case where we have a lot of pre-zero */ + if (!s[0] && s[1] == '0') + { + i= 0; + do + { + s+= 2; + if (s == end) + goto end_i; /* Return 0 */ + } + while (!s[0] && s[1] == '0'); + n_end= s + 2 * INIT_CNT; + } + else + { + /* Read first digit to check that it's a valid number */ + if (s[0] || (c= (s[1]-'0')) > 9) + goto no_conv; + i= c; + s+= 2; + n_end= s + 2 * (INIT_CNT-1); + } + + /* Handle first 9 digits and store them in i */ + if (n_end > end) + n_end= end; + for (; s != n_end ; s+= 2) + { + if (s[0] || (c= (s[1]-'0')) > 9) + goto end_i; + i= i*10+c; + } + if (s == end) + goto end_i; + + /* Handle next 9 digits and store them in j */ + j= 0; + start= s; /* Used to know how much to shift i */ + n_end= true_end= s + 2 * INIT_CNT; + if (n_end > end) + n_end= end; + do + { + if (s[0] || (c= (s[1]-'0')) > 9) + goto end_i_and_j; + j= j*10+c; + s+= 2; + } while (s != n_end); + if (s == end) + { + if (s != true_end) + goto end_i_and_j; + goto end3; + } + if (s[0] || (c= (s[1]-'0')) > 9) + goto end3; + + /* Handle the next 1 or 2 digits and store them in k */ + k=c; + s+= 2; + if (s == end || s[0] || (c= (s[1]-'0')) > 9) + goto end4; + k= k*10+c; + s+= 2; + *endptr= (char*) s; + + /* number string should have ended here */ + if (s != end && !s[0] && (c= (s[1]-'0')) <= 9) + goto overflow; + + /* Check that we didn't get an overflow with the last digit */ + if (i > cutoff || (i == cutoff && ((j > cutoff2 || j == cutoff2) && + k > cutoff3))) + goto overflow; + li=i*LFACTOR2+ (ulonglong) j*100 + k; + return (longlong) li; + +overflow: /* *endptr is set here */ + *error= MY_ERRNO_ERANGE; + return negative ? LONGLONG_MIN : (longlong) ULONGLONG_MAX; + +end_i: + *endptr= (char*) s; + return (negative ? ((longlong) -(long) i) : (longlong) i); + +end_i_and_j: + li= (ulonglong) i * lfactor[(size_t) (s-start) / 2] + j; + *endptr= (char*) s; + return (negative ? -((longlong) li) : (longlong) li); + +end3: + li=(ulonglong) i*LFACTOR+ (ulonglong) j; + *endptr= (char*) s; + return (negative ? -((longlong) li) : (longlong) li); + +end4: + li=(ulonglong) i*LFACTOR1+ (ulonglong) j * 10 + k; + *endptr= (char*) s; + if (negative) + { + if (li > MAX_NEGATIVE_NUMBER) + goto overflow; + return -((longlong) li); + } + return (longlong) li; + +no_conv: + /* There was no number to convert. */ + *error= MY_ERRNO_EDOM; + *endptr= (char *) nptr; + return 0; +} + + +static size_t +my_scan_mb2(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *end, int sequence_type) +{ + const char *str0= str; + end--; /* for easier loop condition, because of two bytes per character */ + + switch (sequence_type) + { + case MY_SEQ_SPACES: + for ( ; str < end; str+= 2) + { + if (str[0] != '\0' || str[1] != ' ') + break; + } + return (size_t) (str - str0); + default: + return 0; + } +} + + +static void +my_fill_mb2(CHARSET_INFO *cs __attribute__((unused)), + char *s, size_t l, int fill) +{ + for ( ; l >= 2; s[0]= 0, s[1]= fill, s+= 2, l-= 2); +} + + +static int +my_vsnprintf_mb2(char *dst, size_t n, const char* fmt, va_list ap) +{ + char *start=dst, *end= dst + n - 1; + for (; *fmt ; fmt++) + { + if (fmt[0] != '%') + { + if (dst == end) /* End of buffer */ + break; + + *dst++='\0'; + *dst++= *fmt; /* Copy ordinary char */ + continue; + } + + fmt++; + + /* Skip if max size is used (to be compatible with printf) */ + while ( (*fmt >= '0' && *fmt <= '9') || *fmt == '.' || *fmt == '-') + fmt++; + + if (*fmt == 'l') + fmt++; + + if (*fmt == 's') /* String parameter */ + { + char *par= va_arg(ap, char *); + size_t plen; + size_t left_len= (size_t)(end-dst); + if (!par) + par= (char*) "(null)"; + plen= strlen(par); + if (left_len <= plen * 2) + plen = left_len / 2 - 1; + + for ( ; plen ; plen--, dst+=2, par++) + { + dst[0]= '\0'; + dst[1]= par[0]; + } + continue; + } + else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */ + { + int iarg; + char nbuf[16]; + char *pbuf= nbuf; + + if ((size_t) (end - dst) < 32) + break; + iarg= va_arg(ap, int); + if (*fmt == 'd') + int10_to_str((long) iarg, nbuf, -10); + else + int10_to_str((long) (uint) iarg, nbuf,10); + + for (; pbuf[0]; pbuf++) + { + *dst++= '\0'; + *dst++= *pbuf; + } + continue; + } + + /* We come here on '%%', unknown code or too long parameter */ + if (dst == end) + break; + *dst++= '\0'; + *dst++= '%'; /* % used as % or unknown code */ + } + + DBUG_ASSERT(dst <= end); + *dst='\0'; /* End of errmessage */ + return (size_t) (dst - start); +} + + +static size_t +my_snprintf_mb2(CHARSET_INFO *cs __attribute__((unused)), + char* to, size_t n, const char* fmt, ...) +{ + va_list args; + va_start(args,fmt); + return my_vsnprintf_mb2(to, n, fmt, args); +} + + +static size_t +my_lengthsp_mb2(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr, size_t length) +{ + const char *end= ptr + length; + while (end > ptr + 1 && end[-1] == ' ' && end[-2] == '\0') + end-= 2; + return (size_t) (end - ptr); +} + +#endif /* HAVE_CHARSET_mb2*/ + + + + +#ifdef HAVE_CHARSET_utf16 + +/* + D800..DB7F - Non-provate surrogate high (896 pages) + DB80..DBFF - Private surrogate high (128 pages) + DC00..DFFF - Surrogate low (1024 codes in a page) +*/ + +#define MY_UTF16_HIGH_HEAD(x) ((((uchar) (x)) & 0xFC) == 0xD8) +#define MY_UTF16_LOW_HEAD(x) ((((uchar) (x)) & 0xFC) == 0xDC) +#define MY_UTF16_SURROGATE(x) (((x) & 0xF800) == 0xD800) + +static int +my_utf16_uni(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t *pwc, const uchar *s, const uchar *e) +{ + if (s + 2 > e) + return MY_CS_TOOSMALL2; + + /* + High bytes: 0xD[89AB] = B'110110??' + Low bytes: 0xD[CDEF] = B'110111??' + Surrogate mask: 0xFC = B'11111100' + */ + + if (MY_UTF16_HIGH_HEAD(*s)) /* Surrogate head */ + { + if (s + 4 > e) + return MY_CS_TOOSMALL4; + + if (!MY_UTF16_LOW_HEAD(s[2])) /* Broken surrigate pair */ + return MY_CS_ILSEQ; + + /* + s[0]= 110110?? (<< 18) + s[1]= ???????? (<< 10) + s[2]= 110111?? (<< 8) + s[3]= ???????? (<< 0) + */ + + *pwc= ((s[0] & 3) << 18) + (s[1] << 10) + + ((s[2] & 3) << 8) + s[3] + 0x10000; + + return 4; + } + + if (MY_UTF16_LOW_HEAD(*s)) /* Low surrogate part without high part */ + return MY_CS_ILSEQ; + + *pwc= (s[0] << 8) + s[1]; + return 2; +} + + +static int +my_uni_utf16(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t wc, uchar *s, uchar *e) +{ + if (wc <= 0xFFFF) + { + if (s + 2 > e) + return MY_CS_TOOSMALL2; + if (MY_UTF16_SURROGATE(wc)) + return MY_CS_ILUNI; + *s++= (uchar) (wc >> 8); + *s= (uchar) (wc & 0xFF); + return 2; + } + + if (wc <= 0x10FFFF) + { + if (s + 4 > e) + return MY_CS_TOOSMALL4; + *s++= (uchar) ((wc-= 0x10000) >> 18) | 0xD8; + *s++= (uchar) (wc >> 10) & 0xFF; + *s++= (uchar) ((wc >> 8) & 3) | 0xDC; + *s= (uchar) wc & 0xFF; + return 4; + } + + return MY_CS_ILUNI; +} + + +static inline void +my_tolower_utf16(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256 && uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].tolower; +} + + +static inline void +my_toupper_utf16(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256 && uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].toupper; +} + + +static inline void +my_tosort_utf16(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256) + { + if (uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].sort; + } + else + { + *wc= REPLACEMENT_CHAR; + } +} + + +static size_t +my_caseup_utf16(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) +{ + my_wc_t wc; + int res; + char *srcend= src + srclen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + DBUG_ASSERT(src == dst && srclen == dstlen); + + while ((src < srcend) && + (res= my_utf16_uni(cs, &wc, (uchar *)src, (uchar*) srcend)) > 0) + { + my_toupper_utf16(uni_plane, &wc); + if (res != my_uni_utf16(cs, wc, (uchar*) src, (uchar*) srcend)) + break; + src+= res; + } + return srclen; +} + + +static void +my_hash_sort_utf16(CHARSET_INFO *cs, const uchar *s, size_t slen, + ulong *n1, ulong *n2) +{ + my_wc_t wc; + int res; + const uchar *e= s+slen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + + while (e > s + 1 && e[-1] == ' ' && e[-2] == '\0') + e-= 2; + + while ((s < e) && (res= my_utf16_uni(cs, &wc, (uchar *)s, (uchar*)e)) > 0) + { + my_tosort_utf16(uni_plane, &wc); + n1[0]^= (((n1[0] & 63) + n2[0]) * (wc & 0xFF)) + (n1[0] << 8); + n2[0]+= 3; + n1[0]^= (((n1[0] & 63) + n2[0]) * (wc >> 8)) + (n1[0] << 8); + n2[0]+= 3; + s+= res; + } +} + + +static size_t +my_casedn_utf16(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) +{ + my_wc_t wc; + int res; + char *srcend= src + srclen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + DBUG_ASSERT(src == dst && srclen == dstlen); + + while ((src < srcend) && + (res= my_utf16_uni(cs, &wc, (uchar*) src, (uchar*) srcend)) > 0) + { + my_tolower_utf16(uni_plane, &wc); + if (res != my_uni_utf16(cs, wc, (uchar*) src, (uchar*) srcend)) + break; + src+= res; + } + return srclen; +} + + +static int +my_strnncoll_utf16(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool t_is_prefix) +{ + int s_res, t_res; + my_wc_t s_wc,t_wc; + const uchar *se= s + slen; + const uchar *te= t + tlen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + + while (s < se && t < te) + { + s_res= my_utf16_uni(cs, &s_wc, s, se); + t_res= my_utf16_uni(cs, &t_wc, t, te); + + if (s_res <= 0 || t_res <= 0) + { + /* Incorrect string, compare by char value */ + return my_bincmp(s, se, t, te); + } + + my_tosort_utf16(uni_plane, &s_wc); + my_tosort_utf16(uni_plane, &t_wc); + + if (s_wc != t_wc) + { + return s_wc > t_wc ? 1 : -1; + } + + s+= s_res; + t+= t_res; + } + return (int) (t_is_prefix ? (t - te) : ((se - s) - (te - t))); +} + + +/** + Compare strings, discarding end space + + If one string is shorter as the other, then we space extend the other + so that the strings have equal length. + + This will ensure that the following things hold: + + "a" == "a " + "a\0" < "a" + "a\0" < "a " + + @param cs Character set pinter. + @param a First string to compare. + @param a_length Length of 'a'. + @param b Second string to compare. + @param b_length Length of 'b'. + + IMPLEMENTATION + + @return Comparison result. + @retval Negative number, if a less than b. + @retval 0, if a is equal to b + @retval Positive number, if a > b +*/ + +static int +my_strnncollsp_utf16(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool diff_if_only_endspace_difference) +{ + int res; + my_wc_t s_wc, t_wc; + const uchar *se= s + slen, *te= t + tlen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + + DBUG_ASSERT((slen % 2) == 0); + DBUG_ASSERT((tlen % 2) == 0); + +#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE + diff_if_only_endspace_difference= FALSE; +#endif + + while (s < se && t < te) + { + int s_res= my_utf16_uni(cs, &s_wc, s, se); + int t_res= my_utf16_uni(cs, &t_wc, t, te); + + if (s_res <= 0 || t_res <= 0) + { + /* Incorrect string, compare bytewise */ + return my_bincmp(s, se, t, te); + } + + my_tosort_utf16(uni_plane, &s_wc); + my_tosort_utf16(uni_plane, &t_wc); + + if (s_wc != t_wc) + { + return s_wc > t_wc ? 1 : -1; + } + + s+= s_res; + t+= t_res; + } + + slen= (size_t) (se - s); + tlen= (size_t) (te - t); + res= 0; + + if (slen != tlen) + { + int s_res, swap= 1; + if (diff_if_only_endspace_difference) + res= 1; /* Assume 's' is bigger */ + if (slen < tlen) + { + slen= tlen; + s= t; + se= te; + swap= -1; + res= -res; + } + + for ( ; s < se; s+= s_res) + { + if ((s_res= my_utf16_uni(cs, &s_wc, s, se)) < 0) + { + DBUG_ASSERT(0); + return 0; + } + if (s_wc != ' ') + return (s_wc < ' ') ? -swap : swap; + } + } + return res; +} + + +static uint +my_ismbchar_utf16(CHARSET_INFO *cs __attribute__((unused)), + const char *b __attribute__((unused)), + const char *e __attribute__((unused))) +{ + if (b + 2 > e) + return 0; + + if (MY_UTF16_HIGH_HEAD(*b)) + { + return (b + 4 <= e) && MY_UTF16_LOW_HEAD(b[2]) ? 4 : 0; + } + + if (MY_UTF16_LOW_HEAD(*b)) + return 0; + + return 2; +} + + +static uint +my_mbcharlen_utf16(CHARSET_INFO *cs __attribute__((unused)), + uint c __attribute__((unused))) +{ + return MY_UTF16_HIGH_HEAD(c) ? 4 : 2; +} + + +static size_t +my_numchars_utf16(CHARSET_INFO *cs, + const char *b, const char *e) +{ + size_t nchars= 0; + for ( ; ; nchars++) + { + size_t charlen= my_ismbchar_utf16(cs, b, e); + if (!charlen) + break; + b+= charlen; + } + return nchars; +} + + +static size_t +my_charpos_utf16(CHARSET_INFO *cs, + const char *b, const char *e, size_t pos) +{ + const char *b0= b; + uint charlen; + + for ( ; pos; b+= charlen, pos--) + { + if (!(charlen= my_ismbchar(cs, b, e))) + return (e + 2 - b0); /* Error, return pos outside the string */ + } + return (size_t) (pos ? (e + 2 - b0) : (b - b0)); +} + + +static size_t +my_well_formed_len_utf16(CHARSET_INFO *cs, + const char *b, const char *e, + size_t nchars, int *error) +{ + const char *b0= b; + uint charlen; + *error= 0; + + for ( ; nchars; b+= charlen, nchars--) + { + if (!(charlen= my_ismbchar(cs, b, e))) + { + *error= b < e ? 1 : 0; + break; + } + } + return (size_t) (b - b0); +} + + +static int +my_wildcmp_utf16_ci(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many) +{ + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + return my_wildcmp_unicode(cs, str, str_end, wildstr, wildend, + escape, w_one, w_many, uni_plane); +} + + +static int +my_wildcmp_utf16_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) +{ + return my_wildcmp_unicode(cs, str, str_end, wildstr, wildend, + escape, w_one, w_many, NULL); +} + + +static int +my_strnncoll_utf16_bin(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool t_is_prefix) +{ + int s_res,t_res; + my_wc_t s_wc,t_wc; + const uchar *se=s+slen; + const uchar *te=t+tlen; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + + while ( s < se && t < te ) + { + s_res= my_utf16_uni(cs,&s_wc, s, se); + t_res= my_utf16_uni(cs,&t_wc, t, te); + + if (s_res <= 0 || t_res <= 0) + { + /* Incorrect string, compare by char value */ + return my_bincmp(s, se, t, te); + } + if (s_wc != t_wc) + { + return s_wc > t_wc ? 1 : -1; + } + + s+= s_res; + t+= t_res; + } + return (int) (t_is_prefix ? (t - te) : ((se - s) - (te - t))); +} + + +static int +my_strnncollsp_utf16_bin(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool diff_if_only_endspace_difference) +{ + int res; + my_wc_t s_wc, t_wc; + const uchar *se= s + slen, *te= t + tlen; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + + DBUG_ASSERT((slen % 2) == 0); + DBUG_ASSERT((tlen % 2) == 0); + +#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE + diff_if_only_endspace_difference= FALSE; +#endif + + while (s < se && t < te) + { + int s_res= my_utf16_uni(cs, &s_wc, s, se); + int t_res= my_utf16_uni(cs, &t_wc, t, te); + + if (s_res <= 0 || t_res <= 0) + { + /* Incorrect string, compare bytewise */ + return my_bincmp(s, se, t, te); + } + + if (s_wc != t_wc) + { + return s_wc > t_wc ? 1 : -1; + } + + s+= s_res; + t+= t_res; + } + + slen= (size_t) (se - s); + tlen= (size_t) (te - t); + res= 0; + + if (slen != tlen) + { + int s_res, swap= 1; + if (diff_if_only_endspace_difference) + res= 1; /* Assume 's' is bigger */ + if (slen < tlen) + { + slen= tlen; + s= t; + se= te; + swap= -1; + res= -res; + } + + for ( ; s < se; s+= s_res) + { + if ((s_res= my_utf16_uni(cs, &s_wc, s, se)) < 0) + { + DBUG_ASSERT(0); + return 0; + } + if (s_wc != ' ') + return (s_wc < ' ') ? -swap : swap; + } + } + return res; +} + + +static void +my_hash_sort_utf16_bin(CHARSET_INFO *cs __attribute__((unused)), + const uchar *key, size_t len,ulong *nr1, ulong *nr2) +{ + const uchar *pos = key; + + key+= len; + + while (key > pos + 1 && key[-1] == ' ' && key[-2] == '\0') + key-= 2; + + for (; pos < (uchar*) key ; pos++) + { + nr1[0]^= (ulong) ((((uint) nr1[0] & 63) + nr2[0]) * + ((uint)*pos)) + (nr1[0] << 8); + nr2[0]+= 3; + } +} + + +/** + Calculate min_str and max_str that ranges a LIKE string. + + @param ptr Pointer to LIKE pattern. + @param ptr_length Length of LIKE pattern. + @param escape Escape character in LIKE. (Normally '\'). + All escape characters should be removed + from min_str and max_str. + @param res_length Length of min_str and max_str. + @param min_str Smallest case sensitive string that ranges LIKE. + Should be space padded to res_length. + @param max_str Largest case sensitive string that ranges LIKE. + Normally padded with the biggest character sort value. + + @return Optimization status. + @retval FALSE if LIKE pattern can be optimized + @rerval TRUE if LIKE can't be optimized. +*/ + +my_bool +my_like_range_utf16(CHARSET_INFO *cs, + const char *ptr, size_t ptr_length, + pbool escape, pbool w_one, pbool w_many, + size_t res_length, + char *min_str,char *max_str, + size_t *min_length,size_t *max_length) +{ + const char *end=ptr+ptr_length; + char *min_org=min_str; + char *min_end=min_str+res_length; + size_t charlen= res_length / cs->mbmaxlen; + + for ( ; ptr + 1 < end && min_str + 1 < min_end && charlen > 0 + ; ptr+=2, charlen--) + { + if (ptr[0] == '\0' && ptr[1] == escape && ptr + 1 < end) + { + ptr+=2; /* Skip escape */ + *min_str++= *max_str++ = ptr[0]; + *min_str++= *max_str++ = ptr[1]; + continue; + } + if (ptr[0] == '\0' && ptr[1] == w_one) /* '_' in SQL */ + { + *min_str++= (char) (cs->min_sort_char >> 8); + *min_str++= (char) (cs->min_sort_char & 255); + *max_str++= (char) (cs->max_sort_char >> 8); + *max_str++= (char) (cs->max_sort_char & 255); + continue; + } + if (ptr[0] == '\0' && ptr[1] == w_many) /* '%' in SQL */ + { + /* + Calculate length of keys: + 'a\0\0... is the smallest possible string when we have space expand + a\ff\ff... is the biggest possible string + */ + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : + res_length); + *max_length= res_length; + do { + *min_str++ = 0; + *min_str++ = 0; + *max_str++ = (char) (cs->max_sort_char >> 8); + *max_str++ = (char) (cs->max_sort_char & 255); + } while (min_str + 1 < min_end); + return FALSE; + } + *min_str++= *max_str++ = ptr[0]; + *min_str++= *max_str++ = ptr[1]; + } + + /* Temporary fix for handling w_one at end of string (key compression) */ + { + char *tmp; + for (tmp= min_str ; tmp-1 > min_org && tmp[-1] == '\0' && tmp[-2]=='\0';) + { + *--tmp=' '; + *--tmp='\0'; + } + } + + *min_length= *max_length = (size_t) (min_str - min_org); + while (min_str + 1 < min_end) + { + *min_str++ = *max_str++ = '\0'; + *min_str++ = *max_str++ = ' '; /* Because if key compression */ + } + return FALSE; +} + + +static MY_COLLATION_HANDLER my_collation_utf16_general_ci_handler = +{ + NULL, /* init */ + my_strnncoll_utf16, + my_strnncollsp_utf16, + my_strnxfrm_unicode, + my_strnxfrmlen_simple, + my_like_range_utf16, + my_wildcmp_utf16_ci, + my_strcasecmp_mb2_or_mb4, + my_instr_mb, + my_hash_sort_utf16, + my_propagate_simple +}; + + +static MY_COLLATION_HANDLER my_collation_utf16_bin_handler = +{ + NULL, /* init */ + my_strnncoll_utf16_bin, + my_strnncollsp_utf16_bin, + my_strnxfrm_unicode, + my_strnxfrmlen_simple, + my_like_range_utf16, + my_wildcmp_utf16_bin, + my_strcasecmp_mb2_or_mb4, + my_instr_mb, + my_hash_sort_utf16_bin, + my_propagate_simple +}; + + +MY_CHARSET_HANDLER my_charset_utf16_handler= +{ + NULL, /* init */ + my_ismbchar_utf16, /* ismbchar */ + my_mbcharlen_utf16, /* mbcharlen */ + my_numchars_utf16, + my_charpos_utf16, + my_well_formed_len_utf16, + my_lengthsp_mb2, + my_numcells_mb, + my_utf16_uni, /* mb_wc */ + my_uni_utf16, /* wc_mb */ + my_mb_ctype_mb, + my_caseup_str_mb2_or_mb4, + my_casedn_str_mb2_or_mb4, + my_caseup_utf16, + my_casedn_utf16, + my_snprintf_mb2, + my_l10tostr_mb2_or_mb4, + my_ll10tostr_mb2_or_mb4, + my_fill_mb2, + my_strntol_mb2_or_mb4, + my_strntoul_mb2_or_mb4, + my_strntoll_mb2_or_mb4, + my_strntoull_mb2_or_mb4, + my_strntod_mb2_or_mb4, + my_strtoll10_mb2, + my_strntoull10rnd_mb2_or_mb4, + my_scan_mb2 +}; + + +CHARSET_INFO my_charset_utf16_general_ci= +{ + 54,0,0, /* number */ + MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII, + "utf16", /* cs name */ + "utf16_general_ci", /* name */ + "UTF-16 Unicode", /* comment */ + NULL, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 1, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 0, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_general_ci_handler +}; + + +CHARSET_INFO my_charset_utf16_bin= +{ + 55,0,0, /* number */ + MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE|MY_CS_NONASCII, + "utf16", /* cs name */ + "utf16_bin", /* name */ + "UTF-16 Unicode", /* comment */ + NULL, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 1, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 2, /* mbminlen */ + 4, /* mbmaxlen */ + 0, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf16_handler, + &my_collation_utf16_bin_handler +}; + +#endif /* HAVE_CHARSET_utf16 */ + + +#ifdef HAVE_CHARSET_utf32 + +static int +my_utf32_uni(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t *pwc, const uchar *s, const uchar *e) +{ + if (s + 4 > e) + return MY_CS_TOOSMALL4; + *pwc= (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + (s[3]); + return 4; +} + + +static int +my_uni_utf32(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t wc, uchar *s, uchar *e) +{ + if (s + 4 > e) + return MY_CS_TOOSMALL4; + + s[0]= (uchar) (wc >> 24); + s[1]= (uchar) (wc >> 16) & 0xFF; + s[2]= (uchar) (wc >> 8) & 0xFF; + s[3]= (uchar) wc & 0xFF; + return 4; +} + + +static inline void +my_tolower_utf32(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256 && uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].tolower; +} + + +static inline void +my_toupper_utf32(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256 && uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].toupper; +} + + +static inline void +my_tosort_utf32(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256) + { + if (uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].sort; + } + else + { + *wc= REPLACEMENT_CHAR; + } +} + + +static size_t +my_caseup_utf32(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) +{ + my_wc_t wc; + int res; + char *srcend= src + srclen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + DBUG_ASSERT(src == dst && srclen == dstlen); + + while ((src < srcend) && + (res= my_utf32_uni(cs, &wc, (uchar *)src, (uchar*) srcend)) > 0) + { + my_toupper_utf32(uni_plane, &wc); + if (res != my_uni_utf32(cs, wc, (uchar*) src, (uchar*) srcend)) + break; + src+= res; + } + return srclen; +} + + +static inline void +my_hash_add(ulong *n1, ulong *n2, uint ch) +{ + n1[0]^= (((n1[0] & 63) + n2[0]) * (ch)) + (n1[0] << 8); + n2[0]+= 3; +} + + +static void +my_hash_sort_utf32(CHARSET_INFO *cs, const uchar *s, size_t slen, + ulong *n1, ulong *n2) +{ + my_wc_t wc; + int res; + const uchar *e= s + slen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + + /* Skip trailing spaces */ + while (e > s + 3 && e[-1] == ' ' && !e[-2] && !e[-3] && !e[-4]) + e-= 4; + + while ((res= my_utf32_uni(cs, &wc, (uchar*) s, (uchar*) e)) > 0) + { + my_tosort_utf32(uni_plane, &wc); + my_hash_add(n1, n2, (uint) (wc >> 24)); + my_hash_add(n1, n2, (uint) (wc >> 16) & 0xFF); + my_hash_add(n1, n2, (uint) (wc >> 8) & 0xFF); + my_hash_add(n1, n2, (uint) (wc & 0xFF)); + s+= res; + } +} + + +static size_t +my_casedn_utf32(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) +{ + my_wc_t wc; + int res; + char *srcend= src + srclen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + DBUG_ASSERT(src == dst && srclen == dstlen); + + while ((res= my_utf32_uni(cs, &wc, (uchar*) src, (uchar*) srcend)) > 0) + { + my_tolower_utf32(uni_plane,&wc); + if (res != my_uni_utf32(cs, wc, (uchar*) src, (uchar*) srcend)) + break; + src+= res; + } + return srclen; +} + + +static int +my_strnncoll_utf32(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool t_is_prefix) +{ + my_wc_t s_wc,t_wc; + const uchar *se= s + slen; + const uchar *te= t + tlen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + + while (s < se && t < te) + { + int s_res= my_utf32_uni(cs, &s_wc, s, se); + int t_res= my_utf32_uni(cs, &t_wc, t, te); + + if ( s_res <= 0 || t_res <= 0) + { + /* Incorrect string, compare by char value */ + return my_bincmp(s, se, t, te); + } + + my_tosort_utf32(uni_plane, &s_wc); + my_tosort_utf32(uni_plane, &t_wc); + + if (s_wc != t_wc) + { + return s_wc > t_wc ? 1 : -1; + } + + s+= s_res; + t+= t_res; + } + return (int) (t_is_prefix ? (t - te) : ((se - s) - (te - t))); +} + + +/** + Compare strings, discarding end space + + If one string is shorter as the other, then we space extend the other + so that the strings have equal length. + + This will ensure that the following things hold: + + "a" == "a " + "a\0" < "a" + "a\0" < "a " + + @param cs Character set pinter. + @param a First string to compare. + @param a_length Length of 'a'. + @param b Second string to compare. + @param b_length Length of 'b'. + + IMPLEMENTATION + + @return Comparison result. + @retval Negative number, if a less than b. + @retval 0, if a is equal to b + @retval Positive number, if a > b +*/ + + +static int +my_strnncollsp_utf32(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool diff_if_only_endspace_difference) +{ + int res; + my_wc_t s_wc, t_wc; + const uchar *se= s + slen, *te= t + tlen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + + DBUG_ASSERT((slen % 4) == 0); + DBUG_ASSERT((tlen % 4) == 0); + +#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE + diff_if_only_endspace_difference= FALSE; +#endif + + while ( s < se && t < te ) + { + int s_res= my_utf32_uni(cs, &s_wc, s, se); + int t_res= my_utf32_uni(cs, &t_wc, t, te); + + if ( s_res <= 0 || t_res <= 0 ) + { + /* Incorrect string, compare bytewise */ + return my_bincmp(s, se, t, te); + } + + my_tosort_utf32(uni_plane, &s_wc); + my_tosort_utf32(uni_plane, &t_wc); + + if ( s_wc != t_wc ) + { + return s_wc > t_wc ? 1 : -1; + } + + s+= s_res; + t+= t_res; + } + + slen= (size_t) (se - s); + tlen= (size_t) (te - t); + res= 0; + + if (slen != tlen) + { + int s_res, swap= 1; + if (diff_if_only_endspace_difference) + res= 1; /* Assume 's' is bigger */ + if (slen < tlen) + { + slen= tlen; + s= t; + se= te; + swap= -1; + res= -res; + } + + for ( ; s < se; s+= s_res) + { + if ((s_res= my_utf32_uni(cs, &s_wc, s, se)) < 0) + { + DBUG_ASSERT(0); + return 0; + } + if (s_wc != ' ') + return (s_wc < ' ') ? -swap : swap; + } + } + return res; +} + + +static size_t +my_strnxfrmlen_utf32(CHARSET_INFO *cs __attribute__((unused)), size_t len) +{ + return len / 2; +} + + +static uint +my_ismbchar_utf32(CHARSET_INFO *cs __attribute__((unused)), + const char *b __attribute__((unused)), + const char *e __attribute__((unused))) +{ + return 4; +} + + +static uint +my_mbcharlen_utf32(CHARSET_INFO *cs __attribute__((unused)) , + uint c __attribute__((unused))) +{ + return 4; +} + + +static int +my_vsnprintf_utf32(char *dst, size_t n, const char* fmt, va_list ap) +{ + char *start= dst, *end= dst + n; + DBUG_ASSERT((n % 4) == 0); + for (; *fmt ; fmt++) + { + if (fmt[0] != '%') + { + if (dst >= end) /* End of buffer */ + break; + + *dst++= '\0'; + *dst++= '\0'; + *dst++= '\0'; + *dst++= *fmt; /* Copy ordinary char */ + continue; + } + + fmt++; + + /* Skip if max size is used (to be compatible with printf) */ + while ( (*fmt>='0' && *fmt<='9') || *fmt == '.' || *fmt == '-') + fmt++; + + if (*fmt == 'l') + fmt++; + + if (*fmt == 's') /* String parameter */ + { + reg2 char *par= va_arg(ap, char *); + size_t plen; + size_t left_len= (size_t)(end - dst); + if (!par) par= (char*)"(null)"; + plen= strlen(par); + if (left_len <= plen*4) + plen= left_len / 4 - 1; + + for ( ; plen ; plen--, dst+= 4, par++) + { + dst[0]= '\0'; + dst[1]= '\0'; + dst[2]= '\0'; + dst[3]= par[0]; + } + continue; + } + else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */ + { + register int iarg; + char nbuf[16]; + char *pbuf= nbuf; + + if ((size_t) (end - dst) < 64) + break; + iarg= va_arg(ap, int); + if (*fmt == 'd') + int10_to_str((long) iarg, nbuf, -10); + else + int10_to_str((long) (uint) iarg,nbuf,10); + + for (; pbuf[0]; pbuf++) + { + *dst++= '\0'; + *dst++= '\0'; + *dst++= '\0'; + *dst++= *pbuf; + } + continue; + } + + /* We come here on '%%', unknown code or too long parameter */ + if (dst == end) + break; + *dst++= '\0'; + *dst++= '\0'; + *dst++= '\0'; + *dst++= '%'; /* % used as % or unknown code */ + } + + DBUG_ASSERT(dst < end); + *dst++= '\0'; + *dst++= '\0'; + *dst++= '\0'; + *dst++= '\0'; /* End of errmessage */ + return (size_t) (dst - start - 4); +} + + +static size_t +my_snprintf_utf32(CHARSET_INFO *cs __attribute__((unused)), + char* to, size_t n, const char* fmt, ...) +{ + va_list args; + va_start(args,fmt); + return my_vsnprintf_utf32(to, n, fmt, args); +} + + +static longlong +my_strtoll10_utf32(CHARSET_INFO *cs __attribute__((unused)), + const char *nptr, char **endptr, int *error) +{ + const char *s, *end, *start, *n_end, *true_end; + uchar c; + unsigned long i, j, k; + ulonglong li; + int negative; + ulong cutoff, cutoff2, cutoff3; + + s= nptr; + /* If fixed length string */ + if (endptr) + { + /* Make sure string length is even */ + end= s + ((*endptr - s) / 4) * 4; + while (s < end && !s[0] && !s[1] && !s[2] && + (s[3] == ' ' || s[3] == '\t')) + s+= 4; + if (s == end) + goto no_conv; + } + else + { + /* We don't support null terminated strings in UCS2 */ + goto no_conv; + } + + /* Check for a sign. */ + negative= 0; + if (!s[0] && !s[1] && !s[2] && s[3] == '-') + { + *error= -1; /* Mark as negative number */ + negative= 1; + s+= 4; + if (s == end) + goto no_conv; + cutoff= MAX_NEGATIVE_NUMBER / LFACTOR2; + cutoff2= (MAX_NEGATIVE_NUMBER % LFACTOR2) / 100; + cutoff3= MAX_NEGATIVE_NUMBER % 100; + } + else + { + *error= 0; + if (!s[0] && !s[1] && !s[2] && s[3] == '+') + { + s+= 4; + if (s == end) + goto no_conv; + } + cutoff= ULONGLONG_MAX / LFACTOR2; + cutoff2= ULONGLONG_MAX % LFACTOR2 / 100; + cutoff3= ULONGLONG_MAX % 100; + } + + /* Handle case where we have a lot of pre-zero */ + if (!s[0] && !s[1] && !s[2] && s[3] == '0') + { + i= 0; + do + { + s+= 4; + if (s == end) + goto end_i; /* Return 0 */ + } + while (!s[0] && !s[1] && !s[2] && s[3] == '0'); + n_end= s + 4 * INIT_CNT; + } + else + { + /* Read first digit to check that it's a valid number */ + if (s[0] || s[1] || s[2] || (c= (s[3]-'0')) > 9) + goto no_conv; + i= c; + s+= 4; + n_end= s + 4 * (INIT_CNT-1); + } + + /* Handle first 9 digits and store them in i */ + if (n_end > end) + n_end= end; + for (; s != n_end ; s+= 4) + { + if (s[0] || s[1] || s[2] || (c= (s[3] - '0')) > 9) + goto end_i; + i= i * 10 + c; + } + if (s == end) + goto end_i; + + /* Handle next 9 digits and store them in j */ + j= 0; + start= s; /* Used to know how much to shift i */ + n_end= true_end= s + 4 * INIT_CNT; + if (n_end > end) + n_end= end; + do + { + if (s[0] || s[1] || s[2] || (c= (s[3] - '0')) > 9) + goto end_i_and_j; + j= j * 10 + c; + s+= 4; + } while (s != n_end); + if (s == end) + { + if (s != true_end) + goto end_i_and_j; + goto end3; + } + if (s[0] || s[1] || s[2] || (c= (s[3] - '0')) > 9) + goto end3; + + /* Handle the next 1 or 2 digits and store them in k */ + k=c; + s+= 4; + if (s == end || s[0] || s[1] || s[2] || (c= (s[3]-'0')) > 9) + goto end4; + k= k * 10 + c; + s+= 2; + *endptr= (char*) s; + + /* number string should have ended here */ + if (s != end && !s[0] && !s[1] && !s[2] && (c= (s[3] - '0')) <= 9) + goto overflow; + + /* Check that we didn't get an overflow with the last digit */ + if (i > cutoff || (i == cutoff && ((j > cutoff2 || j == cutoff2) && + k > cutoff3))) + goto overflow; + li= i * LFACTOR2+ (ulonglong) j * 100 + k; + return (longlong) li; + +overflow: /* *endptr is set here */ + *error= MY_ERRNO_ERANGE; + return negative ? LONGLONG_MIN : (longlong) ULONGLONG_MAX; + +end_i: + *endptr= (char*) s; + return (negative ? ((longlong) -(long) i) : (longlong) i); + +end_i_and_j: + li= (ulonglong) i * lfactor[(size_t) (s-start) / 4] + j; + *endptr= (char*) s; + return (negative ? -((longlong) li) : (longlong) li); + +end3: + li= (ulonglong) i*LFACTOR+ (ulonglong) j; + *endptr= (char*) s; + return (negative ? -((longlong) li) : (longlong) li); + +end4: + li= (ulonglong) i*LFACTOR1+ (ulonglong) j * 10 + k; + *endptr= (char*) s; + if (negative) + { + if (li > MAX_NEGATIVE_NUMBER) + goto overflow; + return -((longlong) li); + } + return (longlong) li; + +no_conv: + /* There was no number to convert. */ + *error= MY_ERRNO_EDOM; + *endptr= (char *) nptr; + return 0; +} + + +static size_t +my_numchars_utf32(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e) +{ + return (size_t) (e - b) / 4; +} + + +static size_t +my_charpos_utf32(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, size_t pos) +{ + size_t string_length= (size_t) (e - b); + return pos * 4 > string_length ? string_length + 4 : pos * 4; +} + + +static size_t +my_well_formed_len_utf32(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t nchars, int *error) +{ + /* Ensure string length is divisible by 4 */ + const char *b0= b; + size_t length= e - b; + DBUG_ASSERT((length % 4) == 0); + *error= 0; + nchars*= 4; + if (length > nchars) + { + length= nchars; + e= b + nchars; + } + for (; b < e; b+= 4) + { + /* Don't accept characters greater than U+10FFFF */ + if (b[0] || (uchar) b[1] > 0x10) + { + *error= 1; + return b - b0; + } + } + return length; +} + + +static +void my_fill_utf32(CHARSET_INFO *cs, + char *s, size_t slen, int fill) +{ + char buf[10]; + uint buflen; + char *e= s + slen; + + DBUG_ASSERT((slen % 4) == 0); + + buflen= cs->cset->wc_mb(cs, (my_wc_t) fill, (uchar*) buf, + (uchar*) buf + sizeof(buf)); + DBUG_ASSERT(buflen == 4); + while (s < e) + { + memcpy(s, buf, 4); + s+= 4; + } +} + + +static size_t +my_lengthsp_utf32(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr, size_t length) +{ + const char *end= ptr + length; + DBUG_ASSERT((length % 4) == 0); + while (end > ptr + 3 && end[-1] == ' ' && !end[-2] && !end[-3] && !end[-4]) + end-= 4; + return (size_t) (end - ptr); +} + + +static int +my_wildcmp_utf32_ci(CHARSET_INFO *cs, + const char *str, const char *str_end, + const char *wildstr, const char *wildend, + int escape, int w_one, int w_many) +{ + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + return my_wildcmp_unicode(cs, str, str_end, wildstr, wildend, + escape, w_one, w_many, uni_plane); +} + + +static int +my_wildcmp_utf32_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) +{ + return my_wildcmp_unicode(cs, str, str_end, wildstr, wildend, + escape, w_one, w_many, NULL); +} + + +static int +my_strnncoll_utf32_bin(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool t_is_prefix) +{ + my_wc_t s_wc, t_wc; + const uchar *se= s + slen; + const uchar *te= t + tlen; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + + while (s < se && t < te) + { + int s_res= my_utf32_uni(cs, &s_wc, s, se); + int t_res= my_utf32_uni(cs, &t_wc, t, te); + + if (s_res <= 0 || t_res <= 0) + { + /* Incorrect string, compare by char value */ + return my_bincmp(s, se, t, te); + } + if (s_wc != t_wc) + { + return s_wc > t_wc ? 1 : -1; + } + + s+= s_res; + t+= t_res; + } + return (int) (t_is_prefix ? (t-te) : ((se - s) - (te - t))); +} + + +static inline my_wc_t +my_utf32_get(const uchar *s) +{ + return + ((my_wc_t) s[0] << 24) + + ((my_wc_t) s[1] << 16) + + ((my_wc_t) s[2] << 8) + + s[3]; +} + + +static int +my_strnncollsp_utf32_bin(CHARSET_INFO *cs __attribute__((unused)), + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool diff_if_only_endspace_difference + __attribute__((unused))) +{ + const uchar *se, *te; + size_t minlen; + + DBUG_ASSERT((slen % 4) == 0); + DBUG_ASSERT((tlen % 4) == 0); + + se= s + slen; + te= t + tlen; + + for (minlen= min(slen, tlen); minlen; minlen-= 4) + { + my_wc_t s_wc= my_utf32_get(s); + my_wc_t t_wc= my_utf32_get(t); + if (s_wc != t_wc) + return s_wc > t_wc ? 1 : -1; + + s+= 4; + t+= 4; + } + + if (slen != tlen) + { + int swap= 1; + if (slen < tlen) + { + s= t; + se= te; + swap= -1; + } + + for ( ; s < se ; s+= 4) + { + my_wc_t s_wc= my_utf32_get(s); + if (s_wc != ' ') + return (s_wc < ' ') ? -swap : swap; + } + } + return 0; +} + + +/** + Calculate min_str and max_str that ranges a LIKE string. + + @param ptr Pointer to LIKE pattern. + @param ptr_length Length of LIKE pattern. + @param escape Escape character in LIKE. (Normally '\'). + All escape characters should be removed + from min_str and max_str. + @param res_length Length of min_str and max_str. + @param min_str Smallest case sensitive string that ranges LIKE. + Should be space padded to res_length. + @param max_str Largest case sensitive string that ranges LIKE. + Normally padded with the biggest character sort value. + + @return Optimization status. + @retval FALSE if LIKE pattern can be optimized + @rerval TRUE if LIKE can't be optimized. +*/ + +my_bool +my_like_range_utf32(CHARSET_INFO *cs, + const char *ptr, size_t ptr_length, + pbool escape, pbool w_one, pbool w_many, + size_t res_length, + char *min_str,char *max_str, + size_t *min_length,size_t *max_length) +{ + const char *end= ptr + ptr_length; + char *min_org= min_str; + char *min_end= min_str + res_length; + char *max_end= max_str + res_length; + size_t charlen= res_length / cs->mbmaxlen; + + DBUG_ASSERT((res_length % 4) == 0); + + for ( ; charlen > 0; ptr+= 4, charlen--) + { + my_wc_t wc; + int res; + if ((res= my_utf32_uni(cs, &wc, ptr, end)) < 0) + { + my_fill_utf32(cs, min_str, min_end - min_str, cs->min_sort_char); + my_fill_utf32(cs, max_str, min_end - min_str, cs->max_sort_char); + /* min_length and max_legnth are not important */ + return TRUE; + } + + if (wc == (my_wc_t) escape) + { + ptr+= 4; /* Skip escape */ + if ((res= my_utf32_uni(cs, &wc, ptr, end)) < 0) + { + my_fill_utf32(cs, min_str, min_end - min_str, cs->min_sort_char); + my_fill_utf32(cs, max_str, max_end - min_str, cs->max_sort_char); + /* min_length and max_length are not important */ + return TRUE; + } + if (my_uni_utf32(cs, wc, min_str, min_end) != 4 || + my_uni_utf32(cs, wc, max_str, max_end) != 4) + goto pad_set_lengths; + *min_str++= 4; + *max_str++= 4; + continue; + } + + if (wc == (my_wc_t) w_one) + { + if (my_uni_utf32(cs, cs->min_sort_char, min_str, min_end) != 4 || + my_uni_utf32(cs, cs->max_sort_char, max_str, max_end) != 4) + goto pad_set_lengths; + min_str+= 4; + max_str+= 4; + continue; + } + + if (wc == (my_wc_t) w_many) + { + /* + Calculate length of keys: + 'a\0\0... is the smallest possible string when we have space expand + a\ff\ff... is the biggest possible string + */ + *min_length= ((cs->state & MY_CS_BINSORT) ? + (size_t) (min_str - min_org) : + res_length); + *max_length= res_length; + goto pad_min_max; + } + + /* Normal character */ + if (my_uni_utf32(cs, wc, min_str, min_end) != 4 || + my_uni_utf32(cs, wc, max_str, max_end) != 4) + goto pad_set_lengths; + min_str+= 4; + max_str+= 4; + } + +pad_set_lengths: + *min_length= *max_length= (size_t) (min_str - min_org); + +pad_min_max: + my_fill_utf32(cs, min_str, min_end - min_str, cs->min_sort_char); + my_fill_utf32(cs, max_str, max_end - max_str, cs->max_sort_char); + return FALSE; +} + + +static size_t +my_scan_utf32(CHARSET_INFO *cs, + const char *str, const char *end, int sequence_type) +{ + const char *str0= str; + + switch (sequence_type) + { + case MY_SEQ_SPACES: + for ( ; str < end; ) + { + my_wc_t wc; + int res= my_utf32_uni(cs, &wc, str, end); + if (res < 0 || wc != ' ') + break; + str+= res; + } + return (size_t) (str - str0); + default: + return 0; + } +} + + +static MY_COLLATION_HANDLER my_collation_utf32_general_ci_handler = +{ + NULL, /* init */ + my_strnncoll_utf32, + my_strnncollsp_utf32, + my_strnxfrm_unicode, + my_strnxfrmlen_utf32, + my_like_range_utf32, + my_wildcmp_utf32_ci, + my_strcasecmp_mb2_or_mb4, + my_instr_mb, + my_hash_sort_utf32, + my_propagate_simple +}; + + +static MY_COLLATION_HANDLER my_collation_utf32_bin_handler = +{ + NULL, /* init */ + my_strnncoll_utf32_bin, + my_strnncollsp_utf32_bin, + my_strnxfrm_unicode, + my_strnxfrmlen_utf32, + my_like_range_utf32, + my_wildcmp_utf32_bin, + my_strcasecmp_mb2_or_mb4, + my_instr_mb, + my_hash_sort_utf32, + my_propagate_simple +}; + + +MY_CHARSET_HANDLER my_charset_utf32_handler= +{ + NULL, /* init */ + my_ismbchar_utf32, + my_mbcharlen_utf32, + my_numchars_utf32, + my_charpos_utf32, + my_well_formed_len_utf32, + my_lengthsp_utf32, + my_numcells_mb, + my_utf32_uni, + my_uni_utf32, + my_mb_ctype_mb, + my_caseup_str_mb2_or_mb4, + my_casedn_str_mb2_or_mb4, + my_caseup_utf32, + my_casedn_utf32, + my_snprintf_utf32, + my_l10tostr_mb2_or_mb4, + my_ll10tostr_mb2_or_mb4, + my_fill_utf32, + my_strntol_mb2_or_mb4, + my_strntoul_mb2_or_mb4, + my_strntoll_mb2_or_mb4, + my_strntoull_mb2_or_mb4, + my_strntod_mb2_or_mb4, + my_strtoll10_utf32, + my_strntoull10rnd_mb2_or_mb4, + my_scan_utf32 +}; + + +CHARSET_INFO my_charset_utf32_general_ci= +{ + 60,0,0, /* number */ + MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_NONASCII, + "utf32", /* cs name */ + "utf32_general_ci", /* name */ + "UTF-32 Unicode", /* comment */ + NULL, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 1, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 0, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_general_ci_handler +}; + + +CHARSET_INFO my_charset_utf32_bin= +{ + 61,0,0, /* number */ + MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE|MY_CS_NONASCII, + "utf32", /* cs name */ + "utf32_bin", /* name */ + "UTF-32 Unicode", /* comment */ + NULL, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 1, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 4, /* mbminlen */ + 4, /* mbmaxlen */ + 0, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf32_handler, + &my_collation_utf32_bin_handler +}; + + +#endif /* HAVE_CHARSET_utf32 */ + + +#ifdef HAVE_CHARSET_ucs2 static uchar ctype_ucs2[] = { 0, @@ -160,13 +2981,6 @@ static void my_hash_sort_ucs2(CHARSET_INFO *cs, const uchar *s, size_t slen, } -static size_t my_caseup_str_ucs2(CHARSET_INFO * cs __attribute__((unused)), - char * s __attribute__((unused))) -{ - return 0; -} - - static size_t my_casedn_ucs2(CHARSET_INFO *cs, char *src, size_t srclen, char *dst __attribute__((unused)), size_t dstlen __attribute__((unused))) @@ -190,13 +3004,6 @@ static size_t my_casedn_ucs2(CHARSET_INFO *cs, char *src, size_t srclen, } -static size_t my_casedn_str_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char * s __attribute__((unused))) -{ - return 0; -} - - static int my_strnncoll_ucs2(CHARSET_INFO *cs, const uchar *s, size_t slen, const uchar *t, size_t tlen, @@ -313,88 +3120,6 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), } -static int my_strncasecmp_ucs2(CHARSET_INFO *cs, - const char *s, const char *t, size_t len) -{ - int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; - const char *se=s+len; - const char *te=t+len; - MY_UNICASE_INFO **uni_plane= cs->caseinfo; - - while ( s < se && t < te ) - { - int plane; - - s_res=my_ucs2_uni(cs,&s_wc, (const uchar*)s, (const uchar*)se); - t_res=my_ucs2_uni(cs,&t_wc, (const uchar*)t, (const uchar*)te); - - if ( s_res <= 0 || t_res <= 0 ) - { - /* Incorrect string, compare by char value */ - return ((int)s[0]-(int)t[0]); - } - - plane=(s_wc>>8) & 0xFF; - s_wc = uni_plane[plane] ? uni_plane[plane][s_wc & 0xFF].tolower : s_wc; - - plane=(t_wc>>8) & 0xFF; - t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].tolower : t_wc; - - if ( s_wc != t_wc ) - return ((int) s_wc) - ((int) t_wc); - - s+=s_res; - t+=t_res; - } - return (int) ( (se-s) - (te-t) ); -} - - -static int my_strcasecmp_ucs2(CHARSET_INFO *cs, const char *s, const char *t) -{ - size_t s_len= strlen(s); - size_t t_len= strlen(t); - size_t len = (s_len > t_len) ? s_len : t_len; - return my_strncasecmp_ucs2(cs, s, t, len); -} - - -static size_t my_strnxfrm_ucs2(CHARSET_INFO *cs, - uchar *dst, size_t dstlen, const uchar *src, - size_t srclen) -{ - my_wc_t wc; - int res; - int plane; - uchar *de = dst + dstlen; - const uchar *se = src + srclen; - MY_UNICASE_INFO **uni_plane= cs->caseinfo; - - while( src < se && dst < de ) - { - if ((res=my_ucs2_uni(cs,&wc, src, se))<0) - { - break; - } - src+=res; - srclen-=res; - - plane=(wc>>8) & 0xFF; - wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc; - - if ((res=my_uni_ucs2(cs,wc,dst,de)) <0) - { - break; - } - dst+=res; - } - if (dst < de) - cs->cset->fill(cs, (char*) dst, (size_t) (de - dst), ' '); - return dstlen; -} - - static uint my_ismbchar_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *b __attribute__((unused)), const char *e __attribute__((unused))) @@ -410,899 +3135,6 @@ static uint my_mbcharlen_ucs2(CHARSET_INFO *cs __attribute__((unused)) , } -static int my_vsnprintf_ucs2(char *dst, size_t n, const char* fmt, va_list ap) -{ - char *start=dst, *end=dst+n-1; - for (; *fmt ; fmt++) - { - if (fmt[0] != '%') - { - if (dst == end) /* End of buffer */ - break; - - *dst++='\0'; *dst++= *fmt; /* Copy ordinary char */ - continue; - } - - fmt++; - - /* Skip if max size is used (to be compatible with printf) */ - while ( (*fmt>='0' && *fmt<='9') || *fmt == '.' || *fmt == '-') - fmt++; - - if (*fmt == 'l') - fmt++; - - if (*fmt == 's') /* String parameter */ - { - reg2 char *par = va_arg(ap, char *); - size_t plen; - size_t left_len = (size_t)(end-dst); - if (!par) par = (char*)"(null)"; - plen= strlen(par); - if (left_len <= plen*2) - plen = left_len/2 - 1; - - for ( ; plen ; plen--, dst+=2, par++) - { - dst[0]='\0'; - dst[1]=par[0]; - } - continue; - } - else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */ - { - register int iarg; - char nbuf[16]; - char *pbuf=nbuf; - - if ((size_t) (end-dst) < 32) - break; - iarg = va_arg(ap, int); - if (*fmt == 'd') - int10_to_str((long) iarg, nbuf, -10); - else - int10_to_str((long) (uint) iarg,nbuf,10); - - for (; pbuf[0]; pbuf++) - { - *dst++='\0'; - *dst++=*pbuf; - } - continue; - } - - /* We come here on '%%', unknown code or too long parameter */ - if (dst == end) - break; - *dst++='\0'; - *dst++='%'; /* % used as % or unknown code */ - } - - DBUG_ASSERT(dst <= end); - *dst='\0'; /* End of errmessage */ - return (size_t) (dst - start); -} - -static size_t my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char* to, size_t n, const char* fmt, ...) -{ - va_list args; - va_start(args,fmt); - return my_vsnprintf_ucs2(to, n, fmt, args); -} - - -long my_strntol_ucs2(CHARSET_INFO *cs, - const char *nptr, size_t l, int base, - char **endptr, int *err) -{ - int negative=0; - int overflow; - int cnv; - my_wc_t wc; - register unsigned int cutlim; - register uint32 cutoff; - register uint32 res; - register const uchar *s= (const uchar*) nptr; - register const uchar *e= (const uchar*) nptr+l; - const uchar *save; - - *err= 0; - do - { - if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) - { - switch (wc) - { - case ' ' : break; - case '\t': break; - case '-' : negative= !negative; break; - case '+' : break; - default : goto bs; - } - } - else /* No more characters or bad multibyte sequence */ - { - if (endptr !=NULL ) - *endptr = (char*)s; - err[0] = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM; - return 0; - } - s+=cnv; - } while (1); - -bs: - -#ifdef NOT_USED - if (base <= 0 || base == 1 || base > 36) - base = 10; -#endif - - overflow = 0; - res = 0; - save = s; - cutoff = ((uint32)~0L) / (uint32) base; - cutlim = (uint) (((uint32)~0L) % (uint32) base); - - do { - if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) - { - s+=cnv; - if ( wc>='0' && wc<='9') - wc -= '0'; - else if ( wc>='A' && wc<='Z') - wc = wc - 'A' + 10; - else if ( wc>='a' && wc<='z') - wc = wc - 'a' + 10; - else - break; - if ((int)wc >= base) - break; - if (res > cutoff || (res == cutoff && wc > cutlim)) - overflow = 1; - else - { - res *= (uint32) base; - res += wc; - } - } - else if (cnv==MY_CS_ILSEQ) - { - if (endptr !=NULL ) - *endptr = (char*)s; - err[0]=EILSEQ; - return 0; - } - else - { - /* No more characters */ - break; - } - } while(1); - - if (endptr != NULL) - *endptr = (char *) s; - - if (s == save) - { - err[0]=EDOM; - return 0L; - } - - if (negative) - { - if (res > (uint32) INT_MIN32) - overflow = 1; - } - else if (res > INT_MAX32) - overflow = 1; - - if (overflow) - { - err[0]=ERANGE; - return negative ? INT_MIN32 : INT_MAX32; - } - - return (negative ? -((long) res) : (long) res); -} - - -ulong my_strntoul_ucs2(CHARSET_INFO *cs, - const char *nptr, size_t l, int base, - char **endptr, int *err) -{ - int negative=0; - int overflow; - int cnv; - my_wc_t wc; - register unsigned int cutlim; - register uint32 cutoff; - register uint32 res; - register const uchar *s= (const uchar*) nptr; - register const uchar *e= (const uchar*) nptr+l; - const uchar *save; - - *err= 0; - do - { - if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) - { - switch (wc) - { - case ' ' : break; - case '\t': break; - case '-' : negative= !negative; break; - case '+' : break; - default : goto bs; - } - } - else /* No more characters or bad multibyte sequence */ - { - if (endptr !=NULL ) - *endptr = (char*)s; - err[0] = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM; - return 0; - } - s+=cnv; - } while (1); - -bs: - -#ifdef NOT_USED - if (base <= 0 || base == 1 || base > 36) - base = 10; -#endif - - overflow = 0; - res = 0; - save = s; - cutoff = ((uint32)~0L) / (uint32) base; - cutlim = (uint) (((uint32)~0L) % (uint32) base); - - do - { - if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) - { - s+=cnv; - if ( wc>='0' && wc<='9') - wc -= '0'; - else if ( wc>='A' && wc<='Z') - wc = wc - 'A' + 10; - else if ( wc>='a' && wc<='z') - wc = wc - 'a' + 10; - else - break; - if ((int)wc >= base) - break; - if (res > cutoff || (res == cutoff && wc > cutlim)) - overflow = 1; - else - { - res *= (uint32) base; - res += wc; - } - } - else if (cnv==MY_CS_ILSEQ) - { - if (endptr !=NULL ) - *endptr = (char*)s; - err[0]=EILSEQ; - return 0; - } - else - { - /* No more characters */ - break; - } - } while(1); - - if (endptr != NULL) - *endptr = (char *) s; - - if (s == save) - { - err[0]=EDOM; - return 0L; - } - - if (overflow) - { - err[0]=(ERANGE); - return (~(uint32) 0); - } - - return (negative ? -((long) res) : (long) res); -} - - - -longlong my_strntoll_ucs2(CHARSET_INFO *cs, - const char *nptr, size_t l, int base, - char **endptr, int *err) -{ - int negative=0; - int overflow; - int cnv; - my_wc_t wc; - register ulonglong cutoff; - register unsigned int cutlim; - register ulonglong res; - register const uchar *s= (const uchar*) nptr; - register const uchar *e= (const uchar*) nptr+l; - const uchar *save; - - *err= 0; - do - { - if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) - { - switch (wc) - { - case ' ' : break; - case '\t': break; - case '-' : negative= !negative; break; - case '+' : break; - default : goto bs; - } - } - else /* No more characters or bad multibyte sequence */ - { - if (endptr !=NULL ) - *endptr = (char*)s; - err[0] = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM; - return 0; - } - s+=cnv; - } while (1); - -bs: - -#ifdef NOT_USED - if (base <= 0 || base == 1 || base > 36) - base = 10; -#endif - - overflow = 0; - res = 0; - save = s; - cutoff = (~(ulonglong) 0) / (unsigned long int) base; - cutlim = (uint) ((~(ulonglong) 0) % (unsigned long int) base); - - do { - if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) - { - s+=cnv; - if ( wc>='0' && wc<='9') - wc -= '0'; - else if ( wc>='A' && wc<='Z') - wc = wc - 'A' + 10; - else if ( wc>='a' && wc<='z') - wc = wc - 'a' + 10; - else - break; - if ((int)wc >= base) - break; - if (res > cutoff || (res == cutoff && wc > cutlim)) - overflow = 1; - else - { - res *= (ulonglong) base; - res += wc; - } - } - else if (cnv==MY_CS_ILSEQ) - { - if (endptr !=NULL ) - *endptr = (char*)s; - err[0]=EILSEQ; - return 0; - } - else - { - /* No more characters */ - break; - } - } while(1); - - if (endptr != NULL) - *endptr = (char *) s; - - if (s == save) - { - err[0]=EDOM; - return 0L; - } - - if (negative) - { - if (res > (ulonglong) LONGLONG_MIN) - overflow = 1; - } - else if (res > (ulonglong) LONGLONG_MAX) - overflow = 1; - - if (overflow) - { - err[0]=ERANGE; - return negative ? LONGLONG_MIN : LONGLONG_MAX; - } - - return (negative ? -((longlong)res) : (longlong)res); -} - - - - -ulonglong my_strntoull_ucs2(CHARSET_INFO *cs, - const char *nptr, size_t l, int base, - char **endptr, int *err) -{ - int negative=0; - int overflow; - int cnv; - my_wc_t wc; - register ulonglong cutoff; - register unsigned int cutlim; - register ulonglong res; - register const uchar *s= (const uchar*) nptr; - register const uchar *e= (const uchar*) nptr+l; - const uchar *save; - - *err= 0; - do - { - if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) - { - switch (wc) - { - case ' ' : break; - case '\t': break; - case '-' : negative= !negative; break; - case '+' : break; - default : goto bs; - } - } - else /* No more characters or bad multibyte sequence */ - { - if (endptr !=NULL ) - *endptr = (char*)s; - err[0]= (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM; - return 0; - } - s+=cnv; - } while (1); - -bs: - -#ifdef NOT_USED - if (base <= 0 || base == 1 || base > 36) - base = 10; -#endif - - overflow = 0; - res = 0; - save = s; - cutoff = (~(ulonglong) 0) / (unsigned long int) base; - cutlim = (uint) ((~(ulonglong) 0) % (unsigned long int) base); - - do - { - if ((cnv=cs->cset->mb_wc(cs,&wc,s,e))>0) - { - s+=cnv; - if ( wc>='0' && wc<='9') - wc -= '0'; - else if ( wc>='A' && wc<='Z') - wc = wc - 'A' + 10; - else if ( wc>='a' && wc<='z') - wc = wc - 'a' + 10; - else - break; - if ((int)wc >= base) - break; - if (res > cutoff || (res == cutoff && wc > cutlim)) - overflow = 1; - else - { - res *= (ulonglong) base; - res += wc; - } - } - else if (cnv==MY_CS_ILSEQ) - { - if (endptr !=NULL ) - *endptr = (char*)s; - err[0]= EILSEQ; - return 0; - } - else - { - /* No more characters */ - break; - } - } while(1); - - if (endptr != NULL) - *endptr = (char *) s; - - if (s == save) - { - err[0]= EDOM; - return 0L; - } - - if (overflow) - { - err[0]= ERANGE; - return (~(ulonglong) 0); - } - - return (negative ? -((longlong) res) : (longlong) res); -} - - -double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *nptr, size_t length, - char **endptr, int *err) -{ - char buf[256]; - double res; - register char *b=buf; - register const uchar *s= (const uchar*) nptr; - const uchar *end; - my_wc_t wc; - int cnv; - - *err= 0; - /* Cut too long strings */ - if (length >= sizeof(buf)) - length= sizeof(buf)-1; - end= s+length; - - while ((cnv=cs->cset->mb_wc(cs,&wc,s,end)) > 0) - { - s+=cnv; - if (wc > (int) (uchar) 'e' || !wc) - break; /* Can't be part of double */ - *b++= (char) wc; - } - - *endptr= b; - res= my_strtod(buf, endptr, err); - *endptr= nptr + (size_t) (*endptr- buf); - return res; -} - - -ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *nptr, size_t length, - int unsign_fl, - char **endptr, int *err) -{ - char buf[256], *b= buf; - ulonglong res; - const uchar *end, *s= (const uchar*) nptr; - my_wc_t wc; - int cnv; - - /* Cut too long strings */ - if (length >= sizeof(buf)) - length= sizeof(buf)-1; - end= s + length; - - while ((cnv= cs->cset->mb_wc(cs,&wc,s,end)) > 0) - { - s+= cnv; - if (wc > (int) (uchar) 'e' || !wc) - break; /* Can't be a number part */ - *b++= (char) wc; - } - - res= my_strntoull10rnd_8bit(cs, buf, b - buf, unsign_fl, endptr, err); - *endptr= (char*) nptr + 2 * (size_t) (*endptr- buf); - return res; -} - - -/* - This is a fast version optimized for the case of radix 10 / -10 -*/ - -size_t my_l10tostr_ucs2(CHARSET_INFO *cs, - char *dst, size_t len, int radix, long int val) -{ - char buffer[66]; - register char *p, *db, *de; - long int new_val; - int sl=0; - unsigned long int uval = (unsigned long int) val; - - p = &buffer[sizeof(buffer)-1]; - *p='\0'; - - if (radix < 0) - { - if (val < 0) - { - sl = 1; - /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */ - uval = (unsigned long int)0 - uval; - } - } - - new_val = (long) (uval / 10); - *--p = '0'+ (char) (uval - (unsigned long) new_val * 10); - val = new_val; - - while (val != 0) - { - new_val=val/10; - *--p = '0' + (char) (val-new_val*10); - val= new_val; - } - - if (sl) - { - *--p='-'; - } - - for ( db=dst, de=dst+len ; (dstcset->wc_mb(cs,(my_wc_t)p[0],(uchar*) dst, (uchar*) de); - if (cnvres>0) - dst+=cnvres; - else - break; - } - return (int) (dst-db); -} - - -size_t my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *dst, size_t len, int radix, longlong val) -{ - char buffer[65]; - register char *p, *db, *de; - long long_val; - int sl=0; - ulonglong uval= (ulonglong) val; - - if (radix < 0) - { - if (val < 0) - { - sl=1; - /* Avoid integer overflow in (-val) for LONGLONG_MIN (BUG#31799). */ - uval = (ulonglong)0 - uval; - } - } - - p = &buffer[sizeof(buffer)-1]; - *p='\0'; - - if (uval == 0) - { - *--p='0'; - goto cnv; - } - - while (uval > (ulonglong) LONG_MAX) - { - ulonglong quo= uval/(uint) 10; - uint rem= (uint) (uval- quo* (uint) 10); - *--p = '0' + rem; - uval= quo; - } - - long_val= (long) uval; - while (long_val != 0) - { - long quo= long_val/10; - *--p = (char) ('0' + (long_val - quo*10)); - long_val= quo; - } - -cnv: - if (sl) - { - *--p='-'; - } - - for ( db=dst, de=dst+len ; (dstcset->wc_mb(cs, (my_wc_t) p[0], (uchar*) dst, (uchar*) de); - if (cnvres>0) - dst+=cnvres; - else - break; - } - return (int) (dst-db); -} - - -#undef ULONGLONG_MAX -#define ULONGLONG_MAX (~(ulonglong) 0) -#define MAX_NEGATIVE_NUMBER ((ulonglong) LL(0x8000000000000000)) -#define INIT_CNT 9 -#define LFACTOR ULL(1000000000) -#define LFACTOR1 ULL(10000000000) -#define LFACTOR2 ULL(100000000000) - -static unsigned long lfactor[9]= -{ - 1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L -}; - - -longlong my_strtoll10_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *nptr, char **endptr, int *error) -{ - const char *s, *end, *start, *n_end, *true_end; - uchar c; - unsigned long i, j, k; - ulonglong li; - int negative; - ulong cutoff, cutoff2, cutoff3; - - s= nptr; - /* If fixed length string */ - if (endptr) - { - /* Make sure string length is even */ - end= s + ((*endptr - s) / 2) * 2; - while (s < end && !s[0] && (s[1] == ' ' || s[1] == '\t')) - s+= 2; - if (s == end) - goto no_conv; - } - else - { - /* We don't support null terminated strings in UCS2 */ - goto no_conv; - } - - /* Check for a sign. */ - negative= 0; - if (!s[0] && s[1] == '-') - { - *error= -1; /* Mark as negative number */ - negative= 1; - s+= 2; - if (s == end) - goto no_conv; - cutoff= MAX_NEGATIVE_NUMBER / LFACTOR2; - cutoff2= (MAX_NEGATIVE_NUMBER % LFACTOR2) / 100; - cutoff3= MAX_NEGATIVE_NUMBER % 100; - } - else - { - *error= 0; - if (!s[0] && s[1] == '+') - { - s+= 2; - if (s == end) - goto no_conv; - } - cutoff= ULONGLONG_MAX / LFACTOR2; - cutoff2= ULONGLONG_MAX % LFACTOR2 / 100; - cutoff3= ULONGLONG_MAX % 100; - } - - /* Handle case where we have a lot of pre-zero */ - if (!s[0] && s[1] == '0') - { - i= 0; - do - { - s+= 2; - if (s == end) - goto end_i; /* Return 0 */ - } - while (!s[0] && s[1] == '0'); - n_end= s + 2 * INIT_CNT; - } - else - { - /* Read first digit to check that it's a valid number */ - if (s[0] || (c= (s[1]-'0')) > 9) - goto no_conv; - i= c; - s+= 2; - n_end= s + 2 * (INIT_CNT-1); - } - - /* Handle first 9 digits and store them in i */ - if (n_end > end) - n_end= end; - for (; s != n_end ; s+= 2) - { - if (s[0] || (c= (s[1]-'0')) > 9) - goto end_i; - i= i*10+c; - } - if (s == end) - goto end_i; - - /* Handle next 9 digits and store them in j */ - j= 0; - start= s; /* Used to know how much to shift i */ - n_end= true_end= s + 2 * INIT_CNT; - if (n_end > end) - n_end= end; - do - { - if (s[0] || (c= (s[1]-'0')) > 9) - goto end_i_and_j; - j= j*10+c; - s+= 2; - } while (s != n_end); - if (s == end) - { - if (s != true_end) - goto end_i_and_j; - goto end3; - } - if (s[0] || (c= (s[1]-'0')) > 9) - goto end3; - - /* Handle the next 1 or 2 digits and store them in k */ - k=c; - s+= 2; - if (s == end || s[0] || (c= (s[1]-'0')) > 9) - goto end4; - k= k*10+c; - s+= 2; - *endptr= (char*) s; - - /* number string should have ended here */ - if (s != end && !s[0] && (c= (s[1]-'0')) <= 9) - goto overflow; - - /* Check that we didn't get an overflow with the last digit */ - if (i > cutoff || (i == cutoff && ((j > cutoff2 || j == cutoff2) && - k > cutoff3))) - goto overflow; - li=i*LFACTOR2+ (ulonglong) j*100 + k; - return (longlong) li; - -overflow: /* *endptr is set here */ - *error= MY_ERRNO_ERANGE; - return negative ? LONGLONG_MIN : (longlong) ULONGLONG_MAX; - -end_i: - *endptr= (char*) s; - return (negative ? ((longlong) -(long) i) : (longlong) i); - -end_i_and_j: - li= (ulonglong) i * lfactor[(size_t) (s-start) / 2] + j; - *endptr= (char*) s; - return (negative ? -((longlong) li) : (longlong) li); - -end3: - li=(ulonglong) i*LFACTOR+ (ulonglong) j; - *endptr= (char*) s; - return (negative ? -((longlong) li) : (longlong) li); - -end4: - li=(ulonglong) i*LFACTOR1+ (ulonglong) j * 10 + k; - *endptr= (char*) s; - if (negative) - { - if (li > MAX_NEGATIVE_NUMBER) - goto overflow; - return -((longlong) li); - } - return (longlong) li; - -no_conv: - /* There was no number to convert. */ - *error= MY_ERRNO_EDOM; - *endptr= (char *) nptr; - return 0; -} - - static size_t my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e) @@ -1335,25 +3167,6 @@ size_t my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), } -static -void my_fill_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *s, size_t l, int fill) -{ - for ( ; l >= 2; s[0]= 0, s[1]= fill, s+=2, l-=2); -} - - -static -size_t my_lengthsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, size_t length) -{ - const char *end= ptr+length; - while (end > ptr+1 && end[-1] == ' ' && end[-2] == '\0') - end-=2; - return (size_t) (end-ptr); -} - - static int my_wildcmp_ucs2_ci(CHARSET_INFO *cs, const char *str,const char *str_end, @@ -1456,29 +3269,6 @@ static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), } -static -int my_strcasecmp_ucs2_bin(CHARSET_INFO *cs, const char *s, const char *t) -{ - size_t s_len= strlen(s); - size_t t_len= strlen(t); - size_t len = (s_len > t_len) ? s_len : t_len; - return my_strncasecmp_ucs2(cs, s, t, len); -} - - -static -size_t my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar *dst, size_t dstlen, - const uchar *src, size_t srclen) -{ - if (dst != src) - memcpy(dst,src,srclen= min(dstlen,srclen)); - if (dstlen > srclen) - cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' '); - return dstlen; -} - - static void my_hash_sort_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), const uchar *key, size_t len,ulong *nr1, ulong *nr2) @@ -1613,38 +3403,16 @@ fill_max_and_min: -size_t my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *end, int sequence_type) -{ - const char *str0= str; - end--; /* for easier loop condition, because of two bytes per character */ - - switch (sequence_type) - { - case MY_SEQ_SPACES: - for ( ; str < end; str+= 2) - { - if (str[0] != '\0' || str[1] != ' ') - break; - } - return (size_t) (str - str0); - default: - return 0; - } -} - - - static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler = { NULL, /* init */ my_strnncoll_ucs2, my_strnncollsp_ucs2, - my_strnxfrm_ucs2, + my_strnxfrm_unicode, my_strnxfrmlen_simple, my_like_range_ucs2, my_wildcmp_ucs2_ci, - my_strcasecmp_ucs2, + my_strcasecmp_mb2_or_mb4, my_instr_mb, my_hash_sort_ucs2, my_propagate_simple @@ -1656,11 +3424,11 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = NULL, /* init */ my_strnncoll_ucs2_bin, my_strnncollsp_ucs2_bin, - my_strnxfrm_ucs2_bin, + my_strnxfrm_unicode, my_strnxfrmlen_simple, my_like_range_ucs2, my_wildcmp_ucs2_bin, - my_strcasecmp_ucs2_bin, + my_strcasecmp_mb2_or_mb4, my_instr_mb, my_hash_sort_ucs2_bin, my_propagate_simple @@ -1675,27 +3443,27 @@ MY_CHARSET_HANDLER my_charset_ucs2_handler= my_numchars_ucs2, my_charpos_ucs2, my_well_formed_len_ucs2, - my_lengthsp_ucs2, + my_lengthsp_mb2, my_numcells_mb, my_ucs2_uni, /* mb_wc */ my_uni_ucs2, /* wc_mb */ my_mb_ctype_mb, - my_caseup_str_ucs2, - my_casedn_str_ucs2, + my_caseup_str_mb2_or_mb4, + my_casedn_str_mb2_or_mb4, my_caseup_ucs2, my_casedn_ucs2, - my_snprintf_ucs2, - my_l10tostr_ucs2, - my_ll10tostr_ucs2, - my_fill_ucs2, - my_strntol_ucs2, - my_strntoul_ucs2, - my_strntoll_ucs2, - my_strntoull_ucs2, - my_strntod_ucs2, - my_strtoll10_ucs2, - my_strntoull10rnd_ucs2, - my_scan_ucs2 + my_snprintf_mb2, + my_l10tostr_mb2_or_mb4, + my_ll10tostr_mb2_or_mb4, + my_fill_mb2, + my_strntol_mb2_or_mb4, + my_strntoul_mb2_or_mb4, + my_strntoll_mb2_or_mb4, + my_strntoull_mb2_or_mb4, + my_strntod_mb2_or_mb4, + my_strtoll10_mb2, + my_strntoull10rnd_mb2_or_mb4, + my_scan_mb2 }; @@ -1764,4 +3532,4 @@ CHARSET_INFO my_charset_ucs2_bin= }; -#endif +#endif /* HAVE_CHARSET_ucs2 */ diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 91f633e45ce..7de5cdd00ee 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -27,6 +27,16 @@ #define EILSEQ ENOENT #endif + +#define MY_UTF8MB3_GENERAL_CI MY_UTF8MB3 "_general_ci" +#define MY_UTF8MB3_GENERAL_CS MY_UTF8MB3 "_general_cs" +#define MY_UTF8MB3_BIN MY_UTF8MB3 "_bin" +#define MY_UTF8MB4_GENERAL_CI MY_UTF8MB4 "_general_ci" +#define MY_UTF8MB4_GENERAL_CS MY_UTF8MB4 "_general_cs" +#define MY_UTF8MB4_BIN MY_UTF8MB4 "_bin" + + + #ifndef HAVE_CHARSET_utf8 #define HAVE_CHARSET_utf8 #endif @@ -39,6 +49,14 @@ #define HAVE_UNIDATA #endif +#ifdef HAVE_CHARSET_utf16 +#define HAVE_UNIDATA +#endif + +#ifdef HAVE_CHARSET_utf32 +#define HAVE_UNIDATA +#endif + #ifdef HAVE_UNIDATA #include "my_uctype.h" @@ -1702,6 +1720,24 @@ MY_UNICASE_INFO *my_unicase_turkish[256]= }; +#define REPLACEMENT_CHAR 0xFFFD; + + +static inline void +my_tosort_unicode(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256) + { + if (uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].sort; + } + else + { + *wc= REPLACEMENT_CHAR; + } +} + /* ** Compare string against string with wildcard @@ -1712,13 +1748,14 @@ MY_UNICASE_INFO *my_unicase_turkish[256]= ** 1 if matched with wildcard */ -int my_wildcmp_unicode(CHARSET_INFO *cs, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many, - MY_UNICASE_INFO **weights) +int +my_wildcmp_unicode(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many, + MY_UNICASE_INFO **weights) { - int result= -1; /* Not found, using wildcards */ + int result= -1; /* Not found, using wildcards */ my_wc_t s_wc, w_wc; int scan, plane; int (*mb_wc)(struct charset_info_st *, my_wc_t *, @@ -1734,14 +1771,14 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, (const uchar*)wildend)) <= 0) return 1; - if (w_wc == (my_wc_t)w_many) + if (w_wc == (my_wc_t) w_many) { - result= 1; /* Found an anchor char */ + result= 1; /* Found an anchor char */ break; } wildstr+= scan; - if (w_wc == (my_wc_t)escape && wildstr < wildend) + if (w_wc == (my_wc_t) escape && wildstr < wildend) { if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, (const uchar*)wildend)) <= 0) @@ -1755,29 +1792,27 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, return 1; str+= scan; - if (!escaped && w_wc == (my_wc_t)w_one) + if (!escaped && w_wc == (my_wc_t) w_one) { - result= 1; /* Found an anchor char */ + result= 1; /* Found an anchor char */ } else { if (weights) { - plane=(s_wc>>8) & 0xFF; - s_wc = weights[plane] ? weights[plane][s_wc & 0xFF].sort : s_wc; - plane=(w_wc>>8) & 0xFF; - w_wc = weights[plane] ? weights[plane][w_wc & 0xFF].sort : w_wc; + my_tosort_unicode(weights, &s_wc); + my_tosort_unicode(weights, &w_wc); } if (s_wc != w_wc) - return 1; /* No match */ + return 1; /* No match */ } if (wildstr == wildend) - return (str != str_end); /* Match if both are at end */ + return (str != str_end); /* Match if both are at end */ } - if (w_wc == (my_wc_t)w_many) - { /* Found w_many */ + if (w_wc == (my_wc_t) w_many) + { /* Found w_many */ /* Remove any '%' and '_' from the wild search string */ for ( ; wildstr != wildend ; ) @@ -1786,29 +1821,29 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, (const uchar*)wildend)) <= 0) return 1; - if (w_wc == (my_wc_t)w_many) - { - wildstr+= scan; - continue; - } - - if (w_wc == (my_wc_t)w_one) - { - wildstr+= scan; + if (w_wc == (my_wc_t)w_many) + { + wildstr+= scan; + continue; + } + + if (w_wc == (my_wc_t)w_one) + { + wildstr+= scan; if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, (const uchar*)str_end)) <=0) return 1; str+= scan; - continue; - } - break; /* Not a wild character */ + continue; + } + break; /* Not a wild character */ } if (wildstr == wildend) - return 0; /* Ok if w_many is last */ + return 0; /* Ok if w_many is last */ if (str == str_end) - return -1; + return -1; if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, (const uchar*)wildend)) <=0) @@ -1836,10 +1871,8 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, return 1; if (weights) { - plane=(s_wc>>8) & 0xFF; - s_wc = weights[plane] ? weights[plane][s_wc & 0xFF].sort : s_wc; - plane=(w_wc>>8) & 0xFF; - w_wc = weights[plane] ? weights[plane][w_wc & 0xFF].sort : w_wc; + my_tosort_unicode(weights, &s_wc); + my_tosort_unicode(weights, &w_wc); } if (s_wc == w_wc) @@ -1861,8 +1894,53 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, return (str != str_end ? 1 : 0); } -#endif +/* + This function is shared between utf8mb3/utf8mb4/ucs2/utf16/utf32 +*/ +size_t +my_strnxfrm_unicode(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) +{ + my_wc_t wc; + int res; + uchar *de= dst + dstlen; + uchar *de_beg= de - 1; + const uchar *se = src + srclen; + MY_UNICASE_INFO **uni_plane= (cs->state & MY_CS_BINSORT) ? + NULL : cs->caseinfo; + LINT_INIT(wc); + DBUG_ASSERT(src); + + while (dst < de_beg) + { + if ((res= cs->cset->mb_wc(cs,&wc, src, se)) <= 0) + break; + src+=res; + + if (uni_plane) + my_tosort_unicode(uni_plane, &wc); + + *dst++= (uchar) (wc >> 8); + if (dst < de) + *dst++= (uchar) (wc & 0xFF); + } + + while (dst < de_beg) /* Fill the tail with keys for space character */ + { + *dst++= 0x00; + *dst++= 0x20; + } + + if (dst < de) /* Clear the last byte, if "dstlen" was an odd number */ + *dst= 0x00; + + return dstlen; +} + + +#endif /* HAVE_UNIDATA */ #ifdef HAVE_CHARSET_utf8 @@ -2569,44 +2647,6 @@ size_t my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), } -static size_t my_strnxfrm_utf8(CHARSET_INFO *cs, - uchar *dst, size_t dstlen, - const uchar *src, size_t srclen) -{ - my_wc_t wc; - int res; - int plane; - uchar *de= dst + dstlen; - uchar *de_beg= de - 1; - const uchar *se = src + srclen; - MY_UNICASE_INFO **uni_plane= cs->caseinfo; - - while (dst < de_beg) - { - if ((res=my_utf8_uni(cs,&wc, src, se)) <= 0) - break; - src+=res; - - plane=(wc>>8) & 0xFF; - wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc; - - *dst++= (uchar)(wc >> 8); - *dst++= (uchar)(wc & 0xFF); - - } - - while (dst < de_beg) /* Fill the tail with keys for space character */ - { - *dst++= 0x00; - *dst++= 0x20; - } - - if (dst < de) /* Clear the last byte, if "dstlen" was an odd number */ - *dst= 0x00; - - return dstlen; -} - static uint my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e) { my_wc_t wc; @@ -2642,7 +2682,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = NULL, /* init */ my_strnncoll_utf8, my_strnncollsp_utf8, - my_strnxfrm_utf8, + my_strnxfrm_unicode, my_strnxfrmlen_utf8, my_like_range_mb, my_wildcmp_utf8, @@ -2891,7 +2931,7 @@ static MY_COLLATION_HANDLER my_collation_cs_handler = NULL, /* init */ my_strnncoll_utf8_cs, my_strnncollsp_utf8_cs, - my_strnxfrm_utf8, + my_strnxfrm_unicode, my_strnxfrmlen_utf8, my_like_range_simple, my_wildcmp_mb, @@ -4154,7 +4194,7 @@ static MY_COLLATION_HANDLER my_collation_filename_handler = NULL, /* init */ my_strnncoll_utf8, my_strnncollsp_utf8, - my_strnxfrm_utf8, + my_strnxfrm_unicode, my_strnxfrmlen_utf8, my_like_range_mb, my_wildcmp_utf8, @@ -4284,3 +4324,859 @@ int main() +#ifdef HAVE_CHARSET_utf8mb4 + +/* + We consider bytes with code more than 127 as a letter. + This garantees that word boundaries work fine with regular + expressions. Note, there is no need to mark byte 255 as a + letter, it is illegal byte in UTF8. +*/ +static uchar ctype_utf8mb4[]= +{ + 0, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 72, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 132,132,132,132,132,132,132,132,132,132, 16, 16, 16, 16, 16, 16, + 16,129,129,129,129,129,129, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 16, 16, 16, + 16,130,130,130,130,130,130, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 32, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0 +}; + + +static uchar to_lower_utf8mb4[]= +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, + 112,113,114,115,116,117,118,119,120,121,122, 91, 92, 93, 94, 95, + 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, + 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, + 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, + 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, + 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, + 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, + 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, + 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, + 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, + 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 +}; + + +static uchar to_upper_utf8mb4[]= +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,123,124,125,126,127, + 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, + 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, + 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, + 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, + 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, + 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, + 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, + 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 +}; + + +static inline int +bincmp_utf8mb4(const uchar *s, const uchar *se, + const uchar *t, const uchar *te) +{ + int slen= (int) (se - s), tlen= (int) (te - t); + int len= min(slen, tlen); + int cmp= memcmp(s, t, len); + return cmp ? cmp : slen - tlen; +} + + +static int +my_mb_wc_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t * pwc, const uchar *s, const uchar *e) +{ + uchar c; + + if (s >= e) + return MY_CS_TOOSMALL; + + c= s[0]; + if (c < 0x80) + { + *pwc= c; + return 1; + } + else if (c < 0xc2) + return MY_CS_ILSEQ; + else if (c < 0xe0) + { + if (s + 2 > e) /* We need 2 characters */ + return MY_CS_TOOSMALL2; + + if (!((s[1] ^ 0x80) < 0x40)) + return MY_CS_ILSEQ; + + *pwc= ((my_wc_t) (c & 0x1f) << 6) | (my_wc_t) (s[1] ^ 0x80); + return 2; + } + else if (c < 0xf0) + { + if (s + 3 > e) /* We need 3 characters */ + return MY_CS_TOOSMALL3; + + if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && + (c >= 0xe1 || s[1] >= 0xa0))) + return MY_CS_ILSEQ; + + *pwc= ((my_wc_t) (c & 0x0f) << 12) | + ((my_wc_t) (s[1] ^ 0x80) << 6) | + (my_wc_t) (s[2] ^ 0x80); + return 3; + } + else if (c < 0xf5) + { + if (s + 4 > e) /* We need 4 characters */ + return MY_CS_TOOSMALL4; + + /* + UTF-8 quick four-byte mask: + 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + Encoding allows to encode U+00010000..U+001FFFFF + + The maximum character defined in the Unicode standard is U+0010FFFF. + Higher characters U+00110000..U+001FFFFF are not used. + + 11110000.10010000.10xxxxxx.10xxxxxx == F0.90.80.80 == U+00010000 (min) + 11110100.10001111.10111111.10111111 == F4.8F.BF.BF == U+0010FFFF (max) + + Valid codes: + [F0][90..BF][80..BF][80..BF] + [F1][80..BF][80..BF][80..BF] + [F2][80..BF][80..BF][80..BF] + [F3][80..BF][80..BF][80..BF] + [F4][80..8F][80..BF][80..BF] + */ + + if (!((s[1] ^ 0x80) < 0x40 && + (s[2] ^ 0x80) < 0x40 && + (s[3] ^ 0x80) < 0x40 && + (c >= 0xf1 || s[1] >= 0x90) && + (c <= 0xf3 || s[1] <= 0x8F))) + return MY_CS_ILSEQ; + *pwc = ((my_wc_t) (c & 0x07) << 18) | + ((my_wc_t) (s[1] ^ 0x80) << 12) | + ((my_wc_t) (s[2] ^ 0x80) << 6) | + (my_wc_t) (s[3] ^ 0x80); + return 4; + } + return MY_CS_ILSEQ; +} + + +/* + The same as above, but without range check + for example, for a null-terminated string +*/ +static int +my_mb_wc_utf8mb4_no_range(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t *pwc, const uchar *s) +{ + uchar c; + + c= s[0]; + if (c < 0x80) + { + *pwc = c; + return 1; + } + + if (c < 0xc2) + return MY_CS_ILSEQ; + + if (c < 0xe0) + { + if (!((s[1] ^ 0x80) < 0x40)) + return MY_CS_ILSEQ; + + *pwc = ((my_wc_t) (c & 0x1f) << 6) | (my_wc_t) (s[1] ^ 0x80); + return 2; + } + + if (c < 0xf0) + { + if (!((s[1] ^ 0x80) < 0x40 && + (s[2] ^ 0x80) < 0x40 && + (c >= 0xe1 || s[1] >= 0xa0))) + return MY_CS_ILSEQ; + *pwc= ((my_wc_t) (c & 0x0f) << 12) | + ((my_wc_t) (s[1] ^ 0x80) << 6) | + (my_wc_t) (s[2] ^ 0x80); + + return 3; + } + else if (c < 0xf5) + { + if (!((s[1] ^ 0x80) < 0x40 && + (s[2] ^ 0x80) < 0x40 && + (s[3] ^ 0x80) < 0x40 && + (c >= 0xf1 || s[1] >= 0x90) && + (c <= 0xf3 || s[1] <= 0x8F))) + return MY_CS_ILSEQ; + *pwc = ((my_wc_t) (c & 0x07) << 18) | + ((my_wc_t) (s[1] ^ 0x80) << 12) | + ((my_wc_t) (s[2] ^ 0x80) << 6) | + (my_wc_t) (s[3] ^ 0x80); + return 4; + } + return MY_CS_ILSEQ; +} + + +static int +my_wc_mb_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t wc, uchar *r, uchar *e) +{ + int count; + + if (r >= e) + return MY_CS_TOOSMALL; + + if (wc < 0x80) + count= 1; + else if (wc < 0x800) + count= 2; + else if (wc < 0x10000) + count= 3; + else if (wc < 0x200000) + count= 4; + else return MY_CS_ILUNI; + + if (r + count > e) + return MY_CS_TOOSMALLN(count); + + switch (count) { + /* Fall through all cases!!! */ + case 4: r[3] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x10000; + case 3: r[2] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x800; + case 2: r[1] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0xc0; + case 1: r[0] = (uchar) wc; + } + return count; +} + + +/* + The same as above, but without range check. +*/ +static int +my_wc_mb_utf8mb4_no_range(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t wc, uchar *r) +{ + int count; + + if (wc < 0x80) + count= 1; + else if (wc < 0x800) + count= 2; + else if (wc < 0x10000) + count= 3; + else if (wc < 0x200000) + count= 4; + else + return MY_CS_ILUNI; + + switch (count) + { + /* Fall through all cases!!! */ + case 4: r[3]= (uchar) (0x80 | (wc & 0x3f)); wc= wc >> 6; wc |= 0x10000; + case 3: r[2]= (uchar) (0x80 | (wc & 0x3f)); wc= wc >> 6; wc |= 0x800; + case 2: r[1]= (uchar) (0x80 | (wc & 0x3f)); wc= wc >> 6; wc |= 0xc0; + case 1: r[0]= (uchar) wc; + } + return count; +} + + +static inline void +my_tolower_utf8mb4(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256 && uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].tolower; +} + + +static inline void +my_toupper_utf8mb4(MY_UNICASE_INFO **uni_plane, my_wc_t *wc) +{ + int page= *wc >> 8; + if (page < 256 && uni_plane[page]) + *wc= uni_plane[page][*wc & 0xFF].toupper; +} + + +static size_t +my_caseup_utf8mb4(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst, size_t dstlen) +{ + my_wc_t wc; + int srcres, dstres; + char *srcend= src + srclen, *dstend= dst + dstlen, *dst0= dst; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + DBUG_ASSERT(src != dst || cs->caseup_multiply == 1); + + while ((src < srcend) && + (srcres= my_mb_wc_utf8mb4(cs, &wc, + (uchar *) src, (uchar*) srcend)) > 0) + { + my_toupper_utf8mb4(uni_plane, &wc); + if ((dstres= my_wc_mb_utf8mb4(cs, wc, (uchar*) dst, (uchar*) dstend)) <= 0) + break; + src+= srcres; + dst+= dstres; + } + return (size_t) (dst - dst0); +} + + +static inline void +my_hash_add(ulong *n1, ulong *n2, uint ch) +{ + n1[0]^= (((n1[0] & 63) + n2[0]) * (ch)) + (n1[0] << 8); + n2[0]+= 3; +} + + +static void +my_hash_sort_utf8mb4(CHARSET_INFO *cs, const uchar *s, size_t slen, + ulong *n1, ulong *n2) +{ + my_wc_t wc; + int res; + const uchar *e= s + slen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + + /* + Remove end space. We do this to be able to compare + 'A ' and 'A' as identical + */ + while (e > s && e[-1] == ' ') + e--; + + while ((res= my_mb_wc_utf8mb4(cs, &wc, (uchar*) s, (uchar*) e)) > 0) + { + my_tosort_unicode(uni_plane, &wc); + my_hash_add(n1, n2, (uint) (wc & 0xFF)); + my_hash_add(n1, n2, (uint) (wc >> 8) & 0xFF); + if (wc > 0xFFFF) + { + /* + Put the highest byte only if it is non-zero, + to make hash functions for utf8mb3 and utf8mb4 + compatible for BMP characters. + This is useful to keep order of records in + test results, e.g. for "SHOW GRANTS". + */ + my_hash_add(n1, n2, (uint) (wc >> 16) & 0xFF); + } + s+= res; + } +} + + +static size_t +my_caseup_str_utf8mb4(CHARSET_INFO *cs, char *src) +{ + my_wc_t wc; + int srcres, dstres; + char *dst= src, *dst0= src; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + DBUG_ASSERT(cs->caseup_multiply == 1); + + while (*src && + (srcres= my_mb_wc_utf8mb4_no_range(cs, &wc, (uchar *) src)) > 0) + { + my_toupper_utf8mb4(uni_plane, &wc); + if ((dstres= my_wc_mb_utf8mb4_no_range(cs, wc, (uchar*) dst)) <= 0) + break; + src+= srcres; + dst+= dstres; + } + *dst= '\0'; + return (size_t) (dst - dst0); +} + + +static size_t +my_casedn_utf8mb4(CHARSET_INFO *cs, + char *src, size_t srclen, + char *dst, size_t dstlen) +{ + my_wc_t wc; + int srcres, dstres; + char *srcend= src + srclen, *dstend= dst + dstlen, *dst0= dst; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + DBUG_ASSERT(src != dst || cs->casedn_multiply == 1); + + while ((src < srcend) && + (srcres= my_mb_wc_utf8mb4(cs, &wc, + (uchar*) src, (uchar*) srcend)) > 0) + { + my_tolower_utf8mb4(uni_plane, &wc); + if ((dstres= my_wc_mb_utf8mb4(cs, wc, (uchar*) dst, (uchar*) dstend)) <= 0) + break; + src+= srcres; + dst+= dstres; + } + return (size_t) (dst - dst0); +} + + +static size_t +my_casedn_str_utf8mb4(CHARSET_INFO *cs, char *src) +{ + my_wc_t wc; + int srcres, dstres; + char *dst= src, *dst0= src; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + DBUG_ASSERT(cs->casedn_multiply == 1); + + while (*src && + (srcres= my_mb_wc_utf8mb4_no_range(cs, &wc, (uchar *) src)) > 0) + { + my_tolower_utf8mb4(uni_plane, &wc); + if ((dstres= my_wc_mb_utf8mb4_no_range(cs, wc, (uchar*) dst)) <= 0) + break; + src+= srcres; + dst+= dstres; + } + + /* + In rare cases lower string can be shorter than + the original string, for example: + + "U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE" + (which is 0xC4B0 in utf8, i.e. two bytes) + + is converted into + + "U+0069 LATIN SMALL LETTER I" + (which is 0x69 in utf8, i.e. one byte) + + So, we need to put '\0' terminator after converting. + */ + + *dst= '\0'; + return (size_t) (dst - dst0); +} + + +static int +my_strnncoll_utf8mb4(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool t_is_prefix) +{ + my_wc_t s_wc,t_wc; + const uchar *se= s + slen; + const uchar *te= t + tlen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + + while ( s < se && t < te ) + { + int s_res= my_mb_wc_utf8mb4(cs, &s_wc, s, se); + int t_res= my_mb_wc_utf8mb4(cs, &t_wc, t, te); + + if ( s_res <= 0 || t_res <= 0 ) + { + /* Incorrect string, compare bytewise */ + return bincmp_utf8mb4(s, se, t, te); + } + + my_tosort_unicode(uni_plane, &s_wc); + my_tosort_unicode(uni_plane, &t_wc); + + if ( s_wc != t_wc ) + { + return s_wc > t_wc ? 1 : -1; + } + + s+= s_res; + t+= t_res; + } + return (int) (t_is_prefix ? (t - te) : ((se - s) - (te - t))); +} + + +/** + + Compare strings, discarding end space + + If one string is shorter as the other, then we space extend the other + so that the strings have equal length. + + This will ensure that the following things hold: + + "a" == "a " + "a\0" < "a" + "a\0" < "a " + + @param cs Character set pinter. + @param a First string to compare. + @param a_length Length of 'a'. + @param b Second string to compare. + @param b_length Length of 'b'. + @param diff_if_only_endspace_difference + Set to 1 if the strings should be regarded as different + if they only difference in end space + + @return Comparison result. + @retval Negative number, if a less than b. + @retval 0, if a is equal to b + @retval Positive number, if a > b +*/ + +static int +my_strnncollsp_utf8mb4(CHARSET_INFO *cs, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, + my_bool diff_if_only_endspace_difference) +{ + int res; + my_wc_t s_wc, t_wc; + const uchar *se= s + slen, *te= t + tlen; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + LINT_INIT(s_wc); + LINT_INIT(t_wc); + +#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE + diff_if_only_endspace_difference= FALSE; +#endif + + while ( s < se && t < te ) + { + int s_res= my_mb_wc_utf8mb4(cs, &s_wc, s, se); + int t_res= my_mb_wc_utf8mb4(cs, &t_wc, t, te); + + if ( s_res <= 0 || t_res <= 0 ) + { + /* Incorrect string, compare bytewise */ + return bincmp_utf8mb4(s, se, t, te); + } + + my_tosort_unicode(uni_plane, &s_wc); + my_tosort_unicode(uni_plane, &t_wc); + + if ( s_wc != t_wc ) + { + return s_wc > t_wc ? 1 : -1; + } + + s+=s_res; + t+=t_res; + } + + slen= (size_t) (se-s); + tlen= (size_t) (te-t); + res= 0; + + if (slen != tlen) + { + int swap= 1; + if (diff_if_only_endspace_difference) + res= 1; /* Assume 'a' is bigger */ + if (slen < tlen) + { + slen= tlen; + s= t; + se= te; + swap= -1; + res= -res; + } + /* + This following loop uses the fact that in UTF-8 + all multibyte characters are greater than space, + and all multibyte head characters are greater than + space. It means if we meet a character greater + than space, it always means that the longer string + is greater. So we can reuse the same loop from the + 8bit version, without having to process full multibute + sequences. + */ + for ( ; s < se; s++) + { + if (*s != ' ') + return (*s < ' ') ? -swap : swap; + } + } + return res; +} + + +/** + Compare 0-terminated UTF8 strings. + + @param cs character set handler + @param s First 0-terminated string to compare + @param t Second 0-terminated string to compare + + @return Comparison result. + @retval negative number if s < t + @retval positive number if s > t + @retval 0 is the strings are equal +*/ + +static int +my_strcasecmp_utf8mb4(CHARSET_INFO *cs, const char *s, const char *t) +{ + MY_UNICASE_INFO **uni_plane= cs->caseinfo; + while (s[0] && t[0]) + { + my_wc_t s_wc,t_wc; + + if ((uchar) s[0] < 128) + { + /* + s[0] is between 0 and 127. + It represents a single byte character. + Convert it into weight according to collation. + */ + s_wc= plane00[(uchar) s[0]].tolower; + s++; + } + else + { + int res= my_mb_wc_utf8mb4_no_range(cs, &s_wc, (const uchar*) s); + + /* + In the case of wrong multibyte sequence we will + call strcmp() for byte-to-byte comparison. + */ + if (res <= 0) + return strcmp(s, t); + s+= res; + + my_tolower_utf8mb4(uni_plane, &s_wc); + } + + + /* Do the same for the second string */ + + if ((uchar) t[0] < 128) + { + /* Convert single byte character into weight */ + t_wc= plane00[(uchar) t[0]].tolower; + t++; + } + else + { + int res= my_mb_wc_utf8mb4_no_range(cs, &t_wc, (const uchar*) t); + if (res <= 0) + return strcmp(s, t); + t+= res; + + my_tolower_utf8mb4(uni_plane, &t_wc); + } + + /* Now we have two weights, let's compare them */ + if ( s_wc != t_wc ) + return ((int) s_wc) - ((int) t_wc); + } + return ((int) (uchar) s[0]) - ((int) (uchar) t[0]); +} + + +static int +my_wildcmp_utf8mb4(CHARSET_INFO *cs, + const char *str, const char *strend, + const char *wildstr, const char *wildend, + int escape, int w_one, int w_many) +{ + return my_wildcmp_unicode(cs, str, strend, wildstr, wildend, + escape, w_one, w_many, cs->caseinfo); +} + + +static size_t +my_strnxfrmlen_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), size_t len) +{ + /* TODO: fix when working on WL "Unicode new version" */ + return (len * 2 + 2) / 4; +} + + +static uint +my_ismbchar_utf8mb4(CHARSET_INFO *cs, const char *b, const char *e) +{ + my_wc_t wc; + int res= my_mb_wc_utf8mb4(cs,&wc, (const uchar*)b, (const uchar*)e); + return (res > 1) ? res : 0; +} + + +static uint +my_mbcharlen_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), uint c) +{ + if (c < 0x80) + return 1; + if (c < 0xc2) + return 0; /* Illegal mb head */ + if (c < 0xe0) + return 2; + if (c < 0xf0) + return 3; + if (c < 0xf8) + return 4; + return 0; /* Illegal mb head */; +} + + +static MY_COLLATION_HANDLER my_collation_utf8mb4_general_ci_handler= +{ + NULL, /* init */ + my_strnncoll_utf8mb4, + my_strnncollsp_utf8mb4, + my_strnxfrm_unicode, + my_strnxfrmlen_utf8mb4, + my_like_range_mb, + my_wildcmp_utf8mb4, + my_strcasecmp_utf8mb4, + my_instr_mb, + my_hash_sort_utf8mb4, + my_propagate_complex +}; + + +static MY_COLLATION_HANDLER my_collation_utf8mb4_bin_handler = +{ + NULL, /* init */ + my_strnncoll_mb_bin, + my_strnncollsp_mb_bin, + my_strnxfrm_unicode, + my_strnxfrmlen_utf8mb4, + my_like_range_mb, + my_wildcmp_mb_bin, + my_strcasecmp_mb_bin, + my_instr_mb, + my_hash_sort_mb_bin, + my_propagate_simple +}; + + +MY_CHARSET_HANDLER my_charset_utf8mb4_handler= +{ + NULL, /* init */ + my_ismbchar_utf8mb4, + my_mbcharlen_utf8mb4, + my_numchars_mb, + my_charpos_mb, + my_well_formed_len_mb, + my_lengthsp_8bit, + my_numcells_mb, + my_mb_wc_utf8mb4, + my_wc_mb_utf8mb4, + my_mb_ctype_mb, + my_caseup_str_utf8mb4, + my_casedn_str_utf8mb4, + my_caseup_utf8mb4, + my_casedn_utf8mb4, + my_snprintf_8bit, + my_long10_to_str_8bit, + my_longlong10_to_str_8bit, + my_fill_8bit, + my_strntol_8bit, + my_strntoul_8bit, + my_strntoll_8bit, + my_strntoull_8bit, + my_strntod_8bit, + my_strtoll10_8bit, + my_strntoull10rnd_8bit, + my_scan_8bit +}; + + + +CHARSET_INFO my_charset_utf8mb4_general_ci= +{ + 45,0,0, /* number */ + MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM|MY_CS_UNICODE|MY_CS_UNICODE_SUPPLEMENT, /* state */ + MY_UTF8MB4, /* cs name */ + MY_UTF8MB4_GENERAL_CI,/* name */ + "UTF-8 Unicode", /* comment */ + NULL, /* tailoring */ + ctype_utf8mb4, /* ctype */ + to_lower_utf8mb4, /* to_lower */ + to_upper_utf8mb4, /* to_upper */ + to_upper_utf8mb4, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 1, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 0, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_utf8mb4_general_ci_handler +}; + + +CHARSET_INFO my_charset_utf8mb4_bin= +{ + 46,0,0, /* number */ + MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE|MY_CS_UNICODE_SUPPLEMENT, /* state */ + MY_UTF8MB4, /* cs name */ + MY_UTF8MB4_BIN, /* name */ + "UTF-8 Unicode", /* comment */ + NULL, /* tailoring */ + ctype_utf8mb4, /* ctype */ + to_lower_utf8mb4, /* to_lower */ + to_upper_utf8mb4, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + my_unicase_default, /* caseinfo */ + NULL, /* state_map */ + NULL, /* ident_map */ + 1, /* strxfrm_multiply */ + 1, /* caseup_multiply */ + 1, /* casedn_multiply */ + 1, /* mbminlen */ + 4, /* mbmaxlen */ + 0, /* min_sort_char */ + 0xFFFF, /* max_sort_char */ + ' ', /* pad char */ + 0, /* escape_with_backslash_is_dangerous */ + &my_charset_utf8mb4_handler, + &my_collation_utf8mb4_bin_handler +}; + +#endif /* HAVE_CHARSET_utf8mb4 */ From a814ee238d7394fec20a7035558288fbef6609c6 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 24 Feb 2010 15:39:11 +0300 Subject: [PATCH 69/96] Post-merge fix. --- mysql-test/r/func_gconcat.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 3c2225fb933..22f3088c325 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -996,7 +996,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort; Distinct 2 DERIVED td ALL NULL NULL NULL NULL 2 100.00 Distinct; Using join buffer Warnings: -Note 1003 select 1 AS `1` from (select distinct group_concat(`test`.`td`.`f1` separator ',') AS `GROUP_CONCAT(td.f1)` from `test`.`t1` join `test`.`t1` `td` group by `test`.`td`.`f1`) `d` join `test`.`t1` +Note 1003 select 1 AS `1` from `test`.`t1` SELECT 1 FROM (SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1; 1 From 9c5e3b83c9a95fa224e826786444243bf9c47490 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 24 Feb 2010 19:07:08 +0400 Subject: [PATCH 70/96] Added forgotten test dependencies --- mysql-test/t/ctype_utf16.test | 2 ++ mysql-test/t/ctype_utf8mb4.test | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/t/ctype_utf16.test b/mysql-test/t/ctype_utf16.test index 2e0a9e644b1..b997bde6e7c 100644 --- a/mysql-test/t/ctype_utf16.test +++ b/mysql-test/t/ctype_utf16.test @@ -1,4 +1,6 @@ -- source include/have_utf16.inc +-- source include/have_utf8mb4.inc + --disable_warnings DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index 2c166364b1a..de3ad6bea75 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1,3 +1,5 @@ +--source include/have_utf8mb4.inc + # # Tests with the utf8mb4 character set # From 3275a27d5066b3cff8a6a8783418c173cd0d1264 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 24 Feb 2010 19:42:40 +0400 Subject: [PATCH 71/96] Removing compilation-dependent query. --- mysql-test/r/ctype_utf8mb4.result | 12 ------------ mysql-test/t/ctype_utf8mb4.test | 1 - 2 files changed, 13 deletions(-) diff --git a/mysql-test/r/ctype_utf8mb4.result b/mysql-test/r/ctype_utf8mb4.result index 5eae2c3bc1a..f20c88829e9 100644 --- a/mysql-test/r/ctype_utf8mb4.result +++ b/mysql-test/r/ctype_utf8mb4.result @@ -1797,18 +1797,6 @@ ayy select concat(a, if(b>10, 'x' 'æ', 'y' 'Ăź')) from t1; ERROR HY000: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'concat' drop table t1; -SHOW ENGINES; -Engine Support Comment Transactions XA Savepoints -ndbcluster NO Clustered, fault-tolerant tables NULL NULL NULL -MRG_MYISAM YES Collection of identical MyISAM tables NO NO NO -MEMORY YES Hash based, stored in memory, useful for temporary tables NO NO NO -BLACKHOLE YES /dev/null storage engine (anything you write to it disappears) NO NO NO -CSV YES CSV storage engine NO NO NO -MyISAM DEFAULT Default engine as of MySQL 3.23 with great performance NO NO NO -ARCHIVE YES Archive storage engine NO NO NO -FEDERATED NO Federated MySQL storage engine NULL NULL NULL -PERFORMANCE_SCHEMA YES Performance Schema NO NO NO -InnoDB YES Supports transactions, row-level locking, and foreign keys YES YES YES CREATE TABLE t1 ( colA int(11) NOT NULL, colB varchar(255) character set utf8mb4 NOT NULL, diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test index de3ad6bea75..218ce012412 100644 --- a/mysql-test/t/ctype_utf8mb4.test +++ b/mysql-test/t/ctype_utf8mb4.test @@ -1397,7 +1397,6 @@ drop table t1; # Bug#19960: Inconsistent results when joining # InnoDB tables using partial UTF8 indexes # -SHOW ENGINES; --disable_warnings CREATE TABLE t1 ( colA int(11) NOT NULL, From 3acf917fee390b7e132d4a081cbd76dbae324b64 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 25 Feb 2010 12:15:46 +0400 Subject: [PATCH 72/96] After-fix for WL#1213 Fixing cmake files. --- cmake/character_sets.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/character_sets.cmake b/cmake/character_sets.cmake index 82de1f27d96..d51444ec433 100644 --- a/cmake/character_sets.cmake +++ b/cmake/character_sets.cmake @@ -22,15 +22,15 @@ IF(NOT DEFAULT_COLLATIONS) SET(DEFAULT_COLLATION "latin1_swedish_ci") ENDIF() -SET(CHARSETS ${DEFAULT_CHARSET} latin1 utf8 utf8mb3) -SET(CHARSETS_COMPLEX big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2 sjis tis620 ucs2 ujis utf8 utf8mb3 utf16 utf32) +SET(CHARSETS ${DEFAULT_CHARSET} latin1 utf8 utf8mb4) +SET(CHARSETS_COMPLEX big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2 sjis tis620 ucs2 ujis utf8 utf8mb4 utf16 utf32) SET(CHARSETS_AVAILABLE binary armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257 cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8 greek hebrew hp8 keybcs2 koi8r koi8u latin1 latin2 latin5 latin7 macce macroman -sjis swe7 tis620 ucs2 ujis utf8 utf8mb3 utf16 utf32) +sjis swe7 tis620 ucs2 ujis utf8 utf8mb4 utf16 utf32) SET (EXTRA_CHARSETS "all") From b5ae1327f73af7e893bf6415a74d633739fa903b Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 25 Feb 2010 16:57:15 +0200 Subject: [PATCH 73/96] Backport of the fix for bug #49552 to 5.0-bugteam --- mysql-test/r/delete.result | 12 ++++++++++++ mysql-test/t/delete.test | 15 +++++++++++++++ sql/sql_parse.cc | 4 ++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index a682d90fbf7..d3cf69279fd 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -241,4 +241,16 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1; ERROR 42000: Incorrect number of arguments for FUNCTION test.f1; expected 0, got 1 DROP TABLE t1; DROP FUNCTION f1; +# +# Bug #49552 : sql_buffer_result cause crash + not found records +# in multitable delete/subquery +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2),(3); +SET SESSION SQL_BUFFER_RESULT=1; +DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1; +SET SESSION SQL_BUFFER_RESULT=DEFAULT; +SELECT * FROM t1; +a +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index ec70587c9d1..d9091c92a52 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -247,4 +247,19 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1; DROP TABLE t1; DROP FUNCTION f1; + +--echo # +--echo # Bug #49552 : sql_buffer_result cause crash + not found records +--echo # in multitable delete/subquery +--echo # + +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (1),(2),(3); +SET SESSION SQL_BUFFER_RESULT=1; +DELETE t1 FROM (SELECT SUM(a) a FROM t1) x,t1; + +SET SESSION SQL_BUFFER_RESULT=DEFAULT; +SELECT * FROM t1; +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 61c2d70a563..64d6888d772 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4009,9 +4009,9 @@ end_with_restore_list: select_lex->where, 0, (ORDER *)NULL, (ORDER *)NULL, (Item *)NULL, (ORDER *)NULL, - select_lex->options | thd->options | + (select_lex->options | thd->options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | - OPTION_SETUP_TABLES_DONE, + OPTION_SETUP_TABLES_DONE) & ~OPTION_BUFFER_RESULT, del_result, unit, select_lex); res|= thd->net.report_error; if (unlikely(res)) From 735de9ea7e3f16ac53c413a19e772b19e2bc8dd8 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 25 Feb 2010 18:48:53 +0300 Subject: [PATCH 74/96] Bug #50335: Assertion `!(order->used & map)' in eq_ref_table The problem was in an incorrect debug assertion. The expression used in the failing assertion states that when finding references matching ORDER BY expressions, there can be only one reference to a single table. But that does not make any sense, all test cases for this bug are valid examples with multiple identical WHERE expressions referencing the same table which are also present in the ORDER BY list. Fixed by removing the failing assertion. We also have to take care of the 'found' counter so that we count multiple references only once. We rely on this fact later in eq_ref_table(). --- mysql-test/r/join.result | 11 +++++++++++ mysql-test/t/join.test | 13 +++++++++++++ sql/sql_select.cc | 8 +++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index 8691eb27220..102b39c3992 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1145,3 +1145,14 @@ NULL NULL 1 DROP TABLE t1, t2, mm1; +# +# Bug #50335: Assertion `!(order->used & map)' in eq_ref_table +# +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (0,0), (1,1); +SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a; +a b a b +0 0 0 0 +1 1 1 1 +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 645321a3a5e..761121313e5 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -816,3 +816,16 @@ CREATE TABLE mm1(a CHAR(9),b INT,KEY(b),KEY(a)) ENGINE=MERGE UNION=(t1,t2); SELECT t1.a FROM mm1,t1; DROP TABLE t1, t2, mm1; + +--echo # +--echo # Bug #50335: Assertion `!(order->used & map)' in eq_ref_table +--echo # + +CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (0,0), (1,1); + +SELECT * FROM t1 STRAIGHT_JOIN t1 t2 ON t1.a=t2.a AND t1.a=t2.b ORDER BY t2.a, t1.a; + +DROP TABLE t1; + +--echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 52f9aae7a0c..b9f59fac4d6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7028,9 +7028,11 @@ eq_ref_table(JOIN *join, ORDER *start_order, JOIN_TAB *tab) } if (order) { - found++; - DBUG_ASSERT(!(order->used & map)); - order->used|=map; + if (!(order->used & map)) + { + found++; + order->used|= map; + } continue; // Used in ORDER BY } if (!only_eq_ref_tables(join,start_order, (*ref_item)->used_tables())) From 48c861fb9f3569b3bc45fda802515fd379632d29 Mon Sep 17 00:00:00 2001 From: Christopher Powers Date: Thu, 25 Feb 2010 09:49:09 -0600 Subject: [PATCH 75/96] Bug #48739 MySQL crashes on specific INTERVAL in select query Fixed crash caused by x64 int/long incompatibility introduced in Bug #29125. --- sql/item_timefunc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index de76f821795..d582f26d46c 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -379,7 +379,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, if (tmp - val > 6) tmp= (char*) val + 6; l_time->second_part= (int) my_strtoll10(val, &tmp, &error); - frac_part= 6 - (uint) (tmp - val); + frac_part= 6 - (int) (tmp - val); if (frac_part > 0) l_time->second_part*= (ulong) log_10_int[frac_part]; val= tmp; @@ -870,7 +870,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, value= value*LL(10) + (longlong) (*str - '0'); if (transform_msec && i == count - 1) // microseconds always last { - long msec_length= 6 - (uint) (str - start); + long msec_length= 6 - (int) (str - start); if (msec_length > 0) value*= (long) log_10_int[msec_length]; } From 79d8de67a911be0f18adfd4c19c65909879b76eb Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Thu, 25 Feb 2010 23:13:11 +0400 Subject: [PATCH 76/96] Bug #45360: wrong results Propagation of a large unsigned numeric constant in the WHERE expression led to wrong result. For example, "WHERE a = CAST(0xFFFFFFFFFFFFFFFF AS USIGNED) AND FOO(a)", where a is an UNSIGNED BIGINT, and FOO() accepts strings, was transformed to "... AND FOO('-1')". That has been fixed. Also EXPLAIN EXTENDED printed incorrect numeric constants in transformed WHERE expressions like above. That has been fixed too. --- mysql-test/r/bigint.result | 34 ++++++++++++++++++++++++++++++++++ mysql-test/t/bigint.test | 35 +++++++++++++++++++++++++++++++++++ sql/item.cc | 4 ++-- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 4a5b8fcf4aa..8f9b75fc664 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -404,3 +404,37 @@ describe t1; Field Type Null Key Default Extra bi decimal(19,0) NO 0 drop table t1; +# +# Bug #45360: wrong results +# +CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY, +a BIGINT(20) UNSIGNED, +b VARCHAR(20)); +INSERT INTO t1 (a) VALUES +(0), +(CAST(0x7FFFFFFFFFFFFFFF AS UNSIGNED)), +(CAST(0x8000000000000000 AS UNSIGNED)), +(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED)); +UPDATE t1 SET b = a; +# FFFFFFFFFFFFFFFF +EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 18446744073709551615 AND TRIM(a) = b; +SHOW WARNINGS; +Level Code Message +Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 18446744073709551615) and ('18446744073709551615' = `test`.`t1`.`b`)) +# 8000000000000000 +EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 9223372036854775808 AND TRIM(a) = b; +SHOW WARNINGS; +Level Code Message +Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 9223372036854775808) and ('9223372036854775808' = `test`.`t1`.`b`)) +# 7FFFFFFFFFFFFFFF +EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 9223372036854775807 AND TRIM(a) = b; +SHOW WARNINGS; +Level Code Message +Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 9223372036854775807) and ('9223372036854775807' = `test`.`t1`.`b`)) +# 0 +EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = 0 AND TRIM(a) = b; +SHOW WARNINGS; +Level Code Message +Note 1003 select 1 AS `1` from `test`.`t1` where ((`test`.`t1`.`a` = 0) and ('0' = `test`.`t1`.`b`)) +DROP TABLE t1; +# End of 5.1 tests diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 5a589816dcd..e19bba971f9 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -327,3 +327,38 @@ drop table t1; create table t1 select -9223372036854775809 bi; describe t1; drop table t1; + +--echo # +--echo # Bug #45360: wrong results +--echo # + +CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY, + a BIGINT(20) UNSIGNED, + b VARCHAR(20)); + +INSERT INTO t1 (a) VALUES + (0), + (CAST(0x7FFFFFFFFFFFFFFF AS UNSIGNED)), + (CAST(0x8000000000000000 AS UNSIGNED)), + (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED)); + +UPDATE t1 SET b = a; + +let $n = `SELECT MAX(id) FROM t1`; +while($n) { + let $x = `SELECT a FROM t1 WHERE id = $n`; + dec $n; + let $hex = `SELECT HEX($x)`; + echo # $hex; + + --disable_result_log + eval EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE a = $x AND TRIM(a) = b; + --enable_result_log + SHOW WARNINGS; +} + +DROP TABLE t1; + +--echo # End of 5.1 tests + + diff --git a/sql/item.cc b/sql/item.cc index f8cca3a0667..934e897f923 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2209,14 +2209,14 @@ String *Item_int::val_str(String *str) { // following assert is redundant, because fixed=1 assigned in constructor DBUG_ASSERT(fixed == 1); - str->set(value, &my_charset_bin); + str->set_int(value, unsigned_flag, &my_charset_bin); return str; } void Item_int::print(String *str, enum_query_type query_type) { // my_charset_bin is good enough for numbers - str_value.set(value, &my_charset_bin); + str_value.set_int(value, unsigned_flag, &my_charset_bin); str->append(str_value); } From bf875901047faa8796aa0fe6a6bca32ea7fde956 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Thu, 25 Feb 2010 23:10:42 +0300 Subject: [PATCH 77/96] Fix mysqld--help-notwin.result. --- mysql-test/r/mysqld--help-win.result | 38 +++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/mysql-test/r/mysqld--help-win.result b/mysql-test/r/mysqld--help-win.result index 15649cbc0fa..a9fc6df71a6 100644 --- a/mysql-test/r/mysqld--help-win.result +++ b/mysql-test/r/mysqld--help-win.result @@ -1,8 +1,8 @@ The following options may be given as the first argument: ---print-defaults Print the program argument list and exit ---no-defaults Don't read default options from any options file ---defaults-file=# Only read default options from the given file # ---defaults-extra-file=# Read this file after the global files are read +--print-defaults Print the program argument list and exit. +--no-defaults Don't read default options from any option file. +--defaults-file=# Only read default options from the given file #. +--defaults-extra-file=# Read this file after the global files are read. --abort-slave-event-count=# Option used by mysql-test for debugging and testing of @@ -60,7 +60,7 @@ The following options may be given as the first argument: NDBCLUSTER table --binlog-ignore-db=name Tells the master that updates to the given database - should not be logged tothe binary log. + should not be logged to the binary log. --binlog-row-event-max-size=# The maximum size of a row-based binary log event in bytes. Rows will be grouped into events smaller than this @@ -90,7 +90,7 @@ The following options may be given as the first argument: NEVER, AUTO, ALWAYS --connect-timeout=# The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake' - --console Write error output on screen; Don't remove the console + --console Write error output on screen; don't remove the console window on windows. --core-file Write core on errors. -h, --datadir=name Path to the database root directory @@ -132,7 +132,7 @@ The following options may be given as the first argument: Enable the event scheduler. Possible values are ON, OFF, and DISABLED (keep the event scheduler completely deactivated, it cannot be activated run-time) - -T, --exit-info[=#] Used for debugging; Use at your own risk! + -T, --exit-info[=#] Used for debugging. Use at your own risk. --expire-logs-days=# If non-zero, binary logs will be purged after expire_logs_days days; possible purges happen at startup @@ -157,7 +157,7 @@ The following options may be given as the first argument: Number of best matches to use for query expansion --ft-stopword-file=name Use stopwords from this file instead of built-in list - --gdb Set up signals usable for debugging + --gdb Set up signals usable for debugging. --general-log Log connections and queries to a table or log file. Defaults logging to a file hostname.log or a table mysql.general_logif --log-output=TABLE is used @@ -253,7 +253,7 @@ The following options may be given as the first argument: log if it is open. --log-tc=name Path to transaction coordinator log (used for transactions that affect more than one storage engine, - when binary log is disabled) + when binary log is disabled). --log-tc-size=# Size of transaction coordinator log. -W, --log-warnings[=#] Log some not critical warnings to the log file @@ -372,10 +372,11 @@ The following options may be given as the first argument: --old-passwords Use old password encryption method (needed for 4.0 and older clients) --old-style-user-limits - Enable old-style user limits (before 5.0.3 user resources - were counted per each user+host vs. per account) - --one-thread (deprecated): Only use one thread (for debugging under - Linux). Use thread-handling=no-threads instead + Enable old-style user limits (before 5.0.3, user + resources were counted per each user+host vs. per + account). + --one-thread (Deprecated): Only use one thread (for debugging under + Linux). Use thread-handling=no-threads instead. --open-files-limit=# If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this @@ -447,7 +448,7 @@ The following options may be given as the first argument: (3306), whatever comes first --port-open-timeout=# Maximum time in seconds to wait for the port to become - free. (Default: no wait) + free. (Default: No wait). --preload-buffer-size=# The size of the buffer that is allocated when preloading indexes @@ -593,14 +594,15 @@ The following options may be given as the first argument: --shared-memory-base-name=name Base name of shared memory --show-slave-auth-info - Show user and password in SHOW SLAVE HOSTS on this master + Show user and password in SHOW SLAVE HOSTS on this + master. --skip-grant-tables Start without grant tables. This gives all users FULL - ACCESS to all tables! + ACCESS to all tables. --skip-host-cache Don't cache host names. --skip-name-resolve Don't resolve hostnames. All hostnames are IP's or 'localhost'. --skip-networking Don't allow connection with TCP/IP - --skip-new Don't use new, possible wrong routines. + --skip-new Don't use new, possibly wrong routines. --skip-show-database Don't allow 'SHOW DATABASE' commands --skip-slave-start If set, slave is not autostarted. @@ -720,7 +722,7 @@ The following options may be given as the first argument: Enable symbolic link support. Deprecated option; use --symbolic-links instead. -u, --user=name Run mysqld daemon as user. - -v, --verbose Used with --help option for detailed help + -v, --verbose Used with --help option for detailed help. -V, --version Output version information and exit. --wait-timeout=# The number of seconds the server waits for activity on a connection before closing it From da2e47a5330e73472c4c224b2e41748a18e2946a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 26 Feb 2010 10:28:44 +0400 Subject: [PATCH 78/96] After-fix for WL#2649 Number-to-string conversion. This change fixes test failure for partition_repair_myisam and partition_recover_myisam. The problem was that: - the file std_data/corrupt_crash.MYI contains charsetnr=63 (binary) for index segments. - the new .frm file contains charsetnr=8 (latin1) for the same segments. As a result REPAIR refused to repair frm+MYI files with different segment definition. This fix restores the old behavior for frm and MYI files: they now store charsetnr=63 for numeric/datetime data types. --- storage/heap/ha_heap.cc | 2 +- storage/myisam/ha_myisam.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 8d07d21c6ae..4d01b9fd1c9 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -689,7 +689,7 @@ int ha_heap::create(const char *name, TABLE *table_arg, if (field->flags & (ENUM_FLAG | SET_FLAG)) seg->charset= &my_charset_bin; else - seg->charset= field->charset(); + seg->charset= field->charset_for_protocol(); if (field->null_ptr) { seg->null_bit= field->null_bit; diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 1117e8fff15..8a32e7255c0 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -274,7 +274,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, keydef[i].seg[j].bit_start= keydef[i].seg[j].bit_end= keydef[i].seg[j].bit_length= 0; keydef[i].seg[j].bit_pos= 0; - keydef[i].seg[j].language= field->charset()->number; + keydef[i].seg[j].language= field->charset_for_protocol()->number; if (field->null_ptr) { From ffad1562542a72f41912ef1edd55b3a49e7fe89d Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 26 Feb 2010 13:01:31 +0400 Subject: [PATCH 79/96] Applying InnoDB snapshot Detailed revision comments: r6535 | sunny | 2010-01-30 00:08:40 +0200 (Sat, 30 Jan 2010) | 11 lines branches/5.1: Undo the change from r6424. We need to return DB_SUCCESS even if we were unable to initialize the tabe autoinc value. This is required for the open to succeed. The only condition we currently treat as a hard error is if the autoinc field instance passed in by MySQL is NULL. Previously if the table autoinc value was 0 and the next value was requested we had an assertion that would fail. Change that assertion and treat a value of 0 to mean that the autoinc system is unavailable. Generation of next value will now return failure. rb://237 --- storage/innobase/handler/ha_innodb.cc | 38 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 9b6c2cf9895..e3aa5fb4f5b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2652,9 +2652,9 @@ ha_innobase::innobase_initialize_autoinc() auto_inc = innobase_get_int_col_max_value(field); } else { /* We have no idea what's been passed in to us as the - autoinc column. We set it to the MAX_INT of our table - autoinc type. */ - auto_inc = 0xFFFFFFFFFFFFFFFFULL; + autoinc column. We set it to the 0, effectively disabling + updates to the table. */ + auto_inc = 0; ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Unable to determine the AUTOINC " @@ -2663,7 +2663,7 @@ ha_innobase::innobase_initialize_autoinc() if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { /* If the recovery level is set so high that writes - are disabled we force the AUTOINC counter to the MAX + are disabled we force the AUTOINC counter to 0 value effectively disabling writes to the table. Secondly, we avoid reading the table in case the read results in failure due to a corrupted table/index. @@ -2672,7 +2672,10 @@ ha_innobase::innobase_initialize_autoinc() tables can be dumped with minimal hassle. If an error were returned in this case, the first attempt to read the table would fail and subsequent SELECTs would succeed. */ + auto_inc = 0; } else if (field == NULL) { + /* This is a far more serious error, best to avoid + opening the table and return failure. */ my_error(ER_AUTOINC_READ_FAILED, MYF(0)); } else { dict_index_t* index; @@ -2701,7 +2704,7 @@ ha_innobase::innobase_initialize_autoinc() "InnoDB: Unable to find the AUTOINC column " "%s in the InnoDB table %s.\n" "InnoDB: We set the next AUTOINC column " - "value to the maximum possible value,\n" + "value to 0,\n" "InnoDB: in effect disabling the AUTOINC " "next value generation.\n" "InnoDB: You can either set the next " @@ -2710,7 +2713,13 @@ ha_innobase::innobase_initialize_autoinc() "recreating the table.\n", col_name, index->table->name); - my_error(ER_AUTOINC_READ_FAILED, MYF(0)); + /* This will disable the AUTOINC generation. */ + auto_inc = 0; + + /* We want the open to succeed, so that the user can + take corrective action. ie. reads should succeed but + updates should fail. */ + err = DB_SUCCESS; break; default: /* row_search_max_autoinc() should only return @@ -3968,11 +3977,17 @@ no_commit: prebuilt->autoinc_error = DB_SUCCESS; if ((error = update_auto_increment())) { - /* We don't want to mask autoinc overflow errors. */ - if (prebuilt->autoinc_error != DB_SUCCESS) { - error = (int) prebuilt->autoinc_error; + /* Handle the case where the AUTOINC sub-system + failed during initialization. */ + if (prebuilt->autoinc_error == DB_UNSUPPORTED) { + error_result = ER_AUTOINC_READ_FAILED; + /* Set the error message to report too. */ + my_error(ER_AUTOINC_READ_FAILED, MYF(0)); + goto func_exit; + } else if (prebuilt->autoinc_error != DB_SUCCESS) { + error = (int) prebuilt->autoinc_error; goto report_error; } @@ -7883,7 +7898,10 @@ ha_innobase::innobase_get_autoinc( *value = dict_table_autoinc_read(prebuilt->table); /* It should have been initialized during open. */ - ut_a(*value != 0); + if (*value == 0) { + prebuilt->autoinc_error = DB_UNSUPPORTED; + dict_table_autoinc_unlock(prebuilt->table); + } } return(ulong(prebuilt->autoinc_error)); From 91c42548c8685bcebecf19c960b2ab99c173b02d Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 26 Feb 2010 13:02:05 +0400 Subject: [PATCH 80/96] Applying InnoDB snapshot Detailed revision comments: r6536 | sunny | 2010-01-30 00:13:42 +0200 (Sat, 30 Jan 2010) | 6 lines branches/5.1: Check *first_value everytime against the column max value and set *first_value to next autoinc if it's > col max value. ie. not rely on what is passed in from MySQL. [49497] Error 1467 (ER_AUTOINC_READ_FAILED) on inserting a negative value rb://236 --- mysql-test/r/innodb-autoinc.result | 83 +++++++++++++++++++++++++++ mysql-test/t/innodb-autoinc.test | 31 ++++++++++ storage/innobase/handler/ha_innodb.cc | 54 +++++++---------- 3 files changed, 134 insertions(+), 34 deletions(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index c03daa3565e..a36b3a1a865 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -1161,3 +1161,86 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 DROP TABLE t1; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-685113344), (1), (NULL), (NULL); +SELECT * FROM t1; +c1 +-685113344 +1 +2 +3 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-685113344), (2), (NULL), (NULL); +SELECT * FROM t1; +c1 +-685113344 +2 +3 +4 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL), (2), (-685113344), (NULL); +INSERT INTO t1 VALUES (4), (5), (6), (NULL); +SELECT * FROM t1; +c1 +-685113344 +1 +2 +3 +4 +5 +6 +7 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL), (2), (-685113344), (5); +SELECT * FROM t1; +c1 +-685113344 +1 +2 +5 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (-685113344), (NULL); +SELECT * FROM t1; +c1 +-685113344 +1 +2 +3 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index bb431408937..ef0359b78b0 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -631,3 +631,34 @@ REPLACE INTO t1 VALUES (-1); SELECT * FROM t1; SHOW CREATE TABLE t1; DROP TABLE t1; + +## +# 49497: Error 1467 (ER_AUTOINC_READ_FAILED) on inserting a negative value +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-685113344), (1), (NULL), (NULL); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-685113344), (2), (NULL), (NULL); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL), (2), (-685113344), (NULL); +INSERT INTO t1 VALUES (4), (5), (6), (NULL); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL), (2), (-685113344), (5); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (-685113344), (NULL); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e3aa5fb4f5b..7b501a23d21 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2652,9 +2652,9 @@ ha_innobase::innobase_initialize_autoinc() auto_inc = innobase_get_int_col_max_value(field); } else { /* We have no idea what's been passed in to us as the - autoinc column. We set it to the 0, effectively disabling - updates to the table. */ - auto_inc = 0; + autoinc column. We set it to the MAX_INT of our table + autoinc type. */ + auto_inc = 0xFFFFFFFFFFFFFFFFULL; ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Unable to determine the AUTOINC " @@ -2663,7 +2663,7 @@ ha_innobase::innobase_initialize_autoinc() if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { /* If the recovery level is set so high that writes - are disabled we force the AUTOINC counter to 0 + are disabled we force the AUTOINC counter to the MAX value effectively disabling writes to the table. Secondly, we avoid reading the table in case the read results in failure due to a corrupted table/index. @@ -2672,10 +2672,7 @@ ha_innobase::innobase_initialize_autoinc() tables can be dumped with minimal hassle. If an error were returned in this case, the first attempt to read the table would fail and subsequent SELECTs would succeed. */ - auto_inc = 0; } else if (field == NULL) { - /* This is a far more serious error, best to avoid - opening the table and return failure. */ my_error(ER_AUTOINC_READ_FAILED, MYF(0)); } else { dict_index_t* index; @@ -2704,7 +2701,7 @@ ha_innobase::innobase_initialize_autoinc() "InnoDB: Unable to find the AUTOINC column " "%s in the InnoDB table %s.\n" "InnoDB: We set the next AUTOINC column " - "value to 0,\n" + "value to the maximum possible value,\n" "InnoDB: in effect disabling the AUTOINC " "next value generation.\n" "InnoDB: You can either set the next " @@ -2713,13 +2710,7 @@ ha_innobase::innobase_initialize_autoinc() "recreating the table.\n", col_name, index->table->name); - /* This will disable the AUTOINC generation. */ - auto_inc = 0; - - /* We want the open to succeed, so that the user can - take corrective action. ie. reads should succeed but - updates should fail. */ - err = DB_SUCCESS; + my_error(ER_AUTOINC_READ_FAILED, MYF(0)); break; default: /* row_search_max_autoinc() should only return @@ -3977,17 +3968,11 @@ no_commit: prebuilt->autoinc_error = DB_SUCCESS; if ((error = update_auto_increment())) { - /* We don't want to mask autoinc overflow errors. */ - /* Handle the case where the AUTOINC sub-system - failed during initialization. */ - if (prebuilt->autoinc_error == DB_UNSUPPORTED) { - error_result = ER_AUTOINC_READ_FAILED; - /* Set the error message to report too. */ - my_error(ER_AUTOINC_READ_FAILED, MYF(0)); - goto func_exit; - } else if (prebuilt->autoinc_error != DB_SUCCESS) { + /* We don't want to mask autoinc overflow errors. */ + if (prebuilt->autoinc_error != DB_SUCCESS) { error = (int) prebuilt->autoinc_error; + goto report_error; } @@ -7898,10 +7883,7 @@ ha_innobase::innobase_get_autoinc( *value = dict_table_autoinc_read(prebuilt->table); /* It should have been initialized during open. */ - if (*value == 0) { - prebuilt->autoinc_error = DB_UNSUPPORTED; - dict_table_autoinc_unlock(prebuilt->table); - } + ut_a(*value != 0); } return(ulong(prebuilt->autoinc_error)); @@ -7981,6 +7963,11 @@ ha_innobase::get_auto_increment( invoking this method. So we are not sure if it's guaranteed to be 0 or not. */ + /* We need the upper limit of the col type to check for + whether we update the table autoinc counter or not. */ + ulonglong col_max_value = innobase_get_int_col_max_value( + table->next_number_field); + /* Called for the first time ? */ if (trx->n_autoinc_rows == 0) { @@ -7997,6 +7984,11 @@ ha_innobase::get_auto_increment( /* Not in the middle of a mult-row INSERT. */ } else if (prebuilt->autoinc_last_value == 0) { set_if_bigger(*first_value, autoinc); + /* Check for -ve values. */ + } else if (*first_value > col_max_value && trx->n_autoinc_rows > 0) { + /* Set to next logical value. */ + ut_a(autoinc > trx->n_autoinc_rows); + *first_value = (autoinc - trx->n_autoinc_rows) - 1; } *nb_reserved_values = trx->n_autoinc_rows; @@ -8007,12 +7999,6 @@ ha_innobase::get_auto_increment( ulonglong need; ulonglong current; ulonglong next_value; - ulonglong col_max_value; - - /* We need the upper limit of the col type to check for - whether we update the table autoinc counter or not. */ - col_max_value = innobase_get_int_col_max_value( - table->next_number_field); current = *first_value > col_max_value ? autoinc : *first_value; need = *nb_reserved_values * increment; From ac68d90faa138ced5f8441bd35874a7297a8236e Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 26 Feb 2010 13:02:26 +0400 Subject: [PATCH 81/96] Applying InnoDB snapshot Detailed revision comments: r6537 | sunny | 2010-01-30 00:35:00 +0200 (Sat, 30 Jan 2010) | 2 lines branches/5.1: Undo r6536. --- mysql-test/r/innodb-autoinc.result | 83 --------------------------- mysql-test/t/innodb-autoinc.test | 31 ---------- storage/innobase/handler/ha_innodb.cc | 54 ++++++++++------- 3 files changed, 34 insertions(+), 134 deletions(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index a36b3a1a865..c03daa3565e 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -1161,86 +1161,3 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 DROP TABLE t1; -DROP TABLE IF EXISTS t1; -Warnings: -Note 1051 Unknown table 't1' -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (-685113344), (1), (NULL), (NULL); -SELECT * FROM t1; -c1 --685113344 -1 -2 -3 -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`c1`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 -DROP TABLE t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (-685113344), (2), (NULL), (NULL); -SELECT * FROM t1; -c1 --685113344 -2 -3 -4 -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`c1`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 -DROP TABLE t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (NULL), (2), (-685113344), (NULL); -INSERT INTO t1 VALUES (4), (5), (6), (NULL); -SELECT * FROM t1; -c1 --685113344 -1 -2 -3 -4 -5 -6 -7 -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`c1`) -) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 -DROP TABLE t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (NULL), (2), (-685113344), (5); -SELECT * FROM t1; -c1 --685113344 -1 -2 -5 -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`c1`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 -DROP TABLE t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1), (2), (-685113344), (NULL); -SELECT * FROM t1; -c1 --685113344 -1 -2 -3 -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`c1`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 -DROP TABLE t1; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index ef0359b78b0..bb431408937 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -631,34 +631,3 @@ REPLACE INTO t1 VALUES (-1); SELECT * FROM t1; SHOW CREATE TABLE t1; DROP TABLE t1; - -## -# 49497: Error 1467 (ER_AUTOINC_READ_FAILED) on inserting a negative value -# -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (-685113344), (1), (NULL), (NULL); -SELECT * FROM t1; -SHOW CREATE TABLE t1; -DROP TABLE t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (-685113344), (2), (NULL), (NULL); -SELECT * FROM t1; -SHOW CREATE TABLE t1; -DROP TABLE t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (NULL), (2), (-685113344), (NULL); -INSERT INTO t1 VALUES (4), (5), (6), (NULL); -SELECT * FROM t1; -SHOW CREATE TABLE t1; -DROP TABLE t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (NULL), (2), (-685113344), (5); -SELECT * FROM t1; -SHOW CREATE TABLE t1; -DROP TABLE t1; -CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1), (2), (-685113344), (NULL); -SELECT * FROM t1; -SHOW CREATE TABLE t1; -DROP TABLE t1; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7b501a23d21..e3aa5fb4f5b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2652,9 +2652,9 @@ ha_innobase::innobase_initialize_autoinc() auto_inc = innobase_get_int_col_max_value(field); } else { /* We have no idea what's been passed in to us as the - autoinc column. We set it to the MAX_INT of our table - autoinc type. */ - auto_inc = 0xFFFFFFFFFFFFFFFFULL; + autoinc column. We set it to the 0, effectively disabling + updates to the table. */ + auto_inc = 0; ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Unable to determine the AUTOINC " @@ -2663,7 +2663,7 @@ ha_innobase::innobase_initialize_autoinc() if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { /* If the recovery level is set so high that writes - are disabled we force the AUTOINC counter to the MAX + are disabled we force the AUTOINC counter to 0 value effectively disabling writes to the table. Secondly, we avoid reading the table in case the read results in failure due to a corrupted table/index. @@ -2672,7 +2672,10 @@ ha_innobase::innobase_initialize_autoinc() tables can be dumped with minimal hassle. If an error were returned in this case, the first attempt to read the table would fail and subsequent SELECTs would succeed. */ + auto_inc = 0; } else if (field == NULL) { + /* This is a far more serious error, best to avoid + opening the table and return failure. */ my_error(ER_AUTOINC_READ_FAILED, MYF(0)); } else { dict_index_t* index; @@ -2701,7 +2704,7 @@ ha_innobase::innobase_initialize_autoinc() "InnoDB: Unable to find the AUTOINC column " "%s in the InnoDB table %s.\n" "InnoDB: We set the next AUTOINC column " - "value to the maximum possible value,\n" + "value to 0,\n" "InnoDB: in effect disabling the AUTOINC " "next value generation.\n" "InnoDB: You can either set the next " @@ -2710,7 +2713,13 @@ ha_innobase::innobase_initialize_autoinc() "recreating the table.\n", col_name, index->table->name); - my_error(ER_AUTOINC_READ_FAILED, MYF(0)); + /* This will disable the AUTOINC generation. */ + auto_inc = 0; + + /* We want the open to succeed, so that the user can + take corrective action. ie. reads should succeed but + updates should fail. */ + err = DB_SUCCESS; break; default: /* row_search_max_autoinc() should only return @@ -3968,11 +3977,17 @@ no_commit: prebuilt->autoinc_error = DB_SUCCESS; if ((error = update_auto_increment())) { - /* We don't want to mask autoinc overflow errors. */ - if (prebuilt->autoinc_error != DB_SUCCESS) { - error = (int) prebuilt->autoinc_error; + /* Handle the case where the AUTOINC sub-system + failed during initialization. */ + if (prebuilt->autoinc_error == DB_UNSUPPORTED) { + error_result = ER_AUTOINC_READ_FAILED; + /* Set the error message to report too. */ + my_error(ER_AUTOINC_READ_FAILED, MYF(0)); + goto func_exit; + } else if (prebuilt->autoinc_error != DB_SUCCESS) { + error = (int) prebuilt->autoinc_error; goto report_error; } @@ -7883,7 +7898,10 @@ ha_innobase::innobase_get_autoinc( *value = dict_table_autoinc_read(prebuilt->table); /* It should have been initialized during open. */ - ut_a(*value != 0); + if (*value == 0) { + prebuilt->autoinc_error = DB_UNSUPPORTED; + dict_table_autoinc_unlock(prebuilt->table); + } } return(ulong(prebuilt->autoinc_error)); @@ -7963,11 +7981,6 @@ ha_innobase::get_auto_increment( invoking this method. So we are not sure if it's guaranteed to be 0 or not. */ - /* We need the upper limit of the col type to check for - whether we update the table autoinc counter or not. */ - ulonglong col_max_value = innobase_get_int_col_max_value( - table->next_number_field); - /* Called for the first time ? */ if (trx->n_autoinc_rows == 0) { @@ -7984,11 +7997,6 @@ ha_innobase::get_auto_increment( /* Not in the middle of a mult-row INSERT. */ } else if (prebuilt->autoinc_last_value == 0) { set_if_bigger(*first_value, autoinc); - /* Check for -ve values. */ - } else if (*first_value > col_max_value && trx->n_autoinc_rows > 0) { - /* Set to next logical value. */ - ut_a(autoinc > trx->n_autoinc_rows); - *first_value = (autoinc - trx->n_autoinc_rows) - 1; } *nb_reserved_values = trx->n_autoinc_rows; @@ -7999,6 +8007,12 @@ ha_innobase::get_auto_increment( ulonglong need; ulonglong current; ulonglong next_value; + ulonglong col_max_value; + + /* We need the upper limit of the col type to check for + whether we update the table autoinc counter or not. */ + col_max_value = innobase_get_int_col_max_value( + table->next_number_field); current = *first_value > col_max_value ? autoinc : *first_value; need = *nb_reserved_values * increment; From 6d4e34cabbccbfe75537060e9fafed9c041d1c8d Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 26 Feb 2010 13:02:57 +0400 Subject: [PATCH 82/96] Applying InnoDB snapshot Detailed revision comments: r6538 | sunny | 2010-01-30 00:43:06 +0200 (Sat, 30 Jan 2010) | 6 lines branches/5.1: Check *first_value every time against the column max value and set *first_value to next autoinc if it's > col max value. ie. not rely on what is passed in from MySQL. [49497] Error 1467 (ER_AUTOINC_READ_FAILED) on inserting a negative value rb://236 --- mysql-test/r/innodb-autoinc.result | 83 +++++++++++++++++++++++++++ mysql-test/t/innodb-autoinc.test | 31 ++++++++++ storage/innobase/handler/ha_innodb.cc | 16 ++++-- 3 files changed, 124 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result index c03daa3565e..a36b3a1a865 100644 --- a/mysql-test/r/innodb-autoinc.result +++ b/mysql-test/r/innodb-autoinc.result @@ -1161,3 +1161,86 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`c1`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 DROP TABLE t1; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-685113344), (1), (NULL), (NULL); +SELECT * FROM t1; +c1 +-685113344 +1 +2 +3 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-685113344), (2), (NULL), (NULL); +SELECT * FROM t1; +c1 +-685113344 +2 +3 +4 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL), (2), (-685113344), (NULL); +INSERT INTO t1 VALUES (4), (5), (6), (NULL); +SELECT * FROM t1; +c1 +-685113344 +1 +2 +3 +4 +5 +6 +7 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL), (2), (-685113344), (5); +SELECT * FROM t1; +c1 +-685113344 +1 +2 +5 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (-685113344), (NULL); +SELECT * FROM t1; +c1 +-685113344 +1 +2 +3 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`c1`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test index bb431408937..ef0359b78b0 100644 --- a/mysql-test/t/innodb-autoinc.test +++ b/mysql-test/t/innodb-autoinc.test @@ -631,3 +631,34 @@ REPLACE INTO t1 VALUES (-1); SELECT * FROM t1; SHOW CREATE TABLE t1; DROP TABLE t1; + +## +# 49497: Error 1467 (ER_AUTOINC_READ_FAILED) on inserting a negative value +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-685113344), (1), (NULL), (NULL); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-685113344), (2), (NULL), (NULL); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL), (2), (-685113344), (NULL); +INSERT INTO t1 VALUES (4), (5), (6), (NULL); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL), (2), (-685113344), (5); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (c1 INTEGER AUTO_INCREMENT, PRIMARY KEY (c1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1), (2), (-685113344), (NULL); +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e3aa5fb4f5b..b037fa0d0fd 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7981,6 +7981,11 @@ ha_innobase::get_auto_increment( invoking this method. So we are not sure if it's guaranteed to be 0 or not. */ + /* We need the upper limit of the col type to check for + whether we update the table autoinc counter or not. */ + ulonglong col_max_value = innobase_get_int_col_max_value( + table->next_number_field); + /* Called for the first time ? */ if (trx->n_autoinc_rows == 0) { @@ -7997,6 +8002,11 @@ ha_innobase::get_auto_increment( /* Not in the middle of a mult-row INSERT. */ } else if (prebuilt->autoinc_last_value == 0) { set_if_bigger(*first_value, autoinc); + /* Check for -ve values. */ + } else if (*first_value > col_max_value && trx->n_autoinc_rows > 0) { + /* Set to next logical value. */ + ut_a(autoinc > trx->n_autoinc_rows); + *first_value = (autoinc - trx->n_autoinc_rows) - 1; } *nb_reserved_values = trx->n_autoinc_rows; @@ -8007,12 +8017,6 @@ ha_innobase::get_auto_increment( ulonglong need; ulonglong current; ulonglong next_value; - ulonglong col_max_value; - - /* We need the upper limit of the col type to check for - whether we update the table autoinc counter or not. */ - col_max_value = innobase_get_int_col_max_value( - table->next_number_field); current = *first_value > col_max_value ? autoinc : *first_value; need = *nb_reserved_values * increment; From 167888c6c3aa8a3caea24a1325b22ff02da902ae Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 26 Feb 2010 13:03:23 +0400 Subject: [PATCH 83/96] Applying InnoDB snapshot, fixes BUG#49001 Detailed revision comments: r6545 | jyang | 2010-02-03 03:57:32 +0200 (Wed, 03 Feb 2010) | 8 lines branches/5.1: Fix bug #49001, "SHOW INNODB STATUS deadlock info incorrect when deadlock detection aborts". Print the correct lock owner when recursive function lock_deadlock_recursive() exceeds its maximum depth LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK. rb://217, approved by Marko. --- storage/innobase/lock/lock0lock.c | 98 ++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 35 deletions(-) diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index 4cc10931060..8f4b64cda96 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -306,6 +306,7 @@ FILE* lock_latest_err_file; /* Flags for recursive deadlock search */ #define LOCK_VICTIM_IS_START 1 #define LOCK_VICTIM_IS_OTHER 2 +#define LOCK_EXCEED_MAX_DEPTH 3 /************************************************************************ Checks if a lock request results in a deadlock. */ @@ -332,16 +333,18 @@ lock_deadlock_recursive( was found and we chose some other trx as a victim: we must do the search again in this last case because there may be another - deadlock! */ + deadlock! + LOCK_EXCEED_MAX_DEPTH if the lock search + exceeds max steps and/or max depth. */ trx_t* start, /* in: recursion starting point */ trx_t* trx, /* in: a transaction waiting for a lock */ lock_t* wait_lock, /* in: the lock trx is waiting to be granted */ ulint* cost, /* in/out: number of calculation steps thus far: if this exceeds LOCK_MAX_N_STEPS_... - we return LOCK_VICTIM_IS_START */ + we return LOCK_EXCEED_MAX_DEPTH */ ulint depth); /* in: recursion depth: if this exceeds LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK, we - return LOCK_VICTIM_IS_START */ + return LOCK_EXCEED_MAX_DEPTH */ /************************************************************************* Gets the nth bit of a record lock. */ @@ -3084,8 +3087,6 @@ lock_deadlock_occurs( lock_t* lock, /* in: lock the transaction is requesting */ trx_t* trx) /* in: transaction */ { - dict_table_t* table; - dict_index_t* index; trx_t* mark_trx; ulint ret; ulint cost = 0; @@ -3107,31 +3108,50 @@ retry: ret = lock_deadlock_recursive(trx, trx, lock, &cost, 0); - if (ret == LOCK_VICTIM_IS_OTHER) { + switch (ret) { + case LOCK_VICTIM_IS_OTHER: /* We chose some other trx as a victim: retry if there still is a deadlock */ - goto retry; - } - if (ret == LOCK_VICTIM_IS_START) { - if (lock_get_type(lock) & LOCK_TABLE) { - table = lock->un_member.tab_lock.table; - index = NULL; - } else { - index = lock->index; - table = index->table; - } + case LOCK_EXCEED_MAX_DEPTH: + /* If the lock search exceeds the max step + or the max depth, the current trx will be + the victim. Print its information. */ + rewind(lock_latest_err_file); + ut_print_timestamp(lock_latest_err_file); - lock_deadlock_found = TRUE; - - fputs("*** WE ROLL BACK TRANSACTION (2)\n", + fputs("TOO DEEP OR LONG SEARCH IN THE LOCK TABLE" + " WAITS-FOR GRAPH, WE WILL ROLL BACK" + " FOLLOWING TRANSACTION \n", lock_latest_err_file); - return(TRUE); + fputs("\n*** TRANSACTION:\n", lock_latest_err_file); + trx_print(lock_latest_err_file, trx, 3000); + + fputs("*** WAITING FOR THIS LOCK TO BE GRANTED:\n", + lock_latest_err_file); + + if (lock_get_type(lock) == LOCK_REC) { + lock_rec_print(lock_latest_err_file, lock); + } else { + lock_table_print(lock_latest_err_file, lock); + } + break; + + case LOCK_VICTIM_IS_START: + fputs("*** WE ROLL BACK TRANSACTION (2)\n", + lock_latest_err_file); + break; + + default: + /* No deadlock detected*/ + return(FALSE); } - return(FALSE); + lock_deadlock_found = TRUE; + + return(TRUE); } /************************************************************************ @@ -3147,16 +3167,18 @@ lock_deadlock_recursive( was found and we chose some other trx as a victim: we must do the search again in this last case because there may be another - deadlock! */ + deadlock! + LOCK_EXCEED_MAX_DEPTH if the lock search + exceeds max steps and/or max depth. */ trx_t* start, /* in: recursion starting point */ trx_t* trx, /* in: a transaction waiting for a lock */ lock_t* wait_lock, /* in: the lock trx is waiting to be granted */ ulint* cost, /* in/out: number of calculation steps thus far: if this exceeds LOCK_MAX_N_STEPS_... - we return LOCK_VICTIM_IS_START */ + we return LOCK_EXCEED_MAX_DEPTH */ ulint depth) /* in: recursion depth: if this exceeds LOCK_MAX_DEPTH_IN_DEADLOCK_CHECK, we - return LOCK_VICTIM_IS_START */ + return LOCK_EXCEED_MAX_DEPTH */ { lock_t* lock; ulint bit_no = ULINT_UNDEFINED; @@ -3215,7 +3237,7 @@ lock_deadlock_recursive( lock_trx = lock->trx; - if (lock_trx == start || too_far) { + if (lock_trx == start) { /* We came back to the recursion starting point: a deadlock detected; or we have @@ -3262,19 +3284,10 @@ lock_deadlock_recursive( } #ifdef UNIV_DEBUG if (lock_print_waits) { - fputs("Deadlock detected" - " or too long search\n", + fputs("Deadlock detected\n", stderr); } #endif /* UNIV_DEBUG */ - if (too_far) { - - fputs("TOO DEEP OR LONG SEARCH" - " IN THE LOCK TABLE" - " WAITS-FOR GRAPH\n", ef); - - return(LOCK_VICTIM_IS_START); - } if (trx_weight_cmp(wait_lock->trx, start) >= 0) { @@ -3310,6 +3323,21 @@ lock_deadlock_recursive( return(LOCK_VICTIM_IS_OTHER); } + if (too_far) { + +#ifdef UNIV_DEBUG + if (lock_print_waits) { + fputs("Deadlock search exceeds" + " max steps or depth.\n", + stderr); + } +#endif /* UNIV_DEBUG */ + /* The information about transaction/lock + to be rolled back is available in the top + level. Do not print anything here. */ + return(LOCK_EXCEED_MAX_DEPTH); + } + if (lock_trx->que_state == TRX_QUE_LOCK_WAIT) { /* Another trx ahead has requested lock in an From 757a1ff33acc48f4466cc1b720a6d45356963d43 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 26 Feb 2010 13:03:58 +0400 Subject: [PATCH 84/96] Applying InnoDB snapshot, fixes BUG#38901 Detailed revision comments: r6613 | inaam | 2010-02-09 20:23:09 +0200 (Tue, 09 Feb 2010) | 11 lines branches/5.1: Fix Bug #38901 InnoDB logs error repeatedly when trying to load page into buffer pool In buf_page_get_gen() if we are unable to read a page (because of corruption or some other reason) we keep on retrying. This fills up error log with millions of entries in no time and we'd eventually run out of disk space. This patch limits the number of attempts that we make (currently set to 100) and after that we abort with a message. rb://241 Approved by: Heikki --- storage/innobase/buf/buf0buf.c | 28 +++++++++++++++++++++++++++- storage/innobase/buf/buf0rea.c | 15 ++++++--------- storage/innobase/include/buf0rea.h | 6 ++---- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index 901ce8e0fef..45867388a61 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -224,6 +224,9 @@ in the free list to the frames. /* Value in microseconds */ static const int WAIT_FOR_READ = 20000; +/* Number of attemtps made to read in a page in the buffer pool */ +static const ulint BUF_PAGE_READ_MAX_RETRIES = 100; + buf_pool_t* buf_pool = NULL; /* The buffer buf_pool of the database */ #ifdef UNIV_DEBUG @@ -1160,6 +1163,7 @@ buf_page_get_gen( ulint fix_type; ibool success; ibool must_read; + ulint retries = 0; ut_ad(mtr); ut_ad((rw_latch == RW_S_LATCH) @@ -1200,7 +1204,29 @@ loop: return(NULL); } - buf_read_page(space, offset); + if (buf_read_page(space, offset)) { + retries = 0; + } else if (retries < BUF_PAGE_READ_MAX_RETRIES) { + ++retries; + } else { + fprintf(stderr, "InnoDB: Error: Unable" + " to read tablespace %lu page no" + " %lu into the buffer pool after" + " %lu attempts\n" + "InnoDB: The most probable cause" + " of this error may be that the" + " table has been corrupted.\n" + "InnoDB: You can try to fix this" + " problem by using" + " innodb_force_recovery.\n" + "InnoDB: Please see reference manual" + " for more details.\n" + "InnoDB: Aborting...\n", + space, offset, + BUF_PAGE_READ_MAX_RETRIES); + + ut_error; + } #ifdef UNIV_DEBUG buf_dbg_counter++; diff --git a/storage/innobase/buf/buf0rea.c b/storage/innobase/buf/buf0rea.c index fdec0206990..451436ef75b 100644 --- a/storage/innobase/buf/buf0rea.c +++ b/storage/innobase/buf/buf0rea.c @@ -299,30 +299,27 @@ buffer buf_pool if it is not already there. Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by the i/o-handler thread. Does a random read-ahead if it seems sensible. */ - -ulint +ibool buf_read_page( /*==========*/ - /* out: number of page read requests issued: this can - be > 1 if read-ahead occurred */ + /* out: TRUE if success, FALSE otherwise */ ulint space, /* in: space id */ ulint offset) /* in: page number */ { ib_longlong tablespace_version; ulint count; - ulint count2; ulint err; tablespace_version = fil_space_get_version(space); - count = buf_read_ahead_random(space, offset); + buf_read_ahead_random(space, offset); /* We do the i/o in the synchronous aio mode to save thread switches: hence TRUE */ - count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, + count = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space, tablespace_version, offset); - srv_buf_pool_reads+= count2; + srv_buf_pool_reads+= count; if (err == DB_TABLESPACE_DELETED) { ut_print_timestamp(stderr); fprintf(stderr, @@ -336,7 +333,7 @@ buf_read_page( /* Flush pages from the end of the LRU list if necessary */ buf_flush_free_margin(); - return(count + count2); + return(count > 0); } /************************************************************************ diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h index e4620172860..015f30fe6c2 100644 --- a/storage/innobase/include/buf0rea.h +++ b/storage/innobase/include/buf0rea.h @@ -18,12 +18,10 @@ buffer buf_pool if it is not already there. Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by the i/o-handler thread. Does a random read-ahead if it seems sensible. */ - -ulint +ibool buf_read_page( /*==========*/ - /* out: number of page read requests issued: this can - be > 1 if read-ahead occurred */ + /* out: TRUE if success, FALSE otherwise */ ulint space, /* in: space id */ ulint offset);/* in: page number */ /************************************************************************ From 42d56179506b8d8a289d0bfa7b112c54b15e4b6e Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 26 Feb 2010 13:04:24 +0400 Subject: [PATCH 85/96] Applying InnoDB snapshot, fixes BUG#50691 Detailed revision comments: r6669 | jyang | 2010-02-11 12:24:19 +0200 (Thu, 11 Feb 2010) | 7 lines branches/5.1: Fix bug #50691, AIX implementation of readdir_r causes InnoDB errors. readdir_r() returns an non-NULL value in the case of reaching the end of a directory. It should not be treated as an error return. rb://238 approved by Marko --- storage/innobase/os/os0file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 085f62daacc..7373a97cfb0 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -759,7 +759,15 @@ next_file: #ifdef HAVE_READDIR_R ret = readdir_r(dir, (struct dirent*)dirent_buf, &ent); - if (ret != 0) { + if (ret != 0 +#ifdef UNIV_AIX + /* On AIX, only if we got non-NULL 'ent' (result) value and + a non-zero 'ret' (return) value, it indicates a failed + readdir_r() call. An NULL 'ent' with an non-zero 'ret' + would indicate the "end of the directory" is reached. */ + && ent != NULL +#endif + ) { fprintf(stderr, "InnoDB: cannot read directory %s, error %lu\n", dirname, (ulong)ret); From cc01fc3f5f1860670113f10a1ac968a8067ab071 Mon Sep 17 00:00:00 2001 From: Evgeny Potemkin Date: Fri, 26 Feb 2010 14:17:00 +0300 Subject: [PATCH 86/96] Bug#50843: Filesort used instead of clustered index led to performance degradation. Filesort + join cache combination is preferred to full index scan because it is usually faster. But it's not the case when the index is clustered one. Now test_if_skip_sort_order function prefers filesort only if index isn't clustered. --- mysql-test/r/innodb_mysql.result | 14 ++++++++++++++ mysql-test/t/innodb_mysql.test | 12 ++++++++++++ sql/sql_select.cc | 19 +++++++++++++------ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index b54fb90b412..c4279018cb8 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -2281,4 +2281,18 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; 1 DROP TABLE t1; +# +# Bug#50843: Filesort used instead of clustered index led to +# performance degradation. +# +create table t1(f1 int not null primary key, f2 int) engine=innodb; +create table t2(f1 int not null, key (f1)) engine=innodb; +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1),(2),(3); +explain select t1.* from t1 left join t2 using(f1) group by t1.f1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 +1 SIMPLE t2 ref f1 f1 4 test.t1.f1 1 Using index +drop table t1,t2; +# End of 5.1 tests diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index d9fecccfbdc..a3c11b8b8d6 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -545,5 +545,17 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; DROP TABLE t1; +--echo # +--echo # Bug#50843: Filesort used instead of clustered index led to +--echo # performance degradation. +--echo # +create table t1(f1 int not null primary key, f2 int) engine=innodb; +create table t2(f1 int not null, key (f1)) engine=innodb; +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1),(2),(3); +explain select t1.* from t1 left join t2 using(f1) group by t1.f1; +drop table t1,t2; +--echo # + --echo End of 5.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 52f9aae7a0c..c4fac5b50ef 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13304,12 +13304,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ if (select_limit >= table_records) { - /* - filesort() and join cache are usually faster than reading in - index order and not using join cache - */ - if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1) - DBUG_RETURN(0); keys= *table->file->keys_to_use_for_scanning(); keys.merge(table->covering_keys); @@ -13459,6 +13453,19 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, } } } + + /* + filesort() and join cache are usually faster than reading in + index order and not using join cache, except in case that chosen + index is clustered primary key. + */ + if ((select_limit >= table_records) && + (tab->type == JT_ALL && + tab->join->tables > tab->join->const_tables + 1) && + ((unsigned) best_key != table->s->primary_key || + !table->file->primary_key_is_clustered())) + DBUG_RETURN(0); + if (best_key >= 0) { bool quick_created= FALSE; From fe94dec6799b81ddc6660b3d9301deff5ac82507 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 26 Feb 2010 15:39:25 +0400 Subject: [PATCH 87/96] Bug#50995 Having clause on subquery result produces incorrect results. The problem is that cond->fix_fields(thd, 0) breaks condition(cuts off 'having'). The reason of that is that NULL valued Item pointer is present in the middle of Item list and it breaks the Item processing loop. --- mysql-test/r/having.result | 20 ++++++++++++++++++++ mysql-test/t/having.test | 26 ++++++++++++++++++++++++++ sql/item_cmpfunc.h | 18 +++++++++++++++--- sql/sql_select.cc | 8 +++++--- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index 9c3cc8fc89e..68ba34e353c 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -430,4 +430,24 @@ SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL; b COUNT(DISTINCT a) NULL 1 DROP TABLE t1; +# +# Bug#50995 Having clause on subquery result produces incorrect results. +# +CREATE TABLE t1 +( +id1 INT, +id2 INT NOT NULL, +INDEX id1(id2) +); +INSERT INTO t1 SET id1=1, id2=1; +INSERT INTO t1 SET id1=2, id2=1; +INSERT INTO t1 SET id1=3, id2=1; +SELECT t1.id1, +(SELECT 0 FROM DUAL +WHERE t1.id1=t1.id1) AS amount FROM t1 +WHERE t1.id2 = 1 +HAVING amount > 0 +ORDER BY t1.id1; +id1 amount +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index af9af4fe1fc..185ca4bdddb 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -442,4 +442,30 @@ INSERT INTO t1 VALUES (1, 1), (2,2), (3, NULL); SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL; DROP TABLE t1; + +--echo # +--echo # Bug#50995 Having clause on subquery result produces incorrect results. +--echo # + +CREATE TABLE t1 +( + id1 INT, + id2 INT NOT NULL, + INDEX id1(id2) +); + +INSERT INTO t1 SET id1=1, id2=1; +INSERT INTO t1 SET id1=2, id2=1; +INSERT INTO t1 SET id1=3, id2=1; + +SELECT t1.id1, +(SELECT 0 FROM DUAL + WHERE t1.id1=t1.id1) AS amount FROM t1 +WHERE t1.id2 = 1 +HAVING amount > 0 +ORDER BY t1.id1; + +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 38025ff0af5..425f54fb079 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1474,9 +1474,21 @@ public: Item_cond(THD *thd, Item_cond *item); Item_cond(List &nlist) :Item_bool_func(), list(nlist), abort_on_null(0) {} - bool add(Item *item) { return list.push_back(item); } - bool add_at_head(Item *item) { return list.push_front(item); } - void add_at_head(List *nlist) { list.prepand(nlist); } + bool add(Item *item) + { + DBUG_ASSERT(item); + return list.push_back(item); + } + bool add_at_head(Item *item) + { + DBUG_ASSERT(item); + return list.push_front(item); + } + void add_at_head(List *nlist) + { + DBUG_ASSERT(nlist->elements); + list.prepand(nlist); + } bool fix_fields(THD *, Item **ref); enum Type type() const { return COND_ITEM; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b9f59fac4d6..1d88343ad6d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8200,7 +8200,8 @@ static Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, else { DBUG_ASSERT(cond->type() == Item::COND_ITEM); - ((Item_cond *) cond)->add_at_head(&eq_list); + if (eq_list.elements) + ((Item_cond *) cond)->add_at_head(&eq_list); } cond->quick_fix_field(); @@ -15657,7 +15658,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) Item_cond_and *cond=new Item_cond_and(); TABLE *table=join_tab->table; - int error; + int error= 0; if (!cond) DBUG_RETURN(TRUE); @@ -15675,7 +15676,8 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) cond->fix_fields(thd, (Item**)&cond); if (join_tab->select) { - error=(int) cond->add(join_tab->select->cond); + if (join_tab->select->cond) + error=(int) cond->add(join_tab->select->cond); join_tab->select_cond=join_tab->select->cond=cond; } else if ((join_tab->select= make_select(join_tab->table, 0, 0, cond, 0, From 6f51e9e4f8e1d9615952788c722389fa36dda4c8 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 26 Feb 2010 14:49:13 +0200 Subject: [PATCH 88/96] Bug #51468: mysqld_multi is broken in 5.1.44 Fixed a syntax error in mysqld_multi.sh --- scripts/mysqld_multi.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 528a1ca2e98..3d3853bcb22 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -71,7 +71,6 @@ sub main print "WARNING: --config-file is deprecated and will be removed\n"; print "in MySQL 5.6. Please use --defaults-extra-file instead\n"; } - } } foreach (@defaults_options) From 17cb596bb0a7965e599f56efdcb45cf9c98d3f36 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 1 Mar 2010 10:35:14 +0200 Subject: [PATCH 89/96] tree version change --- .bzr-mysql/default.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf index 557df1b1ffe..f79c1cd6319 100644 --- a/.bzr-mysql/default.conf +++ b/.bzr-mysql/default.conf @@ -1,4 +1,4 @@ [MYSQL] post_commit_to = "commits@lists.mysql.com" post_push_to = "commits@lists.mysql.com" -tree_name = "mysql-5.0-bugteam" +tree_name = "mysql-5.0" From c3a6c0f0e33fa50420c0afdae96b40fa9e90861d Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Mon, 1 Mar 2010 10:19:39 +0100 Subject: [PATCH 90/96] Update the README file for new contributed software, as provided by Trudy Pelzer. --- README | 1384 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 1011 insertions(+), 373 deletions(-) diff --git a/README b/README index 7da14e60f51..2d612bbdab6 100644 --- a/README +++ b/README @@ -1,3 +1,534 @@ +DO NOT TRANSLATE OR LOCALIZE + +*************************************************************************** + +%%The following software may be included in this product: +FindGTest.cmake (part of CMake 2.8.0) + +Use of any of this software is governed by the terms of the license below: + +# Copyright 2009 Kitware, Inc. +# Copyright 2009 Philip Lowman +# Copyright 2009 Daniel Blezek +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#=========================================================================== +== +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) +# +# Thanks to Daniel Blezek for the GTEST_ADD_TESTS code + + +Text of Copyright.txt mentioned above: + +CMake - Cross Platform Makefile Generator +Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the names of Kitware, Inc., the Insight Software Consortium, + nor the names of their contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*************************************************************************** + +%%The following software may be included in this product: +Cmake + +Use of any of this software is governed by the terms of the license below: + +CMake is distributed under BSD License + + Copyright (c) 2008, Kitware, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + * Neither the name of Kitware, Inc. nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY Kitware, Inc. "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL Kitware Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. + +Additional License(s) + +cmake-2.4.8/Utilities/cmtar/compat/gethostname.c: + gethostname.c: minimal substitute for missing gethostname() function + created 2000-Mar-02 jmk + requires SVR4 uname() and -lc + + by Jim Knoble + Copyright ? 2000 Jim Knoble + + Permission to use, copy, modify, distribute, and sell this software + and its documentation for any purpose is hereby granted without fee, + provided that the above copyright notice appear in all copies and + that both that copyright notice and this permission notice appear in + supporting documentation. + + This software is provided "as is", without warranty of any kind, + express or implied, including but not limited to the warranties of + merchantability, fitness for a particular purpose and + noninfringement. In no event shall the author(s) be liable for any + claim, damages or other liability, whether in an action of contract, + tort or otherwise, arising from, out of or in connection with the + software or the use or other dealings in the software. + +---------------------------------- + +* Originally written by Steven M. Bellovin while +* at the University of North Carolina at Chapel Hill. Later tweaked by +* a couple of people on Usenet. Completely overhauled by Rich $alz +* and Jim Berets in August, 1990. +* +* This code is in the public domain and has no copyright. + +------------------------------- + + THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT. + You may freely copy it for use as a template for your own field types. + If you develop a field type that might be of general use, please send + it back to the ncurses maintainers for inclusion in the next version. + +************************************************************************** + + * + Author : Per Foreby, perf@efd.lth.se + * + Author : Juergen Pfeifer, juergen.pfeifer@gmx.net + * + + * +************************************************************************** + +---------------------------------------- + + Copyright (c) 2002 Insight Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for +details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +-------------------------------------------- + + Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free +Software Foundati +on, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. + +--------------------------------------------------- + +cmake-2.4.8/Utilities/cmzlib/zlib.h: + zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.4, March 11th, 2002 + + Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must +not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source +distribution. + + Jean-loup Gailly Mark Adler + +---------------------------------------------- + + This source code was modified by Martin Hedenfalk + for + use in Curl. His latest changes were done 2000-09-18. + + It has since been patched away like a madman by Daniel Stenberg + to make it better applied to curl conditions, and to +make + it not use globals, pollute name space and more. This source code +awaits a + rewrite to work around the paragraph 2 in the BSD licenses as explained + below. + + Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Hgskolan + It has since been patched and modified a lot by Daniel Stenberg + to make it better applied to curl conditions, and to +make + it not use globals, pollute name space and more. This source code +awaits a + rewrite to work around the paragraph 2 in the BSD licenses as explained + below. + + Copyright (c) 1998, 1999 Kungliga Tekniska Hgskolan + (Royal Institute of Technology, Stockholm, Sweden). + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the Institute nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE +LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + +--------------------------------------------- + + Permission to use, copy, modify, and distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND + CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. + +-------------------------------------------------- + +cmake-2.4.8/Utilities/cmcurl/inet_pton.c, +cmake-2.4.8/Source/CTest/Curl/inet_pto +n.c: + This is from the BIND 4.9.4 release, modified to compile by itself + + Copyright (c) 1996 by Internet Software Consortium. + + Permission to use, copy, modify, and distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM +DISCLAIMS + ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES + OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS + SOFTWARE. + +------------------------------------------------------- + +* Copyright (C) 2001 by Eric Kidd. All rights reserved. +* Copyright (C) 2001 by Luke Howard. All rights reserved. +* Copyright (C) 2002 Ximian, Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* 3. The name of the author may not be used to endorse or promote products +* derived from this software without specific prior written +permission. +* +* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +** SUCH DAMAGE. + +--------------------------------------------------- + + Copyright (c) 1994 + The Regents of the University of California. All rights reserved. + + This code is derived from software contributed to Berkeley by + Chuck Karish of Mindcraft, Inc. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + Copyright (c) 1985, 1986 The Regents of the University of California. + All rights reserved. + + This code is derived from software contributed to Berkeley by + James A. Woods, derived from original work by Spencer Thomas + and Joseph Orost. + +------------------------------------------------ + + Copyright (c) 1989, 1993, 1994 + The Regents of the University of California. All rights reserved. + + This code is derived from software contributed to Berkeley by + Guido van Rossum. + + Copyright (c) 1990 The Regents of the University of California. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the University of + California, Berkeley and its contributors. + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +------------------------------------------------------ + + Project ___| | | | _ \| | + / __| | | | |_) | | + | (__| |_| | _ <| |___ + \___|\___/|_| \_\_____| + + Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + + Copyright (C) 2004, Daniel Stenberg, , et al. + + This software is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at http://curl.haxx.se/docs/copyright.html. + + You may opt to use, copy, modify, merge, publish, distribute and/or sell + copies of the Software, and permit persons to whom the Software is + furnished to do so, under the terms of the COPYING file. + + This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + KIND, either express or implied. + +------------------------------------------------------------ + +*************************************************************************** + Copyright (c) 1998 Free Software Foundation, Inc. + * + Copyright (c) 1998,2000 Free Software Foundation, Inc. + * + + * + Permission is hereby granted, free of charge, to any person obtaining +a * + copy of this software and associated documentation files (the + * + "Software"), to deal in the Software without restriction, including + * + without limitation the rights to use, copy, modify, merge, publish, + * + distribute, distribute with modifications, sublicense, and/or sell + * + copies of the Software, and to permit persons to whom the Software is + * + furnished to do so, subject to the following conditions: + * + + * + The above copyright notice and this permission notice shall be +included * + in all copies or substantial portions of the Software. + * + + * + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS * + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. * + IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, * + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * + THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + + * + + * + Except as contained in this notice, the name(s) of the above +copyright * + holders shall not be used in advertising or otherwise to promote the + * + sale, use or other dealings in this Software without prior written + * + authorization. + * + *************************************************************************** + +------------------------------------------------------ + + Copyright (c) 1997 Todd C. Miller + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + *************************************************************************** %%The following software may be included in this product: @@ -520,6 +1051,189 @@ Use of any of this software is governed by the terms of the license below: *************************************************************************** +%%The following software may be included in this product: +libevent + +Use of any of this software is governed by the terms of the license below: + +/* + * Copyright (c) 2000-2004 Niels Provos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +Additional License(s) + +http://creativecommons.org/licenses/publicdomain + +*************************************************************************** + +%%The following software may be included in this product: +Async DNS Library + +Use of any of this software is governed by the terms of the license below: + +/* Async DNS Library + * Adam Langley + * http://www.imperialviolet.org/eventdns.html + * Public Domain code + * + * This software is Public Domain. To view a copy of the public domain dedication, + * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to + * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. + * + * I ask and expect, but do not require, that all derivative works contain an + * attribution similar to: + * Parts developed by Adam Langley + * + * You may wish to replace the word "Parts" with something else depending on + * the amount of original code. + * + * (Derivative works does not include programs which link against, run or include + * the source verbatim in their source distributions) + * + * Version: 0.1b + */ + +*************************************************************************** + +%%The following software may be included in this product: +log.c + +Use of any of this software is governed by the terms of the license below: + +/* $OpenBSD: err.c,v 1.2 2002/06/25 15:50:15 mickey Exp $ */ + +/* + * log.c + * + * Based on err.c, which was adapted from OpenBSD libc *err* *warn* code. + * + * Copyright (c) 2005 Nick Mathewson + * + * Copyright (c) 2000 Dug Song + * + * Copyright (c) 1993 + * The Regents of the University of California. All rights +reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +*************************************************************************** + +%%The following software may be included in this product: +min_heap.h + +Use of any of this software is governed by the terms of the license below: + +/* + * Copyright (c) 2006 Maxim Yegorushkin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +*************************************************************************** + +%%The following software may be included in this product: +win32.c + +Use of any of this software is governed by the terms of the license below: + +/* + * Copyright 2000-2002 Niels Provos + * Copyright 2003 Michael A. Davis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +*************************************************************************** + %%The following software may be included in this product: regex++ @@ -619,6 +1333,113 @@ http://bioinfo.mbb.yale.edu/genome/yeast/cluster/database/mysql/include/t_ctype. *************************************************************************** +%%The following software may be included in this product: +SHA-1 in C + +Use of any of this software is governed by the terms of the license below: + + SHA-1 in C + By Steve Reid + 100% Public Domain + +Additional License(s) + +100% Public Domain + +*************************************************************************** + +%%The following software may be included in this product: +TCMalloc (part of google-perftools) + +Use of any of this software is governed by the terms of the license below: + +# Copyright (c) 1998-2006, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Additional License(s) + +*** File src/tests/ptmalloc/thread-m.h contains this GPLv2 (or later) +text: + +/* Basic platform-independent macro definitions for mutexes and + thread-specific data. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Wolfram Gloger , 1996. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If +not, + write to the Free Software Foundation, Inc., 59 Temple Place - +Suite 330, + Boston, MA 02111-1307, USA. */ + + + +*** File src/tests/ptmalloc/malloc-machine.h contains this BSD like text: + +/* Basic platform-independent macro definitions for mutexes, + thread-specific data and parameters for malloc. + Posix threads (pthreads) version. + Copyright (C) 2004 Wolfram Gloger . + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that (i) the above copyright notices and this permission +notice appear in all copies of the software and related documentation, +and (ii) the name of Wolfram Gloger may not be used in any advertising +or publicity relating to the software. + +THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, +INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY +DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY +OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +*/ + +*************************************************************************** + %%The following software may be included in this product: The tz database @@ -670,6 +1491,167 @@ archived older versions of code and data; there is also a smaller HTTP mirror. *************************************************************************** +%%The following software may be included in this product: +UnicodeData.txt + +Use of any of this software is governed by the terms of the license below: + +Unicode Terms of Use + + For the general privacy policy governing access to this site, see the +Unicode Privacy Policy. For trademark usage, see the Unicode Consortium® +Trademarks and Logo Policy. + Notice to End User: Terms of Use + Carefully read the following legal agreement ("Agreement"). Use or copying +of the software and/or codes provided with this agreement (The "Software") +constitutes your acceptance of these terms + + 1. Unicode Copyright. + 1. Copyright © 1991-2008 Unicode, Inc. All rights reserved. + 2. Certain documents and files on this website contain a legend +indicating that "Modification is permitted." Any person is hereby authorized, +without fee, to modify such documents and files to create derivative works +conforming to the Unicode® Standard, subject to Terms and Conditions herein. + 3. Any person is hereby authorized, without fee, to view, use, +reproduce, and distribute all documents and files solely for informational +purposes in the creation of products supporting the Unicode Standard, subject to +the Terms and Conditions herein. + 4. Further specifications of rights and restrictions pertaining to +the use of the particular set of data files known as the "Unicode Character +Database" can be found in Exhibit 1. + 5. Each version of the Unicode Standard has further specifications +of rights and restrictions of use. For the book editions, these are found on the +back of the title page. For the online edition, certain files (such as the PDF +files for book chapters and code charts) carry specific restrictions. All other +files are covered under these general Terms of Use. To request a permission to +reproduce any part of the Unicode Standard, please contact the Unicode Consortium. + 6. No license is granted to "mirror" the Unicode website where a +fee is charged for access to the "mirror" site. + 7. Modification is not permitted with respect to this document. All +copies of this document must be verbatim. + 2. Restricted Rights Legend. Any technical data or software which is +licensed to the United States of America, its agencies and/or instrumentalities +under this Agreement is commercial technical data or commercial computer +software developed exclusively at private expense as defined in FAR 2.101, or +DFARS 252.227-7014 (June 1995), as applicable. For technical data, use, +duplication, or disclosure by the Government is subject to restrictions as set +forth in DFARS 202.227-7015 Technical Data, Commercial and Items (Nov 1995) and +this Agreement. For Software, in accordance with FAR 12-212 or DFARS 227-7202, +as applicable, use, duplication or disclosure by the Government is subject to +the restrictions set forth in this Agreement. + 3. Warranties and Disclaimers. + 1. This publication and/or website may include technical or +typographical errors or other inaccuracies . Changes are periodically added to +the information herein; these changes will be incorporated in new editions of +the publication and/or website. Unicode may make improvements and/or changes in +the product(s) and/or program(s) described in this publication and/or website at +any time. + 2. If this file has been purchased on magnetic or optical media +from Unicode, Inc. the sole and exclusive remedy for any claim will be exchange +of the defective media within ninety (90) days of original purchase. + 3. EXCEPT AS PROVIDED IN SECTION C.2, THIS PUBLICATION AND/OR +SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND EITHER EXPRESS, +IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. UNICODE +AND ITS LICENSORS ASSUME NO RESPONSIBILITY FOR ERRORS OR OMISSIONS IN THIS +PUBLICATION AND/OR SOFTWARE OR OTHER DOCUMENTS WHICH ARE REFERENCED BY OR LINKED +TO THIS PUBLICATION OR THE UNICODE WEBSITE. + 4. Waiver of Damages. In no event shall Unicode or its licensors be +liable for any special, incidental, indirect or consequential damages of any +kind, or any damages whatsoever, whether or not Unicode was advised of the +possibility of the damage, including, without limitation, those resulting from +the following: loss of use, data or profits, in connection with the use, +modification or distribution of this information or its derivatives. + 5. Trademarks. + 1. Unicode and the Unicode logo are registered trademarks of +Unicode, Inc. + 2. This site contains product names and corporate names of other +companies. All product names and company names and logos mentioned herein are +the trademarks or registered trademarks of their respective owners. Other +products and corporate names mentioned herein which are trademarks of a third +party are used only for explanation and for the owners' benefit and with no +intent to infringe. + 3. Use of third party products or information referred to herein is +at the user’s risk. + 6. Miscellaneous. + 1. Jurisdiction and Venue. This server is operated from a location +in the State of California, United States of America. Unicode makes no +representation that the materials are appropriate for use in other locations. If +you access this server from other locations, you are responsible for compliance +with local laws. This Agreement, all use of this site and any claims and damages +resulting from use of this site are governed solely by the laws of the State of +California without regard to any principles which would apply the laws of a +different jurisdiction. The user agrees that any disputes regarding this site +shall be resolved solely in the courts located in Santa Clara County, +California. The user agrees said courts have personal jurisdiction and agree to +waive any right to transfer the dispute to any other forum. + 2. Modification by Unicode Unicode shall have the right to modify +this Agreement at any time by posting it to this site. The user may not assign +any part of this Agreement without Unicode’s prior written consent. + 3. Taxes. The user agrees to pay any taxes arising from access to +this website or use of the information herein, except for those based on +Unicode’s net income. + 4. Severability. If any provision of this Agreement is declared +invalid or unenforceable, the remaining provisions of this Agreement shall +remain in effect. + 5. Entire Agreement. This Agreement constitutes the entire +agreement between the parties. + +EXHIBIT 1 +UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE + + Unicode Data Files include all data files under the directories +http://www.unicode.org/Public/, http://www.unicode.org/reports/, and +http://www.unicode.org/cldr/data/ . Unicode Software includes any source code +published in the Unicode Standard or under the directories +http://www.unicode.org/Public/, http://www.unicode.org/reports/, and +http://www.unicode.org/cldr/data/. + + NOTICE TO USER: Carefully read the following legal agreement. BY +DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA FILES +("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY ACCEPT, AND +AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU +DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES +OR SOFTWARE. + + COPYRIGHT AND PERMISSION NOTICE + + Copyright © 1991-2008 Unicode, Inc. All rights reserved. Distributed under +the Terms of Use in http://www.unicode.org/copyright.html. + + Permission is hereby granted, free of charge, to any person obtaining a copy +of the Unicode data files and any associated documentation (the "Data Files") or +Unicode software and any associated documentation (the "Software") to deal in +the Data Files or Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files or +Software are furnished to do so, provided that (a) the above copyright notice(s) +and this permission notice appear with all copies of the Data Files or Software, +(b) both the above copyright notice(s) and this permission notice appear in +associated documentation, and (c) there is clear notice in each modified Data +File or in the Software as well as in the documentation associated with the Data +File(s) or Software that the data or software has been modified. + + THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD +PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING +OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE. + + Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in these Data Files or Software without prior written authorization of the +copyright holder. + + Unicode and the Unicode logo are trademarks of Unicode, Inc., and may be +registered in some jurisdictions. All other trademarks and registered trademarks +mentioned herein are the property of their respective owners. + +*************************************************************************** + %%The following software may be included in this product: zlib @@ -703,6 +1685,35 @@ Use of any of this software is governed by the terms of the license below: *************************************************************************** +%%The following software may be included in this product: +dtoa.c + +Use of any of this software is governed by the terms of the license below: + +/**************************************************************** + + This file incorporates work covered by the following copyright and + permission notice: + + The author of this software is David M. Gay. + + Copyright (c) 1991, 2000, 2001 by Lucent Technologies. + + Permission to use, copy, modify, and distribute this software for any + purpose without fee is hereby granted, provided that this entire + notice is included in all copies of any software which is or includes a copy + or modification of this software and in all copies of the supporting + documentation for such software. + + THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY + REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + + ***************************************************************/ + +*************************************************************************** + %%The following software may be included in this product: getarg.{c,h} @@ -1239,376 +2250,3 @@ Use of any of this software is governed by the terms of the license below: */ *************************************************************************** - -%%The following software may be included in this product: -libevent - -Use of any of this software is governed by the terms of the license below: - -/* - * Copyright (c) 2000-2004 Niels Provos - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -Additional License(s) - -http://creativecommons.org/licenses/publicdomain - -*************************************************************************** - -%%The following software may be included in this product: -Async DNS Library - -Use of any of this software is governed by the terms of the license below: - -/* Async DNS Library - * Adam Langley - * http://www.imperialviolet.org/eventdns.html - * Public Domain code - * - * This software is Public Domain. To view a copy of the public domain dedication, - * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to - * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. - * - * I ask and expect, but do not require, that all derivative works contain an - * attribution similar to: - * Parts developed by Adam Langley - * - * You may wish to replace the word "Parts" with something else depending on - * the amount of original code. - * - * (Derivative works does not include programs which link against, run or include - * the source verbatim in their source distributions) - * - * Version: 0.1b - */ - -*************************************************************************** - -%%The following software may be included in this product: -log.c - -Use of any of this software is governed by the terms of the license below: - -/* $OpenBSD: err.c,v 1.2 2002/06/25 15:50:15 mickey Exp $ */ - -/* - * log.c - * - * Based on err.c, which was adapted from OpenBSD libc *err* *warn* code. - * - * Copyright (c) 2005 Nick Mathewson - * - * Copyright (c) 2000 Dug Song - * - * Copyright (c) 1993 - * The Regents of the University of California. All rights -reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -*************************************************************************** - -%%The following software may be included in this product: -min_heap.h - -Use of any of this software is governed by the terms of the license below: - -/* - * Copyright (c) 2006 Maxim Yegorushkin - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -*************************************************************************** - -%%The following software may be included in this product: -win32.c - -Use of any of this software is governed by the terms of the license below: - -/* - * Copyright 2000-2002 Niels Provos - * Copyright 2003 Michael A. Davis - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -*************************************************************************** - -%%The following software may be included in this product: -UnicodeData.txt - -Use of any of this software is governed by the terms of the license below: - -Unicode Terms of Use - - For the general privacy policy governing access to this site, see the -Unicode Privacy Policy. For trademark usage, see the Unicode Consortium® -Trademarks and Logo Policy. - Notice to End User: Terms of Use - Carefully read the following legal agreement ("Agreement"). Use or copying -of the software and/or codes provided with this agreement (The "Software") -constitutes your acceptance of these terms - - 1. Unicode Copyright. - 1. Copyright © 1991-2008 Unicode, Inc. All rights reserved. - 2. Certain documents and files on this website contain a legend -indicating that "Modification is permitted." Any person is hereby authorized, -without fee, to modify such documents and files to create derivative works -conforming to the Unicode® Standard, subject to Terms and Conditions herein. - 3. Any person is hereby authorized, without fee, to view, use, -reproduce, and distribute all documents and files solely for informational -purposes in the creation of products supporting the Unicode Standard, subject to -the Terms and Conditions herein. - 4. Further specifications of rights and restrictions pertaining to -the use of the particular set of data files known as the "Unicode Character -Database" can be found in Exhibit 1. - 5. Each version of the Unicode Standard has further specifications -of rights and restrictions of use. For the book editions, these are found on the -back of the title page. For the online edition, certain files (such as the PDF -files for book chapters and code charts) carry specific restrictions. All other -files are covered under these general Terms of Use. To request a permission to -reproduce any part of the Unicode Standard, please contact the Unicode Consortium. - 6. No license is granted to "mirror" the Unicode website where a -fee is charged for access to the "mirror" site. - 7. Modification is not permitted with respect to this document. All -copies of this document must be verbatim. - 2. Restricted Rights Legend. Any technical data or software which is -licensed to the United States of America, its agencies and/or instrumentalities -under this Agreement is commercial technical data or commercial computer -software developed exclusively at private expense as defined in FAR 2.101, or -DFARS 252.227-7014 (June 1995), as applicable. For technical data, use, -duplication, or disclosure by the Government is subject to restrictions as set -forth in DFARS 202.227-7015 Technical Data, Commercial and Items (Nov 1995) and -this Agreement. For Software, in accordance with FAR 12-212 or DFARS 227-7202, -as applicable, use, duplication or disclosure by the Government is subject to -the restrictions set forth in this Agreement. - 3. Warranties and Disclaimers. - 1. This publication and/or website may include technical or -typographical errors or other inaccuracies . Changes are periodically added to -the information herein; these changes will be incorporated in new editions of -the publication and/or website. Unicode may make improvements and/or changes in -the product(s) and/or program(s) described in this publication and/or website at -any time. - 2. If this file has been purchased on magnetic or optical media -from Unicode, Inc. the sole and exclusive remedy for any claim will be exchange -of the defective media within ninety (90) days of original purchase. - 3. EXCEPT AS PROVIDED IN SECTION C.2, THIS PUBLICATION AND/OR -SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND EITHER EXPRESS, -IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. UNICODE -AND ITS LICENSORS ASSUME NO RESPONSIBILITY FOR ERRORS OR OMISSIONS IN THIS -PUBLICATION AND/OR SOFTWARE OR OTHER DOCUMENTS WHICH ARE REFERENCED BY OR LINKED -TO THIS PUBLICATION OR THE UNICODE WEBSITE. - 4. Waiver of Damages. In no event shall Unicode or its licensors be -liable for any special, incidental, indirect or consequential damages of any -kind, or any damages whatsoever, whether or not Unicode was advised of the -possibility of the damage, including, without limitation, those resulting from -the following: loss of use, data or profits, in connection with the use, -modification or distribution of this information or its derivatives. - 5. Trademarks. - 1. Unicode and the Unicode logo are registered trademarks of -Unicode, Inc. - 2. This site contains product names and corporate names of other -companies. All product names and company names and logos mentioned herein are -the trademarks or registered trademarks of their respective owners. Other -products and corporate names mentioned herein which are trademarks of a third -party are used only for explanation and for the owners' benefit and with no -intent to infringe. - 3. Use of third party products or information referred to herein is -at the user’s risk. - 6. Miscellaneous. - 1. Jurisdiction and Venue. This server is operated from a location -in the State of California, United States of America. Unicode makes no -representation that the materials are appropriate for use in other locations. If -you access this server from other locations, you are responsible for compliance -with local laws. This Agreement, all use of this site and any claims and damages -resulting from use of this site are governed solely by the laws of the State of -California without regard to any principles which would apply the laws of a -different jurisdiction. The user agrees that any disputes regarding this site -shall be resolved solely in the courts located in Santa Clara County, -California. The user agrees said courts have personal jurisdiction and agree to -waive any right to transfer the dispute to any other forum. - 2. Modification by Unicode Unicode shall have the right to modify -this Agreement at any time by posting it to this site. The user may not assign -any part of this Agreement without Unicode’s prior written consent. - 3. Taxes. The user agrees to pay any taxes arising from access to -this website or use of the information herein, except for those based on -Unicode’s net income. - 4. Severability. If any provision of this Agreement is declared -invalid or unenforceable, the remaining provisions of this Agreement shall -remain in effect. - 5. Entire Agreement. This Agreement constitutes the entire -agreement between the parties. - -EXHIBIT 1 -UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE - - Unicode Data Files include all data files under the directories -http://www.unicode.org/Public/, http://www.unicode.org/reports/, and -http://www.unicode.org/cldr/data/ . Unicode Software includes any source code -published in the Unicode Standard or under the directories -http://www.unicode.org/Public/, http://www.unicode.org/reports/, and -http://www.unicode.org/cldr/data/. - - NOTICE TO USER: Carefully read the following legal agreement. BY -DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA FILES -("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY ACCEPT, AND -AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU -DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES -OR SOFTWARE. - - COPYRIGHT AND PERMISSION NOTICE - - Copyright © 1991-2008 Unicode, Inc. All rights reserved. Distributed under -the Terms of Use in http://www.unicode.org/copyright.html. - - Permission is hereby granted, free of charge, to any person obtaining a copy -of the Unicode data files and any associated documentation (the "Data Files") or -Unicode software and any associated documentation (the "Software") to deal in -the Data Files or Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, and/or sell copies of -the Data Files or Software, and to permit persons to whom the Data Files or -Software are furnished to do so, provided that (a) the above copyright notice(s) -and this permission notice appear with all copies of the Data Files or Software, -(b) both the above copyright notice(s) and this permission notice appear in -associated documentation, and (c) there is clear notice in each modified Data -File or in the Software as well as in the documentation associated with the Data -File(s) or Software that the data or software has been modified. - - THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD -PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS -NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL -DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING -OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE. - - Except as contained in this notice, the name of a copyright holder shall not -be used in advertising or otherwise to promote the sale, use or other dealings -in these Data Files or Software without prior written authorization of the -copyright holder. - - Unicode and the Unicode logo are trademarks of Unicode, Inc., and may be -registered in some jurisdictions. All other trademarks and registered trademarks -mentioned herein are the property of their respective owners. - -*************************************************************************** - -%%The following software may be included in this product: -dtoa.c - -Use of any of this software is governed by the terms of the license below: - -/**************************************************************** - - This file incorporates work covered by the following copyright and - permission notice: - - The author of this software is David M. Gay. - - Copyright (c) 1991, 2000, 2001 by Lucent Technologies. - - Permission to use, copy, modify, and distribute this software for any - purpose without fee is hereby granted, provided that this entire - notice is included in all copies of any software which is or includes a copy - or modification of this software and in all copies of the supporting - documentation for such software. - - THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY - REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - - ***************************************************************/ - -*************************************************************************** From dec27c317b36b4e8c662fb217e66731f18707944 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Mon, 1 Mar 2010 13:07:06 +0300 Subject: [PATCH 91/96] Add configure.am to .bzrignore. --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index cee9eca9db5..08dded71ee5 100644 --- a/.bzrignore +++ b/.bzrignore @@ -3079,3 +3079,4 @@ libmysqld/sys_vars.cc libmysqld/keycaches.cc client/dtoa.c libmysqld/sql_audit.cc +configure.am From ef5ef725e359ec5714f36b4ca2a4e6282f198b88 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Mon, 1 Mar 2010 13:07:42 +0300 Subject: [PATCH 92/96] Disable partition_debug_sync temporarily awaiting a patch from Mattias. --- mysql-test/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 3b34ef368e1..6c50d988bdc 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -15,3 +15,4 @@ sp_sync : Bug#48157 2010-02-06 5.5-m3 demands a differnt soluti innodb-autoinc : Bug#49267 2009-12-02 test fails on windows because of different case mode innodb : Bug#49396 2009-12-03 test fails in embedded mode plugin_load : Bug#42144 2009-12-21 alik plugin_load fails +partition_debug_sync : 2010-03-01 alik Disable partition_debug_sync temporarily awaiting a patch from Mattias From 158e89792a489f344f5bbe631e78c5e0847bedce Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Mon, 1 Mar 2010 11:42:44 +0100 Subject: [PATCH 93/96] Spec file for RPMs: Now that Oracle has legally acquired Sun, change the copyright owner and the vendor. --- support-files/mysql.spec.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 18e55d7a06a..91848ffc8bd 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -21,7 +21,8 @@ # NOTE: "vendor" is used in upgrade/downgrade check, so you can't # change these, has to be exactly as is. %define mysql_old_vendor MySQL AB -%define mysql_vendor Sun Microsystems, Inc. +%define mysql_vendor_2 Sun Microsystems, Inc. +%define mysql_vendor Oracle and/or its affiliates %define mysql_version @VERSION@ @@ -617,6 +618,7 @@ if [ $? -eq 0 -a -n "$installed" ]; then vendor=`rpm -q --queryformat='%{VENDOR}' "$installed" 2>&1` version=`rpm -q --queryformat='%{VERSION}' "$installed" 2>&1` myoldvendor='%{mysql_old_vendor}' + myvendor_2='%{mysql_vendor_2}' myvendor='%{mysql_vendor}' myversion='%{mysql_version}' @@ -628,10 +630,10 @@ if [ $? -eq 0 -a -n "$installed" ]; then [ -z "$new_family" ] && new_family="" error_text= - if [ "$vendor" != "$myoldvendor" -a "$vendor" != "$myvendor" ]; then + if [ "$vendor" != "$myoldvendor" -a "$vendor" != "$myvendor_2" -a "$vendor" != "$myvendor" ]; then error_text="$error_text The current MySQL server package is provided by a different -vendor ($vendor) than $myoldvendor or $myvendor. +vendor ($vendor) than $myoldvendor, $myvendor_2, or $myvendor. Some files may be installed to different locations, including log files and the service startup script in %{_sysconfdir}/init.d/. " @@ -1036,6 +1038,11 @@ fi # merging BK trees) ############################################################################## %changelog +* Mon Mar 01 2010 Joerg Bruehe + +- Set "Oracle and/or its affiliates" as the vendor and copyright owner, + accept upgrading from packages showing MySQL or Sun as vendor. + * Fri Feb 05 2010 Joerg Bruehe - Formatting changes: From 0bba3928b0b3fef2c079638c58c2a9c4d654c7fd Mon Sep 17 00:00:00 2001 From: "hery.ramilison@sun.com" <> Date: Mon, 1 Mar 2010 11:58:26 +0100 Subject: [PATCH 94/96] Raise version number after cloning 5.1.45 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 45f86677a86..904c54abb5f 100644 --- a/configure.in +++ b/configure.in @@ -12,7 +12,7 @@ dnl dnl When changing the major version number please also check the switch dnl statement in mysqlbinlog::check_master_version(). You may also need dnl to update version.c in ndb. -AC_INIT([MySQL Server], [5.1.45], [], [mysql]) +AC_INIT([MySQL Server], [5.1.46], [], [mysql]) AC_CONFIG_SRCDIR([sql/mysqld.cc]) AC_CANONICAL_SYSTEM From b2838f1a706efcd4f69ae55e22a4a896635c4045 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 2 Mar 2010 00:05:30 +0100 Subject: [PATCH 95/96] manual merge fix of bug#42438 in mysql-next-mr-merge --- mysql-test/r/partition_debug_sync.result | 14 +++++++++++--- mysql-test/t/disabled.def | 1 - mysql-test/t/partition_debug_sync.test | 14 +++++++++++--- sql/sql_base.cc | 2 ++ sql/sql_table.cc | 7 ++++--- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/partition_debug_sync.result b/mysql-test/r/partition_debug_sync.result index 5eb19f42395..5ab1044934b 100644 --- a/mysql-test/r/partition_debug_sync.result +++ b/mysql-test/r/partition_debug_sync.result @@ -4,6 +4,8 @@ SET DEBUG_SYNC= 'RESET'; # Bug#42438: Crash ha_partition::change_table_ptr # Test when remove partitioning is done while drop table is waiting # for the table. +# After MDL was introduced, there is no longer any race, so test is done +# by adding a small sleep to verify that the delete waits. # Con 1 SET DEBUG_SYNC= 'RESET'; CREATE TABLE t1 @@ -16,21 +18,25 @@ ENGINE = MYISAM PARTITION p1 VALUES LESS THAN (20), PARTITION p2 VALUES LESS THAN (100), PARTITION p3 VALUES LESS THAN MAXVALUE ) */; +SET SESSION debug= "+d,sleep_before_create_table_no_lock"; SET DEBUG_SYNC= 'alter_table_before_create_table_no_lock SIGNAL removing_partitioning WAIT_FOR waiting_for_alter'; SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL partitioning_removed'; ALTER TABLE t1 REMOVE PARTITIONING; # Con default SET DEBUG_SYNC= 'now WAIT_FOR removing_partitioning'; -SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter'; +SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL waiting_for_alter'; SET DEBUG_SYNC= 'rm_table_part2_before_delete_table WAIT_FOR partitioning_removed'; DROP TABLE IF EXISTS t1; # Con 1 +SET SESSION debug= "-d,sleep_before_create_table_no_lock"; SET DEBUG_SYNC= 'RESET'; SET DEBUG_SYNC= 'RESET'; # # Bug#42438: Crash ha_partition::change_table_ptr # Test when remove partitioning is failing due to drop table is already # in progress. +# After MDL was introduced, there is no longer any race, so test is done +# by adding a small sleep to verify that the alter waits. CREATE TABLE t2 (a INTEGER, b INTEGER NOT NULL, @@ -41,14 +47,16 @@ ENGINE = MYISAM PARTITION p1 VALUES LESS THAN (20), PARTITION p2 VALUES LESS THAN (100), PARTITION p3 VALUES LESS THAN MAXVALUE ) */; -SET DEBUG_SYNC= 'before_lock_tables_takes_lock SIGNAL removing_partitions WAIT_FOR waiting_for_alter'; +SET DEBUG_SYNC= 'open_tables_acquire_upgradable_mdl SIGNAL removing_partitions WAIT_FOR waiting_for_alter'; SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done'; ALTER TABLE t2 REMOVE PARTITIONING; # Con default +SET SESSION debug= "+d,sleep_before_part2_delete_table"; SET DEBUG_SYNC= 'now WAIT_FOR removing_partitions'; -SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter'; +SET DEBUG_SYNC= 'rm_table_part2_before_delete_table SIGNAL waiting_for_alter'; SET DEBUG_SYNC= 'rm_table_part2_before_binlog SIGNAL delete_done'; DROP TABLE IF EXISTS t2; +SET SESSION debug= "-d,sleep_before_part2_delete_table"; # Con 1 ERROR 42S02: Table 'test.t2' doesn't exist SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 6c50d988bdc..3b34ef368e1 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -15,4 +15,3 @@ sp_sync : Bug#48157 2010-02-06 5.5-m3 demands a differnt soluti innodb-autoinc : Bug#49267 2009-12-02 test fails on windows because of different case mode innodb : Bug#49396 2009-12-03 test fails in embedded mode plugin_load : Bug#42144 2009-12-21 alik plugin_load fails -partition_debug_sync : 2010-03-01 alik Disable partition_debug_sync temporarily awaiting a patch from Mattias diff --git a/mysql-test/t/partition_debug_sync.test b/mysql-test/t/partition_debug_sync.test index 69bc86a8bb7..9165006f537 100644 --- a/mysql-test/t/partition_debug_sync.test +++ b/mysql-test/t/partition_debug_sync.test @@ -15,6 +15,8 @@ SET DEBUG_SYNC= 'RESET'; --echo # Bug#42438: Crash ha_partition::change_table_ptr --echo # Test when remove partitioning is done while drop table is waiting --echo # for the table. +--echo # After MDL was introduced, there is no longer any race, so test is done +--echo # by adding a small sleep to verify that the delete waits. connect(con1, localhost, root,,); --echo # Con 1 SET DEBUG_SYNC= 'RESET'; @@ -28,18 +30,20 @@ ENGINE = MYISAM PARTITION p1 VALUES LESS THAN (20), PARTITION p2 VALUES LESS THAN (100), PARTITION p3 VALUES LESS THAN MAXVALUE ) */; +SET SESSION debug= "+d,sleep_before_create_table_no_lock"; SET DEBUG_SYNC= 'alter_table_before_create_table_no_lock SIGNAL removing_partitioning WAIT_FOR waiting_for_alter'; SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL partitioning_removed'; --send ALTER TABLE t1 REMOVE PARTITIONING connection default; --echo # Con default SET DEBUG_SYNC= 'now WAIT_FOR removing_partitioning'; -SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter'; +SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL waiting_for_alter'; SET DEBUG_SYNC= 'rm_table_part2_before_delete_table WAIT_FOR partitioning_removed'; DROP TABLE IF EXISTS t1; --echo # Con 1 connection con1; --reap +SET SESSION debug= "-d,sleep_before_create_table_no_lock"; connection default; SET DEBUG_SYNC= 'RESET'; connection con1; @@ -49,6 +53,8 @@ SET DEBUG_SYNC= 'RESET'; --echo # Bug#42438: Crash ha_partition::change_table_ptr --echo # Test when remove partitioning is failing due to drop table is already --echo # in progress. +--echo # After MDL was introduced, there is no longer any race, so test is done +--echo # by adding a small sleep to verify that the alter waits. CREATE TABLE t2 (a INTEGER, b INTEGER NOT NULL, @@ -59,15 +65,17 @@ ENGINE = MYISAM PARTITION p1 VALUES LESS THAN (20), PARTITION p2 VALUES LESS THAN (100), PARTITION p3 VALUES LESS THAN MAXVALUE ) */; -SET DEBUG_SYNC= 'before_lock_tables_takes_lock SIGNAL removing_partitions WAIT_FOR waiting_for_alter'; +SET DEBUG_SYNC= 'open_tables_acquire_upgradable_mdl SIGNAL removing_partitions WAIT_FOR waiting_for_alter'; SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done'; --send ALTER TABLE t2 REMOVE PARTITIONING connection default; --echo # Con default +SET SESSION debug= "+d,sleep_before_part2_delete_table"; SET DEBUG_SYNC= 'now WAIT_FOR removing_partitions'; -SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter'; +SET DEBUG_SYNC= 'rm_table_part2_before_delete_table SIGNAL waiting_for_alter'; SET DEBUG_SYNC= 'rm_table_part2_before_binlog SIGNAL delete_done'; DROP TABLE IF EXISTS t2; +SET SESSION debug= "-d,sleep_before_part2_delete_table"; --echo # Con 1 connection con1; --error ER_NO_SUCH_TABLE diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 254b4ce7dd3..63b6a168590 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4377,6 +4377,8 @@ open_tables_acquire_upgradable_mdl(THD *thd, TABLE_LIST *tables_start, MDL_request_list mdl_requests; TABLE_LIST *table; + DEBUG_SYNC(thd, "open_tables_acquire_upgradable_mdl"); + for (table= tables_start; table && table != tables_end; table= table->next_global) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 969f8bdf789..3c6b4760fd3 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1897,18 +1897,15 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, mysql_ha_rm_tables(thd, tables); /* Disable drop of enabled log tables, must be done before name locking */ - mysql_mutex_lock(&LOCK_open); for (table= tables; table; table= table->next_local) { if (check_if_log_table(table->db_length, table->db, table->table_name_length, table->table_name, 1)) { - mysql_mutex_unlock(&LOCK_open); my_error(ER_BAD_LOG_STATEMENT, MYF(0), "DROP"); DBUG_RETURN(1); } } - mysql_mutex_unlock(&LOCK_open); if (!drop_temporary) { @@ -2061,6 +2058,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, Is exclusive meta-data lock enough ? */ DEBUG_SYNC(thd, "rm_table_part2_before_delete_table"); + DBUG_EXECUTE_IF("sleep_before_part2_delete_table", + my_sleep(100000);); mysql_mutex_lock(&LOCK_open); if (drop_temporary || ((access(path, F_OK) && @@ -7128,6 +7127,8 @@ view_err: create_info->data_file_name=create_info->index_file_name=0; DEBUG_SYNC(thd, "alter_table_before_create_table_no_lock"); + DBUG_EXECUTE_IF("sleep_before_create_table_no_lock", + my_sleep(100000);); /* Create a table with a temporary name. With create_info->frm_only == 1 this creates a .frm file only. From 0c01d8d86c681d57373bf4dd41d555a5f643cec8 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Tue, 2 Mar 2010 10:22:33 +0300 Subject: [PATCH 96/96] Remove test from experimental because Bug 45578 and 46010 are fixed. --- mysql-test/collections/default.experimental | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index fa9c3d75b7f..aa240fc2ce9 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -1,12 +1,10 @@ # For easier human reading (MTR doesn't care), please keep entries # in alphabetical order. This also helps with merge conflict resolution. -binlog.binlog_tmp_table* # Bug#45578:2009-07-10 alik Test binlog_tmp_table fails ramdonly on PB2: Unknown table 't2' binlog.binlog_multi_engine # joro : NDB tests marked as experimental as agreed with bochklin funcs_1.charset_collation_1 # depends on compile-time decisions -main.ctype_gbk_binlog @solaris # Bug#46010: main.ctype_gbk_binlog fails sporadically : Table 't2' already exists main.information_schema # Bug#47449 2009-09-19 alik main.information_schema and innodb.innodb_information_schema fail sporadically main.lock_multi_bug38499 # Bug#47448 2009-09-19 alik main.lock_multi_bug38499 times out sporadically main.lock_multi_bug38691 @solaris # Bug#47792 2009-10-02 alik main.lock_multi_bug38691 times out sporadically on Solaris 10