* { font-family: Consolas, Lucida Console, Courier New; font-size: 100%; }
h1 { font-size: 150%; }
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 100%; width: 100%; }
.highlight span { width: 100%; display:-moz-inline-stack; display:inline-block; zoom:1; *display:inline; }
body { background: #ffffff; }
body .c { color: #999988; font-style: italic } /* Comment */
body .err { color: #a61717; background-color: #e3d2d2 } /* Error */
body .k { font-weight: bold } /* Keyword */
body .o { font-weight: bold } /* Operator */
body .cm { color: #999988; font-style: italic } /* Comment.Multiline */
body .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
body .c1 { color: #999988; font-style: italic } /* Comment.Single */
body .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
body .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
body .ge { font-style: italic } /* Generic.Emph */
body .gr { color: #aa0000 } /* Generic.Error */
body .gh { color: #999999 } /* Generic.Heading */
body .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
body .go { color: #888888 } /* Generic.Output */
body .gp { color: #555555 } /* Generic.Prompt */
body .gs { font-weight: bold } /* Generic.Strong */
body .gu { color: #aaaaaa } /* Generic.Subheading */
body .gt { color: #aa0000 } /* Generic.Traceback */
body .kc { font-weight: bold } /* Keyword.Constant */
body .kd { font-weight: bold } /* Keyword.Declaration */
body .kp { font-weight: bold } /* Keyword.Pseudo */
body .kr { font-weight: bold } /* Keyword.Reserved */
body .kt { color: #445588; font-weight: bold } /* Keyword.Type */
body .m { color: #009999 } /* Literal.Number */
body .s { color: #bb8844 } /* Literal.String */
body .na { color: #008080 } /* Name.Attribute */
body .nb { color: #999999 } /* Name.Builtin */
body .nc { color: #445588; font-weight: bold } /* Name.Class */
body .no { color: #008080 } /* Name.Constant */
body .ni { color: #800080 } /* Name.Entity */
body .ne { color: #990000; font-weight: bold } /* Name.Exception */
body .nf { color: #990000; font-weight: bold } /* Name.Function */
body .nn { color: #555555 } /* Name.Namespace */
body .nt { color: #000080 } /* Name.Tag */
body .nv { color: #008080 } /* Name.Variable */
body .ow { font-weight: bold } /* Operator.Word */
body .w { color: #bbbbbb } /* Text.Whitespace */
body .mf { color: #009999 } /* Literal.Number.Float */
body .mh { color: #009999 } /* Literal.Number.Hex */
body .mi { color: #009999 } /* Literal.Number.Integer */
body .mo { color: #009999 } /* Literal.Number.Oct */
body .sb { color: #bb8844 } /* Literal.String.Backtick */
body .sc { color: #bb8844 } /* Literal.String.Char */
body .sd { color: #bb8844 } /* Literal.String.Doc */
body .s2 { color: #bb8844 } /* Literal.String.Double */
body .se { color: #bb8844 } /* Literal.String.Escape */
body .sh { color: #bb8844 } /* Literal.String.Heredoc */
body .si { color: #bb8844 } /* Literal.String.Interpol */
body .sx { color: #bb8844 } /* Literal.String.Other */
body .sr { color: #808000 } /* Literal.String.Regex */
body .s1 { color: #bb8844 } /* Literal.String.Single */
body .ss { color: #bb8844 } /* Literal.String.Symbol */
body .bp { color: #999999 } /* Name.Builtin.Pseudo */
body .vc { color: #008080 } /* Name.Variable.Class */
body .vg { color: #008080 } /* Name.Variable.Global */
body .vi { color: #008080 } /* Name.Variable.Instance */
body .il { color: #009999 } /* Literal.Number.Integer.Long */
Info
Revision:3305
Author:victor
Date:2008-06-12 20:43:44 +0300 (Thu, 12 Jun 2008)
Comment:Fixed issue 196; added new tables to schema
Changes
U trunk/ChangeLog
U trunk/doc/internal/db_format_change.txt
U trunk/include/netxmsdb.h
U trunk/sql/schema.in
U trunk/src/server/core/dcitem.cpp
U trunk/src/server/tools/nxdbmgr/upgrade.cpp
Diff
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-06-12 15:59:32 UTC (rev 3304)
+++ trunk/ChangeLog 2008-06-12 17:43:44 UTC (rev 3305)
@@ -6,7 +6,7 @@
- Scripts in event processing policy now has access to node properties
via $node variable and to event properties via $event variable
- Implemented XML encoding for NXCP messages
-- Fixed issues: #201, #220, #221
+- Fixed issues: #196, #201, #220, #221
*
Modified: trunk/doc/internal/db_format_change.txt
===================================================================
--- trunk/doc/internal/db_format_change.txt 2008-06-12 15:59:32 UTC (rev 3304)
+++ trunk/doc/internal/db_format_change.txt 2008-06-12 17:43:44 UTC (rev 3305)
@@ -1,4 +1,32 @@
*************
+* 80 ==> 81 *
+*************
+
+- New column added to table "dci_schedules":
+ ALTER TABLE dci_schedules ADD schedule_id integer not null
+- Set primary key constraints:
+ dci_schedules ---> item_id,schedule_id
+ address_lists ---> list_type,community_id,addr_type,addr1,addr2
+ lpp_associations ---> lpp_id,node_id,log_file
+- New tables added:
+ CREATE TABLE object_custom_attributes
+ (
+ object_id integer not null,
+ attr_name varchar(127) not null,
+ attr_value SQL_TEXT not null,
+ PRIMARY KEY(object_id,attr_name)
+ ) TABLE_TYPE;
+ CREATE TABLE web_maps
+ (
+ id integer not null,
+ title varchar(63) not null,
+ properties SQL_TEXT not null,
+ data SQL_TEXT not null,
+ PRIMARY KEY(id)
+ ) TABLE_TYPE;
+
+
+*************
* 79 ==> 80 *
*************
Modified: trunk/include/netxmsdb.h
===================================================================
--- trunk/include/netxmsdb.h 2008-06-12 15:59:32 UTC (rev 3304)
+++ trunk/include/netxmsdb.h 2008-06-12 17:43:44 UTC (rev 3305)
@@ -24,6 +24,6 @@
#ifndef _netxmsdb_h
#define _netxmsdb_h
-#define DB_FORMAT_VERSION 80
+#define DB_FORMAT_VERSION 81
#endif
Modified: trunk/sql/schema.in
===================================================================
--- trunk/sql/schema.in 2008-06-12 15:59:32 UTC (rev 3304)
+++ trunk/sql/schema.in 2008-06-12 17:43:44 UTC (rev 3305)
@@ -114,6 +114,19 @@
/*
+** Object custom attributes
+*/
+
+CREATE TABLE object_custom_attributes
+(
+ object_id integer not null,
+ attr_name varchar(127) not null,
+ attr_value SQL_TEXT not null,
+ PRIMARY KEY(object_id,attr_name)
+) TABLE_TYPE;
+
+
+/*
** Zone object
*/
@@ -476,8 +489,10 @@
CREATE TABLE dci_schedules
(
+ schedule_id integer not null,
item_id integer not null,
- schedule varchar(255) not null
+ schedule varchar(255) not null,
+ PRIMARY KEY(item_id,schedule_id)
) TABLE_TYPE;
@@ -1067,7 +1082,8 @@
community_id integer not null, // community id for snmp community addr list, otherwise 0
addr_type integer not null, // 0 - addr/mask, 1 - address range
addr1 varchar(15) not null,
- addr2 varchar(15) not null
+ addr2 varchar(15) not null,
+ PRIMARY KEY(list_type,community_id,addr_type,addr1,addr2)
) TABLE_TYPE;
CREATE INDEX idx_address_lists_list_type ON address_lists(list_type);
@@ -1151,7 +1167,8 @@
(
lpp_id integer not null,
node_id integer not null,
- log_file varchar(255) not null
+ log_file varchar(255) not null,
+ PRIMARY KEY(lpp_id,node_id,log_file)
) TABLE_TYPE;
@@ -1243,3 +1260,18 @@
community varchar(255) not null,
PRIMARY KEY(id)
) TABLE_TYPE;
+
+
+/*
+** Maps for XULRunner client and web clients
+*/
+
+CREATE TABLE web_maps
+(
+ id integer not null,
+ title varchar(63) not null,
+ properties SQL_TEXT not null,
+ data SQL_TEXT not null,
+ PRIMARY KEY(id)
+) TABLE_TYPE;
+
Modified: trunk/src/server/core/dcitem.cpp
===================================================================
--- trunk/src/server/core/dcitem.cpp 2008-06-12 15:59:32 UTC (rev 3304)
+++ trunk/src/server/core/dcitem.cpp 2008-06-12 17:43:44 UTC (rev 3305)
@@ -561,8 +561,8 @@
for(i = 0; i < m_dwNumSchedules; i++)
{
pszEscSchedule = EncodeSQLString(m_ppScheduleList[i]);
- sprintf(pszQuery, "INSERT INTO dci_schedules (item_id,schedule) VALUES (%d,'%s')",
- m_dwId, pszEscSchedule);
+ sprintf(pszQuery, "INSERT INTO dci_schedules (item_id,schedule_id,schedule) VALUES (%d,%d,'%s')",
+ m_dwId, i + 1, pszEscSchedule);
free(pszEscSchedule);
DBQuery(hdb, pszQuery);
}
@@ -684,6 +684,8 @@
QueueSQLRequest(szQuery);
sprintf(szQuery, "DELETE FROM thresholds WHERE item_id=%d", m_dwId);
QueueSQLRequest(szQuery);
+ sprintf(szQuery, "DELETE FROM dci_schedules WHERE item_id=%d", m_dwId);
+ QueueSQLRequest(szQuery);
}
Modified: trunk/src/server/tools/nxdbmgr/upgrade.cpp
===================================================================
--- trunk/src/server/tools/nxdbmgr/upgrade.cpp 2008-06-12 15:59:32 UTC (rev 3304)
+++ trunk/src/server/tools/nxdbmgr/upgrade.cpp 2008-06-12 17:43:44 UTC (rev 3305)
@@ -87,6 +87,99 @@
//
+// Set primary key constraint
+//
+
+static BOOL SetPrimaryKey(const TCHAR *table, const TCHAR *key)
+{
+ TCHAR query[4096];
+
+ if (g_iSyntax == DB_SYNTAX_SQLITE)
+ return TRUE; // SQLite does not support adding constraints
+
+ _sntprintf(query, 4096, _T("ALTER TABLE %s ADD PRIMARY KEY (%s)"), table, key);
+ return SQLQuery(query);
+}
+
+
+//
+// Upgrade from V80 to V81
+//
+
+static BOOL H_UpgradeFromV80(void)
+{
+ DB_RESULT hResult;
+ TCHAR query[1024], buffer[1024];
+ int i;
+
+ // Update dci_schedules table
+ hResult = SQLSelect(_T("SELECT item_id,schedule FROM dci_schedules"));
+ if (hResult != NULL)
+ {
+ if (!SQLQuery(_T("DELETE FROM dci_schedules")))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+
+ if (!SQLQuery(_T("ALTER TABLE dci_schedules ADD schedule_id integer not null")))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+
+ for(i = 0; i < DBGetNumRows(hResult); i++)
+ {
+ _sntprintf(query, 1024, _T("INSERT INTO dci_schedules (item_id,schedule_id,schedule) VALUES(%d,%d,'%s')"),
+ DBGetFieldULong(hResult, i, 0), i + 1, DBGetField(hResult, i, 1, buffer, 1024));
+ if (!SQLQuery(query))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+ }
+ DBFreeResult(hResult);
+ }
+ else
+ {
+ if (!g_bIgnoreErrors)
+ return FALSE;
+ }
+
+ // Set primary key constraints
+ if (!SetPrimaryKey(_T("dci_schedules"), _T("item_id,schedule_id")))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+
+ if (!SetPrimaryKey(_T("address_lists"), _T("list_type,community_id,addr_type,addr1,addr2")))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+
+ if (!SetPrimaryKey(_T("lpp_associations"), _T("lpp_id,node_id,log_file")))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+
+ // Create new tables
+ if (!CreateTable(_T("CREATE TABLE object_custom_attributes (")
+ _T("object_id integer not null,")
+ _T("attr_name varchar(127) not null,")
+ _T("attr_value $SQL:TEXT not null,")
+ _T("PRIMARY KEY(object_id,attr_name))")))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+
+ if (!CreateTable(_T("CREATE TABLE web_maps (")
+ _T("id integer not null,")
+ _T("title varchar(63) not null,")
+ _T("properties $SQL:TEXT not null,")
+ _T("data $SQL:TEXT not null,")
+ _T("PRIMARY KEY(id))")))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+
+ if (!SQLQuery(_T("UPDATE config SET var_value='81' WHERE var_name='DBFormatVersion'")))
+ if (!g_bIgnoreErrors)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+//
// Upgrade from V79 to V80
//
@@ -3532,6 +3625,7 @@
{ 77, H_UpgradeFromV77 },
{ 78, H_UpgradeFromV78 },
{ 79, H_UpgradeFromV79 },
+ { 80, H_UpgradeFromV80 },
{ 0, NULL }
};
Received on Thu Jun 12 2008 - 20:43:45 EEST
This archive was generated by hypermail 2.2.0 : Thu Jun 12 2008 - 20:40:18 EEST