diff --git a/doc/box-protocol.txt b/doc/box-protocol.txt index 3de24f9e1d752140455b56eb292efdde4eacdf49..1654bb86ffbfa3f9cd198442589c2c047bc0c128 100644 --- a/doc/box-protocol.txt +++ b/doc/box-protocol.txt @@ -14,9 +14,12 @@ Tarantool IPROTO protocol. ; int8 - a single 8-bit byte (i.e. an octet) ; ; int32 - a 32-bit integer in little-endian format (Intel x86) - +; ; int64 - a 64-bit integer in little-endian format (Intel x86) ; +; msgpack - a valid msgpack sequence for everything else, see +; http://msgpack.org +; ; All requests and responses utilize the same basic structure: <packet> ::= <request> | <response> @@ -27,7 +30,7 @@ Tarantool IPROTO protocol. ; response is an error message. ; -<response> ::= <header><return_code>{<response_body>} +<response> ::= <header><response_body> ; ; <header> has a fixed structure of three 4-byte integers (12 bytes): @@ -86,15 +89,13 @@ Tarantool IPROTO protocol. ; ; <response_body> carries command reply -; It is only present if <return_code> is 0 (success). -; <call_response_body> can be arbitrary, it purely depends -; on what your procedure does. +; If <return_code> is 0 (success), it contains zero or more +; tuples, otherwise it carries an error message that corresponds +; the return code. ; -<response_body> ::= <select_response_body> | - <insert_response_body> | - <update_response_body> | - <delete_response_body> +<response_body> ::= <return_code><text> | + <0><count><fq_tuple>* ; <select_request_body> (required <header> <type> is 17): ; @@ -262,7 +263,7 @@ Tarantool IPROTO protocol. ; field data in case of splice argument contains 3 nested <field> ; objects, which store the arguments: -<op_arg_splice> ::= <message_pack_array(3)><offset><length><string> +<op_arg_splice> ::= <message_pack_array(3)> # <offset><length><string> <offset> ::= <message_pack_uint> <length> ::= <message_pack_uint> diff --git a/include/lua/utils.h b/include/lua/utils.h index e7771a6bd9ff0ad09c0b62fffc752015d6745bfb..9c1e86472c0b35b7a3bad4290b960eb57a9143bb 100644 --- a/include/lua/utils.h +++ b/include/lua/utils.h @@ -50,7 +50,7 @@ struct lua_State; /** * @brief Allocate a new block of memory with the given size, push onto the - * stack a new cdata of type ctypeid with the block address, and returns + * stack a new cdata of type ctypeid with the block address, and return * this address. Allocated memory is a subject of GC. * CTypeID must be used from FFI at least once. * @param L Lua State @@ -95,8 +95,8 @@ struct luaL_field { /** * @brief Convert a value from the Lua stack to a lua_field structure. - * This function is designed to use with lua bindings and data - * serializators (YAML, MsgPack, JSON, etc.). + * This function is designed for use with Lua bindings and data + * serialization functions (YAML, MsgPack, JSON, etc.). * * Conversion rules: * - LUA_TNUMBER when is integer and >= 0 -> UINT @@ -115,26 +115,28 @@ struct luaL_field { * - CTID_BOOL -> BOOL * - otherwise -> EXT * - * By default all LUA_TTABLEs (incl. empty ones) are handled as ARRAYs. - * If a table has non-numbering indexes or the table is too sparse when it will - * be handles as a map. The user can force MAP or ARRAY serialization by - * setting a metatable with "_serializer_type" = "map" | "array" value. + * By default all LUA_TTABLEs (including empty ones) are handled as ARRAYs. + * If a table has other than numeric indexes or is too + * sparse, then it is handled as a map. The user can force MAP or + * ARRAY serialization by setting * "_serializer_type" = "map" | "array" + * in the table's metatable. * - * YAML also supports special "_serializer_compact" = true | false + * YAML also supports a special "_serializer_compact" = true | false * flag that controls block vs flow output ([1,2,3] vs - 1\n - 2\n - 3\n). + * It can be set in the table's metatable. * * MAP and ARRAY members are not saved to lua_field structure and should be - * process manually. + * processed manually. * - * Use the following code for ARRAYs: + * Use the following code for arrays: * field.max; // the maximal index of the array * for (uint32_t i = 0; i < field.max; i++) { - * lua_rawgeti(L, index, i + 1); + * lua_rawgeti(L, index, i + 1); * handle_value(L, -1) * lua_pop(L, 1); * } * - * Use the following code for MAPs: + * Use the following code for maps: * field.size; // the number of members in the map * lua_pushnil(L); * while (lua_next(L, index) != 0) { diff --git a/src/box/bitset_index.cc b/src/box/bitset_index.cc index afcfda674efdf42d653f3b803a506f609ec96f1a..86562ffaeacaf7c5c8f91f1926f514fb21c4fa60 100644 --- a/src/box/bitset_index.cc +++ b/src/box/bitset_index.cc @@ -200,7 +200,7 @@ BitsetIndex::initIterator(struct iterator *iterator, enum iterator_type type, const char *key, uint32_t part_count) const { assert(iterator->free == bitset_index_iterator_free); - assert (part_count != 0 || key == NULL); + assert(part_count != 0 || key == NULL); (void) part_count; struct bitset_index_iterator *it = bitset_index_iterator(iterator); diff --git a/src/box/box_lua.cc b/src/box/box_lua.cc index 5348d5e408f0f665861007856636f60c60e1b401..e07536d5c7a7c145b68cc889a44bd3f24a4ed2a6 100644 --- a/src/box/box_lua.cc +++ b/src/box/box_lua.cc @@ -31,7 +31,6 @@ #include "lua/init.h" #include "lua/utils.h" #include "lua/msgpack.h" -#include <signal.h> #include <fiber.h> #include "box/box.h" #include "request.h" @@ -538,14 +537,14 @@ lbox_tuple_next(struct lua_State *L) struct tuple_iterator *it = NULL; if (argc == 0 || (argc == 1 && lua_type(L, 2) == LUA_TNIL)) { it = (struct tuple_iterator *) lua_newuserdata(L, sizeof(*it)); - assert (it != NULL); + assert(it != NULL); luaL_getmetatable(L, tuple_iteratorlib_name); lua_setmetatable(L, -2); tuple_rewind(it, tuple); } else if (argc == 1 && lua_type(L, 2) == LUA_TUSERDATA) { it = (struct tuple_iterator *) luaL_checkudata(L, 2, tuple_iteratorlib_name); - assert (it != NULL); + assert(it != NULL); lua_pushvalue(L, 2); } else { return luaL_error(L, "tuple.next(): bad arguments"); diff --git a/src/box/hash_index.cc b/src/box/hash_index.cc index 68cc670697433ab43708e5ea399dec4d36ff3932..d81aa7985d2f69f1194865edcdd67ae4204a1e70 100644 --- a/src/box/hash_index.cc +++ b/src/box/hash_index.cc @@ -285,7 +285,7 @@ void HashIndex::initIterator(struct iterator *ptr, enum iterator_type type, const char *key, uint32_t part_count) const { - assert (key != NULL || part_count == 0); + assert(key != NULL || part_count == 0); (void) part_count; assert(ptr->free == hash_iterator_free); diff --git a/src/box/index.cc b/src/box/index.cc index b4a88a248c6ad33b5df503f2ec96f40058d6d7c7..94b9987e793a69b48b5e63d39140fe3ac5619eb5 100644 --- a/src/box/index.cc +++ b/src/box/index.cc @@ -59,7 +59,7 @@ void key_validate(struct key_def *key_def, enum iterator_type type, const char *key, uint32_t part_count) { - assert (key != NULL || part_count == 0); + assert(key != NULL || part_count == 0); if (part_count == 0) { /* * Zero key parts are allowed: @@ -89,7 +89,7 @@ void primary_key_validate(struct key_def *key_def, const char *key, uint32_t part_count) { - assert (key != NULL || part_count == 0); + assert(key != NULL || part_count == 0); if (key_def->part_count != part_count) { tnt_raise(ClientError, ER_EXACT_MATCH, key_def->part_count, part_count); diff --git a/src/box/schema.cc b/src/box/schema.cc index e22f817aedd203fb2d353223be360de282134c76..2d54d9be55e3f7d6a8fa0d7854bc306696d76c6f 100644 --- a/src/box/schema.cc +++ b/src/box/schema.cc @@ -88,7 +88,7 @@ space_foreach(void (*func)(struct space *sp, void *udata), void *udata) mh_int_t i; struct space *space; char key[6]; - assert (mp_sizeof_uint(SC_SYSTEM_ID_MIN) <= sizeof(key)); + assert(mp_sizeof_uint(SC_SYSTEM_ID_MIN) <= sizeof(key)); mp_encode_uint(key, SC_SYSTEM_ID_MIN); /* diff --git a/src/box/tree_index.cc b/src/box/tree_index.cc index 1576001c1c7f1cbe17f8528e84731b1075b69ed7..caf1b75aee3bae945c01496490a4c41a4cb0299d 100644 --- a/src/box/tree_index.cc +++ b/src/box/tree_index.cc @@ -286,7 +286,7 @@ void TreeIndex::initIterator(struct iterator *iterator, enum iterator_type type, const char *key, uint32_t part_count) const { - assert (key != NULL || part_count == 0); + assert(key != NULL || part_count == 0); struct tree_iterator *it = tree_iterator(iterator); if (part_count == 0) { diff --git a/src/box/tuple.cc b/src/box/tuple.cc index 7e892c052e44b0eb3a984a8508003045019dda2e..d155a233a167c3c1e3e3de380bc8183e25438eae 100644 --- a/src/box/tuple.cc +++ b/src/box/tuple.cc @@ -384,7 +384,7 @@ tuple_update(struct tuple_format *format, &new_size); /* Allocate a new tuple. */ - assert (mp_typeof(*new_data) == MP_ARRAY); + assert(mp_typeof(*new_data) == MP_ARRAY); struct tuple *new_tuple = tuple_new(format, &new_data, new_data + new_size); @@ -401,7 +401,7 @@ struct tuple * tuple_new(struct tuple_format *format, const char **data, const char *end) { size_t tuple_len = end - *data; - assert (mp_typeof(**data) == MP_ARRAY); + assert(mp_typeof(**data) == MP_ARRAY); struct tuple *new_tuple = tuple_alloc(format, tuple_len); memcpy(new_tuple->data, end - tuple_len, tuple_len); try {