SQLite Android Bindings
Check-in [2aa724ae34]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Apply the 64-bit pointer fix to this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | api-level-15
Files: files | file ages | folders
SHA1: 2aa724ae349a3c4268e78ee341ceacf6f697b163
User & Date: dan 2015-04-04 08:23:51
Context
2016-05-20
18:45
Update to Android Studio and gradle build system. Closed-Leaf check-in: f82877032c user: dan tags: api-level-15
2015-04-04
08:23
Apply the 64-bit pointer fix to this branch. check-in: 2aa724ae34 user: dan tags: api-level-15
08:19
Update this code to support 64-bit pointers. See also: https://android.googlesource.com/platform/frameworks/base.git/+/738702d28ab7e0e89e3c6e18fd46cc1361917eb9 check-in: 3e4327dc6e user: dan tags: trunk
2015-03-03
15:42
Merge fix for supplementary unicode characters with this branch. check-in: 530b9f3aef user: dan tags: api-level-15
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to jni/sqlite/android_database_SQLiteConnection.cpp.

   137    137     rc = memcmp(pKey1, pKey2, n);
   138    138     if( rc==0 ){
   139    139       rc = nKey1 - nKey2;
   140    140     }
   141    141     return rc;
   142    142   }
   143    143   
   144         -static jint nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFlags,
          144  +static jlong nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFlags,
   145    145           jstring labelStr, jboolean enableTrace, jboolean enableProfile) {
   146    146       int sqliteFlags;
   147    147       if (openFlags & SQLiteConnection::CREATE_IF_NECESSARY) {
   148    148           sqliteFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
   149    149       } else if (openFlags & SQLiteConnection::OPEN_READONLY) {
   150    150           sqliteFlags = SQLITE_OPEN_READONLY;
   151    151       } else {
................................................................................
   206    206           sqlite3_trace(db, &sqliteTraceCallback, connection);
   207    207       }
   208    208       if (enableProfile) {
   209    209           sqlite3_profile(db, &sqliteProfileCallback, connection);
   210    210       }
   211    211   
   212    212       ALOGV("Opened connection %p with label '%s'", db, label.c_str());
   213         -    return reinterpret_cast<jint>(connection);
          213  +    return reinterpret_cast<jlong>(connection);
   214    214   }
   215    215   
   216         -static void nativeClose(JNIEnv* env, jclass clazz, jint connectionPtr) {
          216  +static void nativeClose(JNIEnv* env, jclass clazz, jlong connectionPtr) {
   217    217       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   218    218   
   219    219       if (connection) {
   220    220           ALOGV("Closing connection %p", connection->db);
   221    221           int err = sqlite3_close(connection->db);
   222    222           if (err != SQLITE_OK) {
   223    223               // This can happen if sub-objects aren't closed first.  Make sure the caller knows.
................................................................................
   281    281   static void sqliteCustomFunctionDestructor(void* data) {
   282    282       jobject functionObjGlobal = reinterpret_cast<jobject>(data);
   283    283       JNIEnv* env = 0;
   284    284       gpJavaVM->GetEnv((void**)&env, JNI_VERSION_1_4);
   285    285       env->DeleteGlobalRef(functionObjGlobal);
   286    286   }
   287    287   
   288         -static void nativeRegisterCustomFunction(JNIEnv* env, jclass clazz, jint connectionPtr,
          288  +static void nativeRegisterCustomFunction(JNIEnv* env, jclass clazz, jlong connectionPtr,
   289    289           jobject functionObj) {
   290    290       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   291    291   
   292    292       jstring nameStr = jstring(env->GetObjectField(
   293    293               functionObj, gSQLiteCustomFunctionClassInfo.name));
   294    294       jint numArgs = env->GetIntField(functionObj, gSQLiteCustomFunctionClassInfo.numArgs);
   295    295   
................................................................................
   305    305           ALOGE("sqlite3_create_function returned %d", err);
   306    306           env->DeleteGlobalRef(functionObjGlobal);
   307    307           throw_sqlite3_exception(env, connection->db);
   308    308           return;
   309    309       }
   310    310   }
   311    311   
   312         -static void nativeRegisterLocalizedCollators(JNIEnv* env, jclass clazz, jint connectionPtr,
          312  +static void nativeRegisterLocalizedCollators(JNIEnv* env, jclass clazz, jlong connectionPtr,
   313    313           jstring localeStr) {
   314    314       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   315    315   
   316    316       const char* locale = env->GetStringUTFChars(localeStr, NULL);
   317    317   #if 0
   318    318       int err = register_localized_collators(connection->db, locale, UTF16_STORAGE);
   319    319       env->ReleaseStringUTFChars(localeStr, locale);
................................................................................
   320    320   
   321    321       if (err != SQLITE_OK) {
   322    322           throw_sqlite3_exception(env, connection->db);
   323    323       }
   324    324   #endif
   325    325   }
   326    326   
   327         -static jint nativePrepareStatement(JNIEnv* env, jclass clazz, jint connectionPtr,
          327  +static jlong nativePrepareStatement(JNIEnv* env, jclass clazz, jlong connectionPtr,
   328    328           jstring sqlString) {
   329    329       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   330    330   
   331    331       jsize sqlLength = env->GetStringLength(sqlString);
   332    332       const jchar* sql = env->GetStringCritical(sqlString, NULL);
   333    333       sqlite3_stmt* statement;
   334    334       int err = sqlite3_prepare16_v2(connection->db,
................................................................................
   348    348           env->ReleaseStringUTFChars(sqlString, query);
   349    349           throw_sqlite3_exception(env, connection->db, message);
   350    350           free(message);
   351    351           return 0;
   352    352       }
   353    353   
   354    354       ALOGV("Prepared statement %p on connection %p", statement, connection->db);
   355         -    return reinterpret_cast<jint>(statement);
          355  +    return reinterpret_cast<jlong>(statement);
   356    356   }
   357    357   
   358         -static void nativeFinalizeStatement(JNIEnv* env, jclass clazz, jint connectionPtr,
   359         -        jint statementPtr) {
          358  +static void nativeFinalizeStatement(JNIEnv* env, jclass clazz, jlong connectionPtr,
          359  +        jlong statementPtr) {
   360    360       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   361    361       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   362    362   
   363    363       // We ignore the result of sqlite3_finalize because it is really telling us about
   364    364       // whether any errors occurred while executing the statement.  The statement itself
   365    365       // is always finalized regardless.
   366    366       ALOGV("Finalized statement %p on connection %p", statement, connection->db);
   367    367       sqlite3_finalize(statement);
   368    368   }
   369    369   
   370         -static jint nativeGetParameterCount(JNIEnv* env, jclass clazz, jint connectionPtr,
   371         -        jint statementPtr) {
          370  +static jint nativeGetParameterCount(JNIEnv* env, jclass clazz, jlong connectionPtr,
          371  +        jlong statementPtr) {
   372    372       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   373    373       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   374    374   
   375    375       return sqlite3_bind_parameter_count(statement);
   376    376   }
   377    377   
   378         -static jboolean nativeIsReadOnly(JNIEnv* env, jclass clazz, jint connectionPtr,
   379         -        jint statementPtr) {
          378  +static jboolean nativeIsReadOnly(JNIEnv* env, jclass clazz, jlong connectionPtr,
          379  +        jlong statementPtr) {
   380    380       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   381    381       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   382    382   
   383    383       return sqlite3_stmt_readonly(statement) != 0;
   384    384   }
   385    385   
   386         -static jint nativeGetColumnCount(JNIEnv* env, jclass clazz, jint connectionPtr,
   387         -        jint statementPtr) {
          386  +static jint nativeGetColumnCount(JNIEnv* env, jclass clazz, jlong connectionPtr,
          387  +        jlong statementPtr) {
   388    388       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   389    389       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   390    390   
   391    391       return sqlite3_column_count(statement);
   392    392   }
   393    393   
   394         -static jstring nativeGetColumnName(JNIEnv* env, jclass clazz, jint connectionPtr,
   395         -        jint statementPtr, jint index) {
          394  +static jstring nativeGetColumnName(JNIEnv* env, jclass clazz, jlong connectionPtr,
          395  +        jlong statementPtr, jint index) {
   396    396       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   397    397       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   398    398   
   399    399       const jchar* name = static_cast<const jchar*>(sqlite3_column_name16(statement, index));
   400    400       if (name) {
   401    401           size_t length = 0;
   402    402           while (name[length]) {
................................................................................
   403    403               length += 1;
   404    404           }
   405    405           return env->NewString(name, length);
   406    406       }
   407    407       return NULL;
   408    408   }
   409    409   
   410         -static void nativeBindNull(JNIEnv* env, jclass clazz, jint connectionPtr,
   411         -        jint statementPtr, jint index) {
          410  +static void nativeBindNull(JNIEnv* env, jclass clazz, jlong connectionPtr,
          411  +        jlong statementPtr, jint index) {
   412    412       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   413    413       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   414    414   
   415    415       int err = sqlite3_bind_null(statement, index);
   416    416       if (err != SQLITE_OK) {
   417    417           throw_sqlite3_exception(env, connection->db, NULL);
   418    418       }
   419    419   }
   420    420   
   421         -static void nativeBindLong(JNIEnv* env, jclass clazz, jint connectionPtr,
   422         -        jint statementPtr, jint index, jlong value) {
          421  +static void nativeBindLong(JNIEnv* env, jclass clazz, jlong connectionPtr,
          422  +        jlong statementPtr, jint index, jlong value) {
   423    423       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   424    424       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   425    425   
   426    426       int err = sqlite3_bind_int64(statement, index, value);
   427    427       if (err != SQLITE_OK) {
   428    428           throw_sqlite3_exception(env, connection->db, NULL);
   429    429       }
   430    430   }
   431    431   
   432         -static void nativeBindDouble(JNIEnv* env, jclass clazz, jint connectionPtr,
   433         -        jint statementPtr, jint index, jdouble value) {
          432  +static void nativeBindDouble(JNIEnv* env, jclass clazz, jlong connectionPtr,
          433  +        jlong statementPtr, jint index, jdouble value) {
   434    434       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   435    435       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   436    436   
   437    437       int err = sqlite3_bind_double(statement, index, value);
   438    438       if (err != SQLITE_OK) {
   439    439           throw_sqlite3_exception(env, connection->db, NULL);
   440    440       }
   441    441   }
   442    442   
   443         -static void nativeBindString(JNIEnv* env, jclass clazz, jint connectionPtr,
   444         -        jint statementPtr, jint index, jstring valueString) {
          443  +static void nativeBindString(JNIEnv* env, jclass clazz, jlong connectionPtr,
          444  +        jlong statementPtr, jint index, jstring valueString) {
   445    445       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   446    446       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   447    447   
   448    448       jsize valueLength = env->GetStringLength(valueString);
   449    449       const jchar* value = env->GetStringCritical(valueString, NULL);
   450    450       int err = sqlite3_bind_text16(statement, index, value, valueLength * sizeof(jchar),
   451    451               SQLITE_TRANSIENT);
   452    452       env->ReleaseStringCritical(valueString, value);
   453    453       if (err != SQLITE_OK) {
   454    454           throw_sqlite3_exception(env, connection->db, NULL);
   455    455       }
   456    456   }
   457    457   
   458         -static void nativeBindBlob(JNIEnv* env, jclass clazz, jint connectionPtr,
   459         -        jint statementPtr, jint index, jbyteArray valueArray) {
          458  +static void nativeBindBlob(JNIEnv* env, jclass clazz, jlong connectionPtr,
          459  +        jlong statementPtr, jint index, jbyteArray valueArray) {
   460    460       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   461    461       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   462    462   
   463    463       jsize valueLength = env->GetArrayLength(valueArray);
   464    464       jbyte* value = static_cast<jbyte*>(env->GetPrimitiveArrayCritical(valueArray, NULL));
   465    465       int err = sqlite3_bind_blob(statement, index, value, valueLength, SQLITE_TRANSIENT);
   466    466       env->ReleasePrimitiveArrayCritical(valueArray, value, JNI_ABORT);
   467    467       if (err != SQLITE_OK) {
   468    468           throw_sqlite3_exception(env, connection->db, NULL);
   469    469       }
   470    470   }
   471    471   
   472         -static void nativeResetStatementAndClearBindings(JNIEnv* env, jclass clazz, jint connectionPtr,
   473         -        jint statementPtr) {
          472  +static void nativeResetStatementAndClearBindings(JNIEnv* env, jclass clazz, jlong connectionPtr,
          473  +        jlong statementPtr) {
   474    474       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   475    475       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   476    476   
   477    477       int err = sqlite3_reset(statement);
   478    478       if (err == SQLITE_OK) {
   479    479           err = sqlite3_clear_bindings(statement);
   480    480       }
................................................................................
   490    490                   "Queries can be performed using SQLiteDatabase query or rawQuery methods only.");
   491    491       } else if (err != SQLITE_DONE) {
   492    492           throw_sqlite3_exception(env, connection->db);
   493    493       }
   494    494       return err;
   495    495   }
   496    496   
   497         -static void nativeExecute(JNIEnv* env, jclass clazz, jint connectionPtr,
   498         -        jint statementPtr) {
          497  +static void nativeExecute(JNIEnv* env, jclass clazz, jlong connectionPtr,
          498  +        jlong statementPtr) {
   499    499       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   500    500       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   501    501   
   502    502       executeNonQuery(env, connection, statement);
   503    503   }
   504    504   
   505    505   static jint nativeExecuteForChangedRowCount(JNIEnv* env, jclass clazz,
   506         -        jint connectionPtr, jint statementPtr) {
          506  +        jlong connectionPtr, jlong statementPtr) {
   507    507       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   508    508       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   509    509   
   510    510       int err = executeNonQuery(env, connection, statement);
   511    511       return err == SQLITE_DONE ? sqlite3_changes(connection->db) : -1;
   512    512   }
   513    513   
   514    514   static jlong nativeExecuteForLastInsertedRowId(JNIEnv* env, jclass clazz,
   515         -        jint connectionPtr, jint statementPtr) {
          515  +        jlong connectionPtr, jlong statementPtr) {
   516    516       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   517    517       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   518    518   
   519    519       int err = executeNonQuery(env, connection, statement);
   520    520       return err == SQLITE_DONE && sqlite3_changes(connection->db) > 0
   521    521               ? sqlite3_last_insert_rowid(connection->db) : -1;
   522    522   }
................................................................................
   526    526       if (err != SQLITE_ROW) {
   527    527           throw_sqlite3_exception(env, connection->db);
   528    528       }
   529    529       return err;
   530    530   }
   531    531   
   532    532   static jlong nativeExecuteForLong(JNIEnv* env, jclass clazz,
   533         -        jint connectionPtr, jint statementPtr) {
          533  +        jlong connectionPtr, jlong statementPtr) {
   534    534       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   535    535       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   536    536   
   537    537       int err = executeOneRowQuery(env, connection, statement);
   538    538       if (err == SQLITE_ROW && sqlite3_column_count(statement) >= 1) {
   539    539           return sqlite3_column_int64(statement, 0);
   540    540       }
   541    541       return -1;
   542    542   }
   543    543   
   544    544   static jstring nativeExecuteForString(JNIEnv* env, jclass clazz,
   545         -        jint connectionPtr, jint statementPtr) {
          545  +        jlong connectionPtr, jlong statementPtr) {
   546    546       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   547    547       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   548    548   
   549    549       int err = executeOneRowQuery(env, connection, statement);
   550    550       if (err == SQLITE_ROW && sqlite3_column_count(statement) >= 1) {
   551    551           const jchar* text = static_cast<const jchar*>(sqlite3_column_text16(statement, 0));
   552    552           if (text) {
................................................................................
   590    590   
   591    591   #endif
   592    592       jniThrowIOException(env, -1);
   593    593       return -1;
   594    594   }
   595    595   
   596    596   static jint nativeExecuteForBlobFileDescriptor(JNIEnv* env, jclass clazz,
   597         -        jint connectionPtr, jint statementPtr) {
          597  +        jlong connectionPtr, jlong statementPtr) {
   598    598       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   599    599       sqlite3_stmt* statement = reinterpret_cast<sqlite3_stmt*>(statementPtr);
   600    600   
   601    601       int err = executeOneRowQuery(env, connection, statement);
   602    602       if (err == SQLITE_ROW && sqlite3_column_count(statement) >= 1) {
   603    603           const void* blob = sqlite3_column_blob(statement, 0);
   604    604           if (blob) {
................................................................................
   740    740   ** If the countAllRows argument is true, nRow is the total number of rows
   741    741   ** returned by the query. Otherwise, nRow is one greater than the index of 
   742    742   ** the last row copied into the CursorWindow.
   743    743   */
   744    744   static jlong nativeExecuteForCursorWindow(
   745    745     JNIEnv *pEnv, 
   746    746     jclass clazz,
   747         -  jint connectionPtr,             /* Pointer to SQLiteConnection C++ object */
   748         -  jint statementPtr,              /* Pointer to sqlite3_stmt object */
          747  +  jlong connectionPtr,            /* Pointer to SQLiteConnection C++ object */
          748  +  jlong statementPtr,             /* Pointer to sqlite3_stmt object */
   749    749     jobject win,                    /* The CursorWindow object to populate */
   750    750     jint startPos,                  /* First row to add (advisory) */
   751    751     jint iRowRequired,              /* Required row */
   752    752     jboolean countAllRows
   753    753   ) {
   754    754     SQLiteConnection *pConnection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   755    755     sqlite3_stmt *pStmt = reinterpret_cast<sqlite3_stmt*>(statementPtr);
................................................................................
   827    827       return 0;
   828    828     }
   829    829   
   830    830     jlong lRet = jlong(iStart) << 32 | jlong(nRow);
   831    831     return lRet;
   832    832   }
   833    833   
   834         -static jint nativeGetDbLookaside(JNIEnv* env, jobject clazz, jint connectionPtr) {
          834  +static jint nativeGetDbLookaside(JNIEnv* env, jobject clazz, jlong connectionPtr) {
   835    835       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   836    836   
   837    837       int cur = -1;
   838    838       int unused;
   839    839       sqlite3_db_status(connection->db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur, &unused, 0);
   840    840       return cur;
   841    841   }
   842    842   
   843         -static void nativeCancel(JNIEnv* env, jobject clazz, jint connectionPtr) {
          843  +static void nativeCancel(JNIEnv* env, jobject clazz, jlong connectionPtr) {
   844    844       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   845    845       connection->canceled = true;
   846    846   }
   847    847   
   848         -static void nativeResetCancel(JNIEnv* env, jobject clazz, jint connectionPtr,
          848  +static void nativeResetCancel(JNIEnv* env, jobject clazz, jlong connectionPtr,
   849    849           jboolean cancelable) {
   850    850       SQLiteConnection* connection = reinterpret_cast<SQLiteConnection*>(connectionPtr);
   851    851       connection->canceled = false;
   852    852   
   853    853       if (cancelable) {
   854    854           sqlite3_progress_handler(connection->db, 4, sqliteProgressHandlerCallback,
   855    855                   connection);
................................................................................
   866    866   #endif
   867    867   }
   868    868   
   869    869   
   870    870   static JNINativeMethod sMethods[] =
   871    871   {
   872    872       /* name, signature, funcPtr */
   873         -    { "nativeOpen", "(Ljava/lang/String;ILjava/lang/String;ZZ)I",
          873  +    { "nativeOpen", "(Ljava/lang/String;ILjava/lang/String;ZZ)J",
   874    874               (void*)nativeOpen },
   875         -    { "nativeClose", "(I)V",
          875  +    { "nativeClose", "(J)V",
   876    876               (void*)nativeClose },
   877         -    { "nativeRegisterCustomFunction", "(ILorg/sqlite/database/sqlite/SQLiteCustomFunction;)V",
          877  +    { "nativeRegisterCustomFunction", "(JLorg/sqlite/database/sqlite/SQLiteCustomFunction;)V",
   878    878               (void*)nativeRegisterCustomFunction },
   879         -    { "nativeRegisterLocalizedCollators", "(ILjava/lang/String;)V",
          879  +    { "nativeRegisterLocalizedCollators", "(JLjava/lang/String;)V",
   880    880               (void*)nativeRegisterLocalizedCollators },
   881         -    { "nativePrepareStatement", "(ILjava/lang/String;)I",
          881  +    { "nativePrepareStatement", "(JLjava/lang/String;)J",
   882    882               (void*)nativePrepareStatement },
   883         -    { "nativeFinalizeStatement", "(II)V",
          883  +    { "nativeFinalizeStatement", "(JJ)V",
   884    884               (void*)nativeFinalizeStatement },
   885         -    { "nativeGetParameterCount", "(II)I",
          885  +    { "nativeGetParameterCount", "(JJ)I",
   886    886               (void*)nativeGetParameterCount },
   887         -    { "nativeIsReadOnly", "(II)Z",
          887  +    { "nativeIsReadOnly", "(JJ)Z",
   888    888               (void*)nativeIsReadOnly },
   889         -    { "nativeGetColumnCount", "(II)I",
          889  +    { "nativeGetColumnCount", "(JJ)I",
   890    890               (void*)nativeGetColumnCount },
   891         -    { "nativeGetColumnName", "(III)Ljava/lang/String;",
          891  +    { "nativeGetColumnName", "(JJI)Ljava/lang/String;",
   892    892               (void*)nativeGetColumnName },
   893         -    { "nativeBindNull", "(III)V",
          893  +    { "nativeBindNull", "(JJI)V",
   894    894               (void*)nativeBindNull },
   895         -    { "nativeBindLong", "(IIIJ)V",
          895  +    { "nativeBindLong", "(JJIJ)V",
   896    896               (void*)nativeBindLong },
   897         -    { "nativeBindDouble", "(IIID)V",
          897  +    { "nativeBindDouble", "(JJID)V",
   898    898               (void*)nativeBindDouble },
   899         -    { "nativeBindString", "(IIILjava/lang/String;)V",
          899  +    { "nativeBindString", "(JJILjava/lang/String;)V",
   900    900               (void*)nativeBindString },
   901         -    { "nativeBindBlob", "(III[B)V",
          901  +    { "nativeBindBlob", "(JJI[B)V",
   902    902               (void*)nativeBindBlob },
   903         -    { "nativeResetStatementAndClearBindings", "(II)V",
          903  +    { "nativeResetStatementAndClearBindings", "(JJ)V",
   904    904               (void*)nativeResetStatementAndClearBindings },
   905         -    { "nativeExecute", "(II)V",
          905  +    { "nativeExecute", "(JJ)V",
   906    906               (void*)nativeExecute },
   907         -    { "nativeExecuteForLong", "(II)J",
          907  +    { "nativeExecuteForLong", "(JJ)J",
   908    908               (void*)nativeExecuteForLong },
   909         -    { "nativeExecuteForString", "(II)Ljava/lang/String;",
          909  +    { "nativeExecuteForString", "(JJ)Ljava/lang/String;",
   910    910               (void*)nativeExecuteForString },
   911         -    { "nativeExecuteForBlobFileDescriptor", "(II)I",
          911  +    { "nativeExecuteForBlobFileDescriptor", "(JJ)I",
   912    912               (void*)nativeExecuteForBlobFileDescriptor },
   913         -    { "nativeExecuteForChangedRowCount", "(II)I",
          913  +    { "nativeExecuteForChangedRowCount", "(JJ)I",
   914    914               (void*)nativeExecuteForChangedRowCount },
   915         -    { "nativeExecuteForLastInsertedRowId", "(II)J",
          915  +    { "nativeExecuteForLastInsertedRowId", "(JJ)J",
   916    916               (void*)nativeExecuteForLastInsertedRowId },
   917         -    { "nativeExecuteForCursorWindow", "(IILandroid/database/CursorWindow;IIZ)J",
          917  +    { "nativeExecuteForCursorWindow", "(JJLandroid/database/CursorWindow;IIZ)J",
   918    918               (void*)nativeExecuteForCursorWindow },
   919         -    { "nativeGetDbLookaside", "(I)I",
          919  +    { "nativeGetDbLookaside", "(J)I",
   920    920               (void*)nativeGetDbLookaside },
   921         -    { "nativeCancel", "(I)V",
          921  +    { "nativeCancel", "(J)V",
   922    922               (void*)nativeCancel },
   923         -    { "nativeResetCancel", "(IZ)V",
          923  +    { "nativeResetCancel", "(JZ)V",
   924    924               (void*)nativeResetCancel },
   925    925   
   926    926       { "nativeHasCodec", "()Z", (void*)nativeHasCodec },
   927    927   };
   928    928   
   929    929   #define FIND_CLASS(var, className) \
   930    930           var = env->FindClass(className); \

Changes to src/org/sqlite/database/sqlite/SQLiteConnection.java.

   108    108       private final PreparedStatementCache mPreparedStatementCache;
   109    109       private PreparedStatement mPreparedStatementPool;
   110    110   
   111    111       // The recent operations log.
   112    112       private final OperationLog mRecentOperations = new OperationLog();
   113    113   
   114    114       // The native SQLiteConnection pointer.  (FOR INTERNAL USE ONLY)
   115         -    private int mConnectionPtr;
          115  +    private long mConnectionPtr;
   116    116   
   117    117       private boolean mOnlyAllowReadOnlyOperations;
   118    118   
   119    119       // The number of times attachCancellationSignal has been called.
   120    120       // Because SQLite statement execution can be reentrant, we keep track of how many
   121    121       // times we have attempted to attach a cancellation signal to the connection so that
   122    122       // we can ensure that we detach the signal at the right time.
   123    123       private int mCancellationSignalAttachCount;
   124    124   
   125         -    private static native int nativeOpen(String path, int openFlags, String label,
          125  +    private static native long nativeOpen(String path, int openFlags, String label,
   126    126               boolean enableTrace, boolean enableProfile);
   127         -    private static native void nativeClose(int connectionPtr);
   128         -    private static native void nativeRegisterCustomFunction(int connectionPtr,
          127  +    private static native void nativeClose(long connectionPtr);
          128  +    private static native void nativeRegisterCustomFunction(long connectionPtr,
   129    129               SQLiteCustomFunction function);
   130         -    private static native void nativeRegisterLocalizedCollators(int connectionPtr, String locale);
   131         -    private static native int nativePrepareStatement(int connectionPtr, String sql);
   132         -    private static native void nativeFinalizeStatement(int connectionPtr, int statementPtr);
   133         -    private static native int nativeGetParameterCount(int connectionPtr, int statementPtr);
   134         -    private static native boolean nativeIsReadOnly(int connectionPtr, int statementPtr);
   135         -    private static native int nativeGetColumnCount(int connectionPtr, int statementPtr);
   136         -    private static native String nativeGetColumnName(int connectionPtr, int statementPtr,
          130  +    private static native void nativeRegisterLocalizedCollators(long connectionPtr, String locale);
          131  +    private static native long nativePrepareStatement(long connectionPtr, String sql);
          132  +    private static native void nativeFinalizeStatement(long connectionPtr, long statementPtr);
          133  +    private static native int nativeGetParameterCount(long connectionPtr, long statementPtr);
          134  +    private static native boolean nativeIsReadOnly(long connectionPtr, long statementPtr);
          135  +    private static native int nativeGetColumnCount(long connectionPtr, long statementPtr);
          136  +    private static native String nativeGetColumnName(long connectionPtr, long statementPtr,
          137  +            int index);
          138  +    private static native void nativeBindNull(long connectionPtr, long statementPtr,
   137    139               int index);
   138         -    private static native void nativeBindNull(int connectionPtr, int statementPtr,
   139         -            int index);
   140         -    private static native void nativeBindLong(int connectionPtr, int statementPtr,
          140  +    private static native void nativeBindLong(long connectionPtr, long statementPtr,
   141    141               int index, long value);
   142         -    private static native void nativeBindDouble(int connectionPtr, int statementPtr,
          142  +    private static native void nativeBindDouble(long connectionPtr, long statementPtr,
   143    143               int index, double value);
   144         -    private static native void nativeBindString(int connectionPtr, int statementPtr,
          144  +    private static native void nativeBindString(long connectionPtr, long statementPtr,
   145    145               int index, String value);
   146         -    private static native void nativeBindBlob(int connectionPtr, int statementPtr,
          146  +    private static native void nativeBindBlob(long connectionPtr, long statementPtr,
   147    147               int index, byte[] value);
   148    148       private static native void nativeResetStatementAndClearBindings(
   149         -            int connectionPtr, int statementPtr);
   150         -    private static native void nativeExecute(int connectionPtr, int statementPtr);
   151         -    private static native long nativeExecuteForLong(int connectionPtr, int statementPtr);
   152         -    private static native String nativeExecuteForString(int connectionPtr, int statementPtr);
          149  +            long connectionPtr, long statementPtr);
          150  +    private static native void nativeExecute(long connectionPtr, long statementPtr);
          151  +    private static native long nativeExecuteForLong(long connectionPtr, long statementPtr);
          152  +    private static native String nativeExecuteForString(long connectionPtr, long statementPtr);
   153    153       private static native int nativeExecuteForBlobFileDescriptor(
   154         -            int connectionPtr, int statementPtr);
   155         -    private static native int nativeExecuteForChangedRowCount(int connectionPtr, int statementPtr);
          154  +            long connectionPtr, long statementPtr);
          155  +    private static native int nativeExecuteForChangedRowCount(long connectionPtr, long statementPtr);
   156    156       private static native long nativeExecuteForLastInsertedRowId(
   157         -            int connectionPtr, int statementPtr);
          157  +            long connectionPtr, long statementPtr);
   158    158       private static native long nativeExecuteForCursorWindow(
   159         -            int connectionPtr, int statementPtr, CursorWindow win,
          159  +            long connectionPtr, long statementPtr, CursorWindow win,
   160    160               int startPos, int requiredPos, boolean countAllRows);
   161         -    private static native int nativeGetDbLookaside(int connectionPtr);
   162         -    private static native void nativeCancel(int connectionPtr);
   163         -    private static native void nativeResetCancel(int connectionPtr, boolean cancelable);
          161  +    private static native int nativeGetDbLookaside(long connectionPtr);
          162  +    private static native void nativeCancel(long connectionPtr);
          163  +    private static native void nativeResetCancel(long connectionPtr, boolean cancelable);
   164    164   
   165    165       private static native boolean nativeHasCodec();
   166    166       public static boolean hasCodec(){ return nativeHasCodec(); }
   167    167   
   168    168       private SQLiteConnection(SQLiteConnectionPool pool,
   169    169               SQLiteDatabaseConfiguration configuration,
   170    170               int connectionId, boolean primaryConnection) {
................................................................................
   898    898               }
   899    899               // The statement is already in the cache but is in use (this statement appears
   900    900               // to be not only re-entrant but recursive!).  So prepare a new copy of the
   901    901               // statement but do not cache it.
   902    902               skipCache = true;
   903    903           }
   904    904   
   905         -        final int statementPtr = nativePrepareStatement(mConnectionPtr, sql);
          905  +        final long statementPtr = nativePrepareStatement(mConnectionPtr, sql);
   906    906           try {
   907    907               final int numParameters = nativeGetParameterCount(mConnectionPtr, statementPtr);
   908    908               final int type = DatabaseUtils.getSqlStatementType(sql);
   909    909               final boolean readOnly = nativeIsReadOnly(mConnectionPtr, statementPtr);
   910    910               statement = obtainPreparedStatement(sql, statementPtr, numParameters, type, readOnly);
   911    911               if (!skipCache && isCacheable(type)) {
   912    912                   mPreparedStatementCache.put(sql, statement);
................................................................................
   999    999                       "Expected " + statement.mNumParameters + " bind arguments but "
  1000   1000                       + count + " were provided.");
  1001   1001           }
  1002   1002           if (count == 0) {
  1003   1003               return;
  1004   1004           }
  1005   1005   
  1006         -        final int statementPtr = statement.mStatementPtr;
         1006  +        final long statementPtr = statement.mStatementPtr;
  1007   1007           for (int i = 0; i < count; i++) {
  1008   1008               final Object arg = bindArgs[i];
  1009   1009               switch (ExtraUtils.getTypeOfObject(arg)) {
  1010   1010                   case Cursor.FIELD_TYPE_NULL:
  1011   1011                       nativeBindNull(mConnectionPtr, statementPtr, i + 1);
  1012   1012                       break;
  1013   1013                   case Cursor.FIELD_TYPE_INTEGER:
................................................................................
  1084   1084        *
  1085   1085        * @param printer The printer to receive the dump, not null.
  1086   1086        * @param verbose True to dump more verbose information.
  1087   1087        */
  1088   1088       void dumpUnsafe(Printer printer, boolean verbose) {
  1089   1089           printer.println("Connection #" + mConnectionId + ":");
  1090   1090           if (verbose) {
  1091         -            printer.println("  connectionPtr: 0x" + Integer.toHexString(mConnectionPtr));
         1091  +            printer.println("  connectionPtr: 0x" + Long.toHexString(mConnectionPtr));
  1092   1092           }
  1093   1093           printer.println("  isPrimaryConnection: " + mIsPrimaryConnection);
  1094   1094           printer.println("  onlyAllowReadOnlyOperations: " + mOnlyAllowReadOnlyOperations);
  1095   1095   
  1096   1096           mRecentOperations.dump(printer, verbose);
  1097   1097   
  1098   1098           if (verbose) {
................................................................................
  1190   1190       }
  1191   1191   
  1192   1192       @Override
  1193   1193       public String toString() {
  1194   1194           return "SQLiteConnection: " + mConfiguration.path + " (" + mConnectionId + ")";
  1195   1195       }
  1196   1196   
  1197         -    private PreparedStatement obtainPreparedStatement(String sql, int statementPtr,
         1197  +    private PreparedStatement obtainPreparedStatement(String sql, long statementPtr,
  1198   1198               int numParameters, int type, boolean readOnly) {
  1199   1199           PreparedStatement statement = mPreparedStatementPool;
  1200   1200           if (statement != null) {
  1201   1201               mPreparedStatementPool = statement.mPoolNext;
  1202   1202               statement.mPoolNext = null;
  1203   1203               statement.mInCache = false;
  1204   1204           } else {
................................................................................
  1237   1237           public PreparedStatement mPoolNext;
  1238   1238   
  1239   1239           // The SQL from which the statement was prepared.
  1240   1240           public String mSql;
  1241   1241   
  1242   1242           // The native sqlite3_stmt object pointer.
  1243   1243           // Lifetime is managed explicitly by the connection.
  1244         -        public int mStatementPtr;
         1244  +        public long mStatementPtr;
  1245   1245   
  1246   1246           // The number of parameters that the prepared statement has.
  1247   1247           public int mNumParameters;
  1248   1248   
  1249   1249           // The statement type.
  1250   1250           public int mType;
  1251   1251   
................................................................................
  1283   1283               if (!cache.isEmpty()) {
  1284   1284                   int i = 0;
  1285   1285                   for (Map.Entry<String, PreparedStatement> entry : cache.entrySet()) {
  1286   1286                       PreparedStatement statement = entry.getValue();
  1287   1287                       if (statement.mInCache) { // might be false due to a race with entryRemoved
  1288   1288                           String sql = entry.getKey();
  1289   1289                           printer.println("    " + i + ": statementPtr=0x"
  1290         -                                + Integer.toHexString(statement.mStatementPtr)
         1290  +                                + Long.toHexString(statement.mStatementPtr)
  1291   1291                                   + ", numParameters=" + statement.mNumParameters
  1292   1292                                   + ", type=" + statement.mType
  1293   1293                                   + ", readOnly=" + statement.mReadOnly
  1294   1294                                   + ", sql=\"" + trimSqlForDisplay(sql) + "\"");
  1295   1295                       }
  1296   1296                       i += 1;
  1297   1297                   }