feat(db): add IBM Db2 LUW provider (#786) - #787
Open
nycjay wants to merge 1 commit into
Open
Conversation
Connect to Db2 LUW over DRDA with the native ibm_db driver. The provider extends SQLBaseProvider and overrides only prepareQuery(): Db2's SQL is Oracle-shaped (double-quoted identifiers, FETCH FIRST / OFFSET ... FETCH NEXT paging), so identifier escaping is inherited unchanged. Schema reads the SYSCAT.* catalog views scoped to CURRENT SCHEMA. Per-table maintenance maps analyze to RUNSTATS and optimize to REORG through SYSPROC.ADMIN_CMD; Db2 has no whole-database form, so there is no global maintenance card. Bound ? parameters are forwarded to the driver so inline row edit works (UPDATE ... WHERE pk); verified end-to-end against Db2 v11.5.9.0. Capabilities are conservative and honest: supportsExplain false (Db2 EXPLAIN populates explain tables rather than returning a single-statement plan, same as MSSQL libredb#126), supportsTransactions false (no held-session transaction wired, so the toolbar and SANDBOX stay hidden), and monitoring panels return neutral empties instead of fabricated zeros. All documented as intentional follow-ups. Includes the provider triad (db2.ts, docs/providers/db2.md, and the integration test at 100% line coverage), the registration surfaces, a db2 service in database-compose.yml, and the external-engine count copy. Closes libredb#786
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds IBM Db2 LUW as a database provider (type-id db2), over the DRDA protocol with the native ibm_db driver. It extends SQLBaseProvider and overrides only prepareQuery(), because Db2's SQL is Oracle-shaped (double-quoted identifiers, FETCH FIRST / OFFSET ... FETCH NEXT paging).
Type of Change
Related Issue
Closes #786
Changes Made
Deliberate follow-ups, not gaps: supportsExplain: false (Db2 EXPLAIN populates explain tables rather than returning a single-statement plan, same as MSSQL #126), supportsTransactions: false (no held-session transaction wired, so the toolbar and SANDBOX stay hidden), monitoring panels return neutral empties instead of fabricated zeros, and columnTypes is omitted because the high-level query() exposes no declared type.
Testing
Verified end-to-end against a live Db2 v11.5.9.0 server, driving the app with Playwright and the API: connect and schema tree (columns, PK/nullable, FKs, indexes, untrimmed names); paging (FETCH FIRST, then OFFSET ... FETCH NEXT, an already-bounded query left alone); CRUD with read-your-writes; value fidelity (BIGINT → lossless string, BLOB → Buffer, CLOB/DECFLOAT/XML, CHAR(n) space-padded as expected); error paths (SQL0204N, SQL0104N throw rather than returning zero rows); per-table RUNSTATS/REORG plus rejection of a global or unsupported op; capability-gated UI (no Explain button or tab, no transaction toolbar/SANDBOX, Create Table present, inline-edit present); and an inline row edit persisting through UPDATE ... WHERE pk. ibm_db loads under both Bun and Node.
Two commands I could not run locally (per the "CI is the merge gate" note in CONTRIBUTING):
Test Environment
Screenshots (if applicable)
Checklist
bun run test:coverageandbun run coverage:check)src/lib/db/providers/, I updated the matchingdocs/providers/documentation andtests/integration/db/tests in the same PR (provider triad)Additional Notes
This PR adds a runtime dependency (ibm_db), unlike the recent HTTP-only providers. Rationale is under Changes Made.