From 1e0fddfd1de8bb337176faa0c894b4bc05180c6a Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Fri, 27 Oct 2017 16:20:50 -0400 Subject: [PATCH 01/11] Fix bug 666 workaround to trigger ROLLBACK in next event tick (needed to support version with pre-populated database on Windows) --- CHANGES.md | 4 ++++ SQLitePlugin.coffee.md | 21 ++++++++++++--------- package.json | 2 +- plugin.xml | 2 +- spec/www/spec/db-open-close-delete-test.js | 12 ++++++++---- www/SQLitePlugin.js | 20 +++++++++++++------- 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4bd1f14a2..6b1c2daf8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +###### cordova-sqlite-legacy-express-core 1.0.1 + +- Fix bug 666 workaround to trigger ROLLBACK in the next event tick (needed to support version with pre-populated database on Windows) + ###### cordova-sqlite-legacy-express-core 1.0.0 - Workaround solution to BUG litehelpers/Cordova-sqlite-storage#666 (hanging transaction in case of location reload/change) diff --git a/SQLitePlugin.coffee.md b/SQLitePlugin.coffee.md index 6e1313003..a3dc8c066 100644 --- a/SQLitePlugin.coffee.md +++ b/SQLitePlugin.coffee.md @@ -213,12 +213,14 @@ success @ return + # (done) + else console.log 'OPEN database: ' + @dbname opensuccesscb = => # NOTE: the db state is NOT stored (in @openDBs) if the db was closed or deleted. - # console.log 'OPEN database: ' + @dbname + ' succeeded' + console.log 'OPEN database: ' + @dbname + ' ok' #if !@openDBs[@dbname] then call open error cb, and abort pending tx if any if !@openDBs[@dbname] @@ -248,19 +250,21 @@ # store initial DB state: @openDBs[@dbname] = DB_STATE_INIT - # As a WORKAROUND SOLUTION to BUG litehelpers/Cordova-sqlite-storage#666: + # As a WORKAROUND SOLUTION to BUG litehelpers/Cordova-sqlite-storage#666 + # (in the next event tick): # If the database was never opened on the JavaScript side # start an extra ROLLBACK statement to abort any pending transaction # (does not matter whether it succeeds or fails here). # FUTURE TBD a better solution would be to send a special signal or parameter # if the database was never opened on the JavaScript side. - if not txLocks[@dbname] - myfn = (tx) -> - tx.addStatement 'ROLLBACK' - return - @addTransaction new SQLitePluginTransaction @, myfn, null, null, false, false + nextTick => + if not txLocks[@dbname] + myfn = (tx) -> + tx.addStatement 'ROLLBACK' + return + @addTransaction new SQLitePluginTransaction @, myfn, null, null, false, false - cordova.exec opensuccesscb, openerrorcb, "SQLitePlugin", "open", [ @openargs ] + cordova.exec opensuccesscb, openerrorcb, "SQLitePlugin", "open", [ @openargs ] return @@ -942,4 +946,3 @@ #### vim: set filetype=coffee : #### vim: set expandtab : - diff --git a/package.json b/package.json index e2077ab48..65ee03f73 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-express-core", - "version": "1.0.0", + "version": "1.0.1", "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 7cb41b37c..c67c46975 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.1"> Cordova sqlite storage plugin - legacy express core version diff --git a/spec/www/spec/db-open-close-delete-test.js b/spec/www/spec/db-open-close-delete-test.js index 33957b6fd..31d710f8c 100755 --- a/spec/www/spec/db-open-close-delete-test.js +++ b/spec/www/spec/db-open-close-delete-test.js @@ -577,8 +577,10 @@ var mytests = function() { // XXX SEE BELOW: repeat scenario but wait for open callback before close/delete/reopen // Needed to support some large-scale applications: test_it(suiteName + ' immediate close, then delete then re-open allows subsequent queries to run', function () { - // TBD POSSIBLY BROKEN on iOS/macOS due to current background processing implementation: - if (!isAndroid && !isWindows && !isWP8) pending('POSSIBLY BROKEN on iOS/macOS (background processing implementation)'); + // TBD POSSIBLY BROKEN on iOS/macOS ... + // if (!isAndroid && !isWindows && !isWP8) pending(...); + // TBD CURRENTLY BROKEN DUE TO BUG 666 WORKAROUND HACK + pending('CURRENTLY BROKEN DUE TO BUG 666 WORKAROUND HACK'); var dbName = "Immediate-close-delete-Reopen.db"; var dbargs = {name: dbName, location: 'default'}; @@ -846,8 +848,10 @@ var mytests = function() { // Needed to support some large-scale applications: test_it(suiteName + ' repeatedly open and delete database faster (5x)', function () { - // TBD CURRENTLY BROKEN on iOS/macOS due to current background processing implementation: - if (!isAndroid && !isWindows && !isWP8) pending('CURRENTLY BROKEN on iOS/macOS (background processing implementation)'); + // TBD POSSIBLY BROKEN on iOS/macOS ... + // if (!isAndroid && !isWindows && !isWP8) pending(...); + // TBD CURRENTLY BROKEN DUE TO BUG 666 WORKAROUND HACK + pending('CURRENTLY BROKEN DUE TO BUG 666 WORKAROUND HACK'); var dbName = 'repeatedly-open-and-delete-faster-5x.db'; var dbargs = {name: dbName, location: 'default'}; diff --git a/www/SQLitePlugin.js b/www/SQLitePlugin.js index 476349c80..6d612d448 100644 --- a/www/SQLitePlugin.js +++ b/www/SQLitePlugin.js @@ -162,7 +162,7 @@ }; SQLitePlugin.prototype.open = function(success, error) { - var myfn, openerrorcb, opensuccesscb; + var openerrorcb, opensuccesscb; if (this.dbname in this.openDBs) { console.log('database already open: ' + this.dbname); nextTick((function(_this) { @@ -175,6 +175,7 @@ opensuccesscb = (function(_this) { return function() { var txLock; + console.log('OPEN database: ' + _this.dbname + ' ok'); if (!_this.openDBs[_this.dbname]) { console.log('database was closed during open operation'); } @@ -201,13 +202,18 @@ }; })(this); this.openDBs[this.dbname] = DB_STATE_INIT; - if (!txLocks[this.dbname]) { - myfn = function(tx) { - tx.addStatement('ROLLBACK'); + nextTick((function(_this) { + return function() { + var myfn; + if (!txLocks[_this.dbname]) { + myfn = function(tx) { + tx.addStatement('ROLLBACK'); + }; + _this.addTransaction(new SQLitePluginTransaction(_this, myfn, null, null, false, false)); + } + return cordova.exec(opensuccesscb, openerrorcb, "SQLitePlugin", "open", [_this.openargs]); }; - this.addTransaction(new SQLitePluginTransaction(this, myfn, null, null, false, false)); - } - cordova.exec(opensuccesscb, openerrorcb, "SQLitePlugin", "open", [this.openargs]); + })(this)); } }; From 7fa8c53a503829adf4c75d53accaa4676cc97882 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 5 Sep 2017 19:36:04 -0400 Subject: [PATCH 02/11] @craig-at-rsg add PSPDFThreadSafeMutableDictionary for iOS/macOS PSPDFThreadSafeMutableDictionary.m from https://gist.github.com/steipete/5928916 ref: litehelpers/Cordova-sqlite-storage#716 --- LICENSE.md | 2 + package.json | 2 +- plugin.xml | 2 +- src/ios/PSPDFThreadSafeMutableDictionary.h | 28 ++++ src/ios/PSPDFThreadSafeMutableDictionary.m | 159 +++++++++++++++++++++ 5 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 src/ios/PSPDFThreadSafeMutableDictionary.h create mode 100644 src/ios/PSPDFThreadSafeMutableDictionary.m diff --git a/LICENSE.md b/LICENSE.md index e621188a3..d257c7fcf 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -14,6 +14,8 @@ MIT only based on Phonegap-SQLitePlugin by @davibe (Davide Bertola ) and @joenoon (Joe Noon ) +includes PSPDFThreadSafeMutableDictionary (PSPDFThreadSafeMutableDictionary.m ) MIT license by @steipete () + ## REMOVED from this version branch: Windows (8.1/...) version MIT or Apache 2.0 diff --git a/package.json b/package.json index 65ee03f73..d2050a2d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-express-core", - "version": "1.0.1", + "version": "1.0.2-pre00", "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 c67c46975..74aad5c4b 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.2-pre00"> Cordova sqlite storage plugin - legacy express core version diff --git a/src/ios/PSPDFThreadSafeMutableDictionary.h b/src/ios/PSPDFThreadSafeMutableDictionary.h new file mode 100644 index 000000000..05cd9ac1f --- /dev/null +++ b/src/ios/PSPDFThreadSafeMutableDictionary.h @@ -0,0 +1,28 @@ +// PSPDFThreadSafeMutableDictionary.h header copied from +// PSPDFThreadSafeMutableDictionary.m +// +// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +// Dictionary-Subclasss whose primitive operations are thread safe. +@interface PSPDFThreadSafeMutableDictionary : NSMutableDictionary +@end diff --git a/src/ios/PSPDFThreadSafeMutableDictionary.m b/src/ios/PSPDFThreadSafeMutableDictionary.m new file mode 100644 index 000000000..f8c53e210 --- /dev/null +++ b/src/ios/PSPDFThreadSafeMutableDictionary.m @@ -0,0 +1,159 @@ +// +// PSPDFThreadSafeMutableDictionary.m +// +// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +// Dictionary-Subclasss whose primitive operations are thread safe. +@interface PSPDFThreadSafeMutableDictionary : NSMutableDictionary +@end + +// ---------------------------------------------------------------- + +// +// PSPDFThreadSafeMutableDictionary.m +// PSPDFKit +// +// Copyright (c) 2013 PSPDFKit GmbH. All rights reserved. +// + +#import "PSPDFThreadSafeMutableDictionary.h" +#import + +#define LOCKED(...) OSSpinLockLock(&_lock); \ +__VA_ARGS__; \ +OSSpinLockUnlock(&_lock); + +@implementation PSPDFThreadSafeMutableDictionary { + OSSpinLock _lock; + NSMutableDictionary *_dictionary; // Class Cluster! +} + +/////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark - NSObject + +- (id)init { + return [self initWithCapacity:0]; +} + +- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys { + if ((self = [self initWithCapacity:objects.count])) { + [objects enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + _dictionary[keys[idx]] = obj; + }]; + } + return self; +} + +- (id)initWithCapacity:(NSUInteger)capacity { + if ((self = [super init])) { + _dictionary = [[NSMutableDictionary alloc] initWithCapacity:capacity]; + _lock = OS_SPINLOCK_INIT; + } + return self; +} + +/////////////////////////////////////////////////////////////////////////////////////////// +#pragma mark - NSMutableDictionary + +- (void)setObject:(id)anObject forKey:(id)aKey { + LOCKED(_dictionary[aKey] = anObject) +} + +- (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary { + LOCKED([_dictionary addEntriesFromDictionary:otherDictionary]); +} + +- (void)setDictionary:(NSDictionary *)otherDictionary { + LOCKED([_dictionary setDictionary:otherDictionary]); +} + +- (void)removeObjectForKey:(id)aKey { + LOCKED([_dictionary removeObjectForKey:aKey]) +} + +- (void)removeAllObjects { + LOCKED([_dictionary removeAllObjects]); +} + +- (NSUInteger)count { + LOCKED(NSUInteger count = _dictionary.count) + return count; +} + +- (NSArray *)allKeys { + LOCKED(NSArray *allKeys = _dictionary.allKeys) + return allKeys; +} + +- (NSArray *)allValues { + LOCKED(NSArray *allValues = _dictionary.allValues) + return allValues; +} + +- (id)objectForKey:(id)aKey { + LOCKED(id obj = _dictionary[aKey]) + return obj; +} + +- (NSEnumerator *)keyEnumerator { + LOCKED(NSEnumerator *keyEnumerator = [_dictionary keyEnumerator]) + return keyEnumerator; +} + +- (id)copyWithZone:(NSZone *)zone { + return [self mutableCopyWithZone:zone]; +} + +- (id)mutableCopyWithZone:(NSZone *)zone { + LOCKED(id copiedDictionary = [[self.class allocWithZone:zone] initWithDictionary:_dictionary]) + return copiedDictionary; +} + +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state + objects:(id __unsafe_unretained [])stackbuf + count:(NSUInteger)len { + LOCKED(NSUInteger count = [[_dictionary copy] countByEnumeratingWithState:state objects:stackbuf count:len]); + return count; +} + +- (void)performLockedWithDictionary:(void (^)(NSDictionary *dictionary))block { + if (block) LOCKED(block(_dictionary)); +} + +- (BOOL)isEqual:(id)object { + if (object == self) return YES; + + if ([object isKindOfClass:PSPDFThreadSafeMutableDictionary.class]) { + PSPDFThreadSafeMutableDictionary *other = object; + __block BOOL isEqual = NO; + [other performLockedWithDictionary:^(NSDictionary *dictionary) { + [self performLockedWithDictionary:^(NSDictionary *otherDictionary) { + isEqual = [dictionary isEqual:otherDictionary]; + }]; + }]; + return isEqual; + } + return NO; +} + +@end From 570d5e8a793f7441bb7996d809abd884569dc729 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 5 Sep 2017 19:36:04 -0400 Subject: [PATCH 03/11] Fix PSPDFThreadSafeMutableDictionary.m redeclaration issue --- src/ios/PSPDFThreadSafeMutableDictionary.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ios/PSPDFThreadSafeMutableDictionary.m b/src/ios/PSPDFThreadSafeMutableDictionary.m index f8c53e210..2b39604b9 100644 --- a/src/ios/PSPDFThreadSafeMutableDictionary.m +++ b/src/ios/PSPDFThreadSafeMutableDictionary.m @@ -23,9 +23,11 @@ #import +/* ** ALREADY INCLUDED BY #import "PSPDFThreadSafeMutableDictionary.h" // Dictionary-Subclasss whose primitive operations are thread safe. @interface PSPDFThreadSafeMutableDictionary : NSMutableDictionary @end +// */ // ---------------------------------------------------------------- From 6d946d0cb0c2acd93a37fb404e94ccf0d690e6dd Mon Sep 17 00:00:00 2001 From: craig-at-rsg Date: Tue, 5 Sep 2017 19:37:43 -0400 Subject: [PATCH 04/11] Update SQLitePlugin.m & plugin.xml to use PSPDFThreadSafeMutableDictionary (iOS/macOS) with minor changes by @brodybits: - import PSPDFThreadSafeMutableDictionary in SQLitePlugin.m instead of SQLitePlugin.h - update SQLitePlugin.m & plugin.xml in single commit - update plugin version - update docs ref: litehelpers/Cordova-sqlite-storage#716 --- CHANGES.md | 4 ++++ LICENSE.md | 2 +- README.md | 1 + package.json | 2 +- plugin.xml | 10 +++++++++- src/ios/SQLitePlugin.m | 4 +++- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6b1c2daf8..968eb4fe2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +###### cordova-sqlite-legacy-express-core 1.0.2 + +- Use PSPDFThreadSafeMutableDictionary for iOS/macOS to avoid threading issue ref: litehelpers/Cordova-sqlite-storage#716 + ###### cordova-sqlite-legacy-express-core 1.0.1 - Fix bug 666 workaround to trigger ROLLBACK in the next event tick (needed to support version with pre-populated database on Windows) diff --git a/LICENSE.md b/LICENSE.md index d257c7fcf..23233c14e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -14,7 +14,7 @@ MIT only based on Phonegap-SQLitePlugin by @davibe (Davide Bertola ) and @joenoon (Joe Noon ) -includes PSPDFThreadSafeMutableDictionary (PSPDFThreadSafeMutableDictionary.m ) MIT license by @steipete () +includes and uses PSPDFThreadSafeMutableDictionary (PSPDFThreadSafeMutableDictionary.m ) MIT license by @steipete () ## REMOVED from this version branch: Windows (8.1/...) version diff --git a/README.md b/README.md index 5f6e44d3b..4e99f8554 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase ## Announcements +- Fixed iOS/macOS platform version to use [PSPDFThreadSafeMutableDictionary.m](https://gist.github.com/steipete/5928916) to avoid threading issue ref: [litehelpers/Cordova-sqlite-storage#716](https://github.com/litehelpers/Cordova-sqlite-storage/issues/716) - Resolved transaction problem after window.location (page) change with possible data loss ref: [litehelpers/Cordova-sqlite-storage#666](https://github.com/litehelpers/Cordova-sqlite-storage/issues/666) - [brodybits / cordova-sqlite-test-app](https://github.com/brodybits/cordova-sqlite-test-app) project is a CC0 (public domain) starting point (NOTE that this plugin must be added) and may also be used to reproduce issues with this plugin. - The Lawnchair adapter is now moved to [litehelpers / cordova-sqlite-lawnchair-adapter](https://github.com/litehelpers/cordova-sqlite-lawnchair-adapter). diff --git a/package.json b/package.json index d2050a2d7..9950f0d74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-express-core", - "version": "1.0.2-pre00", + "version": "1.0.2", "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 74aad5c4b..a0a873850 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.2"> Cordova sqlite storage plugin - legacy express core version @@ -41,6 +41,10 @@ + + + + @@ -55,6 +59,10 @@ + + + + diff --git a/src/ios/SQLitePlugin.m b/src/ios/SQLitePlugin.m index d1ff85c4e..a56bf5ad2 100755 --- a/src/ios/SQLitePlugin.m +++ b/src/ios/SQLitePlugin.m @@ -10,6 +10,8 @@ #import "sqlite3.h" +#import "PSPDFThreadSafeMutableDictionary.h" + // FUTURE TBD (in another version branch): //#define READ_BLOB_AS_BASE64 @@ -27,7 +29,7 @@ -(void)pluginInitialize NSLog(@"Initializing SQLitePlugin"); { - openDBs = [NSMutableDictionary dictionaryWithCapacity:0]; + openDBs = [PSPDFThreadSafeMutableDictionary dictionaryWithCapacity:0]; appDBPaths = [NSMutableDictionary dictionaryWithCapacity:0]; #if !__has_feature(objc_arc) [openDBs retain]; From 68d0406e39de5c7efa470990037732e6466f642a Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Thu, 2 Nov 2017 17:33:34 -0400 Subject: [PATCH 05/11] README.md document multiple sqlite problem ref: litehelpers/Cordova-sqlite-storage#626 --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 837494071..162d7f76d 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,16 @@ _XXX TBD ???:_ +## WARNING: Multiple SQLite problem on Android + +This plugin uses a non-standard [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) implementation on Android. In case an application access the **same** database using multiple plugins there is a risk of data corruption ref: [litehelpers/Cordova-sqlite-storage#626](https://github.com/litehelpers/Cordova-sqlite-storage/issues/626)) as described in and . + +The workaround is to use the `androidDatabaseImplementation: 2` setting as described in the **Android sqlite implementation** section below: + +```js +var db = window.sqlitePlugin.openDatabase({name: "my.db", androidDatabaseImplementation: 2}); +``` + ## BREAKING CHANGE: Database location parameter is now mandatory The `location` or `iosDatabaseLocation` *must* be specified in the `openDatabase` and `deleteDatabase` calls, as documented below. @@ -361,6 +371,8 @@ var db = window.sqlitePlugin.openDatabase({name: 'my.db', location: 'default'}, **WARNING:** The new "default" location value is *NOT* the same as the old default location and would break an upgrade for an app that was using the old default value (0) on iOS. +**WARNING 2:** As described above: by default this plugin uses a non-standard [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) implementation on Android. In case an application access the **same** database using multiple plugins there is a risk of data corruption ref: [litehelpers/Cordova-sqlite-storage#626](https://github.com/litehelpers/Cordova-sqlite-storage/issues/626)) as described in and . The workaround is to use the `androidDatabaseImplementation: 2` setting as described in the **Android sqlite implementation** section below. + To specify a different location (affects iOS/macOS *only*): ```js @@ -441,9 +453,13 @@ By default, this plugin uses [Android-sqlite-connector](https://github.com/liteg var db = window.sqlitePlugin.openDatabase({name: "my.db", androidDatabaseImplementation: 2}); ``` +**IMPORTANT:** +- As described above: by default this plugin uses a non-standard [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) implementation on Android. In case an application access the **same** database using multiple plugins there is a risk of data corruption ref: [litehelpers/Cordova-sqlite-storage#626](https://github.com/litehelpers/Cordova-sqlite-storage/issues/626)) as described in and . The workaround is to use the `androidDatabaseImplementation: 2` setting as described here. +- In case of the `androidDatabaseImplementation: 2` setting, [litehelpers/Cordova-sqlite-storage#193](https://github.com/litehelpers/Cordova-sqlite-storage/issues/193) reported that in certain Android versions, if the app is stopped or aborted without closing the database then there is an unexpected database lock and the data that was inserted is lost. The workaround is described below. + ### Workaround for Android db locking issue -[litehelpers/Cordova-sqlite-storage#193](https://github.com/litehelpers/Cordova-sqlite-storage/issues/193) was reported (as observed by several app developers) that certain versions of the Android database classes, if the app is stopped or aborted without closing the database then: +[litehelpers/Cordova-sqlite-storage#193](https://github.com/litehelpers/Cordova-sqlite-storage/issues/193) reported (as observed by several app developers) that certain versions of the Android database classes, if the app is stopped or aborted without closing the database then: - (sometimes) there is an unexpected database lock - the data that was inserted is lost. From da62bbe03bdc76c8da2b9302551fe0bc2e7bdd83 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Thu, 2 Nov 2017 19:18:08 -0400 Subject: [PATCH 06/11] Windows 10 (UWP) build with /SAFESEH flag on Win32 (x86) target ref: - litehelpers/Cordova-sqlite-storage#563 (comment) - litehelpers/Cordova-sqlite-storage#685 --- CHANGES.md | 4 +++- README.md | 1 + package.json | 2 +- plugin.xml | 2 +- .../SQLite3-Win-RT/SQLite3/SQLite3.UWP/SQLite3.UWP.vcxproj | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9b33cd4e9..e09c5ef0a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ # Changes -##### cordova-sqlite-legacy-core 1.0.0 +##### cordova-sqlite-legacy-core 1.0.1-pre1 + +- Windows 10 (UWP) build with /SAFESEH flag on Win32 (x86) target ###### cordova-sqlite-legacy-express-core 1.0.2 diff --git a/README.md b/README.md index 162d7f76d..be883f321 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase ## Announcements +- Windows 10 (UWP) build with /SAFESEH flag on Win32 (x86) target to specify "Image has Safe Exception Handlers" as described in - Fixed iOS/macOS platform version to use [PSPDFThreadSafeMutableDictionary.m](https://gist.github.com/steipete/5928916) to avoid threading issue ref: [litehelpers/Cordova-sqlite-storage#716](https://github.com/litehelpers/Cordova-sqlite-storage/issues/716) - Resolved transaction problem after window.location (page) change with possible data loss ref: [litehelpers/Cordova-sqlite-storage#666](https://github.com/litehelpers/Cordova-sqlite-storage/issues/666) - [brodybits / cordova-sqlite-test-app](https://github.com/brodybits/cordova-sqlite-test-app) project is a CC0 (public domain) starting point (NOTE that this plugin must be added) and may also be used to reproduce issues with this plugin. diff --git a/package.json b/package.json index 48516d674..d38925a8c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-core", - "version": "1.0.0", + "version": "1.0.1-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 53fc223c3..126066336 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.1-pre1"> Cordova sqlite storage plugin - legacy core version branch diff --git a/src/windows/SQLite3-Win-RT/SQLite3/SQLite3.UWP/SQLite3.UWP.vcxproj b/src/windows/SQLite3-Win-RT/SQLite3/SQLite3.UWP/SQLite3.UWP.vcxproj index 3c46ddcf1..1241bd2c7 100644 --- a/src/windows/SQLite3-Win-RT/SQLite3/SQLite3.UWP/SQLite3.UWP.vcxproj +++ b/src/windows/SQLite3-Win-RT/SQLite3/SQLite3.UWP/SQLite3.UWP.vcxproj @@ -131,6 +131,7 @@ Console false + /SAFESEH %(AdditionalOptions) @@ -147,6 +148,7 @@ Console false + /SAFESEH %(AdditionalOptions) From ece0c61fcc189a206e6a15715285fc541829c839 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Fri, 3 Nov 2017 11:21:05 -0400 Subject: [PATCH 07/11] SQLite build with flag fixes in this version branch - SQLITE_THREADSAFE=2 on iOS/macOS (SQLITE_THREADSAFE=1 on Android/Windows) to avoid possible malformed database due to multithreaded access ref: litehelpers/Cordova-sqlite-storage#703 - Drop -DSQLITE_OMIT_BUILTIN_TEST (renamed & not recommended) - Certain LOCAL_CFLAGS added from https://www.sqlite.org/compile.html#recommended_compile_time_options - Minor reordering --- CHANGES.md | 3 ++- README.md | 17 ++++++++++++++++- package.json | 2 +- plugin.xml | 8 +++++--- .../SQLite3/SQLite3.Shared.vcxitems | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e09c5ef0a..0a5c51c21 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,8 @@ # Changes -##### cordova-sqlite-legacy-core 1.0.1-pre1 +##### cordova-sqlite-legacy-core 1.0.1 +- SQLite 3.15.2 build with SQLITE_THREADSAFE=2 on iOS/macOS (SQLITE_THREADSAFE=1 on Android/Windows) and other flag fixes in this version branch to avoid possible malformed database due to multithreaded access ref: litehelpers/Cordova-sqlite-storage#703 - Windows 10 (UWP) build with /SAFESEH flag on Win32 (x86) target ###### cordova-sqlite-legacy-express-core 1.0.2 diff --git a/README.md b/README.md index be883f321..81f575627 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,23 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - 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`). - This version uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-storage-dependencies` via npm. +- Build with SQLite (version `3.8.10.2`) with the following build settings for iOS/macOS/Windows: + - `SQLITE_THREADSAFE=1` (`SQLITE_THREADSAFE=2` on iOS/macOS) + - `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_RTREE` + - `SQLITE_DEFAULT_PAGE_SIZE=1024` and `SQLITE_DEFAULT_CACHE_SIZE=2000` to avoid "potentially distruptive change(s)" from SQLite 3.12.0 ref: + - `SQLITE_OS_WINRT` for Windows only +- Use of other systems such as Cordova Plugman, PhoneGap CLI, PhoneGap Build, and Intel XDK is no longer supported 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) (available with GPL or commercial license options) or [litehelpers / Cordova-sqlite-legacy-build-support](https://github.com/litehelpers/Cordova-sqlite-legacy-build-support) (limited testing, limited updates) - The iOS database location is now mandatory, as documented below. -- _SQLite version `3.8.10.2` is supported for ~~all supported platforms~~ Android/iOS/Windows; macOS platform version in this version branch uses the builtin `libsqlite3.dylib` framework library (**TODO** iOS and macOS should use the same sqlite version)_ - This version supports the use of two (2) possible Android sqlite database implementations: - default: lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) - optional: built-in Android database classes (usage described below) diff --git a/package.json b/package.json index d38925a8c..45ee9b34a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-core", - "version": "1.0.1-pre1", + "version": "1.0.1", "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 126066336..ee5b28141 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.1"> Cordova sqlite storage plugin - legacy core version branch @@ -60,7 +60,7 @@ + compiler-flags="-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" /> @@ -78,7 +78,9 @@ - + + diff --git a/src/windows/SQLite3-Win-RT/SQLite3/SQLite3.Shared.vcxitems b/src/windows/SQLite3-Win-RT/SQLite3/SQLite3.Shared.vcxitems index fc0eeeb93..37144485e 100644 --- a/src/windows/SQLite3-Win-RT/SQLite3/SQLite3.Shared.vcxitems +++ b/src/windows/SQLite3-Win-RT/SQLite3/SQLite3.Shared.vcxitems @@ -11,7 +11,7 @@ %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory);$(MSBuildThisFileDirectory)..\..\..\..\node_modules\cordova-sqlite-storage-dependencies - /DSQLITE_TEMP_STORE=2 /DSQLITE_THREADSAFE=2 /DSQLITE_ENABLE_FTS3 /DSQLITE_ENABLE_FTS3_PARENTHESIS /DSQLITE_ENABLE_FTS4 /DSQLITE_ENABLE_COLUMN_METADATA /DSQLITE_ENABLE_RTREE /DSQLITE_OS_WINRT %(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) From 8ac39fa1d17a40b7bc703040f90b92f3a63a2a25 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 5 Nov 2017 11:27:07 -0500 Subject: [PATCH 08/11] Fix log in case of transaction waiting for open to finish; test/doc fixes --- CHANGES.md | 3 +- README.md | 53 ++++++++++++++++++------------------ SQLitePlugin.coffee.md | 2 +- package.json | 2 +- plugin.xml | 2 +- spec/www/index.html | 4 ++- spec/www/spec/regexp-test.js | 6 ++-- www/SQLitePlugin.js | 2 +- 8 files changed, 39 insertions(+), 35 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0a5c51c21..42296867f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,8 @@ # Changes -##### cordova-sqlite-legacy-core 1.0.1 +##### cordova-sqlite-legacy-core 1.0.2 +- Fix log in case of transaction waiting for open to finish; doc fixes - SQLite 3.15.2 build with SQLITE_THREADSAFE=2 on iOS/macOS (SQLITE_THREADSAFE=1 on Android/Windows) and other flag fixes in this version branch to avoid possible malformed database due to multithreaded access ref: litehelpers/Cordova-sqlite-storage#703 - Windows 10 (UWP) build with /SAFESEH flag on Win32 (x86) target diff --git a/README.md b/README.md index 81f575627..0cc994404 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ # Cordova/PhoneGap sqlite storage adapter (legacy core version branch) -Native interface to sqlite in a Cordova/PhoneGap plugin for _Android/iOS/macOS/Windows_, with API similar to HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/). +Native interface to sqlite in a Cordova/PhoneGap plugin for Android/iOS/macOS/Windows, with API similar to HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/). -License for Android and Windows versions: MIT or Apache 2.0 +License terms for Android and Windows platform versions: MIT or Apache 2.0 -License for iOS/macOS platform version: MIT only +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 core version branch)._ +This version branch contains the source code for the Android/iOS/macOS 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._ - -_XXX TBD ???:_ +This version branch uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-storage-dependencies` via npm. + @@ -80,7 +80,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - `SQLITE_ENABLE_RTREE` - `SQLITE_DEFAULT_PAGE_SIZE=1024` and `SQLITE_DEFAULT_CACHE_SIZE=2000` to avoid "potentially distruptive change(s)" from SQLite 3.12.0 ref: - `SQLITE_OS_WINRT` for Windows only -- Use of other systems such as Cordova Plugman, PhoneGap CLI, PhoneGap Build, and Intel XDK is no longer supported 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) (available with GPL or commercial license options) or [litehelpers / Cordova-sqlite-legacy-build-support](https://github.com/litehelpers/Cordova-sqlite-legacy-build-support) (limited testing, limited updates) +- Use of other systems such as Cordova Plugman, PhoneGap CLI, PhoneGap Build, and Intel XDK is no longer supported 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) (available with GPL or commercial license terms) or [litehelpers / Cordova-sqlite-legacy-build-support](https://github.com/litehelpers/Cordova-sqlite-legacy-build-support) (limited testing, limited updates) - The iOS database location is now mandatory, as documented below. - This version supports the use of two (2) possible Android sqlite database implementations: - default: lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) @@ -98,7 +98,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - R-Tree is *not* tested or supported for Android in this version branch. - Android is supported back to SDK 10 (a.k.a. Gingerbread, Android 2.3.3); support for older versions is available upon request. - iOS versions supported: 8.x/9.x/10.x -- In case of memory issues please use smaller transactions or use the version (with GPL or commercial license options) at: [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) +- In case of memory issues please use smaller transactions or use the version at [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms). @@ -113,7 +113,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - [brodybits / sql-promise-helper](https://github.com/brodybits/sql-promise-helper) provides a Promise-based API wrapper. - [nolanlawson / pouchdb-adapter-cordova-sqlite](https://github.com/nolanlawson/pouchdb-adapter-cordova-sqlite) supports this plugin along with other implementations such as [nolanlawson / sqlite-plugin-2](https://github.com/nolanlawson/sqlite-plugin-2) and [Microsoft / cordova-plugin-websql](https://github.com/Microsoft/cordova-plugin-websql). - macOS ("osx" platform) is now supported -- New [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) version with Android JSON and SQL statement handling implemented in C, as well as support for PhoneGap Build, Intel XDK, etc., available with GPL or commercial license options. Handles large SQL batches in less than half the time as this version. Also supports arbitrary database location on Android. +- New [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) version with Android JSON and SQL statement handling implemented in C, as well as support for PhoneGap Build, Intel XDK, etc. (GPL or commercial license terms). Handles large SQL batches in less than half the time as this version. Also supports arbitrary database location on Android. - Published [brodybits / Cordova-quick-start-checklist](https://github.com/brodybits/Cordova-quick-start-checklist) and [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/brodybits/Avoiding-some-Cordova-pitfalls). - Windows 8.1/Windows Phone 8.1/Windows 10 version is available **here** _(Visual Studio 2015 required, Visual Studio 2017 NOT supported by this version branch)_ as well as in [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) (with pre-populated database support) and [litehelpers / Cordova-sqlite-legacy](https://github.com/litehelpers/Cordova-sqlite-legacy) (with WP8 support). - Android version _currently uses_ the lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) by default configuration (may be changed as described below) @@ -189,7 +189,7 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww - As described below, auto-vacuum is NOT enabled by default. - 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) - INSERT statement that affects multiple rows (due to SELECT cause or using TRIGGER(s), for example) does not report proper rowsAffected on Android -- Memory issue observed when adding a large number of records due to the JSON implementation which is improved in [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (available with GPL or commercial license options) +- Memory issue observed when adding a large number of records due to the JSON implementation which is improved in [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms) - Infinity (positive or negative) values are not supported on Android/iOS/macOS due to issues described above including a possible crash on iOS/macOS ref: [litehelpers/Cordova-sqlite-storage#405](https://github.com/litehelpers/Cordova-sqlite-storage/issues/405) - A stability issue was reported on the iOS version when in use together with [SockJS](http://sockjs.org/) client such as [pusher-js](https://github.com/pusher/pusher-js) at the same time (see [litehelpers/Cordova-sqlite-storage#196](https://github.com/litehelpers/Cordova-sqlite-storage/issues/196)). The workaround is to call sqlite functions and [SockJS](http://sockjs.org/) client functions in separate ticks (using setTimeout with 0 timeout). - If a sql statement fails for which there is no error handler or the error handler does not return `false` to signal transaction recovery, the plugin fires the remaining sql callbacks before aborting the transaction. @@ -220,17 +220,17 @@ Issues fixed in some newer version branches: - ~~The db version, display name, and size parameter values are not supported and will be ignored.~~ (No longer supported by the API) - Absolute and relative subdirectory path(s) are not tested or supported. - This plugin will not work before the callback for the 'deviceready' event has been fired, as described in **Usage**. (This is consistent with the other Cordova plugins.) -- Extremely large records are not supported by this plugin version. TBD: specify maximum record; FUTURE TBD: to be fixed in [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (available with GPL or commercial license options) -- This plugin version will not work within a web worker (not properly supported by the Cordova framework). Use within a web worker is supported for Android/iOS in: [litehelpers / Cordova-sqlite-evplus-legacy-workers-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-workers-free) (available with GPL or premium commercial license options) +- Extremely large records are not supported by this plugin version. TBD: specify maximum record; FUTURE TBD: to be fixed in [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms). +- This plugin version will not work within a web worker (not properly supported by the Cordova framework). Use within a web worker is supported for Android/iOS in [litehelpers / cordova-sqlite-evmax-ext-workers-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evmax-ext-workers-legacy-build-free) (GPL or premium commercial license terms). - In-memory database `db=window.sqlitePlugin.openDatabase({name: ':memory:', ...})` is currently not supported. - The Android version cannot work with more than 100 open db files (due to the threading model used). -- UNICODE `\u2028` (line separator) and `\u2029` (paragraph separator) characters are currently not supported and known to be broken _on_ iOS, macOS, and Android _platforms_ due to JSON issues reported in [Cordova bug CB-9435](https://issues.apache.org/jira/browse/CB-9435) and [cordova/cordova-discuss#57](https://github.com/cordova/cordova-discuss/issues/57). There *may* be a similar issue with certain other UNICODE characters in the iOS/macOS version (needs further investigation). This is fixed for iOS in: [litehelpers / Cordova-sqlite-evplus-legacy-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-free) and [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (available with GPL or special commercial license options) as well as [litehelpers / Cordova-sqlite-evplus-legacy-workers-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-workers-free) (available with GPL or premium commercial license options) -- The BLOB data type is not fully supported by this version branch. SELECT BLOB in Base64 format is supported by [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) (permissive license terms) and [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license options). -- Truncation in case of UNICODE `\u0000` (same as `\0`) character on Android _(default Android-sqlite-connector database implementation) and Windows_ +- UNICODE `\u2028` (line separator) and `\u2029` (paragraph separator) characters are not supported and known to be broken on iOS, macOS, and Android platforms due to JSON issues reported in [Cordova bug CB-9435](https://issues.apache.org/jira/browse/CB-9435) and [cordova/cordova-discuss#57](https://github.com/cordova/cordova-discuss/issues/57). There *may* be a similar issue with certain other UNICODE characters in the iOS/macOS version (needs further investigation). This is fixed for iOS in [litehelpers / cordova-sqlite-evplus-ext-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evplus-ext-legacy-build-free) and [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (GPL or special commercial license terms) as well as [litehelpers / cordova-sqlite-evmax-ext-workers-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evmax-ext-workers-legacy-build-free) (GPL or premium commercial license terms). +- The BLOB data type is not fully supported by this version branch. SELECT BLOB in Base64 format is supported by [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) (permissive license terms) and [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms). +- Truncation in case of UNICODE `\u0000` (same as `\0`) character on Android (default Android-sqlite-connector database implementation) and Windows. - Case-insensitive matching and other string manipulations on Unicode characters, which is provided by optional ICU integration in the sqlite source and working with recent versions of Android, is not supported for any target platforms. - iOS/macOS platform version uses a thread pool but with only one thread working at a time due to "synchronized" database access - Some large query results may be slow, also due to the JSON implementation. -- ATTACH to another database file is not supported by this version. Attach/detach is supported (along with the memory and iOS UNICODE `\u2028` line separator / `\u2029` paragraph separator fixes) in: [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (available with GPL or special commercial license options) +- ATTACH to another database file is not supported by this version branch. Attach/detach is supported (along with the memory and iOS UNICODE `\u2028` line separator / `\u2029` paragraph separator fixes) in [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (available with GPL or special commercial license terms). - UPDATE/DELETE with LIMIT or ORDER BY is not supported. - WITH clause is not supported by some older Android/iOS versions. - User-defined savepoints are not supported and not expected to be compatible with the transaction locking mechanism used by this plugin. In addition, the use of BEGIN/COMMIT/ROLLBACK statements is not supported. @@ -309,17 +309,18 @@ Documented in: [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/b ## Alternatives -### Other versions +### Comparison of sqlite plugin versions -- [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) - 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) -- [litehelpers / Cordova-sqlite-legacy-build-support](https://github.com/litehelpers/Cordova-sqlite-legacy-build-support) - maintenance of WP8 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 +- [litehelpers / Cordova-sqlite-storage](https://github.com/litehelpers/Cordova-sqlite-storage) - core version for Android/iOS/macOS/Windows (permissive license terms) +- [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) - 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 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 version. Supports arbitrary database location on Android. Support for build environments such as PhoneGap Build and Intel XDK. Available with GPL or commercial license options. Also includes REGEXP (Android/iOS/macOS) and SELECT BLOB in Base64 format (all platforms Android/iOS/macOS/Windows). -- [litehelpers / Cordova-sqlite-evplus-legacy-workers-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-workers-free) - version with support for web workers, includes internal memory improvements to support larger transactions (Android/iOS) and fix to support all Unicode characters (iOS) (with GPL or premium commercial license options) -- [litehelpers / Cordova-sqlite-evplus-legacy-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-free) - internal memory improvements to support larger transactions (Android/iOS) and fix to support all Unicode characters (iOS) - with GPL or special commercial license options -- [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) - version with support for ATTACH, includes internal memory improvements to support larger transactions (Android/iOS) and fix to support all Unicode characters (with GPL or special commercial license options) -- Adaptation for React Native Android and iOS: [andpor / react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage) -- Original version for iOS (with a slightly different transaction API): [davibe / Phonegap-SQLitePlugin](https://github.com/davibe/Phonegap-SQLitePlugin) +- [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 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). +- [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) - version with support for ATTACH, includes internal memory improvements to support larger transactions (Android/iOS) and fix to support all Unicode characters (GPL or special commercial license terms). +- [litehelpers / cordova-sqlite-evmax-ext-workers-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evmax-ext-workers-legacy-build-free) - version with support for web workers, includes internal memory improvements to support larger transactions (Android/iOS) and fix to support all Unicode characters (iOS). (GPL or premium commercial license terms). +- Adaptation for React Native Android and iOS: [andpor / react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage) (permissive license terms) +- Original version for iOS (with a non-standard, outdated transaction API): [davibe / Phonegap-SQLitePlugin](https://github.com/davibe/Phonegap-SQLitePlugin) (permissive license terms) diff --git a/SQLitePlugin.coffee.md b/SQLitePlugin.coffee.md index a3dc8c066..dccb55d84 100644 --- a/SQLitePlugin.coffee.md +++ b/SQLitePlugin.coffee.md @@ -135,7 +135,7 @@ else if @dbname of @openDBs - console.log 'new transaction is waiting for open operation' + console.log 'new transaction is queued, waiting for open operation to finish' else # XXX SHOULD NOT GET HERE. # FUTURE TBD TODO: in this exceptional case abort and discard the transaction. diff --git a/package.json b/package.json index 45ee9b34a..d2cdd750e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-core", - "version": "1.0.1", + "version": "1.0.2", "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 ee5b28141..13af87aec 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.2"> Cordova sqlite storage plugin - legacy core version branch diff --git a/spec/www/index.html b/spec/www/index.html index d84a43e65..fa6e981e8 100644 --- a/spec/www/index.html +++ b/spec/www/index.html @@ -16,8 +16,10 @@ - + + + diff --git a/spec/www/spec/regexp-test.js b/spec/www/spec/regexp-test.js index a0e0ee3dc..368f24d9e 100644 --- a/spec/www/spec/regexp-test.js +++ b/spec/www/spec/regexp-test.js @@ -40,11 +40,11 @@ var mytests = function() { it(suiteName + 'Simple REGEXP test', function(done) { - if (isWP8) pending('NOT IMPLEMENTED for WP8'); - if (isWindows) pending('NOT IMPLEMENTED for Windows'); + if (isWP8) pending('NOT IMPLEMENTED for WP8 (plugin)'); + if (isWindows) pending('NOT IMPLEMENTED for Windows (plugin)'); if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin'); // TBD SKIP for Android plugin (for now) if (isWebSql && !isAndroid && !isWindows && !isWP8) pending('SKIP for iOS (WebKit) Web SQL'); - if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('NOT IMPLEMENTED for iOS/macOS'); + if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('NOT IMPLEMENTED for iOS/macOS plugin'); var db = openDatabase('simple-regexp-test.db', '1.0', 'test', DEFAULT_SIZE); diff --git a/www/SQLitePlugin.js b/www/SQLitePlugin.js index 6d612d448..51dee0cf5 100644 --- a/www/SQLitePlugin.js +++ b/www/SQLitePlugin.js @@ -102,7 +102,7 @@ this.startNextTransaction(); } else { if (this.dbname in this.openDBs) { - console.log('new transaction is waiting for open operation'); + console.log('new transaction is queued, waiting for open operation to finish'); } else { console.log('database is closed, new transaction is [stuck] waiting until db is opened again!'); } From 060c0a0d76b9220df496e8602aabfba47f759120 Mon Sep 17 00:00:00 2001 From: Daniel Sogl Date: Fri, 2 Jun 2017 12:06:45 +0200 Subject: [PATCH 09/11] style(package): add macOS Platform ref: litehelpers/Cordova-sqlite-storage#695 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index d2cdd750e..b9f16b409 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "platforms": [ "android", "ios", + "osx", "windows" ] }, From 89cbb948dd18bb25e3033fb15eedc0002d0bbdcf Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 7 Nov 2017 16:04:37 -0500 Subject: [PATCH 10/11] Update Android platforms supported; other doc updates --- README.md | 79 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 0cc994404..f46fe9386 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ The workaround is to use the `androidDatabaseImplementation: 2` setting as descr var db = window.sqlitePlugin.openDatabase({name: "my.db", androidDatabaseImplementation: 2}); ``` + + ## BREAKING CHANGE: Database location parameter is now mandatory The `location` or `iosDatabaseLocation` *must* be specified in the `openDatabase` and `deleteDatabase` calls, as documented below. @@ -63,9 +65,9 @@ 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` 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`). - This version uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-storage-dependencies` via npm. -- Build with SQLite (version `3.8.10.2`) with the following build settings for iOS/macOS/Windows: +- SQLite `3.8.10.2` included when building (all platforms), with the following definitions for iOS/macOS/Windows: - `SQLITE_THREADSAFE=1` (`SQLITE_THREADSAFE=2` on iOS/macOS) - `SQLITE_DEFAULT_MEMSTATUS=0` - `SQLITE_OMIT_DECLTYPE` @@ -85,19 +87,24 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - This version supports the use of two (2) possible Android sqlite database implementations: - default: lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) - optional: built-in Android database classes (usage described below) -- WP8 support is available in: _[litehelpers / Cordova-sqlite-legacy-build-support](https://github.com/litehelpers/Cordova-sqlite-legacy-build-support) (along with Windows 8.1/Windows Phone 8.1/Windows 10 using Visual Studio 2015)_ +- Support for WP8 is available in: [litehelpers / Cordova-sqlite-legacy-build-support](https://github.com/litehelpers/Cordova-sqlite-legacy-build-support) (along with Windows 8.1/Windows Phone 8.1/Windows 10 using Visual Studio 2015) - The following features are available in [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext): - REGEXP (Android/iOS/macOS) - SELECT BLOB data in Base64 format (all platforms Android/iOS/macOS/Windows) - Pre-populated database (Android/iOS/macOS/Windows) - Amazon Fire-OS is dropped due to lack of support by Cordova. Android version should be used to deploy to Fire-OS 5.0(+) devices. For reference: [cordova/cordova-discuss#32 (comment)](https://github.com/cordova/cordova-discuss/issues/32#issuecomment-167021676) -- Windows version using the performant C++ [doo / SQLite3-WinRT](https://github.com/doo/SQLite3-WinRT) component is in an alpha state: - - Issue with UNICODE `\u0000` character (same as `\0`) +- Windows version (using a customized version of the performant [doo / SQLite3-WinRT](https://github.com/doo/SQLite3-WinRT) C++ component) has the following known limitations: + - This version branch with dependency on platform toolset libraries included by Visual Studio 2015 ref: [litehelpers/Cordova-sqlite-storage#580](https://github.com/litehelpers/Cordova-sqlite-storage/issues/580) + - It is **not** possible to use this plugin with the default "Any CPU" target. A specific target CPU type **must** be specified when building an app with this plugin. + - Truncation issue with UNICODE `\u0000` character (same as `\0`) - No background processing -- FTS3 and FTS4 are tested working OK in this version branch (for all target platforms in this version branch Android/iOS/macOS) -- R-Tree is *not* tested or supported for Android in this version branch. -- Android is supported back to SDK 10 (a.k.a. Gingerbread, Android 2.3.3); support for older versions is available upon request. -- iOS versions supported: 8.x/9.x/10.x + - INCORRECT error code and INCONSISTENT error message in error callbacks ref: [litehelpers/Cordova-sqlite-storage#539](https://github.com/litehelpers/Cordova-sqlite-storage/issues/539) + - Not possible to read BLOB column values + - Windows platform version uses `UTF-16le` internal database encoding while the other platform versions use `UTF-8` internal encoding. (`UTF-8` internal encoding is preferred ref: [litehelpers/Cordova-sqlite-storage#652](https://github.com/litehelpers/Cordova-sqlite-storage/issues/652)) +- FTS3, FTS4, and R-Tree support is tested working OK in this version (for all target platforms in this version branch Android/iOS/macOS/Windows) +- Android versions supported: 2.3.3 - 7.1.1 (API level 10 - 25), depending on Cordova version ref: +minimum API level is supported back to SDK 10 (a.k.a. Gingerbread, Android 2.3.3); support for older versions is available upon request. +- iOS versions supported: 8.x / 9.x / 10.x / 11.x - In case of memory issues please use smaller transactions or use the version at [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms). @@ -115,8 +122,8 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - macOS ("osx" platform) is now supported - New [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) version with Android JSON and SQL statement handling implemented in C, as well as support for PhoneGap Build, Intel XDK, etc. (GPL or commercial license terms). Handles large SQL batches in less than half the time as this version. Also supports arbitrary database location on Android. - Published [brodybits / Cordova-quick-start-checklist](https://github.com/brodybits/Cordova-quick-start-checklist) and [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/brodybits/Avoiding-some-Cordova-pitfalls). -- Windows 8.1/Windows Phone 8.1/Windows 10 version is available **here** _(Visual Studio 2015 required, Visual Studio 2017 NOT supported by this version branch)_ as well as in [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) (with pre-populated database support) and [litehelpers / Cordova-sqlite-legacy](https://github.com/litehelpers/Cordova-sqlite-legacy) (with WP8 support). -- Android version _currently uses_ the lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) by default configuration (may be changed as described below) +- Windows 8.1/Windows Phone 8.1/Windows 10 version is available **here** (Visual Studio 2015 required, Visual Studio 2017 NOT supported by this version branch) as well as in [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) (with pre-populated database support) and [litehelpers / Cordova-sqlite-legacy](https://github.com/litehelpers/Cordova-sqlite-legacy) (with WP8 support). +- Android version currently uses the lightweight [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector) by default configuration (may be changed as described below). - Self-test functions to verify proper installation and operation of this plugin - More explicit `openDatabase` and `deleteDatabase` `iosDatabaseLocation` option - Added simple sql batch function @@ -129,13 +136,13 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - Drop-in replacement for HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/): the only change should be to replace the static `window.openDatabase()` factory call with `window.sqlitePlugin.openDatabase()`, with parameters as documented below. - Failure-safe nested transactions with batch processing optimizations (according to HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/)) -- API (based on HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/)) is designed to be as flexible as possible but does not allow the application to leave any transactions hanging open. +- Transaction API (based on HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/)) is designed for maximum flexiblibility, does not allow any transactions to be left hanging open. - As described in [this posting](http://brodyspark.blogspot.com/2012/12/cordovaphonegap-sqlite-plugins-offer.html): - - Keeps sqlite database in a user data location that is known; can be reconfigured (iOS/macOS platform version); and may be synchronized to iCloud (iOS platform version). - - No 5MB maximum, more information at: http://www.sqlite.org/limits.html + - Keeps sqlite database in known, platform specific user data location on all platforms (Android/iOS/macOS/Windows), which can be reconfigured on iOS/macOS. Whether or not the database on the iOS platform is synchronized to iCloud depends on the selected database location. + - No arbitrary size limit. SQLite limits described at: - Also tested for multi-page applications with window location changes -- This project is self-contained (with sqlite3 dependencies auto-fetched by npm); no dependencies on other plugins such as cordova-plugin-file -- Windows 8.1/Windows Phone 8.1/Windows 10 version uses the performant C++ [doo / SQLite3-WinRT](https://github.com/doo/SQLite3-WinRT) component. +- This project is self-contained though with sqlite3 dependencies auto-fetched by npm. There are no dependencies on other plugins such as cordova-plugin-file. +- Windows platform version uses a customized version of the performant [doo / SQLite3-WinRT](https://github.com/doo/SQLite3-WinRT) C++ component. - [SQLCipher](https://www.zetetic.net/sqlcipher/) support for Android/iOS/macOS/Windows is available in: [litehelpers / Cordova-sqlcipher-adapter](https://github.com/litehelpers/Cordova-sqlcipher-adapter) - Intellectual property: - All source code is tracked to the original author in git @@ -152,7 +159,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase - [Trailforks Mountain Bike Trail Map App](http://www.trailforks.com/apps/map/) with a couple of nice videos at: - [Get It Done app](http://getitdoneapp.com/) by [marcucio.com](http://marcucio.com/) - [KAAHE Health Encyclopedia](http://www.kaahe.org/en/index.php?option=com_content&view=article&id=817): Official health app of the Kingdom of Saudi Arabia. -- [Larkwire](http://www.larkwire.com/) (iOS version): Learn bird songs the fun way +- [Larkwire](http://www.larkwire.com/) (iOS platform): Learn bird songs the fun way - [Tangorin](https://play.google.com/store/apps/details?id=com.tangorin.app) (Android) Japanese Dictionary at [tangorin.com](http://tangorin.com/) @@ -188,10 +195,10 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww - iOS/macOS platform version does not support certain rapidly repeated open-and-close or open-and-delete test scenarios due to how the implementation handles background processing - As described below, auto-vacuum is NOT enabled by default. - 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) -- INSERT statement that affects multiple rows (due to SELECT cause or using TRIGGER(s), for example) does not report proper rowsAffected on Android +- Execution of INSERT statement that affects multiple rows (due to SELECT cause or using TRIGGER(s), for example) reports incorrect rowsAffected on Android in case the built-in Android database used (using the `androidDatabaseImplementation` option in `window.sqlitePlugin.openDatabase`) - Memory issue observed when adding a large number of records due to the JSON implementation which is improved in [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms) - Infinity (positive or negative) values are not supported on Android/iOS/macOS due to issues described above including a possible crash on iOS/macOS ref: [litehelpers/Cordova-sqlite-storage#405](https://github.com/litehelpers/Cordova-sqlite-storage/issues/405) -- A stability issue was reported on the iOS version when in use together with [SockJS](http://sockjs.org/) client such as [pusher-js](https://github.com/pusher/pusher-js) at the same time (see [litehelpers/Cordova-sqlite-storage#196](https://github.com/litehelpers/Cordova-sqlite-storage/issues/196)). The workaround is to call sqlite functions and [SockJS](http://sockjs.org/) client functions in separate ticks (using setTimeout with 0 timeout). +- A stability issue was reported on the iOS platform version when in use together with [SockJS](http://sockjs.org/) client such as [pusher-js](https://github.com/pusher/pusher-js) at the same time (see [litehelpers/Cordova-sqlite-storage#196](https://github.com/litehelpers/Cordova-sqlite-storage/issues/196)). The workaround is to call sqlite functions and [SockJS](http://sockjs.org/) client functions in separate ticks (using setTimeout with 0 timeout). - If a sql statement fails for which there is no error handler or the error handler does not return `false` to signal transaction recovery, the plugin fires the remaining sql callbacks before aborting the transaction. - In case of an error, the error `code` member is bogus on _Android and Windows_. - Possible crash on Android when using Unicode emoji and other 4-octet UTF-8 characters due to [Android bug 81341](https://code.google.com/p/android/issues/detail?id=81341), which *should* be fixed in Android 6.x @@ -200,9 +207,6 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww - It is NOT possible to open multiple databases with the same name but in different locations (iOS/macOS platform version). - Incorrect or missing insertId/rowsAffected in results for INSERT/UPDATE/DELETE SQL statements with extra semicolon(s) in the beginning for Android (android.database implementation) - readTransaction does *not* reject modification SQL statements with extra semicolon(s) in the beginning -- Problems reported with PhoneGap Build in the past: - - PhoneGap Build Hydration. - - Apparently FIXED: ~~PhoneGap Build may fail to build the iOS version unless the name of the app starts with an uppercase and contains no spaces (see [litehelpers/Cordova-sqlite-storage#243](https://github.com/litehelpers/Cordova-sqlite-storage/issues/243); [Wizcorp/phonegap-facebook-plugin#830](https://github.com/Wizcorp/phonegap-facebook-plugin/issues/830); [phonegap/build#431](https://github.com/phonegap/build/issues/431)).~~ Issues fixed in some newer version branches: - In case of an error, the error `code` member is bogus on Android @@ -220,19 +224,21 @@ Issues fixed in some newer version branches: - ~~The db version, display name, and size parameter values are not supported and will be ignored.~~ (No longer supported by the API) - Absolute and relative subdirectory path(s) are not tested or supported. - This plugin will not work before the callback for the 'deviceready' event has been fired, as described in **Usage**. (This is consistent with the other Cordova plugins.) -- Extremely large records are not supported by this plugin version. TBD: specify maximum record; FUTURE TBD: to be fixed in [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms). +- Extremely large records are not supported by this plugin. It is recommended to store images and similar binary data in separate files. TBD: specify maximum record. For future consideration: support in a version such as [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (available with GPL or commercial license options) - This plugin version will not work within a web worker (not properly supported by the Cordova framework). Use within a web worker is supported for Android/iOS in [litehelpers / cordova-sqlite-evmax-ext-workers-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evmax-ext-workers-legacy-build-free) (GPL or premium commercial license terms). - In-memory database `db=window.sqlitePlugin.openDatabase({name: ':memory:', ...})` is currently not supported. -- The Android version cannot work with more than 100 open db files (due to the threading model used). -- UNICODE `\u2028` (line separator) and `\u2029` (paragraph separator) characters are not supported and known to be broken on iOS, macOS, and Android platforms due to JSON issues reported in [Cordova bug CB-9435](https://issues.apache.org/jira/browse/CB-9435) and [cordova/cordova-discuss#57](https://github.com/cordova/cordova-discuss/issues/57). There *may* be a similar issue with certain other UNICODE characters in the iOS/macOS version (needs further investigation). This is fixed for iOS in [litehelpers / cordova-sqlite-evplus-ext-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evplus-ext-legacy-build-free) and [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (GPL or special commercial license terms) as well as [litehelpers / cordova-sqlite-evmax-ext-workers-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evmax-ext-workers-legacy-build-free) (GPL or premium commercial license terms). -- The BLOB data type is not fully supported by this version branch. SELECT BLOB in Base64 format is supported by [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) (permissive license terms) and [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms). +- The Android platform version cannot properly support more than 100 open database files due to the threading model used. +- SQL error messages reported by Windows platform version are not consistent with Android/iOS/macOS platform versions. +- UNICODE `\u2028` (line separator) and `\u2029` (paragraph separator) characters are not supported and known to be broken on iOS, macOS, and Android platform versions due to JSON issues reported in [Cordova bug CB-9435](https://issues.apache.org/jira/browse/CB-9435) and [cordova/cordova-discuss#57](https://github.com/cordova/cordova-discuss/issues/57). +- UNICODE `\u2028` (line separator) and `\u2029` (paragraph separator) characters are currently not supported and known to be broken on iOS, macOS, and Android platform versions due to JSON issues reported in [Cordova bug CB-9435](https://issues.apache.org/jira/browse/CB-9435) and [cordova/cordova-discuss#57](https://github.com/cordova/cordova-discuss/issues/57). This is fixed with a workaround for iOS/macOS in: [litehelpers / Cordova-sqlite-evplus-legacy-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-free) and [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (available with GPL or special commercial license options) as well as [litehelpers / Cordova-sqlite-evplus-legacy-workers-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-workers-free) (available with GPL or premium commercial license options) +- The BLOB data type is not fully supported by this version branch. SELECT BLOB in Base64 format is supported by [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) (permissive license terms) and [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license options). - Truncation in case of UNICODE `\u0000` (same as `\0`) character on Android (default Android-sqlite-connector database implementation) and Windows. - Case-insensitive matching and other string manipulations on Unicode characters, which is provided by optional ICU integration in the sqlite source and working with recent versions of Android, is not supported for any target platforms. -- iOS/macOS platform version uses a thread pool but with only one thread working at a time due to "synchronized" database access +- The iOS/macOS platform version uses a thread pool but with only one thread working at a time due to "synchronized" database access - Some large query results may be slow, also due to the JSON implementation. - ATTACH to another database file is not supported by this version branch. Attach/detach is supported (along with the memory and iOS UNICODE `\u2028` line separator / `\u2029` paragraph separator fixes) in [litehelpers / Cordova-sqlite-evplus-legacy-attach-detach-free](https://github.com/litehelpers/Cordova-sqlite-evplus-legacy-attach-detach-free) (available with GPL or special commercial license terms). - UPDATE/DELETE with LIMIT or ORDER BY is not supported. -- WITH clause is not supported by some older Android/iOS versions. +- WITH clause is not supported on some older Android platform versions in case the `androidDatabaseImplementation: 2` (built-in android.database implementation) option is used. - User-defined savepoints are not supported and not expected to be compatible with the transaction locking mechanism used by this plugin. In addition, the use of BEGIN/COMMIT/ROLLBACK statements is not supported. - Problems have been reported when using this plugin with Crosswalk (for Android). It may help to install Crosswalk as a plugin instead of using Crosswalk to create the project. - Does not work with [axemclion / react-native-cordova-plugin](https://github.com/axemclion/react-native-cordova-plugin) since the `window.sqlitePlugin` object is *not* properly exported (ES5 feature). It is recommended to use [andpor / react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage) for SQLite database access with React Native Android/iOS instead. @@ -322,7 +328,7 @@ Documented in: [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/b - Adaptation for React Native Android and iOS: [andpor / react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage) (permissive license terms) - Original version for iOS (with a non-standard, outdated transaction API): [davibe / Phonegap-SQLitePlugin](https://github.com/davibe/Phonegap-SQLitePlugin) (permissive license terms) - + ### Other SQLite adapter projects @@ -344,7 +350,6 @@ Documented in: [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/b - Use [phearme / cordova-ContentProviderPlugin](https://github.com/phearme/cordova-ContentProviderPlugin) to query content providers on Android devices - [ABB-Austin / cordova-plugin-indexeddb-async](https://github.com/ABB-Austin/cordova-plugin-indexeddb-async) - Asynchronous IndexedDB plugin for Cordova that uses [axemclion / IndexedDBShim](https://github.com/axemclion/IndexedDBShim) (Browser/iOS/Android/Windows) and [Thinkwise / cordova-plugin-websql](https://github.com/Thinkwise/cordova-plugin-websql) - (Windows) -- Another sqlite binding for React-Native (iOS version): [almost/react-native-sqlite](https://github.com/almost/react-native-sqlite) - Use [NativeScript](https://www.nativescript.org) with its web view and [NathanaelA / nativescript-sqlite](https://github.com/Natha naelA/nativescript-sqlite) (Android and/or iOS) - Standard HTML5 [local storage](https://en.wikipedia.org/wiki/Web_storage#localStorage) @@ -362,7 +367,7 @@ To verify that both the Javascript and native part of this plugin are installed window.sqlitePlugin.echoTest(successCallback, errorCallback); ``` -To verify that this plugin is able to open, populate, read, update, and delete a test database (named `___$$$___litehelpers___$$$___test___$$$___.db`) properly: +To verify that this plugin is able to open a database (named `___$$$___litehelpers___$$$___test___$$$___.db`), execute the CRUD (create, read, update, and delete) operations, and clean it up properly: ```js window.sqlitePlugin.selfTest(successCallback, errorCallback); @@ -372,7 +377,7 @@ window.sqlitePlugin.selfTest(successCallback, errorCallback); ## General -- Drop-in replacement for HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/): the only change should be to replace the static `window.openDatabase()` factory call with `window.sqlitePlugin.openDatabase()`, with parameters as documented below. (Some known deviations are documented in newer version branches.) +- Drop-in replacement for HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/): the only change should be to replace the static `window.openDatabase()` factory call with `window.sqlitePlugin.openDatabase()`, with parameters as documented below. Some known deviations are documented in TBD newer version branches. Reports of any additional deviations would be appreciated. - Single-page application design is recommended. - In case of a multi-page application the JavaScript used by each page must use `sqlitePlugin.openDatabase` to open the database access handle object before it can access the data. @@ -467,7 +472,7 @@ window.openDatabase = function(dbname, ignored1, ignored2, ignored3) { By default, this plugin uses [Android-sqlite-connector](https://github.com/liteglue/Android-sqlite-connector), which is lightweight and should be more efficient than the built-in Android database classes. To use the built-in Android database classes instead: ```js -var db = window.sqlitePlugin.openDatabase({name: "my.db", androidDatabaseImplementation: 2}); +var db = window.sqlitePlugin.openDatabase({name: 'my.db', location: 'default', androidDatabaseImplementation: 2}); ``` **IMPORTANT:** @@ -476,7 +481,7 @@ var db = window.sqlitePlugin.openDatabase({name: "my.db", androidDatabaseImpleme ### Workaround for Android db locking issue -[litehelpers/Cordova-sqlite-storage#193](https://github.com/litehelpers/Cordova-sqlite-storage/issues/193) reported (as observed by several app developers) that certain versions of the Android database classes, if the app is stopped or aborted without closing the database then: +[litehelpers/Cordova-sqlite-storage#193](https://github.com/litehelpers/Cordova-sqlite-storage/issues/193) reported (as observed by a number of app developers in the past) that when using the `androidDatabaseImplementation: 2` setting on certain Android versions and if the app is stopped or aborted without closing the database then: - (sometimes) there is an unexpected database lock - the data that was inserted is lost. @@ -658,7 +663,7 @@ db.readTransaction(function(tx) { The threading model depends on which version is used: - For Android, one background thread per db; -- for _iOS/macOS_, background processing using a very limited thread pool (only one thread working at a time); +- for iOS/macOS, background processing using a very limited thread pool (only one thread working at a time); - for Windows, no background processing. @@ -804,7 +809,7 @@ db.executeSql("SELECT LENGTH('tenletters') AS stringlength", [], function (res) }); ``` -**SECOND BUG:** When a database connection is closed, any queued transactions are left hanging. All pending transactions should be errored when a database connection is closed. +**SECOND BUG:** When a database connection is closed, any queued transactions are left hanging. TODO: All pending transactions should be errored whenever a database connection is closed. **NOTE:** As described above, if multiple database access handle objects are opened for the same database and one database handle access object is closed, the database is no longer available for the other database handle objects. Possible workarounds: - It is still possible to open one or more new database handle objects on a database that has been closed. @@ -902,7 +907,7 @@ cordova platform add ios - `www`: `SQLitePlugin.js` platform-independent Javascript as generated from `SQLitePlugin.coffee.md` (and checked in!) - `src`: platform-specific source code - `spec`: test suite using Jasmine (2.2.0) -- `tests`: very simple Jasmine test suite that is run on Circle CI (Android version) and Travis CI (iOS version) (used as a placeholder) +- `tests`: very simple Jasmine test suite that is run on Circle CI (Android platform) and Travis CI (iOS platform) (used as a placeholder) ## Installation test From 65fc769ebb67c705f92c9886c0df531408cd0dad Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 7 Nov 2017 14:50:36 -0500 Subject: [PATCH 11/11] Suppress warnings for sqlite3.c & PSPDFThreadSafeMutableDictionary.m on iOS/macOS Thanks to @cjpearson for the suggestion in litehelpers/Cordova-sqlite-storage#569 --- CHANGES.md | 4 ++++ package.json | 2 +- plugin.xml | 12 +++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 42296867f..d41aebf8a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +##### cordova-sqlite-legacy-core 1.0.3 + +- Suppress warnings when building sqlite3.c & PSPDFThreadSafeMutableDictionary.m on iOS/macOS + ##### cordova-sqlite-legacy-core 1.0.2 - Fix log in case of transaction waiting for open to finish; doc fixes diff --git a/package.json b/package.json index b9f16b409..90ac5281e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-core", - "version": "1.0.2", + "version": "1.0.3", "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 13af87aec..961559845 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.3"> Cordova sqlite storage plugin - legacy core version branch @@ -56,11 +56,12 @@ - + + 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" /> @@ -76,11 +77,12 @@ - + + 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" />