210f05b80f378889bd273f33722a9dc43ca9aa97
galt
  Mon Jun 3 15:11:04 2013 -0700
fixed bug where it should not use a cgi-var if it is an empty string
diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c
index 986890c..d22f064 100644
--- src/hg/lib/jksql.c
+++ src/hg/lib/jksql.c
@@ -1083,40 +1083,45 @@
 
 boolean sqlDatabaseExists(char *database)
 /* Return TRUE if database exists. */
 {
 struct sqlConnection *conn = sqlMayConnect(database);
 boolean exists = (conn != NULL);
 sqlDisconnect(&conn);
 return exists;
 }
 
 boolean sqlTableExists(struct sqlConnection *sc, char *table)
 /* Return TRUE if a table exists. */
 {
 char query[256];
 struct sqlResult *sr;
+if (sameString(table,""))
+    {
+    sqlCheckError("jksql sqlTableExists: Buggy code is feeding me empty table name. table=[%s].\n", table);  
+    return FALSE;
+    }
 // TODO If the ability to supply a list of tables is hardly used,
 // then we could switch it to simply %s below supporting a single
 // table at a time more securely.
 // DEBUG informational
 if (strchr(table,','))
     dumpStack("sqlTableExists called on multiple tables with table=[%s]\n", table);
 if (strchr(table,'%'))
     {
     // verbose is better than warn for early code calls?
-    dumpStack("jksql sqlTableExists: Buggy code is feeding me junk wildcards. table=[%s].\n", table);  
+    sqlCheckError("jksql sqlTableExists: Buggy code is feeding me junk wildcards. table=[%s].\n", table);  
     return FALSE;
     }
 // DEBUG END
 //verbose(1,"DEBUG sqlTableExists table=[%s]\n", table); // DEBUG REMOVE
 sqlSafef(query, sizeof(query), "SELECT 1 FROM %-s LIMIT 0", sqlCkIl(table));  // DEBUG RESTORE
 //safef(query, sizeof(query), "NOSQLINJ SELECT 1 FROM %s LIMIT 0", table);  // DEBUG REMOVE
 if ((sr = sqlUseOrStore(sc,query,mysql_use_result, FALSE)) == NULL)
     return FALSE;
 // TODO consider using sqlGetResultExt or something that would
 // allow you to abort on all errors except the actual table not found:
 // ERROR 1146 (42S02): Table 'hg19.chr_est' doesn't exist
 sqlFreeResult(&sr);
 return TRUE;
 }