948ec3974265b6527f4e6383f0f8e06d3d2dfd2f
markd
  Wed Aug 4 14:13:48 2010 -0700
fixed bug were attempt to allocated a connection cache entry with no-abort for a non-existant database would go very wrong
diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c
index d8f513a..7d89456 100644
--- src/hg/lib/jksql.c
+++ src/hg/lib/jksql.c
@@ -1816,13 +1816,20 @@
     || sameString(database, scce->conn->conn->db);
 }
 
-static void sqlConnCacheEntrySetDb(struct sqlConnCacheEntry *scce,
-                                   char *database)
+static boolean sqlConnCacheEntrySetDb(struct sqlConnCacheEntry *scce,
+                                      char *database,
+                                      boolean abort)
 /* set the connect cache and connect to the specified database */
 {
 if (mysql_select_db(scce->conn->conn, database) != 0)
+    {
+    if (abort) 
     errAbort("Couldn't set connection database to %s\n%s",
              database, mysql_error(scce->conn->conn));
+    else
+        return FALSE;
+    }
+return TRUE;
 }
 
 static struct sqlConnCacheEntry *sqlConnCacheFindFree(struct sqlConnCache *cache,
@@ -1897,7 +1904,10 @@
     {
     scce = sqlConnCacheFindFree(cache, profile, database, FALSE);
     if (scce != NULL)
-        sqlConnCacheEntrySetDb(scce, database);
+        {
+        if (!sqlConnCacheEntrySetDb(scce, database, abort))
+            scce = NULL;  // got error with no abort
+        }
     else
         scce = sqlConnCacheAddNew(cache, profile, database, abort);
     }