Repository navigation
DuckDB lists nothing on a Mac that cannot reach the extension registry #2285
Description
Reported by a user on 0.66.0 (119) with DuckDB Driver 1.0.33, user-installed from the registry: no DuckDB connection works. .duckdb files fail, and so do Parquet and CSV files. Uninstalling and reinstalling the plugin changes nothing.
Cause
The macOS libduckdb.a is the bare DuckDB amalgamation and links no extensions:
nm -jU Libs/libduckdb_arm64.a | grep -ci corefunction -> 0
nm -jU Libs/ios/DuckDB.xcframework/ios-arm64/libduckdb-device.a | grep -ci corefunction -> 10
current_database() and current_schema() live in the core_functions extension, so DuckDB fetches it from extensions.duckdb.org the first time either is called. Measured against the shipped library with the extension directory pointed at an empty folder and autoload off, which is what an offline, firewalled or proxied Mac sees:
SELECT current_database() -> Binder Error: Referenced table "system" not found!
SELECT current_schema() -> Binder Error: Referenced table "system" not found!
duckdb_databases() -> works
duckdb_tables() -> works
information_schema.schemata -> works
Plugin 1.0.33 (#2136) rewrote every metadata query to filter on current_database(). DuckDBSchemaQueries.swift has 16 occurrences; the code it replaced had none. So on a machine that cannot reach the extension registry, 1.0.32 listed everything and 1.0.33 lists nothing: no databases, no schemas, no tables, no columns.
Two information_schema views are also built on core_functions and fail the same way, which is why primary keys and foreign keys were already broken offline before #2136:
information_schema.key_column_usage -> Extension Autoloading Error: ... core_functions
information_schema.referential_constraints -> Scalar Function with name "list_apply" is not in the catalog,
but it exists in the core_functions extension
The same missing extension takes ordinary SQL with it. Measured on the shipped library with no extensions available:
SELECT sum(x) / avg(x) -> Scalar Function with name "sum" is not in the catalog,
but it exists in the core_functions extension
round(), median(), string_agg(), date_trunc(), len(), [1,2,3] -> same
upper(), substr(), regexp_matches(), strftime(), LIKE, CAST, ORDER BY -> fine
Parquet and CSV need the parquet extension downloaded for the same reason: the file opens and its views are listed, but selecting from it fails.
Fix
Two parts.
- Take the plugin's metadata off the downloadable extension. The
duckdb_*()table functions are core, carrydatabase_name, and cover every query the driver makes. The catalog becomes a bound parameter resolved once at connect fromduckdb_settings(), which tracksUSEwithoutcurrent_database(). - Rebuild the macOS
libduckdbfrom source withcore_functions,json,parquetandiculinked statically, the way the iOS build already does. That is what restoressum()and Parquet reading on a restricted network.
Also found
docs/databases/duckdb.mdxsays the plugin bundles DuckDB 1.5.3.duckdb_library_version()reports 1.5.2, andscripts/build-duckdb.shcannot produce 1.5.3 becauseDUCKDB_SHA256is still the literalREPLACE_WITH_placeholder.duckdb_types()reportstype_categoryas NULL for a user-defined ENUM and names the kind inlogical_type, so the driver'stype_category = 'ENUM'filter matched nothing and ENUM columns never got their allowed values.
Activity