From be758ce3ae490909d9bb12a15b30794fc69b7cbf Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 18 Sep 2014 17:57:46 +0000 Subject: [PATCH] Update the ota extension to support SQLITE_ENABLE_8_3_NAMES builds. FossilOrigin-Name: 718da6de870231d358384473b40e81c4394b8067 --- ext/ota/sqlite3ota.c | 41 +++++++++++++++++++++++++++++++++++++++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/ext/ota/sqlite3ota.c b/ext/ota/sqlite3ota.c index 34f5e3db6e..18a71910e5 100644 --- a/ext/ota/sqlite3ota.c +++ b/ext/ota/sqlite3ota.c @@ -999,12 +999,46 @@ static void otaLoadTransactionState(sqlite3ota *p, OtaState *pState){ } } +/* +** This routine is a copy of the sqlite3FileSuffix3() routine from the core. +** It is a no-op unless SQLITE_ENABLE_8_3_NAMES is defined. +** +** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database +** filename in zBaseFilename is a URI with the "8_3_names=1" parameter and +** if filename in z[] has a suffix (a.k.a. "extension") that is longer than +** three characters, then shorten the suffix on z[] to be the last three +** characters of the original suffix. +** +** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always +** do the suffix shortening regardless of URI parameter. +** +** Examples: +** +** test.db-journal => test.nal +** test.db-wal => test.wal +** test.db-shm => test.shm +** test.db-mj7f3319fa => test.9fa +*/ +static void otaFileSuffix3(const char *zBase, char *z){ +#ifdef SQLITE_ENABLE_8_3_NAMES +#if SQLITE_ENABLE_8_3_NAMES<2 + if( sqlite3_uri_boolean(zBase, "8_3_names", 0) ) +#endif + { + int i, sz; + sz = sqlite3Strlen30(z); + for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){} + if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4); + } +#endif +} + /* ** Move the "*-oal" file corresponding to the target database to the ** "*-wal" location. If an error occurs, leave an error code and error ** message in the ota handle. */ -static void otaMoveOalFile(sqlite3ota *p){ +static void otaMoveOalFile(const char *zBase, sqlite3ota *p){ char *zWal = sqlite3_mprintf("%s-wal", p->zTarget); char *zOal = sqlite3_mprintf("%s-oal", p->zTarget); @@ -1012,6 +1046,8 @@ static void otaMoveOalFile(sqlite3ota *p){ if( zWal==0 || zOal==0 ){ p->rc = SQLITE_NOMEM; }else{ + otaFileSuffix3(zBase, zWal); + otaFileSuffix3(zBase, zOal); rename(zOal, zWal); } @@ -1096,6 +1132,7 @@ sqlite3ota *sqlite3ota_open(const char *zTarget, const char *zOta){ int sqlite3ota_close(sqlite3ota *p, char **pzErrmsg){ int rc; if( p ){ + const char *zBase = sqlite3_db_filename(p->db, "main"); /* If the update has not been fully applied, save the state in ** the ota db. If successful, this call also commits the open @@ -1121,7 +1158,7 @@ int sqlite3ota_close(sqlite3ota *p, char **pzErrmsg){ /* If the OTA has been completely applied and no error occurred, move ** the *-oal file to *-wal. */ if( p->rc==SQLITE_DONE ){ - otaMoveOalFile(p); + otaMoveOalFile(zBase, p); } rc = p->rc; diff --git a/manifest b/manifest index 98eac4a03c..ec203b7073 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\squotes\sinstead\sof\sangle-brackets\sto\sinclude\ssqlite3.h\sfrom\ssqlite3ota.h. -D 2014-09-18T16:38:10.149 +C Update\sthe\sota\sextension\sto\ssupport\sSQLITE_ENABLE_8_3_NAMES\sbuilds. +D 2014-09-18T17:57:46.895 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -127,7 +127,7 @@ 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 4b7f15662e725bd79c92242293336d74ebeff854 +F ext/ota/sqlite3ota.c b22002105b3b7f3baf63bda2b4e6a00c4973418c F ext/ota/sqlite3ota.h 7b20abe9247d292429d00f0a5c237ff6e0dc0196 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 F ext/rtree/rtree.c 57bec53e1a677ab74217fe1f20a58c3a47261d6b @@ -1206,7 +1206,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 0da1862b1b68f15c7c14286a982dda886d1e3b4a -R e1133f29a6887c2dcc50626f2201457f +P fce9c6ccf101d28492a84b85463433f32ef569fb +R feab70887c117c061b61fe713ccedbe4 U dan -Z d4fc012b67241f1149bf53ab8b647500 +Z 86cf672a01ea748dc788d9b12ee5fdc1 diff --git a/manifest.uuid b/manifest.uuid index 497c4aa9aa..1b666612e7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fce9c6ccf101d28492a84b85463433f32ef569fb \ No newline at end of file +718da6de870231d358384473b40e81c4394b8067 \ No newline at end of file -- 2.47.2