Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] box.execute should be immutable function
@ 2019-11-14 11:50 Maria
  2019-11-14 16:51 ` Nikita Pettik
  2019-12-17 14:39 ` Igor Munkin
  0 siblings, 2 replies; 31+ messages in thread
From: Maria @ 2019-11-14 11:50 UTC (permalink / raw)
  To: tarantool-patches, georgy

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)

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2020-05-12 16:17 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14 11:50 [Tarantool-patches] [PATCH] box.execute should be immutable function Maria
2019-11-14 16:51 ` Nikita Pettik
2019-12-17 14:39 ` Igor Munkin
2019-12-24 15:32   ` [Tarantool-patches] [PATCH] box: make box.execute() immutable Maria Khaydich
2019-12-25  1:30     ` Igor Munkin
2019-12-26 14:08     ` Alexander Turenko
2020-01-13 12:13       ` Maria Khaydich
2020-01-13 15:48         ` Igor Munkin
2020-01-18 10:56           ` Maria Khaydich
2020-02-20 17:51             ` Alexander Turenko
2020-02-20 21:15               ` Igor Munkin
2020-03-11 15:56               ` Maria Khaydich
2020-03-18 22:25                 ` Igor Munkin
2020-05-02 14:52                   ` Alexander Turenko
2020-05-12 16:16                 ` Alexander Turenko
2020-03-11 15:57               ` [Tarantool-patches] [PATCH 1/2] box: make box.cfg idempotent function Maria Khaydich
2020-03-12 13:29                 ` Konstantin Osipov
2020-03-12 19:25                   ` Maria Khaydich
2020-03-12 20:00                     ` Konstantin Osipov
2020-03-18 22:26                       ` Igor Munkin
2020-03-19  7:19                         ` Konstantin Osipov
2020-03-19  9:08                           ` Igor Munkin
2020-03-19 10:06                             ` Konstantin Osipov
2020-03-19 10:26                               ` Igor Munkin
2020-05-06 11:17                           ` Alexander Turenko
2020-05-06 11:49                             ` Konstantin Osipov
2020-05-06 12:53                               ` Alexander Turenko
2020-05-06 13:02                                 ` Konstantin Osipov
2020-05-06 13:13                                   ` Alexander Turenko
2020-03-18 22:26                 ` Igor Munkin
2020-05-12 16:17                   ` Alexander Turenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox