diff --git a/db/sqlite3/src/moz.build b/db/sqlite3/src/moz.build index 293f39c0dcfd..b5016fe93809 100644 --- a/db/sqlite3/src/moz.build +++ b/db/sqlite3/src/moz.build @@ -80,6 +80,10 @@ if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_MEMORY']: DEFINES['HAVE_MALLOC_USABLE_SIZE'] = True DEFINES['SQLITE_WITHOUT_MSIZE'] = True +# Omit unused functions to save some library footprint. +DEFINES['SQLITE_OMIT_DEPRECATED'] = True +DEFINES['SQLITE_OMIT_BUILTIN_TEST'] = True + # Suppress warnings in third-party code. if CONFIG['GNU_CC']: CFLAGS += [ diff --git a/db/sqlite3/src/sqlite.symbols b/db/sqlite3/src/sqlite.symbols index edd000a97c8c..640ee4382f8f 100644 --- a/db/sqlite3/src/sqlite.symbols +++ b/db/sqlite3/src/sqlite.symbols @@ -3,7 +3,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. sqlite3_aggregate_context -sqlite3_aggregate_count sqlite3_auto_extension sqlite3_bind_blob sqlite3_bind_double @@ -59,7 +58,7 @@ sqlite3_errcode sqlite3_errmsg sqlite3_errmsg16 sqlite3_exec -sqlite3_expired +sqlite3_expanded_sql sqlite3_extended_result_codes sqlite3_file_control sqlite3_finalize @@ -68,7 +67,6 @@ sqlite3_free_table sqlite3_get_autocommit sqlite3_get_auxdata sqlite3_get_table -sqlite3_global_recover sqlite3_initialize sqlite3_interrupt sqlite3_last_insert_rowid @@ -76,7 +74,6 @@ sqlite3_libversion sqlite3_libversion_number sqlite3_load_extension sqlite3_malloc -sqlite3_memory_alarm sqlite3_memory_highwater sqlite3_memory_used sqlite3_mutex_alloc @@ -94,7 +91,6 @@ sqlite3_prepare sqlite3_prepare16 sqlite3_prepare16_v2 sqlite3_prepare_v2 -sqlite3_profile sqlite3_progress_handler sqlite3_realloc sqlite3_release_memory @@ -128,10 +124,8 @@ sqlite3_stmt_status #ifdef XP_UNIX sqlite3_temp_directory #endif -sqlite3_thread_cleanup sqlite3_total_changes -sqlite3_trace -sqlite3_transfer_bindings +sqlite3_trace_v2 sqlite3_unlock_notify sqlite3_update_hook sqlite3_uri_parameter diff --git a/storage/mozStorageConnection.cpp b/storage/mozStorageConnection.cpp index 7a8964c85810..30f43604e3f2 100644 --- a/storage/mozStorageConnection.cpp +++ b/storage/mozStorageConnection.cpp @@ -194,10 +194,39 @@ Module gModules[] = { //////////////////////////////////////////////////////////////////////////////// //// Local Functions -void tracefunc (void *aClosure, const char *aStmt) +int tracefunc (unsigned aReason, void *aClosure, void *aP, void *aX) { - MOZ_LOG(gStorageLog, LogLevel::Debug, ("sqlite3_trace on %p for '%s'", aClosure, - aStmt)); + switch (aReason) { + case SQLITE_TRACE_STMT: { + // aP is a pointer to the prepared statement. + sqlite3_stmt* stmt = static_cast(aP); + // aX is a pointer to a string containing the unexpanded SQL or a comment, + // starting with "--"" in case of a trigger. + char* expanded = static_cast(aX); + // Simulate what sqlite_trace was doing. + if (!::strncmp(expanded, "--", 2)) { + MOZ_LOG(gStorageLog, LogLevel::Debug, + ("TRACE_STMT on %p: '%s'", aClosure, expanded)); + } else { + char* sql = ::sqlite3_expanded_sql(stmt); + MOZ_LOG(gStorageLog, LogLevel::Debug, + ("TRACE_STMT on %p: '%s'", aClosure, sql)); + ::sqlite3_free(sql); + } + break; + } + case SQLITE_TRACE_PROFILE: { + // aX is pointer to a 64bit integer containing nanoseconds it took to + // execute the last command. + sqlite_int64 time = *(static_cast(aX)) / 1000000; + if (time > 0) { + MOZ_LOG(gStorageLog, LogLevel::Debug, + ("TRACE_TIME on %p: %dms", aClosure, time)); + } + break; + } + } + return 0; } void @@ -701,7 +730,9 @@ Connection::initializeInternal() // SQLite tracing can slow down queries (especially long queries) // significantly. Don't trace unless the user is actively monitoring SQLite. if (MOZ_LOG_TEST(gStorageLog, LogLevel::Debug)) { - ::sqlite3_trace(mDBConn, tracefunc, this); + ::sqlite3_trace_v2(mDBConn, + SQLITE_TRACE_STMT | SQLITE_TRACE_PROFILE, + tracefunc, this); MOZ_LOG(gStorageLog, LogLevel::Debug, ("Opening connection to '%s' (%p)", mTelemetryFilename.get(), this));