summaryrefslogtreecommitdiff
path: root/sql/key.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mysql.com>2010-11-11 11:08:53 +0300
committerAlexander Barkov <bar@mysql.com>2010-11-11 11:08:53 +0300
commit0c4e115c952c8c6a429c81d844b5767cd80ad479 (patch)
tree1d982331f4effe14c88baf1c2c7517dc5e4b3a63 /sql/key.cc
parenta7a1cf0d33125fb321a90bbb9499e3aaa3ef80c9 (diff)
downloadmariadb-git-0c4e115c952c8c6a429c81d844b5767cd80ad479.tar.gz
Bug#57687 crash when reporting duplicate group_key error and utf8
Fixing DoS regression problem. Using "key_part->fieldnr - 1" to access the desired field is only correct in real INSERT queries. In case of inserting records into a temporary table when performing GROUP BY queries this expression does not work. Fix: Instead of accessing field_length and comparing it to key_part->length, there is an easier way to check if we're dealing with a prefix key: check key_part_flag against HA_PART_KEY_SEG flag.
Diffstat (limited to 'sql/key.cc')
-rw-r--r--sql/key.cc4
1 files changed, 1 insertions, 3 deletions
diff --git a/sql/key.cc b/sql/key.cc
index e28e0803986..288afd034a9 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -364,9 +364,7 @@ void key_unpack(String *to,TABLE *table,uint idx)
while (tmp_end > tmp.ptr() && !*--tmp_end) ;
tmp.length(tmp_end - tmp.ptr() + 1);
}
- if (cs->mbmaxlen > 1 &&
- table->field[key_part->fieldnr - 1]->field_length !=
- key_part->length)
+ if (cs->mbmaxlen > 1 && (key_part->key_part_flag & HA_PART_KEY_SEG))
{
/*
Prefix key, multi-byte charset.