You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sqlite: statement iterator state is corrupted by coincident statement execution #61819
Statement iterators that have not finished iterating are not invalidated when the statement is reset.
const{ DatabaseSync }=require('node:sqlite');constdb=newDatabaseSync(':memory:')db.exec('CREATE TABLE test (value INTEGER NOT NULL)');for(leti=0;i<10;i++){db.prepare('INSERT INTO test (value) VALUES (?)').run(i);}conststmt=db.prepare('SELECT * FROM test');constit=stmt.iterate();it.next().value;// { value: 0 }it.next().value;// { value: 1 }it.next().value;// { value: 2 }// resets, executes and re-resets statementstmt.get();// { value: 0 }// sqlite3_step restarts from beginning of resultit.next().value;// { value: 0 }it.next().value;// { value: 1 }it.next().value;// { value: 2 }// these will raceconstit2=stmt.iterate();it.next().value;// { value: 0 }it2.next().value;// { value: 1 }it.next().value;// { value: 2 }it2.next().value;// { value: 3 }
If the statement iterator is not done and the statement is reset, then the iterator should be invalidated and subsequent calls to .next() should throw.
Activity
Renegade334 commentedon Feb 14, 2026
cc @nodejs/sqlite