diff options
author | Gopal Shankar <gopal.shankar@oracle.com> | 2014-06-25 09:50:17 +0530 |
---|---|---|
committer | Gopal Shankar <gopal.shankar@oracle.com> | 2014-06-25 09:50:17 +0530 |
commit | e107c24f1c7d7a0314042588a78381fc96e01288 (patch) | |
tree | 407ba44bdac859b70b6372b2fc210bbb26e6f426 /sql/table.cc | |
parent | 688416794ae69cc76bd6bc11d281705599700621 (diff) | |
download | mariadb-git-e107c24f1c7d7a0314042588a78381fc96e01288.tar.gz |
Bug#18776592 INNODB: FAILING ASSERTION: PRIMARY_KEY_NO == -1 ||
PRIMARY_KEY_NO == 0
This bug is a backport of the following revision of 5.6 source tree:
# committer: Gopal Shankar <gopal.shankar@oracle.com>
# branch nick: priKey56
# timestamp: Wed 2013-05-29 11:11:46 +0530
# message:
# Bug#16368875 INNODB: FAILING ASSERTION:
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sql/table.cc b/sql/table.cc index 67f7922a2e1..ba1839bb6ec 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1525,13 +1525,25 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, primary_key=key; for (i=0 ; i < keyinfo->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; } } |