From 93cc2de56d88f773a28c15f0cfca37544d6320e9 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Wed, 29 Jul 2026 09:29:09 +0200 Subject: [PATCH] Skip MEOS timezone init when no IANA timezone database is present meos_initialize_timezone loads /usr/share/zoneinfo through MEOS's pgtz code, which fails on opendir when the zoneinfo database is absent (Alpine/musl images, minimal containers, edge devices), erroring the whole extension load. Guard the call on the presence of /usr/share/zoneinfo so the extension loads against UTC instead of failing at startup. --- src/mobilityduck_extension.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mobilityduck_extension.cpp b/src/mobilityduck_extension.cpp index d2896139..7c24fae8 100644 --- a/src/mobilityduck_extension.cpp +++ b/src/mobilityduck_extension.cpp @@ -228,8 +228,17 @@ static void LoadInternal(ExtensionLoader &loader) { /* Set the MEOS timezone to Europe/Brussels so that all temporal-type * text I/O uses a consistent, named timezone on every platform. * Brussels is a non-UTC zone that surfaces bugs hidden by UTC (e.g. - * off-by-one-hour errors in timestamp handling). */ - meos_initialize_timezone("Europe/Brussels"); + * off-by-one-hour errors in timestamp handling). + * + * Skip the timezone init when no IANA timezone database is present on + * the system (Alpine/musl images, minimal containers, edge devices). + * Without /usr/share/zoneinfo, MEOS's pgtz code fails on opendir; + * skipping the timezone init lets the extension load against UTC + * instead of erroring at startup. */ + struct stat tz_st {}; + if (stat("/usr/share/zoneinfo", &tz_st) == 0 && (tz_st.st_mode & S_IFDIR)) { + meos_initialize_timezone("Europe/Brussels"); + } meos_initialize_error_handler(&MobilityduckMeosErrorHandler); });