X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4CB53D76A1 for ; Thu, 3 Nov 2005 11:25:17 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35835-05 for ; Thu, 3 Nov 2005 15:25:13 +0000 (GMT) Received: from smtp104.rog.mail.re2.yahoo.com (smtp104.rog.mail.re2.yahoo.com [206.190.36.82]) by svr1.postgresql.org (Postfix) with SMTP id 3BC9CD7226 for ; Thu, 3 Nov 2005 11:25:15 -0400 (AST) Received: (qmail 15486 invoked from network); 3 Nov 2005 15:25:12 -0000 Received: from unknown (HELO ?192.168.2.27?) (annavm@rogers.com@72.56.98.122 with plain) by smtp104.rog.mail.re2.yahoo.com with SMTP; 3 Nov 2005 15:25:12 -0000 Message-ID: <436A2B4F.6000005@westernavionics.com> Date: Thu, 03 Nov 2005 10:22:55 -0500 From: Ranen Ghosh User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: error encountered in windows when libpq sends large query string to server Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/3 X-Sequence-Number: 5799 A winsock error is encountered when attempting to send a large query string (over 60 megabytes after escape characters were added) to a postgresql server from windows XP. The error was observed in using the pyPgSQL python binding to libpq, but was traced to libpq. In python, the error was: libpq.OperationalError? could not send data to server: No buffer space available (0x00002747/10055) from postgresql-8.0.3/src/interfaces/libpq/win32.c: WSAENOBUFS, "No buffer space available" from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp: WSAENOBUFS 10055 The problem is client side: when a smaller query string is successfully sent, a series of TCP packets are exchanged between the client and the server; but when the large query string is sent, there are no TCP packets exchanged. The query-string-size at which the error occurs is somewhere around 64 megabytes after escaping. The problem occurs in postgresql-8.0.3/src/interfaces/libpq/fe-misc.c, in pqSendSome(), which calls pqsecure_write() in postgresql-8.0.3/src/interfaces/libpq/fe-secure.c. In this function, the send() function call fails when the length of the buffer reaches approximately 64M. The code for postgresql-8.1beta3 does not seem to implement the above mentioned functions differently. As the error is client side, and the error message is a winsock error, I had thought that the most likely solution was changing an attribute of the socket (perhaps with setsockopt()) to expand the buffer space available). The default value of SO_SNDBUF is 8192. Changing this value to 0 or to 16384 (and confirming that the value had in fact changed internally) had no effect on the problem, however.