diff options
author | 2013-11-29 08:12:57 -0500 | |
---|---|---|
committer | 2013-11-29 08:12:57 -0500 | |
commit | 85ad40354025624282341901394235c6a97c5c2c (patch) | |
tree | c61ba5b966e260a7ee66288250f23db340bff7af /src/postgres.sml | |
parent | b05abde0714e680b1d108bb696260d61f1a9890b (diff) |
Postgres: remove DML error code logging and (hopefully) fix the real problem, not checking for concurrency faults on SELECTs
Diffstat (limited to 'src/postgres.sml')
-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, |