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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class PrestoPreparedStatement
private final Map<Integer, String> parameters = new HashMap<>();
private final String statementName;
private final String originalSql;
private boolean isClosed;

PrestoPreparedStatement(PrestoConnection connection, String statementName, String sql)
throws SQLException
Expand All @@ -88,8 +89,12 @@ public class PrestoPreparedStatement
public void close()
throws SQLException
{
if (isClosed) {
return;
}
super.execute(format("DEALLOCATE PREPARE %s", statementName));
super.close();
isClosed = true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@ public void testDeallocate()
}
}

@Test
public void testCloseIdempotency()
throws Exception
{
try (Connection connection = createConnection()) {
PreparedStatement statement = connection.prepareStatement("SELECT 123");
statement.close();
statement.close();
}
}

@Test
public void testExecuteUpdate()
throws Exception
Expand Down