3846f517009c43abc65d227a4695645c9b5f3e8a braney Fri Feb 15 18:31:21 2013 -0800 changes necessary to support assembly hubs (#8072) diff --git src/hg/hgTables/joining.c src/hg/hgTables/joining.c index 6b8f691..a22f970 100644 --- src/hg/hgTables/joining.c +++ src/hg/hgTables/joining.c @@ -1,30 +1,31 @@ /* Joining.c - stuff to help create joined queries. Most of * the joining is happening in C rather than SQL, mostly so * that we can filter on an ID hash as we go, and also deal * with prefixes and suffixes to the dang keys. */ #include "common.h" #include "hash.h" #include "localmem.h" #include "memalloc.h" #include "dystring.h" #include "obscure.h" #include "jksql.h" #include "joiner.h" #include "hdb.h" #include "hgTables.h" +#include "trackHub.h" struct joinedRow /* A row that is joinable. Allocated in joinableResult->lm. */ { struct joinedRow *next; struct slName **fields; /* Fields user has requested. */ struct slName **keys; /* Fields to key from. */ bool passedFilter; /* TRUE if row has passed filter at this stage. */ bool hitThisTable; /* TRUE if hit on this table. */ }; struct joinedTables /* Database query result table that is joinable. */ @@ -281,34 +282,37 @@ hFreeConn(&conn); } else { fieldList = getBedFields(15); } makeOrderedCommaFieldList(fieldList, dtfList, dy); slFreeList(&fieldList); } static void makeBigBedOrderedCommaFieldList(struct joinerDtf *dtfList, struct dyString *dy) /* Make comma-separated field list in same order as fields are in * big bed. */ { -struct sqlConnection *conn = hAllocConn(dtfList->database); +struct sqlConnection *conn = NULL; +if (!trackHubDatabase(database)) + conn = hAllocConn(dtfList->database); struct slName *fieldList = bigBedGetFields(dtfList->table, conn); makeOrderedCommaFieldList(fieldList, dtfList, dy); slFreeList(&fieldList); +if (!trackHubDatabase(database)) hFreeConn(&conn); } static void makeBamOrderedCommaFieldList(struct joinerDtf *dtfList, struct dyString *dy) /* Make comma-separated field list in same order as fields are in * big bed. */ { struct slName *fieldList = bamGetFields(dtfList->table); makeOrderedCommaFieldList(fieldList, dtfList, dy); slFreeList(&fieldList); } static void makeVcfOrderedCommaFieldList(struct joinerDtf *dtfList, struct dyString *dy) @@ -997,44 +1001,48 @@ * add it to the filterTables list to trigger joining and identifier and/or region filtering */ if (!hasTable) { struct joinerDtf *dtf; AllocVar(dtf); dtf->database = cloneString(dtfDb); dtf->table = cloneString(dtfTable); slAddTail(&filterTables, dtf); doJoin = TRUE; } } if (! doJoin) { - struct sqlConnection *conn = hAllocConn(dtfList->database); + struct sqlConnection *conn = NULL; + + if (!trackHubDatabase(database)) + conn = hAllocConn(dtfList->database); struct dyString *dy = dyStringNew(0); if (isBigBed(database, dtfList->table, NULL, ctLookupName)) makeBigBedOrderedCommaFieldList(dtfList, dy); else if (isBamTable(dtfList->table)) makeBamOrderedCommaFieldList(dtfList, dy); else if (isVcfTable(dtfList->table)) makeVcfOrderedCommaFieldList(dtfList, dy); else if (isCustomTrack(dtfList->table)) makeCtOrderedCommaFieldList(dtfList, dy); else makeDbOrderedCommaFieldList(conn, dtfList->table, dtfList, dy); doTabOutTable(dtfList->database, dtfList->table, f, conn, dy->string); + if (!trackHubDatabase(database)) hFreeConn(&conn); } else { struct joiner *joiner = allJoiner; struct joinedTables *joined = joinedTablesCreate(joiner, primaryDb, primaryTable, dtfList, filterTables, 1000000, getRegions()); joinedTablesTabOutFile(joined, f); joinedTablesFree(&joined); } joinerDtfFreeList(&dtfList); joinerDtfFreeList(&filterTables); }