Skip to content

Commit

Permalink
cordova-sqlite-ext build fixes & updates for 3.0.0
Browse files Browse the repository at this point in the history
- Use cordova-sqlite-ext-deps 1.1.0 with SQLite 3.22.0,
  with Android sqlite-native-driver NDK build in JAR
  (along with other compile-time option updates)
  to resolve issue on cordova-android@7
  ref: storesafe/cordova-sqlite-storage#729
- SQLITE_DEFAULT_SYNCHRONOUS=3 (EXTRA DURABLE) compile-time setting on
  all platforms (Android/iOS/macOS/Windows)
  ref: storesafe/cordova-sqlite-storage#736
- plugin.xml use lib-file for Android sqlite-native-driver NDK build in
  JAR from cordova-sqlite-ext-deps (1.1.0) to resolve issue on
  cordova-android@7 (along with other compile-time option updates)
  ref: storesafe/cordova-sqlite-storage#729
- SQLITE_THREADSAFE=1 for iOS/macOS along with others (Android/Windows)
  ref: storesafe/cordova-sqlite-storage#754
- Enable FTS5 & JSON1 on all platforms
  • Loading branch information
Christopher J. Brody committed Apr 9, 2018
1 parent c344fb9 commit 803f473
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

### cordova-sqlite-ext 3.0.0-0.00+dev

TBD
- cordova-sqlite-ext build fixes & updates for 3.0.0
- use cordova-sqlite-ext-deps 1.1.0 with SQLite 3.22.0
- SQLITE_DEFAULT_SYNCHRONOUS=3 (EXTRA DURABLE) compile-time setting on all platforms ref: litehelpers/Cordova-sqlite-storage#736
- plugin.xml use lib-file for Android sqlite-native-driver NDK build in JAR to resolve issue on cordova-android@7 (along with other compile-time option updates) ref: litehelpers/Cordova-sqlite-storage#729
- cordova-sqlite-ext with SQLITE_THREADSAFE=1 for iOS/macOS ref: litehelpers/Cordova-sqlite-storage#754
- Enable FTS5 & JSON1 on all platforms

## cordova-sqlite-ext 2.0.0

Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ See the [Sample section](#sample) for a sample with a more detailed explanation
- New major release under development, with the following major changes:
- TBD
- This plugin is NOT supported by PhoneGap Developer App or PhoneGap Desktop App.
- This plugin will NOT work on `cordova-android@7` due to issue with JAR and NDK library files as discussed in [litehelpers/Cordova-sqlite-storage#729](https://github.com/litehelpers/Cordova-sqlite-storage/issues/729).
- A recent version of the Cordova CLI (such as `6.5.0` / `7.1.0` / `8.0.0`) is recommended. Cordova versions older than `6.0.0` are missing the `cordova-ios@4.0.0` security fixes. In addition it may be needed to use `cordova prepare` in case of cordova-ios older than `4.3.0` (Cordova CLI `6.4.0`).
- This plugin version uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-ext-deps` via npm.
- Use of other systems such as Cordova Plugman, PhoneGap CLI, PhoneGap Build, and Intel XDK is no longer supported by this plugin version since they do not honor the `before_plugin_install` hook. The supported solution is to use [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms); alternative with permissive license terms is available at: [brodybits / cordova-sqlite-legacy-build-support](https://github.com/brodybits/cordova-sqlite-legacy-build-support) (limited testing, limited updates).
Expand All @@ -141,21 +140,23 @@ See the [Sample section](#sample) for a sample with a more detailed explanation
- BASE64 integrated from [brodybits / sqlite3-base64](https://github.com/brodybits/sqlite3-base64), using [brodybits / libb64-encode](https://github.com/brodybits/libb64-encode) (based on <http://libb64.sourceforge.net/> by Chris Venter, public domain)
- REGEXP for Android (default Android-sqlite-connector database implementation), iOS, and macOS using [brodybits / sqlite3-regexp-cached](https://github.com/brodybits/sqlite3-regexp-cached) (based on <http://git.altlinux.org/people/at/packages/?p=sqlite3-pcre.git> by Alexey Tourbin, public domain)
- BLOB column values are NO LONGER automatically converted to Base64 format. MUST use SELECT BASE64(column) to return column value in Base64 format as documented below.
- SQLite version `3.15.2` included when building with the following build settings:
- `SQLITE_THREADSAFE=2` on iOS/macOS (`SQLITE_THREADSAFE=1` on Android/Windows)
- `SQLITE_DEFAULT_MEMSTATUS=0` (_iOS/macOS/Windows_)
- `SQLITE_OMIT_DECLTYPE` (_iOS/macOS/Windows_)
- `SQLITE_OMIT_DEPRECATED` (_iOS/macOS/Windows_)
- `SQLITE_OMIT_PROGRESS_CALLBACK` (_iOS/macOS/Windows_)
- `SQLITE_OMIT_SHARED_CACHE` (_iOS/macOS/Windows_)
- SQLite version `3.22.0` included when building with the following build settings:
- `SQLITE_THREADSAFE=1`
- `SQLITE_DEFAULT_SYNCHRONOUS=3` (EXTRA DURABLE build setting) ref: [litehelpers/Cordova-sqlite-storage#736](https://github.com/litehelpers/Cordova-sqlite-storage/issues/736)
- `SQLITE_DEFAULT_MEMSTATUS=0`
- `SQLITE_OMIT_DECLTYPE`
- `SQLITE_OMIT_DEPRECATED`
- `SQLITE_OMIT_PROGRESS_CALLBACK`
- `SQLITE_OMIT_SHARED_CACHE`
- `SQLITE_TEMP_STORE=2`
- `SQLITE_OMIT_LOAD_EXTENSION`
- `SQLITE_ENABLE_FTS3`
- `SQLITE_ENABLE_FTS3_PARENTHESIS`
- `SQLITE_ENABLE_FTS4`
- `SQLITE_ENABLE_FTS5`
- `SQLITE_ENABLE_RTREE`
- `SQLITE_ENABLE_JSON1`
- `SQLITE_DEFAULT_PAGE_SIZE=1024` and `SQLITE_DEFAULT_CACHE_SIZE=2000` to avoid "potentially distruptive change(s)" from SQLite 3.12.0 ref: <http://sqlite.org/pgszchng2016.html>
- `SQLITE_OMIT_BUILTIN_TEST` - TBD unwanted option to be removed in the near future (_Android only_)
- `NDEBUG` on Windows (Release build only)
- The iOS database location is now mandatory, as documented below.
- This version branch supports the use of two (2) possible Android sqlite database implementations:
Expand All @@ -175,7 +176,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation
- The macOS platform version ("osx" platform) is not tested in a release build and should be considered pre-alpha.
- Android versions supported: 2.3.3 - 7.1.1 (API level 10 - 25), depending on Cordova version ref: <https://cordova.apache.org/docs/en/latest/guide/platforms/android/>
- iOS versions supported: 8.x / 9.x / 10.x / 11.x (see [deviations section](#deviations) below for differences in case of WKWebView)
- FTS3, FTS4, and R-Tree are fully tested and supported for all target platforms in this version branch.
- FTS3, FTS4, FTS5, R-Tree, and JSON1 are fully tested and supported for all target platforms in this version branch.
- Default `PRAGMA journal_mode` setting (*tested*):
- Android (builtin android.database implementation _as selected using the `androidDatabaseImplementation` option in `window.sqlitePlugin.openDatabase`_): `persist` _(Android pre-8.0)_
- otherwise: `delete`
Expand All @@ -186,6 +187,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation

## Announcements

- Using recent version of SQLite3 (`3.22.0`) with `SQLITE_DEFAULT_SYNCHRONOUS=3` (EXTRA DURABLE) build setting to be extra robust against possible database corruption ref: [litehelpers/Cordova-sqlite-storage#736](https://github.com/litehelpers/Cordova-sqlite-storage/issues/736)
- This plugin version references Windows platform toolset v141 to support Visual Studio 2017. Visual Studio 2015 is now supported by [litehelpers / cordova-sqlite-legacy](https://github.com/litehelpers/cordova-sqlite-legacy) (WITH the extra BASE64, REGEXP, and pre-populated database features INCLUDED).
- Ionic 3 starter template is available at: [iursevla / ionic3-PreDB](https://github.com/iursevla/ionic3-PreDB), Unlicense (public domain)
- Ionic 2 starter template is available at: [iursevla / ionic2-PreDB](https://github.com/iursevla/ionic2-PreDB), Unlicense (public domain)
Expand Down Expand Up @@ -469,7 +471,6 @@ See **Security of sensitive data** in the [Security](#security) section above.

## Known issues

- This plugin will NOT work on `cordova-android@7` due to issue with JAR and NDK library files as discussed in [litehelpers/Cordova-sqlite-storage#729](https://github.com/litehelpers/Cordova-sqlite-storage/issues/729).
- The iOS/macOS platform versions do not support certain rapidly repeated open-and-close or open-and-delete test scenarios due to how the implementation handles background processing
- The Android platform version does not always handle four-byte UTF-8 characters emoji characters such as `\u1F603` (SMILING FACE, MOUTH OPEN) correctly ref: [litehelpers/Cordova-sqlite-storage#564](https://github.com/litehelpers/Cordova-sqlite-storage/issues/564). It is sometimes possible to store and retrieve such characters but certain operations such as hex conversions do not work properly when using the default [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) database implementation. It is suspected that such characters would be stored incorrectly by the default Android platform version. Note that this is not an issue in case the built-in Android database is used (using the `androidDatabaseImplementation: 2` setting in `window.sqlitePlugin.openDatabase`)
- It is possible to request a SQL statement list such as "SELECT 1; SELECT 2" within a single SQL statement string, however the plugin will only execute the first statement and silently ignore the others ref: [litehelpers/Cordova-sqlite-storage#551](https://github.com/litehelpers/Cordova-sqlite-storage/issues/551)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"homepage": "https://github.com/litehelpers/cordova-sqlite-ext",
"dependencies": {
"cordova-sqlite-ext-deps": "0.4.1"
"cordova-sqlite-ext-deps": "1.1.0"
},
"scripts": {
"start": "node scripts/prepareSpec.js"
Expand Down
14 changes: 5 additions & 9 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@
<source-file src="src/android/io/sqlc/SQLiteConnectorDatabase.java" target-dir="src/io/sqlc"/>

<!-- Android-sqlite-connector [jar]: -->
<source-file src="node_modules/cordova-sqlite-ext-deps/libs/sqlite-connector.jar" target-dir="libs"/>
<!-- Android-sqlite-connector native driver [native libs]: -->
<source-file src="node_modules/cordova-sqlite-ext-deps/libs/arm64-v8a/libsqlc-native-driver.so" target-dir="libs/arm64-v8a"/>
<source-file src="node_modules/cordova-sqlite-ext-deps/libs/armeabi/libsqlc-native-driver.so" target-dir="libs/armeabi"/>
<source-file src="node_modules/cordova-sqlite-ext-deps/libs/armeabi-v7a/libsqlc-native-driver.so" target-dir="libs/armeabi-v7a"/>
<source-file src="node_modules/cordova-sqlite-ext-deps/libs/x86/libsqlc-native-driver.so" target-dir="libs/x86"/>
<source-file src="node_modules/cordova-sqlite-ext-deps/libs/x86_64/libsqlc-native-driver.so" target-dir="libs/x86_64"/>
<lib-file src="node_modules/cordova-sqlite-ext-deps/libs/sqlite-connector.jar" />
<!-- Android-sqlite-connector native driver [native libs in jar]: -->
<lib-file src="node_modules/cordova-sqlite-ext-deps/libs/sqlite-native-driver.jar" />
</platform>

<!-- iOS -->
Expand Down Expand Up @@ -70,7 +66,7 @@

<header-file src="node_modules/cordova-sqlite-ext-deps/sqlite3.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/sqlite3.c"
compiler-flags="-w -DSQLITE_THREADSAFE=2 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_TEMP_STORE=2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE -DSQLITE_DEFAULT_PAGE_SIZE=1024 -DSQLITE_DEFAULT_CACHE_SIZE=2000" />
compiler-flags="-w -DSQLITE_THREADSAFE=1 -DSQLITE_DEFAULT_SYNCHRONOUS=3 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_TEMP_STORE=2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_JSON1 -DSQLITE_DEFAULT_PAGE_SIZE=1024 -DSQLITE_DEFAULT_CACHE_SIZE=2000" />
</platform>

<!-- macOS (osx) -->
Expand Down Expand Up @@ -101,7 +97,7 @@

<header-file src="node_modules/cordova-sqlite-ext-deps/sqlite3.h" />
<source-file src="node_modules/cordova-sqlite-ext-deps/sqlite3.c"
compiler-flags="-w -DSQLITE_THREADSAFE=2 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_TEMP_STORE=2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE -DSQLITE_DEFAULT_PAGE_SIZE=1024 -DSQLITE_DEFAULT_CACHE_SIZE=2000" />
compiler-flags="-w -DSQLITE_THREADSAFE=1 -DSQLITE_DEFAULT_SYNCHRONOUS=3 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_TEMP_STORE=2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_JSON1 -DSQLITE_DEFAULT_PAGE_SIZE=1024 -DSQLITE_DEFAULT_CACHE_SIZE=2000" />
</platform>

<!-- windows -->
Expand Down
13 changes: 7 additions & 6 deletions spec/www/spec/db-tx-error-mapping-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ var mytests = function() {
});
}, MYTIMEOUT);

it(suiteName + 'INSERT syntax error [VALUES in the wrong place] with a trailing space', function(done) {
it(suiteName + 'INSERT syntax error [VALUES in the wrong place] with a trailing space [XXX "incomplete input" message]', function(done) {
if (isWP8) pending('SKIP for WP(8)'); // FUTURE TBD

var db = openDatabase("INSERT-Syntax-error-test.db", "1.0", "Demo", DEFAULT_SIZE);
Expand Down Expand Up @@ -196,12 +196,13 @@ var mytests = function() {
expect(error.message).toMatch(/could not prepare statement.*1 near \"VALUES\": syntax error/);
else if (isWindows)
expect(error.message).toMatch(/Error preparing an SQLite statement/);
else if (isAndroid && !isImpl2)
expect(error.message).toMatch(/sqlite3_prepare_v2 failure:.*near \" \": syntax error/);
//* else if (isAndroid && !isImpl2) //* XXX TBD Android (default implementation) vs ...
//* expect(error.message).toMatch(/sqlite3_prepare_v2 failure:.*near \" \": syntax error/);
else if (isAndroid && isImpl2)
expect(error.message).toMatch(/near \"VALUES\": syntax error.*code 1.*while compiling: INSERT INTO test_table/);
else
expect(error.message).toMatch(/near \" \": syntax error/);
//* expect(error.message).toMatch(/near \" \": syntax error/);
expect(error.message).toMatch(/incomplete input/); // XXX SQLite 3.22.0

// FAIL transaction & check reported transaction error:
return true;
Expand All @@ -226,8 +227,8 @@ var mytests = function() {
expect(error.message).toMatch(/callback raised an exception.*or.*error callback did not return false/);
else if (isWindows)
expect(error.message).toMatch(/error callback did not return false.*Error preparing an SQLite statement/);
else
expect(error.message).toMatch(/error callback did not return false.*syntax error/);
//* else //* XXX TBD
//* expect(error.message).toMatch(/error callback did not return false.*syntax error/);

isWebSql ? done() : db.close(done, done);
}, function() {
Expand Down
15 changes: 6 additions & 9 deletions spec/www/spec/db-tx-sql-features-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,9 @@ var mytests = function() {
});
}, MYTIMEOUT);

// Test for Cordova-sqlcipher-adapter version (SQLCipher 3.4.0 based on SQLite 3.11.0)
it(suiteName + 'Basic JSON1 json test', function(done) {
//if (isWebSql) pending('SKIP for Web SQL (not implemented)');
pending('SKIP: NOT IMPLEMENTED for this version');
if (isWebSql) pending('SKIP for Web SQL (not implemented)');
if (!isWebSql && isAndroid && isImpl2) pending('SKIP for androidDatabaseImplementation: 2 [NOT IMPLEMENTED]');

var db = openDatabase('basic-json1-json-test.db', '1.0', 'Test', DEFAULT_SIZE);

Expand All @@ -197,10 +196,9 @@ var mytests = function() {
});
}, MYTIMEOUT);

// Test for Cordova-sqlcipher-adapter version (SQLCipher 3.4.0 based on SQLite 3.11.0)
it(suiteName + 'JSON1 json_object test', function(done) {
//if (isWebSql) pending('SKIP for Web SQL (not implemented)');
pending('SKIP: NOT IMPLEMENTED for this version');
if (isWebSql) pending('SKIP for Web SQL (not implemented)');
if (!isWebSql && isAndroid && isImpl2) pending('SKIP for androidDatabaseImplementation: 2 [NOT IMPLEMENTED]');

var db = openDatabase('json1-json-object-test.db', '1.0', 'Test', DEFAULT_SIZE);

Expand Down Expand Up @@ -228,10 +226,9 @@ var mytests = function() {
});
}, MYTIMEOUT);

// Test for Cordova-sqlcipher-adapter version (SQLCipher 3.4.0 based on SQLite 3.11.0)
it(suiteName + 'create virtual table using FTS5', function(done) {
//if (isWebSql) pending('SKIP for Web SQL (not implemented)');
pending('SKIP: NOT IMPLEMENTED for this version');
if (isWebSql) pending('SKIP for Web SQL (not implemented)');
if (!isWebSql && isAndroid && isImpl2) pending('SKIP for androidDatabaseImplementation: 2 [NOT IMPLEMENTED]');

var db = openDatabase('virtual-table-using-fts5.db', '1.0', 'Test', DEFAULT_SIZE);

Expand Down
2 changes: 1 addition & 1 deletion spec/www/spec/sqlite-version-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var mytests = function() {
expect(rs.rows.item(0).myResult).toMatch(/3\.[0-9]+\.[0-9]+/);
// Check specific [plugin only]:
if (!isWebSql && !(!isWindows && isAndroid && isImpl2))
expect(rs.rows.item(0).myResult).toBe('3.15.2');
expect(rs.rows.item(0).myResult).toBe('3.22.0');

// Close (plugin only) & finish:
(isWebSql) ? done() : db.close(done, done);
Expand Down
2 changes: 1 addition & 1 deletion src/windows/SQLite3-Win-RT/SQLite3/SQLite3.Shared.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory);$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps;$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\sqlite3-base64;$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-ext-deps\libb64-encode</AdditionalIncludeDirectories>
<AdditionalOptions>/DSQLITE_THREADSAFE=1 /DSQLITE_DEFAULT_MEMSTATUS=0 /DSQLITE_OMIT_DECLTYPE /DSQLITE_OMIT_DEPRECATED /DSQLITE_OMIT_PROGRESS_CALLBACK /DSQLITE_OMIT_SHARED_CACHE /DSQLITE_TEMP_STORE=2 /DSQLITE_OMIT_LOAD_EXTENSION /DSQLITE_ENABLE_FTS3 /DSQLITE_ENABLE_FTS3_PARENTHESIS /DSQLITE_ENABLE_FTS4 /DSQLITE_ENABLE_RTREE /DSQLITE_DEFAULT_PAGE_SIZE=1024 /DSQLITE_OS_WINRT %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/DSQLITE_THREADSAFE=1 /DSQLITE_DEFAULT_SYNCHRONOUS=3 /DSQLITE_DEFAULT_MEMSTATUS=0 /DSQLITE_OMIT_DECLTYPE /DSQLITE_OMIT_DEPRECATED /DSQLITE_OMIT_PROGRESS_CALLBACK /DSQLITE_OMIT_SHARED_CACHE /DSQLITE_TEMP_STORE=2 /DSQLITE_OMIT_LOAD_EXTENSION /DSQLITE_ENABLE_FTS3 /DSQLITE_ENABLE_FTS3_PARENTHESIS /DSQLITE_ENABLE_FTS4 /DSQLITE_ENABLE_FTS5 /DSQLITE_ENABLE_RTREE /DSQLITE_ENABLE_JSON1 /DSQLITE_DEFAULT_PAGE_SIZE=1024 /DSQLITE_OS_WINRT %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down

0 comments on commit 803f473

Please sign in to comment.