Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/MainDistributionPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:
name: Build extension binaries
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@v1.3.2
with:
duckdb_version: v1.3.2
duckdb_version: main
extension_name: sqlite_scanner
ci_tools_version: v1.3.2
ci_tools_version: main

duckdb-stable-deploy:
name: Deploy extension binaries
needs: duckdb-stable-build
uses: duckdb/extension-ci-tools/.github/workflows/_extension_deploy.yml@v1.3.2
secrets: inherit
with:
duckdb_version: v1.3.2
duckdb_version: main
extension_name: sqlite_scanner
ci_tools_version: v1.3.2
ci_tools_version: main
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
deploy_versioned: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
2 changes: 1 addition & 1 deletion duckdb
Submodule duckdb updated 3154 files
6 changes: 2 additions & 4 deletions src/include/sqlite_scanner_extension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ class SqliteScannerExtension : public Extension {
std::string Name() override {
return "sqlite_scanner";
}
void Load(DuckDB &db) override;
void Load(ExtensionLoader &loader) override;
};

extern "C" {
DUCKDB_EXTENSION_API void sqlite_scanner_init(duckdb::DatabaseInstance &db);
DUCKDB_EXTENSION_API const char *sqlite_scanner_version();
DUCKDB_EXTENSION_API void sqlite_scanner_storage_init(DBConfig &config);
DUCKDB_CPP_EXTENSION_ENTRY(sqlite_scanner, loader);
}
2 changes: 1 addition & 1 deletion src/include/storage/sqlite_delete.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace duckdb {

class SQLiteDelete : public PhysicalOperator {
public:
SQLiteDelete(LogicalOperator &op, TableCatalogEntry &table, idx_t row_id_index);
SQLiteDelete(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table, idx_t row_id_index);

//! The table to delete from
TableCatalogEntry &table;
Expand Down
2 changes: 1 addition & 1 deletion src/include/storage/sqlite_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace duckdb {
//! PhysicalCreateSequence represents a CREATE SEQUENCE command
class SQLiteCreateIndex : public PhysicalOperator {
public:
explicit SQLiteCreateIndex(unique_ptr<CreateIndexInfo> info, TableCatalogEntry &table);
SQLiteCreateIndex(PhysicalPlan &physical_plan, unique_ptr<CreateIndexInfo> info, TableCatalogEntry &table);

unique_ptr<CreateIndexInfo> info;
TableCatalogEntry &table;
Expand Down
6 changes: 4 additions & 2 deletions src/include/storage/sqlite_insert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ namespace duckdb {
class SQLiteInsert : public PhysicalOperator {
public:
//! INSERT INTO
SQLiteInsert(LogicalOperator &op, TableCatalogEntry &table, physical_index_vector_t<idx_t> column_index_map);
SQLiteInsert(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table,
physical_index_vector_t<idx_t> column_index_map);
//! CREATE TABLE AS
SQLiteInsert(LogicalOperator &op, SchemaCatalogEntry &schema, unique_ptr<BoundCreateTableInfo> info);
SQLiteInsert(PhysicalPlan &physical_plan, LogicalOperator &op, SchemaCatalogEntry &schema,
unique_ptr<BoundCreateTableInfo> info);

//! The table to insert into
optional_ptr<TableCatalogEntry> table;
Expand Down
3 changes: 2 additions & 1 deletion src/include/storage/sqlite_update.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace duckdb {

class SQLiteUpdate : public PhysicalOperator {
public:
SQLiteUpdate(LogicalOperator &op, TableCatalogEntry &table, vector<PhysicalIndex> columns);
SQLiteUpdate(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table,
vector<PhysicalIndex> columns);

//! The table to delete from
TableCatalogEntry &table;
Expand Down
27 changes: 10 additions & 17 deletions src/sqlite_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "sqlite_scanner_extension.hpp"

#include "duckdb/catalog/catalog.hpp"
#include "duckdb/main/extension_util.hpp"
#include "duckdb/main/extension/extension_loader.hpp"
#include "duckdb/parser/parsed_data/create_table_function_info.hpp"

using namespace duckdb;
Expand All @@ -20,16 +20,17 @@ static void SetSqliteDebugQueryPrint(ClientContext &context, SetScope scope, Val
SQLiteDB::DebugSetPrintQueries(BooleanValue::Get(parameter));
}

static void LoadInternal(DatabaseInstance &db) {
static void LoadInternal(ExtensionLoader &loader) {
SqliteScanFunction sqlite_fun;
ExtensionUtil::RegisterFunction(db, sqlite_fun);
loader.RegisterFunction(sqlite_fun);

SqliteAttachFunction attach_func;
ExtensionUtil::RegisterFunction(db, attach_func);
loader.RegisterFunction(attach_func);

SQLiteQueryFunction query_func;
ExtensionUtil::RegisterFunction(db, query_func);
loader.RegisterFunction(query_func);

auto &db = loader.GetDatabaseInstance();
auto &config = DBConfig::GetConfig(db);
config.AddExtensionOption("sqlite_all_varchar", "Load all SQLite columns as VARCHAR columns", LogicalType::BOOLEAN);

Expand All @@ -39,19 +40,11 @@ static void LoadInternal(DatabaseInstance &db) {
config.storage_extensions["sqlite_scanner"] = make_uniq<SQLiteStorageExtension>();
}

void SqliteScannerExtension::Load(DuckDB &db) {
LoadInternal(*db.instance);
void SqliteScannerExtension::Load(ExtensionLoader &loader) {
LoadInternal(loader);
}

DUCKDB_EXTENSION_API void sqlite_scanner_init(duckdb::DatabaseInstance &db) {
LoadInternal(db);
}

DUCKDB_EXTENSION_API const char *sqlite_scanner_version() {
return DuckDB::LibraryVersion();
}

DUCKDB_EXTENSION_API void sqlite_scanner_storage_init(DBConfig &config) {
config.storage_extensions["sqlite_scanner"] = make_uniq<SQLiteStorageExtension>();
DUCKDB_CPP_EXTENSION_ENTRY(sqlite_scanner, loader) {
LoadInternal(loader);
}
}
12 changes: 7 additions & 5 deletions src/sqlite_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@

namespace duckdb {

static unique_ptr<Catalog> SQLiteAttach(StorageExtensionInfo *storage_info, ClientContext &context,
static unique_ptr<Catalog> SQLiteAttach(optional_ptr<StorageExtensionInfo> storage_info, ClientContext &context,
AttachedDatabase &db, const string &name, AttachInfo &info,
AccessMode access_mode) {
AttachOptions &attach_options) {
SQLiteOpenOptions options;
options.access_mode = access_mode;
for (auto &entry : info.options) {
options.access_mode = attach_options.access_mode;
for (auto &entry : attach_options.options) {
if (StringUtil::CIEquals(entry.first, "busy_timeout")) {
options.busy_timeout = entry.second.GetValue<uint64_t>();
} else if (StringUtil::CIEquals(entry.first, "journal_mode")) {
options.journal_mode = entry.second.ToString();
} else {
throw NotImplementedException("Unsupported parameter for SQLite Attach: %s", entry.first);
}
}
return make_uniq<SQLiteCatalog>(db, info.path, std::move(options));
}

static unique_ptr<TransactionManager> SQLiteCreateTransactionManager(StorageExtensionInfo *storage_info,
static unique_ptr<TransactionManager> SQLiteCreateTransactionManager(optional_ptr<StorageExtensionInfo> storage_info,
AttachedDatabase &db, Catalog &catalog) {
auto &sqlite_catalog = catalog.Cast<SQLiteCatalog>();
return make_uniq<SQLiteTransactionManager>(db, sqlite_catalog);
Expand Down
6 changes: 4 additions & 2 deletions src/storage/sqlite_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

namespace duckdb {

SQLiteDelete::SQLiteDelete(LogicalOperator &op, TableCatalogEntry &table, idx_t row_id_index)
: PhysicalOperator(PhysicalOperatorType::EXTENSION, op.types, 1), table(table), row_id_index(row_id_index) {
SQLiteDelete::SQLiteDelete(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table,
idx_t row_id_index)
: PhysicalOperator(physical_plan, PhysicalOperatorType::EXTENSION, op.types, 1), table(table),
row_id_index(row_id_index) {
}

//===--------------------------------------------------------------------===//
Expand Down
6 changes: 4 additions & 2 deletions src/storage/sqlite_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

namespace duckdb {

SQLiteCreateIndex::SQLiteCreateIndex(unique_ptr<CreateIndexInfo> info, TableCatalogEntry &table)
: PhysicalOperator(PhysicalOperatorType::EXTENSION, {LogicalType::BIGINT}, 1), info(std::move(info)), table(table) {
SQLiteCreateIndex::SQLiteCreateIndex(PhysicalPlan &physical_plan, unique_ptr<CreateIndexInfo> info,
TableCatalogEntry &table)
: PhysicalOperator(physical_plan, PhysicalOperatorType::EXTENSION, {LogicalType::BIGINT}, 1), info(std::move(info)),
table(table) {
}

//===--------------------------------------------------------------------===//
Expand Down
11 changes: 6 additions & 5 deletions src/storage/sqlite_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

namespace duckdb {

SQLiteInsert::SQLiteInsert(LogicalOperator &op, TableCatalogEntry &table,
SQLiteInsert::SQLiteInsert(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table,
physical_index_vector_t<idx_t> column_index_map_p)
: PhysicalOperator(PhysicalOperatorType::EXTENSION, op.types, 1), table(&table), schema(nullptr),
: PhysicalOperator(physical_plan, PhysicalOperatorType::EXTENSION, op.types, 1), table(&table), schema(nullptr),
column_index_map(std::move(column_index_map_p)) {
}

SQLiteInsert::SQLiteInsert(LogicalOperator &op, SchemaCatalogEntry &schema, unique_ptr<BoundCreateTableInfo> info)
: PhysicalOperator(PhysicalOperatorType::EXTENSION, op.types, 1), table(nullptr), schema(&schema),
SQLiteInsert::SQLiteInsert(PhysicalPlan &physical_plan, LogicalOperator &op, SchemaCatalogEntry &schema,
unique_ptr<BoundCreateTableInfo> info)
: PhysicalOperator(physical_plan, PhysicalOperatorType::EXTENSION, op.types, 1), table(nullptr), schema(&schema),
info(std::move(info)) {
}

Expand Down Expand Up @@ -184,7 +185,7 @@ PhysicalOperator &SQLiteCatalog::PlanInsert(ClientContext &context, PhysicalPlan
if (op.return_chunk) {
throw BinderException("RETURNING clause not yet supported for insertion into SQLite table");
}
if (op.action_type != OnConflictAction::THROW) {
if (op.on_conflict_info.action_type != OnConflictAction::THROW) {
throw BinderException("ON CONFLICT clause not yet supported for insertion into SQLite table");
}

Expand Down
6 changes: 4 additions & 2 deletions src/storage/sqlite_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

namespace duckdb {

SQLiteUpdate::SQLiteUpdate(LogicalOperator &op, TableCatalogEntry &table, vector<PhysicalIndex> columns_p)
: PhysicalOperator(PhysicalOperatorType::EXTENSION, op.types, 1), table(table), columns(std::move(columns_p)) {
SQLiteUpdate::SQLiteUpdate(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table,
vector<PhysicalIndex> columns_p)
: PhysicalOperator(physical_plan, PhysicalOperatorType::EXTENSION, op.types, 1), table(table),
columns(std::move(columns_p)) {
}

//===--------------------------------------------------------------------===//
Expand Down
4 changes: 2 additions & 2 deletions test/sql/storage/attach_on_conflict.test
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ UNIQUE constraint failed
statement error
INSERT OR IGNORE INTO s.tbl VALUES (1)
----
ON CONFLICT clause not yet supported for insertion into SQLite table
does not support

# INSERT OR IGNORE in a table without primary key constraints
statement ok
Expand All @@ -30,4 +30,4 @@ CREATE TABLE s.tbl2(i INTEGER)
statement error
INSERT OR REPLACE INTO s.tbl2 VALUES (1)
----
There are no UNIQUE/PRIMARY KEY Indexes
no UNIQUE/PRIMARY KEY constraints
Loading