/ Check-in [7353caab]
Login

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

Overview
Comment:Merge the preupdate hook change from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | upsert
Files: files | file ages | folders
SHA3-256: 7353caabb31803ccff83fe188c4ee65e75c883de2beea79cbe17375a4a98d9ac
User & Date: drh 2018-04-13 16:29:50
Context
2018-04-13
18:59
Add infrastructure for doing an UPDATE as part of an UPSERT. Still no actual UPDATE code, however. check-in: 6d3017f9 user: drh tags: upsert
16:29
Merge the preupdate hook change from trunk. check-in: 7353caab user: drh tags: upsert
16:23
Remove an always-true branch from the preupdate hook logic. check-in: 0ab45188 user: drh tags: trunk
15:14
Get the ON CONFLICT DO NOTHING form of upsert working by mapping it into INSERT OR IGNORE. check-in: d07f05e9 user: drh tags: upsert
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/insert.c.

  1464   1464           }
  1465   1465           if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
  1466   1466             sqlite3MultiWrite(pParse);
  1467   1467             sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
  1468   1468                                      regNewData, 1, 0, OE_Replace, 1, -1);
  1469   1469           }else{
  1470   1470   #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
  1471         -          if( HasRowid(pTab) ){
  1472         -            /* This OP_Delete opcode fires the pre-update-hook only. It does
  1473         -            ** not modify the b-tree. It is more efficient to let the coming
  1474         -            ** OP_Insert replace the existing entry than it is to delete the
  1475         -            ** existing entry and then insert a new one. */
  1476         -            sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
  1477         -            sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
  1478         -          }
         1471  +          assert( HasRowid(pTab) );
         1472  +          /* This OP_Delete opcode fires the pre-update-hook only. It does
         1473  +          ** not modify the b-tree. It is more efficient to let the coming
         1474  +          ** OP_Insert replace the existing entry than it is to delete the
         1475  +          ** existing entry and then insert a new one. */
         1476  +          sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
         1477  +          sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
  1479   1478   #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
  1480   1479             if( pTab->pIndex ){
  1481   1480               sqlite3MultiWrite(pParse);
  1482   1481               sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,-1);
  1483   1482             }
  1484   1483           }
  1485   1484           seenReplace = 1;