comparison src/postgres.sml @ 1918:c3c84fd38815

Postgres: remove DML error code logging and (hopefully) fix the real problem, not checking for concurrency faults on SELECTs
author Adam Chlipala <adam@chlipala.net>
date Fri, 29 Nov 2013 08:12:57 -0500
parents e2345c438f08
children 2f33d9a51765
comparison
equal deleted inserted replaced
1917:398298ca82b9 1918:c3c84fd38815
600 newline, 600 newline,
601 newline, 601 newline,
602 602
603 string "if (PQresultStatus(res) != PGRES_TUPLES_OK) {", 603 string "if (PQresultStatus(res) != PGRES_TUPLES_OK) {",
604 newline, 604 newline,
605 box [string "PQclear(res);", 605 box [string "if (!strcmp(PQresultErrorField(res, PG_DIAG_SQLSTATE), \"40001\")) {",
606 box [newline,
607 string "PQclear(res);",
608 newline,
609 string "uw_error(ctx, UNLIMITED_RETRY, \"Serialization failure\");",
610 newline],
611 string "}",
612 newline,
613 string "if (!strcmp(PQresultErrorField(res, PG_DIAG_SQLSTATE), \"40P01\")) {",
614 box [newline,
615 string "PQclear(res);",
616 newline,
617 string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");",
618 newline],
619 string "}",
620 newline,
621 string "PQclear(res);",
606 newline, 622 newline,
607 string "uw_error(ctx, FATAL, \"", 623 string "uw_error(ctx, FATAL, \"",
608 string (ErrorMsg.spanToString loc), 624 string (ErrorMsg.spanToString loc),
609 string ": Query failed:\\n%s\\n%s\", ", 625 string ": Query failed:\\n%s\\n%s\", ",
610 query, 626 query,
766 string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");", 782 string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");",
767 newline], 783 newline],
768 string "}", 784 string "}",
769 newline, 785 newline,
770 case mode of 786 case mode of
771 Settings.Error => box [string "{", 787 Settings.Error => box [string "PQclear(res);",
772 newline,
773 string "char *sqlstate = uw_strdup(ctx, PQresultErrorField(res, PG_DIAG_SQLSTATE));",
774 newline,
775 string "PQclear(res);",
776 newline, 788 newline,
777 string "uw_error(ctx, FATAL, \"", 789 string "uw_error(ctx, FATAL, \"",
778 string (ErrorMsg.spanToString loc), 790 string (ErrorMsg.spanToString loc),
779 string ": DML failed:\\n%s\\n%s: %s\", ", 791 string ": DML failed:\\n%s\\n%s\", ",
780 dml, 792 dml,
781 string ", sqlstate, PQerrorMessage(conn));", 793 string ", PQerrorMessage(conn));"]
782 newline,
783 string "}"]
784 | Settings.None => box [string "uw_set_error_message(ctx, PQerrorMessage(conn));", 794 | Settings.None => box [string "uw_set_error_message(ctx, PQerrorMessage(conn));",
785 newline, 795 newline,
786 newline, 796 newline,
787 797
788 string "res = PQexec(conn, \"ROLLBACK TO s\");", 798 string "res = PQexec(conn, \"ROLLBACK TO s\");",