sql: provide a user friendly frontend for accessing session settings
Currently if a user wants to change session setting with SQL, one has to execute UPDATE query like: [[UPDATE "_session_settings" SET "value" = true WHERE "name" = 'name']] However, direct access to system spaces isn't considered to be a good practice. To avoid that and a bit simplify user's life, we introduce SQL shortcut command SET SESSION. Closes #4711 @TarantoolBot document Title: API for accessing _session_settings space. There are two ways of updating values of session settings: via Lua and SQL. Lua: box.session.settings is a table, which is always accessible to user. The syntax is the following: `box.session.settings.<setting_name> = <new_value>`. Example of usage: ``` tarantool> box.session.settings.sql_default_engine --- - memtx ... tarantool> box.session.settings.sql_default_engine = 'vinyl' --- ... ``` The table itself represents the (unordered) result of select from _session_settings space. SQL: Instead of typing long UPDATE query one can use the SET SESSION command: `box.execute([[SET SESSION "<setting_name>" = <new_value>]])`. Note, that this query is case sensitive so the name must be quoted. Also, SET SESSION doesn't provide any implicit casts, so <new_value> must be of the type corresponding to the setting being updated. Example: ``` tarantool> box.execute([[set session "sql_default_engine" = 'memtx']]) --- - row_count: 1 ... tarantool> box.execute([[set session "sql_defer_foreign_keys" = true]]) --- - row_count: 1 ... ```
Showing
- extra/mkkeywordhash.c 1 addition, 0 deletionsextra/mkkeywordhash.c
- src/box/sql/build.c 20 additions, 0 deletionssrc/box/sql/build.c
- src/box/sql/parse.y 6 additions, 0 deletionssrc/box/sql/parse.y
- src/box/sql/sqlInt.h 11 additions, 0 deletionssrc/box/sql/sqlInt.h
- src/box/sql/vdbe.c 54 additions, 0 deletionssrc/box/sql/vdbe.c
- test/box/session_settings.result 49 additions, 0 deletionstest/box/session_settings.result
- test/box/session_settings.test.lua 13 additions, 0 deletionstest/box/session_settings.test.lua
Loading
Please register or sign in to comment