diff -urN mythtv-0.24.1+fixes.20111207.40f3bae.orig/mythtv/libs/libmythdb/mythdbcon.cpp mythtv-0.24.1+fixes.20111207.40f3bae/mythtv/libs/libmythdb/mythdbcon.cpp --- mythtv-0.24.1+fixes.20111207.40f3bae.orig/mythtv/libs/libmythdb/mythdbcon.cpp 2011-12-08 19:03:54.000000000 +0200 +++ mythtv-0.24.1+fixes.20111207.40f3bae/mythtv/libs/libmythdb/mythdbcon.cpp 2011-12-08 19:28:36.000000000 +0200 @@ -509,6 +509,35 @@ if (!result && QSqlQuery::lastError().number() == 2006 && Reconnect()) result = QSqlQuery::exec(); + if (!result) + { + QString err = MythDB::GetError("MSqlQuery", *this); + MSqlBindings tmp = QSqlQuery::boundValues(); + bool has_null_strings = false; + for (MSqlBindings::iterator it = tmp.begin(); it != tmp.end(); ++it) + { + if (it->type() != QVariant::String) + continue; + if (it->isNull() || it->toString().isNull()) + { + has_null_strings = true; + *it = QVariant(QString("")); + } + } + if (has_null_strings) + { + bindValues(tmp); + result = QSqlQuery::exec(); + } + if (result) + { + VERBOSE(VB_IMPORTANT, + QString("Original query failed, but resend with empty " + "strings in place of NULL strings worked. ") + + "\n" + err); + } + } + if (VERBOSE_LEVEL_CHECK(VB_DATABASE)) { QString str = lastQuery(); @@ -732,7 +761,7 @@ if (!m_last_prepared_query.isEmpty()) { MSqlBindings tmp = QSqlQuery::boundValues(); - if (!prepare(m_last_prepared_query)) + if (!QSqlQuery::prepare(m_last_prepared_query)) return false; bindValues(tmp); } diff -urN mythtv-0.24.1+fixes.20111207.40f3bae.orig/mythtv/libs/libmythdb/mythdb.cpp mythtv-0.24.1+fixes.20111207.40f3bae/mythtv/libs/libmythdb/mythdb.cpp --- mythtv-0.24.1+fixes.20111207.40f3bae.orig/mythtv/libs/libmythdb/mythdb.cpp 2011-12-08 19:03:54.000000000 +0200 +++ mythtv-0.24.1+fixes.20111207.40f3bae/mythtv/libs/libmythdb/mythdb.cpp 2011-12-08 19:19:02.000000000 +0200 @@ -136,7 +136,17 @@ QString str = QString("%1").arg("", indent); for (; it != bindings.end(); ++it) { - const QString curBinding = it.key() + '=' + (*it).toString() + ','; + QString val = (*it).toString(); + if ((*it).isNull()) + { + val = "NULL"; + } + else if (it->type() == QVariant::String) + { + val = (it->toString().isNull()) ? + "NULL" : QString("\"%1\"").arg(val); + } + const QString curBinding = it.key() + '=' + val + ','; if ((curColumn > indent) && ((curBinding.length() + curColumn) > maxColumn)) { @@ -158,7 +168,7 @@ return str; } -void MythDB::DBError(const QString &where, const MSqlQuery& query) +QString MythDB::GetError(const QString &where, const MSqlQuery &query) { QString str = QString("DB Error (%1):\n").arg(where); @@ -171,7 +181,12 @@ str += tmp; } str += DBErrorMessage(query.lastError()); - VERBOSE(VB_IMPORTANT, QString("%1").arg(str)); + return str; +} + +void MythDB::DBError(const QString &where, const MSqlQuery &query) +{ + VERBOSE(VB_IMPORTANT, GetError(where, query)); } QString MythDB::DBErrorMessage(const QSqlError& err) diff -urN mythtv-0.24.1+fixes.20111207.40f3bae.orig/mythtv/libs/libmythdb/mythdb.h mythtv-0.24.1+fixes.20111207.40f3bae/mythtv/libs/libmythdb/mythdb.h --- mythtv-0.24.1+fixes.20111207.40f3bae.orig/mythtv/libs/libmythdb/mythdb.h 2011-12-08 19:03:54.000000000 +0200 +++ mythtv-0.24.1+fixes.20111207.40f3bae/mythtv/libs/libmythdb/mythdb.h 2011-12-08 19:21:05.000000000 +0200 @@ -19,6 +19,7 @@ MDBManager *GetDBManager(void); Settings *GetOldSettings(void); + static QString GetError(const QString &where, const MSqlQuery &query); static void DBError(const QString &where, const MSqlQuery &query); static QString DBErrorMessage(const QSqlError &err); diff -urN mythtv-0.24.1+fixes.20111207.40f3bae.orig/mythtv/libs/libmythdb/mythversion.h mythtv-0.24.1+fixes.20111207.40f3bae/mythtv/libs/libmythdb/mythversion.h --- mythtv-0.24.1+fixes.20111207.40f3bae.orig/mythtv/libs/libmythdb/mythversion.h 2011-12-08 19:03:54.000000000 +0200 +++ mythtv-0.24.1+fixes.20111207.40f3bae/mythtv/libs/libmythdb/mythversion.h 2011-12-08 19:30:51.000000000 +0200 @@ -11,7 +11,7 @@ /// Update this whenever the plug-in API changes. /// Including changes in the libmythdb, libmyth, libmythtv, libmythav* and /// libmythui class methods used by plug-ins. -#define MYTH_BINARY_VERSION "0.24.20110804-1" +#define MYTH_BINARY_VERSION "0.24.20110804-1-vp" /** \brief Increment this whenever the MythTV network protocol changes. *