Skip to content

Commit 9e38881

Browse files
committed
#110 - fixed
1 parent f857bfb commit 9e38881

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

examples/simple_rest_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,21 @@ def delete(url, data):
9393
# ===
9494
# upsert (insert in this case) into the 'tester'
9595
upserted = upsert(req_url, { 'key': 'my_key_1', 'new_value': 100,
96-
"updated_value": "+,1,10"})
96+
"updated_value": "+,2,10"})
9797

9898
# should be {"result": []}, if okay
9999
print ('upserted = ', upserted)
100100

101101
# ===
102102
# add 10 to the value into the 'tester'
103103
upserted = upsert(req_url, { 'key': 'my_key_1', 'new_value': 1000,
104-
"updated_value": "+,1,10"})
104+
"updated_value": "+,2,10"})
105105
# should be {"result": []}, if okay
106106
print ('upserted = ', upserted)
107107

108108
# ===
109109
# - 10 to the value into the 'tester'
110-
updated = update(req_url, { 'key': 'my_key', 'value': "-,1,10"})
110+
updated = update(req_url, { 'key': 'my_key', 'value': "-,2,10"})
111111
# should be {"result": [[{list of updated values}]]}, if okay
112112
print ('updated = ', updated)
113113

examples/simple_rest_client.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ echo inserted = `curl -s -X POST $req_url?"key=my_key_6&value=2"`
5050
# Update values into the tester
5151

5252
# %23 is urencode('#'). Delete field from the tuple
53-
echo Updated = `curl -s -X PUT $req_url?"key=my_key_5&value=%23,1,10"`
53+
echo Updated = `curl -s -X PUT $req_url?"key=my_key_5&value=%23,2,10"`
5454
# %2B is urencode('+')
55-
echo Updated = `curl -s -X PUT -d 'key=my_key_6' -d "value=%2B,1,999" $req_url`
55+
echo Updated = `curl -s -X PUT -d 'key=my_key_6' -d "value=%2B,2,999" $req_url`
5656

5757
# %3D is urencode('=').
58-
echo Upserted = `curl -s -X PATCH $req_url?"key=my_key_5&new_value=10&updated_value=%3D,1,10"`
58+
echo Upserted = `curl -s -X PATCH $req_url?"key=my_key_5&new_value=10&updated_value=%3D,2,10"`
5959

6060
# Select values from the tester
6161
echo Selected = `curl -s $req_url?key=my_key_5`

src/ngx_http_tnt_module.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ ngx_http_tnt_format_bind_operation(ngx_http_request_t *r, struct tp *tp,
20022002
ngx_str_t *name, ngx_str_t *val)
20032003
{
20042004
u_char *update_operation, *filedno_pt, *filedno_pt_end;
2005-
char filedno_s[sizeof("1867996680")];
2005+
ngx_int_t filedno;
20062006

20072007
update_operation = ngx_http_tnt_read_next(val, ',');
20082008

@@ -2031,10 +2031,13 @@ ngx_http_tnt_format_bind_operation(ngx_http_request_t *r, struct tp *tp,
20312031
goto no_fieldno;
20322032
}
20332033

2034-
snprintf(filedno_s, sizeof(filedno_s), "%.*s",
2035-
(int) (filedno_pt_end - filedno_pt), (char *) filedno_pt);
2034+
filedno = ngx_atoi(filedno_pt, (size_t) (filedno_pt_end - filedno_pt));
2035+
if (filedno < 0 || filedno - 1 < 0) {
2036+
goto no_fieldno;
2037+
}
2038+
filedno -= 1;
20362039

2037-
if (tp_op(tp, *update_operation, (uint32_t) atoi(filedno_s)) == NULL) {
2040+
if (tp_op(tp, *update_operation, (uint32_t) filedno) == NULL) {
20382041
return NGX_ERROR;
20392042
}
20402043

src/ngx_http_tnt_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
#ifndef NGX_HTTP_TNT_VERSION_H
3535
#define NGX_HTTP_TNT_VERSION_H 1
3636

37-
#define NGX_HTTP_TNT_MODULE_VERSION_STRING "v2.5-rc3"
37+
#define NGX_HTTP_TNT_MODULE_VERSION_STRING "v2.5-rc4"
3838

3939
#endif

t/v26_features.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
321321
update = [
322322
{'space_id': 512},
323323
{'value': 1},
324-
{'string': '=,1,some XXXX big string'},
325-
{'float': '-,2,2.1'},
326-
{'double': '=,3,4.1'},
327-
{'bool': '=,4,false'},
328-
{'int': '%2B,5,1001'}
324+
{'string': '=,2,some XXXX big string'},
325+
{'float': '-,3,2.1'},
326+
{'double': '=,4,4.1'},
327+
{'bool': '=,5,false'},
328+
{'int': '%2B,6,1001'}
329329
]
330330

331331
expected = [
@@ -371,7 +371,7 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
371371
{'index_id': 1},
372372
{'key': 1},
373373
{'key1': 'str'},
374-
{'string': '=,2,updated string'}
374+
{'string': '=,3,updated string'}
375375
]
376376

377377
expected = [
@@ -393,7 +393,7 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
393393
{'space_id': 514},
394394
{'key': 2},
395395
{'key1': 'str2'},
396-
{'string': '=,2,Text'}
396+
{'string': '=,3,Text'}
397397
]
398398

399399
result = get_success(BASE_URL + '/upsert_fmt', upsert, None, False)
@@ -403,7 +403,7 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
403403
{'space_id': 514},
404404
{'key': 2},
405405
{'key1': 'str2'},
406-
{'string': '=,2,'}
406+
{'string': '=,3,'}
407407
]
408408

409409
result = get_success(BASE_URL + '/upsert_fmt', upsert, None, False)
@@ -445,8 +445,8 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
445445
result = post_form_success(BASE_URL + '/select_post', {'id': 11}, None)
446446
assert result['result'][0][0] == 11 and result['result'][1][0] == 12, \
447447
'Expected != result'
448-
result = post_form_success(BASE_URL + '/update_post', {'id': 12, 'value': '=,1,TEXT',
449-
'value1': '=,2,3.14'}, None)
448+
result = post_form_success(BASE_URL + '/update_post', {'id': 12, 'value': '=,2,TEXT',
449+
'value1': '=,3,3.14'}, None)
450450
assert result['result'][0][0] == 12 and result['result'][0][1] == 'TEXT' \
451451
and result['result'][0][2] == 3.14, 'Expected != result'
452452

@@ -457,27 +457,25 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
457457
print ('[+] Update format validation')
458458

459459
_, result = post_form(BASE_URL + '/update_post', {'id': 12, 'value': '=,TEXT',
460-
'value1': '=,2,3.14'}, None)
460+
'value1': '=,3,3.14'}, None)
461461
assert _ == 400 and 'error' in result, 'Expected != result'
462462

463463
_, result = post_form(BASE_URL + '/update_post', {'id': 12, 'value': 'TEXT',
464-
'value1': '=,2,3.14'}, None)
464+
'value1': '=,3,3.14'}, None)
465465
assert _ == 400 and 'error' in result, 'Expected != result'
466466
_, result = post_form(BASE_URL + '/update_post', {'id': 12, 'value': '=,,TEXT',
467-
'value1': '=,2,3.14'}, None)
467+
'value1': '=,4,3.14'}, None)
468468
assert _ == 400 and 'error' in result, 'Expected != result'
469469
_, result = post_form(BASE_URL + '/update_post', {'id': 12, 'value': '=,TEXT',
470-
'value1': '=,2,3.14'}, None)
470+
'value1': '=,3,3.14'}, None)
471471
assert _ == 400 and 'error' in result, 'Expected != result'
472472

473473
print ('[+] OK')
474474

475475
# ============
476476
#
477-
print (''' [+] Issues
478-
https://github.com/tarantool/nginx_upstream_module/issues/110 and
479-
https://github.com/tarantool/nginx_upstream_module/issues/111
480-
''')
477+
print ('''[+] Issues https://github.com/tarantool/nginx_upstream_module/issues/110 and
478+
https://github.com/tarantool/nginx_upstream_module/issues/111''')
481479

482480
## Issue 111
483481
_, result = delete(BASE_URL + '/issue_110_and_111', \
@@ -489,7 +487,7 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
489487
None)
490488

491489
result = put_success(BASE_URL + '/issue_110_and_111', \
492-
{'key': 'test_inc', 'value': '#,1,10'}, None, True)
490+
{'key': 'test_inc', 'value': '#,2,10'}, None, True)
493491
assert result[0] == 'test_inc', "Expected != Result"
494492

495493
result = get_success(BASE_URL + '/issue_110_and_111', \
@@ -508,7 +506,7 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
508506
None)
509507

510508
_, result = patch(BASE_URL + '/issue_110_and_111', \
511-
{'key': 'test_inc_2', 'new_value' : 1, 'updated_value': '+,1,5'})
509+
{'key': 'test_inc_2', 'new_value' : 1, 'updated_value': '+,2,5'})
512510
assert _ == 200 and 'result' in result and 'id' in result, \
513511
'expected: result and id'
514512

@@ -517,7 +515,7 @@ def arr_of_dicts_to_arr(arr_of_dicts, start_from = 0):
517515
assert result[1] == 6, "Expected != Result"
518516

519517
_, result = patch(BASE_URL + '/issue_110_and_111', \
520-
{'key': 'test_inc_2', 'new_value' : 1, 'updated_value': '=,1,5'})
518+
{'key': 'test_inc_2', 'new_value' : 1, 'updated_value': '=,2,5'})
521519
assert _ == 200 and 'result' in result and 'id' in result, \
522520
'expected: result and id'
523521
result = get_success(BASE_URL + '/issue_110_and_111', \

0 commit comments

Comments
 (0)