Skip to content

Implement SQLGetInfo(SQL_DBMV_VER) to get the version of the ClickHouse Server#496

Merged
slabko merged 1 commit intoClickHouse:masterfrom
slabko:get_dbms_version
May 21, 2025
Merged

Implement SQLGetInfo(SQL_DBMV_VER) to get the version of the ClickHouse Server#496
slabko merged 1 commit intoClickHouse:masterfrom
slabko:get_dbms_version

Conversation

@slabko
Copy link
Copy Markdown
Contributor

@slabko slabko commented May 20, 2025

The ODBC standard has a special way to get the version of the DBMS using SQLGetInfo with SQL_DBMV_VER. This change implements this option.

The ODBC standard has a special way to get the version of the DBMS using
`SQLGetInfo` with `SQL_DBMV_VER`. This change implements this option.
@slabko slabko requested review from Copilot and slvrtrn May 20, 2025 21:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to retrieve the DBMS version via SQLGetInfo using SQL_DBMS_VER. Key changes include:

  • Adding a new test (test_dbms_version) to verify the DBMS version retrieval.
  • Implementing getServerVersion in the driver APIs and updating the SQLGetInfo switch.
  • Introducing a helper to propagate diagnostics between handles.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/src/e2e/test_sanity.py Added test to compare driver-retrieved versus query version
driver/test/misc_it.cpp Added integration test for GetDatabaseVersion
driver/diagnostics.h & diagnostics.cpp Added helper copyDiagnosticsRecords for diagnostics propagation
driver/api/odbc.cpp Updated SQLGetInfo switch to delegate SQL_DBMS_VER handling
driver/api/impl/impl.h & impl.cpp Added getServerVersion implementation for retrieving DBMS version

if (string_length_ptr)
*string_length_ptr = indicator;

if (indicator < 0)
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider refining the error handling here by explicitly checking for SQL_NULL_DATA instead of any value less than 0. This would clarify that the error is due to a null or missing version value.

Suggested change
if (indicator < 0)
if (indicator == SQL_NULL_DATA)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative indicator, wither it SQL_NULL_DATA or anything else, means that we did not get the data we expected and we cannot go further. SQL_NULL_DATA is just a special case of the same problem.

@slabko slabko changed the title Add ability to get version of DBMS from driver Implement SQLGetInfo(SQL_DBMV_VER) to get the version of the ClickHouse Server May 20, 2025
@slabko slabko requested a review from mshustov May 21, 2025 05:54
@slabko slabko merged commit 2b0fa41 into ClickHouse:master May 21, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants