Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ ExecuteResult prepareAndExecuteInternal(
final PrepareCallback callback)
throws SQLException {

return ArrowFlightPreparedStatement.builder(getConnection())
.withQuery(query)
.withExistingStatement(this)
.build()
.prepareAndExecuteInternal(callback);
final ArrowFlightPreparedStatement replacement =
ArrowFlightPreparedStatement.builder(getConnection())
.withQuery(query)
.withExistingStatement(this)
.build();
closePreparedResources();
return replacement.prepareAndExecuteInternal(callback);
}

Schema getDataSetSchema() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,33 @@ public void testExecuteShouldRunSelectQuery() throws SQLException {
is(allOf(equalTo(statement.getLargeUpdateCount()), equalTo(-1L))));
}

@Test
public void testExecuteMultipleTimesClosesAllPreparedStatements() throws SQLException {
PRODUCER.clearActionTypeCounter();

assertThat(statement.execute(SAMPLE_QUERY_CMD), is(true));
assertThat(statement.execute(SAMPLE_QUERY_CMD), is(true));

assertThat(
PRODUCER
.getActionTypeCounter()
.getOrDefault(FlightSqlUtils.FLIGHT_SQL_CREATE_PREPARED_STATEMENT.getType(), 0),
is(2));
assertThat(
PRODUCER
.getActionTypeCounter()
.getOrDefault(FlightSqlUtils.FLIGHT_SQL_CLOSE_PREPARED_STATEMENT.getType(), 0),
is(1));

statement.close();

assertThat(
PRODUCER
.getActionTypeCounter()
.getOrDefault(FlightSqlUtils.FLIGHT_SQL_CLOSE_PREPARED_STATEMENT.getType(), 0),
is(2));
}

@Test
public void testExecutePrepareFailurePreservesServerError() {
final SQLException exception =
Expand Down
Loading