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

Commit9329593

Browse files
committed
pg_receivewal, pg_recvlogical: allow canceling initial password prompt.
Previously it was impossible to terminate these programs via control-Cwhile they were prompting for a password. We can fix that triviallyfor their initial password prompts, by moving setup of the SIGINThandler from just before to just after their initial GetConnection()calls.This fix doesn't permit escaping out of later re-prompts, but thoseshould be exceedingly rare, since the user's password or the server'sauthentication setup would have to have changed meanwhile. Weconsidered applying a fix similar to commit46d665b, but thatseemed more complicated than it'd be worth. Moreover, this way isback-patchable, which that wasn't.The misbehavior exists in all supported versions, so back-patch to all.Tom Lane and Nathan BossartDiscussion:https://postgr.es/m/747443.1635536754@sss.pgh.pa.us
1 parentf5e3fab commit9329593

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

‎src/bin/pg_basebackup/pg_receivewal.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,6 @@ main(int argc, char **argv)
676676
close_destination_dir(dir,basedir);
677677
}
678678

679-
#ifndefWIN32
680-
pqsignal(SIGINT,sigint_handler);
681-
#endif
682-
683679
/*
684680
* Obtain a connection before doing anything.
685681
*/
@@ -689,6 +685,14 @@ main(int argc, char **argv)
689685
exit(1);
690686
atexit(disconnect_atexit);
691687

688+
/*
689+
* Trap signals. (Don't do this until after the initial password prompt,
690+
* if one is needed, in GetConnection.)
691+
*/
692+
#ifndefWIN32
693+
pqsignal(SIGINT,sigint_handler);
694+
#endif
695+
692696
/*
693697
* Run IDENTIFY_SYSTEM to make sure we've successfully have established a
694698
* replication connection and haven't connected using a database specific

‎src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ StreamLogicalLog(void)
214214
output_written_lsn=InvalidXLogRecPtr;
215215
output_fsync_lsn=InvalidXLogRecPtr;
216216

217-
query=createPQExpBuffer();
218-
219217
/*
220218
* Connect in replication mode to the server
221219
*/
@@ -234,6 +232,7 @@ StreamLogicalLog(void)
234232
replication_slot);
235233

236234
/* Initiate the replication stream at specified location */
235+
query=createPQExpBuffer();
237236
appendPQExpBuffer(query,"START_REPLICATION SLOT \"%s\" LOGICAL %X/%X",
238237
replication_slot, (uint32) (startpos >>32), (uint32)startpos);
239238

@@ -922,22 +921,25 @@ main(int argc, char **argv)
922921
exit(1);
923922
}
924923

925-
#ifndefWIN32
926-
pqsignal(SIGINT,sigint_handler);
927-
pqsignal(SIGHUP,sighup_handler);
928-
#endif
929-
930924
/*
931-
* Obtain a connection to server. This is not really necessary but it
932-
* helps to get more precise error messages about authentication, required
933-
* GUC parameters and such.
925+
* Obtain a connection to server. Notably, if we need a password, we want
926+
* to collect it from the user immediately.
934927
*/
935928
conn=GetConnection();
936929
if (!conn)
937930
/* Error message already written in GetConnection() */
938931
exit(1);
939932
atexit(disconnect_atexit);
940933

934+
/*
935+
* Trap signals. (Don't do this until after the initial password prompt,
936+
* if one is needed, in GetConnection.)
937+
*/
938+
#ifndefWIN32
939+
pqsignal(SIGINT,sigint_handler);
940+
pqsignal(SIGHUP,sighup_handler);
941+
#endif
942+
941943
/*
942944
* Run IDENTIFY_SYSTEM to make sure we connected using a database specific
943945
* replication connection.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp