Skip to content

Interactive console now has its own per-session variables scope #4191

Open
@TarantoolBot

Description

@TarantoolBot

Related dev. issue(s): tarantool/tarantool#9985
Related doc. issue(s): #4196

Product: Tarantool
Since: 3.2
Root document:

SME: @ Totktonada

Details

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.

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.

console_1> _G.x = 1
console_1> x
---
- 1
...

Example 3. Different console sessions have separate variable scopes.

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.

Requested by @ Totktonada in tarantool/tarantool@d36493c (tarantool/tarantool#10001, tarantool/tarantool#9985).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions