Bug 483152 - Stop giving the ability to get the native sqlite3_stmt pointer
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Fri, 20 Mar 2009 18:41:01 -0400
changeset 26431 b48482c54995ef7fb8b6d6506da910a7c4d4c815
parent 26430 dee8dab15435086e3afdf1146a19cebd1bf23d6d
child 26432 825869c4798a0225eff37aaeaf04f505d54775ac
push idunknown
push userunknown
push dateunknown
bugs483152
milestone1.9.2a1pre
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
storage/src/mozStorageConnection.cpp
storage/src/mozStorageStatement.cpp
storage/src/mozStorageStatement.h
storage/src/mozStorageStatementRow.h
storage/src/mozStorageStatementWrapper.h
--- a/storage/public/mozIStorageStatement.idl
+++ b/storage/public/mozIStorageStatement.idl
@@ -40,19 +40,17 @@
 #include "nsISupports.idl"
 #include "mozIStorageValueArray.idl"
 
 interface mozIStorageConnection;
 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.
    * This method does not need to be used from native callers since you can just
    * set the statement to null, but is extremely useful to JS callers.
    */
   void finalize();
 
@@ -196,18 +194,16 @@ interface mozIStorageStatement : mozISto
    * the statement is in the "executing" state.
    */
   const long MOZ_STORAGE_STATEMENT_INVALID = 0;
   const long MOZ_STORAGE_STATEMENT_READY = 1;
   const long MOZ_STORAGE_STATEMENT_EXECUTING = 2;
 
   readonly attribute long state;
 
-  [noscript,notxpcom] sqlite3stmtptr getNativeStatementPointer();
-
   /**
    * Escape a string for SQL LIKE search.
    *
    * @param     aValue the string to escape for SQL LIKE 
    * @param     aEscapeChar the escape character
    * @returns   an AString of an escaped version of aValue
    *            (%, _ and the escape char are escaped with the escape char)
    *            For example, we will convert "foo/bar_baz%20cheese" 
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -393,17 +393,18 @@ nsresult
 mozStorageConnection::ExecuteAsync(mozIStorageStatement ** aStatements,
                                    PRUint32 aNumStatements,
                                    mozIStorageStatementCallback *aCallback,
                                    mozIStoragePendingStatement **_stmt)
 {
     int rc = SQLITE_OK;
     nsTArray<sqlite3_stmt *> 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<mozStorageStatement *>(aStatements[i])->nativeStatement();
         if (!old_stmt) {
           rc = SQLITE_MISUSE;
           break;
         }
         NS_ASSERTION(sqlite3_db_handle(old_stmt) == mDBConn,
                      "Statement must be from this database connection!");
 
         // Clone this statement.  We only need a sqlite3_stmt object, so we can
--- a/storage/src/mozStorageStatement.cpp
+++ b/storage/src/mozStorageStatement.cpp
@@ -608,23 +608,16 @@ mozStorageStatement::ExecuteStep(PRBool 
 nsresult
 mozStorageStatement::ExecuteAsync(mozIStorageStatementCallback *aCallback,
                                   mozIStoragePendingStatement **_stmt)
 {
     mozIStorageStatement * stmts[1] = {this};
     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)
 {
     if (!mDBConnection || !mDBStatement) {
         *_retval = MOZ_STORAGE_STATEMENT_INVALID;
     } else if (mExecuting) {
         *_retval = MOZ_STORAGE_STATEMENT_EXECUTING;
--- a/storage/src/mozStorageStatement.h
+++ b/storage/src/mozStorageStatement.h
@@ -73,17 +73,17 @@ public:
      */
     nsresult Initialize(mozStorageConnection *aDBConnection,
                         const nsACString &aSQLStatement);
 
 
     /**
      * Obtains the native statement pointer.
      */
-    inline sqlite3_stmt *NativeStatement() { return mDBStatement; }
+    inline sqlite3_stmt *nativeStatement() { return mDBStatement; }
 
 private:
     ~mozStorageStatement();
 
 protected:
     nsRefPtr<mozStorageConnection> mDBConnection;
     sqlite3_stmt *mDBStatement;
     PRUint32 mParamCount;
--- a/storage/src/mozStorageStatementRow.h
+++ b/storage/src/mozStorageStatementRow.h
@@ -55,18 +55,15 @@ public:
     NS_DECL_ISUPPORTS
 
     // mozIStorageStatementRow interface (empty)
     NS_DECL_MOZISTORAGESTATEMENTROW
 
     // nsIXPCScriptable interface
     NS_DECL_NSIXPCSCRIPTABLE
 protected:
-    sqlite3_stmt* NativeStatement() {
-        return mStatement->GetNativeStatementPointer();
-    }
 
     mozStorageStatement *mStatement;
 
     friend class mozStorageStatement;
 };
 
 #endif /* _MOZSTORAGESTATEMENTROW_H_ */
--- a/storage/src/mozStorageStatementWrapper.h
+++ b/storage/src/mozStorageStatementWrapper.h
@@ -63,17 +63,17 @@ public:
     NS_DECL_MOZISTORAGESTATEMENTWRAPPER
     NS_DECL_NSIXPCSCRIPTABLE
 
 private:
     ~mozStorageStatementWrapper();
 
 protected:
     sqlite3_stmt* NativeStatement() {
-        return mStatement->GetNativeStatementPointer();
+        return mStatement->nativeStatement();
     }
 
     // note: pointer to the concrete statement
     nsRefPtr<mozStorageStatement> mStatement;
     PRUint32 mParamCount;
     PRUint32 mResultColumnCount;
     nsTArray<nsString> mColumnNames;