From 43e79a86029a2611b4ae4f0feff0b0f065fb5b37 Mon Sep 17 00:00:00 2001 From: "Damon P. Cortesi" Date: Tue, 13 Feb 2024 09:56:55 -0800 Subject: [PATCH] Bump duckdb version to next minor and remove custom patch --- .github/workflows/Linux.yml | 9 +-- .github/workflows/Windows.yml | 7 -- .github/workflows/macOS.yml | 9 +-- duckdb | 2 +- duckdb-ext/duckdb | 2 +- duckdb-namedparams.patch | 118 ---------------------------------- 6 files changed, 4 insertions(+), 143 deletions(-) delete mode 100644 duckdb-namedparams.patch diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index e696abc..f274c01 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -100,15 +100,8 @@ jobs: run: | cd duckdb git checkout ${{ matrix.duckdb_version }} - cd duckdb-ext/duckdb - git checkout ${{ matrix.duckdb_version }} - - - name: Patch DuckDB with named parameter support - run: | - cd duckdb - git apply ../duckdb-namedparams.patch cd ../duckdb-ext/duckdb - git apply ../../duckdb-namedparams.patch + git checkout ${{ matrix.duckdb_version }} - if: ${{ matrix.arch == 'linux_amd64_gcc4' }} uses: ./duckdb/.github/actions/centos_7_setup diff --git a/.github/workflows/Windows.yml b/.github/workflows/Windows.yml index 79871f9..3df5b48 100644 --- a/.github/workflows/Windows.yml +++ b/.github/workflows/Windows.yml @@ -40,13 +40,6 @@ jobs: cd ../duckdb-ext/duckdb git checkout ${{ matrix.duckdb_version }} - - name: Patch DuckDB with named parameter support - run: | - cd duckdb - git apply ../duckdb-namedparams.patch - cd ../duckdb-ext/duckdb - git apply ../../duckdb-namedparams.patch - - name: Build extension run: | dir duckdb-ext/duckdb/src/include diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 41d00be..82eddf7 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -42,15 +42,8 @@ jobs: run: | cd duckdb git checkout ${{ matrix.duckdb_version }} - cd duckdb-ext/duckdb - git checkout ${{ matrix.duckdb_version }} - - - name: Patch DuckDB with named parameter support - run: | - cd duckdb - git apply ../duckdb-namedparams.patch cd ../duckdb-ext/duckdb - git apply ../../duckdb-namedparams.patch + git checkout ${{ matrix.duckdb_version }} # Build extension - name: Build extension diff --git a/duckdb b/duckdb index b00b93f..6536a77 160000 --- a/duckdb +++ b/duckdb @@ -1 +1 @@ -Subproject commit b00b93f0b14bfff869e1facfd86a6b556a6f1c6e +Subproject commit 6536a772329002b05decbfc0a9d3f606e0ec7f55 diff --git a/duckdb-ext/duckdb b/duckdb-ext/duckdb index b00b93f..6536a77 160000 --- a/duckdb-ext/duckdb +++ b/duckdb-ext/duckdb @@ -1 +1 @@ -Subproject commit b00b93f0b14bfff869e1facfd86a6b556a6f1c6e +Subproject commit 6536a772329002b05decbfc0a9d3f606e0ec7f55 diff --git a/duckdb-namedparams.patch b/duckdb-namedparams.patch deleted file mode 100644 index 88fbb35..0000000 --- a/duckdb-namedparams.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 5f8ba2ba0c139b69aa34c316471be74877e234e8 Mon Sep 17 00:00:00 2001 -From: "Damon P. Cortesi" -Date: Sat, 4 Mar 2023 16:21:03 -0800 -Subject: [PATCH] Add support for named paramters in the API - ---- - src/include/duckdb.h | 21 +++++++++++++++++++++ - src/main/capi/table_function-c.cpp | 23 +++++++++++++++++++++++ - test/api/capi/capi_table_functions.cpp | 9 +++++++++ - 3 files changed, 53 insertions(+) - -diff --git a/src/include/duckdb.h b/src/include/duckdb.h -index 3c75c42b1c0..93219e0e123 100644 ---- a/src/include/duckdb.h -+++ b/src/include/duckdb.h -@@ -1710,6 +1710,16 @@ Adds a parameter to the table function. - */ - DUCKDB_API void duckdb_table_function_add_parameter(duckdb_table_function table_function, duckdb_logical_type type); - -+/*! -+Adds a named parameter to the table function. -+ -+* table_function: The table function -+* name: The name of the parameter -+* type: The type of the parameter to add. -+*/ -+DUCKDB_API void duckdb_table_function_add_named_parameter(duckdb_table_function table_function, const char *name, -+ duckdb_logical_type type); -+ - /*! - Assigns extra information to the table function that can be fetched during binding, etc. - -@@ -1818,6 +1828,17 @@ The result must be destroyed with `duckdb_destroy_value`. - */ - DUCKDB_API duckdb_value duckdb_bind_get_parameter(duckdb_bind_info info, idx_t index); - -+/*! -+Retrieves a named parameter with the given name. -+ -+The result must be destroyed with `duckdb_destroy_value`. -+ -+* info: The info object -+* name: The name of the parameter -+* returns: The value of the parameter. Must be destroyed with `duckdb_destroy_value`. -+*/ -+DUCKDB_API duckdb_value duckdb_bind_get_named_parameter(duckdb_bind_info info, const char *name); -+ - /*! - Sets the user-provided bind data in the bind object. This object can be retrieved again during execution. - -diff --git a/src/main/capi/table_function-c.cpp b/src/main/capi/table_function-c.cpp -index ac2d6fbcd2b..fd57c38fa75 100644 ---- a/src/main/capi/table_function-c.cpp -+++ b/src/main/capi/table_function-c.cpp -@@ -208,6 +208,16 @@ void duckdb_table_function_add_parameter(duckdb_table_function function, duckdb_ - tf->arguments.push_back(*logical_type); - } - -+void duckdb_table_function_add_named_parameter(duckdb_table_function function, const char *name, -+ duckdb_logical_type type) { -+ if (!function || !type) { -+ return; -+ } -+ auto tf = (duckdb::TableFunction *)function; -+ auto logical_type = (duckdb::LogicalType *)type; -+ tf->named_parameters.insert({name, *logical_type}); -+} -+ - void duckdb_table_function_set_extra_info(duckdb_table_function function, void *extra_info, - duckdb_delete_callback_t destroy) { - if (!function) { -@@ -319,6 +329,19 @@ duckdb_value duckdb_bind_get_parameter(duckdb_bind_info info, idx_t index) { - return reinterpret_cast(new duckdb::Value(bind_info->input.inputs[index])); - } - -+duckdb_value duckdb_bind_get_named_parameter(duckdb_bind_info info, const char *name) { -+ if (!info || !name) { -+ return nullptr; -+ } -+ auto bind_info = (duckdb::CTableInternalBindInfo *)info; -+ auto t = bind_info->input.named_parameters.find(name); -+ if (t == bind_info->input.named_parameters.end()) { -+ return nullptr; -+ } else { -+ return reinterpret_cast(new duckdb::Value(t->second)); -+ } -+} -+ - void duckdb_bind_set_bind_data(duckdb_bind_info info, void *bind_data, duckdb_delete_callback_t destroy) { - if (!info) { - return; -diff --git a/test/api/capi/capi_table_functions.cpp b/test/api/capi/capi_table_functions.cpp -index 97852c51ff1..4c919b607d4 100644 ---- a/test/api/capi/capi_table_functions.cpp -+++ b/test/api/capi/capi_table_functions.cpp -@@ -67,6 +67,11 @@ static void capi_register_table_function(duckdb_connection connection, const cha - duckdb_table_function_add_parameter(function, type); - duckdb_destroy_logical_type(&type); - -+ // add a named parameter -+ duckdb_logical_type itype = duckdb_create_logical_type(DUCKDB_TYPE_INTEGER); -+ duckdb_table_function_add_named_parameter(function, "my_parameter", itype); -+ duckdb_destroy_logical_type(&itype); -+ - // set up the function pointers - duckdb_table_function_set_bind(function, bind); - duckdb_table_function_set_init(function, init); -@@ -93,6 +98,10 @@ TEST_CASE("Test Table Functions C API", "[capi]") { - REQUIRE_NO_FAIL(*result); - REQUIRE(result->Fetch(0, 0) == 42); - -+ result = tester.Query("SELECT * FROM my_function(1, my_parameter=3)"); -+ REQUIRE_NO_FAIL(*result); -+ REQUIRE(result->Fetch(0, 0) == 42); -+ - result = tester.Query("SELECT * FROM my_function(3)"); - REQUIRE_NO_FAIL(*result); - REQUIRE(result->Fetch(0, 0) == 42);