Update of /cvsroot/perfparse/_perfparse/db_tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9539
Modified Files:
convert.c
Log Message:
more work
Index: convert.c
===================================================================
RCS file: /cvsroot/perfparse/_perfparse/db_tools/convert.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** convert.c 7 Dec 2006 23:47:13 -0000 1.9
--- convert.c 11 Dec 2006 23:44:48 -0000 1.10
***************
*** 141,152 ****
if (version < 0.20)
{
printf (_("Warning, this stage may take some time:\n"));
! printf (_("Creating new group table:\n"));
! query ("create table perfdata_groups (group_id INT AUTO_INCREMENT PRIMARY KEY, group_name VARCHAR(75) UNIQUE) type=InnoDB select group_name from perfdata_host_group");
! printf (_
! ("Dropping foreign key from perfdata_host to perfdata_host_group table.\n"));
DropForeignKey ("perfdata_host", "perfdata_host_group");
! printf (_("Dropping table perfdata_host_group\n"));
query ("drop table perfdata_host_group");
}
--- 141,170 ----
if (version < 0.20)
{
+ int steps=5;
printf (_("Warning, this stage may take some time:\n"));
! printf (_("[Step 1/%d] Creating new group table:\n"),steps);
! query ("create table perfdata_groups \
! (group_id INT AUTO_INCREMENT PRIMARY KEY, \
! group_name VARCHAR(75) UNIQUE) type=InnoDB \
! select group_name from perfdata_host_group");
! printf (_("[Step 2/%d] Dropping foreign key from perfdata_host to perfdata_host_group table.\n"),steps);
DropForeignKey ("perfdata_host", "perfdata_host_group");
! printf (_("[Step 3/%d] Dropping table perfdata_host_group\n"),steps);
query ("drop table perfdata_host_group");
+ printf(_("[Step 4/%d] Creating group mapping table perfdata_host_groups\n"),steps);
+ query ("CREATE TABLE IF NOT EXISTS perfdata_host_groups ( \
+ group_id INT, \
+ FOREIGN KEY perfdata_host_groups_ibfk_1 (group_id) \
+ REFERENCES perfdata_groups(group_id) ON DELETE CASCADE, \
+ host_id INT, \
+ FOREIGN KEY perfdata_host_groups_ibfk_2 (host_id) \
+ REFERENCES perfdata_host(host_id) ON DELETE CASCADE \
+ ) type=InnoDB;");
+ printf(_("[Step 5/%d] Filling table perfdata_host_groups\n"),steps);
+ query ("insert into perfdata_host_groups(group_id,host_id) \
+ select g.group_id, h.host_id from perfdata_groups g,\
+ perfdata_host h where g.group_name=h.group_name");
+
+
}
***************
*** 157,161 ****
* Create where missing
*/
! checkTables ();
/*
--- 175,180 ----
* Create where missing
*/
! /* disabled for the moment */
! // checkTables ();
/*
***************
*** 214,219 ****
&& pmatch[i].rm_eo != -1)
{
! tmpstr = resultstr->str +
! pmatch[i].rm_eo;
*tmpstr = '\0';
/*printf ("Match %d so: %d, eo:%d String %s\n", i,
--- 233,237 ----
&& pmatch[i].rm_eo != -1)
{
! tmpstr = resultstr->str + pmatch[i].rm_eo;
*tmpstr = '\0';
/*printf ("Match %d so: %d, eo:%d String %s\n", i,
***************
*** 221,227 ****
g_string_printf (querystr,
"ALTER TABLE %s DROP FOREIGN KEY %s",
! TableName,
! resultstr->str +
! pmatch[i].rm_so);
query (querystr->str);
}
--- 239,243 ----
g_string_printf (querystr,
"ALTER TABLE %s DROP FOREIGN KEY %s",
! TableName, resultstr->str + pmatch[i].rm_so);
query (querystr->str);
}
|