aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/TransactionsInfoLog.h
blob: fc3783b59163ffc6e224a033e9f01c9e425425b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once

#include <Core/NamesAndAliases.h>
#include <Interpreters/SystemLog.h>
#include <Common/TransactionID.h>

namespace DB
{

struct TransactionInfoContext;

struct TransactionsInfoLogElement
{
    enum Type
    {
        UNKNOWN = 0,

        BEGIN = 1,
        COMMIT = 2,
        ROLLBACK = 3,

        ADD_PART = 10,
        LOCK_PART = 11,
        UNLOCK_PART = 12,
    };

    Type type = UNKNOWN;
    Decimal64 event_time = 0;
    UInt64 thread_id;

    String query_id;
    TransactionID tid = Tx::EmptyTID;

    /// For COMMIT events
    CSN csn = Tx::UnknownCSN;

    /// For *_PART events
    StorageID table = StorageID::createEmpty();
    String part_name;

    static std::string name() { return "TransactionsInfoLog"; }
    static NamesAndTypesList getNamesAndTypes();
    static NamesAndAliases getNamesAndAliases() { return {}; }
    void appendToBlock(MutableColumns & columns) const;
    static const char * getCustomColumnList() { return nullptr; }

    void fillCommonFields(const TransactionInfoContext * context = nullptr);
};

class TransactionsInfoLog : public SystemLog<TransactionsInfoLogElement>
{
    using SystemLog<TransactionsInfoLogElement>::SystemLog;
};


void tryWriteEventToSystemLog(Poco::Logger * log, TransactionsInfoLogElement::Type type,
                              const TransactionID & tid, const TransactionInfoContext & context);

}