1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +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.


mysql-test/extra/binlog_tests/binlog_insert_delayed.test:
  Updated the test file to test multi INSERT DELAYED statement
  is no longer causes an unsafe warning and binlogged as INSERT
  without DELAYED.
mysql-test/extra/rpl_tests/create_recursive_construct.inc:
  Updated for the patch of bug#54579.
mysql-test/suite/binlog/r/binlog_row_binlog.result:
  Updated for the patch of bug#54579.
mysql-test/suite/binlog/r/binlog_statement_insert_delayed.result:
  Test result for BUG#54579.
mysql-test/suite/binlog/r/binlog_stm_binlog.result:
  Updated for the patch of bug#54579.
mysql-test/suite/binlog/r/binlog_unsafe.result:
  Updated for the patch of bug#54579.
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Updated for the patch of bug#54579.
sql/sql_insert.cc:
  Added code to genetate a new query string for removing
  DELAYED keyword for multi INSERT DEALAYED statement.
sql/sql_yacc.yy:
  Added code to record the DELAYED keyword position and remove the setting
  of unsafe statement for INSERT DELAYED statement
This commit is contained in:
unknown
2010-08-30 14:03:28 +08:00
parent f5d2191052
commit 89f3fec1e3
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 ||