cockroachdb / cockroachdb/cockroach

cli/sql: interactive prompt specifier %n does not follow username changes

Open
#105,136 1 comment 0 reactions 0 assignees View on GitHub
A-cli-client C-bug T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

As per the psql docs, `%n` is meant to reflect the current SQL user.
This is currently incorrect: it only shows the value in the conn URL and fails to update after SET SESSION AUTHORIZATION.

(Originally when the prompt specifier `%n` was implemented, it was not possible to change the username after the SQL session was open. The logic in the shell should have been adapted when SET SESSION AUTHORIZATION was implemented)

**To Reproduce**

Use `%n` in prompt then use SET SESSION AUTHORIZATION.

**Expected behavior**

The display of `%n` should be handled like that of the current database, by extracting the current user known server-side.

Note: this might be the opportunity to also implement `%#` which changes the prompt depending on whether the user has admin privileges.

Jira issue: CRDB-28891

Epic CRDB-23743

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.