From 4fa3f8a4148b6369349d0ff500f1c5b6eedda55d Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 1 Jan 2018 15:28:11 -0500 Subject: [PATCH 1/5] Update src copyright year to 2018 --- CHANGES.md | 4 ++++ package.json | 2 +- plugin.xml | 2 +- src/android/io/sqlc/SQLiteAndroidDatabase.java | 2 +- src/android/io/sqlc/SQLitePlugin.java | 2 +- src/ios/SQLitePlugin.h | 2 +- src/ios/SQLitePlugin.m | 2 +- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index eec631683..06d200f3e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +###### cordova-sqlite-legacy-express-core 1.0.5-pre01 + +TBD + ###### cordova-sqlite-legacy-express-core 1.0.4 - Cleaned up workaround solution to BUG 666: close db before opening (ignore close error) diff --git a/package.json b/package.json index 6e3a1b0eb..b8807e4cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-express-core", - "version": "1.0.4", + "version": "1.0.5-pre01", "description": "Native interface to SQLite for PhoneGap/Cordova (legacy express core version)", "cordova": { "id": "cordova-sqlite-legacy-express-core", diff --git a/plugin.xml b/plugin.xml index e76aae76d..f73a90842 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.5-pre01"> Cordova sqlite storage plugin - legacy express core version 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 f4fb74cf8..ca6a907fd 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 */ 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..43a704c53 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). From 0614fd056f5e4226487008e18e600f5d4f1a8653 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 1 Jan 2018 17:00:54 -0500 Subject: [PATCH 2/5] cordova-sqlite-legacy-express-core doc fixes --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fd4de49ba..5feb5e5a5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ License terms for iOS/macOS platform version: MIT only ## About this version branch -This version branch contains the source code for the Android/iOS/macOS platforms (legacy express core version branch). This version does not contain any libraries or source code from www.sqlite.org. This version branch uses the built-in sqlite libraries on Android, iOS, and macOS. +This plugin version branch contains the source code for the Android/iOS/macOS platforms (legacy express core version branch). This version does not contain any libraries or source code from www.sqlite.org. This version branch uses the built-in sqlite libraries on Android, iOS, and macOS. This version branch is now used to develop Android platform version without dependency on JAR or NDK library artifacts for testing on `cordova-android@7`. @@ -49,7 +49,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase ## Status -- A recent version of the Cordova CLI (such as `6.5.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` / `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 necessary to use `cordova prepare` in case of cordova-ios older than `4.3.0` (Cordova CLI `6.4.0`). - The iOS database location is now mandatory, as documented below. - Android platform version in this version branch is now using the built-in Android SQLite database classes. Integration with the lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) is available in the default [litehelpers / Cordova-sqlite-storage](https://github.com/litehelpers/Cordova-sqlite-storage) version branch as well as other versions such as [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) and [litehelpers / Cordova-sqlite-legacy](https://github.com/litehelpers/Cordova-sqlite-legacy). - iOS/macOS platform version in this version branch uses builtin `libsqlite3.dylib` framework library. Other versions such as the default [litehelpers / Cordova-sqlite-storage](https://github.com/litehelpers/Cordova-sqlite-storage) version branch, [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext), and [litehelpers / Cordova-sqlite-legacy](https://github.com/litehelpers/Cordova-sqlite-legacy) include a build of a recent sqlite3 amalgamation. @@ -66,7 +66,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - Android versions supported: 2.3.3 - 7.1.1 (API level 10 - 25), depending on Cordova version ref: - iOS versions supported: 8.x / 9.x / 10.x / 11.x - Default `PRAGMA journal_mode` setting (*tested*): - - Android (builtin android.database implementation): `persist` + - Android pre-8.0 (builtin android.database implementation): `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). @@ -999,7 +999,7 @@ To run from a windows powershell (here is a sample for android target): - `SQLitePlugin.coffee.md`: platform-independent (Literate CoffeeScript, can be compiled with a recent CoffeeScript (1.x) compiler) - `www`: platform-independent Javascript as generated from `SQLitePlugin.coffee.md` using `coffeescript@1` (and committed!) - `src`: platform-specific source code -- `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) From ef1875550854098edeaacdf0617f9243858a9e12 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 1 Jan 2018 17:00:54 -0500 Subject: [PATCH 3/5] general doc updates --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5feb5e5a5..5f194852e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ License terms for Android platform version: MIT or Apache 2.0 License terms for iOS/macOS platform version: MIT only -## About this version branch +## About this plugin version branch This plugin version branch contains the source code for the Android/iOS/macOS platforms (legacy express core version branch). This version does not contain any libraries or source code from www.sqlite.org. This version branch uses the built-in sqlite libraries on Android, iOS, and macOS. @@ -14,7 +14,7 @@ This version branch is now used to develop Android platform version without depe NOTE: This version branch has some additional known [issues fixed in newer version branches](#issues-fixed-in-newer-version-branches). - + ## BREAKING CHANGE: Database location parameter is now mandatory @@ -75,7 +75,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 @@ -292,7 +292,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). From 9cc042f9a280acd5c3e5060fbb596a31274d2cff Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 1 Jan 2018 17:17:09 -0500 Subject: [PATCH 4/5] Signal INTERNAL ERROR in case of attempt to reuse db (Android/iOS) Should never happen due to workaround solution to litehelpers/Cordova-sqlite-storage#666 --- CHANGES.md | 4 ++-- package.json | 2 +- plugin.xml | 2 +- src/android/io/sqlc/SQLitePlugin.java | 9 ++------- src/ios/SQLitePlugin.m | 6 ++++-- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 06d200f3e..cf9773f67 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,8 @@ # Changes -###### cordova-sqlite-legacy-express-core 1.0.5-pre01 +###### cordova-sqlite-legacy-express-core 1.0.5-pre02 -TBD +- 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-express-core 1.0.4 diff --git a/package.json b/package.json index b8807e4cb..9c4a2b47e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-express-core", - "version": "1.0.5-pre01", + "version": "1.0.5-pre02", "description": "Native interface to SQLite for PhoneGap/Cordova (legacy express core version)", "cordova": { "id": "cordova-sqlite-legacy-express-core", diff --git a/plugin.xml b/plugin.xml index f73a90842..aecd531ad 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.5-pre02"> Cordova sqlite storage plugin - legacy express core version diff --git a/src/android/io/sqlc/SQLitePlugin.java b/src/android/io/sqlc/SQLitePlugin.java index ca6a907fd..6b49e3376 100755 --- a/src/android/io/sqlc/SQLitePlugin.java +++ b/src/android/io/sqlc/SQLitePlugin.java @@ -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.m b/src/ios/SQLitePlugin.m index 43a704c53..6575b4902 100755 --- a/src/ios/SQLitePlugin.m +++ b/src/ios/SQLitePlugin.m @@ -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,8 +125,9 @@ -(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"]; + // 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"]; } else { const char *name = [dbname UTF8String]; sqlite3 *db; From 7572e388b0ac8aa2dca373128f242f5f335b01e4 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 1 Jan 2018 17:31:05 -0500 Subject: [PATCH 5/5] iOS/macOS @synchronized guard for sqlite3_open operation --- CHANGES.md | 3 ++- package.json | 2 +- plugin.xml | 2 +- src/ios/SQLitePlugin.m | 6 +++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cf9773f67..d8deede04 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,8 @@ # Changes -###### cordova-sqlite-legacy-express-core 1.0.5-pre02 +###### 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-express-core 1.0.4 diff --git a/package.json b/package.json index 9c4a2b47e..1b3fb1861 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-express-core", - "version": "1.0.5-pre02", + "version": "1.0.5", "description": "Native interface to SQLite for PhoneGap/Cordova (legacy express core version)", "cordova": { "id": "cordova-sqlite-legacy-express-core", diff --git a/plugin.xml b/plugin.xml index aecd531ad..c18d3557a 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.5"> Cordova sqlite storage plugin - legacy express core version diff --git a/src/ios/SQLitePlugin.m b/src/ios/SQLitePlugin.m index 6575b4902..50a98b264 100755 --- a/src/ios/SQLitePlugin.m +++ b/src/ios/SQLitePlugin.m @@ -128,7 +128,11 @@ -(void)openNow: (CDVInvokedUrlCommand*)command // 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"]; - } else { + [self.commandDelegate sendPluginResult:pluginResult callbackId: command.callbackId]; + return; + } + + @synchronized(self) { const char *name = [dbname UTF8String]; sqlite3 *db;