Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: third_party/sqlite/src/ext/rbu/sqlite3rbu.h

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 ** 2014 August 30 2 ** 2014 August 30
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ** 97 **
98 ** The order of the columns in the data_% table does not matter. 98 ** The order of the columns in the data_% table does not matter.
99 ** 99 **
100 ** Instead of a regular table, the RBU database may also contain virtual 100 ** Instead of a regular table, the RBU database may also contain virtual
101 ** tables or view named using the data_<target> naming scheme. 101 ** tables or view named using the data_<target> naming scheme.
102 ** 102 **
103 ** Instead of the plain data_<target> naming scheme, RBU database tables 103 ** Instead of the plain data_<target> naming scheme, RBU database tables
104 ** may also be named data<integer>_<target>, where <integer> is any sequence 104 ** may also be named data<integer>_<target>, where <integer> is any sequence
105 ** of zero or more numeric characters (0-9). This can be significant because 105 ** of zero or more numeric characters (0-9). This can be significant because
106 ** tables within the RBU database are always processed in order sorted by 106 ** tables within the RBU database are always processed in order sorted by
107 ** name. By judicious selection of the the <integer> portion of the names 107 ** name. By judicious selection of the <integer> portion of the names
108 ** of the RBU tables the user can therefore control the order in which they 108 ** of the RBU tables the user can therefore control the order in which they
109 ** are processed. This can be useful, for example, to ensure that "external 109 ** are processed. This can be useful, for example, to ensure that "external
110 ** content" FTS4 tables are updated before their underlying content tables. 110 ** content" FTS4 tables are updated before their underlying content tables.
111 ** 111 **
112 ** If the target database table is a virtual table or a table that has no 112 ** If the target database table is a virtual table or a table that has no
113 ** PRIMARY KEY declaration, the data_% table must also contain a column 113 ** PRIMARY KEY declaration, the data_% table must also contain a column
114 ** named "rbu_rowid". This column is mapped to the tables implicit primary 114 ** named "rbu_rowid". This column is mapped to the tables implicit primary
115 ** key column - "rowid". Virtual tables for which the "rowid" column does 115 ** key column - "rowid". Virtual tables for which the "rowid" column does
116 ** not function like a primary key value cannot be updated using RBU. For 116 ** not function like a primary key value cannot be updated using RBU. For
117 ** example, if the target db contains either of the following: 117 ** example, if the target db contains either of the following:
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 ** not work out of the box with zipvfs. Refer to the comment describing 308 ** not work out of the box with zipvfs. Refer to the comment describing
309 ** the zipvfs_create_vfs() API below for details on using RBU with zipvfs. 309 ** the zipvfs_create_vfs() API below for details on using RBU with zipvfs.
310 */ 310 */
311 sqlite3rbu *sqlite3rbu_open( 311 sqlite3rbu *sqlite3rbu_open(
312 const char *zTarget, 312 const char *zTarget,
313 const char *zRbu, 313 const char *zRbu,
314 const char *zState 314 const char *zState
315 ); 315 );
316 316
317 /* 317 /*
318 ** Open an RBU handle to perform an RBU vacuum on database file zTarget.
319 ** An RBU vacuum is similar to SQLite's built-in VACUUM command, except
320 ** that it can be suspended and resumed like an RBU update.
321 **
322 ** The second argument to this function identifies a database in which
323 ** to store the state of the RBU vacuum operation if it is suspended. The
324 ** first time sqlite3rbu_vacuum() is called, to start an RBU vacuum
325 ** operation, the state database should either not exist or be empty
326 ** (contain no tables). If an RBU vacuum is suspended by calling
327 ** sqlite3rbu_close() on the RBU handle before sqlite3rbu_step() has
328 ** returned SQLITE_DONE, the vacuum state is stored in the state database.
329 ** The vacuum can be resumed by calling this function to open a new RBU
330 ** handle specifying the same target and state databases.
331 **
332 ** If the second argument passed to this function is NULL, then the
333 ** name of the state database is "<database>-vacuum", where <database>
334 ** is the name of the target database file. In this case, on UNIX, if the
335 ** state database is not already present in the file-system, it is created
336 ** with the same permissions as the target db is made.
337 **
338 ** This function does not delete the state database after an RBU vacuum
339 ** is completed, even if it created it. However, if the call to
340 ** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents
341 ** of the state tables within the state database are zeroed. This way,
342 ** the next call to sqlite3rbu_vacuum() opens a handle that starts a
343 ** new RBU vacuum operation.
344 **
345 ** As with sqlite3rbu_open(), Zipvfs users should rever to the comment
346 ** describing the sqlite3rbu_create_vfs() API function below for
347 ** a description of the complications associated with using RBU with
348 ** zipvfs databases.
349 */
350 sqlite3rbu *sqlite3rbu_vacuum(
351 const char *zTarget,
352 const char *zState
353 );
354
355 /*
318 ** Internally, each RBU connection uses a separate SQLite database 356 ** Internally, each RBU connection uses a separate SQLite database
319 ** connection to access the target and rbu update databases. This 357 ** connection to access the target and rbu update databases. This
320 ** API allows the application direct access to these database handles. 358 ** API allows the application direct access to these database handles.
321 ** 359 **
322 ** The first argument passed to this function must be a valid, open, RBU 360 ** The first argument passed to this function must be a valid, open, RBU
323 ** handle. The second argument should be passed zero to access the target 361 ** handle. The second argument should be passed zero to access the target
324 ** database handle, or non-zero to access the rbu update database handle. 362 ** database handle, or non-zero to access the rbu update database handle.
325 ** Accessing the underlying database handles may be useful in the 363 ** Accessing the underlying database handles may be useful in the
326 ** following scenarios: 364 ** following scenarios:
327 ** 365 **
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 int sqlite3rbu_close(sqlite3rbu *pRbu, char **pzErrmsg); 432 int sqlite3rbu_close(sqlite3rbu *pRbu, char **pzErrmsg);
395 433
396 /* 434 /*
397 ** Return the total number of key-value operations (inserts, deletes or 435 ** Return the total number of key-value operations (inserts, deletes or
398 ** updates) that have been performed on the target database since the 436 ** updates) that have been performed on the target database since the
399 ** current RBU update was started. 437 ** current RBU update was started.
400 */ 438 */
401 sqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu); 439 sqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu);
402 440
403 /* 441 /*
442 ** Obtain permyriadage (permyriadage is to 10000 as percentage is to 100)
443 ** progress indications for the two stages of an RBU update. This API may
444 ** be useful for driving GUI progress indicators and similar.
445 **
446 ** An RBU update is divided into two stages:
447 **
448 ** * Stage 1, in which changes are accumulated in an oal/wal file, and
449 ** * Stage 2, in which the contents of the wal file are copied into the
450 ** main database.
451 **
452 ** The update is visible to non-RBU clients during stage 2. During stage 1
453 ** non-RBU reader clients may see the original database.
454 **
455 ** If this API is called during stage 2 of the update, output variable
456 ** (*pnOne) is set to 10000 to indicate that stage 1 has finished and (*pnTwo)
457 ** to a value between 0 and 10000 to indicate the permyriadage progress of
458 ** stage 2. A value of 5000 indicates that stage 2 is half finished,
459 ** 9000 indicates that it is 90% finished, and so on.
460 **
461 ** If this API is called during stage 1 of the update, output variable
462 ** (*pnTwo) is set to 0 to indicate that stage 2 has not yet started. The
463 ** value to which (*pnOne) is set depends on whether or not the RBU
464 ** database contains an "rbu_count" table. The rbu_count table, if it
465 ** exists, must contain the same columns as the following:
466 **
467 ** CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;
468 **
469 ** There must be one row in the table for each source (data_xxx) table within
470 ** the RBU database. The 'tbl' column should contain the name of the source
471 ** table. The 'cnt' column should contain the number of rows within the
472 ** source table.
473 **
474 ** If the rbu_count table is present and populated correctly and this
475 ** API is called during stage 1, the *pnOne output variable is set to the
476 ** permyriadage progress of the same stage. If the rbu_count table does
477 ** not exist, then (*pnOne) is set to -1 during stage 1. If the rbu_count
478 ** table exists but is not correctly populated, the value of the *pnOne
479 ** output variable during stage 1 is undefined.
480 */
481 void sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int *pnTwo);
482
483 /*
484 ** Obtain an indication as to the current stage of an RBU update or vacuum.
485 ** This function always returns one of the SQLITE_RBU_STATE_XXX constants
486 ** defined in this file. Return values should be interpreted as follows:
487 **
488 ** SQLITE_RBU_STATE_OAL:
489 ** RBU is currently building a *-oal file. The next call to sqlite3rbu_step()
490 ** may either add further data to the *-oal file, or compute data that will
491 ** be added by a subsequent call.
492 **
493 ** SQLITE_RBU_STATE_MOVE:
494 ** RBU has finished building the *-oal file. The next call to sqlite3rbu_step( )
495 ** will move the *-oal file to the equivalent *-wal path. If the current
496 ** operation is an RBU update, then the updated version of the database
497 ** file will become visible to ordinary SQLite clients following the next
498 ** call to sqlite3rbu_step().
499 **
500 ** SQLITE_RBU_STATE_CHECKPOINT:
501 ** RBU is currently performing an incremental checkpoint. The next call to
502 ** sqlite3rbu_step() will copy a page of data from the *-wal file into
503 ** the target database file.
504 **
505 ** SQLITE_RBU_STATE_DONE:
506 ** The RBU operation has finished. Any subsequent calls to sqlite3rbu_step()
507 ** will immediately return SQLITE_DONE.
508 **
509 ** SQLITE_RBU_STATE_ERROR:
510 ** An error has occurred. Any subsequent calls to sqlite3rbu_step() will
511 ** immediately return the SQLite error code associated with the error.
512 */
513 #define SQLITE_RBU_STATE_OAL 1
514 #define SQLITE_RBU_STATE_MOVE 2
515 #define SQLITE_RBU_STATE_CHECKPOINT 3
516 #define SQLITE_RBU_STATE_DONE 4
517 #define SQLITE_RBU_STATE_ERROR 5
518
519 int sqlite3rbu_state(sqlite3rbu *pRbu);
520
521 /*
404 ** Create an RBU VFS named zName that accesses the underlying file-system 522 ** Create an RBU VFS named zName that accesses the underlying file-system
405 ** via existing VFS zParent. Or, if the zParent parameter is passed NULL, 523 ** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
406 ** then the new RBU VFS uses the default system VFS to access the file-system. 524 ** then the new RBU VFS uses the default system VFS to access the file-system.
407 ** The new object is registered as a non-default VFS with SQLite before 525 ** The new object is registered as a non-default VFS with SQLite before
408 ** returning. 526 ** returning.
409 ** 527 **
410 ** Part of the RBU implementation uses a custom VFS object. Usually, this 528 ** Part of the RBU implementation uses a custom VFS object. Usually, this
411 ** object is created and deleted automatically by RBU. 529 ** object is created and deleted automatically by RBU.
412 ** 530 **
413 ** The exception is for applications that also use zipvfs. In this case, 531 ** The exception is for applications that also use zipvfs. In this case,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 ** before all database handles that use it have been closed, the results 570 ** before all database handles that use it have been closed, the results
453 ** are undefined. 571 ** are undefined.
454 */ 572 */
455 void sqlite3rbu_destroy_vfs(const char *zName); 573 void sqlite3rbu_destroy_vfs(const char *zName);
456 574
457 #ifdef __cplusplus 575 #ifdef __cplusplus
458 } /* end of the 'extern "C"' block */ 576 } /* end of the 'extern "C"' block */
459 #endif 577 #endif
460 578
461 #endif /* _SQLITE3RBU_H */ 579 #endif /* _SQLITE3RBU_H */
OLDNEW
« no previous file with comments | « third_party/sqlite/src/ext/rbu/rbuvacuum2.test ('k') | third_party/sqlite/src/ext/rbu/sqlite3rbu.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698