Add support for latest DuckDB (#22)

This commit is contained in:
Y.
2025-09-10 12:16:45 +02:00
committed by GitHub
parent 3fff3b2d1f
commit bba41c82c5
3 changed files with 23 additions and 6 deletions

View File

@@ -27,6 +27,10 @@ set(EXTENSION_SOURCES
src/utils/serialization.cpp src/utils/serialization.cpp
src/watcher.cpp) src/watcher.cpp)
add_definitions(-DDUCKDB_MAJOR_VERSION=${DUCKDB_MAJOR_VERSION})
add_definitions(-DDUCKDB_MINOR_VERSION=${DUCKDB_MINOR_VERSION})
add_definitions(-DDUCKDB_PATCH_VERSION=${DUCKDB_PATCH_VERSION})
find_package(Git) find_package(Git)
if(NOT Git_FOUND) if(NOT Git_FOUND)
message(FATAL_ERROR "Git not found, unable to determine git sha") message(FATAL_ERROR "Git not found, unable to determine git sha")

View File

@@ -6,6 +6,14 @@
#endif #endif
#include <type_traits> #include <type_traits>
// TODO we cannot run these checks because they are not defined for DuckDB < 1.4.x
// #ifndef DUCKDB_MAJOR_VERSION
// #error "DUCKDB_MAJOR_VERSION is not defined"
// ...
#define DUCKDB_VERSION_AT_MOST(major, minor, patch) \
(DUCKDB_MAJOR_VERSION < (major) || (DUCKDB_MAJOR_VERSION == (major) && DUCKDB_MINOR_VERSION < (minor)) || \
(DUCKDB_MAJOR_VERSION == (major) && DUCKDB_MINOR_VERSION == (minor) && DUCKDB_PATCH_VERSION <= (patch)))
namespace duckdb { namespace duckdb {
typedef std::string (*simple_tf_t)(ClientContext &); typedef std::string (*simple_tf_t)(ClientContext &);

View File

@@ -2,6 +2,7 @@
#include <duckdb/main/attached_database.hpp> #include <duckdb/main/attached_database.hpp>
#include "utils/helpers.hpp"
#include "utils/md_helpers.hpp" #include "utils/md_helpers.hpp"
#include "http_server.hpp" #include "http_server.hpp"
#include "settings.hpp" #include "settings.hpp"
@@ -23,19 +24,23 @@ bool WasCatalogUpdated(DatabaseInstance &db, Connection &connection,
// Check currently attached databases // Check currently attached databases
for (const auto &db_ref : databases) { for (const auto &db_ref : databases) {
auto &db = db_ref.get(); #if DUCKDB_VERSION_AT_MOST(1, 3, 2)
if (db.IsTemporary()) { auto &db_instance = db_ref.get();
#else
auto &db_instance = *db_ref;
#endif
if (db_instance.IsTemporary()) {
continue; // ignore temp databases continue; // ignore temp databases
} }
db_oids.insert(db.oid); db_oids.insert(db_instance.oid);
auto &catalog = db.GetCatalog(); auto &catalog = db_instance.GetCatalog();
auto current_version = catalog.GetCatalogVersion(context); auto current_version = catalog.GetCatalogVersion(context);
auto last_version_it = last_state.db_to_catalog_version.find(db.oid); auto last_version_it = last_state.db_to_catalog_version.find(db_instance.oid);
if (last_version_it == last_state.db_to_catalog_version.end() // first time if (last_version_it == last_state.db_to_catalog_version.end() // first time
|| !(last_version_it->second == current_version)) { // updated || !(last_version_it->second == current_version)) { // updated
has_change = true; has_change = true;
last_state.db_to_catalog_version[db.oid] = current_version; last_state.db_to_catalog_version[db_instance.oid] = current_version;
} }
} }