diff --git a/CHANGES.md b/CHANGES.md index 102b3e2f3..47cc5a347 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Changes +##### cordova-sqlite-legacy-core 1.0.7-pre1 + +###### cordova-sqlite-legacy-express-core 1.0.5 + +- iOS/macOS @synchronized guard for sqlite3_open operation +- Signal INTERNAL ERROR in case of attempt to reuse db (Android/iOS) (should never happen due to workaround solution to BUG 666) + ##### cordova-sqlite-legacy-core 1.0.6 ###### cordova-sqlite-legacy-express-core 1.0.4 diff --git a/README.md b/README.md index 833625575..da7392503 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ License terms for Android and Windows platform versions: MIT or Apache 2.0 License terms for iOS/macOS platform version: MIT only -## About this version branch +## About this plugin version branch -This version branch contains the source code for the Android/iOS/macOS/Windows platforms (legacy core version branch). +This _plugin version branch_ contains the source code for the Android/iOS/macOS/Windows platforms (legacy core version branch). This version branch uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-storage-dependencies` via npm. @@ -22,7 +22,7 @@ NOTE: This version branch has some additional known [issues fixed in newer versi - + ## WARNING: Multiple SQLite problem on Android @@ -69,7 +69,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase ## Status -- A recent version of the Cordova CLI (such as `6.5.0` or `7.1.0`) is recommended. Cordova versions older than `6.0.0` are missing the `cordova-ios@4.0.0` security fixes. In addition it is *required* to use `cordova prepare` in case of cordova-ios older than `4.3.0` (Cordova CLI `6.4.0`). +- A recent version of the Cordova CLI (such as `6.5.0` or `7.1.0`) is recommended. _(TBD issue with cordova-android@7 as included by Cordova 8)_ Cordova versions older than `6.0.0` are missing the `cordova-ios@4.0.0` security fixes. In addition it is *required* to use `cordova prepare` in case of cordova-ios older than `4.3.0` (Cordova CLI `6.4.0`). - This version branch uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-storage-dependencies` via npm. - 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). - SQLite `3.8.10.2` included when building (all platforms), with the following definitions for iOS/macOS/Windows: @@ -111,7 +111,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - iOS versions supported: 8.x / 9.x / 10.x / 11.x - FTS3, FTS4, and R-Tree 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_ (builtin android.database implementation _as selected using the `androidDatabaseImplementation` option in `window.sqlitePlugin.openDatabase`_): `persist` - otherwise: `delete` - AUTO-VACUUM is not enabled by default. If no form of `VACUUM` or `PRAGMA auto_vacuum` is used then sqlite will automatically reuse deleted data space for new data but the database file will never shrink. For reference: and [litehelpers/Cordova-sqlite-storage#646](https://github.com/litehelpers/Cordova-sqlite-storage/issues/646) - In case of memory issues please use smaller transactions or use the plugin version at [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms). @@ -120,7 +120,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase ## Announcements -- Nice overview of this and other alternatives for storing local data at: +- Nice overview of alternatives for storing local data in Cordova apps at: - New alternative solution for small data storage: [TheCocoaProject/ cordova-plugin-nativestorage](https://github.com/TheCocoaProject/cordova-plugin-nativestorage) - simpler "native storage of variables" for Android/iOS/Windows - Resolved Java 6/7/8 concurrent map compatibility issue reported in [litehelpers/Cordova-sqlite-storage#726](https://github.com/litehelpers/Cordova-sqlite-storage/issues/726), THANKS to pointer by [@NeoLSN (Jason Yang/楊朝傑)](https://github.com/NeoLSN) in [litehelpers/Cordova-sqlite-storage#727](https://github.com/litehelpers/Cordova-sqlite-storage/issues/727). - Updated workaround solution to [BUG 666 (litehelpers/Cordova-sqlite-storage#666)](https://github.com/litehelpers/Cordova-sqlite-storage/issues/666) (possible transaction issue after window.location change with possible data loss): close database if already open before opening again @@ -345,7 +345,8 @@ Documented in: [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/b - [litehelpers / Cordova-sqlite-storage](https://github.com/litehelpers/Cordova-sqlite-storage) - core plugin version for Android/iOS/macOS/Windows (permissive license terms) - [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) - plugin version with REGEXP (Android/iOS/macOS), SELECT BLOB in Base64 format (all platforms Android/iOS/macOS/Windows), and pre-populated databases (all platforms Android/iOS/macOS/Windows). Permissive license terms. -- [litehelpers / Cordova-sqlite-legacy-build-support](https://github.com/litehelpers/Cordova-sqlite-legacy-build-support) - maintenance of WP8 platform version along with Windows 8.1/Windows Phone 8.1 and the other supported platforms Android/iOS/macOS/Windows 10; limited support for PhoneGap CLI/PhoneGap Build/plugman/Intel XDK; limited testing; limited updates. Permissive license terms. +- [litehelpers / cordova-sqlite-legacy](https://github.com/litehelpers/cordova-sqlite-legacy) - support for Windows 8.1/Windows Phone 8.1 along with Android/iOS/macOS/Windows 10, with support for REGEXP (Android/iOS/macOS), SELECT BLOB in Base64 format (all platforms Android/iOS/macOS/Windows), and pre-populated databases (all platforms Android/iOS/macOS/Windows). Limited updates. Permissive license terms. +- [brodybits / cordova-sqlite-legacy-build-support](https://github.com/brodybits/cordova-sqlite-legacy-build-support) - maintenance of WP8 platform version along with Windows 8.1/Windows Phone 8.1 and the other supported platforms Android/iOS/macOS/Windows 10; limited support for PhoneGap CLI/PhoneGap Build/plugman/Intel XDK; limited testing; limited updates. Permissive license terms. - [litehelpers / Cordova-sqlcipher-adapter](https://github.com/litehelpers/Cordova-sqlcipher-adapter) - supports [SQLCipher](https://www.zetetic.net/sqlcipher/) for Android/iOS/macOS/Windows - [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) - Enhancements for Android: JSON and SQL statement handling implemented in C, supports larger transactions and handles large SQL batches in less than half the time as this plugin version. Supports arbitrary database location on Android. Support for build environments such as PhoneGap Build and Intel XDK. Also includes REGEXP (Android/iOS/macOS) and SELECT BLOB in Base64 format (all platforms Android/iOS/macOS/Windows). GPL or commercial license terms. - [litehelpers / cordova-sqlite-evplus-ext-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evplus-ext-legacy-build-free) - internal memory improvements to support larger transactions (Android/iOS) and fix to support all Unicode characters (iOS). (GPL or special commercial license terms). @@ -1071,7 +1072,7 @@ To run from a windows powershell (here is a sample for android target): - `src`: platform-specific source code - `node_modules`: placeholder for external dependencies - `scripts`: installation hook script to fetch the external dependencies via `npm` -- `spec`: test suite using Jasmine +- `spec`: test suite using Jasmine (`2.2.0`) - `tests`: very simple Jasmine test suite that is run on Circle CI (Android platform) and Travis CI (iOS platform) (used as a placeholder) diff --git a/package.json b/package.json index 30bee5be1..d6cd9fea8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-core", - "version": "1.0.6", + "version": "1.0.7-pre1", "description": "Native interface to SQLite for PhoneGap/Cordova (legacy core version branch)", "cordova": { "id": "cordova-sqlite-legacy-core", diff --git a/plugin.xml b/plugin.xml index 778b1d9b8..e1468a928 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.7-pre1"> Cordova sqlite storage plugin - legacy core version branch diff --git a/src/android/io/sqlc/SQLiteAndroidDatabase.java b/src/android/io/sqlc/SQLiteAndroidDatabase.java index a18871841..578b1908e 100644 --- a/src/android/io/sqlc/SQLiteAndroidDatabase.java +++ b/src/android/io/sqlc/SQLiteAndroidDatabase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017: Christopher J. Brody (aka Chris Brody) + * Copyright (c) 2012-2018: Christopher J. Brody (aka Chris Brody) * Copyright (c) 2005-2010, Nitobi Software Inc. * Copyright (c) 2010, IBM Corporation */ diff --git a/src/android/io/sqlc/SQLitePlugin.java b/src/android/io/sqlc/SQLitePlugin.java index dad0c034f..d2b009814 100755 --- a/src/android/io/sqlc/SQLitePlugin.java +++ b/src/android/io/sqlc/SQLitePlugin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017: Christopher J. Brody (aka Chris Brody) + * Copyright (c) 2012-2018: Christopher J. Brody (aka Chris Brody) * Copyright (c) 2005-2010, Nitobi Software Inc. * Copyright (c) 2010, IBM Corporation */ @@ -196,16 +196,11 @@ public void onDestroy() { // -------------------------------------------------------------------------- private void startDatabase(String dbname, JSONObject options, CallbackContext cbc) { - // TODO: is it an issue that we can orphan an existing thread? What should we do here? - // If we re-use the existing DBRunner it might be in the process of closing... DBRunner r = dbrmap.get(dbname); - // Brody TODO: It may be better to terminate the existing db thread here & start a new one, instead. if (r != null) { - // don't orphan the existing thread; just re-open the existing database. - // In the worst case it might be in the process of closing, but even that's less serious - // than orphaning the old DBRunner. - cbc.success(); + // NO LONGER EXPECTED due to BUG 666 workaround solution: + cbc.error("INTERNAL ERROR: database already open for db name: " + dbname); } else { r = new DBRunner(dbname, options, cbc); dbrmap.put(dbname, r); diff --git a/src/ios/SQLitePlugin.h b/src/ios/SQLitePlugin.h index 107ef6b1f..c459606e6 100755 --- a/src/ios/SQLitePlugin.h +++ b/src/ios/SQLitePlugin.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017: Christopher J. Brody (aka Chris Brody) + * Copyright (c) 2012-2018: Christopher J. Brody (aka Chris Brody) * Copyright (C) 2011 Davide Bertola * * This library is available under the terms of the MIT License (2008). diff --git a/src/ios/SQLitePlugin.m b/src/ios/SQLitePlugin.m index a56bf5ad2..50a98b264 100755 --- a/src/ios/SQLitePlugin.m +++ b/src/ios/SQLitePlugin.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017: Christopher J. Brody (aka Chris Brody) + * Copyright (c) 2012-2018: Christopher J. Brody (aka Chris Brody) * Copyright (C) 2011 Davide Bertola * * This library is available under the terms of the MIT License (2008). @@ -117,6 +117,7 @@ -(void)openNow: (CDVInvokedUrlCommand*)command NSString *dbname = [self getDBPath:dbfilename at:dblocation]; if (dbname == NULL) { + // XXX NOT EXPECTED (INTERNAL ERROR): NSLog(@"No db name specified for open"); pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"You must specify database name"]; } @@ -124,9 +125,14 @@ -(void)openNow: (CDVInvokedUrlCommand*)command NSValue *dbPointer = [openDBs objectForKey:dbfilename]; if (dbPointer != NULL) { - NSLog(@"Reusing existing database connection for db name %@", dbfilename); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Database opened"]; - } else { + // NO LONGER EXPECTED due to BUG 666 workaround solution: + NSLog(@"INTERNAL ERROR: database already open for db name: %@ (db file name: %@)", dbname, dbfilename); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString: @"INTERNAL ERROR: database already open"]; + [self.commandDelegate sendPluginResult:pluginResult callbackId: command.callbackId]; + return; + } + + @synchronized(self) { const char *name = [dbname UTF8String]; sqlite3 *db;