[patches] [PATCH 3/4] iproto: move IPROTO_SQL_ROW_COUNT to enum sql_info_key
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Wed Mar 14 00:49:26 MSK 2018
IPROTO_SQL_ROW_COUNT is not a top level key in an iproto response
and can be moved into a separate enum.
Signed-off-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
---
src/box/execute.c | 8 ++++++--
src/box/execute.h | 10 ++++++++--
src/box/iproto_constants.c | 1 -
src/box/iproto_constants.h | 3 +--
src/box/lua/net_box.lua | 6 +++---
5 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/box/execute.c b/src/box/execute.c
index 2c347e92c..91e253beb 100644
--- a/src/box/execute.c
+++ b/src/box/execute.c
@@ -57,6 +57,10 @@ const char *sql_options_key_strs[] = {
"return tuple",
};
+const char *sql_info_key_strs[] = {
+ "row count",
+};
+
/**
* Name and value of an SQL prepared statement parameter.
* @todo: merge with sqlite3_value.
@@ -684,14 +688,14 @@ sql_execute_and_encode(sqlite3 *db, struct sqlite3_stmt *stmt, struct obuf *out,
if (iproto_reply_map_key(out, 1, IPROTO_SQL_INFO) != 0)
goto err_body;
int changes = sqlite3_changes(db);
- int size = mp_sizeof_uint(IPROTO_SQL_ROW_COUNT) +
+ int size = mp_sizeof_uint(SQL_INFO_ROW_COUNT) +
mp_sizeof_uint(changes);
char *buf = obuf_alloc(out, size);
if (buf == NULL) {
diag_set(OutOfMemory, size, "obuf_alloc", "buf");
goto err_body;
}
- buf = mp_encode_uint(buf, IPROTO_SQL_ROW_COUNT);
+ buf = mp_encode_uint(buf, SQL_INFO_ROW_COUNT);
buf = mp_encode_uint(buf, changes);
/* Reply DATA if needed. */
diff --git a/src/box/execute.h b/src/box/execute.h
index a0d23a4ef..ab5fe485e 100644
--- a/src/box/execute.h
+++ b/src/box/execute.h
@@ -43,7 +43,13 @@ enum sql_options_key {
sql_options_key_MAX,
};
+enum sql_info_key {
+ SQL_INFO_ROW_COUNT = 0,
+ sql_info_key_MAX,
+};
+
extern const char *sql_options_key_strs[];
+extern const char *sql_info_key_strs[];
struct obuf;
struct region;
@@ -99,13 +105,13 @@ xrow_decode_sql(const struct xrow_header *row, struct sql_request *request,
* +-------------------- OR ----------------------+
* | IPROTO_BODY: { |
* | IPROTO_SQL_INFO: { |
- * | IPROTO_SQL_ROW_COUNT: number |
+ * | SQL_INFO_ROW_COUNT: number |
* | } |
* | } |
* +-------------------- OR ----------------------+
* | IPROTO_BODY: { |
* | IPROTO_SQL_INFO: { |
- * | IPROTO_SQL_ROW_COUNT: number |
+ * | SQL_INFO_ROW_COUNT: number |
* | }, |
* | IPROTO_DATA: [ |
* | tuple |
diff --git a/src/box/iproto_constants.c b/src/box/iproto_constants.c
index 21c3b1696..203c85a52 100644
--- a/src/box/iproto_constants.c
+++ b/src/box/iproto_constants.c
@@ -194,7 +194,6 @@ const char *iproto_key_strs[IPROTO_KEY_MAX] = {
"SQL bind", /* 0x41 */
"SQL options", /* 0x42 */
"SQL info", /* 0x43 */
- "SQL row count", /* 0x44 */
};
const char *vy_page_info_key_strs[VY_PAGE_INFO_KEY_MAX] = {
diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h
index ea4ab3254..ee79681b2 100644
--- a/src/box/iproto_constants.h
+++ b/src/box/iproto_constants.h
@@ -107,11 +107,10 @@ enum iproto_key {
IPROTO_SQL_OPTIONS = 0x42,
/**
* IPROTO_SQL_INFO: {
- * IPROTO_SQL_ROW_COUNT: number
+ * SQL_INFO_ROW_COUNT: number
* }
*/
IPROTO_SQL_INFO = 0x43,
- IPROTO_SQL_ROW_COUNT = 0x44,
IPROTO_KEY_MAX
};
diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index 0c6d30c24..b258ecbdf 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -38,7 +38,7 @@ local IPROTO_SYNC_KEY = 0x01
local IPROTO_SCHEMA_VERSION_KEY = 0x05
local IPROTO_METADATA_KEY = 0x32
local IPROTO_SQL_INFO_KEY = 0x43
-local IPROTO_SQL_ROW_COUNT_KEY = 0x44
+local SQL_INFO_ROW_COUNT_KEY = 0
local IPROTO_FIELD_NAME_KEY = 0x29
local IPROTO_DATA_KEY = 0x30
local IPROTO_ERROR_KEY = 0x31
@@ -870,8 +870,8 @@ function remote_methods:execute(query, parameters, sql_opts, netbox_opts)
return data -- body length. Body is written to the buffer.
end
if info ~= nil then
- assert(info[IPROTO_SQL_ROW_COUNT_KEY] ~= nil)
- local ret = {rowcount = info[IPROTO_SQL_ROW_COUNT_KEY]}
+ assert(info[SQL_INFO_ROW_COUNT_KEY] ~= nil)
+ local ret = {rowcount = info[SQL_INFO_ROW_COUNT_KEY]}
if data ~= nil and #data > 0 then
assert(#data == 1)
ret.last_tuple = data[1]
--
2.14.3 (Apple Git-98)
More information about the Tarantool-patches
mailing list