7db12c44c65b58c3a893a7d74adb76473cf29211
galt
  Tue Jun 11 16:25:59 2013 -0700
fixing bug related to incorrect detection of wildcards in table names and prefixes
diff --git src/hg/lib/joiner.c src/hg/lib/joiner.c
index b0023e0..c2ea1d6 100644
--- src/hg/lib/joiner.c
+++ src/hg/lib/joiner.c
@@ -1070,36 +1070,36 @@
 return NULL;
 }
 
 static boolean tableExists(char *database, char *table, char *splitPrefix)
 /* Return TRUE if database and table exist.  If splitPrefix is given,
  * check for existence with and without it. */
 {
 struct sqlConnection *conn = hAllocConnMaybe(database);
 if (conn == NULL)
     return FALSE;
 char t2[1024];
 if (isNotEmpty(splitPrefix))
     safef(t2, sizeof(t2), "%s%s", splitPrefix, table);
 else
     safef(t2, sizeof(t2), "%s", table);
-boolean hasSqlWildcard = (strchr(table, '%') || strchr(table, '_'));
+boolean hasSqlWildcard = (strchr(t2, '%') || strchr(t2, '_'));
 boolean exists = hasSqlWildcard ? sqlTableWildExists(conn, t2) : sqlTableExists(conn, t2);
 if (!exists && isNotEmpty(splitPrefix))
     {
-    safef(t2, sizeof(t2), "%s", table);
-    exists = hasSqlWildcard ? sqlTableWildExists(conn, t2) : sqlTableExists(conn, t2);
+    hasSqlWildcard = (strchr(table, '%') || strchr(table, '_'));
+    exists = hasSqlWildcard ? sqlTableWildExists(conn, table) : sqlTableExists(conn, table);
     }
 hFreeConn(&conn);
 return exists;
 }
 
 static void addChildren(struct joinerSet *js,  struct slRef **pList)
 /* Recursively add children to list. */
 {
 struct slRef *childRef;
 for (childRef = js->children; childRef != NULL; childRef = childRef->next)
     {
     struct joinerSet *child = childRef->val;
     refAdd(pList, child);
     addChildren(child, pList);
     }