Ticket #7539: mythsqlverbose.patch
File mythsqlverbose.patch, 2.7 KB (added by , 14 years ago) |
---|
-
libs/libmythdb/mythdbcon.h
26 26 bool isOpen(void); 27 27 bool OpenDatabase(void); 28 28 bool KickDatabase(void); 29 QString GetConnectionName(void) { return m_name; } 29 30 QSqlDatabase db(void) { return m_db; } 30 31 31 32 private: … … 112 113 /// \brief Wrap QSqlQuery::exec() so we can display SQL 113 114 bool exec(void); 114 115 116 /// \brief Wrap QSqlQuery::next() so we can display the query results 117 bool next(void); 118 115 119 /// \brief Wrap QSqlQuery::exec(const QString &query) so we can display SQL 116 120 bool exec(const QString &query); 117 121 -
libs/libmythdb/mythdbcon.cpp
10 10 #include <QSemaphore> 11 11 #include <QSqlError> 12 12 #include <QSqlField> 13 #include <QSqlRecord> 13 14 14 15 // MythTV 15 16 #include "compat.h" … … 443 444 str.replace(b.key(), '\'' + b.value().toString() + '\''); 444 445 } 445 446 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())); 447 451 } 448 452 449 453 return result; … … 451 455 452 456 bool MSqlQuery::exec(const QString &query) 453 457 { 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 } 455 466 456 467 return QSqlQuery::exec(query); 457 468 } 458 469 470 bool 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 459 499 bool MSqlQuery::prepare(const QString& query) 460 500 { 461 501 QMutexLocker lock(&prepareLock);