diff src/mysql.sml @ 880:8e9f2d247dba

Testing nested queries
author Adam Chlipala <adamc@hcoop.net>
date Fri, 17 Jul 2009 12:25:34 -0400
parents b2a175a0f2ef
children 9c1b7e46eed2
line wrap: on
line diff
--- a/src/mysql.sml	Thu Jul 16 18:10:29 2009 -0400
+++ b/src/mysql.sml	Fri Jul 17 12:25:34 2009 -0400
@@ -596,7 +596,7 @@
              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 @@
               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 @@
                    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 "}",