non blcoking behaviour

Started by Erik Hofmanabout 25 years ago2 messagesbugs
Jump to latest
#1Erik Hofman
erik@ehofman.com

============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : Erik Hofman
Your email address : erik@ehofman.com

System Configuration
---------------------
Architecture (example: Intel Pentium) : SGI O2 / Mips RM5200

Operating System (example: Linux 2.0.26 ELF) :Irix 6.5.9

PostgreSQL version (example: PostgreSQL-7.0): PostgreSQL-7.0.3

Compiler used (example: gcc 2.8.0) : MipsPro C 7.3

Please enter a FULL description of your problem:
------------------------------------------------

I'm programming PostgreSQL using the non blocking function right now,
but i had a real struggle with it :(

The PQstatus returns CONNECTION_MADE, but PQsendQuery only checks for
CONNECTION_OK.
So PQsendQuery doesn't send the query, while i think that after
CONNECTION_MADE the query could be sent also.

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Probably adding CONNECTION_MADE to PQsendQuery

Erik

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Erik Hofman (#1)
Re: non blcoking behaviour

Erik Hofman <erik@ehofman.com> writes:

Probably adding CONNECTION_MADE to PQsendQuery

The code is not broken, but it would be if we changed that.

CONNECTION_MADE is an intermediate state in the nonblocking connection
procedure; it does not entitle you to send a query. You really
shouldn't be looking at PQstatus anyway, IMHO, until you've gotten a
PGRES_POLLING_OK result from PQconnectPoll.

regards, tom lane