diff src/cjr_print.sml @ 1293:acabf3935060

tryDml
author Adam Chlipala <adam@chlipala.net>
date Sun, 05 Sep 2010 14:00:57 -0400
parents 514be09d5018
children b4480a56cab7
line wrap: on
line diff
--- a/src/cjr_print.sml	Sun Sep 05 12:50:06 2010 -0400
+++ b/src/cjr_print.sml	Sun Sep 05 14:00:57 2010 -0400
@@ -1791,8 +1791,11 @@
                      box []]
         end
 
-      | EDml {dml, prepared} =>
-        box [string "(uw_begin_region(ctx), ({",
+      | EDml {dml, prepared, mode} =>
+        box [case mode of
+                 Settings.Error => box []
+               | Settings.None => string "({const char *uw_errmsg = NULL;",
+             string "(uw_begin_region(ctx), ({",
              newline,
              case prepared of
                  NONE => box [string "char *dml = ",
@@ -1800,7 +1803,7 @@
                               string ";",
                               newline,
                               newline,
-                              #dml (Settings.currentDbms ()) loc]
+                              #dml (Settings.currentDbms ()) (loc, mode)]
                | SOME {id, dml = dml'} =>
                  let
                      val inputs = getPargs dml
@@ -1823,16 +1826,23 @@
                           #dmlPrepared (Settings.currentDbms ()) {loc = loc,
                                                                   id = id,
                                                                   dml = dml',
-                                                                  inputs = map #2 inputs}]
+                                                                  inputs = map #2 inputs,
+                                                                  mode = mode}]
                  end,
              newline,
              newline,
-
              string "uw_end_region(ctx);",
              newline,
-             string "uw_unit_v;",
+
+             case mode of
+                 Settings.Error => string "uw_unit_v;"
+               | Settings.None => string "uw_errmsg ? uw_strdup(ctx, uw_errmsg) : NULL;",
+
              newline,
-             string "}))"]
+             string "}))",
+             case mode of
+                 Settings.Error => box []
+               | Settings.None => string ";})"]
 
       | ENextval {seq, prepared} =>
         box [string "({",