comparison src/cjr_print.sml @ 486:8e055bbbd28b

Remove some allocation
author Adam Chlipala <adamc@hcoop.net>
date Sun, 09 Nov 2008 18:19:47 -0500
parents c9566d49ecfe
children 0fd65c50e0e2
comparison
equal deleted inserted replaced
485:3ce20b0b6914 486:8e055bbbd28b
1184 string "=", 1184 string "=",
1185 space, 1185 space,
1186 p_exp env initial, 1186 p_exp env initial,
1187 string ";", 1187 string ";",
1188 newline, 1188 newline,
1189 case prepared of
1190 NONE => box [string "printf(\"Executing: %s\\n\", query);",
1191 newline]
1192 | _ => box [],
1193 string "PGresult *res = ", 1189 string "PGresult *res = ",
1194 case prepared of 1190 case prepared of
1195 NONE => string "PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);" 1191 NONE => string "PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);"
1196 | SOME n => box [string "PQexecPrepared(conn, \"uw", 1192 | SOME n => box [string "PQexecPrepared(conn, \"uw",
1197 string (Int.toString n), 1193 string (Int.toString n),
1369 newline, 1365 newline,
1370 string "}))"] 1366 string "}))"]
1371 1367
1372 | ENextval {seq, prepared} => 1368 | ENextval {seq, prepared} =>
1373 let 1369 let
1374 val query = (EFfiApp ("Basis", "strcat", [seq, (EPrim (Prim.String "')"), loc)]), loc) 1370 val query = case seq of
1375 val query = (EFfiApp ("Basis", "strcat", [(EPrim (Prim.String "SELECT NEXTVAL('"), loc), query]), loc) 1371 (EPrim (Prim.String s), loc) =>
1372 (EPrim (Prim.String ("SELECT NEXTVAL('" ^ s ^ "')")), loc)
1373 | _ =>
1374 let
1375 val query = (EFfiApp ("Basis", "strcat", [seq, (EPrim (Prim.String "')"), loc)]), loc)
1376 in
1377 (EFfiApp ("Basis", "strcat", [(EPrim (Prim.String "SELECT NEXTVAL('"), loc), query]), loc)
1378 end
1376 in 1379 in
1377 box [string "(uw_begin_region(ctx), ", 1380 box [string "(uw_begin_region(ctx), ",
1378 string "({", 1381 string "({",
1379 newline, 1382 newline,
1380 string "PGconn *conn = uw_get_db(ctx);", 1383 string "PGconn *conn = uw_get_db(ctx);",