diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 143e5d8..d4de011 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: polypheny-jar - path: dbms/build/libs/dbms-0.10.0-SNAPSHOT.jar + path: dbms/build/libs/dbms-0.10.1-SNAPSHOT.jar build: needs: build-polypheny @@ -63,7 +63,7 @@ jobs: uses: polypheny/GitHub-Action-Run-Polypheny@dev with: cmd: ./gradlew build -PdisableToolchain=true - jar: dbms-0.10.0-SNAPSHOT.jar + jar: dbms-0.10.1-SNAPSHOT.jar java: ${{ env.JAVA_HOME_17_X64 || env.JAVA_HOME_17_ARM64 }}/bin/java build-windows: @@ -91,7 +91,7 @@ jobs: uses: polypheny/GitHub-Action-Run-Polypheny@v0.2.0 with: cmd: gradlew.bat build -PdisableToolchain=true - jar: dbms-0.10.0-SNAPSHOT.jar + jar: dbms-0.10.1-SNAPSHOT.jar java: ${{ env.JAVA_HOME_17_X64 }}\bin\java test-stores: @@ -99,7 +99,7 @@ jobs: strategy: fail-fast: false matrix: - adapter: [ mongodb, hsqldb, monetdb, postgresql, file, cottontail, neo4j ] + adapter: [ mongodb, hsqldb, monetdb, postgresql, file, neo4j ] timeout-minutes: 10 runs-on: ubuntu-latest name: Test on ${{ matrix.adapter }} @@ -118,5 +118,5 @@ jobs: uses: polypheny/GitHub-Action-Run-Polypheny@v0.2.0 with: cmd: ./gradlew build -PdisableToolchain=true - jar: dbms-0.10.0-SNAPSHOT.jar + jar: dbms-0.10.1-SNAPSHOT.jar default-store: ${{ matrix.adapter }} diff --git a/src/main/java/org/polypheny/jdbc/multimodel/PolyStatement.java b/src/main/java/org/polypheny/jdbc/multimodel/PolyStatement.java index debf74a..5602e44 100644 --- a/src/main/java/org/polypheny/jdbc/multimodel/PolyStatement.java +++ b/src/main/java/org/polypheny/jdbc/multimodel/PolyStatement.java @@ -28,17 +28,23 @@ public class PolyStatement { - private static final long SCALAR_NOT_SET = -1; private static final int NO_STATEMENT_ID = -1; @Getter - private PolyConnection connection; + private final PolyConnection connection; @Getter private int statementId; private void resetStatement() { - statementId = NO_STATEMENT_ID; + if ( statementId != NO_STATEMENT_ID ) { + try { + getPrismInterfaceClient().closeStatement( statementId, 0 ); + } catch ( PrismInterfaceServiceException e ) { + // Ignore cleanup errors + } + statementId = NO_STATEMENT_ID; + } } diff --git a/src/main/java/org/polypheny/jdbc/multimodel/RelationalResult.java b/src/main/java/org/polypheny/jdbc/multimodel/RelationalResult.java index 4198591..13c81d1 100644 --- a/src/main/java/org/polypheny/jdbc/multimodel/RelationalResult.java +++ b/src/main/java/org/polypheny/jdbc/multimodel/RelationalResult.java @@ -54,7 +54,7 @@ private void fetchMore() throws PrismInterfaceServiceException { int id = polyStatement.getStatementId(); int timeout = getPolyphenyConnection().getTimeout(); Frame frame = getPrismInterfaceClient().fetchResult( id, timeout, PropertyUtils.getDEFAULT_FETCH_SIZE() ); - if ( frame.getResultCase() != ResultCase.DOCUMENT_FRAME ) { + if ( frame.getResultCase() != ResultCase.RELATIONAL_FRAME ) { throw new PrismInterfaceServiceException( PrismInterfaceErrors.RESULT_TYPE_INVALID, "Statement returned a result of illegal type " + frame.getResultCase() @@ -105,7 +105,7 @@ public boolean hasNext() { @Override public PolyRow next() { if ( !hasNext() ) { - throw new NoSuchElementException( "There are no more documents" ); + throw new NoSuchElementException( "There are no more rows" ); } return rows.get( ++index ); } diff --git a/src/test/java/org/polypheny/jdbc/QueryTest.java b/src/test/java/org/polypheny/jdbc/QueryTest.java index 0b74f49..ed46d6f 100644 --- a/src/test/java/org/polypheny/jdbc/QueryTest.java +++ b/src/test/java/org/polypheny/jdbc/QueryTest.java @@ -27,7 +27,9 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.polypheny.jdbc.multimodel.DocumentResult; +import org.polypheny.jdbc.multimodel.PolyRow; import org.polypheny.jdbc.multimodel.PolyStatement; +import org.polypheny.jdbc.multimodel.RelationalResult; import org.polypheny.jdbc.multimodel.Result; import org.polypheny.jdbc.multimodel.Result.ResultType; import org.polypheny.jdbc.types.PolyDocument; @@ -73,6 +75,29 @@ public void simpleRelationalTest() { } + @Test + public void largeRelationalTest() { + try ( Connection connection = TestHelper.getConnection() ) { + if ( !connection.isWrapperFor( PolyConnection.class ) ) { + fail( "Driver must support unwrapping to PolyphenyConnection" ); + } + PolyStatement polyStatement = connection.unwrap( PolyConnection.class ).createPolyStatement(); + polyStatement.execute( "public", "sql", "DROP TABLE IF EXISTS ids" ); + polyStatement.execute( "public", "sql", "CREATE TABLE ids(id INTEGER PRIMARY KEY)" ); + for ( int i = 0; i < 1000; i++ ) { + polyStatement.execute( "public", "sql", "INSERT INTO ids(id) VALUES(" + i + ")" ); + } + Result result = polyStatement.execute( "public", "sql", "SELECT * FROM ids" ); + assertEquals( ResultType.RELATIONAL, result.getResultType() ); + RelationalResult r = result.unwrap( RelationalResult.class ); + for ( PolyRow polyRow : r ) { + } + } catch ( SQLException e ) { + throw new RuntimeException( e ); + } + } + + @Test public void simpleMqlTest() { try ( Connection connection = TestHelper.getConnection() ) {