Skip to content
Snippets Groups Projects
Commit 82b340e6 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Merge branch 'bug1009992'

parents e0aba82b b93bde39
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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);
}
......
......@@ -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;
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment