Skip to content

Commit

Permalink
Merge branch 'cordova-sqlite-legacy-express-core' into cordova-sqlite…
Browse files Browse the repository at this point in the history
…-legacy-core
  • Loading branch information
Christopher J. Brody committed Jan 1, 2018
2 parents 852cff6 + 7572e38 commit b42ad79
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 24 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes

##### cordova-sqlite-legacy-core 1.0.7-pre1

###### cordova-sqlite-legacy-express-core 1.0.5

- iOS/macOS @synchronized guard for sqlite3_open operation
- Signal INTERNAL ERROR in case of attempt to reuse db (Android/iOS) (should never happen due to workaround solution to BUG 666)

##### cordova-sqlite-legacy-core 1.0.6

###### cordova-sqlite-legacy-express-core 1.0.4
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ License terms for Android and Windows platform versions: MIT or Apache 2.0

License terms for iOS/macOS platform version: MIT only

## About this version branch
## About this plugin version branch

This version branch contains the source code for the Android/iOS/macOS/Windows platforms (legacy core version branch).
This _plugin version branch_ contains the source code for the Android/iOS/macOS/Windows platforms (legacy core version branch).

This version branch uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-storage-dependencies` via npm.

Expand All @@ -22,7 +22,7 @@ NOTE: This version branch has some additional known [issues fixed in newer versi

<!-- FUTURE TBD other version-specific bug notices -->

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

## WARNING: Multiple SQLite problem on Android

Expand Down Expand Up @@ -69,7 +69,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase

## Status

- A recent version of the Cordova CLI (such as `6.5.0` or `7.1.0`) is recommended. Cordova versions older than `6.0.0` are missing the `[email protected]` security fixes. In addition it is *required* to use `cordova prepare` in case of cordova-ios older than `4.3.0` (Cordova CLI `6.4.0`).
- A recent version of the Cordova CLI (such as `6.5.0` or `7.1.0`) is recommended. _(TBD issue with cordova-android@7 as included by Cordova 8)_ Cordova versions older than `6.0.0` are missing the `[email protected]` security fixes. In addition it is *required* to use `cordova prepare` in case of cordova-ios older than `4.3.0` (Cordova CLI `6.4.0`).
- This version branch uses a `before_plugin_install` hook to install sqlite3 library dependencies from `cordova-sqlite-storage-dependencies` via npm.
- This plugin will NOT work on `cordova-android@7` due to issue with JAR and NDK library files as discussed in [litehelpers/Cordova-sqlite-storage#729](https://github.com/litehelpers/Cordova-sqlite-storage/issues/729).
- SQLite `3.8.10.2` included when building (all platforms), with the following definitions for iOS/macOS/Windows:
Expand Down Expand Up @@ -111,7 +111,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase
- iOS versions supported: 8.x / 9.x / 10.x / 11.x
- FTS3, FTS4, and R-Tree are fully tested and supported for all target platforms in this version branch.
- Default `PRAGMA journal_mode` setting (*tested*):
- Android (builtin android.database implementation _as selected using the `androidDatabaseImplementation` option in `window.sqlitePlugin.openDatabase`_): `persist`
- Android _pre-8.0_ (builtin android.database implementation _as selected using the `androidDatabaseImplementation` option in `window.sqlitePlugin.openDatabase`_): `persist`
- otherwise: `delete`
- AUTO-VACUUM is not enabled by default. If no form of `VACUUM` or `PRAGMA auto_vacuum` is used then sqlite will automatically reuse deleted data space for new data but the database file will never shrink. For reference: <http://www.sqlite.org/pragma.html#pragma_auto_vacuum> and [litehelpers/Cordova-sqlite-storage#646](https://github.com/litehelpers/Cordova-sqlite-storage/issues/646)
- In case of memory issues please use smaller transactions or use the plugin version at [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) (GPL or commercial license terms).
Expand All @@ -120,7 +120,7 @@ Use the `location` or `iosDatabaseLocation` option in `sqlitePlugin.openDatabase

## Announcements

- Nice overview of this and other alternatives for storing local data at: <https://www.sitepoint.com/storing-local-data-in-a-cordova-app/>
- Nice overview of alternatives for storing local data in Cordova apps at: <https://www.sitepoint.com/storing-local-data-in-a-cordova-app/>
- New alternative solution for small data storage: [TheCocoaProject/ cordova-plugin-nativestorage](https://github.com/TheCocoaProject/cordova-plugin-nativestorage) - simpler "native storage of variables" for Android/iOS/Windows
- Resolved Java 6/7/8 concurrent map compatibility issue reported in [litehelpers/Cordova-sqlite-storage#726](https://github.com/litehelpers/Cordova-sqlite-storage/issues/726), THANKS to pointer by [@NeoLSN (Jason Yang/楊朝傑)](https://github.com/NeoLSN) in [litehelpers/Cordova-sqlite-storage#727](https://github.com/litehelpers/Cordova-sqlite-storage/issues/727).
- Updated workaround solution to [BUG 666 (litehelpers/Cordova-sqlite-storage#666)](https://github.com/litehelpers/Cordova-sqlite-storage/issues/666) (possible transaction issue after window.location change with possible data loss): close database if already open before opening again
Expand Down Expand Up @@ -345,7 +345,8 @@ Documented in: [brodybits / Avoiding-some-Cordova-pitfalls](https://github.com/b

- [litehelpers / Cordova-sqlite-storage](https://github.com/litehelpers/Cordova-sqlite-storage) - core plugin version for Android/iOS/macOS/Windows (permissive license terms)
- [litehelpers / cordova-sqlite-ext](https://github.com/litehelpers/cordova-sqlite-ext) - plugin version with REGEXP (Android/iOS/macOS), SELECT BLOB in Base64 format (all platforms Android/iOS/macOS/Windows), and pre-populated databases (all platforms Android/iOS/macOS/Windows). Permissive license terms.
- [litehelpers / Cordova-sqlite-legacy-build-support](https://github.com/litehelpers/Cordova-sqlite-legacy-build-support) - maintenance of WP8 platform version along with Windows 8.1/Windows Phone 8.1 and the other supported platforms Android/iOS/macOS/Windows 10; limited support for PhoneGap CLI/PhoneGap Build/plugman/Intel XDK; limited testing; limited updates. Permissive license terms.
- [litehelpers / cordova-sqlite-legacy](https://github.com/litehelpers/cordova-sqlite-legacy) - support for Windows 8.1/Windows Phone 8.1 along with Android/iOS/macOS/Windows 10, with support for REGEXP (Android/iOS/macOS), SELECT BLOB in Base64 format (all platforms Android/iOS/macOS/Windows), and pre-populated databases (all platforms Android/iOS/macOS/Windows). Limited updates. Permissive license terms.
- [brodybits / cordova-sqlite-legacy-build-support](https://github.com/brodybits/cordova-sqlite-legacy-build-support) - maintenance of WP8 platform version along with Windows 8.1/Windows Phone 8.1 and the other supported platforms Android/iOS/macOS/Windows 10; limited support for PhoneGap CLI/PhoneGap Build/plugman/Intel XDK; limited testing; limited updates. Permissive license terms.
- [litehelpers / Cordova-sqlcipher-adapter](https://github.com/litehelpers/Cordova-sqlcipher-adapter) - supports [SQLCipher](https://www.zetetic.net/sqlcipher/) for Android/iOS/macOS/Windows
- [litehelpers / Cordova-sqlite-evcore-extbuild-free](https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free) - Enhancements for Android: JSON and SQL statement handling implemented in C, supports larger transactions and handles large SQL batches in less than half the time as this plugin version. Supports arbitrary database location on Android. Support for build environments such as PhoneGap Build and Intel XDK. Also includes REGEXP (Android/iOS/macOS) and SELECT BLOB in Base64 format (all platforms Android/iOS/macOS/Windows). GPL or commercial license terms.
- [litehelpers / cordova-sqlite-evplus-ext-legacy-build-free](https://github.com/litehelpers/cordova-sqlite-evplus-ext-legacy-build-free) - internal memory improvements to support larger transactions (Android/iOS) and fix to support all Unicode characters (iOS). (GPL or special commercial license terms).
Expand Down Expand Up @@ -1071,7 +1072,7 @@ To run from a windows powershell (here is a sample for android target):
- `src`: platform-specific source code
- `node_modules`: placeholder for external dependencies
- `scripts`: installation hook script to fetch the external dependencies via `npm`
- `spec`: test suite using Jasmine
- `spec`: test suite using Jasmine (`2.2.0`)
- `tests`: very simple Jasmine test suite that is run on Circle CI (Android platform) and Travis CI (iOS platform) (used as a placeholder)

<!-- END Source tree -->
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-legacy-core",
"version": "1.0.6",
"version": "1.0.7-pre1",
"description": "Native interface to SQLite for PhoneGap/Cordova (legacy core version branch)",
"cordova": {
"id": "cordova-sqlite-legacy-core",
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-legacy-core"
version="1.0.6">
version="1.0.7-pre1">

<name>Cordova sqlite storage plugin - legacy core version branch</name>

Expand Down
2 changes: 1 addition & 1 deletion src/android/io/sqlc/SQLiteAndroidDatabase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2017: Christopher J. Brody (aka Chris Brody)
* Copyright (c) 2012-2018: Christopher J. Brody (aka Chris Brody)
* Copyright (c) 2005-2010, Nitobi Software Inc.
* Copyright (c) 2010, IBM Corporation
*/
Expand Down
11 changes: 3 additions & 8 deletions src/android/io/sqlc/SQLitePlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2017: Christopher J. Brody (aka Chris Brody)
* Copyright (c) 2012-2018: Christopher J. Brody (aka Chris Brody)
* Copyright (c) 2005-2010, Nitobi Software Inc.
* Copyright (c) 2010, IBM Corporation
*/
Expand Down Expand Up @@ -196,16 +196,11 @@ public void onDestroy() {
// --------------------------------------------------------------------------

private void startDatabase(String dbname, JSONObject options, CallbackContext cbc) {
// TODO: is it an issue that we can orphan an existing thread? What should we do here?
// If we re-use the existing DBRunner it might be in the process of closing...
DBRunner r = dbrmap.get(dbname);

// Brody TODO: It may be better to terminate the existing db thread here & start a new one, instead.
if (r != null) {
// don't orphan the existing thread; just re-open the existing database.
// In the worst case it might be in the process of closing, but even that's less serious
// than orphaning the old DBRunner.
cbc.success();
// NO LONGER EXPECTED due to BUG 666 workaround solution:
cbc.error("INTERNAL ERROR: database already open for db name: " + dbname);
} else {
r = new DBRunner(dbname, options, cbc);
dbrmap.put(dbname, r);
Expand Down
2 changes: 1 addition & 1 deletion src/ios/SQLitePlugin.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2017: Christopher J. Brody (aka Chris Brody)
* Copyright (c) 2012-2018: Christopher J. Brody (aka Chris Brody)
* Copyright (C) 2011 Davide Bertola
*
* This library is available under the terms of the MIT License (2008).
Expand Down
14 changes: 10 additions & 4 deletions src/ios/SQLitePlugin.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2017: Christopher J. Brody (aka Chris Brody)
* Copyright (c) 2012-2018: Christopher J. Brody (aka Chris Brody)
* Copyright (C) 2011 Davide Bertola
*
* This library is available under the terms of the MIT License (2008).
Expand Down Expand Up @@ -117,16 +117,22 @@ -(void)openNow: (CDVInvokedUrlCommand*)command
NSString *dbname = [self getDBPath:dbfilename at:dblocation];

if (dbname == NULL) {
// XXX NOT EXPECTED (INTERNAL ERROR):
NSLog(@"No db name specified for open");
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"You must specify database name"];
}
else {
NSValue *dbPointer = [openDBs objectForKey:dbfilename];

if (dbPointer != NULL) {
NSLog(@"Reusing existing database connection for db name %@", dbfilename);
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Database opened"];
} else {
// NO LONGER EXPECTED due to BUG 666 workaround solution:
NSLog(@"INTERNAL ERROR: database already open for db name: %@ (db file name: %@)", dbname, dbfilename);
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString: @"INTERNAL ERROR: database already open"];
[self.commandDelegate sendPluginResult:pluginResult callbackId: command.callbackId];
return;
}

@synchronized(self) {
const char *name = [dbname UTF8String];
sqlite3 *db;

Expand Down

0 comments on commit b42ad79

Please sign in to comment.