SQLite

Check-in [84417bbd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a possible NULL pointer dereference due to the sqlite3_interrupt() enhancement at [bd8fa10e59f58886]. Reported by forum post f5a2b1db87.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 84417bbd144b2197c9930a520feb94b59053957c190be79f8deaaaebca68ecf1
User & Date: drh 2023-03-08 23:05:18
References
2023-03-21
14:20
Add ALWAYS() on a branch this is always true now due to [84417bbd144b2197]. (check-in: badf7d0e user: drh tags: trunk)
Context
2023-03-09
08:51
Experimental addition of sqlite3-node.mjs, for node.js, based on feedback from forum post ac7a94d4f77db235 and related off-list discussions. Build changes only - no code changes. (check-in: a5db97fa user: stephan tags: trunk)
01:35
Fix a possible NULL pointer dereference due to the sqlite3_interrupt() enhancement in the 3.41.0 release. (check-in: 66d24a22 user: drh tags: branch-3.41)
2023-03-08
23:05
Fix a possible NULL pointer dereference due to the sqlite3_interrupt() enhancement at [bd8fa10e59f58886]. Reported by forum post f5a2b1db87. (check-in: 84417bbd user: drh tags: trunk)
22:48
Backout the OP_MakeRecord optimization as it does not work. (check-in: 25017312 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/trigger.c.

979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
  sqlite3SelectPrep(pParse, &sSelect, 0);
  if( pParse->nErr==0 ){
    assert( db->mallocFailed==0 );
    sqlite3GenerateColumnNames(pParse, &sSelect);
  }
  sqlite3ExprListDelete(db, sSelect.pEList);
  pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
  if( !db->mallocFailed ){
    NameContext sNC;
    memset(&sNC, 0, sizeof(sNC));
    if( pReturning->nRetCol==0 ){
      pReturning->nRetCol = pNew->nExpr;
      pReturning->iRetCur = pParse->nTab++;
    }
    sNC.pParse = pParse;







|







979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
  sqlite3SelectPrep(pParse, &sSelect, 0);
  if( pParse->nErr==0 ){
    assert( db->mallocFailed==0 );
    sqlite3GenerateColumnNames(pParse, &sSelect);
  }
  sqlite3ExprListDelete(db, sSelect.pEList);
  pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
  if( pParse->nErr==0 ){
    NameContext sNC;
    memset(&sNC, 0, sizeof(sNC));
    if( pReturning->nRetCol==0 ){
      pReturning->nRetCol = pNew->nExpr;
      pReturning->iRetCur = pParse->nTab++;
    }
    sNC.pParse = pParse;

Changes to test/returning1.test.

208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
    INSERT INTO log VALUES('insert', new.rowid, new.a, new.b);
  END;
  CREATE TRIGGER tr2 INSTEAD OF UPDATE ON t1 BEGIN
    INSERT INTO log VALUES('update', new.rowid, new.a, new.b);
  END;
}

do_catchsql_test 10.3 {
  INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid;
} {1 {no such column: rowid}}

do_catchsql_test 10.3 {
  UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid;
} {1 {no such column: rowid}}

do_execsql_test 10.4 {
  SELECT * FROM log;
} {}

# 2021-04-27 dbsqlfuzz 78b9400770ef8cc7d9427dfba26f4fcf46ea7dc2
# Returning clauses on TEMP tables with triggers.







|

|

|

|







208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
    INSERT INTO log VALUES('insert', new.rowid, new.a, new.b);
  END;
  CREATE TRIGGER tr2 INSTEAD OF UPDATE ON t1 BEGIN
    INSERT INTO log VALUES('update', new.rowid, new.a, new.b);
  END;
}

do_catchsql_test 10.3a {
  INSERT INTO t1(a, b) VALUES(1234, 5678) RETURNING rowid;
} {1 {no such column: new.rowid}}

do_catchsql_test 10.3b {
  UPDATE t1 SET a='z' WHERE b='y' RETURNING rowid;
} {1 {no such column: new.rowid}}

do_execsql_test 10.4 {
  SELECT * FROM log;
} {}

# 2021-04-27 dbsqlfuzz 78b9400770ef8cc7d9427dfba26f4fcf46ea7dc2
# Returning clauses on TEMP tables with triggers.
403
404
405
406
407
408
409
410











411
#
reset_db
do_execsql_test 17.0 {
  CREATE TABLE bug(id INTEGER PRIMARY KEY NOT NULL, x);
  INSERT INTO bug(id,x) VALUES(20, NULL);
  UPDATE bug SET x=NULL WHERE id = 20 RETURNING quote(x), x IS NULL;
} {NULL 1}












finish_test








>
>
>
>
>
>
>
>
>
>
>

403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
#
reset_db
do_execsql_test 17.0 {
  CREATE TABLE bug(id INTEGER PRIMARY KEY NOT NULL, x);
  INSERT INTO bug(id,x) VALUES(20, NULL);
  UPDATE bug SET x=NULL WHERE id = 20 RETURNING quote(x), x IS NULL;
} {NULL 1}

# 2023-03-08 https://sqlite.org/forum/forumpost/f5a2b1db87
# NULL pointer dereference following an error.
#
do_execsql_test 18.0 {
  CREATE TABLE v0(c1 INT);
  CREATE VIEW view_2(c1) AS SELECT CASE WHEN c1 COLLATE TRUE THEN TRUE ELSE TRUE END FROM v0;
}
do_catchsql_test 18.1 {
  INSERT INTO view_2 DEFAULT VALUES RETURNING *;
} {1 {no such collation sequence: TRUE}}

finish_test