Skip to content
This repository
Browse code

bug1009992: bug fix for https://bugs.launchpad.net/tarantool/+bug/100…

  • Loading branch information...
commit b93bde392117d1afb116956324fc829cb2070027 1 parent cddad70
Dmitry Simonenko authored
16  connector/c/tnt/tnt_reply.c
@@ -86,14 +86,6 @@ int tnt_reply_from(struct tnt_reply *r, tnt_reply_t rcv, void *ptr) {
86 86
 	if (r->op == TNT_OP_PING)
87 87
 		return 0;
88 88
 
89  
-	/* checking validity of operation */
90  
-	if (r->op != TNT_OP_INSERT &&
91  
-	    r->op != TNT_OP_UPDATE &&
92  
-	    r->op != TNT_OP_DELETE &&
93  
-	    r->op != TNT_OP_SELECT &&
94  
-	    r->op != TNT_OP_CALL)
95  
-		return -1;
96  
-
97 89
 	/* reading code */
98 90
 	if (rcv(ptr, (char*)&r->code, sizeof(r->code)) == -1)
99 91
 		return -1;
@@ -111,6 +103,14 @@ int tnt_reply_from(struct tnt_reply *r, tnt_reply_t rcv, void *ptr) {
111 103
 		return 0;
112 104
 	}
113 105
 
  106
+	/* checking validity of the operation */
  107
+	if (r->op != TNT_OP_INSERT &&
  108
+	    r->op != TNT_OP_UPDATE &&
  109
+	    r->op != TNT_OP_DELETE &&
  110
+	    r->op != TNT_OP_SELECT &&
  111
+	    r->op != TNT_OP_CALL)
  112
+		return -1;
  113
+
114 114
 	/* code only (BOX_QUIET flag) */
115 115
 	if (size == 0)
116 116
 		return 0;
3  mod/box/box.m
@@ -77,10 +77,9 @@ static void box_process_rw(struct txn *txn, Port *port,
77 77
 {
78 78
 	ev_tstamp start = ev_now(), stop;
79 79
 
80  
-	stat_collect(stat_base, op, 1);
81  
-
82 80
 	@try {
83 81
 		Request *request = [[Request build: op] init: data];
  82
+		stat_collect(stat_base, op, 1);
84 83
 		[request execute: txn :port];
85 84
 		txn_commit(txn);
86 85
 	}
33  test/box/protocol.c
@@ -21,10 +21,8 @@ void test_ping()
21 21
 		0x0, 0x0, 0x0, 0x0,    0x0, 0x0, 0x0, 0x0,
22 22
 		0x0, 0x0, 0x0, 0x0,    0x1, 0x0, 0x0, 0x0,
23 23
 		0x4, 0x1, 0x0, 0x0, 0x0 };
24  
-
25 24
 	tnt_io_send_raw(TNT_SNET_CAST(t), (char*)message, sizeof(message), 1);
26 25
 	t->wrcnt++;
27  
-
28 26
 	struct tnt_iter i;
29 27
 	tnt_iter_reply(&i, t);
30 28
 	tnt_next(&i);
@@ -37,23 +35,20 @@ void test_ping()
37 35
  * https://bugs.launchpad.net/tarantool/+bug/702397 "If SELECT
38 36
  * request specifies tuple count 0, no error"
39 37
  */
40  
-
41 38
 void test_bug702397()
42 39
 {
43 40
 	const char message[]= {
44 41
 		0x11, 0x0, 0x0, 0x0,    0x14, 0x0, 0x0, 0x0,    0x0, 0x0, 0x0, 0x0,
45 42
 		0x0, 0x0, 0x0, 0x0,     0x0, 0x0, 0x0, 0x0,     0x0, 0x0, 0x0, 0x0,
46 43
 		0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0 };
47  
-
48 44
 	tnt_io_send_raw(TNT_SNET_CAST(t), (char*)message, sizeof(message), 1);
49 45
 	t->wrcnt++;
50  
-
51 46
 	struct tnt_iter i;
52 47
 	tnt_iter_reply(&i, t);
53 48
 	tnt_next(&i);
54 49
 	struct tnt_reply *r = TNT_IREPLY_PTR(&i);
55 50
 	printf("return_code: %s, %s\n",
56  
-	       tnt_errcode_str(r->code >> 8), r->error);
  51
+	       tnt_errcode_str(TNT_REPLY_ERR(r)), r->error);
57 52
 	tnt_iter_free(&i);
58 53
 }
59 54
 
@@ -61,7 +56,6 @@ void test_bug702397()
61 56
  * https://bugs.launchpad.net/tarantool/+bug/702399
62 57
  * ERR_CODE_ILLEGAL_PARAMS is returned when there is no such key
63 58
  */
64  
-
65 59
 void test_bug702399()
66 60
 {
67 61
 	const char message[]= {
@@ -71,16 +65,36 @@ void test_bug702399()
71 65
 		0xff, 0xff, 0xff, 0xff,
72 66
 		0x1, 0x0, 0x0, 0x0,     0x1, 0x0, 0x0, 0x0,
73 67
 		0x4,    0x1, 0x0, 0x0, 0x0 };
74  
-
75 68
 	tnt_io_send_raw(TNT_SNET_CAST(t), (char*)message, sizeof(message), 1);
76 69
 	t->wrcnt++;
  70
+	struct tnt_iter i;
  71
+	tnt_iter_reply(&i, t);
  72
+	tnt_next(&i);
  73
+	struct tnt_reply *r = TNT_IREPLY_PTR(&i);
  74
+	printf("return_code: %s, %s\n",
  75
+	       tnt_errcode_str(TNT_REPLY_ERR(r)), r->error);
  76
+	tnt_iter_free(&i);
  77
+}
77 78
 
  79
+/** A test case for Bug#1009992
  80
+ * https://bugs.launchpad.net/tarantool/+bug/1009992
  81
+ * ER_ILLEGAL_PARAMS is returned on bad operation id
  82
+ */
  83
+void test_bug1009992()
  84
+{
  85
+	struct tnt_header h = {
  86
+		.type = 12345678, /* bad operation */
  87
+		.len = 0,
  88
+		.reqid = 0
  89
+	};
  90
+	tnt_io_send_raw(TNT_SNET_CAST(t), (char*)&h, sizeof(h), 1);
  91
+	t->wrcnt++;
78 92
 	struct tnt_iter i;
79 93
 	tnt_iter_reply(&i, t);
80 94
 	tnt_next(&i);
81 95
 	struct tnt_reply *r = TNT_IREPLY_PTR(&i);
82 96
 	printf("return_code: %s, %s\n",
83  
-	       tnt_errcode_str(r->code >> 8), r->error);
  97
+	       tnt_errcode_str(TNT_REPLY_ERR(r)), r->error);
84 98
 	tnt_iter_free(&i);
85 99
 }
86 100
 
@@ -99,6 +113,7 @@ int main()
99 113
 	test_ping();
100 114
 	test_bug702397();
101 115
 	test_bug702399();
  116
+	test_bug1009992();
102 117
 
103 118
 	tnt_stream_free(t);
104 119
 	return 0;
1  test/box/protocol.result
... ...
@@ -1,5 +1,6 @@
1 1
 return_code: 0
2 2
 return_code: ER_ILLEGAL_PARAMS, Illegal parameters, tuple count must be positive
3 3
 return_code: ER_NO_SUCH_INDEX, No index #1 is defined in space 0
  4
+return_code: ER_ILLEGAL_PARAMS, Illegal parameters, unsupported command code, check the error log
4 5
 delete from t0 where k0 = 1
5 6
 Delete OK, 1 row affected

0 notes on commit b93bde3

Please sign in to comment.
Something went wrong with that request. Please try again.