summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSachin Setiya <sachin.setiya@mariadb.com>2017-05-30 15:28:52 +0530
committerSachin Setiya <sachin.setiya@mariadb.com>2017-05-30 15:28:52 +0530
commit92209ac6f69974169c543ae82da077f06f2b7c71 (patch)
tree1713781010a286fa9a493781a3eb001af062fd62 /sql
parent0e3170e30d2a4e8f1ed6fd4bbe935355f7370a34 (diff)
parent725e47bfb524f4b1d29076c8777056bedd5f00ea (diff)
downloadmariadb-git-92209ac6f69974169c543ae82da077f06f2b7c71.tar.gz
Merge tag 'mariadb-10.0.31' into 10.0-galera
Signed-off-by: Sachin Setiya <sachin.setiya@mariadb.com>
Diffstat (limited to 'sql')
-rw-r--r--sql/CMakeLists.txt79
-rw-r--r--sql/discover.cc3
-rw-r--r--sql/events.cc2
-rw-r--r--sql/field.cc2
-rw-r--r--sql/filesort.cc1
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/item.cc22
-rw-r--r--sql/item.h5
-rw-r--r--sql/item_cmpfunc.cc75
-rw-r--r--sql/item_cmpfunc.h7
-rw-r--r--sql/item_func.cc3
-rw-r--r--sql/item_strfunc.cc25
-rw-r--r--sql/item_subselect.cc26
-rw-r--r--sql/item_subselect.h15
-rw-r--r--sql/item_sum.cc2
-rw-r--r--sql/item_sum.h1
-rw-r--r--sql/item_xmlfunc.cc7
-rw-r--r--sql/lock.cc3
-rw-r--r--sql/log.cc16
-rw-r--r--sql/log_event_old.cc6
-rw-r--r--sql/mysqld.cc9
-rw-r--r--sql/mysqld.h4
-rw-r--r--sql/opt_range.cc7
-rw-r--r--sql/opt_subselect.cc109
-rw-r--r--sql/opt_sum.cc12
-rw-r--r--sql/records.cc2
-rw-r--r--sql/rpl_mi.cc6
-rw-r--r--sql/rpl_parallel.cc3
-rw-r--r--sql/share/errmsg-utf8.txt2
-rw-r--r--sql/slave.cc13
-rw-r--r--sql/sp.cc4
-rw-r--r--sql/sp_head.cc3
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_audit.cc3
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_const.h1
-rw-r--r--sql/sql_digest.cc4
-rw-r--r--sql/sql_lex.cc6
-rw-r--r--sql/sql_lex.h5
-rw-r--r--sql/sql_load.cc78
-rw-r--r--sql/sql_parse.cc18
-rw-r--r--sql/sql_plugin.cc5
-rw-r--r--sql/sql_prepare.cc8
-rw-r--r--sql/sql_repl.cc6
-rw-r--r--sql/sql_select.cc43
-rw-r--r--sql/sql_show.cc5
-rw-r--r--sql/sql_table.cc18
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--sql/sys_vars.cc3
49 files changed, 514 insertions, 175 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index e917c257a07..8606fd6890d 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -173,6 +173,63 @@ ELSE()
SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})
ENDIF()
+
+IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
+
+ # mysqld.exe must to export symbols from some specific libs.
+ # These symbols are used by dynamic plugins, that "link" to mysqld.
+ #
+ # To do that, we
+ #
+ # 1. Generate mysqld_lib.def text file with all symbols from static
+ # libraries mysys, dbug, strings, sql.
+ # 2. Then we call
+ # lib.exe /DEF:mysqld_lib.def ...
+ # to create import library mysqld_lib.lib and export library mysqld_lib.exp
+ # 3. mysqld.exe links with mysqld_lib.exp (exporting symbols)
+ # 4. plugins link with mysqld_lib.lib (importing symbols)
+ #
+ # We do not not regenerate .def, .lib and .exp
+ # without necessity.E.g source modifications, that do not
+ # change list of exported symbols, will not result in a relink for plugins.
+
+ SET(MYSQLD_DEF ${CMAKE_CURRENT_BINARY_DIR}/mysqld_lib.def)
+ SET(MYSQLD_EXP ${CMAKE_CURRENT_BINARY_DIR}/mysqld_lib.exp)
+ SET(MYSQLD_LIB ${CMAKE_CURRENT_BINARY_DIR}/mysqld_lib.lib)
+ SET(MYSQLD_CORELIBS sql mysys mysys_ssl dbug strings)
+ FOREACH (CORELIB ${MYSQLD_CORELIBS})
+ GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
+ FILE(TO_NATIVE_PATH ${LOC} LOC)
+ SET (LIB_LOCATIONS ${LIB_LOCATIONS} ${LOC})
+ ENDFOREACH (CORELIB)
+
+ SET(_PLATFORM x86)
+ IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ SET(_PLATFORM x64)
+ ENDIF()
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${MYSQLD_DEF}
+ COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
+ ${_PLATFORM} /forLib ${LIB_LOCATIONS} > mysqld_lib.def.tmp
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different mysqld_lib.def.tmp mysqld_lib.def
+ COMMAND ${CMAKE_COMMAND} -E remove mysqld_lib.def.tmp
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${MYSQLD_CORELIBS}
+ )
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${MYSQLD_LIB}
+ COMMAND lib
+ ARGS /NAME:mysqld.exe "/DEF:${MYSQLD_DEF}" "/MACHINE:${_PLATFORM}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${MYSQLD_DEF}
+ )
+ ADD_CUSTOM_TARGET(gen_mysqld_lib DEPENDS ${MYSQLD_LIB})
+ ADD_LIBRARY(mysqld_import_lib UNKNOWN IMPORTED GLOBAL)
+ SET_TARGET_PROPERTIES(mysqld_import_lib PROPERTIES IMPORTED_LOCATION ${MYSQLD_LIB})
+ENDIF()
+
MYSQL_ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE} DESTINATION ${INSTALL_SBINDIR} COMPONENT Server)
IF(APPLE)
@@ -193,25 +250,9 @@ IF(NOT WITHOUT_DYNAMIC_PLUGINS)
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} -Wl,--export-all-symbols")
ENDIF()
IF(MSVC)
- # Set module definition file. Also use non-incremental linker,
- # incremental appears to crash from time to time,if used with /DEF option
- SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} /DEF:mysqld.def /INCREMENTAL:NO")
-
- FOREACH (CORELIB sql mysys mysys_ssl dbug strings)
- GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
- FILE(TO_NATIVE_PATH ${LOC} LOC)
- SET (LIB_LOCATIONS ${LIB_LOCATIONS} ${LOC})
- ENDFOREACH (CORELIB ${MYSQLD_CORE_LIBS})
- SET(_PLATFORM x86)
- IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
- SET(_PLATFORM x64)
- ENDIF()
- ADD_CUSTOM_COMMAND(TARGET mysqld PRE_LINK
- COMMAND echo ${_PLATFORM} && cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
- ${_PLATFORM} ${LIB_LOCATIONS} > mysqld.def
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- ADD_DEPENDENCIES(sql GenError)
- ENDIF(MSVC)
+ SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "${mysqld_link_flags} \"${MYSQLD_EXP}\"")
+ ADD_DEPENDENCIES(mysqld gen_mysqld_lib)
+ ENDIF()
ENDIF(NOT WITHOUT_DYNAMIC_PLUGINS)
SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
diff --git a/sql/discover.cc b/sql/discover.cc
index d8ed718fc58..d8bf6ca79c5 100644
--- a/sql/discover.cc
+++ b/sql/discover.cc
@@ -89,8 +89,7 @@ int readfrm(const char *name, const uchar **frmdata, size_t *len)
error= 0;
err:
- if (file > 0)
- (void) mysql_file_close(file, MYF(MY_WME));
+ (void) mysql_file_close(file, MYF(MY_WME));
err_end: /* Here when no file */
DBUG_RETURN (error);
diff --git a/sql/events.cc b/sql/events.cc
index 41f6aac5d64..0be9ce4e6f5 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1,5 +1,6 @@
/*
Copyright (c) 2005, 2013, Oracle and/or its affiliates.
+ Copyright (c) 2017, MariaDB Corporation.
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
@@ -242,6 +243,7 @@ common_1_lev_code:
break;
case INTERVAL_WEEK:
expr/= 7;
+ /* fall through */
default:
close_quote= FALSE;
break;
diff --git a/sql/field.cc b/sql/field.cc
index dec89e16674..7d7fad2d84d 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -9464,7 +9464,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
case MYSQL_TYPE_DATE:
/* We don't support creation of MYSQL_TYPE_DATE anymore */
sql_type= MYSQL_TYPE_NEWDATE;
- /* fall trough */
+ /* fall through */
case MYSQL_TYPE_NEWDATE:
length= MAX_DATE_WIDTH;
break;
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 73a6c89e53f..8a7d5610dc2 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -914,6 +914,7 @@ write_keys(Sort_param *param, Filesort_info *fs_info, uint count,
/* check we won't have more buffpeks than we can possibly keep in memory */
if (my_b_tell(buffpek_pointers) + sizeof(BUFFPEK) > (ulonglong)UINT_MAX)
goto err;
+ bzero(&buffpek, sizeof(buffpek));
buffpek.file_pos= my_b_tell(tempfile);
if ((ha_rows) count > param->max_rows)
count=(uint) param->max_rows; /* purecov: inspected */
diff --git a/sql/handler.cc b/sql/handler.cc
index 17122d1d1e5..91dde9a8d27 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -6044,7 +6044,7 @@ int handler::ha_external_lock(THD *thd, int lock_type)
MYSQL_TABLE_LOCK_WAIT(m_psi, PSI_TABLE_EXTERNAL_LOCK, lock_type,
{ error= external_lock(thd, lock_type); })
- if (error == 0)
+ if (error == 0 || lock_type == F_UNLCK)
{
m_lock_type= lock_type;
cached_table_flags= table_flags();
diff --git a/sql/item.cc b/sql/item.cc
index 86f1795a4da..4ce8396f71e 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2010, 2016, MariaDB
+ Copyright (c) 2010, 2017, MariaDB
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
@@ -5925,7 +5925,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
collation.collation);
break;
}
- /* Fall through to make_string_field() */
+ /* Fall through */
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_VAR_STRING:
@@ -7141,19 +7141,6 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
last_checked_context->select_lex->nest_level);
}
}
- else if (ref_type() != VIEW_REF)
- {
- /*
- It could be that we're referring to something that's in ancestor selects.
- We must make an appropriate mark_as_dependent() call for each such
- outside reference.
- */
- Dependency_marker dep_marker;
- dep_marker.current_select= current_sel;
- dep_marker.thd= thd;
- (*ref)->walk(&Item::enumerate_field_refs_processor, FALSE,
- (uchar*)&dep_marker);
- }
DBUG_ASSERT(*ref);
/*
@@ -9477,7 +9464,10 @@ void Item_cache_row::set_null()
Item_type_holder::Item_type_holder(THD *thd, Item *item)
- :Item(thd, item), enum_set_typelib(0), fld_type(get_real_type(item))
+ :Item(thd, item),
+ enum_set_typelib(0),
+ fld_type(get_real_type(item)),
+ geometry_type(Field::GEOM_GEOMETRY)
{
DBUG_ASSERT(item->fixed);
maybe_null= item->maybe_null;
diff --git a/sql/item.h b/sql/item.h
index 2f8607d8fad..4d33a0eb6c1 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -4116,6 +4116,11 @@ public:
virtual double val_real() = 0;
virtual longlong val_int() = 0;
virtual int save_in_field(Field *field, bool no_conversions) = 0;
+ bool walk(Item_processor processor, bool walk_subquery, uchar *args)
+ {
+ return (item->walk(processor, walk_subquery, args)) ||
+ (this->*processor)(args);
+ }
};
/**
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 192e06566ff..038a0ebabc2 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -5104,6 +5104,15 @@ int Regexp_processor_pcre::default_regex_flags()
return default_regex_flags_pcre(current_thd);
}
+void Regexp_processor_pcre::set_recursion_limit(THD *thd)
+{
+ long stack_used;
+ DBUG_ASSERT(thd == current_thd);
+ stack_used= available_stack_size(thd->thread_stack, &stack_used);
+ m_pcre_extra.match_limit_recursion=
+ (my_thread_stack_size - stack_used)/my_pcre_frame_size;
+}
+
/**
Convert string to lib_charset, if needed.
@@ -5193,15 +5202,77 @@ void Regexp_processor_pcre::pcre_exec_warn(int rc) const
*/
switch (rc)
{
+ case PCRE_ERROR_NULL:
+ errmsg= "pcre_exec: null arguement passed";
+ break;
+ case PCRE_ERROR_BADOPTION:
+ errmsg= "pcre_exec: bad option";
+ break;
+ case PCRE_ERROR_BADMAGIC:
+ errmsg= "pcre_exec: bad magic - not a compiled regex";
+ break;
+ case PCRE_ERROR_UNKNOWN_OPCODE:
+ errmsg= "pcre_exec: error in compiled regex";
+ break;
case PCRE_ERROR_NOMEMORY:
errmsg= "pcre_exec: Out of memory";
break;
+ case PCRE_ERROR_NOSUBSTRING:
+ errmsg= "pcre_exec: no substring";
+ break;
+ case PCRE_ERROR_MATCHLIMIT:
+ errmsg= "pcre_exec: match limit exceeded";
+ break;
+ case PCRE_ERROR_CALLOUT:
+ errmsg= "pcre_exec: callout error";
+ break;
case PCRE_ERROR_BADUTF8:
errmsg= "pcre_exec: Invalid utf8 byte sequence in the subject string";
break;
+ case PCRE_ERROR_BADUTF8_OFFSET:
+ errmsg= "pcre_exec: Started at invalid location within utf8 byte sequence";
+ break;
+ case PCRE_ERROR_PARTIAL:
+ errmsg= "pcre_exec: partial match";
+ break;
+ case PCRE_ERROR_INTERNAL:
+ errmsg= "pcre_exec: internal error";
+ break;
+ case PCRE_ERROR_BADCOUNT:
+ errmsg= "pcre_exec: ovesize is negative";
+ break;
+ case PCRE_ERROR_RECURSIONLIMIT:
+ my_snprintf(buf, sizeof(buf), "pcre_exec: recursion limit of %ld exceeded",
+ m_pcre_extra.match_limit_recursion);
+ errmsg= buf;
+ break;
+ case PCRE_ERROR_BADNEWLINE:
+ errmsg= "pcre_exec: bad newline options";
+ break;
+ case PCRE_ERROR_BADOFFSET:
+ errmsg= "pcre_exec: start offset negative or greater than string length";
+ break;
+ case PCRE_ERROR_SHORTUTF8:
+ errmsg= "pcre_exec: ended in middle of utf8 sequence";
+ break;
+ case PCRE_ERROR_JIT_STACKLIMIT:
+ errmsg= "pcre_exec: insufficient stack memory for JIT compile";
+ break;
case PCRE_ERROR_RECURSELOOP:
errmsg= "pcre_exec: Recursion loop detected";
break;
+ case PCRE_ERROR_BADMODE:
+ errmsg= "pcre_exec: compiled pattern passed to wrong bit library function";
+ break;
+ case PCRE_ERROR_BADENDIANNESS:
+ errmsg= "pcre_exec: compiled pattern passed to wrong endianness processor";
+ break;
+ case PCRE_ERROR_JIT_BADOPTION:
+ errmsg= "pcre_exec: bad jit option";
+ break;
+ case PCRE_ERROR_BADLENGTH:
+ errmsg= "pcre_exec: negative length";
+ break;
default:
/*
As other error codes should normally not happen,
@@ -5237,7 +5308,7 @@ int Regexp_processor_pcre::pcre_exec_with_warn(const pcre *code,
bool Regexp_processor_pcre::exec(const char *str, int length, int offset)
{
- m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, NULL, str, length, offset, 0,
+ m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, &m_pcre_extra, str, length, offset, 0,
m_SubStrVec, m_subpatterns_needed * 3);
return false;
}
@@ -5248,7 +5319,7 @@ bool Regexp_processor_pcre::exec(String *str, int offset,
{
if (!(str= convert_if_needed(str, &subject_converter)))
return true;
- m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, NULL,
+ m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, &m_pcre_extra,
str->c_ptr_safe(), str->length(),
offset, 0,
m_SubStrVec, m_subpatterns_needed * 3);
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index b84cb26fb9c..17ad1bd8c7d 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1550,6 +1550,7 @@ public:
class Regexp_processor_pcre
{
pcre *m_pcre;
+ pcre_extra m_pcre_extra;
bool m_conversion_is_needed;
bool m_is_const;
int m_library_flags;
@@ -1574,8 +1575,12 @@ public:
m_data_charset(&my_charset_utf8_general_ci),
m_library_charset(&my_charset_utf8_general_ci),
m_subpatterns_needed(0)
- {}
+ {
+ m_pcre_extra.flags= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
+ m_pcre_extra.match_limit_recursion= 100L;
+ }
int default_regex_flags();
+ void set_recursion_limit(THD *);
void init(CHARSET_INFO *data_charset, int extra_flags, uint nsubpatterns)
{
m_library_flags= default_regex_flags() | extra_flags |
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ef164d060d2..9c5ef502693 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2009, 2015, MariaDB
+ Copyright (c) 2009, 2017, MariaDB
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
@@ -2034,6 +2034,7 @@ my_decimal *Item_func_mod::decimal_op(my_decimal *decimal_value)
return decimal_value;
case E_DEC_DIV_ZERO:
signal_divide_by_null();
+ /* fall through */
default:
null_value= 1;
return 0;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 4ea3075e69c..7cd712cc5e1 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2013, Monty Program Ab.
+ Copyright (c) 2000, 2017, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2017, MariaDB
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
@@ -3926,6 +3926,7 @@ String *Item_func_quote::val_str(String *str)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
+ ulong max_allowed_packet= current_thd->variables.max_allowed_packet;
char *from, *to, *end, *start;
String *arg= args[0]->val_str(str);
uint arg_length, new_length;
@@ -3944,11 +3945,14 @@ String *Item_func_quote::val_str(String *str)
new_length= arg_length + 2; /* for beginning and ending ' signs */
for (from= (char*) arg->ptr(), end= from + arg_length; from < end; from++)
new_length+= get_esc_bit(escmask, (uchar) *from);
+ if (new_length > max_allowed_packet)
+ goto toolong;
}
else
{
new_length= (arg_length * 2) + /* For string characters */
(2 * collation.collation->mbmaxlen); /* For quotes */
+ set_if_smaller(new_length, max_allowed_packet);
}
if (tmp_value.alloc(new_length))
@@ -3964,7 +3968,7 @@ String *Item_func_quote::val_str(String *str)
/* Put leading quote */
if ((mblen= cs->cset->wc_mb(cs, '\'', (uchar *) to, to_end)) <= 0)
- goto null;
+ goto toolong;
to+= mblen;
for (start= (char*) arg->ptr(), end= start + arg_length; start < end; )
@@ -3984,17 +3988,17 @@ String *Item_func_quote::val_str(String *str)
if (escape)
{
if ((mblen= cs->cset->wc_mb(cs, '\\', (uchar*) to, to_end)) <= 0)
- goto null;
+ goto toolong;
to+= mblen;
}
if ((mblen= cs->cset->wc_mb(cs, wc, (uchar*) to, to_end)) <= 0)
- goto null;
+ goto toolong;
to+= mblen;
}
/* Put trailing quote */
if ((mblen= cs->cset->wc_mb(cs, '\'', (uchar *) to, to_end)) <= 0)
- goto null;
+ goto toolong;
to+= mblen;
new_length= to - tmp_value.ptr();
goto ret;
@@ -4038,6 +4042,11 @@ ret:
null_value= 0;
return &tmp_value;
+toolong:
+ push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_WARN_ALLOWED_PACKET_OVERFLOWED,
+ ER_THD(current_thd, ER_WARN_ALLOWED_PACKET_OVERFLOWED),
+ func_name(), max_allowed_packet);
null:
null_value= 1;
return 0;
@@ -5081,7 +5090,7 @@ bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
goto null;
case DYN_COL_INT:
signed_value= 1; // For error message
- /* fall_trough */
+ /* fall through */
case DYN_COL_UINT:
if (signed_value || val.x.ulong_value <= LONGLONG_MAX)
{
@@ -5094,7 +5103,7 @@ bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
}
/* let double_to_datetime_with_warn() issue the warning message */
val.x.double_value= static_cast<double>(ULONGLONG_MAX);
- /* fall_trough */
+ /* fall through */
case DYN_COL_DOUBLE:
if (double_to_datetime_with_warn(val.x.double_value, ltime, fuzzy_date,
0 /* TODO */))
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index e87db62bd98..70b730a5a33 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1381,8 +1381,9 @@ Item_in_subselect::Item_in_subselect(Item * left_exp,
st_select_lex *select_lex):
Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE),
in_strategy(SUBS_NOT_TRANSFORMED),
- pushed_cond_guards(NULL), is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE),
- is_flattenable_semijoin(FALSE), is_registered_semijoin(FALSE),
+ pushed_cond_guards(NULL), do_not_convert_to_sj(FALSE), is_jtbm_merged(FALSE),
+ is_jtbm_const_tab(FALSE), is_flattenable_semijoin(FALSE),
+ is_registered_semijoin(FALSE),
upper_item(0)
{
DBUG_ENTER("Item_in_subselect::Item_in_subselect");
@@ -2512,6 +2513,27 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
DBUG_ENTER("Item_in_subselect::inject_in_to_exists_cond");
DBUG_ASSERT(thd == join_arg->thd);
+ if (select_lex->min_max_opt_list.elements)
+ {
+ /*
+ MIN/MAX optimizations have been applied to Item_sum objects
+ of the subquery this subquery predicate in opt_sum_query().
+ Injection of new condition invalidates this optimizations.
+ Thus those optimizations must be rolled back.
+ */
+ List_iterator_fast<Item_sum> it(select_lex->min_max_opt_list);
+ Item_sum *item;
+ while ((item= it++))
+ {
+ item->clear();
+ item->reset_forced_const();
+ }
+ if (where_item)
+ where_item->update_used_tables();
+ if (having_item)
+ having_item->update_used_tables();
+ }
+
if (where_item)
{
List<Item> *and_args= NULL;
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index f457eb92e3e..ad43215e437 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -490,6 +490,8 @@ public:
Item *left_expr_orig;
/* Priority of this predicate in the convert-to-semi-join-nest process. */
int sj_convert_priority;
+ /* May be TRUE only for the candidates to semi-join conversion */
+ bool do_not_convert_to_sj;
/*
Types of left_expr and subquery's select list allow to perform subquery
materialization. Currently, we set this to FALSE when it as well could
@@ -580,8 +582,8 @@ public:
Item_in_subselect()
:Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE),
in_strategy(SUBS_NOT_TRANSFORMED),
- pushed_cond_guards(NULL), func(NULL), is_jtbm_merged(FALSE),
- is_jtbm_const_tab(FALSE), upper_item(0) {}
+ pushed_cond_guards(NULL), func(NULL), do_not_convert_to_sj(FALSE),
+ is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE), upper_item(0) {}
void cleanup();
subs_type substype() { return IN_SUBS; }
void reset()
@@ -635,6 +637,8 @@ public:
*/
int get_identifier();
+ void block_conversion_to_sj () { do_not_convert_to_sj= TRUE; }
+
bool test_strategy(uchar strategy)
{ return MY_TEST(in_strategy & strategy); }
@@ -705,6 +709,13 @@ public:
in_strategy= (SUBS_STRATEGY_CHOSEN | strategy);
DBUG_VOID_RETURN;
}
+
+ bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
+ {
+ return left_expr->walk(processor, walk_subquery, arg) ||
+ Item_subselect::walk(processor, walk_subquery, arg);
+ }
+
bool exists2in_processor(uchar *opt_arg __attribute__((unused)))
{
return 0;
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index d1ab102c709..0f10d832ba6 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3442,7 +3442,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
args[i]->fix_fields(thd, args + i)) ||
args[i]->check_cols(1))
return TRUE;
- with_subselect|= args[i]->with_subselect;
+ with_subselect|= args[i]->with_subselect;
}
/* skip charset aggregation for order columns */
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 09a20487226..f4be2108e1b 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -454,6 +454,7 @@ public:
used_tables_cache= 0;
forced_const= TRUE;
}
+ void reset_forced_const() { forced_const= FALSE; }
virtual bool const_item() const { return forced_const; }
virtual bool const_during_execution() const { return false; }
virtual void print(String *str, enum_query_type query_type);
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index f8bf7cbf93a..c7fd923b0ae 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -1,4 +1,5 @@
-/* Copyright (c) 2005, 2013, Oracle and/or its affiliates.
+/* Copyright (c) 2005, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2017, MariaDB
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
@@ -2751,9 +2752,9 @@ int xml_enter(MY_XML_PARSER *st,const char *attr, size_t len)
node.parent= data->parent; // Set parent for the new node to old parent
data->parent= numnodes; // Remember current node as new parent
- DBUG_ASSERT(data->level <= MAX_LEVEL);
+ DBUG_ASSERT(data->level < MAX_LEVEL);
data->pos[data->level]= numnodes;
- if (data->level < MAX_LEVEL)
+ if (data->level < MAX_LEVEL - 1)
node.level= data->level++;
else
return MY_XML_ERROR;
diff --git a/sql/lock.cc b/sql/lock.cc
index 7153b85d740..f7b9980ef05 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -396,12 +396,15 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock, bool free_lock)
{
DBUG_ENTER("mysql_unlock_tables");
+ bool errors= thd->is_error();
if (sql_lock->table_count)
unlock_external(thd, sql_lock->table, sql_lock->table_count);
if (sql_lock->lock_count)
thr_multi_unlock(sql_lock->locks, sql_lock->lock_count, 0);
if (free_lock)
my_free(sql_lock);
+ if (!errors)
+ thd->clear_error();
DBUG_VOID_RETURN;
}
diff --git a/sql/log.cc b/sql/log.cc
index 3f3e0201c0c..596a0a449d2 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2016, MariaDB
+ Copyright (c) 2009, 2017, MariaDB
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
@@ -1360,7 +1360,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
/* fill in user_host value: the format is "%s[%s] @ %s [%s]" */
user_host_len= (strxnmov(user_host_buff, MAX_USER_HOST_SIZE,
- sctx->priv_user ? sctx->priv_user : "", "[",
+ sctx->priv_user, "[",
sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""), "] @ ",
sctx->host ? sctx->host : "", " [",
sctx->ip ? sctx->ip : "", "]", NullS) -
@@ -5564,13 +5564,20 @@ int THD::binlog_write_table_map(TABLE *table, bool is_transactional,
IO_CACHE *file=
cache_mngr->get_binlog_cache_log(use_trans_cache(this, is_transactional));
+ binlog_cache_data *cache_data=
+ cache_mngr->get_binlog_cache_data(use_trans_cache(this, is_transactional));
+
if (with_annotate && *with_annotate)
{
Annotate_rows_log_event anno(table->in_use, is_transactional, false);
/* Annotate event should be written not more than once */
*with_annotate= 0;
if ((error= anno.write(file)))
+ {
+ if (my_errno == EFBIG)
+ cache_data->set_incident();
DBUG_RETURN(error);
+ }
}
if ((error= the_event.write(file)))
DBUG_RETURN(error);
@@ -9023,8 +9030,10 @@ void TC_LOG_MMAP::close()
mysql_cond_destroy(&COND_pool);
mysql_cond_destroy(&COND_active);
mysql_cond_destroy(&COND_queue_busy);
+ /* fall through */
case 5:
data[0]='A'; // garble the first (signature) byte, in case mysql_file_delete fails
+ /* fall through */
case 4:
for (i=0; i < npages; i++)
{
@@ -9033,10 +9042,13 @@ void TC_LOG_MMAP::close()
mysql_mutex_destroy(&pages[i].lock);
mysql_cond_destroy(&pages[i].cond);
}
+ /* fall through */
case 3:
my_free(pages);
+ /* fall through */
case 2:
my_munmap((char*)data, (size_t)file_length);
+ /* fall through */
case 1:
mysql_file_close(fd, MYF(0));
}
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 8bdb81f5283..73869e82f72 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1681,8 +1681,7 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi)
default:
rli->report(ERROR_LEVEL, thd->net.last_errno, NULL,
"Error in %s event: row application failed. %s",
- get_type_str(),
- thd->net.last_error ? thd->net.last_error : "");
+ get_type_str(), thd->net.last_error);
thd->is_slave_error= 1;
break;
}
@@ -1721,8 +1720,7 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi)
"Error in %s event: error during transaction execution "
"on table %s.%s. %s",
get_type_str(), table->s->db.str,
- table->s->table_name.str,
- thd->net.last_error ? thd->net.last_error : "");
+ table->s->table_name.str, thd->net.last_error);
/*
If one day we honour --skip-slave-errors in row-based replication, and
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 349971e86fa..baf3d0f6758 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -107,6 +107,7 @@ ulong wsrep_running_threads = 0; // # of currently running wsrep threads
#include "sp_rcontext.h"
#include "sp_cache.h"
#include "sql_reload.h" // reload_acl_and_cache
+#include "pcre.h"
#ifdef HAVE_POLL_H
#include <poll.h>
@@ -3664,6 +3665,7 @@ static void init_libstrings()
#endif
}
+ulonglong my_pcre_frame_size;
static void init_pcre()
{
@@ -3671,6 +3673,8 @@ static void init_pcre()
pcre_free= pcre_stack_free= my_str_free_mysqld;
#ifndef EMBEDDED_LIBRARY
pcre_stack_guard= check_enough_stack_size_slow;
+ /* See http://pcre.org/original/doc/html/pcrestack.html */
+ my_pcre_frame_size= -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0) + 16;
#endif
}
@@ -8509,7 +8513,7 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff)
{
struct st_data {
KEY_CACHE_STATISTICS stats;
- SHOW_VAR var[8];
+ SHOW_VAR var[9];
} *data;
SHOW_VAR *v;
@@ -9558,6 +9562,9 @@ mysql_getopt_value(const char *name, uint length,
return (uchar**) &key_cache->changed_blocks_hash_size;
}
}
+ /* We return in all cases above. Let us silence -Wimplicit-fallthrough */
+ DBUG_ASSERT(0);
+ /* fall through */
case OPT_REPLICATE_DO_DB:
case OPT_REPLICATE_DO_TABLE:
case OPT_REPLICATE_IGNORE_DB:
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 731391490e0..4af04a3df75 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -106,7 +106,7 @@ extern ulong slave_run_triggers_for_rbr;
#endif //RBR_TRIGGERS
extern ulonglong slave_type_conversions_options;
extern my_bool read_only, opt_readonly;
-extern my_bool lower_case_file_system;
+extern MYSQL_PLUGIN_IMPORT my_bool lower_case_file_system;
extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
extern my_bool opt_secure_auth;
extern char* opt_secure_file_priv;
@@ -492,6 +492,8 @@ extern pthread_t signal_thread;
extern struct st_VioSSLFd * ssl_acceptor_fd;
#endif /* HAVE_OPENSSL */
+extern ulonglong my_pcre_frame_size;
+
/*
The following variables were under INNODB_COMPABILITY_HOOKS
*/
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 8f9d5abfa4d..481d8445fa8 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -7549,7 +7549,10 @@ QUICK_SELECT_I *TRP_ROR_UNION::make_quick(PARAM *param,
{
if (!(quick= (*scan)->make_quick(param, FALSE, &quick_roru->alloc)) ||
quick_roru->push_quick_back(quick))
+ {
+ delete quick_roru;
DBUG_RETURN(NULL);
+ }
}
quick_roru->records= records;
quick_roru->read_time= read_cost;
@@ -11194,9 +11197,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
*/
thd->mem_root= old_root;
- if (!quick || create_err)
- return 0; /* no ranges found */
- if (quick->init())
+ if (!quick || create_err || quick->init())
goto err;
quick->records= records;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 564a108c766..03204a627ed 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -1001,6 +1001,25 @@ bool check_for_outer_joins(List<TABLE_LIST> *join_list)
}
+void find_and_block_conversion_to_sj(Item *to_find,
+ List_iterator_fast<Item_in_subselect> &li)
+{
+ if (to_find->type() != Item::SUBSELECT_ITEM ||
+ ((Item_subselect *) to_find)->substype() != Item_subselect::IN_SUBS)
+ return;
+ Item_in_subselect *in_subq;
+ li.rewind();
+ while ((in_subq= li++))
+ {
+ if (in_subq == to_find)
+ {
+ in_subq->block_conversion_to_sj();
+ return;
+ }
+ }
+}
+
+
/*
Convert semi-join subquery predicates into semi-join join nests
@@ -1053,7 +1072,6 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
Query_arena *arena, backup;
Item_in_subselect *in_subq;
THD *thd= join->thd;
- List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
DBUG_ENTER("convert_join_subqueries_to_semijoins");
if (join->select_lex->sj_subselects.is_empty())
@@ -1071,6 +1089,89 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
subq_sel->update_used_tables();
}
+ /*
+ Check all candidates to semi-join conversion that occur
+ in ON expressions of outer join. Set the flag blocking
+ this conversion for them.
+ */
+ TABLE_LIST *tbl;
+ List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
+ while ((tbl= ti++))
+ {
+ TABLE_LIST *embedded;
+ TABLE_LIST *embedding= tbl;
+ do
+ {
+ embedded= embedding;
+ bool block_conversion_to_sj= false;
+ if (embedded->on_expr)
+ {
+ /*
+ Conversion of an IN subquery predicate into semi-join
+ is blocked now if the predicate occurs:
+ - in the ON expression of an outer join
+ - in the ON expression of an inner join embedded directly
+ or indirectly in the inner nest of an outer join
+ */
+ for (TABLE_LIST *tl= embedded; tl; tl= tl->embedding)
+ {
+ if (tl->outer_join)
+ {
+ block_conversion_to_sj= true;
+ break;
+ }
+ }
+ }
+ if (block_conversion_to_sj)
+ {
+ Item *cond= embedded->on_expr;
+ if (!cond)
+ ;
+ else if (cond->type() != Item::COND_ITEM)
+ find_and_block_conversion_to_sj(cond, li);
+ else if (((Item_cond*) cond)->functype() ==
+ Item_func::COND_AND_FUNC)
+ {
+ Item *item;
+ List_iterator<Item> it(*(((Item_cond*) cond)->argument_list()));
+ while ((item= it++))
+ {
+ find_and_block_conversion_to_sj(item, li);
+ }
+ }
+ }
+ embedding= embedded->embedding;
+ }
+ while (embedding &&
+ embedding->nested_join->join_list.head() == embedded);
+ }
+
+ /*
+ Block conversion to semi-joins for those candidates that
+ are encountered in the WHERE condition of the multi-table view
+ with CHECK OPTION if this view is used in UPDATE/DELETE.
+ (This limitation can be, probably, easily lifted.)
+ */
+ li.rewind();
+ while ((in_subq= li++))
+ {
+ if (in_subq->emb_on_expr_nest != NO_JOIN_NEST &&
+ in_subq->emb_on_expr_nest->effective_with_check)
+ {
+ in_subq->block_conversion_to_sj();
+ }
+ }
+
+ if (join->select_options & SELECT_STRAIGHT_JOIN)
+ {
+ /* Block conversion to semijoins for all candidates */
+ li.rewind();
+ while ((in_subq= li++))
+ {
+ in_subq->block_conversion_to_sj();
+ }
+ }
+
li.rewind();
/* First, convert child join's subqueries. We proceed bottom-up here */
while ((in_subq= li++))
@@ -1089,8 +1190,10 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
if (convert_join_subqueries_to_semijoins(child_join))
DBUG_RETURN(TRUE);
+
+
in_subq->sj_convert_priority=
- MY_TEST(in_subq->emb_on_expr_nest != NO_JOIN_NEST) * MAX_TABLES * 2 +
+ MY_TEST(in_subq->do_not_convert_to_sj) * MAX_TABLES * 2 +
in_subq->is_correlated * MAX_TABLES + child_join->outer_tables;
}
@@ -1123,7 +1226,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
bool remove_item= TRUE;
/* Stop processing if we've reached a subquery that's attached to the ON clause */
- if (in_subq->emb_on_expr_nest != NO_JOIN_NEST)
+ if (in_subq->do_not_convert_to_sj)
break;
if (in_subq->is_flattenable_semijoin)
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 1ff1f4a6449..9712b3c3d42 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2008-2011 Monty Program Ab
+ Copyright (c) 2008, 2017, MariaDB Corporation.
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
@@ -254,6 +254,8 @@ int opt_sum_query(THD *thd,
int error= 0;
DBUG_ENTER("opt_sum_query");
+ thd->lex->current_select->min_max_opt_list.empty();
+
if (conds)
where_tables= conds->used_tables();
@@ -447,7 +449,14 @@ int opt_sum_query(THD *thd,
item_sum->aggregator_clear();
}
else
+ {
item_sum->reset_and_add();
+ /*
+ Save a reference to the item for possible rollback
+ of the min/max optimizations for this select
+ */
+ thd->lex->current_select->min_max_opt_list.push_back(item_sum);
+ }
item_sum->make_const();
recalc_const_item= 1;
break;
@@ -1041,6 +1050,7 @@ static int maxmin_in_range(bool max_fl, Field* field, COND *cond)
case Item_func::LT_FUNC:
case Item_func::LE_FUNC:
less_fl= 1;
+ /* fall through */
case Item_func::GT_FUNC:
case Item_func::GE_FUNC:
{
diff --git a/sql/records.cc b/sql/records.cc
index a37f7a18c11..940fd97d123 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -69,7 +69,7 @@ static int rr_index_desc(READ_RECORD *info);
bool init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
bool print_error, uint idx, bool reverse)
{
- int error;
+ int error= 0;
DBUG_ENTER("init_read_record_idx");
empty_record(table);
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 18cbd2b6e6e..d63bf8fc29c 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -564,7 +564,7 @@ file '%s')", fname);
mi->connect_retry= (uint) connect_retry;
mi->ssl= (my_bool) ssl;
mi->ssl_verify_server_cert= ssl_verify_server_cert;
- mi->heartbeat_period= master_heartbeat_period;
+ mi->heartbeat_period= MY_MIN(SLAVE_MAX_HEARTBEAT_PERIOD, master_heartbeat_period);
}
DBUG_PRINT("master_info",("log_file_name: %s position: %ld",
mi->master_log_name,
@@ -681,8 +681,8 @@ int flush_master_info(Master_info* mi,
contents of file). But because of number of lines in the first line
of file we don't care about this garbage.
*/
- char heartbeat_buf[sizeof(mi->heartbeat_period) * 4]; // buffer to suffice always
- sprintf(heartbeat_buf, "%.3f", mi->heartbeat_period);
+ char heartbeat_buf[FLOATING_POINT_BUFFER];
+ my_fcvt(mi->heartbeat_period, 3, heartbeat_buf, NULL);
my_b_seek(file, 0L);
my_b_printf(file,
"%u\n%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n%s\n%s\n%s\n%s\n%s\n%d\n%s\n%s\n%s\n%s\n%d\n%s\n%s\n"
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index e5964e9c038..43e52c00e8d 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -1109,7 +1109,8 @@ handle_rpl_parallel_thread(void *arg)
thd->wait_for_commit_ptr= &rgi->commit_orderer;
- if (opt_gtid_ignore_duplicates)
+ if (opt_gtid_ignore_duplicates &&
+ rgi->rli->mi->using_gtid != Master_info::USE_GTID_NO)
{
int res=
rpl_global_gtid_slave_state->check_duplicate_gtid(&rgi->current_gtid,
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index d8c64a9d534..de0daf759fe 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -4841,7 +4841,7 @@ WARN_DATA_TRUNCATED 01000
spa "Datos truncados para columna '%s' en la línea %lu"
ER_WARN_USING_OTHER_HANDLER
eng "Using storage engine %s for table '%s'"
- ger "Für Tabelle '%s' wird Speicher-Engine %s benutzt"
+ ger "Speicher-Engine %s wird für Tabelle '%s' benutzt"
jpn "ストレージエンジン %s が表 '%s' に利用されています。"
por "Usando engine de armazenamento %s para tabela '%s'"
spa "Usando motor de almacenamiento %s para tabla '%s'"
diff --git a/sql/slave.cc b/sql/slave.cc
index 8acf687a732..b1cda1129bd 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2016, MariaDB
+ Copyright (c) 2009, 2017, MariaDB
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
@@ -3629,7 +3629,8 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
DBUG_RETURN(1);
}
- if (opt_gtid_ignore_duplicates)
+ if (opt_gtid_ignore_duplicates &&
+ rli->mi->using_gtid != Master_info::USE_GTID_NO)
{
int res= rpl_global_gtid_slave_state->check_duplicate_gtid
(&serial_rgi->current_gtid, serial_rgi);
@@ -5734,8 +5735,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
TODO: handling `when' for SHOW SLAVE STATUS' snds behind
*/
- if ((memcmp(mi->master_log_name, hb.get_log_ident(), hb.get_ident_len())
- && mi->master_log_name != NULL)
+ if (memcmp(mi->master_log_name, hb.get_log_ident(), hb.get_ident_len())
|| mi->master_log_pos > hb.log_pos)
{
/* missed events of heartbeat from the past */
@@ -5886,9 +5886,8 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
mi->last_queued_gtid.seq_no == 1000)
goto skip_relay_logging;
});
- /* Fall through to default case ... */
#endif
-
+ /* fall through */
default:
default_action:
if (mi->using_gtid != Master_info::USE_GTID_NO && mi->gtid_event_seen)
@@ -6240,7 +6239,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr);
/* we disallow empty users */
- if (mi->user == NULL || mi->user[0] == 0)
+ if (mi->user[0] == 0)
{
mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL,
ER(ER_SLAVE_FATAL_ERROR),
diff --git a/sql/sp.cc b/sql/sp.cc
index c247101ca7f..78de0209e6f 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2002, 2015, Oracle and/or its affiliates.
- Copyright (c) 2009, 2015, MariaDB
+ Copyright (c) 2002, 2016, Oracle and/or its affiliates.
+ Copyright (c) 2009, 2017, MariaDB
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
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index fb0f3132816..ea9e1c1c822 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2002, 2016, Oracle and/or its affiliates.
- Copyright (c) 2011, 2016, MariaDB
+ Copyright (c) 2011, 2017, MariaDB
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
@@ -142,6 +142,7 @@ sp_get_item_value(THD *thd, Item *item, String *str)
if (item->field_type() != MYSQL_TYPE_BIT)
return item->val_str(str);
else {/* Bit type is handled as binary string */}
+ /* fall through */
case STRING_RESULT:
{
String *result= item->val_str(str);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index d4b23a9fbc2..3ed1a687c5a 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -10679,12 +10679,6 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
/* global privileges */
grant->privilege= sctx->master_access;
- if (!sctx->priv_user)
- {
- DBUG_PRINT("info", ("privilege 0x%lx", grant->privilege));
- DBUG_VOID_RETURN; // it is slave
- }
-
if (!thd->db || strcmp(db, thd->db))
{
/* db privileges */
diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc
index b659054a50b..60a75cb06e7 100644
--- a/sql/sql_audit.cc
+++ b/sql/sql_audit.cc
@@ -369,8 +369,7 @@ int initialize_audit_plugin(st_plugin_int *plugin)
{
st_mysql_audit *data= (st_mysql_audit*) plugin->plugin->info;
- if (!data->class_mask || !data->event_notify ||
- !data->class_mask[0])
+ if (!data->event_notify || !data->class_mask[0])
{
sql_print_error("Plugin '%s' has invalid data.",
plugin->name.str);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index a8db8463e8e..7a87ec3bd87 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2016, MariaDB
+ Copyright (c) 2008, 2017, MariaDB
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
diff --git a/sql/sql_const.h b/sql/sql_const.h
index 5c3a6d9a7cf..da2eef1b441 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -69,6 +69,7 @@
#define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1))
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
RAND_TABLE_BIT)
+#define CONNECT_STRING_MAXLEN 65535 /* stored in 2 bytes in .frm */
#define MAX_FIELDS 4096 /* Limit in the .frm file */
#define MAX_PARTITIONS 8192
diff --git a/sql/sql_digest.cc b/sql/sql_digest.cc
index c8ba371ea7e..0cc969b3758 100644
--- a/sql/sql_digest.cc
+++ b/sql/sql_digest.cc
@@ -1,4 +1,5 @@
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2017, MariaDB Corporation.
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
@@ -453,7 +454,8 @@ sql_digest_state* digest_add_token(sql_digest_state *state,
}
} while (found_unary);
}
- /* fall through, for case NULL_SYM below */
+ /* for case NULL_SYM below */
+ /* fall through */
case LEX_HOSTNAME:
case TEXT_STRING:
case NCHAR_STRING:
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index a98514acbb8..5f22a657dfe 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2009, 2016, MariaDB
+ Copyright (c) 2009, 2017, MariaDB
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
@@ -1174,12 +1174,14 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
state= MY_LEX_HEX_NUMBER;
break;
}
+ /* fall through */
case MY_LEX_IDENT_OR_BIN:
if (lip->yyPeek() == '\'')
{ // Found b'bin-number'
state= MY_LEX_BIN_NUMBER;
break;
}
+ /* fall through */
case MY_LEX_IDENT:
const char *start;
#if defined(USE_MB) && defined(USE_MB_IDENT)
@@ -1527,6 +1529,7 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
break;
}
/* " used for strings */
+ /* fall through */
case MY_LEX_STRING: // Incomplete text string
if (!(yylval->lex_str.str = get_text(lip, 1, 1)))
{
@@ -1876,6 +1879,7 @@ void st_select_lex::init_query()
leaf_tables_prep.empty();
leaf_tables.empty();
item_list.empty();
+ min_max_opt_list.empty();
join= 0;
having= prep_having= where= prep_where= 0;
olap= UNSPECIFIED_OLAP_TYPE;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index c4fd109009f..d28546edf10 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -704,6 +704,11 @@ public:
*/
List<Item_func_match> *ftfunc_list;
List<Item_func_match> ftfunc_list_alloc;
+ /*
+ The list of items to which MIN/MAX optimizations of opt_sum_query()
+ have been applied. Used to rollback those optimizations if it's needed.
+ */
+ List<Item_sum> min_max_opt_list;
JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
List<TABLE_LIST> top_join_list; /* join list of the top level */
List<TABLE_LIST> *join_list; /* list for the currently parsed join */
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 6d803961621..c391cfba00c 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -1060,7 +1060,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
{
uint length;
uchar *pos;
- Item *real_item;
+ Item_field *real_item;
if (read_info.read_field())
break;
@@ -1072,16 +1072,26 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
pos=read_info.row_start;
length=(uint) (read_info.row_end-pos);
- real_item= item->real_item();
+ real_item= item->field_for_view_update();
if ((!read_info.enclosed &&
(enclosed_length && length == 4 &&
!memcmp(pos, STRING_WITH_LEN("NULL")))) ||
(length == 1 && read_info.found_null))
{
- if (real_item->type() == Item::FIELD_ITEM)
+ if (item->type() == Item::STRING_ITEM)
{
- Field *field= ((Item_field *)real_item)->field;
+ ((Item_user_var_as_out_param *)item)->set_null_value(
+ read_info.read_charset);
+ }
+ else if (!real_item)
+ {
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
+ DBUG_RETURN(1);
+ }
+ else
+ {
+ Field *field= real_item->field;
if (field->reset())
{
my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name,
@@ -1104,23 +1114,23 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
/* Do not auto-update this field. */
field->set_has_explicit_value();
}
- else if (item->type() == Item::STRING_ITEM)
- {
- ((Item_user_var_as_out_param *)item)->set_null_value(
- read_info.read_charset);
- }
- else
- {
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
- DBUG_RETURN(1);
- }
continue;
}
- if (real_item->type() == Item::FIELD_ITEM)
+ if (item->type() == Item::STRING_ITEM)
+ {
+ ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
+ read_info.read_charset);
+ }
+ else if (!real_item)
+ {
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
+ DBUG_RETURN(1);
+ }
+ else
{
- Field *field= ((Item_field *)real_item)->field;
+ Field *field= real_item->field;
field->set_notnull();
read_info.row_end[0]=0; // Safe to change end marker
if (field == table->next_number_field)
@@ -1128,16 +1138,6 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
field->store((char*) pos, length, read_info.read_charset);
field->set_has_explicit_value();
}
- else if (item->type() == Item::STRING_ITEM)
- {
- ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
- read_info.read_charset);
- }
- else
- {
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
- DBUG_RETURN(1);
- }
}
if (thd->is_error())
@@ -1157,10 +1157,20 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
break;
for (; item ; item= it++)
{
- Item *real_item= item->real_item();
- if (real_item->type() == Item::FIELD_ITEM)
+ Item_field *real_item= item->field_for_view_update();
+ if (item->type() == Item::STRING_ITEM)
+ {
+ ((Item_user_var_as_out_param *)item)->set_null_value(
+ read_info.read_charset);
+ }
+ else if (!real_item)
{
- Field *field= ((Item_field *)real_item)->field;
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
+ DBUG_RETURN(1);
+ }
+ else
+ {
+ Field *field= real_item->field;
if (field->reset())
{
my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0),field->field_name,
@@ -1182,16 +1192,6 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
ER(ER_WARN_TOO_FEW_RECORDS),
thd->get_stmt_da()->current_row_for_warning());
}
- else if (item->type() == Item::STRING_ITEM)
- {
- ((Item_user_var_as_out_param *)item)->set_null_value(
- read_info.read_charset);
- }
- else
- {
- my_error(ER_LOAD_DATA_INVALID_COLUMN, MYF(0), item->full_name());
- DBUG_RETURN(1);
- }
}
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3db0f37974a..f39566cec34 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2015, MariaDB
+/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2017, MariaDB
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
@@ -2785,8 +2785,8 @@ mysql_execute_command(THD *thd)
MYF(0));
goto error;
}
- /* no break; fall through */
}
+ /* fall through */
case SQLCOM_SHOW_STATUS_PROC:
case SQLCOM_SHOW_STATUS_FUNC:
#ifdef WITH_WSREP
@@ -3632,8 +3632,8 @@ end_with_restore_list:
/* mysql_update return 2 if we need to switch to multi-update */
if (up_result != 2)
break;
- /* Fall through */
}
+ /* Fall through */
case SQLCOM_UPDATE_MULTI:
{
DBUG_ASSERT(first_table == all_tables && first_table != 0);
@@ -3751,6 +3751,7 @@ end_with_restore_list:
DBUG_PRINT("debug", ("Just after generate_incident()"));
}
#endif
+ /* fall through */
case SQLCOM_INSERT:
#ifdef WITH_WSREP
if (WSREP_CLIENT(thd) &&
@@ -4648,6 +4649,7 @@ end_with_restore_list:
initialize this variable because RESET shares the same code as FLUSH
*/
lex->no_write_to_binlog= 1;
+ /* fall through */
case SQLCOM_FLUSH:
{
int write_to_binlog;
@@ -6694,12 +6696,6 @@ bool check_fk_parent_table_access(THD *thd,
****************************************************************************/
-#if STACK_DIRECTION < 0
-#define used_stack(A,B) (long) (A - B)
-#else
-#define used_stack(A,B) (long) (B - A)
-#endif
-
#ifndef DBUG_OFF
long max_stack_used;
#endif
@@ -6716,7 +6712,7 @@ bool check_stack_overrun(THD *thd, long margin,
{
long stack_used;
DBUG_ASSERT(thd == current_thd);
- if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >=
+ if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
(long) (my_thread_stack_size - margin))
{
thd->is_fatal_error= 1;
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 14f1107be33..eb8e0004380 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2005, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2014, SkySQL Ab.
+ Copyright (c) 2010, 2017, MariaDB Corporation.
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
@@ -1816,8 +1816,8 @@ static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)
switch ((*(p++)= *(list++))) {
case '\0':
list= NULL; /* terminate the loop */
- /* fall through */
#ifndef __WIN__
+ /* fall through */
case ':': /* can't use this as delimiter as it may be drive letter */
#endif
case ';':
@@ -1858,6 +1858,7 @@ static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list)
str->str= p;
continue;
}
+ /* fall through */
default:
str->length++;
continue;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 5ff03d19339..1bb465d220b 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2015, MariaDB
+ Copyright (c) 2008, 2017, MariaDB
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
@@ -2010,7 +2010,7 @@ static int mysql_test_handler_read(Prepared_statement *stmt,
THD *thd= stmt->thd;
LEX *lex= stmt->lex;
SQL_HANDLER *ha_table;
- DBUG_ENTER("mysql_test_select");
+ DBUG_ENTER("mysql_test_handler_read");
lex->select_lex.context.resolve_in_select_list= TRUE;
@@ -2108,7 +2108,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
/* mysql_test_update returns 2 if we need to switch to multi-update */
if (res != 2)
break;
-
+ /* fall through */
case SQLCOM_UPDATE_MULTI:
res= mysql_test_multiupdate(stmt, tables, res == 2);
break;
@@ -3022,7 +3022,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length)
{
stmt->state= Query_arena::STMT_ERROR;
stmt->last_errno= thd->get_stmt_da()->sql_errno();
- strncpy(stmt->last_error, thd->get_stmt_da()->message(), MYSQL_ERRMSG_SIZE);
+ strmake_buf(stmt->last_error, thd->get_stmt_da()->message());
}
thd->set_stmt_da(save_stmt_da);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index ece137aa380..bd0d31213e6 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -3694,9 +3694,6 @@ bool mysql_show_binlog_events(THD* thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
- Format_description_log_event *description_event= new
- Format_description_log_event(3); /* MySQL 4.0 by default */
-
DBUG_ASSERT(thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS ||
thd->lex->sql_command == SQLCOM_SHOW_RELAYLOG_EVENTS);
@@ -3722,6 +3719,9 @@ bool mysql_show_binlog_events(THD* thd)
binary_log= &(mi->rli.relay_log);
}
+ Format_description_log_event *description_event= new
+ Format_description_log_event(3); /* MySQL 4.0 by default */
+
if (binary_log->is_open())
{
LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c9ad3f48d9d..6a281a4583e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8443,8 +8443,6 @@ get_best_combination(JOIN *join)
join->full_join=0;
join->hash_join= FALSE;
- used_tables= OUTER_REF_TABLE_BIT; // Outer row is already read
-
fix_semijoin_strategies_for_picked_join_order(join);
JOIN_TAB_RANGE *root_range;
@@ -8508,7 +8506,6 @@ get_best_combination(JOIN *join)
j->bush_root_tab= sjm_nest_root;
form=join->table[tablenr]=j->table;
- used_tables|= form->map;
form->reginfo.join_tab=j;
DBUG_PRINT("info",("type: %d", j->type));
if (j->type == JT_CONST)
@@ -8535,9 +8532,6 @@ get_best_combination(JOIN *join)
join->best_positions[tablenr].loosescan_picker.loosescan_key);
j->index= join->best_positions[tablenr].loosescan_picker.loosescan_key;
}*/
-
- if (keyuse && create_ref_for_key(join, j, keyuse, TRUE, used_tables))
- DBUG_RETURN(TRUE); // Something went wrong
if ((j->type == JT_REF || j->type == JT_EQ_REF) &&
is_hash_join_key_no(j->ref.key))
@@ -8563,6 +8557,23 @@ get_best_combination(JOIN *join)
}
root_range->end= j;
+ used_tables= OUTER_REF_TABLE_BIT; // Outer row is already read
+ for (j=join_tab, tablenr=0 ; tablenr < table_count ; tablenr++,j++)
+ {
+ if (j->bush_children)
+ j= j->bush_children->start;
+
+ used_tables|= j->table->map;
+ if (j->type != JT_CONST && j->type != JT_SYSTEM)
+ {
+ if ((keyuse= join->best_positions[tablenr].key) &&
+ create_ref_for_key(join, j, keyuse, TRUE, used_tables))
+ DBUG_RETURN(TRUE); // Something went wrong
+ }
+ if (j->last_leaf_in_bush)
+ j= j->bush_root_tab;
+ }
+
join->top_join_tab_count= join->join_tab_ranges.head()->end -
join->join_tab_ranges.head()->start;
/*
@@ -9476,12 +9487,20 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
/*
Step #2: Extract WHERE/ON parts
*/
+ uint i;
+ for (i= join->top_join_tab_count - 1; i >= join->const_tables; i--)
+ {
+ if (!join->join_tab[i].bush_children)
+ break;
+ }
+ uint last_top_base_tab_idx= i;
+
table_map save_used_tables= 0;
used_tables=((select->const_tables=join->const_table_map) |
OUTER_REF_TABLE_BIT | RAND_TABLE_BIT);
JOIN_TAB *tab;
table_map current_map;
- uint i= join->const_tables;
+ i= join->const_tables;
for (tab= first_depth_first_tab(join); tab;
tab= next_depth_first_tab(join, tab), i++)
{
@@ -9519,8 +9538,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
Following force including random expression in last table condition.
It solve problem with select like SELECT * FROM t1 WHERE rand() > 0.5
*/
- if (tab == join->join_tab + join->top_join_tab_count - 1)
- current_map|= OUTER_REF_TABLE_BIT | RAND_TABLE_BIT;
+ if (tab == join->join_tab + last_top_base_tab_idx)
+ current_map|= RAND_TABLE_BIT;
used_tables|=current_map;
if (tab->type == JT_REF && tab->quick &&
@@ -9558,10 +9577,10 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
save_used_tables= 0;
}
else
- {
- tmp= make_cond_for_table(thd, cond, used_tables, current_map, i,
+ {
+ tmp= make_cond_for_table(thd, cond, used_tables, current_map, i,
FALSE, FALSE);
- }
+ }
/* Add conditions added by add_not_null_conds(). */
if (tab->select_cond)
add_cond_and_fix(thd, &tmp, tab->select_cond);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index bfa3d19008f..ce9815216bb 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2009, 2016, MariaDB
+ Copyright (c) 2009, 2017, MariaDB
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
@@ -985,6 +985,7 @@ public:
is_handled= FALSE;
break;
}
+ /* fall through */
case ER_COLUMNACCESS_DENIED_ERROR:
case ER_VIEW_NO_EXPLAIN: /* Error was anonymized, ignore all the same. */
case ER_PROCACCESS_DENIED_ERROR:
@@ -3048,7 +3049,7 @@ static bool show_status_array(THD *thd, const char *wild,
for (; variables->name; variables++)
{
- bool wild_checked;
+ bool wild_checked= 0;
strnmov(prefix_end, variables->name, len);
name_buffer[sizeof(name_buffer)-1]=0; /* Safety */
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0732d6b74f0..e591b8a1eb7 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3252,6 +3252,21 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
bool tmp_table= create_table_mode == C_ALTER_TABLE;
DBUG_ENTER("mysql_prepare_create_table");
+ LEX_STRING* connect_string = &create_info->connect_string;
+ if (connect_string->length != 0 &&
+ connect_string->length > CONNECT_STRING_MAXLEN &&
+ (system_charset_info->cset->charpos(system_charset_info,
+ connect_string->str,
+ (connect_string->str +
+ connect_string->length),
+ CONNECT_STRING_MAXLEN)
+ < connect_string->length))
+ {
+ my_error(ER_WRONG_STRING_LENGTH, MYF(0),
+ connect_string->str, "CONNECTION", CONNECT_STRING_MAXLEN);
+ DBUG_RETURN(TRUE);
+ }
+
select_field_pos= alter_info->create_list.elements - select_field_count;
null_fields=blob_columns=0;
create_info->varchar= 0;
@@ -6899,7 +6914,8 @@ bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled,
case Alter_info::LEAVE_AS_IS:
if (!indexes_were_disabled)
break;
- /* fall-through: disabled indexes */
+ /* disabled indexes */
+ /* fall through */
case Alter_info::DISABLE:
error= table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index e6a0d484580..5a0c18b5109 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -4681,9 +4681,11 @@ size_number:
case 'g':
case 'G':
text_shift_number+=10;
+ /* fall through */
case 'm':
case 'M':
text_shift_number+=10;
+ /* fall through */
case 'k':
case 'K':
text_shift_number+=10;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 6457a8597bd..4ae5379289e 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1681,7 +1681,10 @@ Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var)
return true;
}
if (res->length() == 0)
+ {
list= NULL;
+ list_len= 0;
+ }
else if (!(list= gtid_parse_string_to_list(res->ptr(), res->length(),
&list_len)))
{