Diff
Not logged in

Differences From:

File src/db.c part of check-in [5eac33a6bd] - Bug fix in the local database finder. by drh on 2007-07-30 13:01:08. [view]

To:

File src/db.c part of check-in [396cc2a4eb] - When errors occur during CGI, make sure the error is returned in a correct CGI reply. by drh on 2007-07-30 13:34:35. [view]

@@ -57,11 +57,22 @@
 ** Call this routine when a database error occurs.
 */
 static void db_err(const char *zFormat, ...){
   va_list ap;
+  char *z;
   va_start(ap, zFormat);
-  fprintf(stderr, "%s\n", vmprintf(zFormat, ap));
+  z = vmprintf(zFormat, ap);
   va_end(ap);
+  if( g.cgiPanic ){
+    g.cgiPanic = 0;
+    cgi_printf("<p><font color=\"red\">%h</font></p>", z);
+    style_footer();
+    cgi_reply();
+  }else{
+    fprintf(stderr, "%s: %s\n", g.argv[0], z);
+  }
+  db_force_rollback();
+  exit(1);
   exit(1);
 }
 
 static int nBegin = 0;      /* Nesting depth of BEGIN */