Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/jni/duckdb_java.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ static duckdb::unique_ptr<QueryResult> execute_prepared_statement(JNIEnv *env, j
duckdb::unique_ptr<QueryResultStream<>> complete_query_streaming(JNIEnv *env, duckdb::unique_ptr<QueryResult> pending) {
auto stream = make_uniq<QueryResultStream<>>(std::move(pending));
while (!duckdb::IsObservable(stream->ExecuteTask())) {
if (stream->HasError()) {
throw_execution_java_error(env, stream.get());
return nullptr;
}
}
if (stream->HasError()) {
throw_execution_java_error(env, stream.get());
return nullptr;
}
return stream;
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/org/duckdb/TestResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,23 @@ public static void test_result_streaming_ddl() throws Exception {
}
}

public static void test_result_streaming_error() throws Exception {
Properties props = new Properties();
props.setProperty(JDBC_STREAM_RESULTS, String.valueOf(true));

String QUERY = "SELECT CAST('x' || i::VARCHAR AS INTEGER) AS v FROM range(10) t(i)";
try (Connection conn = DriverManager.getConnection(JDBC_URL, props); Statement stmt = conn.createStatement()) {
String msg = assertThrows(() -> { stmt.executeQuery(QUERY); }, SQLException.class);
assertTrue(msg.contains("Conversion Error: Could not convert string 'x0' to INT32"), msg);
}

try (Connection conn = DriverManager.getConnection(JDBC_URL, props);
PreparedStatement ps = conn.prepareStatement(QUERY)) {
String msg = assertThrows(ps::executeQuery, SQLException.class);
assertTrue(msg.contains("Conversion Error: Could not convert string 'x0' to INT32"), msg);
}
}

public static void test_stream_multiple_open_results() throws Exception {
Properties props = new Properties();
props.setProperty(JDBC_STREAM_RESULTS, String.valueOf(true));
Expand Down
Loading