Bug 745384 - Allow passing null to queries from java to gecko. r=gpascutto
authorWes Johnston <wjohnston@mozilla.com>
Fri, 05 Oct 2012 18:01:06 -0700
changeset 115794 8e36fd7113baa49f211599e541f943c685fad335
parent 115793 9b6d9a19c61417f4fb7d01cecb64251059b0d747
child 115795 9e6567a9d1b24f96d2a9a8f3ca1a70664f1a1f92
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgpascutto
bugs745384
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 745384 - Allow passing null to queries from java to gecko. r=gpascutto
mozglue/android/SQLiteBridge.cpp
mozglue/android/SQLiteBridge.h
--- a/mozglue/android/SQLiteBridge.cpp
+++ b/mozglue/android/SQLiteBridge.cpp
@@ -21,16 +21,17 @@
 
 #define SQLITE_WRAPPER_INT(name) name ## _t f_ ## name;
 
 SQLITE_WRAPPER_INT(sqlite3_open)
 SQLITE_WRAPPER_INT(sqlite3_errmsg)
 SQLITE_WRAPPER_INT(sqlite3_prepare_v2)
 SQLITE_WRAPPER_INT(sqlite3_bind_parameter_count)
 SQLITE_WRAPPER_INT(sqlite3_bind_text)
+SQLITE_WRAPPER_INT(sqlite3_bind_null)
 SQLITE_WRAPPER_INT(sqlite3_step)
 SQLITE_WRAPPER_INT(sqlite3_column_count)
 SQLITE_WRAPPER_INT(sqlite3_finalize)
 SQLITE_WRAPPER_INT(sqlite3_close)
 SQLITE_WRAPPER_INT(sqlite3_column_name)
 SQLITE_WRAPPER_INT(sqlite3_column_type)
 SQLITE_WRAPPER_INT(sqlite3_column_blob)
 SQLITE_WRAPPER_INT(sqlite3_column_bytes)
@@ -247,16 +248,21 @@ sqliteInternalCall(JNIEnv* jenv,
         goto error_close;
     }
 
     if (jParams != NULL) {
         // Bind parameters, if any
         if (numPars > 0) {
             for (int i = 0; i < numPars; i++) {
                 jobject jObjectParam = jenv->GetObjectArrayElement(jParams, i);
+                if (jObjectParam == NULL) {
+                  // SQLite parameters index from 1
+                  rc = f_sqlite3_bind_null(ppStmt, i + 1);
+                  continue;
+                }
                 // IsInstanceOf or isAssignableFrom? String is final, so IsInstanceOf
                 // should be OK.
                 jboolean isString = jenv->IsInstanceOf(jObjectParam, stringClass);
                 if (isString != JNI_TRUE) {
                     asprintf(&errorMsg, "Parameter is not of String type");
                     goto error_close;
                 }
                 jstring jStringParam = (jstring)jObjectParam;
--- a/mozglue/android/SQLiteBridge.h
+++ b/mozglue/android/SQLiteBridge.h
@@ -13,16 +13,17 @@ void setup_sqlite_functions(void *sqlite
 typedef return_type (*name ## _t)(args);  \
 extern name ## _t f_ ## name;
 
 SQLITE_WRAPPER(sqlite3_open, int, const char*, sqlite3**)
 SQLITE_WRAPPER(sqlite3_errmsg, const char*, sqlite3*)
 SQLITE_WRAPPER(sqlite3_prepare_v2, int, sqlite3*, const char*, int, sqlite3_stmt**, const char**)
 SQLITE_WRAPPER(sqlite3_bind_parameter_count, int, sqlite3_stmt*)
 SQLITE_WRAPPER(sqlite3_bind_text, int, sqlite3_stmt*, int, const char*, int, void(*)(void*))
+SQLITE_WRAPPER(sqlite3_bind_null, int, sqlite3_stmt*, int)
 SQLITE_WRAPPER(sqlite3_step, int, sqlite3_stmt*)
 SQLITE_WRAPPER(sqlite3_column_count, int, sqlite3_stmt*)
 SQLITE_WRAPPER(sqlite3_finalize, int, sqlite3_stmt*)
 SQLITE_WRAPPER(sqlite3_close, int, sqlite3*)
 SQLITE_WRAPPER(sqlite3_column_name, const char*, sqlite3_stmt*, int)
 SQLITE_WRAPPER(sqlite3_column_type, int, sqlite3_stmt*, int)
 SQLITE_WRAPPER(sqlite3_column_blob, const void*, sqlite3_stmt*, int)
 SQLITE_WRAPPER(sqlite3_column_bytes, int, sqlite3_stmt*, int)