c4fe426d0936ce30c7fd65c63dd29a19abb830dc
braney
  Sun Mar 15 15:22:12 2015 -0700
allow using different names for the following tables:  dbDb, defaultDb,
genomeClade, and clade.   This will allow for testing of alternate
versions of these tables on hgwdev.

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index b98ce0e..2d8c5cc 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -46,45 +46,83 @@
 #include "filePath.h"
 
 
 #ifdef LOWELAB
 #define DEFAULT_PROTEINS "proteins060115"
 #define DEFAULT_GENOME "Pyrobaculum aerophilum"
 #else
 #define DEFAULT_PROTEINS "proteins"
 #define DEFAULT_GENOME "Human"
 #endif
 
 
 static struct sqlConnCache *hdbCc = NULL;  /* cache for primary database connection */
 static struct sqlConnCache *centralCc = NULL;
 static char *centralDb = NULL;
-static struct sqlConnCache *centralArchiveCc = NULL;
-static char *centralArchiveDb = NULL;
 static struct sqlConnCache *cartCc = NULL;  /* cache for cart; normally same as centralCc */
 static char *cartDb = NULL;
 static char *hdbTrackDb = NULL;
 
 /* cached list of tables in databases.  This keeps a hash of databases to
  * hashes of track/table name to slName list of actual table names, which
  * might be split.  Since individual tables can be mapped to different
  * profiles, and this information is only available when processing trackDb,
  * another table is kept to determine if these need to be checked.
  */
 static struct hash *tableList = NULL; // db to track to tables
 static struct hash *tableListProfChecked = NULL;  // profile:db that have been check
 
+char *dbDbTable()
+/* Return the name of the dbDb table. */
+{
+static char *dbDbTable = NULL;
+if (dbDbTable == NULL)
+    dbDbTable = cfgOptionEnvDefault("HGDB_DBDBTABLE",
+	    dbdDbTableConfVariable, defaultDbdDbTableName);
+return dbDbTable;
+}
+
+char *genomeCladeTable()
+/* Return the name of the genomeClade table. */
+{
+static char *genomeCladeTable = NULL;
+if (genomeCladeTable == NULL)
+    genomeCladeTable = cfgOptionEnvDefault("HGDB_GENOMECLADETABLE",
+	    genomeCladeTableConfVariable, defaultGenomeCladeTableName);
+return genomeCladeTable;
+}
+
+char *defaultDbTable()
+/* Return the name of the defaultDb table. */
+{
+static char *defaultDbTable = NULL;
+if (defaultDbTable == NULL)
+    defaultDbTable = cfgOptionEnvDefault("HGDB_DEFAULTDBTABLE",
+	    defaultDbTableConfVariable, defaultDefaultDbTableName);
+return defaultDbTable;
+}
+
+char *cladeTable()
+/* Return the name of the clade table. */
+{
+static char *cladeTable = NULL;
+if (cladeTable == NULL)
+    cladeTable = cfgOptionEnvDefault("HGDB_CLADETABLE",
+	    cladeTableConfVariable, defaultCladeTableName);
+return cladeTable;
+}
+
 static struct chromInfo *lookupChromInfo(char *db, char *chrom)
 /* Query db.chromInfo for the first entry matching chrom. */
 {
 struct chromInfo *ci = NULL;
 
 if (trackHubDatabase(db))
     {
     ci = trackHubMaybeChromInfo(db, chrom);
     return ci;
     }
 
 struct sqlConnection *conn = hAllocConn(db);
 struct sqlResult *sr = NULL;
 char **row = NULL;
 char query[256];
@@ -251,73 +289,56 @@
 struct hashEl *hel;
 
 while ((hel = hashNext(&cook)) != NULL)
     {
     if (sqlTableExists(conn, hel->name))
 	{
 	struct slName *name = newSlName(hel->name);
 	slAddHead(&list, name);
 	}
     }
 
 freeHash(&nameHash);
 return list;
 }
 
-boolean hArchiveDbExists(char *database)
-/*
-  Function to check if this is a valid db name in the dbDbArch table
-  of archived databases.
-*/
-{
-struct sqlConnection *conn = hConnectCentral();
-char buf[128];
-char query[256];
-boolean res = FALSE;
-sqlSafef(query, sizeof(query), "select name from dbDbArch where name = '%s'",
-      database);
-res = (sqlQuickQuery(conn, query, buf, sizeof(buf)) != NULL);
-hDisconnectCentral(&conn);
-return res;
-}
-
 boolean hDbExists(char *database)
 /*
   Function to check if this is a valid db name
 */
 {
 static struct hash *dbsChecked = NULL;
 
 if (dbsChecked)
     {
     struct hashEl *hel = hashLookup(dbsChecked, database);
     if (hel != NULL)
 	return ptToInt(hel->val);
     }
 else
     dbsChecked = newHash(0);
 
 if (trackHubDatabase(database))
     {
     hashAddInt(dbsChecked, database, TRUE);
     return TRUE;
     }
 
 struct sqlConnection *conn = hConnectCentral();
 char buf[128];
 char query[256];
-sqlSafef(query, sizeof(query), "select name from dbDb where name = '%s'", database);
+sqlSafef(query, sizeof(query), "select name from %s where name = '%s'",dbDbTable(),  database);
 boolean res = (sqlQuickQuery(conn, query, buf, sizeof(buf)) != NULL);
 if (res)
     {
     // this is done instead of sqlDatabaseExists() since it uses the cache,
     // which will recycle free connections for new databases
     struct sqlConnection *conn2 = hAllocConnMaybe(database);
     res = (conn2 != NULL);
     hFreeConn(&conn2);
     }
 hDisconnectCentral(&conn);
 hashAddInt(dbsChecked, database, res);
 return res;
 }
 
 boolean hDbIsActive(char *database)
@@ -333,31 +354,31 @@
     }
 else
     dbsChecked = newHash(0);
 
 if (trackHubDatabase(database))
     {
     hashAddInt(dbsChecked, database, TRUE);
     return TRUE;
     }
 
 struct sqlConnection *conn = hConnectCentral();
 char buf[128];
 char query[256];
 boolean res = FALSE;
 sqlSafef(query, sizeof(query),
-      "select name from dbDb where name = '%s' and active = 1", database);
+      "select name from %s where name = '%s' and active = 1",dbDbTable(),  database);
 res = (sqlQuickQuery(conn, query, buf, sizeof(buf)) != NULL);
 hDisconnectCentral(&conn);
 hashAddInt(dbsChecked, database, res);
 return res;
 }
 
 char *hDefaultDbForGenome(char *genome)
 /* Purpose: Return the default database matching the Genome.
  * param Genome - The Genome for which we are trying to get the
  *    default database.
  * return - The default database name for this Genome
  * Free the returned database name. */
 {
 char *dbName;
 
@@ -365,124 +386,124 @@
     return dbName;
 
 struct sqlConnection *conn = hConnectCentral();
 struct sqlResult *sr = NULL;
 char **row;
 struct defaultDb *db = NULL;
 char query [256];
 char *result = NULL;
 
 if (NULL == genome)
     {
     genome = cfgOptionDefault("defaultGenome", DEFAULT_GENOME);
     }
 
 /* Get proper default from defaultDb table */
-sqlSafef(query, sizeof(query), "select * from defaultDb where genome = '%s'",
-      genome);
+sqlSafef(query, sizeof(query), "select * from %s where genome = '%s'",
+      defaultDbTable(), genome);
 sr = sqlGetResult(conn, query);
 if ((row = sqlNextRow(sr)) != NULL)
     {
     db = defaultDbLoad(row);
     }
 if (db == NULL)
     {
     /* Can't find any of specified ones ?  Then use the first
      *	This is for the product browser which may have none of
      *	the usual UCSC genomes, but it needs to be able to function.
      */
-    sqlSafef(query, sizeof(query), "select * from defaultDb");
+    sqlSafef(query, sizeof(query), "select * from %s", defaultDbTable());
     sr = sqlGetResult(conn, query);
     if ((row = sqlNextRow(sr)) != NULL)
 	{
 	db = defaultDbLoad(row);
 	}
     if (db == NULL)
-	errAbort("Can't find genome \"%s\" in central database table defaultDb.\n", genome);
+	errAbort("Can't find genome \"%s\" in central database table %s.\n", genome, defaultDbTable());
     }
 
 sqlFreeResult(&sr);
 hDisconnectCentral(&conn);
 AllocArray(result, strlen(db->name) + 1);
 strcpy(result, db->name);
 defaultDbFree(&db);
 return result;
 }
 
 char *hDefaultGenomeForClade(char *clade)
 /* Return highest relative priority genome for clade. */
 {
 char *genome = NULL;
 if ((genome = trackHubCladeToGenome(clade)) != NULL) 
     return genome;
 
 struct sqlConnection *conn = hConnectCentral();
 char query[512];
 /* Get the top-priority genome *with an active database* so if genomeClade
  * gets pushed from hgwdev to hgwbeta/RR with genomes whose dbs haven't been
  * pushed yet, they'll be ignored. */
 sqlSafef(query, sizeof(query),
-      "select genomeClade.genome from genomeClade,dbDb "
-      "where genomeClade.clade = '%s' and genomeClade.genome = dbDb.genome "
-      "and dbDb.active = 1 "
-      "order by genomeClade.priority limit 1",
-      clade);
+      "select g.genome from %s d,%s g "
+      "where g.clade = '%s' and g.genome = d.genome "
+      "and d.active = 1 "
+      "order by g.priority limit 1",
+      dbDbTable(), genomeCladeTable(), clade);
 genome = sqlQuickString(conn, query);
 hDisconnectCentral(&conn);
 return genome;
 }
 
 char *hDbForSciName(char *sciName)
 /* Get default db for scientific name */
 {
 char *db = NULL;
 char query[256];
 struct sqlConnection *centralConn = hConnectCentral();
 
 sqlSafef(query, sizeof(query),
-    "select defaultDb.name from dbDb,defaultDb "
-    "where dbDb.scientificName='%s' "
-    "and dbDb.name = defaultDb.name ", sciName);
+    "select f.name from %s d,%s f "
+    "where d.scientificName='%s' "
+    "and d.name = f.name ", dbDbTable(), defaultDbTable(), sciName);
 db = sqlQuickString(centralConn, query);
 hDisconnectCentral(&centralConn);
 
 return db;
 }
 
 char *hDbForTaxon(struct sqlConnection *conn, int taxon)
 /* Get database associated with NCBI taxon number if any. */
 {
 char *db = NULL;
 char *binomial = NULL;
 char query[256];
 
 /* Figure out scientific name. */
 if (taxon != 0)
     {
     sqlSafef(query, sizeof(query),
 	"select binomial from uniProt.taxon where id=%d", taxon);
     binomial = sqlQuickString(conn, query);
     }
 /* Get default database for that organism. */
 if (binomial != NULL)
     {
     struct sqlConnection *centralConn = hConnectCentral();
     sqlSafef(query, sizeof(query),
-        "select defaultDb.name from dbDb,defaultDb "
-	"where dbDb.scientificName='%s' "
-	"and dbDb.name not like 'zoo%%' "
-	"and dbDb.name = defaultDb.name ", binomial);
+        "select f.name from %s d,%s f "
+	"where d.scientificName='%s' "
+	"and d.name not like 'zoo%%' "
+	"and d.name = f.name ", dbDbTable(), defaultDbTable(), binomial);
     db = sqlQuickString(centralConn, query);
     hDisconnectCentral(&centralConn);
     }
 freeMem(binomial);
 return db;
 }
 
 char *hDefaultDb()
 /* Return the default db if all else fails */
 {
 char *genome = cfgOptionDefault("defaultGenome", DEFAULT_GENOME);
 return hDefaultDbForGenome(genome);
 }
 
 char *hDefaultChrom(char *db)
@@ -677,69 +698,30 @@
  * not specific to a particular genome lives.  Free this up
  * with hDisconnectCentral(). */
 {
 if (centralCc == NULL)
     hCentralMkCache();
 return sqlConnCacheAlloc(centralCc, centralDb);
 }
 
 void hDisconnectCentral(struct sqlConnection **pConn)
 /* Put back connection for reuse. */
 {
 if (*pConn != NULL)
     sqlConnCacheDealloc(centralCc, pConn);
 }
 
-static void hArchiveCentralMkCache()
-/* create the archive central database cache, trying to connect to the
- * database and failing over if needed */
-{
-char *archiveProfile = "archivecentral";
-centralArchiveDb = cfgOption2(archiveProfile, "db");
-centralArchiveCc = sqlConnCacheNewProfile(archiveProfile);
-struct sqlConnection *conn = sqlConnCacheMayAlloc(centralArchiveCc, centralArchiveDb);
-if (conn == NULL)
-    {
-    sqlConnCacheDealloc(centralArchiveCc, &conn);
-    sqlConnCacheFree(&centralArchiveCc);
-    archiveProfile = "archivebackup";
-    centralDb = cfgOption2(archiveProfile, "database");
-    centralCc = sqlConnCacheNewProfile(archiveProfile);
-    conn = sqlConnCacheAlloc(centralCc, centralDb);
-    }
-/* now that a profile has been determined, make sure this database goes
- * through that profile */
-sqlProfileAddDb(archiveProfile, centralArchiveDb);
-sqlConnCacheDealloc(centralCc, &conn);
-}
-
-struct sqlConnection *hConnectArchiveCentral()
-/* Connect to central database for archives.
- * Free this up with hDisconnectCentralArchive(). */
-{
-if (centralArchiveCc == NULL)
-    hArchiveCentralMkCache();
-return sqlConnCacheAlloc(centralArchiveCc, centralArchiveDb);
-}
-
-void hDisconnectArchiveCentral(struct sqlConnection **pConn)
-/* Put back connection for reuse. */
-{
-if (*pConn != NULL)
-    sqlConnCacheDealloc(centralArchiveCc, pConn);
-}
-
 static void hCartMkCache()
 /* Create the cart connection cache.  Defaults to the central connection
  * unless cart.db or cart.host are configured. */
 {
 if ((cfgOption("cart.db") != NULL) || (cfgOption("cart.host") != NULL)
     || (cfgOption("cart.user") != NULL) || (cfgOption("cart.password") != NULL))
     {
     /* use explict cart options */
     cartDb = cfgOption("cart.db");
     if ((cartDb == NULL) || (cfgOption("cart.host") == NULL)
         || (cfgOption("cart.user") == NULL) || (cfgOption("cart.password") == NULL))
         errAbort("Must specify either all or none of the cart options in the hg.conf file.");
     cartCc = sqlConnCacheNewProfile("cart");
     /* make sure this database goes through that profile */
     sqlProfileAddDb("cart", cartDb);
@@ -2287,33 +2269,33 @@
  * for parameter that is unknown and it will be returned
  * as a result.  This result can be freeMem'd when done. */
 {
 if ((database != NULL) && trackHubDatabase(database))
     {
     return trackHubAssemblyField(database, "description");
     }
 
 struct sqlConnection *conn = hConnectCentral();
 struct sqlResult *sr;
 char **row;
 char *ret = NULL;
 struct dyString *dy = newDyString(128);
 
 if (database != NULL)
-    sqlDyStringPrintf(dy, "select description from dbDb where name = '%s'", database);
+    sqlDyStringPrintf(dy, "select description from %s where name = '%s'", dbDbTable(), database);
 else if (freeze != NULL)
-    sqlDyStringPrintf(dy, "select name from dbDb where description = '%s'", freeze);
+    sqlDyStringPrintf(dy, "select name from %s where description = '%s'", dbDbTable(), freeze);
 else
     internalErr();
 sr = sqlGetResult(conn, dy->string);
 if ((row = sqlNextRow(sr)) != NULL)
     ret = cloneString(row[0]);
 sqlFreeResult(&sr);
 hDisconnectCentral(&conn);
 freeDyString(&dy);
 return ret;
 }
 
 
 char *hFreezeFromDb(char *database)
 /* return the freeze for the database version.
    For example: "hg6" returns "Dec 12, 2000". If database
@@ -2324,99 +2306,86 @@
 
 char *hDbFromFreeze(char *freeze)
 /* Return database version from freeze name. */
 {
 return hFreezeDbConversion(NULL, freeze);
 }
 
 boolean hgNearOk(char *database)
 /* Return TRUE if ok to put up familyBrowser (hgNear)
  * on this database. */
 {
 struct sqlConnection *conn = hConnectCentral();
 char query[256];
 boolean ok;
 sqlSafef(query, sizeof(query),
-	"select hgNearOk from dbDb where name = '%s'", database);
+	"select hgNearOk from %s where name = '%s'", dbDbTable(), database);
 ok = sqlQuickNum(conn, query);
 hDisconnectCentral(&conn);
 return ok;
 }
 
 boolean hgPcrOk(char *database)
 /* Return TRUE if ok to put up hgPcr on this database. */
 {
 struct sqlConnection *conn = hConnectCentral();
 char query[256];
 boolean ok;
 sqlSafef(query, sizeof(query),
 	"select canPcr from blatServers where db = '%s' and isTrans=0", database);
 ok = sqlQuickNum(conn, query);
 hDisconnectCentral(&conn);
 return ok;
 }
 
-char *hArchiveOrCentralDbDbOptionalField(char *database, char *field, boolean archive)
+char *hCentralDbDbOptionalField(char *database, char *field)
 /* Look up field in dbDb table keyed by database,
  * Return NULL if database doesn't exist.
  * Free this string when you are done. Look in
  * either the regular or the archive dbDb table for .
  * The name for this function may be a little silly. */
 {
 struct sqlConnection *conn = hConnectCentral();
 char buf[128];
 char query[256];
-char dbDbTable[128];
 char *res = NULL;
 
-if (archive)
-    safef(dbDbTable, sizeof(dbDbTable), "dbDbArch");
-else
-    safef(dbDbTable, sizeof(dbDbTable), "dbDb");
-
 sqlSafef(query, sizeof(query), "select %s from %s where name = '%s'",
-      field, dbDbTable, database);
+      field, dbDbTable(), database);
 if (sqlQuickQuery(conn, query, buf, sizeof(buf)) != NULL)
     res = cloneString(buf);
 
 hDisconnectCentral(&conn);
 return res;
 }
 
-char *hArchiveDbDbOptionalField(char *database, char *field)
-/* Wrapper for hArchiveOrCentralDbDbOptionalField to
- * look up in the archive database. */
-{
-return hArchiveOrCentralDbDbOptionalField(database, field, TRUE);
-}
 
 char *hDbDbOptionalField(char *database, char *field)
-/* Wrapper for hArchiveOrCentralDbDbOptionalField to
- * look up in the regular central database. */
+ /* Look up in the regular central database. */
 {
 if (trackHubDatabase(database))
     {
     // In dbDb the genome field is the name of the organism, but
     // genome is the name of the assembly in track hubs.
     // Since we're called from dbDb aware code, we map a request
     // for the field "genome" to "organism"
     if (sameString(field, "genome"))
 	field = "organism";
     return trackHubAssemblyField(database, field);
     }
 
-char *res = hArchiveOrCentralDbDbOptionalField(database, field, FALSE);
+char *res = hCentralDbDbOptionalField(database, field);
 
 return res;
 }
 
 char *hDbDbField(char *database, char *field)
 /* Look up field in dbDb table keyed by database.
  * Free this string when you are done. */
 {
 char *res = hDbDbOptionalField(database, field);
 if (res == NULL)
     errAbort("Can't find %s for %s", field, database);
 return res;
 }
 
 char *hDefaultPos(char *database)
@@ -2424,48 +2393,30 @@
   organism associated with database.   use freeMem on
  * this when done. */
 {
 return hDbDbField(database, "defaultPos");
 }
 
 char *hOrganism(char *database)
 /* Return organism associated with database.   use freeMem on
  * this when done. */
 {
 if (sameString(database, "rep"))    /* bypass dbDb if repeat */
     return cloneString("Repeat");
 return hDbDbOptionalField(database, "organism");
 }
 
-char *hArchiveOrganism(char *database)
-/* Return organism name from the archive database.  E.g. "hg12". */
-{
-char *organism = hOrganism(database);
-if (!organism)
-    organism = hArchiveDbDbOptionalField(database, "organism");
-return organism;
-}
-
-char *hGenomeOrArchive(char *database)
-/* Return genome name associated from the regular or the archive database. */
-{
-char *genome = hGenome(database);
-if (!genome)
-    genome = hArchiveDbDbOptionalField(database, "genome");
-return genome;
-}
-
 char *hDbDbNibPath(char *database)
 /* return nibPath from dbDb for database, has to be freed */
 {
 char* seqDir = NULL;
 bool useNib = cfgOptionBooleanDefault("allowNib", TRUE);
 if (useNib)
     seqDir = hDbDbOptionalField(database, "nibPath");
 else
     {
     char buf[4096];
     safef(buf, sizeof(buf), "/gbdb/%s", database);
     char *twoBitDir = hReplaceGbdbSeqDir(buf, database);
     seqDir = twoBitDir;
     }
 return seqDir;
@@ -2516,116 +2467,121 @@
 {
 char query[256];
 struct sqlConnection *conn = hAllocConn(database);
 int ret;
 
 sqlSafef(query, sizeof(query), "select id from organism where name = '%s'",
 				    hScientificName(database));
 ret = sqlQuickNum(conn, query);
 hFreeConn(&conn);
 return ret;
 }
 
 static boolean hGotCladeConn(struct sqlConnection *conn)
 /* Return TRUE if central db contains clade info tables. */
 {
-return (sqlTableExists(conn, "clade") && sqlTableExists(conn, "genomeClade"));
+return (sqlTableExists(conn, cladeTable()) && sqlTableExists(conn, genomeCladeTable()));
 }
 
 boolean hGotClade()
 /* Return TRUE if central db contains clade info tables. */
 {
 struct sqlConnection *conn = hConnectCentral();
 boolean gotClade = hGotCladeConn(conn);
 hDisconnectCentral(&conn);
 return gotClade;
 }
 
 char *hClade(char *genome)
 /* If central database has clade tables, return the clade for the
  * given genome; otherwise return NULL. */
 {
 char *clade;
+if (genome == NULL)
+    return NULL;
+
 if ((clade = trackHubAssemblyClade(genome)) != NULL)
     return clade;
 
 if (isHubTrack(genome))
     {
     pushWarnHandler(cartHubWarn);
     warn("Current genome '%s' is supported by a hub that is no longer connected. Switching to default database.", trackHubSkipHubName(genome));
     popWarnHandler();
     return cloneString("none");
     }
 
 struct sqlConnection *conn = hConnectCentral();
 if (hGotCladeConn(conn))
     {
     char query[512];
     sqlSafef(query, sizeof(query),
-	  "select clade from genomeClade where genome = '%s'", genome);
+	  "select clade from %s where genome = '%s'", genomeCladeTable(), genome);
     clade = sqlQuickString(conn, query);
     hDisconnectCentral(&conn);
     if (clade == NULL)
 	{
-	warn("Warning: central database genomeClade doesn't contain "
-	     "genome \"%s\"", genome);
+	warn("Warning: central database %s doesn't contain "
+	     "genome \"%s\"", genomeCladeTable(), genome);
 	return cloneString("other");
 	}
     else
 	return clade;
     }
 else
     {
     hDisconnectCentral(&conn);
     return NULL;
     }
 }
 
 struct dbDb *hDbDb(char *database)
 /* Return dbDb entry for a database */
 {
 if (trackHubDatabase(database))
     return trackHubDbDbFromAssemblyDb(database);
 
 struct sqlConnection *conn = hConnectCentral();
 struct sqlResult *sr;
 char **row;
 struct dbDb *db = NULL;
 
 struct dyString *ds = dyStringNew(0);
-sqlDyStringPrintf(ds, "select * from dbDb where name='%s'", database);
+sqlDyStringPrintf(ds, "select * from %s where name='%s'", dbDbTable(), database);
 sr = sqlGetResult(conn, ds->string);
 if ((row = sqlNextRow(sr)) != NULL)
     db = dbDbLoad(row);
 sqlFreeResult(&sr);
 hDisconnectCentral(&conn);
 dyStringFree(&ds);
 return db;
 }
 
 struct dbDb *hDbDbListMaybeCheck(boolean doCheck)
 /* Return list of databases in dbDb.  If doCheck, check database existence.
  * The list includes the name, description, and where to
  * find the nib-formatted DNA files. Free this with dbDbFree. */
 {
 struct sqlConnection *conn = hConnectCentral();
 struct sqlResult *sr;
 char **row;
 struct dbDb *dbList = NULL, *db;
 struct hash *hash = sqlHashOfDatabases();
 
-sr = sqlGetResult(conn, "NOSQLINJ select * from dbDb order by orderKey,name desc");
+char query[1024];
+safef(query, sizeof query,  "NOSQLINJ select * from %s order by orderKey,name desc", dbDbTable());
+sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     db = dbDbLoad(row);
     if (!doCheck || hashLookup(hash, db->name))
         {
 	slAddHead(&dbList, db);
 	}
     else
         dbDbFree(&db);
     }
 sqlFreeResult(&sr);
 hashFree(&hash);
 hDisconnectCentral(&conn);
 slReverse(&dbList);
 return dbList;
@@ -2635,118 +2591,41 @@
 /* Return list of databases that are actually online.
  * The list includes the name, description, and where to
  * find the nib-formatted DNA files. Free this with dbDbFree. */
 {
 return hDbDbListMaybeCheck(TRUE);
 }
 
 static struct dbDb *hDbDbListDeadOrAlive()
 /* Return list of databases named in dbDb whether they exist or not.
  * The list includes the name, description, and where to
  * find the nib-formatted DNA files. Free this with dbDbFree. */
 {
 return hDbDbListMaybeCheck(FALSE);
 }
 
-struct dbDb *archiveDbDbLoad(char **row)
-/* Load a archive dbDb from row fetched with select * from dbDb
-         from database.  Dispose of this with dbDbFree().
-  NOTE: this table schema is now detached from the
-  main production dbDb, so we are not using the autoSql functions */
-{
-    struct dbDb *ret;
-
-    AllocVar(ret);
-    ret->name = cloneString(row[0]);
-    ret->description = cloneString(row[1]);
-    ret->nibPath = cloneString(row[2]);
-    ret->organism = cloneString(row[3]);
-    ret->defaultPos = cloneString(row[4]);
-    ret->active = sqlSigned(row[5]);
-    ret->orderKey = sqlSigned(row[6]);
-    ret->genome = cloneString(row[7]);
-    ret->scientificName = cloneString(row[8]);
-    ret->htmlPath = cloneString(row[9]);
-    ret->hgNearOk = sqlSigned(row[10]);
-    return ret;
-}
-
-struct dbDb *hArchiveDbDbList()
-/* Return list of databases in archive central dbDb.
- * Free this with dbDbFree. */
-{
-struct sqlConnection *conn;
-struct sqlResult *sr;
-char **row;
-struct dbDb *dbList = NULL, *db;
-char *assembly;
-char *next;
-
-conn = hConnectCentral();
-
-if (conn)
-    {
-    /* NOTE: archive orderKey convention is opposite of production server! */
-    sr = sqlGetResult(conn, "NOSQLINJ select * from dbDbArch order by orderKey desc,name desc");
-    while ((row = sqlNextRow(sr)) != NULL)
-        {
-        db = archiveDbDbLoad(row);
-        /* strip organism out of assembly description if it's there
-         * (true in hg6-hg11 entries) */
-        next = assembly = cloneString(db->description);
-        if (sameString(nextWord(&next), db->genome))
-            {
-            freez(&db->description);
-            db->description = cloneString(next);
-            }
-        freez(&assembly);
-        slAddHead(&dbList, db);
-        }
-    sqlFreeResult(&sr);
-
-    hDisconnectCentral(&conn);
-    slReverse(&dbList);
-    }
-return dbList;
-}
-
 struct hash *hDbDbHash()
 /* The hashed-up version of the entire dbDb table, keyed on the db */
-/* this is likely better to use than hArchiveOrganism if it's likely to be */
-/* repeatedly called */
 {
 struct hash *dbDbHash = newHash(16);
 struct dbDb *list = hDbDbList();
 struct dbDb *dbdb;
 for (dbdb = list; dbdb != NULL; dbdb = dbdb->next)
     hashAdd(dbDbHash, dbdb->name, dbdb);
 return dbDbHash;
 }
 
-struct hash *hDbDbAndArchiveHash()
-/* hDbDbHash() plus the dbDb rows from the archive table */
-{
-struct hash *dbDbHash = newHash(16);
-struct dbDb *archList = hArchiveDbDbList();
-struct dbDb *list = hDbDbList();
-struct dbDb *bothList = slCat(list, archList);
-struct dbDb *dbdb;
-for (dbdb = bothList; dbdb != NULL; dbdb = dbdb->next)
-    hashAdd(dbDbHash, dbdb->name, dbdb);
-return dbDbHash;
-}
-
 int hDbDbCmpOrderKey(const void *va, const void *vb)
 /* Compare to sort based on order key */
 {
 const struct dbDb *a = *((struct dbDb **)va);
 const struct dbDb *b = *((struct dbDb **)vb);
 
 if (b->orderKey > a->orderKey) return -1;
 else if (b->orderKey < a->orderKey) return 1;
 else return 0;
 }
 
 struct slName *hDbList()
 /* List of all database versions that are online (database
  * names only).  See also hDbDbList. */
 {
@@ -4346,38 +4225,42 @@
 {
 char *theClade = theDb ? hClade(hGenome(theDb)) : NULL;
 struct sqlConnection *conn = hConnectCentral(); // after hClade, since it access hgcentral too
 struct sqlResult *sr = NULL;
 char **row;
 struct dbDb *dbList = NULL, *db;
 
 dbList = trackHubGetDbDbs(theClade);
 slReverse(&dbList); // since we do a slReverse at the end of this function
 
 /* Scan through dbDb table, loading into list */
 if (theClade != NULL)
     {
     char query[1024];
     sqlSafef(query, sizeof(query),
-	  "select dbDb.* from dbDb,genomeClade where dbDb.active = 1 and "
-	  "dbDb.genome = genomeClade.genome and genomeClade.clade = \"%s\" "
-	  "order by dbDb.orderKey,dbDb.name desc", theClade);
+	  "select d.* from %s d,%s g where d.active = 1 and "
+	  "d.genome = g.genome and g.clade = \"%s\" "
+	  "order by d.orderKey,d.name desc", dbDbTable(),genomeCladeTable(),    theClade);
     sr = sqlGetResult(conn, query);
     }
     else
-	sr = sqlGetResult(conn,
-	   "NOSQLINJ select * from dbDb where active = 1 order by orderKey,name desc");
+    {
+    char query[1024];
+    sqlSafef(query, sizeof(query),
+	   "select * from %s where active = 1 order by orderKey,name desc", dbDbTable());
+    sr = sqlGetResult(conn, query);
+    }
 while ((row = sqlNextRow(sr)) != NULL)
     {
     db = dbDbLoad(row);
     slAddHead(&dbList, db);
     }
 sqlFreeResult(&sr);
 hDisconnectCentral(&conn);
 slReverse(&dbList);
 return dbList;
 }
 
 struct dbDb *hGetIndexedDatabases()
 /* Get list of all active databases.
  * Dispose of this with dbDbFreeList. */
 {
@@ -4387,59 +4270,61 @@
 struct dbDb *hGetIndexedDatabasesForClade(char *db)
 /* Get list of active databases in db's clade.
  * Dispose of this with dbDbFreeList. */
 {
 return hGetIndexedDbsMaybeClade(db);
 }
 
 struct slPair *hGetCladeOptions()
 /* Return a list of slPairs, each containing clade menu value (hgcentral.clade.name, e.g. 'mammal')
  * and clade menu label (hgcentral.clade.label, e.g. 'Mammal'),
  * useful for constructing a clade menu. */
 {
 // get only the clades that have actual active genomes
 char *query = "NOSQLINJ "
     "SELECT DISTINCT(c.name), c.label "
-    "FROM clade c, genomeClade g, dbDb d "
+    "FROM %s c, %s g, %s d "
     "WHERE c.name=g.clade AND d.organism=g.genome AND d.active=1 "
     "ORDER BY c.priority";
+char queryBuf[4096];
+safef(queryBuf, sizeof queryBuf, query, cladeTable(),  genomeCladeTable(), dbDbTable());
 struct sqlConnection *conn = hConnectCentral();
 struct slPair *nativeClades = sqlQuickPairList(conn, query);
 hDisconnectCentral(&conn);
 
 struct slPair *trackHubClades = trackHubGetCladeLabels();
 
 return slCat(nativeClades, trackHubClades);
 }
 
 struct slPair *hGetGenomeOptionsForClade(char *clade)
 /* Return a list of slPairs, each containing genome menu value and menu label,
  * useful for constructing a genome menu for the given clade. */
 {
 struct slPair *pairList = NULL;
 if (isHubTrack(clade))
     {
     struct dbDb *hubDbDbList = trackHubGetDbDbs(clade), *dbDb;
     for (dbDb = hubDbDbList;  dbDb != NULL;  dbDb = dbDb->next)
 	slAddHead(&pairList, slPairNew(dbDb->genome, cloneString(dbDb->genome)));
     }
 else
     {
     struct dyString *dy =
-	sqlDyStringCreate("select distinct(dbDb.genome) from dbDb,genomeClade "
-			  "where dbDb.genome=genomeClade.genome and genomeClade.clade = '%s' "
-			  "order by orderKey", clade);
+	sqlDyStringCreate("select distinct(d.genome) from %s d,%s g "
+			  "where d.genome=g.genome and g.clade = '%s' "
+			  "order by orderKey", dbDbTable(), genomeCladeTable(), clade);
     // Although clade and db menus have distinct values vs. labels, we actually use the
     // same strings for values and labels in the genome menu!  So we get a plain list
     // from the query and turn it into a pair list.
     struct sqlConnection *conn = hConnectCentral();
     struct slName *nativeGenomes = sqlQuickList(conn, dy->string), *g;
     hDisconnectCentral(&conn);
     dyStringFree(&dy);
     for (g = nativeGenomes;  g != NULL;  g = g->next)
 	slAddHead(&pairList, slPairNew(g->name, cloneString(g->name)));
     }
 slReverse(&pairList);
 return pairList;
 }
 
 struct slPair *hGetDbOptionsForGenome(char *genome)
@@ -4450,32 +4335,32 @@
 if (isHubTrack(genome))
     {
     char *clade = trackHubAssemblyClade(genome);
     struct dbDb *hubDbDbList = trackHubGetDbDbs(clade), *dbDb;
     for (dbDb = hubDbDbList;  dbDb != NULL;  dbDb = dbDb->next)
 	{
 	char *db = dbDb->name;
 	if (isEmpty(db))
 	    db = dbDb->genome;
 	slAddHead(&pairList, slPairNew(db, cloneString(db)));
 	}
     slReverse(&pairList);
     }
 else
     {
-    struct dyString *dy = sqlDyStringCreate("select name,description from dbDb "
-					    "where genome = '%s' order by orderKey", genome);
+    struct dyString *dy = sqlDyStringCreate("select name,description from %s "
+					    "where genome = '%s' order by orderKey", dbDbTable(), genome);
     struct sqlConnection *conn = hConnectCentral();
     pairList = sqlQuickPairList(conn, dy->string);
     hDisconnectCentral(&conn);
     dyStringFree(&dy);
     }
 return pairList;
 }
 
 struct slName *hLiftOverFromDbs()
 /* Return a list of names of the DBs in the
  * fromDb column of the liftOverChain.*/
 {
 struct slName *names = NULL;
 struct liftOverChain *chainList = liftOverChainListFiltered(), *chain;
 for (chain = chainList; chain != NULL; chain = chain->next)
@@ -4493,105 +4378,101 @@
 struct slName *names = NULL;
 struct liftOverChain *chainList = liftOverChainListForDbFiltered(fromDb), *chain;
 for (chain = chainList; chain != NULL; chain = chain->next)
     slNameStore(&names, chain->toDb);
 liftOverChainFreeList(&chainList);
 return names;
 }
 
 struct slName *hLiftOverOrgs(boolean from, char *fromDb)
 /* Just a function hLiftOverFromOrgs and
  * hLiftOverToOrgs call. */
 {
 struct slName *dbs = (from) ? hLiftOverFromDbs() : hLiftOverToDbs(fromDb);
 struct slName *names = NULL, *org;
 for (org = dbs; org != NULL; org = org->next)
-    slNameStore(&names, hArchiveOrganism(org->name));
+    slNameStore(&names, hOrganism(org->name));
 slReverse(&names);
 slFreeList(&dbs);
 return names;
 }
 
 struct slName *hLiftOverFromOrgs()
 /* Return a list of names of organisms that
  * have databases in the fromDb column of
  * liftOverChain.*/
 {
 return hLiftOverOrgs(TRUE,NULL);
 }
 
 struct slName *hLiftOverToOrgs(char *fromDb)
 /* Return a list of names of the organisms with
  * databases in the toDb column of the liftOverChain.
  * If fromDb!=NULL, return only those with that
  * fromDb. */
 {
 return hLiftOverOrgs(FALSE,fromDb);
 }
 
 
 struct hash *hGetDatabaseRank()
 /* Get list of databases and make a hash of order rank
  * Dispose of this with hashFree. */
 {
-struct dbDb *allDbList = NULL, *regDb = NULL, *archDb = NULL, *dbDb;
+struct dbDb *allDbList = NULL, *dbDb;
 struct hash *dbNameHash = newHash(3);
 int rank = 0;
 
 /* Get list of all current and archived databases */
-regDb = hDbDbListDeadOrAlive();
-archDb = hArchiveDbDbList();
-allDbList = slCat(regDb, archDb);
+allDbList = hDbDbListDeadOrAlive();
 
 /* Create a hash all dbs with rank number */
 for (dbDb = allDbList; dbDb != NULL; dbDb = dbDb->next)
     {
     if (!hashFindVal(dbNameHash, dbDb->name))
 	{
 	if (dbDb->active)
     	    hashAddInt(dbNameHash, dbDb->name, ++rank);
 	}
     }
 hashAddInt(dbNameHash, "maxRank", rank);
 dbDbFreeList(&allDbList);
 return dbNameHash;
 }
 
 struct dbDb *hGetLiftOverFromDatabases()
 /* Get list of databases for which there is at least one liftOver chain file
  * from this assembly to another.
  * Dispose of this with dbDbFreeList. */
 {
-struct dbDb *allDbList = NULL, *regDb = NULL, *archDb = NULL;
+struct dbDb *allDbList = NULL;
 struct dbDb *liftOverDbList = NULL, *dbDb, *nextDbDb;
 struct liftOverChain *chainList = NULL, *chain;
 struct hash *hash = newHash(0), *dbNameHash = newHash(3);
 
 /* Get list of all liftOver chains in central database */
 chainList = liftOverChainList();
 
 /* Create hash of databases having liftOver chains from this database */
 for (chain = chainList; chain != NULL; chain = chain->next)
     {
     if (!hashFindVal(hash, chain->fromDb))
         hashAdd(hash, chain->fromDb, chain->fromDb);
     }
 
 /* Get list of all current and archived databases */
-regDb = hDbDbList();
-archDb = hArchiveDbDbList();
-allDbList = slCat(regDb, archDb);
+allDbList = hDbDbList();
 
 /* Create a new dbDb list of all entries in the liftOver hash */
 for (dbDb = allDbList; dbDb != NULL; dbDb = nextDbDb)
     {
     /* current dbDb entries */
     nextDbDb = dbDb->next;
     if (hashFindVal(hash, dbDb->name) && !hashFindVal(dbNameHash, dbDb->name))
 	{
         slAddHead(&liftOverDbList, dbDb);
 	hashAdd(dbNameHash, dbDb->name, dbDb->name);
 	}
     else
         dbDbFree(&dbDb);
     }
 
@@ -4613,231 +4494,74 @@
 {
 struct dbDb *allDbList = NULL, *liftOverDbList = NULL, *dbDb, *nextDbDb;
 struct liftOverChain *chainList = NULL, *chain;
 struct hash *hash = newHash(0);
 struct hash *dbNameHash = newHash(3);
 
 /* Get list of all liftOver chains in central database */
 chainList = liftOverChainListForDbFiltered(fromDb);
 
 /* Create hash of databases having liftOver chains from the fromDb */
 for (chain = chainList; chain != NULL; chain = chain->next)
     if (sameString(chain->fromDb,fromDb))
 	hashAdd(hash, chain->toDb, chain->toDb);
 
 /* Get list of all current databases */
-allDbList = slCat(hDbDbListDeadOrAlive(),hArchiveDbDbList());
+allDbList = hDbDbListDeadOrAlive();
 
 /* Create a new dbDb list of all entries in the liftOver hash */
 for (dbDb = allDbList; dbDb != NULL; dbDb = nextDbDb)
     {
     nextDbDb = dbDb->next;
     if (hashFindVal(hash, dbDb->name) && !hashFindVal(dbNameHash, dbDb->name))
 	{
         slAddHead(&liftOverDbList, dbDb);
 	/* to avoid duplicates in the returned list. */
 	hashAdd(dbNameHash, dbDb->name, dbDb->name);
 	}
     else
         dbDbFree(&dbDb);
     }
 hashFree(&hash);
 liftOverChainFreeList(&chainList);
 
 /* sort by orderKey so that assemblies always appear from most recent */
 /* to the oldest assemblies in the dropdown menu for toDbs */
 slSort(&liftOverDbList, hDbDbCmpOrderKey);
 return liftOverDbList;
 }
 
-#ifndef GBROWSE
-struct dbDb *hGetAxtInfoDbs(char *db)
-/* Get list of db's where we have axt files listed in axtInfo .
- * The db's with the same organism as current db go last.
- * Dispose of result with dbDbFreeList. */
-{
-struct dbDb *dbDbList = NULL, *dbDb;
-struct hash *hash = hashNew(7); // 2^^7 entries = 128
-struct slName *dbNames = NULL, *dbName;
-struct dyString *query = newDyString(256);
-struct sqlConnection *conn = hAllocConn(db);
-struct sqlResult *sr = NULL;
-char **row;
-char *organism = hOrganism(db);
-int count;
-
-if (! hTableExists(db, "axtInfo"))
-    {
-    dyStringFree(&query);
-    hashFree(&hash);
-    hFreeConn(&conn);
-    return NULL;
-    }
-
-/* "species" is a misnomer, we're really looking up database names. */
-sr = sqlGetResult(conn, "NOSQLINJ select species from axtInfo");
-while ((row = sqlNextRow(sr)) != NULL)
-    {
-    // uniquify database names and make sure the databases still exist
-    if ((hashLookup(hash, row[0]) == NULL) && hDbExists(row[0]))
-	{
-	struct slName *sln = newSlName(cloneString(row[0]));
-	slAddHead(&dbNames, sln);
-	hashStoreName(hash, cloneString(row[0]));
-	}
-    }
-sqlFreeResult(&sr);
-hFreeConn(&conn);
-
-/* Traverse the uniquified list of databases twice: first for db's with
- * a different organism, then for db's with this organism. */
-conn = hConnectCentral();
-dyStringClear(query);
-sqlDyStringAppend(query, "SELECT * from dbDb");
-count = 0;
-for (dbName = dbNames;  dbName != NULL;  dbName = dbName->next)
-    {
-    char *dbOrg = hOrganism(dbName->name);
-    if (! sameString(dbOrg, organism))
-	{
-	count++;
-	if (count == 1)
-	    sqlDyStringPrintf(query, " where active = 1 and (name = '%s'",
-			   dbName->name);
-	else
-	    sqlDyStringPrintf(query, " or name = '%s'", dbName->name);
-	}
-    }
-dyStringPrintf(query, ") order by orderKey desc");
-if (count > 0)
-    {
-    sr = sqlGetResult(conn, query->string);
-    while ((row = sqlNextRow(sr)) != NULL)
-	{
-	dbDb = dbDbLoad(row);
-	slAddHead(&dbDbList, dbDb);
-	}
-    sqlFreeResult(&sr);
-    }
-dyStringClear(query);
-sqlDyStringAppend(query, "SELECT * from dbDb");
-count = 0;
-for (dbName = dbNames;  dbName != NULL;  dbName = dbName->next)
-    {
-    char *dbOrg = hOrganism(dbName->name);
-    if (sameString(dbOrg, organism))
-	{
-	count++;
-	if (count == 1)
-	    sqlDyStringPrintf(query, " where active = 1 and (name = '%s'",
-			   dbName->name);
-	else
-	    sqlDyStringPrintf(query, " or name = '%s'", dbName->name);
-	}
-    }
-dyStringPrintf(query, ") order by orderKey, name desc");
-if (count > 0)
-    {
-    sr = sqlGetResult(conn, query->string);
-    while ((row = sqlNextRow(sr)) != NULL)
-	{
-	dbDb = dbDbLoad(row);
-	slAddHead(&dbDbList, dbDb);
-	}
-    sqlFreeResult(&sr);
-    }
-hDisconnectCentral(&conn);
-slFreeList(&dbNames);
-dyStringFree(&query);
-hashFree(&hash);
-
-slReverse(&dbDbList);
-return(dbDbList);
-}
-
-struct axtInfo *hGetAxtAlignments(char *db, char *otherDb)
-/* Get list of alignments where we have axt files listed in axtInfo .
- * Dispose of this with axtInfoFreeList. */
-{
-struct sqlConnection *conn = hAllocConn(db);
-struct sqlResult *sr = NULL;
-char **row;
-struct axtInfo *aiList = NULL, *ai;
-char query[256];
-
-sqlSafef(query, sizeof(query),
-      "select * from axtInfo where species = '%s' and chrom = '%s' "
-      "order by sort",
-      otherDb, hDefaultChrom(db));
-/* Scan through axtInfo table, loading into list */
-sr = sqlGetResult(conn, query);
-while ((row = sqlNextRow(sr)) != NULL)
-    {
-    ai = axtInfoLoad(row);
-    slAddHead(&aiList, ai);
-    }
-sqlFreeResult(&sr);
-hFreeConn(&conn);
-slReverse(&aiList);
-return aiList;
-}
-
-struct axtInfo *hGetAxtAlignmentsChrom(char *db, char *otherDb, char *chrom)
-/* Get list of alignments where we have axt files listed in axtInfo for a specified chromosome .
- * Dispose of this with axtInfoFreeList. */
-{
-struct sqlConnection *conn = hAllocConn(db);
-struct sqlResult *sr = NULL;
-char **row;
-struct axtInfo *aiList = NULL, *ai;
-char query[256];
-
-sqlSafef(query, sizeof(query),
-      "select * from axtInfo where species = '%s' and chrom = '%s'",
-      otherDb, chrom);
-/* Scan through axtInfo table, loading into list */
-sr = sqlGetResult(conn, query);
-while ((row = sqlNextRow(sr)) != NULL)
-    {
-    ai = axtInfoLoad(row);
-    slAddHead(&aiList, ai);
-    }
-sqlFreeResult(&sr);
-hFreeConn(&conn);
-slReverse(&aiList);
-return aiList;
-}
-#endif /* GBROWSE */
-
 struct dbDb *hGetBlatIndexedDatabases()
 /* Get list of databases for which there is a BLAT index.
  * Dispose of this with dbDbFreeList. */
 {
 struct hash *hash=newHash(5);
 struct sqlConnection *conn = hConnectCentral();
 struct sqlResult *sr;
 char **row;
 struct dbDb *dbList = NULL, *db;
 
 /* Get hash of active blat servers. */
 sr = sqlGetResult(conn, "NOSQLINJ select db from blatServers");
 while ((row = sqlNextRow(sr)) != NULL)
     hashAdd(hash, row[0], NULL);
 sqlFreeResult(&sr);
 
 /* Scan through dbDb table, keeping ones that are indexed. */
-sr = sqlGetResult(conn, "NOSQLINJ select * from dbDb order by orderKey,name desc");
+char query[1024];
+safef(query,  sizeof query, "NOSQLINJ select * from %s order by orderKey,name desc", dbDbTable());
+sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     db = dbDbLoad(row);
     if (hashLookup(hash, db->name))
         {
 	slAddHead(&dbList, db);
 	}
     else
         dbDbFree(&db);
     }
 sqlFreeResult(&sr);
 hDisconnectCentral(&conn);
 hashFree(&hash);
 slReverse(&dbList);
 dbList = slCat(dbList, trackHubGetBlatDbDbs());
@@ -4859,46 +4583,46 @@
 }
 
 struct blatServerTable *hFindBlatServer(char *db, boolean isTrans)
 /* Return server for given database.  Db can either be
  * database name or description. Ponter returned is owned
  * by this function and shouldn't be modified */
 {
 static struct blatServerTable st;
 struct sqlConnection *conn = hConnectCentral();
 char query[256];
 struct sqlResult *sr;
 char **row;
 char dbActualName[32];
 
 /* If necessary convert database description to name. */
-sqlSafef(query, sizeof(query), "select name from dbDb where name = '%s'", db);
+sqlSafef(query, sizeof(query), "select name from %s where name = '%s'", dbDbTable(), db);
 if (!sqlExists(conn, query))
     {
     sqlSafef(query, sizeof(query),
-	  "select name from dbDb where description = '%s'", db);
+	  "select name from %s where description = '%s'",dbDbTable(),  db);
     if (sqlQuickQuery(conn, query, dbActualName, sizeof(dbActualName)) != NULL)
         db = dbActualName;
     }
 
 /* Do a little join to get data to fit into the blatServerTable. */
 sqlSafef(query, sizeof(query),
-               "select dbDb.name,dbDb.description,blatServers.isTrans"
-               ",blatServers.host,blatServers.port,dbDb.nibPath "
-	       "from dbDb,blatServers where blatServers.isTrans = %d and "
-	       "dbDb.name = '%s' and dbDb.name = blatServers.db",
-	       isTrans, db);
+               "select d.name,d.description,blatServers.isTrans"
+               ",blatServers.host,blatServers.port,d.nibPath "
+	       "from %s d,blatServers where blatServers.isTrans = %d and "
+	       "d.name = '%s' and d.name = blatServers.db",
+	        dbDbTable(), isTrans, db);
 sr = sqlGetResult(conn, query);
 if ((row = sqlNextRow(sr)) == NULL)
     {
     errAbort("Can't find a server for %s database %s\n",
 	    (isTrans ? "translated" : "DNA"), db);
     }
 st.db = cloneString(row[0]);
 st.genome = cloneString(row[1]);
 st.isTrans = atoi(row[2]);
 st.host = cloneString(row[3]);
 st.port = cloneString(row[4]);
 st.nibDir = cloneString(row[5]);
 sqlFreeResult(&sr);
 hDisconnectCentral(&conn);
 return &st;