diff options
author | 2013-12-23 15:59:17 +0000 | |
---|---|---|
committer | 2013-12-23 15:59:17 +0000 | |
commit | 76b26fec5a3b521a084491d77d6c9e1e28ab603c (patch) | |
tree | 710b0b096b788b1fb51c6222c97cc30632f0f964 /src/postgres.sml | |
parent | b04455ed08e613b7a5b0491894ba688508546c13 (diff) |
Proper handling of serialization failures during SQL COMMIT
Diffstat (limited to 'src/postgres.sml')
-rw-r--r-- | src/postgres.sml | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/postgres.sml b/src/postgres.sml index 272097e7..8cfa5f48 100644 --- a/src/postgres.sml +++ b/src/postgres.sml @@ -438,7 +438,23 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = newline, newline, string "if (PQresultStatus(res) != PGRES_COMMAND_OK) {", - box [string "PQclear(res);", + box [string "if (!strcmp(PQresultErrorField(res, PG_DIAG_SQLSTATE), \"40001\")) {", + box [newline, + string "PQclear(res);", + newline, + string "return -1;", + newline], + string "}", + newline, + string "if (!strcmp(PQresultErrorField(res, PG_DIAG_SQLSTATE), \"40P01\")) {", + box [newline, + string "PQclear(res);", + newline, + string "return -1;", + newline], + string "}", + newline, + string "PQclear(res);", newline, string "return 1;", newline], |