Skip to content

Commit

Permalink
Fix: RefreshRow causes row to become readOnly Issue pgjdbc#2193
Browse files Browse the repository at this point in the history
  • Loading branch information
davecramer committed Jun 28, 2021
1 parent efa57b3 commit f9bac20
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Rework OSGi bundle activator so it does not rely on exception message to check DataSourceFactory presence PR [#507](https://github.com/pgjdbc/pgjdbc/pull/507)
- Fix "Avoid leaking server error details through BatchUpdateException when logServerErrorDetail=false" [PR #2148](https://github.com/pgjdbc/pgjdbc/pull/2148) fixes Issue #2147
- Fix database metadata getFunctions() and getProcedures() to ignore search_path when no schema pattern is specified [PR #2174](https://github.com/pgjdbc/pgjdbc/pull/2174)
- Fix refreshRow made the row readOnly. Fixes Issue #2193

## [42.2.20] (2021-04-19)

Expand Down
3 changes: 2 additions & 1 deletion pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,8 @@ public void refreshRow() throws SQLException {
PgResultSet rs = (PgResultSet) selectStatement.executeQuery();

if (rs.next()) {
rowBuffer = rs.thisRow;
// we know
rowBuffer = rs.thisRow.updateableCopy();
}

castNonNull(rows).set(currentRow, castNonNull(rowBuffer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,26 @@ public void testUpdateable() throws SQLException {
st.close();
}

@Test
public void test2193() throws Exception {
Statement st =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = st.executeQuery("select * from updateable");
assertNotNull(rs);
rs.moveToInsertRow();
rs.updateInt(1, 1);
rs.updateString(2, "jake");
rs.updateString(3, "avalue");
rs.insertRow();
rs.first();

rs.updateString(2, "bob");
rs.updateRow();
rs.refreshRow();
rs.updateString(2, "jake");
rs.updateRow();
}

@Test
public void testInsertRowIllegalMethods() throws Exception {
Statement st =
Expand Down

0 comments on commit f9bac20

Please sign in to comment.