void joinerCheckTableCoverage(struct joiner *joiner, char *specificDb)
/* Check that all tables either are part of an identifier or
 * are in the tablesIgnored statements. */
{
    struct slName *miss, *missList = NULL;
    struct hashEl *dbList, *db;

    dbList = hashElListHash(joiner->databasesChecked);
    for (db = dbList; db != NULL; db = db->next)
    {
        if (specificDb == NULL || sameString(db->name, specificDb))
        {
            struct sqlConnection *conn = sqlMayConnect(db->name);
            if (conn == NULL)
                warn("Error: database %s doesn't exist", db->name);
            else
            {
                struct slName *table;
                struct slName *tableList = sqlListTables(conn);
                struct hash *hash = getCoveredTables(joiner, db->name, conn);
                for (table = tableList; table != NULL; table = table->next)
                {
                    if (!hashLookup(hash, table->name))
                    {
                        char fullName[256];
                        safef(fullName, sizeof(fullName), "%s.%s",
                              db->name, table->name);
                        miss = slNameNew(fullName);
                        slAddHead(&missList, miss);
                    }
                    else
                        verbose(2,"tableCovered: '%s'\n", table->name);
                }
                slFreeList(&tableList);
                freeHash(&hash);
                reportErrorList(&missList, "tables not in .joiner file");
            }
            sqlDisconnect(&conn);
        }
    }
    slFreeList(&dbList);
}
Ejemplo n.º 2
0
struct slName *tablesForDb(char *db)
/* Find tables associated with database. */
{
boolean isGenomeDb = sameString(db, database);
struct sqlConnection *conn = hAllocConn(db);
struct slName *raw, *rawList = sqlListTables(conn);
struct slName *cooked, *cookedList = NULL;
struct hash *uniqHash = newHash(0);

hFreeConn(&conn);
for (raw = rawList; raw != NULL; raw = raw->next)
    {
    if (cartTrackDbIsAccessDenied(db, raw->name))
        continue;
    if (isGenomeDb)
	{
	/* Deal with tables split across chromosomes. */
	char *root = unsplitTableName(raw->name);
	if (cartTrackDbIsAccessDenied(db, root))
	    continue;
	if (!hashLookup(uniqHash, root))
	    {
	    hashAdd(uniqHash, root, NULL);
	    cooked = slNameNew(root);
	    slAddHead(&cookedList, cooked);
	    }
	}
    else
        {
	char dbTable[256];
	safef(dbTable, sizeof(dbTable), "%s.%s", db, raw->name);
	cooked = slNameNew(dbTable);
	slAddHead(&cookedList, cooked);
	}
    }
hashFree(&uniqHash);
slFreeList(&rawList);
slSort(&cookedList, slNameCmp);
return cookedList;
}