Ticket #7539: mythsqlverbose.patch

File mythsqlverbose.patch, 2.7 KB (added by Dibblah, 14 years ago)
  • libs/libmythdb/mythdbcon.h

     
    2626    bool isOpen(void);
    2727    bool OpenDatabase(void);
    2828    bool KickDatabase(void);
     29    QString GetConnectionName(void) { return m_name; }
    2930    QSqlDatabase db(void) { return m_db; }
    3031
    3132  private:
     
    112113    /// \brief Wrap QSqlQuery::exec() so we can display SQL
    113114    bool exec(void);
    114115
     116    /// \brief Wrap QSqlQuery::next() so we can display the query results
     117    bool next(void);
     118
    115119    /// \brief Wrap QSqlQuery::exec(const QString &query) so we can display SQL
    116120    bool exec(const QString &query);
    117121
  • libs/libmythdb/mythdbcon.cpp

     
    1010#include <QSemaphore>
    1111#include <QSqlError>
    1212#include <QSqlField>
     13#include <QSqlRecord>
    1314
    1415// MythTV
    1516#include "compat.h"
     
    443444            str.replace(b.key(), '\'' + b.value().toString() + '\'');
    444445        }
    445446
    446         VERBOSE(VB_DATABASE, "MSqlQuery::exec() \"" + str + '"');
     447        VERBOSE(VB_DATABASE, QString("MSqlQuery::exec(%1 \"%2\") - %3 rows")
     448            .arg(m_db->MSqlDatabase::GetConnectionName())
     449            .arg(str)
     450            .arg(QSqlQuery::size()));
    447451    }
    448452
    449453    return result;
     
    451455
    452456bool MSqlQuery::exec(const QString &query)
    453457{
    454     VERBOSE(VB_DATABASE, "MSqlQuery::exec(\"" + query + "\")");
     458    if (print_verbose_messages & VB_DATABASE)
     459    {
     460        VERBOSE(VB_DATABASE,
     461            QString("MSqlQuery::exec(%1 \"%1\") returned %2 row(s)")
     462            .arg(m_db->MSqlDatabase::GetConnectionName())
     463            .arg(query)
     464            .arg(QSqlQuery::size()));
     465    }
    455466
    456467    return QSqlQuery::exec(query);
    457468}
    458469
     470bool MSqlQuery::next()
     471{
     472    bool result = QSqlQuery::next();   
     473
     474    if ((print_verbose_messages & (VB_DATABASE|VB_EXTRA))
     475        == (VB_DATABASE|VB_EXTRA))
     476    {
     477        if (result) {
     478            QString str;
     479            QSqlRecord record=QSqlQuery::record();
     480
     481            for ( long int i = 0; i<record.count(); i++ )
     482            {
     483                if (!str.isEmpty())
     484                {
     485                    str.append(", ");
     486                }
     487                str.append(record.fieldName(i) + " = " + value(i).toString());
     488            }
     489
     490            VERBOSE(VB_EXTRA+VB_DATABASE, QString("MSqlQuery::next(%1) \"%2\"")
     491                .arg(m_db->MSqlDatabase::GetConnectionName())
     492                .arg(str));
     493        }
     494    }
     495
     496    return result;
     497}
     498
    459499bool MSqlQuery::prepare(const QString& query)
    460500{
    461501    QMutexLocker lock(&prepareLock);