5642df620a393628d64ef16efe6e6db6d99ef379 hiram Tue Apr 5 13:05:08 2011 -0700 indicate total tables even when not using tableStatus and indicate no tables when no tables diff --git src/hg/dbTrash/dbTrash.c src/hg/dbTrash/dbTrash.c index 1e1f45b..3be26a4 100644 --- src/hg/dbTrash/dbTrash.c +++ src/hg/dbTrash/dbTrash.c @@ -1,17 +1,18 @@ /* dbTrash - drop tables from a database older than specified N hours. */ #include "common.h" +#include "obscure.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "jksql.h" #include "hdb.h" #include "customTrack.h" static char const rcsid[] = "$Id: dbTrash.c,v 1.17 2009/01/15 20:29:01 hiram Exp $"; void usage() /* Explain usage and exit. */ { errAbort( "dbTrash - drop tables from a database older than specified N hours\n" "usage:\n" @@ -317,62 +318,89 @@ } } /* perhaps the table was already dropped, but not from the metaInfo */ struct hashEl *elList = hashElListHash(expiredHash); struct hashEl *el; for (el = elList; el != NULL; el = el->next) { verbose(2,"%s exists in %s only\n", el->name, CT_META_INFO); if (drop) ctTouchLastUse(conn, el->name, FALSE); /* removes metaInfo row */ } if (drop) { + char comment[256]; if (expiredTableNames) { - char comment[256]; struct slName *el; int droppedCount = 0; /* customTrash DB user permissions do not have permissions to * drop tables. Must use standard special user that has all * permissions. If we are not using the standard user at this * point, then switch to it. */ if (sameWord(db,CUSTOM_TRASH)) { sqlDisconnect(&conn); conn = sqlConnect(db); } for (el = expiredTableNames; el != NULL; el = el->next) { verbose(2,"# drop %s\n", el->name); sqlDropTable(conn, el->name); ctTouchLastUse(conn, el->name, FALSE); /* removes metaInfo row */ ++droppedCount; } /* add a comment to the history table and finish up connection */ if (tableStatus) safef(comment, sizeof(comment), "Dropped %d tables with " "total size %llu", droppedCount, totalSize); else safef(comment, sizeof(comment), "Dropped %d tables, no size info", droppedCount); verbose(2,"# %s\n", comment); hgHistoryComment(conn, "%s", comment); } + else + { + safef(comment, sizeof(comment), + "Dropped no tables, none expired"); + verbose(2,"# %s\n", comment); + } + } +else + { + char comment[256]; + if (expiredTableNames) + { + int droppedCount = slCount(expiredTableNames); + if (tableStatus) + safef(comment, sizeof(comment), "Would have dropped %d tables with " + "total size %llu", droppedCount, totalSize); + else + safef(comment, sizeof(comment), + "Would have dropped %d tables, no size info", droppedCount); + verbose(2,"# %s\n", comment); + } + else + { + safef(comment, sizeof(comment), + "Would have dropped no tables, none expired"); + verbose(2,"# %s\n", comment); + } } sqlDisconnect(&conn); } int main(int argc, char *argv[]) /* Process command line. */ { struct tm *tm; if (argc < 2) usage(); optionInit(&argc, argv, options); if (!optionExists("age")) { @@ -406,17 +434,19 @@ historyToo = optionExists("historyToo"); db = optionVal("db",db); extFileCheck = optionExists("extFile"); extDel = optionExists("extDel"); tableStatus = optionExists("tableStatus"); topDir = optionVal("topDir", topDir); verbose(2,"# drop requested: %s\n", drop ? "TRUE" : "FALSE"); verbose(2,"# historyToo: %s\n", historyToo ? "TRUE" : "FALSE"); verbose(2,"# extFile: %s\n", extFileCheck ? "TRUE" : "FALSE"); verbose(2,"# extDel: %s\n", extDel ? "TRUE" : "FALSE"); verbose(2,"# tableStatus: %s\n", tableStatus ? "TRUE" : "FALSE"); verbose(2,"# topDir: %s\n", topDir); verbose(2,"# database: %s\n", db); dbTrash(db); +if (verboseLevel() > 1) + printVmPeak(); return 0; }