A suspicious code in PQconnectPoll() - Mailing list pgsql-hackers

From Matsumura, Ryo
Subject A suspicious code in PQconnectPoll()
Date
Msg-id 03040DFF97E6E54E88D3BFEE5F5480F74AC1541C@G01JPEXMBYT04
Whole thread Raw
List pgsql-hackers
Hi

I find a suspicious code in libpq:PQconnectPoll(). I think it should be
fixed, but I could not produce a concrete problem.
What do you think about it?

I understand that PQconnectPoll() returns PGRES_POLLING_WRITING or
PGRES_POLLING_READ until state machine reaches terminal state(OK or BAD).
The return value indicates for users which event they should wait for
before next PQconnectPoll().
But PQconnectPoll() calls PQsendQuery("SHOW transaction_read_only")
in CONNECTION_AUTH_OK without returning PGRES_POLLING_WRITING before.


My idea is as following:

case CONNECTION_AWAITING_RESPONSE:
  receive authetication OK, transit state machine to AUTH_OK and
  return PGRES_POLLING_READING.

case CONNECTION_AUTH_OK:
  clear any data from backend using PQisBusy(), transit to
  CHECK_WRITABLE_STARTED(new state!), and return PGRES_POLLING_WRITING.

case CONNECTION_CHECK_WRITABLE_STARTED (new state!):
  call PQsendQuery("SHOW transaction_read_only"), and transit to
  CONNECTION_CHECK_WRITABLE, and return CONNECTION_CHECK_READING.


Regards
Ryo Matsumura



pgsql-hackers by date:

Previous
From: Жарков Роман
Date:
Subject: Re: Intermittent pg_ctl failures on Windows
Next
From: Michael Paquier
Date:
Subject: Compiler warnings with MinGW