Skip to content

Add ClientName paramter#520

Merged
slabko merged 3 commits intomasterfrom
client-name-parameter
Aug 7, 2025
Merged

Add ClientName paramter#520
slabko merged 3 commits intomasterfrom
client-name-parameter

Conversation

@slabko
Copy link
Copy Markdown
Contributor

@slabko slabko commented Aug 5, 2025

This PR introduces an additional optional driver setting, ClientName, which can be passed in the connection string. The value of this setting acts as a prefix for the User-Agent string that is sent with each request. The rest of the User-Agent string remains unchanged - it includes the name of the connector (clickhouse-odbc), the version, the platform, and so on.

For example, the following connection string:

DSN={Clickhouse DSN (Unicode)}; ClientName=TestApp/0.1

will produce the following User-Agent:

TestApp/0.1 clickhouse-odbc/1.4.2.20250618 (Windows-10.0.19045) UNICODE

Fixes #459

@slabko slabko force-pushed the client-name-parameter branch 2 times, most recently from 028fc69 to ac76624 Compare August 6, 2025 11:04
@slabko slabko force-pushed the client-name-parameter branch from ac76624 to 7ce219d Compare August 6, 2025 11:15
@slabko slabko marked this pull request as ready for review August 6, 2025 13:13
@slabko slabko requested review from Copilot and mshustov August 6, 2025 13:13
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 support for a new optional ClientName parameter that allows applications to identify themselves in the User-Agent header sent with requests to ClickHouse. The parameter acts as a prefix to the existing User-Agent string format.

  • Introduces ClientName parameter in connection strings and DSN configuration
  • Updates User-Agent string construction to include the client name prefix
  • Adds comprehensive test coverage for the new functionality

Reviewed Changes

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

Show a summary per file
File Description
packaging/odbc.ini.sample Documents the new ClientName parameter and reorganizes configuration documentation
driver/test/misc_it.cpp Adds test cases for ClientName parameter and User-Agent verification
driver/test/error_handling_it.cpp Removes duplicate getQueryId method (moved to base class)
driver/test/client_test_base.h Consolidates common test utilities including getQueryId method
driver/platform/win/setup.cpp Updates Windows setup to handle ClientName configuration
driver/connection.h Adds client_name field and removes unused useragent field
driver/connection.cpp Implements ClientName parameter parsing and User-Agent string construction
driver/config/ini_defines.h Defines ClientName configuration constants
driver/config/config.h Updates ConnInfo structure with clientName field
driver/config/config.cpp Adds ClientName to DSN parameter list
README.md Documents the new ClientName parameter
Comments suppressed due to low confidence (1)

packaging/odbc.ini.sample:1

  • The word 'paramter' is misspelled. It should be 'parameter'.
# Insert the content of this file into ~/.odbc.ini or /etc/odbc.ini files.

Comment on lines +383 to +384
FAIL() << "Entry for query id " << query_id << " has not been found";
}
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The FAIL() statement is placed outside the while loop, which means it will always execute if the loop completes without finding the entry. This should be placed inside the loop or the loop should have a separate flag to track if the entry was found.

Suggested change
FAIL() << "Entry for query id " << query_id << " has not been found";
}
}
FAIL() << "Entry for query id " << query_id << " has not been found";

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

@slabko slabko Aug 6, 2025

Choose a reason for hiding this comment

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

The loop has a retrun statement in the place where it finds the expected row and checks its content. The test must fail when the loop ends without returning somewhere in the middle of it.

@slabko slabko merged commit bc7f47b into master Aug 7, 2025
20 checks passed
@slabko slabko deleted the client-name-parameter branch February 17, 2026 12:13
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.

Allow client name setting for user agent

2 participants