diff --git a/src/box/memtx_engine.cc b/src/box/memtx_engine.cc index 9e51618d06f76e8f256644d58c9ebe8a95ba39bd..81cfca2c01c8cbf16540c2a6f3bc44277cdca000 100644 --- a/src/box/memtx_engine.cc +++ b/src/box/memtx_engine.cc @@ -887,7 +887,14 @@ MemtxEngine::keydefCheck(struct space *space, struct key_def *key_def) space_name(space), "RTREE index can not be unique"); } - break; + if (key_def->parts[0].type != ARRAY) { + tnt_raise(ClientError, ER_MODIFY_INDEX, + key_def->name, + space_name(space), + "RTREE index field type must be ARRAY"); + } + /* no furter checks of parts needed */ + return; case BITSET: if (key_def->part_count != 1) { tnt_raise(ClientError, ER_MODIFY_INDEX, @@ -901,38 +908,29 @@ MemtxEngine::keydefCheck(struct space *space, struct key_def *key_def) space_name(space), "BITSET can not be unique"); } - break; + if (key_def->parts[0].type != NUM && + key_def->parts[0].type != STRING) { + tnt_raise(ClientError, ER_MODIFY_INDEX, + key_def->name, + space_name(space), + "BITSET index field type must be NUM or STR"); + } + /* no furter checks of parts needed */ + return; default: tnt_raise(ClientError, ER_INDEX_TYPE, key_def->name, space_name(space)); break; } + /* Only HASH and TREE indexes checks parts there */ + /* Just check that there are no ARRAY parts */ for (uint32_t i = 0; i < key_def->part_count; i++) { - switch (key_def->parts[i].type) { - case NUM: - case STRING: - case INT: - case NUMBER: - case SCALAR: - if (key_def->type == RTREE) { - tnt_raise(ClientError, ER_MODIFY_INDEX, - key_def->name, - space_name(space), - "RTREE index field type must be ARRAY"); - } - break; - case ARRAY: - if (key_def->type != RTREE) { - tnt_raise(ClientError, ER_MODIFY_INDEX, - key_def->name, - space_name(space), - "ARRAY field type is not supported"); - } - break; - default: - unreachable(); - break; + if (key_def->parts[i].type == ARRAY) { + tnt_raise(ClientError, ER_MODIFY_INDEX, + key_def->name, + space_name(space), + "ARRAY field type is not supported"); } } } diff --git a/test/box/bitset.result b/test/box/bitset.result index 0bb158f632bf375b81a435963c4f24dc259c56a6..bb2a295d8d23bb12de11723d6e955bd7a209abb7 100644 --- a/test/box/bitset.result +++ b/test/box/bitset.result @@ -1868,8 +1868,8 @@ _ = space:create_index('primary', { type = 'hash', parts = {1, 'num'}, unique = ... _ = space:create_index('bitset', { type = 'bitset', parts = {2, 'number'}, unique = false }) --- -- error: 'Can''t create or modify index ''bitset'' in space ''test'': NUMBER field - type is not supported' +- error: 'Can''t create or modify index ''bitset'' in space ''test'': BITSET index + field type must be NUM or STR' ... space:drop() ---