summaryrefslogtreecommitdiff
path: root/sql/log_event.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r--sql/log_event.cc70
1 files changed, 41 insertions, 29 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 9481261d3ef..4983263f589 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -215,8 +215,9 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error,
char buff[MAX_SLAVE_ERRMSG], *slider;
const char *buff_end= buff + sizeof(buff);
uint len;
- List_iterator_fast<MYSQL_ERROR> it(thd->warning_info->warn_list());
- MYSQL_ERROR *err;
+ Diagnostics_area::Sql_condition_iterator it=
+ thd->get_stmt_da()->sql_conditions();
+ const Sql_condition *err;
buff[0]= 0;
for (err= it++, slider= buff; err && slider < buff_end - 1;
@@ -228,7 +229,7 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error,
}
if (ha_error != 0)
- rli->report(level, thd->is_error() ? thd->stmt_da->sql_errno() : 0,
+ rli->report(level, thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0,
"Could not execute %s event on table %s.%s;"
"%s handler error %s; "
"the event's master log %s, end_log_pos %lu",
@@ -236,7 +237,7 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error,
buff, handler_error == NULL ? "<unknown>" : handler_error,
log_name, pos);
else
- rli->report(level, thd->is_error() ? thd->stmt_da->sql_errno() : 0,
+ rli->report(level, thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0,
"Could not execute %s event on table %s.%s;"
"%s the event's master log %s, end_log_pos %lu",
type, table->s->db.str, table->s->table_name.str,
@@ -440,13 +441,13 @@ inline int ignored_error_code(int err_code)
*/
int convert_handler_error(int error, THD* thd, TABLE *table)
{
- uint actual_error= (thd->is_error() ? thd->stmt_da->sql_errno() :
+ uint actual_error= (thd->is_error() ? thd->get_stmt_da()->sql_errno() :
0);
if (actual_error == 0)
{
table->file->print_error(error, MYF(0));
- actual_error= (thd->is_error() ? thd->stmt_da->sql_errno() :
+ actual_error= (thd->is_error() ? thd->get_stmt_da()->sql_errno() :
ER_UNKNOWN_ERROR);
if (actual_error == ER_UNKNOWN_ERROR)
if (global_system_variables.log_warnings)
@@ -2108,7 +2109,8 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr,
{
uint i32= uint3korr(ptr);
my_b_printf(file , "'%04d:%02d:%02d'",
- (i32 / (16L * 32L)), (i32 / 32L % 16L), (i32 % 32L));
+ (int)(i32 / (16L * 32L)), (int)(i32 / 32L % 16L),
+ (int)(i32 % 32L));
my_snprintf(typestr, typestr_length, "DATE");
return 3;
}
@@ -2236,11 +2238,11 @@ Rows_log_event::print_verbose_one_row(IO_CACHE *file, table_def *td,
if (is_null)
{
- my_b_printf(file, "### @%d=NULL", i + 1);
+ my_b_printf(file, "### @%lu=NULL", (ulong)i + 1);
}
else
{
- my_b_printf(file, "### @%d=", i + 1);
+ my_b_printf(file, "### @%lu=", (ulong)i + 1);
size_t size= log_event_print_value(file, value,
td->type(i), td->field_metadata(i),
typestr, sizeof(typestr));
@@ -2311,14 +2313,23 @@ void Rows_log_event::print_verbose(IO_CACHE *file,
if (!(map= print_event_info->m_table_map.get_table(m_table_id)) ||
!(td= map->create_table_def()))
{
- my_b_printf(file, "### Row event for unknown table #%d", m_table_id);
+ my_b_printf(file, "### Row event for unknown table #%lu",
+ (ulong) m_table_id);
return;
}
+ /* If the write rows event contained no values for the AI */
+ if (((type_code == WRITE_ROWS_EVENT) && (m_rows_buf==m_rows_end)))
+ {
+ my_b_printf(file, "### INSERT INTO `%s`.`%s` VALUES ()\n",
+ map->get_db_name(), map->get_table_name());
+ goto end;
+ }
+
for (const uchar *value= m_rows_buf; value < m_rows_end; )
{
size_t length;
- my_b_printf(file, "### %s %`s.%`s\n",
+ my_b_printf(file, "### %s '%s'.'%s'\n",
sql_command,
map->get_db_name(), map->get_table_name());
/* Print the first image */
@@ -3467,7 +3478,7 @@ void Query_log_event::print_query_header(IO_CACHE* file,
if (different_db)
memcpy(print_event_info->db, db, db_len + 1);
if (db[0] && different_db)
- my_b_printf(file, "use %`s%s\n", db, print_event_info->delimiter);
+ my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
}
end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10);
@@ -3943,7 +3954,8 @@ START SLAVE; . Query: '%s'", expected_error, thd->query());
}
/* If the query was not ignored, it is printed to the general log */
- if (!thd->is_error() || thd->stmt_da->sql_errno() != ER_SLAVE_IGNORED_TABLE)
+ if (!thd->is_error() ||
+ thd->get_stmt_da()->sql_errno() != ER_SLAVE_IGNORED_TABLE)
general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
else
{
@@ -3968,14 +3980,14 @@ compare_errors:
not exist errors", we silently clear the error if TEMPORARY was used.
*/
if (thd->lex->sql_command == SQLCOM_DROP_TABLE && thd->lex->drop_temporary &&
- thd->is_error() && thd->stmt_da->sql_errno() == ER_BAD_TABLE_ERROR &&
+ thd->is_error() && thd->get_stmt_da()->sql_errno() == ER_BAD_TABLE_ERROR &&
!expected_error)
- thd->stmt_da->reset_diagnostics_area();
+ thd->get_stmt_da()->reset_diagnostics_area();
/*
If we expected a non-zero error code, and we don't get the same error
code, and it should be ignored or is related to a concurrency issue.
*/
- actual_error= thd->is_error() ? thd->stmt_da->sql_errno() : 0;
+ actual_error= thd->is_error() ? thd->get_stmt_da()->sql_errno() : 0;
DBUG_PRINT("info",("expected_error: %d sql_errno: %d",
expected_error, actual_error));
@@ -3993,7 +4005,7 @@ Error on slave: actual message='%s', error code=%d. \
Default database: '%s'. Query: '%s'",
ER_SAFE(expected_error),
expected_error,
- actual_error ? thd->stmt_da->message() : "no error",
+ actual_error ? thd->get_stmt_da()->message() : "no error",
actual_error,
print_slave_db_safe(db), query_arg);
thd->is_slave_error= 1;
@@ -4017,7 +4029,7 @@ Default database: '%s'. Query: '%s'",
{
rli->report(ERROR_LEVEL, actual_error,
"Error '%s' on query. Default database: '%s'. Query: '%s'",
- (actual_error ? thd->stmt_da->message() :
+ (actual_error ? thd->get_stmt_da()->message() :
"unexpected success or fatal error"),
print_slave_db_safe(thd->db), query_arg);
thd->is_slave_error= 1;
@@ -5301,7 +5313,7 @@ void Load_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info,
}
if (db && db[0] && different_db)
- my_b_printf(&cache, "%suse %`s%s\n",
+ my_b_printf(&cache, "%suse %s%s\n",
commented ? "# " : "",
db, print_event_info->delimiter);
@@ -5353,7 +5365,7 @@ void Load_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info,
{
if (i)
my_b_printf(&cache, ",");
- my_b_printf(&cache, "%`s", field);
+ my_b_printf(&cache, "%s", field);
field += field_lens[i] + 1;
}
@@ -5484,7 +5496,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
{
thd->set_time(when, when_sec_part);
thd->set_query_id(next_query_id());
- thd->warning_info->opt_clear_warning_info(thd->query_id);
+ thd->get_stmt_da()->opt_clear_warning_info(thd->query_id);
TABLE_LIST tables;
tables.init_one_table(thd->strmake(thd->db, thd->db_length),
@@ -5630,9 +5642,9 @@ error:
thd->catalog= 0;
thd->set_db(NULL, 0); /* will free the current database */
thd->reset_query();
- thd->stmt_da->can_overwrite_status= TRUE;
+ thd->get_stmt_da()->set_overwrite_status(true);
thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
- thd->stmt_da->can_overwrite_status= FALSE;
+ thd->get_stmt_da()->set_overwrite_status(false);
close_thread_tables(thd);
/*
- If inside a multi-statement transaction,
@@ -5659,8 +5671,8 @@ error:
int sql_errno;
if (thd->is_error())
{
- err= thd->stmt_da->message();
- sql_errno= thd->stmt_da->sql_errno();
+ err= thd->get_stmt_da()->message();
+ sql_errno= thd->get_stmt_da()->sql_errno();
}
else
{
@@ -8496,7 +8508,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
if (open_and_lock_tables(thd, rli->tables_to_lock, FALSE, 0))
{
- uint actual_error= thd->stmt_da->sql_errno();
+ uint actual_error= thd->get_stmt_da()->sql_errno();
if (thd->is_slave_error || thd->is_fatal_error)
{
/*
@@ -8507,7 +8519,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
*/
rli->report(ERROR_LEVEL, actual_error,
"Error executing row event: '%s'",
- (actual_error ? thd->stmt_da->message() :
+ (actual_error ? thd->get_stmt_da()->message() :
"unexpected success or fatal error"));
thd->is_slave_error= 1;
}
@@ -9835,8 +9847,8 @@ void Table_map_log_event::print(FILE *, PRINT_EVENT_INFO *print_event_info)
{
print_header(&print_event_info->head_cache, print_event_info, TRUE);
my_b_printf(&print_event_info->head_cache,
- "\tTable_map: %`s.%`s mapped to number %lu\n",
- m_dbnam, m_tblnam, m_table_id);
+ "\tTable_map: '%s'.'%s' mapped to number %lu\n",
+ m_dbnam, m_tblnam, (ulong) m_table_id);
print_base64(&print_event_info->body_cache, print_event_info, TRUE);
}
}