ClickHouse/src/Storages/StorageSQLite.h

54 lines
1.3 KiB
C++
Raw Normal View History

2021-05-17 11:02:35 +00:00
#pragma once
2021-07-08 13:27:30 +00:00
#if !defined(ARCADIA_BUILD)
#include "config_core.h"
#endif
#if USE_SQLITE
2021-07-10 08:05:23 +00:00
#include <common/shared_ptr_helper.h>
2021-05-17 11:02:35 +00:00
#include <Storages/IStorage.h>
2021-07-13 22:16:27 +00:00
#include <sqlite3.h> // Y_IGNORE
2021-05-17 11:02:35 +00:00
namespace DB
{
2021-07-10 08:05:23 +00:00
2021-07-07 20:39:41 +00:00
class StorageSQLite final : public shared_ptr_helper<StorageSQLite>, public IStorage, public WithContext
2021-05-17 11:02:35 +00:00
{
2021-07-10 08:05:23 +00:00
friend struct shared_ptr_helper<StorageSQLite>;
2021-05-17 11:02:35 +00:00
public:
2021-07-10 08:05:23 +00:00
using SQLitePtr = std::shared_ptr<sqlite3>;
2021-05-17 11:02:35 +00:00
StorageSQLite(
const StorageID & table_id_,
2021-07-10 08:05:23 +00:00
SQLitePtr sqlite_db_,
2021-05-17 11:02:35 +00:00
const String & remote_table_name_,
const ColumnsDescription & columns_,
const ConstraintsDescription & constraints_,
2021-06-01 20:52:12 +00:00
ContextPtr context_);
2021-05-17 11:02:35 +00:00
std::string getName() const override { return "SQLite"; }
Pipe read(
const Names & column_names,
const StorageMetadataPtr & /*metadata_snapshot*/,
SelectQueryInfo & query_info,
ContextPtr context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
unsigned num_streams) override;
2021-05-24 18:59:10 +00:00
BlockOutputStreamPtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, ContextPtr context) override;
2021-05-17 11:02:35 +00:00
private:
String remote_table_name;
ContextPtr global_context;
2021-07-10 08:05:23 +00:00
SQLitePtr sqlite_db;
2021-05-17 11:02:35 +00:00
};
}
2021-07-08 13:27:30 +00:00
#endif