diff --git a/.github/workflows/MainDistributionPipeline.yml b/.github/workflows/MainDistributionPipeline.yml index c1f3a24..b7d299b 100644 --- a/.github/workflows/MainDistributionPipeline.yml +++ b/.github/workflows/MainDistributionPipeline.yml @@ -16,9 +16,9 @@ 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 @@ -26,8 +26,8 @@ jobs: 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' }} diff --git a/duckdb b/duckdb index 0b83e5d..da1eb68 160000 --- a/duckdb +++ b/duckdb @@ -1 +1 @@ -Subproject commit 0b83e5d2f68bc02dfefde74b846bd039f078affa +Subproject commit da1eb68203a47dff51d30bbf7ca76fbfcfe9597a diff --git a/extension-ci-tools b/extension-ci-tools index b808e51..4317e39 160000 --- a/extension-ci-tools +++ b/extension-ci-tools @@ -1 +1 @@ -Subproject commit b808e5130cb6e1341ab968a2a9c0f5f236dd2ec8 +Subproject commit 4317e39099f4b71d614f00d044aaec651bec6fc9 diff --git a/src/include/sqlite_scanner_extension.hpp b/src/include/sqlite_scanner_extension.hpp index 40dfb9a..fa79d01 100644 --- a/src/include/sqlite_scanner_extension.hpp +++ b/src/include/sqlite_scanner_extension.hpp @@ -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); } \ No newline at end of file diff --git a/src/include/storage/sqlite_delete.hpp b/src/include/storage/sqlite_delete.hpp index 3c07df3..7315ebe 100644 --- a/src/include/storage/sqlite_delete.hpp +++ b/src/include/storage/sqlite_delete.hpp @@ -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; diff --git a/src/include/storage/sqlite_index.hpp b/src/include/storage/sqlite_index.hpp index 4400497..f60a33a 100644 --- a/src/include/storage/sqlite_index.hpp +++ b/src/include/storage/sqlite_index.hpp @@ -16,7 +16,7 @@ namespace duckdb { //! PhysicalCreateSequence represents a CREATE SEQUENCE command class SQLiteCreateIndex : public PhysicalOperator { public: - explicit SQLiteCreateIndex(unique_ptr info, TableCatalogEntry &table); + SQLiteCreateIndex(PhysicalPlan &physical_plan, unique_ptr info, TableCatalogEntry &table); unique_ptr info; TableCatalogEntry &table; diff --git a/src/include/storage/sqlite_insert.hpp b/src/include/storage/sqlite_insert.hpp index 65ec357..89a3f39 100644 --- a/src/include/storage/sqlite_insert.hpp +++ b/src/include/storage/sqlite_insert.hpp @@ -16,9 +16,11 @@ namespace duckdb { class SQLiteInsert : public PhysicalOperator { public: //! INSERT INTO - SQLiteInsert(LogicalOperator &op, TableCatalogEntry &table, physical_index_vector_t column_index_map); + SQLiteInsert(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table, + physical_index_vector_t column_index_map); //! CREATE TABLE AS - SQLiteInsert(LogicalOperator &op, SchemaCatalogEntry &schema, unique_ptr info); + SQLiteInsert(PhysicalPlan &physical_plan, LogicalOperator &op, SchemaCatalogEntry &schema, + unique_ptr info); //! The table to insert into optional_ptr table; diff --git a/src/include/storage/sqlite_update.hpp b/src/include/storage/sqlite_update.hpp index 0061620..8d40413 100644 --- a/src/include/storage/sqlite_update.hpp +++ b/src/include/storage/sqlite_update.hpp @@ -15,7 +15,8 @@ namespace duckdb { class SQLiteUpdate : public PhysicalOperator { public: - SQLiteUpdate(LogicalOperator &op, TableCatalogEntry &table, vector columns); + SQLiteUpdate(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table, + vector columns); //! The table to delete from TableCatalogEntry &table; diff --git a/src/sqlite_extension.cpp b/src/sqlite_extension.cpp index f85328f..5161298 100644 --- a/src/sqlite_extension.cpp +++ b/src/sqlite_extension.cpp @@ -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; @@ -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); @@ -39,19 +40,11 @@ static void LoadInternal(DatabaseInstance &db) { config.storage_extensions["sqlite_scanner"] = make_uniq(); } -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(); +DUCKDB_CPP_EXTENSION_ENTRY(sqlite_scanner, loader) { + LoadInternal(loader); } } diff --git a/src/sqlite_storage.cpp b/src/sqlite_storage.cpp index 09d212d..38255f6 100644 --- a/src/sqlite_storage.cpp +++ b/src/sqlite_storage.cpp @@ -12,22 +12,24 @@ namespace duckdb { -static unique_ptr SQLiteAttach(StorageExtensionInfo *storage_info, ClientContext &context, +static unique_ptr SQLiteAttach(optional_ptr 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(); } 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(db, info.path, std::move(options)); } -static unique_ptr SQLiteCreateTransactionManager(StorageExtensionInfo *storage_info, +static unique_ptr SQLiteCreateTransactionManager(optional_ptr storage_info, AttachedDatabase &db, Catalog &catalog) { auto &sqlite_catalog = catalog.Cast(); return make_uniq(db, sqlite_catalog); diff --git a/src/storage/sqlite_delete.cpp b/src/storage/sqlite_delete.cpp index c19f45b..e8d55d1 100644 --- a/src/storage/sqlite_delete.cpp +++ b/src/storage/sqlite_delete.cpp @@ -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) { } //===--------------------------------------------------------------------===// diff --git a/src/storage/sqlite_index.cpp b/src/storage/sqlite_index.cpp index 440db80..9c05afa 100644 --- a/src/storage/sqlite_index.cpp +++ b/src/storage/sqlite_index.cpp @@ -6,8 +6,10 @@ namespace duckdb { -SQLiteCreateIndex::SQLiteCreateIndex(unique_ptr info, TableCatalogEntry &table) - : PhysicalOperator(PhysicalOperatorType::EXTENSION, {LogicalType::BIGINT}, 1), info(std::move(info)), table(table) { +SQLiteCreateIndex::SQLiteCreateIndex(PhysicalPlan &physical_plan, unique_ptr info, + TableCatalogEntry &table) + : PhysicalOperator(physical_plan, PhysicalOperatorType::EXTENSION, {LogicalType::BIGINT}, 1), info(std::move(info)), + table(table) { } //===--------------------------------------------------------------------===// diff --git a/src/storage/sqlite_insert.cpp b/src/storage/sqlite_insert.cpp index 9cd4786..73d17a0 100644 --- a/src/storage/sqlite_insert.cpp +++ b/src/storage/sqlite_insert.cpp @@ -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 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 info) - : PhysicalOperator(PhysicalOperatorType::EXTENSION, op.types, 1), table(nullptr), schema(&schema), +SQLiteInsert::SQLiteInsert(PhysicalPlan &physical_plan, LogicalOperator &op, SchemaCatalogEntry &schema, + unique_ptr info) + : PhysicalOperator(physical_plan, PhysicalOperatorType::EXTENSION, op.types, 1), table(nullptr), schema(&schema), info(std::move(info)) { } @@ -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"); } diff --git a/src/storage/sqlite_update.cpp b/src/storage/sqlite_update.cpp index b550549..cfead5b 100644 --- a/src/storage/sqlite_update.cpp +++ b/src/storage/sqlite_update.cpp @@ -8,8 +8,10 @@ namespace duckdb { -SQLiteUpdate::SQLiteUpdate(LogicalOperator &op, TableCatalogEntry &table, vector 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 columns_p) + : PhysicalOperator(physical_plan, PhysicalOperatorType::EXTENSION, op.types, 1), table(table), + columns(std::move(columns_p)) { } //===--------------------------------------------------------------------===// diff --git a/test/sql/storage/attach_on_conflict.test b/test/sql/storage/attach_on_conflict.test index 6f7e678..7c13892 100644 --- a/test/sql/storage/attach_on_conflict.test +++ b/test/sql/storage/attach_on_conflict.test @@ -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 @@ -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