Skip to content

Commit

Permalink
PARTIALLY Revert "Workaround solution to BUG storesafe/cordova-sqlite…
Browse files Browse the repository at this point in the history
…-storage#666"

PARTIALLY reverts commit a760cc6.

(REMOVED OLD WORKAROUND SOLUTION to BUG 666;
new workaround solution also not wanted.)
  • Loading branch information
Christopher J. Brody committed Feb 4, 2018
1 parent 50600d3 commit 8ed1caf
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 101 deletions.
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Changes

## cordova-sqlite-evmax-ext-workers-legacy-build-free 0.1.1-fix1
## cordova-sqlite-evmax-ext-workers-legacy-build-free 0.1.1-fix2

TBD
- Revert unwanted BUG 666 workaround solution

## cordova-sqlite-evmax-ext-workers-legacy-build-free 0.1.0

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ _NOTE: Commercial licenses for Cordova-sqlite-enterprise-free purchased before J
TBD: no Circle CI or Travis CI working in this version branch.
-->

<!-- XXX SKIP FOR NOW:
## About this version branch
_Proof of concept with *very basic* support for web workers (Android/iOS/macOS ONLY)._
-->

<!-- END About this version branch -->

## DATA LOSS RISK WARNING IN MULTI-PAGE APPS

_This plugin version suffers from a data loss risk in case of multi-page apps as discussed in <https://github.com/litehelpers/Cordova-sqlite-storage/issues/666>. Workaround solution in cordova-sqlite-storage is problematic in this plugin version in case of access from both main and worker threads._

## IMPORTANT API DEPRECATION NOTICE

The following API calls are now deprecated and may be removed in the near future (ref [litehelpers / cordova-sqlite-evplus-legacy-workers-free#5](https://github.com/litehelpers/cordova-sqlite-evplus-legacy-workers-free/issues/5)):
Expand Down Expand Up @@ -163,7 +169,6 @@ TBD test:

- Windows 10 (UWP) build with /SAFESEH flag on Win32 (x86) target to specify "Image has Safe Exception Handlers" as described in <https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers>
- 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).
Expand Down Expand Up @@ -254,6 +259,7 @@ As "strongly recommended" by [Web SQL Database API 8.5 SQL injection](https://ww

## Known issues

- XXX POSSIBLE Transaction problem after page change WITH POSSIBLE DATA LOSS ref: [litehelpers/Cordova-sqlite-storage#666](https://github.com/litehelpers/Cordova-sqlite-storage/issues/666)
- 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)
Expand Down
73 changes: 49 additions & 24 deletions SQLitePlugin.coffee.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,12 @@
# 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

# XXX NO UNWANTED WORKAROUND SOLUTION for
# BUG litehelpers/Cordova-sqlite-storage#666
# in this plugin version as discussed in
# https://github.com/litehelpers/cordova-sqlite-evmax-ext-workers-legacy-build-free/issues/7
# nextTick =>
if (true)
if isWorker
aqrequest 'sq', 'open', (encodeURIComponent (JSON.stringify [@openargs])), (s) ->
if s == 'a1'
Expand Down Expand Up @@ -1005,20 +997,53 @@
# TX SHOULD SUCCEED to demonstrate solution to BUG litehelpers/Cordova-sqlite-storage#666:
db.transaction (tx) ->
tx.executeSql 'SELECT ? AS myResult', [null], (ignored, resutSet) ->
if !resutSet.rows
return SelfTest.finishWithError errorcb, 'Missing resutSet.rows'
if !resutSet.rows.length
return SelfTest.finishWithError errorcb, 'Missing resutSet.rows.length'
if resutSet.rows.length isnt 1
return SelfTest.finishWithError errorcb,
"Incorrect resutSet.rows.length value: #{resutSet.rows.length} (expected: 1)"
SelfTest.step3 successcb, errorcb
# XXX TBD IGNORED FOR NOW:
# if !resutSet.rows
# return SelfTest.finishWithError errorcb, 'Missing resutSet.rows'
# if !resutSet.rows.length
# return SelfTest.finishWithError errorcb, 'Missing resutSet.rows.length'
# if resutSet.rows.length isnt 1
# return SelfTest.finishWithError errorcb,
# "Incorrect resutSet.rows.length value: #{resutSet.rows.length} (expected: 1)"
# SelfTest.step3 successcb, errorcb
return
return

, (txError) ->
# NOT EXPECTED:
return SelfTest.finishWithError errorcb, "UNEXPECTED TRANSACTION ERROR: #{txError}"
# XXX
# EXPECTED RESULT DUE TO BUG litehelpers/Cordova-sqlite-storage#666:
if !txError
return SelfTest.finishWithError errorcb, 'Missing txError object'
# second try should work:
db.transaction (tx2) ->
tx2.executeSql 'SELECT ? AS myResult', [null], (ignored, resutSet) ->
if !resutSet.rows
return SelfTest.finishWithError errorcb, 'Missing resutSet.rows'
if !resutSet.rows.length
return SelfTest.finishWithError errorcb, 'Missing resutSet.rows.length'
if resutSet.rows.length isnt 1
return SelfTest.finishWithError errorcb,
SelfTest.step3 successcb, errorcb
return
return
, (tx2_err) ->
return SelfTest.finishWithError errorcb, "UNEXPECTED TRANSACTION ERROR: #{tx2_err}"
return

, () ->
# XXX
# TX SUCCESS POSSIBLE FOR Android (android.database) ONLY
# NOTE: Windows 10 (UWP) mobile platform also shows "Android" in navigator.userAgent,
# filtered out here.
# FUTURE TBD android.database implementation should be fixed to report error in this case.
# XXX GONE:
# if /Android/.test(navigator.userAgent) and not /Windows /.test(navigator.userAgent)
# return SelfTest.step3 successcb, errorcb
# OTHERWISE:
# TX SUCCESS NOT EXPECTED DUE TO BUG litehelpers/Cordova-sqlite-storage#666:
return SelfTest.finishWithError errorcb, 'UNEXPECTED SUCCESS ref: litehelpers/Cordova-sqlite-storage#666'
return

, (open_err) ->
SelfTest.finishWithError errorcb, "Open database error: #{open_err}"
return
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-sqlite-evmax-ext-workers-legacy-build-free",
"version": "0.1.1-fix1",
"version": "0.1.1-fix2",
"description": "Native interface to SQLite for PhoneGap/Cordova - evmax legacy workers - premium enterprise version with legacy support for web workers",
"cordova": {
"id": "cordova-sqlite-evmax-ext-workers-legacy-build-free",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-sqlite-evmax-ext-workers-legacy-build-free"
version="0.1.1-fix1">
version="0.1.1-fix2">

<name>Cordova sqlite storage - evmax legacy workers - premium enterprise version with legacy support for web workers</name>

Expand Down
71 changes: 35 additions & 36 deletions spec/www/spec/SQLitePlugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
License for this version: GPL v3 (http://www.gnu.org/licenses/gpl.txt) or commercial license.
Contact for commercial license: [email protected]
Expand Down Expand Up @@ -249,28 +248,19 @@ Contact for commercial license: [email protected]
};
})(this);
this.openDBs[this.dbname] = DB_STATE_INIT;
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));
}
if (isWorker) {
return aqrequest('sq', 'open', encodeURIComponent(JSON.stringify([_this.openargs])), function(s) {
if (s === 'a1') {
return opensuccesscb(s);
} else {
return openerrorcb();
}
});
} else {
return root.sqlitePluginHelper.exec('open', [_this.openargs], opensuccesscb, openerrorcb);
}
};
})(this));
if (true) {
if (isWorker) {
aqrequest('sq', 'open', encodeURIComponent(JSON.stringify([this.openargs])), function(s) {
if (s === 'a1') {
return opensuccesscb(s);
} else {
return openerrorcb();
}
});
} else {
root.sqlitePluginHelper.exec('open', [this.openargs], opensuccesscb, openerrorcb);
}
}
}
};

Expand Down Expand Up @@ -909,20 +899,29 @@ Contact for commercial license: [email protected]
location: 'default'
}, function(db) {
db.transaction(function(tx) {
tx.executeSql('SELECT ? AS myResult', [null], function(ignored, resutSet) {
if (!resutSet.rows) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows');
}
if (!resutSet.rows.length) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.length');
}
if (resutSet.rows.length !== 1) {
return SelfTest.finishWithError(errorcb, "Incorrect resutSet.rows.length value: " + resutSet.rows.length + " (expected: 1)");
}
SelfTest.step3(successcb, errorcb);
});
tx.executeSql('SELECT ? AS myResult', [null], function(ignored, resutSet) {});
}, function(txError) {
return SelfTest.finishWithError(errorcb, "UNEXPECTED TRANSACTION ERROR: " + txError);
if (!txError) {
return SelfTest.finishWithError(errorcb, 'Missing txError object');
}
db.transaction(function(tx2) {
tx2.executeSql('SELECT ? AS myResult', [null], function(ignored, resutSet) {
if (!resutSet.rows) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows');
}
if (!resutSet.rows.length) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.length');
}
if (resutSet.rows.length !== 1) {
return SelfTest.finishWithError(errorcb);
}
SelfTest.step3(successcb, errorcb);
});
}, function(tx2_err) {
return SelfTest.finishWithError(errorcb, "UNEXPECTED TRANSACTION ERROR: " + tx2_err);
});
}, function() {
return SelfTest.finishWithError(errorcb, 'UNEXPECTED SUCCESS ref: litehelpers/Cordova-sqlite-storage#666');
});
}, function(open_err) {
return SelfTest.finishWithError(errorcb, "Open database error: " + open_err);
Expand Down
71 changes: 35 additions & 36 deletions www/SQLitePlugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
License for this version: GPL v3 (http://www.gnu.org/licenses/gpl.txt) or commercial license.
Contact for commercial license: [email protected]
Expand Down Expand Up @@ -249,28 +248,19 @@ Contact for commercial license: [email protected]
};
})(this);
this.openDBs[this.dbname] = DB_STATE_INIT;
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));
}
if (isWorker) {
return aqrequest('sq', 'open', encodeURIComponent(JSON.stringify([_this.openargs])), function(s) {
if (s === 'a1') {
return opensuccesscb(s);
} else {
return openerrorcb();
}
});
} else {
return root.sqlitePluginHelper.exec('open', [_this.openargs], opensuccesscb, openerrorcb);
}
};
})(this));
if (true) {
if (isWorker) {
aqrequest('sq', 'open', encodeURIComponent(JSON.stringify([this.openargs])), function(s) {
if (s === 'a1') {
return opensuccesscb(s);
} else {
return openerrorcb();
}
});
} else {
root.sqlitePluginHelper.exec('open', [this.openargs], opensuccesscb, openerrorcb);
}
}
}
};

Expand Down Expand Up @@ -909,20 +899,29 @@ Contact for commercial license: [email protected]
location: 'default'
}, function(db) {
db.transaction(function(tx) {
tx.executeSql('SELECT ? AS myResult', [null], function(ignored, resutSet) {
if (!resutSet.rows) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows');
}
if (!resutSet.rows.length) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.length');
}
if (resutSet.rows.length !== 1) {
return SelfTest.finishWithError(errorcb, "Incorrect resutSet.rows.length value: " + resutSet.rows.length + " (expected: 1)");
}
SelfTest.step3(successcb, errorcb);
});
tx.executeSql('SELECT ? AS myResult', [null], function(ignored, resutSet) {});
}, function(txError) {
return SelfTest.finishWithError(errorcb, "UNEXPECTED TRANSACTION ERROR: " + txError);
if (!txError) {
return SelfTest.finishWithError(errorcb, 'Missing txError object');
}
db.transaction(function(tx2) {
tx2.executeSql('SELECT ? AS myResult', [null], function(ignored, resutSet) {
if (!resutSet.rows) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows');
}
if (!resutSet.rows.length) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.length');
}
if (resutSet.rows.length !== 1) {
return SelfTest.finishWithError(errorcb);
}
SelfTest.step3(successcb, errorcb);
});
}, function(tx2_err) {
return SelfTest.finishWithError(errorcb, "UNEXPECTED TRANSACTION ERROR: " + tx2_err);
});
}, function() {
return SelfTest.finishWithError(errorcb, 'UNEXPECTED SUCCESS ref: litehelpers/Cordova-sqlite-storage#666');
});
}, function(open_err) {
return SelfTest.finishWithError(errorcb, "Open database error: " + open_err);
Expand Down

0 comments on commit 8ed1caf

Please sign in to comment.