From 96758992253b5cc54feeb9162c0fc13a9efa9f6d Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Wed, 5 Aug 2015 01:00:20 +0300
Subject: [PATCH] box.slab.stats(): return a correct tuple, not a multi-return

Make box.slab.stats() output CALL compatible.
---
 src/box/lua/slab.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/box/lua/slab.cc b/src/box/lua/slab.cc
index f9e79e7402..de50dba4fc 100644
--- a/src/box/lua/slab.cc
+++ b/src/box/lua/slab.cc
@@ -63,6 +63,8 @@ small_stats_lua_cb(const struct mempool_stats *stats, void *cb_ctx)
 	 * Create a Lua table for every slab class. A class is
 	 * defined by its item size.
 	 */
+	/** Assign next slab size to the next member of an array. */
+	lua_pushnumber(L, lua_objlen(L, -1) + 1);
 	lua_newtable(L);
 	/**
 	 * This is in fact only to force YaML flow "compact" for this
@@ -94,6 +96,7 @@ small_stats_lua_cb(const struct mempool_stats *stats, void *cb_ctx)
 	luaL_pushuint64(L, stats->objcount);
 	lua_settable(L, -3);
 
+	lua_settable(L, -3);
 	return 0;
 }
 
@@ -103,7 +106,7 @@ static int
 lbox_slab_stats(struct lua_State *L)
 {
 	struct small_stats totals;
-	int top = lua_gettop(L);
+	lua_newtable(L);
 	/*
 	 * List all slabs used for tuples and slabs used for
 	 * indexes, with their stats.
@@ -113,7 +116,7 @@ lbox_slab_stats(struct lua_State *L)
 	mempool_stats(&memtx_index_extent_pool, &index_stats);
 	small_stats_lua_cb(&index_stats, L);
 
-	return lua_gettop(L) - top;
+	return 1;
 }
 
 
-- 
GitLab