Sometimes, the psql startup hangs when it cannot resolve or connect to a host. Intuitively, I would like to press Ctrl+C and correct the connection string or investigate. But that doesn't work because Ctrl+C is already bound to the query cancel handler by that time.
It seems to me that there is no point in setting up the cancel handler before the database connection is established. Example patch attached. Comments?
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 5d7fe6e..65a1cde 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -111,8 +111,6 @@ static void parse_psql_options(int argc, char *argv[], setvbuf(stderr, NULL, _IONBF, 0); #endif - setup_cancel_handler(); - pset.progname = get_progname(argv[0]); pset.db = NULL; @@ -249,6 +247,8 @@ static void parse_psql_options(int argc, char *argv[], exit(EXIT_BADCONN); } + setup_cancel_handler(); + PQsetNoticeProcessor(pset.db, NoticeProcessor, NULL); SyncVariables();
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers