aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sqlite.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2010-09-05 14:00:57 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2010-09-05 14:00:57 -0400
commitee175ea1f9151123e47d9cbfee0c6329b2e5d934 (patch)
treeb1f65d2c756f6867bc59eb1a0bb424deefacfabe /src/sqlite.sml
parent1d30544730c4785eef4aabc4a224c03fe1b26983 (diff)
tryDml
Diffstat (limited to 'src/sqlite.sml')
-rw-r--r--src/sqlite.sml23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/sqlite.sml b/src/sqlite.sml
index 74093f21..20afd5bc 100644
--- a/src/sqlite.sml
+++ b/src/sqlite.sml
@@ -688,7 +688,7 @@ fun queryPrepared {loc, id, query, inputs, cols, doCols, nested} =
box [string "uw_pop_cleanup(ctx);",
newline]]
-fun dmlCommon {loc, dml} =
+fun dmlCommon {loc, dml, mode} =
box [string "int r;",
newline,
@@ -701,14 +701,17 @@ fun dmlCommon {loc, dml} =
newline,
newline,
- string "if (r != SQLITE_DONE) uw_error(ctx, FATAL, \"",
- string (ErrorMsg.spanToString loc),
- string ": DML step failed: %s<br />%s\", ",
- dml,
- string ", sqlite3_errmsg(conn->conn));",
+ string "if (r != SQLITE_DONE) ",
+ case mode of
+ Settings.Error => box [string "uw_error(ctx, FATAL, \"",
+ string (ErrorMsg.spanToString loc),
+ string ": DML step failed: %s<br />%s\", ",
+ dml,
+ string ", sqlite3_errmsg(conn->conn));"]
+ | Settings.None => string "uw_errmsg = sqlite3_errmsg(conn->conn);",
newline]
-fun dml loc =
+fun dml (loc, mode) =
box [string "uw_conn *conn = uw_get_db(ctx);",
newline,
string "sqlite3_stmt *stmt;",
@@ -721,12 +724,12 @@ fun dml loc =
newline,
newline,
- dmlCommon {loc = loc, dml = string "dml"},
+ dmlCommon {loc = loc, dml = string "dml", mode = mode},
string "uw_pop_cleanup(ctx);",
newline]
-fun dmlPrepared {loc, id, dml, inputs} =
+fun dmlPrepared {loc, id, dml, inputs, mode = mode} =
box [string "uw_conn *conn = uw_get_db(ctx);",
newline,
p_pre_inputs inputs,
@@ -761,7 +764,7 @@ fun dmlPrepared {loc, id, dml, inputs} =
dmlCommon {loc = loc, dml = box [string "\"",
string (String.toCString dml),
- string "\""]},
+ string "\""], mode = mode},
string "uw_pop_cleanup(ctx);",
newline,