100197dd44df6edfff0cfb94a4c9b8dbacc49b54 galt Mon May 20 15:21:23 2013 -0700 does not work on innodb diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c index a3d4600..4dc7aba 100644 --- src/hg/lib/jksql.c +++ src/hg/lib/jksql.c @@ -2226,72 +2226,75 @@ if (gmTime) tm = gmtime(timep); else tm = localtime(timep); ret = (char *)needMem(25*sizeof(char)); /* 25 is good for a billion years */ snprintf(ret, 25*sizeof(char), "%d-%02d-%02d %02d:%02d:%02d", 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); return(ret); } static int getUpdateFieldIndex(struct sqlResult *sr) -/* Return index of update field. */ +/* Return index of update field. + * Note: does NOT work on innoDB! */ { static int updateFieldIndex = -1; if (updateFieldIndex < 0) { int ix; char *name; for (ix=0; ;++ix) { name = sqlFieldName(sr); if (name == NULL) errAbort("Can't find Update_time field in show table status result"); if (sameString("Update_time", name)) { updateFieldIndex = ix; break; } } } return updateFieldIndex; } char *sqlTableUpdate(struct sqlConnection *conn, char *table) -/* Get last update time for table as an SQL string */ +/* Get last update time for table as an SQL string + * Note: does NOT work on innoDB! */ { char query[512], **row; struct sqlResult *sr; int updateIx; char *ret; safef(query, sizeof(query), "show table status like '%s'", table); sr = sqlGetResult(conn, query); updateIx = getUpdateFieldIndex(sr); row = sqlNextRow(sr); if (row == NULL) errAbort("Database table %s doesn't exist", table); ret = cloneString(row[updateIx]); sqlFreeResult(&sr); return ret; } time_t sqlTableUpdateTime(struct sqlConnection *conn, char *table) -/* Get last update time for table. */ +/* Get last update time for table. + * Note: does NOT work on innoDB! */ { char *date = sqlTableUpdate(conn, table); time_t time = sqlDateToUnixTime(date); freeMem(date); return time; } char *sqlGetPrimaryKey(struct sqlConnection *conn, char *table) /* Get primary key if any for table, return NULL if none. */ { char query[512]; struct sqlResult *sr; char **row; char *key = NULL; safef(query, sizeof(query), "describe %s", table);