diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-08-07 18:06:56 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-08-07 18:06:56 +0200 |
commit | 6fb17a06016506498f4de75ff754f500f9f674f1 (patch) | |
tree | d03c86959f150edc0f6f27ca2c06ccbc0e6e5bf0 /sql/table.cc | |
parent | 2023fac28130d7d3f7d6776332239c62c3890195 (diff) | |
parent | a4ab2431a20f6e2198d980f8e84fa7118515ca3b (diff) | |
download | mariadb-git-6fb17a06016506498f4de75ff754f500f9f674f1.tar.gz |
5.5.39 merge
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/sql/table.cc b/sql/table.cc index 23761e02831..c951351fba8 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1774,13 +1774,25 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, key_part= keyinfo->key_part; for (i=0 ; i < keyinfo->user_defined_key_parts ;i++) { - uint fieldnr= key_part[i].fieldnr; - if (!fieldnr || - share->field[fieldnr-1]->null_ptr || - share->field[fieldnr-1]->key_length() != - key_part[i].length) + DBUG_ASSERT(key_part[i].fieldnr > 0); + // Table field corresponding to the i'th key part. + Field *table_field= share->field[key_part[i].fieldnr - 1]; + + /* + If the key column is of NOT NULL BLOB type, then it + will definitly have key prefix. And if key part prefix size + is equal to the BLOB column max size, then we can promote + it to primary key. + */ + if (!table_field->real_maybe_null() && + table_field->type() == MYSQL_TYPE_BLOB && + table_field->field_length == key_part[i].length) + continue; + + if (table_field->real_maybe_null() || + table_field->key_length() != key_part[i].length) { - primary_key=MAX_KEY; // Can't be used + primary_key= MAX_KEY; // Can't be used break; } } @@ -4210,7 +4222,8 @@ bool TABLE_LIST::create_field_translation(THD *thd) while ((item= it++)) { - transl[field_count].name= item->name; + DBUG_ASSERT(item->name && item->name[0]); + transl[field_count].name= thd->strdup(item->name); transl[field_count++].item= item; } field_translation= transl; |