Ticket #4884: contextdiff

File contextdiff, 1.8 KB (added by michael bishop <clever@…>, 18 years ago)

patch from 'svn diff'

Line 
1Index: mythcontext.cpp
2===================================================================
3--- mythcontext.cpp (revision 16421)
4+++ mythcontext.cpp (working copy)
5@@ -2599,28 +2617,21 @@
6 bool success = false;
7
8 MSqlQuery query(MSqlQuery::InitCon());
9+ QString oldval=GetSettingOnHost(key,host,NULL);
10+// this default value may taint the setting cache if the item has never been queryed before but the clearcache below should clear that up
11+ if ((oldval==newValue)&&(oldval)){
12+ VERBOSE(VB_IMPORTANT,QString("value allready set properly\n"));
13+ return true;
14+ }
15 if (query.isConnected())
16 {
17-
18+// the new code requires a 'ALTER TABLE `settings` DROP INDEX `value` , ADD UNIQUE `value` ( `value` , `hostname` )' to be added to the db schema
19 if ((host) && (host != ""))
20- query.prepare("DELETE FROM settings WHERE value = :KEY "
21- "AND hostname = :HOSTNAME ;");
22- else
23- query.prepare("DELETE FROM settings WHERE value = :KEY "
24- "AND hostname is NULL;");
25-
26- query.bindValue(":KEY", key);
27- query.bindValue(":HOSTNAME", host);
28-
29- if (!query.exec() || !query.isActive())
30- MythContext::DBError("Clear setting", query);
31-
32- if ((host) && (host != ""))
33 query.prepare("INSERT INTO settings (value,data,hostname) "
34- "VALUES ( :VALUE, :DATA, :HOSTNAME );");
35+ "VALUES ( :VALUE, :DATA, :HOSTNAME ) on duplicate key update data=:DATA;");
36 else
37 query.prepare("INSERT INTO settings (value,data,hostname ) "
38- "VALUES ( :VALUE, :DATA, NULL );");
39+ "VALUES (:VALUE,:DATA,NULL) on duplicate key update data=:DATA;");
40
41 query.bindValue(":VALUE", key);
42 query.bindValue(":DATA", newValue);