comparison 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
comparison
equal deleted inserted replaced
879:b2a175a0f2ef 880:8e9f2d247dba
594 string "}", 594 string "}",
595 newline, 595 newline,
596 newline] 596 newline]
597 end 597 end
598 598
599 fun p_getcol {wontLeakStrings = _, col = i, typ = t} = 599 fun p_getcol {loc, wontLeakStrings = _, col = i, typ = t} =
600 let 600 let
601 fun getter t = 601 fun getter t =
602 case t of 602 case t of
603 String => box [string "({", 603 String => box [string "({",
604 newline, 604 newline,
931 931
932 box [string "stmt = mysql_stmt_init(conn->conn);", 932 box [string "stmt = mysql_stmt_init(conn->conn);",
933 newline, 933 newline,
934 string "if (stmt == NULL) uw_error(ctx, FATAL, \"Out of memory allocating prepared statement\");", 934 string "if (stmt == NULL) uw_error(ctx, FATAL, \"Out of memory allocating prepared statement\");",
935 newline, 935 newline,
936 string "uw_push_cleanup(ctx, (void (*)(void *))mysql_stmt_close, stmt);", 936 if nested then
937 box [string "uw_push_cleanup(ctx, (void (*)(void *))mysql_stmt_close, stmt);",
938 newline]
939 else
940 box [],
937 string "if (mysql_stmt_prepare(stmt, \"", 941 string "if (mysql_stmt_prepare(stmt, \"",
938 string (String.toString query), 942 string (String.toString query),
939 string "\", ", 943 string "\", ",
940 string (Int.toString (size query)), 944 string (Int.toString (size query)),
941 string ")) {", 945 string ")) {",
944 newline, 948 newline,
945 string "strncpy(msg, mysql_stmt_error(stmt), 1024);", 949 string "strncpy(msg, mysql_stmt_error(stmt), 1024);",
946 newline, 950 newline,
947 string "msg[1023] = 0;", 951 string "msg[1023] = 0;",
948 newline, 952 newline,
953 if nested then
954 box []
955 else
956 box [string "mysql_stmt_close(stmt);",
957 newline],
949 string "uw_error(ctx, FATAL, \"Error preparing statement: %s\", msg);", 958 string "uw_error(ctx, FATAL, \"Error preparing statement: %s\", msg);",
950 newline], 959 newline],
951 string "}", 960 string "}",
952 newline, 961 newline,
953 if nested then 962 if nested then