box.rollback_to_savepoint() | Tarantool

box.rollback_to_savepoint()

box.rollback_to_savepoint(savepoint)

Do not end the transaction, but cancel all its data-change and box.savepoint() operations that were done after the specified savepoint.

Return:error if the savepoint cannot be set in absence of active transaction.

Possible errors: error if the savepoint does not exist.

Example

-- Insert test data --
box.space.bands:insert { 1, 'Roxette', 1986 }
box.space.bands:insert { 2, 'Scorpions', 1965 }
box.space.bands:insert { 3, 'Ace of Base', 1987 }

-- Rollback the transaction to a savepoint --
box.begin()
box.space.bands:insert { 4, 'The Beatles', 1960 }
save1 = box.savepoint()
box.space.bands:replace { 1, 'Pink Floyd', 1965 }
box.rollback_to_savepoint(save1)
box.commit()
Found what you were looking for?
Feedback