private int executeMutation(MutationPlan plan) throws SQLException {
// Note that the upsert select statements will need to commit any open transaction here,
// since they'd update data directly from coprocessors, and should thus operate on
// the latest state
MutationState state = plan.execute();
connection.getMutationState().join(state);
if (connection.getAutoCommit()) {
connection.commit();
}
lastResultSet = null;
lastQueryPlan = null;
// Unfortunately, JDBC uses an int for update count, so we
// just max out at Integer.MAX_VALUE
long updateCount = state.getUpdateCount();
lastUpdateCount = (int)Math.min(Integer.MAX_VALUE, updateCount);
return lastUpdateCount;
}