pgsql/src/interfaces/libpq fe-exec.c fe-misc.c ...

From: momjian(at)postgresql(dot)org (Bruce Momjian - CVS)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql/src/interfaces/libpq fe-exec.c fe-misc.c ...
Date: 2002-03-05 05:20:13
Message-ID: 20020305052013.AEB7147598E@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

CVSROOT: /cvsroot
Module name: pgsql
Changes by: momjian(at)postgresql(dot)org 02/03/05 00:20:13

Modified files:
src/interfaces/libpq: fe-exec.c fe-misc.c libpq-fe.h libpq-int.h

Log message:
Here's a patch against 7.1.3 that fixes a problem with sending larger
queries over non-blocking connections with libpq. "Larger" here
basically means that it doesn't fit into the output buffer.

The basic strategy is to fix pqFlush and pqPutBytes.

The problem with pqFlush as it stands now is that it returns EOF when an
error occurs or when not all data could be sent. The latter case is
clearly not an error for a non-blocking connection but the caller can't
distringuish it from an error very well.

The first part of the fix is therefore to fix pqFlush. This is done by
to renaming it to pqSendSome which only differs from pqFlush in its
return values to allow the caller to make the above distinction and a
new pqFlush which is implemented in terms of pqSendSome and behaves
exactly like the old pqFlush.

The second part of the fix modifies pqPutBytes to use pqSendSome instead
of pqFlush and to either send all the data or if not all data can be
sent on a non-blocking connection to at least put all data into the
output buffer, enlarging it if necessary. The callers of pqPutBytes
don't have to be changed because from their point of view pqPutBytes
behaves like before. It either succeeds in queueing all output data or
fails with an error.

I've also added a new API function PQsendSome which analogously to
PQflush just calls pqSendSome. Programs using non-blocking queries
should use this new function. The main difference is that this function
will have to be called repeatedly (calling select() properly in between)
until all data has been written.

AFAICT, the code in CVS HEAD hasn't changed with respect to non-blocking
queries and this fix should work there, too, but I haven't tested that
yet.

Bernhard Herzog

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian - CVS 2002-03-05 05:30:44 pgsql/src/backend/access gist/gist.c gist/gist ...
Previous Message Tom Lane 2002-03-05 05:13:37 pgsql/src/backend/optimizer/prep Tag: REL7_2_S ...