ClickHouse/dbms/src/Storages/TableStructureLockHolder.h

43 lines
834 B
C++
Raw Normal View History

2019-03-05 10:12:20 +00:00
#pragma once
#include <Common/RWLock.h>
namespace DB
{
2019-03-07 18:34:46 +00:00
/// Structs that hold table structure (columns, their types, default values etc.) locks when executing queries.
/// See IStorage::lock* methods for comments.
struct TableStructureWriteLockHolder
2019-03-05 10:12:20 +00:00
{
void release()
{
*this = TableStructureWriteLockHolder();
}
private:
friend class IStorage;
2019-03-05 10:12:20 +00:00
/// Order is important.
RWLockImpl::LockHolder alter_intention_lock;
RWLockImpl::LockHolder new_data_structure_lock;
RWLockImpl::LockHolder structure_lock;
};
2019-03-05 10:12:20 +00:00
struct TableStructureReadLockHolder
{
2019-08-27 14:31:34 +00:00
void release()
{
*this = TableStructureReadLockHolder();
}
private:
friend class IStorage;
/// Order is important.
RWLockImpl::LockHolder new_data_structure_lock;
RWLockImpl::LockHolder structure_lock;
2019-03-05 10:12:20 +00:00
};
}