SQLite

Check-in [e657c1d60f]
Login

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

Overview
Comment:Minor simplification to the upsert logic.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e657c1d60f5fca9464e9bcab24bc328855bec9986e0a029877f639355da4b201
User & Date: drh 2018-04-19 21:29:52.191
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: c6f71115eb user: drh tags: trunk)
21:29
Minor simplification to the upsert logic. (check-in: e657c1d60f 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: 893e6089c8 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/upsert.c.
254
255
256
257
258
259
260


261
262
263
264

265
266
267
268
      if( pE2 ){
        pE2->iTable = regKey;
        pE2->affinity = pTab->zColAff[j];
      }
      pWhere = sqlite3ExprAnd(db,pWhere,sqlite3PExpr(pParse, TK_EQ, pE1, pE2));
    }
  }


  pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
  sqlite3Update(pParse, pSrc, 
      sqlite3ExprListDup(db, pUpsert->pUpsertSet, 0),
      pWhere, OE_Abort, 0, 0, pUpsert);

  VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
}

#endif /* SQLITE_OMIT_UPSERT */







>
>

|
<

>




254
255
256
257
258
259
260
261
262
263
264

265
266
267
268
269
270
      if( pE2 ){
        pE2->iTable = regKey;
        pE2->affinity = pTab->zColAff[j];
      }
      pWhere = sqlite3ExprAnd(db,pWhere,sqlite3PExpr(pParse, TK_EQ, pE1, pE2));
    }
  }
  /* pUpsert does not own pUpsertSrc - the outer INSERT statement does.  So
  ** we have to make a copy before passing it down into sqlite3Update() */
  pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
  sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,

      pWhere, OE_Abort, 0, 0, pUpsert);
  pUpsert->pUpsertSet = 0;  /* Will have been deleted by sqlite3Update() */
  VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
}

#endif /* SQLITE_OMIT_UPSERT */