Backport #100607 to 25.8.16: Re-add {database} macro support in clickhouse-client prompt#1688
Open
il9ue wants to merge 1 commit intoreleases/25.8.16from
Open
Backport #100607 to 25.8.16: Re-add {database} macro support in clickhouse-client prompt#1688il9ue wants to merge 1 commit intoreleases/25.8.16from
il9ue wants to merge 1 commit intoreleases/25.8.16from
Conversation
Backport of ClickHouse#100607 to antalya-25.8. - Dynamic {database} substitution in ClientBase::getPrompt() from default_database (updated by USE and --database). - ClientBase::syncDefaultDatabase() runs SELECT currentDatabase() after the handshake so the prompt reflects server-side default_database when --database is not passed. - Sync call in Client::connect() is guarded by is_interactive, default_database.empty(), and prompt contains {database}. - Expect tests for both clickhouse-client and clickhouse-local. Closes ClickHouse#49118
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Re-add support for the
{database}macro in theclickhouse-clientandclickhouse-localprompt (prompt_by_server_display_name). The database name now updates dynamically afterUSEstatements and correctly reflects the--databaseCLI flag and server-sidedefault_databaseconfiguration. (ClickHouse#100607 by @il9ue)Backport of ClickHouse/ClickHouse#100607 to
releases/25.8.16. Closes upstream issue ClickHouse/ClickHouse#49118.Summary of changes
ClientBase::getPrompt()now dynamically substitutes{database}fromdefault_database, which is updated onUSEand by the--databaseflag.ClientBase::syncDefaultDatabase()firesSELECT currentDatabase()after the connection handshake so the prompt reflects the server-sidedefault_databasewhen--databaseis not passed. Failure is logged and degrades gracefully.Client::connect()is guarded byis_interactive && default_database.empty() && prompt.find("{database}")— no extra round-trip in batch mode, when--databasewas passed, or when the macro is absent from the prompt.{database}added to the macro documentation inprograms/client/clickhouse-client.xml.clickhouse-client(04056_client_prompt_database.expect) andclickhouse-local(04057_local_prompt_database.expect).Note on local build
Local build was blocked by a pre-existing clang-21
-Wmissing-noreturnerror inbase/base/JSON.cpp(from thePOCO_IMPLEMENT_EXCEPTIONmacro), unrelated to this backport. Relying on CI for verification. If04057_local_prompt_database.expectfails, the first thing to check is--enable-progress-table-toggle=0— that flag came from the upstream PR and I was unable to verify it exists inreleases/25.8.16'sclickhouse-local.Note on upstream status
Upstream ClickHouse/ClickHouse#100607 is currently open (approved LGTM by @ilejn, awaiting CI trigger from a maintainer). Happy to wait for upstream merge before landing this in Stable if that's Altinity's preferred policy.
CI/CD Options
Exclude tests:
Regression jobs to run: