Skip site navigation (1) Skip section navigation (2)

Re: libpq, blocking/nonblocking mechanism

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: PostgreSQL Interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: libpq, blocking/nonblocking mechanism
Date: 2005-05-31 10:51:54
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
From the docs:

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:
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?

In response to


pgsql-interfaces by date

Next:From: Volkan YAZICIDate: 2005-06-01 18:18:18
Subject: Re: libpq, blocking/nonblocking mechanism
Previous:From: sqlDate: 2005-05-30 09:28:29
Subject: Re: MacOS Interface ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group