Skip to content

Version 4.0.0 / SQLCipher 4.2.0 / SQLite 3.28.0#21

Merged
rkistner merged 154 commits intomasterfrom
upgrade
Jul 5, 2019
Merged

Version 4.0.0 / SQLCipher 4.2.0 / SQLite 3.28.0#21
rkistner merged 154 commits intomasterfrom
upgrade

Conversation

@rkistner
Copy link
Copy Markdown
Member

@rkistner rkistner commented Jul 5, 2019

Changes:

  • Bump version to 4.0.0 (SQLCipher contains breaking changes).
  • Pull in upstream changes from node-sqlite3.
  • Upgrade to SQLCipher 4.2.0 / SQLite 3.28.0.
  • Target Node 8, 10, 12 and Electron 3, 4, 5.
  • Use openssl@1.1 on macOS (tests are failing with 1.0).

Excluding upstream, these are the changes for this PR:
https://github.com/journeyapps/node-sqlcipher/pull/21/files/ad9d41033c4d2b61cad1dffc3eb07b0a2c14b719..25c8c914763d06ed4bf0932a5c60a2cdb2f4f62c

refack and others added 25 commits January 12, 2019 14:54
* make compatible with V8 7.1

* Remove use of two argument Concat

* fixup! bump nan
* Update brew (build_against_electron.sh)

* Update brew (build_against_node.sh)
Usage:
```
docker build .
```
This can be then declined for several arch, elsewhere.

Change-Id: I79000463955d16eec8809c870f7d02c60da53432
Bug: TryGhost/node-sqlite3#418
Forwarded: TryGhost/node-sqlite3#1112
TryGhost/node-sqlite3#1028
Origin: https://github.com/tizenteam/node-sqlite3
Signed-off-by: Philippe Coval <p.coval@samsung.com>
This exposes the sqlite3 backup api as described at https://sqlite.org/backup.html.

This implementation draws on TryGhost/node-sqlite3#883,
extending it to create a backup object that can be used in the background,
without leaving the database locked for an extended period of time.  This is
crucial for making backups of large live databases in a non-disruptive manner.
Example usage:

```
var db = new sqlite3.Database('live.db');
var backup = db.backup('backup.db');
...
// in event loop, move backup forward when we have time.
if (backup.idle) { backup.step(NPAGES); }
if (backup.completed) { /* success! backup made */  }
if (backup.failed)    { /* sadness! backup broke */ }
// do other work in event loop - fine to modify live.db
...
```

Here is how sqlite's backup api is exposed:

 * `sqlite3_backup_init`: This is implemented as `db.backup(filename, [callback])`
   or `db.backup(filename, destDbName, sourceDbName, filenameIsDest, [callback])`.
 * `sqlite3_backup_step`: This is implemented as `backup.step(pages, [callback])`.
 * `sqlite3_backup_finish`: This is implemented as `backup.finish([callback])`.
 * `sqlite3_backup_remaining`: This is implemented as a `backup.remaining` getter.
 * `sqlite3_backup_pagecount`: This is implemented as a `backup.pageCount` getter.

Some conveniences are added in the node api.

There are the following read-only properties:
 * `backup.completed` is set to `true` when the backup succeeeds.
 * `backup.failed` is set to `true` when the backup has a fatal error.
 * `backup.idle` is set to `true` when no operation is currently in progress or
   queued for the backup.
 * `backup.remaining` is an integer with the remaining number of pages after the
   last call to `backup.step` (-1 if `step` not yet called).
 * `backup.pageCount` is an integer with the total number of pages measured during
   the last call to `backup.step` (-1 if `step` not yet called).

There is the following writable property:
 * `backup.retryErrors`: an array of sqlite3 error codes that are treated as
   non-fatal - meaning, if they occur, backup.failed is not set, and the backup
   may continue.  By default, this is `[sqlite3.BUSY, sqlite3.LOCKED]`.

The `db.backup(filename, [callback])` shorthand is sufficient for making a
backup of a database opened by node-sqlite3.  If using attached or temporary
databases, or moving data in the opposite direction, the more complete
(but daunting) `db.backup(filename, destDbName, sourceDbName, filenameIsDest, [callback])`
signature is provided.

A backup will finish automatically when it succeeds or a fatal error
occurs, meaning it is not necessary to call `db.finish()`.
By default, SQLITE_LOCKED and SQLITE_BUSY errors are not treated as
failures, and the backup will continue if they occur.  The set of errors
that are tolerated can be controlled by setting `backup.retryErrors`.
To disable automatic finishing and stick strictly to sqlite's raw api,
set `backup.retryErrors` to `[]`.  In that case, it is necessary to call
`backup.finish()`.

In the same way as node-sqlite3 databases and statements, backup methods
can be called safely without callbacks, due to an internal call queue.  So
for example this naive code will correctly back up a db, if there are
no errors:
```
var backup = db.backup('backup.db');
backup.step(-1);
backup.finish();
```
tests: wait for the backup to complete before finishing it
tests: only trigger internal backup (from main to temp tables) when version is larger or equal to 3.26
It took less than 10 min to build on Ubuntu 18.04 x86_64

If merged other arch will come next, and then automated by CI.

Bug: TryGhost/node-sqlite3#903
Forwarded: TryGhost/node-sqlite3#1147
Change-Id: Ic91292879deed92fcffd90d7b2d79f551c5b06f4
Signed-off-by: Philippe Coval <p.coval@samsung.com>
ci: use trusty to compile for node12
Version bump; readmel changes; fixes; cleanup.
@rkistner rkistner requested a review from kblum July 5, 2019 09:34
@rkistner
Copy link
Copy Markdown
Member Author

rkistner commented Jul 5, 2019

The status shows failed builds because of cancelling duplicates, but all builds are passing, with the exception of Node 8.16 on MacOS:

https://circleci.com/workflow-run/c0c8b292-84df-4ff1-a211-e44842588786
https://ci.appveyor.com/project/journeyapps/node-sqlcipher/builds/25768170

Copy link
Copy Markdown

@kblum kblum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested, but the changes look good to me (aside from the CI failure).

@rkistner rkistner merged commit 1b0fad0 into master Jul 5, 2019
@rkistner rkistner deleted the upgrade branch July 5, 2019 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.