696a1c3885a8f92adeb0508a68f5f9f962f0b1e4 galt Wed Jun 19 21:32:03 2013 -0700 dealing with code looking for split tableNames which unfortunately use chrom names with dashes which mysql does not allow. diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c index 0317f20..7e407c0 100644 --- src/hg/lib/jksql.c +++ src/hg/lib/jksql.c @@ -1085,47 +1085,50 @@ /* 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); + dumpStack("jksql sqlTableExists: Buggy code is feeding me empty table name. table=[%s].\n", table); fflush(stderr); // log only 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? - sqlCheckError("jksql sqlTableExists: Buggy code is feeding me junk wildcards. table=[%s].\n", table); + dumpStack("jksql sqlTableExists: Buggy code is feeding me junk wildcards. table=[%s].\n", table); fflush(stderr); // log only return FALSE; } -// DEBUG END -//verbose(1,"DEBUG sqlTableExists table=[%s]\n", table); // DEBUG REMOVE +if (strchr(table,'-')) + { + return FALSE; // mysql does not allow tables with dash (-) so it will not be found. + // hg/lib/hdb.c can generate an invalid table names with dashes while looking for split tables, + // if the first chrom name has a dash in it. Examples found were: scaffold_0.1-193456 scaffold_0.1-13376 HERVE_a-int 1-1 + // Assembly hubs also may have dashes in chrom names. + } 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; } bool sqlColumnExists(struct sqlConnection *conn, char *tableName, char *column) /* return TRUE if column exists in table. tableName can contain sql wildcards */ { char query[1024];