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

Commit3bd7556

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 parent6d07cbc commit3bd7556

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
@@ -675,10 +675,6 @@ main(int argc, char **argv)
675675
close_destination_dir(dir,basedir);
676676
}
677677

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

687+
/*
688+
* Trap signals. (Don't do this until after the initial password prompt,
689+
* if one is needed, in GetConnection.)
690+
*/
691+
#ifndefWIN32
692+
pqsignal(SIGINT,sigint_handler);
693+
#endif
694+
691695
/*
692696
* Run IDENTIFY_SYSTEM to make sure we've successfully have established a
693697
* 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
@@ -212,8 +212,6 @@ StreamLogicalLog(void)
212212
output_written_lsn=InvalidXLogRecPtr;
213213
output_fsync_lsn=InvalidXLogRecPtr;
214214

215-
query=createPQExpBuffer();
216-
217215
/*
218216
* Connect in replication mode to the server
219217
*/
@@ -232,6 +230,7 @@ StreamLogicalLog(void)
232230
replication_slot);
233231

234232
/* Initiate the replication stream at specified location */
233+
query=createPQExpBuffer();
235234
appendPQExpBuffer(query,"START_REPLICATION SLOT \"%s\" LOGICAL %X/%X",
236235
replication_slot,LSN_FORMAT_ARGS(startpos));
237236

@@ -920,22 +919,25 @@ main(int argc, char **argv)
920919
exit(1);
921920
}
922921

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp