mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Applied all changes from Igor and Sanja
This commit is contained in:
143
sql/sql_class.cc
143
sql/sql_class.cc
@@ -691,7 +691,7 @@ int thd_tx_is_read_only(const THD *thd)
|
||||
extern "C"
|
||||
void thd_inc_row_count(THD *thd)
|
||||
{
|
||||
thd->warning_info->inc_current_row_for_warning();
|
||||
thd->get_stmt_da()->inc_current_row_for_warning();
|
||||
}
|
||||
|
||||
|
||||
@@ -810,9 +810,9 @@ char *thd_security_context(THD *thd, char *buffer, unsigned int length,
|
||||
bool Drop_table_error_handler::handle_condition(THD *thd,
|
||||
uint sql_errno,
|
||||
const char* sqlstate,
|
||||
MYSQL_ERROR::enum_warning_level level,
|
||||
Sql_condition::enum_warning_level level,
|
||||
const char* msg,
|
||||
MYSQL_ERROR ** cond_hdl)
|
||||
Sql_condition ** cond_hdl)
|
||||
{
|
||||
*cond_hdl= NULL;
|
||||
return ((sql_errno == EE_DELETE && my_errno == ENOENT) ||
|
||||
@@ -835,8 +835,6 @@ THD::THD()
|
||||
stmt_depends_on_first_successful_insert_id_in_prev_stmt(FALSE),
|
||||
m_examined_row_count(0),
|
||||
accessed_rows_and_keys(0),
|
||||
warning_info(&main_warning_info),
|
||||
stmt_da(&main_da),
|
||||
m_statement_psi(NULL),
|
||||
m_idle_psi(NULL),
|
||||
m_server_idle(false),
|
||||
@@ -856,7 +854,8 @@ THD::THD()
|
||||
#if defined(ENABLED_DEBUG_SYNC)
|
||||
debug_sync_control(0),
|
||||
#endif /* defined(ENABLED_DEBUG_SYNC) */
|
||||
main_warning_info(0, false, false)
|
||||
main_da(0, false),
|
||||
m_stmt_da(&main_da)
|
||||
{
|
||||
ulong tmp;
|
||||
|
||||
@@ -868,8 +867,8 @@ THD::THD()
|
||||
THD *old_THR_THD= current_thd;
|
||||
set_current_thd(this);
|
||||
status_var.memory_used= 0;
|
||||
main_da.init();
|
||||
|
||||
main_warning_info.init();
|
||||
/*
|
||||
Pass nominal parameters to init_alloc_root only to ensure that
|
||||
the destructor works OK in case of an error. The main_mem_root
|
||||
@@ -1029,9 +1028,9 @@ void THD::push_internal_handler(Internal_error_handler *handler)
|
||||
|
||||
bool THD::handle_condition(uint sql_errno,
|
||||
const char* sqlstate,
|
||||
MYSQL_ERROR::enum_warning_level level,
|
||||
Sql_condition::enum_warning_level level,
|
||||
const char* msg,
|
||||
MYSQL_ERROR ** cond_hdl)
|
||||
Sql_condition ** cond_hdl)
|
||||
{
|
||||
if (!m_internal_handler)
|
||||
{
|
||||
@@ -1068,7 +1067,7 @@ void THD::raise_error(uint sql_errno)
|
||||
const char* msg= ER(sql_errno);
|
||||
(void) raise_condition(sql_errno,
|
||||
NULL,
|
||||
MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||
Sql_condition::WARN_LEVEL_ERROR,
|
||||
msg);
|
||||
}
|
||||
|
||||
@@ -1084,7 +1083,7 @@ void THD::raise_error_printf(uint sql_errno, ...)
|
||||
va_end(args);
|
||||
(void) raise_condition(sql_errno,
|
||||
NULL,
|
||||
MYSQL_ERROR::WARN_LEVEL_ERROR,
|
||||
Sql_condition::WARN_LEVEL_ERROR,
|
||||
ebuff);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@@ -1094,7 +1093,7 @@ void THD::raise_warning(uint sql_errno)
|
||||
const char* msg= ER(sql_errno);
|
||||
(void) raise_condition(sql_errno,
|
||||
NULL,
|
||||
MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
Sql_condition::WARN_LEVEL_WARN,
|
||||
msg);
|
||||
}
|
||||
|
||||
@@ -1110,7 +1109,7 @@ void THD::raise_warning_printf(uint sql_errno, ...)
|
||||
va_end(args);
|
||||
(void) raise_condition(sql_errno,
|
||||
NULL,
|
||||
MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
Sql_condition::WARN_LEVEL_WARN,
|
||||
ebuff);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@@ -1124,7 +1123,7 @@ void THD::raise_note(uint sql_errno)
|
||||
const char* msg= ER(sql_errno);
|
||||
(void) raise_condition(sql_errno,
|
||||
NULL,
|
||||
MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||
Sql_condition::WARN_LEVEL_NOTE,
|
||||
msg);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@@ -1143,24 +1142,25 @@ void THD::raise_note_printf(uint sql_errno, ...)
|
||||
va_end(args);
|
||||
(void) raise_condition(sql_errno,
|
||||
NULL,
|
||||
MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||
Sql_condition::WARN_LEVEL_NOTE,
|
||||
ebuff);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
MYSQL_ERROR* THD::raise_condition(uint sql_errno,
|
||||
Sql_condition* THD::raise_condition(uint sql_errno,
|
||||
const char* sqlstate,
|
||||
MYSQL_ERROR::enum_warning_level level,
|
||||
Sql_condition::enum_warning_level level,
|
||||
const char* msg)
|
||||
{
|
||||
MYSQL_ERROR *cond= NULL;
|
||||
Diagnostics_area *da= get_stmt_da();
|
||||
Sql_condition *cond= NULL;
|
||||
DBUG_ENTER("THD::raise_condition");
|
||||
|
||||
if (!(variables.option_bits & OPTION_SQL_NOTES) &&
|
||||
(level == MYSQL_ERROR::WARN_LEVEL_NOTE))
|
||||
(level == Sql_condition::WARN_LEVEL_NOTE))
|
||||
DBUG_RETURN(NULL);
|
||||
|
||||
warning_info->opt_clear_warning_info(query_id);
|
||||
da->opt_clear_warning_info(query_id);
|
||||
|
||||
/*
|
||||
TODO: replace by DBUG_ASSERT(sql_errno != 0) once all bugs similar to
|
||||
@@ -1174,24 +1174,24 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno,
|
||||
if (sqlstate == NULL)
|
||||
sqlstate= mysql_errno_to_sqlstate(sql_errno);
|
||||
|
||||
if ((level == MYSQL_ERROR::WARN_LEVEL_WARN) &&
|
||||
if ((level == Sql_condition::WARN_LEVEL_WARN) &&
|
||||
really_abort_on_warning())
|
||||
{
|
||||
/*
|
||||
FIXME:
|
||||
push_warning and strict SQL_MODE case.
|
||||
*/
|
||||
level= MYSQL_ERROR::WARN_LEVEL_ERROR;
|
||||
level= Sql_condition::WARN_LEVEL_ERROR;
|
||||
killed= KILL_BAD_DATA;
|
||||
}
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case MYSQL_ERROR::WARN_LEVEL_NOTE:
|
||||
case MYSQL_ERROR::WARN_LEVEL_WARN:
|
||||
case Sql_condition::WARN_LEVEL_NOTE:
|
||||
case Sql_condition::WARN_LEVEL_WARN:
|
||||
got_warning= 1;
|
||||
break;
|
||||
case MYSQL_ERROR::WARN_LEVEL_ERROR:
|
||||
case Sql_condition::WARN_LEVEL_ERROR:
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(FALSE);
|
||||
@@ -1200,14 +1200,14 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno,
|
||||
if (handle_condition(sql_errno, sqlstate, level, msg, &cond))
|
||||
DBUG_RETURN(cond);
|
||||
|
||||
if (level == MYSQL_ERROR::WARN_LEVEL_ERROR)
|
||||
if (level == Sql_condition::WARN_LEVEL_ERROR)
|
||||
{
|
||||
is_slave_error= 1; // needed to catch query errors during replication
|
||||
|
||||
if (! stmt_da->is_error())
|
||||
if (!da->is_error())
|
||||
{
|
||||
set_row_count_func(-1);
|
||||
stmt_da->set_error_status(this, sql_errno, msg, sqlstate);
|
||||
da->set_error_status(sql_errno, msg, sqlstate, cond);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1216,7 +1216,7 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno,
|
||||
/* When simulating OOM, skip writing to error log to avoid mtr errors */
|
||||
DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_RETURN(NULL););
|
||||
|
||||
cond= warning_info->push_warning(this, sql_errno, sqlstate, level, msg);
|
||||
da->push_warning(this, sql_errno, sqlstate, level, msg);
|
||||
DBUG_RETURN(cond);
|
||||
}
|
||||
|
||||
@@ -1553,7 +1553,7 @@ THD::~THD()
|
||||
#endif
|
||||
|
||||
free_root(&main_mem_root, MYF(0));
|
||||
main_warning_info.free_memory();
|
||||
main_da.free_memory();
|
||||
if (status_var.memory_used != 0)
|
||||
{
|
||||
DBUG_PRINT("error", ("memory_used: %lld", status_var.memory_used));
|
||||
@@ -1942,42 +1942,6 @@ void THD::cleanup_after_query()
|
||||
table_map_for_update= 0;
|
||||
m_binlog_invoker= FALSE;
|
||||
|
||||
extern "C" enum durability_properties thd_get_durability_property(const MYSQL_THD thd)
|
||||
{
|
||||
enum durability_properties ret= HA_REGULAR_DURABILITY;
|
||||
|
||||
if (thd != NULL)
|
||||
ret= thd->durability_property;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Get the auto_increment_offset auto_increment_increment.
|
||||
Needed by InnoDB.
|
||||
@param thd Thread object
|
||||
@param off auto_increment_offset
|
||||
@param inc auto_increment_increment */
|
||||
extern "C" void thd_get_autoinc(const MYSQL_THD thd, ulong* off, ulong* inc)
|
||||
{
|
||||
*off = thd->variables.auto_increment_offset;
|
||||
*inc = thd->variables.auto_increment_increment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Is strict sql_mode set.
|
||||
Needed by InnoDB.
|
||||
@param thd Thread object
|
||||
@return True if sql_mode has strict mode (all or trans).
|
||||
@retval true sql_mode has strict mode (all or trans).
|
||||
@retval false sql_mode has not strict mode (all or trans).
|
||||
*/
|
||||
extern "C" bool thd_is_strict_mode(const MYSQL_THD thd)
|
||||
{
|
||||
return thd->is_strict_mode();
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (rli_slave)
|
||||
rli_slave->cleanup_after_query();
|
||||
@@ -2691,7 +2655,7 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
|
||||
|
||||
Non-ASCII separator arguments are not fully supported
|
||||
*/
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED,
|
||||
ER(WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED));
|
||||
}
|
||||
@@ -2722,7 +2686,7 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
|
||||
(exchange->opt_enclosed && non_string_results &&
|
||||
field_term_length && strchr(NUMERIC_CHARS, field_term_char)))
|
||||
{
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_AMBIGUOUS_FIELD_TERM, ER(ER_AMBIGUOUS_FIELD_TERM));
|
||||
is_ambiguous_field_term= TRUE;
|
||||
}
|
||||
@@ -2805,7 +2769,7 @@ int select_export::send_data(List<Item> &items)
|
||||
convert_to_printable(printable_buff, sizeof(printable_buff),
|
||||
error_pos, res->ptr() + res->length() - error_pos,
|
||||
res->charset(), 6);
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
|
||||
ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
|
||||
"string", printable_buff,
|
||||
@@ -2816,7 +2780,7 @@ int select_export::send_data(List<Item> &items)
|
||||
/*
|
||||
result is longer than UINT_MAX32 and doesn't fit into String
|
||||
*/
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED),
|
||||
item->full_name(), static_cast<long>(row_count));
|
||||
}
|
||||
@@ -3621,7 +3585,7 @@ int select_dumpvar::send_data(List<Item> &items)
|
||||
bool select_dumpvar::send_eof()
|
||||
{
|
||||
if (! row_count)
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
ER_SP_FETCH_NO_DATA, ER(ER_SP_FETCH_NO_DATA));
|
||||
/*
|
||||
Don't send EOF if we're in error condition (which implies we've already
|
||||
@@ -4202,6 +4166,41 @@ extern "C" bool thd_sqlcom_can_generate_row_events(const MYSQL_THD thd)
|
||||
}
|
||||
|
||||
|
||||
extern "C" enum durability_properties thd_get_durability_property(const MYSQL_THD thd)
|
||||
{
|
||||
enum durability_properties ret= HA_REGULAR_DURABILITY;
|
||||
|
||||
if (thd != NULL)
|
||||
ret= thd->durability_property;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Get the auto_increment_offset auto_increment_increment.
|
||||
Needed by InnoDB.
|
||||
@param thd Thread object
|
||||
@param off auto_increment_offset
|
||||
@param inc auto_increment_increment */
|
||||
extern "C" void thd_get_autoinc(const MYSQL_THD thd, ulong* off, ulong* inc)
|
||||
{
|
||||
*off = thd->variables.auto_increment_offset;
|
||||
*inc = thd->variables.auto_increment_increment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Is strict sql_mode set.
|
||||
Needed by InnoDB.
|
||||
@param thd Thread object
|
||||
@return True if sql_mode has strict mode (all or trans).
|
||||
@retval true sql_mode has strict mode (all or trans).
|
||||
@retval false sql_mode has not strict mode (all or trans).
|
||||
*/
|
||||
extern "C" bool thd_is_strict_mode(const MYSQL_THD thd)
|
||||
{
|
||||
return thd->is_strict_mode();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Interface for MySQL Server, plugins and storage engines to report
|
||||
@@ -5691,7 +5690,7 @@ void THD::issue_unsafe_warnings()
|
||||
{
|
||||
if ((unsafe_type_flags & (1 << unsafe_type)) != 0)
|
||||
{
|
||||
push_warning_printf(this, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||
push_warning_printf(this, Sql_condition::WARN_LEVEL_NOTE,
|
||||
ER_BINLOG_UNSAFE_STATEMENT,
|
||||
ER(ER_BINLOG_UNSAFE_STATEMENT),
|
||||
ER(LEX::binlog_stmt_unsafe_errcode[unsafe_type]));
|
||||
|
Reference in New Issue
Block a user