summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-10-21 15:26:25 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-10-21 15:26:25 +0300
commit5f8561a6bcdb66e05ca539365cce33a9fc1817a2 (patch)
tree3ceb20e3e0e8fc1a0759199ccdf7238f31fd4267 /sql/sql_table.cc
parent3c2ab896b9642c43805a5dfc174c81fc5f902db0 (diff)
parent489ef007bec398c3b7b628325b225c3a015922cf (diff)
downloadmariadb-git-5f8561a6bcdb66e05ca539365cce33a9fc1817a2.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index d28ba06e963..92fd6dd3ea6 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4229,8 +4229,6 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
/* Align key length to multibyte char boundary */
key_part_length-= key_part_length % sql_field->charset->mbmaxlen;
}
- else
- is_hash_field_needed= true;
}
}
// Catch invalid use of partial keys
@@ -4276,11 +4274,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
else
{
- if (key->type == Key::UNIQUE)
- {
- is_hash_field_needed= true;
- }
- else
+ if (key->type != Key::UNIQUE)
{
key_part_length= MY_MIN(max_key_length, file->max_key_part_length());
my_error(ER_TOO_LONG_KEY, MYF(0), key_part_length);
@@ -4289,6 +4283,11 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
}
+ if (key->type == Key::UNIQUE
+ && key_part_length > MY_MIN(max_key_length,
+ file->max_key_part_length()))
+ is_hash_field_needed= true;
+
/* We can not store key_part_length more then 2^16 - 1 in frm */
if (is_hash_field_needed && column->length > UINT_MAX16)
{
@@ -4323,7 +4322,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
unique_key=1;
key_info->key_length=(uint16) key_length;
if (key_info->key_length > max_key_length && key->type == Key::UNIQUE)
- is_hash_field_needed= true;
+ is_hash_field_needed= true; // for case "a BLOB UNIQUE"
if (key_length > max_key_length && key->type != Key::FULLTEXT &&
!is_hash_field_needed)
{