Skip to content

Commit

Permalink
backpatch fixing refreshRow makes resultset readonly fixes Issue #2193 (
Browse files Browse the repository at this point in the history
  • Loading branch information
davecramer committed Jul 2, 2021
1 parent 8d7c78f commit 8f42bf9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Added

### Fixed
- Fix: refreshRow made the row readOnly. Fixes Issue #2193

[42.2.22] (2021-06-16 10:09:33 -0400)
### Changed
Expand Down
7 changes: 6 additions & 1 deletion pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
Expand Up @@ -1357,7 +1357,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
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 8f42bf9

Please sign in to comment.