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.
|
|
|
|
|
2019-03-07 18:04:47 +00:00
|
|
|
struct TableStructureWriteLockHolder
|
2019-03-05 10:12:20 +00:00
|
|
|
{
|
2019-03-07 18:04:47 +00:00
|
|
|
void release()
|
|
|
|
{
|
2020-04-01 12:43:09 +00:00
|
|
|
*this = TableStructureWriteLockHolder();
|
2019-03-07 18:04:47 +00:00
|
|
|
}
|
|
|
|
|
2020-03-28 02:09:29 +00:00
|
|
|
void releaseAllExceptAlterIntention()
|
2020-03-18 14:43:16 +00:00
|
|
|
{
|
2020-04-01 12:43:09 +00:00
|
|
|
new_data_structure_lock.reset();
|
2020-03-18 14:43:16 +00:00
|
|
|
structure_lock.reset();
|
|
|
|
}
|
|
|
|
|
2019-03-07 18:04:47 +00:00
|
|
|
private:
|
|
|
|
friend class IStorage;
|
|
|
|
|
2019-03-05 10:12:20 +00:00
|
|
|
/// Order is important.
|
2020-04-01 12:43:09 +00:00
|
|
|
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-07 18:04:47 +00:00
|
|
|
};
|
2019-03-05 10:12:20 +00:00
|
|
|
|
2019-03-07 18:04:47 +00:00
|
|
|
struct TableStructureReadLockHolder
|
|
|
|
{
|
2019-08-27 14:31:34 +00:00
|
|
|
void release()
|
|
|
|
{
|
2020-04-01 12:43:09 +00:00
|
|
|
*this = TableStructureReadLockHolder();
|
2019-08-27 14:31:34 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 18:04:47 +00:00
|
|
|
private:
|
|
|
|
friend class IStorage;
|
|
|
|
|
|
|
|
/// Order is important.
|
2020-04-01 12:43:09 +00:00
|
|
|
RWLockImpl::LockHolder new_data_structure_lock;
|
2019-03-07 18:04:47 +00:00
|
|
|
RWLockImpl::LockHolder structure_lock;
|
2019-03-05 10:12:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|