From: dan Date: Thu, 18 Sep 2014 14:48:38 +0000 (+0000) Subject: Add an API to query an ota handle for the total number of key/value operations perfor... X-Git-Tag: version-3.8.11~252^2~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4caa8fbc1eb6cf78efadcc148e09d5c83ef1d9ce;p=thirdparty%2Fsqlite.git Add an API to query an ota handle for the total number of key/value operations performed so far. FossilOrigin-Name: e3943fa7bbbfc5e16f73a494d8fa54d19e9cfcf9 --- diff --git a/ext/ota/ota.c b/ext/ota/ota.c index c00eed4f0b..febdbfe2da 100644 --- a/ext/ota/ota.c +++ b/ext/ota/ota.c @@ -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 || ipSelect); 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; +} + /**************************************************************************/ diff --git a/ext/ota/sqlite3ota.h b/ext/ota/sqlite3ota.h index 9473b359f2..30c84c2c02 100644 --- a/ext/ota/sqlite3ota.h +++ b/ext/ota/sqlite3ota.h @@ -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 */ diff --git a/manifest b/manifest index a16f3db600..8130805f1d 100644 --- 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 diff --git a/manifest.uuid b/manifest.uuid index 762f3d0c14..38824d34b1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67ea2979d5831b6d0d55173bd9413b21644cf6a1 \ No newline at end of file +e3943fa7bbbfc5e16f73a494d8fa54d19e9cfcf9 \ No newline at end of file