Mercurial > urweb
comparison src/mysql.sml @ 2270:1e3ba868f8bf
Merge.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Mon, 19 Oct 2015 14:42:22 -0400 |
parents | c76a9712334c |
children |
comparison
equal
deleted
inserted
replaced
2269:f7bc7c11a656 | 2270:1e3ba868f8bf |
---|---|
1 (* Copyright (c) 2009-2010, Adam Chlipala | 1 (* Copyright (c) 2009-2010, 2015, Adam Chlipala |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
544 newline, | 544 newline, |
545 string "msg[1023] = 0;", | 545 string "msg[1023] = 0;", |
546 newline, | 546 newline, |
547 string "mysql_close(mysql);", | 547 string "mysql_close(mysql);", |
548 newline, | 548 newline, |
549 string "uw_error(ctx, BOUNDED_RETRY, ", | 549 string "uw_error(ctx, FATAL, ", |
550 string "\"Connection to MySQL server failed: %s\", msg);"], | 550 string "\"Connection to MySQL server failed: %s\", msg);"], |
551 newline, | 551 newline, |
552 string "}", | 552 string "}", |
553 newline, | 553 newline, |
554 newline, | 554 newline, |
859 | _ => buffers t, | 859 | _ => buffers t, |
860 newline] | 860 newline] |
861 end) cols, | 861 end) cols, |
862 newline, | 862 newline, |
863 | 863 |
864 string "if (mysql_stmt_reset(stmt)) uw_error(ctx, FATAL, \"", | 864 string "if (mysql_stmt_reset(stmt)) {", |
865 string (ErrorMsg.spanToString loc), | 865 box [newline, |
866 string ": Error reseting statement: %s\\n%s\", ", | 866 string "if (mysql_errno(conn->conn) == 2006) uw_try_reconnecting_and_restarting(ctx);", |
867 query, | 867 newline, |
868 string ", mysql_error(conn->conn));", | 868 string "uw_error(ctx, FATAL, \"", |
869 string (ErrorMsg.spanToString loc), | |
870 string ": Error reseting statement: %s\\n%s\", ", | |
871 query, | |
872 string ", mysql_error(conn->conn));", | |
873 newline], | |
874 string "}", | |
869 newline, | 875 newline, |
870 newline, | 876 newline, |
871 | 877 |
872 string "if (mysql_stmt_execute(stmt)) {", | 878 string "if (mysql_stmt_execute(stmt)) {", |
873 newline, | 879 newline, |
1231 else | 1237 else |
1232 box []] | 1238 box []] |
1233 | 1239 |
1234 fun dmlCommon {loc, dml, mode} = | 1240 fun dmlCommon {loc, dml, mode} = |
1235 box [string "if (mysql_stmt_execute(stmt)) {", | 1241 box [string "if (mysql_stmt_execute(stmt)) {", |
1236 box [string "if (mysql_errno(conn->conn) == 1213)", | 1242 box [string "if (mysql_errno(conn->conn) == 2006) uw_try_reconnecting_and_restarting(ctx);", |
1243 newline, | |
1244 string "if (mysql_errno(conn->conn) == 1213)", | |
1237 newline, | 1245 newline, |
1238 box [string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");", | 1246 box [string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");", |
1239 newline], | 1247 newline], |
1240 newline, | 1248 newline, |
1241 case mode of | 1249 case mode of |
1538 string ")"], | 1546 string ")"], |
1539 string ";", | 1547 string ";", |
1540 newline, | 1548 newline, |
1541 newline, | 1549 newline, |
1542 | 1550 |
1543 string "if (mysql_query(conn->conn, insert)) uw_error(ctx, FATAL, \"'nextval' INSERT failed\");", | 1551 string "if (mysql_query(conn->conn, insert)) {", |
1552 box [newline, | |
1553 string "if (mysql_errno(conn->conn) == 2006) uw_try_reconnecting_and_restarting(ctx);", | |
1554 newline, | |
1555 string "uw_error(ctx, FATAL, \"'nextval' INSERT failed\");", | |
1556 newline], | |
1557 string "}", | |
1544 newline, | 1558 newline, |
1545 string "n = mysql_insert_id(conn->conn);", | 1559 string "n = mysql_insert_id(conn->conn);", |
1546 newline, | 1560 newline, |
1547 string "if (mysql_query(conn->conn, delete)) uw_error(ctx, FATAL, \"'nextval' DELETE failed\");", | 1561 string "if (mysql_query(conn->conn, delete)) uw_error(ctx, FATAL, \"'nextval' DELETE failed\");", |
1548 newline] | 1562 newline] |