dbms: added reset of cache in alter modify [#METR-10242]

This commit is contained in:
Pavel Kartavyy 2014-03-04 23:11:32 +04:00
parent 9c269c7b81
commit 108342491f
5 changed files with 25 additions and 2 deletions

View File

@ -102,6 +102,16 @@ public:
return cells.size();
}
void reset()
{
Poco::ScopedLock<Poco::FastMutex> lock(mutex);
queue.clear();
cells.clear();
current_size = 0;
hits = 0;
misses = 0;
}
private:
typedef std::list<Key> LRUQueue;
typedef typename LRUQueue::iterator LRUQueueIterator;

View File

@ -53,6 +53,11 @@ public:
return res;
}
void reset()
{
Base::reset();
}
};
typedef Poco::SharedPtr<UncompressedCache> UncompressedCachePtr;

View File

@ -62,6 +62,11 @@ public:
return res;
}
void reset()
{
Base::reset();
}
};
typedef Poco::SharedPtr<MarkCache> MarkCachePtr;

View File

@ -245,7 +245,7 @@ void IStorage::alterColumns(const ASTAlterQuery::Parameters & params, NamesAndTy
String type_string = String(type_range.first, type_range.second - type_range.first);
DB::DataTypePtr data_type = context.getDataTypeFactory().get(type_string);
NameAndTypePair pair(ast_name_type.name, data_type );
NameAndTypePair pair(ast_name_type.name, data_type);
NamesAndTypesList::iterator column_it = std::find_if(columns->begin(), columns->end(), boost::bind(namesEqual, ast_name_type.name, _1) );
if (column_it == columns->end())
throw Exception("Wrong column name. Cannot find column " + ast_name_type.name + " to modify.", DB::ErrorCodes::ILLEGAL_COLUMN);

View File

@ -1270,7 +1270,7 @@ void StorageMergeTree::alter(const ASTAlterQuery::Parameters & params)
{
if (params.type == ASTAlterQuery::MODIFY)
{
/// @TODO поддержка alter primary ключа
{
Poco::ScopedWriteRWLock mlock(merge_lock);
Poco::ScopedWriteRWLock wlock(write_lock);
@ -1343,6 +1343,9 @@ void StorageMergeTree::alter(const ASTAlterQuery::Parameters & params)
LOG_TRACE(log, "Removing old column " << path + ".mrk" + ".old");
Poco::File(path + ".mrk" + ".old").remove();
}
}
context.getUncompressedCache()->reset();
context.getMarkCache()->reset();
}
{
Poco::ScopedLock<Poco::FastMutex> lock(data_parts_mutex);