comparison src/cjr_print.sml @ 424:b10132434adc

Transactions seem to be working
author Adam Chlipala <adamc@hcoop.net>
date Fri, 24 Oct 2008 16:47:18 -0400
parents ad7e854a518c
children 7009b0ac1501
comparison
equal deleted inserted replaced
423:82067ea6e723 424:b10132434adc
1264 newline, 1264 newline,
1265 newline, 1265 newline,
1266 string "void uw_db_close(uw_context ctx) {", 1266 string "void uw_db_close(uw_context ctx) {",
1267 newline, 1267 newline,
1268 string "PQfinish(uw_get_db(ctx));", 1268 string "PQfinish(uw_get_db(ctx));",
1269 newline,
1270 string "}",
1271 newline,
1272 newline,
1273
1274 string "int uw_db_begin(uw_context ctx) {",
1275 newline,
1276 string "PGconn *conn = uw_get_db(ctx);",
1277 newline,
1278 string "PGresult *res = PQexec(conn, \"BEGIN\");",
1279 newline,
1280 newline,
1281 string "if (res == NULL) return 1;",
1282 newline,
1283 newline,
1284 string "if (PQresultStatus(res) != PGRES_COMMAND_OK) {",
1285 box [string "PQclear(res);",
1286 newline,
1287 string "return 1;",
1288 newline],
1289 string "}",
1290 newline,
1291 string "return 0;",
1292 newline,
1293 string "}",
1294 newline,
1295 newline,
1296
1297 string "int uw_db_commit(uw_context ctx) {",
1298 newline,
1299 string "PGconn *conn = uw_get_db(ctx);",
1300 newline,
1301 string "PGresult *res = PQexec(conn, \"COMMIT\");",
1302 newline,
1303 newline,
1304 string "if (res == NULL) return 1;",
1305 newline,
1306 newline,
1307 string "if (PQresultStatus(res) != PGRES_COMMAND_OK) {",
1308 box [string "PQclear(res);",
1309 newline,
1310 string "return 1;",
1311 newline],
1312 string "}",
1313 newline,
1314 string "return 0;",
1315 newline,
1316 string "}",
1317 newline,
1318 newline,
1319
1320 string "int uw_db_rollback(uw_context ctx) {",
1321 newline,
1322 string "PGconn *conn = uw_get_db(ctx);",
1323 newline,
1324 string "PGresult *res = PQexec(conn, \"ROLLBACK\");",
1325 newline,
1326 newline,
1327 string "if (res == NULL) return 1;",
1328 newline,
1329 newline,
1330 string "if (PQresultStatus(res) != PGRES_COMMAND_OK) {",
1331 box [string "PQclear(res);",
1332 newline,
1333 string "return 1;",
1334 newline],
1335 string "}",
1336 newline,
1337 string "return 0;",
1269 newline, 1338 newline,
1270 string "}", 1339 string "}",
1271 newline] 1340 newline]
1272 1341
1273 | DPreparedStatements ss => 1342 | DPreparedStatements ss =>
2156 if List.exists (fn (DDatabase _, _) => true | _ => false) ds then 2225 if List.exists (fn (DDatabase _, _) => true | _ => false) ds then
2157 box [] 2226 box []
2158 else 2227 else
2159 box [newline, 2228 box [newline,
2160 string "void uw_db_init(uw_context ctx) { };", 2229 string "void uw_db_init(uw_context ctx) { };",
2230 newline,
2231 string "int uw_db_begin(uw_context ctx) { return 0; };",
2232 newline,
2233 string "int uw_db_commit(uw_context ctx) { return 0; };",
2234 newline,
2235 string "int uw_db_rollback(uw_context ctx) { return 0; };",
2161 newline]] 2236 newline]]
2162 end 2237 end
2163 2238
2164 fun p_sql env (ds, _) = 2239 fun p_sql env (ds, _) =
2165 let 2240 let