diff options
author | Adam Chlipala <adam@chlipala.net> | 2013-12-23 15:59:17 +0000 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2013-12-23 15:59:17 +0000 |
commit | fac05ae0a6d7d080436c953d2085e137d75c5796 (patch) | |
tree | 710b0b096b788b1fb51c6222c97cc30632f0f964 /src/postgres.sml | |
parent | 2f6649aa0b392fefe08e3eb604a93220a0c64324 (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], |