fix

fix
This commit is contained in:
feng lv 2020-09-22 17:29:57 +08:00
parent 5d7a77c207
commit c0b5f847d9
3 changed files with 40 additions and 6 deletions

View File

@ -216,22 +216,22 @@ static inline void columnUpdate(Block & old_block, const Block & new_block)
void StorageMemory::mutate(const MutationCommands & commands, const Context & context)
{
auto metadata_snapshot_ = getInMemoryMetadataPtr();
auto storage_id_ = getStorageID();
auto storage_ptr_ = DatabaseCatalog::instance().getTable(storage_id_, context);
auto interpreter = std::make_unique<MutationsInterpreter>(storage_ptr_, metadata_snapshot_, commands, context, true);
auto metadata_snapshot = getInMemoryMetadataPtr();
auto storage = getStorageID();
auto storage_ptr = DatabaseCatalog::instance().getTable(storage, context);
auto interpreter = std::make_unique<MutationsInterpreter>(storage_ptr, metadata_snapshot, commands, context, true);
auto in = interpreter->execute();
in->readPrefix();
BlocksList out;
Block block;
while (block = in->read())
while ((block = in->read()))
{
out.push_back(block);
}
in->readSuffix();
std::lock_guard lock(mutex);
std::lock_guard lock(mutex);
// all column affected
if (interpreter->isAffectingAllColumns())

View File

@ -0,0 +1,14 @@
1 1
2 2
3 3
4 4
5 5
100 1
2 2
3 3
4 4
5 5
2 2
3 3
4 4
5 5

View File

@ -0,0 +1,20 @@
DROP TABLE IF EXISTS defaults;
CREATE TABLE defaults
(
n Int32,
s String
)ENGINE = Memory();
INSERT INTO defaults VALUES(1, '1') (2, '2') (3, '3') (4, '4') (5, '5');
SELECT * FROM defaults;
ALTER TABLE defaults UPDATE n = 100 WHERE s = '1';
SELECT * FROM defaults;
ALTER TABLE defaults DELETE WHERE n = 100;
SELECT * FROM defaults;
DROP TABLE defaults;