# HG changeset patch # User Adam Chlipala # Date 1385730777 18000 # Node ID c3c84fd38815ffe93ce0e6668cfa637269b4f8aa # Parent 398298ca82b9aa8f508fd750c774c5d8585ad78e Postgres: remove DML error code logging and (hopefully) fix the real problem, not checking for concurrency faults on SELECTs diff -r 398298ca82b9 -r c3c84fd38815 src/postgres.sml --- a/src/postgres.sml Thu Nov 28 11:06:11 2013 -0500 +++ b/src/postgres.sml Fri Nov 29 08:12:57 2013 -0500 @@ -602,7 +602,23 @@ string "if (PQresultStatus(res) != PGRES_TUPLES_OK) {", newline, - box [string "PQclear(res);", + box [string "if (!strcmp(PQresultErrorField(res, PG_DIAG_SQLSTATE), \"40001\")) {", + box [newline, + string "PQclear(res);", + newline, + string "uw_error(ctx, UNLIMITED_RETRY, \"Serialization failure\");", + newline], + string "}", + newline, + string "if (!strcmp(PQresultErrorField(res, PG_DIAG_SQLSTATE), \"40P01\")) {", + box [newline, + string "PQclear(res);", + newline, + string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");", + newline], + string "}", + newline, + string "PQclear(res);", newline, string "uw_error(ctx, FATAL, \"", string (ErrorMsg.spanToString loc), @@ -768,19 +784,13 @@ string "}", newline, case mode of - Settings.Error => box [string "{", - newline, - string "char *sqlstate = uw_strdup(ctx, PQresultErrorField(res, PG_DIAG_SQLSTATE));", - newline, - string "PQclear(res);", + Settings.Error => box [string "PQclear(res);", newline, string "uw_error(ctx, FATAL, \"", string (ErrorMsg.spanToString loc), - string ": DML failed:\\n%s\\n%s: %s\", ", + string ": DML failed:\\n%s\\n%s\", ", dml, - string ", sqlstate, PQerrorMessage(conn));", - newline, - string "}"] + string ", PQerrorMessage(conn));"] | Settings.None => box [string "uw_set_error_message(ctx, PQerrorMessage(conn));", newline, newline,