summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-07-31 13:51:28 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-07-31 13:51:28 +0300
commit66ec3a770f7854f500ece66c78f3c87c9cd6da15 (patch)
tree0777df9a8dc587b70851c1edc0cfe96895928717 /sql
parent6053eb1ce278ac1f566cd74498506bf457d6d048 (diff)
parentf35d1721039f8f115fc55e8f4b4d2bb4012161d1 (diff)
downloadmariadb-git-66ec3a770f7854f500ece66c78f3c87c9cd6da15.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc3
-rw-r--r--sql/item.cc29
-rw-r--r--sql/item_create.cc2
-rw-r--r--sql/item_timefunc.cc8
-rw-r--r--sql/item_windowfunc.cc6
-rw-r--r--sql/item_windowfunc.h10
-rw-r--r--sql/log_event.cc14
-rw-r--r--sql/net_serv.cc14
-rw-r--r--sql/slave.cc3
-rw-r--r--sql/sql_base.cc43
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_class.h11
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_plugin.cc43
-rw-r--r--sql/sql_table.cc3
-rw-r--r--sql/sql_time.cc21
-rw-r--r--sql/sql_time.h11
-rw-r--r--sql/table.cc16
-rw-r--r--sql/table.h3
19 files changed, 139 insertions, 104 deletions
diff --git a/sql/field.cc b/sql/field.cc
index ff158010cb6..f5daab00670 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -11388,7 +11388,8 @@ void Field::set_datetime_warning(Sql_condition::enum_warning_level level,
THD *thd= get_thd();
if (thd->really_abort_on_warning() && level >= Sql_condition::WARN_LEVEL_WARN)
make_truncated_value_warning(thd, level, str, ts_type,
- table->s, field_name.str);
+ table->s->db.str, table->s->table_name.str,
+ field_name.str);
else
set_warning(level, code, cuted_increment);
}
diff --git a/sql/item.cc b/sql/item.cc
index ee73591f310..458a5d11bb8 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -2736,14 +2736,7 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,
bool res= FALSE;
uint i;
- /*
- In case we're in statement prepare, create conversion item
- in its memory: it will be reused on each execute.
- */
- Query_arena backup;
- Query_arena *arena= thd->stmt_arena->is_stmt_prepare() ?
- thd->activate_stmt_arena_if_needed(&backup) :
- NULL;
+ DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare());
for (i= 0, arg= args; i < nargs; i++, arg+= item_sep)
{
@@ -2765,20 +2758,8 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,
res= TRUE;
break; // we cannot return here, we need to restore "arena".
}
- /*
- If in statement prepare, then we create a converter for two
- constant items, do it once and then reuse it.
- If we're in execution of a prepared statement, arena is NULL,
- and the conv was created in runtime memory. This can be
- the case only if the argument is a parameter marker ('?'),
- because for all true constants the charset converter has already
- been created in prepare. In this case register the change for
- rollback.
- */
- if (thd->stmt_arena->is_stmt_prepare())
- *arg= conv;
- else
- thd->change_item_tree(arg, conv);
+
+ thd->change_item_tree(arg, conv);
if (conv->fix_fields(thd, arg))
{
@@ -2786,8 +2767,6 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll,
break; // we cannot return here, we need to restore "arena".
}
}
- if (arena)
- thd->restore_active_arena(arena, &backup);
return res;
}
@@ -4330,7 +4309,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
{
ErrConvTime str(&value.time);
make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
- &str, time_type, 0, 0);
+ &str, time_type, NULL, NULL, NULL);
set_zero_time(&value.time, time_type);
}
maybe_null= 0;
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 503165e69df..eb361b8222f 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -7533,7 +7533,7 @@ Item *create_temporal_literal(THD *thd,
ErrConvString err(str, length, cs);
make_truncated_value_warning(thd,
Sql_condition::time_warn_level(status.warnings),
- &err, ltime.time_type, 0, 0);
+ &err, ltime.time_type, NULL, NULL, NULL);
}
return item;
}
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 34b12ee9b55..4708a21be1c 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -431,7 +431,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
make_truncated_value_warning(current_thd,
Sql_condition::WARN_LEVEL_WARN,
val_begin, length,
- cached_timestamp_type, 0, NullS);
+ cached_timestamp_type, NULL, NULL, NULL);
break;
}
} while (++val != val_end);
@@ -1830,13 +1830,13 @@ overflow:
{
ErrConvInteger err2(sec, unsigned_flag);
make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
- &err2, MYSQL_TIMESTAMP_TIME, 0, NullS);
+ &err2, MYSQL_TIMESTAMP_TIME, NULL, NULL, NULL);
}
else
{
ErrConvString err2(err);
make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
- &err2, MYSQL_TIMESTAMP_TIME, 0, NullS);
+ &err2, MYSQL_TIMESTAMP_TIME, NULL, NULL, NULL);
}
return 0;
}
@@ -2885,7 +2885,7 @@ bool Item_func_maketime::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
int len = (int)(ptr - buf) + sprintf(ptr, ":%02u:%02u", (uint)minute, (uint)second);
make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
buf, len, MYSQL_TIMESTAMP_TIME,
- 0, NullS);
+ NULL, NULL, NULL);
}
return (null_value= 0);
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index 7c58c8c5f98..e3e2af8587f 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -557,12 +557,10 @@ void Item_window_func::print(String *str, enum_query_type query_type)
}
window_func()->print(str, query_type);
str->append(" over ");
-#ifndef DBUG_OFF
- if (!window_spec) // one can call dbug_print_item() anytime in gdb
+ if (!window_spec)
str->append(window_name);
else
-#endif
- window_spec->print(str, query_type);
+ window_spec->print(str, query_type);
}
void Item_window_func::print_for_percentile_functions(String *str, enum_query_type query_type)
{
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 977c217cd1e..81bfa8d7cd0 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -640,7 +640,7 @@ class Item_sum_ntile : public Item_sum_int,
{
public:
Item_sum_ntile(THD* thd, Item* num_quantiles_expr) :
- Item_sum_int(thd, num_quantiles_expr)
+ Item_sum_int(thd, num_quantiles_expr), n_old_val_(0)
{ }
longlong val_int()
@@ -653,11 +653,13 @@ class Item_sum_ntile : public Item_sum_int,
longlong num_quantiles= get_num_quantiles();
- if (num_quantiles <= 0) {
+ if (num_quantiles <= 0 ||
+ (static_cast<ulonglong>(num_quantiles) != n_old_val_ && n_old_val_ > 0))
+ {
my_error(ER_INVALID_NTILE_ARGUMENT, MYF(0));
return true;
}
-
+ n_old_val_= static_cast<ulonglong>(num_quantiles);
null_value= false;
ulonglong quantile_size = get_row_count() / num_quantiles;
ulonglong extra_rows = get_row_count() - quantile_size * num_quantiles;
@@ -683,6 +685,7 @@ class Item_sum_ntile : public Item_sum_int,
{
current_row_count_= 0;
partition_row_count_= 0;
+ n_old_val_= 0;
}
const char*func_name() const
@@ -702,6 +705,7 @@ class Item_sum_ntile : public Item_sum_int,
private:
longlong get_num_quantiles() { return args[0]->val_int(); }
+ ulonglong n_old_val_;
};
class Item_sum_percentile_disc : public Item_sum_num,
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 964f451a766..365529b85c9 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -14302,7 +14302,6 @@ end:
if (is_table_scan || is_index_scan)
issue_long_find_row_warning(get_general_type_code(), m_table->alias.c_ptr(),
is_index_scan, rgi);
- table->default_column_bitmaps();
DBUG_RETURN(error);
}
@@ -14633,7 +14632,13 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
#endif /* WSREP_PROC_INFO */
thd_proc_info(thd, message);
- int error= find_row(rgi);
+ // Temporary fix to find out why it fails [/Matz]
+ memcpy(m_table->read_set->bitmap, m_cols.bitmap, (m_table->read_set->n_bits + 7) / 8);
+ memcpy(m_table->write_set->bitmap, m_cols_ai.bitmap, (m_table->write_set->n_bits + 7) / 8);
+
+ m_table->mark_columns_per_binlog_row_image();
+
+ int error= find_row(rgi);
if (unlikely(error))
{
/*
@@ -14703,11 +14708,6 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi)
goto err;
}
- // Temporary fix to find out why it fails [/Matz]
- memcpy(m_table->read_set->bitmap, m_cols.bitmap, (m_table->read_set->n_bits + 7) / 8);
- memcpy(m_table->write_set->bitmap, m_cols_ai.bitmap, (m_table->write_set->n_bits + 7) / 8);
-
- m_table->mark_columns_per_binlog_row_image();
if (m_vers_from_plain && m_table->versioned(VERS_TIMESTAMP))
m_table->vers_update_fields();
error= m_table->file->ha_update_row(m_table->record[1], m_table->record[0]);
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 4fecf8bffd0..5d2ad6d17a6 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2012, 2018, MariaDB Corporation.
+ Copyright (c) 2012, 2020, 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
@@ -45,6 +45,7 @@
#include <violite.h>
#include <signal.h>
#include "probes_mysql.h"
+#include <debug_sync.h>
#include "proxy_protocol.h"
#ifdef EMBEDDED_LIBRARY
@@ -489,6 +490,17 @@ net_write_command(NET *net,uchar command,
DBUG_ENTER("net_write_command");
DBUG_PRINT("enter",("length: %lu", (ulong) len));
+ DBUG_EXECUTE_IF("simulate_error_on_packet_write",
+ {
+ if (command == COM_BINLOG_DUMP)
+ {
+ net->last_errno = ER_NET_ERROR_ON_WRITE;
+ DBUG_ASSERT(!debug_sync_set_action(
+ (THD *)net->thd,
+ STRING_WITH_LEN("now SIGNAL parked WAIT_FOR continue")));
+ DBUG_RETURN(true);
+ }
+ };);
MYSQL_NET_WRITE_START(length);
buff[4]=command; /* For first packet */
diff --git a/sql/slave.cc b/sql/slave.cc
index d4b0226b330..44fb1d0804e 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3639,7 +3639,8 @@ static int request_dump(THD *thd, MYSQL* mysql, Master_info* mi,
in the future, we should do a better error analysis, but for
now we just fill up the error log :-)
*/
- if (mysql_errno(mysql) == ER_NET_READ_INTERRUPTED)
+ if (mysql_errno(mysql) == ER_NET_READ_INTERRUPTED ||
+ mysql_errno(mysql) == ER_NET_ERROR_ON_WRITE)
*suppress_warnings= TRUE; // Suppress reconnect warning
else
sql_print_error("Error on COM_BINLOG_DUMP: %d %s, will retry in %d secs",
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 073c37e9b99..2ae768e4ec3 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5245,6 +5245,24 @@ static void mark_real_tables_as_free_for_reuse(TABLE_LIST *table_list)
}
}
+int TABLE::fix_vcol_exprs(THD *thd)
+{
+ for (Field **vf= vfield; vf && *vf; vf++)
+ if (fix_session_vcol_expr(thd, (*vf)->vcol_info))
+ return 1;
+
+ for (Field **df= default_field; df && *df; df++)
+ if ((*df)->default_value &&
+ fix_session_vcol_expr(thd, (*df)->default_value))
+ return 1;
+
+ for (Virtual_column_info **cc= check_constraints; cc && *cc; cc++)
+ if (fix_session_vcol_expr(thd, (*cc)))
+ return 1;
+
+ return 0;
+}
+
static bool fix_all_session_vcol_exprs(THD *thd, TABLE_LIST *tables)
{
@@ -5252,36 +5270,27 @@ static bool fix_all_session_vcol_exprs(THD *thd, TABLE_LIST *tables)
TABLE_LIST *first_not_own= thd->lex->first_not_own_table();
DBUG_ENTER("fix_session_vcol_expr");
- for (TABLE_LIST *table= tables; table && table != first_not_own;
+ int error= 0;
+ for (TABLE_LIST *table= tables; table && table != first_not_own && !error;
table= table->next_global)
{
TABLE *t= table->table;
if (!table->placeholder() && t->s->vcols_need_refixing &&
table->lock_type >= TL_WRITE_ALLOW_WRITE)
{
+ Query_arena *stmt_backup= thd->stmt_arena;
+ if (thd->stmt_arena->is_conventional())
+ thd->stmt_arena= t->expr_arena;
if (table->security_ctx)
thd->security_ctx= table->security_ctx;
- for (Field **vf= t->vfield; vf && *vf; vf++)
- if (fix_session_vcol_expr(thd, (*vf)->vcol_info))
- goto err;
-
- for (Field **df= t->default_field; df && *df; df++)
- if ((*df)->default_value &&
- fix_session_vcol_expr(thd, (*df)->default_value))
- goto err;
-
- for (Virtual_column_info **cc= t->check_constraints; cc && *cc; cc++)
- if (fix_session_vcol_expr(thd, (*cc)))
- goto err;
+ error= t->fix_vcol_exprs(thd);
thd->security_ctx= save_security_ctx;
+ thd->stmt_arena= stmt_backup;
}
}
- DBUG_RETURN(0);
-err:
- thd->security_ctx= save_security_ctx;
- DBUG_RETURN(1);
+ DBUG_RETURN(error);
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index f958e17a9f2..46c099dc8e2 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -3709,7 +3709,6 @@ void select_dumpvar::cleanup()
Query_arena::Type Query_arena::type() const
{
- DBUG_ASSERT(0); /* Should never be called */
return STATEMENT;
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 3a5db92e284..aa24f44dab1 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -990,7 +990,7 @@ public:
/* We build without RTTI, so dynamic_cast can't be used. */
enum Type
{
- STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE
+ STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE, TABLE_ARENA
};
Query_arena(MEM_ROOT *mem_root_arg, enum enum_state state_arg) :
@@ -3928,13 +3928,20 @@ public:
return 0;
}
+
+ bool is_item_tree_change_register_required()
+ {
+ return !stmt_arena->is_conventional()
+ || stmt_arena->type() == Query_arena::TABLE_ARENA;
+ }
+
void change_item_tree(Item **place, Item *new_value)
{
DBUG_ENTER("THD::change_item_tree");
DBUG_PRINT("enter", ("Register: %p (%p) <- %p",
*place, place, new_value));
/* TODO: check for OOM condition here */
- if (!stmt_arena->is_conventional())
+ if (is_item_tree_change_register_required())
nocheck_register_item_tree_change(place, *place, mem_root);
*place= new_value;
DBUG_VOID_RETURN;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 835848d56e4..ac73b5e9cdf 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7830,8 +7830,8 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
sp_cache_enforce_limit(thd->sp_package_spec_cache, stored_program_cache_size);
sp_cache_enforce_limit(thd->sp_package_body_cache, stored_program_cache_size);
thd->end_statement();
+ thd->Item_change_list::rollback_item_tree_changes();
thd->cleanup_after_query();
- DBUG_ASSERT(thd->Item_change_list::is_empty());
}
else
{
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 4d38a400bb7..ffb7d747537 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -2240,26 +2240,30 @@ static bool do_uninstall(THD *thd, TABLE *table, const LEX_CSTRING *name)
if (!(plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)) ||
plugin->state & (PLUGIN_IS_UNINITIALIZED | PLUGIN_IS_DYING))
{
- my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
- return 1;
- }
- if (!plugin->plugin_dl)
- {
- my_error(ER_PLUGIN_DELETE_BUILTIN, MYF(0));
- return 1;
+ // maybe plugin is in mysql.plugin present so postpond the error
+ plugin= NULL;
}
- if (plugin->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
+
+ if (plugin)
{
- my_error(ER_PLUGIN_IS_PERMANENT, MYF(0), name->str);
- return 1;
- }
+ if (!plugin->plugin_dl)
+ {
+ my_error(ER_PLUGIN_DELETE_BUILTIN, MYF(0));
+ return 1;
+ }
+ if (plugin->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
+ {
+ my_error(ER_PLUGIN_IS_PERMANENT, MYF(0), name->str);
+ return 1;
+ }
- plugin->state= PLUGIN_IS_DELETED;
- if (plugin->ref_count)
- push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
- WARN_PLUGIN_BUSY, ER_THD(thd, WARN_PLUGIN_BUSY));
- else
- reap_needed= true;
+ plugin->state= PLUGIN_IS_DELETED;
+ if (plugin->ref_count)
+ push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
+ WARN_PLUGIN_BUSY, ER_THD(thd, WARN_PLUGIN_BUSY));
+ else
+ reap_needed= true;
+ }
uchar user_key[MAX_KEY_LENGTH];
table->use_all_columns();
@@ -2284,6 +2288,11 @@ static bool do_uninstall(THD *thd, TABLE *table, const LEX_CSTRING *name)
return 1;
}
}
+ else if (!plugin)
+ {
+ my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
+ return 1;
+ }
return 0;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 85b8bfcd340..7c448dea4b1 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -10286,7 +10286,8 @@ err_new_table_cleanup:
thd->abort_on_warning= true;
make_truncated_value_warning(thd, Sql_condition::WARN_LEVEL_WARN,
f_val, strlength(f_val), t_type,
- new_table ? new_table->s : table->s,
+ alter_ctx.new_db.str,
+ alter_ctx.new_name.str,
alter_ctx.datetime_field->field_name.str);
thd->abort_on_warning= save_abort_on_warning;
}
diff --git a/sql/sql_time.cc b/sql/sql_time.cc
index 68e0f2acc12..a629e006c04 100644
--- a/sql/sql_time.cc
+++ b/sql/sql_time.cc
@@ -18,7 +18,6 @@
/* Functions to handle date and time */
#include "mariadb.h"
-#include "sql_priv.h"
#include "sql_time.h"
#include "tztime.h" // struct Time_zone
#include "sql_class.h" // THD
@@ -297,7 +296,7 @@ check_date_with_warn(const MYSQL_TIME *ltime, ulonglong fuzzy_date,
{
ErrConvTime str(ltime);
make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
- &str, ts_type, 0, 0);
+ &str, ts_type, NULL, NULL, NULL);
return true;
}
return false;
@@ -314,7 +313,7 @@ adjust_time_range_with_warn(MYSQL_TIME *ltime, uint dec)
return true;
if (warnings)
make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
- &str, MYSQL_TIMESTAMP_TIME, 0, NullS);
+ &str, MYSQL_TIMESTAMP_TIME, NULL, NULL, NULL);
return false;
}
@@ -403,7 +402,8 @@ str_to_datetime_with_warn(CHARSET_INFO *cs,
ret_val ? Sql_condition::WARN_LEVEL_WARN :
Sql_condition::time_warn_level(status.warnings),
str, length, flags & TIME_TIME_ONLY ?
- MYSQL_TIMESTAMP_TIME : l_time->time_type, 0, NullS);
+ MYSQL_TIMESTAMP_TIME : l_time->time_type,
+ NULL, NULL, NULL);
DBUG_EXECUTE_IF("str_to_datetime_warn",
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_YES, str););
@@ -460,7 +460,8 @@ static bool number_to_time_with_warn(bool neg, ulonglong nr, ulong sec_part,
make_truncated_value_warning(current_thd,
Sql_condition::WARN_LEVEL_WARN, str,
res < 0 ? MYSQL_TIMESTAMP_ERROR : ts_type,
- s, field_name);
+ s ? s->db.str : NULL,
+ s ? s->table_name.str : NULL, field_name);
}
return res < 0;
}
@@ -933,7 +934,8 @@ void make_truncated_value_warning(THD *thd,
Sql_condition::enum_warning_level level,
const ErrConv *sval,
timestamp_type time_type,
- const TABLE_SHARE *s, const char *field_name)
+ const char *db_name, const char *table_name,
+ const char *field_name)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
const char *type_str;
@@ -953,9 +955,6 @@ void make_truncated_value_warning(THD *thd,
}
if (field_name)
{
- const char *db_name= s->db.str;
- const char *table_name= s->table_name.str;
-
if (!db_name)
db_name= "";
if (!table_name)
@@ -1293,7 +1292,7 @@ make_date_with_warn(MYSQL_TIME *ltime, ulonglong fuzzy_date,
/* e.g. negative time */
ErrConvTime str(ltime);
make_truncated_value_warning(current_thd, Sql_condition::WARN_LEVEL_WARN,
- &str, ts_type, 0, 0);
+ &str, ts_type, NULL, NULL, NULL);
return true;
}
if ((ltime->time_type= ts_type) == MYSQL_TIMESTAMP_DATE)
@@ -1457,7 +1456,7 @@ time_to_datetime_with_warn(THD *thd,
{
ErrConvTime str(from);
make_truncated_value_warning(thd, Sql_condition::WARN_LEVEL_WARN,
- &str, MYSQL_TIMESTAMP_DATETIME, 0, 0);
+ &str, MYSQL_TIMESTAMP_DATETIME, NULL, NULL, NULL);
return true;
}
return false;
diff --git a/sql/sql_time.h b/sql/sql_time.h
index 1b121cb36b9..a0eea359c6a 100644
--- a/sql/sql_time.h
+++ b/sql/sql_time.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates.
- Copyright (c) 2011, 2016, MariaDB
+ Copyright (c) 2011, 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
@@ -118,15 +118,18 @@ void make_truncated_value_warning(THD *thd,
Sql_condition::enum_warning_level level,
const ErrConv *str_val,
timestamp_type time_type,
- const TABLE_SHARE *s, const char *field_name);
+ const char *db_name, const char *table_name,
+ const char *field_name);
static inline void make_truncated_value_warning(THD *thd,
Sql_condition::enum_warning_level level, const char *str_val,
size_t str_length, timestamp_type time_type,
- const TABLE_SHARE *s, const char *field_name)
+ const char *db_name, const char *table_name,
+ const char *field_name)
{
const ErrConvString str(str_val, str_length, &my_charset_bin);
- make_truncated_value_warning(thd, level, &str, time_type, s, field_name);
+ make_truncated_value_warning(thd, level, &str, time_type, db_name, table_name,
+ field_name);
}
extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type,
diff --git a/sql/table.cc b/sql/table.cc
index 84c827ec70b..403b68551a0 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -49,6 +49,17 @@
#define MYSQL57_GENERATED_FIELD 128
#define MYSQL57_GCOL_HEADER_SIZE 4
+class Table_arena: public Query_arena
+{
+public:
+ Table_arena(MEM_ROOT *mem_root, enum enum_state state_arg) :
+ Query_arena(mem_root, state_arg){}
+ virtual Type type() const
+ {
+ return TABLE_ARENA;
+ }
+};
+
static Virtual_column_info * unpack_vcol_info_from_frm(THD *, MEM_ROOT *,
TABLE *, String *, Virtual_column_info **, bool *);
static bool check_vcol_forward_refs(Field *, Virtual_column_info *,
@@ -1030,8 +1041,9 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
We need to use CONVENTIONAL_EXECUTION here to ensure that
any new items created by fix_fields() are not reverted.
*/
- table->expr_arena= new (alloc_root(mem_root, sizeof(Query_arena)))
- Query_arena(mem_root, Query_arena::STMT_CONVENTIONAL_EXECUTION);
+ table->expr_arena= new (alloc_root(mem_root, sizeof(Table_arena)))
+ Table_arena(mem_root,
+ Query_arena::STMT_CONVENTIONAL_EXECUTION);
if (!table->expr_arena)
DBUG_RETURN(1);
diff --git a/sql/table.h b/sql/table.h
index d289b6e0ab2..a5821a712c6 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1,7 +1,7 @@
#ifndef TABLE_INCLUDED
#define TABLE_INCLUDED
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
- Copyright (c) 2009, 2019, MariaDB
+ Copyright (c) 2009, 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
@@ -1599,6 +1599,7 @@ public:
TABLE *tmp_table,
TMP_TABLE_PARAM *tmp_table_param,
bool with_cleanup);
+ int fix_vcol_exprs(THD *thd);
Field *find_field_by_name(LEX_CSTRING *str) const;
bool export_structure(THD *thd, class Row_definition_list *defs);
bool is_splittable() { return spl_opt_info != NULL; }