diff options
author | Adam Chlipala <adam@chlipala.net> | 2013-11-29 08:12:57 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2013-11-29 08:12:57 -0500 |
commit | d475845ceef7c1998a7d5091aaef5c55bb229b99 (patch) | |
tree | c61ba5b966e260a7ee66288250f23db340bff7af /src | |
parent | 912c178f111e99eb46ebe74203005c4e93ec26ed (diff) |
Postgres: remove DML error code logging and (hopefully) fix the real problem, not checking for concurrency faults on SELECTs
Diffstat (limited to 'src')
-rw-r--r-- | src/postgres.sml | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/postgres.sml b/src/postgres.sml index e8e3046e..44101527 100644 --- a/src/postgres.sml +++ b/src/postgres.sml @@ -602,7 +602,23 @@ fun queryCommon {loc, query, cols, doCols} = 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 @@ fun dmlCommon {loc, dml, mode} = 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, |