mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
Add more specialized SQL debugging
This commit is contained in:
@@ -51,7 +51,7 @@ Database::Database( const QString& dbname, QObject* parent )
|
|||||||
else
|
else
|
||||||
m_maxConcurrentThreads = qBound( DEFAULT_WORKER_THREADS, QThread::idealThreadCount(), MAX_WORKER_THREADS );
|
m_maxConcurrentThreads = qBound( DEFAULT_WORKER_THREADS, QThread::idealThreadCount(), MAX_WORKER_THREADS );
|
||||||
|
|
||||||
tDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "database worker threads";
|
tDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "database worker threads; current (GUI) thread is " << QThread::currentThread();
|
||||||
|
|
||||||
connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) );
|
connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) );
|
||||||
connect( m_impl, SIGNAL( indexReady() ), SIGNAL( ready() ) );
|
connect( m_impl, SIGNAL( indexReady() ), SIGNAL( ready() ) );
|
||||||
@@ -142,6 +142,7 @@ Database::impl()
|
|||||||
QThread* thread = QThread::currentThread();
|
QThread* thread = QThread::currentThread();
|
||||||
if ( !m_implHash.contains( thread ) )
|
if ( !m_implHash.contains( thread ) )
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "Creating database impl for thread " << QThread::currentThread();
|
||||||
DatabaseImpl* impl = m_impl->clone();
|
DatabaseImpl* impl = m_impl->clone();
|
||||||
m_implHash.insert( thread, impl );
|
m_implHash.insert( thread, impl );
|
||||||
}
|
}
|
||||||
|
@@ -63,6 +63,13 @@ TomahawkSqlQuery::exec( const QString& query )
|
|||||||
bool
|
bool
|
||||||
TomahawkSqlQuery::exec()
|
TomahawkSqlQuery::exec()
|
||||||
{
|
{
|
||||||
|
bool log = false;
|
||||||
|
#ifdef TOMAHAWK_QUERY_ANALYZE
|
||||||
|
log = true;
|
||||||
|
#endif
|
||||||
|
if ( log )
|
||||||
|
tLog( LOGSQL ) << "TomahawkSqlQuery::exec running in thread " << QThread::currentThread();
|
||||||
|
|
||||||
QTime t;
|
QTime t;
|
||||||
t.start();
|
t.start();
|
||||||
|
|
||||||
@@ -81,14 +88,9 @@ TomahawkSqlQuery::exec()
|
|||||||
showError();
|
showError();
|
||||||
|
|
||||||
int e = t.elapsed();
|
int e = t.elapsed();
|
||||||
bool log = ( e >= QUERY_THRESHOLD );
|
|
||||||
|
|
||||||
#ifdef TOMAHAWK_QUERY_ANALYZE
|
if ( log || e >= QUERY_THRESHOLD )
|
||||||
log = true;
|
tLog( LOGSQL ) << "TomahawkSqlQuery::exec (" << t.elapsed() << "ms ):" << lastQuery();
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( log )
|
|
||||||
tLog( LOGSQL ) << "TomahawkSqlQuery (" << t.elapsed() << "ms ):" << lastQuery();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -97,6 +99,13 @@ TomahawkSqlQuery::exec()
|
|||||||
bool
|
bool
|
||||||
TomahawkSqlQuery::commitTransaction()
|
TomahawkSqlQuery::commitTransaction()
|
||||||
{
|
{
|
||||||
|
bool log = false;
|
||||||
|
#ifdef TOMAHAWK_QUERY_ANALYZE
|
||||||
|
log = true;
|
||||||
|
#endif
|
||||||
|
if ( log )
|
||||||
|
tLog( LOGSQL ) << "TomahawkSqlQuery::commitTransaction running in thread " << QThread::currentThread();
|
||||||
|
|
||||||
unsigned int retries = 0;
|
unsigned int retries = 0;
|
||||||
while ( !m_db.commit() && ++retries < 10 )
|
while ( !m_db.commit() && ++retries < 10 )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user