Index: ext/ota/sqlite3ota.c ================================================================== --- ext/ota/sqlite3ota.c +++ ext/ota/sqlite3ota.c @@ -2658,11 +2658,14 @@ sqlite3ota_destroy_vfs(p->zVfsName); p->zVfsName = 0; } } -static sqlite3ota *otaOpen( +/* +** Open and return a new OTA handle. +*/ +sqlite3ota *sqlite3ota_open( const char *zTarget, const char *zOta, const char *zState ){ sqlite3ota *p; @@ -2774,31 +2777,10 @@ return p; } -/* -** Open and return a new OTA handle. -*/ -sqlite3ota *sqlite3ota_open_v2( - const char *zDb, - const char *zOta, - const char *zState -){ - return otaOpen(zDb, zOta, zState); -} - -/* -** Open and return a new OTA handle. -*/ -sqlite3ota *sqlite3ota_open( - const char *zDb, - const char *zOta -){ - return otaOpen(zDb, zOta, 0); -} - /* ** Return the database handle used by pOta. */ sqlite3 *sqlite3ota_db(sqlite3ota *pOta, int bOta){ sqlite3 *db = 0; Index: ext/ota/sqlite3ota.h ================================================================== --- ext/ota/sqlite3ota.h +++ ext/ota/sqlite3ota.h @@ -259,48 +259,35 @@ ** by a call to sqlite3ota_close(). When opening the databases, OTA passes ** the SQLITE_CONFIG_URI flag to sqlite3_open_v2(). So if either zTarget ** or zOta begin with "file:", it will be interpreted as an SQLite ** database URI, not a regular file name. ** +** If the zState argument is passed a NULL value, the OTA extension stores +** the current state of the update (how many rows have been updated, which +** indexes are yet to be updated etc.) within the OTA database itself. This +** can be convenient, as it means that the OTA application does not need to +** organize removing a separate state file after the update is concluded. +** Or, if zState is non-NULL, it must be a path to a database file in which +** the OTA extension can store the state of the update. +** +** When resuming an OTA update, the zState argument must be passed the same +** value as when the OTA update was started. +** +** Once the OTA update is finished, the OTA extension does not +** automatically remove any zState database file, even if it created it. +** ** By default, OTA uses the default VFS to access the files on disk. To ** use a VFS other than the default, an SQLite "file:" URI containing a ** "vfs=..." option may be passed as the zTarget option. ** ** IMPORTANT NOTE FOR ZIPVFS USERS: The OTA extension works with all of ** SQLite's built-in VFSs, including the multiplexor VFS. However it does ** not work out of the box with zipvfs. Refer to the comment describing ** the zipvfs_create_vfs() API below for details on using OTA with zipvfs. */ -sqlite3ota *sqlite3ota_open(const char *zTarget, const char *zOta); - -/* -** Open an OTA handle with an auxiliary state file. -** -** This API is similar to sqlite3ota_open(), except that it allows the user -** to specify a separate SQLite database in which to store the OTA update -** state. -** -** While executing, the OTA extension usually stores the current state -** of the update (how many rows have been updated, which indexes are yet -** to be updated etc.) within the OTA database itself. This can be -** convenient, as it means that the OTA application does not need to -** organize removing a separate state file after the update is concluded. -** However, it can also be inconvenient - for example if the OTA update -** database is sto be stored on a read-only media. -** -** If an OTA update started using a handle opened with this function is -** suspended, the application must use this function to resume it, and -** must pass the same zState argument each time the update is resumed. -** Attempting to resume an sqlite3ota_open_v2() update using sqlite3ota_open(), -** or with a call to sqlite3ota_open_v2() specifying a different zState -** argument leads to undefined behaviour. -** -** Once the OTA update is finished, the OTA extension does not -** automatically remove the zState database file, even if it created it. -*/ -sqlite3ota *sqlite3ota_open_v2( - const char *zTarget, +sqlite3ota *sqlite3ota_open( + const char *zTarget, const char *zOta, const char *zState ); /* Index: ext/ota/test_ota.c ================================================================== --- ext/ota/test_ota.c +++ ext/ota/test_ota.c @@ -122,25 +122,22 @@ ){ sqlite3ota *pOta = 0; const char *zCmd; const char *zTarget; const char *zOta; + const char *zStateDb = 0; if( objc!=4 && objc!=5 ){ Tcl_WrongNumArgs(interp, 1, objv, "NAME TARGET-DB OTA-DB ?STATE-DB?"); return TCL_ERROR; } zCmd = Tcl_GetString(objv[1]); zTarget = Tcl_GetString(objv[2]); zOta = Tcl_GetString(objv[3]); + if( objc==5 ) zStateDb = Tcl_GetString(objv[4]); - if( objc==4 ){ - pOta = sqlite3ota_open(zTarget, zOta); - }else{ - const char *zStateDb = Tcl_GetString(objv[4]); - pOta = sqlite3ota_open_v2(zTarget, zOta, zStateDb); - } + pOta = sqlite3ota_open(zTarget, zOta, zStateDb); Tcl_CreateObjCommand(interp, zCmd, test_sqlite3ota_cmd, (ClientData)pOta, 0); Tcl_SetObjResult(interp, objv[1]); return TCL_OK; }