Re: psql not responding to SIGINT upon db reconnection

Tristan Partin <tristan@neon.tech>

From: "Tristan Partin" <tristan@neon.tech>
To: "Jelte Fennema-Nio" <postgres@jeltef.nl>
Cc: "Robert Haas" <robertmhaas@gmail.com>, "Heikki Linnakangas" <hlinnaka@iki.fi>, <pgsql-hackers@postgresql.org>, "Shlok Kyal" <shlok.kyal.oss@gmail.com>
Date: 2024-04-03T15:16:58Z
Lists: pgsql-hackers
On Wed Apr 3, 2024 at 10:05 AM CDT, Jelte Fennema-Nio wrote:
> On Wed, 3 Apr 2024 at 16:55, Tristan Partin <tristan@neon.tech> wrote:
> > Removing from the switch statement causes a warning:
> >
> > > [1/2] Compiling C object src/bin/psql/psql.p/command.c.o
> > > ../src/bin/psql/command.c: In function ‘wait_until_connected’:
> > > ../src/bin/psql/command.c:3803:17: warning: enumeration value ‘PGRES_POLLING_ACTIVE’ not handled in switch [-Wswitch]
> > >  3803 |                 switch (PQconnectPoll(conn))
> > >       |                 ^~~~~~
>
>
> Ofcourse... fixed now

I think patch 2 makes it worse. The value in -Wswitch is that when new 
enum variants are added, the developer knows the locations to update. 
Adding a default case makes -Wswitch pointless.

Patch 1 is still good. The comment change in patch 2 is good too!

-- 
Tristan Partin
Neon (https://neon.tech)



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix old, misleading comment for PGRES_POLLING_ACTIVE.

  2. Remove reachable call to pg_unreachable().

  3. Allow SIGINT to cancel psql database reconnections.

  4. Expose PQsocketPoll via libpq

  5. Fix query cancellation handling in psql