Skip to content

sqlite: run() throws after committing when lastInsertRowid exceeds 2^53 #66464

Description

@araujogui

Version

v27.0.0-pre (main @ 4486dce)

Platform

Darwin 25.6.0 arm64

Subsystem

sqlite

What steps will reproduce the bug?

const { DatabaseSync } = require('node:sqlite');
const db = new DatabaseSync(':memory:');
db.exec('CREATE TABLE r(id INTEGER PRIMARY KEY); CREATE TABLE o(x)');
db.prepare('INSERT INTO r VALUES (?)').run(2n ** 53n + 1n); // ERR_OUT_OF_RANGE, row is inserted
db.prepare('DELETE FROM o').run();                          // ERR_OUT_OF_RANGE

How often does it reproduce? Is there a required condition?

Always, when readBigInts is off and the connection's last insert rowid exceeds 2^53.

What is the expected behavior? Why is that the expected behavior?

run() shouldn't throw after the write has committed. Proposal: return a BigInt for out-of-range values regardless of readBigInts. Is that acceptable, or should we only document it?

What do you see instead?

run() converts lastInsertRowid and changes only after stepping (src/node_sqlite.cc:4153). If a value is outside the safe-integer range, it throws, but the write has already committed. The last insert rowid belongs to the connection, so every later run() on that connection also throws. Not documented.

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sqliteIssues and PRs related to the SQLite subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions