summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bruehe <joerg@mysql.com>2009-07-13 10:25:12 +0200
committerJoerg Bruehe <joerg@mysql.com>2009-07-13 10:25:12 +0200
commit0a853c2fea91ecbac970ee7057fab1cdf7f631f1 (patch)
tree0bfd1eb3be6df4f43865812fc0ad98e9c1d81b0e
parent25ec6c7b8601e46148f86503d8c0cf235d0d095a (diff)
parent88430260883e9f326c7aca12f9594f8e6ead0701 (diff)
downloadmariadb-git-0a853c2fea91ecbac970ee7057fab1cdf7f631f1.tar.gz
Merge main 5.1 into 5.1-build.
-rw-r--r--client/mysql.cc73
-rw-r--r--client/mysqlbinlog.cc60
-rw-r--r--client/mysqldump.c4
-rw-r--r--cmd-line-utils/readline/bind.c48
-rw-r--r--cmd-line-utils/readline/complete.c15
-rw-r--r--cmd-line-utils/readline/display.c23
-rw-r--r--cmd-line-utils/readline/histexpand.c6
-rw-r--r--cmd-line-utils/readline/histfile.c6
-rw-r--r--cmd-line-utils/readline/history.h4
-rw-r--r--cmd-line-utils/readline/input.c2
-rw-r--r--cmd-line-utils/readline/isearch.c8
-rw-r--r--cmd-line-utils/readline/kill.c18
-rw-r--r--cmd-line-utils/readline/macro.c6
-rw-r--r--cmd-line-utils/readline/mbutil.c8
-rw-r--r--cmd-line-utils/readline/misc.c18
-rw-r--r--cmd-line-utils/readline/nls.c6
-rw-r--r--cmd-line-utils/readline/readline.c2
-rw-r--r--cmd-line-utils/readline/readline.h6
-rw-r--r--cmd-line-utils/readline/rlprivate.h28
-rw-r--r--cmd-line-utils/readline/rltty.c4
-rw-r--r--cmd-line-utils/readline/search.c10
-rw-r--r--cmd-line-utils/readline/terminal.c81
-rw-r--r--cmd-line-utils/readline/text.c38
-rw-r--r--cmd-line-utils/readline/tilde.c2
-rw-r--r--cmd-line-utils/readline/undo.c7
-rw-r--r--cmd-line-utils/readline/util.c6
-rw-r--r--cmd-line-utils/readline/vi_mode.c66
-rw-r--r--configure.in44
-rw-r--r--extra/yassl/src/handshake.cpp6
-rw-r--r--extra/yassl/src/yassl_imp.cpp2
-rw-r--r--extra/yassl/taocrypt/include/modes.hpp2
-rw-r--r--extra/yassl/taocrypt/src/asn.cpp6
-rw-r--r--include/hash.h2
-rw-r--r--mysql-test/collections/default.experimental12
-rw-r--r--mysql-test/extra/rpl_tests/rpl_reset_slave.test54
-rw-r--r--mysql-test/include/commit.inc8
-rw-r--r--mysql-test/include/wait_for_slave_io_error.inc23
-rw-r--r--mysql-test/r/commit_1innodb.result8
-rw-r--r--mysql-test/r/ctype_cp932_binlog_stm.result16
-rw-r--r--mysql-test/r/ctype_gbk_binlog.result26
-rw-r--r--mysql-test/r/func_set.result13
-rw-r--r--mysql-test/r/gis.result48
-rw-r--r--mysql-test/r/innodb_bug40565.result9
-rw-r--r--mysql-test/r/innodb_bug45357.result7
-rw-r--r--mysql-test/r/mysql-bug45236.result8
-rw-r--r--mysql-test/r/partition.result9
-rw-r--r--mysql-test/r/query_cache_debug.result4
-rw-r--r--mysql-test/r/select.result79
-rw-r--r--mysql-test/r/sp-fib.result21
-rw-r--r--mysql-test/r/trigger.result14
-rw-r--r--mysql-test/r/trigger_notembedded.result14
-rw-r--r--mysql-test/r/type_newdecimal.result57
-rw-r--r--mysql-test/r/view.result111
-rw-r--r--mysql-test/r/xa.result8
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result43
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result30
-rw-r--r--mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test143
-rw-r--r--mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt1
-rw-r--r--mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test73
-rw-r--r--mysql-test/suite/funcs_1/r/charset_collation.result40
-rw-r--r--mysql-test/suite/funcs_1/r/charset_collation_1.result312
-rw-r--r--mysql-test/suite/funcs_1/r/charset_collation_2.result314
-rw-r--r--mysql-test/suite/funcs_1/r/charset_collation_3.result312
-rw-r--r--mysql-test/suite/funcs_1/r/storedproc.result8
-rw-r--r--mysql-test/suite/funcs_1/t/charset_collation.test (renamed from mysql-test/suite/funcs_1/datadict/charset_collation.inc)91
-rw-r--r--mysql-test/suite/funcs_1/t/charset_collation_1.test32
-rw-r--r--mysql-test/suite/funcs_1/t/charset_collation_2.test24
-rw-r--r--mysql-test/suite/funcs_1/t/charset_collation_3.test25
-rw-r--r--mysql-test/suite/funcs_1/t/disabled.def3
-rw-r--r--mysql-test/suite/funcs_1/t/storedproc.test19
-rw-r--r--mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result33
-rw-r--r--mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result7
-rw-r--r--mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result1204
-rw-r--r--mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test26
-rw-r--r--mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test11
-rw-r--r--mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test44
-rw-r--r--mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result135
-rw-r--r--mysql-test/suite/rpl/r/rpl_concurrency_error.result119
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_reset_slave.result23
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_reset_slave.result23
-rw-r--r--mysql-test/suite/rpl/t/disabled.def2
-rw-r--r--mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test395
-rw-r--r--mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_concurrency_error.test149
-rw-r--r--mysql-test/suite/rpl/t/rpl_init_slave.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp.test3
-rw-r--r--mysql-test/suite/rpl_ndb/t/disabled.def1
-rw-r--r--mysql-test/t/ctype_cp932_binlog_stm.test5
-rw-r--r--mysql-test/t/ctype_gbk_binlog.test36
-rw-r--r--mysql-test/t/disabled.def2
-rw-r--r--mysql-test/t/func_set.test13
-rw-r--r--mysql-test/t/gis.test24
-rw-r--r--mysql-test/t/init_connect.test5
-rw-r--r--mysql-test/t/innodb_bug40565.test10
-rw-r--r--mysql-test/t/innodb_bug45357.test10
-rw-r--r--mysql-test/t/mysql-bug45236.test45
-rw-r--r--mysql-test/t/partition.test11
-rw-r--r--mysql-test/t/query_cache_debug.test5
-rw-r--r--mysql-test/t/select.test86
-rw-r--r--mysql-test/t/sp-fib.test24
-rw-r--r--mysql-test/t/trigger.test26
-rw-r--r--mysql-test/t/trigger_notembedded.test23
-rw-r--r--mysql-test/t/type_newdecimal.test29
-rw-r--r--mysql-test/t/view.test32
-rw-r--r--mysql-test/t/xa.test14
-rw-r--r--mysys/hash.c36
-rw-r--r--mysys/my_getopt.c15
-rw-r--r--scripts/mysqld_multi.sh20
-rw-r--r--sql/ha_ndbcluster.cc46
-rw-r--r--sql/ha_ndbcluster_binlog.cc32
-rw-r--r--sql/handler.cc13
-rw-r--r--sql/item.cc67
-rw-r--r--sql/item_cmpfunc.cc5
-rw-r--r--sql/item_func.cc70
-rw-r--r--sql/item_func.h3
-rw-r--r--sql/item_geofunc.cc13
-rw-r--r--sql/item_strfunc.cc5
-rw-r--r--sql/item_sum.cc15
-rw-r--r--sql/log.cc145
-rw-r--r--sql/log.h5
-rw-r--r--sql/log_event.cc45
-rw-r--r--sql/log_event.h1
-rw-r--r--sql/my_decimal.h17
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/parse_file.cc4
-rw-r--r--sql/rpl_reporting.cc7
-rw-r--r--sql/rpl_reporting.h10
-rw-r--r--sql/slave.cc49
-rw-r--r--sql/slave.h4
-rw-r--r--sql/spatial.h12
-rw-r--r--sql/sql_acl.cc47
-rw-r--r--sql/sql_analyse.cc2
-rw-r--r--sql/sql_base.cc50
-rw-r--r--sql/sql_class.cc5
-rw-r--r--sql/sql_db.cc18
-rw-r--r--sql/sql_delete.cc8
-rw-r--r--sql/sql_help.cc2
-rw-r--r--sql/sql_insert.cc52
-rw-r--r--sql/sql_lex.cc15
-rw-r--r--sql/sql_load.cc8
-rw-r--r--sql/sql_parse.cc27
-rw-r--r--sql/sql_partition.cc56
-rw-r--r--sql/sql_prepare.cc15
-rw-r--r--sql/sql_rename.cc6
-rw-r--r--sql/sql_repl.cc3
-rw-r--r--sql/sql_select.cc83
-rw-r--r--sql/sql_show.cc34
-rw-r--r--sql/sql_string.cc15
-rw-r--r--sql/sql_table.cc96
-rw-r--r--sql/sql_trigger.cc2
-rw-r--r--sql/sql_update.cc8
-rw-r--r--sql/sql_view.cc14
-rw-r--r--sql/sql_yacc.yy6
-rw-r--r--sql/structs.h4
-rw-r--r--sql/table.cc65
-rw-r--r--sql/thr_malloc.cc2
-rw-r--r--sql/time.cc8
-rw-r--r--sql/tztime.cc4
-rw-r--r--sql/uniques.cc4
-rw-r--r--storage/federated/ha_federated.cc42
-rw-r--r--storage/ibmdb2i/db2i_charsetSupport.cc5
-rw-r--r--storage/ibmdb2i/db2i_collationSupport.cc14
-rw-r--r--storage/ibmdb2i/db2i_conversion.cc44
-rw-r--r--storage/ibmdb2i/db2i_myconv.h1
-rw-r--r--storage/ibmdb2i/db2i_rir.cc401
-rw-r--r--storage/ibmdb2i/ha_ibmdb2i.h10
-rw-r--r--storage/innobase/Makefile.am5
-rw-r--r--storage/innobase/btr/btr0cur.c1
-rw-r--r--storage/innobase/include/fsp0fsp.h58
-rw-r--r--storage/innobase/include/fsp0types.h89
-rw-r--r--storage/innobase/include/mtr0log.ic24
-rw-r--r--storage/innobase/include/trx0rseg.ic1
-rw-r--r--storage/innobase/include/trx0sys.h6
-rw-r--r--storage/innobase/row/row0mysql.c9
-rw-r--r--storage/innobase/trx/trx0rec.c1
-rw-r--r--storage/innobase/trx/trx0sys.c12
-rw-r--r--storage/myisam/ha_myisam.cc2
-rw-r--r--strings/decimal.c6
179 files changed, 5141 insertions, 2109 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 5f360b83dc1..5afbc2e960b 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -115,7 +115,7 @@ extern "C" {
#define PROMPT_CHAR '\\'
#define DEFAULT_DELIMITER ";"
-#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L)
+#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L * 1024L)
typedef struct st_status
{
@@ -2004,7 +2004,7 @@ static COMMANDS *find_command(char *name,char cmd_char)
(uchar*)commands[i].name,len) &&
!commands[i].name[len] &&
(!end || (end && commands[i].takes_params))) ||
- !name && commands[i].cmd_char == cmd_char))
+ (!name && commands[i].cmd_char == cmd_char)))
{
DBUG_PRINT("exit",("found command: %s", commands[i].name));
DBUG_RETURN(&commands[i]);
@@ -2163,7 +2163,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
buffer.length(0);
}
else if (!*ml_comment && (!*in_string && (inchar == '#' ||
- inchar == '-' && pos[1] == '-' &&
+ (inchar == '-' && pos[1] == '-' &&
/*
The third byte is either whitespace or is the
end of the line -- which would occur only
@@ -2171,7 +2171,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
itself whitespace and should also match.
*/
(my_isspace(charset_info,pos[2]) ||
- !pos[2]))))
+ !pos[2])))))
{
// Flush previously accepted characters
if (out != line)
@@ -2732,7 +2732,7 @@ static int com_server_help(String *buffer __attribute__((unused)),
{
MYSQL_ROW cur;
const char *server_cmd= buffer->ptr();
- char cmd_buf[100];
+ char cmd_buf[100 + 1];
MYSQL_RES *result;
int error;
@@ -4264,41 +4264,36 @@ com_status(String *buffer __attribute__((unused)),
MYSQL_RES *result;
LINT_INIT(result);
+ if (mysql_real_query_for_lazy(
+ C_STRING_WITH_LEN("select DATABASE(), USER() limit 1")))
+ return 0;
+
tee_puts("--------------", stdout);
usage(1); /* Print version */
- if (connected)
+ tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
+ /*
+ Don't remove "limit 1",
+ it is protection againts SQL_SELECT_LIMIT=0
+ */
+ if (mysql_store_result_for_lazy(&result))
{
- tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
- /*
- Don't remove "limit 1",
- it is protection againts SQL_SELECT_LIMIT=0
- */
- if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") &&
- (result=mysql_use_result(&mysql)))
+ MYSQL_ROW cur=mysql_fetch_row(result);
+ if (cur)
{
- MYSQL_ROW cur=mysql_fetch_row(result);
- if (cur)
- {
- tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
- tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
- }
- mysql_free_result(result);
- }
-#ifdef HAVE_OPENSSL
- if ((status_str= mysql_get_ssl_cipher(&mysql)))
- tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
- status_str);
- else
-#endif /* HAVE_OPENSSL */
- tee_puts("SSL:\t\t\tNot in use", stdout);
+ tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
+ tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
+ }
+ mysql_free_result(result);
}
+
+#ifdef HAVE_OPENSSL
+ if ((status_str= mysql_get_ssl_cipher(&mysql)))
+ tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
+ status_str);
else
- {
- vidattr(A_BOLD);
- tee_fprintf(stdout, "\nNo connection\n");
- vidattr(A_NORMAL);
- return 0;
- }
+#endif /* HAVE_OPENSSL */
+ tee_puts("SSL:\t\t\tNot in use", stdout);
+
if (skip_updates)
{
vidattr(A_BOLD);
@@ -4317,8 +4312,14 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff));
/* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
- if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1") &&
- (result=mysql_use_result(&mysql)))
+ if (mysql_real_query_for_lazy(C_STRING_WITH_LEN(
+ "select @@character_set_client, @@character_set_connection, "
+ "@@character_set_server, @@character_set_database limit 1")))
+ {
+ if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
+ return 0;
+ }
+ if (mysql_store_result_for_lazy(&result))
{
MYSQL_ROW cur=mysql_fetch_row(result);
if (cur)
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 2cf91ec7da5..e200f23813a 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -681,6 +681,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
{
char ll_buff[21];
Log_event_type ev_type= ev->get_type_code();
+ my_bool destroy_evt= TRUE;
DBUG_ENTER("process_event");
print_event_info->short_form= short_form;
Exit_status retval= OK_CONTINUE;
@@ -689,8 +690,8 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
Format events are not concerned by --offset and such, we always need to
read them to be able to process the wanted events.
*/
- if ((rec_count >= offset) &&
- ((my_time_t)(ev->when) >= start_datetime) ||
+ if (((rec_count >= offset) &&
+ ((my_time_t)(ev->when) >= start_datetime)) ||
(ev_type == FORMAT_DESCRIPTION_EVENT))
{
if (ev_type != FORMAT_DESCRIPTION_EVENT)
@@ -871,12 +872,63 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
break;
}
case TABLE_MAP_EVENT:
+ {
+ Table_map_log_event *map= ((Table_map_log_event *)ev);
+ if (shall_skip_database(map->get_db_name()))
+ {
+ print_event_info->m_table_map_ignored.set_table(map->get_table_id(), map);
+ destroy_evt= FALSE;
+ goto end;
+ }
+ }
case WRITE_ROWS_EVENT:
case DELETE_ROWS_EVENT:
case UPDATE_ROWS_EVENT:
case PRE_GA_WRITE_ROWS_EVENT:
case PRE_GA_DELETE_ROWS_EVENT:
case PRE_GA_UPDATE_ROWS_EVENT:
+ {
+ if (ev_type != TABLE_MAP_EVENT)
+ {
+ Rows_log_event *e= (Rows_log_event*) ev;
+ Table_map_log_event *ignored_map=
+ print_event_info->m_table_map_ignored.get_table(e->get_table_id());
+ bool skip_event= (ignored_map != NULL);
+
+ /*
+ end of statement check:
+ i) destroy/free ignored maps
+ ii) if skip event, flush cache now
+ */
+ if (e->get_flags(Rows_log_event::STMT_END_F))
+ {
+ /*
+ Now is safe to clear ignored map (clear_tables will also
+ delete original table map events stored in the map).
+ */
+ if (print_event_info->m_table_map_ignored.count() > 0)
+ print_event_info->m_table_map_ignored.clear_tables();
+
+ /*
+ One needs to take into account an event that gets
+ filtered but was last event in the statement. If this is
+ the case, previous rows events that were written into
+ IO_CACHEs still need to be copied from cache to
+ result_file (as it would happen in ev->print(...) if
+ event was not skipped).
+ */
+ if (skip_event)
+ {
+ if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file) ||
+ copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file)))
+ goto err;
+ }
+ }
+
+ /* skip the event check */
+ if (skip_event)
+ goto end;
+ }
/*
These events must be printed in base64 format, if printed.
base64 format requires a FD event to be safe, so if no FD
@@ -900,6 +952,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
goto err;
}
/* FALL THROUGH */
+ }
default:
ev->print(result_file, print_event_info);
}
@@ -919,7 +972,8 @@ end:
{
if (remote_opt)
ev->temp_buf= 0;
- delete ev;
+ if (destroy_evt) /* destroy it later if not set (ignored table map) */
+ delete ev;
}
DBUG_RETURN(retval);
}
diff --git a/client/mysqldump.c b/client/mysqldump.c
index d755a17b815..6b2c2a06834 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -4110,7 +4110,7 @@ static my_bool dump_all_views_in_db(char *database)
for (numrows= 0 ; (table= getTableName(1)); )
{
char *end= strmov(afterdot, table);
- if (include_table(hash_key,end - hash_key))
+ if (include_table((uchar*) hash_key,end - hash_key))
{
numrows++;
dynstr_append_checked(&query, quote_name(table, table_buff, 1));
@@ -4131,7 +4131,7 @@ static my_bool dump_all_views_in_db(char *database)
while ((table= getTableName(0)))
{
char *end= strmov(afterdot, table);
- if (include_table(hash_key, end - hash_key))
+ if (include_table((uchar*) hash_key, end - hash_key))
get_view_structure(table, database);
}
if (opt_xml)
diff --git a/cmd-line-utils/readline/bind.c b/cmd-line-utils/readline/bind.c
index 2338f73f6c9..490691943a8 100644
--- a/cmd-line-utils/readline/bind.c
+++ b/cmd-line-utils/readline/bind.c
@@ -79,7 +79,7 @@ static int _rl_read_init_file PARAMS((const char *, int));
static int glean_key_from_name PARAMS((char *));
static int find_boolean_var PARAMS((const char *));
-static char *_rl_get_string_variable_value PARAMS((const char *));
+static const char *_rl_get_string_variable_value PARAMS((const char *));
static int substring_member_of_array PARAMS((char *, const char **));
static int currently_reading_init_file;
@@ -442,7 +442,7 @@ rl_translate_keyseq (seq, array, len)
{
register int i, c, l, temp;
- for (i = l = 0; c = seq[i]; i++)
+ for (i = l = 0; (c = seq[i]); i++)
{
if (c == '\\')
{
@@ -776,7 +776,8 @@ _rl_read_file (filename, sizep)
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
- if (file_size != finfo.st_size || file_size + 1 < file_size)
+if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
+ file_size + 1 < file_size)
{
if (file >= 0)
close (file);
@@ -807,7 +808,7 @@ _rl_read_file (filename, sizep)
/* Re-read the current keybindings file. */
int
rl_re_read_init_file (count, ignore)
- int count, ignore;
+ int count __attribute__((unused)), ignore __attribute__((unused));
{
int r;
r = rl_read_init_file ((const char *)NULL);
@@ -1031,7 +1032,7 @@ parser_if (args)
/* Invert the current parser state if there is anything on the stack. */
static int
parser_else (args)
- char *args;
+ char *args __attribute__((unused));
{
register int i;
@@ -1062,7 +1063,7 @@ parser_else (args)
_rl_parsing_conditionalized_out from the stack. */
static int
parser_endif (args)
- char *args;
+ char *args __attribute__((unused));
{
if (if_stack_depth)
_rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
@@ -1185,7 +1186,7 @@ rl_parse_and_bind (string)
{
int passc = 0;
- for (i = 1; c = string[i]; i++)
+ for (i = 1; (c = string[i]); i++)
{
if (passc)
{
@@ -1276,7 +1277,7 @@ rl_parse_and_bind (string)
int delimiter, passc;
delimiter = string[i++];
- for (passc = 0; c = string[i]; i++)
+ for (passc = 0; (c = string[i]); i++)
{
if (passc)
{
@@ -1436,7 +1437,7 @@ static struct {
#if defined (VISIBLE_STATS)
{ "visible-stats", &rl_visible_stats, 0 },
#endif /* VISIBLE_STATS */
- { (char *)NULL, (int *)NULL }
+ { (char *)NULL, (int *)NULL, 0 }
};
static int
@@ -1505,7 +1506,7 @@ static struct {
{ "editing-mode", V_STRING, sv_editmode },
{ "isearch-terminators", V_STRING, sv_isrchterm },
{ "keymap", V_STRING, sv_keymap },
- { (char *)NULL, 0 }
+ { (char *)NULL, 0, (_rl_sv_func_t*)NULL }
};
static int
@@ -1532,7 +1533,7 @@ bool_to_int (value)
(value[0] == '1' && value[1] == '\0'));
}
-char *
+const char *
rl_variable_value (name)
const char *name;
{
@@ -1799,7 +1800,7 @@ rl_set_keymap_from_edit_mode ()
#endif /* VI_MODE */
}
-char *
+const char *
rl_get_keymap_name_from_edit_mode ()
{
if (rl_editing_mode == emacs_mode)
@@ -2048,7 +2049,7 @@ rl_function_dumper (print_readably)
fprintf (rl_outstream, "\n");
- for (i = 0; name = names[i]; i++)
+ for (i = 0; (name = names[i]); i++)
{
rl_command_func_t *function;
char **invokers;
@@ -2108,7 +2109,7 @@ rl_function_dumper (print_readably)
the output in such a way that it can be read back in. */
int
rl_dump_functions (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
if (rl_dispatching)
fprintf (rl_outstream, "\r\n");
@@ -2188,7 +2189,7 @@ rl_macro_dumper (print_readably)
int
rl_dump_macros (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
if (rl_dispatching)
fprintf (rl_outstream, "\r\n");
@@ -2197,12 +2198,13 @@ rl_dump_macros (count, key)
return (0);
}
-static char *
+static const char *
_rl_get_string_variable_value (name)
const char *name;
{
static char numbuf[32];
- char *ret;
+ const char *ret;
+ char *tmp;
if (_rl_stricmp (name, "bell-style") == 0)
{
@@ -2230,11 +2232,11 @@ _rl_get_string_variable_value (name)
{
if (_rl_isearch_terminators == 0)
return 0;
- ret = _rl_untranslate_macro_value (_rl_isearch_terminators);
- if (ret)
+ tmp = _rl_untranslate_macro_value (_rl_isearch_terminators);
+ if (tmp)
{
- strncpy (numbuf, ret, sizeof (numbuf) - 1);
- free (ret);
+ strncpy (numbuf, tmp, sizeof (numbuf) - 1);
+ free (tmp);
numbuf[sizeof(numbuf) - 1] = '\0';
}
else
@@ -2257,7 +2259,7 @@ rl_variable_dumper (print_readably)
int print_readably;
{
int i;
- char *v;
+ const char *v;
for (i = 0; boolean_varlist[i].name; i++)
{
@@ -2286,7 +2288,7 @@ rl_variable_dumper (print_readably)
the output in such a way that it can be read back in. */
int
rl_dump_variables (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
if (rl_dispatching)
fprintf (rl_outstream, "\r\n");
diff --git a/cmd-line-utils/readline/complete.c b/cmd-line-utils/readline/complete.c
index 916aa5dd9b9..2745e4e4801 100644
--- a/cmd-line-utils/readline/complete.c
+++ b/cmd-line-utils/readline/complete.c
@@ -359,14 +359,14 @@ rl_complete (ignore, invoking_key)
/* List the possible completions. See description of rl_complete (). */
int
rl_possible_completions (ignore, invoking_key)
- int ignore, invoking_key;
+ int ignore __attribute__((unused)), invoking_key __attribute__((unused));
{
return (rl_complete_internal ('?'));
}
int
rl_insert_completions (ignore, invoking_key)
- int ignore, invoking_key;
+ int ignore __attribute__((unused)), invoking_key __attribute__((unused));
{
return (rl_complete_internal ('*'));
}
@@ -696,7 +696,8 @@ print_filename (to_print, full_pathname)
char *to_print, *full_pathname;
{
int printed_len, extension_char, slen, tlen;
- char *s, c, *new_full_pathname, *dn;
+ char *s, c, *new_full_pathname;
+ const char *dn;
extension_char = 0;
printed_len = fnprint (to_print);
@@ -783,7 +784,7 @@ print_filename (to_print, full_pathname)
static char *
rl_quote_filename (s, rtype, qcp)
char *s;
- int rtype;
+ int rtype __attribute__((unused));
char *qcp;
{
char *r;
@@ -884,7 +885,7 @@ _rl_find_completion_word (fp, dp)
/* We didn't find an unclosed quoted substring upon which to do
completion, so use the word break characters to find the
substring on which to complete. */
- while (rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_ANY))
+ while ((rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_ANY)))
{
scan = rl_line_buffer[rl_point];
@@ -1803,7 +1804,7 @@ rl_completion_matches (text, entry_function)
match_list = (char **)xmalloc ((match_list_size + 1) * sizeof (char *));
match_list[1] = (char *)NULL;
- while (string = (*entry_function) (text, matches))
+ while ((string = (*entry_function) (text, matches)))
{
if (matches + 1 == match_list_size)
match_list = (char **)xrealloc
@@ -2111,7 +2112,7 @@ rl_filename_completion_function (text, state)
ring the bell, and reset the counter to zero. */
int
rl_menu_complete (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
rl_compentry_func_t *our_func;
int matching_filenames, found_quote;
diff --git a/cmd-line-utils/readline/display.c b/cmd-line-utils/readline/display.c
index a68ddff8c88..f9b88f0006c 100644
--- a/cmd-line-utils/readline/display.c
+++ b/cmd-line-utils/readline/display.c
@@ -127,7 +127,7 @@ int _rl_want_redisplay = 0;
/* The stuff that gets printed out before the actual text of the line.
This is usually pointing to rl_prompt. */
-char *rl_display_prompt = (char *)NULL;
+const char *rl_display_prompt = (const char *)NULL;
/* Pseudo-global variables declared here. */
@@ -229,7 +229,10 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
int *lp, *lip, *niflp, *vlp;
{
char *r, *ret, *p, *igstart;
- int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
+ int l, rl, last, ignoring, ninvis, invfl, invflset, physchars;
+#if defined (HANDLE_MULTIBYTE)
+ int ind, pind;
+#endif
/* Short-circuit if we can. */
if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
@@ -242,7 +245,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
if (niflp)
*niflp = 0;
if (vlp)
- *vlp = lp ? *lp : strlen (r);
+ *vlp = lp ? *lp : (int)strlen (r);
return r;
}
@@ -459,9 +462,10 @@ rl_redisplay ()
register int in, out, c, linenum, cursor_linenum;
register char *line;
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
- int newlines, lpos, temp, modmark, n0, num;
- char *prompt_this_line;
+ int newlines, lpos, temp, modmark;
+ const char *prompt_this_line;
#if defined (HANDLE_MULTIBYTE)
+ int num, n0;
wchar_t wc;
size_t wc_bytes;
int wc_width;
@@ -626,7 +630,6 @@ rl_redisplay ()
contents of the command line? */
while (lpos >= _rl_screenwidth)
{
- int z;
/* fix from Darin Johnson <darin@acuson.com> for prompt string with
invisible characters that is longer than the screen width. The
prompt_invis_chars_first_line variable could be made into an array
@@ -635,6 +638,7 @@ rl_redisplay ()
prompts that exceed two physical lines?
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
#if defined (HANDLE_MULTIBYTE)
+ int z;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
n0 = num;
@@ -878,6 +882,7 @@ rl_redisplay ()
if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
{
int nleft, pos, changed_screen_line, tx;
+ char empty_str[1] = { 0 };
if (!rl_display_fixed || forced_display)
{
@@ -902,7 +907,7 @@ rl_redisplay ()
#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
#define VIS_CHARS(line) (visible_line + vis_lbreaks[line])
-#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
+#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? empty_str : VIS_CHARS(line)
#define INV_LINE(line) (invisible_line + inv_lbreaks[line])
/* For each line in the buffer, do the updating display. */
@@ -969,7 +974,7 @@ rl_redisplay ()
_rl_move_vert (linenum);
_rl_move_cursor_relative (0, tt);
_rl_clear_to_eol
- ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth);
+ ((linenum == _rl_vis_botlin) ? (int)strlen (tt) : _rl_screenwidth);
}
}
_rl_vis_botlin = inv_botlin;
@@ -2261,7 +2266,7 @@ static void
redraw_prompt (t)
char *t;
{
- char *oldp;
+ const char *oldp;
oldp = rl_display_prompt;
rl_save_prompt ();
diff --git a/cmd-line-utils/readline/histexpand.c b/cmd-line-utils/readline/histexpand.c
index 45377fc3b5e..ab8d8ecc866 100644
--- a/cmd-line-utils/readline/histexpand.c
+++ b/cmd-line-utils/readline/histexpand.c
@@ -87,14 +87,14 @@ char history_comment_char = '\0';
/* The list of characters which inhibit the expansion of text if found
immediately following history_expansion_char. */
-char *history_no_expand_chars = " \t\n\r=";
+const char *history_no_expand_chars = " \t\n\r=";
/* If set to a non-zero value, single quotes inhibit history expansion.
The default is 0. */
int history_quotes_inhibit_expansion = 0;
/* Used to split words by history_tokenize_internal. */
-char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
+const char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
/* If set, this points to a function that is called to verify that a
particular history expansion should be performed. */
@@ -203,7 +203,7 @@ get_history_event (string, caller_index, delimiting_quote)
}
/* Only a closing `?' or a newline delimit a substring search string. */
- for (local_index = i; c = string[i]; i++)
+ for (local_index = i; (c = string[i]); i++)
{
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
diff --git a/cmd-line-utils/readline/histfile.c b/cmd-line-utils/readline/histfile.c
index d98293d933c..118c5ebd328 100644
--- a/cmd-line-utils/readline/histfile.c
+++ b/cmd-line-utils/readline/histfile.c
@@ -186,7 +186,8 @@ read_history_range (filename, from, to)
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
- if (file_size != finfo.st_size || file_size + 1 < file_size)
+if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
+ file_size + 1 < file_size)
{
errno = overflow_errno;
goto error_and_exit;
@@ -339,7 +340,8 @@ history_truncate_file (fname, lines)
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
- if (file_size != finfo.st_size || file_size + 1 < file_size)
+if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
+ file_size + 1 < file_size)
{
close (file);
#if defined (EFBIG)
diff --git a/cmd-line-utils/readline/history.h b/cmd-line-utils/readline/history.h
index 14ca2a996c7..5790ed1c71d 100644
--- a/cmd-line-utils/readline/history.h
+++ b/cmd-line-utils/readline/history.h
@@ -243,9 +243,9 @@ extern int history_length;
extern int history_max_entries;
extern char history_expansion_char;
extern char history_subst_char;
-extern char *history_word_delimiters;
+extern const char *history_word_delimiters;
extern char history_comment_char;
-extern char *history_no_expand_chars;
+extern const char *history_no_expand_chars;
extern char *history_search_delimiter_chars;
extern int history_quotes_inhibit_expansion;
diff --git a/cmd-line-utils/readline/input.c b/cmd-line-utils/readline/input.c
index 62c0443d890..84c0422059a 100644
--- a/cmd-line-utils/readline/input.c
+++ b/cmd-line-utils/readline/input.c
@@ -420,7 +420,7 @@ rl_read_key ()
else
{
/* If input is coming from a macro, then use that. */
- if (c = _rl_next_macro_key ())
+ if ((c = _rl_next_macro_key ()))
return (c);
/* If the user has an event function, then call it periodically. */
diff --git a/cmd-line-utils/readline/isearch.c b/cmd-line-utils/readline/isearch.c
index 8060adb97cd..305c847d8da 100644
--- a/cmd-line-utils/readline/isearch.c
+++ b/cmd-line-utils/readline/isearch.c
@@ -75,7 +75,7 @@ static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
static char *last_isearch_string;
static int last_isearch_string_len;
-static char *default_isearch_terminators = "\033\012";
+static const char *default_isearch_terminators = "\033\012";
_rl_search_cxt *
_rl_scxt_alloc (type, flags)
@@ -119,7 +119,7 @@ _rl_scxt_alloc (type, flags)
void
_rl_scxt_dispose (cxt, flags)
_rl_search_cxt *cxt;
- int flags;
+ int flags __attribute__((unused));
{
FREE (cxt->search_string);
FREE (cxt->allocated_line);
@@ -154,7 +154,7 @@ rl_forward_search_history (sign, key)
static void
rl_display_search (search_string, reverse_p, where)
char *search_string;
- int reverse_p, where;
+ int reverse_p, where __attribute__((unused));
{
char *message;
int msglen, searchlen;
@@ -614,7 +614,7 @@ _rl_isearch_cleanup (cxt, r)
backwards. */
static int
rl_search_history (direction, invoking_key)
- int direction, invoking_key;
+ int direction, invoking_key __attribute__((unused));
{
_rl_search_cxt *cxt; /* local for now, but saved globally */
int c, r;
diff --git a/cmd-line-utils/readline/kill.c b/cmd-line-utils/readline/kill.c
index 42c53948689..adae2e1cd07 100644
--- a/cmd-line-utils/readline/kill.c
+++ b/cmd-line-utils/readline/kill.c
@@ -79,7 +79,7 @@ static int rl_yank_nth_arg_internal PARAMS((int, int, int));
of kill material. */
int
rl_set_retained_kills (num)
- int num;
+ int num __attribute__((unused));
{
return 0;
}
@@ -296,7 +296,7 @@ rl_backward_kill_line (direction, ignore)
/* Kill the whole line, no matter where point is. */
int
rl_kill_full_line (count, ignore)
- int count, ignore;
+ int count __attribute__((unused)), ignore __attribute__((unused));
{
rl_begin_undo_group ();
rl_point = 0;
@@ -314,7 +314,7 @@ rl_kill_full_line (count, ignore)
using behaviour that they expect. */
int
rl_unix_word_rubout (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
int orig_point;
@@ -347,7 +347,7 @@ rl_unix_word_rubout (count, key)
deletes backward to directory separator (`/') or whitespace. */
int
rl_unix_filename_rubout (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
int orig_point, c;
@@ -391,7 +391,7 @@ rl_unix_filename_rubout (count, key)
doing. */
int
rl_unix_line_discard (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
if (rl_point == 0)
rl_ding ();
@@ -428,7 +428,7 @@ region_kill_internal (delete)
/* Copy the text in the region to the kill ring. */
int
rl_copy_region_to_kill (count, ignore)
- int count, ignore;
+ int count __attribute__((unused)), ignore __attribute__((unused));
{
return (region_kill_internal (0));
}
@@ -436,7 +436,7 @@ rl_copy_region_to_kill (count, ignore)
/* Kill the text between the point and mark. */
int
rl_kill_region (count, ignore)
- int count, ignore;
+ int count __attribute__((unused)), ignore __attribute__((unused));
{
int r, npoint;
@@ -501,7 +501,7 @@ rl_copy_backward_word (count, key)
/* Yank back the last killed text. This ignores arguments. */
int
rl_yank (count, ignore)
- int count, ignore;
+ int count __attribute__((unused)), ignore __attribute__((unused));
{
if (rl_kill_ring == 0)
{
@@ -520,7 +520,7 @@ rl_yank (count, ignore)
yank back some other text. */
int
rl_yank_pop (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
int l, n;
diff --git a/cmd-line-utils/readline/macro.c b/cmd-line-utils/readline/macro.c
index 3473f705335..0ee7b3077c3 100644
--- a/cmd-line-utils/readline/macro.c
+++ b/cmd-line-utils/readline/macro.c
@@ -201,7 +201,7 @@ _rl_kill_kbd_macro ()
re-executing the existing macro. */
int
rl_start_kbd_macro (ignore1, ignore2)
- int ignore1, ignore2;
+ int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
{
if (RL_ISSTATE (RL_STATE_MACRODEF))
{
@@ -226,7 +226,7 @@ rl_start_kbd_macro (ignore1, ignore2)
that many times, counting the definition as the first time. */
int
rl_end_kbd_macro (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
{
@@ -246,7 +246,7 @@ rl_end_kbd_macro (count, ignore)
COUNT says how many times to execute it. */
int
rl_call_last_kbd_macro (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
if (current_macro == 0)
_rl_abort_internal ();
diff --git a/cmd-line-utils/readline/mbutil.c b/cmd-line-utils/readline/mbutil.c
index e21708fb748..b571afa18bb 100644
--- a/cmd-line-utils/readline/mbutil.c
+++ b/cmd-line-utils/readline/mbutil.c
@@ -346,8 +346,8 @@ _rl_char_value (buf, ind)
#undef _rl_find_next_mbchar
int
_rl_find_next_mbchar (string, seed, count, flags)
- char *string;
- int seed, count, flags;
+ char *string __attribute__((unused));
+ int seed, count, flags __attribute__((unused));
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_next_mbchar_internal (string, seed, count, flags);
@@ -362,8 +362,8 @@ _rl_find_next_mbchar (string, seed, count, flags)
#undef _rl_find_prev_mbchar
int
_rl_find_prev_mbchar (string, seed, flags)
- char *string;
- int seed, flags;
+ char *string __attribute__((unused));
+ int seed, flags __attribute__((unused));
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_prev_mbchar_internal (string, seed, flags);
diff --git a/cmd-line-utils/readline/misc.c b/cmd-line-utils/readline/misc.c
index e0e6893c60e..f5f0370fb6a 100644
--- a/cmd-line-utils/readline/misc.c
+++ b/cmd-line-utils/readline/misc.c
@@ -228,7 +228,7 @@ _rl_reset_argument ()
/* Start a numeric argument with initial value KEY */
int
rl_digit_argument (ignore, key)
- int ignore, key;
+ int ignore __attribute__((unused)), key;
{
_rl_arg_init ();
if (RL_ISSTATE (RL_STATE_CALLBACK))
@@ -249,7 +249,7 @@ rl_digit_argument (ignore, key)
dispatch on it. If the key is the abort character then abort. */
int
rl_universal_argument (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
_rl_arg_init ();
rl_numeric_arg *= 4;
@@ -413,7 +413,7 @@ _rl_history_set_point ()
void
rl_replace_from_history (entry, flags)
HIST_ENTRY *entry;
- int flags; /* currently unused */
+ int flags __attribute__((unused)); /* currently unused */
{
/* Can't call with `1' because rl_undo_list might point to an undo list
from a history entry, just like we're setting up here. */
@@ -440,7 +440,7 @@ rl_replace_from_history (entry, flags)
/* Meta-< goes to the start of the history. */
int
rl_beginning_of_history (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
return (rl_get_previous_history (1 + where_history (), key));
}
@@ -448,7 +448,7 @@ rl_beginning_of_history (count, key)
/* Meta-> goes to the end of the history. (The current line). */
int
rl_end_of_history (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
rl_maybe_replace_line ();
using_history ();
@@ -553,7 +553,7 @@ rl_get_previous_history (count, key)
/* How to toggle back and forth between editing modes. */
int
rl_vi_editing_mode (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
#if defined (VI_MODE)
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
@@ -566,7 +566,7 @@ rl_vi_editing_mode (count, key)
int
rl_emacs_editing_mode (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
@@ -577,7 +577,7 @@ rl_emacs_editing_mode (count, key)
/* Function for the rest of the library to use to set insert/overwrite mode. */
void
_rl_set_insert_mode (im, force)
- int im, force;
+ int im, force __attribute__((unused));
{
#ifdef CURSOR_MODE
_rl_set_cursor (im, force);
@@ -590,7 +590,7 @@ _rl_set_insert_mode (im, force)
mode. A negative or zero explicit argument selects insert mode. */
int
rl_overwrite_mode (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
if (rl_explicit_arg == 0)
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
diff --git a/cmd-line-utils/readline/nls.c b/cmd-line-utils/readline/nls.c
index 6ec685ed9ea..ff40b14228c 100644
--- a/cmd-line-utils/readline/nls.c
+++ b/cmd-line-utils/readline/nls.c
@@ -101,7 +101,8 @@ _rl_init_eightbit ()
/* If we have setlocale(3), just check the current LC_CTYPE category
value, and go into eight-bit mode if it's not C or POSIX. */
#if defined (HAVE_SETLOCALE)
- char *lspec, *t;
+ const char *lspec;
+ char *t;
/* Set the LC_CTYPE locale category from environment variables. */
lspec = _rl_get_locale_var ("LC_CTYPE");
@@ -127,7 +128,8 @@ _rl_init_eightbit ()
return (0);
#else /* !HAVE_SETLOCALE */
- char *lspec, *t;
+ const char *lspec;
+ char *t;
int i;
/* We don't have setlocale. Finesse it. Check the environment for the
diff --git a/cmd-line-utils/readline/readline.c b/cmd-line-utils/readline/readline.c
index 8c3cad52d36..fb92becdbf9 100644
--- a/cmd-line-utils/readline/readline.c
+++ b/cmd-line-utils/readline/readline.c
@@ -90,7 +90,7 @@ static void bind_arrow_keys_internal PARAMS((Keymap));
static void bind_arrow_keys PARAMS((void));
static void readline_default_bindings PARAMS((void));
-static void reset_default_bindings PARAMS((void));
+static void reset_default_bindings PARAMS((void)) __attribute__((unused));
static int _rl_subseq_result PARAMS((int, Keymap, int, int));
static int _rl_subseq_getchar PARAMS((int));
diff --git a/cmd-line-utils/readline/readline.h b/cmd-line-utils/readline/readline.h
index b71bf98d204..668a452c765 100644
--- a/cmd-line-utils/readline/readline.h
+++ b/cmd-line-utils/readline/readline.h
@@ -304,7 +304,7 @@ extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *))
extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
-extern char *rl_variable_value PARAMS((const char *));
+extern const char *rl_variable_value PARAMS((const char *));
extern int rl_variable_bind PARAMS((const char *, const char *));
/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
@@ -343,7 +343,7 @@ extern void rl_set_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap PARAMS((void));
/* Undocumented; used internally only. */
extern void rl_set_keymap_from_edit_mode PARAMS((void));
-extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
+extern const char *rl_get_keymap_name_from_edit_mode PARAMS((void));
/* Functions for manipulating the funmap, which maps command names to functions. */
extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
@@ -406,7 +406,7 @@ extern void rl_set_screen_size PARAMS((int, int));
extern void rl_get_screen_size PARAMS((int *, int *));
extern void rl_reset_screen_size PARAMS((void));
-extern char *rl_get_termcap PARAMS((const char *));
+extern const char *rl_get_termcap PARAMS((const char *));
/* Functions for character input. */
extern int rl_stuff_char PARAMS((int));
diff --git a/cmd-line-utils/readline/rlprivate.h b/cmd-line-utils/readline/rlprivate.h
index 64aa7bdd3fa..1ab696766b0 100644
--- a/cmd-line-utils/readline/rlprivate.h
+++ b/cmd-line-utils/readline/rlprivate.h
@@ -77,7 +77,7 @@ typedef struct __rl_search_context
int sline_len;
int sline_index;
- char *search_terminators;
+ const char *search_terminators;
} _rl_search_cxt;
/* Callback data for reading numeric arguments */
@@ -164,7 +164,7 @@ extern int rl_set_retained_kills PARAMS((int));
extern void _rl_set_screen_size PARAMS((int, int));
/* undo.c */
-extern int _rl_fix_last_undo_of_type PARAMS((int, int, int));
+extern int _rl_fix_last_undo_of_type PARAMS((enum undo_code, int, int));
/* util.c */
extern char *_rl_savestring PARAMS((const char *));
@@ -359,7 +359,7 @@ extern int _rl_vis_botlin;
extern int _rl_last_c_pos;
extern int _rl_suppress_redisplay;
extern int _rl_want_redisplay;
-extern char *rl_display_prompt;
+extern const char *rl_display_prompt;
/* isearch.c */
extern char *_rl_isearch_terminators;
@@ -398,17 +398,17 @@ extern _rl_search_cxt *_rl_nscxt;
/* terminal.c */
extern int _rl_enable_keypad;
extern int _rl_enable_meta;
-extern char *_rl_term_clreol;
-extern char *_rl_term_clrpag;
-extern char *_rl_term_im;
-extern char *_rl_term_ic;
-extern char *_rl_term_ei;
-extern char *_rl_term_DC;
-extern char *_rl_term_up;
-extern char *_rl_term_dc;
-extern char *_rl_term_cr;
-extern char *_rl_term_IC;
-extern char *_rl_term_forward_char;
+extern const char *_rl_term_clreol;
+extern const char *_rl_term_clrpag;
+extern const char *_rl_term_im;
+extern const char *_rl_term_ic;
+extern const char *_rl_term_ei;
+extern const char *_rl_term_DC;
+extern const char *_rl_term_up;
+extern const char *_rl_term_dc;
+extern const char *_rl_term_cr;
+extern const char *_rl_term_IC;
+extern const char *_rl_term_forward_char;
extern int _rl_screenheight;
extern int _rl_screenwidth;
extern int _rl_screenchars;
diff --git a/cmd-line-utils/readline/rltty.c b/cmd-line-utils/readline/rltty.c
index 8c896bd3b26..8849206fd6d 100644
--- a/cmd-line-utils/readline/rltty.c
+++ b/cmd-line-utils/readline/rltty.c
@@ -764,7 +764,7 @@ rl_deprep_terminal ()
int
rl_restart_output (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
#if defined (__MINGW32__)
return 0;
@@ -802,7 +802,7 @@ rl_restart_output (count, key)
int
rl_stop_output (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
#if defined (__MINGW32__)
return 0;
diff --git a/cmd-line-utils/readline/search.c b/cmd-line-utils/readline/search.c
index cfa5db1dc17..1da450a692a 100644
--- a/cmd-line-utils/readline/search.c
+++ b/cmd-line-utils/readline/search.c
@@ -211,7 +211,7 @@ _rl_nsearch_init (dir, pchar)
rl_end = rl_point = 0;
p = _rl_make_prompt_for_search (pchar ? pchar : ':');
- rl_message ("%s", p, 0);
+ rl_message ("%s", p);
free (p);
RL_SETSTATE(RL_STATE_NSEARCH);
@@ -383,7 +383,7 @@ noninc_search (dir, pchar)
code calls this, KEY will be `?'. */
int
rl_noninc_forward_search (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
return noninc_search (1, (key == '?') ? '?' : 0);
}
@@ -392,7 +392,7 @@ rl_noninc_forward_search (count, key)
calls this, KEY will be `/'. */
int
rl_noninc_reverse_search (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
return noninc_search (-1, (key == '/') ? '/' : 0);
}
@@ -401,7 +401,7 @@ rl_noninc_reverse_search (count, key)
for. If there is no saved search string, abort. */
int
rl_noninc_forward_search_again (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
int r;
@@ -418,7 +418,7 @@ rl_noninc_forward_search_again (count, key)
for. If there is no saved search string, abort. */
int
rl_noninc_reverse_search_again (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
int r;
diff --git a/cmd-line-utils/readline/terminal.c b/cmd-line-utils/readline/terminal.c
index a630bc02e05..3f92821f9dd 100644
--- a/cmd-line-utils/readline/terminal.c
+++ b/cmd-line-utils/readline/terminal.c
@@ -104,34 +104,36 @@ char PC, *BC, *UP;
#endif /* __linux__ */
/* Some strings to control terminal actions. These are output by tputs (). */
-char *_rl_term_clreol;
-char *_rl_term_clrpag;
-char *_rl_term_cr;
-char *_rl_term_backspace;
-char *_rl_term_goto;
-char *_rl_term_pc;
+const char *_rl_term_clreol;
+const char *_rl_term_clrpag;
+const char *_rl_term_cr;
+const char *_rl_term_backspace;
+char _rl_term_backspace_default[2] = { '\b', 0 };
+const char *_rl_term_goto;
+const char *_rl_term_pc;
/* Non-zero if we determine that the terminal can do character insertion. */
int _rl_terminal_can_insert = 0;
/* How to insert characters. */
-char *_rl_term_im;
-char *_rl_term_ei;
-char *_rl_term_ic;
-char *_rl_term_ip;
-char *_rl_term_IC;
+const char *_rl_term_im;
+const char *_rl_term_ei;
+const char *_rl_term_ic;
+const char *_rl_term_ip;
+const char *_rl_term_IC;
/* How to delete characters. */
-char *_rl_term_dc;
-char *_rl_term_DC;
+const char *_rl_term_dc;
+const char *_rl_term_DC;
-char *_rl_term_forward_char;
+const char *_rl_term_forward_char;
/* How to go up a line. */
-char *_rl_term_up;
+const char *_rl_term_up;
+char _rl_term_up_default[2] = { 0, 0 };
/* A visible bell; char if the terminal can be made to flash the screen. */
-static char *_rl_visible_bell;
+static const char *_rl_visible_bell;
/* Non-zero means the terminal can auto-wrap lines. */
int _rl_term_autowrap = -1;
@@ -141,33 +143,33 @@ static int term_has_meta;
/* The sequences to write to turn on and off the meta key, if this
terminal has one. */
-static char *_rl_term_mm;
-static char *_rl_term_mo;
+static const char *_rl_term_mm;
+static const char *_rl_term_mo;
/* The key sequences output by the arrow keys, if this terminal has any. */
-static char *_rl_term_ku;
-static char *_rl_term_kd;
-static char *_rl_term_kr;
-static char *_rl_term_kl;
+static const char *_rl_term_ku;
+static const char *_rl_term_kd;
+static const char *_rl_term_kr;
+static const char *_rl_term_kl;
/* How to initialize and reset the arrow keys, if this terminal has any. */
-static char *_rl_term_ks;
-static char *_rl_term_ke;
+static const char *_rl_term_ks;
+static const char *_rl_term_ke;
/* The key sequences sent by the Home and End keys, if any. */
-static char *_rl_term_kh;
-static char *_rl_term_kH;
-static char *_rl_term_at7; /* @7 */
+static const char *_rl_term_kh;
+static const char *_rl_term_kH;
+static const char *_rl_term_at7; /* @7 */
/* Delete key */
-static char *_rl_term_kD;
+static const char *_rl_term_kD;
/* Insert key */
-static char *_rl_term_kI;
+static const char *_rl_term_kI;
/* Cursor control */
-static char *_rl_term_vs; /* very visible */
-static char *_rl_term_ve; /* normal */
+static const char *_rl_term_vs; /* very visible */
+static const char *_rl_term_ve; /* normal */
static void bind_termcap_arrow_keys PARAMS((Keymap));
@@ -362,7 +364,7 @@ rl_resize_terminal ()
struct _tc_string {
const char *tc_var;
- char **tc_value;
+ const char **tc_value;
};
/* This should be kept sorted, just in case we decide to change the
@@ -409,7 +411,7 @@ get_term_capabilities (bp)
char **bp;
{
#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
- register int i;
+ register unsigned int i;
for (i = 0; i < NUM_TC_STRINGS; i++)
*(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
@@ -496,8 +498,9 @@ _rl_init_terminal_io (terminal_name)
tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
change that later... */
PC = '\0';
- BC = _rl_term_backspace = "\b";
- UP = _rl_term_up;
+ _rl_term_backspace = _rl_term_backspace_default;
+ BC = (char*)_rl_term_backspace;
+ UP = (char*)_rl_term_up;
return 0;
}
@@ -507,8 +510,8 @@ _rl_init_terminal_io (terminal_name)
/* Set up the variables that the termcap library expects the application
to provide. */
PC = _rl_term_pc ? *_rl_term_pc : 0;
- BC = _rl_term_backspace;
- UP = _rl_term_up;
+ BC = (char*)_rl_term_backspace;
+ UP = (char*)_rl_term_up;
if (!_rl_term_cr)
_rl_term_cr = "\r";
@@ -568,11 +571,11 @@ bind_termcap_arrow_keys (map)
_rl_keymap = xkeymap;
}
-char *
+const char *
rl_get_termcap (cap)
const char *cap;
{
- register int i;
+ register unsigned int i;
if (tcap_initialized == 0)
return ((char *)NULL);
diff --git a/cmd-line-utils/readline/text.c b/cmd-line-utils/readline/text.c
index b26afeda525..272848c798c 100644
--- a/cmd-line-utils/readline/text.c
+++ b/cmd-line-utils/readline/text.c
@@ -410,7 +410,7 @@ rl_backward (count, key)
/* Move to the beginning of the line. */
int
rl_beg_of_line (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
rl_point = 0;
return 0;
@@ -419,7 +419,7 @@ rl_beg_of_line (count, key)
/* Move to the end of the line. */
int
rl_end_of_line (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
rl_point = rl_end;
return 0;
@@ -527,7 +527,7 @@ rl_backward_word (count, key)
/* Clear the current line. Numeric argument to C-l does this. */
int
rl_refresh_line (ignore1, ignore2)
- int ignore1, ignore2;
+ int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
{
int curr_line;
@@ -566,7 +566,7 @@ rl_clear_screen (count, key)
int
rl_arrow_keys (count, c)
- int count, c;
+ int count, c __attribute__((unused));
{
int ch;
@@ -884,7 +884,7 @@ _rl_insert_next_callback (data)
int
rl_quoted_insert (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
/* Let's see...should the callback interface futz with signal handling? */
#if defined (HANDLE_SIGNALS)
@@ -907,7 +907,7 @@ rl_quoted_insert (count, key)
/* Insert a tab character. */
int
rl_tab_insert (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
return (_rl_insert_char (count, '\t'));
}
@@ -917,7 +917,7 @@ rl_tab_insert (count, key)
meaning in the future. */
int
rl_newline (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
rl_done = 1;
@@ -951,7 +951,7 @@ rl_newline (count, key)
is special cased. */
int
rl_do_lowercase_version (ignore1, ignore2)
- int ignore1, ignore2;
+ int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
{
return 0;
}
@@ -1118,7 +1118,7 @@ rl_rubout_or_delete (count, key)
/* Delete all spaces and tabs around point. */
int
rl_delete_horizontal_space (count, ignore)
- int count, ignore;
+ int count __attribute__((unused)), ignore __attribute__((unused));
{
int start = rl_point;
@@ -1163,9 +1163,9 @@ rl_delete_or_show_completions (count, key)
A K*rn shell style function. */
int
rl_insert_comment (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
- char *rl_comment_text;
+ const char *rl_comment_text;
int rl_comment_len;
rl_beg_of_line (1, key);
@@ -1202,7 +1202,7 @@ rl_insert_comment (count, key)
/* Uppercase the word at point. */
int
rl_upcase_word (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
return (rl_change_case (count, UpCase));
}
@@ -1210,7 +1210,7 @@ rl_upcase_word (count, key)
/* Lowercase the word at point. */
int
rl_downcase_word (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
return (rl_change_case (count, DownCase));
}
@@ -1218,7 +1218,7 @@ rl_downcase_word (count, key)
/* Upcase the first letter, downcase the rest. */
int
rl_capitalize_word (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
return (rl_change_case (count, CapCase));
}
@@ -1381,7 +1381,7 @@ rl_transpose_words (count, key)
then transpose the characters before point. */
int
rl_transpose_chars (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
#if defined (HANDLE_MULTIBYTE)
char *dummy;
@@ -1557,7 +1557,7 @@ _rl_char_search_callback (data)
int
rl_char_search (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
#if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK))
@@ -1575,7 +1575,7 @@ rl_char_search (count, key)
int
rl_backward_char_search (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
#if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK))
@@ -1612,7 +1612,7 @@ _rl_set_mark_at_pos (position)
/* A bindable command to set the mark. */
int
rl_set_mark (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point));
}
@@ -1620,7 +1620,7 @@ rl_set_mark (count, key)
/* Exchange the position of mark and point. */
int
rl_exchange_point_and_mark (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
if (rl_mark > rl_end)
rl_mark = -1;
diff --git a/cmd-line-utils/readline/tilde.c b/cmd-line-utils/readline/tilde.c
index d50f7a0ffa4..128cc26d9a7 100644
--- a/cmd-line-utils/readline/tilde.c
+++ b/cmd-line-utils/readline/tilde.c
@@ -196,7 +196,7 @@ tilde_expand (string)
int result_size, result_index;
result_index = result_size = 0;
- if (result = strchr (string, '~'))
+ if ((result = strchr (string, '~')))
result = (char *)xmalloc (result_size = (strlen (string) + 16));
else
result = (char *)xmalloc (result_size = (strlen (string) + 1));
diff --git a/cmd-line-utils/readline/undo.c b/cmd-line-utils/readline/undo.c
index 5699193b14c..79846c26024 100644
--- a/cmd-line-utils/readline/undo.c
+++ b/cmd-line-utils/readline/undo.c
@@ -231,7 +231,8 @@ rl_do_undo ()
int
_rl_fix_last_undo_of_type (type, start, end)
- int type, start, end;
+ enum undo_code type;
+ int start, end;
{
UNDO_LIST *rl;
@@ -289,7 +290,7 @@ rl_modifying (start, end)
/* Revert the current line to its previous state. */
int
rl_revert_line (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
if (!rl_undo_list)
rl_ding ();
@@ -309,7 +310,7 @@ rl_revert_line (count, key)
/* Do some undoing of things that were done. */
int
rl_undo_command (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
if (count < 0)
return 0; /* Nothing to do. */
diff --git a/cmd-line-utils/readline/util.c b/cmd-line-utils/readline/util.c
index 935c9c927c2..50cfea75cb9 100644
--- a/cmd-line-utils/readline/util.c
+++ b/cmd-line-utils/readline/util.c
@@ -115,14 +115,14 @@ _rl_abort_internal ()
int
rl_abort (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
return (_rl_abort_internal ());
}
int
rl_tty_status (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
#if defined (TIOCSTAT)
ioctl (1, TIOCSTAT, (char *)0);
@@ -172,7 +172,7 @@ rl_extend_line_buffer (len)
/* A function for simple tilde expansion. */
int
rl_tilde_expand (ignore, key)
- int ignore, key;
+ int ignore __attribute__((unused)), key __attribute__((unused));
{
register int start, end;
char *homedir, *temp;
diff --git a/cmd-line-utils/readline/vi_mode.c b/cmd-line-utils/readline/vi_mode.c
index 25213cb762f..620bb863c7b 100644
--- a/cmd-line-utils/readline/vi_mode.c
+++ b/cmd-line-utils/readline/vi_mode.c
@@ -131,7 +131,7 @@ static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
void
_rl_vi_initialize_line ()
{
- register int i;
+ register size_t i;
for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
vi_mark_chars[i] = -1;
@@ -190,7 +190,7 @@ _rl_vi_stuff_insert (count)
puts you back into insert mode. */
int
rl_vi_redo (count, c)
- int count, c;
+ int count, c __attribute__((unused));
{
int r;
@@ -238,7 +238,7 @@ rl_vi_undo (count, key)
/* Yank the nth arg from the previous line into this line at point. */
int
rl_vi_yank_arg (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
/* Readline thinks that the first word on a line is the 0th, while vi
thinks the first word on a line is the 1st. Compensate. */
@@ -321,7 +321,7 @@ rl_vi_search (count, key)
/* Completion, from vi's point of view. */
int
rl_vi_complete (ignore, key)
- int ignore, key;
+ int ignore __attribute__((unused)), key;
{
if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
{
@@ -348,7 +348,7 @@ rl_vi_complete (ignore, key)
/* Tilde expansion for vi mode. */
int
rl_vi_tilde_expand (ignore, key)
- int ignore, key;
+ int ignore __attribute__((unused)), key;
{
rl_tilde_expand (0, key);
rl_vi_start_inserting (key, 1, rl_arg_sign);
@@ -419,7 +419,7 @@ rl_vi_end_word (count, key)
/* Move forward a word the way that 'W' does. */
int
rl_vi_fWord (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
while (count-- && rl_point < (rl_end - 1))
{
@@ -436,7 +436,7 @@ rl_vi_fWord (count, ignore)
int
rl_vi_bWord (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
while (count-- && rl_point > 0)
{
@@ -460,7 +460,7 @@ rl_vi_bWord (count, ignore)
int
rl_vi_eWord (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
while (count-- && rl_point < (rl_end - 1))
{
@@ -491,7 +491,7 @@ rl_vi_eWord (count, ignore)
int
rl_vi_fword (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
while (count-- && rl_point < (rl_end - 1))
{
@@ -517,7 +517,7 @@ rl_vi_fword (count, ignore)
int
rl_vi_bword (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
while (count-- && rl_point > 0)
{
@@ -556,7 +556,7 @@ rl_vi_bword (count, ignore)
int
rl_vi_eword (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
while (count-- && rl_point < rl_end - 1)
{
@@ -581,7 +581,7 @@ rl_vi_eword (count, ignore)
int
rl_vi_insert_beg (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
rl_beg_of_line (1, key);
rl_vi_insertion_mode (1, key);
@@ -610,7 +610,7 @@ _rl_vi_append_forward (key)
int
rl_vi_append_mode (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
_rl_vi_append_forward (key);
rl_vi_start_inserting (key, 1, rl_arg_sign);
@@ -619,7 +619,7 @@ rl_vi_append_mode (count, key)
int
rl_vi_append_eol (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
rl_end_of_line (1, key);
rl_vi_append_mode (1, key);
@@ -629,7 +629,7 @@ rl_vi_append_eol (count, key)
/* What to do in the case of C-d. */
int
rl_vi_eof_maybe (count, c)
- int count, c;
+ int count __attribute__((unused)), c __attribute__((unused));
{
return (rl_newline (1, '\n'));
}
@@ -640,7 +640,7 @@ rl_vi_eof_maybe (count, c)
switching keymaps. */
int
rl_vi_insertion_mode (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
_rl_keymap = vi_insertion_keymap;
_rl_vi_last_key_before_insert = key;
@@ -703,7 +703,7 @@ _rl_vi_done_inserting ()
int
rl_vi_movement_mode (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
if (rl_point > 0)
rl_backward_char (1, key);
@@ -783,7 +783,7 @@ _rl_vi_change_mbchar_case (count)
int
rl_vi_change_case (count, ignore)
- int count, ignore;
+ int count, ignore __attribute__((unused));
{
int c, p;
@@ -1031,7 +1031,7 @@ rl_digit_loop1 ()
int
rl_vi_delete_to (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
int c;
@@ -1057,7 +1057,7 @@ rl_vi_delete_to (count, key)
int
rl_vi_change_to (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
int c, start_pos;
@@ -1110,7 +1110,7 @@ rl_vi_change_to (count, key)
int
rl_vi_yank_to (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
int c, save;
@@ -1202,7 +1202,7 @@ rl_vi_delete (count, key)
int
rl_vi_back_to_indent (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
rl_beg_of_line (1, key);
while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
@@ -1212,7 +1212,7 @@ rl_vi_back_to_indent (count, key)
int
rl_vi_first_print (count, key)
- int count, key;
+ int count __attribute__((unused)), key;
{
return (rl_vi_back_to_indent (1, key));
}
@@ -1319,7 +1319,7 @@ rl_vi_char_search (count, key)
/* Match brackets */
int
rl_vi_match (ignore, key)
- int ignore, key;
+ int ignore __attribute__((unused)), key;
{
int count = 1, brack, pos, tmp, pre;
@@ -1426,7 +1426,7 @@ rl_vi_bracktype (c)
static int
_rl_vi_change_char (count, c, mb)
int count, c;
- char *mb;
+ char *mb __attribute__((unused));
{
int p;
@@ -1458,8 +1458,8 @@ _rl_vi_change_char (count, c, mb)
static int
_rl_vi_callback_getchar (mb, mlen)
- char *mb;
- int mlen;
+ char *mb __attribute__((unused));
+ int mlen __attribute__((unused));
{
int c;
@@ -1494,7 +1494,7 @@ _rl_vi_callback_change_char (data)
int
rl_vi_change_char (count, key)
- int count, key;
+ int count, key __attribute__((unused));
{
int c;
char mb[MB_LEN_MAX];
@@ -1582,7 +1582,7 @@ rl_vi_overstrike_delete (count, key)
int
rl_vi_replace (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
int i;
@@ -1663,7 +1663,7 @@ _rl_vi_set_mark ()
#if defined (READLINE_CALLBACKS)
static int
_rl_vi_callback_set_mark (data)
- _rl_callback_generic_arg *data;
+ _rl_callback_generic_arg *data __attribute__((unused));
{
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -1674,7 +1674,7 @@ _rl_vi_callback_set_mark (data)
int
rl_vi_set_mark (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
#if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK))
@@ -1721,7 +1721,7 @@ _rl_vi_goto_mark ()
#if defined (READLINE_CALLBACKS)
static int
_rl_vi_callback_goto_mark (data)
- _rl_callback_generic_arg *data;
+ _rl_callback_generic_arg *data __attribute__((unused));
{
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -1732,7 +1732,7 @@ _rl_vi_callback_goto_mark (data)
int
rl_vi_goto_mark (count, key)
- int count, key;
+ int count __attribute__((unused)), key __attribute__((unused));
{
#if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK))
diff --git a/configure.in b/configure.in
index 6867ea8bd92..d68a4121642 100644
--- a/configure.in
+++ b/configure.in
@@ -603,10 +603,11 @@ AC_SUBST(NOINST_LDFLAGS)
# Check if we are using Linux and a glibc compiled with static nss
# (this is true on the MySQL build machines to avoid NSS problems)
#
+AC_CHECK_TOOL([NM], [nm])
if test "$TARGET_LINUX" = "true" -a "$static_nss" = ""
then
- tmp=`nm /usr/lib*/libc.a | grep _nss_files_getaliasent_r`
+ tmp=`$NM ${other_libc_lib:-/usr/lib*}/libc.a | grep _nss_files_getaliasent_r1`
if test -n "$tmp"
then
STATIC_NSS_FLAGS="-lc -lnss_files -lnss_dns -lresolv"
@@ -1624,7 +1625,7 @@ esac
# Build optimized or debug version ?
# First check for gcc and g++
-if test "$ac_cv_prog_gcc" = "yes"
+if test "$GCC" = "yes"
then
DEBUG_CFLAGS="-g"
DEBUG_OPTIMIZE_CC="-O"
@@ -1632,9 +1633,16 @@ then
else
DEBUG_CFLAGS="-g"
DEBUG_OPTIMIZE_CC=""
- OPTIMIZE_CFLAGS="-O"
+ case $SYSTEM_TYPE in
+ *solaris*)
+ OPTIMIZE_CFLAGS="-O1"
+ ;;
+ *)
+ OPTIMIZE_CFLAGS="-O"
+ ;;
+ esac
fi
-if test "$ac_cv_prog_cxx_g" = "yes"
+if test "$GXX" = "yes"
then
DEBUG_CXXFLAGS="-g"
DEBUG_OPTIMIZE_CXX="-O"
@@ -1642,7 +1650,14 @@ then
else
DEBUG_CXXFLAGS="-g"
DEBUG_OPTIMIZE_CXX=""
- OPTIMIZE_CXXFLAGS="-O"
+ case $SYSTEM_TYPE in
+ *solaris*)
+ OPTIMIZE_CXXFLAGS="-O1"
+ ;;
+ *)
+ OPTIMIZE_CXXFLAGS="-O"
+ ;;
+ esac
fi
case $SYSTEM_TYPE in
@@ -2076,6 +2091,25 @@ case "$mysql_cv_sys_os" in
# unsupported priority values are passed to pthread_setschedprio.
# Since the only supported value is 1, treat it as inexistent.
;;
+ SunOS) # Bug#42599 error: `pthread_setschedprio' was not declared in this scope
+ # In some installations, the pthread.h header used by GCC does not
+ # declare the pthread_setscheprio prototype, but the function is
+ # implemented. Since the function is used in C++ code, ensure that
+ # the function prototype is present.
+ AC_MSG_CHECKING([whether pthread_setschedprio is declared])
+ AC_LANG_PUSH([C++])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([#include <pthread.h>],
+ [(void)(pthread_setschedprio);])],
+ [ac_cv_func_pthread_setschedprio=yes],
+ [ac_cv_func_pthread_setschedprio=no])
+ AC_LANG_POP([C++])
+ AC_MSG_RESULT([$ac_cv_func_pthread_setschedprio])
+ if test "$ac_cv_func_pthread_setschedprio" = yes; then
+ AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, 1,
+ [Define to 1 if you have the `pthread_setschedprio' function.])
+ fi
+ ;;
*) AC_CHECK_FUNCS(pthread_setschedprio)
;;
esac
diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp
index 262b5cb3b8b..b4d9005af15 100644
--- a/extra/yassl/src/handshake.cpp
+++ b/extra/yassl/src/handshake.cpp
@@ -790,15 +790,17 @@ void processReply(SSL& ssl)
if (ssl.GetError()) return;
if (DoProcessReply(ssl))
+ {
// didn't complete process
if (!ssl.getSocket().IsNonBlocking()) {
// keep trying now, blocking ok
while (!ssl.GetError())
if (DoProcessReply(ssl) == 0) break;
- }
+ }
else
// user will have try again later, non blocking
ssl.SetError(YasslError(SSL_ERROR_WANT_READ));
+ }
}
@@ -873,10 +875,12 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer)
void sendChangeCipher(SSL& ssl, BufferOutput buffer)
{
if (ssl.getSecurity().get_parms().entity_ == server_end)
+ {
if (ssl.getSecurity().get_resuming())
ssl.verifyState(clientKeyExchangeComplete);
else
ssl.verifyState(clientFinishedComplete);
+ }
if (ssl.GetError()) return;
ChangeCipherSpec ccs;
diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp
index 20dfe50f132..f079df8c7ce 100644
--- a/extra/yassl/src/yassl_imp.cpp
+++ b/extra/yassl/src/yassl_imp.cpp
@@ -1305,6 +1305,7 @@ void ServerHello::Process(input_buffer&, SSL& ssl)
ssl.useSecurity().use_connection().sessionID_Set_ = false;
if (ssl.getSecurity().get_resuming())
+ {
if (memcmp(session_id_, ssl.getSecurity().get_resume().GetID(),
ID_LEN) == 0) {
ssl.set_masterSecret(ssl.getSecurity().get_resume().GetSecret());
@@ -1319,6 +1320,7 @@ void ServerHello::Process(input_buffer&, SSL& ssl)
ssl.useSecurity().set_resuming(false);
ssl.useLog().Trace("server denied resumption");
}
+ }
if (ssl.CompressionOn() && !compression_method_)
ssl.UnSetCompression(); // server isn't supporting yaSSL zlib request
diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp
index d1ebce7568b..4575fe1414b 100644
--- a/extra/yassl/taocrypt/include/modes.hpp
+++ b/extra/yassl/taocrypt/include/modes.hpp
@@ -96,10 +96,12 @@ inline void Mode_BASE::Process(byte* out, const byte* in, word32 sz)
if (mode_ == ECB)
ECB_Process(out, in, sz);
else if (mode_ == CBC)
+ {
if (dir_ == ENCRYPTION)
CBC_Encrypt(out, in, sz);
else
CBC_Decrypt(out, in, sz);
+ }
}
diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp
index 3b1c1c2136a..78200841bda 100644
--- a/extra/yassl/taocrypt/src/asn.cpp
+++ b/extra/yassl/taocrypt/src/asn.cpp
@@ -781,10 +781,12 @@ void CertDecoder::GetDate(DateType dt)
source_.advance(length);
if (!ValidateDate(date, b, dt) && verify_)
+ {
if (dt == BEFORE)
source_.SetError(BEFORE_DATE_E);
else
source_.SetError(AFTER_DATE_E);
+ }
// save for later use
if (dt == BEFORE) {
@@ -1062,6 +1064,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
}
word32 rLen = GetLength(source);
if (rLen != 20)
+ {
if (rLen == 21) { // zero at front, eat
source.next();
--rLen;
@@ -1074,6 +1077,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
source.SetError(DSA_SZ_E);
return 0;
}
+ }
memcpy(decoded, source.get_buffer() + source.get_index(), rLen);
source.advance(rLen);
@@ -1084,6 +1088,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
}
word32 sLen = GetLength(source);
if (sLen != 20)
+ {
if (sLen == 21) {
source.next(); // zero at front, eat
--sLen;
@@ -1096,6 +1101,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)
source.SetError(DSA_SZ_E);
return 0;
}
+ }
memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen);
source.advance(sLen);
diff --git a/include/hash.h b/include/hash.h
index f4b82454b81..629b404e8a7 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -106,7 +106,7 @@ void my_hash_replace(HASH *hash, HASH_SEARCH_STATE *state, uchar *new_row);
my_bool my_hash_check(HASH *hash); /* Only in debug library */
#define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
-#define my_hash_inited(H) ((H)->array.buffer != 0)
+#define my_hash_inited(H) ((H)->blength != 0)
#define my_hash_init_opt(A,B,C,D,E,F,G,H) \
(!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
index 103069f79cf..faa8ba110d3 100644
--- a/mysql-test/collections/default.experimental
+++ b/mysql-test/collections/default.experimental
@@ -1 +1,13 @@
funcs_1.charset_collation_1 # depends on compile-time decisions
+binlog.binlog_tmp_table # Bug#45578: Test binlog_tmp_table fails ramdonly on PB2: Unknown table 't2'
+main.ctype_gbk_binlog # Bug#46010: main.ctype_gbk_binlog fails sporadically : Table 't2' already exists
+rpl.rpl_row_create_table # Bug#45576: rpl_row_create_table fails on PB2
+rpl.rpl_extraColmaster_myisam # Bug#46013: rpl_extraColmaster_myisam fails on pb2
+rpl.rpl_stm_reset_slave # Bug#46014: rpl_stm_reset_slave crashes the server sporadically in pb2
+rpl.rpl_extraCol_myisam # Bug#40796
+rpl.rpl_extraColmaster_innodb # Bug#40796
+rpl.rpl_extraCol_innodb # Bug#40796
+rpl_ndb.rpl_ndb_log # Bug#38998
+rpl.rpl_innodb_bug28430 # Bug#46029
+rpl.rpl_row_basic_3innodb # Bug#45243
+rpl.rpl_truncate_3innodb # Bug#46030
diff --git a/mysql-test/extra/rpl_tests/rpl_reset_slave.test b/mysql-test/extra/rpl_tests/rpl_reset_slave.test
index 2cc041a35e1..1f88c792fce 100644
--- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test
+++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test
@@ -41,3 +41,57 @@ reset slave;
start slave;
sync_with_master;
show status like 'slave_open_temp_tables';
+
+#
+#Bug#34654 RESET SLAVE does not clear LAST_IO_Err*
+#
+
+# clearing the status
+stop slave;
+reset slave;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+echo *** errno must be zero: $last_io_errno ***;
+
+#
+# verifying start slave resets Last_IO_Error and Last_IO_Errno.
+#
+
+change master to master_user='impossible_user_name';
+start slave;
+source include/wait_for_slave_io_error.inc;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+--disable_query_log
+eval SELECT $last_io_errno > 0 as ONE;
+--enable_query_log
+
+source include/stop_slave.inc;
+change master to master_user='root';
+source include/start_slave.inc;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1);
+--echo *** last errno must be zero: $last_io_errno ***
+--echo *** last error must be blank: $last_io_error ***
+
+#
+# verifying reset slave resets Last_{IO,SQL}_Err{or,no}
+#
+
+source include/stop_slave.inc;
+change master to master_user='impossible_user_name';
+start slave;
+source include/wait_for_slave_io_error.inc;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+--disable_query_log
+eval SELECT $last_io_errno > 0 as ONE;
+--enable_query_log
+
+source include/stop_slave.inc;
+reset slave;
+let $last_io_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
+let $last_io_error= query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1);
+let $last_sql_errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
+let $last_sql_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
+--echo *** io last errno must be zero: $last_io_errno ***
+--echo *** io last error must be blank: $last_io_error ***
+--echo *** sql last errno must be zero: $last_sql_errno ***
+--echo *** sql last error must be blank: $last_sql_error ***
diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc
index a4e7d9ae601..d412eae8364 100644
--- a/mysql-test/include/commit.inc
+++ b/mysql-test/include/commit.inc
@@ -669,13 +669,9 @@ call p_verify_status_increment(1, 0, 1, 0);
insert t1 set a=3;
call p_verify_status_increment(2, 2, 2, 2);
savepoint a;
-call p_verify_status_increment(0, 0, 0, 0);
+call p_verify_status_increment(1, 0, 1, 0);
insert t1 set a=4;
---echo # Binlog does not register itself this time for other than the 1st
---echo # statement of the transaction with MIXED/STATEMENT binlog_format.
---echo # It needs registering with the ROW format. Therefore 1,0,2,2 are
---echo # the correct arguments to this test after bug#40221 fixed.
-call p_verify_status_increment(1, 0, 2, 2);
+call p_verify_status_increment(2, 2, 2, 2);
release savepoint a;
rollback;
call p_verify_status_increment(0, 0, 0, 0);
diff --git a/mysql-test/include/wait_for_slave_io_error.inc b/mysql-test/include/wait_for_slave_io_error.inc
new file mode 100644
index 00000000000..094406e02b2
--- /dev/null
+++ b/mysql-test/include/wait_for_slave_io_error.inc
@@ -0,0 +1,23 @@
+# ==== Purpose ====
+#
+# Waits until the IO thread of the current connection has got an
+# error, or until a timeout is reached.
+#
+# ==== Usage ====
+#
+# source include/wait_for_slave_io_error.inc;
+#
+# Parameters to this macro are $slave_timeout and
+# $slave_keep_connection. See wait_for_slave_param.inc for
+# descriptions.
+
+let $old_slave_param_comparison= $slave_param_comparison;
+
+let $slave_param= Last_IO_Errno;
+let $slave_param_comparison= !=;
+let $slave_param_value= 0;
+let $slave_error_message= Failed while waiting for slave to produce an error in its sql thread;
+source include/wait_for_slave_param.inc;
+let $slave_error_message= ;
+
+let $slave_param_comparison= $old_slave_param_comparison;
diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result
index de80dba47c1..cabd4c29c1d 100644
--- a/mysql-test/r/commit_1innodb.result
+++ b/mysql-test/r/commit_1innodb.result
@@ -766,15 +766,11 @@ call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
savepoint a;
-call p_verify_status_increment(0, 0, 0, 0);
+call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
insert t1 set a=4;
-# Binlog does not register itself this time for other than the 1st
-# statement of the transaction with MIXED/STATEMENT binlog_format.
-# It needs registering with the ROW format. Therefore 1,0,2,2 are
-# the correct arguments to this test after bug#40221 fixed.
-call p_verify_status_increment(1, 0, 2, 2);
+call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
release savepoint a;
diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result
index 2f67eb16b2e..044885d1ea7 100644
--- a/mysql-test/r/ctype_cp932_binlog_stm.result
+++ b/mysql-test/r/ctype_cp932_binlog_stm.result
@@ -9,7 +9,7 @@ EXECUTE stmt1 USING @var1;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TABLE t1(f1 blob)
-master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES('ƒ\0')
+master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(0x8300)
SELECT HEX(f1) FROM t1;
HEX(f1)
8300
@@ -29,22 +29,22 @@ HEX(s1) HEX(s2) d
466F6F2773206120426172 ED40ED41ED42 47.93
DROP PROCEDURE bug18293|
DROP TABLE t4|
-SHOW BINLOG EVENTS FROM 369|
+SHOW BINLOG EVENTS FROM 370|
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 369 Query 1 535 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
+master-bin.000001 370 Query 1 536 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
s2 CHAR(50) CHARACTER SET cp932,
d DECIMAL(10,2))
-master-bin.000001 535 Query 1 784 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug18293`(IN ins1 CHAR(50),
+master-bin.000001 536 Query 1 785 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug18293`(IN ins1 CHAR(50),
IN ins2 CHAR(50) CHARACTER SET cp932,
IN ind DECIMAL(10,2))
BEGIN
INSERT INTO t4 VALUES (ins1, ins2, ind);
END
-master-bin.000001 784 Query 1 1048 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172 COLLATE 'latin1_swedish_ci'), NAME_CONST('ins2',_cp932 0xED40ED41ED42 COLLATE 'cp932_japanese_ci'), NAME_CONST('ind',47.93))
-master-bin.000001 1048 Query 1 1137 use `test`; DROP PROCEDURE bug18293
-master-bin.000001 1137 Query 1 1216 use `test`; DROP TABLE t4
+master-bin.000001 785 Query 1 1049 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172 COLLATE 'latin1_swedish_ci'), NAME_CONST('ins2',_cp932 0xED40ED41ED42 COLLATE 'cp932_japanese_ci'), NAME_CONST('ind',47.93))
+master-bin.000001 1049 Query 1 1138 use `test`; DROP PROCEDURE bug18293
+master-bin.000001 1138 Query 1 1217 use `test`; DROP TABLE t4
End of 5.0 tests
-SHOW BINLOG EVENTS FROM 364;
+SHOW BINLOG EVENTS FROM 365;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
CREATE TABLE t1 (a varchar(16)) character set cp932;
diff --git a/mysql-test/r/ctype_gbk_binlog.result b/mysql-test/r/ctype_gbk_binlog.result
new file mode 100644
index 00000000000..a49e170ff19
--- /dev/null
+++ b/mysql-test/r/ctype_gbk_binlog.result
@@ -0,0 +1,26 @@
+SET NAMES gbk;
+CREATE TABLE t1 (
+f1 BLOB
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+CREATE PROCEDURE p1(IN val BLOB)
+BEGIN
+SET @tval = val;
+SET @sql_cmd = CONCAT_WS(' ', 'insert into t1(f1) values(?)');
+PREPARE stmt FROM @sql_cmd;
+EXECUTE stmt USING @tval;
+DEALLOCATE PREPARE stmt;
+END|
+SET @`tcontent`:=_binary 0x50434B000900000000000000E9000000 COLLATE `binary`/*!*/;
+CALL p1(@`tcontent`);
+FLUSH LOGS;
+DROP PROCEDURE p1;
+RENAME TABLE t1 to t2;
+SELECT hex(f1) FROM t2;
+hex(f1)
+50434B000900000000000000E9000000
+SELECT hex(f1) FROM t1;
+hex(f1)
+50434B000900000000000000E9000000
+DROP PROCEDURE p1;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result
index ecdc35ac4cd..14ebc8203ec 100644
--- a/mysql-test/r/func_set.result
+++ b/mysql-test/r/func_set.result
@@ -146,3 +146,16 @@ NULL
0
0
drop table t1;
+CREATE TABLE t1( a SET('a', 'b', 'c') );
+CREATE TABLE t2( a SET('a', 'b', 'c') );
+INSERT INTO t1 VALUES ('d');
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+INSERT INTO t2 VALUES ('');
+SELECT CONVERT( a USING latin1 ) FROM t1;
+CONVERT( a USING latin1 )
+
+SELECT CONVERT( a USING latin1 ) FROM t2;
+CONVERT( a USING latin1 )
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 494b7a36532..a3708d06a1c 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -984,4 +984,52 @@ f4 geometry YES NULL
f5 datetime YES NULL
drop view v1;
drop table t1;
+SELECT MultiPoint(12345,'');
+MultiPoint(12345,'')
+NULL
+SELECT MultiPoint(123451,'');
+MultiPoint(123451,'')
+NULL
+SELECT MultiPoint(1234512,'');
+MultiPoint(1234512,'')
+NULL
+SELECT MultiPoint(12345123,'');
+MultiPoint(12345123,'')
+NULL
+SELECT MultiLineString(12345,'');
+MultiLineString(12345,'')
+NULL
+SELECT MultiLineString(123451,'');
+MultiLineString(123451,'')
+NULL
+SELECT MultiLineString(1234512,'');
+MultiLineString(1234512,'')
+NULL
+SELECT MultiLineString(12345123,'');
+MultiLineString(12345123,'')
+NULL
+SELECT LineString(12345,'');
+LineString(12345,'')
+NULL
+SELECT LineString(123451,'');
+LineString(123451,'')
+NULL
+SELECT LineString(1234512,'');
+LineString(1234512,'')
+NULL
+SELECT LineString(12345123,'');
+LineString(12345123,'')
+NULL
+SELECT Polygon(12345,'');
+Polygon(12345,'')
+NULL
+SELECT Polygon(123451,'');
+Polygon(123451,'')
+NULL
+SELECT Polygon(1234512,'');
+Polygon(1234512,'')
+NULL
+SELECT Polygon(12345123,'');
+Polygon(12345123,'')
+NULL
End of 5.1 tests
diff --git a/mysql-test/r/innodb_bug40565.result b/mysql-test/r/innodb_bug40565.result
new file mode 100644
index 00000000000..21e923d9336
--- /dev/null
+++ b/mysql-test/r/innodb_bug40565.result
@@ -0,0 +1,9 @@
+create table bug40565(value decimal(4,2)) engine=innodb;
+insert into bug40565 values (1), (null);
+update bug40565 set value=NULL;
+affected rows: 1
+info: Rows matched: 2 Changed: 1 Warnings: 0
+update bug40565 set value=NULL;
+affected rows: 0
+info: Rows matched: 2 Changed: 0 Warnings: 0
+drop table bug40565;
diff --git a/mysql-test/r/innodb_bug45357.result b/mysql-test/r/innodb_bug45357.result
new file mode 100644
index 00000000000..7adeff2062f
--- /dev/null
+++ b/mysql-test/r/innodb_bug45357.result
@@ -0,0 +1,7 @@
+set session transaction isolation level read committed;
+create table bug45357(a int, b int,key(b))engine=innodb;
+insert into bug45357 values (25170,6122);
+update bug45357 set a=1 where b=30131;
+delete from bug45357 where b < 20996;
+delete from bug45357 where b < 7001;
+drop table bug45357;
diff --git a/mysql-test/r/mysql-bug45236.result b/mysql-test/r/mysql-bug45236.result
new file mode 100644
index 00000000000..cefcb1d314c
--- /dev/null
+++ b/mysql-test/r/mysql-bug45236.result
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS t1;
+SET @old_max_allowed_packet= @@global.max_allowed_packet;
+SET @@global.max_allowed_packet = 1024 * 1024 + 1024;
+CREATE TABLE t1(data LONGBLOB);
+INSERT INTO t1 SELECT CONCAT(REPEAT('1', 1024*1024 - 27),
+"\'\r dummydb dummyhost");
+DROP TABLE t1;
+SET @@global.max_allowed_packet = @old_max_allowed_packet;
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 20853da1af0..8e3fbde1ea8 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -1982,5 +1982,14 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range bc bc 10 NULL 7 Using where; Using index for group-by
DROP TABLE t1;
+#
+# Bug #45807: crash accessing partitioned table and sql_mode
+# contains ONLY_FULL_GROUP_BY
+#
+SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY';
+CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
+PARTITION BY HASH(id) PARTITIONS 2;
+DROP TABLE t1;
+SET SESSION SQL_MODE=DEFAULT;
End of 5.1 tests
SET @@global.general_log= @old_general_log;
diff --git a/mysql-test/r/query_cache_debug.result b/mysql-test/r/query_cache_debug.result
index b83bccef39c..eb59e62c8ba 100644
--- a/mysql-test/r/query_cache_debug.result
+++ b/mysql-test/r/query_cache_debug.result
@@ -141,9 +141,9 @@ KILL QUERY @flush_thread_id;
** and finally release the mutex. The threads will continue to wait
** until a broadcast signal reaches them causing both threads to
** come alive and check the condition.
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' LIMIT 1 INTO @thread_id;
+SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id;
KILL QUERY @thread_id;
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' LIMIT 1 INTO @thread_id;
+SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id;
KILL QUERY @thread_id;
**
** Finally signal the DELETE statement on THD1 one last time.
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 09c7d1b329d..50b5c3c13fb 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -4457,4 +4457,83 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1
DROP TABLE t1;
+#
+# Bug#45266: Uninitialized variable lead to an empty result.
+#
+drop table if exists A,AA,B,BB;
+CREATE TABLE `A` (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`date_key` date NOT NULL,
+`date_nokey` date NOT NULL,
+`datetime_key` datetime NOT NULL,
+`int_nokey` int(11) NOT NULL,
+`time_key` time NOT NULL,
+`time_nokey` time NOT NULL,
+PRIMARY KEY (`pk`),
+KEY `date_key` (`date_key`),
+KEY `time_key` (`time_key`),
+KEY `datetime_key` (`datetime_key`)
+);
+CREATE TABLE `AA` (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`int_nokey` int(11) NOT NULL,
+`time_key` time NOT NULL,
+KEY `time_key` (`time_key`),
+PRIMARY KEY (`pk`)
+);
+CREATE TABLE `B` (
+`date_nokey` date NOT NULL,
+`date_key` date NOT NULL,
+`time_key` time NOT NULL,
+`datetime_nokey` datetime NOT NULL,
+`varchar_key` varchar(1) NOT NULL,
+KEY `date_key` (`date_key`),
+KEY `time_key` (`time_key`),
+KEY `varchar_key` (`varchar_key`)
+);
+INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x');
+CREATE TABLE `BB` (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`int_nokey` int(11) NOT NULL,
+`date_key` date NOT NULL,
+`varchar_nokey` varchar(1) NOT NULL,
+`date_nokey` date NOT NULL,
+PRIMARY KEY (`pk`),
+KEY `date_key` (`date_key`)
+);
+INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18');
+SELECT table1 . `pk` AS field1
+FROM
+(BB AS table1 INNER JOIN
+(AA AS table2 STRAIGHT_JOIN A AS table3
+ON ( table3 . `date_key` = table2 . `pk` ))
+ON ( table3 . `datetime_key` = table2 . `int_nokey` ))
+WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`)
+GROUP BY field1 ;
+field1
+SELECT table3 .`date_key` field1
+FROM
+B table1 LEFT JOIN B table3 JOIN
+(BB table6 JOIN A table7 ON table6 .`varchar_nokey`)
+ON table6 .`int_nokey` ON table6 .`date_key`
+ WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1;
+field1
+NULL
+SELECT table4 . `time_nokey` AS field1 FROM
+(AA AS table1 CROSS JOIN
+(AA AS table2 STRAIGHT_JOIN
+(B AS table3 STRAIGHT_JOIN A AS table4
+ON ( table4 . `date_key` = table3 . `time_key` ))
+ON ( table4 . `pk` = table3 . `date_nokey` ))
+ON ( table4 . `time_key` = table3 . `datetime_nokey` ))
+WHERE ( table4 . `time_key` < table1 . `time_key` AND
+table1 . `int_nokey` != 'f')
+GROUP BY field1 ORDER BY field1 , field1;
+field1
+SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2;
+field2
+00:05:48
+15:13:38
+drop table A,AA,B,BB;
+#end of test for bug#45266
End of 5.1 tests
diff --git a/mysql-test/r/sp-fib.result b/mysql-test/r/sp-fib.result
index 50183221f03..a26e104c1e8 100644
--- a/mysql-test/r/sp-fib.result
+++ b/mysql-test/r/sp-fib.result
@@ -10,24 +10,17 @@ declare c cursor for select f from t3 order by f desc limit 2;
open c;
fetch c into y;
fetch c into x;
-close c;
insert into t3 values (x+y);
call fib(n-1);
+## Close the cursor AFTER the recursion to ensure that the stack
+## frame is somewhat intact.
+close c;
end;
end if;
end|
set @@max_sp_recursion_depth= 20|
insert into t3 values (0), (1)|
-call fib(3)|
-select * from t3 order by f asc|
-f
-0
-1
-1
-2
-truncate table t3|
-insert into t3 values (0), (1)|
-call fib(10)|
+call fib(4)|
select * from t3 order by f asc|
f
0
@@ -35,12 +28,6 @@ f
1
2
3
-5
-8
-13
-21
-34
-55
drop table t3|
drop procedure fib|
set @@max_sp_recursion_depth= 0|
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index 23f15f618f2..4476735735c 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -2073,4 +2073,18 @@ select @a, @b;
drop trigger trg1;
drop trigger trg2;
drop table t1, t2;
+CREATE TABLE t1 ( a INT, b INT );
+CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT );
+INSERT INTO t1 (a) VALUES (1);
+CREATE TRIGGER tr1
+BEFORE INSERT ON t2
+FOR EACH ROW
+BEGIN
+UPDATE a_nonextisting_table SET a = 1;
+END//
+CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1;
+ERROR 42S02: Table 'test.a_nonextisting_table' doesn't exist
+SELECT * FROM t2;
+a b
+DROP TABLE t1, t2;
End of 5.1 tests.
diff --git a/mysql-test/r/trigger_notembedded.result b/mysql-test/r/trigger_notembedded.result
index 1e13bff03b1..335e6910a3a 100644
--- a/mysql-test/r/trigger_notembedded.result
+++ b/mysql-test/r/trigger_notembedded.result
@@ -462,4 +462,18 @@ unlock tables;
select * from t1;
i
drop table t1;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a char(30)) ENGINE=MEMORY;
+CREATE TRIGGER db1.trg AFTER INSERT ON db1.t1 FOR EACH ROW
+INSERT INTO db1.t1 VALUES('Some very sensitive data goes here');
+CREATE USER 'no_rights'@'localhost';
+REVOKE ALL ON *.* FROM 'no_rights'@'localhost';
+FLUSH PRIVILEGES;
+SELECT trigger_name FROM INFORMATION_SCHEMA.TRIGGERS
+WHERE trigger_schema = 'db1';
+trigger_name
+SHOW CREATE TRIGGER db1.trg;
+ERROR 42000: Access denied; you need the TRIGGER privilege for this operation
+DROP USER 'no_rights'@'localhost';
+DROP DATABASE db1;
End of 5.1 tests.
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index f2b08d1c6b7..748aadee4fb 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -1524,10 +1524,10 @@ Warnings:
Warning 1264 Out of range value for column 'f1' at row 1
DESC t1;
Field Type Null Key Default Extra
-f1 decimal(59,30) NO 0.000000000000000000000000000000
+f1 decimal(65,30) NO 0.000000000000000000000000000000
SELECT f1 FROM t1;
f1
-99999999999999999999999999999.999999999999999999999999999999
+99999999999999999999999999999999999.999999999999999999999999999999
DROP TABLE t1;
select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 *
1.01500000 * 1.01500000 * 0.99500000);
@@ -1577,3 +1577,56 @@ Error 1264 Out of range value for column 'cast(-13.4 as decimal(2,1))' at row 1
select cast(98.6 as decimal(2,0));
cast(98.6 as decimal(2,0))
99
+#
+# Bug #45262: Bad effects with CREATE TABLE and DECIMAL
+#
+CREATE TABLE t1 SELECT .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note 1265 Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field Type Null Key Default Extra
+my_col decimal(30,30) NO 0.000000000000000000000000000000
+SELECT my_col FROM t1;
+my_col
+0.123456789123456789123456789123
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1 + .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note 1265 Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field Type Null Key Default Extra
+my_col decimal(65,30) NO 0.000000000000000000000000000000
+SELECT my_col FROM t1;
+my_col
+1.123456789123456789123456789123
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1 * .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note 1265 Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field Type Null Key Default Extra
+my_col decimal(65,30) NO 0.000000000000000000000000000000
+SELECT my_col FROM t1;
+my_col
+0.123456789123456789123456789123
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note 1265 Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field Type Null Key Default Extra
+my_col decimal(65,4) YES NULL
+SELECT my_col FROM t1;
+my_col
+8.1000
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+Warnings:
+Note 1265 Data truncated for column 'my_col' at row 1
+DESCRIBE t1;
+Field Type Null Key Default Extra
+my_col decimal(65,30) YES NULL
+SELECT my_col FROM t1;
+my_col
+0.012345687012345687012345687012
+DROP TABLE t1;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 613939bfdf6..2dc448a29d8 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -3718,6 +3718,117 @@ DROP TABLE t1;
# -- End of test case for Bug#40825
+#
+# Bug #45806 crash when replacing into a view with a join!
+#
+CREATE TABLE t1(a INT UNIQUE);
+CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a;
+INSERT INTO t1 VALUES (1), (2);
+REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v1;
+a
+1
+2
+1
+2
+REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v1;
+a
+1
+2
+3
+1
+2
+3
+1
+2
+3
+DELETE FROM t1 WHERE a=3;
+INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v1`.`a`= 1;
+SELECT * FROM v1;
+a
+1
+2
+1
+2
+CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a;
+REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v2;
+a
+1
+2
+1
+2
+1
+2
+1
+2
+REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v2;
+a
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v2`.`a`= 1;
+SELECT * FROM v2;
+a
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+DROP VIEW v1;
+DROP VIEW v2;
+DROP TABLE t1;
+# -- End of test case for Bug#45806
# -----------------------------------------------------------------
# -- End of 5.0 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result
index 92f52b402ec..a597806d897 100644
--- a/mysql-test/r/xa.result
+++ b/mysql-test/r/xa.result
@@ -81,3 +81,11 @@ xa rollback 'a';
xa start 'a';
xa end 'a';
xa rollback 'a';
+xa start 'a';
+xa end 'a';
+xa prepare 'a';
+xa commit 'a';
+xa start 'a';
+xa end 'a';
+xa prepare 'a';
+xa commit 'a';
diff --git a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result
new file mode 100644
index 00000000000..354fd832fb3
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_db_filter.result
@@ -0,0 +1,43 @@
+RESET MASTER;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+CREATE TABLE t3 (txt TEXT);
+CREATE TABLE t4 (a int) ENGINE= InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+INSERT INTO t1 VALUES (3);
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3;
+INSERT INTO t1 VALUES (4);
+CREATE DATABASE b42941;
+use b42941;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+CREATE TABLE t3 (txt TEXT);
+CREATE TABLE t4 (a int) ENGINE= InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+INSERT INTO t1 VALUES (3);
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3;
+INSERT INTO t1 VALUES (4);
+INSERT INTO test.t1 VALUES (5);
+FLUSH LOGS;
+UPDATE test.t1 t11, b42941.t1 t12 SET t11.id=10, t12.id=100;
+BEGIN;
+INSERT INTO test.t4 VALUES (1);
+INSERT INTO b42941.t4 VALUES (1);
+UPDATE test.t4 tn4, b42941.t4 tt4 SET tn4.a= 10, tt4.a= 100;
+COMMIT;
+FLUSH LOGS;
+SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1');
+SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2');
+SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1');
+SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2');
+SET @b42941_output.1= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.1');
+SET @b42941_output.2= LOAD_FILE('MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog.2');
+DROP DATABASE b42941;
+use test;
+DROP TABLE t1, t2, t3, t4;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
new file mode 100644
index 00000000000..439bff0cfe1
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
@@ -0,0 +1,30 @@
+### NOT filtered database => assertion: warnings ARE shown
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+Warnings:
+Note 1592 Statement may not be safe to log in statement format.
+DROP TABLE t1;
+### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
+SET SQL_LOG_BIN= 0;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+SET SQL_LOG_BIN= 1;
+### FILTERED database => assertion: warnings ARE NOT shown
+CREATE DATABASE b42851;
+USE b42851;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+DROP DATABASE b42851;
diff --git a/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
new file mode 100644
index 00000000000..0422c204270
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
@@ -0,0 +1,143 @@
+# BUG#42941: --database parameter to mysqlbinlog fails with RBR
+#
+# WHAT
+# ====
+#
+# This test aims at checking whether a rows log event is printed or
+# not when --database parameter is used to filter events from one
+# given database.
+#
+# HOW
+# ===
+#
+# The test is implemented as follows:
+#
+# i) Some operations are done in two different databases:
+# 'test' and 'b42941';
+# ii) mysqlbinlog is used to dump the contents of the binlog file
+# filtering only events from 'b42941'. The result of the dump is
+# stored in a temporary file. (This is done with and without
+# --verbose/hexdump flag);
+# iii) The contents of the dump are loaded into a session variable;
+# iv) The variable contents are searched for 'test' and 'b42941';
+# v) Should 'test' be found, an ERROR is reported. Should 'b42941' be
+# absent, an ERROR is reported.
+
+-- source include/have_log_bin.inc
+-- source include/have_binlog_format_row.inc
+-- source include/have_innodb.inc
+
+RESET MASTER;
+-- let $MYSQLD_DATADIR= `select @@datadir`
+
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+CREATE TABLE t3 (txt TEXT);
+CREATE TABLE t4 (a int) ENGINE= InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+INSERT INTO t1 VALUES (3);
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3
+INSERT INTO t1 VALUES (4);
+
+CREATE DATABASE b42941;
+use b42941;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+CREATE TABLE t3 (txt TEXT);
+CREATE TABLE t4 (a int) ENGINE= InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+INSERT INTO t1 VALUES (3);
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3
+INSERT INTO t1 VALUES (4);
+
+INSERT INTO test.t1 VALUES (5);
+
+FLUSH LOGS;
+
+UPDATE test.t1 t11, b42941.t1 t12 SET t11.id=10, t12.id=100;
+
+BEGIN;
+INSERT INTO test.t4 VALUES (1);
+INSERT INTO b42941.t4 VALUES (1);
+UPDATE test.t4 tn4, b42941.t4 tt4 SET tn4.a= 10, tt4.a= 100;
+COMMIT;
+
+FLUSH LOGS;
+
+-- let $log_file1= $MYSQLD_DATADIR/master-bin.000001
+-- let $log_file2= $MYSQLD_DATADIR/master-bin.000002
+-- let $outfile= $MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog
+-- let $cmd= $MYSQL_BINLOG
+
+let $i= 3;
+while($i)
+{
+ -- let $flags=--database=b42941
+
+ # construct CLI for mysqlbinlog
+ if(`SELECT $i=3`)
+ {
+ -- let $flags= $flags --verbose --hexdump
+ }
+
+ if(`SELECT $i=2`)
+ {
+ -- let $flags= $flags --verbose
+ }
+
+# if(`SELECT $i=1`)
+# {
+ # do nothing $flags is already set as it should be
+# }
+
+ # execute mysqlbinlog on the two available master binlog files
+ -- exec $cmd $flags $log_file1 > $outfile.1
+ -- exec $cmd $flags $log_file2 > $outfile.2
+
+ # load outputs into a variable
+ -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+ -- eval SET @b42941_output.1= LOAD_FILE('$outfile.1')
+
+ -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+ -- eval SET @b42941_output.2= LOAD_FILE('$outfile.2')
+
+ # remove unecessary files
+ -- remove_file $outfile.1
+ -- remove_file $outfile.2
+
+ # assertion: events for database test are filtered
+ if (`SELECT INSTR(@b42941_output.1, 'test')`)
+ {
+ -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1).
+ }
+
+ if (`SELECT INSTR(@b42941_output.2, 'test')`)
+ {
+ -- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2).
+ }
+
+ # assertion: events for database b42941 are not filtered
+ if (!`SELECT INSTR(@b42941_output.1, 'b42941')`)
+ {
+ -- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.1).
+ }
+
+ if (!`SELECT INSTR(@b42941_output.2, 'b42941')`)
+ {
+ -- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.2).
+ }
+
+ dec $i;
+}
+
+DROP DATABASE b42941;
+use test;
+DROP TABLE t1, t2, t3, t4;
diff --git a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt
new file mode 100644
index 00000000000..24c2027e399
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt
@@ -0,0 +1 @@
+--binlog-ignore-db=b42851
diff --git a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
new file mode 100644
index 00000000000..0bf685ea921
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
@@ -0,0 +1,73 @@
+# BUG#42851: Spurious "Statement is not safe to log in statement
+# format." warnings
+#
+# WHY
+# ===
+#
+# This test aims at checking that the fix that removes spurious
+# entries in the error log when the statement is filtered out from
+# binlog, is working.
+#
+# HOW
+# ===
+#
+# The test case is split into three assertions when issuing statements
+# containing LIMIT and ORDER BY:
+#
+# i) issue statements in database that is not filtered => check
+# that warnings ARE shown;
+#
+# ii) issue statements in database that is not filtered, but with
+# binlog disabled => check that warnings ARE NOT shown;
+#
+# iii) issue statements in database that is filtered => check that
+# warnings ARE NOT shown.
+
+-- source include/have_log_bin.inc
+-- source include/have_binlog_format_statement.inc
+
+-- echo ### NOT filtered database => assertion: warnings ARE shown
+
+-- disable_warnings
+DROP TABLE IF EXISTS t1;
+-- enable_warnings
+
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+
+-- echo ### NOT filtered database => assertion: binlog disabled and warnings ARE NOT shown
+
+SET SQL_LOG_BIN= 0;
+
+-- disable_warnings
+DROP TABLE IF EXISTS t1;
+-- enable_warnings
+
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+
+SET SQL_LOG_BIN= 1;
+
+-- echo ### FILTERED database => assertion: warnings ARE NOT shown
+
+CREATE DATABASE b42851;
+USE b42851;
+
+-- disable_warnings
+DROP TABLE IF EXISTS t1;
+-- enable_warnings
+
+CREATE TABLE t1 (a int, b int, primary key (a));
+INSERT INTO t1 VALUES (1,2), (2,3);
+UPDATE t1 SET b='4' WHERE a=1 LIMIT 1;
+UPDATE t1 SET b='5' WHERE a=2 ORDER BY a LIMIT 1;
+DROP TABLE t1;
+
+# clean up
+DROP DATABASE b42851;
diff --git a/mysql-test/suite/funcs_1/r/charset_collation.result b/mysql-test/suite/funcs_1/r/charset_collation.result
new file mode 100644
index 00000000000..b3183ba48e1
--- /dev/null
+++ b/mysql-test/suite/funcs_1/r/charset_collation.result
@@ -0,0 +1,40 @@
+DROP USER dbdict_test@localhost;
+CREATE USER dbdict_test@localhost;
+# Establish connection con (user=dbdict_test)
+
+SELECT *
+FROM information_schema.character_sets
+WHERE character_set_name IN ('utf8','latin1','binary')
+ORDER BY character_set_name;
+CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
+binary binary Binary pseudo charset 1
+latin1 latin1_swedish_ci cp1252 West European 1
+utf8 utf8_general_ci UTF-8 Unicode 3
+
+SELECT *
+FROM information_schema.collations
+WHERE character_set_name IN ('utf8','latin1','binary')
+AND (collation_name LIKE CONCAT(character_set_name,'_general_ci')
+OR
+collation_name LIKE CONCAT(character_set_name,'_bin'))
+ORDER BY collation_name;
+COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
+latin1_bin latin1 47 Yes 1
+latin1_general_ci latin1 48 Yes 1
+utf8_bin utf8 83 Yes 1
+utf8_general_ci utf8 33 Yes Yes 1
+
+SELECT *
+FROM information_schema.collation_character_set_applicability
+WHERE character_set_name IN ('utf8','latin1','binary')
+AND (collation_name LIKE CONCAT(character_set_name,'_general_ci')
+OR
+collation_name LIKE CONCAT(character_set_name,'_bin'))
+ORDER BY collation_name, character_set_name;
+COLLATION_NAME CHARACTER_SET_NAME
+latin1_bin latin1
+latin1_general_ci latin1
+utf8_bin utf8
+utf8_general_ci utf8
+# Switch to connection default + disconnect con
+DROP USER dbdict_test@localhost;
diff --git a/mysql-test/suite/funcs_1/r/charset_collation_1.result b/mysql-test/suite/funcs_1/r/charset_collation_1.result
deleted file mode 100644
index 55ed4b4704c..00000000000
--- a/mysql-test/suite/funcs_1/r/charset_collation_1.result
+++ /dev/null
@@ -1,312 +0,0 @@
-DROP USER dbdict_test@localhost;
-CREATE USER dbdict_test@localhost;
-# Establish connection con (user=dbdict_test)
-
-SELECT *
-FROM information_schema.character_sets
-ORDER BY character_set_name;
-CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
-armscii8 armscii8_general_ci ARMSCII-8 Armenian 1
-ascii ascii_general_ci US ASCII 1
-big5 big5_chinese_ci Big5 Traditional Chinese 2
-binary binary Binary pseudo charset 1
-cp1250 cp1250_general_ci Windows Central European 1
-cp1251 cp1251_general_ci Windows Cyrillic 1
-cp1256 cp1256_general_ci Windows Arabic 1
-cp1257 cp1257_general_ci Windows Baltic 1
-cp850 cp850_general_ci DOS West European 1
-cp852 cp852_general_ci DOS Central European 1
-cp866 cp866_general_ci DOS Russian 1
-cp932 cp932_japanese_ci SJIS for Windows Japanese 2
-dec8 dec8_swedish_ci DEC West European 1
-eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3
-euckr euckr_korean_ci EUC-KR Korean 2
-gb2312 gb2312_chinese_ci GB2312 Simplified Chinese 2
-gbk gbk_chinese_ci GBK Simplified Chinese 2
-geostd8 geostd8_general_ci GEOSTD8 Georgian 1
-greek greek_general_ci ISO 8859-7 Greek 1
-hebrew hebrew_general_ci ISO 8859-8 Hebrew 1
-hp8 hp8_english_ci HP West European 1
-keybcs2 keybcs2_general_ci DOS Kamenicky Czech-Slovak 1
-koi8r koi8r_general_ci KOI8-R Relcom Russian 1
-koi8u koi8u_general_ci KOI8-U Ukrainian 1
-latin1 latin1_swedish_ci cp1252 West European 1
-latin2 latin2_general_ci ISO 8859-2 Central European 1
-latin5 latin5_turkish_ci ISO 8859-9 Turkish 1
-latin7 latin7_general_ci ISO 8859-13 Baltic 1
-macce macce_general_ci Mac Central European 1
-macroman macroman_general_ci Mac West European 1
-sjis sjis_japanese_ci Shift-JIS Japanese 2
-swe7 swe7_swedish_ci 7bit Swedish 1
-tis620 tis620_thai_ci TIS620 Thai 1
-ucs2 ucs2_general_ci UCS-2 Unicode 2
-ujis ujis_japanese_ci EUC-JP Japanese 3
-utf8 utf8_general_ci UTF-8 Unicode 3
-
-SELECT *
-FROM information_schema.collations
-ORDER BY collation_name;
-COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
-armscii8_bin armscii8 64 0
-armscii8_general_ci armscii8 32 Yes 0
-ascii_bin ascii 65 0
-ascii_general_ci ascii 11 Yes 0
-big5_bin big5 84 Yes 1
-big5_chinese_ci big5 1 Yes Yes 1
-binary binary 63 Yes Yes 1
-cp1250_bin cp1250 66 Yes 1
-cp1250_croatian_ci cp1250 44 Yes 1
-cp1250_czech_cs cp1250 34 Yes 2
-cp1250_general_ci cp1250 26 Yes Yes 1
-cp1250_polish_ci cp1250 99 Yes 1
-cp1251_bin cp1251 50 0
-cp1251_bulgarian_ci cp1251 14 0
-cp1251_general_ci cp1251 51 Yes 0
-cp1251_general_cs cp1251 52 0
-cp1251_ukrainian_ci cp1251 23 0
-cp1256_bin cp1256 67 0
-cp1256_general_ci cp1256 57 Yes 0
-cp1257_bin cp1257 58 0
-cp1257_general_ci cp1257 59 Yes 0
-cp1257_lithuanian_ci cp1257 29 0
-cp850_bin cp850 80 0
-cp850_general_ci cp850 4 Yes 0
-cp852_bin cp852 81 0
-cp852_general_ci cp852 40 Yes 0
-cp866_bin cp866 68 0
-cp866_general_ci cp866 36 Yes 0
-cp932_bin cp932 96 Yes 1
-cp932_japanese_ci cp932 95 Yes Yes 1
-dec8_bin dec8 69 0
-dec8_swedish_ci dec8 3 Yes 0
-eucjpms_bin eucjpms 98 Yes 1
-eucjpms_japanese_ci eucjpms 97 Yes Yes 1
-euckr_bin euckr 85 Yes 1
-euckr_korean_ci euckr 19 Yes Yes 1
-gb2312_bin gb2312 86 Yes 1
-gb2312_chinese_ci gb2312 24 Yes Yes 1
-gbk_bin gbk 87 Yes 1
-gbk_chinese_ci gbk 28 Yes Yes 1
-geostd8_bin geostd8 93 0
-geostd8_general_ci geostd8 92 Yes 0
-greek_bin greek 70 0
-greek_general_ci greek 25 Yes 0
-hebrew_bin hebrew 71 0
-hebrew_general_ci hebrew 16 Yes 0
-hp8_bin hp8 72 0
-hp8_english_ci hp8 6 Yes 0
-keybcs2_bin keybcs2 73 0
-keybcs2_general_ci keybcs2 37 Yes 0
-koi8r_bin koi8r 74 0
-koi8r_general_ci koi8r 7 Yes 0
-koi8u_bin koi8u 75 0
-koi8u_general_ci koi8u 22 Yes 0
-latin1_bin latin1 47 Yes 1
-latin1_danish_ci latin1 15 Yes 1
-latin1_general_ci latin1 48 Yes 1
-latin1_general_cs latin1 49 Yes 1
-latin1_german1_ci latin1 5 Yes 1
-latin1_german2_ci latin1 31 Yes 2
-latin1_spanish_ci latin1 94 Yes 1
-latin1_swedish_ci latin1 8 Yes Yes 1
-latin2_bin latin2 77 Yes 1
-latin2_croatian_ci latin2 27 Yes 1
-latin2_czech_cs latin2 2 Yes 4
-latin2_general_ci latin2 9 Yes Yes 1
-latin2_hungarian_ci latin2 21 Yes 1
-latin5_bin latin5 78 0
-latin5_turkish_ci latin5 30 Yes 0
-latin7_bin latin7 79 0
-latin7_estonian_cs latin7 20 0
-latin7_general_ci latin7 41 Yes 0
-latin7_general_cs latin7 42 0
-macce_bin macce 43 0
-macce_general_ci macce 38 Yes 0
-macroman_bin macroman 53 0
-macroman_general_ci macroman 39 Yes 0
-sjis_bin sjis 88 Yes 1
-sjis_japanese_ci sjis 13 Yes Yes 1
-swe7_bin swe7 82 0
-swe7_swedish_ci swe7 10 Yes 0
-tis620_bin tis620 89 Yes 1
-tis620_thai_ci tis620 18 Yes Yes 4
-ucs2_bin ucs2 90 Yes 1
-ucs2_czech_ci ucs2 138 Yes 8
-ucs2_danish_ci ucs2 139 Yes 8
-ucs2_esperanto_ci ucs2 145 Yes 8
-ucs2_estonian_ci ucs2 134 Yes 8
-ucs2_general_ci ucs2 35 Yes Yes 1
-ucs2_hungarian_ci ucs2 146 Yes 8
-ucs2_icelandic_ci ucs2 129 Yes 8
-ucs2_latvian_ci ucs2 130 Yes 8
-ucs2_lithuanian_ci ucs2 140 Yes 8
-ucs2_persian_ci ucs2 144 Yes 8
-ucs2_polish_ci ucs2 133 Yes 8
-ucs2_romanian_ci ucs2 131 Yes 8
-ucs2_roman_ci ucs2 143 Yes 8
-ucs2_slovak_ci ucs2 141 Yes 8
-ucs2_slovenian_ci ucs2 132 Yes 8
-ucs2_spanish2_ci ucs2 142 Yes 8
-ucs2_spanish_ci ucs2 135 Yes 8
-ucs2_swedish_ci ucs2 136 Yes 8
-ucs2_turkish_ci ucs2 137 Yes 8
-ucs2_unicode_ci ucs2 128 Yes 8
-ujis_bin ujis 91 Yes 1
-ujis_japanese_ci ujis 12 Yes Yes 1
-utf8_bin utf8 83 Yes 1
-utf8_czech_ci utf8 202 Yes 8
-utf8_danish_ci utf8 203 Yes 8
-utf8_esperanto_ci utf8 209 Yes 8
-utf8_estonian_ci utf8 198 Yes 8
-utf8_general_ci utf8 33 Yes Yes 1
-utf8_hungarian_ci utf8 210 Yes 8
-utf8_icelandic_ci utf8 193 Yes 8
-utf8_latvian_ci utf8 194 Yes 8
-utf8_lithuanian_ci utf8 204 Yes 8
-utf8_persian_ci utf8 208 Yes 8
-utf8_polish_ci utf8 197 Yes 8
-utf8_romanian_ci utf8 195 Yes 8
-utf8_roman_ci utf8 207 Yes 8
-utf8_slovak_ci utf8 205 Yes 8
-utf8_slovenian_ci utf8 196 Yes 8
-utf8_spanish2_ci utf8 206 Yes 8
-utf8_spanish_ci utf8 199 Yes 8
-utf8_swedish_ci utf8 200 Yes 8
-utf8_turkish_ci utf8 201 Yes 8
-utf8_unicode_ci utf8 192 Yes 8
-
-
-SELECT *
-FROM information_schema.collation_character_set_applicability
-ORDER BY collation_name, character_set_name;
-COLLATION_NAME CHARACTER_SET_NAME
-armscii8_bin armscii8
-armscii8_general_ci armscii8
-ascii_bin ascii
-ascii_general_ci ascii
-big5_bin big5
-big5_chinese_ci big5
-binary binary
-cp1250_bin cp1250
-cp1250_croatian_ci cp1250
-cp1250_czech_cs cp1250
-cp1250_general_ci cp1250
-cp1250_polish_ci cp1250
-cp1251_bin cp1251
-cp1251_bulgarian_ci cp1251
-cp1251_general_ci cp1251
-cp1251_general_cs cp1251
-cp1251_ukrainian_ci cp1251
-cp1256_bin cp1256
-cp1256_general_ci cp1256
-cp1257_bin cp1257
-cp1257_general_ci cp1257
-cp1257_lithuanian_ci cp1257
-cp850_bin cp850
-cp850_general_ci cp850
-cp852_bin cp852
-cp852_general_ci cp852
-cp866_bin cp866
-cp866_general_ci cp866
-cp932_bin cp932
-cp932_japanese_ci cp932
-dec8_bin dec8
-dec8_swedish_ci dec8
-eucjpms_bin eucjpms
-eucjpms_japanese_ci eucjpms
-euckr_bin euckr
-euckr_korean_ci euckr
-filename filename
-gb2312_bin gb2312
-gb2312_chinese_ci gb2312
-gbk_bin gbk
-gbk_chinese_ci gbk
-geostd8_bin geostd8
-geostd8_general_ci geostd8
-greek_bin greek
-greek_general_ci greek
-hebrew_bin hebrew
-hebrew_general_ci hebrew
-hp8_bin hp8
-hp8_english_ci hp8
-keybcs2_bin keybcs2
-keybcs2_general_ci keybcs2
-koi8r_bin koi8r
-koi8r_general_ci koi8r
-koi8u_bin koi8u
-koi8u_general_ci koi8u
-latin1_bin latin1
-latin1_danish_ci latin1
-latin1_general_ci latin1
-latin1_general_cs latin1
-latin1_german1_ci latin1
-latin1_german2_ci latin1
-latin1_spanish_ci latin1
-latin1_swedish_ci latin1
-latin2_bin latin2
-latin2_croatian_ci latin2
-latin2_czech_cs latin2
-latin2_general_ci latin2
-latin2_hungarian_ci latin2
-latin5_bin latin5
-latin5_turkish_ci latin5
-latin7_bin latin7
-latin7_estonian_cs latin7
-latin7_general_ci latin7
-latin7_general_cs latin7
-macce_bin macce
-macce_general_ci macce
-macroman_bin macroman
-macroman_general_ci macroman
-sjis_bin sjis
-sjis_japanese_ci sjis
-swe7_bin swe7
-swe7_swedish_ci swe7
-tis620_bin tis620
-tis620_thai_ci tis620
-ucs2_bin ucs2
-ucs2_czech_ci ucs2
-ucs2_danish_ci ucs2
-ucs2_esperanto_ci ucs2
-ucs2_estonian_ci ucs2
-ucs2_general_ci ucs2
-ucs2_hungarian_ci ucs2
-ucs2_icelandic_ci ucs2
-ucs2_latvian_ci ucs2
-ucs2_lithuanian_ci ucs2
-ucs2_persian_ci ucs2
-ucs2_polish_ci ucs2
-ucs2_romanian_ci ucs2
-ucs2_roman_ci ucs2
-ucs2_slovak_ci ucs2
-ucs2_slovenian_ci ucs2
-ucs2_spanish2_ci ucs2
-ucs2_spanish_ci ucs2
-ucs2_swedish_ci ucs2
-ucs2_turkish_ci ucs2
-ucs2_unicode_ci ucs2
-ujis_bin ujis
-ujis_japanese_ci ujis
-utf8_bin utf8
-utf8_czech_ci utf8
-utf8_danish_ci utf8
-utf8_esperanto_ci utf8
-utf8_estonian_ci utf8
-utf8_general_ci utf8
-utf8_hungarian_ci utf8
-utf8_icelandic_ci utf8
-utf8_latvian_ci utf8
-utf8_lithuanian_ci utf8
-utf8_persian_ci utf8
-utf8_polish_ci utf8
-utf8_romanian_ci utf8
-utf8_roman_ci utf8
-utf8_slovak_ci utf8
-utf8_slovenian_ci utf8
-utf8_spanish2_ci utf8
-utf8_spanish_ci utf8
-utf8_swedish_ci utf8
-utf8_turkish_ci utf8
-utf8_unicode_ci utf8
-# Switch to connection default + disconnect con
-DROP USER dbdict_test@localhost;
diff --git a/mysql-test/suite/funcs_1/r/charset_collation_2.result b/mysql-test/suite/funcs_1/r/charset_collation_2.result
deleted file mode 100644
index a9fb15a588c..00000000000
--- a/mysql-test/suite/funcs_1/r/charset_collation_2.result
+++ /dev/null
@@ -1,314 +0,0 @@
-DROP USER dbdict_test@localhost;
-CREATE USER dbdict_test@localhost;
-# Establish connection con (user=dbdict_test)
-
-SELECT *
-FROM information_schema.character_sets
-ORDER BY character_set_name;
-CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
-armscii8 armscii8_general_ci ARMSCII-8 Armenian 1
-ascii ascii_general_ci US ASCII 1
-big5 big5_chinese_ci Big5 Traditional Chinese 2
-binary binary Binary pseudo charset 1
-cp1250 cp1250_general_ci Windows Central European 1
-cp1251 cp1251_general_ci Windows Cyrillic 1
-cp1256 cp1256_general_ci Windows Arabic 1
-cp1257 cp1257_general_ci Windows Baltic 1
-cp850 cp850_general_ci DOS West European 1
-cp852 cp852_general_ci DOS Central European 1
-cp866 cp866_general_ci DOS Russian 1
-cp932 cp932_japanese_ci SJIS for Windows Japanese 2
-dec8 dec8_swedish_ci DEC West European 1
-eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3
-euckr euckr_korean_ci EUC-KR Korean 2
-gb2312 gb2312_chinese_ci GB2312 Simplified Chinese 2
-gbk gbk_chinese_ci GBK Simplified Chinese 2
-geostd8 geostd8_general_ci GEOSTD8 Georgian 1
-greek greek_general_ci ISO 8859-7 Greek 1
-hebrew hebrew_general_ci ISO 8859-8 Hebrew 1
-hp8 hp8_english_ci HP West European 1
-keybcs2 keybcs2_general_ci DOS Kamenicky Czech-Slovak 1
-koi8r koi8r_general_ci KOI8-R Relcom Russian 1
-koi8u koi8u_general_ci KOI8-U Ukrainian 1
-latin1 latin1_swedish_ci cp1252 West European 1
-latin2 latin2_general_ci ISO 8859-2 Central European 1
-latin5 latin5_turkish_ci ISO 8859-9 Turkish 1
-latin7 latin7_general_ci ISO 8859-13 Baltic 1
-macce macce_general_ci Mac Central European 1
-macroman macroman_general_ci Mac West European 1
-sjis sjis_japanese_ci Shift-JIS Japanese 2
-swe7 swe7_swedish_ci 7bit Swedish 1
-tis620 tis620_thai_ci TIS620 Thai 1
-ucs2 ucs2_general_ci UCS-2 Unicode 2
-ujis ujis_japanese_ci EUC-JP Japanese 3
-utf8 utf8_general_ci UTF-8 Unicode 3
-
-SELECT *
-FROM information_schema.collations
-ORDER BY collation_name;
-COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
-armscii8_bin armscii8 64 0
-armscii8_general_ci armscii8 32 Yes 0
-ascii_bin ascii 65 0
-ascii_general_ci ascii 11 Yes 0
-big5_bin big5 84 Yes 1
-big5_chinese_ci big5 1 Yes Yes 1
-binary binary 63 Yes Yes 1
-cp1250_bin cp1250 66 Yes 1
-cp1250_croatian_ci cp1250 44 Yes 1
-cp1250_czech_cs cp1250 34 Yes 2
-cp1250_general_ci cp1250 26 Yes Yes 1
-cp1250_polish_ci cp1250 99 Yes 1
-cp1251_bin cp1251 50 0
-cp1251_bulgarian_ci cp1251 14 0
-cp1251_general_ci cp1251 51 Yes 0
-cp1251_general_cs cp1251 52 0
-cp1251_ukrainian_ci cp1251 23 0
-cp1256_bin cp1256 67 0
-cp1256_general_ci cp1256 57 Yes 0
-cp1257_bin cp1257 58 0
-cp1257_general_ci cp1257 59 Yes 0
-cp1257_lithuanian_ci cp1257 29 0
-cp850_bin cp850 80 0
-cp850_general_ci cp850 4 Yes 0
-cp852_bin cp852 81 0
-cp852_general_ci cp852 40 Yes 0
-cp866_bin cp866 68 0
-cp866_general_ci cp866 36 Yes 0
-cp932_bin cp932 96 Yes 1
-cp932_japanese_ci cp932 95 Yes Yes 1
-dec8_bin dec8 69 0
-dec8_swedish_ci dec8 3 Yes 0
-eucjpms_bin eucjpms 98 Yes 1
-eucjpms_japanese_ci eucjpms 97 Yes Yes 1
-euckr_bin euckr 85 Yes 1
-euckr_korean_ci euckr 19 Yes Yes 1
-gb2312_bin gb2312 86 Yes 1
-gb2312_chinese_ci gb2312 24 Yes Yes 1
-gbk_bin gbk 87 Yes 1
-gbk_chinese_ci gbk 28 Yes Yes 1
-geostd8_bin geostd8 93 0
-geostd8_general_ci geostd8 92 Yes 0
-greek_bin greek 70 0
-greek_general_ci greek 25 Yes 0
-hebrew_bin hebrew 71 0
-hebrew_general_ci hebrew 16 Yes 0
-hp8_bin hp8 72 0
-hp8_english_ci hp8 6 Yes 0
-keybcs2_bin keybcs2 73 0
-keybcs2_general_ci keybcs2 37 Yes 0
-koi8r_bin koi8r 74 0
-koi8r_general_ci koi8r 7 Yes 0
-koi8u_bin koi8u 75 0
-koi8u_general_ci koi8u 22 Yes 0
-latin1_bin latin1 47 Yes 1
-latin1_danish_ci latin1 15 Yes 1
-latin1_general_ci latin1 48 Yes 1
-latin1_general_cs latin1 49 Yes 1
-latin1_german1_ci latin1 5 Yes 1
-latin1_german2_ci latin1 31 Yes 2
-latin1_spanish_ci latin1 94 Yes 1
-latin1_swedish_ci latin1 8 Yes Yes 1
-latin2_bin latin2 77 Yes 1
-latin2_croatian_ci latin2 27 Yes 1
-latin2_czech_cs latin2 2 Yes 4
-latin2_general_ci latin2 9 Yes Yes 1
-latin2_hungarian_ci latin2 21 Yes 1
-latin5_bin latin5 78 0
-latin5_turkish_ci latin5 30 Yes 0
-latin7_bin latin7 79 0
-latin7_estonian_cs latin7 20 0
-latin7_general_ci latin7 41 Yes 0
-latin7_general_cs latin7 42 0
-macce_bin macce 43 0
-macce_general_ci macce 38 Yes 0
-macroman_bin macroman 53 0
-macroman_general_ci macroman 39 Yes 0
-sjis_bin sjis 88 Yes 1
-sjis_japanese_ci sjis 13 Yes Yes 1
-swe7_bin swe7 82 0
-swe7_swedish_ci swe7 10 Yes 0
-tis620_bin tis620 89 Yes 1
-tis620_thai_ci tis620 18 Yes Yes 4
-ucs2_bin ucs2 90 Yes 1
-ucs2_czech_ci ucs2 138 Yes 8
-ucs2_danish_ci ucs2 139 Yes 8
-ucs2_esperanto_ci ucs2 145 Yes 8
-ucs2_estonian_ci ucs2 134 Yes 8
-ucs2_general_ci ucs2 35 Yes Yes 1
-ucs2_hungarian_ci ucs2 146 Yes 8
-ucs2_icelandic_ci ucs2 129 Yes 8
-ucs2_latvian_ci ucs2 130 Yes 8
-ucs2_lithuanian_ci ucs2 140 Yes 8
-ucs2_persian_ci ucs2 144 Yes 8
-ucs2_polish_ci ucs2 133 Yes 8
-ucs2_romanian_ci ucs2 131 Yes 8
-ucs2_roman_ci ucs2 143 Yes 8
-ucs2_slovak_ci ucs2 141 Yes 8
-ucs2_slovenian_ci ucs2 132 Yes 8
-ucs2_spanish2_ci ucs2 142 Yes 8
-ucs2_spanish_ci ucs2 135 Yes 8
-ucs2_swedish_ci ucs2 136 Yes 8
-ucs2_turkish_ci ucs2 137 Yes 8
-ucs2_unicode_ci ucs2 128 Yes 8
-ujis_bin ujis 91 Yes 1
-ujis_japanese_ci ujis 12 Yes Yes 1
-utf8_bin utf8 83 Yes 1
-utf8_czech_ci utf8 202 Yes 8
-utf8_danish_ci utf8 203 Yes 8
-utf8_esperanto_ci utf8 209 Yes 8
-utf8_estonian_ci utf8 198 Yes 8
-utf8_general_ci utf8 33 Yes Yes 1
-utf8_general_cs utf8 254 Yes 1
-utf8_hungarian_ci utf8 210 Yes 8
-utf8_icelandic_ci utf8 193 Yes 8
-utf8_latvian_ci utf8 194 Yes 8
-utf8_lithuanian_ci utf8 204 Yes 8
-utf8_persian_ci utf8 208 Yes 8
-utf8_polish_ci utf8 197 Yes 8
-utf8_romanian_ci utf8 195 Yes 8
-utf8_roman_ci utf8 207 Yes 8
-utf8_slovak_ci utf8 205 Yes 8
-utf8_slovenian_ci utf8 196 Yes 8
-utf8_spanish2_ci utf8 206 Yes 8
-utf8_spanish_ci utf8 199 Yes 8
-utf8_swedish_ci utf8 200 Yes 8
-utf8_turkish_ci utf8 201 Yes 8
-utf8_unicode_ci utf8 192 Yes 8
-
-
-SELECT *
-FROM information_schema.collation_character_set_applicability
-ORDER BY collation_name, character_set_name;
-COLLATION_NAME CHARACTER_SET_NAME
-armscii8_bin armscii8
-armscii8_general_ci armscii8
-ascii_bin ascii
-ascii_general_ci ascii
-big5_bin big5
-big5_chinese_ci big5
-binary binary
-cp1250_bin cp1250
-cp1250_croatian_ci cp1250
-cp1250_czech_cs cp1250
-cp1250_general_ci cp1250
-cp1250_polish_ci cp1250
-cp1251_bin cp1251
-cp1251_bulgarian_ci cp1251
-cp1251_general_ci cp1251
-cp1251_general_cs cp1251
-cp1251_ukrainian_ci cp1251
-cp1256_bin cp1256
-cp1256_general_ci cp1256
-cp1257_bin cp1257
-cp1257_general_ci cp1257
-cp1257_lithuanian_ci cp1257
-cp850_bin cp850
-cp850_general_ci cp850
-cp852_bin cp852
-cp852_general_ci cp852
-cp866_bin cp866
-cp866_general_ci cp866
-cp932_bin cp932
-cp932_japanese_ci cp932
-dec8_bin dec8
-dec8_swedish_ci dec8
-eucjpms_bin eucjpms
-eucjpms_japanese_ci eucjpms
-euckr_bin euckr
-euckr_korean_ci euckr
-filename filename
-gb2312_bin gb2312
-gb2312_chinese_ci gb2312
-gbk_bin gbk
-gbk_chinese_ci gbk
-geostd8_bin geostd8
-geostd8_general_ci geostd8
-greek_bin greek
-greek_general_ci greek
-hebrew_bin hebrew
-hebrew_general_ci hebrew
-hp8_bin hp8
-hp8_english_ci hp8
-keybcs2_bin keybcs2
-keybcs2_general_ci keybcs2
-koi8r_bin koi8r
-koi8r_general_ci koi8r
-koi8u_bin koi8u
-koi8u_general_ci koi8u
-latin1_bin latin1
-latin1_danish_ci latin1
-latin1_general_ci latin1
-latin1_general_cs latin1
-latin1_german1_ci latin1
-latin1_german2_ci latin1
-latin1_spanish_ci latin1
-latin1_swedish_ci latin1
-latin2_bin latin2
-latin2_croatian_ci latin2
-latin2_czech_cs latin2
-latin2_general_ci latin2
-latin2_hungarian_ci latin2
-latin5_bin latin5
-latin5_turkish_ci latin5
-latin7_bin latin7
-latin7_estonian_cs latin7
-latin7_general_ci latin7
-latin7_general_cs latin7
-macce_bin macce
-macce_general_ci macce
-macroman_bin macroman
-macroman_general_ci macroman
-sjis_bin sjis
-sjis_japanese_ci sjis
-swe7_bin swe7
-swe7_swedish_ci swe7
-tis620_bin tis620
-tis620_thai_ci tis620
-ucs2_bin ucs2
-ucs2_czech_ci ucs2
-ucs2_danish_ci ucs2
-ucs2_esperanto_ci ucs2
-ucs2_estonian_ci ucs2
-ucs2_general_ci ucs2
-ucs2_hungarian_ci ucs2
-ucs2_icelandic_ci ucs2
-ucs2_latvian_ci ucs2
-ucs2_lithuanian_ci ucs2
-ucs2_persian_ci ucs2
-ucs2_polish_ci ucs2
-ucs2_romanian_ci ucs2
-ucs2_roman_ci ucs2
-ucs2_slovak_ci ucs2
-ucs2_slovenian_ci ucs2
-ucs2_spanish2_ci ucs2
-ucs2_spanish_ci ucs2
-ucs2_swedish_ci ucs2
-ucs2_turkish_ci ucs2
-ucs2_unicode_ci ucs2
-ujis_bin ujis
-ujis_japanese_ci ujis
-utf8_bin utf8
-utf8_czech_ci utf8
-utf8_danish_ci utf8
-utf8_esperanto_ci utf8
-utf8_estonian_ci utf8
-utf8_general_ci utf8
-utf8_general_cs utf8
-utf8_hungarian_ci utf8
-utf8_icelandic_ci utf8
-utf8_latvian_ci utf8
-utf8_lithuanian_ci utf8
-utf8_persian_ci utf8
-utf8_polish_ci utf8
-utf8_romanian_ci utf8
-utf8_roman_ci utf8
-utf8_slovak_ci utf8
-utf8_slovenian_ci utf8
-utf8_spanish2_ci utf8
-utf8_spanish_ci utf8
-utf8_swedish_ci utf8
-utf8_turkish_ci utf8
-utf8_unicode_ci utf8
-# Switch to connection default + disconnect con
-DROP USER dbdict_test@localhost;
diff --git a/mysql-test/suite/funcs_1/r/charset_collation_3.result b/mysql-test/suite/funcs_1/r/charset_collation_3.result
deleted file mode 100644
index 55ed4b4704c..00000000000
--- a/mysql-test/suite/funcs_1/r/charset_collation_3.result
+++ /dev/null
@@ -1,312 +0,0 @@
-DROP USER dbdict_test@localhost;
-CREATE USER dbdict_test@localhost;
-# Establish connection con (user=dbdict_test)
-
-SELECT *
-FROM information_schema.character_sets
-ORDER BY character_set_name;
-CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN
-armscii8 armscii8_general_ci ARMSCII-8 Armenian 1
-ascii ascii_general_ci US ASCII 1
-big5 big5_chinese_ci Big5 Traditional Chinese 2
-binary binary Binary pseudo charset 1
-cp1250 cp1250_general_ci Windows Central European 1
-cp1251 cp1251_general_ci Windows Cyrillic 1
-cp1256 cp1256_general_ci Windows Arabic 1
-cp1257 cp1257_general_ci Windows Baltic 1
-cp850 cp850_general_ci DOS West European 1
-cp852 cp852_general_ci DOS Central European 1
-cp866 cp866_general_ci DOS Russian 1
-cp932 cp932_japanese_ci SJIS for Windows Japanese 2
-dec8 dec8_swedish_ci DEC West European 1
-eucjpms eucjpms_japanese_ci UJIS for Windows Japanese 3
-euckr euckr_korean_ci EUC-KR Korean 2
-gb2312 gb2312_chinese_ci GB2312 Simplified Chinese 2
-gbk gbk_chinese_ci GBK Simplified Chinese 2
-geostd8 geostd8_general_ci GEOSTD8 Georgian 1
-greek greek_general_ci ISO 8859-7 Greek 1
-hebrew hebrew_general_ci ISO 8859-8 Hebrew 1
-hp8 hp8_english_ci HP West European 1
-keybcs2 keybcs2_general_ci DOS Kamenicky Czech-Slovak 1
-koi8r koi8r_general_ci KOI8-R Relcom Russian 1
-koi8u koi8u_general_ci KOI8-U Ukrainian 1
-latin1 latin1_swedish_ci cp1252 West European 1
-latin2 latin2_general_ci ISO 8859-2 Central European 1
-latin5 latin5_turkish_ci ISO 8859-9 Turkish 1
-latin7 latin7_general_ci ISO 8859-13 Baltic 1
-macce macce_general_ci Mac Central European 1
-macroman macroman_general_ci Mac West European 1
-sjis sjis_japanese_ci Shift-JIS Japanese 2
-swe7 swe7_swedish_ci 7bit Swedish 1
-tis620 tis620_thai_ci TIS620 Thai 1
-ucs2 ucs2_general_ci UCS-2 Unicode 2
-ujis ujis_japanese_ci EUC-JP Japanese 3
-utf8 utf8_general_ci UTF-8 Unicode 3
-
-SELECT *
-FROM information_schema.collations
-ORDER BY collation_name;
-COLLATION_NAME CHARACTER_SET_NAME ID IS_DEFAULT IS_COMPILED SORTLEN
-armscii8_bin armscii8 64 0
-armscii8_general_ci armscii8 32 Yes 0
-ascii_bin ascii 65 0
-ascii_general_ci ascii 11 Yes 0
-big5_bin big5 84 Yes 1
-big5_chinese_ci big5 1 Yes Yes 1
-binary binary 63 Yes Yes 1
-cp1250_bin cp1250 66 Yes 1
-cp1250_croatian_ci cp1250 44 Yes 1
-cp1250_czech_cs cp1250 34 Yes 2
-cp1250_general_ci cp1250 26 Yes Yes 1
-cp1250_polish_ci cp1250 99 Yes 1
-cp1251_bin cp1251 50 0
-cp1251_bulgarian_ci cp1251 14 0
-cp1251_general_ci cp1251 51 Yes 0
-cp1251_general_cs cp1251 52 0
-cp1251_ukrainian_ci cp1251 23 0
-cp1256_bin cp1256 67 0
-cp1256_general_ci cp1256 57 Yes 0
-cp1257_bin cp1257 58 0
-cp1257_general_ci cp1257 59 Yes 0
-cp1257_lithuanian_ci cp1257 29 0
-cp850_bin cp850 80 0
-cp850_general_ci cp850 4 Yes 0
-cp852_bin cp852 81 0
-cp852_general_ci cp852 40 Yes 0
-cp866_bin cp866 68 0
-cp866_general_ci cp866 36 Yes 0
-cp932_bin cp932 96 Yes 1
-cp932_japanese_ci cp932 95 Yes Yes 1
-dec8_bin dec8 69 0
-dec8_swedish_ci dec8 3 Yes 0
-eucjpms_bin eucjpms 98 Yes 1
-eucjpms_japanese_ci eucjpms 97 Yes Yes 1
-euckr_bin euckr 85 Yes 1
-euckr_korean_ci euckr 19 Yes Yes 1
-gb2312_bin gb2312 86 Yes 1
-gb2312_chinese_ci gb2312 24 Yes Yes 1
-gbk_bin gbk 87 Yes 1
-gbk_chinese_ci gbk 28 Yes Yes 1
-geostd8_bin geostd8 93 0
-geostd8_general_ci geostd8 92 Yes 0
-greek_bin greek 70 0
-greek_general_ci greek 25 Yes 0
-hebrew_bin hebrew 71 0
-hebrew_general_ci hebrew 16 Yes 0
-hp8_bin hp8 72 0
-hp8_english_ci hp8 6 Yes 0
-keybcs2_bin keybcs2 73 0
-keybcs2_general_ci keybcs2 37 Yes 0
-koi8r_bin koi8r 74 0
-koi8r_general_ci koi8r 7 Yes 0
-koi8u_bin koi8u 75 0
-koi8u_general_ci koi8u 22 Yes 0
-latin1_bin latin1 47 Yes 1
-latin1_danish_ci latin1 15 Yes 1
-latin1_general_ci latin1 48 Yes 1
-latin1_general_cs latin1 49 Yes 1
-latin1_german1_ci latin1 5 Yes 1
-latin1_german2_ci latin1 31 Yes 2
-latin1_spanish_ci latin1 94 Yes 1
-latin1_swedish_ci latin1 8 Yes Yes 1
-latin2_bin latin2 77 Yes 1
-latin2_croatian_ci latin2 27 Yes 1
-latin2_czech_cs latin2 2 Yes 4
-latin2_general_ci latin2 9 Yes Yes 1
-latin2_hungarian_ci latin2 21 Yes 1
-latin5_bin latin5 78 0
-latin5_turkish_ci latin5 30 Yes 0
-latin7_bin latin7 79 0
-latin7_estonian_cs latin7 20 0
-latin7_general_ci latin7 41 Yes 0
-latin7_general_cs latin7 42 0
-macce_bin macce 43 0
-macce_general_ci macce 38 Yes 0
-macroman_bin macroman 53 0
-macroman_general_ci macroman 39 Yes 0
-sjis_bin sjis 88 Yes 1
-sjis_japanese_ci sjis 13 Yes Yes 1
-swe7_bin swe7 82 0
-swe7_swedish_ci swe7 10 Yes 0
-tis620_bin tis620 89 Yes 1
-tis620_thai_ci tis620 18 Yes Yes 4
-ucs2_bin ucs2 90 Yes 1
-ucs2_czech_ci ucs2 138 Yes 8
-ucs2_danish_ci ucs2 139 Yes 8
-ucs2_esperanto_ci ucs2 145 Yes 8
-ucs2_estonian_ci ucs2 134 Yes 8
-ucs2_general_ci ucs2 35 Yes Yes 1
-ucs2_hungarian_ci ucs2 146 Yes 8
-ucs2_icelandic_ci ucs2 129 Yes 8
-ucs2_latvian_ci ucs2 130 Yes 8
-ucs2_lithuanian_ci ucs2 140 Yes 8
-ucs2_persian_ci ucs2 144 Yes 8
-ucs2_polish_ci ucs2 133 Yes 8
-ucs2_romanian_ci ucs2 131 Yes 8
-ucs2_roman_ci ucs2 143 Yes 8
-ucs2_slovak_ci ucs2 141 Yes 8
-ucs2_slovenian_ci ucs2 132 Yes 8
-ucs2_spanish2_ci ucs2 142 Yes 8
-ucs2_spanish_ci ucs2 135 Yes 8
-ucs2_swedish_ci ucs2 136 Yes 8
-ucs2_turkish_ci ucs2 137 Yes 8
-ucs2_unicode_ci ucs2 128 Yes 8
-ujis_bin ujis 91 Yes 1
-ujis_japanese_ci ujis 12 Yes Yes 1
-utf8_bin utf8 83 Yes 1
-utf8_czech_ci utf8 202 Yes 8
-utf8_danish_ci utf8 203 Yes 8
-utf8_esperanto_ci utf8 209 Yes 8
-utf8_estonian_ci utf8 198 Yes 8
-utf8_general_ci utf8 33 Yes Yes 1
-utf8_hungarian_ci utf8 210 Yes 8
-utf8_icelandic_ci utf8 193 Yes 8
-utf8_latvian_ci utf8 194 Yes 8
-utf8_lithuanian_ci utf8 204 Yes 8
-utf8_persian_ci utf8 208 Yes 8
-utf8_polish_ci utf8 197 Yes 8
-utf8_romanian_ci utf8 195 Yes 8
-utf8_roman_ci utf8 207 Yes 8
-utf8_slovak_ci utf8 205 Yes 8
-utf8_slovenian_ci utf8 196 Yes 8
-utf8_spanish2_ci utf8 206 Yes 8
-utf8_spanish_ci utf8 199 Yes 8
-utf8_swedish_ci utf8 200 Yes 8
-utf8_turkish_ci utf8 201 Yes 8
-utf8_unicode_ci utf8 192 Yes 8
-
-
-SELECT *
-FROM information_schema.collation_character_set_applicability
-ORDER BY collation_name, character_set_name;
-COLLATION_NAME CHARACTER_SET_NAME
-armscii8_bin armscii8
-armscii8_general_ci armscii8
-ascii_bin ascii
-ascii_general_ci ascii
-big5_bin big5
-big5_chinese_ci big5
-binary binary
-cp1250_bin cp1250
-cp1250_croatian_ci cp1250
-cp1250_czech_cs cp1250
-cp1250_general_ci cp1250
-cp1250_polish_ci cp1250
-cp1251_bin cp1251
-cp1251_bulgarian_ci cp1251
-cp1251_general_ci cp1251
-cp1251_general_cs cp1251
-cp1251_ukrainian_ci cp1251
-cp1256_bin cp1256
-cp1256_general_ci cp1256
-cp1257_bin cp1257
-cp1257_general_ci cp1257
-cp1257_lithuanian_ci cp1257
-cp850_bin cp850
-cp850_general_ci cp850
-cp852_bin cp852
-cp852_general_ci cp852
-cp866_bin cp866
-cp866_general_ci cp866
-cp932_bin cp932
-cp932_japanese_ci cp932
-dec8_bin dec8
-dec8_swedish_ci dec8
-eucjpms_bin eucjpms
-eucjpms_japanese_ci eucjpms
-euckr_bin euckr
-euckr_korean_ci euckr
-filename filename
-gb2312_bin gb2312
-gb2312_chinese_ci gb2312
-gbk_bin gbk
-gbk_chinese_ci gbk
-geostd8_bin geostd8
-geostd8_general_ci geostd8
-greek_bin greek
-greek_general_ci greek
-hebrew_bin hebrew
-hebrew_general_ci hebrew
-hp8_bin hp8
-hp8_english_ci hp8
-keybcs2_bin keybcs2
-keybcs2_general_ci keybcs2
-koi8r_bin koi8r
-koi8r_general_ci koi8r
-koi8u_bin koi8u
-koi8u_general_ci koi8u
-latin1_bin latin1
-latin1_danish_ci latin1
-latin1_general_ci latin1
-latin1_general_cs latin1
-latin1_german1_ci latin1
-latin1_german2_ci latin1
-latin1_spanish_ci latin1
-latin1_swedish_ci latin1
-latin2_bin latin2
-latin2_croatian_ci latin2
-latin2_czech_cs latin2
-latin2_general_ci latin2
-latin2_hungarian_ci latin2
-latin5_bin latin5
-latin5_turkish_ci latin5
-latin7_bin latin7
-latin7_estonian_cs latin7
-latin7_general_ci latin7
-latin7_general_cs latin7
-macce_bin macce
-macce_general_ci macce
-macroman_bin macroman
-macroman_general_ci macroman
-sjis_bin sjis
-sjis_japanese_ci sjis
-swe7_bin swe7
-swe7_swedish_ci swe7
-tis620_bin tis620
-tis620_thai_ci tis620
-ucs2_bin ucs2
-ucs2_czech_ci ucs2
-ucs2_danish_ci ucs2
-ucs2_esperanto_ci ucs2
-ucs2_estonian_ci ucs2
-ucs2_general_ci ucs2
-ucs2_hungarian_ci ucs2
-ucs2_icelandic_ci ucs2
-ucs2_latvian_ci ucs2
-ucs2_lithuanian_ci ucs2
-ucs2_persian_ci ucs2
-ucs2_polish_ci ucs2
-ucs2_romanian_ci ucs2
-ucs2_roman_ci ucs2
-ucs2_slovak_ci ucs2
-ucs2_slovenian_ci ucs2
-ucs2_spanish2_ci ucs2
-ucs2_spanish_ci ucs2
-ucs2_swedish_ci ucs2
-ucs2_turkish_ci ucs2
-ucs2_unicode_ci ucs2
-ujis_bin ujis
-ujis_japanese_ci ujis
-utf8_bin utf8
-utf8_czech_ci utf8
-utf8_danish_ci utf8
-utf8_esperanto_ci utf8
-utf8_estonian_ci utf8
-utf8_general_ci utf8
-utf8_hungarian_ci utf8
-utf8_icelandic_ci utf8
-utf8_latvian_ci utf8
-utf8_lithuanian_ci utf8
-utf8_persian_ci utf8
-utf8_polish_ci utf8
-utf8_romanian_ci utf8
-utf8_roman_ci utf8
-utf8_slovak_ci utf8
-utf8_slovenian_ci utf8
-utf8_spanish2_ci utf8
-utf8_spanish_ci utf8
-utf8_swedish_ci utf8
-utf8_turkish_ci utf8
-utf8_unicode_ci utf8
-# Switch to connection default + disconnect con
-DROP USER dbdict_test@localhost;
diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result
index 7e21ddf1544..3efb361dc82 100644
--- a/mysql-test/suite/funcs_1/r/storedproc.result
+++ b/mysql-test/suite/funcs_1/r/storedproc.result
@@ -18241,8 +18241,6 @@ END//
CALL sp70_n(-1e+40);
f1
-10000000000000000000000000000000000000000
-Warnings:
-Note 1265 Data truncated for column 'f1' at row 1
CALL sp70_n( -10000000000000000000000000000000000000000 );
f1
-10000000000000000000000000000000000000000
@@ -18255,8 +18253,6 @@ END//
CALL sp71_nu(1.00e+40);
f1
10000000000000000000000000000000000000000
-Warnings:
-Note 1265 Data truncated for column 'f1' at row 1
CALL sp71_nu( 10000000000000000000000000000000000000000 );
f1
10000000000000000000000000000000000000000
@@ -18269,8 +18265,6 @@ END//
CALL sp72_nuz(1.00e+40);
f1
0000000000000000000000010000000000000000000000000000000000000000
-Warnings:
-Note 1265 Data truncated for column 'f1' at row 1
CALL sp72_nuz( 10000000000000000000000000000000000000000 );
f1
0000000000000000000000010000000000000000000000000000000000000000
@@ -18283,8 +18277,6 @@ END//
CALL sp73_n_z(1.00e+40);
f1
0000000000000000000000010000000000000000000000000000000000000000
-Warnings:
-Note 1265 Data truncated for column 'f1' at row 1
CALL sp73_n_z( 10000000000000000000000000000000000000000 );
f1
0000000000000000000000010000000000000000000000000000000000000000
diff --git a/mysql-test/suite/funcs_1/datadict/charset_collation.inc b/mysql-test/suite/funcs_1/t/charset_collation.test
index ae03996b073..186eb1f5b85 100644
--- a/mysql-test/suite/funcs_1/datadict/charset_collation.inc
+++ b/mysql-test/suite/funcs_1/t/charset_collation.test
@@ -1,58 +1,16 @@
-# suite/funcs_1/datadict/charset_collation.inc
+# suite/funcs_1/t/charset_collation.test
#
# Tests checking the content of the information_schema tables
# character_sets
# collations
# collation_character_set_applicability
#
-#
-# The amount and properties of character_sets/collations depend on the
-# build type
-# 2007-12 MySQL 5.0, 2008-06 MySQL 5.1
-# ---------------------------------------------------------------------
-#
-# Variant 1 fits to
-# version_comment MySQL Enterprise Server (Commercial)
-# version_comment MySQL Enterprise Server (GPL)
-# version_comment MySQL Classic Server (Commercial)
-# version_comment MySQL Pushbuild Edition, build <number>
-# (version_comment Source distribution
-# and
-# compile was without "max" - > no collation 'utf8_general_ci')
-#
-# Variant 2 fits to
-# version_comment MySQL Enterprise Server (GPL)
-# version_comment MySQL Classic Server (Commercial)
-# version_comment MySQL Pushbuild Edition, build <number>
-# (version_comment Source distribution
-# and
-# compile was without "max" - > collation 'utf8_general_ci' exists)
-#
-# Difference between variant 1 and 2 is the collation 'utf8_general_ci'.
-#
-# Variant 3 fits to
-# version_comment MySQL Community Server (GPL)
-# version_comment MySQL Cluster Server (Commercial)
-# version_comment MySQL Advanced Server (GPL) 5.1
-# version_comment MySQL Advanced Server (Commercial) 5.1
-#
-# Difference between variant 3 and 2 is within the collation properties
-# IS_COMPILED and SORTLEN.
-#
-# 2008-06 All time excluded variant is "vanilla".
-# How to build "vanilla":
-# ./BUILD/autorun.sh
-# ./configure
-# ./make
-# Some properties of "vanilla"
-# version_comment Source distribution
-# Compared to the variants 1 to 3 a lot of character sets are missing.
-# Example: "ucs2_bin" is in variant 1 to 3 but not in "vanilla".
-#
# Created:
-# 2007-12-18 mleich - remove the unstable character_set/collation subtests
-# from include/datadict-master.inc
-# - create this new test
+# 2009-04-28 mleich Replace the charset_collation_* test which failed too often
+# because of changes
+# - in general available character sets and collations
+# - in build types
+# (Bug#40545, Bug#40209, Bug#40618, Bug#38346)
#
# Create a low privileged user.
@@ -61,7 +19,6 @@ DROP USER dbdict_test@localhost;
CREATE USER dbdict_test@localhost;
--echo # Establish connection con (user=dbdict_test)
---replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
connect (con,localhost,dbdict_test,,);
################################################################################
#
@@ -97,32 +54,48 @@ connect (con,localhost,dbdict_test,,);
# combinations for which the current user and PUBLIC have no
# USAGE privilege.
#
-# Notes (2007-12-19 mleich):
+# Notes (2009-04-28 mleich):
# - The requirements are outdated because grant/revoke privilege for using a
# characterset/collation were never implemented.
-# Therefore the tests should simply check the content of these tables.
-#
+# Therefore the tests focus on the completeness and correctness of the
+# content (rows and columns) of these tables.
# - The amount of collations/character sets grows with new MySQL releases.
-#
-# - Even within the same release the amount of records within these tables
+# Even within the same release the amount of records within these tables
# can differ between different build types (community, enterprise, source,...)
-#
+# Therefore we limit the queries to character sets and collations which
+# - exist in all build types
+# - have in all build types the same "state".
+# The character set
+# - utf8 is used for Metadata
+# - ascii is a quite usual
+# The collations <character set>_general_ci and <character set>_bin seem
+# to be available all time.
#
################################################################################
+
+let $char_set_condition= character_set_name IN ('utf8','latin1','binary');
+let $collation_condition=
+ (collation_name LIKE CONCAT(character_set_name,'_general_ci')
+ OR
+ collation_name LIKE CONCAT(character_set_name,'_bin'));
--echo
-SELECT *
+eval SELECT *
FROM information_schema.character_sets
+WHERE $char_set_condition
ORDER BY character_set_name;
--echo
-SELECT *
+eval SELECT *
FROM information_schema.collations
+WHERE $char_set_condition
+ AND $collation_condition
ORDER BY collation_name;
-echo;
--echo
-SELECT *
+eval SELECT *
FROM information_schema.collation_character_set_applicability
+WHERE $char_set_condition
+ AND $collation_condition
ORDER BY collation_name, character_set_name;
diff --git a/mysql-test/suite/funcs_1/t/charset_collation_1.test b/mysql-test/suite/funcs_1/t/charset_collation_1.test
deleted file mode 100644
index 15777062a72..00000000000
--- a/mysql-test/suite/funcs_1/t/charset_collation_1.test
+++ /dev/null
@@ -1,32 +0,0 @@
-# Tests checking the content of the information_schema tables
-# character_sets
-# collations
-# collation_character_set_applicability
-#
-# Content variant 1 which should fit to
-# Enterprise or Classic builds (binaries provided by MySQL)
-# Pushbuilds
-# Source builds without "max"
-#
-# Please read suite/funcs_1/datadict/charset_collation.inc for
-# additional information.
-#
-# Created:
-# 2007-12-18 mleich - remove the unstable character_set/collation subtests
-# from include/datadict-master.inc
-# - create this new test
-#
-
-if (`SELECT EXISTS (SELECT 1 FROM information_schema.collations
- WHERE collation_name = 'utf8_general_cs')
- OR ( @@version_comment NOT LIKE '%Source%'
- AND @@version_comment NOT LIKE '%Enterprise%'
- AND @@version_comment NOT LIKE '%Classic%'
- AND @@version_comment NOT LIKE '%Pushbuild%')
- OR (SELECT count(*) = 0 FROM information_schema.collations
- WHERE collation_name = 'ucs2_bin')`)
-{
- skip Test needs Enterprise, Classic , regular Pushbuild or Source-without-max build;
-}
-
---source suite/funcs_1/datadict/charset_collation.inc
diff --git a/mysql-test/suite/funcs_1/t/charset_collation_2.test b/mysql-test/suite/funcs_1/t/charset_collation_2.test
deleted file mode 100644
index d4924953b7d..00000000000
--- a/mysql-test/suite/funcs_1/t/charset_collation_2.test
+++ /dev/null
@@ -1,24 +0,0 @@
-# Tests checking the content of the information_schema tables
-# character_sets
-# collations
-# collation_character_set_applicability
-#
-# Content variant 2 (compile from source with "max")
-#
-# Please read suite/funcs_1/datadict/charset_collation.inc for
-# additional information.
-#
-# Created:
-# 2007-12-18 mleich - remove the unstable character_set/collation subtests
-# from include/datadict-master.inc
-# - create this new test
-#
-
-if (`SELECT @@version_comment NOT LIKE '%Source%'
- OR NOT EXISTS (SELECT 1 FROM information_schema.collations
- WHERE collation_name = 'utf8_general_cs')`)
-{
- skip Test needs Source build with "max";
-}
-
---source suite/funcs_1/datadict/charset_collation.inc
diff --git a/mysql-test/suite/funcs_1/t/charset_collation_3.test b/mysql-test/suite/funcs_1/t/charset_collation_3.test
deleted file mode 100644
index e88b44e4a0f..00000000000
--- a/mysql-test/suite/funcs_1/t/charset_collation_3.test
+++ /dev/null
@@ -1,25 +0,0 @@
-# Tests checking the content of the information_schema tables
-# character_sets
-# collations
-# collation_character_set_applicability
-#
-# Content variant 3 which should fit to
-# Community and Cluster builds (binaries provided by MySQL)
-#
-# Please read suite/funcs_1/datadict/charset_collation.inc for
-# additional information.
-#
-# Created:
-# 2007-12-18 mleich - remove the unstable character_set/collation subtests
-# from include/datadict-master.inc
-# - create this new test
-#
-
-if (`SELECT @@version_comment NOT LIKE '%Community%'
- AND @@version_comment NOT LIKE '%Cluster%'
- AND @@version_comment NOT LIKE '%Advanced%'`)
-{
- skip Test needs Community, Cluster or Advanced build;
-}
-
---source suite/funcs_1/datadict/charset_collation.inc
diff --git a/mysql-test/suite/funcs_1/t/disabled.def b/mysql-test/suite/funcs_1/t/disabled.def
index 69a69c60708..3f260ca49ba 100644
--- a/mysql-test/suite/funcs_1/t/disabled.def
+++ b/mysql-test/suite/funcs_1/t/disabled.def
@@ -11,6 +11,3 @@
##############################################################################
ndb_trig_1011ext: Bug#32656 NDB: Duplicate key error aborts transaction in handler. Doesn't talk back to SQL
-charset_collation_1: Bug#38346, Bug#40209, Bug#40545, Bug#40618
-charset_collation_2: Bug#38346, Bug#40209, Bug#40545, Bug#40618
-charset_collation_3: Bug#38346, Bug#40209, Bug#40545, Bug#40618
diff --git a/mysql-test/suite/funcs_1/t/storedproc.test b/mysql-test/suite/funcs_1/t/storedproc.test
index dc1177ac8bb..16c4d61bf58 100644
--- a/mysql-test/suite/funcs_1/t/storedproc.test
+++ b/mysql-test/suite/funcs_1/t/storedproc.test
@@ -10,6 +10,17 @@
#
############################################################################
+# Bug#37746 - Arithmetic range ("int") is smaller than expected
+# This code is in place to ensure this test is only skipped
+# for the Win64 platform
+if(`SELECT CONVERT(@@version_compile_os using latin1) IN ("Win64")`)
+{
+--skip Bug#37746 2009-07-07 pcrews Arithmetic range ("int") is smaller than expected
+}
+
+
+
+
# This test cannot be used for the embedded server because we check here
# privileges.
--source include/not_embedded.inc
@@ -22429,7 +22440,9 @@ BEGIN
END//
delimiter ;//
+--disable_warnings
CALL sp70_n(-1e+40);
+--enable_warnings
eval CALL sp70_n( $minus_40 );
@@ -22445,7 +22458,9 @@ BEGIN
END//
delimiter ;//
+--disable_warnings
CALL sp71_nu(1.00e+40);
+--enable_warnings
eval CALL sp71_nu( $plus_40 );
@@ -22461,7 +22476,9 @@ BEGIN
END//
delimiter ;//
+--disable_warnings
CALL sp72_nuz(1.00e+40);
+--enable_warnings
eval CALL sp72_nuz( $plus_40 );
@@ -22477,7 +22494,9 @@ BEGIN
END//
delimiter ;//
+--disable_warnings
CALL sp73_n_z(1.00e+40);
+--enable_warnings
eval CALL sp73_n_z( $plus_40 );
diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result
new file mode 100644
index 00000000000..916e1d93ee5
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45196.result
@@ -0,0 +1,33 @@
+drop table if exists t1;
+create table t1 (c char(10), index(c)) collate ucs2_czech_ci engine=ibmdb2i;
+insert into t1 values ("ch"),("h"),("i");
+select * from t1 order by c;
+c
+h
+ch
+i
+drop table t1;
+create table t1 (c char(10), index(c)) collate utf8_czech_ci engine=ibmdb2i;
+insert into t1 values ("ch"),("h"),("i");
+select * from t1 order by c;
+c
+h
+ch
+i
+drop table t1;
+create table t1 (c char(10), index(c)) collate ucs2_danish_ci engine=ibmdb2i;
+insert into t1 values("abc"),("abcd"),("aaaa");
+select c from t1 order by c;
+c
+abc
+abcd
+aaaa
+drop table t1;
+create table t1 (c char(10), index(c)) collate utf8_danish_ci engine=ibmdb2i;
+insert into t1 values("abc"),("abcd"),("aaaa");
+select c from t1 order by c;
+c
+abc
+abcd
+aaaa
+drop table t1;
diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result
new file mode 100644
index 00000000000..2392b746877
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_45793.result
@@ -0,0 +1,7 @@
+drop table if exists t1;
+create table t1 (c char(10), index(c)) charset macce engine=ibmdb2i;
+insert into t1 values ("test");
+select * from t1 order by c;
+c
+test
+drop table t1;
diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result
new file mode 100644
index 00000000000..4f7d71cab2d
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_collations.result
@@ -0,0 +1,1204 @@
+drop table if exists t1, ffd, fd;
+CREATE TABLE t1 (armscii8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate armscii8_bin engine=ibmdb2i;
+CREATE TABLE t1 (armscii8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate armscii8_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (ascii_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ascii_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (ascii_bin char(10) primary key) collate ascii_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ascii_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ascii_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (ascii_general_ci char(10) primary key) collate ascii_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (big5_bin integer, c char(10), v varchar(20), index(c), index(v)) collate big5_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (big5_bin char(10) primary key) collate big5_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (big5_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate big5_chinese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (big5_chinese_ci char(10) primary key) collate big5_chinese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1250_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1250_bin char(10) primary key) collate cp1250_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1250_croatian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_croatian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1250_croatian_ci char(10) primary key) collate cp1250_croatian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1250_czech_cs integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_czech_cs engine=ibmdb2i;
+CREATE TABLE t1 (cp1250_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1250_general_ci char(10) primary key) collate cp1250_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1250_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1250_polish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1250_polish_ci char(10) primary key) collate cp1250_polish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1251_bin char(10) primary key) collate cp1251_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_bulgarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_bulgarian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1251_bulgarian_ci char(10) primary key) collate cp1251_bulgarian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1251_general_ci char(10) primary key) collate cp1251_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_general_cs engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1251_general_cs char(10) primary key) collate cp1251_general_cs engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1251_ukrainian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1251_ukrainian_ci engine=ibmdb2i;
+CREATE TABLE t1 (cp1256_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1256_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1256_bin char(10) primary key) collate cp1256_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1256_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1256_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp1256_general_ci char(10) primary key) collate cp1256_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp1257_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_bin engine=ibmdb2i;
+CREATE TABLE t1 (cp1257_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (cp1257_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp1257_lithuanian_ci engine=ibmdb2i;
+CREATE TABLE t1 (cp850_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp850_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp850_bin char(10) primary key) collate cp850_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp850_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp850_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp850_general_ci char(10) primary key) collate cp850_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp852_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp852_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp852_bin char(10) primary key) collate cp852_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp852_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp852_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (cp852_general_ci char(10) primary key) collate cp852_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp866_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp866_bin engine=ibmdb2i;
+CREATE TABLE t1 (cp866_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp866_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (cp932_bin integer, c char(10), v varchar(20), index(c), index(v)) collate cp932_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (cp932_bin char(10) primary key) collate cp932_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (cp932_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate cp932_japanese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (cp932_japanese_ci char(10) primary key) collate cp932_japanese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (dec8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate dec8_bin engine=ibmdb2i;
+CREATE TABLE t1 (dec8_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate dec8_swedish_ci engine=ibmdb2i;
+CREATE TABLE t1 (eucjpms_bin integer, c char(10), v varchar(20), index(c), index(v)) collate eucjpms_bin engine=ibmdb2i;
+CREATE TABLE t1 (eucjpms_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate eucjpms_japanese_ci engine=ibmdb2i;
+CREATE TABLE t1 (euckr_bin integer, c char(10), v varchar(20), index(c), index(v)) collate euckr_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (euckr_bin char(10) primary key) collate euckr_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (euckr_korean_ci integer, c char(10), v varchar(20), index(c), index(v)) collate euckr_korean_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (euckr_korean_ci char(10) primary key) collate euckr_korean_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (gb2312_bin integer, c char(10), v varchar(20), index(c), index(v)) collate gb2312_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (gb2312_bin char(10) primary key) collate gb2312_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (gb2312_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate gb2312_chinese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (gb2312_chinese_ci char(10) primary key) collate gb2312_chinese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (gbk_bin integer, c char(10), v varchar(20), index(c), index(v)) collate gbk_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (gbk_bin char(10) primary key) collate gbk_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (gbk_chinese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate gbk_chinese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (gbk_chinese_ci char(10) primary key) collate gbk_chinese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (geostd8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate geostd8_bin engine=ibmdb2i;
+CREATE TABLE t1 (geostd8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate geostd8_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (greek_bin integer, c char(10), v varchar(20), index(c), index(v)) collate greek_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (greek_bin char(10) primary key) collate greek_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (greek_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate greek_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (greek_general_ci char(10) primary key) collate greek_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (hebrew_bin integer, c char(10), v varchar(20), index(c), index(v)) collate hebrew_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (hebrew_bin char(10) primary key) collate hebrew_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (hebrew_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate hebrew_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (hebrew_general_ci char(10) primary key) collate hebrew_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (hp8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate hp8_bin engine=ibmdb2i;
+CREATE TABLE t1 (hp8_english_ci integer, c char(10), v varchar(20), index(c), index(v)) collate hp8_english_ci engine=ibmdb2i;
+CREATE TABLE t1 (keybcs2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate keybcs2_bin engine=ibmdb2i;
+CREATE TABLE t1 (keybcs2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate keybcs2_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (koi8r_bin integer, c char(10), v varchar(20), index(c), index(v)) collate koi8r_bin engine=ibmdb2i;
+CREATE TABLE t1 (koi8r_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate koi8r_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (koi8u_bin integer, c char(10), v varchar(20), index(c), index(v)) collate koi8u_bin engine=ibmdb2i;
+CREATE TABLE t1 (koi8u_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate koi8u_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (latin1_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin1_bin char(10) primary key) collate latin1_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_danish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin1_danish_ci char(10) primary key) collate latin1_danish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin1_general_ci char(10) primary key) collate latin1_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_general_cs engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin1_general_cs char(10) primary key) collate latin1_general_cs engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_german1_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_german1_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin1_german1_ci char(10) primary key) collate latin1_german1_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_german2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_german2_ci engine=ibmdb2i;
+CREATE TABLE t1 (latin1_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_spanish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin1_spanish_ci char(10) primary key) collate latin1_spanish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin1_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin1_swedish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin1_swedish_ci char(10) primary key) collate latin1_swedish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin2_bin char(10) primary key) collate latin2_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin2_croatian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_croatian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin2_croatian_ci char(10) primary key) collate latin2_croatian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin2_czech_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_czech_cs engine=ibmdb2i;
+CREATE TABLE t1 (latin2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin2_general_ci char(10) primary key) collate latin2_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin2_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin2_hungarian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin2_hungarian_ci char(10) primary key) collate latin2_hungarian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin5_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin5_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin5_bin char(10) primary key) collate latin5_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin5_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin5_turkish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (latin5_turkish_ci char(10) primary key) collate latin5_turkish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (latin7_bin integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_bin engine=ibmdb2i;
+CREATE TABLE t1 (latin7_estonian_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_estonian_cs engine=ibmdb2i;
+CREATE TABLE t1 (latin7_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (latin7_general_cs integer, c char(10), v varchar(20), index(c), index(v)) collate latin7_general_cs engine=ibmdb2i;
+CREATE TABLE t1 (macce_bin integer, c char(10), v varchar(20), index(c), index(v)) collate macce_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (macce_bin char(10) primary key) collate macce_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (macce_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate macce_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (macce_general_ci char(10) primary key) collate macce_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (macroman_bin integer, c char(10), v varchar(20), index(c), index(v)) collate macroman_bin engine=ibmdb2i;
+CREATE TABLE t1 (macroman_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate macroman_general_ci engine=ibmdb2i;
+CREATE TABLE t1 (sjis_bin integer, c char(10), v varchar(20), index(c), index(v)) collate sjis_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (sjis_bin char(10) primary key) collate sjis_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (sjis_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate sjis_japanese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (sjis_japanese_ci char(10) primary key) collate sjis_japanese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (swe7_bin integer, c char(10), v varchar(20), index(c), index(v)) collate swe7_bin engine=ibmdb2i;
+CREATE TABLE t1 (swe7_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate swe7_swedish_ci engine=ibmdb2i;
+CREATE TABLE t1 (tis620_bin integer, c char(10), v varchar(20), index(c), index(v)) collate tis620_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (tis620_bin char(10) primary key) collate tis620_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (tis620_thai_ci integer, c char(10), v varchar(20), index(c), index(v)) collate tis620_thai_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 11 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 23 NULL 6 Using where
+drop table t1;
+create table t1 (tis620_thai_ci char(10) primary key) collate tis620_thai_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_bin char(10) primary key) collate ucs2_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_czech_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_czech_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_czech_ci char(10) primary key) collate ucs2_czech_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_danish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_danish_ci char(10) primary key) collate ucs2_danish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_esperanto_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_esperanto_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_esperanto_ci char(10) primary key) collate ucs2_esperanto_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_estonian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_estonian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_estonian_ci char(10) primary key) collate ucs2_estonian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_general_ci char(10) primary key) collate ucs2_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_hungarian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_hungarian_ci char(10) primary key) collate ucs2_hungarian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_icelandic_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_icelandic_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_icelandic_ci char(10) primary key) collate ucs2_icelandic_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_latvian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_latvian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_latvian_ci char(10) primary key) collate ucs2_latvian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_lithuanian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_lithuanian_ci char(10) primary key) collate ucs2_lithuanian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_persian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_persian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_persian_ci char(10) primary key) collate ucs2_persian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_polish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_polish_ci char(10) primary key) collate ucs2_polish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_romanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_romanian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_romanian_ci char(10) primary key) collate ucs2_romanian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_roman_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_roman_ci engine=ibmdb2i;
+CREATE TABLE t1 (ucs2_slovak_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_slovak_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_slovak_ci char(10) primary key) collate ucs2_slovak_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_slovenian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_slovenian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_slovenian_ci char(10) primary key) collate ucs2_slovenian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_spanish2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_spanish2_ci engine=ibmdb2i;
+CREATE TABLE t1 (ucs2_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_spanish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_spanish_ci char(10) primary key) collate ucs2_spanish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_swedish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_swedish_ci char(10) primary key) collate ucs2_swedish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_turkish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_turkish_ci char(10) primary key) collate ucs2_turkish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ucs2_unicode_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ucs2_unicode_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 21 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 43 NULL 6 Using where
+drop table t1;
+create table t1 (ucs2_unicode_ci char(10) primary key) collate ucs2_unicode_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ujis_bin integer, c char(10), v varchar(20), index(c), index(v)) collate ujis_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (ujis_bin char(10) primary key) collate ujis_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (ujis_japanese_ci integer, c char(10), v varchar(20), index(c), index(v)) collate ujis_japanese_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (ujis_japanese_ci char(10) primary key) collate ujis_japanese_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_bin integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_bin engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_bin char(10) primary key) collate utf8_bin engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_czech_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_czech_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_czech_ci char(10) primary key) collate utf8_czech_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_danish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_danish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_danish_ci char(10) primary key) collate utf8_danish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_esperanto_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_esperanto_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_esperanto_ci char(10) primary key) collate utf8_esperanto_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_estonian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_estonian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_estonian_ci char(10) primary key) collate utf8_estonian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_general_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_general_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_general_ci char(10) primary key) collate utf8_general_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_hungarian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_hungarian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_hungarian_ci char(10) primary key) collate utf8_hungarian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_icelandic_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_icelandic_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_icelandic_ci char(10) primary key) collate utf8_icelandic_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_latvian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_latvian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_latvian_ci char(10) primary key) collate utf8_latvian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_lithuanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_lithuanian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_lithuanian_ci char(10) primary key) collate utf8_lithuanian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_persian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_persian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_persian_ci char(10) primary key) collate utf8_persian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_polish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_polish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_polish_ci char(10) primary key) collate utf8_polish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_romanian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_romanian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_romanian_ci char(10) primary key) collate utf8_romanian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_roman_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_roman_ci engine=ibmdb2i;
+CREATE TABLE t1 (utf8_slovak_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_slovak_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_slovak_ci char(10) primary key) collate utf8_slovak_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_slovenian_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_slovenian_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_slovenian_ci char(10) primary key) collate utf8_slovenian_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_spanish2_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_spanish2_ci engine=ibmdb2i;
+CREATE TABLE t1 (utf8_spanish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_spanish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_spanish_ci char(10) primary key) collate utf8_spanish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_swedish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_swedish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_swedish_ci char(10) primary key) collate utf8_swedish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_turkish_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_turkish_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_turkish_ci char(10) primary key) collate utf8_turkish_ci engine=ibmdb2i;
+drop table t1;
+CREATE TABLE t1 (utf8_unicode_ci integer, c char(10), v varchar(20), index(c), index(v)) collate utf8_unicode_ci engine=ibmdb2i;
+insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+insert into t1 select * from t1;
+explain select c,v from t1 force index(c) where c like "ab%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 31 NULL 6 Using where
+explain select c,v from t1 force index(v) where v like "de%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range v v 63 NULL 6 Using where
+drop table t1;
+create table t1 (utf8_unicode_ci char(10) primary key) collate utf8_unicode_ci engine=ibmdb2i;
+drop table t1;
+create table ffd (WHCHD1 CHAR(20), WHCSID decimal(5,0)) engine=ibmdb2i;
+create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i;
+create temporary table intermed (row integer key auto_increment, cs char(30), ccsid integer);
+insert into intermed (cs, ccsid) select * from ffd;
+create temporary table intermed2 (row integer key auto_increment, srtseq char(10));
+insert into intermed2 (srtseq) select * from fd;
+select ccsid, cs, srtseq from intermed inner join intermed2 on intermed.row = intermed2.row;
+ccsid cs srtseq
+500 "ascii_bin" QBLA101F4U
+500 "ascii_general_ci" QALA101F4S
+1200 "big5_bin" QBCHT04B0U
+1200 "big5_chinese_ci" QACHT04B0S
+1153 "cp1250_bin" QELA20481U
+1153 "cp1250_croatian_ci" QALA20481S
+1153 "cp1250_general_ci" QCLA20481S
+1153 "cp1250_polish_ci" QDLA20481S
+1025 "cp1251_bin" QCCYR0401U
+1025 "cp1251_bulgarian_ci QACYR0401S
+1025 "cp1251_general_ci" QBCYR0401S
+1025 "cp1251_general_cs" QBCYR0401U
+420 "cp1256_bin" QBARA01A4U
+420 "cp1256_general_ci" QAARA01A4S
+500 "cp850_bin" QDLA101F4U
+500 "cp850_general_ci" QCLA101F4S
+870 "cp852_bin" QBLA20366U
+870 "cp852_general_ci" QALA20366S
+1200 "cp932_bin" QBJPN04B0U
+1200 "cp932_japanese_ci" QAJPN04B0S
+1200 "euckr_bin" QBKOR04B0U
+1200 "euckr_korean_ci" QAKOR04B0S
+1200 "gb2312_bin" QBCHS04B0U
+1200 "gb2312_chinese_ci" QACHS04B0S
+1200 "gbk_bin" QDCHS04B0U
+1200 "gbk_chinese_ci" QCCHS04B0S
+875 "greek_bin" QBELL036BU
+875 "greek_general_ci" QAELL036BS
+424 "hebrew_bin" QBHEB01A8U
+424 "hebrew_general_ci" QAHEB01A8S
+1148 "latin1_bin" QFLA1047CU
+1148 "latin1_danish_ci" QALA1047CS
+1148 "latin1_general_ci" QBLA1047CS
+1148 "latin1_general_cs" QBLA1047CU
+1148 "latin1_german1_ci" QCLA1047CS
+1148 "latin1_spanish_ci" QDLA1047CS
+1148 "latin1_swedish_ci" QELA1047CS
+870 "latin2_bin" QGLA20366U
+870 "latin2_croatian_ci" QCLA20366S
+870 "latin2_general_ci" QELA20366S
+870 "latin2_hungarian_ci QFLA20366S
+1026 "latin5_bin" QBTRK0402U
+1026 "latin5_turkish_ci" QATRK0402S
+870 "macce_bin" QILA20366U
+870 "macce_general_ci" QHLA20366S
+1200 "sjis_bin" QDJPN04B0U
+1200 "sjis_japanese_ci" QCJPN04B0S
+838 "tis620_bin" QBTHA0346U
+838 "tis620_thai_ci" QATHA0346S
+13488 "ucs2_bin" *HEX
+13488 "ucs2_czech_ci" I34ACS_CZ
+13488 "ucs2_danish_ci" I34ADA_DK
+13488 "ucs2_esperanto_ci" I34AEO
+13488 "ucs2_estonian_ci" I34AET
+13488 "ucs2_general_ci" QAUCS04B0S
+13488 "ucs2_hungarian_ci" I34AHU
+13488 "ucs2_icelandic_ci" I34AIS
+13488 "ucs2_latvian_ci" I34ALV
+13488 "ucs2_lithuanian_ci" I34ALT
+13488 "ucs2_persian_ci" I34AFA
+13488 "ucs2_polish_ci" I34APL
+13488 "ucs2_romanian_ci" I34ARO
+13488 "ucs2_slovak_ci" I34ASK
+13488 "ucs2_slovenian_ci" I34ASL
+13488 "ucs2_spanish_ci" I34AES
+13488 "ucs2_swedish_ci" I34ASW
+13488 "ucs2_turkish_ci" I34ATR
+13488 "ucs2_unicode_ci" I34AEN
+1200 "ujis_bin" QFJPN04B0U
+1200 "ujis_japanese_ci" QEJPN04B0S
+1208 "utf8_bin" *HEX
+1208 "utf8_czech_ci" I34ACS_CZ
+1208 "utf8_danish_ci" I34ADA_DK
+1208 "utf8_esperanto_ci" I34AEO
+1208 "utf8_estonian_ci" I34AET
+1200 "utf8_general_ci" QAUCS04B0S
+1208 "utf8_hungarian_ci" I34AHU
+1208 "utf8_icelandic_ci" I34AIS
+1208 "utf8_latvian_ci" I34ALV
+1208 "utf8_lithuanian_ci" I34ALT
+1208 "utf8_persian_ci" I34AFA
+1208 "utf8_polish_ci" I34APL
+1208 "utf8_romanian_ci" I34ARO
+1208 "utf8_slovak_ci" I34ASK
+1208 "utf8_slovenian_ci" I34ASL
+1208 "utf8_spanish_ci" I34AES
+1208 "utf8_swedish_ci" I34ASW
+1208 "utf8_turkish_ci" I34ATR
+1208 "utf8_unicode_ci" I34AEN
+drop table ffd, fd;
diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test
new file mode 100644
index 00000000000..17b1d658975
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45196.test
@@ -0,0 +1,26 @@
+source suite/ibmdb2i/include/have_ibmdb2i.inc;
+source suite/ibmdb2i/include/have_i61.inc;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (c char(10), index(c)) collate ucs2_czech_ci engine=ibmdb2i;
+insert into t1 values ("ch"),("h"),("i");
+select * from t1 order by c;
+drop table t1;
+
+create table t1 (c char(10), index(c)) collate utf8_czech_ci engine=ibmdb2i;
+insert into t1 values ("ch"),("h"),("i");
+select * from t1 order by c;
+drop table t1;
+
+create table t1 (c char(10), index(c)) collate ucs2_danish_ci engine=ibmdb2i;
+insert into t1 values("abc"),("abcd"),("aaaa");
+select c from t1 order by c;
+drop table t1;
+
+create table t1 (c char(10), index(c)) collate utf8_danish_ci engine=ibmdb2i;
+insert into t1 values("abc"),("abcd"),("aaaa");
+select c from t1 order by c;
+drop table t1;
diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test
new file mode 100644
index 00000000000..93fb78ff421
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_45793.test
@@ -0,0 +1,11 @@
+source suite/ibmdb2i/include/have_ibmdb2i.inc;
+source suite/ibmdb2i/include/have_i61.inc;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (c char(10), index(c)) charset macce engine=ibmdb2i;
+insert into t1 values ("test");
+select * from t1 order by c;
+drop table t1;
diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test
new file mode 100644
index 00000000000..899f330d360
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_collations.test
@@ -0,0 +1,44 @@
+source suite/ibmdb2i/include/have_ibmdb2i.inc;
+source suite/ibmdb2i/include/have_i61.inc;
+--disable_warnings
+drop table if exists t1, ffd, fd;
+--enable_warnings
+
+--disable_abort_on_error
+--error 0,255
+exec system "DLTF QGPL/FFDOUT" > /dev/null;
+--error 0,255
+exec system "DLTF QGPL/FDOUT" > /dev/null;
+--enable_abort_on_error
+let $count= query_get_value(select count(*) from information_schema.COLLATIONS where COLLATION_NAME <> "binary", count(*),1);
+
+while ($count)
+{
+ let $collation = query_get_value(select COLLATION_NAME from information_schema.COLLATIONS where COLLATION_NAME <> "binary" order by COLLATION_NAME desc, COLLATION_NAME, $count);
+ error 0,1005,2504,2028;
+ eval CREATE TABLE t1 ($collation integer, c char(10), v varchar(20), index(c), index(v)) collate $collation engine=ibmdb2i;
+ if (!$mysql_errno)
+ {
+ insert into t1 (c,v) values ("abc","def"),("abcd", "def"),("abcde","defg"),("aaaa","bbbb");
+ insert into t1 select * from t1;
+ explain select c,v from t1 force index(c) where c like "ab%";
+ explain select c,v from t1 force index(v) where v like "de%";
+ drop table t1;
+ eval create table t1 ($collation char(10) primary key) collate $collation engine=ibmdb2i;
+ system system "DSPFFD FILE(\"test\"/\"t1\") OUTPUT(*OUTFILE) OUTFILE(QGPL/FFDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
+ system system "DSPFD FILE(\"test\"/\"t1\") TYPE(*SEQ) OUTPUT(*OUTFILE) OUTFILE(QGPL/FDOUT) OUTMBR(*FIRST *ADD)" > /dev/null;
+ drop table t1;
+ }
+ dec $count;
+}
+
+create table ffd (WHCHD1 CHAR(20), WHCSID decimal(5,0)) engine=ibmdb2i;
+system system "CPYF FROMFILE(QGPL/FFDOUT) TOFILE(\"test\"/\"ffd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null;
+create table fd (SQSSEQ CHAR(10)) engine=ibmdb2i;
+system system "CPYF FROMFILE(QGPL/FDOUT) TOFILE(\"test\"/\"fd\") mbropt(*replace) fmtopt(*drop *map)" > /dev/null;
+create temporary table intermed (row integer key auto_increment, cs char(30), ccsid integer);
+insert into intermed (cs, ccsid) select * from ffd;
+create temporary table intermed2 (row integer key auto_increment, srtseq char(10));
+insert into intermed2 (srtseq) select * from fd;
+select ccsid, cs, srtseq from intermed inner join intermed2 on intermed.row = intermed2.row;
+drop table ffd, fd;
diff --git a/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result b/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result
new file mode 100644
index 00000000000..0e3f83d0aa5
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_binlog_max_cache_size.result
@@ -0,0 +1,135 @@
+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;
+CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
+CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
+CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
+########################################################################################
+# 1 - SINGLE STATEMENT
+########################################################################################
+*** Single statement on transactional table ***
+Got one of the listed errors
+*** Single statement on non-transactional table ***
+*** After WL#2687 the difference between STATEMENT/MIXED and ROW will not exist. ***
+Got one of the listed errors
+*** Single statement on both transactional and non-transactional tables. ***
+*** After WL#2687 we will be able to change the order of the tables. ***
+Got one of the listed errors
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
+START SLAVE SQL_THREAD;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+source include/diff_master_slave.inc;
+########################################################################################
+# 3 - BEGIN - COMMIT
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+COMMIT;
+source include/diff_master_slave.inc;
+########################################################################################
+# 4 - BEGIN - ROLLBACK
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+ROLLBACK;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+source include/diff_master_slave.inc;
+########################################################################################
+# 5 - PROCEDURE
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+CREATE PROCEDURE p1(pd VARCHAR(30000))
+BEGIN
+INSERT INTO t1 (a, data) VALUES (1, pd);
+INSERT INTO t1 (a, data) VALUES (2, pd);
+INSERT INTO t1 (a, data) VALUES (3, pd);
+INSERT INTO t1 (a, data) VALUES (4, pd);
+INSERT INTO t1 (a, data) VALUES (5, 's');
+END//
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t1;
+BEGIN;
+Got one of the listed errors
+COMMIT;
+TRUNCATE TABLE t1;
+BEGIN;
+Got one of the listed errors
+ROLLBACK;
+source include/diff_master_slave.inc;
+########################################################################################
+# 6 - XID
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+ROLLBACK TO sv;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+COMMIT;
+source include/diff_master_slave.inc;
+########################################################################################
+# 7 - NON-TRANS TABLE
+########################################################################################
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+BEGIN;
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+Got one of the listed errors
+COMMIT;
+BEGIN;
+Got one of the listed errors
+COMMIT;
+########################################################################################
+# CLEAN
+########################################################################################
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP TABLE IF EXISTS t6;
+DROP PROCEDURE p1;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP TABLE IF EXISTS t6;
+DROP PROCEDURE p1;
diff --git a/mysql-test/suite/rpl/r/rpl_concurrency_error.result b/mysql-test/suite/rpl/r/rpl_concurrency_error.result
new file mode 100644
index 00000000000..ba617667d5a
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_concurrency_error.result
@@ -0,0 +1,119 @@
+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;
+########################################################################
+# Environment
+########################################################################
+CREATE TABLE t (i INT, PRIMARY KEY(i), f CHAR(8)) engine = Innodb;
+CREATE TABLE n (d DATETIME, f CHAR(32)) engine = MyIsam;
+CREATE TRIGGER tr AFTER UPDATE ON t FOR EACH ROW
+BEGIN
+INSERT INTO n VALUES ( now(), concat( 'updated t: ', old.f, ' -> ', new.f ) );
+END |
+INSERT INTO t VALUES (4,'black'), (2,'red'), (3,'yelow'), (1,'cyan');
+########################################################################
+# Testing ER_LOCK_WAIT_TIMEOUT
+########################################################################
+SET AUTOCOMMIT = 1;
+BEGIN;
+UPDATE t SET f = 'yellow 2' WHERE i = 3;
+SET AUTOCOMMIT = 1;
+BEGIN;
+UPDATE t SET f = 'magenta 2' WHERE f = 'red';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (5 + (2 * 10),"brown");
+INSERT INTO n VALUES (now(),"brown");
+COMMIT;
+ROLLBACK;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'magenta 2' WHERE f = 'red'
+master-bin.000001 # Query # # ROLLBACK
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'yellow 2' WHERE i = 3
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (5 + (2 * 10),"brown")
+master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown")
+master-bin.000001 # Query # # ROLLBACK
+SET AUTOCOMMIT = 1;
+BEGIN;
+UPDATE t SET f = 'gray 2' WHERE i = 3;
+SET AUTOCOMMIT = 1;
+BEGIN;
+UPDATE t SET f = 'dark blue 2' WHERE f = 'red';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (6 + (2 * 10),"brown");
+INSERT INTO n VALUES (now(),"brown");
+COMMIT;
+COMMIT;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'dark blue 2' WHERE f = 'red'
+master-bin.000001 # Query # # ROLLBACK
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'gray 2' WHERE i = 3
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (6 + (2 * 10),"brown")
+master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown")
+master-bin.000001 # Xid # # COMMIT /* XID */
+SET AUTOCOMMIT = 0;
+UPDATE t SET f = 'yellow 1' WHERE i = 3;
+SET AUTOCOMMIT = 0;
+UPDATE t SET f = 'magenta 1' WHERE f = 'red';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (5 + (1 * 10),"brown");
+INSERT INTO n VALUES (now(),"brown");
+COMMIT;
+ROLLBACK;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'magenta 1' WHERE f = 'red'
+master-bin.000001 # Query # # ROLLBACK
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'yellow 1' WHERE i = 3
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (5 + (1 * 10),"brown")
+master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown")
+master-bin.000001 # Query # # ROLLBACK
+SET AUTOCOMMIT = 0;
+UPDATE t SET f = 'gray 1' WHERE i = 3;
+SET AUTOCOMMIT = 0;
+UPDATE t SET f = 'dark blue 1' WHERE f = 'red';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+INSERT INTO t VALUES (6 + (1 * 10),"brown");
+INSERT INTO n VALUES (now(),"brown");
+COMMIT;
+COMMIT;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'dark blue 1' WHERE f = 'red'
+master-bin.000001 # Query # # ROLLBACK
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'gray 1' WHERE i = 3
+master-bin.000001 # Xid # # COMMIT /* XID */
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (6 + (1 * 10),"brown")
+master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown")
+master-bin.000001 # Xid # # COMMIT /* XID */
+source include/diff_master_slave.inc;
+source include/diff_master_slave.inc;
+########################################################################
+# Cleanup
+########################################################################
+DROP TRIGGER tr;
+DROP TABLE t;
+DROP TABLE n;
diff --git a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
index 6126ec4bacc..fa40d8760a8 100644
--- a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result
@@ -174,3 +174,26 @@ start slave;
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 0
+stop slave;
+reset slave;
+*** errno must be zero: 0 ***
+change master to master_user='impossible_user_name';
+start slave;
+ONE
+1
+include/stop_slave.inc
+change master to master_user='root';
+include/start_slave.inc
+*** last errno must be zero: 0 ***
+*** last error must be blank: ***
+include/stop_slave.inc
+change master to master_user='impossible_user_name';
+start slave;
+ONE
+1
+include/stop_slave.inc
+reset slave;
+*** io last errno must be zero: 0 ***
+*** io last error must be blank: ***
+*** sql last errno must be zero: 0 ***
+*** sql last error must be blank: ***
diff --git a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
index bb89d150af7..78d9d7c41eb 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result
@@ -174,3 +174,26 @@ start slave;
show status like 'slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 1
+stop slave;
+reset slave;
+*** errno must be zero: 0 ***
+change master to master_user='impossible_user_name';
+start slave;
+ONE
+1
+include/stop_slave.inc
+change master to master_user='root';
+include/start_slave.inc
+*** last errno must be zero: 0 ***
+*** last error must be blank: ***
+include/stop_slave.inc
+change master to master_user='impossible_user_name';
+start slave;
+ONE
+1
+include/stop_slave.inc
+reset slave;
+*** io last errno must be zero: 0 ***
+*** io last error must be blank: ***
+*** sql last errno must be zero: 0 ***
+*** sql last error must be blank: ***
diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def
index 38fc9e21322..af8eef764ed 100644
--- a/mysql-test/suite/rpl/t/disabled.def
+++ b/mysql-test/suite/rpl/t/disabled.def
@@ -11,3 +11,5 @@
##############################################################################
rpl_cross_version : Bug#42311 2009-03-27 joro rpl_cross_version fails on macosx
+rpl_init_slave : Bug#44920 2009-07006 pcrews MTR2 is not processing master.opt input properly on Windows. *Must be done this way due to the nature of the bug*
+
diff --git a/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt
new file mode 100644
index 00000000000..45631525481
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size-master.opt
@@ -0,0 +1 @@
+--binlog_cache_size=4096 --max_binlog_cache_size=7680
diff --git a/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test
new file mode 100644
index 00000000000..e1f1f8c54bb
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_binlog_max_cache_size.test
@@ -0,0 +1,395 @@
+########################################################################################
+# This test verifies if the binlog is not corrupted when the cache buffer is not
+# big enough to accommodate the changes and is divided in five steps:
+#
+# 1 - Single Statements:
+# 1.1 - Single statement on transactional table.
+# 1.2 - Single statement on non-transactional table.
+# 1.3 - Single statement on both transactional and non-transactional tables.
+# In both 1.2 and 1.3, an incident event is logged to notify the user that the
+# master and slave are diverging.
+#
+# 2 - Transactions ended by an implicit commit.
+#
+# 3 - Transactions ended by a COMMIT.
+#
+# 4 - Transactions ended by a ROLLBACK.
+#
+# 5 - Transactions with a failing statement that updates a non-transactional
+# table. In this case, a failure means that the statement does not get into
+# the cache and an incident event is logged to notify the user that the master
+# and slave are diverging.
+#
+########################################################################################
+
+########################################################################################
+# Configuring the environment
+########################################################################################
+--source include/have_innodb.inc
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_windows.inc
+
+CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
+CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
+CREATE TABLE t3(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
+
+let $data = `select concat('"', repeat('a',2000), '"')`;
+
+--echo ########################################################################################
+--echo # 1 - SINGLE STATEMENT
+--echo ########################################################################################
+
+connection master;
+
+--echo *** Single statement on transactional table ***
+--disable_query_log
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+eval INSERT INTO t1 (a, data) VALUES (1,
+ CONCAT($data, $data, $data, $data, $data));
+--enable_query_log
+
+--echo *** Single statement on non-transactional table ***
+--echo *** After WL#2687 the difference between STATEMENT/MIXED and ROW will not exist. ***
+--disable_query_log
+--disable_warnings
+if (`SELECT @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
+{
+ eval INSERT INTO t2 (a, data) VALUES (2,
+ CONCAT($data, $data, $data, $data, $data, $data));
+ --echo Got one of the listed errors
+}
+if (`SELECT @@binlog_format = 'ROW'`)
+{
+ --error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+ eval INSERT INTO t2 (a, data) VALUES (2,
+ CONCAT($data, $data, $data, $data, $data, $data));
+
+ connection slave;
+ --source include/wait_for_slave_sql_to_stop.inc
+ SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
+ START SLAVE SQL_THREAD;
+ --source include/wait_for_slave_sql_to_start.inc
+}
+--enable_warnings
+--enable_query_log
+
+connection master;
+
+--disable_query_log
+eval INSERT INTO t1 (a, data) VALUES (3, $data);
+eval INSERT INTO t1 (a, data) VALUES (4, $data);
+eval INSERT INTO t1 (a, data) VALUES (5, $data);
+eval INSERT INTO t2 (a, data) VALUES (3, $data);
+eval INSERT INTO t2 (a, data) VALUES (4, $data);
+eval INSERT INTO t2 (a, data) VALUES (5, $data);
+--enable_query_log
+
+--echo *** Single statement on both transactional and non-transactional tables. ***
+--echo *** After WL#2687 we will be able to change the order of the tables. ***
+--disable_query_log
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+eval UPDATE t2, t1 SET t2.data = CONCAT($data, $data, $data, $data),
+ t1.data = CONCAT($data, $data, $data, $data);
+--enable_query_log
+
+connection slave;
+--source include/wait_for_slave_sql_to_stop.inc
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
+START SLAVE SQL_THREAD;
+--source include/wait_for_slave_sql_to_start.inc
+
+#--echo ########################################################################################
+#--echo # 2 - BEGIN - IMPLICIT COMMIT by DDL
+#--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t1 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--eval INSERT INTO t1 (a, data) VALUES (7, 's');
+--eval INSERT INTO t2 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--enable_query_log
+
+--disable_query_log
+ALTER TABLE t3 ADD COLUMN d int;
+--enable_query_log
+
+--disable_query_log
+--eval INSERT INTO t2 (a, data) VALUES (10, $data);
+--eval INSERT INTO t2 (a, data) VALUES (11, $data);
+--eval INSERT INTO t2 (a, data) VALUES (12, $data);
+--eval INSERT INTO t2 (a, data) VALUES (13, $data);
+--enable_query_log
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (14, $data);
+--eval INSERT INTO t1 (a, data) VALUES (15, $data);
+--eval INSERT INTO t1 (a, data) VALUES (16, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (17, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (18, $data);
+--eval INSERT INTO t1 (a, data) VALUES (19, 's');
+--eval INSERT INTO t2 (a, data) VALUES (20, 's');
+--eval INSERT INTO t1 (a, data) VALUES (21, 's');
+--enable_query_log
+
+if (`SELECT @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
+{
+ --disable_query_log
+ CREATE TABLE t4 SELECT * FROM t1;
+ --enable_query_log
+ --echo Got one of the listed errors
+}
+if (`SELECT @@binlog_format = 'ROW'`)
+{
+ --disable_query_log
+ --error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+ CREATE TABLE t4 SELECT * FROM t1;
+ --enable_query_log
+}
+
+--disable_query_log
+--eval INSERT INTO t2 (a, data) VALUES (15, $data);
+--enable_query_log
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (22, $data);
+--eval INSERT INTO t1 (a, data) VALUES (23, $data);
+--eval INSERT INTO t1 (a, data) VALUES (24, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (25, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (26, $data);
+--eval INSERT INTO t1 (a, data) VALUES (27, 's');
+--eval INSERT INTO t2 (a, data) VALUES (28, 's');
+--eval INSERT INTO t1 (a, data) VALUES (29, 's');
+--enable_query_log
+
+--disable_query_log
+CREATE TABLE t5 (a int);
+--enable_query_log
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo # 3 - BEGIN - COMMIT
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t1 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--eval INSERT INTO t1 (a, data) VALUES (7, 's');
+--eval INSERT INTO t2 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--enable_query_log
+COMMIT;
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo # 4 - BEGIN - ROLLBACK
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t1 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--eval INSERT INTO t1 (a, data) VALUES (7, 's');
+--eval INSERT INTO t2 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--enable_query_log
+ROLLBACK;
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo # 5 - PROCEDURE
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+DELIMITER //;
+
+CREATE PROCEDURE p1(pd VARCHAR(30000))
+BEGIN
+ INSERT INTO t1 (a, data) VALUES (1, pd);
+ INSERT INTO t1 (a, data) VALUES (2, pd);
+ INSERT INTO t1 (a, data) VALUES (3, pd);
+ INSERT INTO t1 (a, data) VALUES (4, pd);
+ INSERT INTO t1 (a, data) VALUES (5, 's');
+END//
+
+DELIMITER ;//
+
+TRUNCATE TABLE t1;
+
+--disable_query_log
+eval CALL p1($data);
+--enable_query_log
+
+TRUNCATE TABLE t1;
+
+BEGIN;
+--disable_query_log
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+eval CALL p1($data);
+--enable_query_log
+COMMIT;
+
+TRUNCATE TABLE t1;
+
+BEGIN;
+--disable_query_log
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+eval CALL p1($data);
+--enable_query_log
+ROLLBACK;
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo # 6 - XID
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t1 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+SAVEPOINT sv;
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--eval INSERT INTO t1 (a, data) VALUES (7, 's');
+--eval INSERT INTO t2 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--enable_query_log
+ROLLBACK TO sv;
+COMMIT;
+
+let $diff_statement= SELECT * FROM t1;
+--source include/diff_master_slave.inc
+
+--echo ########################################################################################
+--echo # 7 - NON-TRANS TABLE
+--echo ########################################################################################
+
+connection master;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (1, $data);
+--eval INSERT INTO t1 (a, data) VALUES (2, $data);
+--eval INSERT INTO t2 (a, data) VALUES (3, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (4, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (5, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (6, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (7, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval UPDATE t2 SET data= CONCAT($data, $data);
+--eval INSERT INTO t1 (a, data) VALUES (8, 's');
+--eval INSERT INTO t1 (a, data) VALUES (9, 's');
+--eval INSERT INTO t2 (a, data) VALUES (10, 's');
+--eval INSERT INTO t1 (a, data) VALUES (11, 's');
+--enable_query_log
+COMMIT;
+
+BEGIN;
+--disable_query_log
+--eval INSERT INTO t1 (a, data) VALUES (15, $data);
+--eval INSERT INTO t1 (a, data) VALUES (16, $data);
+--eval INSERT INTO t2 (a, data) VALUES (17, $data);
+--error ER_TRANS_CACHE_FULL, ER_ERROR_ON_WRITE
+--eval INSERT INTO t1 (a, data) VALUES (18, $data);
+--enable_query_log
+COMMIT;
+
+connection slave;
+--source include/wait_for_slave_sql_to_stop.inc
+
+--echo ########################################################################################
+--echo # CLEAN
+--echo ########################################################################################
+
+--disable_warnings
+connection master;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP TABLE IF EXISTS t6;
+DROP PROCEDURE p1;
+connection slave;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE IF EXISTS t4;
+DROP TABLE IF EXISTS t5;
+DROP TABLE IF EXISTS t6;
+DROP PROCEDURE p1;
+--enable_warnings
diff --git a/mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt b/mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt
new file mode 100644
index 00000000000..a6ef074a120
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_concurrency_error-master.opt
@@ -0,0 +1 @@
+--innodb-lock-wait-timeout=1
diff --git a/mysql-test/suite/rpl/t/rpl_concurrency_error.test b/mysql-test/suite/rpl/t/rpl_concurrency_error.test
new file mode 100644
index 00000000000..da2951afb1a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_concurrency_error.test
@@ -0,0 +1,149 @@
+###############################################################################
+#BUG#44581 Slave stops when transaction with non-transactional table gets
+#lock wait timeout
+#
+# In STMT and MIXED modes, a statement that changes both non-transactional and
+# transactional tables must be written to the binary log whenever there are
+# changes to non-transactional tables. This means that the statement gets into
+# the # binary log even when the changes to the transactional tables fail. In
+# particular, in the presence of a failure such statement is annotated with the
+# error number and wrapped in a begin/rollback. On the slave, while applying
+# the statement, it is expected the same failure and the rollback prevents the
+# transactional changes to be persisted.
+
+# This test aims to verify if a statement that updates both transactional and
+# non-transacitonal tables and fails due to concurrency problems is correctly
+# processed by the slave in the sense that the statements get into the binary
+# log, the error is ignored and only the non-transactional tables are changed.
+###############################################################################
+
+--source include/master-slave.inc
+--source include/have_innodb.inc
+--source include/have_binlog_format_statement.inc
+
+--echo ########################################################################
+--echo # Environment
+--echo ########################################################################
+connection master;
+
+CREATE TABLE t (i INT, PRIMARY KEY(i), f CHAR(8)) engine = Innodb;
+CREATE TABLE n (d DATETIME, f CHAR(32)) engine = MyIsam;
+
+DELIMITER |;
+CREATE TRIGGER tr AFTER UPDATE ON t FOR EACH ROW
+BEGIN
+ INSERT INTO n VALUES ( now(), concat( 'updated t: ', old.f, ' -> ', new.f ) );
+END |
+DELIMITER ;|
+
+INSERT INTO t VALUES (4,'black'), (2,'red'), (3,'yelow'), (1,'cyan');
+
+connect (conn1, 127.0.0.1,root,,);
+connect (conn2, 127.0.0.1,root,,);
+
+--echo ########################################################################
+--echo # Testing ER_LOCK_WAIT_TIMEOUT
+--echo ########################################################################
+
+let $type=2;
+
+while ($type)
+{
+ let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
+ connection conn1;
+ if (`select $type = 2`)
+ {
+ SET AUTOCOMMIT = 1;
+ BEGIN;
+ }
+ if (`select $type = 1`)
+ {
+ SET AUTOCOMMIT = 0;
+ }
+ eval UPDATE t SET f = 'yellow $type' WHERE i = 3;
+
+ connection conn2;
+ if (`select $type = 2`)
+ {
+ SET AUTOCOMMIT = 1;
+ BEGIN;
+ }
+ if (`select $type = 1`)
+ {
+ SET AUTOCOMMIT = 0;
+ }
+ --error ER_LOCK_WAIT_TIMEOUT
+ eval UPDATE t SET f = 'magenta $type' WHERE f = 'red';
+ eval INSERT INTO t VALUES (5 + ($type * 10),"brown");
+ INSERT INTO n VALUES (now(),"brown");
+
+ connection conn1;
+ COMMIT;
+
+ connection conn2;
+ ROLLBACK;
+ --source include/show_binlog_events.inc
+
+ let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
+ connection conn1;
+ if (`select $type = 2`)
+ {
+ SET AUTOCOMMIT = 1;
+ BEGIN;
+ }
+ if (`select $type = 1`)
+ {
+ SET AUTOCOMMIT = 0;
+ }
+ eval UPDATE t SET f = 'gray $type' WHERE i = 3;
+
+ connection conn2;
+ if (`select $type = 2`)
+ {
+ SET AUTOCOMMIT = 1;
+ BEGIN;
+ }
+ if (`select $type = 1`)
+ {
+ SET AUTOCOMMIT = 0;
+ }
+ --error ER_LOCK_WAIT_TIMEOUT
+ eval UPDATE t SET f = 'dark blue $type' WHERE f = 'red';
+ eval INSERT INTO t VALUES (6 + ($type * 10),"brown");
+ INSERT INTO n VALUES (now(),"brown");
+
+ connection conn1;
+ COMMIT;
+
+ connection conn2;
+ COMMIT;
+ --source include/show_binlog_events.inc
+
+ dec $type;
+}
+
+connection master;
+sync_slave_with_master;
+
+connection master;
+let $diff_statement= SELECT * FROM t order by i;
+source include/diff_master_slave.inc;
+
+connection master;
+let $diff_statement= SELECT * FROM n order by d, f;
+source include/diff_master_slave.inc;
+
+--echo ########################################################################
+--echo # Cleanup
+--echo ########################################################################
+
+connection master;
+DROP TRIGGER tr;
+DROP TABLE t;
+DROP TABLE n;
+
+sync_slave_with_master;
+
+connection master;
+disconnect conn1;
+disconnect conn2;
diff --git a/mysql-test/suite/rpl/t/rpl_init_slave.test b/mysql-test/suite/rpl/t/rpl_init_slave.test
index dd58b973fca..58d1f6bdc01 100644
--- a/mysql-test/suite/rpl/t/rpl_init_slave.test
+++ b/mysql-test/suite/rpl/t/rpl_init_slave.test
@@ -1,9 +1,3 @@
-if(`SELECT CONVERT(@@version_compile_os using latin1) IN ("Win32", "Win64", "Windows")`)
-{
---skip Bug#44920 2009-05-18 pcrews MTR2 is not processing master.opt input properly on Windows
-}
-
-
source include/master-slave.inc;
#
diff --git a/mysql-test/suite/rpl/t/rpl_sp.test b/mysql-test/suite/rpl/t/rpl_sp.test
index ec6464fb095..9be630e9ae8 100644
--- a/mysql-test/suite/rpl/t/rpl_sp.test
+++ b/mysql-test/suite/rpl/t/rpl_sp.test
@@ -642,3 +642,6 @@ drop procedure ` mysqltestbug36570_p2`;
drop function mysqltestbug36570_f1;
--echo End of 5.0 tests
--echo End of 5.1 tests
+
+# Cleanup
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl_ndb/t/disabled.def b/mysql-test/suite/rpl_ndb/t/disabled.def
index 6908269d014..2f15112515e 100644
--- a/mysql-test/suite/rpl_ndb/t/disabled.def
+++ b/mysql-test/suite/rpl_ndb/t/disabled.def
@@ -11,3 +11,4 @@
##############################################################################
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
+rpl_ndb_2ndb : Bug#45974: rpl_ndb_2ndb fails sporadically
diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test
index 9e9716e5ddb..89df33a6df5 100644
--- a/mysql-test/t/ctype_cp932_binlog_stm.test
+++ b/mysql-test/t/ctype_cp932_binlog_stm.test
@@ -22,7 +22,7 @@ CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)|
SELECT HEX(s1),HEX(s2),d FROM t4|
DROP PROCEDURE bug18293|
DROP TABLE t4|
-SHOW BINLOG EVENTS FROM 369|
+SHOW BINLOG EVENTS FROM 370|
delimiter ;|
--echo End of 5.0 tests
@@ -31,8 +31,9 @@ delimiter ;|
# #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump
# Note: 364 is a magic position (found experimentally, depends on
# the log's contents) that caused the server crash.
+
--error 1220
-SHOW BINLOG EVENTS FROM 364;
+SHOW BINLOG EVENTS FROM 365;
--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
CREATE TABLE t1 (a varchar(16)) character set cp932;
diff --git a/mysql-test/t/ctype_gbk_binlog.test b/mysql-test/t/ctype_gbk_binlog.test
new file mode 100644
index 00000000000..a8f653d1b1e
--- /dev/null
+++ b/mysql-test/t/ctype_gbk_binlog.test
@@ -0,0 +1,36 @@
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/have_gbk.inc
+
+SET NAMES gbk;
+--character_set gbk
+
+CREATE TABLE t1 (
+ f1 BLOB
+) ENGINE=MyISAM DEFAULT CHARSET=gbk;
+
+delimiter |;
+CREATE PROCEDURE p1(IN val BLOB)
+BEGIN
+ SET @tval = val;
+ SET @sql_cmd = CONCAT_WS(' ', 'insert into t1(f1) values(?)');
+ PREPARE stmt FROM @sql_cmd;
+ EXECUTE stmt USING @tval;
+ DEALLOCATE PREPARE stmt;
+END|
+delimiter ;|
+
+SET @`tcontent`:=_binary 0x50434B000900000000000000E9000000 COLLATE `binary`/*!*/;
+CALL p1(@`tcontent`);
+
+FLUSH LOGS;
+DROP PROCEDURE p1;
+RENAME TABLE t1 to t2;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+--exec $MYSQL_BINLOG --force-if-open --short-form $MYSQLD_DATADIR/master-bin.000001 | $MYSQL
+SELECT hex(f1) FROM t2;
+SELECT hex(f1) FROM t1;
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 6d8f0af0c28..5436b7166f4 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -12,3 +12,5 @@
kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
innodb_bug39438 : Bug#42383 2009-01-28 lsoares "This fails in embedded and on windows. Note that this test is not run on windows and on embedded in PB for main trees currently"
query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
+init_connect : Bug#44920 2009-07-06 pcrews MTR not processing master.opt input properly on Windows. *Must be done this way due to the nature of the bug*
+
diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test
index 5f37cd2a13e..294efa8caf1 100644
--- a/mysql-test/t/func_set.test
+++ b/mysql-test/t/func_set.test
@@ -84,3 +84,16 @@ engine=myisam default charset=latin1;
insert into t1 values (''),(null),(null),(''),(''),('');
select find_in_set(f1,f1) as a from t1,(select find_in_set(f1,f1) as b from t1) a;
drop table t1;
+#
+# Bug#45168: assertion with convert() and empty set value
+#
+CREATE TABLE t1( a SET('a', 'b', 'c') );
+CREATE TABLE t2( a SET('a', 'b', 'c') );
+
+INSERT INTO t1 VALUES ('d');
+INSERT INTO t2 VALUES ('');
+
+SELECT CONVERT( a USING latin1 ) FROM t1;
+SELECT CONVERT( a USING latin1 ) FROM t2;
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index 0dae4509518..4a60e777cc7 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -667,4 +667,28 @@ desc v1;
drop view v1;
drop table t1;
+#
+# Bug#44684: valgrind reports invalid reads in
+# Item_func_spatial_collection::val_str
+#
+SELECT MultiPoint(12345,'');
+SELECT MultiPoint(123451,'');
+SELECT MultiPoint(1234512,'');
+SELECT MultiPoint(12345123,'');
+
+SELECT MultiLineString(12345,'');
+SELECT MultiLineString(123451,'');
+SELECT MultiLineString(1234512,'');
+SELECT MultiLineString(12345123,'');
+
+SELECT LineString(12345,'');
+SELECT LineString(123451,'');
+SELECT LineString(1234512,'');
+SELECT LineString(12345123,'');
+
+SELECT Polygon(12345,'');
+SELECT Polygon(123451,'');
+SELECT Polygon(1234512,'');
+SELECT Polygon(12345123,'');
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/init_connect.test b/mysql-test/t/init_connect.test
index 1e93d0d671f..b6bac5f65fa 100644
--- a/mysql-test/t/init_connect.test
+++ b/mysql-test/t/init_connect.test
@@ -2,11 +2,6 @@
# Test of init_connect variable
#
-if(`SELECT CONVERT(@@version_compile_os using latin1) IN ("Win32", "Win64", "Windows")`)
-{
---skip Bug#44920 2009-05-18 pcrews MTR2 is not processing master.opt input properly on Windows
-}
-
# should work with embedded server after mysqltest is fixed
--source include/not_embedded.inc
diff --git a/mysql-test/t/innodb_bug40565.test b/mysql-test/t/innodb_bug40565.test
new file mode 100644
index 00000000000..d7aa0fd514a
--- /dev/null
+++ b/mysql-test/t/innodb_bug40565.test
@@ -0,0 +1,10 @@
+# Bug #40565 Update Query Results in "1 Row Affected" But Should Be "Zero Rows"
+-- source include/have_innodb.inc
+
+create table bug40565(value decimal(4,2)) engine=innodb;
+insert into bug40565 values (1), (null);
+--enable_info
+update bug40565 set value=NULL;
+update bug40565 set value=NULL;
+--disable_info
+drop table bug40565;
diff --git a/mysql-test/t/innodb_bug45357.test b/mysql-test/t/innodb_bug45357.test
new file mode 100644
index 00000000000..81727f352dd
--- /dev/null
+++ b/mysql-test/t/innodb_bug45357.test
@@ -0,0 +1,10 @@
+-- source include/have_innodb.inc
+
+set session transaction isolation level read committed;
+
+create table bug45357(a int, b int,key(b))engine=innodb;
+insert into bug45357 values (25170,6122);
+update bug45357 set a=1 where b=30131;
+delete from bug45357 where b < 20996;
+delete from bug45357 where b < 7001;
+drop table bug45357;
diff --git a/mysql-test/t/mysql-bug45236.test b/mysql-test/t/mysql-bug45236.test
new file mode 100644
index 00000000000..efc10ed19ea
--- /dev/null
+++ b/mysql-test/t/mysql-bug45236.test
@@ -0,0 +1,45 @@
+#
+# Bug #45236: large blob inserts from mysqldump fail, possible memory issue ?
+#
+# This test consumes a significant amount of resources.
+# Therefore it should be kept separated from other tests.
+# Otherwise we might suffer from problems like
+# Bug#43801 mysql.test takes too long, fails due to expired timeout
+# on debx86-b in PB
+#
+
+-- source include/not_embedded.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Have to change the global variable as the session variable is
+# read-only.
+SET @old_max_allowed_packet= @@global.max_allowed_packet;
+# ~1 MB blob length + some space for the rest of INSERT query
+SET @@global.max_allowed_packet = 1024 * 1024 + 1024;
+
+# Create a new connection since the global max_allowed_packet
+# has no effect onr the current one
+connect (con1, localhost, root,,);
+
+CREATE TABLE t1(data LONGBLOB);
+INSERT INTO t1 SELECT CONCAT(REPEAT('1', 1024*1024 - 27),
+ "\'\r dummydb dummyhost");
+
+let $outfile= $MYSQLTEST_VARDIR/tmp/bug41486.sql;
+--error 0,1
+remove_file $outfile;
+--exec $MYSQL_DUMP --compact -t test t1 > $outfile
+# Check that the mysql client does not interpret the "\r" sequence as a command
+--exec $MYSQL --max_allowed_packet=1M test < $outfile 2>&1
+
+DROP TABLE t1;
+
+# Cleanup
+disconnect con1;
+--source include/wait_until_disconnected.inc
+remove_file $outfile;
+connection default;
+SET @@global.max_allowed_packet = @old_max_allowed_packet;
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 8535e1bc5c2..8b4af201af2 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -1976,6 +1976,17 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c;
DROP TABLE t1;
+--echo #
+--echo # Bug #45807: crash accessing partitioned table and sql_mode
+--echo # contains ONLY_FULL_GROUP_BY
+--echo #
+
+SET SESSION SQL_MODE='ONLY_FULL_GROUP_BY';
+CREATE TABLE t1(id INT,KEY(id)) ENGINE=MYISAM
+ PARTITION BY HASH(id) PARTITIONS 2;
+DROP TABLE t1;
+SET SESSION SQL_MODE=DEFAULT;
+
--echo End of 5.1 tests
SET @@global.general_log= @old_general_log;
diff --git a/mysql-test/t/query_cache_debug.test b/mysql-test/t/query_cache_debug.test
index f54e7105807..d30cd458e99 100644
--- a/mysql-test/t/query_cache_debug.test
+++ b/mysql-test/t/query_cache_debug.test
@@ -206,10 +206,11 @@ LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.pro
--echo ** and finally release the mutex. The threads will continue to wait
--echo ** until a broadcast signal reaches them causing both threads to
--echo ** come alive and check the condition.
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' LIMIT 1 INTO @thread_id;
+SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id;
KILL QUERY @thread_id;
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' LIMIT 1 INTO @thread_id;
+SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id;
KILL QUERY @thread_id;
+
--echo **
--echo ** Finally signal the DELETE statement on THD1 one last time.
--echo ** The stmt will complete the query cache invalidation and return
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 715bdf0e667..7d3785ecccc 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3799,4 +3799,90 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20;
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20;
DROP TABLE t1;
+
+--echo #
+--echo # Bug#45266: Uninitialized variable lead to an empty result.
+--echo #
+--disable_warnings
+drop table if exists A,AA,B,BB;
+CREATE TABLE `A` (
+ `pk` int(11) NOT NULL AUTO_INCREMENT,
+ `date_key` date NOT NULL,
+ `date_nokey` date NOT NULL,
+ `datetime_key` datetime NOT NULL,
+ `int_nokey` int(11) NOT NULL,
+ `time_key` time NOT NULL,
+ `time_nokey` time NOT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `date_key` (`date_key`),
+ KEY `time_key` (`time_key`),
+ KEY `datetime_key` (`datetime_key`)
+);
+
+CREATE TABLE `AA` (
+ `pk` int(11) NOT NULL AUTO_INCREMENT,
+ `int_nokey` int(11) NOT NULL,
+ `time_key` time NOT NULL,
+ KEY `time_key` (`time_key`),
+ PRIMARY KEY (`pk`)
+);
+
+CREATE TABLE `B` (
+ `date_nokey` date NOT NULL,
+ `date_key` date NOT NULL,
+ `time_key` time NOT NULL,
+ `datetime_nokey` datetime NOT NULL,
+ `varchar_key` varchar(1) NOT NULL,
+ KEY `date_key` (`date_key`),
+ KEY `time_key` (`time_key`),
+ KEY `varchar_key` (`varchar_key`)
+);
+
+INSERT INTO `B` VALUES ('2003-07-28','2003-07-28','15:13:38','0000-00-00 00:00:00','f'),('0000-00-00','0000-00-00','00:05:48','2004-07-02 14:34:13','x');
+
+CREATE TABLE `BB` (
+ `pk` int(11) NOT NULL AUTO_INCREMENT,
+ `int_nokey` int(11) NOT NULL,
+ `date_key` date NOT NULL,
+ `varchar_nokey` varchar(1) NOT NULL,
+ `date_nokey` date NOT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `date_key` (`date_key`)
+);
+
+INSERT INTO `BB` VALUES (10,8,'0000-00-00','i','0000-00-00'),(11,0,'2005-08-18','','2005-08-18');
+# Test #1
+SELECT table1 . `pk` AS field1
+ FROM
+ (BB AS table1 INNER JOIN
+ (AA AS table2 STRAIGHT_JOIN A AS table3
+ ON ( table3 . `date_key` = table2 . `pk` ))
+ ON ( table3 . `datetime_key` = table2 . `int_nokey` ))
+ WHERE ( table3 . `date_key` <= 4 AND table2 . `pk` = table1 . `varchar_nokey`)
+ GROUP BY field1 ;
+
+SELECT table3 .`date_key` field1
+ FROM
+ B table1 LEFT JOIN B table3 JOIN
+ (BB table6 JOIN A table7 ON table6 .`varchar_nokey`)
+ ON table6 .`int_nokey` ON table6 .`date_key`
+ WHERE NOT ( table1 .`varchar_key` AND table7 .`pk`) GROUP BY field1;
+
+# Test #2
+SELECT table4 . `time_nokey` AS field1 FROM
+ (AA AS table1 CROSS JOIN
+ (AA AS table2 STRAIGHT_JOIN
+ (B AS table3 STRAIGHT_JOIN A AS table4
+ ON ( table4 . `date_key` = table3 . `time_key` ))
+ ON ( table4 . `pk` = table3 . `date_nokey` ))
+ ON ( table4 . `time_key` = table3 . `datetime_nokey` ))
+ WHERE ( table4 . `time_key` < table1 . `time_key` AND
+ table1 . `int_nokey` != 'f')
+ GROUP BY field1 ORDER BY field1 , field1;
+
+SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON table5 .`date_nokey` ON table5 .`int_nokey` GROUP BY field2;
+--enable_warnings
+
+drop table A,AA,B,BB;
+--echo #end of test for bug#45266
--echo End of 5.1 tests
diff --git a/mysql-test/t/sp-fib.test b/mysql-test/t/sp-fib.test
index 90ca2bbd135..24a51b99c2d 100644
--- a/mysql-test/t/sp-fib.test
+++ b/mysql-test/t/sp-fib.test
@@ -22,13 +22,14 @@ begin
begin
declare x, y bigint unsigned;
declare c cursor for select f from t3 order by f desc limit 2;
-
open c;
fetch c into y;
fetch c into x;
- close c;
insert into t3 values (x+y);
call fib(n-1);
+ ## Close the cursor AFTER the recursion to ensure that the stack
+ ## frame is somewhat intact.
+ close c;
end;
end if;
end|
@@ -36,24 +37,17 @@ end|
# Enable recursion
set @@max_sp_recursion_depth= 20|
-# Minimum test: recursion of 3 levels
-
insert into t3 values (0), (1)|
-call fib(3)|
+# The small number of recursion levels is intentional.
+# We need to avoid
+# Bug#15866 main.sp fails (thread stack limit
+# insufficient for recursive call "fib(20)")
+# which affects some platforms.
+call fib(4)|
select * from t3 order by f asc|
-truncate table t3|
-
-# The original test, 20 levels, ran into memory limits on some machines
-# and builds. Try 10 instead...
-
-insert into t3 values (0), (1)|
-
-call fib(10)|
-
-select * from t3 order by f asc|
drop table t3|
drop procedure fib|
set @@max_sp_recursion_depth= 0|
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index 9a5556c518d..1e55f9d5993 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -2370,4 +2370,30 @@ drop trigger trg1;
drop trigger trg2;
drop table t1, t2;
+#
+# Bug#44653: Server crash noticed when executing random queries with partitions.
+#
+CREATE TABLE t1 ( a INT, b INT );
+CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT );
+
+INSERT INTO t1 (a) VALUES (1);
+
+delimiter //;
+CREATE TRIGGER tr1
+BEFORE INSERT ON t2
+FOR EACH ROW
+BEGIN
+ UPDATE a_nonextisting_table SET a = 1;
+END//
+delimiter ;//
+
+--disable_abort_on_error
+CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1;
+--enable_abort_on_error
+
+# Caused failed assertion
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
--echo End of 5.1 tests.
diff --git a/mysql-test/t/trigger_notembedded.test b/mysql-test/t/trigger_notembedded.test
index 9588ec6e3ed..7a7e6c6bc85 100644
--- a/mysql-test/t/trigger_notembedded.test
+++ b/mysql-test/t/trigger_notembedded.test
@@ -909,4 +909,27 @@ select * from t1;
drop table t1;
disconnect flush;
+#
+# Bug#45412 SHOW CREATE TRIGGER does not require privileges to disclose trigger data
+#
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a char(30)) ENGINE=MEMORY;
+CREATE TRIGGER db1.trg AFTER INSERT ON db1.t1 FOR EACH ROW
+ INSERT INTO db1.t1 VALUES('Some very sensitive data goes here');
+
+CREATE USER 'no_rights'@'localhost';
+REVOKE ALL ON *.* FROM 'no_rights'@'localhost';
+FLUSH PRIVILEGES;
+
+connect (con1,localhost,no_rights,,);
+SELECT trigger_name FROM INFORMATION_SCHEMA.TRIGGERS
+ WHERE trigger_schema = 'db1';
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+SHOW CREATE TRIGGER db1.trg;
+
+connection default;
+disconnect con1;
+DROP USER 'no_rights'@'localhost';
+DROP DATABASE db1;
+
--echo End of 5.1 tests.
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 4cf9ea63dad..cd3c3f81510 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1257,3 +1257,32 @@ select cast(-3.4 as decimal(2,1));
select cast(99.6 as decimal(2,0));
select cast(-13.4 as decimal(2,1));
select cast(98.6 as decimal(2,0));
+
+--echo #
+--echo # Bug #45262: Bad effects with CREATE TABLE and DECIMAL
+--echo #
+
+CREATE TABLE t1 SELECT .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 SELECT 1 + .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 SELECT 1 * .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 SELECT 1 / .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS my_col;
+DESCRIBE t1;
+SELECT my_col FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index a788b5ab41e..7bec02e6fb6 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -3703,6 +3703,38 @@ DROP TABLE t1;
--echo # -- End of test case for Bug#40825
--echo
+--echo #
+--echo # Bug #45806 crash when replacing into a view with a join!
+--echo #
+CREATE TABLE t1(a INT UNIQUE);
+CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a;
+INSERT INTO t1 VALUES (1), (2);
+
+REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v1;
+REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v1;
+DELETE FROM t1 WHERE a=3;
+INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v1`.`a`= 1;
+SELECT * FROM v1;
+
+CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a;
+
+REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v2;
+REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v2;
+INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v2`.`a`= 1;
+SELECT * FROM v2;
+
+DROP VIEW v1;
+DROP VIEW v2;
+DROP TABLE t1;
+
+--echo # -- End of test case for Bug#45806
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.0 tests.
--echo # -----------------------------------------------------------------
diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test
index a0d5aa60641..7b1c6a268d5 100644
--- a/mysql-test/t/xa.test
+++ b/mysql-test/t/xa.test
@@ -135,6 +135,20 @@ xa start 'a';
xa end 'a';
xa rollback 'a';
+#
+# Bug#45548: XA transaction without access to InnoDB tables crashes the server
+#
+
+xa start 'a';
+xa end 'a';
+xa prepare 'a';
+xa commit 'a';
+
+xa start 'a';
+xa end 'a';
+xa prepare 'a';
+xa commit 'a';
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysys/hash.c b/mysys/hash.c
index e7b5352af34..63933abb085 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -45,6 +45,32 @@ static uint calc_hash(const HASH *hash, const uchar *key, size_t length)
return nr1;
}
+/**
+ @brief Initialize the hash
+
+ @details
+
+ Initialize the hash, by defining and giving valid values for
+ its elements. The failure to allocate memory for the
+ hash->array element will not result in a fatal failure. The
+ dynamic array that is part of the hash will allocate memory
+ as required during insertion.
+
+ @param[in,out] hash The hash that is initialized
+ @param[in] charset The charater set information
+ @param[in] size The hash size
+ @param[in] key_offest The key offset for the hash
+ @param[in] key_length The length of the key used in
+ the hash
+ @param[in] get_key get the key for the hash
+ @param[in] free_element pointer to the function that
+ does cleanup
+ @param[in] CALLER_INFO_PROTO flag that define the behaviour
+ of the hash
+ @return inidicates success or failure of initialization
+ @retval 0 success
+ @retval 1 failure
+*/
my_bool
_my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
ulong size, size_t key_offset, size_t key_length,
@@ -55,12 +81,6 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size));
hash->records=0;
- if (my_init_dynamic_array_ci(&hash->array, sizeof(HASH_LINK), size,
- growth_size))
- {
- hash->free=0; /* Allow call to my_hash_free */
- DBUG_RETURN(1);
- }
hash->key_offset=key_offset;
hash->key_length=key_length;
hash->blength=1;
@@ -68,7 +88,8 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
hash->free=free_element;
hash->flags=flags;
hash->charset=charset;
- DBUG_RETURN(0);
+ DBUG_RETURN(my_init_dynamic_array_ci(&hash->array,
+ sizeof(HASH_LINK), size, growth_size));
}
@@ -114,6 +135,7 @@ void my_hash_free(HASH *hash)
my_hash_free_elements(hash);
hash->free= 0;
delete_dynamic(&hash->array);
+ hash->blength= 0;
DBUG_VOID_RETURN;
}
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 33942d87e4f..fd3c2501226 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -20,6 +20,7 @@
#include <mysys_err.h>
#include <my_getopt.h>
#include <errno.h>
+#include <m_string.h>
typedef void (*init_func_p)(const struct my_option *option, uchar* *variable,
longlong value);
@@ -649,8 +650,18 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument,
return EXIT_OUT_OF_MEMORY;
break;
case GET_ENUM:
- if (((*(int*)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0)
- return EXIT_ARGUMENT_INVALID;
+ if (((*(int*)result_pos)=
+ find_type(argument, opts->typelib, 2) - 1) < 0)
+ {
+ /*
+ Accept an integer representation of the enumerated item.
+ */
+ char *endptr;
+ unsigned int arg= (unsigned int) strtol(argument, &endptr, 10);
+ if (*endptr || arg >= opts->typelib->count)
+ return EXIT_ARGUMENT_INVALID;
+ *(int*)result_pos= arg;
+ }
break;
case GET_SET:
*((ulonglong*)result_pos)= find_typeset(argument, opts->typelib, &err);
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index f35be69c151..430c74874eb 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use Getopt::Long;
-use POSIX qw(strftime);
+use POSIX qw(strftime getcwd);
$|=1;
$VER="2.16";
@@ -295,6 +295,7 @@ sub start_mysqlds()
{
@options = defaults_for_group($groups[$i]);
+ $basedir_found= 0; # The default
$mysqld_found= 1; # The default
$mysqld_found= 0 if (!length($mysqld));
$com= "$mysqld";
@@ -310,6 +311,14 @@ sub start_mysqlds()
$com= $options[$j];
$mysqld_found= 1;
}
+ elsif ("--basedir=" eq substr($options[$j], 0, 10))
+ {
+ $basedir= $options[$j];
+ $basedir =~ s/^--basedir=//;
+ $basedir_found= 1;
+ $options[$j]= quote_shell_word($options[$j]);
+ $tmp.= " $options[$j]";
+ }
else
{
$options[$j]= quote_shell_word($options[$j]);
@@ -337,7 +346,16 @@ sub start_mysqlds()
print "group [$groups[$i]] separately.\n";
exit(1);
}
+ if ($basedir_found)
+ {
+ $curdir=getcwd();
+ chdir($basedir) or die "Can't change to datadir $basedir";
+ }
system($com);
+ if ($basedir_found)
+ {
+ chdir($curdir) or die "Can't change back to original dir $curdir";
+ }
}
if (!$i && !$opt_no_log)
{
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 3454f3558e8..ddb90427fdc 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -1247,7 +1247,7 @@ int ha_ndbcluster::add_index_handle(THD *thd, NDBDICT *dict, KEY *key_info,
}
if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX)
{
- char unique_index_name[FN_LEN];
+ char unique_index_name[FN_LEN + 1];
static const char* unique_suffix= "$unique";
m_has_unique_index= TRUE;
strxnmov(unique_index_name, FN_LEN, index_name, unique_suffix, NullS);
@@ -5150,7 +5150,7 @@ int ha_ndbcluster::create(const char *name,
uchar *data= NULL, *pack_data= NULL;
bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE);
- char tablespace[FN_LEN];
+ char tablespace[FN_LEN + 1];
NdbDictionary::Table::SingleUserMode single_user_mode= NdbDictionary::Table::SingleUserModeLocked;
DBUG_ENTER("ha_ndbcluster::create");
@@ -5613,7 +5613,7 @@ int ha_ndbcluster::create_index(const char *name, KEY *key_info,
NDB_INDEX_TYPE idx_type, uint idx_no)
{
int error= 0;
- char unique_name[FN_LEN];
+ char unique_name[FN_LEN + 1];
static const char* unique_suffix= "$unique";
DBUG_ENTER("ha_ndbcluster::create_ordered_index");
DBUG_PRINT("info", ("Creating index %u: %s", idx_no, name));
@@ -6661,7 +6661,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,
size_t len;
uchar* data= NULL;
Ndb* ndb;
- char key[FN_REFLEN];
+ char key[FN_REFLEN + 1];
DBUG_ENTER("ndbcluster_discover");
DBUG_PRINT("enter", ("db: %s, name: %s", db, name));
@@ -6672,7 +6672,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db,
ERR_RETURN(ndb->getNdbError());
}
NDBDICT* dict= ndb->getDictionary();
- build_table_filename(key, sizeof(key), db, name, "", 0);
+ build_table_filename(key, sizeof(key) - 1, db, name, "", 0);
/* ndb_share reference temporary */
NDB_SHARE *share= get_share(key, 0, FALSE);
if (share)
@@ -6837,9 +6837,9 @@ int ndbcluster_drop_database_impl(const char *path)
drop_list.push_back(thd->strdup(elmt.name));
}
// Drop any tables belonging to database
- char full_path[FN_REFLEN];
+ char full_path[FN_REFLEN + 1];
char *tmp= full_path +
- build_table_filename(full_path, sizeof(full_path), dbname, "", "", 0);
+ build_table_filename(full_path, sizeof(full_path) - 1, dbname, "", "", 0);
if (ndb->setDatabaseName(dbname))
{
ERR_RETURN(ndb->getNdbError());
@@ -6908,7 +6908,7 @@ int ndb_create_table_from_engine(THD *thd, const char *db,
int ndbcluster_find_all_files(THD *thd)
{
Ndb* ndb;
- char key[FN_REFLEN];
+ char key[FN_REFLEN + 1];
NDBDICT *dict;
int unhandled, retries= 5, skipped;
DBUG_ENTER("ndbcluster_find_all_files");
@@ -6966,7 +6966,7 @@ int ndbcluster_find_all_files(THD *thd)
/* check if database exists */
char *end= key +
- build_table_filename(key, sizeof(key), elmt.database, "", "", 0);
+ build_table_filename(key, sizeof(key) - 1, elmt.database, "", "", 0);
if (my_access(key, F_OK))
{
/* no such database defined, skip table */
@@ -7047,7 +7047,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
{ // extra bracket to avoid gcc 2.95.3 warning
uint i;
Ndb* ndb;
- char name[FN_REFLEN];
+ char name[FN_REFLEN + 1];
HASH ndb_tables, ok_tables;
NDBDICT::List list;
@@ -7117,7 +7117,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
DBUG_PRINT("info", ("%s", file_name->str));
if (hash_search(&ndb_tables, (uchar*) file_name->str, file_name->length))
{
- build_table_filename(name, sizeof(name), db, file_name->str, reg_ext, 0);
+ build_table_filename(name, sizeof(name) - 1, db,
+ file_name->str, reg_ext, 0);
if (my_access(name, F_OK))
{
pthread_mutex_lock(&LOCK_open);
@@ -7139,7 +7140,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
}
// Check for .ndb file with this name
- build_table_filename(name, sizeof(name), db, file_name->str, ha_ndb_ext, 0);
+ build_table_filename(name, sizeof(name) - 1, db,
+ file_name->str, ha_ndb_ext, 0);
DBUG_PRINT("info", ("Check access for %s", name));
if (my_access(name, F_OK))
{
@@ -7182,7 +7184,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
/* setup logging to binlog for all discovered tables */
{
char *end, *end1= name +
- build_table_filename(name, sizeof(name), db, "", "", 0);
+ build_table_filename(name, sizeof(name) - 1, db, "", "", 0);
for (i= 0; i < ok_tables.records; i++)
{
file_name_str= (char*)hash_element(&ok_tables, i);
@@ -7204,7 +7206,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
file_name_str= (char*) hash_element(&ndb_tables, i);
if (!hash_search(&ok_tables, (uchar*) file_name_str, strlen(file_name_str)))
{
- build_table_filename(name, sizeof(name), db, file_name_str, reg_ext, 0);
+ build_table_filename(name, sizeof(name) - 1,
+ db, file_name_str, reg_ext, 0);
if (my_access(name, F_OK))
{
DBUG_PRINT("info", ("%s must be discovered", file_name_str));
@@ -7584,7 +7587,7 @@ void ndbcluster_print_error(int error, const NdbOperation *error_op)
void ha_ndbcluster::set_dbname(const char *path_name, char *dbname)
{
char *end, *ptr, *tmp_name;
- char tmp_buff[FN_REFLEN];
+ char tmp_buff[FN_REFLEN + 1];
tmp_name= tmp_buff;
/* Scan name from the end */
@@ -7610,7 +7613,7 @@ void ha_ndbcluster::set_dbname(const char *path_name, char *dbname)
ptr++;
}
#endif
- filename_to_tablename(tmp_name, dbname, FN_REFLEN);
+ filename_to_tablename(tmp_name, dbname, sizeof(tmp_buff) - 1);
}
/**
@@ -7630,7 +7633,7 @@ void
ha_ndbcluster::set_tabname(const char *path_name, char * tabname)
{
char *end, *ptr, *tmp_name;
- char tmp_buff[FN_REFLEN];
+ char tmp_buff[FN_REFLEN + 1];
tmp_name= tmp_buff;
/* Scan name from the end */
@@ -7651,7 +7654,7 @@ ha_ndbcluster::set_tabname(const char *path_name, char * tabname)
ptr++;
}
#endif
- filename_to_tablename(tmp_name, tabname, FN_REFLEN);
+ filename_to_tablename(tmp_name, tabname, sizeof(tmp_buff) - 1);
}
/**
@@ -7837,11 +7840,12 @@ uint8 ha_ndbcluster::table_cache_type()
uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname,
Uint64 *commit_count)
{
- char name[FN_REFLEN];
+ char name[FN_REFLEN + 1];
NDB_SHARE *share;
DBUG_ENTER("ndb_get_commitcount");
- build_table_filename(name, sizeof(name), dbname, tabname, "", 0);
+ build_table_filename(name, sizeof(name) - 1,
+ dbname, tabname, "", 0);
DBUG_PRINT("enter", ("name: %s", name));
pthread_mutex_lock(&ndbcluster_mutex);
if (!(share=(NDB_SHARE*) hash_search(&ndbcluster_open_tables,
@@ -9945,7 +9949,7 @@ bool ha_ndbcluster::check_if_incompatible_data(HA_CREATE_INFO *create_info,
ai=1;
}
- char tablespace_name[FN_LEN];
+ char tablespace_name[FN_LEN + 1];
if (get_tablespace_name(current_thd, tablespace_name, FN_LEN))
{
if (create_info->tablespace)
diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc
index a0c74b60f84..f705af8bf47 100644
--- a/sql/ha_ndbcluster_binlog.cc
+++ b/sql/ha_ndbcluster_binlog.cc
@@ -788,7 +788,7 @@ static int ndbcluster_create_ndb_apply_status_table(THD *thd)
if (g_ndb_cluster_connection->get_no_ready() <= 0)
DBUG_RETURN(0);
- char buf[1024], *end;
+ char buf[1024 + 1], *end;
if (ndb_extra_logging)
sql_print_information("NDB: Creating " NDB_REP_DB "." NDB_APPLY_TABLE);
@@ -798,7 +798,7 @@ static int ndbcluster_create_ndb_apply_status_table(THD *thd)
if so, remove it since there is none in Ndb
*/
{
- build_table_filename(buf, sizeof(buf),
+ build_table_filename(buf, sizeof(buf) - 1,
NDB_REP_DB, NDB_APPLY_TABLE, reg_ext, 0);
my_delete(buf, MYF(0));
}
@@ -846,7 +846,7 @@ static int ndbcluster_create_schema_table(THD *thd)
if (g_ndb_cluster_connection->get_no_ready() <= 0)
DBUG_RETURN(0);
- char buf[1024], *end;
+ char buf[1024 + 1], *end;
if (ndb_extra_logging)
sql_print_information("NDB: Creating " NDB_REP_DB "." NDB_SCHEMA_TABLE);
@@ -856,7 +856,7 @@ static int ndbcluster_create_schema_table(THD *thd)
if so, remove it since there is none in Ndb
*/
{
- build_table_filename(buf, sizeof(buf),
+ build_table_filename(buf, sizeof(buf) - 1,
NDB_REP_DB, NDB_SCHEMA_TABLE, reg_ext, 0);
my_delete(buf, MYF(0));
}
@@ -1321,8 +1321,8 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share,
NDB_SCHEMA_OBJECT *ndb_schema_object;
{
- char key[FN_REFLEN];
- build_table_filename(key, sizeof(key), db, table_name, "", 0);
+ char key[FN_REFLEN + 1];
+ build_table_filename(key, sizeof(key) - 1, db, table_name, "", 0);
ndb_schema_object= ndb_get_schema_object(key, TRUE, FALSE);
}
@@ -1674,7 +1674,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
if (is_remote_change && is_online_alter_table)
{
const char *tabname= table_share->table_name.str;
- char key[FN_REFLEN];
+ char key[FN_REFLEN + 1];
uchar *data= 0, *pack_data= 0;
size_t length, pack_length;
int error;
@@ -1683,7 +1683,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp,
DBUG_PRINT("info", ("Detected frm change of table %s.%s",
dbname, tabname));
- build_table_filename(key, FN_LEN-1, dbname, tabname, NullS, 0);
+ build_table_filename(key, FN_LEN - 1, dbname, tabname, NullS, 0);
/*
If the there is no local table shadowing the altered table and
it has an frm that is different than the one on disk then
@@ -1926,8 +1926,8 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
break;
case SOT_TRUNCATE_TABLE:
{
- char key[FN_REFLEN];
- build_table_filename(key, sizeof(key),
+ char key[FN_REFLEN + 1];
+ build_table_filename(key, sizeof(key) - 1,
schema->db, schema->name, "", 0);
/* ndb_share reference temporary, free below */
NDB_SHARE *share= get_share(key, 0, FALSE, FALSE);
@@ -2173,8 +2173,8 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd,
int log_query= 0;
{
enum SCHEMA_OP_TYPE schema_type= (enum SCHEMA_OP_TYPE)schema->type;
- char key[FN_REFLEN];
- build_table_filename(key, sizeof(key), schema->db, schema->name, "", 0);
+ char key[FN_REFLEN + 1];
+ build_table_filename(key, sizeof(key) - 1, schema->db, schema->name, "", 0);
if (schema_type == SOT_CLEAR_SLOCK)
{
pthread_mutex_lock(&ndbcluster_mutex);
@@ -2508,8 +2508,8 @@ ndb_rep_event_name(String *event_name,const char *db, const char *tbl)
bool
ndbcluster_check_if_local_table(const char *dbname, const char *tabname)
{
- char key[FN_REFLEN];
- char ndb_file[FN_REFLEN];
+ char key[FN_REFLEN + 1];
+ char ndb_file[FN_REFLEN + 1];
DBUG_ENTER("ndbcluster_check_if_local_table");
build_table_filename(key, FN_LEN-1, dbname, tabname, reg_ext, 0);
@@ -2534,9 +2534,9 @@ ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname)
DBUG_PRINT("info", ("Looking for files in directory %s", dbname));
LEX_STRING *tabname;
List<LEX_STRING> files;
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
- build_table_filename(path, sizeof(path), dbname, "", "", 0);
+ build_table_filename(path, sizeof(path) - 1, dbname, "", "", 0);
if (find_files(thd, &files, dbname, path, NullS, 0) != FIND_FILES_OK)
{
DBUG_PRINT("info", ("Failed to find files"));
diff --git a/sql/handler.cc b/sql/handler.cc
index 058a43eed8d..e65ceba4181 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1242,9 +1242,10 @@ int ha_commit_one_phase(THD *thd, bool all)
#endif
thd->variables.tx_isolation=thd->session_tx_isolation;
}
- if (is_real_trans)
- thd->transaction.cleanup();
}
+ /* Free resources and perform other cleanup even for 'empty' transactions. */
+ if (is_real_trans)
+ thd->transaction.cleanup();
#endif /* USING_TRANSACTIONS */
DBUG_RETURN(error);
}
@@ -3582,7 +3583,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
int error;
uchar *frmblob;
size_t frmlen;
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
HA_CREATE_INFO create_info;
TABLE table;
TABLE_SHARE share;
@@ -3601,7 +3602,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
frmblob and frmlen are set, write the frm to disk
*/
- build_table_filename(path, FN_REFLEN-1, db, name, "", 0);
+ build_table_filename(path, sizeof(path) - 1, db, name, "", 0);
// Save the frm file
error= writefrm(path, frmblob, frmlen);
my_free(frmblob, MYF(0));
@@ -4778,7 +4779,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator)
if ((ptr= (uchar*)my_malloc(ALIGN_SIZE(sizeof(fl_buff)) +
((ALIGN_SIZE(sizeof(LEX_STRING)) +
sizeof(enum log_status) +
- + FN_REFLEN) *
+ + FN_REFLEN + 1) *
(uint) dirp->number_off_files),
MYF(0))) == 0)
{
@@ -4806,7 +4807,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator)
name_ptr= strxnmov(buff->names[buff->entries].str= name_ptr,
FN_REFLEN, fl_dir, file->name, NullS);
buff->names[buff->entries].length= (name_ptr -
- buff->names[buff->entries].str) - 1;
+ buff->names[buff->entries].str);
buff->statuses[buff->entries]= st;
buff->entries++;
}
diff --git a/sql/item.cc b/sql/item.cc
index 06eea020c23..4d9004fff26 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1507,10 +1507,6 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags)
{
set(dt);
}
- else
- {
- // Do nothing
- }
}
else if ((flags & MY_COLL_ALLOW_SUPERSET_CONV) &&
left_is_superset(this, &dt))
@@ -2264,8 +2260,10 @@ Item_decimal::Item_decimal(const char *str_arg, uint length,
name= (char*) str_arg;
decimals= (uint8) decimal_value.frac;
fixed= 1;
- max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
- decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+ decimals,
+ decimals,
+ unsigned_flag);
}
Item_decimal::Item_decimal(longlong val, bool unsig)
@@ -2273,8 +2271,10 @@ Item_decimal::Item_decimal(longlong val, bool unsig)
int2my_decimal(E_DEC_FATAL_ERROR, val, unsig, &decimal_value);
decimals= (uint8) decimal_value.frac;
fixed= 1;
- max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
- decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+ decimals,
+ decimals,
+ unsigned_flag);
}
@@ -2283,8 +2283,10 @@ Item_decimal::Item_decimal(double val, int precision, int scale)
double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value);
decimals= (uint8) decimal_value.frac;
fixed= 1;
- max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
- decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+ decimals,
+ decimals,
+ unsigned_flag);
}
@@ -2304,8 +2306,10 @@ Item_decimal::Item_decimal(my_decimal *value_par)
my_decimal2decimal(value_par, &decimal_value);
decimals= (uint8) decimal_value.frac;
fixed= 1;
- max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
- decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+ decimals,
+ decimals,
+ unsigned_flag);
}
@@ -2315,8 +2319,8 @@ Item_decimal::Item_decimal(const uchar *bin, int precision, int scale)
&decimal_value, precision, scale);
decimals= (uint8) decimal_value.frac;
fixed= 1;
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+ unsigned_flag);
}
@@ -2371,8 +2375,10 @@ void Item_decimal::set_decimal_value(my_decimal *value_par)
my_decimal2decimal(value_par, &decimal_value);
decimals= (uint8) decimal_value.frac;
unsigned_flag= !decimal_value.sign();
- max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
- decimals, unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
+ decimals,
+ decimals,
+ unsigned_flag);
}
@@ -2644,8 +2650,9 @@ void Item_param::set_decimal(const char *str, ulong length)
str2my_decimal(E_DEC_FATAL_ERROR, str, &decimal_value, &end);
state= DECIMAL_VALUE;
decimals= decimal_value.frac;
- max_length= my_decimal_precision_to_length(decimal_value.precision(),
- decimals, unsigned_flag);
+ max_length=
+ my_decimal_precision_to_length_no_truncation(decimal_value.precision(),
+ decimals, unsigned_flag);
maybe_null= 0;
DBUG_VOID_RETURN;
}
@@ -2775,8 +2782,8 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
CHARSET_INFO *tocs= thd->variables.collation_connection;
uint32 dummy_offset;
- value.cs_info.character_set_of_placeholder=
- value.cs_info.character_set_client= fromcs;
+ value.cs_info.character_set_of_placeholder= fromcs;
+ value.cs_info.character_set_client= thd->variables.character_set_client;
/*
Setup source and destination character sets so that they
are different only if conversion is necessary: this will
@@ -2801,8 +2808,9 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
my_decimal2decimal(ent_value, &decimal_value);
state= DECIMAL_VALUE;
decimals= ent_value->frac;
- max_length= my_decimal_precision_to_length(ent_value->precision(),
- decimals, unsigned_flag);
+ max_length=
+ my_decimal_precision_to_length_no_truncation(ent_value->precision(),
+ decimals, unsigned_flag);
item_type= Item::DECIMAL_ITEM;
break;
}
@@ -4410,16 +4418,22 @@ mark_non_agg_field:
Fields from outer selects added to the aggregate function
outer_fields list as its unknown at the moment whether it's
aggregated or not.
+ We're using either the select lex of the cached table (if present)
+ or the field's resolution context. context->select_lex is
+ safe for use because it's either the SELECT we want to use
+ (the current level) or a stub added by non-SELECT queries.
*/
+ SELECT_LEX *select_lex= cached_table ?
+ cached_table->select_lex : context->select_lex;
if (!thd->lex->in_sum_func)
- cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
+ select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
else
{
if (outer_fixed)
thd->lex->in_sum_func->outer_fields.push_back(this);
else if (thd->lex->in_sum_func->nest_level !=
thd->lex->current_select->nest_level)
- cached_table->select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
+ select_lex->full_group_by_flag|= NON_AGG_FIELD_USED;
}
}
return FALSE;
@@ -7294,8 +7308,9 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
int item_prec = max(prev_decimal_int_part, item_int_part) + decimals;
int precision= min(item_prec, DECIMAL_MAX_PRECISION);
unsigned_flag&= item->unsigned_flag;
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision,
+ decimals,
+ unsigned_flag);
}
switch (Field::result_merge_type(fld_type))
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 6f3bdd18ba5..1ff9ca6a419 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2760,8 +2760,9 @@ void Item_func_case::fix_length_and_dec()
agg_num_lengths(args[i + 1]);
if (else_expr_num != -1)
agg_num_lengths(args[else_expr_num]);
- max_length= my_decimal_precision_to_length(max_length + decimals, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(max_length +
+ decimals, decimals,
+ unsigned_flag);
}
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index da0cb7840df..0af3c4954cd 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -452,11 +452,45 @@ Field *Item_func::tmp_table_field(TABLE *table)
return make_string_field(table);
break;
case DECIMAL_RESULT:
- field= new Field_new_decimal(my_decimal_precision_to_length(decimal_precision(),
- decimals,
- unsigned_flag),
- maybe_null, name, decimals, unsigned_flag);
+ {
+ uint8 dec= decimals;
+ uint8 intg= decimal_precision() - dec;
+ uint32 len= max_length;
+
+ /*
+ Trying to put too many digits overall in a DECIMAL(prec,dec)
+ will always throw a warning. We must limit dec to
+ DECIMAL_MAX_SCALE however to prevent an assert() later.
+ */
+
+ if (dec > 0)
+ {
+ int overflow;
+
+ dec= min(dec, DECIMAL_MAX_SCALE);
+
+ /*
+ If the value still overflows the field with the corrected dec,
+ we'll throw out decimals rather than integers. This is still
+ bad and of course throws a truncation warning.
+ */
+
+ const int required_length=
+ my_decimal_precision_to_length(intg + dec, dec,
+ unsigned_flag);
+
+ overflow= required_length - len;
+
+ if (overflow > 0)
+ dec= max(0, dec - overflow); // too long, discard fract
+ else
+ /* Corrected value fits. */
+ len= required_length;
+ }
+
+ field= new Field_new_decimal(len, maybe_null, name, dec, unsigned_flag);
break;
+ }
case ROW_RESULT:
default:
// This case should never be chosen
@@ -545,8 +579,8 @@ void Item_func::count_decimal_length()
set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
}
int precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+ unsigned_flag);
}
@@ -1141,16 +1175,15 @@ void Item_func_additive_op::result_precision()
decimals= max(args[0]->decimals, args[1]->decimals);
int arg1_int= args[0]->decimal_precision() - args[0]->decimals;
int arg2_int= args[1]->decimal_precision() - args[1]->decimals;
- int est_prec= max(arg1_int, arg2_int) + 1 + decimals;
- int precision= min(est_prec, DECIMAL_MAX_PRECISION);
+ int precision= max(arg1_int, arg2_int) + 1 + decimals;
/* Integer operations keep unsigned_flag if one of arguments is unsigned */
if (result_type() == INT_RESULT)
unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
else
unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+ unsigned_flag);
}
@@ -1255,7 +1288,8 @@ void Item_func_mul::result_precision()
decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
uint est_prec = args[0]->decimal_precision() + args[1]->decimal_precision();
uint precision= min(est_prec, DECIMAL_MAX_PRECISION);
- max_length= my_decimal_precision_to_length(precision, decimals,unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+ unsigned_flag);
}
@@ -1311,8 +1345,8 @@ void Item_func_div::result_precision()
else
unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision, decimals,
+ unsigned_flag);
}
@@ -1999,8 +2033,9 @@ void Item_func_round::fix_length_and_dec()
precision-= decimals_delta - length_increase;
decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision,
+ decimals,
+ unsigned_flag);
break;
}
default:
@@ -2243,8 +2278,9 @@ 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(max_int_part+decimals, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(max_int_part +
+ decimals, decimals,
+ unsigned_flag);
cached_field_type= agg_field_type(args, arg_count);
}
diff --git a/sql/item_func.h b/sql/item_func.h
index 67049af81a2..514f93a39ea 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -378,7 +378,8 @@ public:
Item_decimal_typecast(Item *a, int len, int dec) :Item_func(a)
{
decimals= dec;
- max_length= my_decimal_precision_to_length(len, dec, unsigned_flag);
+ max_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 24a92c78e9c..a34204b7181 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -416,7 +416,10 @@ String *Item_func_spatial_collection::val_str(String *str)
else
{
enum Geometry::wkbType wkb_type;
- const char *data= res->ptr() + 4/*SRID*/ + 1;
+ const uint data_offset= 4/*SRID*/ + 1;
+ if (res->length() < data_offset + sizeof(uint32))
+ goto err;
+ const char *data= res->ptr() + data_offset;
/*
In the case of named collection we must check that items
@@ -439,7 +442,7 @@ String *Item_func_spatial_collection::val_str(String *str)
break;
case Geometry::wkb_linestring:
- if (str->append(data, POINT_DATA_SIZE, 512))
+ if (len < POINT_DATA_SIZE || str->append(data, POINT_DATA_SIZE, 512))
goto err;
break;
case Geometry::wkb_polygon:
@@ -448,11 +451,15 @@ String *Item_func_spatial_collection::val_str(String *str)
double x1, y1, x2, y2;
const char *org_data= data;
- if (len < 4 + 2 * POINT_DATA_SIZE)
+ if (len < 4)
goto err;
n_points= uint4korr(data);
data+= 4;
+
+ if (n_points < 2 || len < 4 + n_points * POINT_DATA_SIZE)
+ goto err;
+
float8get(x1, data);
data+= SIZEOF_STORED_DOUBLE;
float8get(y1, data);
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 2d580e4d9a8..be94f19f597 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2710,13 +2710,12 @@ String *Item_func_conv_charset::val_str(String *str)
return null_value ? 0 : &str_value;
/*
Here we don't pass 'str' as a parameter to args[0]->val_str()
- as 'str' may points to 'str_value' (e.g. see Item::save_in_field()),
+ as 'str' may point to 'str_value' (e.g. see Item::save_in_field()),
which we use below to convert string.
Use argument's 'str_value' instead.
*/
- String *arg= args[0]->val_str(&args[0]->str_value);;
+ String *arg= args[0]->val_str(&args[0]->str_value);
uint dummy_errors;
- arg= args[0]->val_str(&args[0]->str_value);
if (!arg)
{
null_value=1;
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 759a53c3c5e..46a58351872 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -798,8 +798,9 @@ void Item_sum_sum::fix_length_and_dec()
{
/* SUM result can't be longer than length(arg) + length(MAX_ROWS) */
int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS;
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision,
+ decimals,
+ unsigned_flag);
curr_dec_buff= 0;
hybrid_type= DECIMAL_RESULT;
my_decimal_set_zero(dec_buffs);
@@ -1233,8 +1234,9 @@ void Item_sum_avg::fix_length_and_dec()
{
int precision= args[0]->decimal_precision() + prec_increment;
decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision,
+ decimals,
+ unsigned_flag);
f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
f_scale= args[0]->decimals;
dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
@@ -1439,8 +1441,9 @@ void Item_sum_variance::fix_length_and_dec()
{
int precision= args[0]->decimal_precision()*2 + prec_increment;
decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
- max_length= my_decimal_precision_to_length(precision, decimals,
- unsigned_flag);
+ max_length= my_decimal_precision_to_length_no_truncation(precision,
+ decimals,
+ unsigned_flag);
break;
}
diff --git a/sql/log.cc b/sql/log.cc
index ee7ee48b42c..8bb6ba8e9c6 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -153,7 +153,8 @@ private:
class binlog_trx_data {
public:
binlog_trx_data()
- : at_least_one_stmt(0), m_pending(0), before_stmt_pos(MY_OFF_T_UNDEF)
+ : at_least_one_stmt(0), incident(FALSE), m_pending(0),
+ before_stmt_pos(MY_OFF_T_UNDEF)
{
trans_log.end_of_file= max_binlog_cache_size;
}
@@ -184,6 +185,7 @@ public:
delete pending();
set_pending(0);
reinit_io_cache(&trans_log, WRITE_CACHE, pos, 0, 0);
+ trans_log.end_of_file= max_binlog_cache_size;
if (pos < before_stmt_pos)
before_stmt_pos= MY_OFF_T_UNDEF;
@@ -206,6 +208,7 @@ public:
if (!empty())
truncate(0);
before_stmt_pos= MY_OFF_T_UNDEF;
+ incident= FALSE;
trans_log.end_of_file= max_binlog_cache_size;
DBUG_ASSERT(empty());
}
@@ -222,11 +225,22 @@ public:
IO_CACHE trans_log; // The transaction cache
+ void set_incident(void)
+ {
+ incident= TRUE;
+ }
+
+ bool has_incident(void)
+ {
+ return(incident);
+ }
+
/**
Boolean that is true if there is at least one statement in the
transaction cache.
*/
bool at_least_one_stmt;
+ bool incident;
private:
/*
@@ -942,7 +956,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
bool error= FALSE;
Log_event_handler **current_handler;
bool is_command= FALSE;
- char user_host_buff[MAX_USER_HOST_SIZE];
+ char user_host_buff[MAX_USER_HOST_SIZE + 1];
Security_context *sctx= thd->security_ctx;
uint user_host_len= 0;
ulonglong query_utime, lock_utime;
@@ -1008,7 +1022,7 @@ bool LOGGER::general_log_write(THD *thd, enum enum_server_command command,
{
bool error= FALSE;
Log_event_handler **current_handler= general_log_handler_list;
- char user_host_buff[MAX_USER_HOST_SIZE];
+ char user_host_buff[MAX_USER_HOST_SIZE + 1];
Security_context *sctx= thd->security_ctx;
ulong id;
uint user_host_len= 0;
@@ -1391,7 +1405,8 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data,
*/
if (end_ev != NULL)
{
- thd->binlog_flush_pending_rows_event(TRUE);
+ if (thd->binlog_flush_pending_rows_event(TRUE))
+ DBUG_RETURN(1);
/*
Doing a commit or a rollback including non-transactional tables,
i.e., ending a transaction where we might write the transaction
@@ -1402,7 +1417,8 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data,
were, we would have to ensure that we're not ending a statement
inside a stored function.
*/
- error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev);
+ error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev,
+ trx_data->has_incident());
trx_data->reset();
/*
@@ -1428,7 +1444,11 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data,
*/
thd->binlog_remove_pending_rows_event(TRUE);
if (all || !(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT)))
+ {
+ if (trx_data->has_incident())
+ mysql_bin_log.write_incident(thd, TRUE);
trx_data->reset();
+ }
else // ...statement
trx_data->truncate(trx_data->before_stmt_pos);
@@ -1544,9 +1564,11 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
YESNO(all),
YESNO(thd->transaction.all.modified_non_trans_table),
YESNO(thd->transaction.stmt.modified_non_trans_table)));
- if (all && thd->transaction.all.modified_non_trans_table ||
- !all && thd->transaction.stmt.modified_non_trans_table ||
- (thd->options & OPTION_KEEP_LOG))
+ if ((all && thd->transaction.all.modified_non_trans_table) ||
+ (!all && thd->transaction.stmt.modified_non_trans_table &&
+ !mysql_bin_log.check_write_error(thd)) ||
+ ((thd->options & OPTION_KEEP_LOG) &&
+ !mysql_bin_log.check_write_error(thd)))
{
/*
We write the transaction cache with a rollback last if we have
@@ -1559,14 +1581,22 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, TRUE, 0);
error= binlog_end_trans(thd, trx_data, &qev, all);
}
- else if (all && !thd->transaction.all.modified_non_trans_table ||
- !all && !thd->transaction.stmt.modified_non_trans_table)
+ else
{
/*
- If we have modified only transactional tables, we can truncate
- the transaction cache without writing anything to the binary
- log.
+ We reach this point if either only transactional tables were modified or
+ the effect of a statement that did not get into the binlog needs to be
+ rolled back. In the latter case, if a statement changed non-transactional
+ tables or had the OPTION_KEEP_LOG associated, we write an incident event
+ to the binlog in order to stop slaves and notify users that some changes
+ on the master did not get into the binlog and slaves will be inconsistent.
+ On the other hand, if a statement is transactional, we just safely roll it
+ back.
*/
+ if ((thd->transaction.stmt.modified_non_trans_table ||
+ (thd->options & OPTION_KEEP_LOG)) &&
+ mysql_bin_log.check_write_error(thd))
+ trx_data->set_incident();
error= binlog_end_trans(thd, trx_data, 0, all);
}
if (!all)
@@ -1574,6 +1604,44 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
DBUG_RETURN(error);
}
+void MYSQL_BIN_LOG::set_write_error(THD *thd)
+{
+ DBUG_ENTER("MYSQL_BIN_LOG::set_write_error");
+
+ write_error= 1;
+
+ if (check_write_error(thd))
+ DBUG_VOID_RETURN;
+
+ if (my_errno == EFBIG)
+ my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(MY_WME));
+ else
+ my_error(ER_ERROR_ON_WRITE, MYF(MY_WME), name, errno);
+
+ DBUG_VOID_RETURN;
+}
+
+bool MYSQL_BIN_LOG::check_write_error(THD *thd)
+{
+ DBUG_ENTER("MYSQL_BIN_LOG::check_write_error");
+
+ bool checked= FALSE;
+
+ if (!thd->is_error())
+ DBUG_RETURN(checked);
+
+ switch (thd->main_da.sql_errno())
+ {
+ case ER_TRANS_CACHE_FULL:
+ case ER_ERROR_ON_WRITE:
+ case ER_BINLOG_LOGGING_IMPOSSIBLE:
+ checked= TRUE;
+ break;
+ }
+
+ DBUG_RETURN(checked);
+}
+
/**
@note
How do we handle this (unlikely but legal) case:
@@ -3854,6 +3922,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
if (pending->write(file))
{
pthread_mutex_unlock(&LOCK_log);
+ set_write_error(thd);
DBUG_RETURN(1);
}
@@ -3928,7 +3997,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
*/
bool const end_stmt=
thd->prelocked_mode && thd->lex->requires_prelocking();
- thd->binlog_flush_pending_rows_event(end_stmt);
+ if (thd->binlog_flush_pending_rows_event(end_stmt))
+ DBUG_RETURN(error);
pthread_mutex_lock(&LOCK_log);
@@ -3979,8 +4049,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
DBUG_PRINT("info", ("Using trans_log: cache: %d, trans_log_pos: %lu",
event_info->get_cache_stmt(),
(ulong) trans_log_pos));
- if (trans_log_pos == 0)
- thd->binlog_start_trans_and_stmt();
+ thd->binlog_start_trans_and_stmt();
file= trans_log;
}
/*
@@ -4058,7 +4127,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
Write the SQL command
*/
- if (event_info->write(file))
+ if (event_info->write(file) ||
+ DBUG_EVALUATE_IF("injecting_fault_writing", 1, 0))
goto err;
if (file == &log_file) // we are writing to the real log (disk)
@@ -4072,13 +4142,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
err:
if (error)
- {
- if (my_errno == EFBIG)
- my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(0));
- else
- my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno);
- write_error=1;
- }
+ set_write_error(thd);
}
if (event_info->flags & LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F)
@@ -4359,6 +4423,29 @@ int query_error_code(THD *thd, bool not_killed)
return error;
}
+bool MYSQL_BIN_LOG::write_incident(THD *thd, bool lock)
+{
+ uint error= 0;
+ DBUG_ENTER("MYSQL_BIN_LOG::write_incident");
+ LEX_STRING const write_error_msg=
+ { C_STRING_WITH_LEN("error writing to the binary log") };
+ Incident incident= INCIDENT_LOST_EVENTS;
+ Incident_log_event ev(thd, incident, write_error_msg);
+ if (lock)
+ pthread_mutex_lock(&LOCK_log);
+ ev.write(&log_file);
+ if (lock)
+ {
+ if (!error && !(error= flush_and_sync()))
+ {
+ signal_update();
+ rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
+ }
+ pthread_mutex_unlock(&LOCK_log);
+ }
+ DBUG_RETURN(error);
+}
+
/**
Write a cached log entry to the binary log.
- To support transaction over replication, we wrap the transaction
@@ -4371,6 +4458,9 @@ int query_error_code(THD *thd, bool not_killed)
@param cache The cache to copy to the binlog
@param commit_event The commit event to print after writing the
contents of the cache.
+ @param incident Defines if an incident event should be created to
+ notify that some non-transactional changes did
+ not get into the binlog.
@note
We only come here if there is something in the cache.
@@ -4380,7 +4470,8 @@ int query_error_code(THD *thd, bool not_killed)
'cache' needs to be reinitialized after this functions returns.
*/
-bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
+bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event,
+ bool incident)
{
DBUG_ENTER("MYSQL_BIN_LOG::write(THD *, IO_CACHE *, Log_event *)");
VOID(pthread_mutex_lock(&LOCK_log));
@@ -4429,6 +4520,10 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
if (commit_event && commit_event->write(&log_file))
goto err;
+
+ if (incident && write_incident(thd, FALSE))
+ goto err;
+
if (flush_and_sync())
goto err;
DBUG_EXECUTE_IF("half_binlogged_transaction", abort(););
diff --git a/sql/log.h b/sql/log.h
index d71dcc3173d..d306d6f7182 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -356,9 +356,12 @@ public:
void new_file();
bool write(Log_event* event_info); // binary log write
- bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
+ bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident);
+ bool write_incident(THD *thd, bool lock);
int write_cache(IO_CACHE *cache, bool lock_log, bool flush_and_sync);
+ void set_write_error(THD *thd);
+ bool check_write_error(THD *thd);
void start_union_events(THD *thd, query_id_t query_id_param);
void stop_union_events(THD *thd);
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 7dd05c3f703..5f77ab3dcc4 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -369,6 +369,34 @@ int convert_handler_error(int error, THD* thd, TABLE *table)
return (actual_error);
}
+inline bool concurrency_error_code(int error)
+{
+ switch (error)
+ {
+ case ER_LOCK_WAIT_TIMEOUT:
+ case ER_LOCK_DEADLOCK:
+ case ER_XA_RBDEADLOCK:
+ return TRUE;
+ default:
+ return (FALSE);
+ }
+}
+
+inline bool unexpected_error_code(int unexpected_error)
+{
+ switch (unexpected_error)
+ {
+ case ER_NET_READ_ERROR:
+ case ER_NET_ERROR_ON_WRITE:
+ case ER_QUERY_INTERRUPTED:
+ case ER_SERVER_SHUTDOWN:
+ case ER_NEW_ABORTING_CONNECTION:
+ return(TRUE);
+ default:
+ return(FALSE);
+ }
+}
+
/*
pretty_print_str()
*/
@@ -3006,7 +3034,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli,
DBUG_PRINT("query",("%s",thd->query));
if (ignored_error_code((expected_error= error_code)) ||
- !check_expected_error(thd,rli,expected_error))
+ !unexpected_error_code(expected_error))
{
if (flags2_inited)
/*
@@ -3138,8 +3166,8 @@ compare_errors:
actual_error= thd->is_error() ? thd->main_da.sql_errno() : 0;
DBUG_PRINT("info",("expected_error: %d sql_errno: %d",
expected_error, actual_error));
- if ((expected_error != actual_error) &&
- expected_error &&
+ if ((expected_error && expected_error != actual_error &&
+ !concurrency_error_code(expected_error)) &&
!ignored_error_code(actual_error) &&
!ignored_error_code(expected_error))
{
@@ -3158,7 +3186,8 @@ Default database: '%s'. Query: '%s'",
/*
If we get the same error code as expected, or they should be ignored.
*/
- else if (expected_error == actual_error ||
+ else if ((expected_error == actual_error &&
+ !concurrency_error_code(expected_error)) ||
ignored_error_code(actual_error))
{
DBUG_PRINT("info",("error ignored"));
@@ -3330,8 +3359,8 @@ void Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
my_b_printf(&cache," at startup");
my_b_printf(&cache, "\n");
if (flags & LOG_EVENT_BINLOG_IN_USE_F)
- my_b_printf(&cache, "# Warning: this binlog was not closed properly. "
- "Most probably mysqld crashed writing it.\n");
+ my_b_printf(&cache, "# Warning: this binlog is either in use or was not "
+ "closed properly.\n");
}
if (!is_artificial_event() && created)
{
@@ -4352,7 +4381,7 @@ void Load_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info,
{
if (i)
my_b_printf(&cache, ",");
- my_b_printf(&cache, field);
+ my_b_printf(&cache, "%s", field);
field += field_lens[i] + 1;
}
@@ -6680,7 +6709,7 @@ void Execute_load_query_log_event::print(FILE* file,
{
my_b_write(&cache, (uchar*) query, fn_pos_start);
my_b_printf(&cache, " LOCAL INFILE \'");
- my_b_printf(&cache, local_fname);
+ my_b_printf(&cache, "%s", local_fname);
my_b_printf(&cache, "\'");
if (dup_handling == LOAD_DUP_REPLACE)
my_b_printf(&cache, " REPLACE");
diff --git a/sql/log_event.h b/sql/log_event.h
index 617db8c44fc..8202dddcc76 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -676,6 +676,7 @@ typedef struct st_print_event_info
#ifdef MYSQL_CLIENT
uint verbose;
table_mapping m_table_map;
+ table_mapping m_table_map_ignored;
#endif
/*
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index 0e79f70ab4e..21669e82c44 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -183,6 +183,19 @@ inline uint my_decimal_length_to_precision(uint length, uint scale,
(unsigned_flag || !length ? 0:1));
}
+inline uint32 my_decimal_precision_to_length_no_truncation(uint precision,
+ uint8 scale,
+ bool unsigned_flag)
+{
+ /*
+ When precision is 0 it means that original length was also 0. Thus
+ unsigned_flag is ignored in this case.
+ */
+ DBUG_ASSERT(precision || !scale);
+ return (uint32)(precision + (scale > 0 ? 1 : 0) +
+ (unsigned_flag || !precision ? 0 : 1));
+}
+
inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale,
bool unsigned_flag)
{
@@ -192,8 +205,8 @@ inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale,
*/
DBUG_ASSERT(precision || !scale);
set_if_smaller(precision, DECIMAL_MAX_PRECISION);
- return (uint32)(precision + (scale>0 ? 1:0) +
- (unsigned_flag || !precision ? 0:1));
+ return my_decimal_precision_to_length_no_truncation(precision, scale,
+ unsigned_flag);
}
inline
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 239fff01071..f7ee7b025f9 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -983,6 +983,7 @@ static void close_connections(void)
}
(void) pthread_mutex_unlock(&LOCK_thread_count);
+ close_active_mi();
DBUG_PRINT("quit",("close_connections thread"));
DBUG_VOID_RETURN;
}
@@ -1664,7 +1665,6 @@ static void network_init(void)
opt_enable_named_pipe)
{
- pipe_name[sizeof(pipe_name)-1]= 0; /* Safety if too long string */
strxnmov(pipe_name, sizeof(pipe_name)-1, "\\\\.\\pipe\\",
mysqld_unix_port, NullS);
bzero((char*) &saPipeSecurity, sizeof(saPipeSecurity));
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index f2dbeba1bbf..3d65fa1de31 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -231,7 +231,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
including dir name, file name itself, and an extension,
and with unpack_filename() executed over it.
*/
- path_end= strxnmov(path, FN_REFLEN, file_name->str, NullS) - path;
+ path_end= strxnmov(path, sizeof(path) - 1, file_name->str, NullS) - path;
}
// temporary file name
@@ -314,7 +314,7 @@ my_bool rename_in_schema_file(THD *thd,
const char *schema, const char *old_name,
const char *new_db, const char *new_name)
{
- char old_path[FN_REFLEN], new_path[FN_REFLEN], arc_path[FN_REFLEN];
+ char old_path[FN_REFLEN + 1], new_path[FN_REFLEN + 1], arc_path[FN_REFLEN + 1];
build_table_filename(old_path, sizeof(old_path) - 1,
schema, old_name, reg_ext, 0);
diff --git a/sql/rpl_reporting.cc b/sql/rpl_reporting.cc
index 28f257790c7..a09140de3c4 100644
--- a/sql/rpl_reporting.cc
+++ b/sql/rpl_reporting.cc
@@ -13,6 +13,7 @@ Slave_reporting_capability::report(loglevel level, int err_code,
va_list args;
va_start(args, msg);
+ pthread_mutex_lock(&err_lock);
switch (level)
{
case ERROR_LEVEL:
@@ -38,6 +39,7 @@ Slave_reporting_capability::report(loglevel level, int err_code,
my_vsnprintf(pbuff, pbuffsize, msg, args);
+ pthread_mutex_unlock(&err_lock);
va_end(args);
/* If the msg string ends with '.', do not add a ',' it would be ugly */
@@ -46,3 +48,8 @@ Slave_reporting_capability::report(loglevel level, int err_code,
(pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
err_code);
}
+
+Slave_reporting_capability::~Slave_reporting_capability()
+{
+ pthread_mutex_destroy(&err_lock);
+}
diff --git a/sql/rpl_reporting.h b/sql/rpl_reporting.h
index 2e3fa3cea83..ce33407e516 100644
--- a/sql/rpl_reporting.h
+++ b/sql/rpl_reporting.h
@@ -16,6 +16,8 @@
class Slave_reporting_capability
{
public:
+ /** lock used to synchronize m_last_error on 'SHOW SLAVE STATUS' **/
+ mutable pthread_mutex_t err_lock;
/**
Constructor.
@@ -24,6 +26,7 @@ public:
Slave_reporting_capability(char const *thread_name)
: m_thread_name(thread_name)
{
+ pthread_mutex_init(&err_lock, MY_MUTEX_INIT_FAST);
}
/**
@@ -44,7 +47,9 @@ public:
STATUS</code>.
*/
void clear_error() {
+ pthread_mutex_lock(&err_lock);
m_last_error.clear();
+ pthread_mutex_unlock(&err_lock);
}
/**
@@ -72,6 +77,7 @@ public:
Error const& last_error() const { return m_last_error; }
+ virtual ~Slave_reporting_capability()= 0;
private:
/**
Last error produced by the I/O or SQL thread respectively.
@@ -79,6 +85,10 @@ private:
mutable Error m_last_error;
char const *const m_thread_name;
+
+ // not implemented
+ Slave_reporting_capability(const Slave_reporting_capability& rhs);
+ Slave_reporting_capability& operator=(const Slave_reporting_capability& rhs);
};
#endif // RPL_REPORTING_H
diff --git a/sql/slave.cc b/sql/slave.cc
index ac371baf522..81be7064f89 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -668,7 +668,7 @@ static int end_slave_on_walk(Master_info* mi, uchar* /*unused*/)
/*
- Free all resources used by slave
+ Release slave threads at time of executing shutdown.
SYNOPSIS
end_slave()
@@ -694,15 +694,32 @@ void end_slave()
once multi-master code is ready.
*/
terminate_slave_threads(active_mi,SLAVE_FORCE_ALL);
+ }
+ pthread_mutex_unlock(&LOCK_active_mi);
+ DBUG_VOID_RETURN;
+}
+
+/**
+ Free all resources used by slave threads at time of executing shutdown.
+ The routine must be called after all possible users of @c active_mi
+ have left.
+
+ SYNOPSIS
+ close_active_mi()
+
+*/
+void close_active_mi()
+{
+ pthread_mutex_lock(&LOCK_active_mi);
+ if (active_mi)
+ {
end_master_info(active_mi);
delete active_mi;
active_mi= 0;
}
pthread_mutex_unlock(&LOCK_active_mi);
- DBUG_VOID_RETURN;
}
-
static bool io_slave_killed(THD* thd, Master_info* mi)
{
DBUG_ENTER("io_slave_killed");
@@ -1493,6 +1510,8 @@ bool show_master_info(THD* thd, Master_info* mi)
pthread_mutex_lock(&mi->data_lock);
pthread_mutex_lock(&mi->rli.data_lock);
+ pthread_mutex_lock(&mi->err_lock);
+ pthread_mutex_lock(&mi->rli.err_lock);
protocol->store(mi->host, &my_charset_bin);
protocol->store(mi->user, &my_charset_bin);
protocol->store((uint32) mi->port);
@@ -1592,6 +1611,8 @@ bool show_master_info(THD* thd, Master_info* mi)
// Last_SQL_Error
protocol->store(mi->rli.last_error().message, &my_charset_bin);
+ pthread_mutex_unlock(&mi->rli.err_lock);
+ pthread_mutex_unlock(&mi->err_lock);
pthread_mutex_unlock(&mi->rli.data_lock);
pthread_mutex_unlock(&mi->data_lock);
@@ -1863,25 +1884,6 @@ static ulong read_event(MYSQL* mysql, Master_info *mi, bool* suppress_warnings)
DBUG_RETURN(len - 1);
}
-
-int check_expected_error(THD* thd, Relay_log_info const *rli,
- int expected_error)
-{
- DBUG_ENTER("check_expected_error");
-
- switch (expected_error) {
- case ER_NET_READ_ERROR:
- case ER_NET_ERROR_ON_WRITE:
- case ER_QUERY_INTERRUPTED:
- case ER_SERVER_SHUTDOWN:
- case ER_NEW_ABORTING_CONNECTION:
- DBUG_RETURN(1);
- default:
- DBUG_RETURN(0);
- }
-}
-
-
/*
Check if the current error is of temporary nature of not.
Some errors are temporary in nature, such as
@@ -2397,6 +2399,7 @@ pthread_handler_t handle_slave_io(void *arg)
pthread_detach_this_thread();
thd->thread_stack= (char*) &thd; // remember where our stack is
+ mi->clear_error();
if (init_slave_thread(thd, SLAVE_THD_IO))
{
pthread_cond_broadcast(&mi->start_cond);
@@ -2511,6 +2514,7 @@ requesting master dump") ||
goto connected;
});
+ DBUG_ASSERT(mi->last_error().number == 0);
while (!io_slave_killed(thd,mi))
{
ulong event_len;
@@ -3710,6 +3714,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
if (!slave_was_killed)
{
+ mi->clear_error(); // clear possible left over reconnect error
if (reconnect)
{
if (!suppress_warnings && global_system_variables.log_warnings)
diff --git a/sql/slave.h b/sql/slave.h
index abd63315e62..a44a7eed83e 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -171,10 +171,10 @@ bool rpl_master_has_bug(const Relay_log_info *rli, uint bug_id, bool report,
bool rpl_master_erroneous_autoinc(THD* thd);
const char *print_slave_db_safe(const char *db);
-int check_expected_error(THD* thd, Relay_log_info const *rli, int error_code);
void skip_load_data_infile(NET* net);
-void end_slave(); /* clean up */
+void end_slave(); /* release slave threads */
+void close_active_mi(); /* clean up slave threads data */
void clear_until_condition(Relay_log_info* rli);
void clear_slave_error(Relay_log_info* rli);
void end_relay_log_info(Relay_log_info* rli);
diff --git a/sql/spatial.h b/sql/spatial.h
index dbf5da6665b..86c2ed8c197 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -116,12 +116,12 @@ struct MBR
int touches(const MBR *mbr)
{
/* The following should be safe, even if we compare doubles */
- return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) &&
- (((mbr->ymin >= ymin) && (mbr->ymin <= ymax)) ||
- ((mbr->ymax >= ymin) && (mbr->ymax <= ymax)))) ||
- (((mbr->ymin == ymax) || (mbr->ymax == ymin)) &&
- (((mbr->xmin >= xmin) && (mbr->xmin <= xmax)) ||
- ((mbr->xmax >= xmin) && (mbr->xmax <= xmax)))));
+ return ((mbr->xmin == xmax || mbr->xmax == xmin) &&
+ ((mbr->ymin >= ymin && mbr->ymin <= ymax) ||
+ (mbr->ymax >= ymin && mbr->ymax <= ymax))) ||
+ ((mbr->ymin == ymax || mbr->ymax == ymin) &&
+ ((mbr->xmin >= xmin && mbr->xmin <= xmax) ||
+ (mbr->xmax >= xmin && mbr->xmax <= xmax)));
}
int within(const MBR *mbr)
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 79fc5d816fd..ab18a2d1d04 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1192,12 +1192,12 @@ static void acl_update_user(const char *user, const char *host,
for (uint i=0 ; i < acl_users.elements ; i++)
{
ACL_USER *acl_user=dynamic_element(&acl_users,i,ACL_USER*);
- if (!acl_user->user && !user[0] ||
- acl_user->user && !strcmp(user,acl_user->user))
+ if ((!acl_user->user && !user[0]) ||
+ (acl_user->user && !strcmp(user,acl_user->user)))
{
- if (!acl_user->host.hostname && !host[0] ||
- acl_user->host.hostname &&
- !my_strcasecmp(system_charset_info, host, acl_user->host.hostname))
+ if ((!acl_user->host.hostname && !host[0]) ||
+ (acl_user->host.hostname &&
+ !my_strcasecmp(system_charset_info, host, acl_user->host.hostname)))
{
acl_user->access=privileges;
if (mqh->specified_limits & USER_RESOURCES::QUERIES_PER_HOUR)
@@ -1275,16 +1275,16 @@ static void acl_update_db(const char *user, const char *host, const char *db,
for (uint i=0 ; i < acl_dbs.elements ; i++)
{
ACL_DB *acl_db=dynamic_element(&acl_dbs,i,ACL_DB*);
- if (!acl_db->user && !user[0] ||
- acl_db->user &&
- !strcmp(user,acl_db->user))
+ if ((!acl_db->user && !user[0]) ||
+ (acl_db->user &&
+ !strcmp(user,acl_db->user)))
{
- if (!acl_db->host.hostname && !host[0] ||
- acl_db->host.hostname &&
- !strcmp(host, acl_db->host.hostname))
+ if ((!acl_db->host.hostname && !host[0]) ||
+ (acl_db->host.hostname &&
+ !strcmp(host, acl_db->host.hostname)))
{
- if (!acl_db->db && !db[0] ||
- acl_db->db && !strcmp(db,acl_db->db))
+ if ((!acl_db->db && !db[0]) ||
+ (acl_db->db && !strcmp(db,acl_db->db)))
{
if (privileges)
acl_db->access=privileges;
@@ -1493,8 +1493,8 @@ bool acl_check_host(const char *host, const char *ip)
return 0;
VOID(pthread_mutex_lock(&acl_cache->lock));
- if (host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host)) ||
- ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip)))
+ if ((host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host))) ||
+ (ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip))))
{
VOID(pthread_mutex_unlock(&acl_cache->lock));
return 0; // Found host
@@ -1711,8 +1711,8 @@ find_acl_user(const char *host, const char *user, my_bool exact)
host,
acl_user->host.hostname ? acl_user->host.hostname :
""));
- if (!acl_user->user && !user[0] ||
- acl_user->user && !strcmp(user,acl_user->user))
+ if ((!acl_user->user && !user[0]) ||
+ (acl_user->user && !strcmp(user,acl_user->user)))
{
if (exact ? !my_strcasecmp(system_charset_info, host,
acl_user->host.hostname ?
@@ -2995,8 +2995,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
{
if (!(rights & CREATE_ACL))
{
- char buf[FN_REFLEN];
- build_table_filename(buf, sizeof(buf), table_list->db,
+ char buf[FN_REFLEN + 1];
+ build_table_filename(buf, sizeof(buf) - 1, table_list->db,
table_list->table_name, reg_ext, 0);
fn_format(buf, buf, "", "", MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS |
MY_RETURN_REAL_PATH | MY_APPEND_EXT);
@@ -5319,16 +5319,13 @@ static int handle_grant_struct(uint struct_no, bool drop,
uint elements;
const char *user;
const char *host;
- ACL_USER *acl_user;
- ACL_DB *acl_db;
- GRANT_NAME *grant_name;
+ ACL_USER *acl_user= NULL;
+ ACL_DB *acl_db= NULL;
+ GRANT_NAME *grant_name= NULL;
DBUG_ENTER("handle_grant_struct");
DBUG_PRINT("info",("scan struct: %u search: '%s'@'%s'",
struct_no, user_from->user.str, user_from->host.str));
- LINT_INIT(acl_user);
- LINT_INIT(acl_db);
- LINT_INIT(grant_name);
LINT_INIT(user);
LINT_INIT(host);
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 9ca6e0a0a2b..d273b3319ee 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -246,7 +246,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len)
}
DBUG_RETURN(0);
}
- for (str++; *(end - 1) == '0'; end--); // jump over zeros at the end
+ for (str++; *(end - 1) == '0'; end--) ; // jump over zeros at the end
if (str == end) // number was something like '123.000'
{
char *endpos= (char*) str;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index de93c6609f7..88e1620b152 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -473,13 +473,14 @@ static TABLE_SHARE
@todo Rework alternative ways to deal with ER_NO_SUCH TABLE.
*/
- if (share || thd->is_error() && thd->main_da.sql_errno() != ER_NO_SUCH_TABLE)
+ if (share || (thd->is_error() && thd->main_da.sql_errno() != ER_NO_SUCH_TABLE))
DBUG_RETURN(share);
/* Table didn't exist. Check if some engine can provide it */
- if ((tmp= ha_create_table_from_engine(thd, table_list->db,
- table_list->table_name)) < 0)
+ tmp= ha_create_table_from_engine(thd, table_list->db,
+ table_list->table_name);
+ if (tmp < 0)
{
/*
No such table in any engine.
@@ -1431,11 +1432,10 @@ static inline uint tmpkeyval(THD *thd, TABLE *table)
void close_temporary_tables(THD *thd)
{
TABLE *table;
- TABLE *next;
+ TABLE *next= NULL;
TABLE *prev_table;
/* Assume thd->options has OPTION_QUOTE_SHOW_CREATE */
bool was_quote_show= TRUE;
- LINT_INIT(next);
if (!thd->temporary_tables)
return;
@@ -2432,7 +2432,7 @@ bool lock_table_name_if_not_cached(THD *thd, const char *db,
bool check_if_table_exists(THD *thd, TABLE_LIST *table, bool *exists)
{
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
int rc;
DBUG_ENTER("check_if_table_exists");
@@ -2617,8 +2617,8 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
distance > 0 - we have lock mode higher then we require
distance == 0 - we have lock mode exactly which we need
*/
- if (best_distance < 0 && distance > best_distance ||
- distance >= 0 && distance < best_distance)
+ if ((best_distance < 0 && distance > best_distance) ||
+ (distance >= 0 && distance < best_distance))
{
best_distance= distance;
best_table= table;
@@ -2649,7 +2649,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
real fix will be made after definition cache will be made)
*/
{
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
enum legacy_db_type not_used;
build_table_filename(path, sizeof(path) - 1,
table_list->db, table_list->table_name, reg_ext, 0);
@@ -2963,6 +2963,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table->insert_values= 0;
table->fulltext_searched= 0;
table->file->ft_handler= 0;
+ table->reginfo.impossible_range= 0;
/* Catch wrong handling of the auto_increment_field_not_null. */
DBUG_ASSERT(!table->auto_increment_field_not_null);
table->auto_increment_field_not_null= FALSE;
@@ -6340,7 +6341,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
(report_error == REPORT_ALL_ERRORS ||
report_error == REPORT_EXCEPT_NON_UNIQUE))
{
- char buff[NAME_LEN*2+1];
+ char buff[NAME_LEN*2 + 2];
if (db && db[0])
{
strxnmov(buff,sizeof(buff)-1,db,".",table_name,NullS);
@@ -6413,8 +6414,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
(and not an item that happens to have a name).
*/
bool is_ref_by_name= 0;
- uint unaliased_counter;
- LINT_INIT(unaliased_counter); // Dependent on found_unaliased
+ uint unaliased_counter= 0;
*resolution= NOT_RESOLVED;
@@ -7439,7 +7439,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array,
thd->lex->current_select->cur_pos_in_select_list= 0;
while ((item= it++))
{
- if (!item->fixed && item->fix_fields(thd, it.ref()) ||
+ if ((!item->fixed && item->fix_fields(thd, it.ref())) ||
(item= *(it.ref()))->check_cols(1))
{
thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
@@ -7753,8 +7753,8 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
DBUG_ASSERT(tables->is_leaf_for_name_resolution());
- if (table_name && my_strcasecmp(table_alias_charset, table_name,
- tables->alias) ||
+ if ((table_name && my_strcasecmp(table_alias_charset, table_name,
+ tables->alias)) ||
(db_name && strcmp(tables->db,db_name)))
continue;
@@ -7785,8 +7785,8 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
information_schema table, or a nested table reference. See the comment
for TABLE_LIST.
*/
- if (!(table && !tables->view && (table->grant.privilege & SELECT_ACL) ||
- tables->view && (tables->grant.privilege & SELECT_ACL)) &&
+ if (!((table && !tables->view && (table->grant.privilege & SELECT_ACL)) ||
+ (tables->view && (tables->grant.privilege & SELECT_ACL))) &&
!any_privileges)
{
field_iterator.set(tables);
@@ -7840,7 +7840,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
*/
if (any_privileges)
{
- DBUG_ASSERT(tables->field_translation == NULL && table ||
+ DBUG_ASSERT((tables->field_translation == NULL && table) ||
tables->is_natural_join);
DBUG_ASSERT(item->type() == Item::FIELD_ITEM);
Item_field *fld= (Item_field*) item;
@@ -7979,7 +7979,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
if (*conds)
{
thd->where="where clause";
- if (!(*conds)->fixed && (*conds)->fix_fields(thd, conds) ||
+ if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) ||
(*conds)->check_cols(1))
goto err_no_arena;
}
@@ -7999,8 +7999,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
{
/* Make a join an a expression */
thd->where="on clause";
- if (!embedded->on_expr->fixed &&
- embedded->on_expr->fix_fields(thd, &embedded->on_expr) ||
+ if ((!embedded->on_expr->fixed &&
+ embedded->on_expr->fix_fields(thd, &embedded->on_expr)) ||
embedded->on_expr->check_cols(1))
goto err_no_arena;
select_lex->cond_count++;
@@ -8155,8 +8155,8 @@ fill_record_n_invoke_before_triggers(THD *thd, List<Item> &fields,
enum trg_event_type event)
{
return (fill_record(thd, fields, values, ignore_errors) ||
- triggers && triggers->process_triggers(thd, event,
- TRG_ACTION_BEFORE, TRUE));
+ (triggers && triggers->process_triggers(thd, event,
+ TRG_ACTION_BEFORE, TRUE)));
}
@@ -8250,8 +8250,8 @@ fill_record_n_invoke_before_triggers(THD *thd, Field **ptr,
enum trg_event_type event)
{
return (fill_record(thd, ptr, values, ignore_errors) ||
- triggers && triggers->process_triggers(thd, event,
- TRG_ACTION_BEFORE, TRUE));
+ (triggers && triggers->process_triggers(thd, event,
+ TRG_ACTION_BEFORE, TRUE)));
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index f1ad410b877..48ddb42f0d8 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -27,6 +27,7 @@
#include "mysql_priv.h"
#include "rpl_rli.h"
+#include "rpl_filter.h"
#include "rpl_record.h"
#include "slave.h"
#include <my_bitmap.h>
@@ -546,6 +547,7 @@ THD::THD()
first_successful_insert_id_in_prev_stmt_for_binlog(0),
first_successful_insert_id_in_cur_stmt(0),
stmt_depends_on_first_successful_insert_id_in_prev_stmt(FALSE),
+ examined_row_count(0),
global_read_lock(0),
is_fatal_error(0),
transaction_rollback_request(0),
@@ -3683,7 +3685,8 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
we should print a warning.
*/
if (sql_log_bin_toplevel && lex->is_stmt_unsafe() &&
- variables.binlog_format == BINLOG_FORMAT_STMT)
+ variables.binlog_format == BINLOG_FORMAT_STMT &&
+ binlog_filter->db_ok(this->db))
{
/*
A warning can be elevated a error when STRICT sql mode.
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 7f77e60138b..98d17fdd318 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -537,13 +537,13 @@ err1:
bool load_db_opt_by_name(THD *thd, const char *db_name,
HA_CREATE_INFO *db_create_info)
{
- char db_opt_path[FN_REFLEN];
+ char db_opt_path[FN_REFLEN + 1];
/*
Pass an empty file name, and the database options file name as extension
to avoid table name to file name encoding.
*/
- (void) build_table_filename(db_opt_path, sizeof(db_opt_path),
+ (void) build_table_filename(db_opt_path, sizeof(db_opt_path) - 1,
db_name, "", MY_DB_OPT_FILE, 0);
return load_db_opt(thd, db_opt_path, db_create_info);
@@ -645,7 +645,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
/* Check directory */
- path_len= build_table_filename(path, sizeof(path), db, "", "", 0);
+ path_len= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
path[path_len-1]= 0; // Remove last '/' from path
if (my_stat(path,&stat_info,MYF(0)))
@@ -791,7 +791,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
We pass MY_DB_OPT_FILE as "extension" to avoid
"table name to file name" encoding.
*/
- build_table_filename(path, sizeof(path), db, "", MY_DB_OPT_FILE, 0);
+ build_table_filename(path, sizeof(path) - 1, db, "", MY_DB_OPT_FILE, 0);
if ((error=write_db_opt(thd, path, create_info)))
goto exit;
@@ -884,7 +884,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
- length= build_table_filename(path, sizeof(path), db, "", "", 0);
+ length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
strmov(path+length, MY_DB_OPT_FILE); // Append db option file name
del_dbopt(path); // Remove dboption hash entry
path[length]= '\0'; // Remove file name
@@ -1841,7 +1841,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
for (uint idx=0 ; idx < nfiles && !thd->killed ; idx++)
{
FILEINFO *file= dirp->dir_entry + idx;
- char *extension, tname[FN_REFLEN];
+ char *extension, tname[FN_REFLEN + 1];
LEX_STRING table_str;
DBUG_PRINT("info",("Examining: %s", file->name));
@@ -1930,7 +1930,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
for (uint idx=0 ; idx < nfiles ; idx++)
{
FILEINFO *file= dirp->dir_entry + idx;
- char oldname[FN_REFLEN], newname[FN_REFLEN];
+ char oldname[FN_REFLEN + 1], newname[FN_REFLEN + 1];
DBUG_PRINT("info",("Examining: %s", file->name));
/* skiping . and .. and MY_DB_OPT_FILE */
@@ -2000,10 +2000,10 @@ exit:
bool check_db_dir_existence(const char *db_name)
{
- char db_dir_path[FN_REFLEN];
+ char db_dir_path[FN_REFLEN + 1];
uint db_dir_path_len;
- db_dir_path_len= build_table_filename(db_dir_path, sizeof(db_dir_path),
+ db_dir_path_len= build_table_filename(db_dir_path, sizeof(db_dir_path) - 1,
db_name, "", "", 0);
if (db_dir_path_len && db_dir_path[db_dir_path_len - 1] == FN_LIBCHAR)
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 277269f3b0d..677098d275a 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -408,7 +408,7 @@ cleanup:
thd->query, thd->query_length,
is_trans, FALSE, errcode);
- if (log_result && transactional_table)
+ if (log_result)
{
error=1;
}
@@ -806,7 +806,7 @@ void multi_delete::abort()
/* the error was handled or nothing deleted and no side effects return */
if (error_handled ||
- !thd->transaction.stmt.modified_non_trans_table && !deleted)
+ (!thd->transaction.stmt.modified_non_trans_table && !deleted))
DBUG_VOID_RETURN;
/* Something already deleted so we have to invalidate cache */
@@ -1051,7 +1051,7 @@ static bool mysql_truncate_by_delete(THD *thd, TABLE_LIST *table_list)
bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
{
HA_CREATE_INFO create_info;
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
TABLE *table;
bool error;
uint path_length;
@@ -1088,7 +1088,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
goto end;
}
- path_length= build_table_filename(path, sizeof(path), table_list->db,
+ path_length= build_table_filename(path, sizeof(path) - 1, table_list->db,
table_list->table_name, reg_ext, 0);
if (!dont_send_ok)
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index f51ad318568..2818aa5082c 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -526,7 +526,7 @@ int send_variant_2_list(MEM_ROOT *mem_root, Protocol *protocol,
String **end= pointers + names->elements;
List_iterator<String> it(*names);
- for (pos= pointers; pos!=end; (*pos++= it++));
+ for (pos= pointers; pos!=end; (*pos++= it++)) ;
my_qsort(pointers,names->elements,sizeof(String*),string_ptr_cmp);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 9de27868d74..104c81ca984 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -301,9 +301,7 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
List<Item> &update_fields, table_map *map)
{
TABLE *table= insert_table_list->table;
- my_bool timestamp_mark;
-
- LINT_INIT(timestamp_mark);
+ my_bool timestamp_mark= 0;
if (table->timestamp_field)
{
@@ -393,7 +391,7 @@ void upgrade_lock_type(THD *thd, thr_lock_type *lock_type,
bool is_multi_insert)
{
if (duplic == DUP_UPDATE ||
- duplic == DUP_REPLACE && *lock_type == TL_WRITE_CONCURRENT_INSERT)
+ (duplic == DUP_REPLACE && *lock_type == TL_WRITE_CONCURRENT_INSERT))
{
*lock_type= TL_WRITE_DEFAULT;
return;
@@ -858,8 +856,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
*/
query_cache_invalidate3(thd, table_list, 1);
}
- if (changed && error <= 0 || thd->transaction.stmt.modified_non_trans_table
- || was_insert_delayed)
+ if ((changed && error <= 0) ||
+ thd->transaction.stmt.modified_non_trans_table ||
+ was_insert_delayed)
{
if (mysql_bin_log.is_open())
{
@@ -897,8 +896,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
if (thd->binlog_query(THD::ROW_QUERY_TYPE,
thd->query, thd->query_length,
transactional_table, FALSE,
- errcode) &&
- transactional_table)
+ errcode))
{
error=1;
}
@@ -1118,6 +1116,33 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
/*
+ Get extra info for tables we insert into
+
+ @param table table(TABLE object) we insert into,
+ might be NULL in case of view
+ @param table(TABLE_LIST object) or view we insert into
+*/
+
+static void prepare_for_positional_update(TABLE *table, TABLE_LIST *tables)
+{
+ if (table)
+ {
+ if(table->reginfo.lock_type != TL_WRITE_DELAYED)
+ table->prepare_for_position();
+ return;
+ }
+
+ DBUG_ASSERT(tables->view);
+ List_iterator<TABLE_LIST> it(*tables->view_tables);
+ TABLE_LIST *tbl;
+ while ((tbl= it++))
+ prepare_for_positional_update(tbl->table, tbl);
+
+ return;
+}
+
+
+/*
Prepare items in INSERT statement
SYNOPSIS
@@ -1266,9 +1291,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
Only call prepare_for_posistion() if we are not performing a DELAYED
operation. It will instead be executed by delayed insert thread.
*/
- if ((duplic == DUP_UPDATE || duplic == DUP_REPLACE) &&
- (table->reginfo.lock_type != TL_WRITE_DELAYED))
- table->prepare_for_position();
+ if (duplic == DUP_UPDATE || duplic == DUP_REPLACE)
+ prepare_for_positional_update(table, table_list);
DBUG_RETURN(FALSE);
}
@@ -3100,7 +3124,10 @@ bool select_insert::send_data(List<Item> &values)
store_values(values);
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
if (thd->is_error())
+ {
+ table->auto_increment_field_not_null= FALSE;
DBUG_RETURN(1);
+ }
if (table_list) // Not CREATE ... SELECT
{
switch (table_list->view_check_option(thd, info.ignore)) {
@@ -3186,7 +3213,8 @@ bool select_insert::send_eof()
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
- if (changed= (info.copied || info.deleted || info.updated))
+ changed= (info.copied || info.deleted || info.updated);
+ if (changed)
{
/*
We must invalidate the table in the query cache before binlog writing
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 03da3c2338a..444a8ae0736 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -780,7 +780,7 @@ bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted)
int MYSQLlex(void *arg, void *yythd)
{
- reg1 uchar c;
+ reg1 uchar c= 0;
bool comment_closed;
int tokval, result_state;
uint length;
@@ -798,7 +798,6 @@ int MYSQLlex(void *arg, void *yythd)
lip->start_token();
state=lip->next_state;
lip->next_state=MY_LEX_OPERATOR_OR_IDENT;
- LINT_INIT(c);
for (;;)
{
switch (state) {
@@ -927,7 +926,7 @@ int MYSQLlex(void *arg, void *yythd)
else
#endif
{
- for (result_state= c; ident_map[c= lip->yyGet()]; result_state|= c);
+ for (result_state= c; ident_map[c= lip->yyGet()]; result_state|= c) ;
/* If there were non-ASCII characters, mark that we must convert */
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
}
@@ -939,7 +938,7 @@ int MYSQLlex(void *arg, void *yythd)
If we find a space then this can't be an identifier. We notice this
below by checking start != lex->ptr.
*/
- for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet());
+ for (; state_map[c] == MY_LEX_SKIP ; c= lip->yyGet()) ;
}
if (start == lip->get_ptr() && c == '.' && ident_map[lip->yyPeek()])
lip->next_state=MY_LEX_IDENT_SEP;
@@ -1012,7 +1011,7 @@ int MYSQLlex(void *arg, void *yythd)
}
else if (c == 'b')
{
- while ((c= lip->yyGet()) == '0' || c == '1');
+ while ((c= lip->yyGet()) == '0' || c == '1') ;
if ((lip->yyLength() >= 3) && !ident_map[c])
{
/* Skip '0b' */
@@ -1071,7 +1070,7 @@ int MYSQLlex(void *arg, void *yythd)
else
#endif
{
- for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c);
+ for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c) ;
/* If there were non-ASCII characters, mark that we must convert */
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
}
@@ -1171,7 +1170,7 @@ int MYSQLlex(void *arg, void *yythd)
case MY_LEX_BIN_NUMBER: // Found b'bin-string'
lip->yySkip(); // Accept opening '
- while ((c= lip->yyGet()) == '0' || c == '1');
+ while ((c= lip->yyGet()) == '0' || c == '1') ;
if (c != '\'')
return(ABORT_SYM); // Illegal hex constant
lip->yySkip(); // Accept closing '
@@ -1446,7 +1445,7 @@ int MYSQLlex(void *arg, void *yythd)
[(global | local | session) .]variable_name
*/
- for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c);
+ for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c) ;
/* If there were non-ASCII characters, mark that we must convert */
result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index babd02c0008..1758a6df5f9 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -750,9 +750,9 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
real_item= item->real_item();
- if (!read_info.enclosed &&
+ if ((!read_info.enclosed &&
(enclosed_length && length == 4 &&
- !memcmp(pos, STRING_WITH_LEN("NULL"))) ||
+ !memcmp(pos, STRING_WITH_LEN("NULL")))) ||
(length == 1 && read_info.found_null))
{
@@ -1151,8 +1151,8 @@ int READ_INFO::read_field()
}
// End of enclosed field if followed by field_term or line_term
if (chr == my_b_EOF ||
- chr == line_term_char && terminator(line_term_ptr,
- line_term_length))
+ (chr == line_term_char && terminator(line_term_ptr,
+ line_term_length)))
{ // Maybe unexpected linefeed
enclosed=1;
found_end_of_line=1;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 83f44bba008..542ce992537 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1350,7 +1350,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (check_access(thd, CREATE_ACL, db.str , 0, 1, 0,
is_schema_db(db.str)))
break;
- general_log_print(thd, command, packet);
+ general_log_print(thd, command, "%.*s", db.length, db.str);
bzero(&create_info, sizeof(create_info));
mysql_create_db(thd, (lower_case_table_names == 2 ? alias.str : db.str),
&create_info, 0);
@@ -1375,7 +1375,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
break;
}
- general_log_write(thd, command, db.str, db.length);
+ general_log_write(thd, command, "%.*s", db.length, db.str);
mysql_rm_db(thd, db.str, 0, 0);
break;
}
@@ -1560,14 +1560,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
- /* If commit fails, we should be able to reset the OK status. */
- thd->main_da.can_overwrite_status= TRUE;
- ha_autocommit_or_rollback(thd, thd->is_error());
- thd->main_da.can_overwrite_status= FALSE;
-
- thd->transaction.stmt.reset();
-
-
/* report error issued during command execution */
if (thd->killed_errno())
{
@@ -1580,6 +1572,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->mysys_var->abort= 0;
}
+ /* If commit fails, we should be able to reset the OK status. */
+ thd->main_da.can_overwrite_status= TRUE;
+ ha_autocommit_or_rollback(thd, thd->is_error());
+ thd->main_da.can_overwrite_status= FALSE;
+
+ thd->transaction.stmt.reset();
+
net_end_statement(thd);
query_cache_end_of_result(thd);
@@ -5171,7 +5170,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
if (schema_db)
{
- if (!(sctx->master_access & FILE_ACL) && (want_access & FILE_ACL) ||
+ if ((!(sctx->master_access & FILE_ACL) && (want_access & FILE_ACL)) ||
(want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
{
if (!no_errors)
@@ -5205,7 +5204,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
DBUG_RETURN(FALSE);
}
if (((want_access & ~sctx->master_access) & ~(DB_ACLS | EXTRA_ACL)) ||
- ! db && dont_check_global_grants)
+ (! db && dont_check_global_grants))
{ // We can never grant this
DBUG_PRINT("error",("No possible access"));
if (!no_errors)
@@ -5483,7 +5482,7 @@ bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
if (!check_access(thd, access, table->db,
&table->grant.privilege, 0, 1,
test(table->schema_table)) &&
- !check_grant(thd, access, table, 0, 1, 1))
+ !check_grant(thd, access, table, 0, 1, 1))
DBUG_RETURN(0);
}
}
@@ -7803,7 +7802,7 @@ bool parse_sql(THD *thd,
/* Check that if MYSQLparse() failed, thd->is_error() is set. */
DBUG_ASSERT(!mysql_parse_status ||
- mysql_parse_status && thd->is_error());
+ (mysql_parse_status && thd->is_error()));
/* Reset parser state. */
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 4a50650b6f4..284eaebbe87 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -918,6 +918,9 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
Set-up the TABLE_LIST object to be a list with a single table
Set the object to zero to create NULL pointers and set alias
and real name to table name and get database name from file name.
+ TODO: Consider generalizing or refactoring Lex::add_table_to_list() so
+ it can be used in all places where we create TABLE_LIST objects.
+ Also consider creating appropriate constructors for TABLE_LIST.
*/
bzero((void*)&tables, sizeof(TABLE_LIST));
@@ -925,6 +928,13 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
tables.table= table;
tables.next_local= 0;
tables.next_name_resolution_table= 0;
+ /*
+ Cache the table in Item_fields. All the tables can be cached except
+ the trigger pseudo table.
+ */
+ tables.cacheable_table= TRUE;
+ context= thd->lex->current_context();
+ tables.select_lex= context->select_lex;
strmov(db_name_string, table->s->normalized_path.str);
dir_length= dirname_length(db_name_string);
db_name_string[dir_length - 1]= 0;
@@ -932,7 +942,6 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
db_name= &db_name_string[home_dir_length];
tables.db= db_name;
- context= thd->lex->current_context();
table->map= 1; //To ensure correct calculation of const item
table->get_fields_in_item_tree= TRUE;
save_table_list= context->table_list;
@@ -964,8 +973,9 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
save_use_only_table_context= thd->lex->use_only_table_context;
thd->lex->use_only_table_context= TRUE;
+ thd->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
- error= func_expr->fix_fields(thd, (Item**)0);
+ error= func_expr->fix_fields(thd, (Item**)&func_expr);
thd->lex->use_only_table_context= save_use_only_table_context;
@@ -5090,7 +5100,7 @@ static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
handler *file= lpt->table->file;
DBUG_ENTER("mysql_change_partitions");
- build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0);
+ build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
if ((error= file->ha_change_partitions(lpt->create_info, path, &lpt->copied,
&lpt->deleted, lpt->pack_frm_data,
lpt->pack_frm_len)))
@@ -5130,7 +5140,7 @@ static bool mysql_rename_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
int error;
DBUG_ENTER("mysql_rename_partitions");
- build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0);
+ build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
if ((error= lpt->table->file->ha_rename_partitions(path)))
{
if (error != 1)
@@ -5171,7 +5181,7 @@ static bool mysql_drop_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
int error;
DBUG_ENTER("mysql_drop_partitions");
- build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "", 0);
+ build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);
if ((error= lpt->table->file->ha_drop_partitions(path)))
{
lpt->table->file->print_error(error, MYF(0));
@@ -5516,10 +5526,10 @@ static bool write_log_drop_shadow_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
partition_info *part_info= lpt->part_info;
DDL_LOG_MEMORY_ENTRY *log_entry;
DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL;
- char shadow_path[FN_REFLEN];
+ char shadow_path[FN_REFLEN + 1];
DBUG_ENTER("write_log_drop_shadow_frm");
- build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
pthread_mutex_lock(&LOCK_gdl);
if (write_log_replace_delete_frm(lpt, 0UL, NULL,
(const char*)shadow_path, FALSE))
@@ -5559,15 +5569,15 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
partition_info *part_info= lpt->part_info;
DDL_LOG_MEMORY_ENTRY *log_entry;
DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry;
- char path[FN_REFLEN];
- char shadow_path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
+ char shadow_path[FN_REFLEN + 1];
DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry;
DBUG_ENTER("write_log_rename_frm");
part_info->first_log_entry= NULL;
- build_table_filename(path, sizeof(path), lpt->db,
+ build_table_filename(path, sizeof(path) - 1, lpt->db,
lpt->table_name, "", 0);
- build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
pthread_mutex_lock(&LOCK_gdl);
if (write_log_replace_delete_frm(lpt, 0UL, shadow_path, path, TRUE))
goto error;
@@ -5610,16 +5620,16 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
partition_info *part_info= lpt->part_info;
DDL_LOG_MEMORY_ENTRY *log_entry;
DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry;
- char tmp_path[FN_REFLEN];
- char path[FN_REFLEN];
+ char tmp_path[FN_REFLEN + 1];
+ char path[FN_REFLEN + 1];
uint next_entry= 0;
DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry;
DBUG_ENTER("write_log_drop_partition");
part_info->first_log_entry= NULL;
- build_table_filename(path, sizeof(path), lpt->db,
+ build_table_filename(path, sizeof(path) - 1, lpt->db,
lpt->table_name, "", 0);
- build_table_filename(tmp_path, sizeof(tmp_path), lpt->db,
+ build_table_filename(tmp_path, sizeof(tmp_path) - 1, lpt->db,
lpt->table_name, "#", 0);
pthread_mutex_lock(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
@@ -5669,14 +5679,14 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
partition_info *part_info= lpt->part_info;
DDL_LOG_MEMORY_ENTRY *log_entry;
DDL_LOG_MEMORY_ENTRY *exec_log_entry= NULL;
- char tmp_path[FN_REFLEN];
- char path[FN_REFLEN];
+ char tmp_path[FN_REFLEN + 1];
+ char path[FN_REFLEN + 1];
uint next_entry= 0;
DBUG_ENTER("write_log_add_change_partition");
- build_table_filename(path, sizeof(path), lpt->db,
+ build_table_filename(path, sizeof(path) - 1, lpt->db,
lpt->table_name, "", 0);
- build_table_filename(tmp_path, sizeof(tmp_path), lpt->db,
+ build_table_filename(tmp_path, sizeof(tmp_path) - 1, lpt->db,
lpt->table_name, "#", 0);
pthread_mutex_lock(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
@@ -5723,16 +5733,16 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
partition_info *part_info= lpt->part_info;
DDL_LOG_MEMORY_ENTRY *log_entry;
DDL_LOG_MEMORY_ENTRY *exec_log_entry= part_info->exec_log_entry;
- char path[FN_REFLEN];
- char shadow_path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
+ char shadow_path[FN_REFLEN + 1];
DDL_LOG_MEMORY_ENTRY *old_first_log_entry= part_info->first_log_entry;
uint next_entry= 0;
DBUG_ENTER("write_log_final_change_partition");
part_info->first_log_entry= NULL;
- build_table_filename(path, sizeof(path), lpt->db,
+ build_table_filename(path, sizeof(path) - 1, lpt->db,
lpt->table_name, "", 0);
- build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
pthread_mutex_lock(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
lpt->alter_info->flags & ALTER_REORGANIZE_PARTITION))
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 5c849d1278a..e7e821dd4ae 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1434,8 +1434,8 @@ static bool mysql_test_set_fields(Prepared_statement *stmt,
THD *thd= stmt->thd;
set_var_base *var;
- if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE) ||
- open_normal_and_derived_tables(thd, tables, 0))
+ if ((tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE))
+ || open_normal_and_derived_tables(thd, tables, 0))
goto error;
while ((var= it++))
@@ -1470,13 +1470,13 @@ static bool mysql_test_call_fields(Prepared_statement *stmt,
THD *thd= stmt->thd;
Item *item;
- if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE) ||
+ if ((tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) ||
open_normal_and_derived_tables(thd, tables, 0))
goto err;
while ((item= it++))
{
- if (!item->fixed && item->fix_fields(thd, it.ref()) ||
+ if ((!item->fixed && item->fix_fields(thd, it.ref())) ||
item->check_cols(1))
goto err;
}
@@ -2227,9 +2227,8 @@ void mysql_sql_stmt_prepare(THD *thd)
LEX_STRING *name= &lex->prepared_stmt_name;
Prepared_statement *stmt;
const char *query;
- uint query_len;
+ uint query_len= 0;
DBUG_ENTER("mysql_sql_stmt_prepare");
- LINT_INIT(query_len);
DBUG_ASSERT(thd->protocol == &thd->protocol_text);
if ((stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name)))
@@ -2846,7 +2845,7 @@ void Prepared_statement::setup_set_params()
Decide if we have to expand the query (because we must write it to logs or
because we want to look it up in the query cache) or not.
*/
- if (mysql_bin_log.is_open() && is_update_query(lex->sql_command) ||
+ if ((mysql_bin_log.is_open() && is_update_query(lex->sql_command)) ||
opt_log || opt_slow_log ||
query_cache_is_cacheable_query(lex))
{
@@ -3297,7 +3296,7 @@ Prepared_statement::reprepare()
&cur_db_changed))
return TRUE;
- error= (name.str && copy.set_name(&name) ||
+ error= ((name.str && copy.set_name(&name)) ||
copy.prepare(query, query_length) ||
validate_metadata(&copy));
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 7cc9130cc4a..0e0b8eb60b9 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -244,7 +244,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
char *new_table_alias, bool skip_error)
{
int rc= 1;
- char name[FN_REFLEN];
+ char name[FN_REFLEN + 1];
const char *new_alias, *old_alias;
frm_type_enum frm_type;
enum legacy_db_type table_type;
@@ -263,14 +263,14 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
}
DBUG_ASSERT(new_alias);
- build_table_filename(name, sizeof(name),
+ build_table_filename(name, sizeof(name) - 1,
new_db, new_alias, reg_ext, 0);
if (!access(name,F_OK))
{
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
DBUG_RETURN(1); // This can't be skipped
}
- build_table_filename(name, sizeof(name),
+ build_table_filename(name, sizeof(name) - 1,
ren_table->db, old_alias, reg_ext, 0);
frm_type= mysql_frm_type(thd, name, &table_type);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 06c6c022780..476c8aaaefb 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -147,7 +147,7 @@ static int send_file(THD *thd)
if (errmsg)
{
sql_print_error("Failed in send_file() %s", errmsg);
- DBUG_PRINT("error", (errmsg));
+ DBUG_PRINT("error", ("%s", errmsg));
}
DBUG_RETURN(error);
}
@@ -1043,6 +1043,7 @@ int reset_slave(THD *thd, Master_info* mi)
Reset errors (the idea is that we forget about the
old master).
*/
+ mi->clear_error();
mi->rli.clear_error();
mi->rli.clear_until_condition();
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 620af5a9ea7..37721660184 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1350,7 +1350,7 @@ JOIN::optimize()
join_tab[const_tables].type != JT_ALL &&
join_tab[const_tables].type != JT_FT &&
join_tab[const_tables].type != JT_REF_OR_NULL &&
- (order && simple_order || group_list && simple_group))
+ ((order && simple_order) || (group_list && simple_group)))
{
if (add_ref_to_table_cond(thd,&join_tab[const_tables])) {
DBUG_RETURN(1);
@@ -1868,9 +1868,9 @@ JOIN::exec()
like SEC_TO_TIME(SUM(...)).
*/
- if (curr_join->group_list && (!test_if_subpart(curr_join->group_list,
+ if ((curr_join->group_list && (!test_if_subpart(curr_join->group_list,
curr_join->order) ||
- curr_join->select_distinct) ||
+ curr_join->select_distinct)) ||
(curr_join->select_distinct &&
curr_join->tmp_table_param.using_indirect_summary_function))
{ /* Must copy to another table */
@@ -2344,9 +2344,10 @@ mysql_select(THD *thd, Item ***rref_pointer_array,
}
else
{
- if (err= join->prepare(rref_pointer_array, tables, wild_num,
- conds, og_num, order, group, having, proc_param,
- select_lex, unit))
+ err= join->prepare(rref_pointer_array, tables, wild_num,
+ conds, og_num, order, group, having, proc_param,
+ select_lex, unit);
+ if (err)
{
goto err;
}
@@ -2361,9 +2362,10 @@ mysql_select(THD *thd, Item ***rref_pointer_array,
DBUG_RETURN(TRUE);
thd_proc_info(thd, "init");
thd->used_tables=0; // Updated by setup_fields
- if (err= join->prepare(rref_pointer_array, tables, wild_num,
- conds, og_num, order, group, having, proc_param,
- select_lex, unit))
+ err= join->prepare(rref_pointer_array, tables, wild_num,
+ conds, og_num, order, group, having, proc_param,
+ select_lex, unit);
+ if (err)
{
goto err;
}
@@ -2430,7 +2432,6 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select,
if (select)
{
select->head=table;
- table->reginfo.impossible_range=0;
if ((error= select->test_quick_select(thd, *(key_map *)keys,(table_map) 0,
limit, 0)) == 1)
DBUG_RETURN(select->quick->records);
@@ -3841,7 +3842,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
if (use->key == prev->key && use->table == prev->table)
{
if (prev->keypart+1 < use->keypart ||
- prev->keypart == use->keypart && found_eq_constant)
+ (prev->keypart == use->keypart && found_eq_constant))
continue; /* remove */
}
else if (use->keypart != 0) // First found must be 0
@@ -5146,8 +5147,8 @@ best_extension_by_limited_search(JOIN *join,
{
if (best_record_count > current_record_count ||
best_read_time > current_read_time ||
- idx == join->const_tables && // 's' is the first table in the QEP
- s->table == join->sort_by_table)
+ (idx == join->const_tables && // 's' is the first table in the QEP
+ s->table == join->sort_by_table))
{
if (best_record_count >= current_record_count &&
best_read_time >= current_read_time &&
@@ -5273,7 +5274,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
double current_read_time=read_time+best;
if (best_record_count > current_record_count ||
best_read_time > current_read_time ||
- idx == join->const_tables && s->table == join->sort_by_table)
+ (idx == join->const_tables && s->table == join->sort_by_table))
{
if (best_record_count >= current_record_count &&
best_read_time >= current_read_time &&
@@ -6220,8 +6221,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
the index if we are using limit and this is the first table
*/
- if (cond &&
- (!tab->keys.is_subset(tab->const_keys) && i > 0) ||
+ if ((cond &&
+ !tab->keys.is_subset(tab->const_keys) && i > 0) ||
(!tab->const_keys.is_clear_all() && i == join->const_tables &&
join->unit->select_limit_cnt <
join->best_positions[i].records_read &&
@@ -7354,7 +7355,7 @@ static bool check_simple_equality(Item *left_item, Item *right_item,
left_item_equal->merge(right_item_equal);
/* Remove the merged multiple equality from the list */
List_iterator<Item_equal> li(cond_equal->current_level);
- while ((li++) != right_item_equal);
+ while ((li++) != right_item_equal) ;
li.remove();
}
}
@@ -9390,13 +9391,17 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
+1: for decimal point
*/
- overflow= my_decimal_precision_to_length(intg + dec, dec,
- item->unsigned_flag) - len;
+ const int required_length=
+ my_decimal_precision_to_length(intg + dec, dec,
+ item->unsigned_flag);
+
+ overflow= required_length - len;
if (overflow > 0)
dec= max(0, dec - overflow); // too long, discard fract
else
- len -= item->decimals - dec; // corrected value fits
+ /* Corrected value fits. */
+ len= required_length;
}
new_field= new Field_new_decimal(len, maybe_null, item->name,
@@ -10032,9 +10037,9 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
reclength=1; // Dummy select
/* Use packed rows if there is blobs or a lot of space to gain */
if (blob_count ||
- string_total_length >= STRING_TOTAL_LENGTH_TO_PACK_ROWS &&
+ (string_total_length >= STRING_TOTAL_LENGTH_TO_PACK_ROWS &&
(reclength / string_total_length <= RATIO_TO_PACK_ROWS ||
- string_total_length / string_count >= AVG_STRING_LENGTH_TO_PACK_ROWS))
+ string_total_length / string_count >= AVG_STRING_LENGTH_TO_PACK_ROWS)))
use_packed_rows= 1;
share->reclength= reclength;
@@ -10835,9 +10840,8 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
{
int rc= 0;
enum_nested_loop_state error= NESTED_LOOP_OK;
- JOIN_TAB *join_tab;
+ JOIN_TAB *join_tab= NULL;
DBUG_ENTER("do_select");
- LINT_INIT(join_tab);
join->procedure=procedure;
join->tmp_table= table; /* Save for easy recursion */
@@ -13076,9 +13080,9 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
*/
uint nr;
key_map keys;
- uint best_key_parts;
- int best_key_direction;
- ha_rows best_records;
+ uint best_key_parts= 0;
+ int best_key_direction= 0;
+ ha_rows best_records= 0;
double read_time;
int best_key= -1;
bool is_best_covering= FALSE;
@@ -13088,9 +13092,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
ha_rows table_records= table->file->stats.records;
bool group= join->group && order == join->group_list;
ha_rows ref_key_quick_rows= HA_POS_ERROR;
- LINT_INIT(best_key_parts);
- LINT_INIT(best_key_direction);
- LINT_INIT(best_records);
/*
If not used with LIMIT, only use keys if the whole query can be
@@ -13135,8 +13136,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
(direction= test_if_order_by_key(order, table, nr, &used_key_parts)))
{
bool is_covering= table->covering_keys.is_set(nr) ||
- nr == table->s->primary_key &&
- table->file->primary_key_is_clustered();
+ (nr == table->s->primary_key &&
+ table->file->primary_key_is_clustered());
/*
Don't use an index scan with ORDER BY without limit.
@@ -13149,7 +13150,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
*/
if (is_covering ||
select_limit != HA_POS_ERROR ||
- ref_key < 0 && (group || table->force_index))
+ (ref_key < 0 && (group || table->force_index)))
{
double rec_per_key;
double index_scan_time;
@@ -13215,12 +13216,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
index_scan_time= select_limit/rec_per_key *
min(rec_per_key, table->file->scan_time());
if (is_covering ||
- ref_key < 0 && (group || table->force_index) ||
+ (ref_key < 0 && (group || table->force_index)) ||
index_scan_time < read_time)
{
ha_rows quick_records= table_records;
- if (is_best_covering && !is_covering ||
- is_covering && ref_key_quick_rows < select_limit)
+ if ((is_best_covering && !is_covering) ||
+ (is_covering && ref_key_quick_rows < select_limit))
continue;
if (table->quick_keys.is_set(nr))
quick_records= table->quick_rows[nr];
@@ -13428,8 +13429,8 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
*/
if ((order != join->group_list ||
!(join->select_options & SELECT_BIG_RESULT) ||
- select && select->quick &&
- select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) &&
+ (select && select->quick &&
+ select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) &&
test_if_skip_sort_order(tab,order,select_limit,0,
is_order_by ? &table->keys_in_use_for_order_by :
&table->keys_in_use_for_group_by))
@@ -14270,8 +14271,8 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
/* Lookup the current GROUP field in the FROM clause. */
order_item_type= order_item->type();
from_field= (Field*) not_found_field;
- if (is_group_field &&
- order_item_type == Item::FIELD_ITEM ||
+ if ((is_group_field &&
+ order_item_type == Item::FIELD_ITEM) ||
order_item_type == Item::REF_ITEM)
{
from_field= find_field_in_tables(thd, (Item_ident*) order_item, tables,
@@ -14706,7 +14707,7 @@ get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables)
if (!map || (map & (RAND_TABLE_BIT | OUTER_REF_TABLE_BIT)))
DBUG_RETURN(0);
- for (; !(map & tables->table->map); tables= tables->next_leaf);
+ for (; !(map & tables->table->map); tables= tables->next_leaf) ;
if (map != tables->table->map)
DBUG_RETURN(0); // More than one table
DBUG_PRINT("exit",("sort by table: %d",tables->table->tablenr));
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index d08b3a248c4..d07e951bfd1 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -601,7 +601,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list)
if (open_normal_and_derived_tables(thd, table_list, 0))
{
if (!table_list->view ||
- thd->is_error() && thd->main_da.sql_errno() != ER_VIEW_INVALID)
+ (thd->is_error() && thd->main_da.sql_errno() != ER_VIEW_INVALID))
DBUG_RETURN(TRUE);
/*
@@ -2819,8 +2819,8 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex,
LOOKUP_FIELD_VALUES *lookup_field_vals,
bool with_i_schema, LEX_STRING *db_name)
{
- char path[FN_REFLEN];
- build_table_filename(path, sizeof(path), db_name->str, "", "", 0);
+ char path[FN_REFLEN + 1];
+ build_table_filename(path, sizeof(path) - 1, db_name->str, "", "", 0);
if (!lookup_field_vals->wild_table_value &&
lookup_field_vals->table_value.str)
{
@@ -2982,8 +2982,8 @@ static int fill_schema_table_names(THD *thd, TABLE *table,
else
{
enum legacy_db_type not_used;
- char path[FN_REFLEN];
- (void) build_table_filename(path, sizeof(path), db_name->str,
+ char path[FN_REFLEN + 1];
+ (void) build_table_filename(path, sizeof(path) - 1, db_name->str,
table_name->str, reg_ext, 0);
switch (mysql_frm_type(thd, path, &not_used)) {
case FRMTYPE_ERROR:
@@ -3238,10 +3238,10 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
if lookup value is empty string then
it's impossible table name or db name
*/
- if (lookup_field_vals.db_value.str &&
- !lookup_field_vals.db_value.str[0] ||
- lookup_field_vals.table_value.str &&
- !lookup_field_vals.table_value.str[0])
+ if ((lookup_field_vals.db_value.str &&
+ !lookup_field_vals.db_value.str[0]) ||
+ (lookup_field_vals.table_value.str &&
+ !lookup_field_vals.table_value.str[0]))
{
error= 0;
goto err;
@@ -3470,7 +3470,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
MY_STAT stat_info;
if (!lookup_field_vals.db_value.str[0])
DBUG_RETURN(0);
- path_len= build_table_filename(path, sizeof(path),
+ path_len= build_table_filename(path, sizeof(path) - 1,
lookup_field_vals.db_value.str, "", "", 0);
path[path_len-1]= 0;
if (!my_stat(path,&stat_info,MYF(0)))
@@ -4116,10 +4116,10 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
TYPE_ENUM_PROCEDURE))
return 0;
- if (lex->sql_command == SQLCOM_SHOW_STATUS_PROC &&
- proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE ||
- lex->sql_command == SQLCOM_SHOW_STATUS_FUNC &&
- proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION ||
+ if ((lex->sql_command == SQLCOM_SHOW_STATUS_PROC &&
+ proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE) ||
+ (lex->sql_command == SQLCOM_SHOW_STATUS_FUNC &&
+ proc_table->field[2]->val_int() == TYPE_ENUM_FUNCTION) ||
(sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0)
{
restore_record(table, s->default_values);
@@ -7071,6 +7071,12 @@ bool show_create_trigger(THD *thd, const sp_name *trg_name)
if (!lst)
return TRUE;
+ if (check_table_access(thd, TRIGGER_ACL, lst, 1, TRUE))
+ {
+ my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "TRIGGER");
+ return TRUE;
+ }
+
/*
Open the table by name in order to load Table_triggers_list object.
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 61731f3b984..7759985ba85 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -322,14 +322,23 @@ bool String::set_or_copy_aligned(const char *str,uint32 arg_length,
return copy_aligned(str, arg_length, offset, cs);
}
- /* Copy with charset conversion */
+
+/**
+ Copies the character data into this String, with optional character set
+ conversion.
+
+ @return
+ FALSE ok
+ TRUE Could not allocate result buffer
+
+*/
bool String::copy(const char *str, uint32 arg_length,
CHARSET_INFO *from_cs, CHARSET_INFO *to_cs, uint *errors)
{
uint32 offset;
-
- DBUG_ASSERT(str != Ptr);
+
+ DBUG_ASSERT(!str || str != Ptr);
if (!needs_conversion(arg_length, from_cs, to_cs, &offset))
{
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0fc1d04a41b..e752421223a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1515,7 +1515,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
/*
Build shadow frm file name
*/
- build_table_shadow_filename(shadow_path, sizeof(shadow_path), lpt);
+ build_table_shadow_filename(shadow_path, sizeof(shadow_path) - 1, lpt);
strxmov(shadow_frm_name, shadow_path, reg_ext, NullS);
if (flags & WFRM_WRITE_SHADOW)
{
@@ -1590,7 +1590,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
/*
Build frm file name
*/
- build_table_filename(path, sizeof(path), lpt->db,
+ build_table_filename(path, sizeof(path) - 1, lpt->db,
lpt->table_name, "", 0);
strxmov(frm_name, path, reg_ext, NullS);
/*
@@ -1792,7 +1792,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
bool dont_log_query)
{
TABLE_LIST *table;
- char path[FN_REFLEN], *alias;
+ char path[FN_REFLEN + 1], *alias;
uint path_length;
String wrong_tables;
int error= 0;
@@ -1922,13 +1922,14 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
/* remove .frm file and engine files */
- path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext,
+ path_length= build_table_filename(path, sizeof(path) - 1, db, alias,
+ reg_ext,
table->internal_tmp_table ?
FN_IS_TMP : 0);
}
if (drop_temporary ||
- (table_type == NULL &&
- (access(path, F_OK) &&
+ ((table_type == NULL &&
+ access(path, F_OK) &&
ha_create_table_from_engine(thd, db, alias)) ||
(!drop_view &&
mysql_frm_type(thd, path, &frm_db_type) != FRMTYPE_TABLE)))
@@ -2010,7 +2011,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
if (!dont_log_query)
{
if (!thd->current_stmt_binlog_row_based ||
- non_temp_tables_count > 0 && !tmp_table_deleted)
+ (non_temp_tables_count > 0 && !tmp_table_deleted))
{
/*
In this case, we are either using statement-based
@@ -2078,11 +2079,11 @@ err_with_placeholders:
bool quick_rm_table(handlerton *base,const char *db,
const char *table_name, uint flags)
{
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
bool error= 0;
DBUG_ENTER("quick_rm_table");
- uint path_length= build_table_filename(path, sizeof(path),
+ uint path_length= build_table_filename(path, sizeof(path) - 1,
db, table_name, reg_ext, flags);
if (my_delete(path,MYF(0)))
error= 1; /* purecov: inspected */
@@ -2719,8 +2720,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
/* Don't pack rows in old tables if the user has requested this */
if ((sql_field->flags & BLOB_FLAG) ||
- sql_field->sql_type == MYSQL_TYPE_VARCHAR &&
- create_info->row_type != ROW_TYPE_FIXED)
+ (sql_field->sql_type == MYSQL_TYPE_VARCHAR &&
+ create_info->row_type != ROW_TYPE_FIXED))
(*db_options)|= HA_OPTION_PACK_RECORD;
it2.rewind();
}
@@ -3189,7 +3190,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->sql_type == MYSQL_TYPE_VARCHAR ||
sql_field->pack_flag & FIELDFLAG_BLOB)))
{
- if (column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB) ||
+ if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) ||
sql_field->sql_type == MYSQL_TYPE_VARCHAR)
key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY;
else
@@ -3471,7 +3472,7 @@ bool mysql_create_table_no_lock(THD *thd,
bool internal_tmp_table,
uint select_field_count)
{
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
uint path_length;
const char *alias;
uint db_options, key_count;
@@ -3679,7 +3680,7 @@ bool mysql_create_table_no_lock(THD *thd,
}
else
{
- path_length= build_table_filename(path, sizeof(path), db, alias, reg_ext,
+ path_length= build_table_filename(path, sizeof(path) - 1, db, alias, reg_ext,
internal_tmp_table ? FN_IS_TMP : 0);
}
@@ -3993,7 +3994,8 @@ mysql_rename_table(handlerton *base, const char *old_db,
const char *new_name, uint flags)
{
THD *thd= current_thd;
- char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN];
+ char from[FN_REFLEN + 1], to[FN_REFLEN + 1],
+ lc_from[FN_REFLEN + 1], lc_to[FN_REFLEN + 1];
char *from_base= from, *to_base= to;
char tmp_name[NAME_LEN+1];
handler *file;
@@ -4005,9 +4007,9 @@ mysql_rename_table(handlerton *base, const char *old_db,
file= (base == NULL ? 0 :
get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base));
- build_table_filename(from, sizeof(from), old_db, old_name, "",
+ build_table_filename(from, sizeof(from) - 1, old_db, old_name, "",
flags & FN_FROM_IS_TMP);
- build_table_filename(to, sizeof(to), new_db, new_name, "",
+ build_table_filename(to, sizeof(to) - 1, new_db, new_name, "",
flags & FN_TO_IS_TMP);
/*
@@ -4020,13 +4022,13 @@ mysql_rename_table(handlerton *base, const char *old_db,
{
strmov(tmp_name, old_name);
my_casedn_str(files_charset_info, tmp_name);
- build_table_filename(lc_from, sizeof(lc_from), old_db, tmp_name, "",
+ build_table_filename(lc_from, sizeof(lc_from) - 1, old_db, tmp_name, "",
flags & FN_FROM_IS_TMP);
from_base= lc_from;
strmov(tmp_name, new_name);
my_casedn_str(files_charset_info, tmp_name);
- build_table_filename(lc_to, sizeof(lc_to), new_db, tmp_name, "",
+ build_table_filename(lc_to, sizeof(lc_to) - 1, new_db, tmp_name, "",
flags & FN_TO_IS_TMP);
to_base= lc_to;
}
@@ -4157,16 +4159,16 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table,
else
{
char* backup_dir= thd->lex->backup_dir;
- char src_path[FN_REFLEN], dst_path[FN_REFLEN], uname[FN_REFLEN];
+ char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1], uname[FN_REFLEN];
char* table_name= table->table_name;
char* db= table->db;
- VOID(tablename_to_filename(table->table_name, uname, sizeof(uname)));
+ VOID(tablename_to_filename(table->table_name, uname, sizeof(uname) - 1));
if (fn_format_relative_to_data_home(src_path, uname, backup_dir, reg_ext))
DBUG_RETURN(-1); // protect buffer overflow
- build_table_filename(dst_path, sizeof(dst_path),
+ build_table_filename(dst_path, sizeof(dst_path) - 1,
db, table_name, reg_ext, 0);
if (lock_and_wait_for_table_name(thd,table))
@@ -4778,7 +4780,7 @@ send_result_message:
const char *err_msg= thd->main_da.message();
if (!thd->vio_ok())
{
- sql_print_error(err_msg);
+ sql_print_error("%s", err_msg);
}
else
{
@@ -5088,7 +5090,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
HA_CREATE_INFO *create_info)
{
TABLE *name_lock= 0;
- char src_path[FN_REFLEN], dst_path[FN_REFLEN];
+ char src_path[FN_REFLEN], dst_path[FN_REFLEN + 1];
uint dst_path_length;
char *db= table->db;
char *table_name= table->table_name;
@@ -5098,7 +5100,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
#ifdef WITH_PARTITION_STORAGE_ENGINE
char tmp_path[FN_REFLEN];
#endif
- char ts_name[FN_LEN];
+ char ts_name[FN_LEN + 1];
DBUG_ENTER("mysql_create_like_table");
@@ -5147,7 +5149,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
goto err;
if (!name_lock)
goto table_exists;
- dst_path_length= build_table_filename(dst_path, sizeof(dst_path),
+ dst_path_length= build_table_filename(dst_path, sizeof(dst_path) - 1,
db, table_name, reg_ext, 0);
if (!access(dst_path, F_OK))
goto table_exists;
@@ -5589,8 +5591,8 @@ compare_tables(TABLE *table,
/* Don't pack rows in old tables if the user has requested this. */
if (create_info->row_type == ROW_TYPE_DYNAMIC ||
(tmp_new_field->flags & BLOB_FLAG) ||
- tmp_new_field->sql_type == MYSQL_TYPE_VARCHAR &&
- create_info->row_type != ROW_TYPE_FIXED)
+ (tmp_new_field->sql_type == MYSQL_TYPE_VARCHAR &&
+ create_info->row_type != ROW_TYPE_FIXED))
create_info->table_options|= HA_OPTION_PACK_RECORD;
/* Check if field was renamed */
@@ -5888,7 +5890,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY)
{
- char *tablespace= static_cast<char *>(thd->alloc(FN_LEN));
+ char *tablespace= static_cast<char *>(thd->alloc(FN_LEN + 1));
/*
Regular alter table of disk stored table (no tablespace/storage change)
Copy tablespace name
@@ -6255,10 +6257,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
TABLE *table, *new_table= 0, *name_lock= 0;
int error= 0;
- char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN];
+ char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1];
char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias;
char index_file[FN_REFLEN], data_file[FN_REFLEN];
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
char reg_path[FN_REFLEN+1];
ha_rows copied,deleted;
handlerton *old_db_type, *new_db_type, *save_old_db_type;
@@ -6271,21 +6273,15 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
#endif
bool need_lock_for_indexes= TRUE;
KEY *key_info_buffer;
- uint index_drop_count;
- uint *index_drop_buffer;
- uint index_add_count;
- uint *index_add_buffer;
- uint candidate_key_count;
+ uint index_drop_count= 0;
+ uint *index_drop_buffer= NULL;
+ uint index_add_count= 0;
+ uint *index_add_buffer= NULL;
+ uint candidate_key_count= 0;
bool committed= 0;
bool no_pk;
DBUG_ENTER("mysql_alter_table");
- LINT_INIT(index_add_count);
- LINT_INIT(index_drop_count);
- LINT_INIT(index_add_buffer);
- LINT_INIT(index_drop_buffer);
- LINT_INIT(candidate_key_count);
-
/*
Check if we attempt to alter mysql.slow_log or
mysql.general_log table and return an error if
@@ -6339,8 +6335,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
db=table_list->db;
if (!new_db || !my_strcasecmp(table_alias_charset, new_db, db))
new_db= db;
- build_table_filename(reg_path, sizeof(reg_path), db, table_name, reg_ext, 0);
- build_table_filename(path, sizeof(path), db, table_name, "", 0);
+ build_table_filename(reg_path, sizeof(reg_path) - 1, db, table_name, reg_ext, 0);
+ build_table_filename(path, sizeof(path) - 1, db, table_name, "", 0);
mysql_ha_rm_tables(thd, table_list, FALSE);
@@ -6487,7 +6483,7 @@ view_err:
DBUG_RETURN(TRUE);
}
- build_table_filename(new_name_buff, sizeof(new_name_buff),
+ build_table_filename(new_name_buff, sizeof(new_name_buff) - 1,
new_db, new_name_buff, reg_ext, 0);
if (!access(new_name_buff, F_OK))
{
@@ -6988,9 +6984,9 @@ view_err:
}
else
{
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
/* table is a normal table: Create temporary table in same directory */
- build_table_filename(path, sizeof(path), new_db, tmp_name, "",
+ build_table_filename(path, sizeof(path) - 1, new_db, tmp_name, "",
FN_IS_TMP);
/* Open our intermediate table */
new_table=open_temporary_table(thd, path, new_db, tmp_name,0);
@@ -7220,12 +7216,12 @@ view_err:
}
else if (mysql_rename_table(new_db_type, new_db, tmp_name, new_db,
new_alias, FN_FROM_IS_TMP) ||
- (new_name != table_name || new_db != db) && // we also do rename
+ ((new_name != table_name || new_db != db) && // we also do rename
(need_copy_table != ALTER_TABLE_METADATA_ONLY ||
mysql_rename_table(save_old_db_type, db, table_name, new_db,
new_alias, NO_FRM_RENAME)) &&
Table_triggers_list::change_table_name(thd, db, table_name,
- new_db, new_alias))
+ new_db, new_alias)))
{
/* Try to get everything back. */
error=1;
@@ -7318,7 +7314,7 @@ view_err:
*/
char path[FN_REFLEN];
TABLE *t_table;
- build_table_filename(path, sizeof(path), new_db, table_name, "", 0);
+ build_table_filename(path + 1, sizeof(path) - 1, new_db, table_name, "", 0);
t_table= open_temporary_table(thd, path, new_db, tmp_name, 0);
if (t_table)
{
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 8cab8fff2f3..c055268ecca 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -344,7 +344,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
need second part of condition below, since check_access() function also
checks that db is specified.
*/
- if (!thd->lex->spname->m_db.length || create && !tables->db_length)
+ if (!thd->lex->spname->m_db.length || (create && !tables->db_length))
{
my_error(ER_NO_DB_ERROR, MYF(0));
DBUG_RETURN(TRUE);
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index ab6ba2ba756..17cc683e14a 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -803,8 +803,7 @@ int mysql_update(THD *thd,
if (thd->binlog_query(THD::ROW_QUERY_TYPE,
thd->query, thd->query_length,
- transactional_table, FALSE, errcode) &&
- transactional_table)
+ transactional_table, FALSE, errcode))
{
error=1; // Rollback update
}
@@ -1814,7 +1813,7 @@ void multi_update::abort()
{
/* the error was handled or nothing deleted and no side effects return */
if (error_handled ||
- !thd->transaction.stmt.modified_non_trans_table && !updated)
+ (!thd->transaction.stmt.modified_non_trans_table && !updated))
return;
/* Something already updated so we have to invalidate cache */
@@ -2087,8 +2086,7 @@ bool multi_update::send_eof()
errcode= query_error_code(thd, killed_status == THD::NOT_KILLED);
if (thd->binlog_query(THD::ROW_QUERY_TYPE,
thd->query, thd->query_length,
- transactional_tables, FALSE, errcode) &&
- trans_safe)
+ transactional_tables, FALSE, errcode))
{
local_error= 1; // Rollback update
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index c81a3ca9aba..2a4c5c950fe 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -801,7 +801,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
char md5[MD5_BUFF_LENGTH];
bool can_be_merged;
- char dir_buff[FN_REFLEN], path_buff[FN_REFLEN];
+ char dir_buff[FN_REFLEN + 1], path_buff[FN_REFLEN + 1];
LEX_STRING dir, file, path;
int error= 0;
DBUG_ENTER("mysql_register_view");
@@ -878,11 +878,11 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
}
loop_out:
/* print file name */
- dir.length= build_table_filename(dir_buff, sizeof(dir_buff),
+ dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1,
view->db, "", "", 0);
dir.str= dir_buff;
- path.length= build_table_filename(path_buff, sizeof(path_buff),
+ path.length= build_table_filename(path_buff, sizeof(path_buff) - 1,
view->db, view->table_name, reg_ext, 0);
path.str= path_buff;
@@ -1569,7 +1569,7 @@ err:
bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
{
- char path[FN_REFLEN];
+ char path[FN_REFLEN + 1];
TABLE_LIST *view;
String non_existant_views;
char *wrong_object_db= NULL, *wrong_object_name= NULL;
@@ -1584,7 +1584,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
{
TABLE_SHARE *share;
frm_type_enum type= FRMTYPE_ERROR;
- build_table_filename(path, sizeof(path),
+ build_table_filename(path, sizeof(path) - 1,
view->db, view->table_name, reg_ext, 0);
if (access(path, F_OK) ||
@@ -1929,7 +1929,7 @@ mysql_rename_view(THD *thd,
{
LEX_STRING pathstr;
File_parser *parser;
- char path_buff[FN_REFLEN];
+ char path_buff[FN_REFLEN + 1];
bool error= TRUE;
DBUG_ENTER("mysql_rename_view");
@@ -1942,7 +1942,7 @@ mysql_rename_view(THD *thd,
is_equal(&view_type, parser->type()))
{
TABLE_LIST view_def;
- char dir_buff[FN_REFLEN];
+ char dir_buff[FN_REFLEN + 1];
LEX_STRING dir, file;
/*
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c40062e5d52..57a828a690b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -5925,7 +5925,7 @@ alter_list_item:
MYSQL_YYABORT;
}
if (check_table_name($3->table.str,$3->table.length) ||
- $3->db.str && check_db_name(&$3->db))
+ ($3->db.str && check_db_name(&$3->db)))
{
my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
MYSQL_YYABORT;
@@ -6079,8 +6079,8 @@ slave_until:
| UNTIL_SYM slave_until_opts
{
LEX *lex=Lex;
- if ((lex->mi.log_file_name || lex->mi.pos) &&
- (lex->mi.relay_log_name || lex->mi.relay_log_pos) ||
+ if (((lex->mi.log_file_name || lex->mi.pos) &&
+ (lex->mi.relay_log_name || lex->mi.relay_log_pos)) ||
!((lex->mi.log_file_name && lex->mi.pos) ||
(lex->mi.relay_log_name && lex->mi.relay_log_pos)))
{
diff --git a/sql/structs.h b/sql/structs.h
index 0a20eee0e9a..a58c18f97c5 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -107,6 +107,10 @@ typedef struct st_reginfo { /* Extra info about reg */
struct st_join_table *join_tab; /* Used by SELECT() */
enum thr_lock_type lock_type; /* How database is used */
bool not_exists_optimize;
+ /*
+ TRUE <=> range optimizer found that there is no rows satisfying
+ table conditions.
+ */
bool impossible_range;
} REGINFO;
diff --git a/sql/table.cc b/sql/table.cc
index 7e8d5ac98b4..60a27e136b1 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -464,34 +464,35 @@ inline bool is_system_table_name(const char *name, uint length)
CHARSET_INFO *ci= system_charset_info;
return (
- /* mysql.proc table */
- length == 4 &&
- my_tolower(ci, name[0]) == 'p' &&
- my_tolower(ci, name[1]) == 'r' &&
- my_tolower(ci, name[2]) == 'o' &&
- my_tolower(ci, name[3]) == 'c' ||
-
- length > 4 &&
- (
- /* one of mysql.help* tables */
- my_tolower(ci, name[0]) == 'h' &&
- my_tolower(ci, name[1]) == 'e' &&
- my_tolower(ci, name[2]) == 'l' &&
- my_tolower(ci, name[3]) == 'p' ||
-
- /* one of mysql.time_zone* tables */
- my_tolower(ci, name[0]) == 't' &&
- my_tolower(ci, name[1]) == 'i' &&
- my_tolower(ci, name[2]) == 'm' &&
- my_tolower(ci, name[3]) == 'e' ||
-
- /* mysql.event table */
- my_tolower(ci, name[0]) == 'e' &&
- my_tolower(ci, name[1]) == 'v' &&
- my_tolower(ci, name[2]) == 'e' &&
- my_tolower(ci, name[3]) == 'n' &&
- my_tolower(ci, name[4]) == 't'
- )
+ /* mysql.proc table */
+ (length == 4 &&
+ my_tolower(ci, name[0]) == 'p' &&
+ my_tolower(ci, name[1]) == 'r' &&
+ my_tolower(ci, name[2]) == 'o' &&
+ my_tolower(ci, name[3]) == 'c') ||
+
+ (length > 4 &&
+ (
+ /* one of mysql.help* tables */
+ (my_tolower(ci, name[0]) == 'h' &&
+ my_tolower(ci, name[1]) == 'e' &&
+ my_tolower(ci, name[2]) == 'l' &&
+ my_tolower(ci, name[3]) == 'p') ||
+
+ /* one of mysql.time_zone* tables */
+ (my_tolower(ci, name[0]) == 't' &&
+ my_tolower(ci, name[1]) == 'i' &&
+ my_tolower(ci, name[2]) == 'm' &&
+ my_tolower(ci, name[3]) == 'e') ||
+
+ /* mysql.event table */
+ (my_tolower(ci, name[0]) == 'e' &&
+ my_tolower(ci, name[1]) == 'v' &&
+ my_tolower(ci, name[2]) == 'e' &&
+ my_tolower(ci, name[3]) == 'n' &&
+ my_tolower(ci, name[4]) == 't')
+ )
+ )
);
}
@@ -3314,8 +3315,8 @@ bool TABLE_LIST::prep_check_option(THD *thd, uint8 check_opt_type)
{
const char *save_where= thd->where;
thd->where= "check option";
- if (!check_option->fixed &&
- check_option->fix_fields(thd, &check_option) ||
+ if ((!check_option->fixed &&
+ check_option->fix_fields(thd, &check_option)) ||
check_option->check_cols(1))
{
DBUG_RETURN(TRUE);
@@ -4031,7 +4032,7 @@ void Field_iterator_table_ref::set_field_iterator()
/* Necesary, but insufficient conditions. */
DBUG_ASSERT(table_ref->is_natural_join ||
table_ref->nested_join ||
- table_ref->join_columns &&
+ (table_ref->join_columns &&
/* This is a merge view. */
((table_ref->field_translation &&
table_ref->join_columns->elements ==
@@ -4040,7 +4041,7 @@ void Field_iterator_table_ref::set_field_iterator()
/* This is stored table or a tmptable view. */
(!table_ref->field_translation &&
table_ref->join_columns->elements ==
- table_ref->table->s->fields)));
+ table_ref->table->s->fields))));
field_it= &natural_join_it;
DBUG_PRINT("info",("field_it for '%s' is Field_iterator_natural_join",
table_ref->alias));
diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc
index 6bf43b51df0..0764fe8be33 100644
--- a/sql/thr_malloc.cc
+++ b/sql/thr_malloc.cc
@@ -21,7 +21,7 @@
extern "C" {
void sql_alloc_error_handler(void)
{
- sql_print_error(ER(ER_OUT_OF_RESOURCES));
+ sql_print_error("%s", ER(ER_OUT_OF_RESOURCES));
THD *thd= current_thd;
if (thd)
diff --git a/sql/time.cc b/sql/time.cc
index a6619cf4cee..962b65e454c 100644
--- a/sql/time.cc
+++ b/sql/time.cc
@@ -111,8 +111,8 @@ uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year)
if (l_time->month == 1 && l_time->day <= 7-weekday)
{
if (!week_year &&
- (first_weekday && weekday != 0 ||
- !first_weekday && weekday >= 4))
+ ((first_weekday && weekday != 0) ||
+ (!first_weekday && weekday >= 4)))
return 0;
week_year= 1;
(*year)--;
@@ -129,8 +129,8 @@ uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year)
if (week_year && days >= 52*7)
{
weekday= (weekday + calc_days_in_year(*year)) % 7;
- if (!first_weekday && weekday < 4 ||
- first_weekday && weekday == 0)
+ if ((!first_weekday && weekday < 4) ||
+ (first_weekday && weekday == 0))
{
(*year)++;
return 1;
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 2a94e179600..c7a4ad049ec 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -447,8 +447,8 @@ prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage)
}
if (end_t == MY_TIME_T_MAX ||
- (cur_off_and_corr > 0) &&
- (end_t >= MY_TIME_T_MAX - cur_off_and_corr))
+ ((cur_off_and_corr > 0) &&
+ (end_t >= MY_TIME_T_MAX - cur_off_and_corr)))
/* end of t space */
break;
diff --git a/sql/uniques.cc b/sql/uniques.cc
index 858bedb04cd..7b6b628f924 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -603,9 +603,9 @@ bool Unique::get(TABLE *table)
outfile=table->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE),
MYF(MY_ZEROFILL));
- if (!outfile || ! my_b_inited(outfile) &&
+ if (!outfile || (! my_b_inited(outfile) &&
open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER,
- MYF(MY_WME)))
+ MYF(MY_WME))))
return 1;
reinit_io_cache(outfile,WRITE_CACHE,0L,0,0);
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index 2fdf1bc7900..8deb8693960 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -2828,34 +2828,32 @@ int ha_federated::info(uint flag)
if (!(row= mysql_fetch_row(result)))
goto error;
- if (flag & (HA_STATUS_VARIABLE | HA_STATUS_CONST))
- {
- /*
- deleted is set in ha_federated::info
- */
- /*
- need to figure out what this means as far as federated is concerned,
- since we don't have a "file"
+ /*
+ deleted is set in ha_federated::info
+ */
+ /*
+ need to figure out what this means as far as federated is concerned,
+ since we don't have a "file"
- data_file_length = ?
- index_file_length = ?
- delete_length = ?
- */
- if (row[4] != NULL)
- stats.records= (ha_rows) my_strtoll10(row[4], (char**) 0,
+ data_file_length = ?
+ index_file_length = ?
+ delete_length = ?
+ */
+ if (row[4] != NULL)
+ stats.records= (ha_rows) my_strtoll10(row[4], (char**) 0,
&error);
- if (row[5] != NULL)
- stats.mean_rec_length= (ulong) my_strtoll10(row[5], (char**) 0, &error);
+ if (row[5] != NULL)
+ stats.mean_rec_length= (ulong) my_strtoll10(row[5], (char**) 0, &error);
- stats.data_file_length= stats.records * stats.mean_rec_length;
+ stats.data_file_length= stats.records * stats.mean_rec_length;
- if (row[12] != NULL)
- stats.update_time= (ulong) my_strtoll10(row[12], (char**) 0,
+ if (row[12] != NULL)
+ stats.update_time= (ulong) my_strtoll10(row[12], (char**) 0,
&error);
- if (row[13] != NULL)
- stats.check_time= (ulong) my_strtoll10(row[13], (char**) 0,
+ if (row[13] != NULL)
+ stats.check_time= (ulong) my_strtoll10(row[13], (char**) 0,
&error);
- }
+
/*
size of IO operations (This is based on a good guess, no high science
involved)
diff --git a/storage/ibmdb2i/db2i_charsetSupport.cc b/storage/ibmdb2i/db2i_charsetSupport.cc
index 7ff3a8c98f6..83bf1b9448b 100644
--- a/storage/ibmdb2i/db2i_charsetSupport.cc
+++ b/storage/ibmdb2i/db2i_charsetSupport.cc
@@ -384,6 +384,11 @@ static int32 convertTextDesc(const int32 inType, const int32 outType, const char
strcpy(outDesc,"IBM-1256");
DBUG_RETURN(0);
}
+ else if (strcmp("macce", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"IBM-1282");
+ DBUG_RETURN(0);
+ }
}
else if (outType == Qlg_TypeAS400CCSID)
{
diff --git a/storage/ibmdb2i/db2i_collationSupport.cc b/storage/ibmdb2i/db2i_collationSupport.cc
index a41f211a689..65a17fd2452 100644
--- a/storage/ibmdb2i/db2i_collationSupport.cc
+++ b/storage/ibmdb2i/db2i_collationSupport.cc
@@ -44,7 +44,7 @@ OF SUCH DAMAGE.
between corresponding array slots but is incomplete without case-sensitivity
markers dynamically added to the mySqlSortSequence names.
*/
-#define MAX_COLLATION 89
+#define MAX_COLLATION 87
static const char* mySQLCollation[MAX_COLLATION] =
{
{"ascii_general"},
@@ -52,7 +52,6 @@ static const char* mySQLCollation[MAX_COLLATION] =
{"big5_chinese"},
{"big5"},
{"cp1250_croatian"},
- {"cp1250_czech"},
{"cp1250_general"},
{"cp1250_polish"},
{"cp1250"},
@@ -84,7 +83,6 @@ static const char* mySQLCollation[MAX_COLLATION] =
{"latin1_swedish"},
{"latin1"},
{"latin2_croatian"},
- {"latin2_czech"},
{"latin2_general"},
{"latin2_hungarian"},
{"latin2"},
@@ -146,7 +144,6 @@ static const char* mySqlSortSequence[MAX_COLLATION] =
{"QACHT04B0"},
{"QBCHT04B0"},
{"QALA20481"},
- {"QBLA20481"},
{"QCLA20481"},
{"QDLA20481"},
{"QELA20481"},
@@ -178,7 +175,6 @@ static const char* mySqlSortSequence[MAX_COLLATION] =
{"QELA1047C"},
{"QFLA1047C"},
{"QCLA20366"},
- {"QDLA20366"},
{"QELA20366"},
{"QFLA20366"},
{"QGLA20366"},
@@ -190,8 +186,8 @@ static const char* mySqlSortSequence[MAX_COLLATION] =
{"QDJPN04B0"},
{"QATHA0346"},
{"QBTHA0346"},
- {"ACS"},
- {"ADA"},
+ {"ACS_CZ"},
+ {"ADA_DK"},
{"AEO"},
{"AET"},
{"QAUCS04B0"},
@@ -211,8 +207,8 @@ static const char* mySqlSortSequence[MAX_COLLATION] =
{"*HEX"},
{"QEJPN04B0"},
{"QFJPN04B0"},
- {"ACS"},
- {"ADA"},
+ {"ACS_CZ"},
+ {"ADA_DK"},
{"AEO"},
{"AET"},
{"QAUCS04B0"},
diff --git a/storage/ibmdb2i/db2i_conversion.cc b/storage/ibmdb2i/db2i_conversion.cc
index 0acde10a4cd..9a85eb01c9b 100644
--- a/storage/ibmdb2i/db2i_conversion.cc
+++ b/storage/ibmdb2i/db2i_conversion.cc
@@ -137,7 +137,9 @@ int ha_ibmdb2i::convertFieldChars(enum_conversionDirection direction,
char* output,
size_t ilen,
size_t olen,
- size_t* outDataLen)
+ size_t* outDataLen,
+ bool tacitErrors,
+ size_t* substChars)
{
DBUG_PRINT("ha_ibmdb2i::convertFieldChars",("Direction: %d; length = %d", direction, ilen));
@@ -157,26 +159,26 @@ int ha_ibmdb2i::convertFieldChars(enum_conversionDirection direction,
size_t initOLen= olen;
size_t substitutedChars = 0;
int rc = iconv(conversion, (char**)&input, &ilen, &output, &olen, &substitutedChars );
+ if (outDataLen) *outDataLen = initOLen - olen;
+ if (substChars) *substChars = substitutedChars;
if (unlikely(rc < 0))
{
int er = errno;
if (er == EILSEQ)
{
- getErrTxt(DB2I_ERR_ILL_CHAR, table->field[fieldID]->field_name);
+ if (!tacitErrors) getErrTxt(DB2I_ERR_ILL_CHAR, table->field[fieldID]->field_name);
return (DB2I_ERR_ILL_CHAR);
}
else
{
- getErrTxt(DB2I_ERR_ICONV,er);
+ if (!tacitErrors) getErrTxt(DB2I_ERR_ICONV,er);
return (DB2I_ERR_ICONV);
}
}
- if (unlikely(substitutedChars))
+ if (unlikely(substitutedChars) && (!tacitErrors))
{
warning(ha_thd(), DB2I_ERR_SUB_CHARS, table->field[fieldID]->field_name);
}
-
- if (outDataLen) *outDataLen = initOLen - olen;
return (0);
}
@@ -555,12 +557,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field,
return 1;
if (fieldCharSet->mbmaxlen > 1)
{
- if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+ if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
{
sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
db2Ccsid = 13488;
}
- else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+ else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
{
sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1)); // Number of bytes
@@ -584,12 +586,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field,
{
if (fieldCharSet->mbmaxlen > 1)
{
- if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+ if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
{
sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
db2Ccsid = 13488;
}
- else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+ else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
{
sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1)); // Number of bytes
@@ -611,12 +613,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field,
{
if (fieldCharSet->mbmaxlen > 1)
{
- if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+ if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
{
sprintf(stringBuildBuffer, "LONG VARGRAPHIC ");
db2Ccsid = 13488;
}
- else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+ else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
{
sprintf(stringBuildBuffer, "LONG VARCHAR ");
@@ -639,12 +641,12 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field,
if (fieldCharSet->mbmaxlen > 1)
{
- if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+ if (memcmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")-1) == 0 ) // UCS2
{
sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
db2Ccsid = 13488;
}
- else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+ else if (memcmp(fieldCharSet->name, "utf8_", sizeof("utf8_")-1) == 0 &&
strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
{
sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of bytes
@@ -671,11 +673,15 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field,
return rtnCode;
}
- // Check whether there is a character conversion available.
- iconv_t temp;
- int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp);
- if (unlikely(rc))
- return rc;
+ if (db2Ccsid != 1208 &&
+ db2Ccsid != 13488)
+ {
+ // Check whether there is a character conversion available.
+ iconv_t temp;
+ int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp);
+ if (unlikely(rc))
+ return rc;
+ }
sprintf(stringBuildBuffer, " CCSID %d ", db2Ccsid);
mapping.append(stringBuildBuffer);
diff --git a/storage/ibmdb2i/db2i_myconv.h b/storage/ibmdb2i/db2i_myconv.h
index a9e87474505..98032748148 100644
--- a/storage/ibmdb2i/db2i_myconv.h
+++ b/storage/ibmdb2i/db2i_myconv.h
@@ -220,6 +220,7 @@ INTERN size_t myconv_dmap(myconv_t cd,
} else {
*pOut=dmapS2S[*pIn];
if (*pOut == 0x00) {
+ errno=EILSEQ; /* 116 */
*outBytesLeft-=(*inBytesLeft-inLen);
*inBytesLeft=inLen;
*outBuf=pOut;
diff --git a/storage/ibmdb2i/db2i_rir.cc b/storage/ibmdb2i/db2i_rir.cc
index a80a181c9ac..091c4d98383 100644
--- a/storage/ibmdb2i/db2i_rir.cc
+++ b/storage/ibmdb2i/db2i_rir.cc
@@ -51,7 +51,6 @@ static inline int getKeyCntFromMap(key_part_map keypart_map)
return (cnt);
}
-
/**
@brief
Given a starting key and an ending key, estimate the number of rows that
@@ -270,81 +269,163 @@ ha_rows ha_ibmdb2i::records_in_range(uint inx,
DB2Field& db2Field = db2Table->db2Field(field->field_index);
litDefPtr->DataType = db2Field.getType();
/*
- Convert the literal to DB2 format.
- */
- rc = convertMySQLtoDB2(field,
- db2Field,
- literalPtr,
- (uchar*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
- if (rc != 0) break;
- litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr);
- litDefPtr->Length = db2Field.getByteLengthInRecord();
- tempLen = litDefPtr->Length;
- /*
- Do additional conversion of a character or graphic value.
- */
- CHARSET_INFO* fieldCharSet = field->charset();
+ Convert the literal to DB2 format
+ */
if ((field->type() != MYSQL_TYPE_BIT) && // Don't do conversion on BIT data
(field->charset() != &my_charset_bin) && // Don't do conversion on BINARY data
- (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR ||
- litDefPtr->DataType == QMY_GRAPHIC || litDefPtr->DataType == QMY_VARGRAPHIC))
+ (litDefPtr->DataType == QMY_CHAR ||
+ litDefPtr->DataType == QMY_VARCHAR ||
+ litDefPtr->DataType == QMY_GRAPHIC ||
+ litDefPtr->DataType == QMY_VARGRAPHIC))
{
- if (litDefPtr->DataType == QMY_VARCHAR ||
- litDefPtr->DataType == QMY_VARGRAPHIC)
- tempPtr = literalPtr + sizeof(uint16);
- else
- tempPtr = literalPtr;
- /* The following code checks to determine if MySQL is passing a
- partial key. DB2 will accept a partial field value, but only
- in the last field position of the key composite (and only if
- there is no ICU sort sequence on the index). */
- tempMinPtr = (char*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0);
- if (field->type() == MYSQL_TYPE_VARCHAR)
- {
- /* MySQL always stores key lengths as 2 bytes, little-endian. */
- tempLen = *(uint8*)tempMinPtr + ((*(uint8*)(tempMinPtr+1)) << 8);
- tempMinPtr = (char*)((char*)tempMinPtr + 2);
- }
- else
- tempLen = field->field_length;
-
- /* Determine if we are dealing with a partial key and if so, find the end of the partial key. */
- if (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR )
- { /* Char or varchar. If UTF8, no conversion is done to DB2 graphic.) */
- endOfMinPtr = (char*)memchr(tempMinPtr,field->charset()->min_sort_char,tempLen);
- if (endOfMinPtr)
- endOfLiteralPtr = tempPtr + ((uint32_t)(endOfMinPtr - tempMinPtr));
- }
- else
- {
- if (strncmp(fieldCharSet->csname, "utf8", sizeof("utf8")) == 0)
- { /* The MySQL charset is UTF8 but we are converting to graphic on DB2. Divide number of UTF8 bytes
- by 3 to get the number of characters, then multiple by 2 for double-byte graphic.*/
- endOfMinPtr = (char*)memchr(tempMinPtr,field->charset()->min_sort_char,tempLen);
- if (endOfMinPtr)
- endOfLiteralPtr = tempPtr + (((uint32_t)((endOfMinPtr - tempMinPtr)) / 3) * 2);
- }
- else
- { /* The DB2 data type is graphic or vargraphic, and we are not converting from UTF8 to graphic. */
- endOfMinPtr = (char*)wmemchr((wchar_t*)tempMinPtr,field->charset()->min_sort_char,tempLen/2);
- if (endOfMinPtr)
- endOfLiteralPtr = tempPtr + (endOfMinPtr - tempMinPtr);
+ // Most of the code is required by the considerable wrangling needed
+ // to prepare partial keys for use by DB2
+ // 1. UTF8 (CCSID 1208) data can be copied across unmodified if it is
+ // utf8_bin. Otherwise, we need to convert the min and max
+ // characters into the min and max characters employed
+ // by the DB2 sort sequence. This is complicated by the fact that
+ // the character widths are not always equal.
+ // 2. Likewise, UCS2 (CCSID 13488) data can be copied across unmodified
+ // if it is ucs2_bin or ucs2_general_ci. Otherwise, we need to
+ // convert the min and max characters into the min and max characters
+ // employed by the DB2 sort sequence.
+ // 3. All other data will use standard iconv conversions. If an
+ // unconvertible character is encountered, we assume it is the min
+ // char and fill the remainder of the DB2 key with 0s. This may not
+ // always be accurate, but it is probably sufficient for range
+ // estimations.
+ const char* keyData = minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0);
+ char* db2Data = literalPtr;
+ uint16 outLen = db2Field.getByteLengthInRecord();
+ uint16 inLen;
+ if (litDefPtr->DataType == QMY_VARCHAR ||
+ litDefPtr->DataType == QMY_VARGRAPHIC)
+ {
+ inLen = *(uint8*)keyData + ((*(uint8*)(keyData+1)) << 8);
+ keyData += 2;
+ outLen -= sizeof(uint16);
+ db2Data += sizeof(uint16);
+ }
+ else
+ {
+ inLen = field->max_display_length();
+ }
+
+ size_t convertedBytes = 0;
+ if (db2Field.getCCSID() == 1208)
+ {
+ DBUG_ASSERT(inLen <= outLen);
+ if (strcmp(field->charset()->name, "utf8_bin"))
+ {
+ const char* end = keyData+inLen;
+ const char* curKey = keyData;
+ char* curDB2 = db2Data;
+ uint32 min = field->charset()->min_sort_char;
+ while ((curKey < end) && (curDB2 < db2Data+outLen-3))
+ {
+ my_wc_t temp;
+ int len = field->charset()->cset->mb_wc(field->charset(),
+ &temp,
+ (const uchar*)curKey,
+ (const uchar*)end);
+ if (temp != min)
+ {
+ DBUG_ASSERT(len <= 3);
+ switch (len)
+ {
+ case 3: *(curDB2+2) = *(curKey+2);
+ case 2: *(curDB2+1) = *(curKey+1);
+ case 1: *(curDB2) = *(curKey);
+ }
+ curDB2 += len;
+ }
+ else
+ {
+ *(curDB2++) = 0xEF;
+ *(curDB2++) = 0xBF;
+ *(curDB2++) = 0xBF;
+ }
+ curKey += len;
+ }
+ convertedBytes = curDB2 - db2Data;
+ }
+ else
+ {
+ memcpy(db2Data, keyData, inLen);
+ convertedBytes = inLen;
+ }
+ rc = 0;
+ }
+ else if (db2Field.getCCSID() == 13488)
+ {
+ DBUG_ASSERT(inLen <= outLen);
+ if (strcmp(field->charset()->name, "ucs2_bin") &&
+ strcmp(field->charset()->name, "ucs2_general_ci"))
+ {
+ const char* end = keyData+inLen;
+ const uint16* curKey = (uint16*)keyData;
+ uint16* curDB2 = (uint16*)db2Data;
+ uint16 min = field->charset()->min_sort_char;
+ while (curKey < (uint16*)end)
+ {
+ if (*curKey != min)
+ *curDB2 = *curKey;
+ else
+ *curDB2 = 0xFFFF;
+ ++curKey;
+ ++curDB2;
}
- }
- /* Enforce here that a partial is only allowed on the last field position
- of the key composite */
- if (endOfLiteralPtr)
- {
- if ((partsInUse + 1) < minKeyCnt)
- {
- rc = HA_POS_ERROR;
- break;
- }
- endByte = endOfLiteralPtr - tempPtr;
- /* We're making an assumption that if MySQL gives us a partial key,
- the length of the partial is the same for both the min_key and max_key. */
- }
+ }
+ else
+ {
+ memcpy(db2Data, keyData, inLen);
+ }
+ convertedBytes = inLen;
+ rc = 0;
+ }
+ else
+ {
+ rc = convertFieldChars(toDB2,
+ field->field_index,
+ keyData,
+ db2Data,
+ inLen,
+ outLen,
+ &convertedBytes,
+ true);
+
+ if (rc == DB2I_ERR_ILL_CHAR)
+ {
+ // If an illegal character is encountered, we fill the remainder
+ // of the key with 0x00. This was implemented as a corollary to
+ // Bug#45012, though it should probably remain even after that
+ // bug is fixed.
+ memset(db2Data+convertedBytes, 0x00, outLen-convertedBytes);
+ convertedBytes = outLen;
+ rc = 0;
+ }
+ }
+
+ if (!rc &&
+ (litDefPtr->DataType == QMY_VARGRAPHIC ||
+ litDefPtr->DataType == QMY_VARCHAR))
+ {
+ *(uint16*)(db2Data-sizeof(uint16)) =
+ convertedBytes / (litDefPtr->DataType == QMY_VARGRAPHIC ? 2 : 1);
+ }
+
}
+ else // Non-character fields
+ {
+ rc = convertMySQLtoDB2(field,
+ db2Field,
+ literalPtr,
+ (uchar*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
+ }
+
+ if (rc != 0) break;
+ litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr);
+ litDefPtr->Length = db2Field.getByteLengthInRecord();
literalPtr = literalPtr + litDefPtr->Length; // Bump pointer for next literal
}
/* If there is a max_key value for this field, and if the max_key value is
@@ -389,28 +470,168 @@ ha_rows ha_ibmdb2i::records_in_range(uint inx,
/*
Convert the literal to DB2 format
*/
- rc = convertMySQLtoDB2(field,
- db2Field,
- literalPtr,
- (uchar*)maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
+ if ((field->type() != MYSQL_TYPE_BIT) && // Don't do conversion on BIT data
+ (field->charset() != &my_charset_bin) && // Don't do conversion on BINARY data
+ (litDefPtr->DataType == QMY_CHAR ||
+ litDefPtr->DataType == QMY_VARCHAR ||
+ litDefPtr->DataType == QMY_GRAPHIC ||
+ litDefPtr->DataType == QMY_VARGRAPHIC))
+ {
+ // We need to handle char fields in a special way in order to account
+ // for partial keys. Refer to the note above for a description of the
+ // basic design.
+ char* keyData = maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0);
+ char* db2Data = literalPtr;
+ uint16 outLen = db2Field.getByteLengthInRecord();
+ uint16 inLen;
+ if (litDefPtr->DataType == QMY_VARCHAR ||
+ litDefPtr->DataType == QMY_VARGRAPHIC)
+ {
+ inLen = *(uint8*)keyData + ((*(uint8*)(keyData+1)) << 8);
+ keyData += 2;
+ outLen -= sizeof(uint16);
+ db2Data += sizeof(uint16);
+ }
+ else
+ {
+ inLen = field->max_display_length();
+ }
+
+ size_t convertedBytes;
+ if (db2Field.getCCSID() == 1208)
+ {
+ if (strcmp(field->charset()->name, "utf8_bin"))
+ {
+ const char* end = keyData+inLen;
+ const char* curKey = keyData;
+ char* curDB2 = db2Data;
+ uint32 max = field->charset()->max_sort_char;
+ while (curKey < end && (curDB2 < db2Data+outLen-3))
+ {
+ my_wc_t temp;
+ int len = field->charset()->cset->mb_wc(field->charset(), &temp, (const uchar*)curKey, (const uchar*)end);
+ if (temp != max)
+ {
+ DBUG_ASSERT(len <= 3);
+ switch (len)
+ {
+ case 3: *(curDB2+2) = *(curKey+2);
+ case 2: *(curDB2+1) = *(curKey+1);
+ case 1: *(curDB2) = *(curKey);
+ }
+ curDB2 += len;
+ }
+ else
+ {
+ *(curDB2++) = 0xE4;
+ *(curDB2++) = 0xB6;
+ *(curDB2++) = 0xBF;
+ }
+ curKey += len;
+ }
+ convertedBytes = curDB2 - db2Data;
+ }
+ else
+ {
+ DBUG_ASSERT(inLen <= outLen);
+ memcpy(db2Data, keyData, inLen);
+ convertedBytes = inLen;
+ }
+ rc = 0;
+ }
+ else if (db2Field.getCCSID() == 13488)
+ {
+ if (strcmp(field->charset()->name, "ucs2_bin") &&
+ strcmp(field->charset()->name, "ucs2_general_ci"))
+ {
+ char* end = keyData+inLen;
+ uint16* curKey = (uint16*)keyData;
+ uint16* curDB2 = (uint16*)db2Data;
+ uint16 max = field->charset()->max_sort_char;
+ while (curKey < (uint16*)end)
+ {
+ if (*curKey != max)
+ *curDB2 = *curKey;
+ else
+ *curDB2 = 0x4DBF;
+ ++curKey;
+ ++curDB2;
+ }
+ }
+ else
+ {
+ memcpy(db2Data, keyData, outLen);
+ }
+ rc = 0;
+ }
+ else
+ {
+ size_t substituteChars = 0;
+ rc = convertFieldChars(toDB2,
+ field->field_index,
+ keyData,
+ db2Data,
+ inLen,
+ outLen,
+ &convertedBytes,
+ true,
+ &substituteChars);
+
+ if (rc == DB2I_ERR_ILL_CHAR)
+ {
+ // If an illegal character is encountered, we fill the remainder
+ // of the key with 0xFF. This was implemented to work around
+ // Bug#45012, though it should probably remain even after that
+ // bug is fixed.
+ memset(db2Data+convertedBytes, 0xFF, outLen-convertedBytes);
+ rc = 0;
+ }
+ else if ((substituteChars &&
+ (litDefPtr->DataType == QMY_VARCHAR ||
+ litDefPtr->DataType == QMY_CHAR)) ||
+ strcmp(field->charset()->name, "cp1251_bulgarian_ci") == 0)
+ {
+ // When iconv translates the max_sort_char with a substitute
+ // character, we have no way to know whether this affects
+ // the sort order of the key. Therefore, to be safe, when
+ // we know that substitute characters have been used in a
+ // single-byte string, we traverse the translated key
+ // in reverse, replacing substitue characters with 0xFF, which
+ // always sorts with the greatest weight in DB2 sort sequences.
+ // cp1251_bulgarian_ci is also handled this way because the
+ // max_sort_char is a control character which does not sort
+ // equivalently in DB2.
+ DBUG_ASSERT(inLen == outLen);
+ char* tmpKey = keyData + inLen - 1;
+ char* tmpDB2 = db2Data + outLen - 1;
+ while (*tmpKey == field->charset()->max_sort_char &&
+ *tmpDB2 != 0xFF)
+ {
+ *tmpDB2 = 0xFF;
+ --tmpKey;
+ --tmpDB2;
+ }
+ }
+ }
+
+ if (!rc &&
+ (litDefPtr->DataType == QMY_VARGRAPHIC ||
+ litDefPtr->DataType == QMY_VARCHAR))
+ {
+ *(uint16*)(db2Data-sizeof(uint16)) =
+ outLen / (litDefPtr->DataType == QMY_VARGRAPHIC ? 2 : 1);
+ }
+ }
+ else
+ {
+ rc = convertMySQLtoDB2(field,
+ db2Field,
+ literalPtr,
+ (uchar*)maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
+ }
if (rc != 0) break;
litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr);
litDefPtr->Length = db2Field.getByteLengthInRecord();
- tempLen = litDefPtr->Length;
- /*
- Now convert a character or graphic value.
- */
- if ((field->type() != MYSQL_TYPE_BIT) &&
- (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR ||
- litDefPtr->DataType == QMY_GRAPHIC || litDefPtr->DataType == QMY_VARGRAPHIC))
- {
- if (litDefPtr->DataType == QMY_VARCHAR || litDefPtr->DataType == QMY_VARGRAPHIC)
- {
- tempPtr = literalPtr + sizeof(uint16);
- }
- else
- tempPtr = literalPtr;
- }
literalPtr = literalPtr + litDefPtr->Length; // Bump pointer for next literal
}
boundsPtr->HiBound.Position = literalCnt;
diff --git a/storage/ibmdb2i/ha_ibmdb2i.h b/storage/ibmdb2i/ha_ibmdb2i.h
index 2a8d65825bf..006b6b163b8 100644
--- a/storage/ibmdb2i/ha_ibmdb2i.h
+++ b/storage/ibmdb2i/ha_ibmdb2i.h
@@ -383,7 +383,15 @@ private:
int32 prepareWriteBufferForLobs();
uint32 adjustLobBuffersForRead();
bool lobFieldsRequested();
- int convertFieldChars(enum_conversionDirection direction, uint16 fieldID, const char* input, char* output, size_t ilen, size_t olen, size_t* outDataLen);
+ int convertFieldChars(enum_conversionDirection direction,
+ uint16 fieldID,
+ const char* input,
+ char* output,
+ size_t ilen,
+ size_t olen,
+ size_t* outDataLen,
+ bool tacitErrors=FALSE,
+ size_t* substChars=NULL);
/**
Fast integer log2 function
diff --git a/storage/innobase/Makefile.am b/storage/innobase/Makefile.am
index 7410bf7e591..0143aee8e1a 100644
--- a/storage/innobase/Makefile.am
+++ b/storage/innobase/Makefile.am
@@ -50,13 +50,14 @@ noinst_HEADERS= include/btr0btr.h include/btr0btr.ic \
include/eval0eval.h include/eval0eval.ic \
include/eval0proc.h include/eval0proc.ic \
include/fil0fil.h include/fsp0fsp.h \
- include/fsp0fsp.ic include/fut0fut.h \
+ include/fsp0fsp.ic include/fsp0types.h \
+ include/fut0fut.h \
include/fut0fut.ic include/fut0lst.h \
include/fut0lst.ic include/ha0ha.h \
include/ha0ha.ic include/hash0hash.h \
include/hash0hash.ic include/ibuf0ibuf.h \
include/ibuf0ibuf.ic include/ibuf0types.h \
- include/lock0iter.h \
+ include/lock0iter.h include/fsp0types.h \
include/lock0lock.h include/lock0lock.ic \
include/lock0priv.h include/lock0priv.ic \
include/lock0types.h include/log0log.h \
diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c
index 54acdf73db6..d2a2e4d2157 100644
--- a/storage/innobase/btr/btr0cur.c
+++ b/storage/innobase/btr/btr0cur.c
@@ -23,6 +23,7 @@ Created 10/16/1994 Heikki Tuuri
#include "btr0cur.ic"
#endif
+#include "mtr0log.h"
#include "page0page.h"
#include "rem0rec.h"
#include "rem0cmp.h"
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index 82e95a2e920..17bfbeec2c1 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -15,29 +15,7 @@ Created 12/18/1995 Heikki Tuuri
#include "fut0lst.h"
#include "ut0byte.h"
#include "page0types.h"
-
-/* If records are inserted in order, there are the following
-flags to tell this (their type is made byte for the compiler
-to warn if direction and hint parameters are switched in
-fseg_alloc_free_page): */
-#define FSP_UP ((byte)111) /* alphabetically upwards */
-#define FSP_DOWN ((byte)112) /* alphabetically downwards */
-#define FSP_NO_DIR ((byte)113) /* no order */
-
-/* File space extent size in pages */
-#define FSP_EXTENT_SIZE 64
-
-/* On a page of any file segment, data may be put starting from this offset: */
-#define FSEG_PAGE_DATA FIL_PAGE_DATA
-
-/* File segment header which points to the inode describing the file segment */
-typedef byte fseg_header_t;
-
-#define FSEG_HDR_SPACE 0 /* space id of the inode */
-#define FSEG_HDR_PAGE_NO 4 /* page number of the inode */
-#define FSEG_HDR_OFFSET 8 /* byte offset of the inode */
-
-#define FSEG_HEADER_SIZE 10
+#include "fsp0types.h"
/**************************************************************************
Initializes the file space system. */
@@ -350,40 +328,6 @@ fseg_print(
fseg_header_t* header, /* in: segment header */
mtr_t* mtr); /* in: mtr */
-/* Flags for fsp_reserve_free_extents */
-#define FSP_NORMAL 1000000
-#define FSP_UNDO 2000000
-#define FSP_CLEANING 3000000
-
-/* Number of pages described in a single descriptor page: currently each page
-description takes less than 1 byte; a descriptor page is repeated every
-this many file pages */
-#define XDES_DESCRIBED_PER_PAGE UNIV_PAGE_SIZE
-
-/* The space low address page map */
-/*--------------------------------------*/
- /* The following two pages are repeated
- every XDES_DESCRIBED_PER_PAGE pages in
- every tablespace. */
-#define FSP_XDES_OFFSET 0 /* extent descriptor */
-#define FSP_IBUF_BITMAP_OFFSET 1 /* insert buffer bitmap */
- /* The ibuf bitmap pages are the ones whose
- page number is the number above plus a
- multiple of XDES_DESCRIBED_PER_PAGE */
-
-#define FSP_FIRST_INODE_PAGE_NO 2 /* in every tablespace */
- /* The following pages exist
- in the system tablespace (space 0). */
-#define FSP_IBUF_HEADER_PAGE_NO 3 /* in tablespace 0 */
-#define FSP_IBUF_TREE_ROOT_PAGE_NO 4 /* in tablespace 0 */
- /* The ibuf tree root page number in
- tablespace 0; its fseg inode is on the page
- number FSP_FIRST_INODE_PAGE_NO */
-#define FSP_TRX_SYS_PAGE_NO 5 /* in tablespace 0 */
-#define FSP_FIRST_RSEG_PAGE_NO 6 /* in tablespace 0 */
-#define FSP_DICT_HDR_PAGE_NO 7 /* in tablespace 0 */
-/*--------------------------------------*/
-
#ifndef UNIV_NONINL
#include "fsp0fsp.ic"
#endif
diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h
new file mode 100644
index 00000000000..6756d9d285c
--- /dev/null
+++ b/storage/innobase/include/fsp0types.h
@@ -0,0 +1,89 @@
+/*****************************************************************************
+
+Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+
+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; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+*****************************************************************************/
+
+/******************************************************
+File space management types
+
+Created May 26, 2009 Vasil Dimov
+*******************************************************/
+
+#ifndef fsp0types_h
+#define fsp0types_h
+
+#include "univ.i"
+
+#include "fil0fil.h" /* for FIL_PAGE_DATA */
+
+/* If records are inserted in order, there are the following
+flags to tell this (their type is made byte for the compiler
+to warn if direction and hint parameters are switched in
+fseg_alloc_free_page): */
+#define FSP_UP ((byte)111) /* alphabetically upwards */
+#define FSP_DOWN ((byte)112) /* alphabetically downwards */
+#define FSP_NO_DIR ((byte)113) /* no order */
+
+/* File space extent size in pages */
+#define FSP_EXTENT_SIZE 64
+
+/* On a page of any file segment, data may be put starting from this offset: */
+#define FSEG_PAGE_DATA FIL_PAGE_DATA
+
+/* File segment header which points to the inode describing the file segment */
+typedef byte fseg_header_t;
+
+#define FSEG_HDR_SPACE 0 /* space id of the inode */
+#define FSEG_HDR_PAGE_NO 4 /* page number of the inode */
+#define FSEG_HDR_OFFSET 8 /* byte offset of the inode */
+
+#define FSEG_HEADER_SIZE 10
+
+/* Flags for fsp_reserve_free_extents */
+#define FSP_NORMAL 1000000
+#define FSP_UNDO 2000000
+#define FSP_CLEANING 3000000
+
+/* Number of pages described in a single descriptor page: currently each page
+description takes less than 1 byte; a descriptor page is repeated every
+this many file pages */
+#define XDES_DESCRIBED_PER_PAGE UNIV_PAGE_SIZE
+
+/* The space low address page map */
+/*--------------------------------------*/
+ /* The following two pages are repeated
+ every XDES_DESCRIBED_PER_PAGE pages in
+ every tablespace. */
+#define FSP_XDES_OFFSET 0 /* extent descriptor */
+#define FSP_IBUF_BITMAP_OFFSET 1 /* insert buffer bitmap */
+ /* The ibuf bitmap pages are the ones whose
+ page number is the number above plus a
+ multiple of XDES_DESCRIBED_PER_PAGE */
+
+#define FSP_FIRST_INODE_PAGE_NO 2 /* in every tablespace */
+ /* The following pages exist
+ in the system tablespace (space 0). */
+#define FSP_IBUF_HEADER_PAGE_NO 3 /* in tablespace 0 */
+#define FSP_IBUF_TREE_ROOT_PAGE_NO 4 /* in tablespace 0 */
+ /* The ibuf tree root page number in
+ tablespace 0; its fseg inode is on the page
+ number FSP_FIRST_INODE_PAGE_NO */
+#define FSP_TRX_SYS_PAGE_NO 5 /* in tablespace 0 */
+#define FSP_FIRST_RSEG_PAGE_NO 6 /* in tablespace 0 */
+#define FSP_DICT_HDR_PAGE_NO 7 /* in tablespace 0 */
+/*--------------------------------------*/
+
+#endif /* fsp0types_h */
diff --git a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic
index 5b1d1ed34d9..1626f1e77e5 100644
--- a/storage/innobase/include/mtr0log.ic
+++ b/storage/innobase/include/mtr0log.ic
@@ -9,6 +9,8 @@ Created 12/7/1995 Heikki Tuuri
#include "mach0data.h"
#include "ut0lst.h"
#include "buf0buf.h"
+#include "fsp0types.h"
+#include "trx0sys.h"
/************************************************************
Opens a buffer to mlog. It must be closed with mlog_close. */
@@ -174,6 +176,28 @@ mlog_write_initial_log_record_fast(
space = buf_block_get_space(block);
offset = buf_block_get_page_no(block);
+ /* check whether the page is in the doublewrite buffer;
+ the doublewrite buffer is located in pages
+ FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the
+ system tablespace */
+ if (space == TRX_SYS_SPACE
+ && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) {
+ if (trx_doublewrite_buf_is_being_created) {
+ /* Do nothing: we only come to this branch in an
+ InnoDB database creation. We do not redo log
+ anything for the doublewrite buffer pages. */
+ return(log_ptr);
+ } else {
+ fprintf(stderr,
+ "Error: trying to redo log a record of type "
+ "%d on page %lu of space %lu in the "
+ "doublewrite buffer, continuing anyway.\n"
+ "Please post a bug report to "
+ "bugs.mysql.com.\n",
+ type, offset, space);
+ }
+ }
+
mach_write_to_1(log_ptr, type);
log_ptr++;
log_ptr += mach_write_compressed(log_ptr, space);
diff --git a/storage/innobase/include/trx0rseg.ic b/storage/innobase/include/trx0rseg.ic
index eb1893587a6..577cd0dee7b 100644
--- a/storage/innobase/include/trx0rseg.ic
+++ b/storage/innobase/include/trx0rseg.ic
@@ -7,6 +7,7 @@ Created 3/26/1996 Heikki Tuuri
*******************************************************/
#include "srv0srv.h"
+#include "mtr0log.h"
/**********************************************************************
Gets a rollback segment header. */
diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h
index a8da5cd51a3..bad3c9d570c 100644
--- a/storage/innobase/include/trx0sys.h
+++ b/storage/innobase/include/trx0sys.h
@@ -13,15 +13,12 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0types.h"
#include "mtr0mtr.h"
-#include "mtr0log.h"
#include "ut0byte.h"
#include "mem0mem.h"
#include "sync0sync.h"
#include "ut0lst.h"
#include "buf0buf.h"
#include "fil0fil.h"
-#include "fut0lst.h"
-#include "fsp0fsp.h"
#include "read0types.h"
/* In a MySQL replication slave, in crash recovery we store the master log
@@ -45,6 +42,8 @@ extern trx_sys_t* trx_sys;
/* Doublewrite system */
extern trx_doublewrite_t* trx_doublewrite;
+/* Set to TRUE when the doublewrite buffer is being created */
+extern ibool trx_doublewrite_buf_is_being_created;
extern ibool trx_doublewrite_must_reset_space_ids;
extern ibool trx_sys_multiple_tablespace_format;
@@ -302,6 +301,7 @@ trx_sys_print_mysql_master_log_pos(void);
/* Space id and page no where the trx system file copy resides */
#define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
+#include "fsp0fsp.h"
#define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
/* The offset of the transaction system header on the page */
diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c
index 2d9ed4fc944..6ec466cf995 100644
--- a/storage/innobase/row/row0mysql.c
+++ b/storage/innobase/row/row0mysql.c
@@ -1529,9 +1529,14 @@ row_unlock_for_mysql(
index = btr_pcur_get_btr_cur(clust_pcur)->index;
}
+ if (UNIV_UNLIKELY(!(index->type & DICT_CLUSTERED))) {
+ /* This is not a clustered index record. We
+ do not know how to unlock the record. */
+ goto no_unlock;
+ }
+
/* If the record has been modified by this
transaction, do not unlock it. */
- ut_a(index->type & DICT_CLUSTERED);
if (index->trx_id_offset) {
rec_trx_id = trx_read_trx_id(rec
@@ -1568,7 +1573,7 @@ row_unlock_for_mysql(
prebuilt->select_lock_type);
}
}
-
+no_unlock:
mtr_commit(&mtr);
}
diff --git a/storage/innobase/trx/trx0rec.c b/storage/innobase/trx/trx0rec.c
index 50f8b011463..38ad53fcfb0 100644
--- a/storage/innobase/trx/trx0rec.c
+++ b/storage/innobase/trx/trx0rec.c
@@ -23,6 +23,7 @@ Created 3/26/1996 Heikki Tuuri
#include "que0que.h"
#include "trx0purge.h"
#include "row0row.h"
+#include "mtr0log.h"
/*=========== UNDO LOG RECORD CREATION AND DECODING ====================*/
diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c
index 40348dd4199..7975950e912 100644
--- a/storage/innobase/trx/trx0sys.c
+++ b/storage/innobase/trx/trx0sys.c
@@ -25,6 +25,7 @@ Created 3/26/1996 Heikki Tuuri
/* The transaction system */
trx_sys_t* trx_sys = NULL;
trx_doublewrite_t* trx_doublewrite = NULL;
+ibool trx_doublewrite_buf_is_being_created = FALSE;
/* The following is set to TRUE when we are upgrading from the old format data
files to the new >= 4.1.x format multiple tablespaces format data files */
@@ -180,6 +181,7 @@ trx_sys_create_doublewrite_buf(void)
start_again:
mtr_start(&mtr);
+ trx_doublewrite_buf_is_being_created = TRUE;
page = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
@@ -196,6 +198,7 @@ start_again:
trx_doublewrite_init(doublewrite);
mtr_commit(&mtr);
+ trx_doublewrite_buf_is_being_created = FALSE;
} else {
fprintf(stderr,
"InnoDB: Doublewrite buffer not found:"
@@ -274,14 +277,8 @@ start_again:
buf_page_dbg_add_level(new_page, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */
- /* Make a dummy change to the page to ensure it will
- be written to disk in a flush */
-
- mlog_write_ulint(new_page + FIL_PAGE_DATA,
- TRX_SYS_DOUBLEWRITE_MAGIC_N,
- MLOG_4BYTES, &mtr);
-
if (i == FSP_EXTENT_SIZE / 2) {
+ ut_a(page_no == FSP_EXTENT_SIZE);
mlog_write_ulint(doublewrite
+ TRX_SYS_DOUBLEWRITE_BLOCK1,
page_no, MLOG_4BYTES, &mtr);
@@ -291,6 +288,7 @@ start_again:
page_no, MLOG_4BYTES, &mtr);
} else if (i == FSP_EXTENT_SIZE / 2
+ TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
+ ut_a(page_no == 2 * FSP_EXTENT_SIZE);
mlog_write_ulint(doublewrite
+ TRX_SYS_DOUBLEWRITE_BLOCK2,
page_no, MLOG_4BYTES, &mtr);
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index e27bc101ac6..efdd9c35b0a 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -95,7 +95,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
if (!thd->vio_ok())
{
- sql_print_error(msgbuf);
+ sql_print_error("%s", msgbuf);
return;
}
diff --git a/strings/decimal.c b/strings/decimal.c
index a7770fbb2e1..616d5291482 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -306,7 +306,7 @@ int decimal_actual_fraction(decimal_t *from)
{
for (i= DIG_PER_DEC1 - ((frac - 1) % DIG_PER_DEC1);
*buf0 % powers10[i++] == 0;
- frac--);
+ frac--) ;
}
return frac;
}
@@ -500,7 +500,7 @@ static void digits_bounds(decimal_t *from, int *start_result, int *end_result)
stop= (int) ((buf_end - from->buf + 1) * DIG_PER_DEC1);
i= 1;
}
- for (; *buf_end % powers10[i++] == 0; stop--);
+ for (; *buf_end % powers10[i++] == 0; stop--) ;
*end_result= stop; /* index of position after last decimal digit (from 0) */
}
@@ -1011,7 +1011,7 @@ static int ull2dec(ulonglong from, decimal_t *to)
sanity(to);
- for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE);
+ for (intg1=1; from >= DIG_BASE; intg1++, from/=DIG_BASE) ;
if (unlikely(intg1 > to->len))
{
intg1=to->len;