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: (view raw, whole thread or download thread mbox)
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:
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

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-2017 The PostgreSQL Global Development Group