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.
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)
{