SQLite

Check-in [3bed599e74]
Login

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

Overview
Comment:Improved VDBE comments on the constraint checker. Fix a missing write lock in the UPDATE logic.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | omit-rowid
Files: files | file ages | folders
SHA1: 3bed599e74d354bf1513e4fb0e8665376ba44d0b
User & Date: drh 2013-11-01 14:03:20.023
Context
2013-11-01
17:08
Change the interface to sqlite3GenerateConstraintChecks() for improved lucidity and to fix issues in dealing with UPDATEs for WITHOUT ROWID tables. Make sure iDataCur and iIdxCur are initialized when processing DELETEs of a VIEW. UPDATE processing distinguishes between changes to ROWID and PRIMARY KEY. (check-in: c525ac5630 user: drh tags: omit-rowid)
14:03
Improved VDBE comments on the constraint checker. Fix a missing write lock in the UPDATE logic. (check-in: 3bed599e74 user: drh tags: omit-rowid)
12:42
Some UPDATE statements now working in WITHOUT ROWID tables. (check-in: 5c0eaea6a2 user: drh tags: omit-rowid)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/insert.c.
1431
1432
1433
1434
1435
1436
1437

1438
1439
1440
1441
1442
1443

1444
1445
1446
1447
1448
1449
1450
    }

    /* Create a record for this index entry as it should appear after
    ** the insert or update. */
    regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn);
    for(i=0; i<pIdx->nColumn; i++){
      int iField = pIdx->aiColumn[i];

      if( iField<0 || iField==pTab->iPKey ){
        iField = regNewData;
      }else{
        iField += regNewData + 1;
      }
      sqlite3VdbeAddOp2(v, OP_SCopy, iField, regIdx+i);

    }
    sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
    sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT);
    VdbeComment((v, "for %s", pIdx->zName));
    sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn);

    /* Find out what action to take in case there is a uniqueness conflict */







>

|

|

|
>







1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
    }

    /* Create a record for this index entry as it should appear after
    ** the insert or update. */
    regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn);
    for(i=0; i<pIdx->nColumn; i++){
      int iField = pIdx->aiColumn[i];
      int x;
      if( iField<0 || iField==pTab->iPKey ){
        x = regNewData;
      }else{
        x = iField + regNewData + 1;
      }
      sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i);
      VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName));
    }
    sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
    sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT);
    VdbeComment((v, "for %s", pIdx->zName));
    sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn);

    /* Find out what action to take in case there is a uniqueness conflict */
Changes to src/update.c.
383
384
385
386
387
388
389

390
391
392
393
394
395
396
    ** index could potentially invoke a REPLACE conflict resolution 
    ** action, then we need to open all indices because we might need
    ** to be deleting some records.
    */
    if( !okOnePass && HasRowid(pTab) ){
      sqlite3OpenTable(pParse, iDataCur, iDb, pTab, OP_OpenWrite); 
    }

    if( onError==OE_Replace ){
      openAll = 1;
    }else{
      openAll = 0;
      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
        if( pIdx->onError==OE_Replace ){
          openAll = 1;







>







383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
    ** index could potentially invoke a REPLACE conflict resolution 
    ** action, then we need to open all indices because we might need
    ** to be deleting some records.
    */
    if( !okOnePass && HasRowid(pTab) ){
      sqlite3OpenTable(pParse, iDataCur, iDb, pTab, OP_OpenWrite); 
    }
    sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);
    if( onError==OE_Replace ){
      openAll = 1;
    }else{
      openAll = 0;
      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
        if( pIdx->onError==OE_Replace ){
          openAll = 1;