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 D819728BCF for ; Sun, 23 Sep 2018 06:11:58 -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 Pw5YzuLIlSOE for ; Sun, 23 Sep 2018 06:11:58 -0400 (EDT) Received: from smtp5.mail.ru (smtp5.mail.ru [94.100.179.24]) (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 14C912865C for ; Sun, 23 Sep 2018 06:11:58 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 1/1] 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> <20180919133830.bvtnqh3ftbdukobh@tkn_work_nb> <5119501537491277@myt3-12f13c3c6b95.qloud-c.yandex.net> <20180921024144.5x5vu3qrdcdoa24v@tkn_work_nb> <3212631537568955@sas1-ea1d14049a51.qloud-c.yandex.net> <20180922010058.ri4ydahzgudsuyyi@tkn_work_nb> From: Vladislav Shpilevoy Message-ID: Date: Sun, 23 Sep 2018 12:11:58 +0200 MIME-Version: 1.0 In-Reply-To: <20180922010058.ri4ydahzgudsuyyi@tkn_work_nb> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Roman Khabibov Cc: tarantool-patches@freelists.org, Kirill Yukhin For me LGTM as well. Kirill, please, push it. On 22/09/2018 03:00, Alexander Turenko wrote: > Hi! > > LGTM for the whole patchset. > > Vlad, can you look at the patchset, please? > > branch: romankhabibov/gh-3518-check-if-txn > issue: https://github.com/tarantool/tarantool/issues/3518 > > WBR, Alexander Turenko. > > On Sat, Sep 22, 2018 at 01:29:15AM +0300, roman.habibov1@yandex.ru wrote: >> >> Hi! Thanks for review. >> >>> Can be reduced to just `box.is_in_txn = builtin.box_txn`. >> Done. >> >> commit 34325f03ab2abc3e3cf237b2310819734447e076 >> 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..8a804f0 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,8 @@ box.begin = function() >> end >> end >> >> +box.is_in_txn = builtin.box_txn >> + >> 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..8a4d11d 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()