As you can see, your sequence S
has id=1
There is system space box.space._sequence_data
which has current values of all sequences. All you need to do is just select your sequence id from the space: box.space._sequence_data:select(1)
.
For example, my_seq
is 4th sequence in my database.
tarantool> my_seq = box.schema.sequence.create('MySeq', {start=111})
---
...
tarantool> box.space._sequence_data:select(my_seq.id)
---
- []
...
tarantool> my_seq:next()
---
- 111
...
tarantool> box.space._sequence_data:select(my_seq.id)
---
- - [4, 111]
As you can see, right after creation _sequence_data
doesn't have any details about new sequence until first use of my_seq:next()
which
initialises the sequence.
As you can see box.space._sequence_data:select(my_seq.id)
returns tuple with number of the sequence and current value.
Please be aware of absence of guarantees for this method. And there are some issues with replication.
In 2.4.1 sequence:currval()
is introduced: https://github.com/tarantool/tarantool/issues/4752