comparison src/mysql.sml @ 876:025806b3c014

Demo compiles again with Postgres and MySQL; MySQL version lacks sequence code and so doesn't work yet
author Adam Chlipala <adamc@hcoop.net>
date Sun, 12 Jul 2009 16:09:54 -0400
parents c50101ddf7fa
children dae141d911d9
comparison
equal deleted inserted replaced
875:c50101ddf7fa 876:025806b3c014
641 newline, 641 newline,
642 string "b;", 642 string "b;",
643 newline, 643 newline,
644 string "})"] 644 string "})"]
645 | Time => box [string "({", 645 | Time => box [string "({",
646 string "MYSQL_TIME *mt = buffer", 646 string "MYSQL_TIME *mt = &buffer",
647 string (Int.toString i), 647 string (Int.toString i),
648 string ";", 648 string ";",
649 newline, 649 newline,
650 newline, 650 newline,
651 string "struct tm t = {mt->second, mt->minute, mt->hour, mt->day, mt->month, mt->year, 0, 0, -1};", 651 string "struct tm t = {mt->second, mt->minute, mt->hour, mt->day, mt->month, mt->year, 0, 0, -1};",
652 newline, 652 newline,
653 string "mktime(&tm);", 653 string "mktime(&t);",
654 newline, 654 newline,
655 string "})"] 655 string "})"]
656 | _ => box [string "buffer", 656 | _ => box [string "buffer",
657 string (Int.toString i)] 657 string (Int.toString i)]
658 in 658 in
715 newline] 715 newline]
716 | Blob => box [string "unsigned long length", 716 | Blob => box [string "unsigned long length",
717 string (Int.toString i), 717 string (Int.toString i),
718 string ";", 718 string ";",
719 newline] 719 newline]
720 | Time => box [string "MYSQL_TIME buffer",
721 string (Int.toString i),
722 string ";",
723 newline]
720 | _ => box [string (p_sql_ctype t), 724 | _ => box [string (p_sql_ctype t),
721 space, 725 space,
722 string "buffer", 726 string "buffer",
723 string (Int.toString i), 727 string (Int.toString i),
724 string ";", 728 string ";",
842 newline] 846 newline]
843 847
844 fun query {loc, cols, doCols} = 848 fun query {loc, cols, doCols} =
845 box [string "uw_conn *conn = uw_get_db(ctx);", 849 box [string "uw_conn *conn = uw_get_db(ctx);",
846 newline, 850 newline,
847 string "MYSQL_stmt *stmt = mysql_stmt_init(conn->conn);", 851 string "MYSQL_STMT *stmt = mysql_stmt_init(conn->conn);",
848 newline, 852 newline,
849 string "if (stmt == NULL) uw_error(ctx, FATAL, \"", 853 string "if (stmt == NULL) uw_error(ctx, FATAL, \"",
850 string (ErrorMsg.spanToString loc), 854 string (ErrorMsg.spanToString loc),
851 string ": can't allocate temporary prepared statement\");", 855 string ": can't allocate temporary prepared statement\");",
852 newline, 856 newline,
880 newline] 884 newline]
881 | Blob => box [string "unsigned long in_length", 885 | Blob => box [string "unsigned long in_length",
882 string (Int.toString i), 886 string (Int.toString i),
883 string ";", 887 string ";",
884 newline] 888 newline]
885 | Time => box [string (p_sql_ctype t), 889 | Time => box [string "MYSQL_TIME in_buffer",
886 space,
887 string "in_buffer",
888 string (Int.toString i), 890 string (Int.toString i),
889 string ";", 891 string ";",
890 newline] 892 newline]
891 | _ => box [] 893 | _ => box []
892 in 894 in
1021 box [case t of 1023 box [case t of
1022 String => box [] 1024 String => box []
1023 | _ => 1025 | _ =>
1024 box [string (p_sql_ctype t), 1026 box [string (p_sql_ctype t),
1025 space, 1027 space,
1028 string "tmp = *arg",
1029 string (Int.toString (i + 1)),
1030 string ";",
1031 newline,
1032 string (p_sql_ctype t),
1033 space,
1026 string "arg", 1034 string "arg",
1027 string (Int.toString (i + 1)), 1035 string (Int.toString (i + 1)),
1028 string " = *arg", 1036 string " = tmp;",
1029 string (Int.toString (i + 1)),
1030 string ";",
1031 newline], 1037 newline],
1032 string "in_is_null", 1038 string "in_is_null",
1033 string (Int.toString i), 1039 string (Int.toString i),
1034 string " = 0;", 1040 string " = 0;",
1035 newline, 1041 newline,
1036 buffers t, 1042 buffers t,
1037 newline]] 1043 newline],
1044 string "}",
1045 newline]
1038 1046
1039 | _ => buffers t, 1047 | _ => buffers t,
1040 newline] 1048 newline]
1041 end) inputs, 1049 end) inputs,
1042 newline, 1050 newline,
1098 newline] 1106 newline]
1099 | Blob => box [string "unsigned long in_length", 1107 | Blob => box [string "unsigned long in_length",
1100 string (Int.toString i), 1108 string (Int.toString i),
1101 string ";", 1109 string ";",
1102 newline] 1110 newline]
1103 | Time => box [string (p_sql_ctype t), 1111 | Time => box [string "MYSQL_TIME in_buffer",
1104 space,
1105 string "in_buffer",
1106 string (Int.toString i), 1112 string (Int.toString i),
1107 string ";", 1113 string ";",
1108 newline] 1114 newline]
1109 | _ => box [] 1115 | _ => box []
1110 in 1116 in
1239 box [case t of 1245 box [case t of
1240 String => box [] 1246 String => box []
1241 | _ => 1247 | _ =>
1242 box [string (p_sql_ctype t), 1248 box [string (p_sql_ctype t),
1243 space, 1249 space,
1250 string "tmp = *arg",
1251 string (Int.toString (i + 1)),
1252 string ";",
1253 newline,
1254 string (p_sql_ctype t),
1255 space,
1244 string "arg", 1256 string "arg",
1245 string (Int.toString (i + 1)), 1257 string (Int.toString (i + 1)),
1246 string " = *arg", 1258 string " = tmp;",
1247 string (Int.toString (i + 1)),
1248 string ";",
1249 newline], 1259 newline],
1250 string "in_is_null", 1260 string "in_is_null",
1251 string (Int.toString i), 1261 string (Int.toString i),
1252 string " = 0;", 1262 string " = 0;",
1253 newline, 1263 newline,
1254 buffers t, 1264 buffers t,
1255 newline]] 1265 newline],
1266 string "}",
1267 newline]
1256 1268
1257 | _ => buffers t, 1269 | _ => buffers t,
1258 newline] 1270 newline]
1259 end) inputs, 1271 end) inputs,
1260 newline, 1272 newline,