summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-09-21 08:12:19 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-09-21 08:12:19 +0300
commite3d44f5d62672478c40294d6e46d9f066e418cac (patch)
tree44b4d1b9d94ced780d4f369f84eddc36791470be /sql
parentd176be8aeaecdb20a963fbd126929ddcd5bd98f3 (diff)
parentf70865bc9e540767d8afc3cc2cbe0e1c92a8c0be (diff)
downloadmariadb-git-e3d44f5d62672478c40294d6e46d9f066e418cac.tar.gz
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/CMakeLists.txt68
-rw-r--r--sql/ha_partition.h4
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/handler.h4
-rw-r--r--sql/item.cc5
-rw-r--r--sql/item_cmpfunc.cc10
-rw-r--r--sql/item_func.cc3
-rw-r--r--sql/item_strfunc.cc14
-rw-r--r--sql/item_strfunc.h18
-rw-r--r--sql/item_sum.cc23
-rw-r--r--sql/item_timefunc.cc16
-rw-r--r--sql/item_timefunc.h6
-rw-r--r--sql/mysqld.cc8
-rw-r--r--sql/share/errmsg-utf8.txt3
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_partition.cc4
-rw-r--r--sql/sql_partition_admin.cc7
-rw-r--r--sql/sql_select.cc13
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/sql_update.cc20
-rw-r--r--sql/sys_vars.cc11
-rw-r--r--sql/table.cc16
-rw-r--r--sql/uniques.cc16
-rw-r--r--sql/wsrep_sst.cc2
24 files changed, 164 insertions, 112 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 9522d589945..0940b394d54 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -50,24 +50,13 @@ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc_ora.cc
-${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
-)
-SET(GEN_DIGEST_SOURCES
- ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
+${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
+${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
)
SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES}
- ${GEN_DIGEST_SOURCES}
PROPERTIES GENERATED 1)
-# Gen_lex_token
-# Make sure sql_yacc.h is generated before compiling gen_lex_token
-
-IF(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
- SET(DEPENDS_gen_lex_token DEPENDS gen_lex_token)
- SET(DEPENDS_gen_lex_hash DEPENDS gen_lex_hash)
-ENDIF()
-
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(gen_lex_token gen_lex_token.cc
@@ -77,7 +66,7 @@ ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
COMMAND gen_lex_token > lex_token.h
- ${DEPENDS_gen_lex_token}
+ DEPENDS gen_lex_token
)
ADD_DEFINITIONS(-DMYSQL_SERVER -DHAVE_EVENT_SCHEDULER)
@@ -158,7 +147,6 @@ SET (SQL_SOURCE
proxy_protocol.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
${GEN_SOURCES}
- ${GEN_DIGEST_SOURCES}
${MYSYS_LIBWRAP_SOURCE}
)
@@ -181,7 +169,6 @@ RECOMPILE_FOR_EMBEDDED)
ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
ADD_DEPENDENCIES(sql GenServerSource)
-ADD_DEPENDENCIES(sql GenDigestServerSource)
DTRACE_INSTRUMENT(sql)
TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
mysys mysys_ssl dbug strings vio pcre
@@ -220,7 +207,7 @@ IF(MSVC AND NOT WITHOUT_DYNAMIC_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)
+ SET(MYSQLD_CORELIBS sql mysys dbug strings)
FOREACH (CORELIB ${MYSQLD_CORELIBS})
GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
FILE(TO_NATIVE_PATH ${LOC} LOC)
@@ -231,6 +218,29 @@ IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(_PLATFORM x64)
ENDIF()
+ # Create a cmake script to generate import and export libs
+ # from a .def file
+ SET(CMAKE_CONFIGURABLE_FILE_CONTENT "
+ IF ((mysqld_lib.def IS_NEWER_THAN mysqld_lib.lib) OR
+ (mysqld_lib.def IS_NEWER_THAN mysqld_lib.exp))
+ FILE(REMOVE mysqld_lib.lib mysqld_lib.exp)
+ SET(ENV{VS_UNICODE_OUTPUT})
+ EXECUTE_PROCESS (
+ COMMAND \"${CMAKE_LINKER}\" /lib /NAME:mysqld.exe \"/DEF:${MYSQLD_DEF}\" /MACHINE:${_PLATFORM}
+ RESULT_VARIABLE ret)
+ IF(NOT ret EQUAL 0)
+ MESSAGE(FATAL_ERROR \"process failed ret=\${ret}\")
+ ENDIF()
+ ENDIF()
+ ")
+
+ CONFIGURE_FILE(
+ ${PROJECT_SOURCE_DIR}/cmake/configurable_file_content.in
+ make_mysqld_lib.cmake)
+
+ IF(CMAKE_VERSION VERSION_GREATER "3.2.0")
+ SET(MYSQLD_LIB_BYPRODUCTS BYPRODUCTS ${MYSQLD_DEF} ${MYSQLD_LIB} ${MYSQLD_EXP})
+ ENDIF()
# Create a cmake script to generate import and export libs
# from a .def file
@@ -252,16 +262,20 @@ IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
make_mysqld_lib.cmake)
ADD_CUSTOM_COMMAND(
- OUTPUT ${MYSQLD_DEF} ${MYSQLD_LIB} ${MYSQLD_EXP}
- COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
- ${_PLATFORM} /forLib ${LIB_LOCATIONS} > mysqld_lib.def.tmp
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mysqld_lib.stamp
+ ${MYSQLD_LIB_BYPRODUCTS}
+ COMMENT "Generating mysqld_lib.def, mysqld_lib.lib, mysqld_lib.exp"
+ COMMAND cscript //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
COMMAND ${CMAKE_COMMAND} -P make_mysqld_lib.cmake
+ COMMAND ${CMAKE_COMMAND} -E touch mysqld_lib.stamp
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${MYSQLD_CORELIBS}
)
- ADD_CUSTOM_TARGET(gen_mysqld_lib DEPENDS ${MYSQLD_LIB})
+ ADD_CUSTOM_TARGET(gen_mysqld_lib DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mysqld_lib.stamp)
ADD_LIBRARY(mysqld_import_lib UNKNOWN IMPORTED GLOBAL)
SET_TARGET_PROPERTIES(mysqld_import_lib PROPERTIES IMPORTED_LOCATION ${MYSQLD_LIB})
ENDIF()
@@ -280,7 +294,6 @@ IF(NOT WITHOUT_DYNAMIC_PLUGINS)
IF(NOT MSVC)
SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
ENDIF()
-
GET_TARGET_PROPERTY(mysqld_link_flags mysqld LINK_FLAGS)
IF(NOT mysqld_link_flags)
SET(mysqld_link_flags)
@@ -319,10 +332,6 @@ IF(WITH_MYSQLD_LDFLAGS)
SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS
"${MYSQLD_LINK_FLAGS} ${WITH_MYSQLD_LDFLAGS}")
ENDIF()
-INSTALL_DEBUG_TARGET(mysqld
- DESTINATION ${INSTALL_SBINDIR}
- PDB_DESTINATION ${INSTALL_SBINDIR}/debug
- RENAME mysqld-debug)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
@@ -364,7 +373,7 @@ ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
COMMAND gen_lex_hash > lex_hash.h
- ${DEPENDS_gen_lex_hash}
+ DEPENDS gen_lex_hash
)
MYSQL_ADD_EXECUTABLE(mysql_tzinfo_to_sql tztime.cc COMPONENT Server)
@@ -376,11 +385,6 @@ ADD_CUSTOM_TARGET(
DEPENDS ${GEN_SOURCES}
)
-ADD_CUSTOM_TARGET(
- GenDigestServerSource
- DEPENDS ${GEN_DIGEST_SOURCES}
-)
-
#Need this only for embedded
SET_TARGET_PROPERTIES(GenServerSource PROPERTIES EXCLUDE_FROM_ALL TRUE)
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index c8aa09c23b7..0402908c640 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -345,6 +345,10 @@ public:
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
uint table_changes);
+ void update_part_create_info(HA_CREATE_INFO *create_info, uint part_id)
+ {
+ m_file[part_id]->update_create_info(create_info);
+ }
private:
int copy_partitions(ulonglong * const copied, ulonglong * const deleted);
void cleanup_new_partition(uint part_count);
diff --git a/sql/handler.cc b/sql/handler.cc
index e5c15524e1d..bcb68ca0695 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1681,7 +1681,7 @@ int ha_rollback_trans(THD *thd, bool all)
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1;
#ifdef WITH_WSREP
- WSREP_WARN("handlerton rollback failed, thd %lu %lld conf %d SQL %s",
+ WSREP_WARN("handlerton rollback failed, thd %llu %lld conf %d SQL %s",
thd->thread_id, thd->query_id, thd->wsrep_conflict_state,
thd->query());
#endif /* WITH_WSREP */
diff --git a/sql/handler.h b/sql/handler.h
index 86287596ca3..5e0adfca072 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1890,10 +1890,6 @@ public:
// Add non-unique, non-primary index
static const HA_ALTER_FLAGS ADD_INDEX = 1ULL << 0;
- //
- // Adds a spatial index. At the moment all engines treat it
- // identically to the ADD_INDEX, so it gets the same code
- static const HA_ALTER_FLAGS ADD_SPATIAL_INDEX = ADD_INDEX;
// Drop non-unique, non-primary index
static const HA_ALTER_FLAGS DROP_INDEX = 1ULL << 1;
diff --git a/sql/item.cc b/sql/item.cc
index 58b3c82ff14..8e77a731400 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2061,7 +2061,10 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref)
set_name(thd, item_name->c_ptr(), (uint) item_name->length(),
system_charset_info);
}
- collation.set(value_item->collation.collation, DERIVATION_IMPLICIT);
+ if (value_item->collation.derivation == DERIVATION_NUMERIC)
+ collation.set_numeric();
+ else
+ collation.set(value_item->collation.collation, DERIVATION_IMPLICIT);
max_length= value_item->max_length;
decimals= value_item->decimals;
fixed= 1;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 89a7cab6ac2..d6cd57770cb 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -4540,11 +4540,11 @@ Item_cond::fix_fields(THD *thd, Item **ref)
const_item_cache= FALSE;
}
- with_sum_func= with_sum_func || item->with_sum_func;
- with_field= with_field || item->with_field;
- with_subselect|= item->has_subquery();
- if (item->maybe_null)
- maybe_null=1;
+ with_sum_func|= item->with_sum_func;
+ with_field|= item->with_field;
+ with_subselect|= item->has_subquery();
+ with_window_func|= item->with_window_func;
+ maybe_null|= item->maybe_null;
}
fix_length_and_dec();
fixed= 1;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index a3b2027f2fc..2af7338b3c6 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -560,7 +560,8 @@ void Item_func::print_op(String *str, enum_query_type query_type)
str->append(func_name());
str->append(' ');
}
- args[arg_count-1]->print_parenthesised(str, query_type, precedence());
+ args[arg_count-1]->print_parenthesised(str, query_type,
+ (enum precedence)(precedence() + 1));
}
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 190a927ba03..cb05516964c 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2809,20 +2809,6 @@ String *Item_func_format::val_str_ascii(String *str)
}
-void Item_func_format::print(String *str, enum_query_type query_type)
-{
- str->append(STRING_WITH_LEN("format("));
- args[0]->print(str, query_type);
- str->append(',');
- args[1]->print(str, query_type);
- if(arg_count > 2)
- {
- str->append(',');
- args[2]->print(str,query_type);
- }
- str->append(')');
-}
-
void Item_func_elt::fix_length_and_dec()
{
uint32 char_length= 0;
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index f9b6f96fb9a..685a64816be 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -92,7 +92,7 @@ public:
{
return val_str_from_val_str_ascii(str, &ascii_buf);
}
- virtual String *val_str_ascii(String *)= 0;
+ String *val_str_ascii(String *)= 0;
};
@@ -559,7 +559,7 @@ public:
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "trim"; }
- virtual void print(String *str, enum_query_type query_type);
+ void print(String *str, enum_query_type query_type);
virtual const char *mode_name() const { return "both"; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_trim>(thd, mem_root, this); }
@@ -943,7 +943,6 @@ public:
String *val_str_ascii(String *);
void fix_length_and_dec();
const char *func_name() const { return "format"; }
- virtual void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_format>(thd, mem_root, this); }
};
@@ -1022,7 +1021,6 @@ public:
const char *func_name() const { return "binlog_gtid_pos"; }
bool check_vcol_func_processor(void *arg)
{
-
return mark_unsupported_function(func_name(), "()", arg, VCOL_IMPOSSIBLE);
}
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -1207,7 +1205,7 @@ public:
collation.set(&my_charset_bin);
max_length=args[0]->max_length;
}
- virtual void print(String *str, enum_query_type query_type);
+ void print(String *str, enum_query_type query_type);
const char *func_name() const { return "cast_as_binary"; }
bool need_parentheses_in_default() { return true; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -1351,7 +1349,7 @@ public:
}
void fix_length_and_dec();
const char *func_name() const { return "convert"; }
- virtual void print(String *str, enum_query_type query_type);
+ void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_conv_charset>(thd, mem_root, this); }
};
@@ -1367,7 +1365,7 @@ public:
const char *func_name() const { return "collate"; }
enum precedence precedence() const { return COLLATE_PRECEDENCE; }
enum Functype functype() const { return COLLATE_FUNC; }
- virtual void print(String *str, enum_query_type query_type);
+ void print(String *str, enum_query_type query_type);
Item_field *field_for_view_update()
{
/* this function is transparent for view updating */
@@ -1549,8 +1547,8 @@ public:
void fix_length_and_dec();
const char *func_name() const{ return "column_create"; }
String *val_str(String *);
- virtual void print(String *str, enum_query_type query_type);
- virtual enum Functype functype() const { return DYNCOL_FUNC; }
+ void print(String *str, enum_query_type query_type);
+ enum Functype functype() const { return DYNCOL_FUNC; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_dyncol_create>(thd, mem_root, this); }
};
@@ -1564,7 +1562,7 @@ public:
{}
const char *func_name() const{ return "column_add"; }
String *val_str(String *);
- virtual void print(String *str, enum_query_type query_type);
+ void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_dyncol_add>(thd, mem_root, this); }
};
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 1ad55cf9f7a..755ed7d302b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -100,7 +100,11 @@ bool Item_sum::init_sum_func_check(THD *thd)
The method verifies whether context conditions imposed on a usage
of any set function are met for this occurrence.
- It checks whether the set function occurs in the position where it
+
+ The function first checks if we are using any window functions as
+ arguments to the set function. In that case it returns an error.
+
+ Afterwards, it checks whether the set function occurs in the position where it
can be aggregated and, when it happens to occur in argument of another
set function, the method checks that these two functions are aggregated in
different subqueries.
@@ -151,6 +155,20 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
curr_sel->name_visibility_map);
bool invalid= FALSE;
DBUG_ASSERT(curr_sel->name_visibility_map); // should be set already
+
+ /*
+ Window functions can not be used as arguments to sum functions.
+ Aggregation happes before window function computation, so there
+ are no values to aggregate over.
+ */
+ if (with_window_func)
+ {
+ my_message(ER_SUM_FUNC_WITH_WINDOW_FUNC_AS_ARG,
+ ER_THD(thd, ER_SUM_FUNC_WITH_WINDOW_FUNC_AS_ARG),
+ MYF(0));
+ return TRUE;
+ }
+
if (window_func_sum_expr_flag)
return false;
/*
@@ -1109,6 +1127,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
return TRUE;
set_if_bigger(decimals, args[i]->decimals);
with_subselect|= args[i]->with_subselect;
+ with_window_func|= args[i]->with_window_func;
}
result_field=0;
max_length=float_length(decimals);
@@ -1139,6 +1158,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
(item= args[0])->check_cols(1))
return TRUE;
with_subselect= args[0]->with_subselect;
+ with_window_func|= args[0]->with_window_func;
fix_length_and_dec();
if (!is_window_func_sum_expr())
@@ -3416,6 +3436,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
args[i]->check_cols(1))
return TRUE;
with_subselect|= args[i]->with_subselect;
+ with_window_func|= args[i]->with_window_func;
}
/* skip charset aggregation for order columns */
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index c05f3f5c7be..0657d483408 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -477,14 +477,14 @@ static bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
{
switch (*++ptr) {
case 'M':
- if (!l_time->month)
+ if (type == MYSQL_TIMESTAMP_TIME || !l_time->month)
return 1;
str->append(locale->month_names->type_names[l_time->month-1],
(uint) strlen(locale->month_names->type_names[l_time->month-1]),
system_charset_info);
break;
case 'b':
- if (!l_time->month)
+ if (type == MYSQL_TIMESTAMP_TIME || !l_time->month)
return 1;
str->append(locale->ab_month_names->type_names[l_time->month-1],
(uint) strlen(locale->ab_month_names->type_names[l_time->month-1]),
@@ -534,26 +534,38 @@ static bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
}
break;
case 'Y':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->year, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 4, '0');
break;
case 'y':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->year%100, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'm':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'c':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;
case 'd':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'e':
+ if (type == MYSQL_TIMESTAMP_TIME)
+ return 1;
length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 4cdf7b63158..a752c160557 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -188,7 +188,6 @@ public:
}
bool check_vcol_func_processor(void *arg)
{
-
return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
}
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -673,8 +672,7 @@ public:
virtual void store_now_in_TIME(THD *thd, MYSQL_TIME *now_time)=0;
bool check_vcol_func_processor(void *arg)
{
- return mark_unsupported_function(func_name(), "()", arg,
- VCOL_TIME_FUNC);
+ return mark_unsupported_function(func_name(), "()", arg, VCOL_TIME_FUNC);
}
};
@@ -813,6 +811,8 @@ public:
bool eq(const Item *item, bool binary_cmp) const;
bool check_vcol_func_processor(void *arg)
{
+ if (is_time_format)
+ return false;
return mark_unsupported_function(func_name(), "()", arg, VCOL_SESSION_FUNC);
}
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 2fc5e3c27a5..e7240ad2cce 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -8215,7 +8215,7 @@ static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff,
#ifdef HAVE_YASSL
static char *
-my_asn1_time_to_string(ASN1_TIME *time, char *buf, size_t len)
+my_asn1_time_to_string(const ASN1_TIME *time, char *buf, size_t len)
{
return yaSSL_ASN1_TIME_to_string(time, buf, len);
}
@@ -8223,7 +8223,7 @@ my_asn1_time_to_string(ASN1_TIME *time, char *buf, size_t len)
#else /* openssl */
static char *
-my_asn1_time_to_string(ASN1_TIME *time, char *buf, size_t len)
+my_asn1_time_to_string(const ASN1_TIME *time, char *buf, size_t len)
{
int n_read;
char *res= NULL;
@@ -8271,7 +8271,7 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
{
SSL *ssl= (SSL*) thd->net.vio->ssl_arg;
X509 *cert= SSL_get_certificate(ssl);
- ASN1_TIME *not_before= X509_get_notBefore(cert);
+ const ASN1_TIME *not_before= X509_get0_notBefore(cert);
var->value= my_asn1_time_to_string(not_before, buff,
SHOW_VAR_FUNC_BUFF_SIZE);
@@ -8305,7 +8305,7 @@ show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff,
{
SSL *ssl= (SSL*) thd->net.vio->ssl_arg;
X509 *cert= SSL_get_certificate(ssl);
- ASN1_TIME *not_after= X509_get_notAfter(cert);
+ const ASN1_TIME *not_after= X509_get0_notAfter(cert);
var->value= my_asn1_time_to_string(not_after, buff,
SHOW_VAR_FUNC_BUFF_SIZE);
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index d0fb0ee1772..0204121c553 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7740,6 +7740,9 @@ ER_RDB_TTL_DURATION_FORMAT
ER_PER_INDEX_CF_DEPRECATED
eng "The per-index column family option has been deprecated"
+ER_SUM_FUNC_WITH_WINDOW_FUNC_AS_ARG
+ eng "Window functions can not be used as arguments to group functions."
+
ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
eng "Illegal parameter data types %s and %s for operation '%s'"
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 92f28a4dc07..9cb69f2aa9a 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -5615,7 +5615,6 @@ user_var_entry *get_variable(HASH *hash, LEX_CSTRING *name,
bool create_if_not_exists);
class SORT_INFO;
-
class multi_delete :public select_result_interceptor
{
TABLE_LIST *delete_tables, *table_being_deleted;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 2614178b622..9fc67272bfa 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -4355,10 +4355,6 @@ bool compare_partition_options(HA_CREATE_INFO *table_create_info,
option_diffs[errors++]= "MAX_ROWS";
if (part_elem->part_min_rows != table_create_info->min_rows)
option_diffs[errors++]= "MIN_ROWS";
- if (part_elem->data_file_name || table_create_info->data_file_name)
- option_diffs[errors++]= "DATA DIRECTORY";
- if (part_elem->index_file_name || table_create_info->index_file_name)
- option_diffs[errors++]= "INDEX DIRECTORY";
for (i= 0; i < errors; i++)
my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0),
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 0512e712102..0c1c9fb02de 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -179,7 +179,8 @@ static bool check_exchange_partition(TABLE *table, TABLE *part_table)
*/
static bool compare_table_with_partition(THD *thd, TABLE *table,
TABLE *part_table,
- partition_element *part_elem)
+ partition_element *part_elem,
+ uint part_id)
{
HA_CREATE_INFO table_create_info, part_create_info;
Alter_info part_alter_info;
@@ -204,6 +205,7 @@ static bool compare_table_with_partition(THD *thd, TABLE *table,
}
/* db_type is not set in prepare_alter_table */
part_create_info.db_type= part_table->part_info->default_engine_type;
+ ((ha_partition*)(part_table->file))->update_part_create_info(&part_create_info, part_id);
/*
Since we exchange the partition with the table, allow exchanging
auto_increment value as well.
@@ -588,7 +590,8 @@ bool Sql_cmd_alter_table_exchange_partition::
DBUG_RETURN(TRUE);
}
- if (compare_table_with_partition(thd, swap_table, part_table, part_elem))
+ if (compare_table_with_partition(thd, swap_table, part_table, part_elem,
+ swap_part_id))
DBUG_RETURN(TRUE);
/* Table and partition has same structure/options, OK to exchange */
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 52544130918..ba3d2e7da2f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -19763,7 +19763,6 @@ bool test_if_use_dynamic_range_scan(JOIN_TAB *join_tab)
int join_init_read_record(JOIN_TAB *tab)
{
- int error;
/*
Note: the query plan tree for the below operations is constructed in
save_agg_explain_data.
@@ -19773,12 +19772,18 @@ int join_init_read_record(JOIN_TAB *tab)
if (tab->filesort && tab->sort_table()) // Sort table.
return 1;
- if (tab->select && tab->select->quick && (error= tab->select->quick->reset()))
+ DBUG_EXECUTE_IF("kill_join_init_read_record",
+ tab->join->thd->set_killed(KILL_QUERY););
+ if (tab->select && tab->select->quick && tab->select->quick->reset())
{
- /* Ensures error status is propageted back to client */
- report_error(tab->table, error);
+ /* Ensures error status is propagated back to client */
+ report_error(tab->table,
+ tab->join->thd->killed ? HA_ERR_QUERY_INTERRUPTED : HA_ERR_OUT_OF_MEM);
return 1;
}
+ /* make sure we won't get ER_QUERY_INTERRUPTED from any code below */
+ DBUG_EXECUTE_IF("kill_join_init_read_record",
+ tab->join->thd->reset_killed(););
if (!tab->preread_init_done && tab->preread_init())
return 1;
if (init_read_record(&tab->read_record, tab->join->thd, tab->table,
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 4006e3aec4d..9c746e470f7 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -7924,7 +7924,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
}
/* see if the constraint depends on *only* on dropped fields */
- if (dropped_fields)
+ if (!drop && dropped_fields)
{
table->default_column_bitmaps();
bitmap_clear_all(table->read_set);
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 02a5a4a15e6..3f39765b531 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -2311,6 +2311,26 @@ int multi_update::do_updates()
do_update= 0; // Don't retry this function
if (!found)
DBUG_RETURN(0);
+
+ /*
+ Update read_set to include all fields that virtual columns may depend on.
+ Usually they're already in the read_set, but if the previous access
+ method was keyread, only the virtual column itself will be in read_set,
+ not its dependencies
+ */
+ while(TABLE *tbl= check_opt_it++)
+ {
+ if (tbl->vcol_set)
+ {
+ bitmap_clear_all(tbl->vcol_set);
+ for (Field **vf= tbl->vfield; *vf; vf++)
+ {
+ if (bitmap_is_set(tbl->read_set, (*vf)->field_index))
+ tbl->mark_virtual_col(*vf);
+ }
+ }
+ }
+
for (cur_table= update_tables; cur_table; cur_table= cur_table->next_local)
{
bool can_compare_record;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index a159fc87aa9..b74c12bb563 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -61,6 +61,7 @@
#include "sql_repl.h"
#include "opt_range.h"
#include "rpl_parallel.h"
+#include <ssl_compat.h>
/*
The rule for this file: everything should be 'static'. When a sys_var
@@ -3578,16 +3579,6 @@ static Sys_var_charptr Sys_malloc_library(
READ_ONLY GLOBAL_VAR(malloc_library), CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(guess_malloc_library()));
-#ifdef HAVE_YASSL
-#include <openssl/ssl.h>
-#define SSL_LIBRARY "YaSSL " YASSL_VERSION
-#elif HAVE_OPENSSL
-#include <openssl/crypto.h>
-#define SSL_LIBRARY SSLeay_version(SSLEAY_VERSION)
-#else
-#error No SSL?
-#endif
-
static char *ssl_library;
static Sys_var_charptr Sys_ssl_library(
"version_ssl_library", "Version of the used SSL library",
diff --git a/sql/table.cc b/sql/table.cc
index 1ef3af422be..eb9e848d549 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -5078,7 +5078,11 @@ int TABLE_LIST::view_check_option(THD *thd, bool ignore_failure)
name_db, name_table);
return ignore_failure ? VIEW_CHECK_SKIP : VIEW_CHECK_ERROR;
}
- return table->verify_constraints(ignore_failure);
+ int result= table->verify_constraints(ignore_failure);
+ /* We check thd->error() because it can be set by conversion problem. */
+ if (thd->is_error())
+ return(VIEW_CHECK_ERROR);
+ return result;
}
@@ -5090,7 +5094,8 @@ int TABLE::verify_constraints(bool ignore_failure)
{
for (Virtual_column_info **chk= check_constraints ; *chk ; chk++)
{
- if ((*chk)->expr->val_int() == 0)
+ /* yes! NULL is ok, see 4.23.3.4 Table check constraints, part 2, SQL:2016 */
+ if ((*chk)->expr->val_int() == 0 && !(*chk)->expr->null_value)
{
my_error(ER_CONSTRAINT_FAILED,
MYF(ignore_failure ? ME_JUST_WARNING : 0), (*chk)->name.str,
@@ -5099,7 +5104,7 @@ int TABLE::verify_constraints(bool ignore_failure)
}
}
}
- return VIEW_CHECK_OK;
+ return(VIEW_CHECK_OK);
}
@@ -5766,9 +5771,10 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
{
DBUG_RETURN(field);
}
+ Name_resolution_context *context= view->view ? &view->view->select_lex.context :
+ &thd->lex->select_lex.context;
Item *item= (new (thd->mem_root)
- Item_direct_view_ref(thd, &view->view->select_lex.context,
- field_ref, view->alias,
+ Item_direct_view_ref(thd, context, field_ref, view->alias,
name, view));
/*
Force creation of nullable item for the result tmp table for outer joined
diff --git a/sql/uniques.cc b/sql/uniques.cc
index fc6437a2f64..e7dc40a5a5f 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -101,6 +101,9 @@ Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
*/
max_elements= (ulong) (max_in_memory_size /
ALIGN_SIZE(sizeof(TREE_ELEMENT)+size));
+ if (!max_elements)
+ max_elements= 1;
+
(void) open_cached_file(&file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE,
MYF(MY_WME));
}
@@ -646,11 +649,12 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg)
if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0))
return 1;
/*
- merge_buffer must fit at least MERGEBUFF2 keys, because
- merge_index() can merge that many BUFFPEKs at once.
+ merge_buffer must fit at least MERGEBUFF2 + 1 keys, because
+ merge_index() can merge that many BUFFPEKs at once. The extra space for one key
+ is needed when a piece of merge buffer is re-read, see merge_walk()
*/
- size_t buff_sz= MY_MAX(MERGEBUFF2, max_in_memory_size/full_size+1) * full_size;
- if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_THREAD_SPECIFIC|MY_WME))))
+ size_t buff_sz= MY_MAX(MERGEBUFF2+1, max_in_memory_size/full_size+1) * full_size;
+ if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_WME))))
return 1;
if (buff_sz < full_size * (file_ptrs.elements + 1UL))
res= merge(table, merge_buffer, buff_sz >= full_size * MERGEBUFF2) ;
@@ -708,8 +712,8 @@ bool Unique::merge(TABLE *table, uchar *buff, bool without_last_merge)
full_size;
sort_param.min_dupl_count= min_dupl_count;
sort_param.res_length= 0;
- sort_param.max_keys_per_buffer=
- (uint) (max_in_memory_size / sort_param.sort_length);
+ sort_param.max_keys_per_buffer=
+ (uint) MY_MAX((max_in_memory_size / sort_param.sort_length), MERGEBUFF2);
sort_param.not_killable= 1;
sort_param.unique_buff= buff +(sort_param.max_keys_per_buffer *
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index 35bf1b251e7..9c00f9fdaf6 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -433,7 +433,7 @@ static int generate_binlog_opt_val(char** ret)
{
assert(opt_bin_logname);
*ret= strcmp(opt_bin_logname, "0") ?
- my_strdup(opt_bin_logname, MYF(0)) : my_strdup("", MYF(0));
+ my_strdup(opt_bin_logname, MYF(0)) : my_strdup("", MYF(0));
}
else
{