db2: add db2i:// scheme for DB2 for i (IBM i / AS-400) - #147
Conversation
The existing db2:// path hardcodes the DB2 LUW port (50000) and always appends PROTOCOL=TCPIP, so DB2 for i (IBM i / AS-400) can only be reached via the native-DSN passthrough. Add a db2i:// scheme that defaults the DRDA port to 446 and make PROTOCOL overridable via a ?PROTOCOL= query param. Same engine/driver as db2://; dialect layer is unchanged. Routed to the DB2 engine in the dispatcher. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Connector PR Review: db2: add db2i:// scheme for DB2 for i (IBM i / AS-400)Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review Summary Security Issues Correctness Issues Suggestions |
Linear: CE-1025
Add
db2i://scheme for DB2 for i (IBM i / AS-400)Summary
The existing
db2://engine is built for DB2 LUW:convertToDB2DSNhardcodes the LUWport (
50000) and always appendsPROTOCOL=TCPIP. That makes DB2 for i (IBM i / AS-400)reachable only through the native-DSN passthrough (
HOSTNAME=…;PORT=446;…), which is awkwardto express in connector configs.
This PR adds a first-class
db2i://scheme for DB2 for i. It reuses the exact same engine,driver (
go_ibm_db+ clidriver), and dialect layer — the only differences are:446(DB2 for i DRDA) instead of50000when the scheme isdb2i://.PROTOCOLis overridable via a?PROTOCOL=query parameter (still defaults toTCPIPwhen unset), by removing
PROTOCOLfrom the reserved-keyword set.db2://(LUW) behavior is unchanged.Motivation
Governing IBM i / AS-400 identity via
baton-sqlover DB2 for i (querying theQSYS2.*IBM i Services). The dialect layer already handles DB2 for i (bind
?,"quoting,author-written
FETCH FIRSTpaging); the LUW port/PROTOCOL defaults were the only blockers toa clean URL-form DSN.
Changes
pkg/database/db2/dsn.godb2i://in addition todb2://(native-DSN passthrough and scheme validation).db2→50000,db2i→446.PROTOCOLfromreservedDSNKeywords; inject theTCPIPdefault only when thecaller didn't supply a
?PROTOCOL=.pkg/database/database.gocase "db2", "db2i":to the DB2 engine.pkg/database/db2/dsn_test.godb2idefault-446, explicit port, andPROTOCOLoverride.docs/db2.mddb2i://scheme (default port 446 vs 50000) in the DSN Format section, andupdated the reserved-keyword note now that
PROTOCOLis overridable via?PROTOCOL=.Backward compatibility
Fully backward compatible.
db2://DSNs produce byte-identical output; existing tests passunchanged except the wrong-scheme error string (updated in this PR).
Testing
go test ./pkg/database/db2/passes, including the newdb2i/ PROTOCOL cases.make build-db2) and ran it against a DB2instance with stub
QSYS2views (mirroring IBM i 7.5USER_INFO_BASIC,GROUP_PROFILE_ENTRIES,AUTHORIZATION_LIST_USER_INFO, etc.). Two configs — accounts-onlyand full (users + groups + special authorities + authorization lists) — synced cleanly:
19 resources, 20 grants, all correct, including the space-delimited
SPECIAL_AUTHORITIEScolumn exploded into per-authority grants via
VALUES+ paddedLIKE.Notes / out of scope
customer-supplied DB2 Connect license (
db2consv_is.lic) — seedocs/db2.md. That's adeployment prerequisite, not addressed by this PR.
5770-XW1 license IBM i shops already hold) would be a separate, larger change — not in scope.
statusCEL mapping did not serializeonto the emitted resource status in local testing (resource status stayed null while the
trait carried the SDK default). Worth a follow-up look, unrelated to the DSN change.