src/hg/lib/jksql.c 1.137
1.137 2009/10/15 23:52:38 galt
adding warnings to jksql new for mysql5
Index: src/hg/lib/jksql.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/jksql.c,v
retrieving revision 1.136
retrieving revision 1.137
diff -b -B -U 4 -r1.136 -r1.137
--- src/hg/lib/jksql.c 23 Sep 2009 18:42:21 -0000 1.136
+++ src/hg/lib/jksql.c 15 Oct 2009 23:52:38 -0000 1.137
@@ -1191,8 +1191,27 @@
return (sqlUnsigned(majorVerBuf) >= 4);
}
+void sqlWarnings(struct sqlConnection *conn, int numberOfWarnings)
+/* Show the number of warnings requested. New feature in mysql5. */
+{
+struct sqlResult *sr;
+char **row;
+char query[256];
+struct dyString *dy = dyStringNew(0);
+safef(query,sizeof(query),"show warnings limit 0, %d", numberOfWarnings);
+sr = sqlGetResult(conn, query);
+dyStringPrintf(dy, "Level Code Message\n");
+while ((row = sqlNextRow(sr)) != NULL)
+ {
+ dyStringPrintf(dy, "%s %s %s\n", row[0], row[1], row[2]);
+ }
+sqlFreeResult(&sr);
+warn("%s", dy->string);
+dyStringFree(&dy);
+}
+
void sqlLoadTabFile(struct sqlConnection *conn, char *path, char *table,
unsigned options)
/* Load a tab-seperated file into a database table, checking for errors.
* Options are the SQL_TAB_* bit set. SQL_TAB_FILE_ON_SERVER is ignored if
@@ -1281,9 +1300,12 @@
doAbort = FALSE; /* don't abort on errors */
else if ((numWarnings > 0) &&
(options & (SQL_TAB_FILE_WARN_ON_ERROR|SQL_TAB_FILE_WARN_ON_WARN)))
doAbort = FALSE; /* don't abort on warnings */
-
+ if (numWarnings > 0)
+ {
+ sqlWarnings(conn, 10); /* show the first 10 warnings */
+ }
if (doAbort)
errAbort("load of %s did not go as planned: %d record(s), "
"%d row(s) skipped, %d warning(s) loading %s",
table, numRecs, numSkipped, numWarnings, path);