Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/sqlite/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -238388,7 +238388,7 @@ static int sessionApplyOneOp(
for(i=0; rc==SQLITE_OK && i<nCol; i++){
sqlite3_value *pOld = sessionChangesetOld(pIter, i);
sqlite3_value *pNew = sessionChangesetNew(pIter, i);
if( p->abPK[i] || (bPatchset==0 && pOld) ){
if( pOld && (p->abPK[i] || bPatchset==0) ){
rc = sessionBindValue(pUp, i*2+2, pOld);
}
if( rc==SQLITE_OK && pNew ){
Expand Down
21 changes: 21 additions & 0 deletions test/parallel/test-sqlite-session.js
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm agnostic towards merging, but we definitely shouldn't be regression testing on sqlite3's behalf, as it'll cause havoc with shared builds.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thanks. I pushed an update to skip this regression test when Node is
built with shared SQLite, so it only runs against the bundled SQLite copy that
this PR patches.

If you would prefer not to carry this SQLite regression test in Node at all,
I’m happy to remove it.

Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,27 @@ test('database.applyChangeset() - wrong arguments', (t) => {
});
});

test('database.applyChangeset() - malformed changeset returns SQLITE_CORRUPT', {
skip: process.config.variables.node_shared_sqlite ?
'requires the bundled SQLite session fix' : false,
}, (t) => {
const database = new DatabaseSync(':memory:');
database.exec('CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d)');

const changeset = Buffer.from(
'540401000000743100177e0072286565286565',
'hex');

t.assert.throws(() => {
database.applyChangeset(changeset);
}, {
name: 'Error',
message: 'database disk image is malformed',
errcode: 11,
code: 'ERR_SQLITE_ERROR',
});
});

test('session.patchset()', (t) => {
const database = new DatabaseSync(':memory:');
database.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');
Expand Down