Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ option(OPENADS_WITH_TLS "Enable TLS transport (vendors mbedtls 3.6 LTS via Fetch
# and nlohmann/json (MIT) at configure time via FetchContent.
option(OPENADS_WITH_HTTP "Enable embedded HTTP web console (Studio) in openads_serverd / ace64.dll" ON)

# Optional ODBC table driver. Talks to any data source through the
# system ODBC driver manager (odbc32 on Windows, unixODBC on Linux);
# the headers and import library ship with the platform SDK, so no
# external dependency is downloaded. OFF by default.
option(OPENADS_WITH_ODBC "Enable ODBC-backed table driver (system ODBC driver manager)" OFF)

# Pull in mbedtls FIRST so our strict /WX -Werror flags don't bleed
# into the upstream sources (C4200 zero-sized arrays etc). Each
# OpenADS target adds the strict flags target-locally below via
Expand Down
37 changes: 37 additions & 0 deletions docs/openads-plus/ODBC_LIVE_TARGETS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ODBC backend — verified live targets

The ODBC Plus backend (`odbc://`) is data-source agnostic: it reaches any
engine through its ODBC driver using only standard catalog calls
(`SQLPrimaryKeys` / `SQLStatistics` / `SQLColumns`) and portable SQL. No
per-dialect code lives in the backend.

The same ABI test cases (`--test-case=*odbc*`) run against any target by
pointing `OPENADS_TEST_ODBC_CONNSTR` at it. Two reproducible harnesses ship:

| Target | Harness | Notes |
|--------|---------|-------|
| Microsoft Access (`.accdb`) | `tools/scripts/run_odbc_tests.ps1` | Zero-server; ADOX fixture, available out of the box on Windows. |
| SQL Server / PostgreSQL / MariaDB / Firebird | `tools/scripts/run_odbc_tests_live.ps1 -ConnStr '...'` | Connection-string driven; seeds the `clientes` fixture over ODBC. |

## Verified

- **Microsoft Access** — 5 cases / 83 assertions (CI fixture).
- **SQL Server 2022** — 5 cases / 83 assertions, via the *ODBC Driver 18 for
SQL Server*. The unmodified backend (same binary that passes against
Access) navigates a `dbo.clientes` table by primary key with no
dialect-specific changes: `SQLPrimaryKeys` is honoured, the identifier
quote character is discovered via `SQLGetInfo`, and numeric literals are
emitted type-aware.

Both read navigation (`GO TOP` / `SKIP` / `SEEK`) and navigational write
(`AdsAppendRecord` → `AdsSetString`/`AdsSetDouble` → `AdsWriteRecord`,
plus `AdsDeleteRecord`) are exercised against the same fixture on both
drivers. Write stages field values and flushes one `INSERT` (append) or
`UPDATE` (positioned edit) per record; `AdsDeleteRecord` issues a `DELETE`
by primary key. v1 expects the caller to supply the primary key on append
(no IDENTITY round-trip yet) and emits SQL literals (parameter binding is a
later hardening slice).

When `OPENADS_TEST_ODBC_CONNSTR` is unset, the live cases skip (the backend
is still exercised by the URI-parsing unit tests), so the suite stays green
on machines without a configured data source.
18 changes: 18 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ add_library(openads_core STATIC
network/mg_wire.cpp
)

if(OPENADS_WITH_ODBC)
target_sources(openads_core PRIVATE
sql_backend/sql_common.cpp
sql_backend/odbc_uri.cpp
sql_backend/odbc_backend.cpp
sql_backend/odbc_connection.cpp
)
endif()

if(WIN32)
target_sources(openads_core PRIVATE
platform/file_win32.cpp
Expand Down Expand Up @@ -98,6 +107,15 @@ if(OPENADS_WITH_TLS)
MbedTLS::mbedtls MbedTLS::mbedx509 MbedTLS::mbedcrypto)
endif()

if(OPENADS_WITH_ODBC)
target_compile_definitions(openads_core PUBLIC OPENADS_WITH_ODBC=1)
if(WIN32)
target_link_libraries(openads_core PUBLIC odbc32)
else()
target_link_libraries(openads_core PUBLIC odbc)
endif()
endif()

# ----------------------------------------------------------------------
# Drop-in replacement DLL: ace32.dll (x86) / ace64.dll (x64).
# Harbour's contrib/rddads links against ace32.lib / ace64.lib import
Expand Down
Loading