diff --git a/src/box/alter.cc b/src/box/alter.cc index f19e311d4c450c31e43845953da6d069074758b3..aec77035a1e5d7d81ecda2b3d535f7646ddc24fb 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -596,11 +596,7 @@ DropIndex::commit(struct alter_space *alter) Index *pk = index_find(alter->old_space, 0); if (pk == NULL) return; - struct iterator *it = pk->position(); - pk->initIterator(it, ITER_ALL, NULL, 0); - struct tuple *tuple; - while ((tuple = it->next(it))) - tuple_ref(tuple, -1); + alter->old_space->engine->factory->dropIndex(pk); } /** Change non-essential (no data change) properties of an index. */ diff --git a/src/box/engine.h b/src/box/engine.h index e32203de8d210030344b069d37c21e7f29f9bfe3..21c586c41994540fc13e3123b4a1f28d9280b368 100644 --- a/src/box/engine.h +++ b/src/box/engine.h @@ -101,6 +101,10 @@ class EngineFactory: public Object { * space. */ virtual Index *createIndex(struct key_def*) = 0; + /* + * Delete all tuples in the index on drop. + */ + virtual void dropIndex(Index*) = 0; /** * Check a key definition for violation of * various limits. diff --git a/src/box/engine_memtx.cc b/src/box/engine_memtx.cc index 4fe7c8d62802b40c2e91daea93a49be8465fdb74..cb8fab1c7d87b54c46117546c8029133787ae275 100644 --- a/src/box/engine_memtx.cc +++ b/src/box/engine_memtx.cc @@ -111,6 +111,16 @@ MemtxFactory::createIndex(struct key_def *key_def) } } +void +MemtxFactory::dropIndex(Index *index) +{ + struct iterator *it = index->position(); + index->initIterator(it, ITER_ALL, NULL, 0); + struct tuple *tuple; + while ((tuple = it->next(it))) + tuple_ref(tuple, -1); +} + void MemtxFactory::keydefCheck(struct key_def *key_def) { diff --git a/src/box/engine_memtx.h b/src/box/engine_memtx.h index 60f73a05930bb669b36708573c4f2a387dbca288..e3ea0c0fa41094536414a4f445c453eeac4e2dfe 100644 --- a/src/box/engine_memtx.h +++ b/src/box/engine_memtx.h @@ -33,6 +33,7 @@ struct MemtxFactory: public EngineFactory { MemtxFactory(); virtual Engine *open(); virtual Index *createIndex(struct key_def *key_def); + virtual void dropIndex(Index *index); virtual void keydefCheck(struct key_def *key_def); virtual void recoveryEvent(enum engine_recovery_event event); }; diff --git a/src/box/engine_sophia.cc b/src/box/engine_sophia.cc index 1c28e62cab37a71cdb0c38dda4a8543f1995638a..3a06c76c0582600a10716d9c40cd508cd6cfa791 100644 --- a/src/box/engine_sophia.cc +++ b/src/box/engine_sophia.cc @@ -134,6 +134,12 @@ SophiaFactory::createIndex(struct key_def *key_def) } } +void +SophiaFactory::dropIndex(Index *index) +{ + (void)index; +} + void SophiaFactory::keydefCheck(struct key_def *key_def) { diff --git a/src/box/engine_sophia.h b/src/box/engine_sophia.h index 2432705e13e3556323c73f0c3cd15634b4fe8f08..c4320ada4517af084c519315d18786347262d9e0 100644 --- a/src/box/engine_sophia.h +++ b/src/box/engine_sophia.h @@ -34,6 +34,7 @@ struct SophiaFactory: public EngineFactory { virtual void init(); virtual Engine *open(); virtual Index *createIndex(struct key_def *key_def); + virtual void dropIndex(Index *index); virtual void keydefCheck(struct key_def *key_def); virtual void txnFinish(struct txn *txn); virtual void recoveryEvent(enum engine_recovery_event event); diff --git a/test/box/sophia.result b/test/box/sophia.result index e576f18229dad901c2db1ae8bf1005519b738d6d..7cae8cef6e6fc90c5528fb2ef51db96264e78d82 100644 --- a/test/box/sophia.result +++ b/test/box/sophia.result @@ -103,7 +103,7 @@ t space:drop() --- ... -os.execute("rm -rf space0123") +os.execute("rm -rf sophia") --- - 0 ... diff --git a/test/box/sophia.test.lua b/test/box/sophia.test.lua index 7843558b3ae293d83ebf56990428a0217903d462..759fe750abd7e9d79163701fadeb2c02606a263f 100644 --- a/test/box/sophia.test.lua +++ b/test/box/sophia.test.lua @@ -24,4 +24,4 @@ for v=1, 10 do table.insert(t, space:get({v})) end t space:drop() -os.execute("rm -rf space0123") +os.execute("rm -rf sophia")