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

Re: nonblocking PQsendQuery will fail for querysize > 8k

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Pflug <Andreas(dot)Pflug(at)web(dot)de>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: nonblocking PQsendQuery will fail for querysize > 8k
Date: 2003-04-01 19:45:14
Message-ID: 2585.1049226314@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-interfaces
Andreas Pflug <Andreas(dot)Pflug(at)web(dot)de> writes:
> I'm having trouble with PQsendQuery if sending medium sized 
> queries. Everything's fine with queries up to 8190 bytes (0x1fffe), but one 
> byte more will not work.

libpq's nonblock mode is incredibly fragile, not to say completely
broken.  See discussion from, eg, Jan 2000:
http://archives.postgresql.org/pgsql-hackers/2000-01/msg00964.php
http://archives.postgresql.org/pgsql-hackers/2000-01/msg01048.php
and nearby comments.

AFAIK most of those complaints never did get addressed; so the nonblock
mode works under light load but falls over as soon as it's stressed at
all.  I'd like to see it rewritten properly, but have not had time
myself.

Making pqPutBytes willing to realloc the output buffer bigger would
definitely help, but it's not the only thing needed to make nonblock
mode robust, per comments in above messages.

BTW, reallocing just big enough to handle the current input is not the
way to go; that will result in lots of malloc traffic if the caller adds
a few bytes at a time.  I'd think about doubling the buffer size until
it's big enough.  Your proposed code is also nonrobust about running out
of memory.

			regards, tom lane


In response to

pgsql-interfaces by date

Next:From: Bruce BadgerDate: 2003-04-01 23:04:21
Subject: The new FE/BE protocol
Previous:From: Alvaro HerreraDate: 2003-04-01 19:25:52
Subject: Re: Oracle Porting, Compiere

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