forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabaseSQLite.h
65 lines (38 loc) · 1.63 KB
/
DatabaseSQLite.h
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
60
61
62
63
64
65
#pragma once
#include "config.h"
#if USE_SQLITE
#include <Core/Names.h>
#include <Databases/DatabasesCommon.h>
#include <Parsers/ASTCreateQuery.h>
#include <sqlite3.h>
namespace DB
{
class DatabaseSQLite final : public IDatabase, WithContext
{
public:
using SQLitePtr = std::shared_ptr<sqlite3>;
DatabaseSQLite(ContextPtr context_, const ASTStorage * database_engine_define_,
bool is_attach_, const String & database_path_);
String getEngineName() const override { return "SQLite"; }
bool canContainMergeTreeTables() const override { return false; }
bool canContainDistributedTables() const override { return false; }
bool shouldBeEmptyOnDetach() const override { return false; }
bool isTableExist(const String & name, ContextPtr context) const override;
StoragePtr tryGetTable(const String & name, ContextPtr context) const override;
DatabaseTablesIteratorPtr getTablesIterator(ContextPtr context, const FilterByNameFunction & filter_by_table_name) const override;
bool empty() const override;
ASTPtr getCreateDatabaseQuery() const override;
void shutdown() override {}
protected:
ASTPtr getCreateTableQueryImpl(const String & table_name, ContextPtr context, bool throw_on_error) const override;
private:
ASTPtr database_engine_define;
String database_path;
mutable SQLitePtr sqlite_db;
Poco::Logger * log;
bool checkSQLiteTable(const String & table_name) const;
NameSet fetchTablesList() const TSA_REQUIRES(mutex);
StoragePtr fetchTable(const String & table_name, ContextPtr context, bool table_checked) const TSA_REQUIRES(mutex);
};
}
#endif