ClickHouse/src/Storages/TableStructureLockHolder.h

49 lines
962 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();
}
2020-03-28 02:09:29 +00:00
void releaseAllExceptAlterIntention()
2020-03-18 14:43:16 +00:00
{
new_data_structure_lock.reset();
2020-03-18 14:43:16 +00:00
structure_lock.reset();
}
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;
2019-03-05 10:12:20 +00:00
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();
2019-08-27 14:31:34 +00:00
}
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
};
}