From 74f617d3a62834e78933cfde72ecf362f20aa5a1 Mon Sep 17 00:00:00 2001 From: Shawn Wilsher Date: Fri, 20 Mar 2009 18:41:01 -0400 Subject: [PATCH] Bug 483152 - Stop giving the ability to get the native sqlite3_stmt pointer We don't really want to give this pointer out to consumers since we track some state, and if they call SQLite functions on it, can cause our internal state to be inaccurate. r=asuth --- storage/public/mozIStorageStatement.idl | 6 +----- storage/src/mozStorageConnection.cpp | 3 ++- storage/src/mozStorageStatement.cpp | 7 ------- storage/src/mozStorageStatement.h | 2 +- storage/src/mozStorageStatementRow.h | 3 --- storage/src/mozStorageStatementWrapper.h | 2 +- 6 files changed, 5 insertions(+), 18 deletions(-) diff --git a/storage/public/mozIStorageStatement.idl b/storage/public/mozIStorageStatement.idl index d134297fd6eb..36e7d7364303 100644 --- a/storage/public/mozIStorageStatement.idl +++ b/storage/public/mozIStorageStatement.idl @@ -45,9 +45,7 @@ interface nsISimpleEnumerator; interface mozIStorageStatementCallback; interface mozIStoragePendingStatement; -[ptr] native sqlite3stmtptr(struct sqlite3_stmt); - -[scriptable, uuid(4a712295-d076-4007-9c78-8c0e15373b9f)] +[scriptable, uuid(471e161a-af46-4eb3-adf6-f6b0c41fe81c)] interface mozIStorageStatement : mozIStorageValueArray { /** * Finalizes a statement so you can successfully close a database connection. @@ -201,8 +199,6 @@ interface mozIStorageStatement : mozIStorageValueArray { readonly attribute long state; - [noscript,notxpcom] sqlite3stmtptr getNativeStatementPointer(); - /** * Escape a string for SQL LIKE search. * diff --git a/storage/src/mozStorageConnection.cpp b/storage/src/mozStorageConnection.cpp index 10df0b906ea1..ff71caeddc5e 100644 --- a/storage/src/mozStorageConnection.cpp +++ b/storage/src/mozStorageConnection.cpp @@ -398,7 +398,8 @@ mozStorageConnection::ExecuteAsync(mozIStorageStatement ** aStatements, int rc = SQLITE_OK; nsTArray stmts(aNumStatements); for (PRUint32 i = 0; i < aNumStatements && rc == SQLITE_OK; i++) { - sqlite3_stmt *old_stmt = aStatements[i]->GetNativeStatementPointer(); + sqlite3_stmt *old_stmt = + static_cast(aStatements[i])->nativeStatement(); if (!old_stmt) { rc = SQLITE_MISUSE; break; diff --git a/storage/src/mozStorageStatement.cpp b/storage/src/mozStorageStatement.cpp index 938849491a79..06bf46a037b7 100644 --- a/storage/src/mozStorageStatement.cpp +++ b/storage/src/mozStorageStatement.cpp @@ -613,13 +613,6 @@ mozStorageStatement::ExecuteAsync(mozIStorageStatementCallback *aCallback, return mDBConnection->ExecuteAsync(stmts, 1, aCallback, _stmt); } -/* [noscript,notxpcom] sqlite3stmtptr getNativeStatementPointer(); */ -sqlite3_stmt* -mozStorageStatement::GetNativeStatementPointer() -{ - return mDBStatement; -} - /* readonly attribute long state; */ NS_IMETHODIMP mozStorageStatement::GetState(PRInt32 *_retval) diff --git a/storage/src/mozStorageStatement.h b/storage/src/mozStorageStatement.h index 1ab8abec0204..2762a08456c0 100644 --- a/storage/src/mozStorageStatement.h +++ b/storage/src/mozStorageStatement.h @@ -78,7 +78,7 @@ public: /** * Obtains the native statement pointer. */ - inline sqlite3_stmt *NativeStatement() { return mDBStatement; } + inline sqlite3_stmt *nativeStatement() { return mDBStatement; } private: ~mozStorageStatement(); diff --git a/storage/src/mozStorageStatementRow.h b/storage/src/mozStorageStatementRow.h index 5cbfc7eb1b79..3945d1334679 100644 --- a/storage/src/mozStorageStatementRow.h +++ b/storage/src/mozStorageStatementRow.h @@ -60,9 +60,6 @@ public: // nsIXPCScriptable interface NS_DECL_NSIXPCSCRIPTABLE protected: - sqlite3_stmt* NativeStatement() { - return mStatement->GetNativeStatementPointer(); - } mozStorageStatement *mStatement; diff --git a/storage/src/mozStorageStatementWrapper.h b/storage/src/mozStorageStatementWrapper.h index 71839737e25e..4df9291b1f67 100644 --- a/storage/src/mozStorageStatementWrapper.h +++ b/storage/src/mozStorageStatementWrapper.h @@ -68,7 +68,7 @@ private: protected: sqlite3_stmt* NativeStatement() { - return mStatement->GetNativeStatementPointer(); + return mStatement->nativeStatement(); } // note: pointer to the concrete statement