Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e5e1bb

Browse files
committed
Fix recently-introduced breakage in psql's \connect command.
Through my misreading of what the existing code actually did,commits85c5428 et al. broke psql's behavior for the case where"\c connstring" provides a password in the connstring. We shoulduse that password in such a case, but as of85c5428 we ignored it(and instead, prompted for a password).Commit94929f1 fixed that in HEAD, but since I thought it wascleaning up a longstanding misbehavior and not one I'd just created,I didn't back-patch it.Hence, back-patch the portions of94929f1 having to do withpassword management. In addition to fixing the introduced bug,this means that "\c -reuse-previous=on connstring" will allowre-use of an existing connection's password if the connstringdoesn't change user/host/port. That didn't happen before, butit seems like a bug fix, and anyway I'm loath to have significantdifferences in this code across versions.Also fix an error with the same root cause about whether or not tooverride a connstring's setting of client_encoding. As of85c5428we always did so; restore the previous behavior of overriding onlywhen stdin/stdout are a terminal and there's no environment settingof PGCLIENTENCODING. (I find that definition a bit surprising, butright now doesn't seem like the time to revisit it.)Per bug #16746 from Krzysztof Gradek. As with the previous patch,back-patch to all supported branches.Discussion:https://postgr.es/m/16746-44b30e2edf4335d4@postgresql.org
1 parentd5e2bdf commit7e5e1bb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

‎src/bin/psql/command.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,6 +3030,7 @@ do_connect(enum trivalue reuse_previous_specification,
30303030
intnconnopts=0;
30313031
boolsame_host= false;
30323032
char*password=NULL;
3033+
char*client_encoding;
30333034
boolsuccess= true;
30343035
boolkeep_password= true;
30353036
boolhas_connection_string;
@@ -3239,6 +3240,16 @@ do_connect(enum trivalue reuse_previous_specification,
32393240
password=prompt_for_password(has_connection_string ?NULL :user);
32403241
}
32413242

3243+
/*
3244+
* Consider whether to force client_encoding to "auto" (overriding
3245+
* anything in the connection string). We do so if we have a terminal
3246+
* connection and there is no PGCLIENTENCODING environment setting.
3247+
*/
3248+
if (pset.notty||getenv("PGCLIENTENCODING"))
3249+
client_encoding=NULL;
3250+
else
3251+
client_encoding="auto";
3252+
32423253
/* Loop till we have a connection or fail, which we might've already */
32433254
while (success)
32443255
{
@@ -3279,8 +3290,9 @@ do_connect(enum trivalue reuse_previous_specification,
32793290
values[paramnum++]=password;
32803291
elseif (strcmp(ci->keyword,"fallback_application_name")==0)
32813292
values[paramnum++]=pset.progname;
3282-
elseif (strcmp(ci->keyword,"client_encoding")==0)
3283-
values[paramnum++]= (pset.notty||getenv("PGCLIENTENCODING")) ?NULL :"auto";
3293+
elseif (client_encoding&&
3294+
strcmp(ci->keyword,"client_encoding")==0)
3295+
values[paramnum++]=client_encoding;
32843296
elseif (ci->val)
32853297
values[paramnum++]=ci->val;
32863298
/* else, don't bother making libpq parse this keyword */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp