If COCKROACH_URL or --url specifies no username with an insecure cluster, the connection is accepted and the underlying pq library uses the name of the user who launched the shell. However the CLI shell's prompt does not see this and the username part appears empty in the prompt.
A better behavior would be to query the database after the connection is established to determine what the current user is, much like the CLI already queries the database for syntax/txn status.
Found while investigating #10835.
I don't think the username field will be empty. lib/pq uses the username provided by the operating system if none is provided through the URL. I tested it out and my os username is correctly used.
After #10862 (thanks for catching that btw) the only issue I see is that the username used for the connection won't be reflected in the prompt.
Oh thanks for your analysis. Then the cli shell should do what is already done for other things and fetch the current user from the database. Changed the issue description accordingly.
@knz, I want to have a try for this.
@a6802739 ok, thanks!
@knz, what does the prevents username from appearing in prompt prompt mean here?
./cockroach sql --url="postgresql://localhost:26257?sslmode=disable"# Welcome to the cockroach SQL interface.
# All statements must be terminated by a semicolon.
# To exit: CTRL + D.
@localhost:26257>
(the username is missing)
@knz, thanks for your reference.
Good evening @knz may i give this is issue a go myself ?
Best regards,
Panos.
yes you can also have a look.
@pmamatsis note we have already a PR out for this in #12408. You can help with reviewing it though.
Good evening @knz,
i have managed to perform the rebase of my PR successfully. I will start working on this issue as discussed and implement it in a way to fit the existing FSM.
I wanted to ask you a newbie question about the rebase. When i am checking into master (i have added the official repository of cockroachdb as 'main') and perform the git status command i am getting the message:
On branch master
Your branch is ahead of 'origin/master' by 796 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
If i execute the command git remote -v i am getting the following results:
main https://github.com/cockroachdb/cockroach.git (fetch)
main https://github.com/cockroachdb/cockroach.git (push)
origin https://github.com/pmamatsis/cockroach (fetch)
origin https://github.com/pmamatsis/cockroach (push)
Best regards,
Panos.
.git/configSent from my Android device with K-9 Mail. Please excuse my brevity.
Good afternoon @knz,
my apologies for the late reply. The contents of my .git/config are the following:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/pmamatsis/cockroach
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "vendor"]
url = https://github.com/cockroachdb/vendored
[remote "main"]
url = https://github.com/cockroachdb/cockroach.git
fetch = +refs/heads/*:refs/remotes/main/*
I have checked the pkg/cli/sql.go file that i have locally against the one in the official cockroachdb repo and they are identical though.
Best regards and thank you in advance,
Panos.
Ok then, it's easy: the message merely indicates that your master branch on https://github.com/pmamatsis/cockroach is not up to date. By running git push you can bring it forward. This will synchronize your repository at https://github.com/pmamatsis/cockroach with ours.
Good evening @knz,
thank you for your prompt and quick reply. I will do this and then i will start working on the current issue.
Best regards,
Panos.
Looks like this was fixed by https://github.com/cockroachdb/cockroach/pull/12408
Closing!