summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-10-22 08:26:28 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-10-22 08:26:28 +0300
commite3d692aa092a76415ce1ce0e9662338873d84abb (patch)
treec6c7fafc561b589f82ed3a0afd696822fd52962d /sql
parent88d22f0e65192ca1b1e69b46661ce57ce19dbaa4 (diff)
parent620ea816adeceaba7c875679ab8505f4c07a22b8 (diff)
downloadmariadb-git-e3d692aa092a76415ce1ce0e9662338873d84abb.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc1
-rw-r--r--sql/log.cc9
-rw-r--r--sql/log_event.cc2
-rw-r--r--sql/mysqld.cc10
-rw-r--r--sql/opt_range.cc20
-rw-r--r--sql/sql_class.h4
-rw-r--r--sql/sql_parse.cc41
-rw-r--r--sql/sql_prepare.cc4
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/sql_type.cc7
-rw-r--r--sql/sql_udf.cc148
-rw-r--r--sql/sql_udf.h8
-rw-r--r--sql/sql_update.cc2
-rw-r--r--sql/sql_yacc.yy4
-rw-r--r--sql/sql_yacc_ora.yy4
-rw-r--r--sql/threadpool_common.cc14
-rw-r--r--sql/wsrep_mysqld.h4
-rw-r--r--sql/wsrep_var.cc4
18 files changed, 196 insertions, 93 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 664289eaa27..78b6afd932c 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5967,6 +5967,7 @@ extern "C" enum icp_result handler_index_cond_check(void* h_arg)
THD *thd= h->table->in_use;
enum icp_result res;
+ DEBUG_SYNC(thd, "handler_index_cond_check");
enum thd_kill_levels abort_at= h->has_transactions() ?
THD_ABORT_SOFTLY : THD_ABORT_ASAP;
if (thd_kill_level(thd) > abort_at)
diff --git a/sql/log.cc b/sql/log.cc
index c77500bb9f5..d119b88c4e0 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -586,9 +586,11 @@ bool LOGGER::is_log_table_enabled(uint log_table_type)
{
switch (log_table_type) {
case QUERY_LOG_SLOW:
- return (table_log_handler != NULL) && global_system_variables.sql_log_slow;
+ return (table_log_handler != NULL) && global_system_variables.sql_log_slow
+ && (log_output_options & LOG_TABLE);
case QUERY_LOG_GENERAL:
- return (table_log_handler != NULL) && opt_log ;
+ return (table_log_handler != NULL) && opt_log
+ && (log_output_options & LOG_TABLE);
default:
DBUG_ASSERT(0);
return FALSE; /* make compiler happy */
@@ -10446,7 +10448,8 @@ binlog_checksum_update(MYSQL_THD thd, struct st_mysql_sys_var *var,
}
-static int show_binlog_vars(THD *thd, SHOW_VAR *var, char *buff)
+static int show_binlog_vars(THD *thd, SHOW_VAR *var, void *,
+ system_status_var *status_var, enum_var_type)
{
mysql_bin_log.set_status_variables(thd);
var->type= SHOW_ARRAY;
diff --git a/sql/log_event.cc b/sql/log_event.cc
index a0c3efcb85b..4792a2c9f0e 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -2056,7 +2056,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
else
DBUG_RETURN(NULL);
#else
- *error= ER(ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE);
+ *error= ER_THD_OR_DEFAULT(current_thd, ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE);
sql_print_error("%s", *error);
DBUG_RETURN(NULL);
#endif
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d6555702d9c..8b013e58f27 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -8452,8 +8452,8 @@ show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff,
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
-static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff,
- enum enum_var_type scope)
+static int show_default_keycache(THD *thd, SHOW_VAR *var, void *buff,
+ system_status_var *, enum_var_type)
{
struct st_data {
KEY_CACHE_STATISTICS stats;
@@ -8486,7 +8486,7 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff,
v->name= 0;
- DBUG_ASSERT((char*)(v+1) <= buff + SHOW_VAR_FUNC_BUFF_SIZE);
+ DBUG_ASSERT((char*)(v+1) <= static_cast<char*>(buff) + SHOW_VAR_FUNC_BUFF_SIZE);
#undef set_one_keycache_var
@@ -8510,8 +8510,8 @@ static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff,
#ifndef DBUG_OFF
-static int debug_status_func(THD *thd, SHOW_VAR *var, char *buff,
- enum enum_var_type scope)
+static int debug_status_func(THD *thd, SHOW_VAR *var, void *buff,
+ system_status_var *, enum_var_type)
{
#define add_var(X,Y,Z) \
v->name= X; \
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index a00e0ebdfb0..ec1f60314d3 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1858,6 +1858,9 @@ SEL_ARG::SEL_ARG(SEL_ARG &arg) :Sql_alloc()
next_key_part=arg.next_key_part;
max_part_no= arg.max_part_no;
use_count=1; elements=1;
+ next= 0;
+ if (next_key_part)
+ ++next_key_part->use_count;
}
@@ -8907,9 +8910,15 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2)
}
bool no_imerge_from_ranges= FALSE;
+ SEL_TREE *rt1= tree1;
+ SEL_TREE *rt2= tree2;
/* Build the range part of the tree for the formula (1) */
if (sel_trees_can_be_ored(param, tree1, tree2, &ored_keys))
{
+ if (no_merges1)
+ rt1= new SEL_TREE(tree1, TRUE, param);
+ if (no_merges2)
+ rt2= new SEL_TREE(tree2, TRUE, param);
bool must_be_ored= sel_trees_must_be_ored(param, tree1, tree2, ored_keys);
no_imerge_from_ranges= must_be_ored;
@@ -8967,12 +8976,6 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2)
else if (!no_ranges1 && !no_ranges2 && !no_imerge_from_ranges)
{
/* Build the imerge part of the tree for the formula (1) */
- SEL_TREE *rt1= tree1;
- SEL_TREE *rt2= tree2;
- if (no_merges1)
- rt1= new SEL_TREE(tree1, TRUE, param);
- if (no_merges2)
- rt2= new SEL_TREE(tree2, TRUE, param);
if (!rt1 || !rt2 ||
result->merges.push_back(imerge_from_ranges) ||
imerge_from_ranges->or_sel_tree(param, rt1) ||
@@ -9637,10 +9640,11 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
if (!tmp->next_key_part)
{
+ SEL_ARG *key2_next= key2->next;
if (key2->use_count)
{
SEL_ARG *key2_cpy= new SEL_ARG(*key2);
- if (key2_cpy)
+ if (!key2_cpy)
return 0;
key2= key2_cpy;
}
@@ -9661,7 +9665,7 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
Move on to next range in key2
*/
key2->increment_use_count(-1); // Free not used tree
- key2=key2->next;
+ key2=key2_next;
continue;
}
else
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 0645452c594..10caa668e9e 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -6337,11 +6337,11 @@ public:
/**
SP Bulk execution safe
*/
-#define CF_SP_BULK_SAFE (1U << 20)
+#define CF_PS_ARRAY_BINDING_SAFE (1U << 20)
/**
SP Bulk execution optimized
*/
-#define CF_SP_BULK_OPTIMIZED (1U << 21)
+#define CF_PS_ARRAY_BINDING_OPTIMIZED (1U << 21)
/**
If command creates or drops a table
*/
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6802816caaf..8408771692d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -583,19 +583,21 @@ void init_update_queries(void)
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE |
CF_CAN_BE_EXPLAINED |
- CF_UPDATES_DATA | CF_SP_BULK_SAFE;
+ CF_UPDATES_DATA |
+ CF_PS_ARRAY_BINDING_SAFE;
sql_command_flags[SQLCOM_UPDATE_MULTI]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE |
CF_CAN_BE_EXPLAINED |
- CF_UPDATES_DATA | CF_SP_BULK_SAFE;
+ CF_UPDATES_DATA |
+ CF_PS_ARRAY_BINDING_SAFE;
sql_command_flags[SQLCOM_INSERT]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE |
CF_CAN_BE_EXPLAINED |
CF_INSERTS_DATA |
- CF_SP_BULK_SAFE |
- CF_SP_BULK_OPTIMIZED;
+ CF_PS_ARRAY_BINDING_SAFE |
+ CF_PS_ARRAY_BINDING_OPTIMIZED;
sql_command_flags[SQLCOM_INSERT_SELECT]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE |
@@ -605,7 +607,8 @@ void init_update_queries(void)
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE |
CF_CAN_BE_EXPLAINED |
- CF_SP_BULK_SAFE | CF_DELETES_DATA;
+ CF_DELETES_DATA |
+ CF_PS_ARRAY_BINDING_SAFE;
sql_command_flags[SQLCOM_DELETE_MULTI]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE |
@@ -615,8 +618,9 @@ void init_update_queries(void)
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE |
CF_CAN_BE_EXPLAINED |
- CF_INSERTS_DATA | CF_SP_BULK_SAFE |
- CF_SP_BULK_OPTIMIZED;
+ CF_INSERTS_DATA |
+ CF_PS_ARRAY_BINDING_SAFE |
+ CF_PS_ARRAY_BINDING_OPTIMIZED;
sql_command_flags[SQLCOM_REPLACE_SELECT]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE |
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE |
@@ -5678,23 +5682,20 @@ mysql_execute_command(THD *thd)
! lex->spname->m_explicit_name)
{
/* DROP FUNCTION <non qualified name> */
- udf_func *udf = find_udf(lex->spname->m_name.str,
- lex->spname->m_name.length);
- if (udf)
+ enum drop_udf_result rc= mysql_drop_function(thd,
+ &lex->spname->m_name);
+ if (rc == UDF_DEL_RESULT_DELETED)
{
- if (check_access(thd, DELETE_ACL, "mysql", NULL, NULL, 1, 0))
- goto error;
+ my_ok(thd);
+ break;
+ }
- if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
- {
- my_ok(thd);
- break;
- }
- my_error(ER_SP_DROP_FAILED, MYF(0),
- "FUNCTION (UDF)", lex->spname->m_name.str);
+ if (rc == UDF_DEL_RESULT_ERROR)
goto error;
- }
+ DBUG_ASSERT(rc == UDF_DEL_RESULT_ABSENT);
+
+ // If there was no current database, so it can not be SP
if (lex->spname->m_db.str == NULL)
{
if (lex->if_exists())
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index a1ca7cc7af2..b3c5700a0b7 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -4360,7 +4360,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
return TRUE;
}
- if (!(sql_command_flags[lex->sql_command] & CF_SP_BULK_SAFE))
+ if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_SAFE))
{
DBUG_PRINT("error", ("Command is not supported in bulk execution."));
my_error(ER_UNSUPPORTED_PS, MYF(0));
@@ -4402,7 +4402,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query,
Here we set parameters for not optimized commands,
optimized commands do it inside thier internal loop.
*/
- if (!(sql_command_flags[lex->sql_command] & CF_SP_BULK_OPTIMIZED))
+ if (!(sql_command_flags[lex->sql_command] & CF_PS_ARRAY_BINDING_OPTIMIZED))
{
if (set_bulk_parameters(TRUE))
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index aaa4b4d6b8b..738e1912994 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -392,11 +392,14 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
If LIMIT ROWS EXAMINED interrupted query execution, issue a warning,
continue with normal processing and produce an incomplete query result.
*/
+ bool saved_abort_on_warning= thd->abort_on_warning;
+ thd->abort_on_warning= false;
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT,
ER_THD(thd, ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT),
thd->accessed_rows_and_keys,
thd->lex->limit_rows_examined->val_uint());
+ thd->abort_on_warning= saved_abort_on_warning;
thd->reset_killed();
}
/* Disable LIMIT ROWS EXAMINED after query execution. */
diff --git a/sql/sql_type.cc b/sql/sql_type.cc
index 9d3a47adfa5..a25aa236b16 100644
--- a/sql/sql_type.cc
+++ b/sql/sql_type.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2015 MariaDB Foundation.
+ Copyright (c) 2015, 2020, 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
@@ -3867,8 +3867,11 @@ cmp_item *Type_handler_temporal_with_date::make_cmp_item(THD *thd,
/***************************************************************************/
-static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y)
+static int srtcmp_in(const void *cs_, const void *x_, const void *y_)
{
+ const CHARSET_INFO *cs= static_cast<const CHARSET_INFO *>(cs_);
+ const String *x= static_cast<const String *>(x_);
+ const String *y= static_cast<const String *>(y_);
return cs->coll->strnncollsp(cs,
(uchar *) x->ptr(),x->length(),
(uchar *) y->ptr(),y->length());
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 3a01ea1118b..d75b1cdedde 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -58,6 +58,8 @@ static udf_func *add_udf(LEX_CSTRING *name, Item_result ret,
const char *dl, Item_udftype typ);
static void del_udf(udf_func *udf);
static void *find_udf_dl(const char *dl);
+static bool find_udf_everywhere(THD* thd, const LEX_CSTRING &name,
+ TABLE *table);
static const char *init_syms(udf_func *tmp, char *nm)
{
@@ -417,6 +419,41 @@ static udf_func *add_udf(LEX_CSTRING *name, Item_result ret, const char *dl,
return tmp;
}
+/**
+ Find record with the udf in the udf func table
+
+ @param exact_name udf name
+ @param table table of mysql.func
+
+ @retval TRUE found
+ @retral FALSE not found
+*/
+
+static bool find_udf_in_table(const LEX_CSTRING &exact_name, TABLE *table)
+{
+ table->use_all_columns();
+ table->field[0]->store(exact_name.str, exact_name.length, &my_charset_bin);
+ return (!table->file->ha_index_read_idx_map(table->record[0], 0,
+ (uchar*) table->field[0]->ptr,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT));
+}
+
+static bool remove_udf_in_table(const LEX_CSTRING &exact_name, TABLE *table)
+{
+ if (find_udf_in_table(exact_name, table))
+ {
+ int error;
+ if ((error= table->file->ha_delete_row(table->record[0])))
+ {
+ table->file->print_error(error, MYF(0));
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
/*
Drop user defined function.
@@ -433,8 +470,7 @@ static int mysql_drop_function_internal(THD *thd, udf_func *udf, TABLE *table)
{
DBUG_ENTER("mysql_drop_function_internal");
- const char *exact_name_str= udf->name.str;
- size_t exact_name_len= udf->name.length;
+ const LEX_CSTRING exact_name= udf->name;
del_udf(udf);
/*
@@ -447,18 +483,17 @@ static int mysql_drop_function_internal(THD *thd, udf_func *udf, TABLE *table)
if (!table)
DBUG_RETURN(1);
- table->use_all_columns();
- table->field[0]->store(exact_name_str, exact_name_len, &my_charset_bin);
- if (!table->file->ha_index_read_idx_map(table->record[0], 0,
- (uchar*) table->field[0]->ptr,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
- {
- int error;
- if (unlikely((error= table->file->ha_delete_row(table->record[0]))))
- table->file->print_error(error, MYF(0));
- }
- DBUG_RETURN(0);
+ bool ret= remove_udf_in_table(exact_name, table);
+ DBUG_RETURN(ret);
+}
+
+
+static TABLE *open_udf_func_table(THD *thd)
+{
+ TABLE_LIST tables;
+ tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_FUNC_NAME,
+ &MYSQL_FUNC_NAME, TL_WRITE);
+ return open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT);
}
@@ -505,8 +540,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
if (check_ident_length(&udf->name))
DBUG_RETURN(1);
- tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_FUNC_NAME, 0, TL_WRITE);
- table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT);
+ table= open_udf_func_table(thd);
mysql_rwlock_wrlock(&THR_LOCK_udf);
DEBUG_SYNC(current_thd, "mysql_create_function_after_lock");
@@ -606,42 +640,65 @@ err:
}
-int mysql_drop_function(THD *thd, const LEX_CSTRING *udf_name)
+enum drop_udf_result mysql_drop_function(THD *thd, const LEX_CSTRING *udf_name)
{
TABLE *table;
- TABLE_LIST tables;
udf_func *udf;
DBUG_ENTER("mysql_drop_function");
+ if (thd->locked_tables_mode)
+ {
+ my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
+ DBUG_RETURN(UDF_DEL_RESULT_ERROR);
+ }
+
+ if (!(table= open_udf_func_table(thd)))
+ DBUG_RETURN(UDF_DEL_RESULT_ERROR);
+
+ // Fast pre-check
+ if (!mysql_rwlock_tryrdlock(&THR_LOCK_udf))
+ {
+ bool found= find_udf_everywhere(thd, *udf_name, table);
+ mysql_rwlock_unlock(&THR_LOCK_udf);
+ if (!found)
+ {
+ close_mysql_tables(thd);
+ DBUG_RETURN(UDF_DEL_RESULT_ABSENT);
+ }
+ }
+
if (!initialized)
{
+ close_mysql_tables(thd);
if (opt_noacl)
- my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str);
- else
- my_message(ER_OUT_OF_RESOURCES, ER_THD(thd, ER_OUT_OF_RESOURCES),
- MYF(0));
- DBUG_RETURN(1);
- }
+ DBUG_RETURN(UDF_DEL_RESULT_ABSENT); // SP should be checked
- tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_FUNC_NAME, 0, TL_WRITE);
- table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT);
+ my_message(ER_OUT_OF_RESOURCES, ER_THD(thd, ER_OUT_OF_RESOURCES), MYF(0));
+ DBUG_RETURN(UDF_DEL_RESULT_ERROR);
+ }
mysql_rwlock_wrlock(&THR_LOCK_udf);
+
+ // re-check under protection
+ if (!find_udf_everywhere(thd, *udf_name, table))
+ {
+ close_mysql_tables(thd);
+ mysql_rwlock_unlock(&THR_LOCK_udf);
+ DBUG_RETURN(UDF_DEL_RESULT_ABSENT);
+ }
+
+ if (check_access(thd, DELETE_ACL, "mysql", NULL, NULL, 1, 0))
+ goto err;
+
+
DEBUG_SYNC(current_thd, "mysql_drop_function_after_lock");
+
if (!(udf= (udf_func*) my_hash_search(&udf_hash, (uchar*) udf_name->str,
(uint) udf_name->length)) )
{
- if (thd->lex->check_exists)
- {
- push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
- ER_FUNCTION_NOT_DEFINED,
- ER_THD(thd, ER_FUNCTION_NOT_DEFINED),
- udf_name->str);
- goto done;
- }
-
- my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str);
- goto err;
+ if (remove_udf_in_table(*udf_name, table))
+ goto err;
+ goto done;
}
if (mysql_drop_function_internal(thd, udf, table))
@@ -655,13 +712,24 @@ done:
while binlogging, to avoid binlog inconsistency.
*/
if (write_bin_log(thd, TRUE, thd->query(), thd->query_length()))
- DBUG_RETURN(1);
+ DBUG_RETURN(UDF_DEL_RESULT_ERROR);
- DBUG_RETURN(0);
+ close_mysql_tables(thd);
+ DBUG_RETURN(UDF_DEL_RESULT_DELETED);
err:
+ close_mysql_tables(thd);
mysql_rwlock_unlock(&THR_LOCK_udf);
- DBUG_RETURN(1);
+ DBUG_RETURN(UDF_DEL_RESULT_ERROR);
+}
+
+static bool find_udf_everywhere(THD* thd, const LEX_CSTRING &name,
+ TABLE *table)
+{
+ if (initialized && my_hash_search(&udf_hash, (uchar*) name.str, name.length))
+ return true;
+
+ return find_udf_in_table(name, table);
}
#endif /* HAVE_DLOPEN */
diff --git a/sql/sql_udf.h b/sql/sql_udf.h
index 694e4fdd9c6..97b0f640b1e 100644
--- a/sql/sql_udf.h
+++ b/sql/sql_udf.h
@@ -140,7 +140,13 @@ void udf_init(void),udf_free(void);
udf_func *find_udf(const char *name, size_t size, bool mark_used=0);
void free_udf(udf_func *udf);
int mysql_create_function(THD *thd,udf_func *udf);
-int mysql_drop_function(THD *thd, const LEX_CSTRING *name);
+enum drop_udf_result
+{
+ UDF_DEL_RESULT_ABSENT,
+ UDF_DEL_RESULT_DELETED,
+ UDF_DEL_RESULT_ERROR
+};
+enum drop_udf_result mysql_drop_function(THD *thd, const LEX_CSTRING *name);
#else
static inline void udf_init(void) { }
static inline void udf_free(void) { }
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 2eb2374091e..318ab8e7f69 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -477,6 +477,8 @@ int mysql_update(THD *thd,
query_plan.set_no_partitions();
if (thd->lex->describe || thd->lex->analyze_stmt)
goto produce_explain_and_leave;
+ if (thd->is_error())
+ DBUG_RETURN(1);
my_ok(thd); // No matching records
DBUG_RETURN(0);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b3d89eab472..0d25d0f7c1e 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2010, 2019, MariaDB
+ Copyright (c) 2010, 2020, 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
@@ -8453,6 +8453,8 @@ alter_list_item:
}
| ALTER opt_column opt_if_exists_table_element field_ident SET DEFAULT column_default_expr
{
+ if (check_expression($7, &$4, VCOL_DEFAULT))
+ MYSQL_YYABORT;
if (unlikely(Lex->add_alter_list($4.str, $7, $3)))
MYSQL_YYABORT;
}
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index a4ee6d725e3..c2684c3ea7f 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2010, 2019, MariaDB
+ Copyright (c) 2010, 2020, 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
@@ -8389,6 +8389,8 @@ alter_list_item:
}
| ALTER opt_column opt_if_exists_table_element field_ident SET DEFAULT column_default_expr
{
+ if (check_expression($7, &$4, VCOL_DEFAULT))
+ MYSQL_YYABORT;
if (unlikely(Lex->add_alter_list($4.str, $7, $3)))
MYSQL_YYABORT;
}
diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc
index 1d51f0da411..03c39d65f23 100644
--- a/sql/threadpool_common.cc
+++ b/sql/threadpool_common.cc
@@ -316,6 +316,16 @@ static void handle_wait_timeout(THD *thd)
thd->net.error= 2;
}
+/** Check if some client data is cached in thd->net or thd->net.vio */
+static bool has_unread_data(THD* thd)
+{
+ NET *net= &thd->net;
+ if (net->compress && net->remain_in_buf)
+ return true;
+ Vio *vio= net->vio;
+ return vio->has_data(vio);
+}
+
/**
Process a single client request or a single batch.
@@ -350,7 +360,6 @@ static int threadpool_process_request(THD *thd)
*/
for(;;)
{
- Vio *vio;
thd->net.reading_or_writing= 0;
if (mysql_audit_release_required(thd))
mysql_audit_release(thd);
@@ -366,8 +375,7 @@ static int threadpool_process_request(THD *thd)
set_thd_idle(thd);
- vio= thd->net.vio;
- if (!vio->has_data(vio))
+ if (!has_unread_data(thd))
{
/* More info on this debug sync is in sql_parse.cc*/
DEBUG_SYNC(thd, "before_do_command_net_read");
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index 55ea032e835..39b6267299c 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -131,8 +131,8 @@ extern const char* wsrep_provider_name;
extern const char* wsrep_provider_version;
extern const char* wsrep_provider_vendor;
-int wsrep_show_status(THD *thd, SHOW_VAR *var, char *buff,
- enum enum_var_type scope);
+int wsrep_show_status(THD *thd, SHOW_VAR *var, void *buff,
+ system_status_var *status_var, enum_var_type scope);
int wsrep_init();
void wsrep_deinit(bool free_options);
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index f18dc565329..413550935cb 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -724,8 +724,8 @@ static int show_var_cmp(const void *var1, const void *var2)
return strcasecmp(((SHOW_VAR*)var1)->name, ((SHOW_VAR*)var2)->name);
}
-int wsrep_show_status (THD *thd, SHOW_VAR *var, char *buff,
- enum enum_var_type scope)
+int wsrep_show_status (THD *thd, SHOW_VAR *var, void *buff,
+ system_status_var *, enum_var_type scope)
{
uint i, maxi= SHOW_VAR_FUNC_BUFF_SIZE / sizeof(*var) - 1;
SHOW_VAR *v= (SHOW_VAR *)buff;