mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#16482467 ORDER BY IGNORED IN SOME SITUATIONS FOR UPDATE QUERY
For queries like update t1 set ... where <unique key> order by ... limit ... we need to handle the fact that unique keys allow NULL values, and hence can return more than one row.
This commit is contained in:
@ -8071,15 +8071,16 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
|||||||
{
|
{
|
||||||
KEY *table_key=quick->head->key_info+quick->index;
|
KEY *table_key=quick->head->key_info+quick->index;
|
||||||
flag=EQ_RANGE;
|
flag=EQ_RANGE;
|
||||||
if ((table_key->flags & HA_NOSAME) && key->part == table_key->key_parts-1)
|
if ((table_key->flags & HA_NOSAME) &&
|
||||||
|
key_tree->part == table_key->key_parts-1)
|
||||||
{
|
{
|
||||||
if (!(table_key->flags & HA_NULL_PART_KEY) ||
|
if ((table_key->flags & HA_NULL_PART_KEY) &&
|
||||||
!null_part_in_key(key,
|
null_part_in_key(key,
|
||||||
param->min_key,
|
param->min_key,
|
||||||
(uint) (tmp_min_key - param->min_key)))
|
(uint) (tmp_min_key - param->min_key)))
|
||||||
flag|= UNIQUE_RANGE;
|
flag|= NULL_RANGE;
|
||||||
else
|
else
|
||||||
flag|= NULL_RANGE;
|
flag|= UNIQUE_RANGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8109,7 +8110,7 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return 1 if there is only one range and this uses the whole primary key
|
Return 1 if there is only one range and this uses the whole unique key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool QUICK_RANGE_SELECT::unique_key_range()
|
bool QUICK_RANGE_SELECT::unique_key_range()
|
||||||
|
Reference in New Issue
Block a user