Re: nonblocking PQsendQuery will fail for querysize > 8k

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: nonblocking PQsendQuery will fail for querysize > 8k
Дата
Msg-id 2585.1049226314@sss.pgh.pa.us
обсуждение исходный текст
Ответ на nonblocking PQsendQuery will fail for querysize > 8k  (Andreas Pflug <Andreas.Pflug@web.de>)
Список pgsql-interfaces
Andreas Pflug <Andreas.Pflug@web.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



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Andreas Pflug
Дата:
Сообщение: nonblocking PQsendQuery will fail for querysize > 8k
Следующее
От: Bruce Badger
Дата:
Сообщение: The new FE/BE protocol