mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 434796
Remove mozIStorageStatement::initialize r=vlad sr=shaver
This commit is contained in:
parent
13420bfff8
commit
faddef0df3
@ -45,15 +45,8 @@ interface nsISimpleEnumerator;
|
||||
|
||||
[ptr] native sqlite3stmtptr(struct sqlite3_stmt);
|
||||
|
||||
[scriptable, uuid(42fad13e-c67d-4b2c-bd61-2c5b17186772)]
|
||||
[scriptable, uuid(4101bda7-6ec8-4a72-bbf8-6569af0030ea)]
|
||||
interface mozIStorageStatement : mozIStorageValueArray {
|
||||
/**
|
||||
* Initialize this query with the given SQL statement.
|
||||
*
|
||||
*/
|
||||
void initialize(in mozIStorageConnection aDBConnection,
|
||||
in AUTF8String aSQLStatement);
|
||||
|
||||
/**
|
||||
* Finalizes a statement so you can successfully close a database connection.
|
||||
* This method does not need to be used from native callers since you can just
|
||||
|
@ -92,31 +92,18 @@ mozStorageStatement::mozStorageStatement()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozStorageStatement::Initialize(mozIStorageConnection *aDBConnection, const nsACString & aSQLStatement)
|
||||
nsresult
|
||||
mozStorageStatement::Initialize(mozStorageConnection *aDBConnection,
|
||||
const nsACString & aSQLStatement)
|
||||
{
|
||||
int srv;
|
||||
NS_ASSERTION(aDBConnection, "No database connection given!");
|
||||
NS_ASSERTION(!mDBStatement, "Calling Initialize on an already initialized statement!");
|
||||
|
||||
// we can't do this if we're mid-execute
|
||||
if (mExecuting) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
sqlite3 *db = nsnull;
|
||||
// XXX - need to implement a private iid to QI for here, to make sure
|
||||
// we have a real mozStorageConnection
|
||||
mozStorageConnection *msc = static_cast<mozStorageConnection*>(aDBConnection);
|
||||
db = msc->GetNativeConnection();
|
||||
sqlite3 *db = aDBConnection->GetNativeConnection();
|
||||
NS_ENSURE_TRUE(db != nsnull, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// clean up old goop
|
||||
if (mDBStatement) {
|
||||
sqlite3_finalize(mDBStatement);
|
||||
mDBStatement = nsnull;
|
||||
}
|
||||
|
||||
int nRetries = 0;
|
||||
|
||||
int srv;
|
||||
while (nRetries < 2) {
|
||||
srv = sqlite3_prepare_v2(db, nsPromiseFlatCString(aSQLStatement).get(),
|
||||
aSQLStatement.Length(), &mDBStatement, NULL);
|
||||
|
@ -39,13 +39,12 @@
|
||||
#ifndef _MOZSTORAGESTATEMENT_H_
|
||||
#define _MOZSTORAGESTATEMENT_H_
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
#include "mozIStorageStatement.h"
|
||||
#include "mozIStorageConnection.h"
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
@ -59,11 +58,23 @@ public:
|
||||
NS_DECL_MOZISTORAGESTATEMENT
|
||||
NS_DECL_MOZISTORAGEVALUEARRAY
|
||||
|
||||
/**
|
||||
* Initializes the object on aDBConnection by preparing the SQL statement
|
||||
* given by aSQLStatement.
|
||||
*
|
||||
* @param aDBConnection
|
||||
* The mozStorageConnection object this statement is associated with.
|
||||
* @param aSQLStatement
|
||||
* The SQL statement to prepare that this object will represent.
|
||||
*/
|
||||
nsresult Initialize(mozStorageConnection *aDBConnection,
|
||||
const nsACString &aSQLStatement);
|
||||
|
||||
private:
|
||||
~mozStorageStatement();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<mozIStorageConnection> mDBConnection;
|
||||
nsRefPtr<mozStorageConnection> mDBConnection;
|
||||
sqlite3_stmt *mDBStatement;
|
||||
PRUint32 mParamCount;
|
||||
PRUint32 mResultColumnCount;
|
||||
|
Loading…
Reference in New Issue
Block a user