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?