Bug 1470961 - Remove unnecessary use of SQLITE_IGNORE. r=asuth draft
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 26 Jun 2018 13:50:57 +0200
changeset 811217 d5d0c60014199da544893003036fa3371b440c00
parent 810123 4f6e597104dabedfecfafa2ab63dc79fd7f8bc7a
push id114243
push usermak77@bonardo.net
push dateWed, 27 Jun 2018 09:22:24 +0000
reviewersasuth
bugs1470961
milestone62.0a1
Bug 1470961 - Remove unnecessary use of SQLITE_IGNORE. r=asuth MozReview-Commit-ID: GhZzTzLULWp
netwerk/cache/nsDiskCacheDeviceSQL.cpp
storage/mozStorageConnection.cpp
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -43,17 +43,16 @@
 #include "mozIStorageFunction.h"
 #include "mozStorageHelper.h"
 
 #include "nsICacheVisitor.h"
 #include "nsISeekableStream.h"
 
 #include "mozilla/Telemetry.h"
 
-#include "sqlite3.h"
 #include "mozilla/storage.h"
 #include "nsVariant.h"
 #include "mozilla/BasePrincipal.h"
 
 using namespace mozilla;
 using namespace mozilla::storage;
 using mozilla::OriginAttributes;
 
@@ -213,17 +212,19 @@ nsOfflineCacheEvictionFunction::OnFuncti
   const char *key = values->AsSharedUTF8String(1, &valueLen);
   nsAutoCString fullKey(clientID);
   fullKey.Append(':');
   fullKey.Append(key);
   int generation  = values->AsInt32(2);
 
   // If the key is currently locked, refuse to delete this row.
   if (mDevice->IsLocked(fullKey)) {
-    NS_ADDREF(*_retval = new IntegerVariant(SQLITE_IGNORE));
+    // This code thought it was performing the equivalent of invoking the SQL
+    // "RAISE(IGNORE)" function.  It was not.  Please see bug 1470961 and any
+    // follow-ups to understand the plan for correcting this bug.
     return NS_OK;
   }
 
   nsCOMPtr<nsIFile> file;
   rv = GetCacheDataFile(mDevice->CacheDirectory(), key,
                         generation, file);
   if (NS_FAILED(rv))
   {
--- a/storage/mozStorageConnection.cpp
+++ b/storage/mozStorageConnection.cpp
@@ -255,19 +255,17 @@ basicFunctionHelper(sqlite3_context *aCt
 
     NS_WARNING(errorMessage.get());
 
     ::sqlite3_result_error(aCtx, errorMessage.get(), -1);
     ::sqlite3_result_error_code(aCtx, nsresultToSQLiteResult(rv));
     return;
   }
   int retcode = variantToSQLiteT(aCtx, result);
-  if (retcode == SQLITE_IGNORE) {
-    ::sqlite3_result_int(aCtx, SQLITE_IGNORE);
-  } else if (retcode != SQLITE_OK) {
+  if (retcode != SQLITE_OK) {
     NS_WARNING("User function returned invalid data type!");
     ::sqlite3_result_error(aCtx,
                            "User function returned invalid data type",
                            -1);
   }
 }
 
 void