summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2013-09-10 11:20:29 +0200
committerTor Didriksen <tor.didriksen@oracle.com>2013-09-10 11:20:29 +0200
commitb9ec18374165acc1081c810104d0371c444fe49d (patch)
treec47289dc7cb5d641256de0b89d3c6fc77756a8b2 /sql/opt_range.cc
parenta88bac6c664a6abff14ce5c5586e6483db3f7828 (diff)
downloadmariadb-git-b9ec18374165acc1081c810104d0371c444fe49d.tar.gz
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. sql/opt_range.cc: When the unique key has multiple key parts, check each key_part for nullability, rather than the first key part. (s/key->part ==/key_tree->part ==/) Also: revert the if() test, for better readability.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 386faed3aa2..c7a7d2531af 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -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;
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) ||
- !null_part_in_key(key,
- param->min_key,
- (uint) (tmp_min_key - param->min_key)))
- flag|= UNIQUE_RANGE;
- else
- flag|= NULL_RANGE;
+ if ((table_key->flags & HA_NULL_PART_KEY) &&
+ null_part_in_key(key,
+ param->min_key,
+ (uint) (tmp_min_key - param->min_key)))
+ flag|= NULL_RANGE;
+ else
+ 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()