ClickHouse/src/Storages/StorageSQLite.h
Azat Khuzhin f10fc95933 Fix INSERT into SQLite with single quote
Previously it leads to syntax error, due to incorrect escaping of single
quotes for SQLite, "\'" had been used instead of "''"

So set output_format_values_escape_quote_with_quote=true for SQLite to
fix this.

v2: prepare modified Context for writing on storage creation
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2024-02-15 12:47:29 +01:00

62 lines
1.4 KiB
C++

#pragma once
#include "config.h"
#if USE_SQLITE
#include <Storages/IStorage.h>
#include <sqlite3.h>
namespace Poco
{
class Logger;
}
namespace DB
{
class StorageSQLite final : public IStorage, public WithContext
{
public:
using SQLitePtr = std::shared_ptr<sqlite3>;
StorageSQLite(
const StorageID & table_id_,
SQLitePtr sqlite_db_,
const String & database_path_,
const String & remote_table_name_,
const ColumnsDescription & columns_,
const ConstraintsDescription & constraints_,
ContextPtr context_);
std::string getName() const override { return "SQLite"; }
Pipe read(
const Names & column_names,
const StorageSnapshotPtr & storage_snapshot,
SelectQueryInfo & query_info,
ContextPtr context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
size_t num_streams) override;
SinkToStoragePtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, ContextPtr context, bool async_insert) override;
static ColumnsDescription getTableStructureFromData(
const SQLitePtr & sqlite_db_,
const String & table);
private:
friend class SQLiteSink; /// for write_context
String remote_table_name;
String database_path;
SQLitePtr sqlite_db;
LoggerPtr log;
ContextPtr write_context;
};
}
#endif