]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add an API to query an ota handle for the total number of key/value operations perfor...
authordan <dan@noemail.net>
Thu, 18 Sep 2014 14:48:38 +0000 (14:48 +0000)
committerdan <dan@noemail.net>
Thu, 18 Sep 2014 14:48:38 +0000 (14:48 +0000)
FossilOrigin-Name: e3943fa7bbbfc5e16f73a494d8fa54d19e9cfcf9

ext/ota/ota.c
ext/ota/sqlite3ota.c
ext/ota/sqlite3ota.h
manifest
manifest.uuid

index c00eed4f0be6190938754783131a41bcf1339302..febdbfe2da9ee19eb11eae2ad4efc7e7a2974d32 100644 (file)
@@ -55,6 +55,7 @@ int main(int argc, char **argv){
   sqlite3ota *pOta;               /* OTA handle */
   int nStep = 0;                  /* Maximum number of step() calls */
   int rc;
+  sqlite3_int64 nProgress = 0;
 
   /* Process command line arguments. Following this block local variables 
   ** zTarget, zOta and nStep are all set. */
@@ -76,16 +77,23 @@ int main(int argc, char **argv){
   ** sqlite3ota_step() a maximum of nStep times.  */
   pOta = sqlite3ota_open(zTarget, zOta);
   for(i=0; (nStep<=0 || i<nStep) && sqlite3ota_step(pOta)==SQLITE_OK; i++);
+  nProgress = sqlite3ota_progress(pOta);
   rc = sqlite3ota_close(pOta, &zErrmsg);
 
   /* Let the user know what happened. */
   switch( rc ){
     case SQLITE_OK:
-      fprintf(stdout, "SQLITE_OK: ota update incomplete\n");
+      fprintf(stdout, 
+          "SQLITE_OK: ota update incomplete (%lld operations so far)\n",
+          nProgress
+      );
       break;
 
     case SQLITE_DONE:
-      fprintf(stdout, "SQLITE_DONE: ota update completed\n");
+      fprintf(stdout, 
+          "SQLITE_DONE: ota update completed (%lld operations)\n",
+          nProgress
+      );
       break;
 
     default:
index cc968a54bb8dae0c138f640320be77ba74e0ff55..8d5a5bf761fceea602eeb94e3bb22424e8d6e189 100644 (file)
@@ -49,6 +49,7 @@ struct OtaState {
   char *zTbl;
   char *zIdx;
   int nRow;
+  sqlite3_int64 nProgress;
 };
 
 /*
@@ -93,6 +94,7 @@ struct sqlite3ota {
   int rc;                         /* Value returned by last ota_step() call */
   char *zErrmsg;                  /* Error message if rc!=SQLITE_OK */
   int nStep;                      /* Rows processed for current object */
+  int nProgress;                  /* Rows processed for all objects */
   OtaObjIter objiter;
 };
 
@@ -881,6 +883,7 @@ int sqlite3ota_step(sqlite3ota *p){
           int rc = sqlite3_step(pIter->pSelect);
           if( rc==SQLITE_ROW ){
             p->nStep++;
+            p->nProgress++;
             return otaStep(p);
           }
           p->rc = sqlite3_reset(pIter->pSelect);
@@ -901,8 +904,8 @@ int sqlite3ota_step(sqlite3ota *p){
 static void otaSaveTransactionState(sqlite3ota *p){
   otaMPrintfExec(p, 
     "INSERT OR REPLACE INTO ota.ota_state(rowid, tbl, idx, row, progress)"
-    "VALUES(1, %Q, %Q, %d, NULL)",
-    p->objiter.zTbl, p->objiter.zIdx, p->nStep
+    "VALUES(1, %Q, %Q, %d, %lld)",
+    p->objiter.zTbl, p->objiter.zIdx, p->nStep, p->nProgress
   );
 }
 
@@ -942,6 +945,7 @@ static OtaState *otaLoadState(sqlite3ota *p){
           pRet->zIdx = 0;
         }
         pRet->nRow = sqlite3_column_int(pStmt, 2);
+        pRet->nProgress = sqlite3_column_int64(pStmt, 3);
       }
     }else{
       pRet = (OtaState*)sqlite3_malloc(sizeof(OtaState));
@@ -1075,6 +1079,7 @@ sqlite3ota *sqlite3ota_open(const char *zTarget, const char *zOta){
     }
 
     if( p->rc==SQLITE_OK ){
+      p->nProgress = pState->nProgress;
       otaLoadTransactionState(p, pState);
     }
 
@@ -1128,6 +1133,15 @@ int sqlite3ota_close(sqlite3ota *p, char **pzErrmsg){
   return rc;
 }
 
+/*
+** Return the total number of key-value operations (inserts, deletes or 
+** updates) that have been performed on the target database since the
+** current OTA update was started.
+*/
+sqlite3_int64 sqlite3ota_progress(sqlite3ota *pOta){
+  return pOta->nProgress;
+}
+
 
 /**************************************************************************/
 
index 9473b359f2b1b0349d7d9e61c6a689bc8d487bb7..30c84c2c020a52f68a5bd7bbd6bee43eaecdb4d6 100644 (file)
@@ -215,5 +215,12 @@ int sqlite3ota_step(sqlite3ota *pOta);
 */
 int sqlite3ota_close(sqlite3ota *pOta, char **pzErrmsg);
 
+/*
+** Return the total number of key-value operations (inserts, deletes or 
+** updates) that have been performed on the target database since the
+** current OTA update was started.
+*/
+sqlite3_int64 sqlite3ota_progress(sqlite3ota *pOta);
+
 #endif /* _SQLITE3OTA_H */
 
index a16f3db60022f358dcbec559fd70235559eadb8c..8130805f1d42978db45b8f7395c6047ba62b9b4a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Merge\slatest\strunk\schanges\swith\sthis\sbranch.
-D 2014-09-18T11:31:52.958
+C Add\san\sAPI\sto\squery\san\sota\shandle\sfor\sthe\stotal\snumber\sof\skey/value\soperations\sperformed\sso\sfar.
+D 2014-09-18T14:48:38.579
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -121,13 +121,13 @@ F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e
 F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
-F ext/ota/ota.c d37097e92a005d3915883adefbb93019ea6f8841
+F ext/ota/ota.c c11a85af71dccc45976622fe7a51169a481caa91
 F ext/ota/ota1.test 7cbf37a9f6cd29320f47b041cfeb0cc1d7eaa916
 F ext/ota/ota2.test 716f9c66e8bf8b0ad2fe3a5d8323e6cf460a2e27
 F ext/ota/ota3.test 1c48b7476af1c5920db9a43e7b1476d421a463b5
 F ext/ota/ota4.test baf23b47748a5056c713871959cc70fc623c90e9
-F ext/ota/sqlite3ota.c 276c0426e678edc06df5c295515b44f773ad6e93
-F ext/ota/sqlite3ota.h 39ce4dffbfcf4ade9e4526369fe2243709345c8e
+F ext/ota/sqlite3ota.c e5dfb63ac4564139b66acf6f712d6d1bb5007b26
+F ext/ota/sqlite3ota.h 4f9d8c56c673f279167ddc57e8f84c0c406346f0
 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
 F ext/rtree/rtree.c 57bec53e1a677ab74217fe1f20a58c3a47261d6b
 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
@@ -1205,7 +1205,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 7da98ca2422166dc5d68607541707f41b77b5784 3bd7c1b2faa2d4cc95b255633204006849bfd5e0
-R 8e63365c95630e53dbe0beb2fbad87f1
+P 67ea2979d5831b6d0d55173bd9413b21644cf6a1
+R 38d6ede7d1ef519b3ce4a32ffbb6512b
 U dan
-Z 4b3913e6deb233dcf8270d9446c1c662
+Z 2cc714eb22b38452d154c6b43dc8544c
index 762f3d0c14934f7f5af2c710dc24bb30dcbad392..38824d34b14c78cfbbeca7e7730199d4209bda84 100644 (file)
@@ -1 +1 @@
-67ea2979d5831b6d0d55173bd9413b21644cf6a1
\ No newline at end of file
+e3943fa7bbbfc5e16f73a494d8fa54d19e9cfcf9
\ No newline at end of file