comparison src/postgres.sml @ 1916:e2345c438f08

Postgres: print SQLSTATE on DML failure, to help figure out when new special cases should be added
author Adam Chlipala <adam@chlipala.net>
date Wed, 27 Nov 2013 15:42:24 -0500
parents 690638bd9fef
children c3c84fd38815
comparison
equal deleted inserted replaced
1915:52e88e139b25 1916:e2345c438f08
766 string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");", 766 string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");",
767 newline], 767 newline],
768 string "}", 768 string "}",
769 newline, 769 newline,
770 case mode of 770 case mode of
771 Settings.Error => box [string "PQclear(res);", 771 Settings.Error => box [string "{",
772 newline,
773 string "char *sqlstate = uw_strdup(ctx, PQresultErrorField(res, PG_DIAG_SQLSTATE));",
774 newline,
775 string "PQclear(res);",
772 newline, 776 newline,
773 string "uw_error(ctx, FATAL, \"", 777 string "uw_error(ctx, FATAL, \"",
774 string (ErrorMsg.spanToString loc), 778 string (ErrorMsg.spanToString loc),
775 string ": DML failed:\\n%s\\n%s\", ", 779 string ": DML failed:\\n%s\\n%s: %s\", ",
776 dml, 780 dml,
777 string ", PQerrorMessage(conn));"] 781 string ", sqlstate, PQerrorMessage(conn));",
782 newline,
783 string "}"]
778 | Settings.None => box [string "uw_set_error_message(ctx, PQerrorMessage(conn));", 784 | Settings.None => box [string "uw_set_error_message(ctx, PQerrorMessage(conn));",
779 newline, 785 newline,
780 newline, 786 newline,
781 787
782 string "res = PQexec(conn, \"ROLLBACK TO s\");", 788 string "res = PQexec(conn, \"ROLLBACK TO s\");",