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

Commit282b6d0

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 parent92e7079 commit282b6d0

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

‎src/bin/pg_basebackup/pg_receivewal.c

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

920-
#ifndefWIN32
921-
pqsignal(SIGINT,sigint_handler);
922-
#endif
923-
924920
/*
925921
* Obtain a connection before doing anything.
926922
*/
@@ -930,6 +926,14 @@ main(int argc, char **argv)
930926
exit(1);
931927
atexit(disconnect_atexit);
932928

929+
/*
930+
* Trap signals. (Don't do this until after the initial password prompt,
931+
* if one is needed, in GetConnection.)
932+
*/
933+
#ifndefWIN32
934+
pqsignal(SIGINT,sigint_handler);
935+
#endif
936+
933937
/*
934938
* Run IDENTIFY_SYSTEM to make sure we've successfully have established a
935939
* replication connection and haven't connected using a database specific

‎src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ StreamLogicalLog(void)
216216
output_written_lsn=InvalidXLogRecPtr;
217217
output_fsync_lsn=InvalidXLogRecPtr;
218218

219-
query=createPQExpBuffer();
220-
221219
/*
222220
* Connect in replication mode to the server
223221
*/
@@ -236,6 +234,7 @@ StreamLogicalLog(void)
236234
replication_slot);
237235

238236
/* Initiate the replication stream at specified location */
237+
query=createPQExpBuffer();
239238
appendPQExpBuffer(query,"START_REPLICATION SLOT \"%s\" LOGICAL %X/%X",
240239
replication_slot,LSN_FORMAT_ARGS(startpos));
241240

@@ -932,23 +931,25 @@ main(int argc, char **argv)
932931
exit(1);
933932
}
934933

935-
936-
#ifndefWIN32
937-
pqsignal(SIGINT,sigint_handler);
938-
pqsignal(SIGHUP,sighup_handler);
939-
#endif
940-
941934
/*
942-
* Obtain a connection to server. This is not really necessary but it
943-
* helps to get more precise error messages about authentication, required
944-
* GUC parameters and such.
935+
* Obtain a connection to server. Notably, if we need a password, we want
936+
* to collect it from the user immediately.
945937
*/
946938
conn=GetConnection();
947939
if (!conn)
948940
/* Error message already written in GetConnection() */
949941
exit(1);
950942
atexit(disconnect_atexit);
951943

944+
/*
945+
* Trap signals. (Don't do this until after the initial password prompt,
946+
* if one is needed, in GetConnection.)
947+
*/
948+
#ifndefWIN32
949+
pqsignal(SIGINT,sigint_handler);
950+
pqsignal(SIGHUP,sighup_handler);
951+
#endif
952+
952953
/*
953954
* Run IDENTIFY_SYSTEM to make sure we connected using a database specific
954955
* replication connection.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp