Index: src/hg/hgTables/joining.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTables/joining.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -b -B -U 4 -r1.57 -r1.58
--- src/hg/hgTables/joining.c	12 Apr 2010 05:32:51 -0000	1.57
+++ src/hg/hgTables/joining.c	13 Apr 2010 05:51:25 -0000	1.58
@@ -1132,31 +1132,32 @@
 return bedList;
 }
 
 struct bed *dbGetFilteredBedsOnRegions(struct sqlConnection *conn, 
-	char *table, struct region *regionList, struct lm *lm, 
+	char *db, char *dbVarName, char *table, char *tableVarName,
+	struct region *regionList, struct lm *lm, 
 	int *retFieldCount)
 /* Get list of beds from database, in all regions, that pass filtering. */
 {
 /* A joining query may be required if the filter incorporates linked tables. */
-struct hTableInfo *hti = getHti(database, table, conn);
-struct slName *fieldList = getBedFieldSlNameList(hti, database, table);
+struct hTableInfo *hti = getHti(db, table, conn);
+struct slName *fieldList = getBedFieldSlNameList(hti, db, table);
 struct joinerDtf *dtfList = NULL;
 struct joinerDtf *filterTables = NULL;
-boolean doJoin = joinRequired(database, table,
+boolean doJoin = joinRequired(db, table,
 			      fieldList, &dtfList, &filterTables);
 struct region *region;
 struct bed *bedList = NULL;
-char *idField = getIdField(database, curTrack, table, hti);
-struct hash *idHash = identifierHash(database, table);
+char *idField = getIdField(db, curTrack, table, hti);
+struct hash *idHash = identifierHash(db, table);
 
 if (! doJoin)
     {
     for (region = regionList; region != NULL; region = region->next)
 	{
 	char *identifierFilter = identifierWhereClause(idField, idHash);
-	char *filter = filterClause(database, table, region->chrom, identifierFilter);
-	struct bed *bedListRegion = getRegionAsMergedBed(database, table,
+	char *filter = filterClause(dbVarName, tableVarName, region->chrom, identifierFilter);
+	struct bed *bedListRegion = getRegionAsMergedBed(dbVarName, tableVarName,
 				    region, filter, idHash, lm, retFieldCount);
 	struct bed *bed, *nextBed;
 	for (bed = bedListRegion; bed != NULL; bed = nextBed)
 	    {
@@ -1170,9 +1171,9 @@
 else
     {
     struct joiner *joiner = allJoiner;
     struct joinedTables *joined = joinedTablesCreate(joiner, 
-    	database, table, dtfList, filterTables, 1000000, regionList);
+    	db, table, dtfList, filterTables, 1000000, regionList);
     int bedFieldCount = hTableInfoBedFieldCount(hti);
     if (retFieldCount != NULL)
 	*retFieldCount = bedFieldCount;
     bedList = joinedTablesToBed(joined, hti, bedFieldCount, lm);

