ClickHouse/dbms/Storages/TableStructureLockHolder.h
Ivan 97f2a2213e
Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00

49 lines
962 B
C++

#pragma once
#include <Common/RWLock.h>
namespace DB
{
/// Structs that hold table structure (columns, their types, default values etc.) locks when executing queries.
/// See IStorage::lock* methods for comments.
struct TableStructureWriteLockHolder
{
void release()
{
*this = TableStructureWriteLockHolder();
}
void releaseAllExceptAlterIntention()
{
new_data_structure_lock.reset();
structure_lock.reset();
}
private:
friend class IStorage;
/// Order is important.
RWLockImpl::LockHolder alter_intention_lock;
RWLockImpl::LockHolder new_data_structure_lock;
RWLockImpl::LockHolder structure_lock;
};
struct TableStructureReadLockHolder
{
void release()
{
*this = TableStructureReadLockHolder();
}
private:
friend class IStorage;
/// Order is important.
RWLockImpl::LockHolder new_data_structure_lock;
RWLockImpl::LockHolder structure_lock;
};
}