changeset 1013:d9483301ff0e

Get char working with MySQL
author Adam Chlipala <adamc@hcoop.net>
date Thu, 22 Oct 2009 17:04:37 -0400
parents 32dbb5636ae7
children ea9f03ac2710
files src/mysql.sml
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/mysql.sml	Thu Oct 22 16:25:31 2009 -0400
+++ b/src/mysql.sml	Thu Oct 22 17:04:37 2009 -0400
@@ -49,7 +49,7 @@
         Int => "MYSQL_TYPE_LONGLONG"
       | Float => "MYSQL_TYPE_DOUBLE"
       | String => "MYSQL_TYPE_STRING"
-      | Char => "MYSQL_TYPE_TINY"
+      | Char => "MYSQL_TYPE_STRING"
       | Bool => "MYSQL_TYPE_LONG"
       | Time => "MYSQL_TYPE_TIMESTAMP"
       | Blob => "MYSQL_TYPE_BLOB"
@@ -790,6 +790,16 @@
                                                                      string (Int.toString i),
                                                                      string ";",
                                                                      newline]
+                                                    | Char => box [string "out[",
+                                                                   string (Int.toString i),
+                                                                   string "].buffer_length = 1;",
+                                                                   newline,
+                                                                   string "out[",
+                                                                   string (Int.toString i),
+                                                                   string "].buffer = &buffer",
+                                                                   string (Int.toString i),
+                                                                   string ";",
+                                                                   newline]
                                                     | Blob => box [string "out[",
                                                                    string (Int.toString i),
                                                                    string "].length = &length",
@@ -927,7 +937,8 @@
                                                                    newline]
                                                     | Time => box [string "MYSQL_TIME in_buffer",
                                                                    string (Int.toString i),
-                                                                   string ";",                                                                   newline]
+                                                                   string ";",
+                                                                   newline]
                                                     | _ => box []
                                           in
                                               box [case t of
@@ -1023,6 +1034,16 @@
                                                                      string (Int.toString i),
                                                                      string ";",
                                                                      newline]
+                                                    | Char => box [string "in[",
+                                                                   string (Int.toString i),
+                                                                   string "].buffer = &arg",
+                                                                   string (Int.toString (i + 1)),
+                                                                   string ";",
+                                                                   newline,
+                                                                   string "in[",
+                                                                   string (Int.toString i),
+                                                                   string "].buffer_length = 1;",
+                                                                   newline]
                                                     | Blob => box [string "in[",
                                                                    string (Int.toString i),
                                                                    string "].buffer = arg",
@@ -1185,7 +1206,7 @@
 fun dml loc =
     box [string "uw_conn *conn = uw_get_db(ctx);",
          newline,
-         string "MYSQL_stmt *stmt = mysql_stmt_init(conn->conn);",
+         string "MYSQL_STMT *stmt = mysql_stmt_init(conn->conn);",
          newline,
          string "if (stmt == NULL) uw_error(ctx, FATAL, \"",
          string (ErrorMsg.spanToString loc),