Issue
Better-sqlite3 cannot insert blobs larger than ~512MB, even though MAX_LENGTH is compiled as 2147483647 (2GB).
Expected behavior
Should be able to insert blobs up to the configured limit (default 1GB or 2GB).
Actual behavior
- Maximum successful blob size: 536,870,881 bytes (~512 MB)
- Minimum failing blob size: 536,870,882 bytes
- Error:
string or blob too big
Test code
const Database = require('better-sqlite3');
const db = new Database('test.db');
db.pragma('journal_mode = WAL');
db.exec('CREATE TABLE test (id INTEGER PRIMARY KEY, data BLOB)');
const stmt = db.prepare('INSERT INTO test (id, data) VALUES (?, ?)');
// This works:
const buf1 = Buffer.alloc(536870881, 0);
stmt.run(1, buf1);
// This fails:
const buf2 = Buffer.alloc(536870882, 0);
stmt.run(2, buf2); // Error: string or blob too big
Environment
- better-sqlite3 version: 11.10.0
- SQLite version: 3.49.2
- MAX_LENGTH (compile option): 2147483647
- Node.js version: v22.20.0
- OS: macOS
Issue
Better-sqlite3 cannot insert blobs larger than ~512MB, even though
MAX_LENGTHis compiled as 2147483647 (2GB).Expected behavior
Should be able to insert blobs up to the configured limit (default 1GB or 2GB).
Actual behavior
string or blob too bigTest code
Environment