Skip to content

v2026.09.04 — scans that can be run twice, and a backend with no known gaps

Choose a tag to compare

@jrosskopf jrosskopf released this 04 Sep 09:41
· 114 commits to master since this release

sap_read_table gains row-range partitioning, and the three extensions gain one tuning
vocabulary. The reason this is one release rather than two is the second half of the list:
four separate silent wrong-results defects, all in released erpl, all returning data
rather than failing.

The sharpest is that a re-scanned sap_read_table returned nothing at all — a prepared
statement, a nested-loop join or an un-materialised CTE referenced twice would silently
answer zero rows on the second scan. If you use erpl from a prepared statement or in a
join, upgrade.

The erpl-proto backend also passes every suite with no recorded gaps for the first time.

Added

  • [rfc] sap_read_table can now split a scan by rows. Parallelism was per
    column — one concurrent RFC_READ_TABLE call per projected column — so a narrow
    extract got none at all, and raising threads did nothing. partitions hands each
    worker a row window read with ROWSKIPS/ROWCOUNT. Measured on a 164,664-row
    single-column extract: 2.23s unpartitioned, 0.83s at eight partitions (2.7x),
    with the knee visible at eight. Opt-in, because partitioned workers finish in
    whatever order they finish while an unpartitioned scan returns rows sorted.

  • [rfc] erpl_rfc_partitions and erpl_rfc_partition_window_rows, plus a
    partitions named parameter.

  • [rfc] One tuning vocabulary across the extensions. Paging and parallelism were
    spelled differently everywhere: RFC had THREADS plus erpl_rfc_read_table_batch_budget,
    ODP had threads and no settings at all, BICS had neither. threads /
    erpl_rfc_max_threads and fetch_size / erpl_rfc_fetch_size now mean the same thing
    wherever they appear, and fetch_size is settable per query rather than per session.
    No breaking renames — erpl_rfc_read_table_batch_budget still works and writes the same
    value.

  • [odp] erpl_odp_fetch_size and erpl_odp_max_threads, ODP's first settings.
    I_MAXPACKAGESIZE was compiled in at 2 MiB and reachable from nowhere, so round-trips
    could not be traded against per-packet memory.

  • [bics] sap_bics_begin honours its rows, columns and filters parameters.
    They were declared and never read — accepted with no error and no effect. Building a
    query this way also costs three fewer full session round-trips.

  • [rfc] sap_rfc_live_connections(), sap_rfc_connections_opened() and
    sap_rfc_connections_closed() report how many SAP RFC connections erpl has opened,
    closed and still holds. Between queries the live count should be 0 — a non-zero value
    means SAP sessions are still reserved, which client-side timing cannot reveal.

Fixed

  • [odp] PRAGMA sap_odp_close_delta_cursor never closed anything. It matched the
    cursor on (SUBSCRIBER_PROC, QUEUENAME) and took the first row, but SAP retains every
    closed cursor as history, so that pair routinely has a dozen rows — the open one was
    found at position 7 behind six closed rows from previous days. The pragma reported
    'CLOSED' without ever calling RODPS_REPL_ODP_CLOSE, so delta cursors accumulated
    server-side while cleanup looked like it was working.

    Two more defects sat in the branch that made unreachable: every exception was reported
    as 'CLOSED', and the call's ET_RETURN was never read — RODPS_REPL_ODP_CLOSE returns
    RFC_OK even when it refuses, so a rejected close was indistinguishable from a
    successful one. Behaviour change: two new results, neither of which raises —
    'REFUSED: <SAP message>' when SAP rejects the close (typically
    ILLEGAL_REQ_STATE_FOR_CONFIRM, meaning the request was left mid-fetch and only
    sap_odp_drop will clear it) and 'STILL_OPEN' when the cursor survives a call that
    reported no error.

  • [odp] sap_odp_read_full crashed at threads := 8 on a source with fewer packages
    than workers — a null local state, dereferenced unconditionally.

  • [bics] The result-size refusal message stated what a query would really cost. BICS
    memory scales with result rows, not data cells, so the cell-derived figure it used
    to quote understated a 46,755-row result by 19x — and suggested raising a setting that
    would have let the query through and then run the process out of memory.

  • [rfc] sap_rfc_invoke failed on any module whose result parameters are all
    tables.
    RFC_READ_TABLE is the canonical case — its results are DATA, FIELDS
    and OPTIONS, with no scalar export — and invoking it raised
    Unimplemented type for cast (STRUCT(WA VARCHAR) -> STRUCT(WA VARCHAR)[]).

    The result was treated as pivoted whenever every value happened to be list-shaped,
    so rows were unnested into columns still declared LIST(STRUCT). Detection now also
    requires each element type to match its declared column type, which distinguishes
    genuinely pivoted (path-selected) data from a bare invoke. Selecting a table through
    path := still pivots to the row's fields, as before.

  • [rfc] MAX_ROWS combined with partitions hung. The unpartitioned path trims
    ROWCOUNT to land exactly on the limit, which a partitioned window cannot do because
    ROWCOUNT must stay batch-aligned; it over-fetches the final batch, and the clip then
    left the read spinning with rows it would never emit.

  • [rfc] The runtime RFC_READ_TABLE fallback reassigned a std::string on the
    bind data from execute time. Column-parallel reads already made that reachable from
    two tasks at once; it is now serialised.

  • [rfc] fetch_size and partitions did nothing to the batch size of a
    single-column scan.
    MaxBatchSizeForColumnCount returned the full 32768-row cap
    whenever a scan projected one column, discarding the budget that
    ResolveEffectiveMaxBatchSize had just divided across the partition workers — so every
    worker asked SAP for ROWCOUNT=32768 however erpl_rfc_fetch_size and partitions
    were set. The exemption was deliberate, on the reasoning that a narrow scan is already
    under any sane budget; that reasoning ignored the division, and a narrow scan is
    precisely what partitioning exists for.

    Measured on a 300,000-row single-column read at partitions = 8: peak RSS 405 MB →
    307 MB (−24%)
    with no loss of throughput (2.17s → 2.07s). The budget now binds for
    every column count; only a zero budget or a scan with no projected column bypasses it.

  • [rfc] A partitioned scan never returned its allocator arenas to the OS. The serial
    path calls malloc_trim(0) when the scan finishes, but each partition worker retires on
    a different code path that did not, so every worker thread's glibc arena kept its
    high-water mark — which is what getrusage reports.

  • [rfc] A partitioned scan past the ROWSKIPS ceiling returned a truncated result
    instead of refusing.
    The row-window scheduler signalled the ABAP INT4 limit by
    returning "no more windows", which is the same answer it gives at the end of a table —
    and a worker retires on an empty chunk, which DuckDB reads as end-of-scan. A scan beyond
    2,147,483,647 rows therefore produced a silently short answer, while API_REFERENCE
    states that erpl refuses rather than wrapping. It now raises, naming the limit.

    The same guard was off by one and refused the last legal window (start
    2,147,450,880 at a 32768-row window). Both are covered by new boundary tests.

  • [rfc] The RFC_READ_TABLE fallback could retry without limit. After the runtime
    fallback had switched functions, the selection call returns a cached success, and the
    retry branch neither counted the attempt nor slept — so a second TABLE_WITHOUT_DATA
    from the fallback function became a tight loop against the SAP system, once per
    partition worker. It now retries only when the selected function actually changed, and
    otherwise reports the original error.

  • [rfc] A re-scanned sap_read_table silently returned nothing. The column state
    machines lived in bind data, which DuckDB reuses across executions of one bound plan,
    so the second scan resumed from an exhausted cursor:

    PREPARE q AS SELECT count(*) FROM sap_read_table('SFLIGHT');
    EXECUTE q;   -- 94
    EXECUTE q;   --  0   <- no error

    Any re-scanned plan hit it: a prepared statement, a nested-loop join, an
    un-materialised CTE referenced twice. Serial scans now build their machines in the
    global state, which DuckDB rebuilds per execution — the pattern the partitioned path
    already used, which is why PARTITIONS was never affected.

    The same defect was present in sap_show_tables, sap_odp_show_subscriptions and the
    internal table lister behind ATTACH; all three are fixed.

  • [rfc] The persistent-connection budget was spent permanently.
    erpl_rfc_max_persistent_connections was a monotonic counter on bind data that never
    released a slot, so a second execution of a bound plan began with the budget already
    exhausted and every scan fell back to per-batch open/close. Slots are now leased:
    released when the connection is dropped, reset per execution.

  • [rfc] A long scan could follow a secret replaced underneath it. The DuckDB
    secret was re-resolved on every connection open, so replacing it mid-query could send
    later windows of the same scan to a different SAP system, with no error. Credentials are
    now resolved once per execution.

  • [rfc] Setting a trace option while tracing was enabled deadlocked the process.
    erpl_trace_level, erpl_trace_output and the other setters logged their own change
    while holding the tracer mutex, which the writer re-locks. The sequence documented for
    diagnosing SAP communication was itself the trigger; it presents as a hung query.

Changed

  • [all] The erpl-proto backend is pinned to v2026.9.2.1, and its known-failure
    list is now empty.
    The previous pin carried a table-delta padding gap
    (sap_rfc_struct_layout), and the releases that fixed it regressed BICS from 45/45 to
    23/45 on a nested-TTYP basXML defect. Both are now fixed upstream, so every suite
    passes on the proto backend with no recorded gaps for the first time: RFC 34/34,
    ODP 25/25, BICS 45/45.

Build

  • [all] The erpl-proto backend is pinned to the v2026.8.29.1 release rather than
    an untagged commit.