comparison src/mysql.sml @ 2178:c76a9712334c

Database-server reconnection for MySQL
author Adam Chlipala <adam@chlipala.net>
date Sat, 17 Oct 2015 11:31:22 -0400
parents 00cf8214c2e3
children
comparison
equal deleted inserted replaced
2177:00cf8214c2e3 2178:c76a9712334c
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]