X-Original-To: pgsql-interfaces@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 593D1475E14 for ; Mon, 31 Mar 2003 19:24:08 -0500 (EST) Received: from smtp.web.de (smtp03.web.de [217.72.192.158]) by postgresql.org (Postfix) with ESMTP id A54F6475AF8 for ; Mon, 31 Mar 2003 19:24:07 -0500 (EST) Received: from p508184a5.dip0.t-ipconnect.de ([80.129.132.165] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 1909ZS-0000CZ-00 for pgsql-interfaces@postgresql.org; Tue, 01 Apr 2003 02:24:10 +0200 Message-ID: <3E88CE22.8010503@web.de> Date: Tue, 01 Apr 2003 01:24:18 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: nonblocking PQsendQuery will fail for querysize > 8k Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-14.9 required=5.0 tests=BAYES_01,QUOTED_EMAIL_TEXT,RCVD_IN_NJABL, USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/3 X-Sequence-Number: 3942 Repost from pgadmin-hackers This happens with 7.3.2 windows libpq. Regards, Andreas > -----Original Message----- > From: Andreas Pflug [mailto:Andreas.Pflug@web.de] > Sent: 31 March 2003 17:57 > To: pgadmin-hackers@postgresql.org > Subject: Re: [pgadmin-hackers] Maximum PQsendQuery size? > > > Andreas Pflug wrote: > > > 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. In this case, PQsendQuery and > PQconsumeInput > > will return ok, but PQisBusy stays busy. How can I get around this? > > > > Regards, > > > > Andreas > > > > > I already found a solution in pgsql/src/interfaces/libpq/fe-misc.c. > > conn->outBuffer initially has 8k size. For a successful 8190 byte > execute, this contains a 'Q', the query and the terminating > zero byte. > If pqPutBytes() finds avail to be too small, it will first try to > pqSendSome(), but this will not be good if the connection is > nonblocking. > > As a fix, the outbuffer is realloced to be big enough, before > processing > continues: > > avail = Max(conn->outBufSize - conn->outCount, 0); > >>>>> > if (nbytes > avail && pqIsnonblocking(conn)) > { > char *newbuf; > conn->outBufSize = conn->outBufSize - avail + nbytes; > newbuf = realloc(conn->outBuffer, conn->outBufSize); > conn->outBuffer = newbuf; > avail = conn->outBufSize - conn->outCount; > } > <<<<< > remaining = Min(avail, nbytes); > >