Skip to content

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

Open
@knz

Description

@knz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cli-clientCLI commands that pertain to using SQL featuresC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions