diff --git a/CHANGES.md b/CHANGES.md index d41aebf8a..8e9372129 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +##### cordova-sqlite-legacy-core 1.0.4 + +- New workaround solution to BUG 666: close db before opening (ignore close error) + ##### cordova-sqlite-legacy-core 1.0.3 - Suppress warnings when building sqlite3.c & PSPDFThreadSafeMutableDictionary.m on iOS/macOS diff --git a/README.md b/README.md index f46fe9386..24c3df237 100644 --- a/README.md +++ b/README.md @@ -111,9 +111,9 @@ minimum API level is supported back to SDK 10 (a.k.a. Gingerbread, Android 2.3.3 ## Announcements +- New 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): attempt to close database before opening (ignore close error) - 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. - The Lawnchair adapter is now moved to [litehelpers / cordova-sqlite-lawnchair-adapter](https://github.com/litehelpers/cordova-sqlite-lawnchair-adapter). - [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) now supports SELECT BLOB data in Base64 format on all platforms in addition to REGEXP (Android/iOS/macOS) and pre-populated database (all platforms). diff --git a/SQLitePlugin.coffee.md b/SQLitePlugin.coffee.md index dccb55d84..d9ffc12ab 100644 --- a/SQLitePlugin.coffee.md +++ b/SQLitePlugin.coffee.md @@ -250,22 +250,15 @@ # store initial DB state: @openDBs[@dbname] = DB_STATE_INIT - # 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. - nextTick => - if not txLocks[@dbname] - myfn = (tx) -> - tx.addStatement 'ROLLBACK' - return - @addTransaction new SQLitePluginTransaction @, myfn, null, null, false, false - + # NEW WORKAROUND SOLUTION to BUG litehelpers/Cordova-sqlite-storage#666: + # Request to native implementation to close existing database + # connection if it is already open. Wait for success or error + # response before opening the database. + openStep2 = => cordova.exec opensuccesscb, openerrorcb, "SQLitePlugin", "open", [ @openargs ] + cordova.exec openStep2, openStep2, 'SQLitePlugin', 'close', [ { path: @dbname } ] + return SQLitePlugin::close = (success, error) -> diff --git a/package.json b/package.json index 90ac5281e..7addf8dd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-core", - "version": "1.0.3", + "version": "1.0.4", "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 961559845..2121bc60a 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.4"> Cordova sqlite storage plugin - legacy core version branch diff --git a/spec/www/spec/db-open-close-delete-test.js b/spec/www/spec/db-open-close-delete-test.js index 31d710f8c..b40012e44 100755 --- a/spec/www/spec/db-open-close-delete-test.js +++ b/spec/www/spec/db-open-close-delete-test.js @@ -272,7 +272,7 @@ var mytests = function() { test_it(suiteName + ' database.close (immediately after open) calls its success callback', 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)'); + if (!isAndroid && !isWindows && !isWP8) pending('CURRENTLY BROKEN on iOS/macOS (background processing implementation)'); // asynch test coming up stop(1); @@ -577,10 +577,7 @@ 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 ... - // if (!isAndroid && !isWindows && !isWP8) pending(...); - // TBD CURRENTLY BROKEN DUE TO BUG 666 WORKAROUND HACK - pending('CURRENTLY BROKEN DUE TO BUG 666 WORKAROUND HACK'); + if (!isAndroid && !isWindows && !isWP8) pending('CURRENTLY BROKEN on iOS/macOS (background processing implementation)'); var dbName = "Immediate-close-delete-Reopen.db"; var dbargs = {name: dbName, location: 'default'}; @@ -850,8 +847,8 @@ var mytests = function() { test_it(suiteName + ' repeatedly open and delete database faster (5x)', function () { // 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'); + // TBD CURRENTLY BROKEN DUE TO BUG 666 WORKAROUND SOLUTION + pending('CURRENTLY BROKEN DUE TO BUG 666 WORKAROUND SOLUTION'); 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 51dee0cf5..a605e7883 100644 --- a/www/SQLitePlugin.js +++ b/www/SQLitePlugin.js @@ -162,7 +162,7 @@ }; SQLitePlugin.prototype.open = function(success, error) { - var openerrorcb, opensuccesscb; + var openStep2, openerrorcb, opensuccesscb; if (this.dbname in this.openDBs) { console.log('database already open: ' + this.dbname); nextTick((function(_this) { @@ -202,18 +202,16 @@ }; })(this); this.openDBs[this.dbname] = DB_STATE_INIT; - nextTick((function(_this) { + openStep2 = (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)); + })(this); + cordova.exec(openStep2, openStep2, 'SQLitePlugin', 'close', [ + { + path: this.dbname + } + ]); } };