Tarantool development patches archive
 help / color / mirror / Atom feed
From: roman.habibov1@yandex.ru
To: Alexander Turenko <alexander.turenko@tarantool.org>
Cc: "tarantool-patches@freelists.org"
	<tarantool-patches@freelists.org>,
	Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 1/1] box: add a method to check if transaction is open
Date: Fri, 21 Sep 2018 03:54:37 +0300	[thread overview]
Message-ID: <5119501537491277@myt3-12f13c3c6b95.qloud-c.yandex.net> (raw)
In-Reply-To: <20180919133830.bvtnqh3ftbdukobh@tkn_work_nb>



Hi! Thanks for review.

> Why do you return a table with boolean, but not boolean?
Fixed.

> It is better to use output filtering feature of test-run to avoid such
> redundant diffs.
>
> Consider test/app/socket.test.lua:
>
> ```
>  12 env = require('test_run')
>  13 test_run = env.new()
>  14 test_run:cmd("push filter '(error: .builtin/.*[.]lua):[0-9]+' to '\\1'")
> ```
>
> It is not a blocker for that patch, but if you intend to include it, do
> it in the separate commit before 'add a method to check if txn is open'.
I added a separate commit.

commit e613be2ef5f12e43ae4a346c4b30e87940ade661
Author: Roman Khabibov <roman.habibov1@yandex.ru>
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..e2a5635 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..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()

  reply	other threads:[~2018-09-21  0:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07  1:00 [tarantool-patches] [PATCH] " Roman Khabibov
2018-09-10  6:21 ` [tarantool-patches] " Kirill Shcherbatov
2018-09-11  0:23   ` roman.habibov1
2018-09-11  0:25     ` roman.habibov1
2018-09-11 11:51       ` Kirill Shcherbatov
2018-09-19 13:38         ` Alexander Turenko
2018-09-21  0:54           ` roman.habibov1 [this message]
2018-09-21  2:41             ` [tarantool-patches] Re: [PATCH 1/1] " Alexander Turenko
2018-09-21 22:29               ` roman.habibov1
2018-09-22  1:00                 ` Alexander Turenko
2018-09-23 10:11                   ` Vladislav Shpilevoy
2018-09-21  0:54           ` [tarantool-patches] Re: [PATCH 2/2] test: add output filtering feature roman.habibov1
2018-09-21  2:53             ` Alexander Turenko
2018-09-21 22:25               ` roman.habibov1
2018-09-24  8:38 ` [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5119501537491277@myt3-12f13c3c6b95.qloud-c.yandex.net \
    --to=roman.habibov1@yandex.ru \
    --cc=alexander.turenko@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 1/1] box: add a method to check if transaction is open' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox