diff --git a/lib/modules/Sql.pmod/pgsql_util.pmod b/lib/modules/Sql.pmod/pgsql_util.pmod
index 5bd4b21c1bb2c8813513cf916a7c37e5553db86f..19e32ada1ffeab3dbeed5107b086ca8869702303 100644
--- a/lib/modules/Sql.pmod/pgsql_util.pmod
+++ b/lib/modules/Sql.pmod/pgsql_util.pmod
@@ -35,8 +35,9 @@
 #define LOSTERROR	"Database connection lost"
 
 //! The instance of the pgsql dedicated backend.
-final Pike.Backend local_backend = Pike.SmallBackend();
+final Pike.Backend local_backend;
 
+private Pike.Backend cb_backend;
 private Thread.Mutex backendmux = Thread.Mutex();
 private Thread.ResourceCount clientsregistered = Thread.ResourceCount();
 
@@ -96,6 +97,16 @@ final Regexp transendprefix
 private Regexp execfetchlimit
  = iregexp("^\a*((UPDA|DELE)TE|INSERT)\a|\aLIMIT\a+[1-9][; \t\f\r\n]*$");
 
+private void default_backend_runs() {		// Runs as soon as the
+  cb_backend = Pike.DefaultBackend;		// DefaultBackend has started
+}
+
+private void create() {
+  // Run callbacks from our local_backend until DefaultBackend has started
+  cb_backend = local_backend = Pike.SmallBackend();
+  call_out(default_backend_runs, 0);
+}
+
 private Regexp iregexp(string expr) {
   Stdio.Buffer ret = Stdio.Buffer();
   foreach (expr; ; int c)
@@ -181,7 +192,7 @@ private int oidformat(int oid) {
 
 private inline mixed callout(function(mixed ...:void) f,
  float|int delay, mixed ... args) {
-  return local_backend->call_out(f, delay, @args);
+  return cb_backend->call_out(f, delay, @args);
 }
 
 // Some pgsql utility functions
@@ -1259,6 +1270,10 @@ class sql_result {
     plugbuffer->sendcmd(flushmode, this);
   }
 
+  inline private array setuptimeout() {
+    return local_backend->call_out(gottimeout, timeout);
+  }
+
   //! @returns
   //!  One result row at a time.
   //!
@@ -1274,7 +1289,7 @@ class sql_result {
     if (!eoffound) {
       if (!datarow) {
         PD("%O Block for datarow\n", _portalname);
-        array cid = callout(gottimeout, timeout);
+        array cid = setuptimeout();
         PT(datarow = datarows->read());
         local_backend->remove_call_out(cid);
         if (arrayp(datarow))
@@ -1300,7 +1315,7 @@ class sql_result {
       return 0;
     array(array|int) datarow = datarows->try_read_array();
     if (!sizeof(datarow)) {
-      array cid = callout(gottimeout, timeout);
+      array cid = setuptimeout();
       PT(datarow = datarows->read_array());
       local_backend->remove_call_out(cid);
     }
@@ -1340,7 +1355,7 @@ class sql_result {
    array(mixed) args) {
     int|array datarow;
     for (;;) {
-      array cid = callout(gottimeout, timeout);
+      array cid = setuptimeout();
       PT(datarow = datarows->read());
       local_backend->remove_call_out(cid);
       if (!arrayp(datarow))
@@ -1369,7 +1384,7 @@ class sql_result {
    array(mixed) args) {
     array(array|int) datarow;
     for (;;) {
-      array cid = callout(gottimeout, timeout);
+      array cid = setuptimeout();
       PT(datarow = datarows->read_array());
       local_backend->remove_call_out(cid);
       if (!datarow || !arrayp(datarow[-1]))