8dd9c1352b4461676b163531bf9e81bc4fb86c67
braney
  Thu May 26 13:35:57 2016 -0700
clone a string that might be a literal

diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c
index e37de14..e37c828 100644
--- src/hg/lib/jksql.c
+++ src/hg/lib/jksql.c
@@ -862,30 +862,31 @@
     return conn;
     }
 else
     {
     monitorPrint(conn, "SQL_NOT_FOUND_TABLE_CACHE", "%s", tableListTable);
     return NULL;
     }
 }
 
 static bool sqlTableCacheTableExists(struct sqlConnection *conn, char* table)
 /* check if table exists in table name cache */
 // (see redmine 3780 for some historical background on this caching)
 {
 char query[1024];
 char *tableListTable = cfgVal("showTableCache");
+table = cloneString(table);
 char *dot = strchr(table, '.');
 if (dot)
     {
     *dot = 0;
     sqlSafef(query, sizeof(query), "SELECT count(*) FROM %s.%s WHERE tableName='%s'", table, tableListTable, dot+1);
     *dot = '.';
     }
 else
     sqlSafef(query, sizeof(query), "SELECT count(*) FROM %s WHERE tableName='%s'", tableListTable, table);
 return (sqlQuickNum(conn, query)!=0);
 }
 
 static struct slName *sqlTableCacheQuery(struct sqlConnection *conn, char *likeExpr)
 /* This function queries the tableCache table. It is used by the sqlTableList 
  * function, so it doe not have to connect to the main sql server just to get a list of table names.