diff --git a/src/box/alter.cc b/src/box/alter.cc index 95027043e87085469bdb22edd32eeb4abf499341..32d3cea5f01c02552f20698e95bba590172e63ff 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -1397,6 +1397,7 @@ on_replace_dd_truncate(struct trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); + txn_check_autocommit(txn, "Space _truncate"); struct tuple *old_tuple = stmt->old_tuple; struct tuple *new_tuple = stmt->new_tuple; diff --git a/test/engine/truncate.result b/test/engine/truncate.result index 91153e2f17ea12f01d9f96868a5130a18b719a61..01be5ffecb5db950b087f1f7a084e1f75a717ab0 100644 --- a/test/engine/truncate.result +++ b/test/engine/truncate.result @@ -8,6 +8,35 @@ fiber = require('fiber') --- ... -- +-- Check that space truncation is forbidden in a transaction. +-- +s = box.schema.create_space('test', {engine = engine}) +--- +... +_ = s:create_index('pk') +--- +... +_ = s:insert{123} +--- +... +box.begin() +--- +... +s:truncate() +--- +- error: Space _truncate does not support multi-statement transactions +... +box.commit() +--- +... +s:select() +--- +- - [123] +... +s:drop() +--- +... +-- -- Truncate space with no indexes. -- s = box.schema.create_space('test', {engine = engine}) diff --git a/test/engine/truncate.test.lua b/test/engine/truncate.test.lua index 41f5694d19fbd5391674147736a5760398c65f61..0f6addd58a0091cbe25d6cee8a79a939a30f83e3 100644 --- a/test/engine/truncate.test.lua +++ b/test/engine/truncate.test.lua @@ -3,6 +3,18 @@ engine = test_run:get_cfg('engine') fiber = require('fiber') +-- +-- Check that space truncation is forbidden in a transaction. +-- +s = box.schema.create_space('test', {engine = engine}) +_ = s:create_index('pk') +_ = s:insert{123} +box.begin() +s:truncate() +box.commit() +s:select() +s:drop() + -- -- Truncate space with no indexes. --