Ticket #9704: mythtv-0.24-backport_reconnect_fixes.patch
File mythtv-0.24-backport_reconnect_fixes.patch, 29.7 KB (added by , 14 years ago) |
---|
-
mythtv/libs/libmyth/programinfo.cpp
Backports 063e45ed23 , 4dfcdb8dd , and 1fb0a77fc from master. Corrects one additional addBindValue() in ProgramInfo::QueryDVDBookmark that no longer exists in master. --- mythplugins/mythmusic/mythmusic/smartplaylist.cpp | 2 1 + 1 - 0 ! mythplugins/mythweather/mythweather/weatherSource.cpp | 6 3 + 3 - 0 ! mythtv/libs/libmyth/programinfo.cpp | 28 14 + 14 - 0 ! mythtv/libs/libmythdb/mythdb.cpp | 2 1 + 1 - 0 ! mythtv/libs/libmythdb/mythdb.h | 5 3 + 2 - 0 ! mythtv/libs/libmythdb/mythdbcon.cpp | 201 121 + 80 - 0 ! mythtv/libs/libmythdb/mythdbcon.h | 54 47 + 7 - 0 ! mythtv/libs/libmythdb/mythversion.h | 2 1 + 1 - 0 ! mythtv/libs/libmythtv/datadirect.cpp | 3 1 + 2 - 0 ! mythtv/libs/libmythtv/dbcheck.cpp | 8 4 + 4 - 0 ! mythtv/programs/mythbackend/httpstatus.cpp | 9 3 + 6 - 0 ! mythtv/programs/mythbackend/main_helpers.cpp | 12 5 + 7 - 0 ! mythtv/programs/mythbackend/mainserver.cpp | 8 3 + 5 - 0 ! mythtv/programs/mythbackend/scheduler.cpp | 4 2 + 2 - 0 ! mythtv/programs/mythfrontend/progfind.cpp | 2 1 + 1 - 0 ! 15 files changed, 210 insertions(+), 136 deletions(-)
old new QStringList ProgramInfo::QueryDVDBookmar 2216 2216 { 2217 2217 query.prepare(" SELECT title, framenum, audionum, subtitlenum " 2218 2218 " FROM dvdbookmark " 2219 " WHERE serialid = ?");2220 query. addBindValue(serialid);2219 " WHERE serialid = :SERIALID "); 2220 query.bindValue(":SERIALID", serialid); 2221 2221 2222 2222 if (query.exec() && query.next()) 2223 2223 { … … QStringList ProgramInfo::QueryDVDBookmar 2231 2231 int days = -(gCoreContext->GetNumSetting("DVDBookmarkDays", 10)); 2232 2232 QDateTime removedate = mythCurrentDateTime().addDays(days); 2233 2233 query.prepare(" DELETE from dvdbookmark " 2234 " WHERE timestamp < ?");2235 query. addBindValue(removedate.toString(Qt::ISODate));2234 " WHERE timestamp < :REMOVEDATE "); 2235 query.bindValue(":REMOVEDATE", removedate.toString(Qt::ISODate)); 2236 2236 2237 2237 if (!query.exec()) 2238 2238 MythDB::DBError("GetDVDBookmark deleting old entries", query); … … void ProgramInfo::SaveDVDBookmark(const 2263 2263 MythDB::DBError("SetDVDBookmark inserting", query); 2264 2264 2265 2265 query.prepare(" UPDATE dvdbookmark " 2266 " SET title = ?, "2267 " audionum = ?, "2268 " subtitlenum = ?, "2269 " framenum = ?, "2266 " SET title = :TITLE , " 2267 " audionum = :AUDIONUM , " 2268 " subtitlenum = :SUBTITLENUM , " 2269 " framenum = :FRAMENUM , " 2270 2270 " timestamp = NOW() " 2271 " WHERE serialid = ? ;");2272 query. addBindValue(title);2273 query. addBindValue(audionum);2274 query. addBindValue(subtitlenum);2275 query. addBindValue(frame);2276 query. addBindValue(serialid);2271 " WHERE serialid = :SERIALID"); 2272 query.bindValue(":TITLE",title); 2273 query.bindValue(":AUDIONUM",audionum); 2274 query.bindValue(":SUBTITLENUM",subtitlenum); 2275 query.bindValue(":FRAMENUM",frame); 2276 query.bindValue(":SERIALID",serialid); 2277 2277 2278 2278 if (!query.exec()) 2279 2279 MythDB::DBError("SetDVDBookmark updating", query); -
mythtv/libs/libmythdb/mythdb.cpp
old new QString MythDB::toCommaList(const QMap<Q 158 158 return str; 159 159 } 160 160 161 void MythDB::DBError(const QString &where, const QSqlQuery& query)161 void MythDB::DBError(const QString &where, const MSqlQuery& query) 162 162 { 163 163 QString str = QString("DB Error (%1):\n").arg(where); 164 164 -
mythtv/libs/libmythdb/mythdb.h
old new class MDBManager; 14 14 15 15 class MPUBLIC MythDB 16 16 { 17 friend class MSqlQuery; 17 18 public: 18 19 MDBManager *GetDBManager(void); 19 20 Settings *GetOldSettings(void); 20 21 21 static void DBError(const QString &where, const QSqlQuery &query);22 static QString DBErrorMessage(const QSqlError &err);22 static void DBError(const QString &where, const MSqlQuery &query); 23 static QString DBErrorMessage(const QSqlError &err); 23 24 24 25 DatabaseParams GetDatabaseParams(void) const; 25 26 void SetDatabaseParams(const DatabaseParams ¶ms); -
mythtv/libs/libmythdb/mythdbcon.cpp
old new 15 15 #include "mythdb.h" 16 16 #include "mythverbose.h" 17 17 18 #define DEBUG_RECONNECT 0 19 #if DEBUG_RECONNECT 20 #include <stdlib.h> 21 #endif 22 18 23 static const uint kPurgeTimeout = 60 * 60; 19 24 20 25 MSqlDatabase::MSqlDatabase(const QString &name) … … bool MSqlDatabase::OpenDatabase() 158 163 return connected; 159 164 } 160 165 161 bool MSqlDatabase::KickDatabase( )166 bool MSqlDatabase::KickDatabase(void) 162 167 { 163 // Some explanation is called for. This exists because the mysql164 // driver does not gracefully handle the situation where a TCP165 // socketconnection is dropped (for example due to a timeout). If166 // a Unix domain socket connection is lost, the driver167 // transparently reestablishes the connection and we don't even168 // notice. However, when this happens with a TCP connection, the169 // driver returns an error for the next query to be executed, and170 // THEN reestablishes the connection (so the second query succeeds171 // with no intervention).172 // mdz, 2003/08/11173 174 175 if (m_lastDBKick.secsTo(QDateTime::currentDateTime()) < 30 &&176 m_db.isOpen())177 {178 return true;179 }180 181 QString query("SELECT NULL;");182 for (unsigned int i = 0 ; i < 2 ; ++i, usleep(50000))183 {184 if (m_db.isOpen())185 {186 QSqlQuery result = m_db.exec(query); // don't convert to MSqlQuery187 if (result.isActive())188 {189 m_lastDBKick = QDateTime::currentDateTime();190 return true;191 }192 }193 194 if (i == 0)195 {196 m_db.close();197 m_db.open();198 }199 else200 VERBOSE(VB_IMPORTANT, MythDB::DBErrorMessage(m_db.lastError()));201 }202 203 168 m_lastDBKick = QDateTime::currentDateTime().addSecs(-60); 204 169 205 return false; 170 if (!m_db.isOpen()) 171 m_db.open(); 172 173 return m_db.isOpen(); 206 174 } 207 175 208 176 bool MSqlDatabase::Reconnect() … … MSqlQueryInfo MSqlQuery::DDCon() 503 471 504 472 bool MSqlQuery::exec() 505 473 { 474 if (!m_db) 475 { 476 // Database structure's been deleted 477 return false; 478 } 479 480 if (m_last_prepared_query.isEmpty()) 481 { 482 VERBOSE(VB_IMPORTANT, 483 "MSqlQuery::exec(void) called without a prepared query."); 484 return false; 485 } 486 487 #if DEBUG_RECONNECT 488 if (random() < RAND_MAX / 50) 489 { 490 VERBOSE(VB_IMPORTANT, 491 "MSqlQuery disconnecting DB to test reconnection logic"); 492 m_db->m_db.close(); 493 } 494 #endif 495 506 496 // Database connection down. Try to restart it, give up if it's still 507 497 // down 508 if (!m_db->isOpen() && ! m_db->Reconnect())498 if (!m_db->isOpen() && !Reconnect()) 509 499 { 510 500 VERBOSE(VB_IMPORTANT, "MySQL server disconnected"); 511 501 return false; … … bool MSqlQuery::exec() 516 506 // if the query failed with "MySQL server has gone away" 517 507 // Close and reopen the database connection and retry the query if it 518 508 // connects again 519 if (!result && QSqlQuery::lastError().number() == 2006 && m_db->Reconnect())509 if (!result && QSqlQuery::lastError().number() == 2006 && Reconnect()) 520 510 result = QSqlQuery::exec(); 521 511 522 512 if (VERBOSE_LEVEL_CHECK(VB_DATABASE)) … … bool MSqlQuery::exec() 547 537 548 538 bool MSqlQuery::exec(const QString &query) 549 539 { 540 if (!m_db) 541 { 542 // Database structure's been deleted 543 return false; 544 } 545 550 546 // Database connection down. Try to restart it, give up if it's still 551 547 // down 552 if (!m_db->isOpen() && ! m_db->Reconnect())548 if (!m_db->isOpen() && !Reconnect()) 553 549 { 554 550 VERBOSE(VB_IMPORTANT, "MySQL server disconnected"); 555 551 return false; … … bool MSqlQuery::exec(const QString &quer 560 556 // if the query failed with "MySQL server has gone away" 561 557 // Close and reopen the database connection and retry the query if it 562 558 // connects again 563 if (!result && QSqlQuery::lastError().number() == 2006 && m_db->Reconnect())559 if (!result && QSqlQuery::lastError().number() == 2006 && Reconnect()) 564 560 result = QSqlQuery::exec(query); 565 561 566 562 VERBOSE(VB_DATABASE, … … bool MSqlQuery::exec(const QString &quer 573 569 return result; 574 570 } 575 571 576 bool MSqlQuery::next() 572 bool MSqlQuery::seekDebug(const char *type, bool result, 573 int where, bool relative) const 577 574 { 578 bool result = QSqlQuery::next();579 580 575 if (result && VERBOSE_LEVEL_CHECK(VB_DATABASE|VB_EXTRA)) 581 576 { 582 577 QString str; 583 QSqlRecord rec ord=QSqlQuery::record();578 QSqlRecord rec = record(); 584 579 585 for ( long int i = 0; i<record.count(); i++)580 for (long int i = 0; i < rec.count(); i++) 586 581 { 587 582 if (!str.isEmpty()) 588 583 str.append(", "); 589 584 590 str.append(record.fieldName(i) + " = " + value(i).toString()); 585 str.append(rec.fieldName(i) + " = " + 586 value(i).toString()); 591 587 } 592 588 593 VERBOSE(VB_DATABASE+VB_EXTRA, 594 QString("MSqlQuery::next(%1) Result: \"%2\"") 595 .arg(m_db->MSqlDatabase::GetConnectionName()) 596 .arg(str)); 589 if (QString("seek")==type) 590 { 591 VERBOSE(VB_DATABASE+VB_EXTRA, 592 QString("MSqlQuery::seek(%1,%2,%3) Result: \"%4\"") 593 .arg(m_db->MSqlDatabase::GetConnectionName()) 594 .arg(where).arg(relative) 595 .arg(str)); 596 } 597 else 598 { 599 VERBOSE(VB_DATABASE+VB_EXTRA, 600 QString("MSqlQuery::%1(%2) Result: \"%3\"") 601 .arg(type).arg(m_db->MSqlDatabase::GetConnectionName()) 602 .arg(str)); 603 } 597 604 } 598 599 605 return result; 600 606 } 601 607 608 bool MSqlQuery::next(void) 609 { 610 return seekDebug("next", QSqlQuery::next(), 0, false); 611 } 612 613 bool MSqlQuery::previous(void) 614 { 615 return seekDebug("previous", QSqlQuery::previous(), 0, false); 616 } 617 618 bool MSqlQuery::first(void) 619 { 620 return seekDebug("first", QSqlQuery::first(), 0, false); 621 } 622 623 bool MSqlQuery::last(void) 624 { 625 return seekDebug("last", QSqlQuery::last(), 0, false); 626 } 627 628 bool MSqlQuery::seek(int where, bool relative) 629 { 630 return seekDebug("seek", QSqlQuery::seek(where, relative), where, relative); 631 } 632 602 633 bool MSqlQuery::prepare(const QString& query) 603 634 { 635 if (!m_db) 636 { 637 // Database structure's been deleted 638 return false; 639 } 640 604 641 m_last_prepared_query = query; 642 605 643 #ifdef DEBUG_QT4_PORT 606 644 if (query.contains(m_testbindings)) 607 645 { … … bool MSqlQuery::prepare(const QString& q 614 652 615 653 // Database connection down. Try to restart it, give up if it's still 616 654 // down 617 if (!m_db->isOpen() && !m_db->Reconnect()) 655 if (!m_db) 656 { 657 // Database structure has been deleted... 658 return false; 659 } 660 661 if (!m_db->isOpen() && !Reconnect()) 618 662 { 619 663 VERBOSE(VB_IMPORTANT, "MySQL server disconnected"); 620 664 return false; … … bool MSqlQuery::prepare(const QString& q 625 669 // if the prepare failed with "MySQL server has gone away" 626 670 // Close and reopen the database connection and retry the query if it 627 671 // connects again 628 if (!ok && QSqlQuery::lastError().number() == 2006 && m_db->Reconnect())672 if (!ok && QSqlQuery::lastError().number() == 2006 && Reconnect()) 629 673 ok = QSqlQuery::prepare(query); 630 674 631 675 if (!ok && !(GetMythDB()->SuppressDBMessages())) … … bool MSqlQuery::testDBConnection() 649 693 return isOpen; 650 694 } 651 695 652 void MSqlQuery::bindValue (const QString & placeholder, 653 const QVariant & val, QSql::ParamType paramType) 696 void MSqlQuery::bindValue(const QString &placeholder, const QVariant &val) 654 697 { 655 698 #ifdef DEBUG_QT4_PORT 656 699 // XXX - HACK BEGIN … … void MSqlQuery::bindValue (const QString 665 708 // XXX - HACK END 666 709 #endif 667 710 668 if (val.type() == QVariant::String && val.isNull()) 669 { 670 QSqlQuery::bindValue(placeholder, QString(""), paramType); 671 return; 672 } 673 QSqlQuery::bindValue(placeholder, val, paramType); 711 QSqlQuery::bindValue(placeholder, val, QSql::In); 674 712 } 675 713 676 void MSqlQuery::bindValue(int pos, const QVariant & val, 677 QSql::ParamType paramType) 714 void MSqlQuery::bindValues(const MSqlBindings &bindings) 678 715 { 679 if (val.type() == QVariant::String && val.isNull()) 680 { 681 QSqlQuery::bindValue(pos, QString(""), paramType); 682 return; 683 } 684 QSqlQuery::bindValue(pos, val, paramType); 685 } 686 687 void MSqlQuery::bindValues(MSqlBindings &bindings) 688 { 689 MSqlBindings::Iterator it; 716 MSqlBindings::const_iterator it; 690 717 for (it = bindings.begin(); it != bindings.end(); ++it) 691 718 { 692 719 bindValue(it.key(), it.value()); … … QVariant MSqlQuery::lastInsertId() 698 725 return QSqlQuery::lastInsertId(); 699 726 } 700 727 728 bool MSqlQuery::Reconnect(void) 729 { 730 if (!m_db->Reconnect()) 731 return false; 732 if (!m_last_prepared_query.isEmpty()) 733 { 734 MSqlBindings tmp = QSqlQuery::boundValues(); 735 if (!prepare(m_last_prepared_query)) 736 return false; 737 bindValues(tmp); 738 } 739 return true; 740 } 741 701 742 void MSqlAddMoreBindings(MSqlBindings &output, MSqlBindings &addfrom) 702 743 { 703 744 MSqlBindings::Iterator it; -
mythtv/libs/libmythdb/mythdbcon.h
old new 2 2 #define MYTHDBCON_H_ 3 3 4 4 #include <QSqlDatabase> 5 #include <QSqlRecord> 6 #include <QSqlError> 5 7 #include <QVariant> 6 8 #include <QSqlQuery> 7 9 #include <QRegExp> … … 14 16 class QSemaphore; 15 17 16 18 /// \brief QSqlDatabase wrapper, used by MSqlQuery. Do not use directly. 17 class M PUBLIC MSqlDatabase19 class MSqlDatabase 18 20 { 19 21 friend class MDBManager; 20 22 friend class MSqlQuery; … … MPUBLIC void MSqlEscapeAsAQuery(QString 101 103 * will crash if closed and reopend - so we never close them and keep them in 102 104 * a pool. 103 105 */ 104 class MPUBLIC MSqlQuery : p ublicQSqlQuery106 class MPUBLIC MSqlQuery : private QSqlQuery 105 107 { 108 friend void MSqlEscapeAsAQuery(QString&, MSqlBindings&); 106 109 public: 107 110 /// \brief Get DB connection from pool 108 111 MSqlQuery(const MSqlQueryInfo &qi); … … class MPUBLIC MSqlQuery : public QSqlQue 118 121 /// \brief Wrap QSqlQuery::next() so we can display the query results 119 122 bool next(void); 120 123 124 /// \brief Wrap QSqlQuery::previous() so we can display the query results 125 bool previous(void); 126 127 /// \brief Wrap QSqlQuery::first() so we can display the query results 128 bool first(void); 129 130 /// \brief Wrap QSqlQuery::last() so we can display the query results 131 bool last(void); 132 133 /// \brief Wrap QSqlQuery::seek(int,bool) 134 // so we can display the query results 135 bool seek(int, bool relative = false); 136 121 137 /// \brief Wrap QSqlQuery::exec(const QString &query) so we can display SQL 122 138 bool exec(const QString &query); 123 139 124 140 /// \brief QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2 125 141 bool prepare(const QString &query); 126 142 127 /// \brief Wrap QSqlQuery::bindValue so we can convert null QStrings to empty QStrings 128 void bindValue ( const QString & placeholder, const QVariant & val, QSql::ParamType paramType = QSql::In ); 129 /// \brief Wrap QSqlQuery::bindValue so we can convert null QStrings to empty QStrings 130 void bindValue ( int pos, const QVariant & val, QSql::ParamType paramType = QSql::In ); 143 void bindValue(const QString &placeholder, const QVariant &val); 131 144 132 145 /// \brief Add all the bindings in the passed in bindings 133 void bindValues( MSqlBindings &bindings);146 void bindValues(const MSqlBindings &bindings); 134 147 135 148 /** \brief Return the id of the last inserted row 136 149 * … … class MPUBLIC MSqlQuery : public QSqlQue 142 155 */ 143 156 QVariant lastInsertId(); 144 157 158 /// Reconnects server and re-prepares and re-binds the last prepared 159 /// query. 160 bool Reconnect(void); 161 162 // Thunks that allow us to make QSqlQuery private 163 QVariant value(int i) const { return QSqlQuery::value(i); } 164 QString executedQuery(void) const { return QSqlQuery::executedQuery(); } 165 QMap<QString, QVariant> boundValues(void) const 166 { return QSqlQuery::boundValues(); } 167 QSqlError lastError(void) const { return QSqlQuery::lastError(); } 168 int size(void) const { return QSqlQuery::size();} 169 bool isActive(void) const { return QSqlQuery::isActive(); } 170 QSqlRecord record(void) const { return QSqlQuery::record(); } 171 int numRowsAffected() const { return QSqlQuery::numRowsAffected(); } 172 void setForwardOnly(bool f) { QSqlQuery::setForwardOnly(f); } 173 bool isNull(int field) const { return QSqlQuery::isNull(field); } 174 const QSqlDriver *driver(void) const { return QSqlQuery::driver(); } 175 int at(void) const { return QSqlQuery::at(); } 176 145 177 /// \brief Checks DB connection + login (login info via Mythcontext) 146 178 static bool testDBConnection(); 147 179 … … class MPUBLIC MSqlQuery : public QSqlQue 155 187 static MSqlQueryInfo DDCon(); 156 188 157 189 private: 190 // Only QSql::In is supported as a param type and only named params... 191 void bindValue(const QString&, const QVariant&, QSql::ParamType); 192 void bindValue(int, const QVariant&, QSql::ParamType); 193 void addBindValue(const QVariant&, QSql::ParamType = QSql::In); 194 195 bool seekDebug(const char *type, bool result, 196 int where, bool relative) const; 197 158 198 MSqlDatabase *m_db; 159 199 bool m_isConnected; 160 200 bool m_returnConnection; -
mythtv/libs/libmythdb/mythversion.h
old new 11 11 /// Update this whenever the plug-in API changes. 12 12 /// Including changes in the libmythdb, libmyth, libmythtv, libmythav* and 13 13 /// libmythui class methods used by plug-ins. 14 #define MYTH_BINARY_VERSION "0.24.20110 505-1"14 #define MYTH_BINARY_VERSION "0.24.20110804-1" 15 15 16 16 /** \brief Increment this whenever the MythTV network protocol changes. 17 17 * -
mythtv/libs/libmythtv/datadirect.cpp
old new bool DataDirectProcessor::UpdateChannels 822 822 823 823 if (!chan_update_q.exec()) 824 824 { 825 MythDB::DBError("Updating channel table", 826 chan_update_q.lastQuery()); 825 MythDB::DBError("Updating channel table", chan_update_q); 827 826 } 828 827 } 829 828 -
mythtv/libs/libmythtv/dbcheck.cpp
old new NULL 3659 3659 { 3660 3660 MythDB::DBError(QString("Unable to perform test for database " 3661 3661 "corruption before character set conversion."), 3662 thequery);3662 query); 3663 3663 return false; 3664 3664 } 3665 3665 // If the conversion to utf8 resulted in warnings, the data in the … … NULL 3688 3688 { 3689 3689 MythDB::DBError(QString("Error getting database warnings for " 3690 3690 "database corruption test."), 3691 thequery);3691 query); 3692 3692 return false; 3693 3693 } 3694 3694 // Test creating an index to see if we had partial corruption that … … NULL 3702 3702 if (!ok) 3703 3703 { 3704 3704 MythDB::DBError(QString("Index creation failed."), 3705 thequery);3705 query); 3706 3706 VERBOSE(VB_IMPORTANT, "DB charset pre-conversion test " 3707 3707 "failed! Your database seems to be partially " 3708 3708 "corrupted. Please move the backup to a safe " … … NULL 3716 3716 thequery = QString("DROP TEMPORARY TABLE temp_%1;").arg(table); 3717 3717 if (!query.exec(thequery)) 3718 3718 MythDB::DBError(QString("Error dropping temporary table %1.") 3719 .arg(table), thequery);3719 .arg(table), query); 3720 3720 3721 3721 tableIndex++; 3722 3722 } -
mythtv/programs/mythbackend/httpstatus.cpp
old new void HttpStatus::FillStatusXML( QDomDocu 430 430 MSqlQuery query(MSqlQuery::InitCon()); 431 431 query.prepare("SELECT MAX(endtime) FROM program WHERE manualid = 0;"); 432 432 433 if (query.exec() && query. isActive() && query.size())433 if (query.exec() && query.next()) 434 434 { 435 query.next(); 436 437 if (query.isValid()) 438 GuideDataThrough = QDateTime::fromString(query.value(0).toString(), 439 Qt::ISODate); 435 GuideDataThrough = QDateTime::fromString( 436 query.value(0).toString(), Qt::ISODate); 440 437 } 441 438 442 439 guide.setAttribute("start", gCoreContext->GetSetting("mythfilldatabaseLastRunStart")); -
mythtv/programs/mythbackend/main_helpers.cpp
old new bool setupTVs(bool ismaster, bool &error 75 75 "DATE_FORMAT(starttime, '%Y%m%d%H%i00'), '_', " 76 76 "DATE_FORMAT(endtime, '%Y%m%d%H%i00'), '.nuv') " 77 77 "WHERE basename = '';")) 78 MythDB::DBError("Updating record basename", 79 query.lastQuery()); 78 MythDB::DBError("Updating record basename", query); 80 79 81 80 // Hack to make sure record.station gets set if the user 82 81 // downgrades to a prior version and creates new entries 83 82 // without it. 84 83 if (!query.exec("UPDATE channel SET callsign=chanid " 85 84 "WHERE callsign IS NULL OR callsign='';")) 86 MythDB::DBError("Updating channel callsign", query .lastQuery());85 MythDB::DBError("Updating channel callsign", query); 87 86 88 87 if (query.exec("SELECT MIN(chanid) FROM channel;")) 89 88 { … … bool setupTVs(bool ismaster, bool &error 91 90 int min_chanid = query.value(0).toInt(); 92 91 if (!query.exec(QString("UPDATE record SET chanid = %1 " 93 92 "WHERE chanid IS NULL;").arg(min_chanid))) 94 MythDB::DBError("Updating record chanid", query .lastQuery());93 MythDB::DBError("Updating record chanid", query); 95 94 } 96 95 else 97 MythDB::DBError("Querying minimum chanid", query .lastQuery());96 MythDB::DBError("Querying minimum chanid", query); 98 97 99 98 MSqlQuery records_without_station(MSqlQuery::InitCon()); 100 99 records_without_station.prepare("SELECT record.chanid," … … bool setupTVs(bool ismaster, bool &error 113 112 records_without_station.value(0)); 114 113 if (!update_record.exec()) 115 114 { 116 MythDB::DBError("Updating record station", 117 update_record.lastQuery()); 115 MythDB::DBError("Updating record station", update_record); 118 116 } 119 117 } while (records_without_station.next()); 120 118 } -
mythtv/programs/mythbackend/mainserver.cpp
old new void MainServer::getGuideDataThrough(QDa 2929 2929 MSqlQuery query(MSqlQuery::InitCon()); 2930 2930 query.prepare("SELECT MAX(endtime) FROM program WHERE manualid = 0;"); 2931 2931 2932 if (query.exec() && query. isActive() && query.size())2932 if (query.exec() && query.next()) 2933 2933 { 2934 query.next(); 2935 if (query.isValid()) 2936 GuideDataThrough = QDateTime::fromString(query.value(0).toString(), 2937 Qt::ISODate); 2934 GuideDataThrough = QDateTime::fromString( 2935 query.value(0).toString(), Qt::ISODate); 2938 2936 } 2939 2937 } 2940 2938 -
mythtv/programs/mythbackend/scheduler.cpp
old new void Scheduler::AddNewRecords(void) 3604 3604 { 3605 3605 result.prepare("DROP TABLE IF EXISTS sched_temp_record;"); 3606 3606 if (!result.exec()) 3607 MythDB::DBError("AddNewRecords sched_temp_record", query);3607 MythDB::DBError("AddNewRecords sched_temp_record", result); 3608 3608 } 3609 3609 3610 3610 result.prepare("DROP TABLE IF EXISTS sched_temp_recorded;"); 3611 3611 if (!result.exec()) 3612 MythDB::DBError("AddNewRecords drop table", query);3612 MythDB::DBError("AddNewRecords drop table", result); 3613 3613 } 3614 3614 3615 3615 void Scheduler::AddNotListed(void) { -
mythtv/programs/mythfrontend/progfind.cpp
old new void ProgFinder::getShowNames() 527 527 query.bindValues(bindings); 528 528 if (!query.exec()) 529 529 { 530 MythDB::DBError("getShowNames", thequery);530 MythDB::DBError("getShowNames", query); 531 531 return; 532 532 } 533 533 -
mythplugins/mythmusic/mythmusic/smartplaylist.cpp
old new void SmartPLResultViewer::setSQL(QString 1733 1733 query.value(4).toString(), 1734 1734 query.value(5).toString(), 1735 1735 query.value(6).toString()); 1736 } while (query.prev ());1736 } while (query.previous()); 1737 1737 } 1738 1738 1739 1739 // set selection to first item -
mythplugins/mythweather/mythweather/weatherSource.cpp
old new ScriptInfo *WeatherSource::ProbeScript(c 304 304 db.bindValue(":EMAIL", info.email); 305 305 if (!db.exec()) 306 306 { 307 MythDB::DBError("Updating weather source settings.", query);307 MythDB::DBError("Updating weather source settings.", db); 308 308 return NULL; 309 309 } 310 310 } … … ScriptInfo *WeatherSource::ProbeScript(c 338 338 db.bindValue(":TYPES", info.types.join(",")); 339 339 if (!db.exec()) 340 340 { 341 MythDB::DBError("Inserting weather source", query);341 MythDB::DBError("Inserting weather source", db); 342 342 return NULL; 343 343 } 344 344 query = "SELECT sourceid FROM weathersourcesettings " … … ScriptInfo *WeatherSource::ProbeScript(c 350 350 db.bindValue(":NAME", info.name); 351 351 if (!db.exec()) 352 352 { 353 MythDB::DBError("Getting weather sourceid", query);353 MythDB::DBError("Getting weather sourceid", db); 354 354 return NULL; 355 355 } 356 356 else if (!db.next())