/ Check-in [e657c1d6]
Login

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

Overview
Comment:Minor simplification to the upsert logic.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:e657c1d60f5fca9464e9bcab24bc328855bec9986e0a029877f639355da4b201
User & Date: drh 2018-04-19 21:29:52
Context
2018-04-19
23:52
Fix the handling of "PRAGMA count_changes=ON" with UPSERT. Also improved the implementation of count_changes in other places, without changing the behavior. check-in: c6f71115 user: drh tags: trunk
21:29
Minor simplification to the upsert logic. check-in: e657c1d6 user: drh tags: trunk
20:06
Modify a test case in zipfile2.test to take into account that with some platform/file-system combinations it is possible to fopen() and fread() (but not fwrite()) a directory. check-in: 893e6089 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/upsert.c.

   254    254         if( pE2 ){
   255    255           pE2->iTable = regKey;
   256    256           pE2->affinity = pTab->zColAff[j];
   257    257         }
   258    258         pWhere = sqlite3ExprAnd(db,pWhere,sqlite3PExpr(pParse, TK_EQ, pE1, pE2));
   259    259       }
   260    260     }
          261  +  /* pUpsert does not own pUpsertSrc - the outer INSERT statement does.  So
          262  +  ** we have to make a copy before passing it down into sqlite3Update() */
   261    263     pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
   262         -  sqlite3Update(pParse, pSrc, 
   263         -      sqlite3ExprListDup(db, pUpsert->pUpsertSet, 0),
          264  +  sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
   264    265         pWhere, OE_Abort, 0, 0, pUpsert);
          266  +  pUpsert->pUpsertSet = 0;  /* Will have been deleted by sqlite3Update() */
   265    267     VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
   266    268   }
   267    269   
   268    270   #endif /* SQLITE_OMIT_UPSERT */