Skip to content

Commit 2b89240

Browse files
maltesanderclaude
andcommitted
docs: a 3.x driver does not export the deprecated 2.x functions
The rule behind the last three commits, so the class does not come back. Appendix G's mapping fires only when the driver does not support the function, so an export removes the Driver Manager's implementation rather than adding one -- and the DM's is usually better informed, being derived from the driver's own SQLGetInfo answers. Also corrects the get_functions guidance, which said to list every exported function but not to list only those, and did not distinguish the 3.x bitmap from the 2.x array. They answer different questions: the bitmap says what core exports, the array says what a 2.x application can call, and the second is a superset because the DM maps the difference. An entry in the array naming a FunctionId absent from CORE_EXPORTED_FUNCTIONS is deliberate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 2412293 commit 2b89240

1 file changed

Lines changed: 40 additions & 5 deletions

File tree

AGENTS.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,46 @@ a driver to work on Windows — omitting any one can cause silent crashes,
564564
connecting, which is rare.
565565

566566
- **`get_functions`**: List **every** exported FFI function, not just
567-
query-related ones. The Windows DM uses the 3.x bitmap (`func_id=999`) to
568-
build its dispatch table. Missing entries (e.g. `SetEnvAttr`, `GetStmtAttr`,
569-
`BindCol`) cause NULL function pointer crashes. The 2.x array (`func_id=0`)
570-
also needs correct entries — `stackable-odbc-core` maps 3.x IDs to their deprecated
571-
2.x equivalents automatically, but only for IDs present in the list.
567+
query-related ones — and **nothing core does not export**. The Windows DM uses
568+
the 3.x bitmap (`func_id=999`) to build its dispatch table. Missing entries
569+
(e.g. `SetEnvAttr`, `GetStmtAttr`, `BindCol`) cause NULL function pointer
570+
crashes. Build the list from `CORE_EXPORTED_FUNCTIONS` and it cannot drift in
571+
either direction.
572+
573+
The 2.x array (`func_id=0`) is a **different question with a different
574+
answer**, and this is the part most easily got wrong. It asks "can an ODBC 2.x
575+
application call this", so it reports the deprecated functions as supported
576+
even though core exports none of them — the Driver Manager's mapping is what
577+
makes that true. `stackable-odbc-core` derives those entries from their 3.x
578+
counterparts automatically. An entry there naming a `FunctionId` absent from
579+
`CORE_EXPORTED_FUNCTIONS` is correct and deliberate, not an oversight; psqlODBC
580+
ships the same combination (`pfExists[SQL_API_SQLERROR] = TRUE` beside a
581+
commented-out `;;SQLError` in its `.def`).
582+
583+
#### A 3.x driver does not export the deprecated 2.x functions
584+
585+
Appendix G, "Mapping Deprecated Functions": a 3.x driver "does not have to
586+
implement the ODBC 2.x functions", and the mapping "is triggered when the driver
587+
is an ODBC 3.x driver and **the driver does not support the function that is
588+
being mapped**."
589+
590+
So exporting one does not *add* a capability — it **removes the Driver
591+
Manager's**, which is usually better informed. unixODBC's `SQLSetScrollOptions`
592+
mapping is 572 lines that check the requested concurrency against the driver's
593+
own `SQLGetInfo` answers before setting anything; core's export was a bare
594+
`SQL_ERROR` that replaced all of it. `SQLError`'s mapping routes to
595+
`SQLGetDiagRec`, which core implements properly; core's export answered
596+
`SQL_NO_DATA` and an ODBC 2.x application saw no diagnostics at all.
597+
598+
Core therefore exports none of Appendix G's seventeen, and psqlODBC comments out
599+
every one of them in its `.def`. **One exception:** `SQLFreeStmt` is an ODBC 3.x
600+
function in its own right, and the Windows DM passes its deprecated `SQL_DROP`
601+
option through rather than mapping it.
602+
603+
The generalisable trap: "we export it, so we should make it work" is backwards
604+
whenever the Driver Manager already maps the function. Check
605+
`CORE_UNEXPORTED_FUNCTIONS` — each entry records which 3.x function the DM maps
606+
it to — before implementing any deprecated entry point.
572607

573608
- **`get_type_info`**: Include **both** ANSI and Unicode type variants.
574609
pyodbc queries `SQLGetTypeInfo(SQL_VARCHAR=12)` and

0 commit comments

Comments
 (0)