Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update some other files to better match stock Android. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 253313a7ee8cc014432f1603d7eced48773bd3f5 |
User & Date: | dan 2017-11-28 17:05:09 |
Context
2017-11-28
| ||
18:16 | Fix a broken test case in DatabaseUtilsTest.java. check-in: e4878173ae user: dan tags: trunk | |
17:05 | Update some other files to better match stock Android. check-in: 253313a7ee user: dan tags: trunk | |
15:46 | Update further java classfiles to match the latest Android code. check-in: e782e01fbe user: dan tags: trunk | |
Changes
Changes to sqlite3/src/main/java/org/sqlite/database/sqlite/SQLiteConnection.java.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 .. 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 ... 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 ... 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 .... 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 .... 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 .... 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 .... 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 .... 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 .... 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 |
/* ** Modified to support SQLite extensions by the SQLite developers: ** sqlite-dev@sqlite.org. */ package org.sqlite.database.sqlite; /* import dalvik.system.BlockGuard; */ import org.sqlite.database.sqlite.CloseGuard; import android.database.Cursor; import android.database.CursorWindow; import org.sqlite.database.DatabaseUtils; import org.sqlite.database.sqlite.SQLiteDebug.DbStats; import android.os.CancellationSignal; import android.os.OperationCanceledException; import android.os.ParcelFileDescriptor; import android.util.Log; import android.util.LruCache; import android.util.Printer; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; ................................................................................ public final class SQLiteConnection implements CancellationSignal.OnCancelListener { private static final String TAG = "SQLiteConnection"; private static final boolean DEBUG = false; private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; private static final Pattern TRIM_SQL_PATTERN = Pattern.compile("[\\s]*\\n+[\\s]*"); private final CloseGuard mCloseGuard = CloseGuard.get(); private final SQLiteConnectionPool mPool; private final SQLiteDatabaseConfiguration mConfiguration; private final int mConnectionId; private final boolean mIsPrimaryConnection; private final boolean mIsReadOnlyConnection; ................................................................................ private void open() { mConnectionPtr = nativeOpen(mConfiguration.path, mConfiguration.openFlags, mConfiguration.label, SQLiteDebug.DEBUG_SQL_STATEMENTS, SQLiteDebug.DEBUG_SQL_TIME); setPageSize(); setForeignKeyModeFromConfiguration(); setJournalSizeLimit(); setAutoCheckpointInterval(); setWalModeFromConfiguration(); setLocaleFromConfiguration(); // Register custom functions. final int functionCount = mConfiguration.customFunctions.size(); for (int i = 0; i < functionCount; i++) { SQLiteCustomFunction function = mConfiguration.customFunctions.get(i); nativeRegisterCustomFunction(mConnectionPtr, function); ................................................................................ & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0; boolean localeChanged = !configuration.locale.equals(mConfiguration.locale); // Update configuration parameters. mConfiguration.updateParametersFrom(configuration); // Update prepared statement cache size. /* mPreparedStatementCache.resize(configuration.maxSqlCacheSize); */ // Update foreign key mode. if (foreignKeyModeChanged) { setForeignKeyModeFromConfiguration(); } // Update WAL. ................................................................................ || statementType == DatabaseUtils.STATEMENT_SELECT) { return true; } return false; } private void applyBlockGuardPolicy(PreparedStatement statement) { /* if (!mConfiguration.isInMemoryDb()) {*/ /* if (statement.mReadOnly) {*/ /* BlockGuard.getThreadPolicy().onReadFromDisk();*/ /* } else {*/ /* BlockGuard.getThreadPolicy().onWriteToDisk();*/ /* }*/ /* }*/ } /** * Dumps debugging information about this connection. * * @param printer The printer to receive the dump, not null. * @param verbose True to dump more verbose information. ................................................................................ private void recyclePreparedStatement(PreparedStatement statement) { statement.mSql = null; statement.mPoolNext = mPreparedStatementPool; mPreparedStatementPool = statement; } private static String trimSqlForDisplay(String sql) { return TRIM_SQL_PATTERN.matcher(sql).replaceAll(" "); } /** * Holder type for a prepared statement. * * Although this object holds a pointer to a native statement object, it * does not have a finalizer. This is deliberate. The {@link SQLiteConnection} ................................................................................ } else { operation.mFinished = false; operation.mException = null; if (operation.mBindArgs != null) { operation.mBindArgs.clear(); } } operation.mStartTime = System.currentTimeMillis(); operation.mKind = kind; operation.mSql = sql; if (bindArgs != null) { if (operation.mBindArgs == null) { operation.mBindArgs = new ArrayList<Object>(); } else { operation.mBindArgs.clear(); ................................................................................ logOperationLocked(cookie, detail); } } private boolean endOperationDeferLogLocked(int cookie) { final Operation operation = getOperationLocked(cookie); if (operation != null) { operation.mEndTime = System.currentTimeMillis(); operation.mFinished = true; return SQLiteDebug.DEBUG_LOG_SLOW_QUERIES && SQLiteDebug.shouldLogSlowQuery( operation.mEndTime - operation.mStartTime); } return false; } ................................................................................ printer.println(" <none>"); } } } } private static final class Operation { private static final SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); public long mStartTime; public long mEndTime; public String mKind; public String mSql; public ArrayList<Object> mBindArgs; public boolean mFinished; public Exception mException; public int mCookie; public void describe(StringBuilder msg, boolean verbose) { msg.append(mKind); if (mFinished) { msg.append(" took ").append(mEndTime - mStartTime).append("ms"); } else { msg.append(" started ").append(System.currentTimeMillis() - mStartTime) .append("ms ago"); } msg.append(" - ").append(getStatus()); if (mSql != null) { msg.append(", sql=\"").append(trimSqlForDisplay(mSql)).append("\""); } if (verbose && mBindArgs != null && mBindArgs.size() != 0) { ................................................................................ private String getStatus() { if (!mFinished) { return "running"; } return mException != null ? "failed" : "succeeded"; } private String getFormattedStartTime() { return sDateFormat.format(new Date(mStartTime)); } } } |
< > < < > | < > | < < < < < < < | > > > > | > | > > > > | < > | | | > > > > > > > < > > > > > |
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 .. 91 92 93 94 95 96 97 98 99 100 101 102 103 104 ... 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 ... 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 .... 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 .... 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 .... 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 .... 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 .... 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 .... 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 |
/* ** Modified to support SQLite extensions by the SQLite developers: ** sqlite-dev@sqlite.org. */ package org.sqlite.database.sqlite; import org.sqlite.database.sqlite.CloseGuard; import android.database.Cursor; import android.database.CursorWindow; import org.sqlite.database.DatabaseUtils; import org.sqlite.database.sqlite.SQLiteDebug.DbStats; import android.os.CancellationSignal; import android.os.OperationCanceledException; import android.os.ParcelFileDescriptor; import android.os.SystemClock; import android.util.Log; import android.util.LruCache; import android.util.Printer; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; ................................................................................ public final class SQLiteConnection implements CancellationSignal.OnCancelListener { private static final String TAG = "SQLiteConnection"; private static final boolean DEBUG = false; private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; private final CloseGuard mCloseGuard = CloseGuard.get(); private final SQLiteConnectionPool mPool; private final SQLiteDatabaseConfiguration mConfiguration; private final int mConnectionId; private final boolean mIsPrimaryConnection; private final boolean mIsReadOnlyConnection; ................................................................................ private void open() { mConnectionPtr = nativeOpen(mConfiguration.path, mConfiguration.openFlags, mConfiguration.label, SQLiteDebug.DEBUG_SQL_STATEMENTS, SQLiteDebug.DEBUG_SQL_TIME); setPageSize(); setForeignKeyModeFromConfiguration(); setWalModeFromConfiguration(); setJournalSizeLimit(); setAutoCheckpointInterval(); setLocaleFromConfiguration(); // Register custom functions. final int functionCount = mConfiguration.customFunctions.size(); for (int i = 0; i < functionCount; i++) { SQLiteCustomFunction function = mConfiguration.customFunctions.get(i); nativeRegisterCustomFunction(mConnectionPtr, function); ................................................................................ & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0; boolean localeChanged = !configuration.locale.equals(mConfiguration.locale); // Update configuration parameters. mConfiguration.updateParametersFrom(configuration); // Update prepared statement cache size. // sqlite.org: android.util.LruCache.resize() requires API level 21. // mPreparedStatementCache.resize(configuration.maxSqlCacheSize); // Update foreign key mode. if (foreignKeyModeChanged) { setForeignKeyModeFromConfiguration(); } // Update WAL. ................................................................................ || statementType == DatabaseUtils.STATEMENT_SELECT) { return true; } return false; } private void applyBlockGuardPolicy(PreparedStatement statement) { } /** * Dumps debugging information about this connection. * * @param printer The printer to receive the dump, not null. * @param verbose True to dump more verbose information. ................................................................................ private void recyclePreparedStatement(PreparedStatement statement) { statement.mSql = null; statement.mPoolNext = mPreparedStatementPool; mPreparedStatementPool = statement; } private static String trimSqlForDisplay(String sql) { // Note: Creating and caching a regular expression is expensive at preload-time // and stops compile-time initialization. This pattern is only used when // dumping the connection, which is a rare (mainly error) case. So: // DO NOT CACHE. return sql.replaceAll("[\\s]*\\n+[\\s]*", " "); } /** * Holder type for a prepared statement. * * Although this object holds a pointer to a native statement object, it * does not have a finalizer. This is deliberate. The {@link SQLiteConnection} ................................................................................ } else { operation.mFinished = false; operation.mException = null; if (operation.mBindArgs != null) { operation.mBindArgs.clear(); } } operation.mStartWallTime = System.currentTimeMillis(); operation.mStartTime = SystemClock.uptimeMillis(); operation.mKind = kind; operation.mSql = sql; if (bindArgs != null) { if (operation.mBindArgs == null) { operation.mBindArgs = new ArrayList<Object>(); } else { operation.mBindArgs.clear(); ................................................................................ logOperationLocked(cookie, detail); } } private boolean endOperationDeferLogLocked(int cookie) { final Operation operation = getOperationLocked(cookie); if (operation != null) { operation.mEndTime = SystemClock.uptimeMillis(); operation.mFinished = true; return SQLiteDebug.DEBUG_LOG_SLOW_QUERIES && SQLiteDebug.shouldLogSlowQuery( operation.mEndTime - operation.mStartTime); } return false; } ................................................................................ printer.println(" <none>"); } } } } private static final class Operation { // Trim all SQL statements to 256 characters inside the trace marker. // This limit gives plenty of context while leaving space for other // entries in the trace buffer (and ensures atrace doesn't truncate the // marker for us, potentially losing metadata in the process). private static final int MAX_TRACE_METHOD_NAME_LEN = 256; public long mStartWallTime; // in System.currentTimeMillis() public long mStartTime; // in SystemClock.uptimeMillis(); public long mEndTime; // in SystemClock.uptimeMillis(); public String mKind; public String mSql; public ArrayList<Object> mBindArgs; public boolean mFinished; public Exception mException; public int mCookie; public void describe(StringBuilder msg, boolean verbose) { msg.append(mKind); if (mFinished) { msg.append(" took ").append(mEndTime - mStartTime).append("ms"); } else { msg.append(" started ").append(System.currentTimeMillis() - mStartWallTime) .append("ms ago"); } msg.append(" - ").append(getStatus()); if (mSql != null) { msg.append(", sql=\"").append(trimSqlForDisplay(mSql)).append("\""); } if (verbose && mBindArgs != null && mBindArgs.size() != 0) { ................................................................................ private String getStatus() { if (!mFinished) { return "running"; } return mException != null ? "failed" : "succeeded"; } private String getTraceMethodName() { String methodName = mKind + " " + mSql; if (methodName.length() > MAX_TRACE_METHOD_NAME_LEN) return methodName.substring(0, MAX_TRACE_METHOD_NAME_LEN); return methodName; } private String getFormattedStartTime() { // Note: SimpleDateFormat is not thread-safe, cannot be compile-time created, and is // relatively expensive to create during preloading. This method is only used // when dumping a connection, which is a rare (mainly error) case. So: // DO NOT CACHE. return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(mStartWallTime)); } } } |
Changes to sqlite3/src/main/java/org/sqlite/database/sqlite/SQLiteConnectionPool.java.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 .... 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 .... 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 |
import org.sqlite.database.sqlite.CloseGuard; import org.sqlite.database.sqlite.SQLiteDebug.DbStats; import android.os.CancellationSignal; import android.os.OperationCanceledException; import android.os.SystemClock; import android.util.Log; /* import android.util.PrefixPrinter; */ import android.util.Printer; import java.io.Closeable; import java.util.ArrayList; import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicBoolean; ................................................................................ /** * Dumps debugging information about this connection pool. * * @param printer The printer to receive the dump, not null. * @param verbose True to dump more verbose information. */ public void dump(Printer printer, boolean verbose) { /* Printer indentedPrinter = Printer.create(printer, " "); synchronized (mLock) { printer.println("Connection pool for " + mConfiguration.path + ":"); printer.println(" Open: " + mIsOpen); printer.println(" Max connections: " + mMaxConnectionPoolSize); printer.println(" Available primary connection:"); if (mAvailablePrimaryConnection != null) { ................................................................................ + ", priority=" + waiter.mPriority + ", sql='" + waiter.mSql + "'"); } } else { indentedPrinter.println("<none>"); } } */ } @Override public String toString() { return "SQLiteConnectionPool: " + mConfiguration.path; } |
< < | < |
23 24 25 26 27 28 29 30 31 32 33 34 35 36 .... 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 .... 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
import org.sqlite.database.sqlite.CloseGuard; import org.sqlite.database.sqlite.SQLiteDebug.DbStats; import android.os.CancellationSignal; import android.os.OperationCanceledException; import android.os.SystemClock; import android.util.Log; import android.util.Printer; import java.io.Closeable; import java.util.ArrayList; import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicBoolean; ................................................................................ /** * Dumps debugging information about this connection pool. * * @param printer The printer to receive the dump, not null. * @param verbose True to dump more verbose information. */ public void dump(Printer printer, boolean verbose) { Printer indentedPrinter = printer; synchronized (mLock) { printer.println("Connection pool for " + mConfiguration.path + ":"); printer.println(" Open: " + mIsOpen); printer.println(" Max connections: " + mMaxConnectionPoolSize); printer.println(" Available primary connection:"); if (mAvailablePrimaryConnection != null) { ................................................................................ + ", priority=" + waiter.mPriority + ", sql='" + waiter.mSql + "'"); } } else { indentedPrinter.println("<none>"); } } } @Override public String toString() { return "SQLiteConnectionPool: " + mConfiguration.path; } |
Changes to sqlite3/src/main/java/org/sqlite/database/sqlite/SQLiteCursor.java.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 .. 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 .. 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 ... 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
/* ** Modified to support SQLite extensions by the SQLite developers: ** sqlite-dev@sqlite.org. */ package org.sqlite.database.sqlite; import org.sqlite.database.DatabaseUtils; import android.database.AbstractWindowedCursor; import android.database.CursorWindow; import android.os.StrictMode; import android.util.Log; import java.util.HashMap; import java.util.Map; ................................................................................ /** The number of rows that can fit in the cursor window, 0 if unknown */ private int mCursorWindowCapacity; /** A mapping of column names to column indices, to speed up lookups */ private Map<String, Integer> mColumnNameMap; /** Used to find out where a cursor was allocated in case it never got released. */ private final Throwable mStackTrace; /** * Execute a query and provide access to its result set through a Cursor * interface. For a query such as: {@code SELECT name, birth, phone FROM * myTable WHERE ... LIMIT 1,20 ORDER BY...} the column names (name, birth, * phone) would be in the projection argument and everything from * {@code FROM} onward would be in the params argument. * ................................................................................ * @param editTable the name of the table used for this query * @param query the {@link SQLiteQuery} object associated with this cursor object. */ public SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { if (query == null) { throw new IllegalArgumentException("query object cannot be null"); } if (/* StrictMode.vmSqliteObjectLeaksEnabled() */ false ) { mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); } else { mStackTrace = null; } mDriver = driver; mEditTable = editTable; mColumnNameMap = null; mQuery = query; mColumns = query.getColumnNames(); } ................................................................................ * Release the native resources, if they haven't been released yet. */ @Override protected void finalize() { try { // if the cursor hasn't been closed yet, close it first if (mWindow != null) { /* if (mStackTrace != null) { String sql = mQuery.getSql(); int len = sql.length(); StrictMode.onSqliteObjectLeaked( "Finalizing a Cursor that has not been deactivated or closed. " + "database = " + mQuery.getDatabase().getLabel() + ", table = " + mEditTable + ", query = " + sql.substring(0, (len > 1000) ? 1000 : len), mStackTrace); } */ close(); } } finally { super.finalize(); } } } |
< < > < < < < < < < < < < < < < < < < < < < < |
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 .. 58 59 60 61 62 63 64 65 66 67 68 69 70 71 .. 92 93 94 95 96 97 98 99 100 101 102 103 104 105 ... 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
/* ** Modified to support SQLite extensions by the SQLite developers: ** sqlite-dev@sqlite.org. */ package org.sqlite.database.sqlite; import android.database.AbstractWindowedCursor; import android.database.CursorWindow; import org.sqlite.database.DatabaseUtils; import android.os.StrictMode; import android.util.Log; import java.util.HashMap; import java.util.Map; ................................................................................ /** The number of rows that can fit in the cursor window, 0 if unknown */ private int mCursorWindowCapacity; /** A mapping of column names to column indices, to speed up lookups */ private Map<String, Integer> mColumnNameMap; /** * Execute a query and provide access to its result set through a Cursor * interface. For a query such as: {@code SELECT name, birth, phone FROM * myTable WHERE ... LIMIT 1,20 ORDER BY...} the column names (name, birth, * phone) would be in the projection argument and everything from * {@code FROM} onward would be in the params argument. * ................................................................................ * @param editTable the name of the table used for this query * @param query the {@link SQLiteQuery} object associated with this cursor object. */ public SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { if (query == null) { throw new IllegalArgumentException("query object cannot be null"); } mDriver = driver; mEditTable = editTable; mColumnNameMap = null; mQuery = query; mColumns = query.getColumnNames(); } ................................................................................ * Release the native resources, if they haven't been released yet. */ @Override protected void finalize() { try { // if the cursor hasn't been closed yet, close it first if (mWindow != null) { close(); } } finally { super.finalize(); } } } |
Changes to sqlite3/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java.
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 .... 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 .... 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 .... 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 |
deleted |= new File(file.getPath() + "-journal").delete(); deleted |= new File(file.getPath() + "-shm").delete(); deleted |= new File(file.getPath() + "-wal").delete(); File dir = file.getParentFile(); if (dir != null) { final String prefix = file.getName() + "-mj"; final FileFilter filter = new FileFilter() { @Override public boolean accept(File candidate) { return candidate.getName().startsWith(prefix); } }; for (File masterJournal : dir.listFiles(filter)) { deleted |= masterJournal.delete(); } } return deleted; } /** * Reopens the database in read-write mode. ................................................................................ public long insertOrThrow(String table, String nullColumnHack, ContentValues values) throws SQLException { return insertWithOnConflict(table, nullColumnHack, values, CONFLICT_NONE); } /** * Convenience method for replacing a row in the database. * * @param table the table in which to replace the row * @param nullColumnHack optional; may be <code>null</code>. * SQL doesn't allow inserting a completely empty row without * naming at least one column name. If your provided <code>initialValues</code> is * empty, no column names are known and an empty row can't be inserted. * If not set to null, the <code>nullColumnHack</code> parameter * provides the name of nullable column name to explicitly insert a NULL into * in the case where your <code>initialValues</code> is empty. * @param initialValues this map contains the initial column values for * the row. * @return the row ID of the newly inserted row, or -1 if an error occurred */ public long replace(String table, String nullColumnHack, ContentValues initialValues) { try { return insertWithOnConflict(table, nullColumnHack, initialValues, CONFLICT_REPLACE); } catch (SQLException e) { ................................................................................ Log.e(TAG, "Error inserting " + initialValues, e); return -1; } } /** * Convenience method for replacing a row in the database. * * @param table the table in which to replace the row * @param nullColumnHack optional; may be <code>null</code>. * SQL doesn't allow inserting a completely empty row without * naming at least one column name. If your provided <code>initialValues</code> is * empty, no column names are known and an empty row can't be inserted. * If not set to null, the <code>nullColumnHack</code> parameter * provides the name of nullable column name to explicitly insert a NULL into * in the case where your <code>initialValues</code> is empty. * @param initialValues this map contains the initial column values for * the row. The key * @throws SQLException * @return the row ID of the newly inserted row, or -1 if an error occurred */ public long replaceOrThrow(String table, String nullColumnHack, ContentValues initialValues) throws SQLException { return insertWithOnConflict(table, nullColumnHack, initialValues, CONFLICT_REPLACE); ................................................................................ * If not set to null, the <code>nullColumnHack</code> parameter * provides the name of nullable column name to explicitly insert a NULL into * in the case where your <code>initialValues</code> is empty. * @param initialValues this map contains the initial column values for the * row. The keys should be the column names and the values the * column values * @param conflictAlgorithm for insert conflict resolver * @return the row ID of the newly inserted row * OR the primary key of the existing row if the input param 'conflictAlgorithm' = * {@link #CONFLICT_IGNORE} * OR -1 if any error */ public long insertWithOnConflict(String table, String nullColumnHack, ContentValues initialValues, int conflictAlgorithm) { acquireReference(); try { StringBuilder sql = new StringBuilder(); sql.append("INSERT"); |
| | > | | > > | > | | < | < > |
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 .... 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 .... 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 .... 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 |
deleted |= new File(file.getPath() + "-journal").delete(); deleted |= new File(file.getPath() + "-shm").delete(); deleted |= new File(file.getPath() + "-wal").delete(); File dir = file.getParentFile(); if (dir != null) { final String prefix = file.getName() + "-mj"; File[] files = dir.listFiles(new FileFilter() { @Override public boolean accept(File candidate) { return candidate.getName().startsWith(prefix); } }); if (files != null) { for (File masterJournal : files) { deleted |= masterJournal.delete(); } } } return deleted; } /** * Reopens the database in read-write mode. ................................................................................ public long insertOrThrow(String table, String nullColumnHack, ContentValues values) throws SQLException { return insertWithOnConflict(table, nullColumnHack, values, CONFLICT_NONE); } /** * Convenience method for replacing a row in the database. * Inserts a new row if a row does not already exist. * * @param table the table in which to replace the row * @param nullColumnHack optional; may be <code>null</code>. * SQL doesn't allow inserting a completely empty row without * naming at least one column name. If your provided <code>initialValues</code> is * empty, no column names are known and an empty row can't be inserted. * If not set to null, the <code>nullColumnHack</code> parameter * provides the name of nullable column name to explicitly insert a NULL into * in the case where your <code>initialValues</code> is empty. * @param initialValues this map contains the initial column values for * the row. The keys should be the column names and the values the column values. * @return the row ID of the newly inserted row, or -1 if an error occurred */ public long replace(String table, String nullColumnHack, ContentValues initialValues) { try { return insertWithOnConflict(table, nullColumnHack, initialValues, CONFLICT_REPLACE); } catch (SQLException e) { ................................................................................ Log.e(TAG, "Error inserting " + initialValues, e); return -1; } } /** * Convenience method for replacing a row in the database. * Inserts a new row if a row does not already exist. * * @param table the table in which to replace the row * @param nullColumnHack optional; may be <code>null</code>. * SQL doesn't allow inserting a completely empty row without * naming at least one column name. If your provided <code>initialValues</code> is * empty, no column names are known and an empty row can't be inserted. * If not set to null, the <code>nullColumnHack</code> parameter * provides the name of nullable column name to explicitly insert a NULL into * in the case where your <code>initialValues</code> is empty. * @param initialValues this map contains the initial column values for * the row. The keys should be the column names and the values the column values. * @throws SQLException * @return the row ID of the newly inserted row, or -1 if an error occurred */ public long replaceOrThrow(String table, String nullColumnHack, ContentValues initialValues) throws SQLException { return insertWithOnConflict(table, nullColumnHack, initialValues, CONFLICT_REPLACE); ................................................................................ * If not set to null, the <code>nullColumnHack</code> parameter * provides the name of nullable column name to explicitly insert a NULL into * in the case where your <code>initialValues</code> is empty. * @param initialValues this map contains the initial column values for the * row. The keys should be the column names and the values the * column values * @param conflictAlgorithm for insert conflict resolver * @return the row ID of the newly inserted row OR <code>-1</code> if either the * input parameter <code>conflictAlgorithm</code> = {@link #CONFLICT_IGNORE} * or an error occurred. */ public long insertWithOnConflict(String table, String nullColumnHack, ContentValues initialValues, int conflictAlgorithm) { acquireReference(); try { StringBuilder sql = new StringBuilder(); sql.append("INSERT"); |
Changes to sqlite3/src/main/java/org/sqlite/database/sqlite/SQLiteDatabaseConfiguration.java.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
* @return True if the database is in-memory.
*/
public boolean isInMemoryDb() {
return path.equalsIgnoreCase(MEMORY_DB_PATH);
}
private static String stripPathForLogs(String path) {
/* Strip off all URI parameters. */
int iIdx = path.indexOf('?');
if( iIdx>=0 ){
path = (String) path.subSequence(0, iIdx);
}
if (path.indexOf('@') == -1) {
return path;
}
return EMAIL_IN_DB_PATTERN.matcher(path).replaceAll("XX@YY");
}
}
|
| > > |
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
* @return True if the database is in-memory. */ public boolean isInMemoryDb() { return path.equalsIgnoreCase(MEMORY_DB_PATH); } private static String stripPathForLogs(String path) { /* Strip off all URI parameters. This is in case a SEE database is * opened with the password specified as a URI parameter. We do not * want the password to appear in any log files. */ int iIdx = path.indexOf('?'); if( iIdx>=0 ){ path = (String) path.subSequence(0, iIdx); } if (path.indexOf('@') == -1) { return path; } return EMAIL_IN_DB_PATTERN.matcher(path).replaceAll("XX@YY"); } } |
Changes to sqlite3/src/main/java/org/sqlite/database/sqlite/SQLiteDebug.java.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
*
* This value can be changed dynamically while the system is running.
* For example, "adb shell setprop db.log.slow_query_threshold 200" will
* log all queries that take 200ms or longer to run.
* @hide
*/
public static final boolean shouldLogSlowQuery(long elapsedTimeMillis) {
int slowQueryMillis = 10000;
return slowQueryMillis >= 0 && elapsedTimeMillis >= slowQueryMillis;
}
/**
* Contains statistics about the active pagers in the current process.
*
* @see #nativeGetPagerStats(PagerStats)
|
| > > |
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
* * This value can be changed dynamically while the system is running. * For example, "adb shell setprop db.log.slow_query_threshold 200" will * log all queries that take 200ms or longer to run. * @hide */ public static final boolean shouldLogSlowQuery(long elapsedTimeMillis) { int slowQueryMillis = Integer.parseInt( System.getProperty("db.log.slow_query_threshold", "10000") ); return slowQueryMillis >= 0 && elapsedTimeMillis >= slowQueryMillis; } /** * Contains statistics about the active pagers in the current process. * * @see #nativeGetPagerStats(PagerStats) |
Changes to sqlite3/src/main/java/org/sqlite/database/sqlite/SQLiteGlobal.java.
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
** sqlite-dev@sqlite.org. */ package org.sqlite.database.sqlite; import android.content.res.Resources; import android.os.StatFs; /* import android.os.SystemProperties; */ /** * Provides access to SQLite functions that affect all database connection, * such as memory management. * * The native code associated with SQLiteGlobal is also sets global configuration options * using sqlite3_config() then calls sqlite3_initialize() to ensure that the SQLite ................................................................................ /** * Gets the default page size to use when creating a database. */ public static int getDefaultPageSize() { synchronized (sLock) { if (sDefaultPageSize == 0) { sDefaultPageSize = new StatFs("/data").getBlockSize(); } return 1024; } } /** |
<
>
>
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
** sqlite-dev@sqlite.org. */ package org.sqlite.database.sqlite; import android.content.res.Resources; import android.os.StatFs; /** * Provides access to SQLite functions that affect all database connection, * such as memory management. * * The native code associated with SQLiteGlobal is also sets global configuration options * using sqlite3_config() then calls sqlite3_initialize() to ensure that the SQLite ................................................................................ /** * Gets the default page size to use when creating a database. */ public static int getDefaultPageSize() { synchronized (sLock) { if (sDefaultPageSize == 0) { // If there is an issue accessing /data, something is so seriously // wrong that we just let the IllegalArgumentException propagate. sDefaultPageSize = new StatFs("/data").getBlockSize(); } return 1024; } } /** |