9495fdb1301d0a0d63c3424849460761fdaf9c8b max Mon Oct 12 05:07:50 2015 -0700 handle table names that include the database diff --git src/hg/hgTables/hgTables.c src/hg/hgTables/hgTables.c index a4c2e6c..ab4a11e 100644 --- src/hg/hgTables/hgTables.c +++ src/hg/hgTables/hgTables.c @@ -928,30 +928,40 @@ if ( sameString(jp->b->database, db) && sameString(jp->b->table, table) ) { idField = cloneString(jp->b->field); break; } } } joinerPairFreeList(&jpList); } } /* If we haven't found the answer but this looks like a non-positional table, * use the first field. */ if (idField == NULL && !isCustomTrack(table) && (hti == NULL || !hti->isPos)) { + char *dotPos = strstr(table, "."); + if (dotPos != NULL) + // if the database is part of the table name in mysql notation + // (= databaseName.tableName), split the table string and override db. + // The jksql table name/field cache cannot handle it otherwise + { + *dotPos = 0; + db = table; + table = dotPos+1; + } struct sqlConnection *conn = track ? hAllocConnTrack(db, track) : hAllocConn(db); struct slName *fieldList = sqlListFields(conn, table); if (fieldList == NULL) errAbort("getIdField: Can't find fields of table %s", table); idField = cloneString(fieldList->name); slFreeList(&fieldList); hFreeConn(&conn); } return idField; } int countTableColumns(struct sqlConnection *conn, char *table) /* Count columns in table. */ { char *splitTable = chromTable(conn, table);