--- a/storage/build/mozStorageCID.h
+++ b/storage/build/mozStorageCID.h
@@ -49,21 +49,15 @@
#define MOZ_STORAGE_CONNECTION_CONTRACTID MOZ_STORAGE_CONTRACTID_PREFIX "/connection;1"
/* bbbb1d61-438f-4436-92ed-8308e5830fb0 */
#define MOZ_STORAGE_SERVICE_CID \
{ 0xbbbb1d61, 0x438f, 0x4436, {0x92, 0xed, 0x83, 0x08, 0xe5, 0x83, 0x0f, 0xb0} }
#define MOZ_STORAGE_SERVICE_CONTRACTID MOZ_STORAGE_CONTRACTID_PREFIX "/service;1"
-/* dab3a846-3a59-4fc2-9745-c6ff48776f00 */
-#define MOZ_STORAGE_STATEMENT_WRAPPER_CID \
-{ 0xdab3a846, 0x3a59, 0x4fc2, {0x97, 0x45, 0xc6, 0xff, 0x48, 0x77, 0x6f, 0x00} }
-
-#define MOZ_STORAGE_STATEMENT_WRAPPER_CONTRACTID MOZ_STORAGE_CONTRACTID_PREFIX "/statement-wrapper;1"
-
/* 3b667ee0-d2da-4ccc-9c3d-95f2ca6a8b4c */
#define VACUUMMANAGER_CID \
{ 0x3b667ee0, 0xd2da, 0x4ccc, { 0x9c, 0x3d, 0x95, 0xf2, 0xca, 0x6a, 0x8b, 0x4c } }
#define VACUUMMANAGER_CONTRACTID MOZ_STORAGE_CONTRACTID_PREFIX "/vacuum;1"
#endif /* MOZSTORAGECID_H */
--- a/storage/build/mozStorageModule.cpp
+++ b/storage/build/mozStorageModule.cpp
@@ -37,47 +37,42 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "mozilla/ModuleUtils.h"
#include "mozStorageService.h"
#include "mozStorageConnection.h"
-#include "mozStorageStatementWrapper.h"
#include "VacuumManager.h"
#include "mozStorageCID.h"
namespace mozilla {
namespace storage {
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Service,
Service::getSingleton)
-NS_GENERIC_FACTORY_CONSTRUCTOR(StatementWrapper)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(VacuumManager,
VacuumManager::getSingleton)
} // namespace storage
} // namespace mozilla
NS_DEFINE_NAMED_CID(MOZ_STORAGE_SERVICE_CID);
-NS_DEFINE_NAMED_CID(MOZ_STORAGE_STATEMENT_WRAPPER_CID);
NS_DEFINE_NAMED_CID(VACUUMMANAGER_CID);
static const mozilla::Module::CIDEntry kStorageCIDs[] = {
{ &kMOZ_STORAGE_SERVICE_CID, false, NULL, mozilla::storage::ServiceConstructor },
- { &kMOZ_STORAGE_STATEMENT_WRAPPER_CID, false, NULL, mozilla::storage::StatementWrapperConstructor },
{ &kVACUUMMANAGER_CID, false, NULL, mozilla::storage::VacuumManagerConstructor },
{ NULL }
};
static const mozilla::Module::ContractIDEntry kStorageContracts[] = {
{ MOZ_STORAGE_SERVICE_CONTRACTID, &kMOZ_STORAGE_SERVICE_CID },
- { MOZ_STORAGE_STATEMENT_WRAPPER_CONTRACTID, &kMOZ_STORAGE_STATEMENT_WRAPPER_CID },
{ VACUUMMANAGER_CONTRACTID, &kVACUUMMANAGER_CID },
{ NULL }
};
static const mozilla::Module::CategoryEntry kStorageCategories[] = {
{ "idle-daily", "MozStorage Vacuum Manager", VACUUMMANAGER_CONTRACTID },
{ NULL }
};
--- a/storage/public/Makefile.in
+++ b/storage/public/Makefile.in
@@ -52,21 +52,22 @@ GRE_MODULE = 1
# storage.h file too.
XPIDLSRCS = \
mozIStorageService.idl \
mozIStorageConnection.idl \
mozIStorageAggregateFunction.idl \
mozIStorageFunction.idl \
mozIStorageProgressHandler.idl \
mozIStorageStatement.idl \
- mozIStorageStatementWrapper.idl \
mozIStorageValueArray.idl \
mozIStorageResultSet.idl \
mozIStorageRow.idl \
mozIStorageError.idl \
+ mozIStorageStatementParams.idl \
+ mozIStorageStatementRow.idl \
mozIStorageStatementCallback.idl \
mozIStoragePendingStatement.idl \
mozIStorageBindingParamsArray.idl \
mozIStorageBindingParams.idl \
mozIStorageCompletionCallback.idl \
mozIStorageBaseStatement.idl \
mozIStorageAsyncStatement.idl \
mozIStorageServiceQuotaManagement.idl \
new file mode 100644
--- /dev/null
+++ b/storage/public/mozIStorageStatementParams.idl
@@ -0,0 +1,11 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+[scriptable, uuid(e65fe6e2-2643-463c-97e2-27665efe2386)]
+interface mozIStorageStatementParams : nsISupports {
+ // Magic interface for parameter setting that implements nsIXPCScriptable.
+};
new file mode 100644
--- /dev/null
+++ b/storage/public/mozIStorageStatementRow.idl
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+
+[scriptable, uuid(02eeaf95-c3db-4182-9340-222c29f68f02)]
+interface mozIStorageStatementRow : nsISupports {
+ // Magic interface we return that implements nsIXPCScriptable, to allow
+ // for by-name access to rows.
+};
deleted file mode 100644
--- a/storage/public/mozIStorageStatementWrapper.idl
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Oracle Corporation code.
- *
- * The Initial Developer of the Original Code is
- * Oracle Corporation
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "mozIStorageStatement.idl"
-
-[scriptable, uuid(02eeaf95-c3db-4182-9340-222c29f68f02)]
-interface mozIStorageStatementRow : nsISupports {
- // magic interface we return that implements nsIXPCScriptable, to allow
- // for by-name access to rows
-};
-
-[scriptable, uuid(e65fe6e2-2643-463c-97e2-27665efe2386)]
-interface mozIStorageStatementParams : nsISupports {
- // magic interface for parameter setting that implements nsIXPCScriptable.
-};
-
-/**
- * @deprecated As of Mozilla 1.9.2. Methods are already provided on
- * mozIStorageStatement.
- */
-[scriptable, deprecated, uuid(eee6f7c9-5586-4eaf-b35c-dca987c4ffd1)]
-interface mozIStorageStatementWrapper : nsISupports {
- /**
- * Initialize this wrapper with aStatement.
- */
- void initialize(in mozIStorageStatement aStatement);
-
- /**
- * The statement that is wrapped.
- */
- readonly attribute mozIStorageStatement statement;
-
- /**
- * Step, reset, and execute the wrapped statement.
- */
- void reset();
- [deprecated] boolean step();
- void execute();
-
- /**
- * The current row. Throws an exception if no row is currently
- * available. Useful only from script. The value of this is only
- * valid while the statement is still executing, and is still on the
- * appropriate row.
- */
- readonly attribute mozIStorageStatementRow row;
-
- /**
- * The parameters; these can be set in lieu of using the call
- * notation on this.
- */
- readonly attribute mozIStorageStatementParams params;
-};
--- a/storage/src/Makefile.in
+++ b/storage/src/Makefile.in
@@ -73,17 +73,16 @@ EXPORTS_mozilla/storage = \
Variant.h \
Variant_inl.h \
$(NULL)
CPPSRCS = \
mozStorageService.cpp \
mozStorageConnection.cpp \
mozStorageStatement.cpp \
- mozStorageStatementWrapper.cpp \
mozStorageStatementParams.cpp \
mozStorageStatementRow.cpp \
mozStorageArgValueArray.cpp \
mozStorageSQLFunctions.cpp \
mozStorageRow.cpp \
mozStorageResultSet.cpp \
mozStorageError.cpp \
mozStorageAsyncStatementExecution.cpp \
--- a/storage/src/mozStorageAsyncStatementParams.h
+++ b/storage/src/mozStorageAsyncStatementParams.h
@@ -35,17 +35,17 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_storage_mozStorageAsyncStatementParams_h_
#define mozilla_storage_mozStorageAsyncStatementParams_h_
-#include "mozIStorageStatementWrapper.h"
+#include "mozIStorageStatementParams.h"
#include "nsIXPCScriptable.h"
class mozIStorageAsyncStatement;
namespace mozilla {
namespace storage {
class AsyncStatement;
--- a/storage/src/mozStorageStatementParams.h
+++ b/storage/src/mozStorageStatementParams.h
@@ -35,17 +35,17 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef MOZSTORAGESTATEMENTPARAMS_H
#define MOZSTORAGESTATEMENTPARAMS_H
-#include "mozIStorageStatementWrapper.h"
+#include "mozIStorageStatementParams.h"
#include "nsIXPCScriptable.h"
class mozIStorageStatement;
namespace mozilla {
namespace storage {
class Statement;
--- a/storage/src/mozStorageStatementRow.h
+++ b/storage/src/mozStorageStatementRow.h
@@ -35,17 +35,17 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef MOZSTORAGESTATEMENTROW_H
#define MOZSTORAGESTATEMENTROW_H
-#include "mozIStorageStatementWrapper.h"
+#include "mozIStorageStatementRow.h"
#include "nsIXPCScriptable.h"
namespace mozilla {
namespace storage {
class Statement;
class StatementRow : public mozIStorageStatementRow
deleted file mode 100644
--- a/storage/src/mozStorageStatementWrapper.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Oracle Corporation code.
- *
- * The Initial Developer of the Original Code is
- * Oracle Corporation
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
- * Shawn Wilsher <me@shawnwilsher.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsString.h"
-
-#include "mozStoragePrivateHelpers.h"
-#include "mozStorageStatementWrapper.h"
-#include "mozStorageStatementParams.h"
-#include "mozStorageStatementRow.h"
-
-#include "sqlite3.h"
-
-namespace mozilla {
-namespace storage {
-
-////////////////////////////////////////////////////////////////////////////////
-//// StatementWrapper
-
-StatementWrapper::StatementWrapper()
-: mStatement(nsnull)
-{
-}
-
-StatementWrapper::~StatementWrapper()
-{
- mStatement = nsnull;
-}
-
-NS_IMPL_ISUPPORTS2(
- StatementWrapper,
- mozIStorageStatementWrapper,
- nsIXPCScriptable
-)
-
-////////////////////////////////////////////////////////////////////////////////
-//// mozIStorageStatementWrapper
-
-NS_IMETHODIMP
-StatementWrapper::Initialize(mozIStorageStatement *aStatement)
-{
- NS_ASSERTION(mStatement == nsnull, "StatementWrapper is already initialized");
- NS_ENSURE_ARG_POINTER(aStatement);
-
- mStatement = static_cast<Statement *>(aStatement);
- PRInt32 state;
- (void)mStatement->GetState(&state);
- NS_ENSURE_TRUE(state != mozIStorageStatement::MOZ_STORAGE_STATEMENT_INVALID, NS_ERROR_FAILURE);
-
- // fetch various things we care about
- (void)mStatement->GetParameterCount(&mParamCount);
- (void)mStatement->GetColumnCount(&mResultColumnCount);
-
- for (unsigned int i = 0; i < mResultColumnCount; i++) {
- const void *name = ::sqlite3_column_name16(nativeStatement(), i);
- (void)mColumnNames.AppendElement(nsDependentString(static_cast<const PRUnichar*>(name)));
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-StatementWrapper::GetStatement(mozIStorageStatement **_statement)
-{
- NS_IF_ADDREF(*_statement = mStatement);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-StatementWrapper::Reset()
-{
- if (!mStatement)
- return NS_ERROR_FAILURE;
-
- return mStatement->Reset();
-}
-
-NS_IMETHODIMP
-StatementWrapper::Step(bool *_hasMoreResults)
-{
- if (!mStatement)
- return NS_ERROR_FAILURE;
-
- bool hasMore = false;
- nsresult rv = mStatement->ExecuteStep(&hasMore);
- if (NS_SUCCEEDED(rv) && !hasMore) {
- *_hasMoreResults = false;
- (void)mStatement->Reset();
- return NS_OK;
- }
-
- *_hasMoreResults = hasMore;
- return rv;
-}
-
-NS_IMETHODIMP
-StatementWrapper::Execute()
-{
- if (!mStatement)
- return NS_ERROR_FAILURE;
-
- return mStatement->Execute();
-}
-
-NS_IMETHODIMP
-StatementWrapper::GetRow(mozIStorageStatementRow **_row)
-{
- NS_ENSURE_ARG_POINTER(_row);
-
- if (!mStatement)
- return NS_ERROR_FAILURE;
-
- PRInt32 state;
- mStatement->GetState(&state);
- if (state != mozIStorageStatement::MOZ_STORAGE_STATEMENT_EXECUTING)
- return NS_ERROR_FAILURE;
-
- if (!mStatementRow) {
- mStatementRow = new StatementRow(mStatement);
- NS_ENSURE_TRUE(mStatementRow, NS_ERROR_OUT_OF_MEMORY);
- }
-
- NS_ADDREF(*_row = mStatementRow);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-StatementWrapper::GetParams(mozIStorageStatementParams **_params)
-{
- NS_ENSURE_ARG_POINTER(_params);
-
- if (!mStatementParams) {
- mStatementParams = new StatementParams(mStatement);
- NS_ENSURE_TRUE(mStatementParams, NS_ERROR_OUT_OF_MEMORY);
- }
-
- NS_ADDREF(*_params = mStatementParams);
- return NS_OK;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//// nsIXPCScriptable
-
-#define XPC_MAP_CLASSNAME StatementWrapper
-#define XPC_MAP_QUOTED_CLASSNAME "StatementWrapper"
-#define XPC_MAP_WANT_CALL
-#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE | \
- nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY
-#include "xpc_map_end.h"
-
-NS_IMETHODIMP
-StatementWrapper::Call(nsIXPConnectWrappedNative *aWrapper,
- JSContext *aCtx,
- JSObject *aScopeObj,
- PRUint32 aArgc,
- jsval *aArgv,
- jsval *_vp,
- bool *_retval)
-{
- if (!mStatement)
- return NS_ERROR_FAILURE;
-
- if (aArgc != mParamCount) {
- *_retval = false;
- return NS_ERROR_FAILURE;
- }
-
- // reset
- (void)mStatement->Reset();
-
- // bind parameters
- for (int i = 0; i < (int)aArgc; i++) {
- nsCOMPtr<nsIVariant> variant(convertJSValToVariant(aCtx, aArgv[i]));
- if (!variant ||
- NS_FAILED(mStatement->BindByIndex(i, variant))) {
- *_retval = false;
- return NS_ERROR_INVALID_ARG;
- }
- }
-
- // if there are no results, we just execute
- if (mResultColumnCount == 0)
- (void)mStatement->Execute();
-
- *_vp = JSVAL_TRUE;
- *_retval = true;
- return NS_OK;
-}
-
-} // namespace storage
-} // namespace mozilla
deleted file mode 100644
--- a/storage/src/mozStorageStatementWrapper.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Oracle Corporation code.
- *
- * The Initial Developer of the Original Code is
- * Oracle Corporation
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef mozStorageStatementWrapper_h
-#define mozStorageStatementWrapper_h
-
-#include "nsTArray.h"
-#include "nsIXPCScriptable.h"
-
-#include "mozStorageStatement.h"
-#include "mozIStorageStatementWrapper.h"
-
-namespace mozilla {
-namespace storage {
-
-class StatementWrapper : public mozIStorageStatementWrapper
- , public nsIXPCScriptable
-{
-public:
- StatementWrapper();
-
- // interfaces
- NS_DECL_ISUPPORTS
- NS_DECL_MOZISTORAGESTATEMENTWRAPPER
- NS_DECL_NSIXPCSCRIPTABLE
-
-private:
- ~StatementWrapper();
-
- sqlite3_stmt *nativeStatement() {
- return mStatement->nativeStatement();
- }
-
- nsRefPtr<Statement> mStatement;
- PRUint32 mParamCount;
- PRUint32 mResultColumnCount;
- nsTArray<nsString> mColumnNames;
-
- nsCOMPtr<mozIStorageStatementRow> mStatementRow;
- nsCOMPtr<mozIStorageStatementParams> mStatementParams;
-};
-
-} // namespace storage
-} // namespace mozilla
-
-#endif // mozStorageStatementWrapper_h
--- a/storage/test/unit/test_bug-365166.js
+++ b/storage/test/unit/test_bug-365166.js
@@ -16,20 +16,14 @@ function run_test() {
var file = getTestDB();
var storageService = Components.classes["@mozilla.org/storage/service;1"].
getService(Components.interfaces.mozIStorageService);
var conn = storageService.openDatabase(file);
var statement = conn.createStatement(sql);
try {
// This shouldn't crash:
do_check_eq(statement.getColumnName(0), colName);
-
- // OK, if the above statement didn't crash, check that initializing a
- // wrapper doesn't crash either:
- var wrapper = Components.classes["@mozilla.org/storage/statement-wrapper;1"]
- .createInstance(Components.interfaces.mozIStorageStatementWrapper);
- wrapper.initialize(statement);
} finally {
statement.reset();
statement.finalize();
}
}
}
--- a/storage/test/unit/test_bug-429521.js
+++ b/storage/test/unit/test_bug-429521.js
@@ -32,59 +32,51 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-function createStatementWrapper(aSQL)
-{
- var stmt = getOpenedDatabase().createStatement(aSQL);
- var wrapper = Components.Constructor("@mozilla.org/storage/statement-wrapper;1", Ci.mozIStorageStatementWrapper)();
- wrapper.initialize(stmt);
- return wrapper;
-}
-
function setup()
{
getOpenedDatabase().createTable("t1", "x TEXT");
- var stmt = getOpenedDatabase().createStatement("INSERT INTO t1 (x) VALUES ('/mozilla.org/20070129_1/Europe/Berlin')");
+ var stmt = createStatement("INSERT INTO t1 (x) VALUES ('/mozilla.org/20070129_1/Europe/Berlin')");
stmt.execute();
stmt.finalize();
}
function test_bug429521()
{
- var wrapper = createStatementWrapper(
+ var stmt = createStatement(
"SELECT DISTINCT(zone) FROM ("+
"SELECT x AS zone FROM t1 WHERE x LIKE '/mozilla.org%'" +
");");
print("*** test_bug429521: started");
try {
- while (wrapper.step()) {
+ while (stmt.executeStep()) {
print("*** test_bug429521: step() Read wrapper.row.zone");
// BUG: the print commands after the following statement
// are never executed. Script stops immediately.
- var tzId = wrapper.row.zone;
+ var tzId = stmt.row.zone;
print("*** test_bug429521: step() Read wrapper.row.zone finished");
}
} catch (e) {
print("*** test_bug429521: " + e);
}
print("*** test_bug429521: finished");
- wrapper.statement.finalize();
+ stmt.finalize();
}
function run_test()
{
setup();
test_bug429521();
--- a/storage/test/unit/test_bug-444233.js
+++ b/storage/test/unit/test_bug-444233.js
@@ -32,64 +32,55 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-// copy from test_storage_statement_wrapper.js
-var wrapper = new Components.Constructor("@mozilla.org/storage/statement-wrapper;1",
- Ci.mozIStorageStatementWrapper,
- "initialize");
-// we want to override the default function for this file
-createStatement = function(aSQL) {
- return new wrapper(getOpenedDatabase().createStatement(aSQL));
-}
-
function setup() {
// Create the table
getOpenedDatabase().createTable("test_bug444233",
"id INTEGER PRIMARY KEY, value TEXT");
// Insert dummy data, using wrapper methods
var stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
stmt.params.value = "value1"
stmt.execute();
- stmt.statement.finalize();
+ stmt.finalize();
stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
stmt.params.value = "value2"
stmt.execute();
- stmt.statement.finalize();
+ stmt.finalize();
}
function test_bug444233() {
print("*** test_bug444233: started");
// Check that there are 2 results
var stmt = createStatement("SELECT COUNT(*) AS number FROM test_bug444233");
- do_check_true(stmt.step());
+ do_check_true(stmt.executeStep());
do_check_eq(2, stmt.row.number);
stmt.reset();
- stmt.statement.finalize();
+ stmt.finalize();
print("*** test_bug444233: doing delete");
// Now try to delete using IN
// Cheating since we know ids are 1,2
try {
var ids = [1, 2];
stmt = createStatement("DELETE FROM test_bug444233 WHERE id IN (:ids)");
stmt.params.ids = ids;
} catch (e) {
print("*** test_bug444233: successfully caught exception");
}
- stmt.statement.finalize();
+ stmt.finalize();
}
function run_test() {
setup();
test_bug444233();
cleanup();
}
deleted file mode 100644
--- a/storage/test/unit/test_storage_statement_wrapper.js
+++ /dev/null
@@ -1,228 +0,0 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- vim:set ts=2 sw=2 sts=2 et:
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Storage Test Code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2007
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Shawn Wilsher <me@shawnwilsher.com> (Original Author)
- * Drew Willcoxon <adw@mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// This file tests the functions of mozIStorageStatementWrapper
-
-function setup()
-{
- getOpenedDatabase().createTable("test", "id INTEGER PRIMARY KEY, val NONE," +
- "alt_val NONE");
-}
-
-var wrapper = new Components.Constructor("@mozilla.org/storage/statement-wrapper;1",
- Ci.mozIStorageStatementWrapper,
- "initialize");
-
-// we want to override the default function for this file
-createStatement = function(aSQL) {
- return new wrapper(getOpenedDatabase().createStatement(aSQL));
-}
-
-/**
- * A convenience wrapper for do_check_eq. Calls do_check_eq on aActualVal
- * and aReturnedVal, with one caveat.
- *
- * Date objects are converted before parameter binding to PRTime's (microsecs
- * since epoch). They are not reconverted when retrieved from the database.
- * This function abstracts away this reconversion so that you can pass in,
- * for example:
- *
- * checkVal(new Date(), aReturnedVal) // this
- * checkVal(new Date().valueOf() * 1000.0, aReturnedVal) // instead of this
- *
- * Should any other types require conversion in the future, their conversions
- * may also be abstracted away here.
- *
- * @param aActualVal
- * the value inserted into the database
- * @param aReturnedVal
- * the value retrieved from the database
- */
-function checkVal(aActualVal, aReturnedVal)
-{
- if (aActualVal instanceof Date) aActualVal = aActualVal.valueOf() * 1000.0;
- do_check_eq(aActualVal, aReturnedVal);
-}
-
-/**
- * Removes all rows from our test table.
- */
-function clearTable()
-{
- var stmt = createStatement("DELETE FROM test");
- stmt.execute();
- stmt.statement.finalize();
- ensureNumRows(0);
-}
-
-/**
- * Ensures that the number of rows in our test table is equal to aNumRows.
- * Calls do_check_eq on aNumRows and the value retrieved by SELECT'ing COUNT(*).
- *
- * @param aNumRows
- * the number of rows our test table should contain
- */
-function ensureNumRows(aNumRows)
-{
- var stmt = createStatement("SELECT COUNT(*) AS number FROM test");
- do_check_true(stmt.step());
- do_check_eq(aNumRows, stmt.row.number);
- stmt.reset();
- stmt.statement.finalize();
-}
-
-/**
- * Verifies that the properties exposed by a for-in loop over aObj are
- * enumerable.
- *
- * @param aObj
- * the object to check
- */
-function checkEnumerableConsistency(aObj)
-{
- for (var p in aObj)
- do_check_true(Object.prototype.propertyIsEnumerable.call(aObj, p));
-}
-
-/**
- * Inserts aVal into our test table and checks that insertion was successful by
- * retrieving the newly inserted value from the database and comparing it
- * against aVal. aVal is bound to a single parameter.
- *
- * @param aVal
- * value to insert into our test table and check
- */
-function insertAndCheckSingleParam(aVal)
-{
- clearTable();
-
- var stmt = createStatement("INSERT INTO test (val) VALUES (:val)");
- stmt.params.val = aVal;
- checkEnumerableConsistency(stmt.params);
- stmt.execute();
- stmt.statement.finalize();
-
- ensureNumRows(1);
-
- stmt = createStatement("SELECT val FROM test WHERE id = 1");
- do_check_true(stmt.step());
- checkVal(aVal, stmt.row.val);
- stmt.reset();
- stmt.statement.finalize();
-}
-
-/**
- * Inserts aVal into our test table and checks that insertion was successful by
- * retrieving the newly inserted value from the database and comparing it
- * against aVal. aVal is bound to two separate parameters, both of which are
- * checked against aVal.
- *
- * @param aVal
- * value to insert into our test table and check
- */
-function insertAndCheckMultipleParams(aVal)
-{
- clearTable();
-
- var stmt = createStatement("INSERT INTO test (val, alt_val) " +
- "VALUES (:val, :val)");
- stmt.params.val = aVal;
- checkEnumerableConsistency(stmt.params);
- stmt.execute();
- stmt.statement.finalize();
-
- ensureNumRows(1);
-
- stmt = createStatement("SELECT val, alt_val FROM test WHERE id = 1");
- do_check_true(stmt.step());
- checkVal(aVal, stmt.row.val);
- checkVal(aVal, stmt.row.alt_val);
- stmt.reset();
- stmt.statement.finalize();
-}
-
-/**
- * A convenience function that prints out a description of aVal using
- * aVal.toString and aVal.toSource. Output is useful when the test fails.
- *
- * @param aVal
- * a value inserted or to be inserted into our test table
- */
-function printValDesc(aVal)
-{
- try
- {
- var toSource = aVal.toSource();
- }
- catch (exc)
- {
- toSource = "";
- }
- print("Testing value: toString=" + aVal +
- (toSource ? " toSource=" + toSource : ""));
-}
-
-function run_test()
-{
- setup();
-
- // function JSValStorageStatementBinder in
- // storage/src/mozStorageStatementParams.cpp tells us that the following types
- // and only the following types are valid as statement parameters:
- var vals = [
- 1337, // int
- 3.1337, // double
- "foo", // string
- true, // boolean
- null, // null
- new Date(), // Date object
- ];
-
- vals.forEach(function (val)
- {
- printValDesc(val);
- print("Single parameter");
- insertAndCheckSingleParam(val);
- print("Multiple parameters");
- insertAndCheckMultipleParams(val)
- });
-
- cleanup();
-}
--- a/storage/test/unit/xpcshell.ini
+++ b/storage/test/unit/xpcshell.ini
@@ -23,15 +23,14 @@ fail-if = os == "android"
[test_storage_aggregates.js]
[test_storage_connection.js]
[test_storage_fulltextindex.js]
[test_storage_function.js]
[test_storage_progresshandler.js]
[test_storage_service.js]
[test_storage_service_unshared.js]
[test_storage_statement.js]
-[test_storage_statement_wrapper.js]
[test_storage_value_array.js]
[test_unicode.js]
[test_vacuum.js]
[test_telemetry_vfs.js]
# Bug 676981: test fails consistently on Android
# fail-if = os == "android"