console: create per-session variables scope
Fixes #9985 @TarantoolBot document Title: Interactive console now has its own per-session variables scope It is counter-intuitive that all the non-local assignments in the console affect globals and may interfere with application's logic. It is also counter-intuitive that the non-local assignments are shared between different console sessions. Now, each console session has its own variables scope and the non-local assignments use it instead of globals. Let's consider examples of the new behavior. Example 1. A console session has a variable scope that is separate from globals. ```lua console_1> _G.x = 1 console_1> x = 2 console_1> _G.x --- - 1 ... console_1> x --- - 2 ... ``` Note: A global variable is still accessible using `_G` even if the same named session scope variable exists. Example 2. A global variable is read if there is no session local variable. ```lua console_1> _G.x = 1 console_1> x --- - 1 ... ``` Example 3. Different console sessions have separate variable scopes. ```lua console_1> x = 1 console_2> x = 2 console_1> x --- - 1 ... console_2> x --- - 2 ... ``` The new behavior is enabled using the `console_session_scope_vars` compat option. The option is `old` by default in Tarantool 3.X, `new` by default in 4.X. The `old` behavior is to be removed in 5.X. Please, create the following page: https://tarantool.io/compat/console_session_scope_vars Please, add the new compat option into the configuration reference.
Showing
- changelogs/unreleased/console-session-scope-vars.md 5 additions, 0 deletionschangelogs/unreleased/console-session-scope-vars.md
- src/box/lua/config/instance_config.lua 6 additions, 0 deletionssrc/box/lua/config/instance_config.lua
- src/box/lua/console.lua 37 additions, 2 deletionssrc/box/lua/console.lua
- test/app-luatest/console_session_scope_vars_test.lua 136 additions, 0 deletionstest/app-luatest/console_session_scope_vars_test.lua
- test/config-luatest/cluster_config_schema_test.lua 1 addition, 0 deletionstest/config-luatest/cluster_config_schema_test.lua
Loading
Please register or sign in to comment