amazon-redshift-jdbc-driver icon indicating copy to clipboard operation
amazon-redshift-jdbc-driver copied to clipboard

Prepared statement SELECT tablename FROM SVV_EXTERNAL_TABLES with setFetchSize gives ERROR: portal "c_6-16720547611010" does not exist if number of rows exceeds fetch size

Open RealTYPICAL opened this issue 2 years ago • 1 comments

Driver version

2.1.0.10

Redshift version

PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.44903

Client Operating System

UBI8

JAVA/JVM version

openjdk version "17.0.5" 2022-10-18

Problem description

  1. Expected behaviour: You should be able to use PreparedStatements with a fetchSize less than the number of rows in the svv_external_tables.

  2. Actual behaviour: If the svv_external_tables number of rows exceeds the fetch size then the portal does not exist issue happens like in: https://github.com/aws/amazon-redshift-jdbc-driver/issues/9

  3. Error message/stack trace: Exception in thread "main" java.lang.RuntimeException: Failed to read row: ERROR: portal "c_6-16720547611010" does not exist

  4. Any other details that can be helpful: enableFetchRingBuffer=false fetchSize needs to be less than than the number of rows in the svv_external_tables Statement still works fine. Same thing happens when querying SELECT tablename FROM pg_tables

Reproduction code

` String query = "SELECT tablename FROM SVV_EXTERNAL_TABLES"; // where svv_external_tables has more than 500 rows PreparedStatement statement = c.prepareStatement(query); statement.setFetchSize(500);

try (ResultSet resultSet = statement.executeQuery()) { while (resultSet.next()) { System.out.println(resultSet.getString(1)); } } `

RealTYPICAL avatar Jan 31 '23 12:01 RealTYPICAL

Thanks for submitting this issue, we will look into it and get back to you.

bhvkshah avatar Jan 31 '23 14:01 bhvkshah