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