diff --git a/include/errcode.h b/include/errcode.h index f1609ad8916cfc9abcdc90690eb7d6d00ceee968..71d239557af148a0e94390773a95eeaf4a2e6f0c 100644 --- a/include/errcode.h +++ b/include/errcode.h @@ -73,7 +73,8 @@ struct errcode_record { /* 54 */_(ERR_CODE_UNUSED54, 0, "Unused54") \ /* 55 */_(ERR_CODE_NODE_FOUND, 2, "Node is found") \ /* 56 */_(ERR_CODE_INDEX_VIOLATION, 2, "Some index violation occur") \ - /* 57 */_(ERR_CODE_NO_SUCH_NAMESPACE, 2, "There is no such namespace") + /* 57 */_(ERR_CODE_NO_SUCH_NAMESPACE, 2, "There is no such namespace") \ + _(ERR_CODE_NO_SUCH_INDEX, 2, "No index with the given id is defined") ENUM0(tnt_error_codes_enum, ERROR_CODES); extern struct errcode_record tnt_error_codes[]; diff --git a/mod/silverbox/box.c b/mod/silverbox/box.c index 527c348147421392851e29f47160af05e9c31a02..c4db16a74a55c3ecba20ff1c8a74d955c134aacd 100644 --- a/mod/silverbox/box.c +++ b/mod/silverbox/box.c @@ -812,10 +812,10 @@ box_dispach(struct box_txn *txn, enum box_mode mode, u16 op, struct tbuf *data) u32 limit = read_u32(data); if (i > MAX_IDX) - box_raise(ERR_CODE_ILLEGAL_PARAMS, "index too big"); + box_raise(ERR_CODE_NO_SUCH_INDEX, "index too big"); txn->index = &namespace[txn->n].index[i]; if (txn->index->key_cardinality == 0) - box_raise(ERR_CODE_ILLEGAL_PARAMS, "index is invalid"); + box_raise(ERR_CODE_NO_SUCH_INDEX, "index is invalid"); stat_collect(stat_base, op, 1); return process_select(txn, limit, offset, data); diff --git a/test/box/protocol.c b/test/box/protocol.c index 5463ca5f0449616638100f9bfef63e15e3ec8ef1..6bc2e864a436b389966404ea8797607983ff4093 100644 --- a/test/box/protocol.c +++ b/test/box/protocol.c @@ -18,13 +18,13 @@ void test_ping() } +/** A test case for Bug#702397 + * https://bugs.launchpad.net/tarantool/+bug/702397 "If SELECT + * request specifies tuple count 0, no error" + */ + void test_bug702397() { - /* - * A test case for Bug#702397 - * https://bugs.launchpad.net/tarantool/+bug/702397 - * "If SELECT request specifies tuple count 0, no error" - */ const char message[]= { 0x11, 0x0, 0x0, 0x0, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -36,6 +36,29 @@ void test_bug702397() tnt_errcode_desc(tnt_res.errcode >> 8)); } + +/** A test case for Bug#702399 + * https://bugs.launchpad.net/tarantool/+bug/702399 + * ERR_CODE_ILLEGAL_PARAMS is returned when there is no such key + */ + +void test_bug702399() +{ + const char message[]= { + 0x11, 0x0, 0x0, 0x0, 0x1d, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xff, 0xff, 0xff, 0xff, + 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, + 0x4, 0x1, 0x0, 0x0, 0x0 }; + struct tnt_result tnt_res; + int res = tnt_execute_raw(conn, message, sizeof message, &tnt_res); + printf("return_code: %s, %s\n", + tnt_errcode_str(tnt_res.errcode >> 8), + tnt_errcode_desc(tnt_res.errcode >> 8)); +} + + int main() { conn = tnt_connect("localhost", 33013); @@ -44,6 +67,7 @@ int main() test_ping(); test_bug702397(); + test_bug702399(); tnt_disconnect(conn); return 0; diff --git a/test/box/protocol.result b/test/box/protocol.result index 34a50786e7282da11da9e42f027ea52366d3e419..20c738386346dc379dccfdef1da43804dfe130c8 100644 --- a/test/box/protocol.result +++ b/test/box/protocol.result @@ -1,2 +1,3 @@ return_code: 0 return_code: ERR_CODE_ILLEGAL_PARAMS, "Illegal parameters" +return_code: ERR_CODE_NO_SUCH_INDEX, "No index with the given id is defined"