2009-05-09 00:29:56 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2004-10-09 00:04:10 +00:00
|
|
|
|
2010-06-01 12:38:00 +00:00
|
|
|
#ifndef mozStorageStatement_h
|
|
|
|
#define mozStorageStatement_h
|
2004-10-09 00:04:10 +00:00
|
|
|
|
2008-06-11 15:00:09 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2004-10-09 00:04:10 +00:00
|
|
|
#include "nsString.h"
|
|
|
|
|
2009-01-22 04:15:34 +00:00
|
|
|
#include "nsTArray.h"
|
2004-12-03 16:56:57 +00:00
|
|
|
|
2009-06-17 19:12:51 +00:00
|
|
|
#include "mozStorageBindingParamsArray.h"
|
2009-07-28 17:21:03 +00:00
|
|
|
#include "mozStorageStatementData.h"
|
2004-10-09 00:04:10 +00:00
|
|
|
#include "mozIStorageStatement.h"
|
2010-03-24 07:32:40 +00:00
|
|
|
#include "mozIStorageValueArray.h"
|
|
|
|
#include "StorageBaseStatementInternal.h"
|
2012-06-13 03:35:10 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2004-10-09 00:04:10 +00:00
|
|
|
|
2008-09-12 21:30:41 +00:00
|
|
|
class nsIXPConnectJSObjectHolder;
|
2009-05-09 00:29:56 +00:00
|
|
|
struct sqlite3_stmt;
|
2009-04-08 16:24:25 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace storage {
|
|
|
|
class StatementJSHelper;
|
2009-04-17 21:19:31 +00:00
|
|
|
class Connection;
|
2008-07-11 19:47:33 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class Statement final : public mozIStorageStatement
|
2015-03-27 18:52:19 +00:00
|
|
|
, public mozIStorageValueArray
|
|
|
|
, public StorageBaseStatementInternal
|
2004-10-09 00:04:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:24:15 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2009-05-09 00:29:56 +00:00
|
|
|
NS_DECL_MOZISTORAGESTATEMENT
|
2010-03-24 07:32:40 +00:00
|
|
|
NS_DECL_MOZISTORAGEBASESTATEMENT
|
|
|
|
NS_DECL_MOZISTORAGEBINDINGPARAMS
|
|
|
|
// NS_DECL_MOZISTORAGEVALUEARRAY (methods in mozIStorageStatement)
|
|
|
|
NS_DECL_STORAGEBASESTATEMENTINTERNAL
|
2009-05-09 00:29:56 +00:00
|
|
|
|
|
|
|
Statement();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the object on aDBConnection by preparing the SQL statement
|
|
|
|
* given by aSQLStatement.
|
|
|
|
*
|
|
|
|
* @param aDBConnection
|
|
|
|
* The Connection object this statement is associated with.
|
2014-04-24 09:54:09 +00:00
|
|
|
* @param aNativeConnection
|
|
|
|
* The native Sqlite connection this statement is associated with.
|
2009-05-09 00:29:56 +00:00
|
|
|
* @param aSQLStatement
|
|
|
|
* The SQL statement to prepare that this object will represent.
|
|
|
|
*/
|
|
|
|
nsresult initialize(Connection *aDBConnection,
|
2014-04-24 09:54:09 +00:00
|
|
|
sqlite3* aNativeConnection,
|
2009-05-09 00:29:56 +00:00
|
|
|
const nsACString &aSQLStatement);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtains the native statement pointer.
|
|
|
|
*/
|
|
|
|
inline sqlite3_stmt *nativeStatement() { return mDBStatement; }
|
2008-07-11 19:47:33 +00:00
|
|
|
|
2009-06-17 19:12:51 +00:00
|
|
|
/**
|
|
|
|
* Obtains and transfers ownership of the array of parameters that are bound
|
|
|
|
* to this statment. This can be null.
|
|
|
|
*/
|
|
|
|
inline already_AddRefed<BindingParamsArray> bindingParamsArray()
|
|
|
|
{
|
|
|
|
return mParamsArray.forget();
|
|
|
|
}
|
|
|
|
|
2004-10-09 00:04:10 +00:00
|
|
|
private:
|
2009-05-09 00:29:56 +00:00
|
|
|
~Statement();
|
2004-10-09 00:04:10 +00:00
|
|
|
|
|
|
|
sqlite3_stmt *mDBStatement;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mParamCount;
|
|
|
|
uint32_t mResultColumnCount;
|
2009-01-22 04:15:34 +00:00
|
|
|
nsTArray<nsCString> mColumnNames;
|
2009-05-09 00:29:56 +00:00
|
|
|
bool mExecuting;
|
2005-04-26 22:28:06 +00:00
|
|
|
|
2009-07-28 17:21:03 +00:00
|
|
|
/**
|
|
|
|
* @return a pointer to the BindingParams object to use with our Bind*
|
|
|
|
* method.
|
|
|
|
*/
|
2010-03-24 07:32:40 +00:00
|
|
|
mozIStorageBindingParams *getParams();
|
2009-07-28 17:21:03 +00:00
|
|
|
|
2009-06-17 19:12:51 +00:00
|
|
|
/**
|
|
|
|
* Holds the array of parameters to bind to this statement when we execute
|
|
|
|
* it asynchronously.
|
|
|
|
*/
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<BindingParamsArray> mParamsArray;
|
2009-06-17 19:12:51 +00:00
|
|
|
|
2008-09-12 21:30:41 +00:00
|
|
|
/**
|
|
|
|
* The following two members are only used with the JS helper. They cache
|
|
|
|
* the row and params objects.
|
|
|
|
*/
|
2015-03-12 16:55:56 +00:00
|
|
|
nsMainThreadPtrHandle<nsIXPConnectJSObjectHolder> mStatementParamsHolder;
|
|
|
|
nsMainThreadPtrHandle<nsIXPConnectJSObjectHolder> mStatementRowHolder;
|
2008-09-12 21:30:41 +00:00
|
|
|
|
2010-03-24 07:32:40 +00:00
|
|
|
/**
|
|
|
|
* Internal version of finalize that allows us to tell it if it is being
|
|
|
|
* called from the destructor so it can know not to dispatch events that
|
|
|
|
* require a reference to us.
|
|
|
|
*
|
|
|
|
* @param aDestructing
|
|
|
|
* Is the destructor calling?
|
|
|
|
*/
|
|
|
|
nsresult internalFinalize(bool aDestructing);
|
|
|
|
|
2015-03-12 16:55:56 +00:00
|
|
|
friend class StatementJSHelper;
|
2004-10-09 00:04:10 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace storage
|
|
|
|
} // namespace mozilla
|
2009-05-09 00:29:56 +00:00
|
|
|
|
2010-06-01 12:38:00 +00:00
|
|
|
#endif // mozStorageStatement_h
|