diff --git a/connector/c/tnt/tnt_reply.c b/connector/c/tnt/tnt_reply.c index b2224319391e3d26a10d7a0cdd8ff0519d1e221a..172b60e8c41880d19884813ff908d7f4eaa76c6e 100644 --- a/connector/c/tnt/tnt_reply.c +++ b/connector/c/tnt/tnt_reply.c @@ -86,14 +86,6 @@ int tnt_reply_from(struct tnt_reply *r, tnt_reply_t rcv, void *ptr) { if (r->op == TNT_OP_PING) return 0; - /* checking validity of operation */ - if (r->op != TNT_OP_INSERT && - r->op != TNT_OP_UPDATE && - r->op != TNT_OP_DELETE && - r->op != TNT_OP_SELECT && - r->op != TNT_OP_CALL) - return -1; - /* reading code */ if (rcv(ptr, (char*)&r->code, sizeof(r->code)) == -1) return -1; @@ -111,6 +103,14 @@ int tnt_reply_from(struct tnt_reply *r, tnt_reply_t rcv, void *ptr) { return 0; } + /* checking validity of the operation */ + if (r->op != TNT_OP_INSERT && + r->op != TNT_OP_UPDATE && + r->op != TNT_OP_DELETE && + r->op != TNT_OP_SELECT && + r->op != TNT_OP_CALL) + return -1; + /* code only (BOX_QUIET flag) */ if (size == 0) return 0; diff --git a/mod/box/box.m b/mod/box/box.m index adaca3f825cc59d16686a910210fa1af285cfa37..4198e98998efe5ec2103b0429a9d7a5caad663a3 100644 --- a/mod/box/box.m +++ b/mod/box/box.m @@ -77,10 +77,9 @@ box_process_rw(struct txn *txn, Port *port, { ev_tstamp start = ev_now(), stop; - stat_collect(stat_base, op, 1); - @try { Request *request = [[Request build: op] init: data]; + stat_collect(stat_base, op, 1); [request execute: txn :port]; txn_commit(txn); } diff --git a/test/box/protocol.c b/test/box/protocol.c index f2f14ed327a2637b05c155d286db2505d451bfeb..2569e97c29ae2c589e70b52fa4b13d525a17f9f1 100644 --- a/test/box/protocol.c +++ b/test/box/protocol.c @@ -21,10 +21,8 @@ void test_ping() 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x4, 0x1, 0x0, 0x0, 0x0 }; - tnt_io_send_raw(TNT_SNET_CAST(t), (char*)message, sizeof(message), 1); t->wrcnt++; - struct tnt_iter i; tnt_iter_reply(&i, t); tnt_next(&i); @@ -37,23 +35,20 @@ void test_ping() * https://bugs.launchpad.net/tarantool/+bug/702397 "If SELECT * request specifies tuple count 0, no error" */ - void test_bug702397() { 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, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0 }; - tnt_io_send_raw(TNT_SNET_CAST(t), (char*)message, sizeof(message), 1); t->wrcnt++; - struct tnt_iter i; tnt_iter_reply(&i, t); tnt_next(&i); struct tnt_reply *r = TNT_IREPLY_PTR(&i); printf("return_code: %s, %s\n", - tnt_errcode_str(r->code >> 8), r->error); + tnt_errcode_str(TNT_REPLY_ERR(r)), r->error); tnt_iter_free(&i); } @@ -61,7 +56,6 @@ void test_bug702397() * 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[]= { @@ -71,16 +65,36 @@ void test_bug702399() 0xff, 0xff, 0xff, 0xff, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x4, 0x1, 0x0, 0x0, 0x0 }; - tnt_io_send_raw(TNT_SNET_CAST(t), (char*)message, sizeof(message), 1); t->wrcnt++; + struct tnt_iter i; + tnt_iter_reply(&i, t); + tnt_next(&i); + struct tnt_reply *r = TNT_IREPLY_PTR(&i); + printf("return_code: %s, %s\n", + tnt_errcode_str(TNT_REPLY_ERR(r)), r->error); + tnt_iter_free(&i); +} +/** A test case for Bug#1009992 + * https://bugs.launchpad.net/tarantool/+bug/1009992 + * ER_ILLEGAL_PARAMS is returned on bad operation id + */ +void test_bug1009992() +{ + struct tnt_header h = { + .type = 12345678, /* bad operation */ + .len = 0, + .reqid = 0 + }; + tnt_io_send_raw(TNT_SNET_CAST(t), (char*)&h, sizeof(h), 1); + t->wrcnt++; struct tnt_iter i; tnt_iter_reply(&i, t); tnt_next(&i); struct tnt_reply *r = TNT_IREPLY_PTR(&i); printf("return_code: %s, %s\n", - tnt_errcode_str(r->code >> 8), r->error); + tnt_errcode_str(TNT_REPLY_ERR(r)), r->error); tnt_iter_free(&i); } @@ -99,6 +113,7 @@ int main() test_ping(); test_bug702397(); test_bug702399(); + test_bug1009992(); tnt_stream_free(t); return 0; diff --git a/test/box/protocol.result b/test/box/protocol.result index 07366ba5a901c426145f9f3bd06b67ed8b31f6a9..2f91546d00141dd1ff8041d0038b9497b69b2819 100644 --- a/test/box/protocol.result +++ b/test/box/protocol.result @@ -1,5 +1,6 @@ return_code: 0 return_code: ER_ILLEGAL_PARAMS, Illegal parameters, tuple count must be positive return_code: ER_NO_SUCH_INDEX, No index #1 is defined in space 0 +return_code: ER_ILLEGAL_PARAMS, Illegal parameters, unsupported command code, check the error log delete from t0 where k0 = 1 Delete OK, 1 row affected