1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Bug #54579 Wrong unsafe warning for INSERT DELAYED in SBR

The lock_type is upgrade to TL_WRITE from TL_WRITE_DELAYED for
INSERT DELAYED when inserting multi values in one statement.
It's safe. But it causes an unsafe warning in SBR.
      
Make INSERT DELAYED safe by logging it as INSERT without DELAYED.
This commit is contained in:
2010-08-30 14:03:28 +08:00
parent 19908377b8
commit 0688c086a0
10 changed files with 139 additions and 122 deletions

View File

@ -620,6 +620,32 @@ bool open_and_lock_for_insert_delayed(THD *thd, TABLE_LIST *table_list)
}
/**
Create a new query string for removing DELAYED keyword for
multi INSERT DEALAYED statement.
@param[in] thd Thread handler
@param[in] buf Query string
@return
0 ok
1 error
*/
static int
create_insert_stmt_from_insert_delayed(THD *thd, String *buf)
{
/* Append the part of thd->query before "DELAYED" keyword */
if (buf->append(thd->query(),
thd->lex->keyword_delayed_begin - thd->query()))
return 1;
/* Append the part of thd->query after "DELAYED" keyword */
if (buf->append(thd->lex->keyword_delayed_begin + 7))
return 1;
return 0;
}
/**
INSERT statement implementation
@ -999,13 +1025,28 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
such case the flag is ignored for constructing binlog event.
*/
DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0);
if (thd->binlog_query(THD::ROW_QUERY_TYPE,
thd->query(), thd->query_length(),
transactional_table, FALSE, FALSE,
errcode))
if (was_insert_delayed && table_list->lock_type == TL_WRITE)
{
/* Binlog multi INSERT DELAYED as INSERT without DELAYED. */
String log_query;
if (create_insert_stmt_from_insert_delayed(thd, &log_query))
{
sql_print_error("Event Error: An error occurred while creating query string"
"for INSERT DELAYED stmt, before writing it into binary log.");
error= 1;
}
else if (thd->binlog_query(THD::ROW_QUERY_TYPE,
log_query.c_ptr(), log_query.length(),
transactional_table, FALSE, FALSE,
errcode))
error= 1;
}
else if (thd->binlog_query(THD::ROW_QUERY_TYPE,
thd->query(), thd->query_length(),
transactional_table, FALSE, FALSE,
errcode))
error= 1;
}
}
}
DBUG_ASSERT(transactional_table || !changed ||