db36afeb468b02149d727fc0c28743a3b7eb6ebe
kate
  Thu Apr 28 20:46:10 2011 -0700
Add commands to encodeExp lib and tool: copy (for backup), remove (whack experiment from table), deacc (was 'revoke').  Expand 'history' command.  Fixes to action and user logging in history table'
diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c
index afc59e3..279f6b7 100644
--- src/hg/lib/jksql.c
+++ src/hg/lib/jksql.c
@@ -924,30 +924,43 @@
 safef(query, sizeof(query), "rename table %s to %s", table1, table2);
 sqlUpdate(sc, query);
 }
 
 void sqlDropTable(struct sqlConnection *sc, char *table)
 /* Drop table if it exists. */
 {
 if (sqlTableExists(sc, table))
     {
     char query[256];
     safef(query, sizeof(query), "drop table %s", table);
     sqlUpdate(sc, query);
     }
 }
 
+void sqlCopyTable(struct sqlConnection *sc, char *table1, char *table2)
+/* Copy table1 to table2 */
+{
+char query[256];
+
+if (table1 == NULL || table2 == NULL)
+    return;
+safef(query, sizeof(query), "create table %s like %s", table2, table1);
+sqlUpdate(sc, query);
+safef(query, sizeof(query), "insert into %s select * from  %s", table2, table1);
+sqlUpdate(sc, query);
+}
+
 void sqlGetLock(struct sqlConnection *sc, char *name)
 /* Sets an advisory lock on the process for 1000s returns 1 if successful,*/
 /* 0 if name already locked or NULL if error occurred */
 /* blocks another client from obtaining a lock with the same name */
 {
 char query[256];
 struct sqlResult *res;
 char **row = NULL;
 
 safef(query, sizeof(query), "select get_lock('%s', 1000)", name);
 res = sqlGetResult(sc, query);
 while ((row=sqlNextRow(res)))
     {
     if (sameWord(*row, "1"))
         break;