diff options
author | Ian Wienand <iwienand@redhat.com> | 2021-07-20 15:01:06 +1000 |
---|---|---|
committer | Ian Wienand <iwienand@redhat.com> | 2021-07-20 16:17:15 +1000 |
commit | fe5aac7e7227ade08cc324b9bc853492ba45638b (patch) | |
tree | dacc8dda9ee7a98823081a09606ee9aa0097b303 | |
parent | 4050ed9f4c7b646b813f0b137869aee8c69a6f51 (diff) |
AccountPatchReview : fix mariadb status matching
mariadb is currently using SQLException.getSQLState() (as used by
getSQLStateInt()) which returns the ANSI SQLSTATE value, not the
MariaDB/mysql error code [1].
The result is that the duplicate key detection doesn't work when using
the mariadb connector. If you have already reviewed a file (or click
"reviewed" in the file chooser) and then open it again you get a 500
error and a long backtrace including something like
Caused by: java.sql.SQLIntegrityConstraintViolationException:
(conn=13) Duplicate entry '3-1-1000001-file-3.txt' for key 'PRIMARY'
We could either continue using getSQLState() and change this to
"23000" (which covers all these values) or do as MySQL connector does
and use the vendor-specific getErrorCode() call. I've taken the later
approach here.
[1] https://mariadb.com/kb/en/mariadb-error-codes/
Change-Id: I5762118ceb5628171b991a80fe701d160ab0d959
-rw-r--r-- | java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java b/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java index b0a3370fe1..5073af15b4 100644 --- a/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java +++ b/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java @@ -37,7 +37,7 @@ public class MariaDBAccountPatchReviewStore extends JdbcAccountPatchReviewStore @Override public StorageException convertError(String op, SQLException err) { - switch (getSQLStateInt(err)) { + switch (err.getErrorCode()) { case 1022: // ER_DUP_KEY case 1062: // ER_DUP_ENTRY case 1169: // ER_DUP_UNIQUE; |