Version
main
Platform
Subsystem
sqlite
What steps will reproduce the bug?
import { Database, constants } from 'node:sqlite';
import { constants as _constants } from 'node:buffer';
const { MAX_STRING_LENGTH } = _constants;
const db = new Database(':memory:');
// '\u20ac' is 1 UTF-16 unit but 3 UTF-8 bytes.
const name = '\u20ac'.repeat(Math.ceil(MAX_STRING_LENGTH / 3) + 10);
try {
if (process.argv[2] === 'columns') {
db.exec(`CREATE TABLE t (x "${name}")`);
db.prepare('SELECT x FROM t').columns();
} else {
db.setAuthorizer(() => constants.SQLITE_OK);
db.prepare(`CREATE TABLE "${name}" (x)`);
}
} catch (err) {
console.log(err.code);
}
Run node repro.js for the authorizer trigger and node repro.js columns for the statement.columns() trigger.
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Both calls should throw a catchable error and not abort the process. With a 10-character name, both complete normally. When SQLite text doesn't fit in a JS string, node:sqlite already throws ERR_STRING_TOO_LONG for column values (#66209) and for error messages. These strings should do the same.
What do you see instead?
#
# Fatal error
# Check failed: String::kMaxLength >= len.
#
#
#
#FailureMessage Object: 0x16ce74ca8
----- Native stack trace -----
Additional information
Noticed while fixing #66520
Version
main
Platform
Subsystem
sqlite
What steps will reproduce the bug?
Run
node repro.jsfor the authorizer trigger andnode repro.js columnsfor thestatement.columns()trigger.How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Both calls should throw a catchable error and not abort the process. With a 10-character name, both complete normally. When SQLite text doesn't fit in a JS string,
node:sqlitealready throwsERR_STRING_TOO_LONGfor column values (#66209) and for error messages. These strings should do the same.What do you see instead?
Additional information
Noticed while fixing #66520