Index: mythcontext.cpp
===================================================================
--- mythcontext.cpp	(revision 16421)
+++ mythcontext.cpp	(working copy)
@@ -2599,28 +2617,21 @@
     bool success = false;
 
     MSqlQuery query(MSqlQuery::InitCon());
+    QString oldval=GetSettingOnHost(key,host,NULL);
+// this default value may taint the setting cache if the item has never been queryed before but the clearcache below should clear that up
+    if ((oldval==newValue)&&(oldval)){
+        VERBOSE(VB_IMPORTANT,QString("value allready set properly\n"));
+        return true;
+    }
     if (query.isConnected())
     {
-
+// the new code requires a 'ALTER TABLE `settings` DROP INDEX `value` , ADD UNIQUE `value` ( `value` , `hostname` )' to be added to the db schema
         if ((host) && (host != ""))
-            query.prepare("DELETE FROM settings WHERE value = :KEY "
-                          "AND hostname = :HOSTNAME ;");
-        else
-            query.prepare("DELETE FROM settings WHERE value = :KEY "
-                          "AND hostname is NULL;");
-
-        query.bindValue(":KEY", key);
-        query.bindValue(":HOSTNAME", host);
-
-        if (!query.exec() || !query.isActive())
-            MythContext::DBError("Clear setting", query);
-
-        if ((host) && (host != ""))
             query.prepare("INSERT INTO settings (value,data,hostname) "
-                          "VALUES ( :VALUE, :DATA, :HOSTNAME );");
+                          "VALUES ( :VALUE, :DATA, :HOSTNAME ) on duplicate key update data=:DATA;");
         else
             query.prepare("INSERT INTO settings (value,data,hostname ) "
-                          "VALUES ( :VALUE, :DATA, NULL );");
+                          "VALUES (:VALUE,:DATA,NULL) on duplicate key update data=:DATA;");
 
         query.bindValue(":VALUE", key);
         query.bindValue(":DATA", newValue);
