cli: add missing username in SQL prompt for connection URL #12408
cli: add missing username in SQL prompt for connection URL #12408a6802739 wants to merge 1 commit intocockroachdb:masterfrom a6802739:missing_username
Conversation
|
Please change the title of the commit message as well. |
asubiotto
left a comment
There was a problem hiding this comment.
Thank you for your PR. However, I think it would be better to implement a built-in function through which the client could query the server and avoid discrepancies between the user shown in the prompt and the current session user.
| if err == nil { | ||
| username = u.Username | ||
| } else { | ||
| username, _ = envutil.EnvString("COCKROACH_USER", 2) |
There was a problem hiding this comment.
I think it would be wrong to do this because we would not be using COCKROACH_USER to connect to the server (since we prefer url parameters over connection flags/environment variables) so there would be a disconnect between the user shown in the prompt and the actual session user. I would just remove this.
There was a problem hiding this comment.
@asubiotto , Thanks for your review. done.
|
@a6802739 this is similar to the work already performed in the shell to determine the current txn state, albeit easier. This is done as follows:
|
|
@asubiotto, @knz, Thanks for your review. I have extend it with a internal query now. |
|
Thank you for working on this. It looks much better now! Just minor stuff left. Reviewed 6 of 6 files at r2. pkg/cli/sql.go, line 418 at r2 (raw file):
Please extract this pkg/sql/show.go, line 37 at r2 (raw file):
Name this pkg/sql/parser/sql.y, line 1532 at r2 (raw file):
If you rename the variable to Comments from Reviewable |
|
@knz, Thanks for your review. And I also add the alias Review status: 0 of 6 files reviewed at latest revision, 4 unresolved discussions, some commit checks pending. pkg/cli/sql.go, line 418 at r2 (raw file): Previously, knz (kena) wrote…
Done. pkg/sql/show.go, line 37 at r2 (raw file): Previously, knz (kena) wrote…
Ok, I will make another PR for pkg/sql/parser/sql.y, line 1532 at r2 (raw file): Previously, knz (kena) wrote…
Done. Comments from Reviewable |
|
Reviewed 6 of 6 files at r3. pkg/cli/sql.go, line 407 at r3 (raw file):
@pmamatsis want to comment on how to better structure this code based on your previous experience? pkg/sql/parser/sql.y, line 1545 at r3 (raw file):
if you intend to support SESSION_USER in a separate PR please remove this rule then. Comments from Reviewable |
|
Also please rebase the PR using the latest master branch. |
|
Hi @knz, In the mean time i am checking the Reviewable site in order to comment. Best regards, |
|
Hi @knz, based on my previous experience i would have done the following:
@knz how do you thing? Did i put it properly ? Best regards, |
|
Yes this sounds fine. @a6802739 what do you think? Are you still planning/willing to work on this? (of course it's ok if you're not!) |
|
@pmamatsis, please go ahead. |
|
Hi @knz, Best regards, |
|
Please wait for #13379 to merge then rebase this one on top of it. |
|
Good morning @knz, Best regards and thank you in advance, |
|
There is no deadline. |
|
Note however that since the last time it is now possible to ask (You'll need to rebase to pick up this change). |
|
Good evening @knz, Best regards, |
|
Oh, that's a bug. Thanks for finding it. |
|
Good afternoon @knz, Best regards, |
|
I'm already nearly done with it. There were also other changes needed around it. :) |
|
ok you'll need the changes in #13678 |
|
Hi @knz, Best regards and thank you in advance, |
|
try |
|
Hi @knz, Best regards, |
|
Hi @knz, To add an Best regards and thank you in advance, |
|
I would recommend replacing this check entirely by a query to the server. This way if the server decides to do something else than the connection string, it will be reflected in the client. |
|
This feature now works properly. Closing this. Thank you for starting this work! |
Fixes #10863.
cc @knz.
This change is