aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/mysql.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-07-17 12:25:34 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-07-17 12:25:34 -0400
commitec734c14f2569e58e462097d5953a26f9fa84f69 (patch)
tree01175fcf8d29d98dc9ca279350fd43f4f6d242ee /src/mysql.sml
parentc01c7e97334a180b55b11a1bba93cf046628948d (diff)
Testing nested queries
Diffstat (limited to 'src/mysql.sml')
-rw-r--r--src/mysql.sml13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mysql.sml b/src/mysql.sml
index e6d42687..eef05a6a 100644
--- a/src/mysql.sml
+++ b/src/mysql.sml
@@ -596,7 +596,7 @@ fun init {dbstring, prepared = ss, tables, views, sequences} =
newline]
end
-fun p_getcol {wontLeakStrings = _, col = i, typ = t} =
+fun p_getcol {loc, wontLeakStrings = _, col = i, typ = t} =
let
fun getter t =
case t of
@@ -933,7 +933,11 @@ fun queryPrepared {loc, id, query, inputs, cols, doCols, nested} =
newline,
string "if (stmt == NULL) uw_error(ctx, FATAL, \"Out of memory allocating prepared statement\");",
newline,
- string "uw_push_cleanup(ctx, (void (*)(void *))mysql_stmt_close, stmt);",
+ if nested then
+ box [string "uw_push_cleanup(ctx, (void (*)(void *))mysql_stmt_close, stmt);",
+ newline]
+ else
+ box [],
string "if (mysql_stmt_prepare(stmt, \"",
string (String.toString query),
string "\", ",
@@ -946,6 +950,11 @@ fun queryPrepared {loc, id, query, inputs, cols, doCols, nested} =
newline,
string "msg[1023] = 0;",
newline,
+ if nested then
+ box []
+ else
+ box [string "mysql_stmt_close(stmt);",
+ newline],
string "uw_error(ctx, FATAL, \"Error preparing statement: %s\", msg);",
newline],
string "}",