diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2015-10-24 11:06:31 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2015-10-24 11:06:31 -0400 |
commit | 7d861ea0debf944cb8e3e38d73a8c0197de574b3 (patch) | |
tree | ed87d21ffe040bf296d2230c7490abda8e34752c /src/mysql.sml | |
parent | 598756dc69f89cf2dd2b889cad63a7a690ae7ed7 (diff) | |
parent | cb0109804fdad0dd423bb344446344cdc08c0886 (diff) |
Merge branch 'upstream' into dfsg_clean20151018+dfsg
Diffstat (limited to 'src/mysql.sml')
-rw-r--r-- | src/mysql.sml | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/mysql.sml b/src/mysql.sml index bb654fee..692be0a2 100644 --- a/src/mysql.sml +++ b/src/mysql.sml @@ -1,4 +1,4 @@ -(* Copyright (c) 2009-2010, Adam Chlipala +(* Copyright (c) 2009-2010, 2015, Adam Chlipala * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -546,7 +546,7 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = newline, string "mysql_close(mysql);", newline, - string "uw_error(ctx, BOUNDED_RETRY, ", + string "uw_error(ctx, FATAL, ", string "\"Connection to MySQL server failed: %s\", msg);"], newline, string "}", @@ -861,11 +861,17 @@ fun queryCommon {loc, query, cols, doCols} = end) cols, newline, - string "if (mysql_stmt_reset(stmt)) uw_error(ctx, FATAL, \"", - string (ErrorMsg.spanToString loc), - string ": Error reseting statement: %s\\n%s\", ", - query, - string ", mysql_error(conn->conn));", + string "if (mysql_stmt_reset(stmt)) {", + box [newline, + string "if (mysql_errno(conn->conn) == 2006) uw_try_reconnecting_and_restarting(ctx);", + newline, + string "uw_error(ctx, FATAL, \"", + string (ErrorMsg.spanToString loc), + string ": Error reseting statement: %s\\n%s\", ", + query, + string ", mysql_error(conn->conn));", + newline], + string "}", newline, newline, @@ -1233,7 +1239,9 @@ fun queryPrepared {loc, id, query, inputs, cols, doCols, nested} = fun dmlCommon {loc, dml, mode} = box [string "if (mysql_stmt_execute(stmt)) {", - box [string "if (mysql_errno(conn->conn) == 1213)", + box [string "if (mysql_errno(conn->conn) == 2006) uw_try_reconnecting_and_restarting(ctx);", + newline, + string "if (mysql_errno(conn->conn) == 1213)", newline, box [string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");", newline], @@ -1540,7 +1548,13 @@ fun nextval {loc, seqE, seqName} = newline, newline, - string "if (mysql_query(conn->conn, insert)) uw_error(ctx, FATAL, \"'nextval' INSERT failed\");", + string "if (mysql_query(conn->conn, insert)) {", + box [newline, + string "if (mysql_errno(conn->conn) == 2006) uw_try_reconnecting_and_restarting(ctx);", + newline, + string "uw_error(ctx, FATAL, \"'nextval' INSERT failed\");", + newline], + string "}", newline, string "n = mysql_insert_id(conn->conn);", newline, |