-
Notifications
You must be signed in to change notification settings - Fork 819
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backpatch changes for 42.2.25 (#2581)
* Backpatch changes for 42.2.25 * fixed test to compile for 42.2.x
- Loading branch information
1 parent
01836f2
commit b5ee575
Showing
4 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
pgjdbc/src/test/java/org/postgresql/test/jdbc2/ResultSetRefreshTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2022, PostgreSQL Global Development Group | ||
* See the LICENSE file in the project root for more information. | ||
*/ | ||
|
||
package org.postgresql.test.jdbc2; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.postgresql.test.TestUtil; | ||
|
||
import org.junit.Test; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
public class ResultSetRefreshTest extends BaseTest4 { | ||
@Test | ||
public void testWithDataColumnThatRequiresEscaping() throws Exception { | ||
TestUtil.dropTable(con, "refresh_row_bad_ident"); | ||
TestUtil.execute("CREATE TABLE refresh_row_bad_ident (id int PRIMARY KEY, \"1 FROM refresh_row_bad_ident; SELECT 2; SELECT *\" int)", con); | ||
TestUtil.execute( "INSERT INTO refresh_row_bad_ident (id) VALUES (1), (2), (3)", con); | ||
|
||
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); | ||
ResultSet rs = stmt.executeQuery("SELECT * FROM refresh_row_bad_ident"); | ||
assertTrue(rs.next()); | ||
try { | ||
rs.refreshRow(); | ||
} catch (SQLException ex) { | ||
throw new RuntimeException("ResultSet.refreshRow() did not handle escaping data column identifiers", ex); | ||
} | ||
rs.close(); | ||
stmt.close(); | ||
} | ||
|
||
@Test | ||
public void testWithKeyColumnThatRequiresEscaping() throws Exception { | ||
TestUtil.dropTable(con, "refresh_row_bad_ident"); | ||
TestUtil.execute("CREATE TABLE refresh_row_bad_ident (\"my key\" int PRIMARY KEY)", con); | ||
TestUtil.execute( "INSERT INTO refresh_row_bad_ident VALUES (1), (2), (3)", con); | ||
|
||
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); | ||
ResultSet rs = stmt.executeQuery("SELECT * FROM refresh_row_bad_ident"); | ||
assertTrue(rs.next()); | ||
try { | ||
rs.refreshRow(); | ||
} catch (SQLException ex) { | ||
throw new RuntimeException("ResultSet.refreshRow() did not handle escaping key column identifiers", ex); | ||
} | ||
rs.close(); | ||
stmt.close(); | ||
} | ||
} |