fixed incorrect sprintf format usage; fixed access to uninitialized memory in DB...
[public/netxms.git] / src / server / tools / nxdbmgr / upgrade_v0.cpp
CommitLineData
da4b354a
VK
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_v0.cpp
20**
21**/
22
23#include "nxdbmgr.h"
24#include <nxevent.h>
25
26/**
27 * Externals
28 */
29BOOL MigrateMaps();
30bool ConvertTDataTables();
31
32/**
33 * Re-create TDATA tables
34 */
35static BOOL RecreateTData(const TCHAR *className, bool multipleTables, bool indexFix)
36{
37 TCHAR query[1024];
38 _sntprintf(query, 256, _T("SELECT id FROM %s"), className);
39 DB_RESULT hResult = SQLSelect(query);
40 if (hResult != NULL)
41 {
42 int count = DBGetNumRows(hResult);
43 for(int i = 0; i < count; i++)
44 {
45 bool recreateTables = true;
46 DWORD id = DBGetFieldULong(hResult, i, 0);
47
48 if (indexFix)
49 {
50 _sntprintf(query, 256, _T("SELECT count(*) FROM dc_tables WHERE node_id=%d"), id);
51 DB_RESULT hResultCount = SQLSelect(query);
52 if (hResultCount != NULL)
53 {
54 recreateTables = (DBGetFieldLong(hResultCount, 0, 0) == 0);
55 DBFreeResult(hResultCount);
56 }
57
58 if (!recreateTables)
59 {
60 _sntprintf(query, 256, _T("CREATE INDEX idx_tdata_rec_%d_id ON tdata_records_%d(record_id)"), id, id);
61 if (!SQLQuery(query))
62 {
63 if (!g_bIgnoreErrors)
64 {
65 DBFreeResult(hResult);
66 return FALSE;
67 }
68 }
69 }
70 }
71
72 if (recreateTables)
73 {
74 if (multipleTables)
75 {
76 _sntprintf(query, 1024, _T("DROP TABLE tdata_rows_%d\nDROP TABLE tdata_records_%d\nDROP TABLE tdata_%d\n<END>"), id, id, id);
77 }
78 else
79 {
80 _sntprintf(query, 256, _T("DROP TABLE tdata_%d\n<END>"), id);
81 }
82 if (!SQLBatch(query))
83 {
84 if (!g_bIgnoreErrors)
85 {
86 DBFreeResult(hResult);
87 return FALSE;
88 }
89 }
90
91 if (!CreateTDataTable(id))
92 {
93 if (!g_bIgnoreErrors)
94 {
95 DBFreeResult(hResult);
96 return FALSE;
97 }
98 }
99 }
100 }
101 DBFreeResult(hResult);
102 }
103 else
104 {
105 if (!g_bIgnoreErrors)
106 return FALSE;
107 }
108 return TRUE;
109}
110
111/**
112 * Convert network masks from dotted decimal format to number of bits
113 */
114static BOOL ConvertNetMasks(const TCHAR *table, const TCHAR *column, const TCHAR *idColumn, const TCHAR *idColumn2 = NULL, const TCHAR *condition = NULL)
115{
116 TCHAR query[256];
117
118 if (idColumn2 != NULL)
119 _sntprintf(query, 256, _T("SELECT %s,%s,%s FROM %s"), idColumn, column, idColumn2, table);
120 else
121 _sntprintf(query, 256, _T("SELECT %s,%s FROM %s"), idColumn, column, table);
122 DB_RESULT hResult = SQLSelect(query);
123 if (hResult == NULL)
124 return FALSE;
125
126 bool success = DBDropColumn(g_hCoreDB, table, column);
127
128 if (success)
129 {
130 _sntprintf(query, 256, _T("ALTER TABLE %s ADD %s integer"), table, column);
131 success = SQLQuery(query);
132 }
133
134 if (success)
135 {
136 int count = DBGetNumRows(hResult);
137 for(int i = 0; (i < count) && success; i++)
138 {
139 if (idColumn2 != NULL)
140 {
141 TCHAR id2[256];
142 _sntprintf(query, 256, _T("UPDATE %s SET %s=%d WHERE %s=%d AND %s='%s'"),
143 table, column, BitsInMask(DBGetFieldIPAddr(hResult, i, 1)), idColumn, DBGetFieldLong(hResult, i, 0),
144 idColumn2, DBGetField(hResult, i, 2, id2, 256));
145 }
146 else
147 {
148 _sntprintf(query, 256, _T("UPDATE %s SET %s=%d WHERE %s=%d"),
149 table, column, BitsInMask(DBGetFieldIPAddr(hResult, i, 1)), idColumn, DBGetFieldLong(hResult, i, 0));
150 }
151 success = SQLQuery(query);
152 }
153 }
154
155 DBFreeResult(hResult);
156 return success;
157}
158
159/**
160 * Convert object tool macros to new format
161 */
162static bool ConvertObjectToolMacros(UINT32 id, const TCHAR *text, const TCHAR *column)
163{
164 if (_tcschr(text, _T('%')) == NULL)
165 return true; // nothing to convert
166
167 String s;
168 for(const TCHAR *p = text; *p != 0; p++)
169 {
170 if (*p == _T('%'))
171 {
172 TCHAR name[256];
173 int i = 0;
174 for(p++; (*p != _T('%')) && (*p != 0); p++)
175 {
176 if (i < 255)
177 name[i++] = *p;
178 }
179 if (*p == 0)
180 break; // malformed string
181 name[i] = 0;
182 if (!_tcscmp(name, _T("ALARM_ID")))
183 {
184 s.append(_T("%Y"));
185 }
186 else if (!_tcscmp(name, _T("ALARM_MESSAGE")))
187 {
188 s.append(_T("%A"));
189 }
190 else if (!_tcscmp(name, _T("ALARM_SEVERITY")))
191 {
192 s.append(_T("%s"));
193 }
194 else if (!_tcscmp(name, _T("ALARM_SEVERITY_TEXT")))
195 {
196 s.append(_T("%S"));
197 }
198 else if (!_tcscmp(name, _T("ALARM_STATE")))
199 {
200 s.append(_T("%y"));
201 }
202 else if (!_tcscmp(name, _T("OBJECT_ID")))
203 {
204 s.append(_T("%I"));
205 }
206 else if (!_tcscmp(name, _T("OBJECT_IP_ADDR")))
207 {
208 s.append(_T("%a"));
209 }
210 else if (!_tcscmp(name, _T("OBJECT_NAME")))
211 {
212 s.append(_T("%n"));
213 }
214 else if (!_tcscmp(name, _T("USERNAME")))
215 {
216 s.append(_T("%U"));
217 }
218 else
219 {
220 s.append(_T("%{"));
221 s.append(name);
222 s.append(_T('}'));
223 }
224 }
225 else
226 {
227 s.append(*p);
228 }
229 }
230
231 String query = _T("UPDATE object_tools SET ");
232 query.append(column);
233 query.append(_T('='));
234 query.append(DBPrepareString(g_hCoreDB, s));
235 query.append(_T(" WHERE tool_id="));
236 query.append(id);
237 return SQLQuery(query);
238}
239
240/**
241 * Create library script
242 */
243static bool CreateLibraryScript(UINT32 id, const TCHAR *name, const TCHAR *code)
244{
245 // Check if script exists
246 TCHAR query[256];
247 _sntprintf(query, 256, _T("SELECT script_id FROM script_library WHERE script_id=%d OR script_name=%s"),
248 id, (const TCHAR *)DBPrepareString(g_hCoreDB, name));
249 DB_RESULT hResult = SQLSelect(query);
250 if (hResult == NULL)
251 return false;
252 bool exist = (DBGetNumRows(hResult) > 0);
253 DBFreeResult(hResult);
254 if (exist)
255 return true;
256
257 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("INSERT INTO script_library (script_id,script_name,script_code) VALUES (?,?,?)"));
258 if (hStmt == NULL)
259 return false;
260
261 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, id);
262 DBBind(hStmt, 2, DB_SQLTYPE_VARCHAR, name, DB_BIND_STATIC);
263 DBBind(hStmt, 3, DB_SQLTYPE_TEXT, code, DB_BIND_STATIC);
264
265 bool success = SQLExecute(hStmt);
266 DBFreeStatement(hStmt);
267 return success;
268}
269
270/**
271 * Set schema version
272 */
273static bool SetSchemaVersion(int version)
274{
275 TCHAR query[256];
276 _sntprintf(query, 256, _T("UPDATE metadata SET var_value='%d' WHERE var_name='SchemaVersion'"), version);
277 return SQLQuery(query);
278}
279
280/**
281 * Finish legacy versions upgrade directly to 30.x
282 */
283static bool FinishLegacyUpgradeToV30(INT32 level21, INT32 level30)
284{
285 _tprintf(_T("Upgrading from version 0.700 to 30.%d\n"), level30);
286
287 const TCHAR *batch =
288 _T("INSERT INTO metadata (var_name,var_value) VALUES ('SchemaVersionMajor','30')\n")
289 _T("INSERT INTO metadata (var_name,var_value) VALUES ('SchemaVersionLevel.0','700')\n")
290 _T("UPDATE metadata SET var_value='700' WHERE var_name='SchemaVersion'\n")
291 _T("<END>");
292 CHK_EXEC(SQLBatch(batch));
293
294 TCHAR query[256];
295 _sntprintf(query, 256, _T("INSERT INTO metadata (var_name,var_value) VALUES ('SchemaVersionLevel.21','%d')"), level21);
296 CHK_EXEC(SQLQuery(query));
297
298 _sntprintf(query, 256, _T("INSERT INTO metadata (var_name,var_value) VALUES ('SchemaVersionMinor','%d')"), level30);
299 CHK_EXEC(SQLQuery(query));
300
301 return true;
302}
303
304/**
305 * Finish legacy versions upgrade to 21.x
306 */
307static bool FinishLegacyUpgradeToV21(INT32 minor)
308{
309 _tprintf(_T("Upgrading from version 0.700 to 21.%d\n"), minor);
310
311 const TCHAR *batch =
312 _T("INSERT INTO metadata (var_name,var_value) VALUES ('SchemaVersionMajor','21')\n")
313 _T("INSERT INTO metadata (var_name,var_value) VALUES ('SchemaVersionLevel.0','700')\n")
314 _T("UPDATE metadata SET var_value='700' WHERE var_name='SchemaVersion'\n")
315 _T("<END>");
316 CHK_EXEC(SQLBatch(batch));
317
318 TCHAR query[256];
319 _sntprintf(query, 256, _T("INSERT INTO metadata (var_name,var_value) VALUES ('SchemaVersionMinor','%d')"), minor);
320 CHK_EXEC(SQLQuery(query));
321
322 return true;
323}
324
325/**
326 * Upgrade from V506 to V700
327 */
328static BOOL H_UpgradeFromV506(int currVersion, int newVersion)
329{
330 CHK_EXEC(FinishLegacyUpgradeToV30(4, 7));
331 return TRUE;
332}
333
334/**
335 * Upgrade from V505 to V700
336 */
337static BOOL H_UpgradeFromV505(int currVersion, int newVersion)
338{
339 CHK_EXEC(FinishLegacyUpgradeToV30(3, 6));
340 return TRUE;
341}
342
343/**
344 * Upgrade from V504 to V700
345 */
346static BOOL H_UpgradeFromV504(int currVersion, int newVersion)
347{
348 CHK_EXEC(FinishLegacyUpgradeToV30(2, 5));
349 return TRUE;
350}
351
352/**
353 * Upgrade from V503 to V700
354 */
355static BOOL H_UpgradeFromV503(int currVersion, int newVersion)
356{
357 CHK_EXEC(FinishLegacyUpgradeToV30(1, 4));
358 return TRUE;
359}
360
361/**
362 * Upgrade from V502 to V700
363 */
364static BOOL H_UpgradeFromV502(int currVersion, int newVersion)
365{
366 CHK_EXEC(FinishLegacyUpgradeToV30(1, 3));
367 return TRUE;
368}
369
370/**
371 * Upgrade from V501 to V700
372 */
373static BOOL H_UpgradeFromV501(int currVersion, int newVersion)
374{
375 CHK_EXEC(FinishLegacyUpgradeToV30(1, 2));
376 return TRUE;
377}
378
379/**
380 * Upgrade from V500 to V700
381 */
382static BOOL H_UpgradeFromV500(int currVersion, int newVersion)
383{
384 CHK_EXEC(FinishLegacyUpgradeToV30(1, 1));
385 return TRUE;
386}
387
388/**
389 * Upgrade from V462 to V700
390 */
391static BOOL H_UpgradeFromV462(int currVersion, int newVersion)
392{
393 CHK_EXEC(FinishLegacyUpgradeToV21(4));
394 return TRUE;
395}
396
397/**
398 * Upgrade from V461 to V700
399 */
400static BOOL H_UpgradeFromV461(int currVersion, int newVersion)
401{
402 CHK_EXEC(FinishLegacyUpgradeToV21(3));
403 return TRUE;
404}
405
406/**
407 * Upgrade from V460 to V700
408 */
409static BOOL H_UpgradeFromV460(int currVersion, int newVersion)
410{
411 CHK_EXEC(FinishLegacyUpgradeToV21(2));
412 return TRUE;
413}
414
415/**
416 * Upgrade from V459 to V700
417 */
418static BOOL H_UpgradeFromV459(int currVersion, int newVersion)
419{
420 CHK_EXEC(FinishLegacyUpgradeToV21(1));
421 return TRUE;
422}
423
424/**
425 * Upgrade from V458 to V459
426 */
427static BOOL H_UpgradeFromV458(int currVersion, int newVersion)
428{
429 CHK_EXEC(SQLQuery(_T("ALTER TABLE dci_summary_tables ADD table_dci_name varchar(255)")));
430 CHK_EXEC(SetSchemaVersion(459));
431 return TRUE;
432}
433
434/**
435 * Upgrade from V457 to V458
436 */
437static BOOL H_UpgradeFromV457(int currVersion, int newVersion)
438{
439 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',need_server_restart=0 WHERE var_name='DeleteUnreachableNodesPeriod'")));
440 CHK_EXEC(CreateConfigParam(_T("LongRunningQueryThreshold"), _T("0"), _T("Threshold in milliseconds to report long running SQL queries (0 to disable)"), 'I', true, true, false, false));
441 CHK_EXEC(SetSchemaVersion(458));
442 return TRUE;
443}
444
445/**
446 * Upgrade from V456 to V457
447 */
448static BOOL H_UpgradeFromV456(int currVersion, int newVersion)
449{
450 CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='EnableAdminInterface'")));
451 CHK_EXEC(SetSchemaVersion(457));
452 return TRUE;
453}
454
455/**
456 * Upgrade from V455 to V456
457 */
458static BOOL H_UpgradeFromV455(int currVersion, int newVersion)
459{
460 CHK_EXEC(
461 CreateEventTemplate(EVENT_PACKAGE_INSTALLED, _T("SYS_PACKAGE_INSTALLED"),
462 SEVERITY_NORMAL, EF_LOG, _T("92e5cf98-a415-4414-9ad8-d155dac77e96"),
463 _T("Package %1 %2 installed"),
464 _T("Generated when new software package is found.\r\n")
465 _T("Parameters:\r\n")
466 _T(" 1) Package name\r\n")
467 _T(" 2) Package version"))
468 );
469
470 CHK_EXEC(
471 CreateEventTemplate(EVENT_PACKAGE_UPDATED, _T("SYS_PACKAGE_UPDATED"),
472 SEVERITY_NORMAL, EF_LOG, _T("9d5878c1-525e-4cab-8f02-2a6c46d7fc36"),
473 _T("Package %1 updated from %3 to %2"),
474 _T("Generated when software package version change is detected.\r\n")
475 _T("Parameters:\r\n")
476 _T(" 1) Package name\r\n")
477 _T(" 2) New package version\r\n")
478 _T(" 3) Old package version"))
479 );
480
481 CHK_EXEC(
482 CreateEventTemplate(EVENT_PACKAGE_REMOVED, _T("SYS_PACKAGE_REMOVED"),
483 SEVERITY_NORMAL, EF_LOG, _T("6ada4ea4-43e4-4444-9d19-ef7366110bb9"),
484 _T("Package %1 %2 removed"),
485 _T("Generated when software package removal is detected.\r\n")
486 _T("Parameters:\r\n")
487 _T(" 1) Package name\r\n")
488 _T(" 2) Last known package version"))
489 );
490
491 int ruleId = NextFreeEPPruleID();
492 TCHAR query[1024];
493 _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) ")
494 _T("VALUES (%d,'2bb3df47-482b-4e4b-9b49-8c72c6b33011',7944,'Generate alarm on software package changes','%%m',5,'SW_PKG_%%i_%%<name>','',0,%d)"),
495 ruleId, EVENT_ALARM_TIMEOUT);
496 CHK_EXEC(SQLQuery(query));
497
498 _sntprintf(query, 256, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_PACKAGE_INSTALLED);
499 CHK_EXEC(SQLQuery(query));
500 _sntprintf(query, 256, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_PACKAGE_UPDATED);
501 CHK_EXEC(SQLQuery(query));
502 _sntprintf(query, 256, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_PACKAGE_REMOVED);
503 CHK_EXEC(SQLQuery(query));
504
505 CHK_EXEC(SetSchemaVersion(456));
506 return TRUE;
507}
508
509/**
510 * Upgrade from V454 to V455
511 */
512static BOOL H_UpgradeFromV454(int currVersion, int newVersion)
513{
514 static const TCHAR *batch =
515 _T("ALTER TABLE interfaces ADD parent_iface integer\n")
516 _T("UPDATE interfaces SET parent_iface=0\n")
517 _T("<END>");
518 CHK_EXEC(SQLBatch(batch));
519 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("interfaces"), _T("parent_iface")));
520
521 CHK_EXEC(SetSchemaVersion(455));
522 return TRUE;
523}
524
525/**
526 * Upgrade from V453 to V454
527 */
528static BOOL H_UpgradeFromV453(int currVersion, int newVersion)
529{
530 static const TCHAR *batch =
531 _T("ALTER TABLE config ADD default_value varchar(2000) null\n")
532 _T("UPDATE config SET default_value='7200' WHERE var_name='ActiveDiscoveryInterval'\n")
533 _T("UPDATE config SET default_value='0' WHERE var_name='ActiveNetworkDiscovery'\n")
534 _T("UPDATE config SET default_value='4000' WHERE var_name='AgentCommandTimeout'\n")
535 _T("UPDATE config SET default_value='netxms' WHERE var_name='AgentDefaultSharedSecret'\n")
536 _T("UPDATE config SET default_value='600' WHERE var_name='AgentUpgradeWaitTime'\n")
537 _T("UPDATE config SET default_value='180' WHERE var_name='AlarmHistoryRetentionTime'\n")
538 _T("UPDATE config SET default_value='4096' WHERE var_name='AlarmListDisplayLimit'\n")
539 _T("UPDATE config SET default_value='0 0 * * *' WHERE var_name='AlarmSummaryEmailSchedule'\n")
540 _T("UPDATE config SET default_value='0' WHERE var_name='AllowDirectSMS'\n")
541 _T("UPDATE config SET default_value='63' WHERE var_name='AllowedCiphers'\n")
542 _T("UPDATE config SET default_value='1' WHERE var_name='AllowTrapVarbindsConversion'\n")
543 _T("UPDATE config SET default_value='0' WHERE var_name='AnonymousFileAccess'\n")
544 _T("UPDATE config SET default_value='1' WHERE var_name='ApplyDCIFromTemplateToDisabledDCI'\n")
545 _T("UPDATE config SET default_value='90' WHERE var_name='AuditLogRetentionTime'\n")
546 _T("UPDATE config SET default_value='1000' WHERE var_name='BeaconPollingInterval'\n")
547 _T("UPDATE config SET default_value='1000' WHERE var_name='BeaconTimeout'\n")
548 _T("UPDATE config SET default_value='0' WHERE var_name='BlockInactiveUserAccounts'\n")
549 _T("UPDATE config SET default_value='604800' WHERE var_name='CapabilityExpirationTime'\n")
550 _T("UPDATE config SET default_value='0' WHERE var_name='CaseInsensitiveLoginNames'\n")
551 _T("UPDATE config SET default_value='0' WHERE var_name='CheckTrustedNodes'\n")
552 _T("UPDATE config SET default_value='4701' WHERE var_name='ClientListenerPort'\n")
553 _T("UPDATE config SET default_value='0' WHERE var_name='ClusterContainerAutoBind'\n")
554 _T("UPDATE config SET default_value='0' WHERE var_name='ClusterTemplateAutoApply'\n")
555 _T("UPDATE config SET default_value='60' WHERE var_name='ConditionPollingInterval'\n")
556 _T("UPDATE config SET default_value='3600' WHERE var_name='ConfigurationPollingInterval'\n")
557 _T("UPDATE config SET default_value='1' WHERE var_name='DashboardDataExportEnableInterpolation'\n")
558 _T("UPDATE config SET default_value='10' WHERE var_name='DBConnectionPoolBaseSize'\n")
559 _T("UPDATE config SET default_value='300' WHERE var_name='DBConnectionPoolCooldownTime'\n")
560 _T("UPDATE config SET default_value='14400' WHERE var_name='DBConnectionPoolMaxLifetime'\n")
561 _T("UPDATE config SET default_value='30' WHERE var_name='DBConnectionPoolMaxSize'\n")
562 _T("UPDATE config SET default_value='0' WHERE var_name='DBLockPID'\n")
563 _T("UPDATE config SET default_value='UNLOCKED' WHERE var_name='DBLockStatus'\n")
564 _T("UPDATE config SET default_value='2' WHERE var_name='DefaultAgentCacheMode'\n")
565 _T("UPDATE config SET default_value='1' WHERE var_name='DefaultAgentProtocolCompressionMode'\n")
566 _T("UPDATE config SET default_value='dd.MM.yyyy' WHERE var_name='DefaultConsoleDateFormat'\n")
567 _T("UPDATE config SET default_value='HH:mm' WHERE var_name='DefaultConsoleShortTimeFormat'\n")
568 _T("UPDATE config SET default_value='HH:mm:ss' WHERE var_name='DefaultConsoleTimeFormat'\n")
569 _T("UPDATE config SET default_value='60' WHERE var_name='DefaultDCIPollingInterval'\n")
570 _T("UPDATE config SET default_value='30' WHERE var_name='DefaultDCIRetentionTime'\n")
571 _T("UPDATE config SET default_value='1' WHERE var_name='DefaultEncryptionPolicy'\n")
572 _T("UPDATE config SET default_value='1' WHERE var_name='DefaultInterfaceExpectedState'\n")
573 _T("UPDATE config SET default_value='0xffffff' WHERE var_name='DefaultMapBackgroundColor'\n")
574 _T("UPDATE config SET default_value='24' WHERE var_name='DefaultSubnetMaskIPv4'\n")
575 _T("UPDATE config SET default_value='64' WHERE var_name='DefaultSubnetMaskIPv6'\n")
576 _T("UPDATE config SET default_value='1' WHERE var_name='DeleteAlarmsOfDeletedObject'\n")
577 _T("UPDATE config SET default_value='0' WHERE var_name='DeleteEmptySubnets'\n")
578 _T("UPDATE config SET default_value='1' WHERE var_name='DeleteEventsOfDeletedObject'\n")
579 _T("UPDATE config SET default_value='0' WHERE var_name='DeleteUnreachableNodesPeriod'\n")
580 _T("UPDATE config SET default_value='none' WHERE var_name='DiscoveryFilter'\n")
581 _T("UPDATE config SET default_value='0' WHERE var_name='DiscoveryFilterFlags'\n")
582 _T("UPDATE config SET default_value='900' WHERE var_name='DiscoveryPollingInterval'\n")
583 _T("UPDATE config SET default_value='1' WHERE var_name='EnableAdminInterface'\n")
584 _T("UPDATE config SET default_value='1' WHERE var_name='EnableAgentRegistration'\n")
585 _T("UPDATE config SET default_value='1' WHERE var_name='EnableAuditLog'\n")
586 _T("UPDATE config SET default_value='0' WHERE var_name='EnableCheckPointSNMP'\n")
587 _T("UPDATE config SET default_value='0' WHERE var_name='EnableReportingServer'\n")
588 _T("UPDATE config SET default_value='0' WHERE var_name='EnableEventStormDetection'\n")
589 _T("UPDATE config SET default_value='0' WHERE var_name='EnableISCListener'\n")
590 _T("UPDATE config SET default_value='1' WHERE var_name='EnableNXSLContainerFunctions'\n")
591 _T("UPDATE config SET default_value='0' WHERE var_name='EnableObjectTransactions'\n")
592 _T("UPDATE config SET default_value='1' WHERE var_name='EnableSNMPTraps'\n")
593 _T("UPDATE config SET default_value='0' WHERE var_name='EnableAlarmSummaryEmails'\n")
594 _T("UPDATE config SET default_value='0' WHERE var_name='EnableSyslogReceiver'\n")
595 _T("UPDATE config SET default_value='1' WHERE var_name='EnableTimedAlarmAck'\n")
596 _T("UPDATE config SET default_value='0' WHERE var_name='EnableXMPPConnector'\n")
597 _T("UPDATE config SET default_value='0' WHERE var_name='EnableZoning'\n")
598 _T("UPDATE config SET default_value='0' WHERE var_name='EscapeLocalCommands'\n")
599 _T("UPDATE config SET default_value='90' WHERE var_name='EventLogRetentionTime'\n")
600 _T("UPDATE config SET default_value='15' WHERE var_name='EventStormDuration'\n")
601 _T("UPDATE config SET default_value='100' WHERE var_name='EventStormEventsPerSecond'\n")
602 _T("UPDATE config SET default_value='0' WHERE var_name='ExtendedLogQueryAccessControl'\n")
603 _T("UPDATE config SET default_value='13' WHERE var_name='ExternalAuditFacility'\n")
604 _T("UPDATE config SET default_value='514' WHERE var_name='ExternalAuditPort'\n")
605 _T("UPDATE config SET default_value='none' WHERE var_name='ExternalAuditServer'\n")
606 _T("UPDATE config SET default_value='5' WHERE var_name='ExternalAuditSeverity'\n")
607 _T("UPDATE config SET default_value='netxmsd-audit' WHERE var_name='ExternalAuditTag'\n")
608 _T("UPDATE config SET default_value='100' WHERE var_name='FirstFreeObjectId'\n")
609 _T("UPDATE config SET default_value='0' WHERE var_name='FixedStatusValue'\n")
610 _T("UPDATE config SET default_value='5' WHERE var_name='GraceLoginCount'\n")
611 _T("UPDATE config SET default_value='none' WHERE var_name='HelpDeskLink'\n")
612 _T("UPDATE config SET default_value='02:00' WHERE var_name='HousekeeperStartTime'\n")
613 _T("UPDATE config SET default_value='46' WHERE var_name='IcmpPingSize'\n")
614 _T("UPDATE config SET default_value='1500' WHERE var_name='IcmpPingTimeout'\n")
615 _T("UPDATE config SET default_value='1' WHERE var_name='ImportConfigurationOnStartup'\n")
616 _T("UPDATE config SET default_value='600' WHERE var_name='InstancePollingInterval'\n")
617 _T("UPDATE config SET default_value='0' WHERE var_name='InternalCA'\n")
618 _T("UPDATE config SET default_value='0' WHERE var_name='IntruderLockoutThreshold'\n")
619 _T("UPDATE config SET default_value='30' WHERE var_name='IntruderLockoutTime'\n")
620 _T("UPDATE config SET default_value='Task' WHERE var_name='JiraIssueType'\n")
621 _T("UPDATE config SET default_value='netxms' WHERE var_name='JiraLogin'\n")
622 _T("UPDATE config SET default_value='NETXMS' WHERE var_name='JiraProjectCode'\n")
623 _T("UPDATE config SET default_value='http://localhost' WHERE var_name='JiraServerURL'\n")
624 _T("UPDATE config SET default_value='90' WHERE var_name='JobHistoryRetentionTime'\n")
625 _T("UPDATE config SET default_value='5' WHERE var_name='JobRetryCount'\n")
626 _T("UPDATE config SET default_value='60' WHERE var_name='KeepAliveInterval'\n")
627 _T("UPDATE config SET default_value='ldap://localhost:389' WHERE var_name='LdapConnectionString'\n")
628 _T("UPDATE config SET default_value='displayName' WHERE var_name='LdapMappingFullName'\n")
629 _T("UPDATE config SET default_value='1000' WHERE var_name='LdapPageSize'\n")
630 _T("UPDATE config SET default_value='0' WHERE var_name='LdapSyncInterval'\n")
631 _T("UPDATE config SET default_value='1' WHERE var_name='LdapUserDeleteAction'\n")
632 _T("UPDATE config SET default_value='60000' WHERE var_name='LockTimeout'\n")
633 _T("UPDATE config SET default_value='0' WHERE var_name='LogAllSNMPTraps'\n")
634 _T("UPDATE config SET default_value='utf8' WHERE var_name='MailEncoding'\n")
635 _T("UPDATE config SET default_value='0' WHERE var_name='MinPasswordLength'\n")
636 _T("UPDATE config SET default_value='1000' WHERE var_name='MinViewRefreshInterval'\n")
637 _T("UPDATE config SET default_value='4747' WHERE var_name='MobileDeviceListenerPort'\n")
638 _T("UPDATE config SET default_value='25' WHERE var_name='NumberOfDataCollectors'\n")
639 _T("UPDATE config SET default_value='10' WHERE var_name='NumberOfUpgradeThreads'\n")
640 _T("UPDATE config SET default_value='86400' WHERE var_name='OfflineDataRelevanceTime'\n")
641 _T("UPDATE config SET default_value='0' WHERE var_name='PasswordComplexity'\n")
642 _T("UPDATE config SET default_value='0' WHERE var_name='PasswordExpiration'\n")
643 _T("UPDATE config SET default_value='0' WHERE var_name='PasswordHistoryLength'\n")
644 _T("UPDATE config SET default_value='1' WHERE var_name='PollCountForStatusChange'\n")
645 _T("UPDATE config SET default_value='10' WHERE var_name='PollerThreadPoolBaseSize'\n")
646 _T("UPDATE config SET default_value='250' WHERE var_name='PollerThreadPoolMaxSize'\n")
647 _T("UPDATE config SET default_value='PAP' WHERE var_name='RADIUSAuthMethod'\n")
648 _T("UPDATE config SET default_value='5' WHERE var_name='RADIUSNumRetries'\n")
649 _T("UPDATE config SET default_value='1645' WHERE var_name='RADIUSPort'\n")
650 _T("UPDATE config SET default_value='1645' WHERE var_name='RADIUSSecondaryPort'\n")
651 _T("UPDATE config SET default_value='netxms' WHERE var_name='RADIUSSecondarySecret'\n")
652 _T("UPDATE config SET default_value='none' WHERE var_name='RADIUSSecondaryServer'\n")
653 _T("UPDATE config SET default_value='netxms' WHERE var_name='RADIUSSecret'\n")
654 _T("UPDATE config SET default_value='none' WHERE var_name='RADIUSServer'\n")
655 _T("UPDATE config SET default_value='3' WHERE var_name='RADIUSTimeout'\n")
656 _T("UPDATE config SET default_value='0' WHERE var_name='ReceiveForwardedEvents'\n")
657 _T("UPDATE config SET default_value='localhost' WHERE var_name='ReportingServerHostname'\n")
658 _T("UPDATE config SET default_value='4710' WHERE var_name='ReportingServerPort'\n")
659 _T("UPDATE config SET default_value='0' WHERE var_name='ResolveDNSToIPOnStatusPoll'\n")
660 _T("UPDATE config SET default_value='1' WHERE var_name='ResolveNodeNames'\n")
661 _T("UPDATE config SET default_value='300' WHERE var_name='RoutingTableUpdateInterval'\n")
662 _T("UPDATE config SET default_value='0' WHERE var_name='RunNetworkDiscovery'\n")
663 _T("UPDATE config SET default_value='60' WHERE var_name='ServerCommandOutputTimeout'\n")
664 _T("UPDATE config SET default_value='<none>' WHERE var_name='SMSDriver'\n")
665 _T("UPDATE config SET default_value='161' WHERE var_name='SNMPPorts'\n")
666 _T("UPDATE config SET default_value='1500' WHERE var_name='SNMPRequestTimeout'\n")
667 _T("UPDATE config SET default_value='90' WHERE var_name='SNMPTrapLogRetentionTime'\n")
668 _T("UPDATE config SET default_value='162' WHERE var_name='SNMPTrapPort'\n")
669 _T("UPDATE config SET default_value='netxms@localhost' WHERE var_name='SMTPFromAddr'\n")
670 _T("UPDATE config SET default_value='NetXMS Server' WHERE var_name='SMTPFromName'\n")
671 _T("UPDATE config SET default_value='25' WHERE var_name='SMTPPort'\n")
672 _T("UPDATE config SET default_value='1' WHERE var_name='SMTPRetryCount'\n")
673 _T("UPDATE config SET default_value='localhost' WHERE var_name='SMTPServer'\n")
674 _T("UPDATE config SET default_value='1' WHERE var_name='StatusCalculationAlgorithm'\n")
675 _T("UPDATE config SET default_value='60' WHERE var_name='StatusPollingInterval'\n")
676 _T("UPDATE config SET default_value='1' WHERE var_name='StatusPropagationAlgorithm'\n")
677 _T("UPDATE config SET default_value='0' WHERE var_name='StatusShift'\n")
678 _T("UPDATE config SET default_value='75' WHERE var_name='StatusSingleThreshold'\n")
679 _T("UPDATE config SET default_value='503C2814' WHERE var_name='StatusThresholds'\n")
680 _T("UPDATE config SET default_value='01020304' WHERE var_name='StatusTranslation'\n")
681 _T("UPDATE config SET default_value='0' WHERE var_name='StrictAlarmStatusFlow'\n")
682 _T("UPDATE config SET default_value='60' WHERE var_name='SyncInterval'\n")
683 _T("UPDATE config SET default_value='0' WHERE var_name='SyncNodeNamesWithDNS'\n")
684 _T("UPDATE config SET default_value='0' WHERE var_name='SyslogIgnoreMessageTimestamp'\n")
685 _T("UPDATE config SET default_value='514' WHERE var_name='SyslogListenPort'\n")
686 _T("UPDATE config SET default_value='0' WHERE var_name='SyslogNodeMatchingPolicy'\n")
687 _T("UPDATE config SET default_value='90' WHERE var_name='SyslogRetentionTime'\n")
688 _T("UPDATE config SET default_value='0' WHERE var_name='ThresholdRepeatInterval'\n")
689 _T("UPDATE config SET default_value='http://tile.openstreetmap.org/' WHERE var_name='TileServerURL'\n")
690 _T("UPDATE config SET default_value='3' WHERE var_name='TopologyDiscoveryRadius'\n")
691 _T("UPDATE config SET default_value='900' WHERE var_name='TopologyExpirationTime'\n")
692 _T("UPDATE config SET default_value='1800' WHERE var_name='TopologyPollingInterval'\n")
693 _T("UPDATE config SET default_value='0' WHERE var_name='TrapSourcesInAllZones'\n")
694 _T("UPDATE config SET default_value='0' WHERE var_name='UseDNSNameForDiscoveredNodes'\n")
695 _T("UPDATE config SET default_value='1' WHERE var_name='UseFQDNForNodeNames'\n")
696 _T("UPDATE config SET default_value='1' WHERE var_name='UseIfXTable'\n")
697 _T("UPDATE config SET default_value='0' WHERE var_name='UseInterfaceAliases'\n")
698 _T("UPDATE config SET default_value='0' WHERE var_name='UseSNMPTrapsForDiscovery'\n")
699 _T("UPDATE config SET default_value='0' WHERE var_name='UseSyslogForDiscovery'\n")
700 _T("UPDATE config SET default_value='netxms@localhost' WHERE var_name='XMPPLogin'\n")
701 _T("UPDATE config SET default_value='netxms' WHERE var_name='XMPPPassword'\n")
702 _T("UPDATE config SET default_value='5222' WHERE var_name='XMPPPort'\n")
703 _T("UPDATE config SET default_value='localhost' WHERE var_name='XMPPServer'\n")
704 _T("<END>");
705 CHK_EXEC(SQLBatch(batch));
706
707 CHK_EXEC(SetSchemaVersion(454));
708 return TRUE;
709}
710
711/**
712 * Upgrade from V452 to V453
713 */
714static BOOL H_UpgradeFromV452(int currVersion, int newVersion)
715{
716 static const TCHAR *batch =
717 _T("ALTER TABLE audit_log ADD value_diff $SQL:TEXT\n")
718 _T("<END>");
719 CHK_EXEC(SQLBatch(batch));
720 CHK_EXEC(SetSchemaVersion(453));
721 return TRUE;
722}
723
724/**
725 * Upgrade from V451 to V452
726 */
727static BOOL H_UpgradeFromV451(int currVersion, int newVersion)
728{
729 static const TCHAR *batch =
730 _T("ALTER TABLE audit_log ADD old_value $SQL:TEXT\n")
731 _T("ALTER TABLE audit_log ADD new_value $SQL:TEXT\n")
732 _T("<END>");
733 CHK_EXEC(SQLBatch(batch));
734 CHK_EXEC(SetSchemaVersion(452));
735 return TRUE;
736}
737
738/**
739 * Upgrade from V450 to V451
740 */
741static BOOL H_UpgradeFromV450(int currVersion, int newVersion)
742{
743 CHK_EXEC(CreateTable(
744 _T("CREATE TABLE object_access_snapshot (")
745 _T(" user_id integer not null,")
746 _T(" object_id integer not null,")
747 _T(" access_rights integer not null,")
748 _T("PRIMARY KEY(user_id,object_id))")));
749
750 CHK_EXEC(SetSchemaVersion(451));
751 return TRUE;
752}
753
754/**
755 * Upgrade from V449 to V450
756 */
757static BOOL H_UpgradeFromV449(int currVersion, int newVersion)
758{
759 static const TCHAR *batch =
760 _T("ALTER TABLE dct_thresholds ADD sample_count integer\n")
761 _T("UPDATE dct_thresholds SET sample_count=1\n")
762 _T("<END>");
763 CHK_EXEC(SQLBatch(batch));
764 DBSetNotNullConstraint(g_hCoreDB, _T("dct_thresholds"), _T("sample_count"));
765
766 CHK_EXEC(CreateTable(
767 _T("CREATE TABLE dct_threshold_instances (")
768 _T(" threshold_id integer not null,")
769 _T(" instance varchar(255) not null,")
770 _T(" match_count integer not null,")
771 _T(" is_active char(1) not null,")
772 _T("PRIMARY KEY(threshold_id,instance))")));
773
774 CHK_EXEC(SetSchemaVersion(450));
775 return TRUE;
776}
777
778/**
779 * Upgrade from V448 to V449
780 */
781static BOOL H_UpgradeFromV448(int currVersion, int newVersion)
782{
783 CHK_EXEC(CreateConfigParam(_T("SMTPPort"), _T("25"), _T("Port used by SMTP server"), 'I', true, false, false, false));
784 CHK_EXEC(SetSchemaVersion(449));
785 return TRUE;
786}
787
788/**
789 * Upgrade from V447 to V448
790 */
791static BOOL H_UpgradeFromV447(int currVersion, int newVersion)
792{
793 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD lldp_id varchar(63)")));
794 CHK_EXEC(SetSchemaVersion(448));
795 return TRUE;
796}
797
798/**
799 * Upgrade from V446 to V447
800 */
801static BOOL H_UpgradeFromV446(int currVersion, int newVersion)
802{
803 CHK_EXEC(CreateTable(
804 _T("CREATE TABLE port_layouts (")
805 _T(" device_oid varchar(255) not null,")
806 _T(" numbering_scheme char(1) not null,")
807 _T(" row_count char(1) not null,")
808 _T(" layout_data varchar(4000) null,")
809 _T("PRIMARY KEY(device_oid))")));
810
811 CHK_EXEC(SetSchemaVersion(447));
812 return TRUE;
813}
814
815/**
816 * Upgrade from V445 to V446
817 */
818static BOOL H_UpgradeFromV445(int currVersion, int newVersion)
819{
820 CHK_EXEC(CreateTable(
821 _T("CREATE TABLE network_map_seed_nodes (")
822 _T(" map_id integer not null,")
823 _T(" seed_node_id integer not null,")
824 _T("PRIMARY KEY(map_id,seed_node_id))")));
825
826 DB_RESULT hResult = DBSelect(g_hCoreDB, _T("SELECT id,seed FROM network_maps"));
827 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("INSERT INTO network_map_seed_nodes (map_id,seed_node_id) VALUES (?,?)"));
828 if (hResult != NULL)
829 {
830 if (hStmt != NULL)
831 {
832 int nRows = DBGetNumRows(hResult);
833 for(int i = 0; i < nRows; i++)
834 {
835 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 0));
836 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 1));
837
838 if (!SQLExecute(hStmt))
839 {
840 if (!g_bIgnoreErrors)
841 {
842 DBFreeStatement(hStmt);
843 DBFreeResult(hResult);
844 return FALSE;
845 }
846 }
847 }
848
849 CHK_EXEC(DBDropColumn(g_hCoreDB, _T("network_maps"), _T("seed")));
850 DBFreeStatement(hStmt);
851 }
852 DBFreeResult(hResult);
853 }
854
855 CHK_EXEC(SetSchemaVersion(446));
856 return TRUE;
857}
858
859/**
860 * Upgrade from V444 to V445
861 */
862static BOOL H_UpgradeFromV444(int currVersion, int newVersion)
863{
864 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD tunnel_id varchar(36) null")));
865 CHK_EXEC(SetSchemaVersion(445));
866 return TRUE;
867}
868
869/**
870 * Upgrade from V443 to V444
871 */
872static BOOL H_UpgradeFromV443(int currVersion, int newVersion)
873{
874 CHK_EXEC(CreateConfigParam(_T("GraceLoginCount"), _T("5"), _T("User's grace login count"), 'I', true, false, false, false));
875 CHK_EXEC(SetSchemaVersion(444));
876 return TRUE;
877}
878
879/**
880 * Upgrade from V442 to V443
881 */
882static BOOL H_UpgradeFromV442(int currVersion, int newVersion)
883{
884 static const TCHAR *batch =
885 _T("ALTER TABLE dc_tables ADD instance varchar(255) null\n")
886 _T("ALTER TABLE dc_tables ADD instd_method integer null\n")
887 _T("UPDATE dc_tables SET instd_method=0\n")
888 _T("ALTER TABLE dc_tables ADD instd_data varchar(255) null\n")
889 _T("ALTER TABLE dc_tables ADD instd_filter $SQL:TEXT null\n")
890 _T("<END>");
891 CHK_EXEC(SQLBatch(batch));
892 DBSetNotNullConstraint(g_hCoreDB, _T("dc_tables"), _T("instd_method"));
893 CHK_EXEC(SetSchemaVersion(443));
894 return TRUE;
895}
896
897/**
898 * Upgrade from V441 to V442
899 */
900static BOOL H_UpgradeFromV441(int currVersion, int newVersion)
901{
902 CHK_EXEC(CreateTable(
903 _T("CREATE TABLE object_urls (")
904 _T(" object_id integer not null,")
905 _T(" url_id integer not null,")
906 _T(" url varchar(2000) null,")
907 _T(" description varchar(2000) null,")
908 _T(" PRIMARY KEY(object_id,url_id))")));
909 CHK_EXEC(SetSchemaVersion(442));
910 return TRUE;
911}
912
913/**
914 * Upgrade from V440 to V441
915 */
916static BOOL H_UpgradeFromV440(int currVersion, int newVersion)
917{
918 CHK_EXEC(CreateConfigParam(_T("TopologyPollingInterval"), _T("1800"), _T("Interval in seconds between topology polls"), 'I', true, true, false, false));
919 CHK_EXEC(SetSchemaVersion(441));
920 return TRUE;
921}
922
923/**
924 * Upgrade from V439 to V440
925 */
926static BOOL H_UpgradeFromV439(int currVersion, int newVersion)
927{
928 static const TCHAR *batch =
929 _T("UPDATE config SET description='Enable/disable automatic deletion of subnet objects without any nodes within.' WHERE var_name='DeleteEmptySubnets'\n")
930 _T("UPDATE config SET description='Instance polling interval (in seconds).' WHERE var_name='InstancePollingInterval'\n")
931 _T("<END>");
932 CHK_EXEC(SQLBatch(batch));
933 CHK_EXEC(SetSchemaVersion(440));
934 return TRUE;
935}
936
937/**
938 * Upgrade from V438 to V439
939 */
940static BOOL H_UpgradeFromV438(int currVersion, int newVersion)
941{
942 static const TCHAR *batch =
943 _T("UPDATE config SET data_type='S' WHERE var_name='LdapUserUniqueId'\n")
944 _T("UPDATE config SET data_type='S' WHERE var_name='LdapGroupUniqueId'\n")
945 _T("<END>");
946 CHK_EXEC(SQLBatch(batch));
947 CHK_EXEC(SetSchemaVersion(439));
948 return TRUE;
949}
950
951/**
952 * Upgrade from V437 to V438
953 */
954static BOOL H_UpgradeFromV437(int currVersion, int newVersion)
955{
956 static const TCHAR *batch =
957 _T("ALTER TABLE snmp_trap_cfg ADD guid varchar(36)\n")
958 _T("UPDATE snmp_trap_cfg SET guid='5d01e7e5-edbb-46ce-b53c-f7f64d1bf8ff' WHERE trap_id=1\n")
959 _T("UPDATE snmp_trap_cfg SET guid='c5464919-fd76-4624-9c21-b6ab73d9df80' WHERE trap_id=2\n")
960 _T("UPDATE snmp_trap_cfg SET guid='44d3b32e-33c5-4a39-b2ad-990a1120155d' WHERE trap_id=3\n")
961 _T("UPDATE snmp_trap_cfg SET guid='c9660f48-a4b3-41c8-b3f9-e9a6a8129db5' WHERE trap_id=4\n")
962 _T("UPDATE snmp_trap_cfg SET guid='4b422ba6-4b45-4881-931a-ed38dc798f9f' WHERE trap_id=5\n")
963 _T("UPDATE snmp_trap_cfg SET guid='bd8b6971-a3e4-4cad-9c70-3a33e61e0913' WHERE trap_id=6\n")
964 _T("ALTER TABLE script_library ADD guid varchar(36)\n")
965 _T("UPDATE script_library SET guid='3b7bddce-3505-42ff-ac60-6a48a64bd0ae' WHERE script_id=1\n")
966 _T("UPDATE script_library SET guid='2fb9212b-97e6-40e7-b434-2df4f7e8f6aa' WHERE script_id=2\n")
967 _T("UPDATE script_library SET guid='38696a00-c519-438c-8cbd-4b3a0cba4af1' WHERE script_id=3\n")
968 _T("UPDATE script_library SET guid='efe50915-47b2-43d8-b4f4-2c09a44970c3' WHERE script_id=4\n")
969 _T("UPDATE script_library SET guid='7837580c-4054-40f2-981f-7185797fe7d7' WHERE script_id=11\n")
970 _T("UPDATE script_library SET guid='f7d1bc7e-4046-4ee4-adb2-718f7361984d' WHERE script_id=12\n")
971 _T("UPDATE script_library SET guid='048fcf32-765b-4702-9c70-f012f62d5a90' WHERE script_id=13\n")
972 _T("UPDATE script_library SET guid='d515c10f-a5c9-4f41-afcd-9ddc8845f288' WHERE script_id=14\n")
973 _T("UPDATE script_library SET guid='7cd1c471-2f14-4fae-8743-8899fed64d18' WHERE script_id=15\n")
974 _T("UPDATE script_library SET guid='befdb083-ac68-481d-a7b7-127e11c3fae0' WHERE script_id=16\n")
975 _T("<END>");
976 CHK_EXEC(SQLBatch(batch));
977
978 DB_RESULT hResult = DBSelect(g_hCoreDB, _T("SELECT trap_id FROM snmp_trap_cfg WHERE guid IS NULL"));
979 if (hResult != NULL)
980 {
981 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("UPDATE snmp_trap_cfg SET guid=? WHERE trap_id=?"));
982 if (hStmt != NULL)
983 {
984 int numRows = DBGetNumRows(hResult);
985 for(int i = 0; i < numRows; i++)
986 {
987 uuid guid = uuid::generate();
988 DBBind(hStmt, 1, DB_SQLTYPE_VARCHAR, guid);
989 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 0));
990
991 if (!SQLExecute(hStmt))
992 {
993 if (!g_bIgnoreErrors)
994 {
995 DBFreeStatement(hStmt);
996 DBFreeResult(hResult);
997 return FALSE;
998 }
999 }
1000 }
1001 DBFreeStatement(hStmt);
1002 }
1003 DBFreeResult(hResult);
1004 }
1005
1006 hResult = DBSelect(g_hCoreDB, _T("SELECT guid,script_id FROM script_library WHERE guid IS NULL"));
1007 if (hResult != NULL)
1008 {
1009 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("UPDATE script_library SET guid=? WHERE script_id=?"));
1010 if (hStmt != NULL)
1011 {
1012 int numRows = DBGetNumRows(hResult);
1013 for(int i = 0; i < numRows; i++)
1014 {
1015 uuid guid = uuid::generate();
1016 DBBind(hStmt, 1, DB_SQLTYPE_VARCHAR, guid);
1017 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 1));
1018 if (!SQLExecute(hStmt))
1019 {
1020 if (!g_bIgnoreErrors)
1021 {
1022 DBFreeStatement(hStmt);
1023 DBFreeResult(hResult);
1024 return FALSE;
1025 }
1026 }
1027 }
1028 DBFreeStatement(hStmt);
1029 }
1030 DBFreeResult(hResult);
1031 }
1032
1033 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("snmp_trap_cfg"), _T("guid")));
1034 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("script_library"), _T("guid")));
1035 CHK_EXEC(SetSchemaVersion(438));
1036 return TRUE;
1037}
1038
1039/**
1040 * Upgrade from V436 to V437
1041 */
1042static BOOL H_UpgradeFromV436(int currVersion, int newVersion)
1043{
1044 CHK_EXEC(
1045 CreateEventTemplate(EVENT_ROUTING_LOOP_DETECTED, _T("SYS_ROUTING_LOOP_DETECTED"),
1046 SEVERITY_MAJOR, EF_LOG, _T("98276f42-dc85-41a5-b449-6ba83d1a71b7"),
1047 _T("Routing loop detected for destination %3 (selected route %6/%7 via %9)"),
1048 _T("Generated when server detects routing loop during network path trace.\r\n")
1049 _T("Source of the event is node which routes packet back to already passed hop.\r\n")
1050 _T("Parameters:\r\n")
1051 _T(" 1) Protocol (IPv4 or IPv6)\r\n")
1052 _T(" 2) Path trace destination node ID\r\n")
1053 _T(" 3) Path trace destination address\r\n")
1054 _T(" 4) Path trace source node ID\r\n")
1055 _T(" 5) Path trace source node address\r\n")
1056 _T(" 6) Routing prefix (subnet address)\r\n")
1057 _T(" 7) Routing prefix length (subnet mask length)\r\n")
1058 _T(" 8) Next hop node ID\r\n")
1059 _T(" 9) Next hop address"))
1060 );
1061 CHK_EXEC(SetSchemaVersion(437));
1062 return TRUE;
1063}
1064
1065/**
1066 * Upgrade from V435 to V436
1067 */
1068static BOOL H_UpgradeFromV435(int currVersion, int newVersion)
1069{
1070 static const TCHAR *batch =
1071 _T("ALTER TABLE nodes ADD agent_comp_mode char(1)\n")
1072 _T("UPDATE nodes SET agent_comp_mode='0'\n")
1073 _T("<END>");
1074 CHK_EXEC(SQLBatch(batch));
1075 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("agent_comp_mode")));
1076 CHK_EXEC(SetSchemaVersion(436));
1077 return TRUE;
1078}
1079
1080/**
1081 * Upgrade from V434 to V435
1082 */
1083static BOOL H_UpgradeFromV434(int currVersion, int newVersion)
1084{
1085 CHK_EXEC(CreateConfigParam(_T("DefaultAgentProtocolCompressionMode"), _T("1"), _T("Default agent protocol compression mode"), 'C', true, false, false, false));
1086 static const TCHAR *batch =
1087 _T("UPDATE config SET data_type='C',description='Default agent cache mode' WHERE var_name='DefaultAgentCacheMode'\n")
1088 _T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultAgentCacheMode','1','On')\n")
1089 _T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultAgentCacheMode','2','Off')\n")
1090 _T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultAgentProtocolCompressionMode','1','Enabled')\n")
1091 _T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultAgentProtocolCompressionMode','2','Disabled')\n")
1092 _T("<END>");
1093 CHK_EXEC(SQLBatch(batch));
1094 CHK_EXEC(SetSchemaVersion(435));
1095 return TRUE;
1096}
1097
1098/**
1099 * Upgrade from V433 to V434
1100 */
1101static BOOL H_UpgradeFromV433(int currVersion, int newVersion)
1102{
1103 CHK_EXEC(
1104 CreateEventTemplate(EVENT_IF_EXPECTED_STATE_UP, _T("SYS_IF_EXPECTED_STATE_UP"),
1105 SEVERITY_NORMAL, EF_LOG, _T("4997c3f5-b332-4077-8e99-983142f0e193"),
1106 _T("Expected state for interface \"%2\" set to UP"),
1107 _T("Generated when interface expected state set to UP.\r\n")
1108 _T("Please note that source of event is node, not an interface itself.\r\n")
1109 _T("Parameters:\r\n")
1110 _T(" 1) Interface index\r\n")
1111 _T(" 2) Interface name"))
1112 );
1113
1114 CHK_EXEC(
1115 CreateEventTemplate(EVENT_IF_EXPECTED_STATE_DOWN, _T("SYS_IF_EXPECTED_STATE_DOWN"),
1116 SEVERITY_NORMAL, EF_LOG, _T("75de536c-4861-4f19-ba56-c43d814431d7"),
1117 _T("Expected state for interface \"%2\" set to DOWN"),
1118 _T("Generated when interface expected state set to DOWN.\r\n")
1119 _T("Please note that source of event is node, not an interface itself.\r\n")
1120 _T("Parameters:\r\n")
1121 _T(" 1) Interface index\r\n")
1122 _T(" 2) Interface name"))
1123 );
1124
1125 CHK_EXEC(
1126 CreateEventTemplate(EVENT_IF_EXPECTED_STATE_IGNORE, _T("SYS_IF_EXPECTED_STATE_IGNORE"),
1127 SEVERITY_NORMAL, EF_LOG, _T("0e488c0e-3340-4e02-ad96-b999b8392e55"),
1128 _T("Expected state for interface \"%2\" set to IGNORE"),
1129 _T("Generated when interface expected state set to IGNORE.\r\n")
1130 _T("Please note that source of event is node, not an interface itself.\r\n")
1131 _T("Parameters:\r\n")
1132 _T(" 1) Interface index\r\n")
1133 _T(" 2) Interface name"))
1134 );
1135
1136 CHK_EXEC(AddEventToEPPRule(_T("6f46d451-ee66-4563-8747-d129877df24d"), EVENT_IF_EXPECTED_STATE_DOWN));
1137 CHK_EXEC(AddEventToEPPRule(_T("6f46d451-ee66-4563-8747-d129877df24d"), EVENT_IF_EXPECTED_STATE_IGNORE));
1138 CHK_EXEC(AddEventToEPPRule(_T("ecc3fb57-672d-489d-a0ef-4214ea896e0f"), EVENT_IF_EXPECTED_STATE_UP));
1139 CHK_EXEC(AddEventToEPPRule(_T("ecc3fb57-672d-489d-a0ef-4214ea896e0f"), EVENT_IF_EXPECTED_STATE_IGNORE));
1140
1141 CHK_EXEC(SetSchemaVersion(434));
1142 return TRUE;
1143}
1144
1145/**
1146 * Upgrade from V432 to V433
1147 */
1148static BOOL H_UpgradeFromV432(int currVersion, int newVersion)
1149{
1150 CHK_EXEC(CreateConfigParam(_T("UseSyslogForDiscovery"), _T("0"), _T("Use syslog messages for new node discovery."), 'B', true, false, false, false));
1151 CHK_EXEC(SetSchemaVersion(433));
1152 return TRUE;
1153}
1154
1155/**
1156 * Upgrade from V431 to V432
1157 */
1158static BOOL H_UpgradeFromV431(int currVersion, int newVersion)
1159{
1160 CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_syslog_source ON syslog(source_object_id)")));
1161 CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_snmp_trap_log_oid ON snmp_trap_log(object_id)")));
1162 CHK_EXEC(SetSchemaVersion(432));
1163 return TRUE;
1164}
1165
1166/**
1167 * Upgrade from V430 to V431
1168 */
1169static BOOL H_UpgradeFromV430(int currVersion, int newVersion)
1170{
1171 CHK_EXEC(SQLQuery(_T("DELETE FROM config_values WHERE var_name='SNMPPorts'")));
1172 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'")));
1173 CHK_EXEC(SetSchemaVersion(431));
1174 return TRUE;
1175}
1176
1177/**
1178 * Upgrade from V429 to V430
1179 */
1180static BOOL H_UpgradeFromV429(int currVersion, int newVersion)
1181{
1182 CHK_EXEC(CreateTable(
1183 _T("CREATE TABLE policy_pstorage_actions (")
1184 _T("rule_id integer not null,")
1185 _T("ps_key varchar(255) not null,")
1186 _T("value varchar(2000) null,")
1187 _T("action integer not null,")
1188 _T("PRIMARY KEY(rule_id,ps_key,action))")));
1189
1190 CHK_EXEC(CreateTable(
1191 _T("CREATE TABLE persistent_storage (")
1192 _T("entry_key varchar(255) not null,")
1193 _T("value varchar(2000) null,")
1194 _T("PRIMARY KEY(entry_key))")));
1195
1196 //Move previous attrs form situations to pstorage
1197 DB_RESULT hResult = SQLSelect(_T("SELECT event_policy.rule_id,situations.name,event_policy.situation_instance,")
1198 _T("policy_situation_attr_list.attr_name,policy_situation_attr_list.attr_value ")
1199 _T("FROM event_policy,situations,policy_situation_attr_list ")
1200 _T("WHERE event_policy.rule_id=policy_situation_attr_list.rule_id ")
1201 _T("AND situations.id=policy_situation_attr_list.situation_id"));
1202 if (hResult != NULL)
1203 {
1204 int count = DBGetNumRows(hResult);
1205 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("INSERT INTO policy_pstorage_actions (rule_id,ps_key,value,action) VALUES (?,?,?,1)"));
1206 if (hStmt != NULL)
1207 {
1208 String key;
1209 for(int i = 0; i < count; i++)
1210 {
1211 TCHAR tmp[256];
1212 DBGetField(hResult, i, 1, tmp, 256);
1213 key.append(tmp);
1214 DBGetField(hResult, i, 2, tmp, 256);
1215 key.append(_T("."));
1216 key.append(tmp);
1217 DBGetField(hResult, i, 3, tmp, 256);
1218 key.append(_T("."));
1219 key.append(tmp);
1220 DBGetField(hResult, i, 4, tmp, 256);
1221
1222 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, DBGetFieldLong(hResult, i, 0));
1223 DBBind(hStmt, 2, DB_SQLTYPE_TEXT, key, DB_BIND_STATIC, 512);
1224 DBBind(hStmt, 3, DB_SQLTYPE_TEXT, tmp, DB_BIND_STATIC);
1225 if (!SQLExecute(hStmt))
1226 {
1227 if (!g_bIgnoreErrors)
1228 {
1229 DBFreeStatement(hStmt);
1230 DBFreeResult(hResult);
1231 return FALSE;
1232 }
1233 }
1234 key.clear();
1235 }
1236 DBFreeStatement(hStmt);
1237 }
1238 else if (!g_bIgnoreErrors)
1239 {
1240 DBFreeStatement(hStmt);
1241 DBFreeResult(hResult);
1242 return FALSE;
1243 }
1244 DBFreeResult(hResult);
1245 }
1246 else
1247 {
1248 if (!g_bIgnoreErrors)
1249 return false;
1250 }
1251
1252 CHK_EXEC(SQLQuery(_T("DROP TABLE situations")));
1253 CHK_EXEC(SQLQuery(_T("DROP TABLE policy_situation_attr_list")));
1254 CHK_EXEC(DBDropColumn(g_hCoreDB, _T("event_policy"), _T("situation_id")));
1255 CHK_EXEC(DBDropColumn(g_hCoreDB, _T("event_policy"), _T("situation_instance")));
1256 CHK_EXEC(SetSchemaVersion(430));
1257 return TRUE;
1258}
1259
1260/**
1261 * Upgrade from V428 to V429
1262 */
1263static BOOL H_UpgradeFromV428(int currVersion, int newVersion)
1264{
1265 CHK_EXEC(DBResizeColumn(g_hCoreDB, _T("config"), _T("description"), 450, true));
1266 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between active network discovery polls.' WHERE var_name='ActiveDiscoveryInterval'")));
1267 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'")));
1268 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'")));
1269 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'")));
1270 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'")));
1271 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'")));
1272 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'")));
1273 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'")));
1274 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'")));
1275 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'")));
1276 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'")));
1277 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='AllowTrapVarbindsConversion'")));
1278 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='AnonymousFileAccess'")));
1279 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'")));
1280 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'")));
1281 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'")));
1282 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in milliseconds between beacon hosts polls.' WHERE var_name='BeaconPollingInterval'")));
1283 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Timeout in milliseconds to consider beacon host unreachable.' WHERE var_name='BeaconTimeout'")));
1284 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='BlockInactiveUserAccounts'")));
1285 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='CapabilityExpirationTime'")));
1286 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable case insensitive login names' WHERE var_name='CaseInsensitiveLoginNames'")));
1287 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable trusted nodes check' WHERE var_name='CheckTrustedNodes'")));
1288 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'")));
1289 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable container auto binding for clusters.' WHERE var_name='ClusterContainerAutoBind'")));
1290 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable template auto apply for clusters.' WHERE var_name='ClusterTemplateAutoApply'")));
1291 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'")));
1292 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between configuration polls.' WHERE var_name='ConfigurationPollingInterval'")));
1293 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable data interpolation in dashboard data export.' WHERE var_name='DashboardDataExportEnableInterpolation'")));
1294 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'")));
1295 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DBConnectionPoolCooldownTime'")));
1296 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DBConnectionPoolMaxLifetime'")));
1297 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='A maximum number of connections in the connection pool.' WHERE var_name='DBConnectionPoolMaxSize'")));
1298 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='DBLockInfo'")));
1299 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DBLockPID'")));
1300 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='DBLockStatus'")));
1301 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DefaultAgentCacheMode'")));
1302 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Default date display format for GUI.' WHERE var_name='DefaultConsoleDateFormat'")));
1303 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Default short time display format for GUI.' WHERE var_name='DefaultConsoleShortTimeFormat'")));
1304 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Default long time display format for GUI.' WHERE var_name='DefaultConsoleTimeFormat'")));
1305 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default polling interval for newly created DCI (in seconds).' WHERE var_name='DefaultDCIPollingInterval'")));
1306 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default retention time for newly created DCI (in days).' WHERE var_name='DefaultDCIRetentionTime'")));
1307 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Set the default encryption policy for communications with agents.' WHERE var_name='DefaultEncryptionPolicy'")));
1308 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Default expected state for new interface objects.' WHERE var_name='DefaultInterfaceExpectedState'")));
1309 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='H',description='Default background color for new network map objects.' WHERE var_name='DefaultMapBackgroundColor'")));
1310 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default mask for synthetic IPv4 subnets.' WHERE var_name='DefaultSubnetMaskIPv4'")));
1311 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Default mask for synthetic IPv6 subnets.' WHERE var_name='DefaultSubnetMaskIPv6'")));
1312 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'")));
1313 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'")));
1314 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'")));
1315 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'")));
1316 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='DiscoveryFilter'")));
1317 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='DiscoveryFilterFlags'")));
1318 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between passive network discovery polls.' WHERE var_name='DiscoveryPollingInterval'")));
1319 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableAdminInterface'")));
1320 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable agent self-registration' WHERE var_name='EnableAgentRegistration'")));
1321 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable audit log.' WHERE var_name='EnableAuditLog'")));
1322 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableCheckPointSNMP'")));
1323 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableReportingServer'")));
1324 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableEventStormDetection'")));
1325 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable Inter-Server Communications Listener.' WHERE var_name='EnableISCListener'")));
1326 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.'")));
1327 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableObjectTransactions'")));
1328 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable SNMP trap processing.' WHERE var_name='EnableSNMPTraps'")));
1329 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable alarm summary e-mails.' WHERE var_name='EnableAlarmSummaryEmails'")));
1330 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable receiving of syslog messages.' WHERE var_name='EnableSyslogReceiver'")));
1331 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EnableTimedAlarmAck'")));
1332 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'")));
1333 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable zoning support' WHERE var_name='EnableZoning'")));
1334 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='EscapeLocalCommands'")));
1335 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The retention time of event logs' WHERE var_name='EventLogRetentionTime'")));
1336 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='EventStormDuration'")));
1337 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Event storm events per second' WHERE var_name='EventStormEventsPerSecond'")));
1338 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable extended access control in log queries.' WHERE var_name='ExtendedLogQueryAccessControl'")));
1339 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'")));
1340 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'")));
1341 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'")));
1342 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'")));
1343 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'")));
1344 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='FirstFreeObjectId'")));
1345 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='FixedStatusValue'")));
1346 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='HelpDeskLink'")));
1347 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'")));
1348 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'")));
1349 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'")));
1350 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Import configuration from local files on server startup.' WHERE var_name='ImportConfigurationOnStartup'")));
1351 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Instance polling interval (in milliseconds).' WHERE var_name='InstancePollingInterval'")));
1352 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Enable/disable internal certificate authority.' WHERE var_name='InternalCA'")));
1353 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='IntruderLockoutThreshold'")));
1354 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='IntruderLockoutTime'")));
1355 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='JiraIssueType'")));
1356 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Jira login name.' WHERE var_name='JiraLogin'")));
1357 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Jira password' WHERE var_name='JiraPassword'")));
1358 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Jira project code' WHERE var_name='JiraProjectCode'")));
1359 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='JiraProjectComponent'")));
1360 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The URL of the Jira server' WHERE var_name='JiraServerURL'")));
1361 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='JobHistoryRetentionTime'")));
1362 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Maximum mumber of job execution retrys.' WHERE var_name='JobRetryCount'")));
1363 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'")));
1364 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'")));
1365 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='LdapGroupUniqueId'")));
1366 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'")));
1367 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'")));
1368 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'")));
1369 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'")));
1370 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'")));
1371 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'")));
1372 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'")));
1373 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'")));
1374 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='User login for LDAP synchronization.' WHERE var_name='LdapSyncUser'")));
1375 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='User password for LDAP synchronization.' WHERE var_name='LdapSyncUserPassword'")));
1376 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'")));
1377 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'")));
1378 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='LdapUserUniqueId'")));
1379 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='LockTimeout'")));
1380 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Log all SNMP traps.' WHERE var_name='LogAllSNMPTraps'")));
1381 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Encoding for e-mails generated by NetXMS server.' WHERE var_name='MailEncoding'")));
1382 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'")));
1383 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'")));
1384 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='MinViewRefreshInterval'")));
1385 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='MobileDeviceListenerPort'")));
1386 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The number of threads used for data collection.' WHERE var_name='NumberOfDataCollectors'")));
1387 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'")));
1388 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'")));
1389 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Set of flags to enforce password complexity.' WHERE var_name='PasswordComplexity'")));
1390 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'")));
1391 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'")));
1392 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'")));
1393 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The base thread pool size.' WHERE var_name='PollerThreadPoolBaseSize'")));
1394 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Maximum thread pool size.' WHERE var_name='PollerThreadPoolMaxSize'")));
1395 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'")));
1396 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The number of retries for RADIUS authentication.' WHERE var_name='RADIUSNumRetries'")));
1397 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Port number used for connection to primary RADIUS server.' WHERE var_name='RADIUSPort'")));
1398 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Port number used for connection to secondary RADIUS server.' WHERE var_name='RADIUSSecondaryPort'")));
1399 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Shared secret used for communication with secondary RADIUS server.' WHERE var_name='RADIUSSecondarySecret'")));
1400 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Host name or IP address of secondary RADIUS server.' WHERE var_name='RADIUSSecondaryServer'")));
1401 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Shared secret used for communication with primary RADIUS server.' WHERE var_name='RADIUSSecret'")));
1402 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Host name or IP address of primary RADIUS server.' WHERE var_name='RADIUSServer'")));
1403 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Timeout in seconds for requests to RADIUS server.' WHERE var_name='RADIUSTimeout'")));
1404 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'")));
1405 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The hostname of the reporting server.' WHERE var_name='ReportingServerHostname'")));
1406 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The port of the reporting server.' WHERE var_name='ReportingServerPort'")));
1407 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Resolve DNS to IP on status poll.' WHERE var_name='ResolveDNSToIPOnStatusPoll'")));
1408 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='' WHERE var_name='ResolveNodeNames'")));
1409 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between reading routing table from node.' WHERE var_name='RoutingTableUpdateInterval'")));
1410 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'")));
1411 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='H',description='Identification color for this server' WHERE var_name='ServerColor'")));
1412 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='ServerCommandOutputTimeout'")));
1413 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Name of this server' WHERE var_name='ServerName'")));
1414 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='Mobile phone driver to be used for sending SMS.' WHERE var_name='SMSDriver'")));
1415 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'")));
1416 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The address used for sending mail from.' WHERE var_name='SMTPFromAddr'")));
1417 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The name used as the sender.' WHERE var_name='SMTPFromName'")));
1418 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Number of retries for sending mail.' WHERE var_name='SMTPRetryCount'")));
1419 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='TCP port for SMTP server.' WHERE var_name='SNMPPorts'")));
1420 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='An SMTP server used for sending mail.' WHERE var_name='SMTPServer'")));
1421 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'")));
1422 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='The time how long SNMP trap logs are retained.' WHERE var_name='SNMPTrapLogRetentionTime'")));
1423 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Port used for SNMP traps.' WHERE var_name='SNMPTrapPort'")));
1424 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='StatusCalculationAlgorithm'")));
1425 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='Interval in seconds between status polls.' WHERE var_name='StatusPollingInterval'")));
1426 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'")));
1427 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='StatusShift'")));
1428 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='StatusSingleThreshold'")));
1429 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='StatusThresholds'")));
1430 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='' WHERE var_name='StatusTranslation'")));
1431 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'")));
1432 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'")));
1433 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'")));
1434 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'")));
1435 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='UDP port used by built-in syslog server.' WHERE var_name='SyslogListenPort'")));
1436 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Node matching policy for built-in syslog daemon.' WHERE var_name='SyslogNodeMatchingPolicy'")));
1437 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'")));
1438 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'")));
1439 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='The URL for the Tile server.' WHERE var_name='TileServerURL'")));
1440 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='TopologyDiscoveryRadius'")));
1441 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='' WHERE var_name='TopologyExpirationTime'")));
1442 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'")));
1443 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'")));
1444 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'")));
1445 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'")));
1446 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='C',description='Control usage of interface aliases (or descriptions).' WHERE var_name='UseInterfaceAliases'")));
1447 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='B',description='Use SNMP trap information for new node discovery.' WHERE var_name='UseSNMPTrapsForDiscovery'")));
1448 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'")));
1449 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'")));
1450 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='I',description='XMPP connection port.' WHERE var_name='XMPPPort'")));
1451 CHK_EXEC(SQLQuery(_T("UPDATE config SET data_type='S',description='XMPP connection server.' WHERE var_name='XMPPServer'")));
1452
1453 CHK_EXEC(CreateTable(
1454 _T("CREATE TABLE config_values (")
1455 _T("var_name varchar(63) not null,")
1456 _T("var_value varchar(15) not null,")
1457 _T("var_description varchar(255) null,")
1458 _T("PRIMARY KEY(var_name,var_value))")));
1459
1460 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('ClientListenerPort','65535')")));
1461 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('ExternalAuditPort','65535')")));
1462 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('MobileDeviceListenerPort','65535')")));
1463 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('RADIUSPort','65535')")));
1464 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('RADIUSSecondaryPort','65535')")));
1465 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('ReportingServerPort','65535')")));
1466 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('SNMPPorts','65535')")));
1467 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('SNMPTrapPort','65535')")));
1468 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('SyslogListenPort','65535')")));
1469 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('XMPPPort','65535')")));
1470 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value) VALUES ('AllowedCiphers','63')")));
1471 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultInterfaceExpectedState','0','UP')")));
1472 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultInterfaceExpectedState','1','DOWN')")));
1473 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultInterfaceExpectedState','2','IGNORE')")));
1474 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultEncryptionPolicy','0','Disabled')")));
1475 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultEncryptionPolicy','1','Allowed')")));
1476 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultEncryptionPolicy','2','Preferred')")));
1477 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('DefaultEncryptionPolicy','3','Required')")));
1478 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','0','Default')")));
1479 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','1','Unchanged')")));
1480 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','2','Fixed')")));
1481 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','3','Relative')")));
1482 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('StatusPropagationAlgorithm','4','Translated')")));
1483 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('UseInterfaceAliases','0','Don`t use aliases')")));
1484 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('UseInterfaceAliases','1','Use aliases when possible')")));
1485 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('UseInterfaceAliases','2','Concatenate alias and name')")));
1486 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('UseInterfaceAliases','3','Concatenate name and alias')")));
1487 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('SyslogNodeMatchingPolicy','0','IP, then hostname')")));
1488 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('SyslogNodeMatchingPolicy','1','Hostname, then IP')")));
1489 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('LdapUserDeleteAction','0','Delete user')")));
1490 CHK_EXEC(SQLQuery(_T("INSERT INTO config_values (var_name,var_value,var_description) VALUES ('LdapUserDeleteAction','1','Disable user')")));
1491
1492 CHK_EXEC(SetSchemaVersion(429));
1493 return TRUE;
1494}
1495
1496/**
1497 * Upgrade from V427 to V428
1498 */
1499static BOOL H_UpgradeFromV427(int currVersion, int newVersion)
1500{
1501 CHK_EXEC(CreateConfigParam(_T("ClusterContainerAutoBind"), _T("0"), _T("Enable/disable container auto binding for clusters"), 'B', true, false, false, false));
1502 CHK_EXEC(CreateConfigParam(_T("ClusterTemplateAutoApply"), _T("0"), _T("Enable/disable template auto apply for clusters"), 'B', true, false, false, false));
1503 CHK_EXEC(SetSchemaVersion(428));
1504 return TRUE;
1505}
1506
1507/**
1508 * Upgrade from V426 to V427
1509 */
1510static BOOL H_UpgradeFromV426(int currVersion, int newVersion)
1511{
1512 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD port_rows integer")));
1513 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD port_numbering_scheme integer")));
1514 CHK_EXEC(SetSchemaVersion(427));
1515 return TRUE;
1516}
1517
1518/**
1519 * Upgrade from V425 to V426
1520 */
1521static BOOL H_UpgradeFromV425(int currVersion, int newVersion)
1522{
1523 CHK_EXEC(CreateConfigParam(_T("EnableAlarmSummaryEmails"), _T(""), _T("Enable alarm summary e-mails"), 'I', true, false, false, false));
1524 CHK_EXEC(CreateConfigParam(_T("AlarmSummaryEmailSchedule"), _T(""), _T("Schedule for sending alarm summary e-mails in cron format"), 'S', true, false, false, false));
1525 CHK_EXEC(CreateConfigParam(_T("AlarmSummaryEmailRecipients"), _T(""), _T("A semicolon separated list of alarm summary e-mail recipient addresses"), 'S', true, false, false, false));
1526 CHK_EXEC(SetSchemaVersion(426));
1527 return TRUE;
1528}
1529
1530/**
1531 * Upgrade from V424 to V425
1532 */
1533static BOOL H_UpgradeFromV424(int currVersion, int newVersion)
1534{
1535 CHK_EXEC(SQLQuery(_T("ALTER TABLE scheduled_tasks ADD comments varchar(255)")));
1536 CHK_EXEC(SetSchemaVersion(425));
1537 return TRUE;
1538}
1539
1540/**
1541 * Upgrade from V423 to V424
1542 */
1543static BOOL H_UpgradeFromV423(int currVersion, int newVersion)
1544{
1545 CHK_EXEC(CreateConfigParam(_T("MessageOfTheDay"), _T(""), _T("Message to be shown when a user logs into the console"), 'S', true, false, false, false));
1546 CHK_EXEC(SetSchemaVersion(424));
1547 return TRUE;
1548}
1549
1550/**
1551 * Upgrade from V422 to V423
1552 */
1553static BOOL H_UpgradeFromV422(int currVersion, int newVersion)
1554{
1555 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));
1556 CHK_EXEC(SetSchemaVersion(423));
1557 return TRUE;
1558}
1559
1560/**
1561 * Upgrade from V421 to V422
1562 */
1563static BOOL H_UpgradeFromV421(int currVersion, int newVersion)
1564{
1565 CHK_EXEC(CreateConfigParam(_T("ServerColor"), _T(""), _T("Identification color for this server"), 'S', true, false, false, false));
1566 CHK_EXEC(CreateConfigParam(_T("ServerName"), _T(""), _T("Name of this server"), 'S', true, false, false, false));
1567 CHK_EXEC(SetSchemaVersion(422));
1568 return TRUE;
1569}
1570
1571/**
1572 * Upgrade from V420 to V421
1573 */
1574static BOOL H_UpgradeFromV420(int currVersion, int newVersion)
1575{
1576 DB_RESULT hResult = SQLSelect(_T("SELECT access_rights,user_id,object_id FROM acl"));
1577 if (hResult != NULL)
1578 {
1579 UINT32 rights;
1580 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("UPDATE acl SET access_rights=? WHERE user_id=? AND object_id=?"));
1581 if (hStmt != NULL)
1582 {
1583 for(int i = 0; i < DBGetNumRows(hResult); i++)
1584 {
1585 rights = DBGetFieldULong(hResult, i, 0);
1586 if ((rights & 0x2) == 0x2)
1587 {
1588 rights = rights | 0x8000; // Add Manage maintenance access right to all users which have Modify object access right
1589 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, rights);
1590 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 1));
1591 DBBind(hStmt, 3, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 2));
1592 SQLExecute(hStmt);
1593 }
1594 }
1595 DBFreeStatement(hStmt);
1596 }
1597 else
1598 {
1599 if (!g_bIgnoreErrors)
1600 {
1601 DBFreeResult(hResult);
1602 return FALSE;
1603 }
1604 }
1605 DBFreeResult(hResult);
1606 }
1607 else
1608 {
1609 if (!g_bIgnoreErrors)
1610 return FALSE;
1611 }
1612
1613 CHK_EXEC(SetSchemaVersion(421));
1614 return TRUE;
1615}
1616
1617/**
1618 * Upgrade from V419 to V420
1619 */
1620static BOOL H_UpgradeFromV419(int currVersion, int newVersion)
1621{
1622 CHK_EXEC(CreateConfigParam(_T("EnableReportingServer"), _T("0"), 1, 1));
1623 CHK_EXEC(CreateConfigParam(_T("ReportingServerHostname"), _T("localhost"), 1, 1));
1624 CHK_EXEC(CreateConfigParam(_T("ReportingServerPort"), _T("4710"), 1, 1));
1625 CHK_EXEC(SetSchemaVersion(420));
1626 return TRUE;
1627}
1628
1629/**
1630 * Upgrade from V418 to V419
1631 */
1632static BOOL H_UpgradeFromV418(int currVersion, int newVersion)
1633{
1634 CHK_EXEC(SQLQuery(_T("ALTER TABLE items ADD npe_name varchar(15)")));
1635 CHK_EXEC(SetSchemaVersion(419));
1636 return TRUE;
1637}
1638
1639/**
1640 * Upgrade from V417 to V418
1641 */
1642static BOOL H_UpgradeFromV417(int currVersion, int newVersion)
1643{
1644 // Update in object tools objectToolFilter objectMenuFilter
1645 // move object tool flags to filter structure
1646 DB_RESULT hResult = SQLSelect(_T("SELECT tool_id,flags,tool_filter FROM object_tools"));
1647 if (hResult != NULL)
1648 {
1649 int count = DBGetNumRows(hResult);
1650 for(int i = 0; i < count; i++)
1651 {
1652 int filteringFlag = 0;
1653 int objectToolFlag = DBGetFieldLong(hResult, i, 1);
1654
1655 // Separate and reorder flags for filter and for object tools
1656 for(int j = 1; j < 5; j = j << 1) //REQUIRES_SNMP 0x01, REQUIRES_AGENT 0x02, REQUIRES_OID_MATCH 0x04
1657 {
1658 if ((objectToolFlag & j) != 0)
1659 {
1660 objectToolFlag = objectToolFlag & ~j;
1661 filteringFlag = filteringFlag | j;
1662 }
1663 }
1664
1665 if ((objectToolFlag & 0x08) != 0) //ASK_CONFIRMATION
1666 {
1667 objectToolFlag = objectToolFlag & ~0x08;
1668 objectToolFlag = objectToolFlag | 0x01;
1669 }
1670
1671 if ((objectToolFlag & 0x10) != 0) //GENERATES_OUTPUT
1672 {
1673 objectToolFlag = objectToolFlag & ~0x10;
1674 objectToolFlag = objectToolFlag | 0x02;
1675 }
1676
1677 if ((objectToolFlag & 0x20) != 0) //DISABLED
1678 {
1679 objectToolFlag = objectToolFlag & ~0x20;
1680 objectToolFlag = objectToolFlag | 0x04;
1681 }
1682
1683 if ((objectToolFlag & 0x40) != 0) //SHOW_IN_COMMANDS
1684 {
1685 objectToolFlag = objectToolFlag & ~0x40;
1686 objectToolFlag = objectToolFlag | 0x08;
1687 }
1688
1689 if ((objectToolFlag & 0x80) != 0) //REQUIRES_NODE_OS_MATCH
1690 {
1691 objectToolFlag = objectToolFlag & ~0x80;
1692 filteringFlag = filteringFlag | 0x08;
1693 }
1694
1695 if ((objectToolFlag & 0x100) != 0) //REQUIRES_TEMPLATE_MATCH
1696 {
1697 objectToolFlag = objectToolFlag & ~0x100;
1698 filteringFlag = filteringFlag | 0x10;
1699 }
1700
1701 if ((objectToolFlag & 0x10000) != 0) //SNMP_INDEXED_BY_VALUE
1702 {
1703 objectToolFlag = objectToolFlag & ~0x10000;
1704 objectToolFlag = objectToolFlag | 0x10;
1705 }
1706
1707 if ((objectToolFlag & 0x20000) != 0) //REQUIRES_WORKSTATION_OS_MATCH
1708 {
1709 objectToolFlag = objectToolFlag & ~0x20000;
1710 filteringFlag = filteringFlag | 0x20;
1711 }
1712
1713 // Add filter flags to XML
1714 TCHAR *xml = DBGetField(hResult, i, 2, NULL, 0);
1715 size_t len = (xml != NULL) ? _tcslen(xml) + 1024 : 1024;
1716 TCHAR *tmp = (TCHAR *)malloc(len * sizeof(TCHAR));
1717 TCHAR *ptr = (xml != NULL) ? _tcsrchr(xml, '<') : NULL;
1718 if (ptr != NULL)
1719 {
1720 *ptr = 0;
1721 _sntprintf(tmp, len, _T("%s<flags>%d</flags></objectMenuFilter>"), xml, filteringFlag);
1722 _tcsncpy(tmp, _T("<objectMenuFilter"), 17); //Change main tag name
1723 }
1724 else
1725 {
1726 _sntprintf(tmp, len, _T("<objectMenuFilter><flags>%d</flags></objectMenuFilter>"), filteringFlag);
1727 }
1728
1729 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("UPDATE object_tools SET flags=?,tool_filter=? WHERE tool_id=?"));
1730 if (hStmt != NULL)
1731 {
1732 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, objectToolFlag);
1733 DBBind(hStmt, 2, DB_SQLTYPE_TEXT, tmp, DB_BIND_DYNAMIC);
1734 DBBind(hStmt, 3, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 0));
1735 if (!SQLExecute(hStmt))
1736 {
1737 if (!g_bIgnoreErrors)
1738 {
1739 free(xml);
1740 DBFreeStatement(hStmt);
1741 DBFreeResult(hResult);
1742 return FALSE;
1743 }
1744 }
1745 }
1746 else
1747 {
1748 free(tmp);
1749 if (!g_bIgnoreErrors)
1750 {
1751 free(xml);
1752 DBFreeResult(hResult);
1753 return FALSE;
1754 }
1755 }
1756 free(xml);
1757 }
1758 DBFreeResult(hResult);
1759 }
1760 else
1761 {
1762 if (!g_bIgnoreErrors)
1763 return false;
1764 }
1765
1766 CHK_EXEC(SetSchemaVersion(418));
1767 return TRUE;
1768}
1769
1770/**
1771 * Upgrade from V416 to V417
1772 */
1773static BOOL H_UpgradeFromV416(int currVersion, int newVersion)
1774{
1775 CHK_EXEC(CreateConfigParam(_T("JiraIssueType"), _T("Task"), true, false));
1776 CHK_EXEC(CreateConfigParam(_T("JiraLogin"), _T("netxms"), true, true));
1777 CHK_EXEC(CreateConfigParam(_T("JiraPassword"), _T(""), true, true));
1778 CHK_EXEC(CreateConfigParam(_T("JiraProjectCode"), _T("NETXMS"), true, false));
1779 CHK_EXEC(CreateConfigParam(_T("JiraProjectComponent"), _T(""), true, false));
1780 CHK_EXEC(CreateConfigParam(_T("JiraServerURL"), _T("http://localhost"), true, true));
1781
1782 CHK_EXEC(SetSchemaVersion(417));
1783 return TRUE;
1784}
1785
1786/**
1787 * Upgrade from V415 to V416
1788 */
1789static BOOL H_UpgradeFromV415(int currVersion, int newVersion)
1790{
1791 CHK_EXEC(CreateTable(
1792 _T("CREATE TABLE alarm_categories (")
1793 _T("id integer not null,")
1794 _T("name varchar(63) null,")
1795 _T("descr varchar(255) null,")
1796 _T("PRIMARY KEY(id))")));
1797 CHK_EXEC(CreateTable(
1798 _T("CREATE TABLE alarm_category_acl (")
1799 _T("category_id integer not null,")
1800 _T("user_id integer not null,")
1801 _T("PRIMARY KEY(category_id,user_id))")));
1802 CHK_EXEC(CreateTable(
1803 _T("CREATE TABLE alarm_category_map (")
1804 _T("alarm_id integer not null,")
1805 _T("category_id integer not null,")
1806 _T("PRIMARY KEY(alarm_id,category_id))")));
1807
1808 CHK_EXEC(SQLQuery(
1809 _T("ALTER TABLE alarms ADD alarm_category_ids varchar(255)")));
1810
1811 // Add view all alarms system access to user group - Everyone
1812 DB_RESULT hResult = SQLSelect(_T("SELECT system_access FROM user_groups WHERE name='Everyone'"));
1813 if (hResult != NULL)
1814 {
1815 UINT64 sysAccess = DBGetFieldUInt64(hResult, 0, 0);
1816 sysAccess = sysAccess | SYSTEM_ACCESS_VIEW_ALL_ALARMS;
1817
1818 TCHAR query[MAX_DB_STRING];
f1c7358a 1819 _sntprintf(query, MAX_DB_STRING, _T("UPDATE user_groups SET system_access=") UINT64_FMT _T(" WHERE name='Everyone'"), sysAccess);
da4b354a
VK
1820 CHK_EXEC(SQLQuery(query));
1821
f1c7358a 1822 DBFreeResult(hResult);
da4b354a
VK
1823 }
1824 else
1825 {
1826 if (!g_bIgnoreErrors)
1827 return false;
1828 }
1829
1830 CHK_EXEC(SetSchemaVersion(416));
1831 return TRUE;
1832}
1833
1834/**
1835 * Upgrade from V414 to V415
1836 */
1837static BOOL H_UpgradeFromV414(int currVersion, int newVersion)
1838{
1839 CHK_EXEC(DBRemoveNotNullConstraint(g_hCoreDB, _T("dci_summary_tables"), _T("menu_path")));
1840 CHK_EXEC(SetSchemaVersion(415));
1841 return TRUE;
1842}
1843
1844/**
1845 * Upgrade from V413 to V414
1846 */
1847static BOOL H_UpgradeFromV413(int currVersion, int newVersion)
1848{
1849 CHK_EXEC(SQLQuery(_T("UPDATE config SET var_name='EnableSyslogReceiver' WHERE var_name='EnableSyslogDaemon'")));
1850 CHK_EXEC(SetSchemaVersion(414));
1851 return TRUE;
1852}
1853
1854/**
1855 * Upgrade from V412 to V413
1856 */
1857static BOOL H_UpgradeFromV412(int currVersion, int newVersion)
1858{
1859 CHK_EXEC(SQLQuery(_T("UPDATE users SET name='system',description='Built-in system account',full_name='',flags=12 WHERE id=0")));
1860
1861 TCHAR password[128];
1862 DB_RESULT hResult = SQLSelect(_T("SELECT password FROM users WHERE id=0"));
1863 if (hResult != NULL)
1864 {
1865 if (DBGetNumRows(hResult) > 0)
1866 DBGetField(hResult, 0, 0, password, 128);
1867 else
1868 _tcscpy(password, _T("3A445C0072CD69D9030CC6644020E5C4576051B1")); // Use default password "netxms"
1869 DBFreeResult(hResult);
1870 }
1871 else
1872 {
1873 if (!g_bIgnoreErrors)
1874 return false;
1875 }
1876
1877 UINT32 userId = 1;
1878 hResult = SQLSelect(_T("SELECT max(id) FROM users"));
1879 if (hResult != NULL)
1880 {
1881 if (DBGetNumRows(hResult) > 0)
1882 userId = DBGetFieldULong(hResult, 0, 0) + 1;
1883 DBFreeResult(hResult);
1884 }
1885 else
1886 {
1887 if (!g_bIgnoreErrors)
1888 return false;
1889 }
1890
1891 uuid guid = uuid::generate();
1892 TCHAR query[1024];
1893 _sntprintf(query, 1024,
1894 _T("INSERT INTO users (id,name,password,system_access,flags,full_name,")
1895 _T(" description,grace_logins,auth_method,guid,")
1896 _T(" cert_mapping_method,cert_mapping_data,")
1897 _T(" auth_failures,last_passwd_change,min_passwd_length,")
1898 _T(" disabled_until,last_login) VALUES (%d,'admin','%s',274877906943,0,")
1899 _T(" '','Default administrator account',5,0,'%s',0,'',0,0,0,0,0)"),
1900 userId, password, (const TCHAR *)guid.toString());
1901 CHK_EXEC(SQLQuery(query));
1902
1903 for(int i = 1; i < 10; i++)
1904 {
1905 _sntprintf(query, 256, _T("INSERT INTO acl (object_id,user_id,access_rights) VALUES (%d,%d,32767)"), i, userId);
1906 CHK_EXEC(SQLQuery(query));
1907 }
1908
1909 //Add adming to Admin group if exists
1910 UINT32 groupId = 0;
1911 hResult = SQLSelect(_T("SELECT id FROM user_groups WHERE name='Admins'"));
1912 if (hResult != NULL)
1913 {
1914 if (DBGetNumRows(hResult) > 0)
1915 groupId = DBGetFieldULong(hResult, 0, 0);
1916 DBFreeResult(hResult);
1917 }
1918 else
1919 {
1920 if (!g_bIgnoreErrors)
1921 return false;
1922 }
1923 if(groupId != 0)
1924 {
1925 _sntprintf(query, 256, _T("INSERT INTO user_group_members (group_id,user_id) VALUES (%d,%d)"), groupId, userId);
1926 CHK_EXEC(SQLQuery(query));
1927 }
1928
1929 //Update non object ACL
1930 _sntprintf(query, 256, _T("UPDATE object_tools_acl SET user_id=%d WHERE user_id=0"), userId);
1931 CHK_EXEC(SQLQuery(query));
1932
1933 _sntprintf(query, 256, _T("UPDATE graph_acl SET user_id=%d WHERE user_id=0"), userId);
1934 CHK_EXEC(SQLQuery(query));
1935
1936 _sntprintf(query, 256, _T("UPDATE graphs SET owner_id=%d WHERE owner_id=0"), userId);
1937 CHK_EXEC(SQLQuery(query));
1938
1939
1940 CHK_EXEC(SetSchemaVersion(413));
1941 return TRUE;
1942}
1943
1944/**
1945 * Upgrade from V411 to V412
1946 */
1947static BOOL H_UpgradeFromV411(int currVersion, int newVersion)
1948{
1949 DB_RESULT hResult = SQLSelect(_T("SELECT id,zone_guid,agent_proxy,snmp_proxy,icmp_proxy,ssh_proxy FROM zones"));
1950 if (hResult != NULL)
1951 {
1952 CHK_EXEC(SQLQuery(_T("DROP TABLE zones")));
1953 CHK_EXEC(CreateTable(
1954 _T("CREATE TABLE zones (")
1955 _T("id integer not null,")
1956 _T("zone_guid integer not null,")
1957 _T("proxy_node integer not null,")
1958 _T("PRIMARY KEY(id))")));
1959 int count = DBGetNumRows(hResult);
1960 if (count > 0)
1961 {
1962 TCHAR query[256];
1963 for(int i = 0; i < count; i++)
1964 {
1965 UINT32 proxy = 0;
1966 for(int j = 2; (j < 6) && (proxy == 0); j++)
1967 proxy = DBGetFieldULong(hResult, i, j);
1968 _sntprintf(query, 256, _T("INSERT INTO zones (id,zone_guid,proxy_node) VALUES (%d,%d,%d)"),
1969 DBGetFieldLong(hResult, i, 0), DBGetFieldLong(hResult, i, 1), (int)proxy);
1970 CHK_EXEC(SQLQuery(query));
1971 }
1972 }
1973 DBFreeResult(hResult);
1974 }
1975 else
1976 {
1977 if (!g_bIgnoreErrors)
1978 return false;
1979 }
1980 CHK_EXEC(SetSchemaVersion(412));
1981 return TRUE;
1982}
1983
1984/**
1985 * Upgrade from V410 to V411
1986 */
1987static BOOL H_UpgradeFromV410(int currVersion, int newVersion)
1988{
1989 //check if tdata upgrade was already done, then just delete "TdataTableUpdated" metadata parameter
1990 if (!MetaDataReadInt(_T("TdataTableUpdated"), 0))
1991 {
1992 StringMap savedMetadata;
1993 DB_RESULT hResult = SQLSelect(_T("SELECT var_name,var_value FROM metadata WHERE var_name LIKE 'TDataTableCreationCommand_%' OR var_name LIKE 'TDataIndexCreationCommand_%'"));
1994 if (hResult != NULL)
1995 {
1996 int count = DBGetNumRows(hResult);
1997 for(int i = 0; i < count; i++)
1998 {
1999 savedMetadata.setPreallocated(DBGetField(hResult, i, 0, NULL, 0), DBGetField(hResult, i, 1, NULL, 0));
2000 }
2001 DBFreeResult(hResult);
2002 }
2003 else if (!g_bIgnoreErrors)
2004 {
2005 return false;
2006 }
2007
2008 static const TCHAR *batch =
2009 _T("DELETE FROM metadata WHERE var_name LIKE 'TDataTableCreationCommand_%' OR var_name LIKE 'TDataIndexCreationCommand_%'\n")
2010 _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")
2011 _T("<END>");
2012 CHK_EXEC(SQLBatch(batch));
2013
2014 if (g_dbSyntax == DB_SYNTAX_MSSQL)
2015 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)')")));
2016 else
2017 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)')")));
2018
2019 // table conversion will require multiple commits
2020 DBCommit(g_hCoreDB);
2021 if (!ConvertTDataTables())
2022 {
2023 if (!g_bIgnoreErrors)
2024 {
2025 // Restore metadata
2026 SQLQuery(_T("DELETE FROM metadata WHERE var_name LIKE 'TDataTableCreationCommand_%' OR var_name LIKE 'TDataIndexCreationCommand_%'"));
2027 StringList *keys = savedMetadata.keys();
2028 for(int i = 0; i < keys->size(); i++)
2029 {
2030 TCHAR query[4096];
2031 _sntprintf(query, 4096, _T("INSERT INTO metadata (var_name,var_value) VALUES (%s,%s)"),
2032 (const TCHAR *)DBPrepareString(g_hCoreDB, keys->get(i)),
2033 (const TCHAR *)DBPrepareString(g_hCoreDB, savedMetadata.get(keys->get(i))));
2034 SQLQuery(query);
2035 }
2036 return false;
2037 }
2038 }
2039
2040 DBBegin(g_hCoreDB);
2041 }
2042 else
2043 {
2044 CHK_EXEC(SQLQuery(_T("DELETE FROM metadata WHERE var_name='TdataTableUpdated'")));
2045 }
2046 CHK_EXEC(SetSchemaVersion(411));
2047 return TRUE;
2048}
2049
2050/**
2051 * Upgrade from V409 to V410
2052 */
2053static BOOL H_UpgradeFromV409(int currVersion, int newVersion)
2054{
2055 static const TCHAR *batch =
2056 _T("ALTER TABLE zones ADD ssh_proxy integer\n")
2057 _T("UPDATE zones SET ssh_proxy=0\n")
2058 _T("ALTER TABLE nodes ADD ssh_login varchar(63)\n")
2059 _T("ALTER TABLE nodes ADD ssh_password varchar(63)\n")
2060 _T("ALTER TABLE nodes ADD ssh_proxy integer\n")
2061 _T("UPDATE nodes SET ssh_proxy=0\n")
2062 _T("<END>");
2063 CHK_EXEC(SQLBatch(batch));
2064
2065 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("ssh_proxy")));
2066 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("zones"), _T("ssh_proxy")));
2067
2068 CHK_EXEC(SetSchemaVersion(410));
2069 return TRUE;
2070}
2071
2072/**
2073 * Upgrade from V408 to V409
2074 */
2075static BOOL H_UpgradeFromV408(int currVersion, int newVersion)
2076{
2077 static const TCHAR *batch =
2078 _T("ALTER TABLE nodes ADD node_type integer\n")
2079 _T("ALTER TABLE nodes ADD node_subtype varchar(127)\n")
2080 _T("UPDATE nodes SET node_type=0\n")
2081 _T("<END>");
2082 CHK_EXEC(SQLBatch(batch));
2083
2084 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("node_type")));
2085
2086 CHK_EXEC(SetSchemaVersion(409));
2087 return TRUE;
2088}
2089
2090/**
2091 * Upgrade from V407 to V408
2092 */
2093static BOOL H_UpgradeFromV407(int currVersion, int newVersion)
2094{
2095 CHK_EXEC(CreateTable(
2096 _T("CREATE TABLE chassis (")
2097 _T(" id integer not null,")
2098 _T(" flags integer not null,")
2099 _T(" controller_id integer not null,")
2100 _T(" rack_id integer not null,")
2101 _T(" rack_image varchar(36) null,")
2102 _T(" rack_position integer not null,")
2103 _T(" rack_height integer not null,")
2104 _T(" PRIMARY KEY(id))")
2105 ));
2106
2107 static const TCHAR *batch =
2108 _T("ALTER TABLE nodes ADD chassis_id integer\n")
2109 _T("UPDATE nodes SET chassis_id=0\n")
2110 _T("<END>");
2111 CHK_EXEC(SQLBatch(batch));
2112
2113 CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("chassis_id")));
2114
2115 CHK_EXEC(SetSchemaVersion(408));
2116 return TRUE;
2117}
2118
2119/**
2120 * Upgrade from V406 to V407
2121 */
2122static BOOL H_UpgradeFromV406(int currVersion, int newVersion)
2123{
2124 DBResizeColumn(g_hCoreDB, _T("user_groups"), _T("ldap_unique_id"), 64, true);
2125 CHK_EXEC(SetSchemaVersion(407));
2126 return TRUE;
2127}
2128
2129/**
2130 * Upgrade from V405 to V406
2131 */
2132static BOOL H_UpgradeFromV405(int currVersion, int newVersion)
2133{
2134 static const TCHAR *batch =
2135 _T("ALTER TABLE nodes ADD syslog_msg_count $SQL:INT64\n")
2136 _T("ALTER TABLE nodes ADD snmp_trap_count $SQL:INT64\n")
2137 _T("UPDATE nodes SET syslog_msg_count=0,snmp_trap_count=0\n")
2138 _T("<END>");
2139 CHK_EXEC(SQLBatch(batch));
2140 CHK_EXEC(SetSchemaVersion(406));
2141 return TRUE;
2142}
2143
2144/**
2145 * Upgrade from V404 to V405
2146 */
2147static BOOL H_UpgradeFromV404(int currVersion, int newVersion)
2148{
2149 CHK_EXEC(CreateEventTemplate(EVENT_AGENT_LOG_PROBLEM, _T("SYS_AGENT_LOG_PROBLEM"),
2150 SEVERITY_MAJOR, EF_LOG, _T("262057ca-357a-4a4d-9b78-42ae96e490a1"),
2151 _T("Problem with agent log: %2"),
2152 _T("Generated on status poll if agent reports problem with log file.\r\n")
2153 _T("Parameters:\r\n")
2154 _T(" 1) Status code\r\n")
2155 _T(" 2) Description")));
2156 CHK_EXEC(CreateEventTemplate(EVENT_AGENT_LOCAL_DATABASE_PROBLEM, _T("SYS_AGENT_LOCAL_DATABASE_PROBLEM"),
2157 SEVERITY_MAJOR, EF_LOG, _T("d02b63f1-1151-429e-adb9-1dfbb3a31b32"),
2158 _T("Problem with agent local database: %2"),
2159 _T("Generated on status poll if agent reports local database problem.\r\n")
2160 _T("Parameters:\r\n")
2161 _T(" 1) Status code\r\n")
2162 _T(" 2) Description")));
2163
2164 int ruleId = NextFreeEPPruleID();
2165 TCHAR query[1024];
2166 _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) ")
2167 _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,'')"),
2168 ruleId, EVENT_ALARM_TIMEOUT);
2169 CHK_EXEC(SQLQuery(query));
2170 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOG_PROBLEM);
2171 CHK_EXEC(SQLQuery(query));
2172
2173 ruleId = NextFreeEPPruleID();
2174 _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) ")
2175 _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,'')"),
2176 ruleId, EVENT_ALARM_TIMEOUT);
2177 CHK_EXEC(SQLQuery(query));
2178 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOCAL_DATABASE_PROBLEM);
2179 CHK_EXEC(SQLQuery(query));
2180
2181 CHK_EXEC(SetSchemaVersion(405));
2182 return TRUE;
2183}
2184
2185/**
2186 * Upgrade from V403 to V404
2187 */
2188static BOOL H_UpgradeFromV403(int currVersion, int newVersion)
2189{
2190 CHK_EXEC(CreateConfigParam(_T("SyslogIgnoreMessageTimestamp"), _T("0"),
2191 _T("Ignore timestamp received in syslog messages and always use server time"),
2192 'B', true, false, false, false));
2193 CHK_EXEC(SetSchemaVersion(404));
2194 return TRUE;
2195}
2196
2197/**
2198 * Upgrade from V402 to V403
2199 */
2200static BOOL H_UpgradeFromV402(int currVersion, int newVersion)
2201{
2202 CHK_EXEC(SQLQuery(_T("DROP TABLE policy_time_range_list")));
2203 CHK_EXEC(SQLQuery(_T("DROP TABLE time_ranges")));
2204 CHK_EXEC(SetSchemaVersion(403));
2205 return TRUE;
2206}
2207
2208/**
2209 * Upgrade from V401 to V402
2210 */
2211static BOOL H_UpgradeFromV401(int currVersion, int newVersion)
2212{
2213 CHK_EXEC(SQLQuery(_T("CREATE INDEX idx_event_log_source ON event_log(event_source)")));
2214 CHK_EXEC(SetSchemaVersion(402));
2215 return TRUE;
2216}
2217
2218/**
2219 * Upgrade from V400 to V401
2220 */
2221static BOOL H_UpgradeFromV400(int currVersion, int newVersion)
2222{
2223 CHK_EXEC(CreateEventTemplate(EVENT_LDAP_SYNC_ERROR, _T("SYS_LDAP_SYNC_ERROR"),
2224 SEVERITY_MAJOR, EF_LOG, _T("f7e8508d-1503-4736-854b-1e5b8b0ad1f2"),
2225 _T("LDAP sync error: %5"),
2226 _T("Generated when LDAP synchronization error occurs.\r\n")
2227 _T("Parameters:\r\n")
2228 _T(" 1) User ID\r\n")
2229 _T(" 2) User GUID\r\n")
2230 _T(" 3) User LDAP DN\r\n")
2231 _T(" 4) User name\r\n")
2232 _T(" 5) Problem description")));
2233
2234 int ruleId = NextFreeEPPruleID();
2235 TCHAR query[1024];
2236 _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);
2237 CHK_EXEC(SQLQuery(query));
2238 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_LDAP_SYNC_ERROR);
2239 CHK_EXEC(SQLQuery(query));
2240
2241 CHK_EXEC(SQLQuery(_T("ALTER TABLE users ADD ldap_unique_id varchar(64)")));
2242 CHK_EXEC(SQLQuery(_T("ALTER TABLE user_groups ADD ldap_unique_id varchar(64)")));
2243 CHK_EXEC(CreateConfigParam(_T("LdapUserUniqueId"), _T(""), true, false, false));
2244 CHK_EXEC(CreateConfigParam(_T("LdapGroupUniqueId"), _T(""), true, false, false));
2245
2246 CHK_EXEC(SetSchemaVersion(401));
2247 return TRUE;
2248}
2249
2250/**
2251 * Upgrade from V399 to V400
2252 */
2253static BOOL H_UpgradeFromV399(int currVersion, int newVersion)
2254{
2255 CHK_EXEC(CreateConfigParam(_T("JobRetryCount"), _T("5"), _T("Maximum mumber of job execution retrys"), 'I', true, false, false, false));
2256 CHK_EXEC(SetSchemaVersion(400));
2257 return TRUE;
2258}
2259
2260/**
2261 * Upgrade from V398 to V399
2262 */
2263static BOOL H_UpgradeFromV398(int currVersion, int newVersion)
2264{
2265 CHK_EXEC(CreateTable(
2266 _T("CREATE TABLE config_repositories (")
2267 _T(" id integer not null,")
2268 _T(" url varchar(1023) not null,")
2269 _T(" auth_token varchar(63) null,")
2270 _T(" description varchar(1023) null,")
2271 _T(" PRIMARY KEY(id))")
2272 ));
2273
2274 CHK_EXEC(SetSchemaVersion(399));
2275 return TRUE;
2276}
2277
2278/**
2279 * Upgrade from V397 to V398
2280 */
2281static BOOL H_UpgradeFromV397(int currVersion, int newVersion)
2282{
2283 CHK_EXEC(CreateTable(
2284 _T("CREATE TABLE currency_codes (")
2285 _T(" numeric_code char(3) not null,")
2286 _T(" alpha_code char(3) not null,")
2287 _T(" description varchar(127) not null,")
2288 _T(" exponent integer not null,")
2289 _T(" PRIMARY KEY(numeric_code))")
2290 ));
2291
2292 CHK_EXEC(CreateTable(
2293 _T("CREATE TABLE country_codes (")
2294 _T(" numeric_code char(3) not null,")
2295 _T(" alpha_code char(2) not null,")
2296 _T(" alpha3_code char(3) not null,")
2297 _T(" name varchar(127) not null,")
2298 _T(" PRIMARY KEY(numeric_code))")
2299 ));
2300
2301 static const TCHAR *batch1 =
2302 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('008', 'ALL', 'Lek', 2)\n")
2303 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('012', 'DZD', 'Algerian Dinar', 2)\n")
2304 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('031', 'AZM', 'Azerbaijanian Manat', 0)\n")
2305 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('032', 'ARS', 'Argentine Peso', 2)\n")
2306 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('036', 'AUD', 'Australian Dollar', 2)\n")
2307 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('044', 'BSD', 'Bahamian Dollar', 2)\n")
2308 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('048', 'BHD', 'Bahraini Dinar', 3)\n")
2309 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('050', 'BDT', 'Taka', 2)\n")
2310 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('051', 'AMD', 'Armenian Dram', 2)\n")
2311 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('052', 'BBD', 'Barbados Dollar', 2)\n")
2312 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('060', 'BMD', 'Bermudian Dollar', 2)\n")
2313 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('064', 'BTN', 'Ngultrum', 2)\n")
2314 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('068', 'BOB', 'Boliviano', 2)\n")
2315 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('072', 'BWP', 'Pula', 2)\n")
2316 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('084', 'BZD', 'Belize Dollar', 2)\n")
2317 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('090', 'SBD', 'Solomon Islands Dollar', 2)\n")
2318 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('096', 'BND', 'Brunei Dollar', 2)\n")
2319 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('100', 'BGL', 'Lev', 0)\n")
2320 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('104', 'MMK', 'Kyat', 2)\n")
2321 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('108', 'BIF', 'Burundi Franc', 0)\n")
2322 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('116', 'KHR', 'Riel', 2)\n")
2323 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('124', 'CAD', 'Canadian Dollar', 2)\n")
2324 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('132', 'CVE', 'Cape Verde Escudo', 2)\n")
2325 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('136', 'KYD', 'Cayman Islands Dollar', 2)\n")
2326 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('144', 'LKR', 'Sri Lanka Rupee', 2)\n")
2327 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('152', 'CLP', 'Chilean Peso', 0)\n")
2328 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('156', 'CNY', 'Yuan Renminbi', 2)\n")
2329 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('170', 'COP', 'Colombian Peso', 2)\n")
2330 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('174', 'KMF', 'Comoro Franc', 0)\n")
2331 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('188', 'CRC', 'Costa Rican Colon', 2)\n")
2332 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('191', 'HRK', 'Croatian Kuna', 2)\n")
2333 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('192', 'CUP', 'Cuban Peso', 2)\n")
2334 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('196', 'CYP', 'Cyprus Pound', 0)\n")
2335 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('203', 'CZK', 'Czech Koruna', 2)\n")
2336 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('208', 'DKK', 'Danish Krone', 2)\n")
2337 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('214', 'DOP', 'Dominican Peso', 2)\n")
2338 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('222', 'SVC', 'El Salvador Colon', 2)\n")
2339 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('230', 'ETB', 'Ethiopian Birr', 2)\n")
2340 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('232', 'ERN', 'Nakfa', 2)\n")
2341 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('233', 'EEK', 'Estonian Kroon', 0)\n")
2342 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('238', 'FKP', 'Falkland Islands Pound', 2)\n")
2343 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('242', 'FJD', 'Fiji Dollar', 2)\n")
2344 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('262', 'DJF', 'Djibouti Franc', 0)\n")
2345 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('270', 'GMD', 'Dalasi', 2)\n")
2346 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('288', 'GHC', 'Cedi', 0)\n")
2347 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('292', 'GIP', 'Gibraltar Pound', 2)\n")
2348 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('320', 'GTQ', 'Quetzal', 2)\n")
2349 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('324', 'GNF', 'Guinea Franc', 0)\n")
2350 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('328', 'GYD', 'Guyana Dollar', 2)\n")
2351 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('332', 'HTG', 'Gourde', 2)\n")
2352 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('340', 'HNL', 'Lempira', 2)\n")
2353 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('344', 'HKD', 'Hong Kong Dollar', 2)\n")
2354 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('348', 'HUF', 'Forint', 2)\n")
2355 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('352', 'ISK', 'Iceland Krona', 0)\n")
2356 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('356', 'INR', 'Indian Rupee', 2)\n")
2357 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('360', 'IDR', 'Rupiah', 2)\n")
2358 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('364', 'IRR', 'Iranian Rial', 2)\n")
2359 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('368', 'IQD', 'Iraqi Dinar', 3)\n")
2360 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('376', 'ILS', 'New Israeli Sheqel', 2)\n")
2361 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('388', 'JMD', 'Jamaican Dollar', 2)\n")
2362 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('392', 'JPY', 'Yen', 0)\n")
2363 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('398', 'KZT', 'Tenge', 2)\n")
2364 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('400', 'JOD', 'Jordanian Dinar', 3)\n")
2365 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('404', 'KES', 'Kenyan Shilling', 2)\n")
2366 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('408', 'KPW', 'North Korean Won', 2)\n")
2367 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('410', 'KRW', 'Won', 0)\n")
2368 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('414', 'KWD', 'Kuwaiti Dinar', 3)\n")
2369 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('417', 'KGS', 'Som', 2)\n")
2370 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('418', 'LAK', 'Kip', 2)\n")
2371 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('422', 'LBP', 'Lebanese Pound', 2)\n")
2372 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('426', 'LSL', 'Lesotho Loti', 2)\n")
2373 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('428', 'LVL', 'Latvian Lats', 2)\n")
2374 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('430', 'LRD', 'Liberian Dollar', 2)\n")
2375 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('434', 'LYD', 'Lybian Dinar', 3)\n")
2376 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('440', 'LTL', 'Lithuanian Litas', 2)\n")
2377 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('446', 'MOP', 'Pataca', 2)\n")
2378 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('450', 'MGF', 'Malagasy Franc', 0)\n")
2379 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('454', 'MWK', 'Kwacha', 2)\n")
2380 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('458', 'MYR', 'Malaysian Ringgit', 2)\n")
2381 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('462', 'MVR', 'Rufiyaa', 2)\n")
2382 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('470', 'MTL', 'Maltese Lira', 0)\n")
2383 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('478', 'MRO', 'Ouguiya', 2)\n")
2384 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('480', 'MUR', 'Mauritius Rupee', 2)\n")
2385 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('484', 'MXN', 'Mexican Peso', 2)\n")
2386 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('496', 'MNT', 'Tugrik', 2)\n")
2387 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('498', 'MDL', 'Moldovan Leu', 2)\n")
2388 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('504', 'MAD', 'Moroccan Dirham', 2)\n")
2389 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('508', 'MZM', 'Metical', 0)\n")
2390 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('512', 'OMR', 'Rial Omani', 3)\n")
2391 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('516', 'NAD', 'Namibia Dollar', 2)\n")
2392 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('524', 'NPR', 'Nepalese Rupee', 2)\n")
2393 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('532', 'ANG', 'Netherlands Antillan Guilder', 2)\n")
2394 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('533', 'AWG', 'Aruban Guilder', 2)\n")
2395 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('548', 'VUV', 'Vatu', 0)\n")
2396 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('554', 'NZD', 'New Zealand Dollar', 2)\n")
2397 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('558', 'NIO', 'Cordoba Oro', 2)\n")
2398 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('566', 'NGN', 'Naira', 2)\n")
2399 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('578', 'NOK', 'Norvegian Krone', 2)\n")
2400 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('586', 'PKR', 'Pakistan Rupee', 2)\n")
2401 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('590', 'PAB', 'Balboa', 2)\n")
2402 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('598', 'PGK', 'Kina', 2)\n")
2403 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('600', 'PYG', 'Guarani', 0)\n")
2404 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('604', 'PEN', 'Nuevo Sol', 2)\n")
2405 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('608', 'PHP', 'Philippine Peso', 2)\n")
2406 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('624', 'GWP', 'Guinea-Bissau Peso', 0)\n")
2407 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('634', 'QAR', 'Qatari Rial', 2)\n")
2408 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('642', 'ROL', 'Leu', 0)\n")
2409 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('643', 'RUB', 'Russian Ruble', 2)\n")
2410 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('646', 'RWF', 'Rwanda Franc', 0)\n")
2411 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('654', 'SHP', 'Saint Helena Pound', 2)\n")
2412 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('678', 'STD', 'Dobra', 2)\n")
2413 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('682', 'SAR', 'Saudi Riyal', 2)\n")
2414 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('690', 'SCR', 'Seychelles Rupee', 2)\n")
2415 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('694', 'SLL', 'Leone', 2)\n")
2416 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('702', 'SGD', 'Singapore Dollar', 2)\n")
2417 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('703', 'SKK', 'Slovak Koruna', 0)\n")
2418 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('704', 'VND', 'Dong', 0)\n")
2419 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('706', 'SOS', 'Somali Shilling', 2)\n")
2420 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('710', 'ZAR', 'Rand', 2)\n")
2421 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('716', 'ZWD', 'Zimbabwe Dollar', 0)\n")
2422 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('728', 'SSP', 'South Sudanese pound', 2)\n")
2423 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('740', 'SRG', 'Suriname Guilder', 0)\n")
2424 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('748', 'SZL', 'Lilangeni', 2)\n")
2425 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('752', 'SEK', 'Swedish Krona', 2)\n")
2426 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('756', 'CHF', 'Swiss Franc', 2)\n")
2427 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('760', 'SYP', 'Syrian Pound', 2)\n")
2428 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('764', 'THB', 'Baht', 2)\n")
2429 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('776', 'TOP', 'Paanga', 2)\n")
2430 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('780', 'TTD', 'Trinidad and Tobago Dollar', 2)\n")
2431 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('784', 'AED', 'UAE Dirham', 2)\n")
2432 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('788', 'TND', 'Tunisian Dinar', 3)\n")
2433 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('795', 'TMM', 'Manat', 0)\n")
2434 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('800', 'UGX', 'Uganda Shilling', 2)\n")
2435 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('807', 'MKD', 'Denar', 2)\n")
2436 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('810', 'RUR', 'Russian Ruble', 0)\n")
2437 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('818', 'EGP', 'Egyptian Pound', 2)\n")
2438 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('826', 'GBP', 'Pound Sterling', 2)\n")
2439 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('834', 'TZS', 'Tanzanian Shilling', 2)\n")
2440 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('840', 'USD', 'US Dollar', 2)\n")
2441 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('858', 'UYU', 'Peso Uruguayo', 2)\n")
2442 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('860', 'UZS', 'Uzbekistan Sum', 2)\n")
2443 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('862', 'VEB', 'Bolivar', 0)\n")
2444 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('882', 'WST', 'Tala', 2)\n")
2445 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('886', 'YER', 'Yemeni Rial', 2)\n")
2446 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('891', 'CSD', 'Serbian Dinar', 0)\n")
2447 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('894', 'ZMK', 'Kwacha', 2)\n")
2448 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('901', 'TWD', 'New Taiwan Dollar', 2)\n")
2449 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('933', 'BYN', 'Belarussian New Ruble', 2)\n")
2450 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('934', 'TMT', 'Turkmenistani Manat', 2)\n")
2451 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('937', 'VEF', 'Venezuelan Bolivar', 2)\n")
2452 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('938', 'SDG', 'Sudanese Pound', 2)\n")
2453 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('941', 'RSD', 'Serbian Dinar', 2)\n")
2454 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('943', 'MZN', 'Mozambican Metical', 2)\n")
2455 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('944', 'AZN', 'Azerbaijani Manat', 2)\n")
2456 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('946', 'RON', 'New Romanian Leu', 2)\n")
2457 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('949', 'TRY', 'New Turkish Lira', 2)\n")
2458 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('950', 'XAF', 'CFA Franc BEAC', 0)\n")
2459 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('951', 'XCD', 'East Carribbean Dollar', 2)\n")
2460 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('952', 'XOF', 'CFA Franc BCEAO', 0)\n")
2461 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('953', 'XPF', 'CFP Franc', 0)\n")
2462 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('967', 'ZMW', 'Zambian Kwacha', 2)\n")
2463 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('968', 'SRD', 'Surinamese Dollar', 2)\n")
2464 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('969', 'MGA', 'Malagasy Ariary', 2)\n")
2465 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('971', 'AFN', 'Afghani', 2)\n")
2466 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('972', 'TJS', 'Somoni', 2)\n")
2467 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('973', 'AOA', 'Kwanza', 2)\n")
2468 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('974', 'BYR', 'Belarussian Ruble', 0)\n")
2469 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('975', 'BGN', 'Bulgarian Lev', 2)\n")
2470 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('976', 'CDF', 'Franc Congolais', 2)\n")
2471 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('977', 'BAM', 'Convertible Marks', 2)\n")
2472 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('978', 'EUR', 'Euro', 2)\n")
2473 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('979', 'MXV', 'Mexican Unidad de Inversion (UDI)', 2)\n")
2474 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('980', 'UAH', 'Hryvnia', 2)\n")
2475 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('981', 'GEL', 'Lari', 2)\n")
2476 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('984', 'BOV', 'Mvdol', 2)\n")
2477 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('985', 'PLN', 'Zloty', 2)\n")
2478 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('986', 'BRL', 'Brazilian Real', 2)\n")
2479 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('990', 'CLF', 'Unidades de Fomento', 0)\n")
2480 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('997', 'USN', 'US dollar (next day funds code)', 2)\n")
2481 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('998', 'USS', 'US dollar (same day funds code)', 2)\n")
2482 _T("INSERT INTO currency_codes (numeric_code, alpha_code, description, exponent) VALUES ('999', 'XXX', 'No currency', 0)\n")
2483 _T("<END>");
2484 static const TCHAR *batch2 =
2485 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AD','AND','020','Andorra')\n")
2486 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AE','ARE','784','United Arab Emirates')\n")
2487 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AF','AFG','004','Afghanistan')\n")
2488 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AG','ATG','028','Antigua and Barbuda')\n")
2489 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AI','AIA','660','Anguilla')\n")
2490 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AL','ALB','008','Albania')\n")
2491 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AM','ARM','051','Armenia')\n")
2492 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AN','ANT','530','Netherlands Antilles')\n")
2493 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AO','AGO','024','Angola')\n")
2494 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AQ','ATA','010','Antarctica')\n")
2495 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AR','ARG','032','Argentina')\n")
2496 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AS','ASM','016','American Samoa')\n")
2497 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AT','AUT','040','Austria')\n")
2498 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AU','AUS','036','Australia')\n")
2499 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AW','ABW','533','Aruba')\n")
2500 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AX','ALA','248','Aland Islands')\n")
2501 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('AZ','AZE','031','Azerbaijan')\n")
2502 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BA','BIH','070','Bosnia and Herzegovina')\n")
2503 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BB','BRB','052','Barbados')\n")
2504 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BD','BGD','050','Bangladesh')\n")
2505 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BE','BEL','056','Belgium')\n")
2506 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BF','BFA','854','Burkina Faso')\n")
2507 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BG','BGR','100','Bulgaria')\n")
2508 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BH','BHR','048','Bahrain')\n")
2509 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BI','BDI','108','Burundi')\n")
2510 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BJ','BEN','204','Benin')\n")
2511 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BL','BLM','652','Saint-Barthelemy')\n")
2512 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BM','BMU','060','Bermuda')\n")
2513 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BN','BRN','096','Brunei Darussalam')\n")
2514 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BO','BOL','068','Bolivia')\n")
2515 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BQ','BES','535','Bonaire, Sint Eustatius and Saba')\n")
2516 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BR','BRA','076','Brazil')\n")
2517 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BS','BHS','044','Bahamas')\n")
2518 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BT','BTN','064','Bhutan')\n")
2519 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BV','BVT','074','Bouvet Island')\n")
2520 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BW','BWA','072','Botswana')\n")
2521 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BY','BLR','112','Belarus')\n")
2522 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('BZ','BLZ','084','Belize')\n")
2523 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CA','CAN','124','Canada')\n")
2524 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CC','CCK','166','Cocos (Keeling) Islands')\n")
2525 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CD','COD','180','Congo, Democratic Republic of the')\n")
2526 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CF','CAF','140','Central African Republic')\n")
2527 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CG','COG','178','Congo (Brazzaville)')\n")
2528 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CH','CHE','756','Switzerland')\n")
2529 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CI','CIV','384','Cote d''Ivoire')\n")
2530 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CK','COK','184','Cook Islands')\n")
2531 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CL','CHL','152','Chile')\n")
2532 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CM','CMR','120','Cameroon')\n")
2533 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CN','CHN','156','China')\n")
2534 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CO','COL','170','Colombia')\n")
2535 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CR','CRI','188','Costa Rica')\n")
2536 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CU','CUB','192','Cuba')\n")
2537 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CV','CPV','132','Cape Verde')\n")
2538 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CW','CUW','531','Curacao')\n")
2539 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CX','CXR','162','Christmas Island')\n")
2540 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CY','CYP','196','Cyprus')\n")
2541 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('CZ','CZE','203','Czech Republic')\n")
2542 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DE','DEU','276','Germany')\n")
2543 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DJ','DJI','262','Djibouti')\n")
2544 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DK','DNK','208','Denmark')\n")
2545 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DM','DMA','212','Dominica')\n")
2546 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DO','DOM','214','Dominican Republic')\n")
2547 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('DZ','DZA','012','Algeria')\n")
2548 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('EC','ECU','218','Ecuador')\n")
2549 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('EE','EST','233','Estonia')\n")
2550 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('EG','EGY','818','Egypt')\n")
2551 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('EH','ESH','732','Western Sahara')\n")
2552 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ER','ERI','232','Eritrea')\n")
2553 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ES','ESP','724','Spain')\n")
2554 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ET','ETH','231','Ethiopia')\n")
2555 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FI','FIN','246','Finland')\n")
2556 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FJ','FJI','242','Fiji')\n")
2557 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FK','FLK','238','Falkland Islands (Malvinas)')\n")
2558 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FM','FSM','583','Micronesia, Federated States of')\n")
2559 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FO','FRO','234','Faroe Islands')\n")
2560 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('FR','FRA','250','France')\n")
2561 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GA','GAB','266','Gabon')\n")
2562 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GB','GBR','826','United Kingdom')\n")
2563 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GD','GRD','308','Grenada')\n")
2564 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GE','GEO','268','Georgia')\n")
2565 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GF','GUF','254','French Guiana')\n")
2566 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GG','GGY','831','Guernsey')\n")
2567 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GH','GHA','288','Ghana')\n")
2568 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GI','GIB','292','Gibraltar')\n")
2569 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GL','GRL','304','Greenland')\n")
2570 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GM','GMB','270','Gambia')\n")
2571 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GN','GIN','324','Guinea')\n")
2572 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GP','GLP','312','Guadeloupe')\n")
2573 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GQ','GNQ','226','Equatorial Guinea')\n")
2574 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GR','GRC','300','Greece')\n")
2575 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GS','SGS','239','South Georgia and the South Sandwich Islands')\n")
2576 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GT','GTM','320','Guatemala')\n")
2577 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GU','GUM','316','Guam')\n")
2578 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GW','GNB','624','Guinea-Bissau')\n")
2579 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('GY','GUY','328','Guyana')\n")
2580 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HK','HKG','344','Hong Kong, Special Administrative Region of China')\n")
2581 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HM','HMD','334','Heard Island and Mcdonald Islands')\n")
2582 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HN','HND','340','Honduras')\n")
2583 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HR','HRV','191','Croatia')\n")
2584 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HT','HTI','332','Haiti')\n")
2585 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('HU','HUN','348','Hungary')\n")
2586 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ID','IDN','360','Indonesia')\n")
2587 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IE','IRL','372','Ireland')\n")
2588 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IL','ISR','376','Israel')\n")
2589 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IM','IMN','833','Isle of Man')\n")
2590 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IN','IND','356','India')\n")
2591 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IO','IOT','086','British Indian Ocean Territory')\n")
2592 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IQ','IRQ','368','Iraq')\n")
2593 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IR','IRN','364','Iran, Islamic Republic of')\n")
2594 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IS','ISL','352','Iceland')\n")
2595 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('IT','ITA','380','Italy')\n")
2596 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('JE','JEY','832','Jersey')\n")
2597 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('JM','JAM','388','Jamaica')\n")
2598 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('JO','JOR','400','Jordan')\n")
2599 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('JP','JPN','392','Japan')\n")
2600 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KE','KEN','404','Kenya')\n")
2601 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KG','KGZ','417','Kyrgyzstan')\n")
2602 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KH','KHM','116','Cambodia')\n")
2603 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KI','KIR','296','Kiribati')\n")
2604 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KM','COM','174','Comoros')\n")
2605 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KN','KNA','659','Saint Kitts and Nevis')\n")
2606 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KP','PRK','408','Korea, Democratic People''s Republic of')\n")
2607 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KR','KOR','410','Korea, Republic of')\n")
2608 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KW','KWT','414','Kuwait')\n")
2609 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KY','CYM','136','Cayman Islands')\n")
2610 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('KZ','KAZ','398','Kazakhstan')\n")
2611 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LA','LAO','418','Lao PDR')\n")
2612 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LB','LBN','422','Lebanon')\n")
2613 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LC','LCA','662','Saint Lucia')\n")
2614 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LI','LIE','438','Liechtenstein')\n")
2615 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LK','LKA','144','Sri Lanka')\n")
2616 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LR','LBR','430','Liberia')\n")
2617 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LS','LSO','426','Lesotho')\n")
2618 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LT','LTU','440','Lithuania')\n")
2619 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LU','LUX','442','Luxembourg')\n")
2620 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LV','LVA','428','Latvia')\n")
2621 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('LY','LBY','434','Libya')\n")
2622 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MA','MAR','504','Morocco')\n")
2623 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MC','MCO','492','Monaco')\n")
2624 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MD','MDA','498','Moldova')\n")
2625 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ME','MNE','499','Montenegro')\n")
2626 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MF','MAF','663','Saint-Martin (French part)')\n")
2627 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MG','MDG','450','Madagascar')\n")
2628 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MH','MHL','584','Marshall Islands')\n")
2629 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MK','MKD','807','Macedonia, Republic of')\n")
2630 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ML','MLI','466','Mali')\n")
2631 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MM','MMR','104','Myanmar')\n")
2632 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MN','MNG','496','Mongolia')\n")
2633 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MO','MAC','446','Macao, Special Administrative Region of China')\n")
2634 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MP','MNP','580','Northern Mariana Islands')\n")
2635 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MQ','MTQ','474','Martinique')\n")
2636 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MR','MRT','478','Mauritania')\n")
2637 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MS','MSR','500','Montserrat')\n")
2638 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MT','MLT','470','Malta')\n")
2639 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MU','MUS','480','Mauritius')\n")
2640 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MV','MDV','462','Maldives')\n")
2641 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MW','MWI','454','Malawi')\n")
2642 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MX','MEX','484','Mexico')\n")
2643 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MY','MYS','458','Malaysia')\n")
2644 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('MZ','MOZ','508','Mozambique')\n")
2645 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NA','NAM','516','Namibia')\n")
2646 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NC','NCL','540','New Caledonia')\n")
2647 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NE','NER','562','Niger')\n")
2648 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NF','NFK','574','Norfolk Island')\n")
2649 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NG','NGA','566','Nigeria')\n")
2650 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NI','NIC','558','Nicaragua')\n")
2651 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NL','NLD','528','Netherlands')\n")
2652 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NO','NOR','578','Norway')\n")
2653 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NP','NPL','524','Nepal')\n")
2654 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NR','NRU','520','Nauru')\n")
2655 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NU','NIU','570','Niue')\n")
2656 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('NZ','NZL','554','New Zealand')\n")
2657 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('OM','OMN','512','Oman')\n")
2658 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PA','PAN','591','Panama')\n")
2659 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PE','PER','604','Peru')\n")
2660 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PF','PYF','258','French Polynesia')\n")
2661 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PG','PNG','598','Papua New Guinea')\n")
2662 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PH','PHL','608','Philippines')\n")
2663 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PK','PAK','586','Pakistan')\n")
2664 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PL','POL','616','Poland')\n")
2665 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PM','SPM','666','Saint Pierre and Miquelon')\n")
2666 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PN','PCN','612','Pitcairn')\n")
2667 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PR','PRI','630','Puerto Rico')\n")
2668 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PS','PSE','275','Palestinian Territory, Occupied')\n")
2669 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PT','PRT','620','Portugal')\n")
2670 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PW','PLW','585','Palau')\n")
2671 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('PY','PRY','600','Paraguay')\n")
2672 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('QA','QAT','634','Qatar')\n")
2673 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RE','REU','638','Reunion')\n")
2674 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RO','ROU','642','Romania')\n")
2675 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RS','SRB','688','Serbia')\n")
2676 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RU','RUS','643','Russian Federation')\n")
2677 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('RW','RWA','646','Rwanda')\n")
2678 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SA','SAU','682','Saudi Arabia')\n")
2679 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SB','SLB','090','Solomon Islands')\n")
2680 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SC','SYC','690','Seychelles')\n")
2681 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SD','SDN','729','Sudan')\n")
2682 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SE','SWE','752','Sweden')\n")
2683 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SG','SGP','702','Singapore')\n")
2684 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SH','SHN','654','Saint Helena')\n")
2685 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SI','SVN','705','Slovenia')\n")
2686 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SJ','SJM','744','Svalbard and Jan Mayen Islands')\n")
2687 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SK','SVK','703','Slovakia')\n")
2688 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SL','SLE','694','Sierra Leone')\n")
2689 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SM','SMR','674','San Marino')\n")
2690 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SN','SEN','686','Senegal')\n")
2691 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SO','SOM','706','Somalia')\n")
2692 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SR','SUR','740','Suriname')\n")
2693 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SS','SSD','728','South Sudan')\n")
2694 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ST','STP','678','Sao Tome and Principe')\n")
2695 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SV','SLV','222','El Salvador')\n")
2696 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SX','SXM','534','Sint Maarten (Dutch part)')\n")
2697 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SY','SYR','760','Syrian Arab Republic (Syria)')\n")
2698 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('SZ','SWZ','748','Swaziland')\n")
2699 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TC','TCA','796','Turks and Caicos Islands')\n")
2700 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TD','TCD','148','Chad')\n")
2701 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TF','ATF','260','French Southern Territories')\n")
2702 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TG','TGO','768','Togo')\n")
2703 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TH','THA','764','Thailand')\n")
2704 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TJ','TJK','762','Tajikistan')\n")
2705 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TK','TKL','772','Tokelau')\n")
2706 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TL','TLS','626','Timor-Leste')\n")
2707 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TM','TKM','795','Turkmenistan')\n")
2708 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TN','TUN','788','Tunisia')\n")
2709 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TO','TON','776','Tonga')\n")
2710 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TR','TUR','792','Turkey')\n")
2711 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TT','TTO','780','Trinidad and Tobago')\n")
2712 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TV','TUV','798','Tuvalu')\n")
2713 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TW','TWN','158','Taiwan')\n")
2714 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('TZ','TZA','834','Tanzania')\n")
2715 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('UA','UKR','804','Ukraine')\n")
2716 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('UG','UGA','800','Uganda')\n")
2717 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('UM','UMI','581','United States Minor Outlying Islands')\n")
2718 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('US','USA','840','United States of America')\n")
2719 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('UY','URY','858','Uruguay')\n")
2720 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('UZ','UZB','860','Uzbekistan')\n")
2721 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('VA','VAT','336','Holy See (Vatican City State)')\n")
2722 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('VC','VCT','670','Saint Vincent and Grenadines')\n")
2723 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('VE','VEN','862','Venezuela')\n")
2724 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('VG','VGB','092','British Virgin Islands')\n")
2725 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('VI','VIR','850','Virgin Islands, US')\n")
2726 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('VN','VNM','704','Viet Nam')\n")
2727 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('VU','VUT','548','Vanuatu')\n")
2728 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('WF','WLF','876','Wallis and Futuna Islands')\n")
2729 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('WS','WSM','882','Samoa')\n")
2730 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('YE','YEM','887','Yemen')\n")
2731 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('YT','MYT','175','Mayotte')\n")
2732 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ZA','ZAF','710','South Africa')\n")
2733 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ZM','ZMB','894','Zambia')\n")
2734 _T("INSERT INTO country_codes (alpha_code,alpha3_code,numeric_code,name) VALUES ('ZW','ZWE','716','Zimbabwe')\n")
2735 _T("<END>");
2736 CHK_EXEC(SQLBatch(batch1));
2737 CHK_EXEC(SQLBatch(batch2));
2738
2739 CHK_EXEC(SetSchemaVersion(398));
2740 return TRUE;
2741}
2742
2743/**
2744 * Upgrade from V396 to V397
2745 */
2746static BOOL H_UpgradeFromV396(int currVersion, int newVersion)
2747{
2748 static GUID_MAPPING eventGuidMapping[] = {
2749 { EVENT_NODE_ADDED, _T("8d34acfd-dad6-4f6e-b6a8-1189683591ef") },
2750 { EVENT_SUBNET_ADDED, _T("75fc3f8b-768f-46b4-bf44-72949436a679") },
2751 { EVENT_INTERFACE_ADDED, _T("33cb8f9c-9427-459c-8a71-45c73f5cc183") },
2752 { EVENT_INTERFACE_UP, _T("09ee209a-0e75-434f-b8c8-399d93305d7b") },
2753 { EVENT_INTERFACE_DOWN, _T("d9a6d46d-97f8-48eb-a86a-2c0f6b150d0d") },
2754 { EVENT_INTERFACE_UNKNOWN, _T("ecb47be1-f911-4c1f-9b00-d0d21694071d") },
2755 { EVENT_INTERFACE_DISABLED, _T("2f3123a2-425f-47db-9c6b-9bc05a7fba2d") },
2756 { EVENT_INTERFACE_TESTING, _T("eb500e5c-3560-4394-8f5f-80aa67036f13") },
2757 { EVENT_INTERFACE_UNEXPECTED_UP, _T("ff21a165-9253-4ecc-929a-ffd1e388d504") },
2758 { EVENT_INTERFACE_EXPECTED_DOWN, _T("911358f4-d2a1-4465-94d7-ce4bc5c38860") },
2759 { EVENT_NODE_NORMAL, _T("03bc11c0-ec20-43be-be45-e60846f744dc") },
2760 { EVENT_NODE_WARNING, _T("1c80deab-aafb-43a7-93a7-1330dd563b47") },
2761 { EVENT_NODE_MINOR, _T("84eaea00-4ed7-41eb-9079-b783e5c60651") },
2762 { EVENT_NODE_MAJOR, _T("27035c88-c27a-4c16-97b3-4658d34a5f63") },
2763 { EVENT_NODE_CRITICAL, _T("8f2e98f8-1cd4-4e12-b41f-48b5c60ebe8e") },
2764 { EVENT_NODE_UNKNOWN, _T("6933cce0-fe1f-4123-817f-af1fb9f0eab4") },
2765 { EVENT_NODE_UNMANAGED, _T("a8356ba7-51b7-4487-b74e-d12132db233c") },
2766 { EVENT_NODE_CAPABILITIES_CHANGED, _T("b04e39f5-d3a7-4d9a-b594-37132f5eaf34") },
2767 { EVENT_SNMP_FAIL, _T("d2fc3b0c-1215-4a92-b8f3-47df5d753602") },
2768 { EVENT_AGENT_FAIL, _T("ba484457-3594-418e-a72a-65336055d025") },
2769 { EVENT_INTERFACE_DELETED, _T("ad7e9856-e361-4095-9361-ccc462d93624") },
2770 { EVENT_THRESHOLD_REACHED, _T("05161c3d-7ceb-406f-af0a-af5c77f324a5") },
2771 { EVENT_THRESHOLD_REARMED, _T("25eef3a7-6158-4c5e-b4e3-8a7aa7ade73c") },
2772 { EVENT_SUBNET_DELETED, _T("af188eb3-e84f-4fd9-aecf-f1ba934a9f1a") },
2773 { EVENT_THREAD_HANGS, _T("df247d13-a63a-43fe-bb02-cb41718ee387") },
2774 { EVENT_THREAD_RUNNING, _T("5589f6ce-7133-44db-8e7a-e1452d636a9a") },
2775 { EVENT_SMTP_FAILURE, _T("1e376009-0d26-4b86-87a2-f4715a02fb38") },
2776 { EVENT_MAC_ADDR_CHANGED, _T("61916ef0-1eee-4df7-a95b-150928d47962") },
2777 { EVENT_INCORRECT_NETMASK, _T("86c08c55-416e-4ac4-bf2b-302b5fddbd68") },
2778 { EVENT_NODE_DOWN, _T("ce34f0d0-5b21-48c2-8788-8ed5ee547023") },
2779 { EVENT_NODE_UP, _T("05f180b6-62e7-4bc4-8a8d-34540214254b") },
2780 { EVENT_SERVICE_DOWN, _T("89caacb5-d2cf-493b-862f-cddbfecac5b6") },
2781 { EVENT_SERVICE_UP, _T("ab35e7c7-2428-44db-ad43-57fe551bb8cc") },
2782 { EVENT_SERVICE_UNKNOWN, _T("d891adae-49fe-4442-a8f3-0ca37ca8820a") },
2783 { EVENT_SMS_FAILURE, _T("c349bf75-458a-4d43-9c27-f71ea4bb06e2") },
2784 { EVENT_SNMP_OK, _T("a821086b-1595-40db-9148-8d770d30a54b") },
2785 { EVENT_AGENT_OK, _T("9c15299a-f2e3-4440-84c5-b17dea87ae2a") },
2786 { EVENT_SCRIPT_ERROR, _T("2cc78efe-357a-4278-932f-91e36754c775") },
2787 { EVENT_CONDITION_ACTIVATED, _T("16a86780-b73a-4601-929c-0c503bd06401") },
2788 { EVENT_CONDITION_DEACTIVATED, _T("926d15d2-9761-4bb6-a1ce-64175303796f") },
2789 { EVENT_DB_CONNECTION_LOST, _T("0311e9c8-8dcf-4a5b-9036-8cff034409ff") },
2790 { EVENT_DB_CONNECTION_RESTORED, _T("d36259a7-5f6b-4e3c-bb6f-17d1f8ac950d") },
2791 { EVENT_CLUSTER_RESOURCE_MOVED, _T("44abe5f3-a7c9-4fbd-8d10-53be172eae83") },
2792 { EVENT_CLUSTER_RESOURCE_DOWN, _T("c3b1d4b5-2e41-4a2f-b379-9d74ebba3a25") },
2793 { EVENT_CLUSTER_RESOURCE_UP, _T("ef6fff96-0cbb-4030-aeba-2473a80c6568") },
2794 { EVENT_CLUSTER_DOWN, _T("8f14d0f7-08d4-4422-92f4-469e5eef93ef") },
2795 { EVENT_CLUSTER_UP, _T("4a9cdb65-aa44-42f2-99b0-1e302aec10f6") },
2796 { EVENT_ALARM_TIMEOUT, _T("4ae4f601-327b-4ef8-9740-8600a1ba2acd") },
2797 { EVENT_LOG_RECORD_MATCHED, _T("d9326159-5c60-410f-990e-fae88df7fdd4") },
2798 { EVENT_EVENT_STORM_DETECTED, _T("c98d8575-d134-4044-ba67-75c5f5d0f6e0") },
2799 { EVENT_EVENT_STORM_ENDED, _T("dfd5e3ba-3182-4deb-bc32-9e6b8c1c6546") },
2800 { EVENT_NETWORK_CONNECTION_LOST, _T("3cb0921a-87a1-46e4-8be1-82ad2dda0015") },
2801 { EVENT_NETWORK_CONNECTION_RESTORED, _T("1c61b3e0-389a-47ac-8469-932a907392bc") },
2802 { EVENT_DB_QUERY_FAILED, _T("5f35d646-63b6-4dcd-b94a-e2ccd060686a") },
2803 { EVENT_DCI_UNSUPPORTED, _T("28367b5b-1541-4526-8cbe-91a17ed31ba4") },
2804 { EVENT_DCI_DISABLED, _T("50196042-0619-4420-9471-16b7c25c0213") },
2805 { EVENT_DCI_ACTIVE, _T("740b6810-b355-46f4-a921-65118504af18") },
2806 { EVENT_IP_ADDRESS_CHANGED, _T("517b6d2a-f5c6-46aa-969d-48e62e05e3bf") },
2807 { EVENT_CONTAINER_AUTOBIND, _T("611133e2-1f76-446f-b278-9d500a823611") },
2808 { EVENT_CONTAINER_AUTOUNBIND, _T("e57603be-0d81-41aa-b07c-12d08640561c") },
2809 { EVENT_TEMPLATE_AUTOAPPLY, _T("bf084945-f928-4428-8c6c-d2965addc832") },
2810 { EVENT_TEMPLATE_AUTOREMOVE, _T("8f7a4b4a-d0a2-4404-9b66-fdbc029f42cf") },
2811 { EVENT_NODE_UNREACHABLE, _T("47bba2ce-c795-4e56-ad44-cbf05741e1ff") },
2812 { EVENT_TABLE_THRESHOLD_ACTIVATED, _T("c08a1cfe-3128-40c2-99cc-378e7ef91f79") },
2813 { EVENT_TABLE_THRESHOLD_DEACTIVATED, _T("479085e7-e1d1-4f2a-9d96-1d522f51b26a") },
2814 { EVENT_IF_PEER_CHANGED, _T("a3a5c1df-9d96-4e98-9e06-b3157dbf39f0") },
2815 { EVENT_AP_ADOPTED, _T("5aaee261-0c5d-44e0-b2f0-223bbba5297d") },
2816 { EVENT_AP_UNADOPTED, _T("846a3581-aad1-4e17-9c55-9bd2e6b1247b") },
2817 { EVENT_AP_DOWN, _T("2c8c6208-d3ab-4b8c-926a-872f4d8abcee") },
2818 { EVENT_IF_MASK_CHANGED, _T("f800e593-057e-4aec-9e47-be0f7718c5c4") },
2819 { EVENT_IF_IPADDR_ADDED, _T("475bdca6-543e-410b-9aff-c217599e0fe6") },
2820 { EVENT_IF_IPADDR_DELETED, _T("ef477387-eb50-4a1a-bf90-717502b9873c") },
2821 { EVENT_MAINTENANCE_MODE_ENTERED, _T("5f6c8b1c-f162-413e-8028-80e7ad2c362d") },
2822 { EVENT_MAINTENANCE_MODE_LEFT, _T("cab06848-a622-430d-8b4c-addeea732657") },
2823 { EVENT_SNMP_UNMATCHED_TRAP, _T("fc3613f7-d151-4221-9acd-d28b6f804335") },
2824 { EVENT_SNMP_COLD_START, _T("39920e99-97bd-4d61-a462-43f89ba6fbdf") },
2825 { EVENT_SNMP_WARM_START, _T("0aa888c1-eba6-4fe7-a37a-b85f2b373bdc") },
2826 { EVENT_SNMP_LINK_DOWN, _T("b71338cc-137d-473c-a0f1-6b131086af56") },
2827 { EVENT_SNMP_LINK_UP, _T("03da14a7-e39c-4a46-a7cb-4bf77ec7936c") },
2828 { EVENT_SNMP_AUTH_FAILURE, _T("37020cb0-dde7-487b-9cfb-0d5ee771aa13") },
2829 { EVENT_SNMP_EGP_NL, _T("aecf5fa4-390c-4125-be10-df8b0e669fe1") },
2830 { 0, NULL }
2831 };
2832
2833 CHK_EXEC(SQLQuery(_T("ALTER TABLE event_cfg ADD guid varchar(36)")));
2834 CHK_EXEC(GenerateGUID(_T("event_cfg"), _T("event_code"), _T("guid"), eventGuidMapping));
2835 CHK_EXEC(SetSchemaVersion(397));
2836 return TRUE;
2837}
2838
2839/**
2840 * Upgrade from V395 to V396
2841 */
2842static BOOL H_UpgradeFromV395(int currVersion, int newVersion)
2843{
2844 CHK_EXEC(CreateTable(
2845 _T("CREATE TABLE ap_log_parser (")
2846 _T(" policy_id integer not null,")
2847 _T(" file_content $SQL:TEXT null,")
2848 _T(" PRIMARY KEY(policy_id))")));
2849
2850 CHK_EXEC(SetSchemaVersion(396));
2851 return TRUE;
2852}
2853
2854/**
2855 * Upgrade from V394 to V395
2856 */
2857static BOOL H_UpgradeFromV394(int currVersion, int newVersion)
2858{
2859 CHK_EXEC(SQLQuery(_T("UPDATE config SET need_server_restart='1' WHERE var_name='OfflineDataRelevanceTime'")));
2860 CHK_EXEC(SetSchemaVersion(395));
2861 return TRUE;
2862}
2863
2864/**
2865 * Upgrade from V393 to V394
2866 */
2867static BOOL H_UpgradeFromV393(int currVersion, int newVersion)
2868{
2869 CHK_EXEC(CreateConfigParam(_T("OfflineDataRelevanceTime"), _T("86400"), _T("Time period in seconds within which received offline data still relevant for threshold validation"), 'I', true, false, false, false));
2870 CHK_EXEC(SetSchemaVersion(394));
2871 return TRUE;
2872}
2873
2874/**
2875 * Upgrade from V392 to V393
2876 */
2877static BOOL H_UpgradeFromV392(int currVersion, int newVersion)
2878{
2879 CHK_EXEC(CreateConfigParam(_T("DefaultInterfaceExpectedState"), _T("0"), _T("Default expected state for new interface objects"), 'C', true, false, false, false));
2880 CHK_EXEC(SetSchemaVersion(393));
2881 return TRUE;
2882}
2883
2884/**
2885 * Upgrade from V391 to V392
2886 */
2887static BOOL H_UpgradeFromV391(int currVersion, int newVersion)
2888{
2889 CHK_EXEC(CreateConfigParam(_T("ImportConfigurationOnStartup"), _T("0"), _T("Import configuration from local files on server startup"), 'B', true, true, false, false));
2890 CHK_EXEC(SetSchemaVersion(392));
2891 return TRUE;
2892}
2893
2894/**
2895 * Upgrade from V390 to V391
2896 */
2897static BOOL H_UpgradeFromV390(int currVersion, int newVersion)
2898{
2899 CHK_EXEC(CreateTable(
2900 _T("CREATE TABLE zmq_subscription (")
2901 _T(" object_id integer not null,")
2902 _T(" subscription_type char(1) not null,")
2903 _T(" ignore_items integer not null,")
2904 _T(" items $SQL:TEXT,")
2905 _T(" PRIMARY KEY(object_id, subscription_type))")));
2906
2907 CHK_EXEC(SetSchemaVersion(391));
2908 return TRUE;
2909}
2910
2911/**
2912 * Upgrade from V389 to V390
2913 */
2914static BOOL H_UpgradeFromV389(int currVersion, int newVersion)
2915{
2916 CHK_EXEC(CreateTable(
2917 _T("CREATE TABLE object_containers (")
2918 _T(" id integer not null,")
2919 _T(" object_class integer not null,")
2920 _T(" flags integer not null,")
2921 _T(" auto_bind_filter $SQL:TEXT null,")
2922 _T(" PRIMARY KEY(id))")));
2923
2924 DB_RESULT hResult = SQLSelect(_T("SELECT id,object_class,flags,auto_bind_filter FROM containers"));
2925 if (hResult != NULL)
2926 {
2927 int count = DBGetNumRows(hResult);
2928 if (count > 0)
2929 {
2930 DB_STATEMENT hStmt = DBPrepare(g_hCoreDB, _T("INSERT INTO object_containers (id,object_class,flags,auto_bind_filter) VALUES (?,?,?,?)"));
2931 if (hStmt != NULL)
2932 {
2933 for(int i = 0; i < count; i++)
2934 {
2935 DBBind(hStmt, 1, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 0));
2936 DBBind(hStmt, 2, DB_SQLTYPE_INTEGER, DBGetFieldLong(hResult, i, 1));
2937 DBBind(hStmt, 3, DB_SQLTYPE_INTEGER, DBGetFieldULong(hResult, i, 2));
2938 DBBind(hStmt, 4, DB_SQLTYPE_TEXT, DBGetField(hResult, i, 3, NULL, 0), DB_BIND_DYNAMIC);
2939 if (!SQLExecute(hStmt))
2940 {
2941 if (!g_bIgnoreErrors)
2942 {
2943 DBFreeStatement(hStmt);
2944 DBFreeResult(hResult);
2945 return FALSE;
2946 }
2947 }
2948 }
2949 DBFreeStatement(hStmt);
2950 }
2951 else if (!g_bIgnoreErrors)
2952 {
2953 DBFreeResult(hResult);
2954 return FALSE;
2955 }
2956 }
2957 DBFreeResult(hResult);
2958 }
2959 else
2960 {
2961 if (!g_bIgnoreErrors)
2962 return FALSE;
2963 }
2964
2965 CHK_EXEC(SQLQuery(_T("DROP TABLE containers")));
2966 CHK_EXEC(SQLQuery(_T("DROP TABLE container_categories")));
2967 CHK_EXEC(SetSchemaVersion(390));
2968 return TRUE;
2969}
2970
2971/**
2972 * Upgrade from V388 to V389
2973 */
2974static BOOL H_UpgradeFromV388(int currVersion, int newVersion)
2975{
2976 static TCHAR batch[] =
2977 _T("ALTER TABLE racks ADD top_bottom_num char(1)\n")
2978 _T("UPDATE racks SET top_bottom_num='0'\n")
2979 _T("<END>");
2980 CHK_EXEC(SQLBatch(batch));
2981 CHK_EXEC(SetSchemaVersion(389));
2982 return TRUE;
2983}
2984
2985/**
2986 * Upgrade from V387 to V388
2987 */
2988static BOOL H_UpgradeFromV387(int currVersion, int newVersion)
2989{
2990 static TCHAR batch[] =
2991 _T("ALTER TABLE alarms ADD dci_id integer\n")
2992 _T("UPDATE alarms SET dci_id=0\n")
2993 _T("ALTER TABLE event_log ADD dci_id integer\n")
2994 _T("UPDATE event_log SET dci_id=0\n")
2995 _T("<END>");
2996 CHK_EXEC(SQLBatch(batch));
2997 CHK_EXEC(SetSchemaVersion(388));
2998 return TRUE;
2999}
3000
3001/**
3002 * Upgrade from V386 to V387
3003 */
3004static BOOL H_UpgradeFromV386(int currVersion, int newVersion)
3005{
3006 DB_RESULT hResult = SQLSelect(_T("SELECT id,flags,filter FROM network_maps WHERE filter IS NOT NULL"));
3007 if (hResult != NULL)
3008 {
3009 int count = DBGetNumRows(hResult);
3010 for(int i = 0; i < count; i++)
3011 {
3012 TCHAR *filter = DBGetField(hResult, i, 2, NULL, 0);
3013 if ((filter != NULL) && (filter[0] != 0))
3014 {
3015 TCHAR query[256];
3016 _sntprintf(query, 256, _T("UPDATE network_maps SET flags=%d WHERE id=%d"),
3017 DBGetFieldULong(hResult, i, 1) | MF_FILTER_OBJECTS, DBGetFieldULong(hResult, i, 0));
3018 CHK_EXEC(SQLQuery(query));
3019 }
3020 free(filter);
3021 }
3022 DBFreeResult(hResult);
3023 }
3024 else
3025 {
3026 if (!g_bIgnoreErrors)
3027 return FALSE;
3028 }
3029 CHK_EXEC(SetSchemaVersion(387));
3030 return TRUE;
3031}
3032
3033/**
3034 * Upgrade from V385 to V386
3035 */
3036static BOOL H_UpgradeFromV385(int currVersion, int newVersion)
3037{
3038 TCHAR query[1024];
3039 int ruleId = NextFreeEPPruleID();
3040
3041 if (!IsEventPairInUse(EVENT_THREAD_HANGS, EVENT_THREAD_RUNNING))
3042 {
3043 _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,'ea1dee96-b42e-499c-a992-0b0f9e4874b9',7944,'Generate an alarm when one of the system threads hangs or stops unexpectedly','%%m',5,'SYS_THREAD_HANG_%%1','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
3044 CHK_EXEC(SQLQuery(query));
3045 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_THREAD_HANGS);
3046 CHK_EXEC(SQLQuery(query));
3047 ruleId++;
3048 _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,'f0c5a6b2-7427-45e5-8333-7d60d2b408e6',7944,'Terminate the alarm when one of the system threads which previously hanged or stopped unexpectedly returned to the running state','%%m',6,'SYS_THREAD_HANG_%%1','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
3049 CHK_EXEC(SQLQuery(query));
3050 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_THREAD_RUNNING);
3051 CHK_EXEC(SQLQuery(query));
3052 ruleId++;
3053 }
3054
3055 if (!IsEventPairInUse(EVENT_MAINTENANCE_MODE_ENTERED, EVENT_MAINTENANCE_MODE_LEFT))
3056 {
3057 _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,'ed3397a8-a496-4534-839b-5a6fc77c167c',7944,'Generate an alarm when the object enters the maintenance mode','%%m',5,'MAINTENANCE_MODE_%%i','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
3058 CHK_EXEC(SQLQuery(query));
3059 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_MAINTENANCE_MODE_ENTERED);
3060 CHK_EXEC(SQLQuery(query));
3061 ruleId++;
3062 _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,'20a0f4a5-d90e-4961-ba88-a65b9ee45d07',7944,'Terminate the alarm when the object leaves the maintenance mode','%%m',6,'MAINTENANCE_MODE_%%i','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
3063 CHK_EXEC(SQLQuery(query));
3064 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_MAINTENANCE_MODE_LEFT);
3065 CHK_EXEC(SQLQuery(query));
3066 ruleId++;
3067 }
3068
3069 if (!IsEventPairInUse(EVENT_AGENT_FAIL, EVENT_AGENT_OK))
3070 {
3071 _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,'c6f66840-4758-420f-a27d-7bbf7b66a511',7944,'Generate an alarm if the NetXMS agent on the node stops responding','%%m',5,'AGENT_UNREACHABLE_%%i','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
3072 CHK_EXEC(SQLQuery(query));
3073 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_FAIL);
3074 CHK_EXEC(SQLQuery(query));
3075 ruleId++;
3076 _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,'9fa60260-c2ec-4371-b4e4-f5346b1d8400',7944,'Terminate the alarm if the NetXMS agent on the node start responding again','%%m',6,'AGENT_UNREACHABLE_%%i','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
3077 CHK_EXEC(SQLQuery(query));
3078 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_OK);
3079 CHK_EXEC(SQLQuery(query));
3080 ruleId++;
3081 }
3082
3083 if (!IsEventPairInUse(EVENT_SNMP_FAIL, EVENT_SNMP_OK))
3084 {
3085 _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,'20ef861f-b8e4-4e04-898e-e57d13863661',7944,'Generate an alarm if the SNMP agent on the node stops responding','%%m',5,'SNMP_UNREACHABLE_%%i','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
3086 CHK_EXEC(SQLQuery(query));
3087 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_SNMP_FAIL);
3088 CHK_EXEC(SQLQuery(query));
3089 ruleId++;
3090 _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,'33f6193a-e103-4f5f-8bee-870bbcc08066',7944,'Terminate the alarm if the SNMP agent on the node start responding again','%%m',6,'SNMP_UNREACHABLE_%%i','',0,%d,0,'')"), ruleId, EVENT_ALARM_TIMEOUT);
3091 CHK_EXEC(SQLQuery(query));
3092 _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_SNMP_OK);
3093 CHK_EXEC(SQLQuery(query));
3094 ruleId++;
3095 }
3096
3097 CHK_EXEC(SQLQuery(_T("UPDATE event_cfg SET severity='3' WHERE event_code=14 OR event_code=15")));
3098 CHK_EXEC(SetSchemaVersion(386));
3099 return TRUE;
3100}
3101
3102
3103/**
3104 * Upgrade from V384 to V385
3105 */
3106static BOOL H_UpgradeFromV384(int currVersion, int newVersion)
3107{
3108 CHK_EXEC(SQLQuery(_T("UPDATE config SET is_visible=1,need_server_restart=0 WHERE var_name='SNMPPorts'")));
3109 CHK_EXEC(SetSchemaVersion(385));
3110 return TRUE;
3111}
3112
3113/**
3114 * Upgrade from V383 to V384
3115 */
3116static BOOL H_UpgradeFromV383(int currVersion, int newVersion)
3117{
3118 CHK_EXEC(ConvertStrings(_T("graphs"), _T("graph_id"), _T("config")));
3119 static TCHAR batch[] =
3120 _T("ALTER TABLE graphs ADD flags integer\n")
3121 _T("ALTER TABLE graphs ADD filters $SQL:TEXT\n")
3122 _T("UPDATE graphs SET flags=0\n")
3123 _T("<END>");
3124 CHK_EXEC(SQLBatch(batch));
3125 CHK_EXEC(SetSchemaVersion(384));
3126 return TRUE;
3127}
3128
3129/**
3130 * Upgrade from V382 to V383
3131 */
3132static BOOL H_UpgradeFromV382(int currVersion, int newVersion)
3133{
3134 CHK_EXEC(DBResizeColumn(g_hCoreDB, _T("nodes"), _T("primary_ip"), 48, false));
3135 CHK_EXEC(SetSchemaVersion(383));
3136 return TRUE;
3137}
3138
3139/**
3140 * Upgrade from V381 to V382
3141 */
3142static BOOL H_UpgradeFromV381(int currVersion, int newVersion)
3143{
3144 CHK_EXEC(CreateLibraryScript(11, _T("Hook::StatusPoll"), _T("/* Available global variables:\r\n * $node - current node, object of 'Node' type\r\n *\r\n * Expected return value:\r\n * none - returned value is ignored\r\n */\r\n")));
3145 CHK_EXEC(CreateLibraryScript(12, _T("Hook::ConfigurationPoll"), _T("/* Available global variables:\r\n * $node - current node, object of 'Node' type\r\n *\r\n * Expected return value:\r\n * none - returned value is ignored\r\n */\r\n")));
3146 CHK_EXEC(CreateLibraryScript(13, _T("Hook::InstancePoll"), _T("/* Available global variables:\r\n * $node - current node, object of 'Node' type\r\n *\r\n * Expected return value:\r\n * none - returned value is ignored\r\n */\r\n")));
3147 CHK_EXEC(CreateLibraryScript(14, _T("Hook::TopologyPoll"), _T("/* Available global variables:\r\n * $node - current node, object of 'Node' type\r\n *\r\n * Expected return value:\r\n * none - returned value is ignored\r\n */\r\n")));
3148 CHK_EXEC(CreateLibraryScript(15, _T("Hook::CreateInterface"), _T("/* Available global variables:\r\n * $node - current node, object of 'Node' type\r\n * $1 - current interface, object of 'Interface' type\r\n *\r\n * Expected return value:\r\n * true/false - boolean - whether interface should be created\r\n */\r\nreturn true;\r\n")));
3149 CHK_EXEC(CreateLibraryScript(16, _T("Hook::AcceptNewNode"), _T("/* Available global variables:\r\n * $ipAddr - IP address of the node being processed\r\n * $ipNetMask - netmask of the node being processed\r\n * $macAddr - MAC address of the node being processed\r\n * $zoneId - zone ID of the node being processed\r\n *\r\n * Expected return value:\r\n * true/false - boolean - whether node should be created\r\n */\r\nreturn true;\r\n")));
3150 CHK_EXEC(SetSchemaVersion(382));
3151 return TRUE;
3152}
3153
3154/**
3155 * Upgrade from V380 to V381
3156 */
3157static BOOL H_UpgradeFromV380(int currVersion, int newVersion)
3158{
3159 static TCHAR batch[] =
3160 _T("ALTER TABLE items ADD guid varchar(36)\n")
3161 _T("ALTER TABLE dc_tables ADD guid varchar(36)\n")
3162 _T("<END>");
3163 CHK_EXEC(SQLBatch(batch));
3164 CHK_EXEC(GenerateGUID(_T("items"), _T("item_id"), _T("guid"), NULL));
3165 CHK_EXEC(GenerateGUID(_T("dc_tables"), _T("item_id"), _T("guid"), NULL));
3166 CHK_EXEC(SetSchemaVersion(381));
3167 return TRUE;
3168}
3169
3170/**
3171 * Upgrade from V379 to V380
3172 */
3173static BOOL H_UpgradeFromV379(int currVersion, int newVersion)
3174{
3175 static TCHAR batch[] =
3176 _T("UPDATE object_properties SET maint_event_id=0 WHERE maint_event_id IS NULL\n")
3177 _T("UPDATE nodes SET last_agent_comm_time=0 WHERE last_agent_comm_time IS NULL\n")
3178 _T("<END>");
3179 CHK_EXEC(SQLBatch(batch));
3180 CHK_EXEC(SetSchemaVersion(380));
3181 return TRUE;
3182}
3183
3184/**
3185 * Upgrade from V378 to V379
3186 */
3187static BOOL H_UpgradeFromV378(int currVersion, int newVersion)
3188{
3189 CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='NumberOfDatabaseWriters'")));
3190 CHK_EXEC(SetSchemaVersion(379));
3191 return TRUE;
3192}
3193
3194/**
3195 * Upgrade from V377 to V378
3196 */
3197static BOOL H_UpgradeFromV377(int currVersion, int newVersion)
3198{
3199 static TCHAR batch[] =
3200 _T("DELETE FROM config WHERE var_name='EnableMultipleDBConnections'\n")
3201 _T("UPDATE config SET var_name='DBConnectionPoolBaseSize' WHERE var_name='ConnectionPoolBaseSize'\n")
3202 _T("UPDATE config SET var_name='DBConnectionPoolMaxSize' WHERE var_name='ConnectionPoolMaxSize'\n")
3203 _T("UPDATE config SET var_name='DBConnectionPoolCooldownTime' WHERE var_name='ConnectionPoolCooldownTime'\n")
3204 _T("UPDATE config SET var_name='DBConnectionPoolMaxLifetime' WHERE var_name='ConnectionPoolMaxLifetime'\n")
3205 _T("<END>");
3206 CHK_EXEC(SQLBatch(batch));
3207 CHK_EXEC(SetSchemaVersion(378));
3208 return TRUE;
3209}
3210
3211/**
3212 * Upgrade from V376 to V377
3213 */
3214static BOOL H_UpgradeFromV376(int currVersion, int newVersion)
3215{
3216 CHK_EXEC(CreateConfigParam(_T("DefaultSubnetMaskIPv4"), _T("24"), _T("Default mask for synthetic IPv4 subnets"), 'I', true, false, false, false));
3217 CHK_EXEC(CreateConfigParam(_T("DefaultSubnetMaskIPv6"), _T("64"), _T("Default mask for synthetic IPv6 subnets"), 'I', true, false, false, false));
3218 CHK_EXEC(SetSchemaVersion(377));
3219 return TRUE;
3220}
3221
3222/**
3223 * Upgrade from V375 to V376
3224 */
3225static BOOL H_UpgradeFromV375(int currVersion, int newVersion)
3226{
3227 static TCHAR batch[] =
3228 _T("ALTER TABLE nodes ADD last_agent_comm_time integer\n")
3229 _T("UPDATE nodes SET last_agent_comm_time=0\n")
3230 _T("<END>");
3231 CHK_EXEC(SQLBatch(batch));
3232
3233 CHK_EXEC(SetSchemaVersion(376));
3234 return TRUE;
3235}
3236
3237/**
3238 * Upgrade from V374 to V375
3239 */
3240static BOOL H_UpgradeFromV374(int currVersion, int newVersion)
3241{
3242 static TCHAR batch[] =
3243 _T("ALTER TABLE object_tools_input_fields ADD sequence_num integer\n")
3244 _T("UPDATE object_tools_input_fields SET sequence_num=-1\n")
3245 _T("<END>");
3246 CHK_EXEC(SQLBatch(batch));
3247
3248 CHK_EXEC(SetSchemaVersion(375));
3249 return TRUE;
3250}
3251
3252/**
3253 * Upgrade from V373 to V374
3254 */
3255static BOOL H_UpgradeFromV373(int currVersion, int newVersion)
3256{
3257 static TCHAR batch[] =
3258 _T("ALTER TABLE object_properties ADD maint_event_id $SQL:INT64\n")
3259 _T("UPDATE object_properties SET maint_mode='0',maint_event_id=0\n")
3260 _T("<END>");
3261 CHK_EXEC(SQLBatch(batch));
3262
3263 CHK_EXEC(CreateEventTemplate(EVENT_MAINTENANCE_MODE_ENTERED, _T("SYS_MAINTENANCE_MODE_ENTERED"), SEVERITY_NORMAL, EF_LOG, NULL,
3264 _T("Entered maintenance mode"),
3265 _T("Generated when node, cluster, or mobile device enters maintenance mode.")));
3266
3267 CHK_EXEC(CreateEventTemplate(EVENT_MAINTENANCE_MODE_LEFT, _T("SYS_MAINTENANCE_MODE_LEFT"), SEVERITY_NORMAL, EF_LOG, NULL,
3268 _T("Left maintenance mode"),
3269 _T("Generated when node, cluster, or mobile device leaves maintenance mode.")));
3270
3271 CHK_EXEC(SetSchemaVersion(374));
3272 return TRUE;
3273}
3274
3275/**
3276 * Upgrade from V372 to V373
3277 */
3278static BOOL H_UpgradeFromV372(int currVersion, int newVersion)
3279{
3280 CHK_EXEC(SQLQuery(_T("ALTER TABLE scheduled_tasks ADD object_id integer")));
3281 CHK_EXEC(SetSchemaVersion(373));
3282 return TRUE;
3283}
3284
3285/**
3286 * Upgrade from V371 to V372
3287 */
3288static BOOL H_UpgradeFromV371(int currVersion, int newVersion)
3289{
3290 static TCHAR batch[] =
3291 _T("ALTER TABLE object_properties ADD maint_mode char(1)\n")
3292 _T("UPDATE object_properties SET maint_mode='0'\n")
3293 _T("<END>");
3294 CHK_EXEC(SQLBatch(batch));
3295 CHK_EXEC(SetSchemaVersion(372));
3296 return TRUE;
3297}
3298
3299/**
3300 * Upgrade from V370 to V371
3301 */
3302static BOOL H_UpgradeFromV370(int currVersion, int newVersion)
3303{
3304 int defaultPollingInterval = ConfigReadInt(_T("DefaultDCIPollingInterval"), 60);
3305 int defaultRetentionTime = ConfigReadInt(_T("DefaultDCIRetentionTime"), 30);
3306
3307 TCHAR query[256];
3308 _sntprintf(query, 256, _T("UPDATE items SET polling_interval=0 WHERE polling_interval=%d"), defaultPollingInterval);
3309 CHK_EXEC(SQLQuery(query));
3310
3311 _sntprintf(query, 256, _T("UPDATE items SET retention_time=0 WHERE retention_time=%d"), defaultRetentionTime);
3312 CHK_EXEC(SQLQuery(query));
3313
3314 _sntprintf(query, 256, _T("UPDATE dc_tables SET polling_interval=0 WHERE polling_interval=%d"), defaultPollingInterval);
3315 CHK_EXEC(SQLQuery(query));
3316
3317 _sntprintf(query, 256, _T("UPDATE dc_tables SET retention_time=0 WHERE retention_time=%d"), defaultRetentionTime);
3318 CHK_EXEC(SQLQuery(query));
3319
3320 CHK_EXEC(SetSchemaVersion(371));
3321 return TRUE;
3322}
3323
3324/**
3325 * Upgrade from V369 to V370
3326 */
3327static BOOL H_UpgradeFromV369(int currVersion, int newVersion)
3328{
3329 CHK_EXEC(CreateTable(
3330 _T("CREATE TABLE dashboard_associations (")
3331 _T(" object_id integer not null,")
3332 _T(" dashboard_id integer not null,")
3333 _T(" PRIMARY KEY(object_id,dashboard_id))")));
3334 CHK_EXEC(SetSchemaVersion(370));
3335 return TRUE;
3336}
3337
3338/**
3339 * Upgrade from V368 to V369
3340 */
3341static BOOL H_UpgradeFromV368(int currVersion, int newVersion)
3342{
3343 CHK_EXEC(CreateTable(
3344 _T("CREATE TABLE scheduled_tasks (")
3345 _T(" id integer not null,")
3346 _T(" taskId varchar(255) null,")
3347 _T(" schedule varchar(127) null,")
3348 _T(" params varchar(1023) null,")
3349 _T(" execution_time integer not null,")
3350 _T(" last_execution_time integer not null,")
3351 _T(" flags integer not null,")
3352 _T(" owner integer not null,")
3353 _T(" PRIMARY KEY(id))")));
3354 CHK_EXEC(SetSchemaVersion(369));
3355 return TRUE;
3356}
3357
3358/**
3359 * Upgrade from V367 to V368
3360 */
3361static BOOL H_UpgradeFromV367(int currVersion, int newVersion)
3362{
3363 static TCHAR batch[] =
3364 _T("ALTER TABLE nodes ADD rack_height integer\n")
3365 _T("UPDATE nodes SET rack_height=1\n")
3366 _T("<END>");
3367 CHK_EXEC(SQLBatch(batch));
3368 CHK_EXEC(SetSchemaVersion(368));
3369 return TRUE;
3370}
3371
3372/**
3373 * Upgrade from V366 to V367
3374 */
3375static BOOL H_UpgradeFromV366(int currVersion, int newVersion)
3376{
3377 CHK_EXEC(CreateConfigParam(_T("TrapSourcesInAllZones"), _T("0"), _T("Search all zones to match trap/syslog source address to node"), 'B', true, true, false, false));
3378
3379 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD snmp_sys_contact varchar(127)")));
3380 CHK_EXEC(SQLQuery(_T("ALTER TABLE nodes ADD snmp_sys_location varchar(127)")));
3381
3382 CHK_EXEC(SetSchemaVersion(367));
3383 return TRUE;
3384}
3385
3386/**
3387 * Upgrade from V365 to V366
3388 */
3389static BOOL H_UpgradeFromV365(int currVersion, int newVersion)
3390{
3391 CHK_EXEC(CreateConfigParam(_T("ServerCommandOutputTimeout"), _T("60"), true, false));
3392
3393 CHK_EXEC(SetSchemaVersion(366));
3394 return TRUE;
3395}
3396
3397/**
3398 * Upgrade from V364 to V365
3399 */
3400static BOOL H_UpgradeFromV364(int currVersion, int newVersion)
3