mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
merge bug11754117-45670 fixes from 5.1.
This commit is contained in:
@ -216,6 +216,7 @@ static bool
|
||||
has_write_table_with_auto_increment(TABLE_LIST *tables);
|
||||
static bool
|
||||
has_write_table_with_auto_increment_and_select(TABLE_LIST *tables);
|
||||
static bool has_write_table_auto_increment_not_first_in_pk(TABLE_LIST *tables);
|
||||
|
||||
uint cached_open_tables(void)
|
||||
{
|
||||
@ -5690,6 +5691,12 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count,
|
||||
if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables &&
|
||||
has_write_table_with_auto_increment_and_select(tables))
|
||||
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT);
|
||||
/* Todo: merge all has_write_table_auto_inc with decide_logging_format */
|
||||
if (thd->variables.binlog_format != BINLOG_FORMAT_ROW && tables)
|
||||
{
|
||||
if (has_write_table_auto_increment_not_first_in_pk(tables))
|
||||
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_AUTOINC_NOT_FIRST);
|
||||
}
|
||||
|
||||
/*
|
||||
INSERT...ON DUPLICATE KEY UPDATE on a table with more than one unique keys
|
||||
@ -9152,6 +9159,32 @@ has_write_table_with_auto_increment_and_select(TABLE_LIST *tables)
|
||||
return(has_select && has_auto_increment_tables);
|
||||
}
|
||||
|
||||
/*
|
||||
Tells if there is a table whose auto_increment column is a part
|
||||
of a compound primary key while is not the first column in
|
||||
the table definition.
|
||||
|
||||
@param tables Table list
|
||||
|
||||
@return true if the table exists, fais if does not.
|
||||
*/
|
||||
|
||||
static bool
|
||||
has_write_table_auto_increment_not_first_in_pk(TABLE_LIST *tables)
|
||||
{
|
||||
for (TABLE_LIST *table= tables; table; table= table->next_global)
|
||||
{
|
||||
/* we must do preliminary checks as table->table may be NULL */
|
||||
if (!table->placeholder() &&
|
||||
table->table->found_next_number_field &&
|
||||
(table->lock_type >= TL_WRITE_ALLOW_WRITE)
|
||||
&& table->table->s->next_number_keypart != 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user