From: Magnus Hagander Date: Wed, 20 Aug 2008 11:53:45 +0000 (+0000) Subject: Make libpq on windows not try to send chunks larger than 64Kb. X-Git-Tag: REL8_4_BETA1~1065 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c91ff03a06443ed88529026ad33464addbf3444d;p=postgresql Make libpq on windows not try to send chunks larger than 64Kb. Per Microsoft knowledge base article Q201213, early versions of Windows fail when we do this. Later versions of Windows appear to have a higher limit than 64Kb, but do still fail on large sends, so we unconditionally limit it for all versions. Patch from Tom Lane. --- diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 33c704b519..cc3e758ef2 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.134 2008/05/29 22:02:44 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.135 2008/08/20 11:53:45 mha Exp $ * *------------------------------------------------------------------------- */ @@ -752,7 +752,16 @@ pqSendSome(PGconn *conn, int len) int sent; char sebuf[256]; +#ifndef WIN32 sent = pqsecure_write(conn, ptr, len); +#else + /* + * Windows can fail on large sends, per KB article Q201213. The failure-point + * appears to be different in different versions of Windows, but 64k should + * always be safe. + */ + sent = pqsecure_write(conn, ptr, Min(len, 65536)); +#endif if (sent < 0) {