Merge 'Stop ignoring table's max value incase of a manual update in autoincrement.' from Pavan Nambi
Some checks are pending
Run long fuzz tests and stress test / run-long-tests (push) Waiting to run
Run long fuzz tests and stress test / simple-stress-test (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Build and push limbo-sim image / deploy (push) Waiting to run
C compat Tests / test (push) Waiting to run
Dart/Flutter / precompile (windows-latest) (push) Waiting to run
Dart/Flutter / publish (push) Waiting to run
Dart/Flutter / precompile (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Dart/Flutter / precompile (macOS-latest) (push) Waiting to run
Dart/Flutter / test (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Dart/Flutter / test (windows-latest) (push) Waiting to run
Java Tests / test (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run

closes https://github.com/tursodatabase/turso/issues/3664

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #3668
This commit is contained in:
Pekka Enberg 2025-10-12 18:38:13 +03:00 committed by GitHub
commit 7221f79a2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -6412,7 +6412,7 @@ pub fn op_new_rowid(
NewRowid {
cursor,
rowid_reg,
..
prev_largest_reg,
},
insn
);
@ -6455,6 +6455,11 @@ pub fn op_new_rowid(
return_if_io!(cursor.rowid())
};
if *prev_largest_reg > 0 {
state.registers[*prev_largest_reg] =
Register::Value(Value::Integer(current_max.unwrap_or(0)));
}
match current_max {
Some(rowid) if rowid < MAX_ROWID => {
// Can use sequential

View file

@ -174,4 +174,17 @@ do_execsql_test_on_specific_db {:memory:} autoinc-conflict-on-nothing {
INSERT INTO t (k) VALUES ('a') ON CONFLICT DO NOTHING;
INSERT INTO t (k) VALUES ('b');
SELECT * FROM t ORDER BY id;
} {1|a 2|a 4|b}
} {1|a 2|a 4|b}
# https://github.com/tursodatabase/turso/issues/3664
do_execsql_test_on_specific_db {:memory:} autoinc-skips-manually-updated-pk {
CREATE TABLE t(a INTEGER PRIMARY KEY AUTOINCREMENT);
INSERT INTO t DEFAULT VALUES;
select * from sqlite_sequence;
UPDATE t SET a = a + 1;
SELECT * FROM sqlite_sequence;
INSERT INTO t DEFAULT VALUES;
SELECT * FROM sqlite_sequence;
} {t|1
t|1
t|3}