mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
WL#4454 change sql_insert.cc::last_uniq_key to match keys in any order
Introduce a flag that will enable the REPLACE command to work correctly with an underlying storage engine that does not report unique key conflicts in the ascending order. sql/handler.h: WL#4454 change sql_insert.cc::last_uniq_key to match keys in any order Adds the flag that will be set by a SE that does not report unique key conflicts in the ascending order. sql/sql_insert.cc: WL#4454 change sql_insert.cc::last_uniq_key to match keys in any order modifies the function used for a last row replace optimization to check for the HA_DUPLICATE_KEY_NOT_IN_ORDER flag.
This commit is contained in:
@@ -1322,6 +1322,23 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
|
||||
|
||||
static int last_uniq_key(TABLE *table,uint keynr)
|
||||
{
|
||||
/*
|
||||
When an underlying storage engine informs that the unique key
|
||||
conflicts are not reported in the ascending order by setting
|
||||
the HA_DUPLICATE_KEY_NOT_IN_ORDER flag, we cannot rely on this
|
||||
information to determine the last key conflict.
|
||||
|
||||
The information about the last key conflict will be used to
|
||||
do a replace of the new row on the conflicting row, rather
|
||||
than doing a delete (of old row) + insert (of new row).
|
||||
|
||||
Hence check for this flag and disable replacing the last row
|
||||
by returning 0 always. Returning 0 will result in doing
|
||||
a delete + insert always.
|
||||
*/
|
||||
if (table->file->ha_table_flags() & HA_DUPLICATE_KEY_NOT_IN_ORDER)
|
||||
return 0;
|
||||
|
||||
while (++keynr < table->s->keys)
|
||||
if (table->key_info[keynr].flags & HA_NOSAME)
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user