b4de30fb01a1168eadfcc65206714f1573eef8c9
max
  Tue Mar 10 06:31:07 2015 -0700
a mirror that has the failover connection (=hgdownload) enabled
currently just crashes in hgTables. Adding an additional check
to catch this condition and suppress printing the example values,
just like what we do for custom tracks.
refs #14945

diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c
index 60f0039..8ec042b 100644
--- src/hg/lib/jksql.c
+++ src/hg/lib/jksql.c
@@ -2973,30 +2973,56 @@
 
 struct slName *sqlRandomSampleConn(struct sqlConnection *conn, char *table,
 				   char *field, int count)
 /* Get random sample from conn. */
 {
 return sqlRandomSampleWithSeedConn(conn, table, field, count, -1);
 }
 
 struct slName *sqlRandomSample(char *db, char *table, char *field, int count)
 /* Get random sample from database. */
 {
 return sqlRandomSampleWithSeed(db, table, field, count, -1);
 }
 
 
+bool sqlCanCreateTemp(struct sqlConnection *conn)
+/* Return True if it looks like we can write temp tables into the current database
+ * Can be used to check if sqlRandomSampleWithSeed-functions are safe to call.
+ * */
+{
+// assume we can write if the current connection has no failOver connection 
+if (conn->failoverConn==NULL)
+    {
+    return TRUE;
+    }
+
+char *err;
+unsigned int errNo;
+
+// try a create temp query
+char *query = "CREATE TEMPORARY TABLE testTemp (number INT); DROP TABLE testTemp;";
+struct sqlResult *sr = sqlGetResultExt(conn, query, &errNo, &err);
+if (sr==NULL)
+    {
+    return FALSE;
+    }
+
+sqlFreeResult(&sr);
+return TRUE;
+}
+
 static struct sqlFieldInfo *sqlFieldInfoParse(char **row)
 /* parse a row into a sqlFieldInfo object */
 {
 struct sqlFieldInfo *fi;
 AllocVar(fi);
 fi->field = cloneString(row[0]);
 fi->type = cloneString(row[1]);
 fi->allowsNull = sameString(row[2], "YES");
 fi->key = cloneString(row[3]);
 fi->defaultVal = cloneString(row[4]);
 fi->extra = cloneString(row[5]);
 return fi;
 }
 
 struct sqlFieldInfo *sqlFieldInfoGet(struct sqlConnection *conn, char *table)