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 CF7D129AE8 for ; Tue, 11 Sep 2018 07:51:23 -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 Nz7GAPfMCQlU for ; Tue, 11 Sep 2018 07:51:23 -0400 (EDT) Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (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 7C38B29A03 for ; Tue, 11 Sep 2018 07:51:21 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open References: <1536282019-17978-1-git-send-email-roman.habibov1@yandex.ru> <41907181536625411@iva8-8d7a47df0521.qloud-c.yandex.net> <41826271536625517@iva7-bd007c44f58e.qloud-c.yandex.net> From: Kirill Shcherbatov Message-ID: Date: Tue, 11 Sep 2018 14:51:19 +0300 MIME-Version: 1.0 In-Reply-To: <41826271536625517@iva7-bd007c44f58e.qloud-c.yandex.net> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit 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: tarantool-patches@freelists.org, Alexander Turenko , Roman Khabibov Now LGTM. Sasha, please, take a look. On 11.09.2018 03:25, roman.habibov1@yandex.ru wrote: > Forgot. Thanks for review! > > 11.09.2018, 03:23, "roman.habibov1@yandex.ru" : >> 10.09.2018, 09:21, "Kirill Shcherbatov" : >>>  Hi! Thank you for a patch. >>>>   +bool >>>>   +box_is_in_txn() >>>>   +{ >>>>   + return box_txn(); >>>>   +} >>> >>>  1. Your function box_is_in_txn is a copy of box_txn routine. There is not reason to introduce it. >>>  Moreover, box_txn is already exported as public API. >> >> Indeed. Removed. >> >>>>   +- - true >>>>   +... >>>>   +-- close transaction >>>>   +box.commit(); >>> >>>  2. Check box.is_in_txn(); here please. >> >> Redone. >> >>>>   +-- gh-3518 no active transaction - false >>> >>>  3. Use tarantool codestyle for comments; at first, you need ticket description >>>  -- >>>  -- gh-3518: Check if transaction opened. >>>  -- >>>>   +box.is_in_txn(); >>>>   +-- start transaction >> >> Done. >> >>>  4. With a capital letter and with a dot at the end, please. Same for other comments. >> >> Sorry. >> >> commit 14fa90d195dc84df21a41c3172d2f0a2e0ca68e2 >> Author: Roman Khabibov >> Date: Fri Sep 7 02:54:28 2018 +0300 >> >>     box: add a method to check if txn is open >> >>     Closes: #3518. >> >> diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua >> index 74b7064..85e87ef 100644 >> --- a/src/box/lua/schema.lua >> +++ b/src/box/lua/schema.lua >> @@ -64,6 +64,8 @@ ffi.cdef[[ >>                      const char *key, const char *key_end); >>      /** \endcond public */ >>      /** \cond public */ >> + bool >> + box_txn(); >>      int64_t >>      box_txn_id(); >>      int >> @@ -321,6 +323,10 @@ box.begin = function() >>      end >>  end >> >> +box.is_in_txn = function() >> + return { builtin.box_txn() } >> +end >> + >>  box.savepoint = function() >>      local csavepoint = builtin.box_txn_savepoint() >>      if csavepoint == nil then >> diff --git a/test/box/misc.result b/test/box/misc.result >> index d9f8d4e..325af3b 100644 >> --- a/test/box/misc.result >> +++ b/test/box/misc.result >> @@ -67,6 +67,7 @@ t >>    - index >>    - info >>    - internal >> + - is_in_txn >>    - on_commit >>    - on_rollback >>    - once >> diff --git a/test/box/transaction.result b/test/box/transaction.result >> index e024084..25bdae5 100644 >> --- a/test/box/transaction.result >> +++ b/test/box/transaction.result >> @@ -43,6 +43,30 @@ box.begin() box.rollback(); >>  box.commit(); >>  --- >>  ... >> +-- >> +-- gh-3518: Add is_in_txn(). >> +-- >> +-- no active transaction - false >> +box.is_in_txn(); >> +--- >> +- - false >> +... >> +-- active transaction - true >> +box.begin(); >> +--- >> +... >> +box.is_in_txn(); >> +--- >> +- - true >> +... >> +-- no active transaction - false >> +box.commit(); >> +--- >> +... >> +box.is_in_txn(); >> +--- >> +- - false >> +... >>  fiber = require('fiber'); >>  --- >>  ... >> diff --git a/test/box/transaction.test.lua b/test/box/transaction.test.lua >> index e1d258e..8f7dfed 100644 >> --- a/test/box/transaction.test.lua >> +++ b/test/box/transaction.test.lua >> @@ -19,6 +19,19 @@ box.begin() box.rollback() box.rollback(); >>  box.begin() box.rollback(); >>  -- no current transaction - implicit begin >>  box.commit(); >> + >> +-- >> +-- gh-3518: Add is_in_txn(). >> +-- >> +-- no active transaction - false >> +box.is_in_txn(); >> +-- active transaction - true >> +box.begin(); >> +box.is_in_txn(); >> +-- no active transaction - false >> +box.commit(); >> +box.is_in_txn(); >> + >>  fiber = require('fiber'); >>  function sloppy() >>      box.begin() >> diff --git a/test/engine/savepoint.result b/test/engine/savepoint.result >> index a62a2e1..00d281b 100644 >> --- a/test/engine/savepoint.result >> +++ b/test/engine/savepoint.result >> @@ -14,7 +14,7 @@ s1 = box.savepoint() >>  ... >>  box.rollback_to_savepoint(s1) >>  --- >> -- error: 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)' >> +- error: 'builtin/box/schema.lua:346: Usage: box.rollback_to_savepoint(savepoint)' >>  ... >>  box.begin() s1 = box.savepoint() >>  --- >> @@ -323,27 +323,27 @@ test_run:cmd("setopt delimiter ''"); >>  ok1, errmsg1 >>  --- >>  - false >> -- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)' >> +- 'builtin/box/schema.lua:346: Usage: box.rollback_to_savepoint(savepoint)' >>  ... >>  ok2, errmsg2 >>  --- >>  - false >> -- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)' >> +- 'builtin/box/schema.lua:346: Usage: box.rollback_to_savepoint(savepoint)' >>  ... >>  ok3, errmsg3 >>  --- >>  - false >> -- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)' >> +- 'builtin/box/schema.lua:346: Usage: box.rollback_to_savepoint(savepoint)' >>  ... >>  ok4, errmsg4 >>  --- >>  - false >> -- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)' >> +- 'builtin/box/schema.lua:346: Usage: box.rollback_to_savepoint(savepoint)' >>  ... >>  ok5, errmsg5 >>  --- >>  - false >> -- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)' >> +- 'builtin/box/schema.lua:346: Usage: box.rollback_to_savepoint(savepoint)' >>  ... >>  s:select{} >>  --- > >