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

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 (view raw or flat)
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


pgsql-committers by date

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

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