X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2B0E452843 for ; Tue, 31 May 2005 07:55:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17075-04 for ; Tue, 31 May 2005 10:55:32 +0000 (GMT) Received: from rhino.esc1.com (hh1098003.direcpc.com [206.71.98.3]) by svr1.postgresql.org (Postfix) with ESMTP id E4E3652876 for ; Tue, 31 May 2005 07:55:20 -0300 (ADT) Received: from rhino.esc1.com (localhost.localdomain [127.0.0.1]) by rhino.esc1.com (8.12.11/8.12.10) with ESMTP id j4VApsGn007488 for ; Tue, 31 May 2005 06:51:54 -0400 Received: from localhost (localhost [[UNIX: localhost]]) by rhino.esc1.com (8.12.11/8.12.11/Submit) id j4VApslx007486 for pgsql-interfaces@postgresql.org; Tue, 31 May 2005 06:51:54 -0400 From: Terry Lee Tucker Organization: Enhanced Solutions Computing To: PostgreSQL Interfaces Subject: Re: libpq, blocking/nonblocking mechanism Date: Tue, 31 May 2005 06:51:54 -0400 User-Agent: KMail/1.5.3 References: <7104a737050528133410045f04@mail.gmail.com> In-Reply-To: <7104a737050528133410045f04@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200505310651.54505.terry@esc1.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.058 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/62 X-Sequence-Number: 5565 =46rom the docs: PQsetnonblocking Sets the nonblocking status of the connection.=20 int PQsetnonblocking(PGconn *conn, int arg); Sets the state of the connection to nonblocking if arg is 1, or blocking i= f=20 arg is 0. Returns 0 if OK, -1 if error.=20 In the nonblocking state, calls to PQsendQuery, PQputline, PQputnbytes, and= =20 PQendcopy will not block but instead return an error if they need to be=20 called again.=20 Note that PQexec does not honor nonblocking mode; if it is called, it will = act=20 in blocking fashion anyway.=20 A call to PQsetnonblocking only affects PQsendQuery, etc. These commands wi= ll=20 work without calling PQsetnonblocking, but they will block. Our application= =20 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 =BB Async. Query > Async. Connect =BB 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" answe= r. > 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