]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Break out the upsert code into a separate source file.
authordrh <drh@noemail.net>
Thu, 12 Apr 2018 21:42:51 +0000 (21:42 +0000)
committerdrh <drh@noemail.net>
Thu, 12 Apr 2018 21:42:51 +0000 (21:42 +0000)
FossilOrigin-Name: 389806b05f163687d8eb858b0f87f9a2d02e90af9f2097924a66715f05177613

Makefile.in
Makefile.msc
main.mk
manifest
manifest.uuid
src/build.c
src/upsert.c [new file with mode: 0644]
tool/mksqlite3c.tcl

index 96ef34009ec93f3bbdddeeca5324a57bc180e9a8..a3ec869643c50aac67c39b499e1a35b9a85855f6 100644 (file)
@@ -187,7 +187,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
          random.lo resolve.lo rowset.lo rtree.lo \
          sqlite3session.lo select.lo sqlite3rbu.lo status.lo stmt.lo \
          table.lo threads.lo tokenize.lo treeview.lo trigger.lo \
-         update.lo util.lo vacuum.lo \
+         update.lo upsert.lo util.lo vacuum.lo \
          vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
          vdbetrace.lo wal.lo walker.lo where.lo wherecode.lo whereexpr.lo \
          utf.lo vtab.lo
@@ -284,6 +284,7 @@ SRC = \
   $(TOP)/src/trigger.c \
   $(TOP)/src/utf.c \
   $(TOP)/src/update.c \
+  $(TOP)/src/upsert.c \
   $(TOP)/src/util.c \
   $(TOP)/src/vacuum.c \
   $(TOP)/src/vdbe.c \
@@ -914,6 +915,9 @@ trigger.lo: $(TOP)/src/trigger.c $(HDR)
 update.lo:     $(TOP)/src/update.c $(HDR)
        $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/update.c
 
+upsert.lo:     $(TOP)/src/upsert.c $(HDR)
+       $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/upsert.c
+
 utf.lo:        $(TOP)/src/utf.c $(HDR)
        $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/utf.c
 
index 7d32af239eb4957202596038f38de7487810c749..50119d836110bab1799a65e31cc4e86f12de1124 100644 (file)
@@ -1193,7 +1193,7 @@ LIBOBJS0 = vdbe.lo parse.lo alter.lo analyze.lo attach.lo auth.lo \
          random.lo resolve.lo rowset.lo rtree.lo \
          sqlite3session.lo select.lo sqlite3rbu.lo status.lo \
          table.lo threads.lo tokenize.lo treeview.lo trigger.lo \
-         update.lo util.lo vacuum.lo \
+         update.lo upsert.lo util.lo vacuum.lo \
          vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
          vdbetrace.lo wal.lo walker.lo where.lo wherecode.lo whereexpr.lo \
          utf.lo vtab.lo
@@ -1292,6 +1292,7 @@ SRC01 = \
   $(TOP)\src\trigger.c \
   $(TOP)\src\utf.c \
   $(TOP)\src\update.c \
+  $(TOP)\src\upsert.c \
   $(TOP)\src\util.c \
   $(TOP)\src\vacuum.c \
   $(TOP)\src\vdbe.c \
@@ -1993,6 +1994,9 @@ trigger.lo:       $(TOP)\src\trigger.c $(HDR)
 update.lo:     $(TOP)\src\update.c $(HDR)
        $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\update.c
 
+upsert.lo:     $(TOP)\src\upsert.c $(HDR)
+       $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\upsert.c
+
 utf.lo:        $(TOP)\src\utf.c $(HDR)
        $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\utf.c
 
diff --git a/main.mk b/main.mk
index e5722c5827c9e0f5059e657aa0c058c4c10bc939..b590b79cb1bb0a4ff185b5dc3f570fbd4a6ed835 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -72,7 +72,7 @@ LIBOBJ+= vdbe.o parse.o \
          random.o resolve.o rowset.o rtree.o \
          select.o sqlite3rbu.o status.o stmt.o \
          table.o threads.o tokenize.o treeview.o trigger.o \
-         update.o userauth.o util.o vacuum.o \
+         update.o upsert.o userauth.o util.o vacuum.o \
          vdbeapi.o vdbeaux.o vdbeblob.o vdbemem.o vdbesort.o \
         vdbetrace.o wal.o walker.o where.o wherecode.o whereexpr.o \
          utf.o vtab.o
@@ -162,6 +162,7 @@ SRC = \
   $(TOP)/src/trigger.c \
   $(TOP)/src/utf.c \
   $(TOP)/src/update.c \
+  $(TOP)/src/upsert.c \
   $(TOP)/src/util.c \
   $(TOP)/src/vacuum.c \
   $(TOP)/src/vdbe.c \
index d191e83f0e59724d9007e3e3ada492026c0e9a0d..a38311d885206e2b606f56450000db050be547d2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,10 +1,10 @@
-C Fix\sanother\stypo\sin\sa\scomment.
-D 2018-04-12T20:21:42.287
+C Break\sout\sthe\supsert\scode\sinto\sa\sseparate\ssource\sfile.
+D 2018-04-12T21:42:51.995
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
-F Makefile.in 7016fc56c6b9bfe5daac4f34be8be38d8c0b5fab79ccbfb764d3b23bf1c6fff3
+F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
-F Makefile.msc 43dd6ae2e5a2bb8df7bfc9ed85935129caffeafb8c1803d24c5d038b1e74c8ca
+F Makefile.msc 59179295f6a9b433e3f59a6dc2fcf6db6fcac35d92015294beb5d27f2924ebb9
 F README.md 7764d56778d567913ef11c82da9ab94aefa0826f7c243351e4e2d7adaef6f373
 F VERSION 7169eb6959db9ad1b7004ae3b754ef6e703eb7d8dde3b07d2e63103413eb25fb
 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
@@ -413,7 +413,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f
 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
-F main.mk 63668484c95454af7fc04a384da27ac556f27368d6d0c345e405e1677c66768f
+F main.mk 068618fe288bf9d93091b808be73e26a93fb2db8435328cc5760f9dd35ba168b
 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
 F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@@ -435,7 +435,7 @@ F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
 F src/btree.c 9eb9531c65346bbfccf5325384b7db1849daf4db6601dcfe21ba5c5b20623b64
 F src/btree.h 0866c0a08255142ea0e754aabd211c843cab32045c978a592a43152405ed0c84
 F src/btreeInt.h 620ab4c7235f43572cf3ac2ac8723cbdf68073be4d29da24897c7b77dda5fd96
-F src/build.c 16cbe486985d0c1649ddfda24dfc25ad92fd74e9561cdd29b6381bcbb23f0657
+F src/build.c 61320fb84034c24313de699f3385c6bfe093c925b4df2931c6eb63d7c94ec62a
 F src/callback.c fe677cb5f5abb02f7a772a62a98c2f516426081df68856e8f2d5f950929b966a
 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
 F src/ctime.c bd9da3f1ff21b432564a16ef0b154cff03585dc43742842e99c58907c6cb4bef
@@ -557,6 +557,7 @@ F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e
 F src/treeview.c 14d5d1254702ec96876aa52642cb31548612384134970409fae333b25b39d6bb
 F src/trigger.c 00ef0b16ab3f0063439e6582086f57f3beb93cd7e7ba46569a8bdc490c16283d
 F src/update.c a72ab172860c73c16fe25a2a3d5ae675fbdd63918cddfa2aaad5f402a86637c9
+F src/upsert.c 8b1a4fc628bbea35b71d8b12878f79a3b3f4ecc6c0566f5bfc44c563ae43626a
 F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
 F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157
 F src/vacuum.c 762ee9bbf8733d87d8cd06f58d950e881982e416f8c767334a40ffd341b6bff5
@@ -1655,7 +1656,7 @@ F tool/mkshellc.tcl 1f45770aea226ac093a9c72f718efbb88a2a2833409ec2e1c4cecae42026
 F tool/mksourceid.c d458f9004c837bee87a6382228ac20d3eae3c49ea3b0a5aace936f8b60748d3b
 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
 F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb
-F tool/mksqlite3c.tcl a03cee30de81a2e67b93e5c659f24113a003677c557daeb008205c8e6d4345d6
+F tool/mksqlite3c.tcl d532ccbe81234f766bab6e5c0451c99529debcea138caccc1862a9645b2d54f2
 F tool/mksqlite3h.tcl 080873e3856eceb9d289a08a00c4b30f875ea3feadcbece796bd509b1532792c
 F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
 F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5
@@ -1717,7 +1718,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P a26f9c9f89c24048cb77d5c0c8de37f46de7dce80f8bf49cadcd58b239dbdfa7
-R 874b3e14cecb965e93edd2dd3103bd97
+P 046bb6d25865041477f046f24c39a4791224f5b622ff70eda909d8ee3c097511
+R 41785e0192d6fba81c3e6856455c92b9
 U drh
-Z d91048704d1bf59cfa4d3acf3d274a10
+Z 05e0d66364795932149da9418a180159
index 421496bd838ca91ef2c6b9a56856f6653a3402ad..8cb4711e821221361d7e7f6aed92335138d21676 100644 (file)
@@ -1 +1 @@
-046bb6d25865041477f046f24c39a4791224f5b622ff70eda909d8ee3c097511
\ No newline at end of file
+389806b05f163687d8eb858b0f87f9a2d02e90af9f2097924a66715f05177613
\ No newline at end of file
index 2b3c8a1cf943a0b63543025c7b4018dc8400ee92..c286b4bbe7fe68af697ae393704e5583872999cb 100644 (file)
@@ -4473,63 +4473,3 @@ void sqlite3WithDelete(sqlite3 *db, With *pWith){
   }
 }
 #endif /* !defined(SQLITE_OMIT_CTE) */
-
-#ifndef SQLITE_OMIT_UPSERT
-/*
-** Free a list of Upsert objects
-*/
-void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){
-  while( p ){
-    Upsert *pNext = p->pUpsertNext;
-    sqlite3ExprListDelete(db, p->pUpsertTarget);
-    sqlite3ExprListDelete(db, p->pUpsertSet);
-    sqlite3ExprDelete(db, p->pUpsertWhere);
-    sqlite3DbFree(db, p);
-    p = pNext;
-  }
-}
-#endif /* SQLITE_OMIT_UPSERT */
-
-#ifndef SQLITE_OMIT_UPSERT
-/*
-** Duplicate an Upsert object.
-*/
-Upsert *sqlite3UpsertDup(sqlite3 *db, Upsert *p){
-  if( p==0 ) return 0;
-  return sqlite3UpsertNew(db,
-           sqlite3UpsertDup(db, p->pUpsertNext),
-           sqlite3ExprListDup(db, p->pUpsertTarget, 0),
-           sqlite3ExprListDup(db, p->pUpsertSet, 0),
-           sqlite3ExprDup(db, p->pUpsertWhere, 0)
-         );
-}
-#endif /* SQLITE_OMIT_UPSERT */
-
-#ifndef SQLITE_OMIT_UPSERT
-/*
-** Create a new Upsert object.
-*/
-Upsert *sqlite3UpsertNew(
-  sqlite3 *db,           /* Determines which memory allocator to use */
-  Upsert *pPrior,        /* Append this upsert to the end of the new one */
-  ExprList *pTarget,     /* Target argument to ON CONFLICT, or NULL */
-  ExprList *pSet,        /* UPDATE columns, or NULL for a DO NOTHING */
-  Expr *pWhere           /* WHERE clause for the ON CONFLICT UPDATE */
-){
-  Upsert *pNew;
-  pNew = sqlite3DbMallocRaw(db, sizeof(Upsert));
-  if( pNew==0 ){
-    sqlite3UpsertDelete(db, pPrior);
-    sqlite3ExprListDelete(db, pTarget);
-    sqlite3ExprListDelete(db, pSet);
-    sqlite3ExprDelete(db, pWhere);
-    return 0;
-  }else{
-    pNew->pUpsertTarget = pTarget;
-    pNew->pUpsertSet = pSet;
-    pNew->pUpsertNext = pPrior;
-    pNew->pUpsertWhere = pWhere;
-  }
-  return pNew;
-}
-#endif /* SQLITE_OMIT_UPSERT */
diff --git a/src/upsert.c b/src/upsert.c
new file mode 100644 (file)
index 0000000..b42ef06
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+** 2018-04-12
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+** This file contains code to implement various aspects of UPSERT
+** processing and handling of the Upsert object.
+*/
+#include "sqliteInt.h"
+
+#ifndef SQLITE_OMIT_UPSERT
+/*
+** Free a list of Upsert objects
+*/
+void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){
+  while( p ){
+    Upsert *pNext = p->pUpsertNext;
+    sqlite3ExprListDelete(db, p->pUpsertTarget);
+    sqlite3ExprListDelete(db, p->pUpsertSet);
+    sqlite3ExprDelete(db, p->pUpsertWhere);
+    sqlite3DbFree(db, p);
+    p = pNext;
+  }
+}
+
+/*
+** Duplicate an Upsert object.
+*/
+Upsert *sqlite3UpsertDup(sqlite3 *db, Upsert *p){
+  if( p==0 ) return 0;
+  return sqlite3UpsertNew(db,
+           sqlite3UpsertDup(db, p->pUpsertNext),
+           sqlite3ExprListDup(db, p->pUpsertTarget, 0),
+           sqlite3ExprListDup(db, p->pUpsertSet, 0),
+           sqlite3ExprDup(db, p->pUpsertWhere, 0)
+         );
+}
+
+/*
+** Create a new Upsert object.
+*/
+Upsert *sqlite3UpsertNew(
+  sqlite3 *db,           /* Determines which memory allocator to use */
+  Upsert *pPrior,        /* Append this upsert to the end of the new one */
+  ExprList *pTarget,     /* Target argument to ON CONFLICT, or NULL */
+  ExprList *pSet,        /* UPDATE columns, or NULL for a DO NOTHING */
+  Expr *pWhere           /* WHERE clause for the ON CONFLICT UPDATE */
+){
+  Upsert *pNew;
+  pNew = sqlite3DbMallocRaw(db, sizeof(Upsert));
+  if( pNew==0 ){
+    sqlite3UpsertDelete(db, pPrior);
+    sqlite3ExprListDelete(db, pTarget);
+    sqlite3ExprListDelete(db, pSet);
+    sqlite3ExprDelete(db, pWhere);
+    return 0;
+  }else{
+    pNew->pUpsertTarget = pTarget;
+    pNew->pUpsertSet = pSet;
+    pNew->pUpsertNext = pPrior;
+    pNew->pUpsertWhere = pWhere;
+  }
+  return pNew;
+}
+
+#endif /* SQLITE_OMIT_UPSERT */
index f2d93aadd0c852bc265dc4e75c8fd9dd8527aa4a..6c1dab6accca31aca34dd1ea03f56a76f27ebcd1 100644 (file)
@@ -363,6 +363,7 @@ foreach file {
    table.c
    trigger.c
    update.c
+   upsert.c
    vacuum.c
    vtab.c
    wherecode.c