5481476932dcbcff3c36b1b77633f699cb0d7a85 galt Mon Oct 30 13:21:53 2017 -0700 Code review feedback. diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c index 134310b..3bfeeb1 100644 --- src/hg/lib/jksql.c +++ src/hg/lib/jksql.c @@ -1710,43 +1710,44 @@ 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. } // use the table cache if we have one struct sqlConnection *cacheConn = sqlTableCacheFindConn(sc); if (cacheConn) return sqlTableCacheTableExists(cacheConn, table); char *err; unsigned int errNo; +const int tableNotFoundCode = 1146; sqlSafef(query, sizeof(query), "SELECT 1 FROM %-s LIMIT 0", sqlCkIl(table)); if ((sr = sqlGetResultExt(sc, query, &errNo, &err)) == NULL) { - if (errNo == 1146) // table not found + if (errNo == tableNotFoundCode) return FALSE; if (sc->failoverConn) { // if not found but we have a main connection, check the main connection, too if ((sr = sqlGetResultExt(sc->failoverConn, query, &errNo, &err)) == NULL) { - if (errNo == 1146) // table not found + if (errNo == tableNotFoundCode) return FALSE; } } } if (!sr) errAbort("Mysql error during sqlTableExists(%s) %d: %s", table, errNo, err); 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 */ {