pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Terry Lee Tucker <terry@esc1.com>
To: PostgreSQL Interfaces <pgsql-interfaces@postgresql.org>
Subject: Re: libpq, blocking/nonblocking mechanism
Date: Tue, 31 May 2005 06:51:54 -0400
Message-ID: <200505310651.54505.terry@esc1.com> (raw)
In-Reply-To: <7104a737050528133410045f04@mail.gmail.com>
References: <7104a737050528133410045f04@mail.gmail.com>

From the docs:
PQsetnonblocking

Sets the nonblocking status of the connection. 

int PQsetnonblocking(PGconn *conn, int arg);


 Sets the state of the connection to nonblocking if arg is 1, or blocking if 
arg is 0. Returns 0 if OK, -1 if error. 


In the nonblocking state, calls to PQsendQuery, PQputline, PQputnbytes, and 
PQendcopy will not block but instead return an error if they need to be 
called again. 


Note that PQexec does not honor nonblocking mode; if it is called, it will act 
in blocking fashion anyway. 

A call to PQsetnonblocking only affects PQsendQuery, etc. These commands will 
work without calling PQsetnonblocking, but they will block. Our application 
uses a combination of PQexec and PQsendQuery.

I'm looking at the documentation in:
file:/usr/share/doc/postgresql-7.4.6/html/libpq-async.html
on my machine.

On Saturday 28 May 2005 04:34 pm, Volkan YAZICI saith:
> Hi,
>
> While I'm trying to figure out the point of PQsetnonblocking() call,
> confused so much on blocking/nonblocking mechanism.
>
> Sync. Connect » Async. Query
> Async. Connect » Sync. Query
>
> Both of above flows work without any PQsetnonblocking() call.
> Therefore sync/async connection and sync/async query execution are not
> dependent to each other. (Right?) If so, what's the point of
> PQsetnonblocking() function? When do we require it and when should we
> use it?
>
> As I saw from src/interfaces/libpq/fe-exec.c, PQsetnonblocking() only
> assigns True or False to conn->nonblocking variable. When I searched
> for "->nonblocking" under libpq directory, I found that it's used
> while creating an empty PGconn and while closing PGconn. This didn't
> help me too.
>
> I'd be so appreciated for a comprehensive "specialized for dummies" answer.
> Regards.
>
> P.S. Documentation pointers will be accepted with pleasure too.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq



view thread (5+ messages)  latest in thread

Message-ID: <200505310651.54505.terry@esc1.com>
Permalink:  ../200505310651.54505.terry@esc1.com/
Also on:    postgresql.org/message-id/200505310651.54505.terry@esc1.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: terry@esc1.com
  Subject: Re: libpq, blocking/nonblocking mechanism
  In-Reply-To: <200505310651.54505.terry@esc1.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox