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

MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table

`inited == NONE` at the initialization time does not always mean
that it'll be `NONE` later, at the execution time. Use a more complex
caller-specific logic to decide whether to create a cloned lookup handler.

Besides LOAD (as in the original bug report) make sure that all
prepare_for_insert() invocations are covered by tests. Add tests for
CREATE ... SELECT, multi-UPDATE, and multi-DELETE.

Don't enable write cache with long uniques.
This commit is contained in:
Sergei Golubchik
2020-04-12 18:09:09 +02:00
parent 8c0b988073
commit fcd84da5f1
11 changed files with 133 additions and 19 deletions

View File

@ -879,8 +879,10 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
if (lock_type != TL_WRITE_DELAYED)
#endif /* EMBEDDED_LIBRARY */
{
bool create_lookup_handler= duplic != DUP_ERROR;
if (duplic != DUP_ERROR || ignore)
{
create_lookup_handler= true;
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
if (table->file->ha_table_flags() & HA_DUPLICATE_POS)
{
@ -888,7 +890,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
goto abort;
}
}
table->file->prepare_for_insert();
table->file->prepare_for_insert(create_lookup_handler);
/**
This is a simple check for the case when the table has a trigger
that reads from it, or when the statement invokes a stored function
@ -3446,7 +3448,7 @@ bool Delayed_insert::handle_inserts(void)
handler_writes() will not have called decide_logging_format.
*/
table->file->prepare_for_row_logging();
table->file->prepare_for_insert();
table->file->prepare_for_insert(1);
using_bin_log= table->file->row_logging;
/*
@ -3931,8 +3933,10 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
#endif
thd->cuted_fields=0;
bool create_lookup_handler= info.handle_duplicates != DUP_ERROR;
if (info.ignore || info.handle_duplicates != DUP_ERROR)
{
create_lookup_handler= true;
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
if (table->file->ha_table_flags() & HA_DUPLICATE_POS)
{
@ -3940,7 +3944,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
DBUG_RETURN(1);
}
}
table->file->prepare_for_insert();
table->file->prepare_for_insert(create_lookup_handler);
if (info.handle_duplicates == DUP_REPLACE &&
(!table->triggers || !table->triggers->has_delete_triggers()))
table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
@ -4698,8 +4702,10 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
restore_record(table,s->default_values); // Get empty record
thd->cuted_fields=0;
bool create_lookup_handler= info.handle_duplicates != DUP_ERROR;
if (info.ignore || info.handle_duplicates != DUP_ERROR)
{
create_lookup_handler= true;
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
if (table->file->ha_table_flags() & HA_DUPLICATE_POS)
{
@ -4707,7 +4713,7 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
DBUG_RETURN(1);
}
}
table->file->prepare_for_insert();
table->file->prepare_for_insert(create_lookup_handler);
if (info.handle_duplicates == DUP_REPLACE &&
(!table->triggers || !table->triggers->has_delete_triggers()))
table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);