/ Check-in [c74e0bc4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove the sqlite3ota_open_v2() API. Add a new parameter to sqlite3ota_open() instead.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c74e0bc481ce995f83ca8384e05dfbe068a0ae85
User & Date: dan 2015-05-19 17:48:11
Context
2015-05-19
19:44
Ensure that when the VM applies TEXT affinity to a value it discards any existing REAL or INTEGER value. Fix for [34cd55d6]. check-in: f5d0ce80 user: dan tags: trunk
17:48
Remove the sqlite3ota_open_v2() API. Add a new parameter to sqlite3ota_open() instead. check-in: c74e0bc4 user: dan tags: trunk
16:50
Merge the ota-update branch with trunk. check-in: 08e2864e user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/ota/sqlite3ota.c.

2656
2657
2658
2659
2660
2661
2662



2663
2664
2665
2666
2667
2668
2669
2670
....
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
static void otaDeleteVfs(sqlite3ota *p){
  if( p->zVfsName ){
    sqlite3ota_destroy_vfs(p->zVfsName);
    p->zVfsName = 0;
  }
}




static sqlite3ota *otaOpen(
  const char *zTarget, 
  const char *zOta,
  const char *zState
){
  sqlite3ota *p;
  int nTarget = strlen(zTarget);
  int nOta = strlen(zOta);
................................................................................
    otaFreeState(pState);
  }

  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;
  if( pOta ){
    db = (bOta ? pOta->dbOta : pOta->dbMain);







>
>
>
|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
....
2775
2776
2777
2778
2779
2780
2781





















2782
2783
2784
2785
2786
2787
2788
static void otaDeleteVfs(sqlite3ota *p){
  if( p->zVfsName ){
    sqlite3ota_destroy_vfs(p->zVfsName);
    p->zVfsName = 0;
  }
}

/*
** Open and return a new OTA handle. 
*/
sqlite3ota *sqlite3ota_open(
  const char *zTarget, 
  const char *zOta,
  const char *zState
){
  sqlite3ota *p;
  int nTarget = strlen(zTarget);
  int nOta = strlen(zOta);
................................................................................
    otaFreeState(pState);
  }

  return p;
}























/*
** Return the database handle used by pOta.
*/
sqlite3 *sqlite3ota_db(sqlite3ota *pOta, int bOta){
  sqlite3 *db = 0;
  if( pOta ){
    db = (bOta ? pOta->dbOta : pOta->dbMain);

Changes to ext/ota/sqlite3ota.h.

257
258
259
260
261
262
263














264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
** Argument zTarget is the path to the target database. Argument zOta is
** the path to the OTA database. Each call to this function must be matched
** 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.
**














** 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,
  const char *zOta,
  const char *zState
);

/*
** Internally, each OTA connection uses a separate SQLite database 
** connection to access the target and ota update databases. This







>
>
>
>
>
>
>
>
>
>
>
>
>
>









<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|







257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286



























287
288
289
290
291
292
293
294
295
** Argument zTarget is the path to the target database. Argument zOta is
** the path to the OTA database. Each call to this function must be matched
** 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,
  const char *zState
);

/*
** Internally, each OTA connection uses a separate SQLite database 
** connection to access the target and ota update databases. This

Changes to ext/ota/test_ota.c.

120
121
122
123
124
125
126

127
128
129
130
131
132
133
134

135
136
137
138
139
140
141
142
143
144
145
146
147
148
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3ota *pOta = 0;
  const char *zCmd;
  const char *zTarget;
  const char *zOta;


  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==4 ){
    pOta = sqlite3ota_open(zTarget, zOta);
  }else{
    const char *zStateDb = Tcl_GetString(objv[4]);
    pOta = sqlite3ota_open_v2(zTarget, zOta, zStateDb);
  }
  Tcl_CreateObjCommand(interp, zCmd, test_sqlite3ota_cmd, (ClientData)pOta, 0);
  Tcl_SetObjResult(interp, objv[1]);
  return TCL_OK;
}

/*
** Tclcmd: sqlite3ota_create_vfs ?-default? NAME PARENT







>








>

<
|
<
<
<
<







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

138




139
140
141
142
143
144
145
  int objc,
  Tcl_Obj *CONST objv[]
){
  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]);


  pOta = sqlite3ota_open(zTarget, zOta, zStateDb);




  Tcl_CreateObjCommand(interp, zCmd, test_sqlite3ota_cmd, (ClientData)pOta, 0);
  Tcl_SetObjResult(interp, objv[1]);
  return TCL_OK;
}

/*
** Tclcmd: sqlite3ota_create_vfs ?-default? NAME PARENT