17e81564934600bd6c06c966d4ade17f4e49d689 braney Mon Apr 18 14:28:20 2016 -0700 get sqlTableExists to work is table names of the form db.table when tableList caching is being used diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c index 0ea0749..e37de14 100644 --- src/hg/lib/jksql.c +++ src/hg/lib/jksql.c @@ -862,30 +862,38 @@ 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"); +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. * Returns all table names from the table name cache as a list. * Can optionally filter with a likeExpr e.g. "LIKE snp%". */ { char *tableList = cfgVal("showTableCache"); struct slName *list = NULL, *el; char query[1024]; // mysql SHOW TABLES is sorted alphabetically by default if (likeExpr==NULL)