5b8c4168d4807c729fc8b1f199d9eb03c9411069 galt Thu Mar 3 18:40:54 2016 -0800 Replacing simple literal NOSQLINJ in string with the #define NOSQLINJ. This is slightly better because the compiler can catch a mis-spelling of the NOSQLINJ keyword. This was suggested by Angie. diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c index 84ba68e..95e40d1 100644 --- src/hg/lib/hdb.c +++ src/hg/lib/hdb.c @@ -514,43 +514,43 @@ * has no chromInfo. */ { if (trackHubDatabase(db)) return trackHubDefaultChrom(db); static struct hash *hash = NULL; struct hashEl *hel = NULL; if (hash == NULL) hash = hashNew(0); hel = hashStore(hash, db); if (hel->val == NULL) { struct sqlConnection *conn = hAllocConn(db); if (sqlTableExists(conn, "chromInfo")) - hel->val = sqlQuickString(conn, "NOSQLINJ select chrom from chromInfo limit 1"); + hel->val = sqlQuickString(conn, NOSQLINJ "select chrom from chromInfo limit 1"); hFreeConn(&conn); } return hel->val; } int hChromCount(char *db) /* Return the number of chromosomes (scaffolds etc.) in the given db. */ { if (trackHubDatabase(db)) return trackHubChromCount(db); struct sqlConnection *conn = hAllocConn(db); -int count = sqlQuickNum(conn, "NOSQLINJ select count(*) from chromInfo"); +int count = sqlQuickNum(conn, NOSQLINJ "select count(*) from chromInfo"); hFreeConn(&conn); return count; } struct sqlConnection *hAllocConn(char *db) /* Get free connection if possible. If not allocate a new one. */ { if (hdbCc == NULL) hdbCc = sqlConnCacheNew(); return sqlConnCacheAlloc(hdbCc, db); } struct sqlConnection *hAllocConnMaybe(char *db) /* Get free connection if possible. If not allocate a new one. Return * NULL if db doesn't exist or can't be connected to. */ @@ -1260,31 +1260,31 @@ { int size = hChromSize(db, chromName); return hDnaFromSeq(db, chromName, 0, size, dnaLower); } struct slName *hAllChromNames(char *db) /* Get list of all chromosome names in database. */ { if (trackHubDatabase(db)) return trackHubAllChromNames(db); struct slName *list = NULL; struct sqlConnection *conn = hAllocConn(db); struct sqlResult *sr; char **row; -sr = sqlGetResult(conn, "NOSQLINJ select chrom from chromInfo"); +sr = sqlGetResult(conn, NOSQLINJ "select chrom from chromInfo"); while ((row = sqlNextRow(sr)) != NULL) { struct slName *el = slNameNew(row[0]); slAddHead(&list, el); } sqlFreeResult(&sr); hFreeConn(&conn); return list; } char *hReplaceGbdbLocal(char* fileName) /* Returns a gbdb filename, potentially rewriting it according to hg.conf's gbdbLoc1 */ /* Result has to be freed */ { if (fileName==NULL) @@ -2577,31 +2577,31 @@ return db; } struct dbDb *hDbDbListMaybeCheck(boolean doCheck) /* Return list of databases in dbDb. If doCheck, check database existence. * The list includes the name, description, and where to * find the nib-formatted DNA files. Free this with dbDbFree. */ { struct sqlConnection *conn = hConnectCentral(); struct sqlResult *sr; char **row; struct dbDb *dbList = NULL, *db; struct hash *hash = sqlHashOfDatabases(); char query[1024]; -safef(query, sizeof query, "NOSQLINJ select * from %s order by orderKey,name desc", dbDbTable()); +safef(query, sizeof query, NOSQLINJ "select * from %s order by orderKey,name desc", dbDbTable()); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { db = dbDbLoad(row); if (!doCheck || hashLookup(hash, db->name)) { slAddHead(&dbList, db); } else dbDbFree(&db); } sqlFreeResult(&sr); hashFree(&hash); hDisconnectCentral(&conn); slReverse(&dbList); @@ -4328,31 +4328,31 @@ } struct dbDb *hGetIndexedDatabasesForClade(char *db) /* Get list of active databases in db's clade. * Dispose of this with dbDbFreeList. */ { return hGetIndexedDbsMaybeClade(db); } struct slPair *hGetCladeOptions() /* Return a list of slPairs, each containing clade menu value (hgcentral.clade.name, e.g. 'mammal') * and clade menu label (hgcentral.clade.label, e.g. 'Mammal'), * useful for constructing a clade menu. */ { // get only the clades that have actual active genomes -char *query = "NOSQLINJ " +char *query = NOSQLINJ "" "SELECT DISTINCT(c.name), c.label " "FROM %s c, %s g, %s d " "WHERE c.name=g.clade AND d.organism=g.genome AND d.active=1 " "ORDER BY c.priority"; char queryBuf[4096]; safef(queryBuf, sizeof queryBuf, query, cladeTable(), genomeCladeTable(), dbDbTable()); struct sqlConnection *conn = hConnectCentral(); struct slPair *nativeClades = sqlQuickPairList(conn, queryBuf); hDisconnectCentral(&conn); struct slPair *trackHubClades = trackHubGetCladeLabels(); return slCat(nativeClades, trackHubClades); } @@ -4589,38 +4589,38 @@ slSort(&liftOverDbList, hDbDbCmpOrderKey); return liftOverDbList; } struct dbDb *hGetBlatIndexedDatabases() /* Get list of databases for which there is a BLAT index. * Dispose of this with dbDbFreeList. */ { struct hash *hash=newHash(5); struct sqlConnection *conn = hConnectCentral(); struct sqlResult *sr; char **row; struct dbDb *dbList = NULL, *db; /* Get hash of active blat servers. */ -sr = sqlGetResult(conn, "NOSQLINJ select db from blatServers"); +sr = sqlGetResult(conn, NOSQLINJ "select db from blatServers"); while ((row = sqlNextRow(sr)) != NULL) hashAdd(hash, row[0], NULL); sqlFreeResult(&sr); /* Scan through dbDb table, keeping ones that are indexed. */ char query[1024]; -safef(query, sizeof query, "NOSQLINJ select * from %s order by orderKey,name desc", dbDbTable()); +safef(query, sizeof query, NOSQLINJ "select * from %s order by orderKey,name desc", dbDbTable()); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { db = dbDbLoad(row); if (hashLookup(hash, db->name)) { slAddHead(&dbList, db); } else dbDbFree(&db); } sqlFreeResult(&sr); hDisconnectCentral(&conn); hashFree(&hash); slReverse(&dbList); @@ -4710,55 +4710,55 @@ answer = cloneString(row[0]); } sqlFreeResult(&sr); hFreeConn(&conn); return answer; } struct hash *hChromSizeHash(char *db) /* Get hash of chromosome sizes for database. Just hashFree it when done. */ { struct sqlConnection *conn = sqlConnect(db); struct sqlResult *sr; char **row; struct hash *hash = newHash(0); -sr = sqlGetResult(conn, "NOSQLINJ select chrom,size from chromInfo"); +sr = sqlGetResult(conn, NOSQLINJ "select chrom,size from chromInfo"); while ((row = sqlNextRow(sr)) != NULL) hashAddInt(hash, row[0], sqlUnsigned(row[1])); sqlFreeResult(&sr); sqlDisconnect(&conn); return hash; } struct hash *hChromSizeHashFromFile(char *fileName) /* Get hash of chromosome sizes from 2- or 3-column chrom.sizes file. hashFree when done. */ { struct hash *chromHash = hashNew(0); struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[2]; while (lineFileRow(lf, row)) hashAddInt(chromHash, row[0], sqlUnsigned(row[1])); lineFileClose(&lf); return chromHash; } struct slName *hChromList(char *db) /* Get the list of chrom names from the database's chromInfo table. */ { struct sqlConnection *conn = hAllocConn(db); -struct slName *list = sqlQuickList(conn, "NOSQLINJ select chrom from chromInfo"); +struct slName *list = sqlQuickList(conn, NOSQLINJ "select chrom from chromInfo"); hFreeConn(&conn); return list; } char *hgDirForOrg(char *org) /* Make directory name from organism name - getting * rid of dots and spaces. */ { org = cloneString(org); stripChar(org, '.'); subChar(org, ' ', '_'); return org; } struct hash *hgReadRa(char *genome, char *database, char *rootDir,