4c9e841fc4f0b1c8664e8b44ed889e38b5a3ad97
angie
  Thu Mar 23 11:40:36 2017 -0700
Yet another place where we need the all_ prefix for the table (again, thanks Jairo!).  fixes #19111

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index 223dec0..47346e7 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -3476,57 +3476,57 @@
 	struct sqlConnection *conn,  /* Open SQL connection. */
 	char *rootTable, 	     /* Table (not including any chrN_) */
 	char *chrom, int start, int end,  /* Range. */
 	char *extraWhere,            /* Extra things to add to where clause. */
 	boolean order, 	   /* If true order by start position (can be slow). */
 	char *fields,      /* If non-NULL comma separated field list. */
 	int *retRowOffset) /* Returns offset past bin field. */
 /* Range query with lots of options. */
 {
 char *db = sqlGetDatabase(conn);
 /* call hFindTableInfoWithConn() to support tracks may from different hosts */
 struct hTableInfo *hti = hFindTableInfoWithConn(conn, chrom, rootTable);
 struct sqlResult *sr = NULL;
 struct dyString *query = newDyString(1024);
 char *table = NULL;
+char fullTable[HDB_MAX_TABLE_STRING];
 int rowOffset = 0;
 
 if (fields == NULL) fields = "*";
 if (hti == NULL)
     {
     warn("table %s doesn't exist or hFindTableInfoDb failed", rootTable);
     }
 else
     {
     if (!sameString(fields,"*"))
 	sqlCkIl(fields);
     sqlDyStringPrintf(query, "select %-s from ", fields);
     if (hti->isSplit)
 	{
-	char fullTable[HDB_MAX_TABLE_STRING];
 	safef(fullTable, sizeof(fullTable), "%s_%s", chrom, rootTable);
 	if (!hTableExists(db, fullTable))
 	     warn("%s doesn't exist", fullTable);
 	else
 	    {
 	    table = fullTable;
 	    sqlDyStringPrintf(query, "%s where ", table);
 	    }
 	}
     else
         {
-	table = rootTable;
+	table = hti->rootName;
 	sqlDyStringPrintf(query, "%s where %s='%s' and ",
 	    table, hti->chromField, chrom);
 	}
     }
 if (table != NULL)
     {
     if (hti->hasBin)
         {
 	hAddBinToQuery(start, end, query);
 	rowOffset = 1;
 	}
     if (start == end) // e.g. size = 0 SNP insertion site
     	sqlDyStringPrintf(query, "%s=%u and %s=%u", hti->startField, end, hti->endField, start);
     else
     	sqlDyStringPrintf(query, "%s<%u and %s>%u", hti->startField, end, hti->endField, start);