/ Check-in [7d308801]
Login

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

Overview
Comment:Recomputed unchanged column values in an UPDATE statement after running BEFORE triggers, in case the triggers have modified any of those values.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | experimental
Files: files | file ages | folders
SHA1: 7d30880114802606d95d037ce8641ef2d5dab4d5
User & Date: drh 2009-11-24 19:02:43
Original Comment: Recomputed unchanged column values in an UPDATE statement after running BEFORE triggers, in case the triggers have modified any of those values.
References
2009-11-27
12:12
Move [7d30880114] to the trunk. Add optimizations to reduce the number of opcodes used for BEFORE UPDATE triggers. check-in: 1b7c5250 user: dan tags: trunk
Context
2009-11-24
19:02
Recomputed unchanged column values in an UPDATE statement after running BEFORE triggers, in case the triggers have modified any of those values. Closed-Leaf check-in: 7d308801 user: drh tags: experimental
16:26
Fix a tracing macro in the VDBE in the VColumn opcode. check-in: cb74b81b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/update.c.

430
431
432
433
434
435
436











437
438
439
440
441
442
443

    /* The row-trigger may have deleted the row being updated. In this
    ** case, jump to the next row. No updates or AFTER triggers are 
    ** required. This behaviour - what happens when the row being updated
    ** is deleted or renamed by a BEFORE trigger - is left undefined in the
    ** documentation.  */
    sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);











  }

  if( !isView ){

    /* Do constraint checks. */
    sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,
        aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);







>
>
>
>
>
>
>
>
>
>
>







430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454

    /* The row-trigger may have deleted the row being updated. In this
    ** case, jump to the next row. No updates or AFTER triggers are 
    ** required. This behaviour - what happens when the row being updated
    ** is deleted or renamed by a BEFORE trigger - is left undefined in the
    ** documentation.  */
    sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);

    /* Recompute the values of columns that are unchanged by the UPDATE
    ** statement.  That way, if the BEFORE TRIGGERs modified any of those
    ** values, the modifications will be reflected in the update.
    */
    for(i=0; i<pTab->nCol; i++){
      if( i!=pTab->iPKey && (j = aXRef[i])<0 ){
        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i);
        sqlite3ColumnDefault(v, pTab, i, regNew+i);
      }
    }
  }

  if( !isView ){

    /* Do constraint checks. */
    sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,
        aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);