diff --git a/debian/changelog b/debian/changelog index c52f88a0017d31f04b46b6f775fceff385e867e6..6c9d88a39326e1714b67bf5c24141dfc23e8ed37 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +tarantool (1.5.1.150.g029f82f-1) unstable; urgency=low + + * New Debian snapshot (fix memory corruption). + + -- Dmitry E. Oboukhov <unera@debian.org> Fri, 25 Oct 2013 15:26:36 +0400 + tarantool (1.5.1.148.g6dddbc7-1) unstable; urgency=low * New Debian snapshot. diff --git a/include/errcode.h b/include/errcode.h index 19cba8326572ac4fd80d4c0841b186165acdcfd1..72bde640a4b6150cd9928003ca63bf095b3ad008 100644 --- a/include/errcode.h +++ b/include/errcode.h @@ -108,7 +108,7 @@ enum { TNT_ERRMSG_MAX = 512 }; /* 53 */_(ER_NO_SUCH_INDEX, 2, "No index #%u is defined in space %u") \ /* 54 */_(ER_NO_SUCH_FIELD, 2, "Field %u was not found in the tuple") \ /* 55 */_(ER_TUPLE_FOUND, 2, "Duplicate key exists in unique index %u") \ - /* 56 */_(ER_UPDATE_FIELD, 2, "Field %u UPDATE error: %s") \ + /* 56 */_(ER_UPDATE_FIELD, 2, "Field %u UPDATE error: %s") \ /* 57 */_(ER_NO_SUCH_SPACE, 2, "Space %u does not exist") diff --git a/src/box/box_lua.cc b/src/box/box_lua.cc index c0d5dfba6df94fd4cffc158a9c35fb4a85a7d181..80f07bc79daf9a8f894cae2461b0417badc84965 100644 --- a/src/box/box_lua.cc +++ b/src/box/box_lua.cc @@ -315,7 +315,9 @@ lbox_tuple_transform(struct lua_State *L) /* * Calculate the number of operations and length of UPDATE expression */ - uint32_t op_cnt = offset < tuple->field_count ? field_count : 0; + uint32_t op_cnt = 0; + if (offset < tuple->field_count && field_count > 0) + op_cnt++; if (argc > 3) op_cnt += argc - 3; @@ -332,10 +334,13 @@ lbox_tuple_transform(struct lua_State *L) luaL_buffinit(L, &b); luaL_addlstring(&b, (char *) &op_cnt, sizeof(op_cnt)); uint32_t offset_u32 = (uint32_t) offset; - for (uint32_t i = 0; i < (uint32_t) field_count; i++) { + uint32_t field_count_u32 = (uint32_t) field_count; + if (field_count > 0) { luaL_addlstring(&b, (char *) &offset_u32, sizeof(offset_u32)); - luaL_addchar(&b, UPDATE_OP_DELETE); - luaL_addvarint32(&b, 0); /* Unused. */ + luaL_addchar(&b, UPDATE_OP_DELETE); /* multi-delete */ + luaL_addvarint32(&b, sizeof(field_count_u32)); + luaL_addlstring(&b, (char *) &field_count_u32, + sizeof(field_count_u32)); } for (int i = argc ; i > 3; i--) { diff --git a/src/box/tuple_update.cc b/src/box/tuple_update.cc index 86d9740dd5a5abf33cb4059d079a2c941566f498..264dba9db8675e8a605c8548ff5c64487e524b55 100644 --- a/src/box/tuple_update.cc +++ b/src/box/tuple_update.cc @@ -443,7 +443,7 @@ init_update_op_splice(struct tuple_update *update, struct update_op *op) STAILQ_INSERT_TAIL(&field->ops, op, next); } -static struct update_op_meta update_op_meta[UPDATE_OP_MAX + 1] = { +static struct update_op_meta update_op_meta[update_op_codes_MAX] = { { init_update_op_set, (do_op_func) do_update_op_set, true }, { init_update_op_arith, (do_op_func) do_update_op_add, true }, { init_update_op_arith, (do_op_func) do_update_op_and, true }, @@ -641,7 +641,7 @@ update_read_ops(struct tuple_update *update, const char *expr, op->field_no = pick_u32(&expr, expr_end); op->opcode = pick_u8(&expr, expr_end); - if (op->opcode >= UPDATE_OP_MAX) + if (op->opcode >= update_op_codes_MAX) tnt_raise(ClientError, ER_UNKNOWN_UPDATE_OP); op->meta = &update_op_meta[op->opcode]; diff --git a/src/box/tuple_update.h b/src/box/tuple_update.h index 5bc7b5402646fa2c82ad59ce8de468f75846727d..fb737e12e2bc75c8cbaf189e3f713fcffac5a236 100644 --- a/src/box/tuple_update.h +++ b/src/box/tuple_update.h @@ -47,8 +47,7 @@ enum { _(UPDATE_OP_SPLICE, 5) \ _(UPDATE_OP_DELETE, 6) \ _(UPDATE_OP_INSERT, 7) \ - _(UPDATE_OP_SUBTRACT, 8) \ - _(UPDATE_OP_MAX, 10) \ + _(UPDATE_OP_SUBTRACT, 8) ENUM(update_op_codes, UPDATE_OP_CODES); diff --git a/test/big/lua.result b/test/big/lua.result index a88cacff16efb9617850deddd05fcb3d8dc981c3..cfdb1112653e074a5d15dea485f13c5b86815fe9 100644 --- a/test/big/lua.result +++ b/test/big/lua.result @@ -658,6 +658,26 @@ space:truncate() --- ... -- +-- Tests for OPENTAR-64 - a limitation for the second argument to tuple:transform +-- +-- 50K is enough for everyone +n = 50000 +--- +... +tab = {}; for i=1,n,1 do table.insert(tab, i) end +--- +... +t = box.tuple.new(tab) +--- +... +t:transform(0, n - 1) +--- +- [50000] +... +t = nil +--- +... +-- -- Tests for lua tuple:find() and tuple:findall() -- -- First space for hash_str tests diff --git a/test/big/lua.test.lua b/test/big/lua.test.lua index 1e750f42dde494d89f88cab6bef02fbaa2d5288a..34db14aa249c4dd4e114cc22a4f8d716b69e86e5 100644 --- a/test/big/lua.test.lua +++ b/test/big/lua.test.lua @@ -222,6 +222,17 @@ t:transform(3, 1, tonumber64(4)) t:transform(0, 1, {}) space:truncate() +-- +-- Tests for OPENTAR-64 - a limitation for the second argument to tuple:transform +-- + +-- 50K is enough for everyone +n = 50000 +tab = {}; for i=1,n,1 do table.insert(tab, i) end +t = box.tuple.new(tab) +t:transform(0, n - 1) +t = nil + -- -- Tests for lua tuple:find() and tuple:findall() --