Re: Improving psql's \password command

2021-11-22 Thread Bossart, Nathan
On 11/21/21, 11:15 AM, "Tom Lane" wrote: > "Bossart, Nathan" writes: >> Yeah, I was looking for a way to simplify this, too. Your approach >> seems reasonable enough to me. > > Hearing no contrary opinions, pushed that way. Thanks! Nathan

Re: Improving psql's \password command

2021-11-21 Thread Tom Lane
"Bossart, Nathan" writes: > On 11/20/21, 1:58 PM, "Tom Lane" wrote: >> Meh ... I'm inclined to fix those programs by just moving their pqsignal >> calls down to after their initial GetConnection calls, as attached. >> This'd be simple enough to back-patch, for one thing. > Yeah, I was looking fo

Re: Improving psql's \password command

2021-11-20 Thread Bossart, Nathan
On 11/20/21, 1:58 PM, "Tom Lane" wrote: > "Bossart, Nathan" writes: >> I did find some missing control-C handling in >> pg_receivewal/pg_recvlogical, though. Attached is a patch for those. > > Meh ... I'm inclined to fix those programs by just moving their pqsignal > calls down to after their in

Re: Improving psql's \password command

2021-11-20 Thread Tom Lane
"Bossart, Nathan" writes: > On 11/19/21, 9:17 AM, "Tom Lane" wrote: >> Hmm, initdb's prompt-for-superuser-password might need it. > I'm able to cancel the superuser password prompt in initdb already. > It looks like the signal handlers aren't set up until after > get_su_pwd(). Right; I misread

Re: Improving psql's \password command

2021-11-19 Thread Tom Lane
"Bossart, Nathan" writes: > Okay, here is an attempt at adding control-C support for \prompt and > \connect. It was reasonably straightforward. I did have to teach > simple_prompt_extended() to add a newline after a cancellation when > "echo" is true. LGTM, pushed after very minor fooling with

Re: Improving psql's \password command

2021-11-17 Thread Bossart, Nathan
On 11/17/21, 4:15 PM, "Tom Lane" wrote: > Pushed with a little further tweaking --- mostly, I felt that > explicitly referring to SIGINT in the API names was too > implementation-specific, so I renamed things. Thanks! > As you mentioned, there are several other simple_prompt() calls > that could

Re: Improving psql's \password command

2021-11-17 Thread Tom Lane
"Bossart, Nathan" writes: > You are right. I'm not sure what I was thinking. Attached a v3 > with that part removed. Pushed with a little further tweaking --- mostly, I felt that explicitly referring to SIGINT in the API names was too implementation-specific, so I renamed things. As you mentio

Re: Improving psql's \password command

2021-11-15 Thread Tom Lane
"Bossart, Nathan" writes: > On 11/15/21, 10:13 AM, "Tom Lane" wrote: >> * I don't believe that this bit is necessary, or if it is, >> the comment fails to justify it: >> >> - initStringInfo(&buf); >> + /* make sure buf is palloc'd so we don't lose changes after a >> longjmp */ >> +

Re: Improving psql's \password command

2021-11-15 Thread Tom Lane
"Bossart, Nathan" writes: > Here is an attempt at adding control-C support for \password. With > this patch, we pass sigint_interrupt_jmp and sigint_interrupt_enabled > all the way down to pg_get_line_append(), which is admittedly a bit > more complicated than I think would be ideal. I see a cou

Re: Improving psql's \password command

2021-11-12 Thread Bossart, Nathan
On 11/12/21, 11:58 AM, "Tom Lane" wrote: > "Bossart, Nathan" writes: >> I haven't started on the SIGINT stuff yet, but I did extract the >> PQuser() fix so that we can hopefully get that one out of the way. I >> made some small adjustments in an attempt to keep the branching in >> this function

Re: Improving psql's \password command

2021-11-12 Thread Tom Lane
"Bossart, Nathan" writes: > I haven't started on the SIGINT stuff yet, but I did extract the > PQuser() fix so that we can hopefully get that one out of the way. I > made some small adjustments in an attempt to keep the branching in > this function from getting too complicated. Right, it makes s

Re: Improving psql's \password command

2021-11-11 Thread Tom Lane
"Bossart, Nathan" writes: > On 10/29/21, 5:07 PM, "Tom Lane" wrote: >> I was afraid somebody would say that. I have looked at it, but AFAICS >> we'd have to duplicate all of sprompt.c and nearly all of pg_get_line.c >> in order to tie it into psql's SIGINT infrastructure, since we wouldn't >> da

Re: Improving psql's \password command

2021-11-11 Thread Bossart, Nathan
On 10/29/21, 5:07 PM, "Tom Lane" wrote: > "Bossart, Nathan" writes: >> Well, as of bf6b9e9, "ALTER ROLE nathan PASSWORD ''" is effectively >> the same as "ALTER ROLE nathan PASSWORD NULL". I agree about the >> user-unfriendliness, but maybe simple_prompt() ignoring control-C is >> the root-cause

Re: Improving psql's \password command

2021-10-29 Thread Tom Lane
"Bossart, Nathan" writes: > On 10/29/21, 12:47 PM, "Tom Lane" wrote: >> While testing that, I noticed another bit of user-unfriendliness: >> there's no obvious way to get out of it if you realize you are >> setting the wrong user's password. simple_prompt() ignores >> control-C, and when you giv

Re: Improving psql's \password command

2021-10-29 Thread Bossart, Nathan
On 10/29/21, 12:47 PM, "Tom Lane" wrote: > While testing that, I noticed another bit of user-unfriendliness: > there's no obvious way to get out of it if you realize you are > setting the wrong user's password. simple_prompt() ignores > control-C, and when you give up and press return, you'll jus

Improving psql's \password command

2021-10-29 Thread Tom Lane
The attached patch responds to the discussion at [1]. That thread pointed out that if you issue "\password" with no argument, psql tries to set the password for the role identified by PQuser(conn), that is, the originally requested login name. That's problematic because if you've done SET SESSION