diff --git a/lib/modules/Sql.pmod/pgsql_util.pmod b/lib/modules/Sql.pmod/pgsql_util.pmod
index 1066a80de185d6afbbd8e28cdf80aa030fba8854..9796877dc3528e89e1b2db677d0bcd443ee7558c 100644
--- a/lib/modules/Sql.pmod/pgsql_util.pmod
+++ b/lib/modules/Sql.pmod/pgsql_util.pmod
@@ -425,7 +425,6 @@ class conxion {
              |SSL.File
 #endif
                        socket;
-  private int towrite;
   final multiset(sql_result) runningportals = (<>);
 
   final MUTEX nostash;
@@ -496,7 +495,7 @@ class conxion {
   private int write_cb() {
     Thread.MutexKey lock = shortmux->lock();
     if (this) {				// Guard against async destructs
-      towrite -= output_to(socket, towrite);
+      output_to(socket);
       lock = 0;
       if (!i->fillread && !sizeof(this))
         close();
@@ -564,10 +563,10 @@ outer:
             case SENDOUT:;
           }
           Thread.MutexKey lock = shortmux->trylock();
-          if (lock && (towrite = sizeof(this))) {
+          if (lock && sizeof(this)) {
             PD("%d>Sendcmd %O\n",
-             socket->query_fd(), ((string)this)[..towrite-1]);
-            towrite -= output_to(socket, towrite);
+             socket->query_fd(), (string)this);
+            output_to(socket);
           }
         } while (0);
         started = 0;