From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 761852C22D for ; Thu, 4 Oct 2018 10:36:38 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Si7sHAThpTCy for ; Thu, 4 Oct 2018 10:36:38 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id AB7F022B9F for ; Thu, 4 Oct 2018 10:36:37 -0400 (EDT) From: AKhatskevich Subject: [tarantool-patches] [PATCH 2/2] lua-yaml: fix yaml encode/decode type inferring Date: Thu, 4 Oct 2018 17:36:14 +0300 Message-Id: <9fab4f4496d3c255ed1de3c7642817d07992a7af.1538663611.git.avkhatskevich@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: kyukhin@tarantool.org, tarantool-patches@freelists.org Changes: * encode boolean values in single-quoted style * encode/decode nulls as '', '~', 'null', 'Null', "NULL", according to the yaml 1.0/1.1/1.2 standard * fix affected tests Related to #3476 Closes #3662 #3583 --- test/app-tap/console.test.lua | 25 +- test/app/fio.result | 2 +- test/app/socket.result | 26 +- test/box/access.result | 8 +- test/box/misc.result | 2 +- test/box/role.result | 8 +- test/box/sequence.result | 2 +- test/vinyl/errinj.result | 10 +- test/vinyl/hermitage.result | 122 ++--- test/vinyl/mvcc.result | 1062 +++++++++++++++++++-------------------- test/vinyl/tx_conflict.result | 4 +- test/vinyl/tx_conflict.test.lua | 4 +- test/vinyl/tx_gap_lock.result | 186 +++---- test/vinyl/tx_serial.result | 4 +- test/vinyl/tx_serial.test.lua | 4 +- test/vinyl/txn_proxy.lua | 6 + third_party/lua-yaml/lyaml.cc | 43 +- third_party/lua-yaml/str_type.h | 33 ++ 18 files changed, 802 insertions(+), 749 deletions(-) create mode 100644 third_party/lua-yaml/str_type.h diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua index 1c76072aa..43b9b599f 100755 --- a/test/app-tap/console.test.lua +++ b/test/app-tap/console.test.lua @@ -21,7 +21,7 @@ local EOL = "\n...\n" test = tap.test("console") -test:plan(57) +test:plan(68) -- Start console and connect to it local server = console.listen(CONSOLE_SOCKET) @@ -60,20 +60,33 @@ client_info = nil -- Check console.delimiter() client:write("require('console').delimiter(';')\n") -test:is(yaml.decode(client:read(EOL)), '', "set delimiter to ';'") +test:is(yaml.decode(client:read(EOL)), nil, "set delimiter to ';'") test:is(state.delimiter, ';', "state.delimiter is ';'") client:write("require('console').delimiter();\n") test:is(yaml.decode(client:read(EOL))[1], ';', "get delimiter is ';'") client:write("require('console').delimiter('');\n") -test:is(yaml.decode(client:read(EOL)), '', "clear delimiter") +test:is(yaml.decode(client:read(EOL)), nil, "clear delimiter") -- -- gh-3476: yaml.encode encodes 'false' and 'true' incorrectly. +-- gh-3662: yaml.encode encodes booleans with multiline format. +-- gh-3583: yaml.encode encodes null incorrectly. -- -test:is(type(yaml.decode(yaml.encode('false'))), 'string') -test:is(type(yaml.decode(yaml.encode('true'))), 'string') -test:is(type(yaml.decode(yaml.encode({a = 'false'})).a), 'string') +local function decoded_to(values, ethalon) + for _, val in ipairs(values) do + test:is(yaml.decode(val), ethalon, val) + end +end + test:is(type(yaml.decode(yaml.encode({a = 'false'})).a), 'string') +test:is((yaml.encode('false')), "--- 'false'\n...\n") +test:is((yaml.encode(false)), "--- false\n...\n") +decoded_to({ 'false', 'no' }, false) +test:is((yaml.encode('true')), "--- 'true'\n...\n") +test:is((yaml.encode(true)), "--- true\n...\n") +decoded_to({ 'true', 'yes' }, true) +decoded_to({ '---', '~', 'null', 'Null', 'NULL' }, nil) +test:is((yaml.encode(nil)), "--- null\n...\n") box.cfg{ listen=IPROTO_SOCKET; diff --git a/test/app/fio.result b/test/app/fio.result index b7a1f65c6..c47a2d8ca 100644 --- a/test/app/fio.result +++ b/test/app/fio.result @@ -69,7 +69,7 @@ err:match("basename") ~= nil ... fio.basename('/') --- -- +- '' ... fio.basename('abc') --- diff --git a/test/app/socket.result b/test/app/socket.result index 729c1eb3f..62967e281 100644 --- a/test/app/socket.result +++ b/test/app/socket.result @@ -1231,7 +1231,7 @@ c:error() ... x, type(x), #x --- -- +- '' - string - 0 ... @@ -1244,7 +1244,7 @@ c:error() ... x, type(x), #x --- -- +- '' - string - 0 ... @@ -1281,7 +1281,7 @@ c:error() ... x, type(x), #x --- -- +- '' - string - 0 ... @@ -1294,7 +1294,7 @@ c:error() ... x, type(x), #x --- -- +- '' - string - 0 ... @@ -1307,7 +1307,7 @@ c:error() ... x, type(x), #x --- -- +- '' - string - 0 ... @@ -1973,7 +1973,7 @@ c:receive(4) ... c:receive("*l") --- -- +- '' ... wch:put("Fu") --- @@ -1997,19 +1997,19 @@ c:receive() --- - null - closed -- +- '' ... c:receive(10) --- - null - closed -- +- '' ... c:receive("*a") --- - null - closed -- +- '' ... c:close() --- @@ -2343,7 +2343,7 @@ received_message == '' -- expected true ... received_message --- -- +- '' ... e == 0 -- expected true --- @@ -2366,7 +2366,7 @@ received_message == '' -- expected true ... received_message --- -- +- '' ... from ~= nil -- expected true --- @@ -2443,7 +2443,7 @@ received_message == '' -- expected true ... received_message --- -- +- '' ... e == 0 -- expected true --- @@ -2466,7 +2466,7 @@ received_message == '' -- expected true ... received_message --- -- +- '' ... from ~= nil -- expected true --- diff --git a/test/box/access.result b/test/box/access.result index 4e49680d0..c3f48c23b 100644 --- a/test/box/access.result +++ b/test/box/access.result @@ -975,7 +975,7 @@ box.schema.user.info('test_user') - test_space - - session,usage - universe - - + - '' - - alter - user - test_user @@ -1008,7 +1008,7 @@ box.schema.user.info('test_user') - public - - session,usage - universe - - + - '' - - alter - user - test_user @@ -1326,7 +1326,7 @@ e.type, e.access_type, e.object_type, e.message obj_type, obj_name, op_type --- - universe -- +- '' - Usage ... euid, auid @@ -1346,7 +1346,7 @@ c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user="test_user", obj_type, obj_name, op_type --- - universe -- +- '' - Session ... euid, auid diff --git a/test/box/misc.result b/test/box/misc.result index 4ee4797d0..fe35f0460 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -55,7 +55,7 @@ t = {} for n in pairs(box) do table.insert(t, tostring(n)) end table.sort(t) ... t --- -- - NULL +- - 'NULL' - atomic - backup - begin diff --git a/test/box/role.result b/test/box/role.result index 3a54e2460..9b044667a 100644 --- a/test/box/role.result +++ b/test/box/role.result @@ -28,7 +28,7 @@ box.schema.role.info('iddqd') --- - - - execute - universe - - + - '' ... box.schema.role.revoke('iddqd', 'execute', 'universe') --- @@ -48,7 +48,7 @@ box.schema.user.info('tester') - public - - session,usage - universe - - + - '' - - alter - user - tester @@ -66,7 +66,7 @@ box.schema.user.info('tester') - iddqd - - session,usage - universe - - + - '' - - alter - user - tester @@ -940,7 +940,7 @@ box.schema.user.info('test_user') - public - - session,usage - universe - - + - '' - - alter - user - test_user diff --git a/test/box/sequence.result b/test/box/sequence.result index b3907659f..f429d7dae 100644 --- a/test/box/sequence.result +++ b/test/box/sequence.result @@ -1361,7 +1361,7 @@ box.schema.user.info() - _priv - - session,usage - universe - - + - '' - - alter - user - user diff --git a/test/vinyl/errinj.result b/test/vinyl/errinj.result index 8badb47af..01e6e05cc 100644 --- a/test/vinyl/errinj.result +++ b/test/vinyl/errinj.result @@ -641,28 +641,28 @@ c0 = txn_proxy.new() ... c0:begin() --- -- +- [] ... c1 = txn_proxy.new() --- ... c1:begin() --- -- +- [] ... c2 = txn_proxy.new() --- ... c2:begin() --- -- +- [] ... c3 = txn_proxy.new() --- ... c3:begin() --- -- +- [] ... -- -- Prepared transactions @@ -770,7 +770,7 @@ c3('s:select{3}') -- c2 is not visible ... c3:commit() --- -- +- [] ... s:drop() --- diff --git a/test/vinyl/hermitage.result b/test/vinyl/hermitage.result index 23495fde1..3d26e5b0f 100644 --- a/test/vinyl/hermitage.result +++ b/test/vinyl/hermitage.result @@ -51,11 +51,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:replace{1, 11}") --- @@ -71,7 +71,7 @@ c1("t:replace{2, 21}") ... c1:commit() --- -- +- [] ... c2("t:replace{2, 22}") --- @@ -79,7 +79,7 @@ c2("t:replace{2, 22}") ... c2:commit() -- success, the last writer wins --- -- +- [] ... t:get{1} -- {1, 12} --- @@ -107,11 +107,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:update(1, {{'=', 2, 11}})") --- @@ -127,7 +127,7 @@ c1("t:update(2, {{'=', 2, 21}})") ... c1:commit() --- -- +- [] ... c2("t:update(2, {{'=', 2, 22}})") --- @@ -163,11 +163,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:replace{1, 101}") --- @@ -179,7 +179,7 @@ c2("t:replace{1, 10}") ... c1:rollback() --- -- +- [] ... c2("t:get{1}") -- {1, 10} --- @@ -187,7 +187,7 @@ c2("t:get{1}") -- {1, 10} ... c2:commit() -- true --- -- +- [] ... -- teardown t:truncate() @@ -207,11 +207,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:replace{1, 101}") --- @@ -227,7 +227,7 @@ c1("t:replace{1, 11}") ... c1:commit() -- ok --- -- +- [] ... c2("t:get{1}") -- {1, 10} --- @@ -235,7 +235,7 @@ c2("t:get{1}") -- {1, 10} ... c2:commit() -- ok --- -- +- [] ... -- teardown t:truncate() @@ -255,11 +255,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:replace{1, 11}") --- @@ -279,7 +279,7 @@ c2("t:get{1}") -- {1, 10} ... c1:commit() -- ok --- -- +- [] ... c2:commit() -- rollback (@fixme: not necessary) --- @@ -303,15 +303,15 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c1("t:replace{1, 11}") --- @@ -327,7 +327,7 @@ c2("t:replace{1, 12}") ... c1:commit() -- ok --- -- +- [] ... c3("t:get{1}") -- {1, 11} --- @@ -343,7 +343,7 @@ c3("t:get{2}") -- {2, 19} ... c2:commit() -- write only transaction - OK to commit --- -- +- [] ... c3("t:get{2}") -- {2, 19} --- @@ -355,7 +355,7 @@ c3("t:get{1}") -- {1, 11} ... c3:commit() -- read only transaction - OK to commit, stays with its read view --- -- +- [] ... -- teardown t:truncate() @@ -375,11 +375,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:select()") -- {1, 10}, {2, 20} --- @@ -391,7 +391,7 @@ c2("t:replace{3, 30}") ... c2:commit() -- ok --- -- +- [] ... c1("t:select()") -- still {1, 10}, {2, 20} --- @@ -399,7 +399,7 @@ c1("t:select()") -- still {1, 10}, {2, 20} ... c1:commit() -- ok --- -- +- [] ... -- teardown t:truncate() @@ -419,11 +419,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:replace{1, 20}") --- @@ -443,11 +443,11 @@ c2("t:get{2}") -- {2, 20} ... c2("t:delete{2}") --- -- +- [] ... c1:commit() -- ok --- -- +- [] ... c2("t:get{1}") -- {1, 10} --- @@ -483,11 +483,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{1}") -- {1, 10} --- @@ -507,7 +507,7 @@ c2("t:replace{1, 12}") ... c1:commit() -- ok --- -- +- [] ... c2:commit() -- rollback -- conflict --- @@ -531,11 +531,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{1}") -- {1, 10} --- @@ -559,7 +559,7 @@ c2("t:replace{2, 18}") ... c2:commit() -- ok --- -- +- [] ... c1("t:get{2}") -- {2, 20} --- @@ -567,7 +567,7 @@ c1("t:get{2}") -- {2, 20} ... c1:commit() -- ok --- -- +- [] ... -- teardown t:truncate() @@ -587,11 +587,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{1}") -- {1, 10} --- @@ -615,15 +615,15 @@ c2("t:replace{2, 18}") ... c2:commit() -- T2 --- -- +- [] ... c1("t:delete{2}") --- -- +- [] ... c1("t:get{2}") -- finds nothing --- -- +- [] ... c1:commit() -- rollback --- @@ -647,11 +647,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{1}") -- {1, 10} --- @@ -679,7 +679,7 @@ c2("t:replace{1, 21}") ... c1:commit() -- ok --- -- +- [] ... c2:commit() -- rollback -- conflict --- @@ -703,11 +703,11 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... -- select * from test where value % 3 = 0 c1("t:select()") -- {1, 10}, {2, 20} @@ -728,7 +728,7 @@ c2("t:replace{4, 42}") ... c1:commit() -- ok --- -- +- [] ... c2:commit() -- rollback --- @@ -752,7 +752,7 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c1("t:get{1}") -- {1, 10} --- @@ -764,7 +764,7 @@ c1("t:get{2}") -- {2, 20} ... c2:begin() --- -- +- [] ... c2("t:replace{2, 25}") --- @@ -772,11 +772,11 @@ c2("t:replace{2, 25}") ... c2:commit() -- ok --- -- +- [] ... c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 10} --- @@ -788,7 +788,7 @@ c3("t:get{2}") -- {2, 25} ... c3:commit() -- ok --- -- +- [] ... c1("t:replace{1, 0}") --- @@ -816,7 +816,7 @@ t:replace{2, 20} ... c1:begin() --- -- +- [] ... c1("t:get{1}") -- {1, 10} --- @@ -828,7 +828,7 @@ c1("t:get{2}") -- {2, 20} ... c2:begin() --- -- +- [] ... c2("t:replace{2, 25}") --- @@ -836,11 +836,11 @@ c2("t:replace{2, 25}") ... c2:commit() -- ok --- -- +- [] ... c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 10} --- @@ -852,12 +852,12 @@ c3("t:get{2}") -- {2, 25} ... c3:commit() -- ok --- -- +- [] ... -- c1("t:replace{1, 0)") c1:commit() -- ok --- -- +- [] ... -- teardown t:truncate() diff --git a/test/vinyl/mvcc.result b/test/vinyl/mvcc.result index 1941744b9..1d354b3ea 100644 --- a/test/vinyl/mvcc.result +++ b/test/vinyl/mvcc.result @@ -41,29 +41,29 @@ t = box.space.test -- c1:begin() --- -- +- [] ... c1:commit() --- -- +- [] ... -- -- empty transaction rollback -- c1:begin() --- -- +- [] ... c1:rollback() --- -- +- [] ... -- -- single-statement transaction commit -- c1:begin() --- -- +- [] ... c1("t:replace{1}") --- @@ -71,7 +71,7 @@ c1("t:replace{1}") ... c1:commit() --- -- +- [] ... c1("t:get{1}") --- @@ -80,14 +80,14 @@ c1("t:get{1}") -- cleanup c1("t:delete{1}") --- -- +- [] ... -- -- single-statement transaction rollback -- c1:begin() --- -- +- [] ... c1("t:replace{1}") --- @@ -95,18 +95,18 @@ c1("t:replace{1}") ... c1:rollback() --- -- +- [] ... c1("t:get{1}") --- -- +- [] ... -- -- basic effects: if a transaction is rolled back, it has no effect -- c1:begin() --- -- +- [] ... c1("t:insert{1}") --- @@ -118,15 +118,15 @@ c1("t:get{1}") ... c1:rollback() --- -- +- [] ... c1("t:get{1}") --- -- +- [] ... c2("t:get{1}") --- -- +- [] ... -- -- multi-statement transaction @@ -137,7 +137,7 @@ test_run:cmd("setopt delimiter ';'") ... c1:begin(); --- -- +- [] ... for i = 1,100 do c1(string.format("t:insert{%d}", i)) @@ -147,7 +147,7 @@ end; ... c1:commit(); --- -- +- [] ... for i = 1,100 do c1(string.format("t:delete{%d}", i)) @@ -172,7 +172,7 @@ test_run:cmd("setopt delimiter ';'") ... c1:begin(); --- -- +- [] ... for i = 1,100 do c1(string.format("t:insert{%d}", i)) @@ -182,7 +182,7 @@ end; ... c1:rollback(); --- -- +- [] ... for i = 1,100 do assert(#c1(string.format("t:get{%d}", i)) == 0) @@ -196,7 +196,7 @@ test_run:cmd("setopt delimiter ''"); -- transaction_set_set_get_commit(void) c1:begin() --- -- +- [] ... c1("t:replace{1, 1}") --- @@ -212,7 +212,7 @@ c1("t:get{1}") ... c1:commit() --- -- +- [] ... c1("t:get{1}") --- @@ -220,12 +220,12 @@ c1("t:get{1}") ... c1("t:delete{1}") --- -- +- [] ... -- transaction_set_set_commit_get(void) c1:begin() --- -- +- [] ... c1("t:replace{1}") --- @@ -237,11 +237,11 @@ c1("t:replace{1, 2}") ... c1:commit() --- -- +- [] ... c2:begin() --- -- +- [] ... c2("t:get{1}") --- @@ -249,16 +249,16 @@ c2("t:get{1}") ... c2:rollback() --- -- +- [] ... c1("t:delete{1}") --- -- +- [] ... -- transaction_set_set_rollback_get(void) c1:begin() --- -- +- [] ... c1("t:replace{1}") --- @@ -270,24 +270,24 @@ c1("t:replace{1, 2}") ... c1:rollback() --- -- +- [] ... c2:begin() --- -- +- [] ... c2("t:get{1}") --- -- +- [] ... c2:rollback() --- -- +- [] ... -- transaction_set_delete_get_commit(void) c1:begin() --- -- +- [] ... c1("t:insert{1}") --- @@ -295,20 +295,20 @@ c1("t:insert{1}") ... c1("t:delete{1}") --- -- +- [] ... c1("t:get{1}") --- -- +- [] ... c1:commit() --- -- +- [] ... -- transaction_set_delete_get_commit_get(void) c1:begin() --- -- +- [] ... c1("t:insert{1}") --- @@ -316,26 +316,26 @@ c1("t:insert{1}") ... c1("t:delete{1}") --- -- +- [] ... c1("t:get{1}") --- -- +- [] ... c1:commit() --- -- +- [] ... c1("t:get{1}") --- -- +- [] ... -- -- transaction_set_delete_set_commit_get(void) -- c1:begin() --- -- +- [] ... c1("t:insert{1, 1}") --- @@ -343,7 +343,7 @@ c1("t:insert{1, 1}") ... c1("t:delete{1}") --- -- +- [] ... c1("t:insert{1, 2}") --- @@ -355,7 +355,7 @@ c1("t:get{1}") ... c1:commit() --- -- +- [] ... c2("t:get{1}") --- @@ -366,14 +366,14 @@ c2("t:get{1}") -- c1("t:delete{1}") --- -- +- [] ... -- -- transaction_set_delete_commit_get_set(void) -- c1:begin() --- -- +- [] ... c1("t:insert{1}") --- @@ -381,15 +381,15 @@ c1("t:insert{1}") ... c1("t:delete{1}") --- -- +- [] ... c1:commit() --- -- +- [] ... c1("t:get{1}") --- -- +- [] ... c1("t:insert{1}") --- @@ -401,22 +401,22 @@ c1("t:get{1}") ... c1("t:delete{1}") --- -- +- [] ... c1("t:get{1}") --- -- +- [] ... -- -- transaction_p_set_commit(void) -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:replace{1, 10}") --- @@ -424,7 +424,7 @@ c1("t:replace{1, 10}") ... c1:commit() --- -- +- [] ... c2("t:replace{2, 15}"); --- @@ -432,7 +432,7 @@ c2("t:replace{2, 15}"); ... c2:commit() --- -- +- [] ... c1("t:get{1}") --- @@ -444,11 +444,11 @@ c1("t:get{2}") ... c1("t:delete{1}") --- -- +- [] ... c1("t:delete{2}") --- -- +- [] ... -- -- no dirty reads: if a transaction is not committed, its effects are not @@ -456,7 +456,7 @@ c1("t:delete{2}") -- c1:begin() --- -- +- [] ... c1("t:insert{1}") --- @@ -471,11 +471,11 @@ c1("t:get{1}") -- c2("t:get{1}") --- -- +- [] ... c1:commit() --- -- +- [] ... -- -- become visible in c2 after c1 commits (c2 runs in autocommit) @@ -491,7 +491,7 @@ c2("t:get{1}") -- c1:begin() --- -- +- [] ... c1("t:get{1}") --- @@ -510,7 +510,7 @@ c1("t:get{1}") ... c2:commit() --- -- +- [] ... -- -- still not visible, even though c2 has committed @@ -522,7 +522,7 @@ c1("t:get{1}") -- commits ok since is a read only transaction c1:commit() --- -- +- [] ... -- -- now visible @@ -533,7 +533,7 @@ c1("t:get{1}") ... c1("t:delete{1}") --- -- +- [] ... -- ******************************* -- tx manager tests from sophia * @@ -544,19 +544,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c1("t:replace{1, 10}") --- @@ -569,7 +569,7 @@ c1("t:get{1}") -- {1, 10} -- c1:commit() --- -- +- [] ... -- -- @@ -585,18 +585,18 @@ c2("t:get{2}") -- {2, 15} -- c2:commit() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... c1("t:delete{2}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -605,19 +605,19 @@ c1("t:delete{2}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -627,7 +627,7 @@ c1("t:replace{1, 10}") -- c1:commit() --- -- +- [] ... -- c2("t:replace{2, 15}") @@ -636,12 +636,12 @@ c2("t:replace{2, 15}") ... c2:commit() --- -- +- [] ... -- c1:begin() --- -- +- [] ... c1("t:get{1}") -- {1, 10} --- @@ -654,18 +654,18 @@ c1("t:get{2}") -- {2, 15} ... c1:rollback() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... c1("t:delete{2}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_p_set_commit_get1(void) @@ -673,19 +673,19 @@ c1("t:delete{2}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") --- -- +- [] ... c2("t:get{200}") --- -- +- [] ... -- c2("t:replace{1, 10}") @@ -694,7 +694,7 @@ c2("t:replace{1, 10}") ... c2:commit() --- -- +- [] ... -- -- try writing an unrelated key @@ -705,12 +705,12 @@ c1("t:replace{2, 15}") ... c1:commit() --- -- +- [] ... -- c2:begin() --- -- +- [] ... c2("t:get{1}") -- {1, 10} --- @@ -718,37 +718,37 @@ c2("t:get{1}") -- {1, 10} ... c2:rollback() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... c1("t:delete{2}") --- -- +- [] ... -- -- -- now try the same key -- -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") --- -- +- [] ... c2("t:get{200}") --- -- +- [] ... -- c2("t:replace{1, 10}") @@ -757,7 +757,7 @@ c2("t:replace{1, 10}") ... c2:commit() --- -- +- [] ... -- c1("t:replace{1, 15}") @@ -766,12 +766,12 @@ c1("t:replace{1, 15}") ... c1:commit() --- -- +- [] ... -- c2:begin() --- -- +- [] ... c2("t:get{1}") -- {1, 15} --- @@ -779,14 +779,14 @@ c2("t:get{1}") -- {1, 15} ... c2:rollback() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_p_set_commit_get2(void) @@ -794,19 +794,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") --- -- +- [] ... c2("t:get{200}") --- -- +- [] ... -- -- @@ -816,7 +816,7 @@ c1("t:replace{2, 15}") ... c1:commit() --- -- +- [] ... -- -- @@ -826,12 +826,12 @@ c2("t:replace{1, 10}") ... c2:commit() -- commits successfully --- -- +- [] ... -- c1:begin() --- -- +- [] ... c1("t:get{1}") -- {1, 10} --- @@ -844,18 +844,18 @@ c1("t:get{2}") -- {2, 15} ... c1:rollback() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... c1("t:delete{2}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_p_set_rollback_get0(void) @@ -863,19 +863,19 @@ c1("t:delete{2}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") --- -- +- [] ... c2("t:get{200}") --- -- +- [] ... -- -- @@ -885,7 +885,7 @@ c1("t:replace{1, 10}") ... c1:rollback() --- -- +- [] ... -- c2("t:replace{2, 15}") @@ -894,24 +894,24 @@ c2("t:replace{2, 15}") ... c2:rollback() --- -- +- [] ... -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- finds nothing --- -- +- [] ... c3("t:get{2}") -- finds nothing --- -- +- [] ... c3:rollback() --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_p_set_rollback_get1(void) @@ -920,19 +920,19 @@ c3:rollback() -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 10}") @@ -941,7 +941,7 @@ c2("t:replace{1, 10}") ... c2:rollback() --- -- +- [] ... -- c1("t:replace{2, 15}") @@ -950,24 +950,24 @@ c1("t:replace{2, 15}") ... c1:rollback() --- -- +- [] ... -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- finds nothing --- -- +- [] ... c3("t:get{2}") -- finds nothing --- -- +- [] ... c3:rollback() --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -976,19 +976,19 @@ c3:rollback() -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- -- @@ -998,7 +998,7 @@ c2("t:replace{1, 10}") ... c2:rollback() --- -- +- [] ... -- c1("t:replace{1, 15}") @@ -1007,29 +1007,29 @@ c1("t:replace{1, 15}") ... c1:rollback() --- -- +- [] ... -- c3("t:get{1}") -- finds nothing --- -- +- [] ... -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- -- @@ -1039,7 +1039,7 @@ c2("t:replace{1, 10}") ... c2:rollback() --- -- +- [] ... -- c1("t:replace{1, 15}") @@ -1048,7 +1048,7 @@ c1("t:replace{1, 15}") ... c1:commit() --- -- +- [] ... -- c3("t:get{1}") -- {1, 15} @@ -1060,7 +1060,7 @@ c3("t:get{1}") -- {1, 15} -- c3("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_c_set_commit0(void) @@ -1068,19 +1068,19 @@ c3("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c1("t:replace{1, 10}") --- @@ -1088,7 +1088,7 @@ c1("t:replace{1, 10}") ... c1:commit() --- -- +- [] ... -- c2("t:replace{1, 15}") @@ -1097,7 +1097,7 @@ c2("t:replace{1, 15}") ... c2:commit() --- -- +- [] ... -- c2("t:get{1}") -- {1,15} @@ -1108,7 +1108,7 @@ c2("t:get{1}") -- {1,15} -- c1("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_c_set_commit1(void) @@ -1116,19 +1116,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 10}") @@ -1137,7 +1137,7 @@ c2("t:replace{1, 10}") ... c2:commit() --- -- +- [] ... -- c1("t:replace{1, 15}") @@ -1146,7 +1146,7 @@ c1("t:replace{1, 15}") ... c1:commit() --- -- +- [] ... -- c3("t:get{1}") -- {1, 15} @@ -1158,7 +1158,7 @@ c3("t:get{1}") -- {1, 15} -- c3("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_c_set_commit2(void) @@ -1166,19 +1166,19 @@ c3("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 15}") @@ -1193,11 +1193,11 @@ c2("t:replace{1, 10}") -- c2:commit() --- -- +- [] ... c1:commit() --- -- +- [] ... -- c3("t:get{1}") -- {1, 15} @@ -1209,24 +1209,24 @@ c3("t:get{1}") -- {1, 15} -- c1("t:delete{1}") --- -- +- [] ... -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 15}") @@ -1242,11 +1242,11 @@ c2("t:replace{1, 10}") -- sic: commit order c1:commit() --- -- +- [] ... c2:commit() -- write after write is ok, the last writer to commit wins --- -- +- [] ... -- c3("t:get{1}") -- {1, 10} @@ -1258,7 +1258,7 @@ c3("t:get{1}") -- {1, 10} -- c1("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_c_set_commit_rollback_a0(void) @@ -1266,19 +1266,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 10}") @@ -1288,7 +1288,7 @@ c2("t:replace{1, 10}") -- c2:rollback() --- -- +- [] ... -- c1("t:replace{1, 15}") @@ -1298,7 +1298,7 @@ c1("t:replace{1, 15}") -- c1:commit() --- -- +- [] ... -- c3("t:get{1}") @@ -1310,26 +1310,26 @@ c3("t:get{1}") -- c1("t:delete{1}") --- -- +- [] ... -- -- -- statement order is irrelevant, rollback order is important c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -1343,11 +1343,11 @@ c2("t:replace{1, 15}") -- c2:rollback() --- -- +- [] ... c1:commit() --- -- +- [] ... -- c3("t:get{1}") @@ -1359,7 +1359,7 @@ c3("t:get{1}") -- c1("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_c_set_commit_rollback_a1(void) @@ -1367,19 +1367,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 10}") @@ -1393,37 +1393,37 @@ c1("t:replace{1, 15}") -- c2:rollback() --- -- +- [] ... c1:commit() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- statements in different order now -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -1437,18 +1437,18 @@ c2("t:replace{1, 15}") -- c2:rollback() --- -- +- [] ... c1:commit() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1457,19 +1457,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 10}") @@ -1478,7 +1478,7 @@ c2("t:replace{1, 10}") ... c2:commit() -- success --- -- +- [] ... -- c1("t:replace{1, 15}") @@ -1487,7 +1487,7 @@ c1("t:replace{1, 15}") ... c1:rollback() -- success --- -- +- [] ... -- c3("t:get{1}") @@ -1498,7 +1498,7 @@ c3("t:get{1}") -- c1("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_c_set_commit_rollback_b1(void) @@ -1506,19 +1506,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 15}") @@ -1532,11 +1532,11 @@ c1("t:replace{1, 10}") -- c2:commit() --- -- +- [] ... c1:rollback() --- -- +- [] ... -- c3("t:get{1}") @@ -1548,26 +1548,26 @@ c3("t:get{1}") -- c1("t:delete{1}") --- -- +- [] ... -- -- now commit the second transaction -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 15}") @@ -1581,11 +1581,11 @@ c1("t:replace{1, 10}") -- c2:commit() --- -- +- [] ... c1:commit() -- ok, the last committer wins --- -- +- [] ... -- c3("t:get{1}") -- {1, 10} @@ -1597,7 +1597,7 @@ c3("t:get{1}") -- {1, 10} -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1606,19 +1606,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 15}") @@ -1627,7 +1627,7 @@ c2("t:replace{1, 15}") ... c2:rollback() --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -1636,38 +1636,38 @@ c1("t:replace{1, 10}") ... c1:rollback() --- -- +- [] ... -- c3("t:get{1}") --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- now commit the second transaction -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 15}") @@ -1676,7 +1676,7 @@ c2("t:replace{1, 15}") ... c2:rollback() --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -1685,7 +1685,7 @@ c1("t:replace{1, 10}") ... c1:commit() --- -- +- [] ... -- c3("t:get{1}") @@ -1697,7 +1697,7 @@ c3("t:get{1}") -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1706,19 +1706,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 10}") @@ -1732,23 +1732,23 @@ c1("t:replace{1, 15}") -- c2:rollback() --- -- +- [] ... c1:rollback() --- -- +- [] ... -- c3("t:get{1}") --- -- +- [] ... -- -- cleanup -- c2("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1757,19 +1757,19 @@ c2("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c2("t:replace{1, 15}") @@ -1784,11 +1784,11 @@ c1("t:replace{1, 10}") -- c1:commit() -- success --- -- +- [] ... c2:commit() -- success, the last writer wins --- -- +- [] ... -- c2("t:get{1}") -- {1, 15} @@ -1800,7 +1800,7 @@ c2("t:get{1}") -- {1, 15} -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1809,19 +1809,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -1836,18 +1836,18 @@ c2("t:replace{1, 15}") -- c2:commit() -- success --- -- +- [] ... c1:commit() -- success, the last writer wins --- -- +- [] ... -- -- cleanup -- c2("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1856,19 +1856,19 @@ c2("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -1883,18 +1883,18 @@ c2("t:replace{1, 15}") -- c2:commit() -- success --- -- +- [] ... c1:commit() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1903,19 +1903,19 @@ c1("t:delete{1}") -- c2:begin() --- -- +- [] ... c1:begin() --- -- +- [] ... c2("t:get{100}") -- start transaction in the engine --- -- +- [] ... c1("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -1930,18 +1930,18 @@ c2("t:replace{1, 15}") -- c2:commit() -- success --- -- +- [] ... c1:commit() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1950,19 +1950,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -1977,18 +1977,18 @@ c2("t:replace{1, 15}") -- c2:commit() -- success --- -- +- [] ... c1:commit() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -1997,19 +1997,19 @@ c1("t:delete{1}") -- c2:begin() --- -- +- [] ... c1:begin() --- -- +- [] ... c2("t:get{100}") -- start transaction in the engine --- -- +- [] ... c1("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -2024,18 +2024,18 @@ c2("t:replace{1, 15}") -- c2:commit() -- success --- -- +- [] ... c1:rollback() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2044,19 +2044,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -2071,22 +2071,22 @@ c2("t:replace{1, 15}") -- c2:commit() -- success --- -- +- [] ... c2:rollback() -- not in transaction --- -- +- [] ... c1:commit() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2095,19 +2095,19 @@ c1("t:delete{1}") -- c2:begin() --- -- +- [] ... c1:begin() --- -- +- [] ... c2("t:get{100}") -- start transaction in the engine --- -- +- [] ... c1("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -2122,26 +2122,26 @@ c2("t:replace{1, 15}") -- c2:commit() -- success --- -- +- [] ... c2:rollback() -- not in transaction --- -- +- [] ... c1:commit() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... c1("t:delete{2}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2150,27 +2150,27 @@ c1("t:delete{2}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c3:begin() --- -- +- [] ... c3("t:get{300}") -- start transaction in the engine --- -- +- [] ... -- -- @@ -2191,23 +2191,23 @@ c3("t:replace{1, 20}") -- c2:commit() -- success --- -- +- [] ... c3:commit() -- success --- -- +- [] ... c1:commit() -- success, the last committer wins --- -- +- [] ... c2:commit() -- not in transaction --- -- +- [] ... c3:commit() -- not in transaction --- -- +- [] ... -- c3:get{1} -- {1, 20} @@ -2219,7 +2219,7 @@ c3:get{1} -- {1, 20} -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2228,27 +2228,27 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c3("t:get{200}") -- start transaction in the engine --- -- +- [] ... c2("t:get{300}") -- start transaction in the engine --- -- +- [] ... -- -- @@ -2269,15 +2269,15 @@ c3("t:replace{1, 30}") -- c1:commit() -- success --- -- +- [] ... c2:commit() -- success --- -- +- [] ... c3:commit() -- success --- -- +- [] ... -- c3("t:get{1}") -- {1, 30} @@ -2288,7 +2288,7 @@ c3("t:get{1}") -- {1, 30} -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2297,27 +2297,27 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c3("t:get{300}") -- start transaction in the engine --- -- +- [] ... -- -- @@ -2338,22 +2338,22 @@ c3("t:replace{1, 20}") -- c2:commit() -- success --- -- +- [] ... c3:commit() -- rollback --- -- +- [] ... c1:rollback() -- success --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2362,27 +2362,27 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c3("t:get{300}") -- start transaction in the engine --- -- +- [] ... -- -- @@ -2403,30 +2403,30 @@ c3("t:replace{1, 20}") -- c2:commit() -- success --- -- +- [] ... c3:commit() -- rollback --- -- +- [] ... c2:rollback() -- success, not in transaction in tarantool --- -- +- [] ... c3:commit() -- success, not in transaction in tarantool --- -- +- [] ... c1:commit() -- rollback --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2435,27 +2435,27 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c3("t:get{300}") -- start transaction in the engine --- -- +- [] ... -- -- @@ -2476,22 +2476,22 @@ c3("t:replace{1, 20}") -- c3:rollback() --- -- +- [] ... c2:commit() --- -- +- [] ... c1:commit() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2500,27 +2500,27 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c3("t:get{300}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -2540,22 +2540,22 @@ c3("t:replace{1, 20}") -- c2:commit() --- -- +- [] ... c3:rollback() --- -- +- [] ... c1:commit() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2564,27 +2564,27 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c3("t:get{300}") -- start transaction in the engine --- -- +- [] ... -- -- @@ -2605,22 +2605,22 @@ c3("t:replace{1, 20}") -- c2:commit() --- -- +- [] ... c3:rollback() --- -- +- [] ... c1:rollback() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2629,19 +2629,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -2650,7 +2650,7 @@ c1("t:replace{1, 10}") ... c1:commit() --- -- +- [] ... -- c2("t:get{1}") -- find newest {1, 10} @@ -2664,12 +2664,12 @@ c2("t:replace{1, 15}") ... c2:commit() -- rollback --- -- +- [] ... -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 10} --- @@ -2677,14 +2677,14 @@ c3("t:get{1}") -- {1, 10} ... c3:commit() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2693,19 +2693,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -2715,12 +2715,12 @@ c1("t:replace{1, 10}") -- c1:rollback() --- -- +- [] ... -- c2("t:get{1}") -- finds nothing --- -- +- [] ... -- c2("t:replace{1, 15}") @@ -2729,12 +2729,12 @@ c2("t:replace{1, 15}") ... c2:commit() --- -- +- [] ... -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 15} --- @@ -2742,14 +2742,14 @@ c3("t:get{1}") -- {1, 15} ... c3:commit() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2758,15 +2758,15 @@ c1("t:delete{1}") -- c7:begin() --- -- +- [] ... c7("t:get{100}") -- start transaction in the engine --- -- +- [] ... c1:begin() --- -- +- [] ... -- c1("t:replace{1, 1}") @@ -2776,7 +2776,7 @@ c1("t:replace{1, 1}") -- c2:begin() --- -- +- [] ... -- c2("t:replace{1, 2}") @@ -2786,7 +2786,7 @@ c2("t:replace{1, 2}") -- c4:begin() --- -- +- [] ... c4("t:replace{1, 4}") --- @@ -2795,7 +2795,7 @@ c4("t:replace{1, 4}") -- c5:begin() --- -- +- [] ... c5("t:replace{1, 5}") --- @@ -2804,11 +2804,11 @@ c5("t:replace{1, 5}") -- c6:begin() --- -- +- [] ... c6("t:get{100}") -- start transaction in the engine --- -- +- [] ... -- c1("t:get{1}") -- {1, 1} @@ -2833,62 +2833,62 @@ c5("t:get{1}") -- {1, 5} -- c6("t:get{1}") -- nothing --- -- +- [] ... -- c7("t:get{1}") -- nothing --- -- +- [] ... -- c3:begin() --- -- +- [] ... -- c3("t:get{1}") -- nothing --- -- +- [] ... c3:rollback() --- -- +- [] ... -- c1:rollback() --- -- +- [] ... c2:rollback() --- -- +- [] ... c3:rollback() --- -- +- [] ... c4:rollback() --- -- +- [] ... c5:rollback() --- -- +- [] ... c6:rollback() --- -- +- [] ... c7:rollback() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -2897,24 +2897,24 @@ c1("t:delete{1}") -- c7:begin() --- -- +- [] ... c1:begin() --- -- +- [] ... c7("t:get{100}") -- start transaction in the engine --- -- +- [] ... c1("t:get{1}") -- start transaction in the engine --- -- +- [] ... -- c3:begin() --- -- +- [] ... c3("t:replace{1, 3}") --- @@ -2922,24 +2922,24 @@ c3("t:replace{1, 3}") ... c3:commit() --- -- +- [] ... -- c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c2("t:get{500}") -- start transaction in the engine --- -- +- [] ... c3("t:get{600}") -- start transaction in the engine --- -- +- [] ... c2("t:get{1}") -- {1, 3} --- @@ -2952,16 +2952,16 @@ c3("t:replace{1, 6}") ... c3:commit() -- c2 goes to read view now --- -- +- [] ... -- c4:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... -- c3("t:replace{1, 9}") @@ -2970,24 +2970,24 @@ c3("t:replace{1, 9}") ... c3:commit() --- -- +- [] ... -- c5:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c5("t:get{800}") -- start transaction in the engine --- -- +- [] ... c3("t:get{900}") -- start transaction in the engine --- -- +- [] ... -- c3("t:replace{1, 12}") @@ -2996,16 +2996,16 @@ c3("t:replace{1, 12}") ... c3:commit() --- -- +- [] ... -- c6:begin() --- -- +- [] ... c6("t:get{1000}") -- start transaction in the engine --- -- +- [] ... -- c2("t:get{1}") -- {1, 3} @@ -3030,7 +3030,7 @@ c6("t:get{1}") -- {1, 12} -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 12} --- @@ -3038,12 +3038,12 @@ c3("t:get{1}") -- {1, 12} ... c3:rollback() --- -- +- [] ... -- c1("t:get{1}") -- nothing --- -- +- [] ... -- c7("t:get{1}") -- {1, 12} @@ -3053,7 +3053,7 @@ c7("t:get{1}") -- {1, 12} -- c2:rollback() --- -- +- [] ... -- c4("t:get{1}") -- {1, 12} @@ -3073,7 +3073,7 @@ c6("t:get{1}") -- {1, 12} -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 12} --- @@ -3081,12 +3081,12 @@ c3("t:get{1}") -- {1, 12} ... c3:rollback() --- -- +- [] ... -- c1("t:get{1}") -- nothing --- -- +- [] ... -- c7("t:get{1}") -- {1, 12} @@ -3096,7 +3096,7 @@ c7("t:get{1}") -- {1, 12} -- c4:rollback() --- -- +- [] ... -- c5("t:get{1}") -- {1, 12} @@ -3111,7 +3111,7 @@ c6("t:get{1}") -- {1, 12} -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 12} --- @@ -3119,12 +3119,12 @@ c3("t:get{1}") -- {1, 12} ... c3:rollback() --- -- +- [] ... -- c1("t:get{1}") -- nothing --- -- +- [] ... -- c7("t:get{1}") -- {1, 12} @@ -3134,7 +3134,7 @@ c7("t:get{1}") -- {1, 12} -- c5:rollback() --- -- +- [] ... -- c6("t:get{1}") -- {1, 12} @@ -3144,7 +3144,7 @@ c6("t:get{1}") -- {1, 12} -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 12} --- @@ -3152,12 +3152,12 @@ c3("t:get{1}") -- {1, 12} ... c3:rollback() --- -- +- [] ... -- c1("t:get{1}") -- nothing --- -- +- [] ... -- c7("t:get{1}") -- {1, 12} @@ -3167,12 +3167,12 @@ c7("t:get{1}") -- {1, 12} -- c6:rollback() --- -- +- [] ... -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 12} --- @@ -3180,12 +3180,12 @@ c3("t:get{1}") -- {1, 12} ... c3:rollback() --- -- +- [] ... -- c1("t:get{1}") -- nothing --- -- +- [] ... -- c7("t:get{1}") -- {1, 12} @@ -3195,16 +3195,16 @@ c7("t:get{1}") -- {1, 12} -- c1:rollback() --- -- +- [] ... c7:rollback() --- -- +- [] ... -- c3:begin() --- -- +- [] ... c3("t:get{1}") -- {1, 12} --- @@ -3212,14 +3212,14 @@ c3("t:get{1}") -- {1, 12} ... c3:rollback() --- -- +- [] ... -- -- cleanup -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -3228,19 +3228,19 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:get{100}") -- start transaction in the engine --- -- +- [] ... c2("t:get{200}") -- start transaction in the engine --- -- +- [] ... c1("t:replace{1, 10}") --- @@ -3253,7 +3253,7 @@ c2("t:replace{1, 15}") -- c1:commit() --- -- +- [] ... -- c2("t:replace{1, 20}") -- should not reset conflict flag @@ -3263,7 +3263,7 @@ c2("t:replace{1, 20}") -- should not reset conflict flag -- c2:commit() -- rollback --- -- +- [] ... -- c3("t:get{1}") @@ -3275,7 +3275,7 @@ c3("t:get{1}") -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -3284,7 +3284,7 @@ c1("t:delete{1}") -- c1:begin() --- -- +- [] ... -- c1("t:replace{1, 10}") @@ -3301,7 +3301,7 @@ c2("t:replace{1, 15}") -- c1:commit() --- -- +- [] ... -- c2("t:get{1}") -- {1, 10} @@ -3311,7 +3311,7 @@ c2("t:get{1}") -- {1, 10} -- c1("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- transaction_sc_get(void) @@ -3324,7 +3324,7 @@ c1("t:replace{1, 7}") -- c2:begin() --- -- +- [] ... -- c2("t:replace{1, 8}") @@ -3339,7 +3339,7 @@ c1("t:get{1}") -- {1, 7} -- c2:commit() --- -- +- [] ... -- c1("t:get{1}") -- {1, 8} @@ -3356,18 +3356,18 @@ c3("t:get{1}") -- {1, 8} -- c1("t:delete{1}") --- -- +- [] ... -- -------------------------------------------------------------------------- -- two conflicting inserts -- -------------------------------------------------------------------------- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... -- c1("t:insert{1, 10}") @@ -3382,7 +3382,7 @@ c2("t:insert{1, 15}") -- c1:commit() -- success --- -- +- [] ... c2:commit() -- rollback, c2 reads {1} before writing it --- @@ -3399,16 +3399,16 @@ c3("t:get{1}") -- {1, 10} -- c1("t:delete{1}") --- -- +- [] ... -- c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... -- c1("t:insert{1, 10}") @@ -3423,7 +3423,7 @@ c2("t:insert{1, 15}") -- c2:commit() -- success --- -- +- [] ... c1:commit() -- rollback, c1 reads {1} before writing it --- @@ -3440,7 +3440,7 @@ c3("t:get{1}") -- {1, 15} -- c1("t:delete{1}") --- -- +- [] ... -- -- -------------------------------------------------------------------------- @@ -3456,7 +3456,7 @@ t:insert{2, 20} ... c7:begin() --- -- +- [] ... c7("t:insert{8, 800}") --- @@ -3464,7 +3464,7 @@ c7("t:insert{8, 800}") ... c3:begin() --- -- +- [] ... c3("t:get{1}") --- @@ -3472,15 +3472,15 @@ c3("t:get{1}") ... c3:commit() --- -- +- [] ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... -- c1("t:replace{4, 40}") @@ -3495,7 +3495,7 @@ c2("t:get{1}") -- c3:begin() --- -- +- [] ... c3("t:insert{3, 30}") --- @@ -3503,7 +3503,7 @@ c3("t:insert{3, 30}") ... c3:commit() --- -- +- [] ... -- c2("t:replace{5, 50}") @@ -3516,15 +3516,15 @@ c1("t:get{1}") ... c1:commit() --- -- +- [] ... c2:commit() --- -- +- [] ... c7:rollback() --- -- +- [] ... -- -- cleanup @@ -3557,11 +3557,11 @@ t:insert{2, 20} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:select{}") --- @@ -3581,7 +3581,7 @@ c2("t:replace{2, 'new'}") ... c1:commit() --- -- +- [] ... c2:commit() -- rollback --- @@ -3593,7 +3593,7 @@ c2:commit() -- rollback -- c1:begin() --- -- +- [] ... c1("t:select{}") --- @@ -3645,7 +3645,7 @@ c1("t:select({3}, {iterator='eq'})") ... c1("t:delete{3}") --- -- +- [] ... c1("t:select({3}, {iterator='ge'})") --- @@ -3669,7 +3669,7 @@ c1("t:replace{3}") ... c1("t:delete{2}") --- -- +- [] ... c1("t:select({3}, {iterator='lt'})") --- @@ -3685,7 +3685,7 @@ c1("t:replace{2}") ... c1("t:delete{1}") --- -- +- [] ... c1("t:select({3}, {iterator='lt'})") --- @@ -3697,7 +3697,7 @@ c1("t:select({3}, {iterator='le'})") ... c1("t:delete{3}") --- -- +- [] ... c1("t:select({3}, {iterator='lt'})") --- @@ -3709,7 +3709,7 @@ c1("t:select({3}, {iterator='le'})") ... c1:rollback() --- -- +- [] ... c1("t:select{}") --- @@ -3722,7 +3722,7 @@ c1("t:select{}") -- c1:begin() --- -- +- [] ... c1("t:select{1}") --- @@ -3734,11 +3734,11 @@ c1("for k, v in box.space.test:pairs() do box.commit() end") ... c1:rollback() --- -- +- [] ... c1:begin() --- -- +- [] ... c1("t:select{1}") --- @@ -3750,7 +3750,7 @@ c1("for k, v in box.space.test:pairs() do box.rollback() end") ... c1:rollback() --- -- +- [] ... t:truncate() --- @@ -3764,7 +3764,7 @@ t:replace{1} ... c1:begin() --- -- +- [] ... c1("t.index.pk:max()") -- {1} --- @@ -3780,7 +3780,7 @@ c1("t.index.pk:count()") -- 1 ... c2:begin() --- -- +- [] ... c2("t:replace{2}") -- conflicts with c1 so c1 starts using a read view --- @@ -3788,7 +3788,7 @@ c2("t:replace{2}") -- conflicts with c1 so c1 starts using a read view ... c2:commit() --- -- +- [] ... c1("t.index.pk:max()") -- {1} --- @@ -3804,7 +3804,7 @@ c1("t.index.pk:count()") -- 1 ... c1:commit() --- -- +- [] ... -- -- Convert the reader to a read view: in this test we have @@ -3813,7 +3813,7 @@ c1:commit() -- c1:begin() --- -- +- [] ... c1("t.index.pk:max()") -- {2} --- @@ -3829,7 +3829,7 @@ c1("t.index.pk:count()") -- 2 ... c2:begin() --- -- +- [] ... c2("t:replace{1, 'new'}") -- conflits with c1 so c1 starts using a read view --- @@ -3841,7 +3841,7 @@ c2("t:replace{3}") ... c2:commit() --- -- +- [] ... c1("t.index.pk:max()") -- {2} --- @@ -3857,7 +3857,7 @@ c1("t.index.pk:count()") -- 2 ... c1:commit() --- -- +- [] ... t:truncate() --- @@ -3876,7 +3876,7 @@ t:replace{2} ... c1:begin() --- -- +- [] ... c1("t:select({}, {limit = 0})") -- none --- @@ -3884,7 +3884,7 @@ c1("t:select({}, {limit = 0})") -- none ... c2:begin() --- -- +- [] ... c2("t:replace{1, 'new'}") --- @@ -3892,7 +3892,7 @@ c2("t:replace{1, 'new'}") ... c2:commit() --- -- +- [] ... c1("t:select({}, {limit = 1})") -- {1, 'new'} --- @@ -3900,7 +3900,7 @@ c1("t:select({}, {limit = 1})") -- {1, 'new'} ... c2:begin() --- -- +- [] ... c2("t:replace{2, 'new'}") --- @@ -3908,7 +3908,7 @@ c2("t:replace{2, 'new'}") ... c2:commit() --- -- +- [] ... c1("t:select()") -- {1, 'new'}, {2, 'new'} --- @@ -3916,7 +3916,7 @@ c1("t:select()") -- {1, 'new'}, {2, 'new'} ... c1:commit() --- -- +- [] ... t:truncate() --- @@ -3929,11 +3929,11 @@ _ = t:create_index('sk', {parts = {2, 'unsigned'}, unique = true}) ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("t:insert{1, 2}") --- @@ -3945,7 +3945,7 @@ c2("t:insert{2, 2}") ... c1:commit() --- -- +- [] ... c2:commit() -- rollback --- @@ -4034,19 +4034,19 @@ c4 = txn_proxy.new() ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c4:begin() --- -- +- [] ... box.stat.vinyl().tx.read_views -- 0 (no read views needed) --- @@ -4094,7 +4094,7 @@ box.stat.vinyl().tx.transactions -- 4 ... c4:commit() --- -- +- [] ... box.stat.vinyl().tx.read_views -- 1 (one read view for all TXs) --- @@ -4106,7 +4106,7 @@ box.stat.vinyl().tx.transactions -- 3 ... c1:commit() --- -- +- [] ... box.stat.vinyl().tx.read_views -- 1 (one read view for all TXs) --- @@ -4118,7 +4118,7 @@ box.stat.vinyl().tx.transactions -- 2 ... c2:rollback() --- -- +- [] ... box.stat.vinyl().tx.read_views -- 1 (one read view for all TXs) --- @@ -4130,7 +4130,7 @@ box.stat.vinyl().tx.transactions -- 1 ... c3:commit() --- -- +- [] ... box.stat.vinyl().tx.read_views -- 0 (no read views needed) --- diff --git a/test/vinyl/tx_conflict.result b/test/vinyl/tx_conflict.result index 03cc62a49..25e5b154d 100644 --- a/test/vinyl/tx_conflict.result +++ b/test/vinyl/tx_conflict.result @@ -185,8 +185,8 @@ function apply(t, k, op) tx.ended = true table.insert(order_of_commit, t) num_committed = num_committed + 1 - local res = tx.con:commit() - if res ~= "" and res[1]['error'] then + local res = tx.con:commit()[1] + if res ~= nil and res['error'] then tx.conflicted = true else tx.select_all = s1:select{} diff --git a/test/vinyl/tx_conflict.test.lua b/test/vinyl/tx_conflict.test.lua index 9208c256e..923f060b6 100644 --- a/test/vinyl/tx_conflict.test.lua +++ b/test/vinyl/tx_conflict.test.lua @@ -152,8 +152,8 @@ function apply(t, k, op) tx.ended = true table.insert(order_of_commit, t) num_committed = num_committed + 1 - local res = tx.con:commit() - if res ~= "" and res[1]['error'] then + local res = tx.con:commit()[1] + if res ~= nil and res['error'] then tx.conflicted = true else tx.select_all = s1:select{} diff --git a/test/vinyl/tx_gap_lock.result b/test/vinyl/tx_gap_lock.result index a456c017e..8e9bd126d 100644 --- a/test/vinyl/tx_gap_lock.result +++ b/test/vinyl/tx_gap_lock.result @@ -42,7 +42,7 @@ _ = s:insert{3} ... c:begin() --- -- +- [] ... c("s:select()") -- {1}, {3} --- @@ -57,7 +57,7 @@ c("s:select()") -- {1}, {3} ... c:commit() --- -- +- [] ... s:truncate() --- @@ -71,7 +71,7 @@ _ = s:insert{2} ... c:begin() --- -- +- [] ... c("s:select()") -- {1}, {2} --- @@ -86,7 +86,7 @@ c("s:select()") -- {1}, {2} ... c:commit() --- -- +- [] ... s:truncate() --- @@ -100,7 +100,7 @@ _ = s:insert{3} ... c:begin() --- -- +- [] ... c("s:select()") -- {2}, {3} --- @@ -115,7 +115,7 @@ c("s:select()") -- {2}, {3} ... c:commit() --- -- +- [] ... s:truncate() --- @@ -126,11 +126,11 @@ _ = s:insert{123} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("s:select({}, {iterator = 'GT'})") -- {123} --- @@ -153,11 +153,11 @@ c2("s:select({}, {iterator = 'LT'})") -- {123} ... c1:commit() --- -- +- [] ... c2:commit() --- -- +- [] ... s:truncate() --- @@ -176,27 +176,27 @@ _ = s:insert{30} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c4:begin() --- -- +- [] ... c5:begin() --- -- +- [] ... c6:begin() --- -- +- [] ... c1("s:select({10}, {iterator = 'GE'})") -- {10}, {20}, {30} --- @@ -254,11 +254,11 @@ _ = s:replace{15, 2} -- send c2 and c3 to read view ... c2("s:get(15)") -- none --- -- +- [] ... c3("s:get(15)") -- none --- -- +- [] ... c4("s:get(15)") -- {15, 2} --- @@ -277,39 +277,39 @@ _ = s:replace{35, 3} -- send c4, c5, and c6 to read view ... c4("s:get(35)") -- none --- -- +- [] ... c5("s:get(35)") -- none --- -- +- [] ... c6("s:get(35)") -- none --- -- +- [] ... c1:commit() --- -- +- [] ... c2:commit() --- -- +- [] ... c3:commit() --- -- +- [] ... c4:commit() --- -- +- [] ... c5:commit() --- -- +- [] ... c6:commit() --- -- +- [] ... s:truncate() --- @@ -328,27 +328,27 @@ _ = s:insert{30} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c4:begin() --- -- +- [] ... c5:begin() --- -- +- [] ... c6:begin() --- -- +- [] ... c1("s:select({30}, {iterator = 'LE'})") -- {30}, {20}, {10} --- @@ -406,11 +406,11 @@ _ = s:replace{25, 2} -- send c2 and c3 to read view ... c2("s:get(25)") -- none --- -- +- [] ... c3("s:get(25)") -- none --- -- +- [] ... c4("s:get(25)") -- {25, 2} --- @@ -429,39 +429,39 @@ _ = s:replace{5, 3} -- send c4, c5, and c6 to read view ... c4("s:get(5)") -- none --- -- +- [] ... c5("s:get(5)") -- none --- -- +- [] ... c6("s:get(5)") -- none --- -- +- [] ... c1:commit() --- -- +- [] ... c2:commit() --- -- +- [] ... c3:commit() --- -- +- [] ... c4:commit() --- -- +- [] ... c5:commit() --- -- +- [] ... c6:commit() --- -- +- [] ... s:truncate() --- @@ -474,19 +474,19 @@ for i = 1, 9 do s:insert{i * 10} end ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c4:begin() --- -- +- [] ... c1("s:select({20}, {iterator = 'GE', limit = 3})") -- {20}, {30}, {40} --- @@ -562,7 +562,7 @@ _ = s:replace{25, 4} -- send c3 to read view ... c3("s:get(25)") -- none --- -- +- [] ... c4("s:get(25)") -- {25, 4} --- @@ -573,23 +573,23 @@ _ = s:replace{75, 5} -- send c4 to read view ... c4("s:get(75)") -- none --- -- +- [] ... c1:commit() --- -- +- [] ... c2:commit() --- -- +- [] ... c3:commit() --- -- +- [] ... c4:commit() --- -- +- [] ... s:drop() --- @@ -620,11 +620,11 @@ _ = s:insert{3, 3} ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c1("s:select({2}, {iterator = 'EQ'})") -- {2, 1}, {2, 2}, {2, 3} --- @@ -669,11 +669,11 @@ c2("s:select({2}, {iterator = 'REQ'})") -- {2, 3}, {2, 2}, {2, 1} ... c1:commit() --- -- +- [] ... c2:commit() --- -- +- [] ... s:drop() --- @@ -708,7 +708,7 @@ gap_lock_count() -- 0 ... c:begin() --- -- +- [] ... c("s:select({10}, {iterator = 'GE', limit = 4})") -- locks [10, 40] --- @@ -769,11 +769,11 @@ _ = s:insert{25} -- send c to read view ... c("s:get(25)") -- none --- -- +- [] ... c:commit() --- -- +- [] ... s:truncate() --- @@ -797,7 +797,7 @@ gap_lock_count() -- 0 ... c:begin() --- -- +- [] ... c("s:select({1}, {iterator = 'GT', limit = 1})") -- locks (1, 10] --- @@ -842,11 +842,11 @@ _ = s:insert{5} -- send c to read view ... c("s:get(5)") -- none --- -- +- [] ... c:commit() --- -- +- [] ... s:truncate() --- @@ -861,7 +861,7 @@ gap_lock_count() -- 0 ... c:begin() --- -- +- [] ... c("s:select({100}, {iterator = 'GT'})") -- locks (100, +inf) --- @@ -888,11 +888,11 @@ _ = s:insert{1000} -- send c to read view ... c("s:get(1000)") -- none --- -- +- [] ... c:commit() --- -- +- [] ... s:truncate() --- @@ -916,7 +916,7 @@ gap_lock_count() -- 0 ... c:begin() --- -- +- [] ... c("s:select({1}, {iterator = 'GE', limit = 2})") -- locks [1, 2] --- @@ -932,7 +932,7 @@ gap_lock_count() -- 1 ... c:commit() --- -- +- [] ... s:drop() --- @@ -950,19 +950,19 @@ gap_lock_count() -- 0 ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c4:begin() --- -- +- [] ... c1("s:select({100}, {iterator = 'GE'})") -- c1: locks [{100}, +inf) --- @@ -1005,11 +1005,11 @@ _ = s:insert{100, 50} -- send c1 and c2 to read view ... c1("s:get({100, 50})") -- none --- -- +- [] ... c2("s:get({100, 50})") -- none --- -- +- [] ... c3("s:get({100, 50})") -- {100, 50} --- @@ -1028,7 +1028,7 @@ _ = s:insert{100, 100} -- send c3 to read view ... c3("s:get({100, 100})") -- none --- -- +- [] ... c4("s:get({100, 100})") -- {100, 100} --- @@ -1043,7 +1043,7 @@ _ = s:insert{100, 101} -- send c4 to read view ... c4("s:get({100, 101})") -- none --- -- +- [] ... gap_lock_count() -- 6 --- @@ -1051,19 +1051,19 @@ gap_lock_count() -- 6 ... c1:commit() --- -- +- [] ... c2:commit() --- -- +- [] ... c3:commit() --- -- +- [] ... c4:commit() --- -- +- [] ... s:truncate() --- @@ -1075,19 +1075,19 @@ gap_lock_count() -- 0 ... c1:begin() --- -- +- [] ... c2:begin() --- -- +- [] ... c3:begin() --- -- +- [] ... c4:begin() --- -- +- [] ... c1("s:select({100}, {iterator = 'LE'})") -- c1: locks (-inf, {100}] --- @@ -1130,11 +1130,11 @@ _ = s:insert{100, 150} -- send c1 and c2 to read view ... c1("s:get({100, 150})") -- none --- -- +- [] ... c2("s:get({100, 150})") -- none --- -- +- [] ... c3("s:get({100, 150})") -- {100, 150} --- @@ -1153,7 +1153,7 @@ _ = s:insert{100, 100} -- send c3 to read view ... c3("s:get({100, 100})") -- none --- -- +- [] ... c4("s:get({100, 100})") -- {100, 100} --- @@ -1168,7 +1168,7 @@ _ = s:insert{100, 99} -- send c4 to read view ... c4("s:get({100, 99})") -- none --- -- +- [] ... gap_lock_count() -- 6 --- @@ -1176,19 +1176,19 @@ gap_lock_count() -- 6 ... c1:commit() --- -- +- [] ... c2:commit() --- -- +- [] ... c3:commit() --- -- +- [] ... c4:commit() --- -- +- [] ... s:drop() --- diff --git a/test/vinyl/tx_serial.result b/test/vinyl/tx_serial.result index 37c3f4467..4d464f7eb 100644 --- a/test/vinyl/tx_serial.result +++ b/test/vinyl/tx_serial.result @@ -151,8 +151,8 @@ function apply(t, k, op) tx.ended = true table.insert(order_of_commit, t) num_committed = num_committed + 1 - local res = tx.con:commit() - if res ~= "" and res[1]['error'] then + local res = tx.con:commit()[1] + if res ~= nil and res['error'] then tx.conflicted = true else tx.select_all = s1:select{} diff --git a/test/vinyl/tx_serial.test.lua b/test/vinyl/tx_serial.test.lua index 0a695a7e5..9d07dd013 100644 --- a/test/vinyl/tx_serial.test.lua +++ b/test/vinyl/tx_serial.test.lua @@ -122,8 +122,8 @@ function apply(t, k, op) tx.ended = true table.insert(order_of_commit, t) num_committed = num_committed + 1 - local res = tx.con:commit() - if res ~= "" and res[1]['error'] then + local res = tx.con:commit()[1] + if res ~= nil and res['error'] then tx.conflicted = true else tx.select_all = s1:select{} diff --git a/test/vinyl/txn_proxy.lua b/test/vinyl/txn_proxy.lua index 7a4d0b865..e043ca277 100644 --- a/test/vinyl/txn_proxy.lua +++ b/test/vinyl/txn_proxy.lua @@ -23,6 +23,12 @@ local mt = { __call = function(self, code_str) self.c1:put(code_str) local res = yaml.decode(self.c2:get()) + -- Get returns 0 arguments in case nothing found. + -- This value is encoded by console as "---" which is nil. + -- Tests using this file expect "{nil}" instead. + if res == nil then + res = {} + end return type(res) == 'table' and setmetatable(res, array_mt) or res end, __index = { diff --git a/third_party/lua-yaml/lyaml.cc b/third_party/lua-yaml/lyaml.cc index 9b07992d8..dd79e3c0c 100644 --- a/third_party/lua-yaml/lyaml.cc +++ b/third_party/lua-yaml/lyaml.cc @@ -27,6 +27,7 @@ */ #include "lyaml.h" +#include "str_type.h" #include "trivia/util.h" @@ -209,7 +210,7 @@ static void load_scalar(struct lua_yaml_loader *loader) { lua_pushnumber(loader->L, dval); return; } else if (!strcmp(tag, "bool")) { - lua_pushboolean(loader->L, !strcmp(str, "true") || !strcmp(str, "yes")); + lua_pushboolean(loader->L, yaml_get_bool(str, length) == YAML_TRUE); return; } else if (!strcmp(tag, "binary")) { frombase64(loader->L, (const unsigned char *)str, length); @@ -218,20 +219,15 @@ static void load_scalar(struct lua_yaml_loader *loader) { } if (loader->event.data.scalar.style == YAML_PLAIN_SCALAR_STYLE) { - if (!strcmp(str, "~")) { + yaml_type type; + if (yaml_get_null(str, length) == YAML_NULL){ luaL_pushnull(loader->L); return; - } else if (!strcmp(str, "true") || !strcmp(str, "yes")) { - lua_pushboolean(loader->L, 1); - return; - } else if (!strcmp(str, "false") || !strcmp(str, "no")) { - lua_pushboolean(loader->L, 0); - return; - } else if (!strcmp(str, "null")) { - luaL_pushnull(loader->L); - return; - } else if (!length) { - lua_pushliteral(loader->L, ""); + } else if ((type = yaml_get_bool(str, length)) != YAML_NO_MATCH){ + if (type == YAML_TRUE) + lua_pushboolean(loader->L, 1); + else + lua_pushboolean(loader->L, 0); return; } @@ -367,8 +363,13 @@ static void load(struct lua_yaml_loader *loader) { if (!do_parse(loader)) return; - if (loader->event.type == YAML_STREAM_END_EVENT) + if (loader->event.type == YAML_STREAM_END_EVENT) { + if (loader->document_count == 0) { + loader->document_count++; + luaL_pushnull(loader->L); + } return; + } loader->document_count++; if (load_node(loader) != 1) @@ -548,7 +549,6 @@ static int yaml_is_flow_mode(struct lua_yaml_dumper *dumper) { (evp->type == YAML_MAPPING_START_EVENT && evp->data.mapping_start.style == YAML_FLOW_MAPPING_STYLE)) { return 1; - break; } } } @@ -597,8 +597,11 @@ static int dump_node(struct lua_yaml_dumper *dumper) return dump_table(dumper, &field); case MP_STR: str = lua_tolstring(dumper->L, -1, &len); - if (lua_isnumber(dumper->L, -1)) { - /* string is convertible to number, quote it to preserve type */ + if ((yaml_get_null(str, len) == YAML_NULL) + || (yaml_get_bool(str, len) != YAML_NO_MATCH) + || (lua_isnumber(dumper->L, -1))) { + /* string is convertible to non-string scalar type, + * quote it to preserve type */ style = YAML_SINGLE_QUOTED_SCALAR_STYLE; break; } @@ -606,12 +609,10 @@ static int dump_node(struct lua_yaml_dumper *dumper) if (utf8_check_printable(str, len)) { if (yaml_is_flow_mode(dumper)) { style = YAML_SINGLE_QUOTED_SCALAR_STYLE; - } else if (strstr(str, "\n\n") != NULL || strcmp(str, "true") == 0 || - strcmp(str, "false") == 0) { + } else if (strstr(str, "\n\n") != 0) { /* * Tarantool-specific: use literal style for string - * with empty lines and strings representing boolean - * types. + * with empty lines. * Useful for tutorial(). */ style = YAML_LITERAL_SCALAR_STYLE; diff --git a/third_party/lua-yaml/str_type.h b/third_party/lua-yaml/str_type.h new file mode 100644 index 000000000..9bb4b7db8 --- /dev/null +++ b/third_party/lua-yaml/str_type.h @@ -0,0 +1,33 @@ +#include + +enum yaml_type{YAML_NO_MATCH = 0, YAML_FALSE, YAML_TRUE, YAML_NULL}; + +/* + * This implementation uses a subset of yaml 1.1 keywords + * which represents boolean. + */ +static yaml_type +yaml_get_bool(const char *str, const size_t len){ + if (len > 5) + return YAML_NO_MATCH; + if (strcmp(str, "false") == 0 || + strcmp(str, "no") == 0) + return YAML_FALSE; + if (strcmp(str, "true") == 0 || + strcmp(str, "yes") == 0) + return YAML_TRUE; + return YAML_NO_MATCH; +} + +static yaml_type +yaml_get_null(const char *str, const size_t len){ + if (len == 0 || (len == 1 && str[0] == '~')) + return YAML_NULL; + if (len == 4) { + if ((strcmp(str, "null") == 0) + || (strcmp(str, "Null") == 0) + || (strcmp(str, "NULL") == 0)) + return YAML_NULL; + } + return YAML_NO_MATCH; +} -- 2.14.1