1#pragma once
2
3#include <Common/RWLock.h>
4
5namespace DB
6{
7
8/// Structs that hold table structure (columns, their types, default values etc.) locks when executing queries.
9/// See IStorage::lock* methods for comments.
10
11struct TableStructureWriteLockHolder
12{
13 void release()
14 {
15 *this = TableStructureWriteLockHolder();
16 }
17
18private:
19 friend class IStorage;
20
21 /// Order is important.
22 RWLockImpl::LockHolder alter_intention_lock;
23 RWLockImpl::LockHolder new_data_structure_lock;
24 RWLockImpl::LockHolder structure_lock;
25};
26
27struct TableStructureReadLockHolder
28{
29 void release()
30 {
31 *this = TableStructureReadLockHolder();
32 }
33
34private:
35 friend class IStorage;
36
37 /// Order is important.
38 RWLockImpl::LockHolder new_data_structure_lock;
39 RWLockImpl::LockHolder structure_lock;
40};
41
42}
43