Skip to content
Snippets Groups Projects
Commit e01ca030 authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Fix #339: box.update unusual operations fail

parent 75e415ad
No related branches found
No related tags found
No related merge requests found
...@@ -294,9 +294,9 @@ do_op_arith(struct tuple_update *update, struct update_op *op, ...@@ -294,9 +294,9 @@ do_op_arith(struct tuple_update *update, struct update_op *op,
case '+': arg->val += val; break; case '+': arg->val += val; break;
case '&': arg->val &= val; break; case '&': arg->val &= val; break;
case '^': arg->val ^= val; break; case '^': arg->val ^= val; break;
case '|': arg->val |= val; case '|': arg->val |= val; break;
case '-': case '-': arg->val = val - arg->val; break;
default: arg->val = val - arg->val; break; default: assert(false); /* checked by update_read_ops */
} }
op->new_field_len = mp_sizeof_uint(arg->val); op->new_field_len = mp_sizeof_uint(arg->val);
} }
......
...@@ -32,6 +32,54 @@ s:update({1000005}, {{'#', 0, 1}}) ...@@ -32,6 +32,54 @@ s:update({1000005}, {{'#', 0, 1}})
s:truncate() s:truncate()
--- ---
... ...
-- test arithmetic
s:insert{1, 0}
---
- [1, 0]
...
s:update(1, {{'+', 1, 10}})
---
- [1, 10]
...
s:update(1, {{'+', 1, 15}})
---
- [1, 25]
...
s:update(1, {{'-', 1, 5}})
---
- [1, 20]
...
s:update(1, {{'-', 1, 20}})
---
- [1, 0]
...
s:update(1, {{'|', 1, 0x9}})
---
- [1, 9]
...
s:update(1, {{'|', 1, 0x6}})
---
- [1, 15]
...
s:update(1, {{'&', 1, 0xabcde}})
---
- [1, 14]
...
s:update(1, {{'&', 1, 0x2}})
---
- [1, 2]
...
s:update(1, {{'^', 1, 0xa2}})
---
- [1, 160]
...
s:update(1, {{'^', 1, 0xa2}})
---
- [1, 2]
...
s:truncate()
---
...
-- test delete multiple fields -- test delete multiple fields
s:insert{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} s:insert{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
--- ---
......
...@@ -10,6 +10,20 @@ s:update({1000004}, {{'#', 0, 1}}) ...@@ -10,6 +10,20 @@ s:update({1000004}, {{'#', 0, 1}})
s:update({1000005}, {{'#', 0, 1}}) s:update({1000005}, {{'#', 0, 1}})
s:truncate() s:truncate()
-- test arithmetic
s:insert{1, 0}
s:update(1, {{'+', 1, 10}})
s:update(1, {{'+', 1, 15}})
s:update(1, {{'-', 1, 5}})
s:update(1, {{'-', 1, 20}})
s:update(1, {{'|', 1, 0x9}})
s:update(1, {{'|', 1, 0x6}})
s:update(1, {{'&', 1, 0xabcde}})
s:update(1, {{'&', 1, 0x2}})
s:update(1, {{'^', 1, 0xa2}})
s:update(1, {{'^', 1, 0xa2}})
s:truncate()
-- test delete multiple fields -- test delete multiple fields
s:insert{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} s:insert{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
s:update({0}, {{'#', 42, 1}}) s:update({0}, {{'#', 42, 1}})
......
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