Fix SQL_DBMS_VER to return the Firebird product version#294
Open
fdcastel wants to merge 1 commit intoFirebirdSQL:masterfrom
Open
Fix SQL_DBMS_VER to return the Firebird product version#294fdcastel wants to merge 1 commit intoFirebirdSQL:masterfrom
fdcastel wants to merge 1 commit intoFirebirdSQL:masterfrom
Conversation
SQLGetInfo(SQL_DBMS_VER) was returning the engine / ODS-compat
implementation number rather than the Firebird release version. On
Firebird 5.0.3 the driver reported `"06.03.1683 WI-V Firebird 5.0"` —
atoi-ing that gives 6, so every ODBC consumer (downstream tools, test
harnesses, version-gated behaviour) mis-identified the server as
Firebird 6. The ODBC specification defines SQL_DBMS_VER as "the
version of the current DBMS product", which for Firebird is the
release version (5.0.3), not the wire-protocol / ODS level.
Root cause is in IscDbc/Attachment.cpp: we request BOTH
`isc_info_firebird_version` (the product version, added in FB 2.x)
AND `isc_info_version` (the legacy InterBase-style engine string) and
parse them into two independent triples — majorFb/minorFb/versionFb
vs local major/minor/version — but build `serverVersion` from the
wrong triple (the engine one). Switch to the product triple with a
defaults-based fallback so very old InterBase / pre-2.0 Firebird is
still handled.
After the fix, FB 5.0.3 now reports `"05.00.1683 WI-V Firebird 5.0"`
and FB 6.0 master reports `"06.00.1910 WI-T Firebird 6.0 …"`.
Why the existing tests didn't catch this
----------------------------------------
test_server_version.cpp only asserted SQL_DBMS_VER was non-empty and
contained a dot — every possible output satisfied both. It also had
a separate test that queried rdb$get_context('ENGINE_VERSION') but
never cross-referenced the two values. Three focused regression
tests are added:
* DBMSVerMajorMatchesEngineVersion — parses the "MM" prefix and
requires it to equal the major token of rdb$get_context.
* DBMSVerMinorMatchesEngineVersion — same for "mm".
* DBMSVerSuffixContainsDBMSName — sanity smoke test.
All three fail cleanly against the unfixed driver with a diagnostic
showing both version strings; all three pass after the fix.
Downstream knock-on: with SQL_DBMS_VER fixed,
tests/test_helpers.h::GetServerMajorVersion — which just does
atoi(SQL_DBMS_VER) — now returns the correct product major, and the
SKIP_ON_FIREBIRD6 macro it gates stops silently firing on FB 3/4/5.
Local full test run unblocks ~20 previously-skipping tests on FB 5.0.3.
Verified locally:
Firebird 5.0.3 (service): full suite — 221 pass, 165 skip, 0 fail.
Firebird 6.0.0.1910 (snapshot): full suite — 202 pass, 184 skip, 0 fail.
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.
Summary
SQLGetInfo(SQL_DBMS_VER)was returning the engine / ODS-compat implementation number rather than the Firebird release version. On Firebird 5.0.3 the driver reported:atoion that string gives 6, so every ODBC consumer (downstream tools, test harnesses, version-gated behaviour) mis-identifies the server as Firebird 6. The ODBC specification definesSQL_DBMS_VERas "the version of the current DBMS product" — which for Firebird is the release version (5.0.3), not the wire-protocol / ODS level.After this PR the same server reports:
and Firebird 6.0 master reports
'06.00.1910 WI-T Firebird 6.0 …'.Root cause
In
IscDbc/Attachment.cppwe already request bothisc_info_firebird_version(the product version, added in Firebird 2.x —5.0.3) andisc_info_version(the legacy InterBase-style engine string —6.3.0.1683). Both handlers parse their respective strings into independent version triples:isc_info_firebird_version→majorFb/minorFb/versionFb(product version)isc_info_version→ localmajor/minor/version(engine / ODS version)But
serverVersion— the backing value ofSQL_DBMS_VER— is formatted from the engine triple. Flip it to the product triple, with a defaults-based fallback so very old InterBase / pre-Firebird-2.0 attachments (whereisc_info_firebird_versionis not served) still produce a reasonable string.Why the existing tests didn't catch this
tests/test_server_version.cpp::SQLGetInfoDBMSVeronly asserted that the string was non-empty and contained a dot — every possible output satisfied both. The same file had a separate test that queriedrdb$get_context('SYSTEM', 'ENGINE_VERSION')but never cross-referenced the two values.Three focused regression tests are added:
DBMSVerMajorMatchesEngineVersionMMprefix and requires it to equal the major token ofrdb$get_contextDBMSVerMinorMatchesEngineVersionmmDBMSVerSuffixContainsDBMSNameSQL_DBMS_NAMEAll three fail cleanly against the unfixed driver with a diagnostic showing both strings:
All three pass after the fix.
Downstream knock-on — an unexpected bonus
With
SQL_DBMS_VERfixed,tests/test_helpers.h::GetServerMajorVersion— which just doesatoi(SQL_DBMS_VER)— now returns the correct product major, and theSKIP_ON_FIREBIRD6macro it gates stops silently firing on FB 3 / 4 / 5. Local FB 5.0.3 full suite jumped from 200 passing → 221 passing (≈21 tests that were silently skipping now actually run).Verification
Blast radius
SQL_DBMS_VERis a well-known ODBC info field. Any consumer that parsed the number as the Firebird major version has been getting6on every supported server for a long time; after this PR they'll get the correct value. Consumers that treat the full string as opaque (most — since only theMM.mm.bbbbprefix is spec-defined) are unaffected. Driver behaviour forSQL_DBMS_NAMEand all other info fields is unchanged.Test plan
'05.00.1683 WI-V Firebird 5.0''06.00.1910 WI-T Firebird 6.0 99191e0'