Skip to content

Commit

Permalink
Fix: RefreshRow causes row to become readOnly Issue #2193 (#2195)
Browse files Browse the repository at this point in the history
* Fix: RefreshRow causes row to become readOnly Issue #2193
  • Loading branch information
davecramer committed Jul 2, 2021
1 parent 944fa0a commit 0077af2
Show file tree
Hide file tree
Showing 3 changed files with 27 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
7 changes: 6 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,12 @@ public void refreshRow() throws SQLException {
PgResultSet rs = (PgResultSet) selectStatement.executeQuery();

if (rs.next()) {
rowBuffer = rs.thisRow;
// we know that the row is updatable as it was tested above.
if ( rs.thisRow == null ) {
rowBuffer = null;
} else {
rowBuffer = castNonNull(rs.thisRow).updateableCopy();
}
}

castNonNull(rows).set(currentRow, castNonNull(rowBuffer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,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 0077af2

Please sign in to comment.