36a6c30381ac63be42824055efee08a9574e2030 galt Wed Nov 14 09:52:24 2012 -0800 temporary tables will now be created in a special database hgTemp diff --git src/hg/hgTables/identifiers.c src/hg/hgTables/identifiers.c index c476e7c..fedbe89 100644 --- src/hg/hgTables/identifiers.c +++ src/hg/hgTables/identifiers.c @@ -65,31 +65,32 @@ /* Return a list of several example values of table.field. */ { if (isBamTable(table)) { assert(sameString(field, "qName")); return randomBamIds(table, conn, count); } if (isVcfTable(table)) { assert(sameString(field, "id")); return randomVcfIds(table, conn, count); } else { char fullTable[HDB_MAX_TABLE_STRING]; - if (! hFindSplitTable(database, NULL, table, fullTable, NULL)) + char *c = strchr(table, '.'); + if (c || ! hFindSplitTable(database, NULL, table, fullTable, NULL)) safecpy(fullTable, sizeof(fullTable), table); return sqlRandomSampleConn(conn, fullTable, field, count); } } static void explainIdentifiers(struct sqlConnection *conn, char *idField) /* Tell the user what field(s) they may paste/upload values for, and give * some examples. */ { char *xrefTable = NULL, *xrefIdField = NULL, *aliasField = NULL; getXrefInfo(conn, &xrefTable, &xrefIdField, &aliasField); hPrintf("The items must be values of the <B>%s</B> field of the currently " "selected table, <B>%s</B>", idField, curTable); if (aliasField != NULL) @@ -112,31 +113,37 @@ if (!isCustomTrack(curTable)) { struct slName *exampleList = NULL, *ex; hPrintf("Some example values:<BR>\n"); exampleList = getExamples(conn, curTable, idField, 3); for (ex = exampleList; ex != NULL; ex = ex->next) { char *tmp = htmlEncode(ex->name); hPrintf("<TT>%s</TT><BR>\n", tmp); freeMem(tmp); } if (aliasField != NULL) { char tmpTable[512]; char query[2048]; - safef(tmpTable, sizeof(tmpTable), "tmp%s%s", curTable, xrefTable); + // do not use any db. prefix on curTable for name + char *plainCurTable = strrchr(curTable, '.'); + if (plainCurTable) + plainCurTable++; + else + plainCurTable = curTable; + safef(tmpTable, sizeof(tmpTable), "hgTemp.tmp%s%s", plainCurTable, xrefTable); if (differentString(xrefTable, curTable)) safef(query, sizeof(query), "create temporary table %s select %s.%s as %s from %s,%s " "where %s.%s = %s.%s and %s.%s != %s.%s limit 100000", tmpTable, xrefTable, aliasField, aliasField, xrefTable, curTable, xrefTable, xrefIdField, curTable, idField, xrefTable, xrefIdField, xrefTable, aliasField); else safef(query, sizeof(query), "create temporary table %s select %s from %s " "where %s != %s limit 100000", tmpTable, aliasField, xrefTable, aliasField, xrefIdField); sqlUpdate(conn, query); exampleList = getExamples(conn, tmpTable, aliasField, 3); for (ex = exampleList; ex != NULL; ex = ex->next) @@ -157,31 +164,34 @@ actualDb = wikiDbName(); } char *oldPasted = forCurTable() ? cartUsualString(cart, hgtaPastedIdentifiers, "") : ""; struct hTableInfo *hti = maybeGetHti(actualDb, curTable, conn); char *idField = getIdField(actualDb, curTrack, curTable, hti); htmlOpen("Paste In Identifiers for %s", curTableLabel()); if (idField == NULL) errAbort("Sorry, I can't tell which field of table %s to treat as the " "identifier field.", curTable); hPrintf("<FORM ACTION=\"%s\" METHOD=%s>\n", getScriptName(), cartUsualString(cart, "formMethod", "POST")); cartSaveSession(cart); hPrintf("Please paste in the identifiers you want to include.\n"); +if (sqlDatabaseExists("hgTemp")) explainIdentifiers(alternateConn, idField); +else + warn("No hgTemp database found for temporary tables.<br>Please src/product/README.mysql.setup for more information."); hPrintf("<BR>\n"); cgiMakeTextArea(hgtaPastedIdentifiers, oldPasted, 10, 70); hPrintf("<BR>\n"); cgiMakeButton(hgtaDoPastedIdentifiers, "submit"); hPrintf(" "); cgiMakeButton(hgtaDoClearPasteIdentifierText, "clear"); hPrintf(" "); cgiMakeButton(hgtaDoMainPage, "cancel"); hPrintf("</FORM>"); cgiDown(0.9); htmlClose(); if (sameWord(curTable, WIKI_TRACK_TABLE)) wikiDisconnect(&alternateConn); }