Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session settings #247

Merged
merged 6 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- Support errors extended information (#209)
- Error type support in MessagePack (#209)
- Event subscription support (#119)
- Session settings support (#215)

### Changed

Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ clean:

.PHONY: deps
deps: clean
( cd ./queue; tarantoolctl rocks install queue 1.2.1 )
( cd ./queue/testdata; tarantoolctl rocks install queue 1.2.1 )

.PHONY: datetime-timezones
datetime-timezones:
Expand Down Expand Up @@ -81,6 +81,12 @@ test-uuid:
go clean -testcache
go test -tags "$(TAGS)" ./uuid/ -v -p 1

.PHONY: test-settings
test-settings:
@echo "Running tests in settings package"
go clean -testcache
go test -tags "$(TAGS)" ./settings/ -v -p 1

.PHONY: test-main
test-main:
@echo "Running tests in main package"
Expand Down
14 changes: 7 additions & 7 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ box.cfg{

box.once("init", function()
local st = box.schema.space.create('schematest', {
id = 516,
id = 616,
temporary = true,
if_not_exists = true,
field_count = 7,
Expand Down Expand Up @@ -36,7 +36,7 @@ box.once("init", function()
st:truncate()

local s = box.schema.space.create('test', {
id = 517,
id = 617,
if_not_exists = true,
})
s:create_index('primary', {
Expand All @@ -46,7 +46,7 @@ box.once("init", function()
})

local s = box.schema.space.create('teststring', {
id = 518,
id = 618,
if_not_exists = true,
})
s:create_index('primary', {
Expand All @@ -56,7 +56,7 @@ box.once("init", function()
})

local s = box.schema.space.create('testintint', {
id = 519,
id = 619,
if_not_exists = true,
})
s:create_index('primary', {
Expand All @@ -66,7 +66,7 @@ box.once("init", function()
})

local s = box.schema.space.create('SQL_TEST', {
id = 520,
id = 620,
if_not_exists = true,
format = {
{name = "NAME0", type = "unsigned"},
Expand All @@ -82,7 +82,7 @@ box.once("init", function()
s:insert{1, "test", "test"}

local s = box.schema.space.create('test_perf', {
id = 521,
id = 621,
temporary = true,
if_not_exists = true,
field_count = 3,
Expand Down Expand Up @@ -117,7 +117,7 @@ box.once("init", function()
end

local s = box.schema.space.create('test_error_type', {
id = 522,
id = 622,
temporary = true,
if_not_exists = true,
field_count = 2,
Expand Down
6 changes: 1 addition & 5 deletions connection_pool/connection_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2379,18 +2379,14 @@ func runTestMain(m *testing.M) int {
waitStart := 100 * time.Millisecond
connectRetry := 3
retryTimeout := 500 * time.Millisecond
workDirs := []string{
"work_dir1", "work_dir2",
"work_dir3", "work_dir4",
"work_dir5"}

// Tarantool supports streams and interactive transactions since version 2.10.0
isStreamUnsupported, err := test_helpers.IsTarantoolVersionLess(2, 10, 0)
if err != nil {
log.Fatalf("Could not check the Tarantool version")
}

instances, err = test_helpers.StartTarantoolInstances(servers, workDirs, test_helpers.StartOpts{
instances, err = test_helpers.StartTarantoolInstances(servers, nil, test_helpers.StartOpts{
InitScript: initScript,
User: connOpts.User,
Pass: connOpts.Pass,
Expand Down
1 change: 0 additions & 1 deletion datetime/datetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,6 @@ func runTestMain(m *testing.M) int {
instance, err := test_helpers.StartTarantool(test_helpers.StartOpts{
InitScript: "config.lua",
Listen: server,
WorkDir: "work_dir",
User: opts.User,
Pass: opts.Pass,
WaitStart: 100 * time.Millisecond,
Expand Down
1 change: 0 additions & 1 deletion decimal/decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ func runTestMain(m *testing.M) int {
instance, err := test_helpers.StartTarantool(test_helpers.StartOpts{
InitScript: "config.lua",
Listen: server,
WorkDir: "work_dir",
User: opts.User,
Pass: opts.Pass,
WaitStart: 100 * time.Millisecond,
Expand Down
2 changes: 1 addition & 1 deletion example_custom_unpacking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func Example_customUnpacking() {
log.Fatalf("Failed to connect: %s", err.Error())
}

spaceNo := uint32(517)
spaceNo := uint32(617)
indexNo := uint32(0)

tuple := Tuple2{Cid: 777, Orig: "orig", Members: []Member{{"lol", "", 1}, {"wut", "", 3}}}
Expand Down
24 changes: 12 additions & 12 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func ExampleConnection_Select() {
conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
conn.Replace(spaceNo, []interface{}{uint(1112), "hallo", "werld"})

resp, err := conn.Select(517, 0, 0, 100, tarantool.IterEq, []interface{}{uint(1111)})
resp, err := conn.Select(617, 0, 0, 100, tarantool.IterEq, []interface{}{uint(1111)})

if err != nil {
fmt.Printf("error in select is %v", err)
Expand All @@ -75,7 +75,7 @@ func ExampleConnection_SelectTyped() {
defer conn.Close()
var res []Tuple

err := conn.SelectTyped(517, 0, 0, 100, tarantool.IterEq, tarantool.IntKey{1111}, &res)
err := conn.SelectTyped(617, 0, 0, 100, tarantool.IterEq, tarantool.IntKey{1111}, &res)

if err != nil {
fmt.Printf("error in select is %v", err)
Expand All @@ -96,7 +96,7 @@ func ExampleConnection_SelectTyped() {
func ExampleConnection_SelectAsync() {
conn := example_connect(opts)
defer conn.Close()
spaceNo := uint32(517)
spaceNo := uint32(617)

conn.Insert(spaceNo, []interface{}{uint(16), "test", "one"})
conn.Insert(spaceNo, []interface{}{uint(17), "test", "one"})
Expand Down Expand Up @@ -223,7 +223,7 @@ func ExampleSelectRequest() {
conn := example_connect(opts)
defer conn.Close()

req := tarantool.NewSelectRequest(517).
req := tarantool.NewSelectRequest(617).
Limit(100).
Key(tarantool.IntKey{1111})
resp, err := conn.Do(req).Get()
Expand Down Expand Up @@ -253,7 +253,7 @@ func ExampleUpdateRequest() {
conn := example_connect(opts)
defer conn.Close()

req := tarantool.NewUpdateRequest(517).
req := tarantool.NewUpdateRequest(617).
Key(tarantool.IntKey{1111}).
Operations(tarantool.NewOperations().Assign(1, "bye"))
resp, err := conn.Do(req).Get()
Expand Down Expand Up @@ -284,7 +284,7 @@ func ExampleUpsertRequest() {
defer conn.Close()

var req tarantool.Request
req = tarantool.NewUpsertRequest(517).
req = tarantool.NewUpsertRequest(617).
Tuple([]interface{}{uint(1113), "first", "first"}).
Operations(tarantool.NewOperations().Assign(1, "updated"))
resp, err := conn.Do(req).Get()
Expand All @@ -305,7 +305,7 @@ func ExampleUpsertRequest() {
}
fmt.Printf("response is %#v\n", resp.Data)

req = tarantool.NewSelectRequest(517).
req = tarantool.NewSelectRequest(617).
Limit(100).
Key(tarantool.IntKey{1113})
resp, err = conn.Do(req).Get()
Expand Down Expand Up @@ -830,12 +830,12 @@ func ExampleSchema() {
}

space1 := schema.Spaces["test"]
space2 := schema.SpacesById[516]
space2 := schema.SpacesById[616]
fmt.Printf("Space 1 ID %d %s\n", space1.Id, space1.Name)
fmt.Printf("Space 2 ID %d %s\n", space2.Id, space2.Name)
// Output:
// Space 1 ID 517 test
// Space 2 ID 516 schematest
// Space 1 ID 617 test
// Space 2 ID 616 schematest
}

// Example demonstrates how to retrieve information with space schema.
Expand All @@ -854,7 +854,7 @@ func ExampleSpace() {

// Access Space objects by name or ID.
space1 := schema.Spaces["test"]
space2 := schema.SpacesById[516] // It's a map.
space2 := schema.SpacesById[616] // It's a map.
fmt.Printf("Space 1 ID %d %s %s\n", space1.Id, space1.Name, space1.Engine)
fmt.Printf("Space 1 ID %d %t\n", space1.FieldsCount, space1.Temporary)

Expand All @@ -875,7 +875,7 @@ func ExampleSpace() {
fmt.Printf("SpaceField 2 %s %s\n", spaceField2.Name, spaceField2.Type)

// Output:
// Space 1 ID 517 test memtx
// Space 1 ID 617 test memtx
// Space 1 ID 0 false
// Index 0 primary
// &{0 unsigned} &{2 string}
Expand Down
4 changes: 2 additions & 2 deletions multi/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rawset(_G, 'get_cluster_nodes', get_cluster_nodes)

box.once("init", function()
local s = box.schema.space.create('test', {
id = 517,
id = 617,
if_not_exists = true,
})
s:create_index('primary', {type = 'tree', parts = {1, 'string'}, if_not_exists = true})
Expand All @@ -22,7 +22,7 @@ box.once("init", function()
box.schema.user.grant('test', 'read,write,execute', 'universe')

local sp = box.schema.space.create('SQL_TEST', {
id = 521,
id = 621,
if_not_exists = true,
format = {
{name = "NAME0", type = "unsigned"},
Expand Down
4 changes: 1 addition & 3 deletions multi/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

var server1 = "127.0.0.1:3013"
var server2 = "127.0.0.1:3014"
var spaceNo = uint32(517)
var spaceNo = uint32(617)
var spaceName = "test"
var indexNo = uint32(0)
var connOpts = tarantool.Opts{
Expand Down Expand Up @@ -592,7 +592,6 @@ func runTestMain(m *testing.M) int {
inst1, err := test_helpers.StartTarantool(test_helpers.StartOpts{
InitScript: initScript,
Listen: server1,
WorkDir: "work_dir1",
User: connOpts.User,
Pass: connOpts.Pass,
WaitStart: waitStart,
Expand All @@ -609,7 +608,6 @@ func runTestMain(m *testing.M) int {
inst2, err := test_helpers.StartTarantool(test_helpers.StartOpts{
InitScript: initScript,
Listen: server2,
WorkDir: "work_dir2",
User: connOpts.User,
Pass: connOpts.Pass,
WaitStart: waitStart,
Expand Down
4 changes: 1 addition & 3 deletions queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,6 @@ func runTestMain(m *testing.M) int {
inst, err := test_helpers.StartTarantool(test_helpers.StartOpts{
InitScript: "testdata/config.lua",
Listen: server,
WorkDir: "work_dir",
User: opts.User,
Pass: opts.Pass,
WaitStart: 100 * time.Millisecond,
Expand All @@ -913,15 +912,14 @@ func runTestMain(m *testing.M) int {

defer test_helpers.StopTarantoolWithCleanup(inst)

workDirs := []string{"work_dir1", "work_dir2"}
poolOpts := test_helpers.StartOpts{
InitScript: "testdata/pool.lua",
User: opts.User,
Pass: opts.Pass,
WaitStart: 3 * time.Second, // replication_timeout * 3
ConnectRetry: -1,
}
instances, err = test_helpers.StartTarantoolInstances(serversPool, workDirs, poolOpts)
instances, err = test_helpers.StartTarantoolInstances(serversPool, nil, poolOpts)

if err != nil {
log.Fatalf("Failed to prepare test tarantool pool: %s", err)
Expand Down
25 changes: 25 additions & 0 deletions queue/testdata/config.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
-- configure path so that you can run application
-- from outside the root directory
if package.setsearchroot ~= nil then
package.setsearchroot()
else
-- Workaround for rocks loading in tarantool 1.10
-- It can be removed in tarantool > 2.2
-- By default, when you do require('mymodule'), tarantool looks into
-- the current working directory and whatever is specified in
-- package.path and package.cpath. If you run your app while in the
-- root directory of that app, everything goes fine, but if you try to
-- start your app with "tarantool myapp/init.lua", it will fail to load
-- its modules, and modules from myapp/.rocks.
local fio = require('fio')
local app_dir = fio.abspath(fio.dirname(arg[0]))
package.path = app_dir .. '/?.lua;' .. package.path
package.path = app_dir .. '/?/init.lua;' .. package.path
package.path = app_dir .. '/.rocks/share/tarantool/?.lua;' .. package.path
package.path = app_dir .. '/.rocks/share/tarantool/?/init.lua;' .. package.path
package.cpath = app_dir .. '/?.so;' .. package.cpath
package.cpath = app_dir .. '/?.dylib;' .. package.cpath
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.so;' .. package.cpath
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.dylib;' .. package.cpath
end

local queue = require('queue')
rawset(_G, 'queue', queue)

Expand Down
25 changes: 25 additions & 0 deletions queue/testdata/pool.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
-- configure path so that you can run application
-- from outside the root directory
if package.setsearchroot ~= nil then
package.setsearchroot()
else
-- Workaround for rocks loading in tarantool 1.10
-- It can be removed in tarantool > 2.2
-- By default, when you do require('mymodule'), tarantool looks into
-- the current working directory and whatever is specified in
-- package.path and package.cpath. If you run your app while in the
-- root directory of that app, everything goes fine, but if you try to
-- start your app with "tarantool myapp/init.lua", it will fail to load
-- its modules, and modules from myapp/.rocks.
local fio = require('fio')
local app_dir = fio.abspath(fio.dirname(arg[0]))
package.path = app_dir .. '/?.lua;' .. package.path
package.path = app_dir .. '/?/init.lua;' .. package.path
package.path = app_dir .. '/.rocks/share/tarantool/?.lua;' .. package.path
package.path = app_dir .. '/.rocks/share/tarantool/?/init.lua;' .. package.path
package.cpath = app_dir .. '/?.so;' .. package.cpath
package.cpath = app_dir .. '/?.dylib;' .. package.cpath
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.so;' .. package.cpath
package.cpath = app_dir .. '/.rocks/lib/tarantool/?.dylib;' .. package.cpath
end

local queue = require('queue')
rawset(_G, 'queue', queue)

Expand Down
21 changes: 21 additions & 0 deletions settings/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package settings

const sessionSettingsSpace string = "_session_settings"

// In Go and IPROTO_UPDATE count starts with 0.
const sessionSettingValueField int = 1

const (
errorMarshalingEnabled string = "error_marshaling_enabled"
sqlDefaultEngine string = "sql_default_engine"
sqlDeferForeignKeys string = "sql_defer_foreign_keys"
sqlFullColumnNames string = "sql_full_column_names"
sqlFullMetadata string = "sql_full_metadata"
sqlParserDebug string = "sql_parser_debug"
sqlRecursiveTriggers string = "sql_recursive_triggers"
sqlReverseUnorderedSelects string = "sql_reverse_unordered_selects"
sqlSelectDebug string = "sql_select_debug"
sqlVDBEDebug string = "sql_vdbe_debug"
)

const selectAllLimit uint32 = 1000
Loading