Backport #100607 to 25.8.16: Re-add {database} macro support in clickhouse-client prompt#1688
Backport #100607 to 25.8.16: Re-add {database} macro support in clickhouse-client prompt#1688il9ue wants to merge 4 commits into
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
Move executeQueryForSingleString and syncDefaultDatabase out of the initAIProvider and checkAIProviderAcknowledgment remain AI-guarded. Fix 04056/04057 expect tests: use $env(CLICKHOUSE_DATABASE) for the randomized DB name and drop the leading \n anchor that fails against the cursor-reset escape sequence the client emits before the prompt.
The .expect test uses log_user 0 and produces no stdout. Add an empty .reference file matching the pattern used by the sibling test 04056_client_prompt_database, which the stateless test framework requires for test discovery. Signed-off-by: Daniel Q. Kim <daniel.kim@altinity.com>
On PR #1688's regression failure (settings/default values/allow_local_data_lakes):The entry exists in the >=25.8_altinity snapshot (line 177, since clickhouse-regression on 0b98a129d, April 13). The framework's logic in settings/tests/default_values.py:75-83 should select that file for an Altinity non-Antalya 25.8 build, which my build is. Yet the test throws SnapshotNotFoundError as if the snapshot file or entry isn't Some quick checks I ran:
My best guess is the Is there a known issue here, or someone who knows the version-detection logic best? |
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: