Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] box: add a method to check if transaction is open
@ 2018-09-07  1:00 Roman Khabibov
  2018-09-10  6:21 ` [tarantool-patches] " Kirill Shcherbatov
  2018-09-24  8:38 ` [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open Kirill Yukhin
  0 siblings, 2 replies; 15+ messages in thread
From: Roman Khabibov @ 2018-09-07  1:00 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy

Add method box.is_in_txn()

Closes: #3518.
---
Branch: https://github.com/tarantool/tarantool/tree/romankhabibov/gh-3518-check-if-txn
Issue: https://github.com/tarantool/tarantool/issues/3518

 extra/exports                 |  1 +
 src/box/lua/schema.lua        |  6 ++++++
 src/box/txn.c                 |  6 ++++++
 src/box/txn.h                 |  8 ++++++++
 test/box/misc.result          |  1 +
 test/box/transaction.result   | 18 ++++++++++++++++++
 test/box/transaction.test.lua |  8 ++++++++
 test/engine/savepoint.result  | 12 ++++++------
 8 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/extra/exports b/extra/exports
index 319d2c4..2f408d9 100644
--- a/extra/exports
+++ b/extra/exports
@@ -136,6 +136,7 @@ luaT_state
 luaT_tolstring
 box_txn
 box_txn_begin
+box_is_in_txn
 box_txn_commit
 box_txn_savepoint
 box_txn_rollback
diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua
index 74b7064..e1526ac 100644
--- a/src/box/lua/schema.lua
+++ b/src/box/lua/schema.lua
@@ -68,6 +68,8 @@ ffi.cdef[[
     box_txn_id();
     int
     box_txn_begin();
+    bool
+    box_is_in_txn();
     /** \endcond public */
     typedef struct txn_savepoint box_txn_savepoint_t;
 
@@ -321,6 +323,10 @@ box.begin = function()
     end
 end
 
+box.is_in_txn = function()
+    return { builtin.box_is_in_txn() }
+end
+
 box.savepoint = function()
     local csavepoint = builtin.box_txn_savepoint()
     if csavepoint == nil then
diff --git a/src/box/txn.c b/src/box/txn.c
index 617ceb8..51b50bf 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -447,6 +447,12 @@ box_txn_begin()
 	return 0;
 }
 
+bool
+box_is_in_txn()
+{
+	return box_txn();
+}
+
 int
 box_txn_commit()
 {
diff --git a/src/box/txn.h b/src/box/txn.h
index e74c14d..e587129 100644
--- a/src/box/txn.h
+++ b/src/box/txn.h
@@ -382,6 +382,14 @@ API_EXPORT int
 box_txn_commit(void);
 
 /**
+ * Check if transaction opened in the current fiber.
+ * @retval true Transaction is opened.
+ * @retval false Transaction is closed.
+ */
+API_EXPORT bool
+box_is_in_txn(void);
+
+/**
  * Rollback the current transaction.
  * May fail if called from a nested
  * statement.
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..fb7ebbd 100644
--- a/test/box/transaction.result
+++ b/test/box/transaction.result
@@ -12,6 +12,24 @@ test_run:cmd("setopt delimiter ';'")
 box.begin() box.commit();
 ---
 ...
+-- gh-3518 no active transaction - false
+box.is_in_txn();
+---
+- - false
+...
+-- start transaction
+box.begin();
+---
+...
+-- active transaction - true
+box.is_in_txn();
+---
+- - true
+...
+-- close transaction
+box.commit();
+---
+...
 -- double begin
 box.begin() box.begin();
 ---
diff --git a/test/box/transaction.test.lua b/test/box/transaction.test.lua
index e1d258e..79a2c0b 100644
--- a/test/box/transaction.test.lua
+++ b/test/box/transaction.test.lua
@@ -3,6 +3,14 @@ test_run = env.new()
 test_run:cmd("setopt delimiter ';'")
 -- empty transaction - ok
 box.begin() box.commit();
+-- gh-3518 no active transaction - false
+box.is_in_txn();
+-- start transaction
+box.begin();
+-- active transaction - true
+box.is_in_txn();
+-- close transaction
+box.commit();
 -- double begin
 box.begin() box.begin();
 -- no active transaction since exception rolled it back
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{}
 ---
-- 
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open
  2018-09-07  1:00 [tarantool-patches] [PATCH] box: add a method to check if transaction is open Roman Khabibov
@ 2018-09-10  6:21 ` Kirill Shcherbatov
  2018-09-11  0:23   ` roman.habibov1
  2018-09-24  8:38 ` [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open Kirill Yukhin
  1 sibling, 1 reply; 15+ messages in thread
From: Kirill Shcherbatov @ 2018-09-10  6:21 UTC (permalink / raw)
  To: tarantool-patches, Roman Khabibov

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.

> +- - true
> +...
> +-- close transaction
> +box.commit();
2. Check box.is_in_txn(); here please.

> +-- 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
4. With a capital letter and with a dot at the end, please. Same for other comments.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open
  2018-09-10  6:21 ` [tarantool-patches] " Kirill Shcherbatov
@ 2018-09-11  0:23   ` roman.habibov1
  2018-09-11  0:25     ` roman.habibov1
  0 siblings, 1 reply; 15+ messages in thread
From: roman.habibov1 @ 2018-09-11  0:23 UTC (permalink / raw)
  To: Kirill Shcherbatov, tarantool-patches



10.09.2018, 09:21, "Kirill Shcherbatov" <kshcherbatov@tarantool.org>:
> 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 <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..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{}
 ---

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open
  2018-09-11  0:23   ` roman.habibov1
@ 2018-09-11  0:25     ` roman.habibov1
  2018-09-11 11:51       ` Kirill Shcherbatov
  0 siblings, 1 reply; 15+ messages in thread
From: roman.habibov1 @ 2018-09-11  0:25 UTC (permalink / raw)
  To: tarantool-patches, Kirill Shcherbatov

Forgot. Thanks for review!

11.09.2018, 03:23, "roman.habibov1@yandex.ru" <roman.habibov1@yandex.ru>:
> 10.09.2018, 09:21, "Kirill Shcherbatov" <kshcherbatov@tarantool.org>:
>>  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 <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..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{}
>  ---

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open
  2018-09-11  0:25     ` roman.habibov1
@ 2018-09-11 11:51       ` Kirill Shcherbatov
  2018-09-19 13:38         ` Alexander Turenko
  0 siblings, 1 reply; 15+ messages in thread
From: Kirill Shcherbatov @ 2018-09-11 11:51 UTC (permalink / raw)
  To: tarantool-patches, 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" <roman.habibov1@yandex.ru>:
>> 10.09.2018, 09:21, "Kirill Shcherbatov" <kshcherbatov@tarantool.org>:
>>>  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 <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..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{}
>>  ---
> 
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open
  2018-09-11 11:51       ` Kirill Shcherbatov
@ 2018-09-19 13:38         ` Alexander Turenko
  2018-09-21  0:54           ` [tarantool-patches] Re: [PATCH 1/1] " roman.habibov1
  2018-09-21  0:54           ` [tarantool-patches] Re: [PATCH 2/2] test: add output filtering feature roman.habibov1
  0 siblings, 2 replies; 15+ messages in thread
From: Alexander Turenko @ 2018-09-19 13:38 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches, Kirill Shcherbatov

Hi, Roman!

Sorry for the late response.

Please, consider comments below.

WBR, Alexander Turenko.

On Tue, Sep 11, 2018 at 02:51:19PM +0300, Kirill Shcherbatov wrote:
> Now LGTM. Sasha, please, take a look.
> 
> >> commit 14fa90d195dc84df21a41c3172d2f0a2e0ca68e2
> >> 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.
> >>

> >> +box.is_in_txn = function()
> >> + return { builtin.box_txn() }
> >> +end
> >> +

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

> >> 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{}
> >>  ---
> > 

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'.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 1/1] box: add a method to check if transaction is open
  2018-09-19 13:38         ` Alexander Turenko
@ 2018-09-21  0:54           ` roman.habibov1
  2018-09-21  2:41             ` Alexander Turenko
  2018-09-21  0:54           ` [tarantool-patches] Re: [PATCH 2/2] test: add output filtering feature roman.habibov1
  1 sibling, 1 reply; 15+ messages in thread
From: roman.habibov1 @ 2018-09-21  0:54 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches, Kirill Shcherbatov



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()

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 2/2] test: add output filtering feature
  2018-09-19 13:38         ` Alexander Turenko
  2018-09-21  0:54           ` [tarantool-patches] Re: [PATCH 1/1] " roman.habibov1
@ 2018-09-21  0:54           ` roman.habibov1
  2018-09-21  2:53             ` Alexander Turenko
  1 sibling, 1 reply; 15+ messages in thread
From: roman.habibov1 @ 2018-09-21  0:54 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches, Kirill Shcherbatov


Add output filtering feature for engine/savepoint.test.

Part of #3518.
---
commit b8be4c51e29110f459bd58dba51d6546cd9da25b
Author: Roman Khabibov <roman.habibov1@yandex.ru>
Date:   Fri Sep 21 03:28:04 2018 +0300

    test: add output filtering feature

diff --git a/test/engine/savepoint.result b/test/engine/savepoint.result
index a62a2e1..9e527f6 100644
--- a/test/engine/savepoint.result
+++ b/test/engine/savepoint.result
@@ -4,6 +4,10 @@ env = require('test_run')
 test_run = env.new()
 ---
 ...
+test_run:cmd("push filter '(.builtin/.*).lua:346' to '\\1.lua:340'")
+---
+- true
+...
 -- gh-2025 box.savepoint
 s1 = nil
 ---
diff --git a/test/engine/savepoint.test.lua b/test/engine/savepoint.test.lua
index de8f297..9d4be7f 100644
--- a/test/engine/savepoint.test.lua
+++ b/test/engine/savepoint.test.lua
@@ -1,5 +1,6 @@
 env = require('test_run')
 test_run = env.new()
+test_run:cmd("push filter '(.builtin/.*).lua:346' to '\\1.lua:340'")
 
 -- gh-2025 box.savepoint
 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 1/1] box: add a method to check if transaction is open
  2018-09-21  0:54           ` [tarantool-patches] Re: [PATCH 1/1] " roman.habibov1
@ 2018-09-21  2:41             ` Alexander Turenko
  2018-09-21 22:29               ` roman.habibov1
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Turenko @ 2018-09-21  2:41 UTC (permalink / raw)
  To: roman.habibov1; +Cc: tarantool-patches, Kirill Shcherbatov

This commit looks good to me, except one comment.

WBR, Alexander Turenko.

> +box.is_in_txn = function()
> +    return builtin.box_txn()
> +end
> +

Can be reduced to just `box.is_in_txn = builtin.box_txn`.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 2/2] test: add output filtering feature
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Turenko @ 2018-09-21  2:53 UTC (permalink / raw)
  To: roman.habibov1; +Cc: tarantool-patches, Kirill Shcherbatov

Hi!

Minor comments are below.

WBR, Alexander Turenko.

On Fri, Sep 21, 2018 at 03:54:42AM +0300, roman.habibov1@yandex.ru wrote:
> 
> Add output filtering feature for engine/savepoint.test.
> 
> Part of #3518.
> ---
> commit b8be4c51e29110f459bd58dba51d6546cd9da25b
> Author: Roman Khabibov <roman.habibov1@yandex.ru>
> Date:   Fri Sep 21 03:28:04 2018 +0300
> 
>     test: add output filtering feature
> 

Please, describe the change in less abstract manner, like 'test: filter
line numbers from engine/savepoint'. Now the description looks like you
are implement this feature from scratch.

> diff --git a/test/engine/savepoint.test.lua b/test/engine/savepoint.test.lua
> index de8f297..9d4be7f 100644
> --- a/test/engine/savepoint.test.lua
> +++ b/test/engine/savepoint.test.lua
> @@ -1,5 +1,6 @@
>  env = require('test_run')
>  test_run = env.new()
> +test_run:cmd("push filter '(.builtin/.*).lua:346' to '\\1.lua:340'")
>  

Tricky thing :)

It is better to remove line numbers entirely as socket.test.lua does and
update the result file, because the current approach does not protect us
from the next line numbers change.

Also I propose to place this commit before 'box: add a method to check
if txn is open' to achieve two points:

* each commit passes the tests (can be useful when someone will bisect
  some problem in the future and is generally recommended way);
* don't need to update the test result twice (update line numbers, then
  remove line numbers).

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 2/2] test: add output filtering feature
  2018-09-21  2:53             ` Alexander Turenko
@ 2018-09-21 22:25               ` roman.habibov1
  0 siblings, 0 replies; 15+ messages in thread
From: roman.habibov1 @ 2018-09-21 22:25 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches, Kirill Shcherbatov


Hi! Thanks for review/

>
> On Fri, Sep 21, 2018 at 03:54:42AM +0300, roman.habibov1@yandex.ru wrote:
>>  Add output filtering feature for engine/savepoint.test.
>>
>>  Part of #3518.
>>  ---
>>  commit b8be4c51e29110f459bd58dba51d6546cd9da25b
>>  Author: Roman Khabibov <roman.habibov1@yandex.ru>
>>  Date: Fri Sep 21 03:28:04 2018 +0300
>>
>>      test: add output filtering feature
>
> Please, describe the change in less abstract manner, like 'test: filter
> line numbers from engine/savepoint'. Now the description looks like you
> are implement this feature from scratch.
Done.

commit a3110d84a171ab886612fe89d2094e2e3bd30f7f
Author: Roman Khabibov <roman.habibov1@yandex.ru>
Date:   Fri Sep 21 03:28:04 2018 +0300

    test: filter line numbers from engine/savepoint
    
    Part of #3518

diff --git a/test/engine/savepoint.result b/test/engine/savepoint.result
index a62a2e1..b3a918d 100644
--- a/test/engine/savepoint.result
+++ b/test/engine/savepoint.result
@@ -4,6 +4,10 @@ env = require('test_run')
 test_run = env.new()
 ---
 ...
+test_run:cmd("push filter '(.builtin/.*.lua):[0-9]+' to '\\1'")
+---
+- true
+...
 -- gh-2025 box.savepoint
 s1 = nil
 ---
@@ -14,7 +18,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: Usage: box.rollback_to_savepoint(savepoint)'
 ...
 box.begin() s1 = box.savepoint()
 ---
@@ -323,27 +327,27 @@ test_run:cmd("setopt delimiter ''");
 ok1, errmsg1
 ---
 - false
-- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)'
+- 'builtin/box/schema.lua: Usage: box.rollback_to_savepoint(savepoint)'
 ...
 ok2, errmsg2
 ---
 - false
-- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)'
+- 'builtin/box/schema.lua: Usage: box.rollback_to_savepoint(savepoint)'
 ...
 ok3, errmsg3
 ---
 - false
-- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)'
+- 'builtin/box/schema.lua: Usage: box.rollback_to_savepoint(savepoint)'
 ...
 ok4, errmsg4
 ---
 - false
-- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)'
+- 'builtin/box/schema.lua: Usage: box.rollback_to_savepoint(savepoint)'
 ...
 ok5, errmsg5
 ---
 - false
-- 'builtin/box/schema.lua:340: Usage: box.rollback_to_savepoint(savepoint)'
+- 'builtin/box/schema.lua: Usage: box.rollback_to_savepoint(savepoint)'
 ...
 s:select{}
 ---
diff --git a/test/engine/savepoint.test.lua b/test/engine/savepoint.test.lua
index de8f297..186ef85 100644
--- a/test/engine/savepoint.test.lua
+++ b/test/engine/savepoint.test.lua
@@ -1,5 +1,6 @@
 env = require('test_run')
 test_run = env.new()
+test_run:cmd("push filter '(.builtin/.*.lua):[0-9]+' to '\\1'")
 
 -- gh-2025 box.savepoint
 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 1/1] box: add a method to check if transaction is open
  2018-09-21  2:41             ` Alexander Turenko
@ 2018-09-21 22:29               ` roman.habibov1
  2018-09-22  1:00                 ` Alexander Turenko
  0 siblings, 1 reply; 15+ messages in thread
From: roman.habibov1 @ 2018-09-21 22:29 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches, Kirill Shcherbatov


Hi! Thanks for review.

> Can be reduced to just `box.is_in_txn = builtin.box_txn`.
Done.

commit 34325f03ab2abc3e3cf237b2310819734447e076
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..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()

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 1/1] box: add a method to check if transaction is open
  2018-09-21 22:29               ` roman.habibov1
@ 2018-09-22  1:00                 ` Alexander Turenko
  2018-09-23 10:11                   ` Vladislav Shpilevoy
  0 siblings, 1 reply; 15+ messages in thread
From: Alexander Turenko @ 2018-09-22  1:00 UTC (permalink / raw)
  To: Roman Khabibov, Vladislav Shpilevoy; +Cc: tarantool-patches, Kirill Shcherbatov

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 <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..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()

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH 1/1] box: add a method to check if transaction is open
  2018-09-22  1:00                 ` Alexander Turenko
@ 2018-09-23 10:11                   ` Vladislav Shpilevoy
  0 siblings, 0 replies; 15+ messages in thread
From: Vladislav Shpilevoy @ 2018-09-23 10:11 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches, 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 <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..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()

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tarantool-patches] Re: [PATCH] box: add a method to check if transaction is open
  2018-09-07  1:00 [tarantool-patches] [PATCH] box: add a method to check if transaction is open Roman Khabibov
  2018-09-10  6:21 ` [tarantool-patches] " Kirill Shcherbatov
@ 2018-09-24  8:38 ` Kirill Yukhin
  1 sibling, 0 replies; 15+ messages in thread
From: Kirill Yukhin @ 2018-09-24  8:38 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy

Hello,
On 07 сен 04:00, Roman Khabibov wrote:
> Add method box.is_in_txn()
> 
> Closes: #3518.
> ---
> Branch: https://github.com/tarantool/tarantool/tree/romankhabibov/gh-3518-check-if-txn
> Issue: https://github.com/tarantool/tarantool/issues/3518
I've checked in updated patch into 2.0 branch.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-09-24  8:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07  1:00 [tarantool-patches] [PATCH] box: add a method to check if transaction is open 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           ` [tarantool-patches] Re: [PATCH 1/1] " roman.habibov1
2018-09-21  2:41             ` 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

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