Skip to content
Open
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
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,49 @@ include extension-ci-tools/makefiles/duckdb_extension.Makefile
# both MEOS (meos_initialize_timezone) and DuckDB (DBConfig::SetOptionByName
# "TimeZone") to Europe/Brussels. Tests pass on any OS timezone — the
# extension is the single source of truth, no TZ env var needed.
#
# LoadInternal also auto-loads ICU so the named "Europe/Brussels" zone
# resolves. DuckDB autoloads ICU from
# $HOME/.duckdb/extensions/<version>/<platform>/icu.duckdb_extension
# and otherwise falls back to a hub download — which fails inside the CI test
# docker (empty path, no network egress) and on the macOS osx_arm64 runner
# (hub ICU not reliably resolvable). So we stage the locally-built ICU into the
# expected path before the unittester runs.
#
# Target DuckDB is the v1.4.x LTS line, with later versions (v1.5.x) supported
# in a multi-version matrix the same way MobilityDB supports PostgreSQL 13-18 —
# so the staging path must NOT hardcode the version or platform. We derive both
# from the freshly-built duckdb binary (authoritative for whatever is being
# tested); DUCKDB_VERSION_TAG and the uname map are fallbacks only.
DUCKDB_VERSION_TAG := v1.4.4

define stage_icu
@if [ -f ./build/$(1)/extension/icu/icu.duckdb_extension ]; then \
duckdb_bin=./build/$(1)/duckdb; \
version_tag=$$( [ -x "$$duckdb_bin" ] && "$$duckdb_bin" --version 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1 ); \
platform=$$( [ -x "$$duckdb_bin" ] && echo 'PRAGMA platform;' | "$$duckdb_bin" -noheader -list 2>/dev/null | tr -d '[:space:]' ); \
[ -n "$$version_tag" ] || version_tag=$(DUCKDB_VERSION_TAG); \
if [ -z "$$platform" ]; then \
case "$$(uname -s)-$$(uname -m)" in \
Linux-x86_64) platform=linux_amd64 ;; \
Linux-aarch64) platform=linux_arm64 ;; \
Darwin-arm64) platform=osx_arm64 ;; \
Darwin-x86_64) platform=osx_amd64 ;; \
*) platform=$$(uname -m) ;; \
esac; \
fi; \
target=$$HOME/.duckdb/extensions/$$version_tag/$$platform; \
mkdir -p "$$target" && cp -f ./build/$(1)/extension/icu/icu.duckdb_extension "$$target/" && \
echo "Staged icu.duckdb_extension at $$target/ (duckdb $$version_tag / $$platform)"; \
fi
endef

test_release_internal:
$(call stage_icu,release)
./build/release/$(TEST_PATH) "$(PROJ_DIR)test/*"
test_debug_internal:
$(call stage_icu,debug)
./build/debug/$(TEST_PATH) "$(PROJ_DIR)test/*"
test_reldebug_internal:
$(call stage_icu,reldebug)
./build/reldebug/$(TEST_PATH) "$(PROJ_DIR)test/*"
25 changes: 20 additions & 5 deletions src/mobilityduck_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <mutex>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <string>

#if defined(_WIN32)
Expand Down Expand Up @@ -227,12 +228,26 @@ static void LoadInternal(ExtensionLoader &loader) {

// Single-timezone model: ensure DuckDB's session timezone matches the
// MEOS timezone so bare TIMESTAMPTZ display agrees with MEOS composite
// type strings. Auto-load ICU (without it, the test framework keeps
// session timezone at UTC) and set the TimeZone option to Brussels.
// type strings. This needs ICU for the named "Europe/Brussels" zone.
//
// If ICU cannot be auto-loaded (no on-disk copy AND no network egress:
// CI docker images, edge/musl deployments, offline installs), degrade
// gracefully to the session default (UTC) instead of failing the whole
// extension load. Tests that assert Brussels display stage ICU locally
// via the Makefile's stage_icu.
auto &db = loader.GetDatabaseInstance();
ExtensionHelper::AutoLoadExtension(db, "icu");
auto &config = DBConfig::GetConfig(db);
config.SetOptionByName("TimeZone", Value("Europe/Brussels"));
try {
ExtensionHelper::AutoLoadExtension(db, "icu");
auto &config = DBConfig::GetConfig(db);
config.SetOptionByName("TimeZone", Value("Europe/Brussels"));
} catch (const std::exception &e) {
// ICU unavailable: leave the session timezone at its default.
// Temporal-type text I/O is unaffected; only bare TIMESTAMPTZ display
// falls back to UTC.
fprintf(stderr,
"mobilityduck: ICU not available (%s); session timezone left "
"at default instead of Europe/Brussels.\n", e.what());
}


// Register scalar function: mobilityduck_openssl_version
Expand Down
Loading