mORMot2 DailyDaily read of upstream commits

DuckDB lands as a native 64-bit SQL provider

A native in-process DuckDB provider is the main change, followed by a full day of ABI, conversion and allocation refinements before build 2.4.17677. SQL proxy metadata also moves to a versioned, cross-architecture format, with fixes for foreign keys and mixed-version replies. Delphi and FPC teams adopting DuckDB, using remote SQL metadata or calling TSynNameValue JSON parsing directly should review this edition.

TL;DR

  • mormot.db.raw.duckdb and mormot.db.sql.duckdb add dynamic 64-bit DuckDB access, prepared statements, transactions, nested types, array binding and an Appender.
  • Official DuckDB binaries are 64-bit only; the Lazarus package now includes both units and tests skip cleanly when the local library is absent.
  • SQL proxy metadata protocol version 2 uses fixed integer layouts and JSON foreign keys across 32-bit and 64-bit peers.
  • SQLite GetIndexes now uses direct PRAGMA queries, avoiding fragile table-valued PRAGMA support in external providers.
  • TSynNameValue gains safe RawUtf8 JSON parsing; callers of the old mutable PUtf8Char overload must migrate to InitFromJsonBuffer.
  • Use build 2.4.17677, after the day's DuckDB conversion and allocation refinements and the proxy compatibility fix.

Upgrade advice

Land on build 2.4.17677. Do not stop on the first DuckDB merge or the intermediate proxy-metadata builds: the Lazarus package, C record layouts, temporal and UUID conversion, scalar allocation paths and response-version handling all changed later in the same batch. Recompile Delphi/FPC consumers, migrate mutable TSynNameValue.InitFromJson(PUtf8Char) calls, and test DuckDB plus mixed-bitness proxy metadata before production.

Build2.4.17647 → 2.4.17677
Commits27
Lines+6941 -702
Read7 min

26 of 26 entries · 27 commits upstream

Stories
# Entry Category Units
1 High SQL proxy foreign keys switch to portable JSON metadata The cGetForeignKeys server command now appends ForeignKeysJson. The client detects a zero-terminated JSON payload and calls TSynNameValue.InitFromJsonBuffer, while retaining the old system-specific binary decoder as a fallback. Fixes mormot.db.proxy+1 5e767fc3+38-4

db: fixed cGetForeignKeys DB proxy command

Impact

Foreign-key metadata can cross process and architecture boundaries without depending on an in-memory binary layout. SQL proxy users should update because the immediately preceding build exposed JSON storage but still sent the old format.

Arnaud Bouchez · 07:26 UTC · view the commit on GitHub →

2 High SQL proxy metadata decoding now follows the response protocol version mormot.db.proxy makes legacy servers return empty field and index payloads instead of serializing incompatible layouts, and the client branches on outheader.Magic rather than its request header when decoding fields, indexes and foreign keys. Fixes mormot.db.proxy cf83b2ce+14-17

db: refined mormot.db.proxy version/magic compatibility

Impact

Mixed-version 32-bit and 64-bit SQL proxy peers no longer choose a metadata decoder from the wrong message version. Legacy peers keep basic compatibility, but version-1 field and index metadata remains deliberately unsupported.

Arnaud Bouchez · 09:45 UTC · view the commit on GitHub →

3 High A native in-process DuckDB provider joins SynDB The new mormot.db.raw.duckdb dynamically binds the 64-bit DuckDB C API, while mormot.db.sql.duckdb implements TSqlDBDuckDBConnectionProperties, thread-safe connections, prepared statements, transactions, array binding, nested-type JSON conversion and TSqlDBDuckDBAppender. test.db.duckdb adds optional regression coverage. New features mormot.db.raw.duckdb+2 a5f9533a+2854-1

db: added DuckDB support via mormot.db.raw.duckdb and mormot.db.sql.duckdb

Impact

Delphi 7 through Delphi 13 and FPC 3.2+ can run analytical SQL in process when a compatible 64-bit DuckDB library is deployed. Official DuckDB binaries do not support Win32, and the database handle is shared while each thread connection gets its own duckdb_connection.

Worth a look

Treat the provider as new code: deploy the matching 64-bit DuckDB library, run test.db.duckdb on every target compiler and platform, and benchmark representative data before production use.

Public API

  • mormot.db.raw.duckdbadded — Adds dynamic DuckDB C API types, loader and conversion helpers.
  • TSqlDBDuckDBConnectionPropertiesadded — Adds the SynDB connection-properties provider for files or :memory:.
  • TSqlDBDuckDBConnectionadded — Adds per-thread DuckDB connections, transactions, scripts and interruption.
  • TSqlDBDuckDBStatementadded — Adds prepared statements, array binding and typed or JSON result access.
  • TSqlDBDuckDBAppenderadded — Adds high-throughput row loading through DuckDB's Appender API.

tf · 15:04 UTC · view the commit on GitHub →

4 Medium TSynNameValue separates safe strings from destructive JSON buffers mormot.core.search adds InitFromJson(const RawUtf8), which copies through TSynTempBuffer before parsing, and renames the in-place PUtf8Char overload to InitFromJsonBuffer. TSynTempBuffer.Init(RawByteString) now returns its buffer pointer. Breaking changes mormot.core.base+2 1f058393+28-14

core: new TSynNameValue.InitFromJsonBuffer() method

Impact

Most callers gain a safer non-destructive API. Source that passed a PUtf8Char to TSynNameValue.InitFromJson may no longer compile and must either call InitFromJsonBuffer explicitly or pass a RawUtf8 value.

Migration required

Search for InitFromJson calls whose argument type is PUtf8Char. Rename destructive calls to InitFromJsonBuffer(Json, false), or pass RawUtf8 to the new copying overload.

Public API

  • TSynNameValue.InitFromJson(const RawUtf8, boolean)added — Adds a copying, non-destructive overload.
  • TSynNameValue.InitFromJson(PUtf8Char, boolean)renamed — Renamed to InitFromJsonBuffer to make in-place mutation explicit.
  • TSynTempBuffer.Init(const RawByteString)signature-changed — Now returns PUtf8Char instead of being a procedure.

Arnaud Bouchez · 07:02 UTC · view the commit on GitHub →

5 Medium SQLite index metadata now uses direct PRAGMA queries TSqlDBConnectionProperties.GetIndexes receives a dedicated dSQLite path using PRAGMA index_list and PRAGMA index_info, with quoted identifiers and the same exception fallback as GetFields. The earlier table-valued SqlGetIndex query becomes a seldom-used fallback. Fixes mormot.db.sql 8cd3d20b+53-24

db: specific SQLite3 path for TSqlDBConnectionProperties.GetIndexes

Impact

SQLite-backed Delphi/FPC services get index names, uniqueness, origin and ordered key columns without depending on table-valued PRAGMA functions that some external providers handle poorly.

Arnaud Bouchez · 09:39 UTC · view the commit on GitHub →

6 Medium SQL variants transfer string ownership without extra copies TSqlDBStatement.ColumnToVariant now transfers temporary ftBlob and ForceUtf8 buffers directly into the destination variant, preserves varSynUnicode as the default text representation and explicitly uses varString for nil UTF-8 values to avoid an FPC invalid-variant error. Fixes mormot.db.core+1 9922dc1b+25-17

db: enhanced variant values support

Impact

FPC callers reading nullable UTF-8 SQL columns should no longer hit the invalid variant type case, and Delphi/FPC blob or forced-UTF8 reads allocate less. Text remains Unicode unless ForceUtf8 is true.

Worth a look

Retest nullable text, blobs and ColumnVariant(..., ForceUtf8=true) on every compiler/backend combination you ship.

Arnaud Bouchez · 09:35 UTC · view the commit on GitHub →

7 Medium Connection properties expose foreign keys as JSON TSqlDBConnectionProperties adds ForeignKeysJson. The getter lazily initializes and loads fForeignKeys before returning TSynNameValue.AsJson; the setter rebuilds the cache through InitFromJson. New features mormot.db.sql 2b91c9f5+24-3

db: new TSqlDBConnectionProperties.ForeignKeysJson property

Impact

Delphi/FPC applications and proxies can persist foreign-key metadata in a portable textual form instead of ForeignKeysData's system-specific binary blob. Existing ForeignKeysData callers remain supported.

Public API

  • TSqlDBConnectionProperties.ForeignKeysJsonadded — Reads or writes cached foreign-key metadata as JSON.

Arnaud Bouchez · 07:03 UTC · view the commit on GitHub →

8 Medium DuckDB row conversion avoids most temporary strings mormot.db.sql.duckdb adds DuckDBVectorValueToTextBuf for stack-buffer conversion of scalar values, caches type and validity data, writes JSON scalars directly, reuses one buffer for array binding and gives TSqlDBDuckDBAppender a pointer-and-length AddText overload. DuckDBTypeToField is no longer exported. Performance mormot.db.sql.duckdb 6d39910a+288-164

db: lots of DuckDB client side optimizations

Impact

DuckDB-backed Delphi and FPC services should allocate less while reading, exporting JSON, binding arrays and appending text. Code that used the provisional DuckDBTypeToField helper must stop calling it.

Worth a look

Benchmark representative queries and remove any direct DuckDBTypeToField call before updating.

Public API

  • DuckDBVectorValueToTextBufadded — Adds stack-buffer conversion for simple DuckDB vector values.
  • TSqlDBDuckDBAppender.AddText(PUtf8Char, PtrInt)added — Adds a no-copy pointer-and-length text overload.
  • DuckDBTypeToFieldremoved — The helper is now internal to mormot.db.sql.duckdb.

Arnaud Bouchez · 15:11 UTC · view the commit on GitHub →

9 Medium DuckDB C records avoid packed access penalties on ARM mormot.db.raw.duckdb removes packed from TDuckDBStringT, TDuckDBHugeInt, TDuckDBInterval and TDuckDBListEntry while preserving their 16-byte layouts. TDuckDBStringT now stores three cardinal words and its accessors use explicit pointer arithmetic. Performance mormot.db.raw.duckdb 2d1593c5+88-89

db: redefined DubkDB struct definitions

Impact

ARM32 and AArch64 Delphi/FPC code should avoid slower unaligned packed-field access while retaining the DuckDB C ABI. Applications that inspect TDuckDBStringT fields directly must use the new Data layout or the accessors.

Worth a look

Recompile all code using the DuckDB units; replace direct TDuckDBStringT variant-field access with DuckStringPtr.

Public API

  • TDuckDBStringTsignature-changed — Prefix, Ptr and Inlined variants are replaced by Data: array[0..2] of cardinal.
  • TDuckDBHugeInt/TDuckDBInterval/TDuckDBListEntrysignature-changed — Records are no longer declared packed, while tested sizes remain 16 bytes.

Arnaud Bouchez · 12:01 UTC · view the commit on GitHub →

10 Medium DuckDB 128-bit decimals format directly into a bounded buffer mormot.db.raw.duckdb adds DuckHugeIntToTextBuf with signed, unsigned and scale handling in TTemp47, and extends DuckHugeIntToText with an optional Scale parameter. mormot.core.base exposes TTemp47 and BSON reuses it for TDecimal128Str. Performance mormot.core.base+2 31fadd70+70-18

db: rewritten DuckDB HugeInt to text conversion

Impact

DuckDB HUGEINT, UHUGEINT and DECIMAL conversion avoids intermediate heap strings and preserves scaled output. The added optional parameter is source-compatible with existing calls.

Public API

  • TTemp47added — Adds a 48-byte temporary character buffer type.
  • DuckHugeIntToTextBufadded — Formats signed, unsigned or scaled 128-bit values into TTemp47.
  • DuckHugeIntToTextsignature-changed — Adds optional Scale: integer = 0.

Arnaud Bouchez · 12:31 UTC · view the commit on GitHub →

11 Medium DuckDB temporal values now use mORMot's system-time conversions mormot.db.raw.duckdb replaces custom calendar arithmetic with TSynSystemTime, adds floor division for negative timestamps, preserves microseconds in text, rounds TDateTime to the nearest millisecond and rejects dates outside supported year ranges. Compiler & platform mormot.db.raw.duckdb 63abf241+97-80

db: use TSynSystemTime for DuckDB date/time process

Impact

DuckDB dates from year 0000-03-01 through 9999 can be rendered as text, while TDateTime conversion accepts years 1 through 9999. Backends using negative timestamps should retest round trips and millisecond rounding.

Worth a look

Test pre-1970 timestamps, sub-millisecond values and boundary dates if those values can reach your DuckDB columns.

Arnaud Bouchez · 12:02 UTC · view the commit on GitHub →

12 Medium SQL proxy protocol version 2 preserves a legacy fallback mormot.db.proxy separates the encryption marker from protocol magic, introduces MAGIC_METADATA version 2 and accepts versions 1 and 2. Version 2 transports integer-layout fields and JSON foreign keys; version 1 retains binary foreign keys while fields and indexes are rejected as unsupported. Compiler & platform mormot.db.proxy 4b8c5202+49-22

db: maintain some mormot.db.proxy backward compatibility

Impact

Current peers can exchange metadata consistently across 32-bit and 64-bit systems. Mixed-version deployments retain limited legacy operation, so metadata calls need explicit testing during a rolling upgrade.

Worth a look

Upgrade server and client together when possible; do not rely on GetFields or GetIndexes against a version-1 peer.

Arnaud Bouchez · 08:05 UTC · view the commit on GitHub →

13 Medium Lazarus packages now include both DuckDB units packages/lazarus/mormot2.lpk and mormot2.pas register mormot.db.raw.duckdb and mormot.db.sql.duckdb, increasing the package unit count from 125 to 127. Compiler & platform mormot.db.raw.duckdb+1 345840ea+12-4

db: properly add DuckDB units to the Lazarus package

Impact

Lazarus/FPC users can import the new DuckDB provider through the standard mormot2 package. Builds before this commit contained the source files but did not expose them through that package.

Worth a look

Regenerate or reopen the Lazarus package before compiling code that uses the DuckDB units.

Arnaud Bouchez · 10:24 UTC · view the commit on GitHub →

14 Medium DuckDB date, interval and UUID conversion moves to stack buffers mormot.db.raw.duckdb removes DuckApplyScale, emits microseconds and interval parts through short stack strings, uses MicroSecsPerMilliSec for timestamp conversion and changes DuckUuidToGuid to pointer parameters with byte-wise field reconstruction. Under the hood mormot.db.raw.duckdb 1080dd73+62-76

db: rewritten date/time and UUID DuckDB logic

Impact

Normal TSqlDBDuckDBStatement callers keep the same high-level API. Direct users of the low-level conversion helpers must recompile and adapt the removed or changed declarations, then retest dates, intervals and UUIDs.

Worth a look

Recompile code that imports mormot.db.raw.duckdb directly and test mixed date-time intervals plus UUID round trips.

Public API

  • DuckApplyScaleremoved — Scaling is performed directly by DuckHugeIntToTextBuf.
  • DuckUuidToGuidsignature-changed — Parameters changed from const/var values to PDuckDBHugeInt and PGuid.

Arnaud Bouchez · 14:09 UTC · view the commit on GitHub →

15 Low DuckDB UUID values gain direct TGuid conversion mormot.db.raw.duckdb adds DuckUuidToGuid and DuckUuidToTextBuf. They undo DuckDB's high-bit flip, rebuild native TGuid fields and format lowercase UUID text without allocating a temporary hexadecimal string. New features mormot.db.raw.duckdb ae7ce1bc+41-15

db: enhanced DuckDB UUID support

Impact

DuckDB UUID columns can be converted consistently to mORMot text or TGuid values. Existing backends not using the new DuckDB provider are unaffected.

Public API

  • DuckUuidToTextBufadded — Formats a DuckDB UUID into TTemp47.
  • DuckUuidToGuidadded — Converts DuckDB's HUGEINT representation to TGuid.

Arnaud Bouchez · 13:28 UTC · view the commit on GitHub →

16 Low SQLite index discovery first gains a table-valued PRAGMA query Despite the commit subject, the diff changes TSqlDBConnectionProperties.SqlGetIndex: dSQLite receives a query built from pragma_index_list and pragma_index_xinfo, including uniqueness, origin and ordered key columns. New features mormot.db.sql 114b0724+22-2

db: preliminary TSqlDBConnectionProperties.GetSqlFields support

Impact

This intermediate implementation improves SQLite index metadata but is replaced later in the same edition by direct PRAGMA calls in GetIndexes for broader provider compatibility.

Arnaud Bouchez · 08:07 UTC · view the commit on GitHub →

17 Low Connection properties can execute formatted SQL directly mormot.db.sql adds TSqlDBConnectionProperties.ExecuteFmt, which applies FormatUtf8 and executes the result without bound parameters. Execute also skips Bind when its open-array parameter list is empty. New features mormot.db.sql 4b4c0a25+17-3

db: new TSqlDBConnectionProperties.ExecuteFmt() method

Impact

Delphi and FPC code gains a concise helper for trusted formatted SQL. Values from untrusted input should still be bound or quoted explicitly because ExecuteFmt performs textual formatting.

Public API

  • TSqlDBConnectionProperties.ExecuteFmtadded — Formats SQL with FormatUtf8 and returns ISqlDBRows.

Arnaud Bouchez · 09:36 UTC · view the commit on GitHub →

18 Low A test case can now skip all published methods before setup mormot.core.test adds virtual TSynTestCase.Prepare, called immediately after construction and before iterating published tests. Returning false bypasses the entire test class; the default implementation returns true. New features mormot.core.test 6cd37aff+11-2

core: new TSynTestCase.Prepare virtual method

Impact

Custom Delphi/FPC test suites can cheaply skip a class when an optional dependency is unavailable. Existing TSynTestCase descendants retain their prior behavior.

Public API

  • TSynTestCase.Prepareadded — Virtual hook returns whether the whole test case should run.

Arnaud Bouchez · 10:22 UTC · view the commit on GitHub →

19 Low DuckDB 128-bit integer formatting divides nine digits at a time DuckHugeIntToText replaces repeated base-10 division with DivU128By1B, extracting groups of nine decimal digits before formatting them into the destination buffer. Performance mormot.db.raw.duckdb ff06cee0+47-18

db: much faster DuckHugeIntToText() function

Impact

HUGEINT and UHUGEINT text conversion becomes faster without changing output or the public signature at this revision. Other database providers are unaffected.

Arnaud Bouchez · 12:03 UTC · view the commit on GitHub →

20 Low DuckDB text bindings now declare UTF-8 pointers explicitly mormot.db.raw.duckdb changes text-bearing C callbacks and DuckStringPtr from PAnsiChar to PUtf8Char, while conversion errors now raise ESqlDBDuckDB with contextual values. mormot.db.sql.duckdb follows the same pointer type consistently. Compiler & platform mormot.db.raw.duckdb+1 0bed0d4d+46-46

db: fixed DuckDB type usage

Impact

The binary ABI remains pointer-compatible, but Delphi and FPC source that directly references the provisional low-level declarations may require a cast or recompilation. High-level provider use is unchanged.

Public API

  • DuckStringPtrsignature-changed — Return type changed from PAnsiChar to PUtf8Char.
  • TDuckDBLib text callbackssignature-changed — Text parameters and results now use PUtf8Char.

Arnaud Bouchez · 12:55 UTC · view the commit on GitHub →

21 Low SQL text assembly avoids avoidable RawUtf8 temporaries mormot.db.sql and mormot.db.proxy switch integer, floating-point, quoting, schema-prefix and array-binding paths to destination-buffer overloads such as Int64ToUtf8, DoubleToStr, Join and QuotedStr. Under the hood mormot.db.proxy+1 1eb18cfc+35-34

db: RawUtf8 usage cleanup for both FPC and Delphi

Impact

Application SQL and results should remain identical, with fewer temporary strings during parameter binding and proxy value conversion on both Delphi and FPC.

Arnaud Bouchez · 09:38 UTC · view the commit on GitHub →

22 Low DuckDB tests now report conversion and bulk-operation timings test.db.duckdb adds boundary cases for DuckHugeIntToTextBuf and DuckUuidToTextBuf, then uses TPrecisionTimer and NotifyTestSpeed around prepared inserts, grouping, full reads, array binding and TSqlDBDuckDBAppender loading. Tests test.db.duckdb 587ce167+87-17

test: let DuckDB coverage give some numbers

Impact

Application code is unchanged. Test runs with a local 64-bit DuckDB library now expose useful throughput numbers while retaining correctness checks.

Arnaud Bouchez · 15:12 UTC · view the commit on GitHub →

23 Low Remote database tests cover fields, indexes and reusable statements test.orm.extdb compares remote and local TSqlDBColumnDefine arrays, checks JSON field metadata, table and index definitions, and retains repeated execution coverage for one prepared proxy statement. Tests test.orm.extdb 9c267e23+37-13

tests: enhanced Remote DB coverage

Impact

Application behavior is unchanged. Regressions in cross-process metadata transport and statement reuse should now be caught by the main external-database tests.

Arnaud Bouchez · 09:40 UTC · view the commit on GitHub →

24 Low DuckDB failures stay covered without polluting test logs test.db.duckdb suppresses expected exception logging while probing the library, duplicate-key rollback and missing-table errors. It also checks all DuckDB record sizes before database-dependent tests run. Tests mormot.db.sql.duckdb+1 f5de6dc8+28-15

test: refined DuckDB coverage - no exception logged

Impact

Only test output changes. ABI layout mistakes in the new DuckDB records should now fail early even when no DuckDB library is available.

Arnaud Bouchez · 12:03 UTC · view the commit on GitHub →

25 Low DuckDB tests skip unsupported or misplaced libraries cleanly test.db.duckdb makes TTestDuckDB.Prepare return false outside CPU64 and requires DuckDBLibraryName beside the executable before attempting to load it. A failed load is reported as a skipped test suite. Tests test.db.duckdb 04c52594+10-3

test: cleaner DuckDB library detection

Impact

CI and local 32-bit runs no longer log expected DuckDB loading failures. Production loading rules for the provider itself are unchanged.

Arnaud Bouchez · 12:45 UTC · view the commit on GitHub →

26 Low The dependency guide lists the new DuckDB units src/FOLDER-DEPENDENCIES.md adds mormot.db.raw.duckdb under raw database APIs and mormot.db.sql.duckdb under SQL database connectors. Docs cfbbf36e+2-0

docs: listed the DuckDB units in FOLDER-DEPENDENCIES

Impact

No application code changes. Developers can locate the DuckDB layers in the documented folder hierarchy.

tf · 15:04 UTC · view the commit on GitHub →

Upstream activity commits per day · last 60 days
Commits1007
Active days49/60
Busiest2026-09-30
Peak60
2026-09-30: 60 commits2026-10-01: 26 commits2026-10-02: 30 commits2026-10-03: 32 commits2026-10-04: 15 commits2026-10-05: 1 commit2026-10-06: 26 commits2026-10-07: 37 commits2026-10-08: 27 commits2026-10-09: 35 commits2026-10-10: 12 commits2026-10-11: 2 commits2026-10-12: 40 commits2026-10-13: 31 commits2026-10-14: 23 commits2026-10-15: 16 commits2026-10-16: 27 commits2026-10-17: 0 commits2026-10-18: 0 commits2026-10-19: 0 commits2026-10-20: 0 commits2026-10-21: 0 commits2026-10-22: 3 commits2026-10-23: 6 commits2026-10-24: 29 commits2026-10-25: 7 commits2026-10-26: 25 commits2026-10-27: 4 commits2026-10-28: 8 commits2026-10-29: 17 commits2026-10-30: 20 commits2026-10-31: 0 commits2026-11-01: 0 commits2026-11-02: 16 commits2026-11-03: 32 commits2026-11-04: 15 commits2026-11-05: 32 commits2026-11-06: 26 commits2026-11-07: 19 commits2026-11-08: 2 commits2026-11-09: 29 commits2026-11-10: 17 commits2026-11-11: 8 commits2026-11-12: 38 commits2026-11-13: 39 commits2026-11-14: 9 commits2026-11-15: 6 commits2026-11-16: 21 commits2026-11-17: 30 commits2026-11-18: 37 commits2026-11-19: 28 commits2026-11-20: 31 commits2026-11-21: 0 commits2026-11-22: 0 commits2026-11-23: 1 commit2026-11-24: 6 commits2026-11-25: 3 commits2026-11-26: 3 commits2026-11-27: 0 commits2026-11-28: 0 commits
2026-09-302026-11-28