1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
Database schema 1347 fails to update due to bad SQL statement
Ref: https://code.mythtv.org/trac/ticket/13155
--- libs/libmythtv/dbcheck.cpp.orig 2018-02-01 11:15:37 UTC
+++ libs/libmythtv/dbcheck.cpp
@@ -3340,25 +3340,24 @@ NULL
if (dbver == "1346")
{
- QString master;
+ QList<QByteArray> updates_ba;
// Create new MasterServerName setting
if (gCoreContext->IsMasterHost())
- master =
- "insert into settings (value,data,hostname) "
- "values('MasterServerName','"
- + gCoreContext->GetHostName() + "', null);";
+ updates_ba.push_back(
+ QString("INSERT INTO settings (value, data, hostname) "
+ "VALUES ('MasterServerName', '%1', NULL);")
+ .arg(gCoreContext->GetHostName()).toLocal8Bit());
else
- master =
- "insert into settings (value,data,hostname) "
- "select 'MasterServerName', b.hostname, null "
- "from settings a, settings b "
- "where a.value = 'MasterServerIP' "
- "and b.value in ('BackendServerIP','BackendServerIP6')"
- "and a.data = b.data;";
+ updates_ba.push_back(
+ QString("INSERT INTO settings (value,data,hostname) "
+ "SELECT 'MasterServerName', b.hostname, NULL "
+ "FROM settings a, settings b "
+ "WHERE a.value = 'MasterServerIP' "
+ "AND b.value IN ('BackendServerIP','BackendServerIP6')"
+ "AND a.data = b.data;")
+ .toLocal8Bit());
- const char *updates[] = {
- // Create new MasterServerName setting
- master.toLocal8Bit().constData(),
+ const char *post_sql[] = {
// Create new BackendServerAddr setting for each backend server
// Assume using IPV4 value.
"insert into settings (value,data,hostname) "
@@ -3385,8 +3384,17 @@ NULL
// Delete obsolete settings
"delete from settings "
"where value in ('WatchTVGuide');",
- NULL
};
+
+ for (uint i = 0; i < sizeof(post_sql)/sizeof(char*); i++)
+ updates_ba.push_back(QByteArray(post_sql[i]));
+
+ // Convert update ByteArrays to NULL terminated char**
+ QList<QByteArray>::const_iterator it = updates_ba.begin();
+ vector<const char*> updates;
+ for (; it != updates_ba.end(); ++it)
+ updates.push_back((*it).constData());
+ updates.push_back(NULL);
if (!performActualUpdate(&updates[0], "1347", dbver))
return false;
|