Merge 'Fix update queries to set n_changes ' from Kim Seon Woo

- `Update` query doesn't update `n_changes`. Let's make it work
- Add `InsertFlags` to add meta information related to insert operations
- For update query, add `UPDATE` flag
- Currently, the update query executes `Insn::Delete` and `Insn::Insert`
internally, it increases `n_change` by 2. So, for the update query,
let's skip increasing `n_change` for the `Insn::Insert`
https://github.com/tursodatabase/limbo/issues/1681

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1683
This commit is contained in:
Pekka Enberg
2025-06-16 16:30:20 +03:00
10 changed files with 71 additions and 21 deletions

View File

@@ -11,7 +11,6 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import tech.turso.TestUtils;
@@ -83,11 +82,9 @@ class JDBC4StatementTest {
}
@Test
@Disabled("limbo's total_changes() works differently from sqlite's total_changes()")
void execute_update_should_return_number_of_updated_elements() throws Exception {
assertThat(stmt.executeUpdate("CREATE TABLE s1 (c1 INT);")).isEqualTo(0);
assertThat(stmt.executeUpdate("INSERT INTO s1 VALUES (1), (2), (3);")).isEqualTo(3);
assertThat(stmt.executeUpdate("UPDATE s1 SET c1 = 0;")).isEqualTo(3);
}