somer DB schema manipulation functions moved to libnxdb from nxdbmgr
[public/netxms.git] / src / server / tools / nxdbmgr / upgrade.cpp
1 /*
2 ** nxdbmgr - NetXMS database manager
3 ** Copyright (C) 2004-2017 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** File: upgrade.cpp
20 **
21 **/
22
23 #include "nxdbmgr.h"
24 #include <nxevent.h>
25
26 /**
27 * Externals
28 */
29 BOOL MigrateMaps();
30 bool ConvertTDataTables();
31
32 /**
33 * Pre-defined GUID mapping for GenerateGUID
34 */
35 struct GUID_MAPPING
36 {
37 UINT32 id;
38 const TCHAR *guid;
39 };
40
41 /**
42 * Generate GUIDs
43 */
44 static bool GenerateGUID(const TCHAR *table, const TCHAR *idColumn, const TCHAR *guidColumn, const GUID_MAPPING *mapping)
45 {
46 TCHAR query[256];
47 _sntprintf(query, 256, _T("SELECT %s FROM %s"), idColumn, table);
48 DB_RESULT hResult = SQLSelect(query);
49 if (hResult == NULL)
50 return false;
51
52 uuid_t guid;
53 TCHAR buffer[64];
54
55 int count = DBGetNumRows(hResult);
56 for(int i = 0; i < count; i++)
57 {
58 const TCHAR *guidText = NULL;
59 UINT32 id = DBGetFieldULong(hResult, i, 0);
60 if (mapping != NULL)
61 {
62 for(int j = 0; mapping[j].guid != NULL; j++)
63 if (mapping[j].id == id)
64 {
65 guidText = mapping[j].guid;
66 break;
67 }
68 }
69 if (guidText == NULL)
70 {
71 _uuid_generate(guid);
72 guidText = _uuid_to_string(guid, buffer);
73 }
74 _sntprintf(query, 256, _T("UPDATE %s SET %s='%s' WHERE %s=%d"), table, guidColumn, guidText, idColumn, id);
75 if (!SQLQuery(query))
76 {
77 DBFreeResult(hResult);
78 return false;
79 }
80 }
81 DBFreeResult(hResult);
82 return true;
83 }
84
85 /**
86 * Create table
87 */
88 static bool CreateTable(const TCHAR *pszQuery)
89 {
90 String query(pszQuery);
91
92 query.replace(_T("$SQL:TEXT"), g_pszSqlType[g_dbSyntax][SQL_TYPE_TEXT]);
93 query.replace(_T("$SQL:TXT4K"), g_pszSqlType[g_dbSyntax][SQL_TYPE_TEXT4K]);
94 query.replace(_T("$SQL:INT64"), g_pszSqlType[g_dbSyntax][SQL_TYPE_INT64]);
95 if (g_dbSyntax == DB_SYNTAX_MYSQL)
96 query += g_pszTableSuffix;
97 return SQLQuery(query);
98 }
99
100 /**
101 * Check if configuration variable exist
102 */
103 static bool IsConfigurationVariableExist(const TCHAR *name)
104 {
105 bool found = false;
106 TCHAR query[256];
107 _sntprintf(query, 256, _T("SELECT var_value FROM config WHERE var_name='%s'"), name);
108 DB_RESULT hResult = DBSelect(g_hCoreDB, query);
109 if (hResult != 0)
110 {
111 found = (DBGetNumRows(hResult) > 0);
112 DBFreeResult(hResult);
113 }
114 return found;
115 }
116
117 /**
118 * Create configuration parameter if it doesn`t exist (unless bForceUpdate set to true)
119 */
120 bool CreateConfigParam(const TCHAR *name, const TCHAR *value, const TCHAR *description, char dataType, bool isVisible, bool needRestart, bool isPublic, bool forceUpdate)
121 {
122 bool success = true;
123 TCHAR szQuery[3024];
124 if (!IsConfigurationVariableExist(name))
125 {
126 _sntprintf(szQuery, 3024, _T("INSERT INTO config (var_name,var_value,is_visible,need_server_restart,is_public,data_type,description) VALUES (%s,%s,%d,%d,'%c','%c',%s)"),
127 (const TCHAR *)DBPrepareString(g_hCoreDB, name, 63),
128 (const TCHAR *)DBPrepareString(g_hCoreDB, value, 2000), isVisible ? 1 : 0, needRestart ? 1 : 0,
129 isPublic ? _T('Y') : _T('N'), dataType, (const TCHAR *)DBPrepareString(g_hCoreDB, description, 255));
130 success = SQLQuery(szQuery);
131 }
132 else if (forceUpdate)
133 {
134 _sntprintf(szQuery, 3024, _T("UPDATE config SET var_value=%s WHERE var_name=%s"),
135 (const TCHAR *)DBPrepareString(g_hCoreDB, value, 2000), (const TCHAR *)DBPrepareString(g_hCoreDB, name, 63));
136 success = SQLQuery(szQuery);
137 }
138 return success;
139 }
140
141 /**
142 * Create configuration parameter if it doesn't exist (unless bForceUpdate set to true)
143 */
144 bool CreateConfigParam(const TCHAR *name, const TCHAR *value, bool isVisible, bool needRestart, bool forceUpdate)
145 {
146 bool success = true;
147 TCHAR szQuery[3024];
148 if (!IsConfigurationVariableExist(name))
149 {
150 _sntprintf(szQuery, 3024, _T("INSERT INTO config (var_name,var_value,is_visible,need_server_restart) VALUES (%s,%s,%d,%d)"),
151 (const TCHAR *)DBPrepareString(g_hCoreDB, name, 63),
152 (const TCHAR *)DBPrepareString(g_hCoreDB, value, 2000), isVisible ? 1 : 0, needRestart ? 1 : 0);
153 success = SQLQuery(szQuery);
154 }
155 else if (forceUpdate)
156 {
157 _sntprintf(szQuery, 3024, _T("UPDATE config SET var_value=%s WHERE var_name=%s"),
158 (const TCHAR *)DBPrepareString(g_hCoreDB, value, 2000), (const TCHAR *)DBPrepareString(g_hCoreDB, name, 63));
159 success = SQLQuery(szQuery);
160 }
161 return success;
162 }
163
164 /**
165 * Convert strings from # encoded form to normal form
166 */
167 static BOOL ConvertStrings(const TCHAR *table, const TCHAR *idColumn, const TCHAR *idColumn2, const TCHAR *column, bool isStringId)
168 {
169 DB_RESULT hResult;
170 TCHAR *query;
171 size_t queryLen = 512;
172 BOOL success = FALSE;
173
174 query = (TCHAR *)malloc(queryLen * sizeof(TCHAR));
175
176 switch(g_dbSyntax)
177 {
178 case DB_SYNTAX_MSSQL:
179 _sntprintf(query, queryLen, _T("UPDATE %s SET %s='' WHERE CAST(%s AS nvarchar(4000))=N'#00'"), table, column, column);
180 break;
181 case DB_SYNTAX_ORACLE:
182 _sntprintf(query, queryLen, _T("UPDATE %s SET %s='' WHERE to_char(%s)='#00'"), table, column, column);
183 break;
184 default:
185 _sntprintf(query, queryLen, _T("UPDATE %s SET %s='' WHERE %s='#00'"), table, column, column);
186 break;
187 }
188 if (!SQLQuery(query))
189 {
190 free(query);
191 return FALSE;
192 }
193
194 _sntprintf(query, queryLen, _T("SELECT %s,%s%s%s FROM %s WHERE %s LIKE '%%#%%'"),
195 idColumn, column, (idColumn2 != NULL) ? _T(",") : _T(""), (idColumn2 != NULL) ? idColumn2 : _T(""), table, column);
196 hResult = SQLSelect(query);
197 if (hResult == NULL)
198 {
199 free(query);
200 return FALSE;
201 }
202
203 int count = DBGetNumRows(hResult);
204 for(int i = 0; i < count; i++)
205 {
206 TCHAR *value = DBGetField(hResult, i, 1, NULL, 0);
207 if (_tcschr(value, _T('#')) != NULL)
208 {
209 DecodeSQLString(value);
210 String newValue = DBPrepareString(g_hCoreDB, value);
211 if (newValue.length() + 256 > queryLen)
212 {
213 queryLen = newValue.length() + 256;
214 query = (TCHAR *)realloc(query, queryLen * sizeof(TCHAR));
215 }
216 if (isStringId)
217 {
218 TCHAR *id = DBGetField(hResult, i, 0, NULL, 0);
219 if (idColumn2 != NULL)
220 {
221 TCHAR *id2 = DBGetField(hResult, i, 2, NULL, 0);
222 _sntprintf(query, queryLen, _T("UPDATE %s SET %s=%s WHERE %s=%s AND %s=%s"),
223 table, column, (const TCHAR *)newValue,
224 idColumn, (const TCHAR *)DBPrepareString(g_hCoreDB, id),
225 idColumn2, (const TCHAR *)DBPrepareString(g_hCoreDB, id2));
226 }
227 else
228 {
229 _sntprintf(query, queryLen, _T("UPDATE %s SET %s=%s WHERE %s=%s"), table, column,
230 (const TCHAR *)newValue, idColumn, (const TCHAR *)DBPrepareString(g_hCoreDB, id));
231 }
232 free(id);
233 }
234 else
235 {
236 INT64 id = DBGetFieldInt64(hResult, i, 0);
237 if (idColumn2 != NULL)
238 {
239 INT64 id2 = DBGetFieldInt64(hResult, i, 2);
240 _sntprintf(query, queryLen, _T("UPDATE %s SET %s=%s WHERE %s=") INT64_FMT _T(" AND %s=") INT64_FMT,
241 table, column, (const TCHAR *)newValue, idColumn, id, idColumn2, id2);
242 }
243 else
244 {
245 _sntprintf(query, queryLen, _T("UPDATE %s SET %s=%s WHERE %s=") INT64_FMT, table, column,
246 (const TCHAR *)newValue, idColumn, id);
247 }
248 }
249 if (!SQLQuery(query))
250 goto cleanup;
251 }
252 }
253 success = TRUE;
254
255 cleanup:
256 DBFreeResult(hResult);
257 free(query);
258 return success;
259 }
260
261 static BOOL ConvertStrings(const TCHAR *table, const TCHAR *idColumn, const TCHAR *column)
262 {
263 return ConvertStrings(table, idColumn, NULL, column, false);
264 }
265
266 /**
267 * Resize varchar column
268 */
269 static bool ResizeColumn(const TCHAR *table, const TCHAR *column, int newSize, bool nullable)
270 {
271 TCHAR query[1024];
272
273 switch(g_dbSyntax)
274 {
275 case DB_SYNTAX_DB2:
276 _sntprintf(query, 1024, _T("ALTER TABLE %s ALTER COLUMN %s SET DATA TYPE varchar(%d)"), table, column, newSize);
277 break;
278 case DB_SYNTAX_MSSQL:
279 _sntprintf(query, 1024, _T("ALTER TABLE %s ALTER COLUMN %s varchar(%d) %s NULL"), table, column, newSize, nullable ? _T("") : _T("NOT"));
280 break;
281 case DB_SYNTAX_PGSQL:
282 _sntprintf(query, 1024, _T("ALTER TABLE %s ALTER COLUMN %s TYPE varchar(%d)"), table, column, newSize);
283 break;
284 case DB_SYNTAX_SQLITE:
285 /* TODO: add SQLite support */
286 query[0] = 0;
287 break;
288 default:
289 _sntprintf(query, 1024, _T("ALTER TABLE %s MODIFY %s varchar(%d)"), table, column, newSize);
290 break;
291 }
292
293 return (query[0] != 0) ? SQLQuery(query) : true;
294 }
295
296 /**
297 * Create new event template
298 */
299 static BOOL CreateEventTemplate(int code, const TCHAR *name, int severity, int flags, const TCHAR *guid, const TCHAR *message, const TCHAR *description)
300 {
301 TCHAR query[4096];
302
303 if (guid != NULL)
304 {
305 _sntprintf(query, 4096, _T("INSERT INTO event_cfg (event_code,event_name,severity,flags,message,description,guid) VALUES (%d,'%s',%d,%d,%s,%s,'%s')"),
306 code, name, severity, flags, (const TCHAR *)DBPrepareString(g_hCoreDB, message),
307 (const TCHAR *)DBPrepareString(g_hCoreDB, description), guid);
308 }
309 else
310 {
311 _sntprintf(query, 4096, _T("INSERT INTO event_cfg (event_code,event_name,severity,flags,message,description) VALUES (%d,'%s',%d,%d,%s,%s)"),
312 code, name, severity, flags, (const TCHAR *)DBPrepareString(g_hCoreDB, message),
313 (const TCHAR *)DBPrepareString(g_hCoreDB, description));
314 }
315 return SQLQuery(query);
316 }
317
318 /**
319 * Re-create TDATA tables
320 */
321 static BOOL RecreateTData(const TCHAR *className, bool multipleTables, bool indexFix)
322 {
323 TCHAR query[1024];
324 _sntprintf(query, 256, _T("SELECT id FROM %s"), className);
325 DB_RESULT hResult = SQLSelect(query);
326 if (hResult != NULL)
327 {
328 int count = DBGetNumRows(hResult);
329 for(int i = 0; i < count; i++)
330 {
331 bool recreateTables = true;
332 DWORD id = DBGetFieldULong(hResult, i, 0);
333
334 if (indexFix)
335 {
336 _sntprintf(query, 256, _T("SELECT count(*) FROM dc_tables WHERE node_id=%d"), id);
337 DB_RESULT hResultCount = SQLSelect(query);
338 if (hResultCount != NULL)
339 {
340 recreateTables = (DBGetFieldLong(hResultCount, 0, 0) == 0);
341 DBFreeResult(hResultCount);
342 }
343
344 if (!recreateTables)
345 {
346 _sntprintf(query, 256, _T("CREATE INDEX idx_tdata_rec_%d_id ON tdata_records_%d(record_id)"), id, id);
347 if (!SQLQuery(query))
348 {
349 if (!g_bIgnoreErrors)
350 {
351 DBFreeResult(hResult);
352 return FALSE;
353 }
354 }
355 }
356 }
357
358 if (recreateTables)
359 {
360 if (multipleTables)
361 {
362 _sntprintf(query, 1024, _T("DROP TABLE tdata_rows_%d\nDROP TABLE tdata_records_%d\nDROP TABLE tdata_%d\n<END>"), id, id, id);
363 }
364 else
365 {
366 _sntprintf(query, 256, _T("DROP TABLE tdata_%d\n<END>"), id);
367 }
368 if (!SQLBatch(query))
369 {
370 if (!g_bIgnoreErrors)
371 {
372 DBFreeResult(hResult);
373 return FALSE;
374 }
375 }
376
377 if (!CreateTDataTable(id))
378 {
379 if (!g_bIgnoreErrors)
380 {
381 DBFreeResult(hResult);
382 return FALSE;
383 }
384 }
385 }
386 }
387 DBFreeResult(hResult);
388 }
389 else
390 {
391 if (!g_bIgnoreErrors)
392 return FALSE;
393 }
394 return TRUE;
395 }
396
397 /**
398 * Convert network masks from dotted decimal format to number of bits
399 */
400 static BOOL ConvertNetMasks(const TCHAR *table, const TCHAR *column, const TCHAR *idColumn, const TCHAR *idColumn2 = NULL, const TCHAR *condition = NULL)
401 {
402 TCHAR query[256];
403
404 if (idColumn2 != NULL)
405 _sntprintf(query, 256, _T("SELECT %s,%s,%s FROM %s"), idColumn, column, idColumn2, table);
406 else
407 _sntprintf(query, 256, _T("SELECT %s,%s FROM %s"), idColumn, column, table);
408 DB_RESULT hResult = SQLSelect(query);
409 if (hResult == NULL)
410 return FALSE;
411
412 BOOL success = SQLDropColumn(table, column);
413
414 if (success)
415 {
416 _sntprintf(query, 256, _T("ALTER TABLE %s ADD %s integer"), table, column);
417 success = SQLQuery(query);
418 }
419
420 if (success)
421 {
422 int count = DBGetNumRows(hResult);
423 for(int i = 0; (i < count) && success; i++)
424 {
425 if (idColumn2 != NULL)
426 {
427 TCHAR id2[256];
428 _sntprintf(query, 256, _T("UPDATE %s SET %s=%d WHERE %s=%d AND %s='%s'"),
429 table, column, BitsInMask(DBGetFieldIPAddr(hResult, i, 1)), idColumn, DBGetFieldLong(hResult, i, 0),
430 idColumn2, DBGetField(hResult, i, 2, id2, 256));
431 }
432 else
433 {
434 _sntprintf(query, 256, _T("UPDATE %s SET %s=%d WHERE %s=%d"),
435 table, column, BitsInMask(DBGetFieldIPAddr(hResult, i, 1)), idColumn, DBGetFieldLong(hResult, i, 0));
436 }
437 success = SQLQuery(query);
438 }
439 }
440
441 DBFreeResult(hResult);
442 return success;
443 }
444
445 /**
446 * Convert object tool macros to new format
447 */
448 static bool ConvertObjectToolMacros(UINT32 id, const TCHAR *text, const TCHAR *column)
449 {
450 if (_tcschr(text, _T('%')) == NULL)
451 return true; // nothing to convert
452
453 String s;
454 for(const TCHAR *p = text; *p != 0; p++)
455 {
456 if (*p == _T('%'))
457 {
458 TCHAR name[256];
459 int i = 0;
460 for(p++; (*p != _T('%')) && (*p != 0); p++)
461 {
462 if (i < 255)
463 name[i++] = *p;
464 }
465 if (*p == 0)
466 break; // malformed string
467 name[i] = 0;
468 if (!_tcscmp(name, _T("ALARM_ID")))
469 {
470 s.append(_T("%Y"));
471 }
472 else if (!_tcscmp(name, _T("ALARM_MESSAGE")))
473 {
474 s.append(_T("%A"));
475 }
476 else if (!_tcscmp(name, _T("ALARM_SEVERITY")))
477 {
478 s.append(_T("%s"));
479 }
480 else if (!_tcscmp(name, _T("ALARM_SEVERITY_TEXT")))
481 {
482 s.append(_T("%S"));
483 }
484 else if (!_tcscmp(name, _T("ALARM_STATE")))
485 {
486 s.append(_T("%y"));
487 }
488 else if (!_tcscmp(name, _T("OBJECT_ID")))
489 {
490 s.append(_T("%I"));
491 }
492 else if (!_tcscmp(name, _T("OBJECT_IP_ADDR")))
493 {
494 s.append(_T("%a"));
495 }
496 else if (!_tcscmp(name, _T("OBJECT_NAME")))
497 {
498 s.append(_T("%n"));
499 }
500 else if (!_tcscmp(name, _T("USERNAME")))
501 {
502 s.append(_T("%U"));
503 }
504 else
505 {
506 s.append(_T("%{"));
507 s.append(name);
508 s.append(_T('}'));
509 }
510 }
511 else
512 {
513 s.append(*p);
514 }
515 }
516
517 String query = _T("UPDATE object_tools SET ");
518 query.append(column);
519 query.append(_T('='));
520 query.append(DBPrepareString(g_hCoreDB, s));
521 query.append(_T(" WHERE tool_id="));
522 query.append(id);
523 return SQLQuery(query);
524 }
525
526 /**
527 * Create library script
528 */
529 static bool CreateLibraryScript(UINT32 id, const TCHAR *name, const TCHAR *code)
530 {
531 // Check if script exists
532 TCHAR query[256];
533 _sntprintf(query, 256, _T("SELECT script_id FROM script_library WHERE script_id=%d OR script_name=%s"),
534 id, (const TCHAR *)DBPrepareString(g_hCoreDB, name));
535 DB_RESULT hResult = SQLSelect(query);
536 if (hResult == NULL)
537 return false;
538 bool exist = (DBGetNumRows(hResult) > 0);
539 DBFreeResult(hResult);
540 if (exist)
541 return true;
542
543 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("INSERT INTO script_library (script_id,script_name,script_code) VALUES (?,?,?)"));
544 if (hStmt == NULL)
545 return false;
546
547 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, id);
548 DBBind(hStmt, 2, DB_SQLTYPE_VARCHAR, name, DB_BIND_STATIC);
549 DBBind(hStmt, 3, DB_SQLTYPE_TEXT, code, DB_BIND_STATIC);
550
551 bool success = SQLExecute(hStmt);
552 DBFreeStatement(hStmt);
553 return success;
554 }
555
556 /**
557 * Check if an event pair is handled by any EPP rules
558 */
559 static bool IsEventPairInUse(UINT32 code1, UINT32 code2)
560 {
561 TCHAR query[256];
562 _sntprintf(query, 256, _T("SELECT count(*) FROM policy_event_list WHERE event_code=%d OR event_code=%d"), code1, code2);
563 DB_RESULT hResult = SQLSelect(query);
564 if (hResult == NULL)
565 return false;
566 bool inUse = (DBGetFieldLong(hResult, 0, 0) > 0);
567 DBFreeResult(hResult);
568 return inUse;
569 }
570
571 /**
572 * Return the next free EPP rule ID
573 */
574 static int NextFreeEPPruleID()
575 {
576 int ruleId = 1;
577 DB_RESULT hResult = SQLSelect(_T("SELECT max(rule_id) FROM event_policy"));
578 if (hResult != NULL)
579 {
580 ruleId = DBGetFieldLong(hResult, 0, 0) + 1;
581 DBFreeResult(hResult);
582 }
583 return ruleId;
584 }
585
586 /**
587 * Add event to EPP rule by rule GUID
588 */
589 static bool AddEventToEPPRule(const TCHAR *guid, UINT32 eventCode)
590 {
591 TCHAR query[256];
592 _sntprintf(query, 256, _T("SELECT rule_id FROM event_policy WHERE rule_guid='%s'"), guid);
593 DB_RESULT hResult = SQLSelect(query);
594 if (hResult == NULL)
595 return false;
596
597 bool success = true;
598 if (DBGetNumRows(hResult) > 0)
599 {
600 _sntprintf(query, 256, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), DBGetFieldLong(hResult, 0, 0), eventCode);
601 success = SQLQuery(query);
602 }
603 DBFreeResult(hResult);
604 return success;
605 }
606
607 /**
608 * Set schema version
609 */
610 static bool SetSchemaVersion(int version)
611 {
612 TCHAR query[256];
613 _sntprintf(query, 256, _T("UPDATE metadata SET var_value='%d' WHERE var_name='SchemaVersion'"), version);
614 return SQLQuery(query);
615 }
616
617 /**
618 * Upgrade from V455 to V456
619 */
620 static BOOL H_UpgradeFromV455(int currVersion, int newVersion)
621 {
622 CHK_EXEC(
623 CreateEventTemplate(EVENT_PACKAGE_INSTALLED, _T("SYS_PACKAGE_INSTALLED"),
624 SEVERITY_NORMAL, EF_LOG, _T("92e5cf98-a415-4414-9ad8-d155dac77e96"),
625 _T("Package %1 %2 installed"),
626 _T("Generated when new software package is found.\r\n")
627 _T("Parameters:\r\n")
628 _T(" 1) Package name\r\n")
629 _T(" 2) Package version"))
630 );
631
632 CHK_EXEC(
633 CreateEventTemplate(EVENT_PACKAGE_UPDATED, _T("SYS_PACKAGE_UPDATED"),
634 SEVERITY_NORMAL, EF_LOG, _T("9d5878c1-525e-4cab-8f02-2a6c46d7fc36"),
635 _T("Package %1 updated from %3 to %2"),
636 _T("Generated when software package version change is detected.\r\n")
637 _T("Parameters:\r\n")
638 _T(" 1) Package name\r\n")
639 _T(" 2) New package version\r\n")
640 _T(" 3) Old package version"))
641 );
642
643 CHK_EXEC(
644 CreateEventTemplate(EVENT_PACKAGE_REMOVED, _T("SYS_PACKAGE_REMOVED"),
645 SEVERITY_NORMAL, EF_LOG, _T("6ada4ea4-43e4-4444-9d19-ef7366110bb9"),
646 _T("Package %1 %2 removed"),
647 _T("Generated when software package removal is detected.\r\n")
648 _T("Parameters:\r\n")
649 _T(" 1) Package name\r\n")
650 _T(" 2) Last known package version"))
651 );
652
653 int ruleId = NextFreeEPPruleID();
654 TCHAR query[1024];
655 _sntprintf(query, 1024, _T("INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_severity,alarm_key,script,alarm_timeout,alarm_timeout_event) ")
656 _T("VALUES (%d,'2bb3df47-482b-4e4b-9b49-8c72c6b33011',7944,'Generate alarm on software package changes','%%m',5,'SW_PKG_%%i_%%<name>','',0,%d)"),
657 ruleId, EVENT_ALARM_TIMEOUT);
658 CHK_EXEC(SQLQuery(query));
659
660 _sntprintf(query, 256, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_PACKAGE_INSTALLED);
661 CHK_EXEC(SQLQuery(query));
662 _sntprintf(query, 256, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_PACKAGE_UPDATED);
663 CHK_EXEC(SQLQuery(query));
664 _sntprintf(query, 256, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_PACKAGE_REMOVED);
665 CHK_EXEC(SQLQuery(query));
666
667 CHK_EXEC(SetSchemaVersion(456));
668 return TRUE;
669 }
670
671 /**
672 * Upgrade from V454 to V455
673 */
674 static BOOL H_UpgradeFromV454(int currVersion, int newVersion)
675 {
676 static const TCHAR *batch =
677 _T("ALTER TABLE interfaces ADD parent_iface integer\n")
678 _T("UPDATE interfaces SET parent_iface=0\n")
679 _T("<END>");
680 CHK_EXEC(SQLBatch(batch));
681 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("interfaces"), _T("parent_iface")));
682 CHK_EXEC(SetSchemaVersion(455));
683 return TRUE;
684 }
685
686 /**
687 * Upgrade from V453 to V454
688 */
689 static BOOL H_UpgradeFromV453(int currVersion, int newVersion)
690 {
691 static const TCHAR *batch =
692 _T("ALTER TABLE config ADD default_value varchar(2000) null\n")
693 _T("UPDATE config SET default_value='7200' WHERE var_name='ActiveDiscoveryInterval'\n")
694 _T("UPDATE config SET default_value='0' WHERE var_name='ActiveNetworkDiscovery'\n")
695 _T("UPDATE config SET default_value='4000' WHERE var_name='AgentCommandTimeout'\n")
696 _T("UPDATE config SET default_value='netxms' WHERE var_name='AgentDefaultSharedSecret'\n")
697 _T("UPDATE config SET default_value='600' WHERE var_name='AgentUpgradeWaitTime'\n")
698 _T("UPDATE config SET default_value='180' WHERE var_name='AlarmHistoryRetentionTime'\n")
699 _T("UPDATE config SET default_value='4096' WHERE var_name='AlarmListDisplayLimit'\n")
700 _T("UPDATE config SET default_value='0 0 * * *' WHERE var_name='AlarmSummaryEmailSchedule'\n")
701 _T("UPDATE config SET default_value='0' WHERE var_name='AllowDirectSMS'\n")
702 _T("UPDATE config SET default_value='63' WHERE var_name='AllowedCiphers'\n")
703 _T("UPDATE config SET default_value='1' WHERE var_name='AllowTrapVarbindsConversion'\n")
704 _T("UPDATE config SET default_value='0' WHERE var_name='AnonymousFileAccess'\n")
705 _T("UPDATE config SET default_value='1' WHERE var_name='ApplyDCIFromTemplateToDisabledDCI'\n")
706 _T("UPDATE config SET default_value='90' WHERE var_name='AuditLogRetentionTime'\n")
707 _T("UPDATE config SET default_value='1000' WHERE var_name='BeaconPollingInterval'\n")
708 _T("UPDATE config SET default_value='1000' WHERE var_name='BeaconTimeout'\n")
709 _T("UPDATE config SET default_value='0' WHERE var_name='BlockInactiveUserAccounts'\n")
710 _T("UPDATE config SET default_value='604800' WHERE var_name='CapabilityExpirationTime'\n")
711 _T("UPDATE config SET default_value='0' WHERE var_name='CaseInsensitiveLoginNames'\n")
712 _T("UPDATE config SET default_value='0' WHERE var_name='CheckTrustedNodes'\n")
713 _T("UPDATE config SET default_value='4701' WHERE var_name='ClientListenerPort'\n")
714 _T("UPDATE config SET default_value='0' WHERE var_name='ClusterContainerAutoBind'\n")
715 _T("UPDATE config SET default_value='0' WHERE var_name='ClusterTemplateAutoApply'\n")
716 _T("UPDATE config SET default_value='60' WHERE var_name='ConditionPollingInterval'\n")
717 _T("UPDATE config SET default_value='3600' WHERE var_name='ConfigurationPollingInterval'\n")
718 _T("UPDATE config SET default_value='1' WHERE var_name='DashboardDataExportEnableInterpolation'\n")
719 _T("UPDATE config SET default_value='10' WHERE var_name='DBConnectionPoolBaseSize'\n")
720 _T("UPDATE config SET default_value='300' WHERE var_name='DBConnectionPoolCooldownTime'\n")
721 _T("UPDATE config SET default_value='14400' WHERE var_name='DBConnectionPoolMaxLifetime'\n")
722 _T("UPDATE config SET default_value='30' WHERE var_name='DBConnectionPoolMaxSize'\n")
723 _T("UPDATE config SET default_value='0' WHERE var_name='DBLockPID'\n")
724 _T("UPDATE config SET default_value='UNLOCKED' WHERE var_name='DBLockStatus'\n")
725 _T("UPDATE config SET default_value='2' WHERE var_name='DefaultAgentCacheMode'\n")
726 _T("UPDATE config SET default_value='1' WHERE var_name='DefaultAgentProtocolCompressionMode'\n")
727 _T("UPDATE config SET default_value='dd.MM.yyyy' WHERE var_name='DefaultConsoleDateFormat'\n")
728 _T("UPDATE config SET default_value='HH:mm' WHERE var_name='DefaultConsoleShortTimeFormat'\n")
729 _T("UPDATE config SET default_value='HH:mm:ss' WHERE var_name='DefaultConsoleTimeFormat'\n")
730 _T("UPDATE config SET default_value='60' WHERE var_name='DefaultDCIPollingInterval'\n")
731 _T("UPDATE config SET default_value='30' WHERE var_name='DefaultDCIRetentionTime'\n")
732 _T("UPDATE config SET default_value='1' WHERE var_name='DefaultEncryptionPolicy'\n")
733 _T("UPDATE config SET default_value='1' WHERE var_name='DefaultInterfaceExpectedState'\n")
734 _T("UPDATE config SET default_value='0xffffff' WHERE var_name='DefaultMapBackgroundColor'\n")
735 _T("UPDATE config SET default_value='24' WHERE var_name='DefaultSubnetMaskIPv4'\n")
736 _T("UPDATE config SET default_value='64' WHERE var_name='DefaultSubnetMaskIPv6'\n")
737 _T("UPDATE config SET default_value='1' WHERE var_name='DeleteAlarmsOfDeletedObject'\n")
738 _T("UPDATE config SET default_value='0' WHERE var_name='DeleteEmptySubnets'\n")
739 _T("UPDATE config SET default_value='1' WHERE var_name='DeleteEventsOfDeletedObject'\n")
740 _T("UPDATE config SET default_value='0' WHERE var_name='DeleteUnreachableNodesPeriod'\n")
741 _T("UPDATE config SET default_value='none' WHERE var_name='DiscoveryFilter'\n")
742 _T("UPDATE config SET default_value='0' WHERE var_name='DiscoveryFilterFlags'\n")
743 _T("UPDATE config SET default_value='900' WHERE var_name='DiscoveryPollingInterval'\n")
744 _T("UPDATE config SET default_value='1' WHERE var_name='EnableAdminInterface'\n")
745 _T("UPDATE config SET default_value='1' WHERE var_name='EnableAgentRegistration'\n")
746 _T("UPDATE config SET default_value='1' WHERE var_name='EnableAuditLog'\n")
747 _T("UPDATE config SET default_value='0' WHERE var_name='EnableCheckPointSNMP'\n")
748 _T("UPDATE config SET default_value='0' WHERE var_name='EnableReportingServer'\n")
749 _T("UPDATE config SET default_value='0' WHERE var_name='EnableEventStormDetection'\n")
750 _T("UPDATE config SET default_value='0' WHERE var_name='EnableISCListener'\n")
751 _T("UPDATE config SET default_value='1' WHERE var_name='EnableNXSLContainerFunctions'\n")
752 _T("UPDATE config SET default_value='0' WHERE var_name='EnableObjectTransactions'\n")
753 _T("UPDATE config SET default_value='1' WHERE var_name='EnableSNMPTraps'\n")
754 _T("UPDATE config SET default_value='0' WHERE var_name='EnableAlarmSummaryEmails'\n")
755 _T("UPDATE config SET default_value='0' WHERE var_name='EnableSyslogReceiver'\n")
756 _T("UPDATE config SET default_value='1' WHERE var_name='EnableTimedAlarmAck'\n")
757 _T("UPDATE config SET default_value='0' WHERE var_name='EnableXMPPConnector'\n")
758 _T("UPDATE config SET default_value='0' WHERE var_name='EnableZoning'\n")
759 _T("UPDATE config SET default_value='0' WHERE var_name='EscapeLocalCommands'\n")
760 _T("UPDATE config SET default_value='90' WHERE var_name='EventLogRetentionTime'\n")
761 _T("UPDATE config SET default_value='15' WHERE var_name='EventStormDuration'\n")
762 _T("UPDATE config SET default_value='100' WHERE var_name='EventStormEventsPerSecond'\n")
763 _T("UPDATE config SET default_value='0' WHERE var_name='ExtendedLogQueryAccessControl'\n")
764 _T("UPDATE config SET default_value='13' WHERE var_name='ExternalAuditFacility'\n")
765 _T("UPDATE config SET default_value='514' WHERE var_name='ExternalAuditPort'\n")
766 _T("UPDATE config SET default_value='none' WHERE var_name='ExternalAuditServer'\n")
767 _T("UPDATE config SET default_value='5' WHERE var_name='ExternalAuditSeverity'\n")
768 _T("UPDATE config SET default_value='netxmsd-audit' WHERE var_name='ExternalAuditTag'\n")
769 _T("UPDATE config SET default_value='100' WHERE var_name='FirstFreeObjectId'\n")
770 _T("UPDATE config SET default_value='0' WHERE var_name='FixedStatusValue'\n")
771 _T("UPDATE config SET default_value='5' WHERE var_name='GraceLoginCount'\n")
772 _T("UPDATE config SET default_value='none' WHERE var_name='HelpDeskLink'\n")
773 _T("UPDATE config SET default_value='02:00' WHERE var_name='HousekeeperStartTime'\n")
774 _T("UPDATE config SET default_value='46' WHERE var_name='IcmpPingSize'\n")
775 _T("UPDATE config SET default_value='1500' WHERE var_name='IcmpPingTimeout'\n")
776 _T("UPDATE config SET default_value='1' WHERE var_name='ImportConfigurationOnStartup'\n")
777 _T("UPDATE config SET default_value='600' WHERE var_name='InstancePollingInterval'\n")
778 _T("UPDATE config SET default_value='0' WHERE var_name='InternalCA'\n")
779 _T("UPDATE config SET default_value='0' WHERE var_name='IntruderLockoutThreshold'\n")
780 _T("UPDATE config SET default_value='30' WHERE var_name='IntruderLockoutTime'\n")
781 _T("UPDATE config SET default_value='Task' WHERE var_name='JiraIssueType'\n")
782 _T("UPDATE config SET default_value='netxms' WHERE var_name='JiraLogin'\n")
783 _T("UPDATE config SET default_value='NETXMS' WHERE var_name='JiraProjectCode'\n")
784 _T("UPDATE config SET default_value='http://localhost' WHERE var_name='JiraServerURL'\n")
785 _T("UPDATE config SET default_value='90' WHERE var_name='JobHistoryRetentionTime'\n")
786 _T("UPDATE config SET default_value='5' WHERE var_name='JobRetryCount'\n")
787 _T("UPDATE config SET default_value='60' WHERE var_name='KeepAliveInterval'\n")
788 _T("UPDATE config SET default_value='ldap://localhost:389' WHERE var_name='LdapConnectionString'\n")
789 _T("UPDATE config SET default_value='displayName' WHERE var_name='LdapMappingFullName'\n")
790 _T("UPDATE config SET default_value='1000' WHERE var_name='LdapPageSize'\n")
791 _T("UPDATE config SET default_value='0' WHERE var_name='LdapSyncInterval'\n")
792 _T("UPDATE config SET default_value='1' WHERE var_name='LdapUserDeleteAction'\n")
793 _T("UPDATE config SET default_value='60000' WHERE var_name='LockTimeout'\n")
794 _T("UPDATE config SET default_value='0' WHERE var_name='LogAllSNMPTraps'\n")
795 _T("UPDATE config SET default_value='utf8' WHERE var_name='MailEncoding'\n")
796 _T("UPDATE config SET default_value='0' WHERE var_name='MinPasswordLength'\n")
797 _T("UPDATE config SET default_value='1000' WHERE var_name='MinViewRefreshInterval'\n")
798 _T("UPDATE config SET default_value='4747' WHERE var_name='MobileDeviceListenerPort'\n")
799 _T("UPDATE config SET default_value='25' WHERE var_name='NumberOfDataCollectors'\n")
800 _T("UPDATE config SET default_value='10' WHERE var_name='NumberOfUpgradeThreads'\n")
801 _T("UPDATE config SET default_value='86400' WHERE var_name='OfflineDataRelevanceTime'\n")
802 _T("UPDATE config SET default_value='0' WHERE var_name='PasswordComplexity'\n")
803 _T("UPDATE config SET default_value='0' WHERE var_name='PasswordExpiration'\n")
804 _T("UPDATE config SET default_value='0' WHERE var_name='PasswordHistoryLength'\n")
805 _T("UPDATE config SET default_value='1' WHERE var_name='PollCountForStatusChange'\n")
806 _T("UPDATE config SET default_value='10' WHERE var_name='PollerThreadPoolBaseSize'\n")
807 _T("UPDATE config SET default_value='250' WHERE var_name='PollerThreadPoolMaxSize'\n")
808 _T("UPDATE config SET default_value='PAP' WHERE var_name='RADIUSAuthMethod'\n")
809 _T("UPDATE config SET default_value='5' WHERE var_name='RADIUSNumRetries'\n")
810 _T("UPDATE config SET default_value='1645' WHERE var_name='RADIUSPort'\n")
811 _T("UPDATE config SET default_value='1645' WHERE var_name='RADIUSSecondaryPort'\n")
812 _T("UPDATE config SET default_value='netxms' WHERE var_name='RADIUSSecondarySecret'\n")
813 _T("UPDATE config SET default_value='none' WHERE var_name='RADIUSSecondaryServer'\n")
814 _T("UPDATE config SET default_value='netxms' WHERE var_name='RADIUSSecret'\n")
815 _T("UPDATE config SET default_value='none' WHERE var_name='RADIUSServer'\n")
816 _T("UPDATE config SET default_value='3' WHERE var_name='RADIUSTimeout'\n")
817 _T("UPDATE config SET default_value='0' WHERE var_name='ReceiveForwardedEvents'\n")
818 _T("UPDATE config SET default_value='localhost' WHERE var_name='ReportingServerHostname'\n")
819 _T("UPDATE config SET default_value='4710' WHERE var_name='ReportingServerPort'\n")
820 _T("UPDATE config SET default_value='0' WHERE var_name='ResolveDNSToIPOnStatusPoll'\n")
821 _T("UPDATE config SET default_value='1' WHERE var_name='ResolveNodeNames'\n")
822 _T("UPDATE config SET default_value='300' WHERE var_name='RoutingTableUpdateInterval'\n")
823 _T("UPDATE config SET default_value='0' WHERE var_name='RunNetworkDiscovery'\n")
824 _T("UPDATE config SET default_value='60' WHERE var_name='ServerCommandOutputTimeout'\n")
825 _T("UPDATE config SET default_value='<none>' WHERE var_name='SMSDriver'\n")
826 _T("UPDATE config SET default_value='161' WHERE var_name='SNMPPorts'\n")
827 _T("UPDATE config SET default_value='1500' WHERE var_name='SNMPRequestTimeout'\n")
828 _T("UPDATE config SET default_value='90' WHERE var_name='SNMPTrapLogRetentionTime'\n")
829 _T("UPDATE config SET default_value='162' WHERE var_name='SNMPTrapPort'\n")
830 _T("UPDATE config SET default_value='netxms@localhost' WHERE var_name='SMTPFromAddr'\n")
831 _T("UPDATE config SET default_value='NetXMS Server' WHERE var_name='SMTPFromName'\n")
832 _T("UPDATE config SET default_value='25' WHERE var_name='SMTPPort'\n")
833 _T("UPDATE config SET default_value='1' WHERE var_name='SMTPRetryCount'\n")
834 _T("UPDATE config SET default_value='localhost' WHERE var_name='SMTPServer'\n")
835 _T("UPDATE config SET default_value='1' WHERE var_name='StatusCalculationAlgorithm'\n")
836 _T("UPDATE config SET default_value='60' WHERE var_name='StatusPollingInterval'\n")
837 _T("UPDATE config SET default_value='1' WHERE var_name='StatusPropagationAlgorithm'\n")
838 _T("UPDATE config SET default_value='0' WHERE var_name='StatusShift'\n")
839 _T("UPDATE config SET default_value='75' WHERE var_name='StatusSingleThreshold'\n")
840 _T("UPDATE config SET default_value='503C2814' WHERE var_name='StatusThresholds'\n")
841 _T("UPDATE config SET default_value='01020304' WHERE var_name='StatusTranslation'\n")
842 _T("UPDATE config SET default_value='0' WHERE var_name='StrictAlarmStatusFlow'\n")
843 _T("UPDATE config SET default_value='60' WHERE var_name='SyncInterval'\n")
844 _T("UPDATE config SET default_value='0' WHERE var_name='SyncNodeNamesWithDNS'\n")
845 _T("UPDATE config SET default_value='0' WHERE var_name='SyslogIgnoreMessageTimestamp'\n")
846 _T("UPDATE config SET default_value='514' WHERE var_name='SyslogListenPort'\n")
847 _T("UPDATE config SET default_value='0' WHERE var_name='SyslogNodeMatchingPolicy'\n")
848 _T("UPDATE config SET default_value='90' WHERE var_name='SyslogRetentionTime'\n")
849 _T("UPDATE config SET default_value='0' WHERE var_name='ThresholdRepeatInterval'\n")
850 _T("UPDATE config SET default_value='http://tile.openstreetmap.org/' WHERE var_name='TileServerURL'\n")
851 _T("UPDATE config SET default_value='3' WHERE var_name='TopologyDiscoveryRadius'\n")
852 _T("UPDATE config SET default_value='900' WHERE var_name='TopologyExpirationTime'\n")
853 _T("UPDATE config SET default_value='1800' WHERE var_name='TopologyPollingInterval'\n")
854 _T("UPDATE config SET default_value='0' WHERE var_name='TrapSourcesInAllZones'\n")
855 _T("UPDATE config SET default_value='0' WHERE var_name='UseDNSNameForDiscoveredNodes'\n")
856 _T("UPDATE config SET default_value='1' WHERE var_name='UseFQDNForNodeNames'\n")
857 _T("UPDATE config SET default_value='1' WHERE var_name='UseIfXTable'\n")
858 _T("UPDATE config SET default_value='0' WHERE var_name='UseInterfaceAliases'\n")
859 _T("UPDATE config SET default_value='0' WHERE var_name='UseSNMPTrapsForDiscovery'\n")
860 _T("UPDATE config SET default_value='0' WHERE var_name='UseSyslogForDiscovery'\n")
861 _T("UPDATE config SET default_value='netxms@localhost' WHERE var_name='XMPPLogin'\n")
862 _T("UPDATE config SET default_value='netxms' WHERE var_name='XMPPPassword'\n")
863 _T("UPDATE config SET default_value='5222' WHERE var_name='XMPPPort'\n")
864 _T("UPDATE config SET default_value='localhost' WHERE var_name='XMPPServer'\n")
865 _T("<END>");
866 CHK_EXEC(SQLBatch(batch));
867
868 CHK_EXEC(SetSchemaVersion(454));
869 return TRUE;
870 }
871
872 /**
873 * Upgrade from V452 to V453
874 */
875 static BOOL H_UpgradeFromV452(int currVersion, int newVersion)
876 {
877 static const TCHAR *batch =
878 _T("ALTER TABLE audit_log ADD value_diff $SQL:TEXT\n")
879 _T("<END>");
880 CHK_EXEC(SQLBatch(batch));
881 CHK_EXEC(SetSchemaVersion(453));
882 return TRUE;
883 }
884
885 /**
886 * Upgrade from V451 to V452
887 */
888 static BOOL H_UpgradeFromV451(int currVersion, int newVersion)
889 {
890 static const TCHAR *batch =
891 _T("ALTER TABLE audit_log ADD old_value $SQL:TEXT\n")
892 _T("ALTER TABLE audit_log ADD new_value $SQL:TEXT\n")
893 _T("<END>");
894 CHK_EXEC(SQLBatch(batch));
895 CHK_EXEC(SetSchemaVersion(452));
896 return TRUE;
897 }
898
899 /**
900 * Upgrade from V450 to V451
901 */
902 static BOOL H_UpgradeFromV450(int currVersion, int newVersion)
903 {
904 CHK_EXEC(CreateTable(
905 _T("CREATE TABLE object_access_snapshot (")
906 _T(" user_id integer not null,")
907 _T(" object_id integer not null,")
908 _T(" access_rights integer not null,")
909 _T("PRIMARY KEY(user_id,object_id))")));
910
911 CHK_EXEC(SetSchemaVersion(451));
912 return TRUE;
913 }
914
915 /**
916 * Upgrade from V449 to V450
917 */
918 static BOOL H_UpgradeFromV449(int currVersion, int newVersion)
919 {
920 static const TCHAR *batch =
921 _T("ALTER TABLE dct_thresholds ADD sample_count integer\n")
922 _T("UPDATE dct_thresholds SET sample_count=1\n")
923 _T("<END>");
924 CHK_EXEC(SQLBatch(batch));
925 DBSetNotNullConstraint(g_hCoreDB, _T("dct_thresholds"), _T("sample_count"));
926
927 CHK_EXEC(CreateTable(
928 _T("CREATE TABLE dct_threshold_instances (")
929 _T(" threshold_id integer not null,")
930 _T(" instance varchar(255) not null,")
931 _T(" match_count integer not null,")
932 _T(" is_active char(1) not null,")
933 _T("PRIMARY KEY(threshold_id,instance))")));
934
935 CHK_EXEC(SetSchemaVersion(450));
936 return TRUE;
937 }
938
939 /**
940 * Upgrade from V448 to V449
941 */
942 static BOOL H_UpgradeFromV448(int currVersion, int newVersion)
943 {
944 CHK_EXEC(CreateConfigParam(_T("SMTPPort"), _T("25"), _T("Port used by SMTP server"), 'I', true, false, false, false));
945 CHK_EXEC(SetSchemaVersion(449));
946 return TRUE;
947 }
948
949 /**
950 * Upgrade from V447 to V448
951 */
952 static BOOL H_UpgradeFromV447(int currVersion, int newVersion)
953 {
954 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD lldp_id varchar(63)")));
955 CHK_EXEC(SetSchemaVersion(448));
956 return TRUE;
957 }
958
959 /**
960 * Upgrade from V446 to V447
961 */
962 static BOOL H_UpgradeFromV446(int currVersion, int newVersion)
963 {
964 CHK_EXEC(CreateTable(
965 _T("CREATE TABLE port_layouts (")
966 _T(" device_oid varchar(255) not null,")
967 _T(" numbering_scheme char(1) not null,")
968 _T(" row_count char(1) not null,")
969 _T(" layout_data varchar(4000) null,")
970 _T("PRIMARY KEY(device_oid))")));
971
972 CHK_EXEC(SetSchemaVersion(447));
973 return TRUE;
974 }
975
976 /**
977 * Upgrade from V445 to V446
978 */
979 static BOOL H_UpgradeFromV445(int currVersion, int newVersion)
980 {
981 CHK_EXEC(CreateTable(
982 _T("CREATE TABLE network_map_seed_nodes (")
983 _T(" map_id integer not null,")
984 _T(" seed_node_id integer not null,")
985 _T("PRIMARY KEY(map_id,seed_node_id))")));
986
987 DB_RESULT hResult = DBSelect(g_hCoreDB, _T("SELECT id,seed FROM network_maps"));
988 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("INSERT INTO network_map_seed_nodes (map_id,seed_node_id) VALUES (?,?)"));
989 if (hResult != NULL)
990 {
991 if (hStmt != NULL)
992 {
993 int nRows = DBGetNumRows(hResult);
994 for(int i = 0; i < nRows; i++)
995 {
996 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 0));
997 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 1));
998
999 if (!SQLExecute(hStmt))
1000 {
1001 if (!g_bIgnoreErrors)
1002 {
1003 DBFreeStatement(hStmt);
1004 DBFreeResult(hResult);
1005 return FALSE;
1006 }
1007 }
1008 }
1009
1010 CHK_EXEC(SQLDropColumn(_T("network_maps"), _T("seed")));
1011 DBFreeStatement(hStmt);
1012 }
1013 DBFreeResult(hResult);
1014 }
1015
1016 CHK_EXEC(SetSchemaVersion(446));
1017 return TRUE;
1018 }
1019
1020 /**
1021 * Upgrade from V444 to V445
1022 */
1023 static BOOL H_UpgradeFromV444(int currVersion, int newVersion)
1024 {
1025 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD tunnel_id varchar(36) null")));
1026 CHK_EXEC(SetSchemaVersion(445));
1027 return TRUE;
1028 }
1029
1030 /**
1031 * Upgrade from V443 to V444
1032 */
1033 static BOOL H_UpgradeFromV443(int currVersion, int newVersion)
1034 {
1035 CHK_EXEC(CreateConfigParam(_T("GraceLoginCount"), _T("5"), _T("User's grace login count"), 'I', true, false, false, false));
1036 CHK_EXEC(SetSchemaVersion(444));
1037 return TRUE;
1038 }
1039
1040 /**
1041 * Upgrade from V442 to V443
1042 */
1043 static BOOL H_UpgradeFromV442(int currVersion, int newVersion)
1044 {
1045 static const TCHAR *batch =
1046 _T("ALTER TABLE dc_tables ADD instance varchar(255) null\n")
1047 _T("ALTER TABLE dc_tables ADD instd_method integer null\n")
1048 _T("UPDATE dc_tables SET instd_method=0\n")
1049 _T("ALTER TABLE dc_tables ADD instd_data varchar(255) null\n")
1050 _T("ALTER TABLE dc_tables ADD instd_filter $SQL:TEXT null\n")
1051 _T("<END>");
1052 CHK_EXEC(SQLBatch(batch));
1053 DBSetNotNullConstraint(g_hCoreDB, _T("dc_tables"), _T("instd_method"));
1054 CHK_EXEC(SetSchemaVersion(443));
1055 return TRUE;
1056 }
1057
1058 /**
1059 * Upgrade from V441 to V442
1060 */
1061 static BOOL H_UpgradeFromV441(int currVersion, int newVersion)
1062 {
1063 CHK_EXEC(CreateTable(
1064 _T("CREATE TABLE object_urls (")
1065 _T(" object_id integer not null,")
1066 _T(" url_id integer not null,")
1067 _T(" url varchar(2000) null,")
1068 _T(" description varchar(2000) null,")
1069 _T(" PRIMARY KEY(object_id,url_id))")));
1070 CHK_EXEC(SetSchemaVersion(442));
1071 return TRUE;
1072 }
1073
1074 /**
1075 * Upgrade from V440 to V441
1076 */
1077 static BOOL H_UpgradeFromV440(int currVersion, int newVersion)
1078 {
1079 CHK_EXEC(CreateConfigParam(_T("TopologyPollingInterval"), _T("1800"), _T("Interval in seconds between topology polls"), 'I', true, true, false, false));
1080 CHK_EXEC(SetSchemaVersion(441));
1081 return TRUE;
1082 }
1083
1084 /**
1085 * Upgrade from V439 to V440
1086 */
1087 static BOOL H_UpgradeFromV439(int currVersion, int newVersion)
1088 {
1089 static const TCHAR *batch =
1090 _T("UPDATE config SET description='Enable/disable automatic deletion of subnet objects without any nodes within.' WHERE var_name='DeleteEmptySubnets'\n")
1091 _T("UPDATE config SET description='Instance polling interval (in seconds).' WHERE var_name='InstancePollingInterval'\n")
1092 _T("<END>");
1093 CHK_EXEC(SQLBatch(batch));
1094 CHK_EXEC(SetSchemaVersion(440));
1095 return TRUE;
1096 }
1097
1098 /**
1099 * Upgrade from V438 to V439
1100 */
1101 static BOOL H_UpgradeFromV438(int currVersion, int newVersion)
1102 {
1103 static const TCHAR *batch =
1104 _T("UPDATE config SET data_type='S' WHERE var_name='LdapUserUniqueId'\n")
1105 _T("UPDATE config SET data_type='S' WHERE var_name='LdapGroupUniqueId'\n")
1106 _T("<END>");
1107 CHK_EXEC(SQLBatch(batch));
1108 CHK_EXEC(SetSchemaVersion(439));
1109 return TRUE;
1110 }
1111
1112 /**
1113 * Upgrade from V437 to V438
1114 */
1115 static BOOL H_UpgradeFromV437(int currVersion, int newVersion)
1116 {
1117 static const TCHAR *batch =
1118 _T("ALTER TABLE snmp_trap_cfg ADD guid varchar(36)\n")
1119 _T("UPDATE snmp_trap_cfg SET guid='5d01e7e5-edbb-46ce-b53c-f7f64d1bf8ff' WHERE trap_id=1\n")
1120 _T("UPDATE snmp_trap_cfg SET guid='c5464919-fd76-4624-9c21-b6ab73d9df80' WHERE trap_id=2\n")
1121 _T("UPDATE snmp_trap_cfg SET guid='44d3b32e-33c5-4a39-b2ad-990a1120155d' WHERE trap_id=3\n")
1122 _T("UPDATE snmp_trap_cfg SET guid='c9660f48-a4b3-41c8-b3f9-e9a6a8129db5' WHERE trap_id=4\n")
1123 _T("UPDATE snmp_trap_cfg SET guid='4b422ba6-4b45-4881-931a-ed38dc798f9f' WHERE trap_id=5\n")
1124 _T("UPDATE snmp_trap_cfg SET guid='bd8b6971-a3e4-4cad-9c70-3a33e61e0913' WHERE trap_id=6\n")
1125 _T("ALTER TABLE script_library ADD guid varchar(36)\n")
1126 _T("UPDATE script_library SET guid='3b7bddce-3505-42ff-ac60-6a48a64bd0ae' WHERE script_id=1\n")
1127 _T("UPDATE script_library SET guid='2fb9212b-97e6-40e7-b434-2df4f7e8f6aa' WHERE script_id=2\n")
1128 _T("UPDATE script_library SET guid='38696a00-c519-438c-8cbd-4b3a0cba4af1' WHERE script_id=3\n")
1129 _T("UPDATE script_library SET guid='efe50915-47b2-43d8-b4f4-2c09a44970c3' WHERE script_id=4\n")
1130 _T("UPDATE script_library SET guid='7837580c-4054-40f2-981f-7185797fe7d7' WHERE script_id=11\n")
1131 _T("UPDATE script_library SET guid='f7d1bc7e-4046-4ee4-adb2-718f7361984d' WHERE script_id=12\n")
1132 _T("UPDATE script_library SET guid='048fcf32-765b-4702-9c70-f012f62d5a90' WHERE script_id=13\n")
1133 _T("UPDATE script_library SET guid='d515c10f-a5c9-4f41-afcd-9ddc8845f288' WHERE script_id=14\n")
1134 _T("UPDATE script_library SET guid='7cd1c471-2f14-4fae-8743-8899fed64d18' WHERE script_id=15\n")
1135 _T("UPDATE script_library SET guid='befdb083-ac68-481d-a7b7-127e11c3fae0' WHERE script_id=16\n")
1136 _T("<END>");
1137 CHK_EXEC(SQLBatch(batch));
1138
1139 DB_RESULT hResult = DBSelect(g_hCoreDB, _T("SELECT trap_id FROM snmp_trap_cfg WHERE guid IS NULL"));
1140 if (hResult != NULL)
1141 {
1142 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("UPDATE snmp_trap_cfg SET guid=? WHERE trap_id=?"));
1143 if (hStmt != NULL)
1144 {
1145 int numRows = DBGetNumRows(hResult);
1146 for(int i = 0; i < numRows; i++)
1147 {
1148 uuid guid = uuid::generate();
1149 DBBind(hStmt, 1, DB_SQLTYPE_VARCHAR, guid);
1150 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 0));
1151
1152 if (!SQLExecute(hStmt))
1153 {
1154 if (!g_bIgnoreErrors)
1155 {
1156 DBFreeStatement(hStmt);
1157 DBFreeResult(hResult);
1158 return FALSE;
1159 }
1160 }
1161 }
1162 DBFreeStatement(hStmt);
1163 }
1164 DBFreeResult(hResult);
1165 }
1166
1167 hResult = DBSelect(g_hCoreDB, _T("SELECT guid,script_id FROM script_library WHERE guid IS NULL"));
1168 if (hResult != NULL)
1169 {
1170 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("UPDATE script_library SET guid=? WHERE script_id=?"));
1171 if (hStmt != NULL)
1172 {
1173 int numRows = DBGetNumRows(hResult);
1174 for(int i = 0; i < numRows; i++)
1175 {
1176 uuid guid = uuid::generate();
1177 DBBind(hStmt, 1, DB_SQLTYPE_VARCHAR, guid);
1178 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 1));
1179 if (!SQLExecute(hStmt))
1180 {
1181 if (!g_bIgnoreErrors)
1182 {
1183 DBFreeStatement(hStmt);
1184 DBFreeResult(hResult);
1185 return FALSE;
1186 }
1187 }
1188 }
1189 DBFreeStatement(hStmt);
1190 }
1191 DBFreeResult(hResult);
1192 }
1193
1194 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("snmp_trap_cfg"), _T("guid")));
1195 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("script_library"), _T("guid")));
1196 CHK_EXEC(SetSchemaVersion(438));
1197 return TRUE;
1198 }
1199
1200 /**
1201 * Upgrade from V436 to V437
1202 */
1203 static BOOL H_UpgradeFromV436(int currVersion, int newVersion)
1204 {
1205 CHK_EXEC(
1206 CreateEventTemplate(EVENT_ROUTING_LOOP_DETECTED, _T("SYS_ROUTING_LOOP_DETECTED"),
1207 SEVERITY_MAJOR, EF_LOG, _T("98276f42-dc85-41a5-b449-6ba83d1a71b7"),
1208 _T("Routing loop detected for destination %3 (selected route %6/%7 via %9)"),
1209 _T("Generated when server detects routing loop during network path trace.\r\n")
1210 _T("Source of the event is node which routes packet back to already passed hop.\r\n")
1211 _T("Parameters:\r\n")
1212 _T(" 1) Protocol (IPv4 or IPv6)\r\n")
1213 _T(" 2) Path trace destination node ID\r\n")
1214 _T(" 3) Path trace destination address\r\n")
1215 _T(" 4) Path trace source node ID\r\n")
1216 _T(" 5) Path trace source node address\r\n")
1217 _T(" 6) Routing prefix (subnet address)\r\n")
1218 _T(" 7) Routing prefix length (subnet mask length)\r\n")
1219 _T(" 8) Next hop node ID\r\n")
1220 _T(" 9) Next hop address"))
1221 );
1222 CHK_EXEC(SetSchemaVersion(437));
1223 return TRUE;
1224 }
1225
1226 /**
1227 * Upgrade from V435 to V436
1228 */
1229 static BOOL H_UpgradeFromV435(int currVersion, int newVersion)
1230 {
1231 static const TCHAR *batch =
1232 _T("ALTER TABLE nodes ADD agent_comp_mode char(1)\n")
1233 _T("UPDATE nodes SET agent_comp_mode='0'\n")
1234 _T("<END>");
1235 CHK_EXEC(SQLBatch(batch));
1236 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("agent_comp_mode")));
1237 CHK_EXEC(SetSchemaVersion(436));
1238 return TRUE;
1239 }
1240
1241 /**
1242 * Upgrade from V434 to V435
1243 */
1244 static BOOL H_UpgradeFromV434(int currVersion, int newVersion)
1245 {
1246 CHK_EXEC(CreateConfigParam(_T("DefaultAgentProtocolCompressionMode"), _T("1"), _T("Default agent protocol compression mode"), 'C', true, false, false, false));
1247 static const TCHAR *batch =
1248 _T("UPDATE config SET data_type='C',description='Default agent cache mode' WHERE var_name='DefaultAgentCacheMode'\n")
1249 _T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultAgentCacheMode','1','On')\n")
1250 _T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultAgentCacheMode','2','Off')\n")
1251 _T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultAgentProtocolCompressionMode','1','Enabled')\n")
1252 _T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultAgentProtocolCompressionMode','2','Disabled')\n")
1253 _T("<END>");
1254 CHK_EXEC(SQLBatch(batch));
1255 CHK_EXEC(SetSchemaVersion(435));
1256 return TRUE;
1257 }
1258
1259 /**
1260 * Upgrade from V433 to V434
1261 */
1262 static BOOL H_UpgradeFromV433(int currVersion, int newVersion)
1263 {
1264 CHK_EXEC(
1265 CreateEventTemplate(EVENT_IF_EXPECTED_STATE_UP, _T("SYS_IF_EXPECTED_STATE_UP"),
1266 SEVERITY_NORMAL, EF_LOG, _T("4997c3f5-b332-4077-8e99-983142f0e193"),
1267 _T("Expected state for interface \"%2\" set to UP"),
1268 _T("Generated when interface expected state set to UP.\r\n")
1269 _T("Please note that source of event is node, not an interface itself.\r\n")
1270 _T("Parameters:\r\n")
1271 _T(" 1) Interface index\r\n")
1272 _T(" 2) Interface name"))
1273 );
1274
1275 CHK_EXEC(
1276 CreateEventTemplate(EVENT_IF_EXPECTED_STATE_DOWN, _T("SYS_IF_EXPECTED_STATE_DOWN"),
1277 SEVERITY_NORMAL, EF_LOG, _T("75de536c-4861-4f19-ba56-c43d814431d7"),
1278 _T("Expected state for interface \"%2\" set to DOWN"),
1279 _T("Generated when interface expected state set to DOWN.\r\n")
1280 _T("Please note that source of event is node, not an interface itself.\r\n")
1281 _T("Parameters:\r\n")
1282 _T(" 1) Interface index\r\n")
1283 _T(" 2) Interface name"))
1284 );
1285
1286 CHK_EXEC(
1287 CreateEventTemplate(EVENT_IF_EXPECTED_STATE_IGNORE, _T("SYS_IF_EXPECTED_STATE_IGNORE"),
1288 SEVERITY_NORMAL, EF_LOG, _T("0e488c0e-3340-4e02-ad96-b999b8392e55"),
1289 _T("Expected state for interface \"%2\" set to IGNORE"),
1290 _T("Generated when interface expected state set to IGNORE.\r\n")
1291 _T("Please note that source of event is node, not an interface itself.\r\n")
1292 _T("Parameters:\r\n")
1293 _T(" 1) Interface index\r\n")
1294 _T(" 2) Interface name"))
1295 );
1296
1297 CHK_EXEC(AddEventToEPPRule(_T("6f46d451-ee66-4563-8747-d129877df24d"), EVENT_IF_EXPECTED_STATE_DOWN));
1298 CHK_EXEC(AddEventToEPPRule(_T("6f46d451-ee66-4563-8747-d129877df24d"), EVENT_IF_EXPECTED_STATE_IGNORE));
1299 CHK_EXEC(AddEventToEPPRule(_T("ecc3fb57-672d-489d-a0ef-4214ea896e0f"), EVENT_IF_EXPECTED_STATE_UP));
1300 CHK_EXEC(AddEventToEPPRule(_T("ecc3fb57-672d-489d-a0ef-4214ea896e0f"), EVENT_IF_EXPECTED_STATE_IGNORE));
1301
1302 CHK_EXEC(SetSchemaVersion(434));
1303 return TRUE;
1304 }
1305
1306 /**
1307 * Upgrade from V432 to V433
1308 */
1309 static BOOL H_UpgradeFromV432(int currVersion, int newVersion)
1310 {
1311 CHK_EXEC(CreateConfigParam(_T("UseSyslogForDiscovery"), _T("0"), _T("Use syslog messages for new node discovery."), 'B', true, false, false, false));
1312 CHK_EXEC(SetSchemaVersion(433));
1313 return TRUE;
1314 }
1315
1316 /**
1317 * Upgrade from V431 to V432
1318 */
1319 static BOOL H_UpgradeFromV431(int currVersion, int newVersion)
1320 {
1321 CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_syslog_source ON syslog(source_object_id)")));
1322 CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_snmp_trap_log_oid ON snmp_trap_log(object_id)")));
1323 CHK_EXEC(SetSchemaVersion(432));
1324 return TRUE;
1325 }
1326
1327 /**
1328 * Upgrade from V430 to V431
1329 */
1330 static BOOL H_UpgradeFromV430(int currVersion, int newVersion)
1331 {
1332 CHK_EXEC(SQLQuery(_T("DELETE FROM config_values WHERE var_name='SNMPPorts'")));
1333 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Comma separated list of UDP ports used by SNMP capable devices.' WHERE var_name='SNMPPorts'")));
1334 CHK_EXEC(SetSchemaVersion(431));
1335 return TRUE;
1336 }
1337
1338 /**
1339 * Upgrade from V429 to V430
1340 */
1341 static BOOL H_UpgradeFromV429(int currVersion, int newVersion)
1342 {
1343 CHK_EXEC(CreateTable(
1344 _T("CREATE TABLE policy_pstorage_actions (")
1345 _T("rule_id integer not null,")
1346 _T("ps_key varchar(255) not null,")
1347 _T("value varchar(2000) null,")
1348 _T("action integer not null,")
1349 _T("PRIMARY KEY(rule_id,ps_key,action))")));
1350
1351 CHK_EXEC(CreateTable(
1352 _T("CREATE TABLE persistent_storage (")
1353 _T("entry_key varchar(255) not null,")
1354 _T("value varchar(2000) null,")
1355 _T("PRIMARY KEY(entry_key))")));
1356
1357 //Move previous attrs form situations to pstorage
1358 DB_RESULT hResult = SQLSelect(_T("SELECT event_policy.rule_id,situations.name,event_policy.situation_instance,")
1359 _T("policy_situation_attr_list.attr_name,policy_situation_attr_list.attr_value ")
1360 _T("FROM event_policy,situations,policy_situation_attr_list ")
1361 _T("WHERE event_policy.rule_id=policy_situation_attr_list.rule_id ")
1362 _T("AND situations.id=policy_situation_attr_list.situation_id"));
1363 if (hResult != NULL)
1364 {
1365 int count = DBGetNumRows(hResult);
1366 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("INSERT INTO policy_pstorage_actions (rule_id,ps_key,value,action) VALUES (?,?,?,1)"));
1367 if (hStmt != NULL)
1368 {
1369 String key;
1370 for(int i = 0; i < count; i++)
1371 {
1372 TCHAR tmp[256];
1373 DBGetField(hResult, i, 1, tmp, 256);
1374 key.append(tmp);
1375 DBGetField(hResult, i, 2, tmp, 256);
1376 key.append(_T("."));
1377 key.append(tmp);
1378 DBGetField(hResult, i, 3, tmp, 256);
1379 key.append(_T("."));
1380 key.append(tmp);
1381 DBGetField(hResult, i, 4, tmp, 256);
1382
1383 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, DBGetFieldLong(hResult, i, 0));
1384 DBBind(hStmt, 2, DB_SQLTYPE_TEXT, key, DB_BIND_STATIC, 512);
1385 DBBind(hStmt, 3, DB_SQLTYPE_TEXT, tmp, DB_BIND_STATIC);
1386 if (!SQLExecute(hStmt))
1387 {
1388 if (!g_bIgnoreErrors)
1389 {
1390 DBFreeStatement(hStmt);
1391 DBFreeResult(hResult);
1392 return FALSE;
1393 }
1394 }
1395 key.clear();
1396 }
1397 DBFreeStatement(hStmt);
1398 }
1399 else if (!g_bIgnoreErrors)
1400 {
1401 DBFreeStatement(hStmt);
1402 DBFreeResult(hResult);
1403 return FALSE;
1404 }
1405 DBFreeResult(hResult);
1406 }
1407 else
1408 {
1409 if (!g_bIgnoreErrors)
1410 return false;
1411 }
1412
1413 CHK_EXEC(SQLQuery(_T("DROP TABLE situations")));
1414 CHK_EXEC(SQLQuery(_T("DROP TABLE policy_situation_attr_list")));
1415 CHK_EXEC(SQLDropColumn(_T("event_policy"), _T("situation_id")));
1416 CHK_EXEC(SQLDropColumn(_T("event_policy"), _T("situation_instance")));
1417 CHK_EXEC(SetSchemaVersion(430));
1418 return TRUE;
1419 }
1420
1421 /**
1422 * Upgrade from V428 to V429
1423 */
1424 static BOOL H_UpgradeFromV428(int currVersion, int newVersion)
1425 {
1426 CHK_EXEC(ResizeColumn(_T("config"), _T("description"), 450, true));
1427 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between active network discovery polls.' WHERE var_name='ActiveDiscoveryInterval'")));
1428 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable active network discovery. This setting is change by Network Discovery GUI' WHERE var_name='ActiveNetworkDiscovery'")));
1429 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Timeout in milliseconds for commands sent to agent. If agent did not respond to command within given number of seconds, \ncommand considered as failed.' WHERE var_name='AgentCommandTimeout'")));
1430 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='String that will be used as a shared secret in case if agent will required authentication.' WHERE var_name='AgentDefaultSharedSecret'")));
1431 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Maximum wait time in seconds for agent restart after upgrade. If agent cannot be contacted after this time period, \nupgrade process is considered as failed.' WHERE var_name='AgentUpgradeWaitTime'")));
1432 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='A number of days the server keeps an alarm history in the database.' WHERE var_name='AlarmHistoryRetentionTime'")));
1433 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Maximum alarm count that will be displayed on Alarm Browser page. Alarms that exceed this count will not be shown.' WHERE var_name='AlarmListDisplayLimit'")));
1434 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='A semicolon separated list of alarm summary e-mail recipient addresses.' WHERE var_name='AlarmSummaryEmailRecipients'")));
1435 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Schedule for sending alarm summary e-mails in cron format' WHERE var_name='AlarmSummaryEmailSchedule'")));
1436 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Allow/disallow sending of SMS via NetXMS server using nxsms utility.' WHERE var_name='AllowDirectSMS'")));
1437 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='A bitmask for encryption algorithms allowed in the server(sum the values to allow multiple algorithms at once): \n\t*1 - AES256 \n\t*2 - Blowfish-256 \n\t*4 - IDEA \n\t*8 - 3DES\n\t*16 - AES128\n\t*32 - Blowfish-128' WHERE var_name='AllowedCiphers'")));
1438 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='AllowTrapVarbindsConversion'")));
1439 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='AnonymousFileAccess'")));
1440 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable applying all DCIs from a template to the node, including disabled ones.' WHERE var_name='ApplyDCIFromTemplateToDisabledDCI'")));
1441 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Retention time in days for the records in audit log. All records older than specified will be deleted by housekeeping process.' WHERE var_name='AuditLogRetentionTime'")));
1442 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Comma-separated list of hosts to be used as beacons for checking NetXMS server network connectivity. Either DNS names \nor IP addresses can be used. This list is pinged by NetXMS server and if none of the hosts have responded, server considers that connection \nwith network is lost and generates specific event.' WHERE var_name='BeaconHosts'")));
1443 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in milliseconds between beacon hosts polls.' WHERE var_name='BeaconPollingInterval'")));
1444 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Timeout in milliseconds to consider beacon host unreachable.' WHERE var_name='BeaconTimeout'")));
1445 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='BlockInactiveUserAccounts'")));
1446 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='CapabilityExpirationTime'")));
1447 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable case insensitive login names' WHERE var_name='CaseInsensitiveLoginNames'")));
1448 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable trusted nodes check' WHERE var_name='CheckTrustedNodes'")));
1449 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The server port for incoming client connections (such as management console).' WHERE var_name='ClientListenerPort'")));
1450 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable container auto binding for clusters.' WHERE var_name='ClusterContainerAutoBind'")));
1451 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable template auto apply for clusters.' WHERE var_name='ClusterTemplateAutoApply'")));
1452 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between polling (re-evaluating) of condition objects.' WHERE var_name='ConditionPollingInterval'")));
1453 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between configuration polls.' WHERE var_name='ConfigurationPollingInterval'")));
1454 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable data interpolation in dashboard data export.' WHERE var_name='DashboardDataExportEnableInterpolation'")));
1455 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='A number of connections to the database created on server startup.' WHERE var_name='DBConnectionPoolBaseSize'")));
1456 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DBConnectionPoolCooldownTime'")));
1457 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DBConnectionPoolMaxLifetime'")));
1458 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='A maximum number of connections in the connection pool.' WHERE var_name='DBConnectionPoolMaxSize'")));
1459 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='DBLockInfo'")));
1460 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DBLockPID'")));
1461 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='DBLockStatus'")));
1462 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DefaultAgentCacheMode'")));
1463 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Default date display format for GUI.' WHERE var_name='DefaultConsoleDateFormat'")));
1464 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Default short time display format for GUI.' WHERE var_name='DefaultConsoleShortTimeFormat'")));
1465 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Default long time display format for GUI.' WHERE var_name='DefaultConsoleTimeFormat'")));
1466 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default polling interval for newly created DCI (in seconds).' WHERE var_name='DefaultDCIPollingInterval'")));
1467 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default retention time for newly created DCI (in days).' WHERE var_name='DefaultDCIRetentionTime'")));
1468 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Set the default encryption policy for communications with agents.' WHERE var_name='DefaultEncryptionPolicy'")));
1469 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Default expected state for new interface objects.' WHERE var_name='DefaultInterfaceExpectedState'")));
1470 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='H',description='Default background color for new network map objects.' WHERE var_name='DefaultMapBackgroundColor'")));
1471 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default mask for synthetic IPv4 subnets.' WHERE var_name='DefaultSubnetMaskIPv4'")));
1472 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default mask for synthetic IPv6 subnets.' WHERE var_name='DefaultSubnetMaskIPv6'")));
1473 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable automatic alarm removal of an object when it is deleted' WHERE var_name='DeleteAlarmsOfDeletedObject'")));
1474 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable automatic deletion of subnet objects without any nodes within. When enabled, empty subnets will be deleted \nby housekeeping process.' WHERE var_name='DeleteEmptySubnets'")));
1475 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable automatic event removal of an object when it is deleted.' WHERE var_name='DeleteEventsOfDeletedObject'")));
1476 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Delete nodes which were unreachable for a number of days specified by this parameter.' WHERE var_name='DeleteUnreachableNodesPeriod'")));
1477 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='DiscoveryFilter'")));
1478 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DiscoveryFilterFlags'")));
1479 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between passive network discovery polls.' WHERE var_name='DiscoveryPollingInterval'")));
1480 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableAdminInterface'")));
1481 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable agent self-registration' WHERE var_name='EnableAgentRegistration'")));
1482 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable audit log.' WHERE var_name='EnableAuditLog'")));
1483 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableCheckPointSNMP'")));
1484 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableReportingServer'")));
1485 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableEventStormDetection'")));
1486 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable Inter-Server Communications Listener.' WHERE var_name='EnableISCListener'")));
1487 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable server-side NXSL functions for container management (such as CreateContainer, RemoveContainer, BindObject, \nUnbindObject).' WHERE var_name='EnableNXSLContainerFunctions.'")));
1488 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableObjectTransactions'")));
1489 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable SNMP trap processing.' WHERE var_name='EnableSNMPTraps'")));
1490 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable alarm summary e-mails.' WHERE var_name='EnableAlarmSummaryEmails'")));
1491 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable receiving of syslog messages.' WHERE var_name='EnableSyslogReceiver'")));
1492 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableTimedAlarmAck'")));
1493 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable XMPP connector (required to enable XMPP message sending).' WHERE var_name='EnableXMPPConnector'")));
1494 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable zoning support' WHERE var_name='EnableZoning'")));
1495 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EscapeLocalCommands'")));
1496 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The retention time of event logs' WHERE var_name='EventLogRetentionTime'")));
1497 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='EventStormDuration'")));
1498 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Event storm events per second' WHERE var_name='EventStormEventsPerSecond'")));
1499 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable extended access control in log queries.' WHERE var_name='ExtendedLogQueryAccessControl'")));
1500 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Syslog facility to be used in audit log records sent to external server.' WHERE var_name='ExternalAuditFacility'")));
1501 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='UDP port of external syslog server to send audit records to.' WHERE var_name='ExternalAuditPort'")));
1502 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='External syslog server to send audit records to. If set to ‘’none’‘, external audit logging is disabled.' WHERE var_name='ExternalAuditServer'")));
1503 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Syslog severity to be used in audit log records sent to external server.' WHERE var_name='ExternalAuditSeverity'")));
1504 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Syslog tag to be used in audit log records sent to external server.' WHERE var_name='ExternalAuditTag'")));
1505 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='FirstFreeObjectId'")));
1506 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='FixedStatusValue'")));
1507 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='HelpDeskLink'")));
1508 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Time when housekeeper starts. Housekeeper deletes old log lines, old DCI data, cleans removed objects and does VACUUM for \nPostgreSQL.' WHERE var_name='HousekeeperStartTime'")));
1509 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Size of ICMP packets (in bytes, excluding IP header size) used for status polls.' WHERE var_name='IcmpPingSize'")));
1510 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Timeout for ICMP ping used for status polls (in milliseconds).' WHERE var_name='IcmpPingTimeout'")));
1511 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Import configuration from local files on server startup.' WHERE var_name='ImportConfigurationOnStartup'")));
1512 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Instance polling interval (in milliseconds).' WHERE var_name='InstancePollingInterval'")));
1513 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable internal certificate authority.' WHERE var_name='InternalCA'")));
1514 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='IntruderLockoutThreshold'")));
1515 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='IntruderLockoutTime'")));
1516 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='JiraIssueType'")));
1517 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Jira login name.' WHERE var_name='JiraLogin'")));
1518 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Jira password' WHERE var_name='JiraPassword'")));
1519 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Jira project code' WHERE var_name='JiraProjectCode'")));
1520 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='JiraProjectComponent'")));
1521 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The URL of the Jira server' WHERE var_name='JiraServerURL'")));
1522 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='JobHistoryRetentionTime'")));
1523 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Maximum mumber of job execution retrys.' WHERE var_name='JobRetryCount'")));
1524 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between sending keep alive packets to connected clients.' WHERE var_name='KeepAliveInterval'")));
1525 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Specifies which object class represents group objects. If the found entry is not of user or group class, it will be ignored.' WHERE var_name='LdapGroupClass'")));
1526 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='LdapGroupUniqueId'")));
1527 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The LdapConnectionString configuration parameter may be a comma- or whitespace-separated list of URIs containing only the \nschema, the host, and the port fields. Format: schema://host:port.' WHERE var_name='LdapConnectionString'")));
1528 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The name of an attribute whose value will be used as a user`s description.' WHERE var_name='LdapMappingDescription'")));
1529 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The name of an attribute whose value will be used as a user`s full name.' WHERE var_name='LdapMappingFullName'")));
1530 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The name of an attribute whose value will be used as a user`s login name.' WHERE var_name='LdapMappingName'")));
1531 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The maximum amount of records that can be returned in one search page.' WHERE var_name='LdapPageSize'")));
1532 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The DN of the entry at which to start the search.' WHERE var_name='LdapSearchBase'")));
1533 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='A string representation of the filter to apply in the search.' WHERE var_name='LdapSearchFilter'")));
1534 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The synchronization interval (in minutes) between the NetXMS server and the LDAP server. If the parameter is set to 0, no \nsynchronization will take place.' WHERE var_name='LdapSyncInterval'")));
1535 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='User login for LDAP synchronization.' WHERE var_name='LdapSyncUser'")));
1536 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='User password for LDAP synchronization.' WHERE var_name='LdapSyncUserPassword'")));
1537 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The object class which represents user objects. If the found entry is not of user or group class, it will be ignored.' WHERE var_name='LdapUserClass'")));
1538 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='This parameter specifies what should be done while synchronizing with a deleted user/group from LDAP.' WHERE var_name='LdapUserDeleteAction'")));
1539 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='LdapUserUniqueId'")));
1540 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='LockTimeout'")));
1541 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Log all SNMP traps.' WHERE var_name='LogAllSNMPTraps'")));
1542 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Encoding for e-mails generated by NetXMS server.' WHERE var_name='MailEncoding'")));
1543 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Message to be shown when a user logs into the console.' WHERE var_name='MessageOfTheDay'")));
1544 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default minimum password length for a NetXMS user. The default applied only if per-user setting is not defined.' WHERE var_name='MinPasswordLength'")));
1545 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='MinViewRefreshInterval'")));
1546 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='MobileDeviceListenerPort'")));
1547 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The number of threads used for data collection.' WHERE var_name='NumberOfDataCollectors'")));
1548 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The number of threads used to perform agent upgrades (i.e. maximum number of parallel upgrades).' WHERE var_name='NumberOfUpgradeThreads'")));
1549 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Time period in seconds within which received offline data still relevant for threshold validation.' WHERE var_name='OfflineDataRelevanceTime'")));
1550 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Set of flags to enforce password complexity.' WHERE var_name='PasswordComplexity'")));
1551 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Password expiration time in days. If set to 0, password expiration is disabled.' WHERE var_name='PasswordExpiration'")));
1552 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Number of previous passwords to keep. Users are not allowed to set password if it matches one from previous passwords list.' WHERE var_name='PasswordHistoryLength'")));
1553 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The number of consecutive unsuccessful polls required to declare interface as down.' WHERE var_name='PollCountForStatusChange'")));
1554 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The base thread pool size.' WHERE var_name='PollerThreadPoolBaseSize'")));
1555 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Maximum thread pool size.' WHERE var_name='PollerThreadPoolMaxSize'")));
1556 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='RADIUS authentication method to be used (PAP, CHAP, MS-CHAPv1, MS-CHAPv2).' WHERE var_name='RADIUSAuthMethod'")));
1557 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The number of retries for RADIUS authentication.' WHERE var_name='RADIUSNumRetries'")));
1558 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Port number used for connection to primary RADIUS server.' WHERE var_name='RADIUSPort'")));
1559 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Port number used for connection to secondary RADIUS server.' WHERE var_name='RADIUSSecondaryPort'")));
1560 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Shared secret used for communication with secondary RADIUS server.' WHERE var_name='RADIUSSecondarySecret'")));
1561 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Host name or IP address of secondary RADIUS server.' WHERE var_name='RADIUSSecondaryServer'")));
1562 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Shared secret used for communication with primary RADIUS server.' WHERE var_name='RADIUSSecret'")));
1563 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Host name or IP address of primary RADIUS server.' WHERE var_name='RADIUSServer'")));
1564 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Timeout in seconds for requests to RADIUS server.' WHERE var_name='RADIUSTimeout'")));
1565 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable reception of events forwarded by another NetXMS server. Please note that for external event reception ISC listener \nshould be enabled as well.' WHERE var_name='ReceiveForwardedEvents'")));
1566 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The hostname of the reporting server.' WHERE var_name='ReportingServerHostname'")));
1567 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The port of the reporting server.' WHERE var_name='ReportingServerPort'")));
1568 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Resolve DNS to IP on status poll.' WHERE var_name='ResolveDNSToIPOnStatusPoll'")));
1569 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='ResolveNodeNames'")));
1570 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between reading routing table from node.' WHERE var_name='RoutingTableUpdateInterval'")));
1571 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable automatic network discovery process. *This setting is changed by Network Discovery in the GUI*.' WHERE var_name='RunNetworkDiscovery'")));
1572 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='H',description='Identification color for this server' WHERE var_name='ServerColor'")));
1573 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='ServerCommandOutputTimeout'")));
1574 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Name of this server' WHERE var_name='ServerName'")));
1575 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Mobile phone driver to be used for sending SMS.' WHERE var_name='SMSDriver'")));
1576 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='SMS driver parameters. For ‘’generic’’ driver, it should be the name of COM port device.' WHERE var_name='SMSDrvConfig'")));
1577 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The address used for sending mail from.' WHERE var_name='SMTPFromAddr'")));
1578 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The name used as the sender.' WHERE var_name='SMTPFromName'")));
1579 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Number of retries for sending mail.' WHERE var_name='SMTPRetryCount'")));
1580 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='TCP port for SMTP server.' WHERE var_name='SNMPPorts'")));
1581 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='An SMTP server used for sending mail.' WHERE var_name='SMTPServer'")));
1582 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Timeout in milliseconds for SNMP requests sent by NetXMS server.' WHERE var_name='SNMPRequestTimeout'")));
1583 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The time how long SNMP trap logs are retained.' WHERE var_name='SNMPTrapLogRetentionTime'")));
1584 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Port used for SNMP traps.' WHERE var_name='SNMPTrapPort'")));
1585 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='StatusCalculationAlgorithm'")));
1586 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between status polls.' WHERE var_name='StatusPollingInterval'")));
1587 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Algorithm for status propagation (how object’s status affects its child object statuses).' WHERE var_name='StatusPropagationAlgorithm'")));
1588 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='StatusShift'")));
1589 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='StatusSingleThreshold'")));
1590 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='StatusThresholds'")));
1591 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='StatusTranslation'")));
1592 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable strict alarm status flow (alarm can be terminated only after it has been resolved).' WHERE var_name='StrictAlarmStatusFlow'")));
1593 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between writing object changes to the database.' WHERE var_name='SyncInterval'")));
1594 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable synchronization of node names with DNS on each configuration poll.' WHERE var_name='SyncNodeNamesWithDNS'")));
1595 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Ignore timestamp received in syslog messages and always use server time.' WHERE var_name='SyslogIgnoreMessageTimestamp'")));
1596 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='UDP port used by built-in syslog server.' WHERE var_name='SyslogListenPort'")));
1597 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Node matching policy for built-in syslog daemon.' WHERE var_name='SyslogNodeMatchingPolicy'")));
1598 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Retention time in days for records in syslog. All records older than specified will be deleted by housekeeping process.' WHERE var_name='SyslogRetentionTime'")));
1599 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='System-wide interval in seconds for resending threshold violation events. Value of 0 disables event resending.' WHERE var_name='ThresholdRepeatInterval'")));
1600 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The URL for the Tile server.' WHERE var_name='TileServerURL'")));
1601 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='TopologyDiscoveryRadius'")));
1602 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='TopologyExpirationTime'")));
1603 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Search all zones to match trap/syslog source address to node.' WHERE var_name='TrapSourcesInAllZones'")));
1604 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable the use of DNS name instead of IP address as primary name for newly discovered nodes.' WHERE var_name='UseDNSNameForDiscoveredNodes'")));
1605 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable the use of fully qualified domain names as primary names for newly discovered nodes.' WHERE var_name='UseFQDNForNodeNames'")));
1606 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable the use of SNMP ifXTable instead of ifTable for interface configuration polling.' WHERE var_name='UseIfXTable'")));
1607 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Control usage of interface aliases (or descriptions).' WHERE var_name='UseInterfaceAliases'")));
1608 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Use SNMP trap information for new node discovery.' WHERE var_name='UseSNMPTrapsForDiscovery'")));
1609 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Login name that will be used to authentication on XMPP server.' WHERE var_name='XMPPLogin'")));
1610 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Password that will be used to authentication on XMPP server.' WHERE var_name='XMPPPassword'")));
1611 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='XMPP connection port.' WHERE var_name='XMPPPort'")));
1612 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='XMPP connection server.' WHERE var_name='XMPPServer'")));
1613
1614 CHK_EXEC(CreateTable(
1615 _T("CREATE TABLE config_values (")
1616 _T("var_name varchar(63) not null,")
1617 _T("var_value varchar(15) not null,")
1618 _T("var_description varchar(255) null,")
1619 _T("PRIMARY KEY(var_name,var_value))")));
1620
1621 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('ClientListenerPort','65535')")));
1622 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('ExternalAuditPort','65535')")));
1623 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('MobileDeviceListenerPort','65535')")));
1624 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('RADIUSPort','65535')")));
1625 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('RADIUSSecondaryPort','65535')")));
1626 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('ReportingServerPort','65535')")));
1627 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('SNMPPorts','65535')")));
1628 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('SNMPTrapPort','65535')")));
1629 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('SyslogListenPort','65535')")));
1630 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('XMPPPort','65535')")));
1631 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('AllowedCiphers','63')")));
1632 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultInterfaceExpectedState','0','UP')")));
1633 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultInterfaceExpectedState','1','DOWN')")));
1634 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultInterfaceExpectedState','2','IGNORE')")));
1635 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultEncryptionPolicy','0','Disabled')")));
1636 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultEncryptionPolicy','1','Allowed')")));
1637 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultEncryptionPolicy','2','Preferred')")));
1638 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultEncryptionPolicy','3','Required')")));
1639 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','0','Default')")));
1640 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','1','Unchanged')")));
1641 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','2','Fixed')")));
1642 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','3','Relative')")));
1643 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','4','Translated')")));
1644 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('UseInterfaceAliases','0','Don`t use aliases')")));
1645 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('UseInterfaceAliases','1','Use aliases when possible')")));
1646 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('UseInterfaceAliases','2','Concatenate alias and name')")));
1647 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('UseInterfaceAliases','3','Concatenate name and alias')")));
1648 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('SyslogNodeMatchingPolicy','0','IP, then hostname')")));
1649 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('SyslogNodeMatchingPolicy','1','Hostname, then IP')")));
1650 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('LdapUserDeleteAction','0','Delete user')")));
1651 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('LdapUserDeleteAction','1','Disable user')")));
1652
1653 CHK_EXEC(SetSchemaVersion(429));
1654 return TRUE;
1655 }
1656
1657 /**
1658 * Upgrade from V427 to V428
1659 */
1660 static BOOL H_UpgradeFromV427(int currVersion, int newVersion)
1661 {
1662 CHK_EXEC(CreateConfigParam(_T("ClusterContainerAutoBind"), _T("0"), _T("Enable/disable container auto binding for clusters"), 'B', true, false, false, false));
1663 CHK_EXEC(CreateConfigParam(_T("ClusterTemplateAutoApply"), _T("0"), _T("Enable/disable template auto apply for clusters"), 'B', true, false, false, false));
1664 CHK_EXEC(SetSchemaVersion(428));
1665 return TRUE;
1666 }
1667
1668 /**
1669 * Upgrade from V426 to V427
1670 */
1671 static BOOL H_UpgradeFromV426(int currVersion, int newVersion)
1672 {
1673 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD port_rows integer")));
1674 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD port_numbering_scheme integer")));
1675 CHK_EXEC(SetSchemaVersion(427));
1676 return TRUE;
1677 }
1678
1679 /**
1680 * Upgrade from V425 to V426
1681 */
1682 static BOOL H_UpgradeFromV425(int currVersion, int newVersion)
1683 {
1684 CHK_EXEC(CreateConfigParam(_T("EnableAlarmSummaryEmails"), _T(""), _T("Enable alarm summary e-mails"), 'I', true, false, false, false));
1685 CHK_EXEC(CreateConfigParam(_T("AlarmSummaryEmailSchedule"), _T(""), _T("Schedule for sending alarm summary e-mails in cron format"), 'S', true, false, false, false));
1686 CHK_EXEC(CreateConfigParam(_T("AlarmSummaryEmailRecipients"), _T(""), _T("A semicolon separated list of alarm summary e-mail recipient addresses"), 'S', true, false, false, false));
1687 CHK_EXEC(SetSchemaVersion(426));
1688 return TRUE;
1689 }
1690
1691 /**
1692 * Upgrade from V424 to V425
1693 */
1694 static BOOL H_UpgradeFromV424(int currVersion, int newVersion)
1695 {
1696 CHK_EXEC(SQLQuery(_T("ALTER TABLE scheduled_tasks ADD comments varchar(255)")));
1697 CHK_EXEC(SetSchemaVersion(425));
1698 return TRUE;
1699 }
1700
1701 /**
1702 * Upgrade from V423 to V424
1703 */
1704 static BOOL H_UpgradeFromV423(int currVersion, int newVersion)
1705 {
1706 CHK_EXEC(CreateConfigParam(_T("MessageOfTheDay"), _T(""), _T("Message to be shown when a user logs into the console"), 'S', true, false, false, false));
1707 CHK_EXEC(SetSchemaVersion(424));
1708 return TRUE;
1709 }
1710
1711 /**
1712 * Upgrade from V422 to V423
1713 */
1714 static BOOL H_UpgradeFromV422(int currVersion, int newVersion)
1715 {
1716 CHK_EXEC(CreateConfigParam(_T("RADIUSAuthMethod"), _T("PAP"), _T("RADIUS authentication method to be used (PAP, CHAP, MS-CHAPv1, MS-CHAPv2)"), 'S', true, false, false, false));
1717 CHK_EXEC(SetSchemaVersion(423));
1718 return TRUE;
1719 }
1720
1721 /**
1722 * Upgrade from V421 to V422
1723 */
1724 static BOOL H_UpgradeFromV421(int currVersion, int newVersion)
1725 {
1726 CHK_EXEC(CreateConfigParam(_T("ServerColor"), _T(""), _T("Identification color for this server"), 'S', true, false, false, false));
1727 CHK_EXEC(CreateConfigParam(_T("ServerName"), _T(""), _T("Name of this server"), 'S', true, false, false, false));
1728 CHK_EXEC(SetSchemaVersion(422));
1729 return TRUE;
1730 }
1731
1732 /**
1733 * Upgrade from V420 to V421
1734 */
1735 static BOOL H_UpgradeFromV420(int currVersion, int newVersion)
1736 {
1737 DB_RESULT hResult = SQLSelect(_T("SELECT access_rights,user_id,object_id FROM acl"));
1738 if (hResult != NULL)
1739 {
1740 UINT32 rights;
1741 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("UPDATE acl SET access_rights=? WHERE user_id=? AND object_id=?"));
1742 if (hStmt != NULL)
1743 {
1744 for(int i = 0; i < DBGetNumRows(hResult); i++)
1745 {
1746 rights = DBGetFieldULong(hResult, i, 0);
1747 if ((rights & 0x2) == 0x2)
1748 {
1749 rights = rights | 0x8000; // Add Manage maintenance access right to all users which have Modify object access right
1750 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, rights);
1751 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 1));
1752 DBBind(hStmt, 3, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 2));
1753 SQLExecute(hStmt);
1754 }
1755 }
1756 DBFreeStatement(hStmt);
1757 }
1758 else
1759 {
1760 if (!g_bIgnoreErrors)
1761 {
1762 DBFreeResult(hResult);
1763 return FALSE;
1764 }
1765 }
1766 DBFreeResult(hResult);
1767 }
1768 else
1769 {
1770 if (!g_bIgnoreErrors)
1771 return FALSE;
1772 }
1773
1774 CHK_EXEC(SetSchemaVersion(421));
1775 return TRUE;
1776 }
1777
1778 /**
1779 * Upgrade from V419 to V420
1780 */
1781 static BOOL H_UpgradeFromV419(int currVersion, int newVersion)
1782 {
1783 CHK_EXEC(CreateConfigParam(_T("EnableReportingServer"), _T("0"), 1, 1));
1784 CHK_EXEC(CreateConfigParam(_T("ReportingServerHostname"), _T("localhost"), 1, 1));
1785 CHK_EXEC(CreateConfigParam(_T("ReportingServerPort"), _T("4710"), 1, 1));
1786 CHK_EXEC(SetSchemaVersion(420));
1787 return TRUE;
1788 }
1789
1790 /**
1791 * Upgrade from V418 to V419
1792 */
1793 static BOOL H_UpgradeFromV418(int currVersion, int newVersion)
1794 {
1795 CHK_EXEC(SQLQuery(_T("ALTER TABLE items ADD npe_name varchar(15)")));
1796 CHK_EXEC(SetSchemaVersion(419));
1797 return TRUE;
1798 }
1799
1800 /**
1801 * Upgrade from V417 to V418
1802 */
1803 static BOOL H_UpgradeFromV417(int currVersion, int newVersion)
1804 {
1805 // Update in object tools objectToolFilter objectMenuFilter
1806 // move object tool flags to filter structure
1807 DB_RESULT hResult = SQLSelect(_T("SELECT tool_id,flags,tool_filter FROM object_tools"));
1808 if (hResult != NULL)
1809 {
1810 int count = DBGetNumRows(hResult);
1811 for(int i = 0; i < count; i++)
1812 {
1813 int filteringFlag = 0;
1814 int objectToolFlag = DBGetFieldLong(hResult, i, 1);
1815
1816 // Separate and reorder flags for filter and for object tools
1817 for(int j = 1; j < 5; j = j << 1) //REQUIRES_SNMP 0x01, REQUIRES_AGENT 0x02, REQUIRES_OID_MATCH 0x04
1818 {
1819 if ((objectToolFlag & j) != 0)
1820 {
1821 objectToolFlag = objectToolFlag & ~j;
1822 filteringFlag = filteringFlag | j;
1823 }
1824 }
1825
1826 if ((objectToolFlag & 0x08) != 0) //ASK_CONFIRMATION
1827 {
1828 objectToolFlag = objectToolFlag & ~0x08;
1829 objectToolFlag = objectToolFlag | 0x01;
1830 }
1831
1832 if ((objectToolFlag & 0x10) != 0) //GENERATES_OUTPUT
1833 {
1834 objectToolFlag = objectToolFlag & ~0x10;
1835 objectToolFlag = objectToolFlag | 0x02;
1836 }
1837
1838 if ((objectToolFlag & 0x20) != 0) //DISABLED
1839 {
1840 objectToolFlag = objectToolFlag & ~0x20;
1841 objectToolFlag = objectToolFlag | 0x04;
1842 }
1843
1844 if ((objectToolFlag & 0x40) != 0) //SHOW_IN_COMMANDS
1845 {
1846 objectToolFlag = objectToolFlag & ~0x40;
1847 objectToolFlag = objectToolFlag | 0x08;
1848 }
1849
1850 if ((objectToolFlag & 0x80) != 0) //REQUIRES_NODE_OS_MATCH
1851 {
1852 objectToolFlag = objectToolFlag & ~0x80;
1853 filteringFlag = filteringFlag | 0x08;
1854 }
1855
1856 if ((objectToolFlag & 0x100) != 0) //REQUIRES_TEMPLATE_MATCH
1857 {
1858 objectToolFlag = objectToolFlag & ~0x100;
1859 filteringFlag = filteringFlag | 0x10;
1860 }
1861
1862 if ((objectToolFlag & 0x10000) != 0) //SNMP_INDEXED_BY_VALUE
1863 {
1864 objectToolFlag = objectToolFlag & ~0x10000;
1865 objectToolFlag = objectToolFlag | 0x10;
1866 }
1867
1868 if ((objectToolFlag & 0x20000) != 0) //REQUIRES_WORKSTATION_OS_MATCH
1869 {
1870 objectToolFlag = objectToolFlag & ~0x20000;
1871 filteringFlag = filteringFlag | 0x20;
1872 }
1873
1874 // Add filter flags to XML
1875 TCHAR *xml = DBGetField(hResult, i, 2, NULL, 0);
1876 size_t len = (xml != NULL) ? _tcslen(xml) + 1024 : 1024;
1877 TCHAR *tmp = (TCHAR *)malloc(len * sizeof(TCHAR));
1878 TCHAR *ptr = (xml != NULL) ? _tcsrchr(xml, '<') : NULL;
1879 if (ptr != NULL)
1880 {
1881 *ptr = 0;
1882 _sntprintf(tmp, len, _T("%s<flags>%d</flags></objectMenuFilter>"), xml, filteringFlag);
1883 _tcsncpy(tmp, _T("<objectMenuFilter"), 17); //Change main tag name
1884 }
1885 else
1886 {
1887 _sntprintf(tmp, len, _T("<objectMenuFilter><flags>%d</flags></objectMenuFilter>"), filteringFlag);
1888 }
1889
1890 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("UPDATE object_tools SET flags=?,tool_filter=? WHERE tool_id=?"));
1891 if (hStmt != NULL)
1892 {
1893 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, objectToolFlag);
1894 DBBind(hStmt, 2, DB_SQLTYPE_TEXT, tmp, DB_BIND_DYNAMIC);
1895 DBBind(hStmt, 3, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 0));
1896 if (!SQLExecute(hStmt))
1897 {
1898 if (!g_bIgnoreErrors)
1899 {
1900 free(xml);
1901 DBFreeStatement(hStmt);
1902 DBFreeResult(hResult);
1903 return FALSE;
1904 }
1905 }
1906 }
1907 else
1908 {
1909 free(tmp);
1910 if (!g_bIgnoreErrors)
1911 {
1912 free(xml);
1913 DBFreeResult(hResult);
1914 return FALSE;
1915 }
1916 }
1917 free(xml);
1918 }
1919 DBFreeResult(hResult);
1920 }
1921 else
1922 {
1923 if (!g_bIgnoreErrors)
1924 return false;
1925 }
1926
1927 CHK_EXEC(SetSchemaVersion(418));
1928 return TRUE;
1929 }
1930
1931 /**
1932 * Upgrade from V416 to V417
1933 */
1934 static BOOL H_UpgradeFromV416(int currVersion, int newVersion)
1935 {
1936 CHK_EXEC(CreateConfigParam(_T("JiraIssueType"), _T("Task"), true, false));
1937 CHK_EXEC(CreateConfigParam(_T("JiraLogin"), _T("netxms"), true, true));
1938 CHK_EXEC(CreateConfigParam(_T("JiraPassword"), _T(""), true, true));
1939 CHK_EXEC(CreateConfigParam(_T("JiraProjectCode"), _T("NETXMS"), true, false));
1940 CHK_EXEC(CreateConfigParam(_T("JiraProjectComponent"), _T(""), true, false));
1941 CHK_EXEC(CreateConfigParam(_T("JiraServerURL"), _T("http://localhost"), true, true));
1942
1943 CHK_EXEC(SetSchemaVersion(417));
1944 return TRUE;
1945 }
1946
1947 /**
1948 * Upgrade from V415 to V416
1949 */
1950 static BOOL H_UpgradeFromV415(int currVersion, int newVersion)
1951 {
1952 CHK_EXEC(CreateTable(
1953 _T("CREATE TABLE alarm_categories (")
1954 _T("id integer not null,")
1955 _T("name varchar(63) null,")
1956 _T("descr varchar(255) null,")
1957 _T("PRIMARY KEY(id))")));
1958 CHK_EXEC(CreateTable(
1959 _T("CREATE TABLE alarm_category_acl (")
1960 _T("category_id integer not null,")
1961 _T("user_id integer not null,")
1962 _T("PRIMARY KEY(category_id,user_id))")));
1963 CHK_EXEC(CreateTable(
1964 _T("CREATE TABLE alarm_category_map (")
1965 _T("alarm_id integer not null,")
1966 _T("category_id integer not null,")
1967 _T("PRIMARY KEY(alarm_id,category_id))")));
1968
1969 CHK_EXEC(SQLQuery(
1970 _T("ALTER TABLE alarms ADD alarm_category_ids varchar(255)")));
1971
1972 // Add view all alarms system access to user group - Everyone
1973 DB_RESULT hResult = SQLSelect(_T("SELECT system_access FROM user_groups WHERE name='Everyone'"));
1974 if (hResult != NULL)
1975 {
1976 UINT64 sysAccess = DBGetFieldUInt64(hResult, 0, 0);
1977 sysAccess = sysAccess | SYSTEM_ACCESS_VIEW_ALL_ALARMS;
1978
1979 TCHAR query[MAX_DB_STRING];
1980 _sntprintf(query, MAX_DB_STRING, _T("UPDATE user_groups SET system_access=%ld WHERE name='Everyone'"), sysAccess);
1981 CHK_EXEC(SQLQuery(query));
1982
1983 DBFreeResult(hResult);
1984 }
1985 else
1986 {
1987 if (!g_bIgnoreErrors)
1988 return false;
1989 }
1990
1991 CHK_EXEC(SetSchemaVersion(416));
1992 return TRUE;
1993 }
1994
1995 /**
1996 * Upgrade from V414 to V415
1997 */
1998 static BOOL H_UpgradeFromV414(int currVersion, int newVersion)
1999 {
2000 CHK_EXEC(DBRemoveNotNullConstraint(g_hCoreDB, _T("dci_summary_tables"), _T("menu_path")));
2001 CHK_EXEC(SetSchemaVersion(415));
2002 return TRUE;
2003 }
2004
2005 /**
2006 * Upgrade from V413 to V414
2007 */
2008 static BOOL H_UpgradeFromV413(int currVersion, int newVersion)
2009 {
2010 CHK_EXEC(SQLQuery(_T("UPDATE config SET var_name='EnableSyslogReceiver' WHERE var_name='EnableSyslogDaemon'")));
2011 CHK_EXEC(SetSchemaVersion(414));
2012 return TRUE;
2013 }
2014
2015 /**
2016 * Upgrade from V412 to V413
2017 */
2018 static BOOL H_UpgradeFromV412(int currVersion, int newVersion)
2019 {
2020 CHK_EXEC(SQLQuery(_T("UPDATE users SET name='system',description='Built-in system account',full_name='',flags=12 WHERE id=0")));
2021
2022 TCHAR password[128];
2023 DB_RESULT hResult = SQLSelect(_T("SELECT password FROM users WHERE id=0"));
2024 if (hResult != NULL)
2025 {
2026 if (DBGetNumRows(hResult) > 0)
2027 DBGetField(hResult, 0, 0, password, 128);
2028 else
2029 _tcscpy(password, _T("3A445C0072CD69D9030CC6644020E5C4576051B1")); // Use default password "netxms"
2030 DBFreeResult(hResult);
2031 }
2032 else
2033 {
2034 if (!g_bIgnoreErrors)
2035 return false;
2036 }
2037
2038 UINT32 userId = 1;
2039 hResult = SQLSelect(_T("SELECT max(id) FROM users"));
2040 if (hResult != NULL)
2041 {
2042 if (DBGetNumRows(hResult) > 0)
2043 userId = DBGetFieldULong(hResult, 0, 0) + 1;
2044 DBFreeResult(hResult);
2045 }
2046 else
2047 {
2048 if (!g_bIgnoreErrors)
2049 return false;
2050 }
2051
2052 uuid guid = uuid::generate();
2053 TCHAR query[1024];
2054 _sntprintf(query, 1024,
2055 _T("INSERT INTO users (id,name,password,system_access,flags,full_name,")
2056 _T(" description,grace_logins,auth_method,guid,")
2057 _T(" cert_mapping_method,cert_mapping_data,")
2058 _T(" auth_failures,last_passwd_change,min_passwd_length,")
2059 _T(" disabled_until,last_login) VALUES (%d,'admin','%s',274877906943,0,")
2060 _T(" '','Default administrator account',5,0,'%s',0,'',0,0,0,0,0)"),
2061 userId, password, (const TCHAR *)guid.toString());
2062 CHK_EXEC(SQLQuery(query));
2063
2064 for(int i = 1; i < 10; i++)
2065 {
2066 _sntprintf(query, 256, _T("INSERT INTO acl (object_id,user_id,access_rights) VALUES (%d,%d,32767)"), i, userId);
2067 CHK_EXEC(SQLQuery(query));
2068 }
2069
2070 //Add adming to Admin group if exists
2071 UINT32 groupId = 0;
2072 hResult = SQLSelect(_T("SELECT id FROM user_groups WHERE name='Admins'"));
2073 if (hResult != NULL)
2074 {
2075 if (DBGetNumRows(hResult) > 0)
2076 groupId = DBGetFieldULong(hResult, 0, 0);
2077 DBFreeResult(hResult);
2078 }
2079 else
2080 {
2081 if (!g_bIgnoreErrors)
2082 return false;
2083 }
2084 if(groupId != 0)
2085 {
2086 _sntprintf(query, 256, _T("INSERT INTO user_group_members (group_id,user_id) VALUES (%d,%d)"), groupId, userId);
2087 CHK_EXEC(SQLQuery(query));
2088 }
2089
2090 //Update non object ACL
2091 _sntprintf(query, 256, _T("UPDATE object_tools_acl SET user_id=%d WHERE user_id=0"), userId);
2092 CHK_EXEC(SQLQuery(query));
2093
2094 _sntprintf(query, 256, _T("UPDATE graph_acl SET user_id=%d WHERE user_id=0"), userId);
2095 CHK_EXEC(SQLQuery(query));
2096
2097 _sntprintf(query, 256, _T("UPDATE graphs SET owner_id=%d WHERE owner_id=0"), userId);
2098 CHK_EXEC(SQLQuery(query));
2099
2100
2101 CHK_EXEC(SetSchemaVersion(413));
2102 return TRUE;
2103 }
2104
2105 /**
2106 * Upgrade from V411 to V412
2107 */
2108 static BOOL H_UpgradeFromV411(int currVersion, int newVersion)
2109 {
2110 DB_RESULT hResult = SQLSelect(_T("SELECT id,zone_guid,agent_proxy,snmp_proxy,icmp_proxy,ssh_proxy FROM zones"));
2111 if (hResult != NULL)
2112 {
2113 CHK_EXEC(SQLQuery(_T("DROP TABLE zones")));
2114 CHK_EXEC(CreateTable(
2115 _T("CREATE TABLE zones (")
2116 _T("id integer not null,")
2117 _T("zone_guid integer not null,")
2118 _T("proxy_node integer not null,")
2119 _T("PRIMARY KEY(id))")));
2120 int count = DBGetNumRows(hResult);
2121 if (count > 0)
2122 {
2123 TCHAR query[256];
2124 for(int i = 0; i < count; i++)
2125 {
2126 UINT32 proxy = 0;
2127 for(int j = 2; (j < 6) && (proxy == 0); j++)
2128 proxy = DBGetFieldULong(hResult, i, j);
2129 _sntprintf(query, 256, _T("INSERT INTO zones (id,zone_guid,proxy_node) VALUES (%d,%d,%d)"),
2130 DBGetFieldLong(hResult, i, 0), DBGetFieldLong(hResult, i, 1), (int)proxy);
2131 CHK_EXEC(SQLQuery(query));
2132 }
2133 }
2134 DBFreeResult(hResult);
2135 }
2136 else
2137 {
2138 if (!g_bIgnoreErrors)
2139 return false;
2140 }
2141 CHK_EXEC(SetSchemaVersion(412));
2142 return TRUE;
2143 }
2144
2145 /**
2146 * Upgrade from V410 to V411
2147 */
2148 static BOOL H_UpgradeFromV410(int currVersion, int newVersion)
2149 {
2150 //check if tdata upgrade was already done, then just delete "TdataTableUpdated" metadata parameter
2151 if (!MetaDataReadInt(_T("TdataTableUpdated"), 0))
2152 {
2153 StringMap savedMetadata;
2154 DB_RESULT hResult = SQLSelect(_T("SELECT var_name,var_value FROM metadata WHERE var_name LIKE 'TDataTableCreationCommand_%' OR var_name LIKE 'TDataIndexCreationCommand_%'"));
2155 if (hResult != NULL)
2156 {
2157 int count = DBGetNumRows(hResult);
2158 for(int i = 0; i < count; i++)
2159 {
2160 savedMetadata.setPreallocated(DBGetField(hResult, i, 0, NULL, 0), DBGetField(hResult, i, 1, NULL, 0));
2161 }
2162 DBFreeResult(hResult);
2163 }
2164 else if (!g_bIgnoreErrors)
2165 {
2166 return false;
2167 }
2168
2169 static const TCHAR *batch =
2170 _T("DELETE FROM metadata WHERE var_name LIKE 'TDataTableCreationCommand_%' OR var_name LIKE 'TDataIndexCreationCommand_%'\n")
2171 _T("INSERT INTO metadata (var_name,var_value) VALUES ('TDataTableCreationCommand_0','CREATE TABLE tdata_%d (item_id integer not null,tdata_timestamp integer not null,tdata_value $SQL:TEXT null)')\n")
2172 _T("<END>");
2173 CHK_EXEC(SQLBatch(batch));
2174
2175 if (g_dbSyntax == DB_SYNTAX_MSSQL)
2176 CHK_EXEC(SQLQuery(_T("INSERT INTO metadata (var_name,var_value) VALUES ('TDataIndexCreationCommand_0','CREATE CLUSTERED INDEX idx_tdata_%d ON tdata_%d(item_id,tdata_timestamp)')")));
2177 else
2178 CHK_EXEC(SQLQuery(_T("INSERT INTO metadata (var_name,var_value) VALUES ('TDataIndexCreationCommand_0','CREATE INDEX idx_tdata_%d ON tdata_%d(item_id,tdata_timestamp)')")));
2179
2180 // table conversion will require multiple commits
2181 DBCommit(g_hCoreDB);
2182 if (!ConvertTDataTables())
2183 {
2184 if (!g_bIgnoreErrors)
2185 {
2186 // Restore metadata
2187 SQLQuery(_T("DELETE FROM metadata WHERE var_name LIKE 'TDataTableCreationCommand_%' OR var_name LIKE 'TDataIndexCreationCommand_%'"));
2188 StringList *keys = savedMetadata.keys();
2189 for(int i = 0; i < keys->size(); i++)
2190 {
2191 TCHAR query[4096];
2192 _sntprintf(query, 4096, _T("INSERT INTO metadata (var_name,var_value) VALUES (%s,%s)"),
2193 (const TCHAR *)DBPrepareString(g_hCoreDB, keys->get(i)),
2194 (const TCHAR *)DBPrepareString(g_hCoreDB, savedMetadata.get(keys->get(i))));
2195 SQLQuery(query);
2196 }
2197 return false;
2198 }
2199 }
2200
2201 DBBegin(g_hCoreDB);
2202 }
2203 else
2204 {
2205 CHK_EXEC(SQLQuery(_T("DELETE FROM metadata WHERE var_name='TdataTableUpdated'")));
2206 }
2207 CHK_EXEC(SetSchemaVersion(411));
2208 return TRUE;
2209 }
2210
2211 /**
2212 * Upgrade from V409 to V410
2213 */
2214 static BOOL H_UpgradeFromV409(int currVersion, int newVersion)
2215 {
2216 static const TCHAR *batch =
2217 _T("ALTER TABLE zones ADD ssh_proxy integer\n")
2218 _T("UPDATE zones SET ssh_proxy=0\n")
2219 _T("ALTER TABLE nodes ADD ssh_login varchar(63)\n")
2220 _T("ALTER TABLE nodes ADD ssh_password varchar(63)\n")
2221 _T("ALTER TABLE nodes ADD ssh_proxy integer\n")
2222 _T("UPDATE nodes SET ssh_proxy=0\n")
2223 _T("<END>");
2224 CHK_EXEC(SQLBatch(batch));
2225
2226 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("ssh_proxy")));
2227 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("zones"), _T("ssh_proxy")));
2228
2229 CHK_EXEC(SetSchemaVersion(410));
2230 return TRUE;
2231 }
2232
2233 /**
2234 * Upgrade from V408 to V409
2235 */
2236 static BOOL H_UpgradeFromV408(int currVersion, int newVersion)
2237 {
2238 static const TCHAR *batch =
2239 _T("ALTER TABLE nodes ADD node_type integer\n")
2240 _T("ALTER TABLE nodes ADD node_subtype varchar(127)\n")
2241 _T("UPDATE nodes SET node_type=0\n")
2242 _T("<END>");
2243 CHK_EXEC(SQLBatch(batch));
2244
2245 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("node_type")));
2246
2247 CHK_EXEC(SetSchemaVersion(409));
2248 return TRUE;
2249 }
2250
2251 /**
2252 * Upgrade from V407 to V408
2253 */
2254 static BOOL H_UpgradeFromV407(int currVersion, int newVersion)
2255 {
2256 CHK_EXEC(CreateTable(
2257 _T("CREATE TABLE chassis (")
2258 _T(" id integer not null,")
2259 _T(" flags integer not null,")
2260 _T(" controller_id integer not null,")
2261 _T(" rack_id integer not null,")
2262 _T(" rack_image varchar(36) null,")
2263 _T(" rack_position integer not null,")
2264 _T(" rack_height integer not null,")
2265 _T(" PRIMARY KEY(id))")
2266 ));
2267
2268 static const TCHAR *batch =
2269 _T("ALTER TABLE nodes ADD chassis_id integer\n")
2270 _T("UPDATE nodes SET chassis_id=0\n")
2271 _T("<END>");
2272 CHK_EXEC(SQLBatch(batch));
2273
2274 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("chassis_id")));
2275
2276 CHK_EXEC(SetSchemaVersion(408));
2277 return TRUE;
2278 }
2279
2280 /**
2281 * Upgrade from V406 to V407
2282 */
2283 static BOOL H_UpgradeFromV406(int currVersion, int newVersion)
2284 {
2285 ResizeColumn(_T("user_groups"), _T("ldap_unique_id"), 64, true);
2286 CHK_EXEC(SetSchemaVersion(407));
2287 return TRUE;
2288 }
2289
2290 /**
2291 * Upgrade from V405 to V406
2292 */
2293 static BOOL H_UpgradeFromV405(int currVersion, int newVersion)
2294 {
2295 static const TCHAR *batch =
2296 _T("ALTER TABLE nodes ADD syslog_msg_count $SQL:INT64\n")
2297 _T("ALTER TABLE nodes ADD snmp_trap_count $SQL:INT64\n")
2298 _T("UPDATE nodes SET syslog_msg_count=0,snmp_trap_count=0\n")
2299 _T("<END>");
2300 CHK_EXEC(SQLBatch(batch));
2301 CHK_EXEC(SetSchemaVersion(406));
2302 return TRUE;
2303 }
2304
2305 /**
2306 * Upgrade from V404 to V405
2307 */
2308 static BOOL H_UpgradeFromV404(int currVersion, int newVersion)
2309 {
2310 CHK_EXEC(CreateEventTemplate(EVENT_AGENT_LOG_PROBLEM, _T("SYS_AGENT_LOG_PROBLEM"),
2311 SEVERITY_MAJOR, EF_LOG, _T("262057ca-357a-4a4d-9b78-42ae96e490a1"),
2312 _T("Problem with agent log: %2"),
2313 _T("Generated on status poll if agent reports problem with log file.\r\n")
2314 _T("Parameters:\r\n")
2315 _T(" 1) Status code\r\n")
2316 _T(" 2) Description")));
2317 CHK_EXEC(CreateEventTemplate(EVENT_AGENT_LOCAL_DATABASE_PROBLEM, _T("SYS_AGENT_LOCAL_DATABASE_PROBLEM"),
2318 SEVERITY_MAJOR, EF_LOG, _T("d02b63f1-1151-429e-adb9-1dfbb3a31b32"),
2319 _T("Problem with agent local database: %2"),
2320 _T("Generated on status poll if agent reports local database problem.\r\n")
2321 _T("Parameters:\r\n")
2322 _T(" 1) Status code\r\n")
2323 _T(" 2) Description")));
2324
2325 int ruleId = NextFreeEPPruleID();
2326 TCHAR query[1024];
2327 _sntprintf(query, 1024, _T("INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_severity,alarm_key,script,alarm_timeout,alarm_timeout_event,situation_id,situation_instance) ")
2328 _T("VALUES (%d,'19bd89ba-8bb2-4915-8546-a1ecc650dedd',7944,'Generate an alarm when there is problem with agent log','%%m',5,'SYS_AGENT_LOG_PROBLEM_%%i','',0,%d,0,'')"),
2329 ruleId, EVENT_ALARM_TIMEOUT);
2330 CHK_EXEC(SQLQuery(query));
2331 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOG_PROBLEM);
2332 CHK_EXEC(SQLQuery(query));
2333
2334 ruleId = NextFreeEPPruleID();
2335 _sntprintf(query, 1024, _T("INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_severity,alarm_key,script,alarm_timeout,alarm_timeout_event,situation_id,situation_instance) ")
2336 _T("VALUES (%d,'cff7fe6b-2ad1-4c18-8a8f-4d397d44fe04',7944,'Generate an alarm when there is problem with agent local database','%%m',5,'SYS_AGENT_LOCAL_DATABASE_PROBLEM_%%i','',0,%d,0,'')"),
2337 ruleId, EVENT_ALARM_TIMEOUT);
2338 CHK_EXEC(SQLQuery(query));
2339 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOCAL_DATABASE_PROBLEM);
2340 CHK_EXEC(SQLQuery(query));
2341
2342 CHK_EXEC(SetSchemaVersion(405));
2343 return TRUE;
2344 }
2345
2346 /**
2347 * Upgrade from V403 to V404
2348 */
2349 static BOOL H_UpgradeFromV403(int currVersion, int newVersion)
2350 {
2351 CHK_EXEC(CreateConfigParam(_T("SyslogIgnoreMessageTimestamp"), _T("0"),
2352 _T("Ignore timestamp received in syslog messages and always use server time"),
2353 'B', true, false, false, false));
2354 CHK_EXEC(SetSchemaVersion(404));
2355 return TRUE;
2356 }
2357
2358 /**
2359 * Upgrade from V402 to V403
2360 */
2361 static BOOL H_UpgradeFromV402(int currVersion, int newVersion)
2362 {
2363 CHK_EXEC(SQLQuery(_T("DROP TABLE policy_time_range_list")));
2364 CHK_EXEC(SQLQuery(_T("DROP TABLE time_ranges")));
2365 CHK_EXEC(SetSchemaVersion(403));
2366 return TRUE;
2367 }
2368
2369 /**
2370 * Upgrade from V401 to V402
2371 */
2372 static BOOL H_UpgradeFromV401(int currVersion, int newVersion)
2373 {
2374 CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_event_log_source ON event_log(event_source)")));
2375 CHK_EXEC(SetSchemaVersion(402));
2376 return TRUE;
2377 }
2378
2379 /**
2380 * Upgrade from V400 to V401
2381 */
2382 static BOOL H_UpgradeFromV400(int currVersion, int newVersion)
2383 {
2384 CHK_EXEC(CreateEventTemplate(EVENT_LDAP_SYNC_ERROR, _T("SYS_LDAP_SYNC_ERROR"),
2385 SEVERITY_MAJOR, EF_LOG, _T("f7e8508d-1503-4736-854b-1e5b8b0ad1f2"),
2386 _T("LDAP sync error: %5"),
2387 _T("Generated when LDAP synchronization error occurs.\r\n")
2388 _T("Parameters:\r\n")
2389 _T(" 1) User ID\r\n")
2390 _T(" 2) User GUID\r\n")
2391 _T(" 3) User LDAP DN\r\n")
2392 _T(" 4) User name\r\n")
2393 _T(" 5) Problem description")));
2394
2395 int ruleId = NextFreeEPPruleID();
2396 TCHAR query[1024];
2397 _sntprintf(query, 1024, _T("INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_severity,alarm_key,script,alarm_timeout,alarm_timeout_event,situation_id,situation_instance) VALUES (%d,'417648af-5361-49a5-9471-6ef31e857b2d',7944,'Generate an alarm when error occurred during LDAP synchronization','%%m',5,'SYS_LDAP_SYNC_ERROR_%%2','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
2398 CHK_EXEC(SQLQuery(query));
2399 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_LDAP_SYNC_ERROR);
2400 CHK_EXEC(SQLQuery(query));
2401
2402 CHK_EXEC(SQLQuery(_T("ALTER TABLE users ADD ldap_unique_id varchar(64)")));
2403 CHK_EXEC(SQLQuery(_T("ALTER TABLE user_groups ADD ldap_unique_id varchar(64)")));
2404 CHK_EXEC(CreateConfigParam(_T("LdapUserUniqueId"), _T(""), true, false, false));
2405 CHK_EXEC(CreateConfigParam(_T("LdapGroupUniqueId"), _T(""), true, false, false));
2406
2407 CHK_EXEC(SetSchemaVersion(401));
2408 return TRUE;
2409 }
2410
2411 /**
2412 * Upgrade from V399 to V400
2413 */
2414 static BOOL H_UpgradeFromV399(int currVersion, int newVersion)
2415 {
2416 CHK_EXEC(CreateConfigParam(_T("JobRetryCount"), _T("5"), _T("Maximum mumber of job execution retrys"), 'I', true, false, false, false));
2417 CHK_EXEC(SetSchemaVersion(400));
2418 return TRUE;
2419 }
2420
2421 /**
2422 * Upgrade from V398 to V399
2423 */
2424 static BOOL H_UpgradeFromV398(int currVersion, int newVersion)
2425 {
2426 CHK_EXEC(CreateTable(
2427 _T("CREATE TABLE config_repositories (")
2428 _T(" id integer not null,")
2429 _T(" url varchar(1023) not null,")
2430 _T(" auth_token varchar(63) null,")
2431 _T(" description varchar(1023) null,")
2432 _T(" PRIMARY KEY(id))")
2433 ));
2434
2435 CHK_EXEC(SetSchemaVersion(399));
2436 return TRUE;
2437 }
2438
2439 /**
2440 * Upgrade from V397 to V398
2441 */
2442 static BOOL H_UpgradeFromV397(int currVersion, int newVersion)
2443 {
2444 CHK_EXEC(CreateTable(
2445 _T("CREATE TABLE currency_codes (")
2446 _T(" numeric_code char(3) not null,")
2447 _T(" alpha_code char(3) not null,")
2448 _T(" description varchar(127) not null,")
2449 _T(" exponent integer not null,")
2450 _T(" PRIMARY KEY(numeric_code))")
2451 ));
2452
2453 CHK_EXEC(CreateTable(
2454 _T("CREATE TABLE country_codes (")
2455 _T(" numeric_code char(3) not null,")
2456 _T(" alpha_code char(2) not null,")
2457 _T(" alpha3_code char(3) not null,")
2458 _T(" name varchar(127) not null,")
2459 _T(" PRIMARY KEY(numeric_code))")
2460 ));
2461
2462 static const TCHAR *batch1 =
2463 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('008', 'ALL', 'Lek', 2)\n")
2464 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('012', 'DZD', 'Algerian Dinar', 2)\n")
2465 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('031', 'AZM', 'Azerbaijanian Manat', 0)\n")
2466 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('032', 'ARS', 'Argentine Peso', 2)\n")
2467 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('036', 'AUD', 'Australian Dollar', 2)\n")
2468 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('044', 'BSD', 'Bahamian Dollar', 2)\n")
2469 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('048', 'BHD', 'Bahraini Dinar', 3)\n")
2470 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('050', 'BDT', 'Taka', 2)\n")
2471 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('051', 'AMD', 'Armenian Dram', 2)\n")
2472 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('052', 'BBD', 'Barbados Dollar', 2)\n")
2473 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('060', 'BMD', 'Bermudian Dollar', 2)\n")
2474 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('064', 'BTN', 'Ngultrum', 2)\n")
2475 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('068', 'BOB', 'Boliviano', 2)\n")
2476 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('072', 'BWP', 'Pula', 2)\n")
2477 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('084', 'BZD', 'Belize Dollar', 2)\n")
2478 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('090', 'SBD', 'Solomon Islands Dollar', 2)\n")
2479 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('096', 'BND', 'Brunei Dollar', 2)\n")
2480 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('100', 'BGL', 'Lev', 0)\n")
2481 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('104', 'MMK', 'Kyat', 2)\n")
2482 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('108', 'BIF', 'Burundi Franc', 0)\n")
2483 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('116', 'KHR', 'Riel', 2)\n")
2484 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('124', 'CAD', 'Canadian Dollar', 2)\n")
2485 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('132', 'CVE', 'Cape Verde Escudo', 2)\n")
2486 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('136', 'KYD', 'Cayman Islands Dollar', 2)\n")
2487 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('144', 'LKR', 'Sri Lanka Rupee', 2)\n")
2488 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('152', 'CLP', 'Chilean Peso', 0)\n")
2489 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('156', 'CNY', 'Yuan Renminbi', 2)\n")
2490 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('170', 'COP', 'Colombian Peso', 2)\n")
2491 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('174', 'KMF', 'Comoro Franc', 0)\n")
2492 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('188', 'CRC', 'Costa Rican Colon', 2)\n")
2493 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('191', 'HRK', 'Croatian Kuna', 2)\n")
2494 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('192', 'CUP', 'Cuban Peso', 2)\n")
2495 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('196', 'CYP', 'Cyprus Pound', 0)\n")
2496 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('203', 'CZK', 'Czech Koruna', 2)\n")
2497 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('208', 'DKK', 'Danish Krone', 2)\n")
2498 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('214', 'DOP', 'Dominican Peso', 2)\n")
2499 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('222', 'SVC', 'El Salvador Colon', 2)\n")
2500 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('230', 'ETB', 'Ethiopian Birr', 2)\n")
2501 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('232', 'ERN', 'Nakfa', 2)\n")
2502 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('233', 'EEK', 'Estonian Kroon', 0)\n")
2503 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('238', 'FKP', 'Falkland Islands Pound', 2)\n")
2504 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('242', 'FJD', 'Fiji Dollar', 2)\n")
2505 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('262', 'DJF', 'Djibouti Franc', 0)\n")
2506 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('270', 'GMD', 'Dalasi', 2)\n")
2507 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('288', 'GHC', 'Cedi', 0)\n")
2508 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('292', 'GIP', 'Gibraltar Pound', 2)\n")
2509 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('320', 'GTQ', 'Quetzal', 2)\n")
2510 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('324', 'GNF', 'Guinea Franc', 0)\n")
2511 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('328', 'GYD', 'Guyana Dollar', 2)\n")
2512 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('332', 'HTG', 'Gourde', 2)\n")
2513 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('340', 'HNL', 'Lempira', 2)\n")
2514 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('344', 'HKD', 'Hong Kong Dollar', 2)\n")
2515 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('348', 'HUF', 'Forint', 2)\n")
2516 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('352', 'ISK', 'Iceland Krona', 0)\n")
2517 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('356', 'INR', 'Indian Rupee', 2)\n")
2518 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('360', 'IDR', 'Rupiah', 2)\n")
2519 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('364', 'IRR', 'Iranian Rial', 2)\n")
2520 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('368', 'IQD', 'Iraqi Dinar', 3)\n")
2521 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('376', 'ILS', 'New Israeli Sheqel', 2)\n")
2522 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('388', 'JMD', 'Jamaican Dollar', 2)\n")
2523 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('392', 'JPY', 'Yen', 0)\n")
2524 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('398', 'KZT', 'Tenge', 2)\n")
2525 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('400', 'JOD', 'Jordanian Dinar', 3)\n")
2526 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('404', 'KES', 'Kenyan Shilling', 2)\n")
2527 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('408', 'KPW', 'North Korean Won', 2)\n")
2528 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('410', 'KRW', 'Won', 0)\n")
2529 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('414', 'KWD', 'Kuwaiti Dinar', 3)\n")
2530 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('417', 'KGS', 'Som', 2)\n")
2531 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('418', 'LAK', 'Kip', 2)\n")
2532 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('422', 'LBP', 'Lebanese Pound', 2)\n")
2533 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('426', 'LSL', 'Lesotho Loti', 2)\n")
2534 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('428', 'LVL', 'Latvian Lats', 2)\n")
2535 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('430', 'LRD', 'Liberian Dollar', 2)\n")
2536 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('434', 'LYD', 'Lybian Dinar', 3)\n")
2537 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('440', 'LTL', 'Lithuanian Litas', 2)\n")
2538 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('446', 'MOP', 'Pataca', 2)\n")
2539 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('450', 'MGF', 'Malagasy Franc', 0)\n")
2540 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('454', 'MWK', 'Kwacha', 2)\n")
2541 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('458', 'MYR', 'Malaysian Ringgit', 2)\n")
2542 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('462', 'MVR', 'Rufiyaa', 2)\n")
2543 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('470', 'MTL', 'Maltese Lira', 0)\n")
2544 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('478', 'MRO', 'Ouguiya', 2)\n")
2545 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('480', 'MUR', 'Mauritius Rupee', 2)\n")
2546 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('484', 'MXN', 'Mexican Peso', 2)\n")
2547 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('496', 'MNT', 'Tugrik', 2)\n")
2548 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('498', 'MDL', 'Moldovan Leu', 2)\n")
2549 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('504', 'MAD', 'Moroccan Dirham', 2)\n")
2550 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('508', 'MZM', 'Metical', 0)\n")
2551 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('512', 'OMR', 'Rial Omani', 3)\n")
2552 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('516', 'NAD', 'Namibia Dollar', 2)\n")
2553 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('524', 'NPR', 'Nepalese Rupee', 2)\n")
2554 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('532', 'ANG', 'Netherlands Antillan Guilder', 2)\n")
2555 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('533', 'AWG', 'Aruban Guilder', 2)\n")
2556 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('548', 'VUV', 'Vatu', 0)\n")
2557 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('554', 'NZD', 'New Zealand Dollar', 2)\n")
2558 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('558', 'NIO', 'Cordoba Oro', 2)\n")
2559 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('566', 'NGN', 'Naira', 2)\n")
2560 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('578', 'NOK', 'Norvegian Krone', 2)\n")
2561 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('586', 'PKR', 'Pakistan Rupee', 2)\n")
2562 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('590', 'PAB', 'Balboa', 2)\n")
2563 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('598', 'PGK', 'Kina', 2)\n")
2564 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('600', 'PYG', 'Guarani', 0)\n")
2565 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('604', 'PEN', 'Nuevo Sol', 2)\n")
2566 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('608', 'PHP', 'Philippine Peso', 2)\n")
2567 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('624', 'GWP', 'Guinea-Bissau Peso', 0)\n")
2568 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('634', 'QAR', 'Qatari Rial', 2)\n")
2569 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('642', 'ROL', 'Leu', 0)\n")
2570 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('643', 'RUB', 'Russian Ruble', 2)\n")
2571 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('646', 'RWF', 'Rwanda Franc', 0)\n")
2572 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('654', 'SHP', 'Saint Helena Pound', 2)\n")
2573 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('678', 'STD', 'Dobra', 2)\n")
2574 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('682', 'SAR', 'Saudi Riyal', 2)\n")
2575 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('690', 'SCR', 'Seychelles Rupee', 2)\n")
2576 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('694', 'SLL', 'Leone', 2)\n")
2577 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('702', 'SGD', 'Singapore Dollar', 2)\n")
2578 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('703', 'SKK', 'Slovak Koruna', 0)\n")
2579 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('704', 'VND', 'Dong', 0)\n")
2580 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('706', 'SOS', 'Somali Shilling', 2)\n")
2581 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('710', 'ZAR', 'Rand', 2)\n")
2582 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('716', 'ZWD', 'Zimbabwe Dollar', 0)\n")
2583 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('728', 'SSP', 'South Sudanese pound', 2)\n")
2584 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('740', 'SRG', 'Suriname Guilder', 0)\n")
2585 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('748', 'SZL', 'Lilangeni', 2)\n")
2586 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('752', 'SEK', 'Swedish Krona', 2)\n")
2587 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('756', 'CHF', 'Swiss Franc', 2)\n")
2588 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('760', 'SYP', 'Syrian Pound', 2)\n")
2589 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('764', 'THB', 'Baht', 2)\n")
2590 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('776', 'TOP', 'Paanga', 2)\n")
2591 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('780', 'TTD', 'Trinidad and Tobago Dollar', 2)\n")
2592 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('784', 'AED', 'UAE Dirham', 2)\n")
2593 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('788', 'TND', 'Tunisian Dinar', 3)\n")
2594 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('795', 'TMM', 'Manat', 0)\n")
2595 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('800', 'UGX', 'Uganda Shilling', 2)\n")
2596 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('807', 'MKD', 'Denar', 2)\n")
2597 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('810', 'RUR', 'Russian Ruble', 0)\n")
2598 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('818', 'EGP', 'Egyptian Pound', 2)\n")
2599 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('826', 'GBP', 'Pound Sterling', 2)\n")
2600 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('834', 'TZS', 'Tanzanian Shilling', 2)\n")
2601 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('840', 'USD', 'US Dollar', 2)\n")
2602 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('858', 'UYU', 'Peso Uruguayo', 2)\n")
2603 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('860', 'UZS', 'Uzbekistan Sum', 2)\n")
2604 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('862', 'VEB', 'Bolivar', 0)\n")
2605 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('882', 'WST', 'Tala', 2)\n")
2606 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('886', 'YER', 'Yemeni Rial', 2)\n")
2607 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('891', 'CSD', 'Serbian Dinar', 0)\n")
2608 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('894', 'ZMK', 'Kwacha', 2)\n")
2609 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('901', 'TWD', 'New Taiwan Dollar', 2)\n")
2610 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('933', 'BYN', 'Belarussian New Ruble', 2)\n")
2611 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('934', 'TMT', 'Turkmenistani Manat', 2)\n")
2612 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('937', 'VEF', 'Venezuelan Bolivar', 2)\n")
2613 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('938', 'SDG', 'Sudanese Pound', 2)\n")
2614 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('941', 'RSD', 'Serbian Dinar', 2)\n")
2615 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('943', 'MZN', 'Mozambican Metical', 2)\n")
2616 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('944', 'AZN', 'Azerbaijani Manat', 2)\n")
2617 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('946', 'RON', 'New Romanian Leu', 2)\n")
2618 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('949', 'TRY', 'New Turkish Lira', 2)\n")
2619 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('950', 'XAF', 'CFA Franc BEAC', 0)\n")
2620 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('951', 'XCD', 'East Carribbean Dollar', 2)\n")
2621 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('952', 'XOF', 'CFA Franc BCEAO', 0)\n")
2622 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('953', 'XPF', 'CFP Franc', 0)\n")
2623 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('967', 'ZMW', 'Zambian Kwacha', 2)\n")
2624 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('968', 'SRD', 'Surinamese Dollar', 2)\n")
2625 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('969', 'MGA', 'Malagasy Ariary', 2)\n")
2626 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('971', 'AFN', 'Afghani', 2)\n")
2627 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('972', 'TJS', 'Somoni', 2)\n")
2628 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('973', 'AOA', 'Kwanza', 2)\n")
2629 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('974', 'BYR', 'Belarussian Ruble', 0)\n")
2630 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('975', 'BGN', 'Bulgarian Lev', 2)\n")
2631 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('976', 'CDF', 'Franc Congolais', 2)\n")
2632 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('977', 'BAM', 'Convertible Marks', 2)\n")
2633 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('978', 'EUR', 'Euro', 2)\n")
2634 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('979', 'MXV', 'Mexican Unidad de Inversion (UDI)', 2)\n")
2635 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('980', 'UAH', 'Hryvnia', 2)\n")
2636 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('981', 'GEL', 'Lari', 2)\n")
2637 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('984', 'BOV', 'Mvdol', 2)\n")
2638 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('985', 'PLN', 'Zloty', 2)\n")
2639 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('986', 'BRL', 'Brazilian Real', 2)\n")
2640 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('990', 'CLF', 'Unidades de Fomento', 0)\n")
2641 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('997', 'USN', 'US dollar (next day funds code)', 2)\n")
2642 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('998', 'USS', 'US dollar (same day funds code)', 2)\n")
2643 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('999', 'XXX', 'No currency', 0)\n")
2644 _T("<END>");
2645 static const TCHAR *batch2 =
2646 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AD','AND','020','Andorra')\n")
2647 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AE','ARE','784','United Arab Emirates')\n")
2648 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AF','AFG','004','Afghanistan')\n")
2649 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AG','ATG','028','Antigua and Barbuda')\n")
2650 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AI','AIA','660','Anguilla')\n")
2651 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AL','ALB','008','Albania')\n")
2652 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AM','ARM','051','Armenia')\n")
2653 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AN','ANT','530','Netherlands Antilles')\n")
2654 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AO','AGO','024','Angola')\n")
2655 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AQ','ATA','010','Antarctica')\n")
2656 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AR','ARG','032','Argentina')\n")
2657 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AS','ASM','016','American Samoa')\n")
2658 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AT','AUT','040','Austria')\n")
2659 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AU','AUS','036','Australia')\n")
2660 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AW','ABW','533','Aruba')\n")
2661 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AX','ALA','248','Aland Islands')\n")
2662 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AZ','AZE','031','Azerbaijan')\n")
2663 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BA','BIH','070','Bosnia and Herzegovina')\n")
2664 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BB','BRB','052','Barbados')\n")
2665 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BD','BGD','050','Bangladesh')\n")
2666 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BE','BEL','056','Belgium')\n")
2667 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BF','BFA','854','Burkina Faso')\n")
2668 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BG','BGR','100','Bulgaria')\n")
2669 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BH','BHR','048','Bahrain')\n")
2670 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BI','BDI','108','Burundi')\n")
2671 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BJ','BEN','204','Benin')\n")
2672 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BL','BLM','652','Saint-Barthelemy')\n")
2673 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BM','BMU','060','Bermuda')\n")
2674 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BN','BRN','096','Brunei Darussalam')\n")
2675 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BO','BOL','068','Bolivia')\n")
2676 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BQ','BES','535','Bonaire, Sint Eustatius and Saba')\n")
2677 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BR','BRA','076','Brazil')\n")
2678 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BS','BHS','044','Bahamas')\n")
2679 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BT','BTN','064','Bhutan')\n")
2680 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BV','BVT','074','Bouvet Island')\n")
2681 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BW','BWA','072','Botswana')\n")
2682 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BY','BLR','112','Belarus')\n")
2683 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BZ','BLZ','084','Belize')\n")
2684 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CA','CAN','124','Canada')\n")
2685 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CC','CCK','166','Cocos (Keeling) Islands')\n")
2686 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CD','COD','180','Congo, Democratic Republic of the')\n")
2687 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CF','CAF','140','Central African Republic')\n")
2688 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CG','COG','178','Congo (Brazzaville)')\n")
2689 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CH','CHE','756','Switzerland')\n")
2690 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CI','CIV','384','Cote d''Ivoire')\n")
2691 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CK','COK','184','Cook Islands')\n")
2692 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CL','CHL','152','Chile')\n")
2693 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CM','CMR','120','Cameroon')\n")
2694 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CN','CHN','156','China')\n")
2695 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CO','COL','170','Colombia')\n")
2696 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CR','CRI','188','Costa Rica')\n")
2697 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CU','CUB','192','Cuba')\n")
2698 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CV','CPV','132','Cape Verde')\n")
2699 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CW','CUW','531','Curacao')\n")
2700 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CX','CXR','162','Christmas Island')\n")
2701 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CY','CYP','196','Cyprus')\n")
2702 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CZ','CZE','203','Czech Republic')\n")
2703 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DE','DEU','276','Germany')\n")
2704 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DJ','DJI','262','Djibouti')\n")
2705 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DK','DNK','208','Denmark')\n")
2706 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DM','DMA','212','Dominica')\n")
2707 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DO','DOM','214','Dominican Republic')\n")
2708 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DZ','DZA','012','Algeria')\n")
2709 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('EC','ECU','218','Ecuador')\n")
2710 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('EE','EST','233','Estonia')\n")
2711 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('EG','EGY','818','Egypt')\n")
2712 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('EH','ESH','732','Western Sahara')\n")
2713 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ER','ERI','232','Eritrea')\n")
2714 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ES','ESP','724','Spain')\n")
2715 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ET','ETH','231','Ethiopia')\n")
2716 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FI','FIN','246','Finland')\n")
2717 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FJ','FJI','242','Fiji')\n")
2718 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FK','FLK','238','Falkland Islands (Malvinas)')\n")
2719 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FM','FSM','583','Micronesia, Federated States of')\n")
2720 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FO','FRO','234','Faroe Islands')\n")
2721 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FR','FRA','250','France')\n")
2722 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GA','GAB','266','Gabon')\n")
2723 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GB','GBR','826','United Kingdom')\n")
2724 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GD','GRD','308','Grenada')\n")
2725 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GE','GEO','268','Georgia')\n")
2726 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GF','GUF','254','French Guiana')\n")
2727 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GG','GGY','831','Guernsey')\n")
2728 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GH','GHA','288','Ghana')\n")
2729 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GI','GIB','292','Gibraltar')\n")
2730 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GL','GRL','304','Greenland')\n")
2731 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GM','GMB','270','Gambia')\n")
2732 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GN','GIN','324','Guinea')\n")
2733 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GP','GLP','312','Guadeloupe')\n")
2734 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GQ','GNQ','226','Equatorial Guinea')\n")
2735 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GR','GRC','300','Greece')\n")
2736 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GS','SGS','239','South Georgia and the South Sandwich Islands')\n")
2737 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GT','GTM','320','Guatemala')\n")
2738 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GU','GUM','316','Guam')\n")
2739 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GW','GNB','624','Guinea-Bissau')\n")
2740 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GY','GUY','328','Guyana')\n")
2741 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HK','HKG','344','Hong Kong, Special Administrative Region of China')\n")
2742 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HM','HMD','334','Heard Island and Mcdonald Islands')\n")
2743 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HN','HND','340','Honduras')\n")
2744 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HR','HRV','191','Croatia')\n")
2745 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HT','HTI','332','Haiti')\n")
2746 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HU','HUN','348','Hungary')\n")
2747 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ID','IDN','360','Indonesia')\n")
2748 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IE','IRL','372','Ireland')\n")
2749 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IL','ISR','376','Israel')\n")
2750 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IM','IMN','833','Isle of Man')\n")
2751 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IN','IND','356','India')\n")
2752 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IO','IOT','086','British Indian Ocean Territory')\n")
2753 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IQ','IRQ','368','Iraq')\n")
2754 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IR','IRN','364','Iran, Islamic Republic of')\n")
2755 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IS','ISL','352','Iceland')\n")
2756 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IT','ITA','380','Italy')\n")
2757 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('JE','JEY','832','Jersey')\n")
2758 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('JM','JAM','388','Jamaica')\n")
2759 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('JO','JOR','400','Jordan')\n")
2760 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('JP','JPN','392','Japan')\n")
2761 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KE','KEN','404','Kenya')\n")
2762 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KG','KGZ','417','Kyrgyzstan')\n")
2763 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KH','KHM','116','Cambodia')\n")
2764 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KI','KIR','296','Kiribati')\n")
2765 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KM','COM','174','Comoros')\n")
2766 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KN','KNA','659','Saint Kitts and Nevis')\n")
2767 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KP','PRK','408','Korea, Democratic People''s Republic of')\n")
2768 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KR','KOR','410','Korea, Republic of')\n")
2769 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KW','KWT','414','Kuwait')\n")
2770 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KY','CYM','136','Cayman Islands')\n")
2771 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KZ','KAZ','398','Kazakhstan')\n")
2772 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LA','LAO','418','Lao PDR')\n")
2773 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LB','LBN','422','Lebanon')\n")
2774 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LC','LCA','662','Saint Lucia')\n")
2775 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LI','LIE','438','Liechtenstein')\n")
2776 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LK','LKA','144','Sri Lanka')\n")
2777 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LR','LBR','430','Liberia')\n")
2778 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LS','LSO','426','Lesotho')\n")
2779 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LT','LTU','440','Lithuania')\n")
2780 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LU','LUX','442','Luxembourg')\n")
2781 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LV','LVA','428','Latvia')\n")
2782 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LY','LBY','434','Libya')\n")
2783 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MA','MAR','504','Morocco')\n")
2784 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MC','MCO','492','Monaco')\n")
2785 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MD','MDA','498','Moldova')\n")
2786 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ME','MNE','499','Montenegro')\n")
2787 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MF','MAF','663','Saint-Martin (French part)')\n")
2788 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MG','MDG','450','Madagascar')\n")
2789 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MH','MHL','584','Marshall Islands')\n")
2790 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MK','MKD','807','Macedonia, Republic of')\n")
2791 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ML','MLI','466','Mali')\n")
2792 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MM','MMR','104','Myanmar')\n")
2793 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MN','MNG','496','Mongolia')\n")
2794 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MO','MAC','446','Macao, Special Administrative Region of China')\n")
2795 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MP','MNP','580','Northern Mariana Islands')\n")
2796 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MQ','MTQ','474','Martinique')\n")
2797 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MR','MRT','478','Mauritania')\n")
2798 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MS','MSR','500','Montserrat')\n")
2799 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MT','MLT','470','Malta')\n")
2800 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MU','MUS','480','Mauritius')\n")
2801 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MV','MDV','462','Maldives')\n")
2802 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MW','MWI','454','Malawi')\n")
2803 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MX','MEX','484','Mexico')\n")
2804 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MY','MYS','458','Malaysia')\n")
2805 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MZ','MOZ','508','Mozambique')\n")
2806 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NA','NAM','516','Namibia')\n")
2807 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NC','NCL','540','New Caledonia')\n")
2808 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NE','NER','562','Niger')\n")
2809 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NF','NFK','574','Norfolk Island')\n")
2810 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NG','NGA','566','Nigeria')\n")
2811 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NI','NIC','558','Nicaragua')\n")
2812 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NL','NLD','528','Netherlands')\n")
2813 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NO','NOR','578','Norway')\n")
2814 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NP','NPL','524','Nepal')\n")
2815 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NR','NRU','520','Nauru')\n")
2816 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NU','NIU','570','Niue')\n")
2817 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NZ','NZL','554','New Zealand')\n")
2818 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('OM','OMN','512','Oman')\n")
2819 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PA','PAN','591','Panama')\n")
2820 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PE','PER','604','Peru')\n")
2821 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PF','PYF','258','French Polynesia')\n")
2822 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PG','PNG','598','Papua New Guinea')\n")
2823 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PH','PHL','608','Philippines')\n")
2824 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PK','PAK','586','Pakistan')\n")
2825 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PL','POL','616','Poland')\n")
2826 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PM','SPM','666','Saint Pierre and Miquelon')\n")
2827 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PN','PCN','612','Pitcairn')\n")
2828 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PR','PRI','630','Puerto Rico')\n")
2829 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PS','PSE','275','Palestinian Territory, Occupied')\n")
2830 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PT','PRT','620','Portugal')\n")
2831 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PW','PLW','585','Palau')\n")
2832 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PY','PRY','600','Paraguay')\n")
2833 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('QA','QAT','634','Qatar')\n")
2834 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RE','REU','638','Reunion')\n")
2835 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RO','ROU','642','Romania')\n")
2836 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RS','SRB','688','Serbia')\n")
2837 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RU','RUS','643','Russian Federation')\n")
2838 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RW','RWA','646','Rwanda')\n")
2839 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SA','SAU','682','Saudi Arabia')\n")
2840 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SB','SLB','090','Solomon Islands')\n")
2841 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SC','SYC','690','Seychelles')\n")
2842 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SD','SDN','729','Sudan')\n")
2843 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SE','SWE','752','Sweden')\n")
2844 _T