5b429c970f5c991dae669604df849b5aa9a8c5d2
angie
  Wed Sep 30 15:43:31 2015 -0700
hFindTableInfoWithConn was checking table existence when chrom was given,
but not when chrom was NULL, and so it failed to check existence for a
table when looking in hgFixed.  Now it always checks existence.
Also, it uses hTableExists (cached) instead of sqlTableExists.
refs #16112

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index c396dc6..62b62c7 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -3045,55 +3045,57 @@
 db = sqlGetDatabase(conn);
 
 if (chrom == NULL)
     chrom = hDefaultChrom(db);
 if (dbHash == NULL)
     dbHash = newHash(8);
 hash = hashFindVal(dbHash, db);
 if (hash == NULL)
     {
     hash = newHash(8);
     hashAdd(dbHash, db, hash);
     }
 if ((hti = hashFindVal(hash, rootName)) == NULL)
     {
     safecpy(fullName, sizeof(fullName), rootName);
-    if ((sameString(rootName, "mrna") && sqlTableExists(conn, "all_mrna")) ||
-	(sameString(rootName, "est") && sqlTableExists(conn, "all_est")))
+    if ((sameString(rootName, "mrna") && hTableExists(db, "all_mrna")) ||
+	(sameString(rootName, "est") && hTableExists(db, "all_est")))
 	{
 	safef(fullName, sizeof(fullName), "all_%s", rootName);
 	rootName = fullName;
 	}
     else
 	{
 	if (chrom != NULL)
 	    {
             // first try the non-split table name then the split table name. 
             // In 2013, very few assemblies have split tables
             // This avoids dozens of mostly useless chrX_table lookups
             isSplit = TRUE;
-	    if (sqlTableExists(conn, fullName))
+	    if (hTableExists(db, fullName))
 		isSplit = FALSE;
             else 
                 {
                 safef(fullName, sizeof(fullName), "%s_%s", chrom, rootName);
-                if (sqlTableExists(conn, fullName))
+                if (hTableExists(db, fullName))
                     isSplit = TRUE; 
                 else
                     return NULL;
                 }
 	    }
+        else if (! hTableExists(db, fullName))
+            return NULL;
 	}
     AllocVar(hti);
     hashAddSaveName(hash, rootName, hti, &hti->rootName);
     hti->isSplit = isSplit;
     hti->isPos = hFindBed12FieldsAndBinWithConn(conn, fullName,
 	hti->chromField, hti->startField, hti->endField,
 	hti->nameField, hti->scoreField, hti->strandField,
 	hti->cdsStartField, hti->cdsEndField,
 	hti->countField, hti->startsField, hti->endsSizesField,
 	hti->spanField, &hti->hasBin);
     hti->hasCDS = (hti->cdsStartField[0] != 0);
     hti->hasBlocks = (hti->startsField[0] != 0);
     if (hti->isPos)
 	{
 	if (sameString(hti->startsField, "exonStarts"))