src/hg/lib/hdb.c 1.414

1.414 2009/09/02 21:59:10 markd
backed out change to use hTableExists in some places, as it attempts to access the cache while it's being build in certain cases
Index: src/hg/lib/hdb.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hdb.c,v
retrieving revision 1.413
retrieving revision 1.414
diff -b -B -U 4 -r1.413 -r1.414
--- src/hg/lib/hdb.c	31 Aug 2009 21:47:45 -0000	1.413
+++ src/hg/lib/hdb.c	2 Sep 2009 21:59:10 -0000	1.414
@@ -234,9 +234,9 @@
 struct hashEl *hel;
 
 while ((hel = hashNext(&cook)) != NULL)
     {
-    if (hTableExists(sqlGetDatabase(conn), hel->name))
+    if (sqlTableExists(conn, hel->name))
 	{
 	struct slName *name = newSlName(hel->name);
 	slAddHead(&list, name);
 	}
@@ -454,9 +454,9 @@
 hel = hashStore(hash, db);
 if (hel->val == NULL)
     {
     struct sqlConnection *conn = hAllocConn(db);
-    if (hTableExists(db, "chromInfo"))
+    if (sqlTableExists(conn, "chromInfo"))
 	hel->val = sqlQuickString(conn, "select chrom from chromInfo limit 1");
     hFreeConn(&conn);
     }
 return hel->val;
@@ -774,22 +774,9 @@
 
 boolean hTableExists(char *db, char *table)
 /* Return TRUE if a table exists in db. */
 {
-// prevent recursive calls; this way function that might be called by both this function and 
-// other places can use hTableExists.
-static boolean building = FALSE;
-if (building)
-    {
-    struct sqlConnection *conn = hAllocConn(db);    
-    boolean exists = sqlTableExists(conn, table);
-    hFreeConn(&conn);
-    return exists;
-    }
-building = TRUE;
 struct hash *hash = tableListGetDbHash(db);
-building = FALSE;
-
 struct slName *tableNames = NULL, *tbl = NULL;
 char trackName[HDB_MAX_TABLE_STRING];
 char chrom[HDB_MAX_CHROM_STRING];
 if (hashFindVal(hash, "chromInfo"))
@@ -3313,9 +3300,9 @@
 {
 char *tbl;
 boolean exists;
 struct sqlConnection *conn = hAllocConnProfileTbl(db, tblSpec, &tbl);
-if ((exists = hTableExists(db, tbl)))
+if ((exists = sqlTableExists(conn, tbl)))
     {
     struct trackDb *oneTable = trackDbLoadWhere(conn, tbl, where), *oneRow;
     while ((oneRow = slPopHead(&oneTable)) != NULL)
         {
@@ -3664,9 +3651,9 @@
 {
 struct slName *tdb, *tdbs = hTrackDbList();
 for (tdb = tdbs; tdb != NULL; tdb = tdb->next)
     {
-    if (hTableExists(sqlGetDatabase(conn), tdb->name))
+    if (sqlTableExists(conn, tdb->name))
         {
         slFreeList(&tdbs);
         return loadTrackDbForTrack(conn, trackName);
         }
@@ -4347,9 +4334,9 @@
 
 for (table = tables; table != NULL; table = table->next)
     {
     struct grp *oneTable = NULL;
-    if (hTableExists(sqlGetDatabase(conn), table->name))
+    if (sqlTableExists(conn, table->name))
 	{
 	safef(query, sizeof(query), "select * from %s", table->name);
 	oneTable = grpLoadByQuery(conn, query);
 	}