From 9cc042f9a280acd5c3e5060fbb596a31274d2cff Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 1 Jan 2018 17:17:09 -0500 Subject: [PATCH] Signal INTERNAL ERROR in case of attempt to reuse db (Android/iOS) Should never happen due to workaround solution to litehelpers/Cordova-sqlite-storage#666 --- CHANGES.md | 4 ++-- package.json | 2 +- plugin.xml | 2 +- src/android/io/sqlc/SQLitePlugin.java | 9 ++------- src/ios/SQLitePlugin.m | 6 ++++-- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 06d200f3e..cf9773f67 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,8 @@ # Changes -###### cordova-sqlite-legacy-express-core 1.0.5-pre01 +###### cordova-sqlite-legacy-express-core 1.0.5-pre02 -TBD +- Signal INTERNAL ERROR in case of attempt to reuse db (Android/iOS) (should never happen due to workaround solution to BUG 666) ###### cordova-sqlite-legacy-express-core 1.0.4 diff --git a/package.json b/package.json index b8807e4cb..9c4a2b47e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-sqlite-legacy-express-core", - "version": "1.0.5-pre01", + "version": "1.0.5-pre02", "description": "Native interface to SQLite for PhoneGap/Cordova (legacy express core version)", "cordova": { "id": "cordova-sqlite-legacy-express-core", diff --git a/plugin.xml b/plugin.xml index f73a90842..aecd531ad 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.0.5-pre02"> Cordova sqlite storage plugin - legacy express core version diff --git a/src/android/io/sqlc/SQLitePlugin.java b/src/android/io/sqlc/SQLitePlugin.java index ca6a907fd..6b49e3376 100755 --- a/src/android/io/sqlc/SQLitePlugin.java +++ b/src/android/io/sqlc/SQLitePlugin.java @@ -196,16 +196,11 @@ public void onDestroy() { // -------------------------------------------------------------------------- private void startDatabase(String dbname, JSONObject options, CallbackContext cbc) { - // TODO: is it an issue that we can orphan an existing thread? What should we do here? - // If we re-use the existing DBRunner it might be in the process of closing... DBRunner r = dbrmap.get(dbname); - // Brody TODO: It may be better to terminate the existing db thread here & start a new one, instead. if (r != null) { - // don't orphan the existing thread; just re-open the existing database. - // In the worst case it might be in the process of closing, but even that's less serious - // than orphaning the old DBRunner. - cbc.success(); + // NO LONGER EXPECTED due to BUG 666 workaround solution: + cbc.error("INTERNAL ERROR: database already open for db name: " + dbname); } else { r = new DBRunner(dbname, options, cbc); dbrmap.put(dbname, r); diff --git a/src/ios/SQLitePlugin.m b/src/ios/SQLitePlugin.m index 43a704c53..6575b4902 100755 --- a/src/ios/SQLitePlugin.m +++ b/src/ios/SQLitePlugin.m @@ -117,6 +117,7 @@ -(void)openNow: (CDVInvokedUrlCommand*)command NSString *dbname = [self getDBPath:dbfilename at:dblocation]; if (dbname == NULL) { + // XXX NOT EXPECTED (INTERNAL ERROR): NSLog(@"No db name specified for open"); pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"You must specify database name"]; } @@ -124,8 +125,9 @@ -(void)openNow: (CDVInvokedUrlCommand*)command NSValue *dbPointer = [openDBs objectForKey:dbfilename]; if (dbPointer != NULL) { - NSLog(@"Reusing existing database connection for db name %@", dbfilename); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Database opened"]; + // NO LONGER EXPECTED due to BUG 666 workaround solution: + NSLog(@"INTERNAL ERROR: database already open for db name: %@ (db file name: %@)", dbname, dbfilename); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString: @"INTERNAL ERROR: database already open"]; } else { const char *name = [dbname UTF8String]; sqlite3 *db;