[Tarantool-patches] [PATCH] box.execute should be immutable function

Maria maria.khaydich at tarantool.org
Thu Nov 14 14:50:20 MSK 2019


Using box.execute method before explicitly
configuring box automatically invoked box.cfg
nonetheless. Any further calls to the latter
caused its reconfiguration which could lead
to an error when trying to use the method.

Closes #4231
Issue:
https://github.com/tarantool/tarantool/issues/4231
Branch:
https://github.com/tarantool/tarantool/compare/eljashm/gh-4231-box.execute-immutable-function
---
 src/box/lua/load_cfg.lua      |  4 +++-
 test/box-tap/execute.test.lua | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100755 test/box-tap/execute.test.lua

diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua
index e7f62cf4e..042edf913 100644
--- a/src/box/lua/load_cfg.lua
+++ b/src/box/lua/load_cfg.lua
@@ -528,7 +528,9 @@ box.cfg = locked(load_cfg)
 -- metatable.
 --
 function box.execute(...)
-    load_cfg()
+    if not box.cfg then
+        load_cfg()
+    end
     return box.execute(...)
 end
 
diff --git a/test/box-tap/execute.test.lua b/test/box-tap/execute.test.lua
new file mode 100755
index 000000000..301cf4a1c
--- /dev/null
+++ b/test/box-tap/execute.test.lua
@@ -0,0 +1,17 @@
+#!/usr/bin/env tarantool
+
+local tap = require('tap')
+local test = tap.test('execute')
+test:plan(1)
+
+local box_execute = box.execute
+box.cfg{}
+
+local status, err = pcall(
+    function() 
+        box_execute("CREATE TABLE t1 (s1 INTEGER, PRIMARY KEY (s1));") 
+    end)
+
+test:ok(status and err == nil, "box.execute after box.cfg")
+test:check()
+os.exit(0)
-- 
2.21.0 (Apple Git-122.2)



More information about the Tarantool-patches mailing list