/ Check-in [e73ac0cb]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix a broken assert() and comparison for INSERT INTO ... SELECT when the SELECT uses an unknown collating sequence.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e73ac0cbac257d2d2b28e51423e30d7449b6c7b5
User & Date: drh 2015-04-19 22:41:22
Context
2015-04-19
23:11
Fix an off-by-one assert() in the virtual table argument tokenizer. check-in: c83052e4 user: drh tags: trunk
22:41
Fix a broken assert() and comparison for INSERT INTO ... SELECT when the SELECT uses an unknown collating sequence. check-in: e73ac0cb user: drh tags: trunk
22:31
Silently ignore parser stack overflow when parsing a malformed schema in PRAGMA writable_schema mode. check-in: 2cb37b95 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/insert.c.

645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
    addrTop = sqlite3VdbeCurrentAddr(v) + 1;
    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
    sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
    dest.iSdst = bIdListInOrder ? regData : 0;
    dest.nSdst = pTab->nCol;
    rc = sqlite3Select(pParse, pSelect, &dest);
    regFromSelect = dest.iSdst;
    assert( pParse->nErr==0 || rc );
    if( rc || db->mallocFailed ) goto insert_cleanup;
    sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);
    sqlite3VdbeJumpHere(v, addrTop - 1);                       /* label B: */
    assert( pSelect->pEList );
    nColumn = pSelect->pEList->nExpr;

    /* Set useTempTable to TRUE if the result of the SELECT statement
    ** should be written into a temporary table (template 4).  Set to







<
|







645
646
647
648
649
650
651

652
653
654
655
656
657
658
659
    addrTop = sqlite3VdbeCurrentAddr(v) + 1;
    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
    sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
    dest.iSdst = bIdListInOrder ? regData : 0;
    dest.nSdst = pTab->nCol;
    rc = sqlite3Select(pParse, pSelect, &dest);
    regFromSelect = dest.iSdst;

    if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;
    sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);
    sqlite3VdbeJumpHere(v, addrTop - 1);                       /* label B: */
    assert( pSelect->pEList );
    nColumn = pSelect->pEList->nExpr;

    /* Set useTempTable to TRUE if the result of the SELECT statement
    ** should be written into a temporary table (template 4).  Set to

Changes to test/insert4.test.

556
557
558
559
560
561
562





563
564
    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, y);
    INSERT INTO t2 VALUES(1,3);
    INSERT INTO t1 SELECT * FROM t2;
    SELECT * FROM t1;
  }
} {1 3}







finish_test







>
>
>
>
>


556
557
558
559
560
561
562
563
564
565
566
567
568
569
    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, y);
    INSERT INTO t2 VALUES(1,3);
    INSERT INTO t1 SELECT * FROM t2;
    SELECT * FROM t1;
  }
} {1 3}

do_catchsql_test insert4-9.1 {
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(x);
  INSERT INTO t1(x) VALUES(5 COLLATE xyzzy) UNION SELECT 0;
} {1 {no such collation sequence: xyzzy}}

finish_test