SQLite

Check-in [c6506b82aa]
Login

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

Overview
Comment:Improved the comment on the block of code the provides the performance optimization originally added by check-in [925840cfdb]. The original check-in omitted condition 4, which was the cause of bug [30027b613b].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | replace-fix
Files: files | file ages | folders
SHA1: c6506b82aa6583ccde5f673c79526d5f3920b67a
User & Date: drh 2017-01-04 22:02:56.715
Context
2017-01-05
06:57
Fix some problems with foreign key processing within REPLACE ops on WITHOUT ROWID tables with no triggers or auxiliary indexes. (Closed-Leaf check-in: c1220b1af6 user: dan tags: replace-fix)
2017-01-04
22:02
Improved the comment on the block of code the provides the performance optimization originally added by check-in [925840cfdb]. The original check-in omitted condition 4, which was the cause of bug [30027b613b]. (check-in: c6506b82aa user: drh tags: replace-fix)
20:13
Possible fix for [30027b61]. There may still be problems surrounding foreign key processing. (check-in: 71ccb1f4c4 user: dan tags: replace-fix)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/insert.c.
1545
1546
1547
1548
1549
1550
1551








1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
    }
    if( overrideError!=OE_Default ){
      onError = overrideError;
    }else if( onError==OE_Default ){
      onError = OE_Abort;
    }









    if( ix==0 && pPk==pIdx && onError==OE_Replace && pPk->pNext==0 ){
      if( 0==(db->flags&SQLITE_RecTriggers)
       || 0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0)
      ){
        sqlite3VdbeResolveLabel(v, addrUniqueOk);
        continue;
      }
    }

    
    /* Check to see if the new index entry will be unique */
    sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
                         regIdx, pIdx->nKeyCol); VdbeCoverage(v);

    /* Generate code to handle collisions */
    regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
    if( isUpdate || onError==OE_Replace ){







>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
<
<







1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567


1568
1569
1570
1571
1572
1573
1574
    }
    if( overrideError!=OE_Default ){
      onError = overrideError;
    }else if( onError==OE_Default ){
      onError = OE_Abort;
    }

    /* Collision detection may be omitted if all of the following are true:
    **   (1) The conflict resolution algorithm is REPLACE
    **   (2) The table is a WITHOUT ROWID table
    **   (3) There are no secondary indexes on the table
    **   (4) No delete triggers need to be fired if there is a conflict
    */ 
    if( (ix==0 && pIdx->pNext==0)                   /* Condition 3 */
     && pPk==pIdx                                   /* Condition 2 */
     && onError==OE_Replace                         /* Condition 1 */
     && ( 0==(db->flags&SQLITE_RecTriggers) ||      /* Condition 4 */
          0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))
    ){
      sqlite3VdbeResolveLabel(v, addrUniqueOk);
      continue;
    }



    /* Check to see if the new index entry will be unique */
    sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
                         regIdx, pIdx->nKeyCol); VdbeCoverage(v);

    /* Generate code to handle collisions */
    regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
    if( isUpdate || onError==OE_Replace ){