bug#21873 MySQLD Crash on ALTER...ADD..UNIQUE..USING HASH statement for NDB...

bug#21873 MySQLD Crash on ALTER...ADD..UNIQUE..USING HASH statement for NDB backed table: Use passed key_info to check for nullable fields
parent 22ed3050
...@@ -639,3 +639,6 @@ select a, sha1(b) from t1; ...@@ -639,3 +639,6 @@ select a, sha1(b) from t1;
a sha1(b) a sha1(b)
1 08f5d02c8b8bc244f275bdfc22c42c5cab0d9d7d 1 08f5d02c8b8bc244f275bdfc22c42c5cab0d9d7d
drop table t1; drop table t1;
create table t1(id int not null) engine = NDB;
alter table t1 add constraint uk_test unique (id) using hash;
drop table t1;
...@@ -329,4 +329,12 @@ select a, sha1(b) from t1; ...@@ -329,4 +329,12 @@ select a, sha1(b) from t1;
drop table t1; drop table t1;
# bug#21873 MySQLD Crash on ALTER...ADD..UNIQUE..USING HASH statement for NDB backed table
create table t1(id int not null) engine = NDB;
alter table t1 add constraint uk_test unique (id) using hash;
drop table t1;
# End of 4.1 tests # End of 4.1 tests
...@@ -1399,9 +1399,8 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_key(uint inx, ...@@ -1399,9 +1399,8 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_key(uint inx,
ORDERED_INDEX); ORDERED_INDEX);
} }
int ha_ndbcluster::check_index_fields_not_null(uint inx) int ha_ndbcluster::check_index_fields_not_null(KEY* key_info)
{ {
KEY* key_info= table->key_info + inx;
KEY_PART_INFO* key_part= key_info->key_part; KEY_PART_INFO* key_part= key_info->key_part;
KEY_PART_INFO* end= key_part+key_info->key_parts; KEY_PART_INFO* end= key_part+key_info->key_parts;
DBUG_ENTER("ha_ndbcluster::check_index_fields_not_null"); DBUG_ENTER("ha_ndbcluster::check_index_fields_not_null");
...@@ -5016,7 +5015,7 @@ int ha_ndbcluster::create_index(const char *name, KEY *key_info, ...@@ -5016,7 +5015,7 @@ int ha_ndbcluster::create_index(const char *name, KEY *key_info,
error= create_unique_index(unique_name, key_info); error= create_unique_index(unique_name, key_info);
break; break;
case UNIQUE_INDEX: case UNIQUE_INDEX:
if (!(error= check_index_fields_not_null(idx_no))) if (!(error= check_index_fields_not_null(key_info)))
error= create_unique_index(unique_name, key_info); error= create_unique_index(unique_name, key_info);
break; break;
case ORDERED_INDEX: case ORDERED_INDEX:
......
...@@ -808,7 +808,7 @@ private: ...@@ -808,7 +808,7 @@ private:
NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const; NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const;
NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info, NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info,
bool primary) const; bool primary) const;
int check_index_fields_not_null(uint index_no); int check_index_fields_not_null(KEY *key_info);
uint set_up_partition_info(partition_info *part_info, uint set_up_partition_info(partition_info *part_info,
TABLE *table, TABLE *table,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment