[svn-commits] r142 - in branches/advisor/src/back/scf: hdr scm

thial01 at ingres.com thial01 at ingres.com
Sat Jul 5 13:56:16 PDT 2008


Author: thial01
Date: 2008-07-05 13:56:16 -0700 (Sat, 05 Jul 2008)
New Revision: 142

Modified:
   branches/advisor/src/back/scf/hdr/scm.h
   branches/advisor/src/back/scf/hdr/scmonitor.h
   branches/advisor/src/back/scf/scm/scmima.c
   branches/advisor/src/back/scf/scm/scmmain.c
   branches/advisor/src/back/scf/scm/scmonitor.sc
Log:
First functional version of the monitor daemon - see #174


Modified: branches/advisor/src/back/scf/hdr/scm.h
===================================================================
--- branches/advisor/src/back/scf/hdr/scm.h	2008-07-04 15:42:43 UTC (rev 141)
+++ branches/advisor/src/back/scf/hdr/scm.h	2008-07-05 20:56:16 UTC (rev 142)
@@ -57,7 +57,7 @@
 	u_i4		est_cpu;
 	u_i4		est_dio;
 	u_i4		pages_touched;
-	i4			time;
+	i4			time; 
 }   SCM_STATEMENT;
 
 /*}
@@ -86,7 +86,7 @@
 	i4			structure;
 	u_i4		data_pages;
 	u_i4		overflow_pages;
-
+	i4			time;
 }   SCM_TABLE;
 
 /*}
@@ -106,7 +106,7 @@
 	char	name[DB_MAXNAME];
 	i4		table_id;
 	u_i4	frequency;
-
+	i4		time;
 }   SCM_ATTRIBUTE;
 
 /*}
@@ -130,7 +130,7 @@
 	i4			structure;
 	u_i4		data_pages;
 	u_i4		overflow_pages;
-
+	i4			time;
 }   SCM_INDEX;
 
 /*}

Modified: branches/advisor/src/back/scf/hdr/scmonitor.h
===================================================================
--- branches/advisor/src/back/scf/hdr/scmonitor.h	2008-07-04 15:42:43 UTC (rev 141)
+++ branches/advisor/src/back/scf/hdr/scmonitor.h	2008-07-05 20:56:16 UTC (rev 142)
@@ -51,7 +51,7 @@
 	i4			structure;
 	u_i4		data_pages;
 	u_i4		overflow_pages;
-
+	i4			time;
 }   ESQL_SCM_TABLE;
 
 typedef struct _ESQL_SCM_ATTRIBUTE
@@ -62,7 +62,7 @@
 	char	name[DB_MAXNAME];
 	i4		table_id;
 	u_i4	frequency;
-
+	i4		time;
 }   ESQL_SCM_ATTRIBUTE;
 
 
@@ -78,7 +78,7 @@
 	i4			structure;
 	u_i4		data_pages;
 	u_i4		overflow_pages;
-
+	i4			time;
 }   ESQL_SCM_INDEX;
 
 

Modified: branches/advisor/src/back/scf/scm/scmima.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmima.c	2008-07-04 15:42:43 UTC (rev 141)
+++ branches/advisor/src/back/scf/scm/scmima.c	2008-07-05 20:56:16 UTC (rev 142)
@@ -219,6 +219,12 @@
 	MO_SIZEOF_MEMBER(SCM_TABLE, est_tup), MO_READ, scm_tab_index_class,
 	CL_OFFSETOF(SCM_TABLE, est_tup), MOuintget, MOnoset,
 	0, MOidata_index
+    },
+    {
+    MO_CDATA_INDEX, "exp.scf.scm.tab.act_tup",
+	MO_SIZEOF_MEMBER(SCM_TABLE, act_tup), MO_READ, scm_tab_index_class,
+	CL_OFFSETOF(SCM_TABLE, act_tup), MOuintget, MOnoset,
+	0, MOidata_index
     },    
     {
     MO_CDATA_INDEX, "exp.scf.scm.tab.structure",
@@ -237,7 +243,13 @@
 	MO_SIZEOF_MEMBER(SCM_TABLE, overflow_pages), MO_READ, scm_tab_index_class,
 	CL_OFFSETOF(SCM_TABLE, overflow_pages), MOuintget, MOnoset,
 	0, MOidata_index
-    },    
+    }, 
+    {
+    MO_CDATA_INDEX, "exp.scf.scm.tab.time",
+	MO_SIZEOF_MEMBER(SCM_TABLE, time), MO_READ, scm_tab_index_class,
+	CL_OFFSETOF(SCM_TABLE, time), MOintget, MOnoset,
+	0, MOidata_index
+    }, 
     { 0 }
 };
 
@@ -278,7 +290,13 @@
 	MO_SIZEOF_MEMBER(SCM_ATTRIBUTE, frequency), MO_READ, scm_atr_index_class,
 	CL_OFFSETOF(SCM_ATTRIBUTE, frequency), MOuintget, MOnoset,
 	0, MOidata_index
-    },        
+    },     
+    {
+    MO_CDATA_INDEX, "exp.scf.scm.atr.time",
+	MO_SIZEOF_MEMBER(SCM_ATTRIBUTE, time), MO_READ, scm_atr_index_class,
+	CL_OFFSETOF(SCM_ATTRIBUTE, time), MOintget, MOnoset,
+	0, MOidata_index
+    },
     { 0 }
 };
 
@@ -343,7 +361,13 @@
 	MO_SIZEOF_MEMBER(SCM_INDEX, overflow_pages), MO_READ, scm_idx_index_class,
 	CL_OFFSETOF(SCM_INDEX, overflow_pages), MOuintget, MOnoset,
 	0, MOidata_index
-    },            
+    },       
+    {
+    MO_CDATA_INDEX, "exp.scf.scm.idx.time",
+	MO_SIZEOF_MEMBER(SCM_INDEX, time), MO_READ, scm_idx_index_class,
+	CL_OFFSETOF(SCM_INDEX, time), MOintget, MOnoset,
+	0, MOidata_index
+    }, 
     { 0 }
 };
 

Modified: branches/advisor/src/back/scf/scm/scmmain.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmmain.c	2008-07-04 15:42:43 UTC (rev 141)
+++ branches/advisor/src/back/scf/scm/scmmain.c	2008-07-05 20:56:16 UTC (rev 142)
@@ -781,6 +781,11 @@
 	table->structure = structure;
 	table->data_pages = datapages;
 	table->overflow_pages = overflow;
+
+	/* And update the time we saw the table */
+	SYSTIME now;
+	TMnow(&now);
+	table->time = now.TM_secs; 
 	
 	/* 
 	** Now log the reference between this table 
@@ -997,7 +1002,11 @@
 	
 	/* Update the entry */
 	attribute->frequency++;
-	
+	/* And update the time we saw the attribute */
+	SYSTIME now;
+	TMnow(&now);
+	attribute->time = now.TM_secs; 
+
 	/* 
 	** Now log the reference between this attribute 
 	** and the current statement 
@@ -1126,13 +1135,14 @@
 	STncpy(index->name, name, DB_MAXNAME);
 	index->database[DB_MAXNAME-1] = '\0';
 	index->name[DB_MAXNAME-1] = '\0';
+	index->time = 0;
 	/*
 	** If this index is never actually used
 	** this remains at 0 and we should remove 
 	** this unnecessary index
 	*/ 
-	index->frequency = 0;	
-        
+	index->frequency = 0;
+
 	/* Increment the current id */
 	scm->cur_idx_idx++;
 
@@ -1202,6 +1212,12 @@
 			
 			/* We found it  */
 			scm->indexes[i]->frequency++;
+			
+			/* And update the time we saw the query */
+			SYSTIME now;
+			TMnow(&now);
+			scm->indexes[i]->time = now.TM_secs; 
+			
 			return;
 		}
 	}

Modified: branches/advisor/src/back/scf/scm/scmonitor.sc
===================================================================
--- branches/advisor/src/back/scf/scm/scmonitor.sc	2008-07-04 15:42:43 UTC (rev 141)
+++ branches/advisor/src/back/scf/scm/scmonitor.sc	2008-07-05 20:56:16 UTC (rev 142)
@@ -78,6 +78,8 @@
 PROGRAM =	monitordb
 **/
 
+#undef		DEBUG	
+
 /* Global definitions */
 exec sql begin declare section;
 	char	db_name[DB_MAXNAME];
@@ -85,6 +87,10 @@
 	ESQL_SCM	*scm;
 exec sql end declare section;
 
+/* How long do we sleep between wake-ups? */
+#define		SLEEP		30000
+/* How often do we wake up until we store data in workload db? */
+#define		ROUNDS		10
 
 /*{
 **
@@ -110,6 +116,10 @@
 get_statements( VOID ) 
 {
 
+#ifdef DEBUG 
+	SIprintf("get_statements\n");
+#endif		
+
 	exec sql begin declare section;
 		ESQL_SCM_STATEMENT statement;
 	exec sql end declare section;
@@ -121,8 +131,12 @@
 		
 	exec sql open stm for readonly;
 	
+	i4	i = 0;
+	
     for (;;)
     {
+    	MEfill(sizeof(ESQL_SCM_STATEMENT), 0, &statement);
+    
         exec sql fetch stm into :statement;
         if (sqlca.sqlcode == 100)
         {
@@ -133,15 +147,8 @@
             SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
             PCexit(FAIL);
         }
-        
-        /* See if we need to wrap around */
-        if (scm->cur_stm_idx > MAXMONITOR)
-        {
-        	scm->cur_stm_idx = 0;
-        }
-        
-        scm->statements[scm->cur_stm_idx] = statement;
-        scm->cur_stm_idx++;
+                
+        scm->statements[i++] = statement;
 
     }
 
@@ -173,6 +180,11 @@
 VOID
 put_statements( VOID ) 
 {
+
+#ifdef DEBUG 
+	SIprintf("put_statements\n");
+#endif		
+
 	i4		i;
 	exec sql begin declare section;
 		ESQL_SCM_STATEMENT	statement;
@@ -266,6 +278,10 @@
 get_tables( VOID ) 
 {
 
+#ifdef DEBUG 
+	SIprintf("get_tables\n");
+#endif		
+
 	exec sql begin declare section;
 		ESQL_SCM_TABLE table;
 	exec sql end declare section;
@@ -277,8 +293,13 @@
 		
 	exec sql open tab for readonly;
 	
+	i4	i = 0;
+	
     for (;;)
     {
+    
+    	MEfill(sizeof(ESQL_SCM_TABLE), 0, &table);
+    
         exec sql fetch tab into :table;
         if (sqlca.sqlcode == 100)
         {
@@ -290,19 +311,112 @@
             PCexit(FAIL);
         }
         
-        /* See if we need to wrap around */
-        if (scm->cur_tab_idx > MAXMONITOR)
+        scm->tables[i++] = table;
+        
+    }
+
+    exec sql close tab;
+
+	return;
+}
+
+/*{
+**
+**  Name: put_tables() -   put tables to workload db
+**
+**  Description:
+**	Put table data to the workload db 
+**
+**  Inputs:
+**		none
+**
+**  Outputs:
+**	Returns:
+**	    none
+**	Exceptions:
+**
+**  History:
+**      04-Jul-2008 (thial01)
+**          Created
+*/
+
+VOID
+put_tables( VOID ) 
+{
+
+#ifdef DEBUG 
+	SIprintf("put_tables\n");
+#endif		
+
+	i4		i;
+	exec sql begin declare section;
+		ESQL_SCM_TABLE	table;
+		i4				time;
+	exec sql end declare section;
+
+    for (i = 0; i < MAXMONITOR; i++)
+    {
+    	/* 
+    	** We cannot check for table == null here
+    	** as it is already allocated.
+    	** So use the server member instead
+    	*/
+        if (scm->tables[i].server[0] == '\0')
         {
-        	scm->cur_tab_idx = 0;
+        	return;
         }
         
-        scm->tables[scm->cur_tab_idx] = table;
-        scm->cur_tab_idx++;
+        table = scm->tables[i];
         
+        time = 0;
+        
+        exec sql select time
+        		into :time
+        		from tables
+        			where database = :db_name
+        				and table_id = :table.table_id;
+        				
+        /* 
+        ** Let's see if we saw this before
+        ** and the timestamp is new so that
+        ** we need to update it or not
+        */
+        if (time > 0)
+        {
+        	if (table.time > time)
+        	{
+        		exec sql update tables
+        			set 
+	        			frequency = :table.frequency,
+	        			statistics = :table.statistics,
+    	    			est_cpu = :table.est_cpu,
+        				act_cpu = :table.act_cpu,
+        				est_dio = :table.est_dio,
+        				act_dio = :table.act_dio,
+        				est_tup = :table.est_tup,
+        				act_tup = :table.act_tup,
+          				structure = :table.structure,
+	        			data_pages = :table.data_pages,
+    	    			overflow_pages = :table.overflow_pages,
+        				time = :table.time
+        			where database = :db_name
+        				and table_id = :table.table_id;
+        	}
+        		        
+        } else
+        {
+        	exec sql insert into tables
+        		values (:table);
+        }
+        	
+		if (sqlca.sqlcode != 0)
+        {
+            SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
+            PCexit(FAIL);
+        }
+        
     }
 
-    exec sql close tab;
-
 	return;
 }
 
@@ -330,6 +444,10 @@
 get_attributes( VOID ) 
 {
 
+#ifdef DEBUG 
+	SIprintf("get_attributes\n");
+#endif		
+
 	exec sql begin declare section;
 		ESQL_SCM_ATTRIBUTE attribute;
 	exec sql end declare section;
@@ -341,8 +459,13 @@
 		
 	exec sql open atr for readonly;
 	
+	i4	i = 0;
+	
     for (;;)
     {
+    
+    	MEfill(sizeof(ESQL_SCM_ATTRIBUTE), 0, &attribute);
+    
         exec sql fetch atr into :attribute;
         if (sqlca.sqlcode == 100)
         {
@@ -354,19 +477,105 @@
             PCexit(FAIL);
         }
         
-        /* See if we need to wrap around */
-        if (scm->cur_atr_idx > MAXMONITOR)
+        scm->attributes[i++] = attribute;
+
+    }
+
+    exec sql close atr;
+
+	return;
+}
+
+/*{
+**
+**  Name: put_attributes() -   put attributes to workload db
+**
+**  Description:
+**	Put attribute data to the workload db 
+**
+**  Inputs:
+**		none
+**
+**  Outputs:
+**	Returns:
+**	    none
+**	Exceptions:
+**
+**  History:
+**      04-Jul-2008 (thial01)
+**          Created
+*/
+
+VOID
+put_attributes( VOID ) 
+{
+
+#ifdef DEBUG 
+	SIprintf("put_attributes\n");
+#endif		
+
+	i4		i;
+	exec sql begin declare section;
+		ESQL_SCM_ATTRIBUTE	attribute;
+		i4					time;
+	exec sql end declare section;
+
+    for (i = 0; i < MAXMONITOR; i++)
+    {
+    	/* 
+    	** We cannot check for attribute == null here
+    	** as it is already allocated.
+    	** So use the server member instead
+    	*/
+        if (scm->attributes[i].server[0] == '\0')
         {
-        	scm->cur_atr_idx = 0;
+        	return;
         }
         
-        scm->attributes[scm->cur_atr_idx] = attribute;
-        scm->cur_atr_idx++;
+        attribute = scm->attributes[i];
+        
+        time = 0;
+        
+        exec sql select time
+        		into :time
+        		from attributes
+        			where database = :db_name
+        				and table_id = :attribute.table_id
+        				and attribute_id = :attribute.attribute_id;
+        				
+        /* 
+        ** Let's see if we saw this before
+        ** and the timestamp is new so that
+        ** we need to update it or not
+        */
+        if (time > 0)
+        {
+        	if (attribute.time > time)
+        	{
+        		exec sql update attributes
+        			set 
+	        			frequency = :attribute.frequency,
+        				time = :attribute.time
+        			where database = :db_name
+        				and table_id = :attribute.table_id
+        				and attribute_id = :attribute.attribute_id;
 
+        	}
+        		        
+        } else
+        {
+        	exec sql insert into attributes
+        		values (:attribute);
+        }
+        	
+		if (sqlca.sqlcode != 0)
+        {
+            SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
+            PCexit(FAIL);
+        }
+        
     }
 
-    exec sql close atr;
-
 	return;
 }
 
@@ -394,6 +603,10 @@
 get_indexes( VOID ) 
 {
 
+#ifdef DEBUG 
+	SIprintf("get_indexes\n");
+#endif		
+
 	exec sql begin declare section;
 		ESQL_SCM_INDEX index;
 	exec sql end declare section;
@@ -405,8 +618,13 @@
 		
 	exec sql open idx for readonly;
 	
+	i4	i = 0;
+	
     for (;;)
     {
+    
+    	MEfill(sizeof(ESQL_SCM_INDEX), 0, &index);
+    
         exec sql fetch idx into :index;
         if (sqlca.sqlcode == 100)
         {
@@ -418,14 +636,7 @@
             PCexit(FAIL);
         }
         
-        /* See if we need to wrap around */
-        if (scm->cur_idx_idx > MAXMONITOR)
-        {
-        	scm->cur_idx_idx = 0;
-        }
-        
-        scm->indexes[scm->cur_idx_idx] = index;
-        scm->cur_idx_idx++;
+        scm->indexes[i++] = index;
 
     }
 
@@ -436,6 +647,100 @@
 
 /*{
 **
+**  Name: put_indexes() -   put indexes to workload db
+**
+**  Description:
+**	Put index data to the workload db 
+**
+**  Inputs:
+**		none
+**
+**  Outputs:
+**	Returns:
+**	    none
+**	Exceptions:
+**
+**  History:
+**      04-Jul-2008 (thial01)
+**          Created
+*/
+
+VOID
+put_indexes( VOID ) 
+{
+
+#ifdef DEBUG 
+	SIprintf("put_indexes\n");
+#endif		
+
+	i4		i;
+	exec sql begin declare section;
+		ESQL_SCM_INDEX		index;
+		i4					time;
+	exec sql end declare section;
+
+    for (i = 0; i < MAXMONITOR; i++)
+    {
+    	/* 
+    	** We cannot check for index == null here
+    	** as it is already allocated.
+    	** So use the server member instead
+    	*/
+        if (scm->indexes[i].server[0] == '\0')
+        {
+        	return;
+        }
+        
+        index = scm->indexes[i];
+        
+        time = 0;
+        
+        exec sql select time
+        		into :time
+        		from indexes
+        			where database = :db_name
+        				and index_id = :index.index_id;
+        				
+        /* 
+        ** Let's see if we saw this before
+        ** and the timestamp is new so that
+        ** we need to update it or not
+        */
+        if (time > 0)
+        {
+        	if (index.time > time)
+        	{
+        		exec sql update indexes
+        			set 
+	        			frequency = :index.frequency,
+	        			structure = :index.structure,
+	        			data_pages = :index.data_pages,
+	        			overflow_pages = :index.overflow_pages,
+        				time = :index.time
+        			where database = :db_name
+        				and index_id = :index.index_id;
+        				
+        	}
+        		        
+        } else
+        {
+        	exec sql insert into indexes
+        		values (:index);
+        }
+        	
+		if (sqlca.sqlcode != 0)
+        {
+            SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
+            PCexit(FAIL);
+        }
+        
+    }
+
+	return;
+}
+
+/*{
+**
 **  Name: get_references() -   read references from IMA
 **
 **  Description:
@@ -458,6 +763,10 @@
 get_references( VOID ) 
 {
 
+#ifdef DEBUG 
+	SIprintf("get_references\n");
+#endif
+
 	exec sql begin declare section;
 		ESQL_SCM_REFERENCE reference;
 	exec sql end declare section;
@@ -469,8 +778,13 @@
 		
 	exec sql open ref for readonly;
 	
+	i4	i = 0;
+	
     for (;;)
     {
+    	
+    	MEfill(sizeof(ESQL_SCM_REFERENCE), 0, &reference);
+    
         exec sql fetch ref into :reference;
         if (sqlca.sqlcode == 100)
         {
@@ -482,14 +796,7 @@
             PCexit(FAIL);
         }
         
-        /* See if we need to wrap around */
-        if (scm->cur_ref_idx > MAXMONITOR)
-        {
-        	scm->cur_ref_idx = 0;
-        }
-        
-        scm->references[scm->cur_ref_idx] = reference;
-        scm->cur_ref_idx++;
+        scm->references[i++] = reference;
 
     }
 
@@ -498,7 +805,85 @@
 	return;
 }
 
+/*{
+**
+**  Name: put_references() -   put references to workload db
+**
+**  Description:
+**	Put reference data to the workload db 
+**
+**  Inputs:
+**		none
+**
+**  Outputs:
+**	Returns:
+**	    none
+**	Exceptions:
+**
+**  History:
+**      04-Jul-2008 (thial01)
+**          Created
+*/
 
+VOID
+put_references( VOID ) 
+{
+
+#ifdef DEBUG 
+	SIprintf("put_references\n");
+#endif
+
+	i4		i;
+	exec sql begin declare section;
+		ESQL_SCM_REFERENCE	reference;
+		i4					rowcount;
+	exec sql end declare section;
+
+    for (i = 0; i < MAXMONITOR; i++)
+    {
+    	/* 
+    	** We cannot check for reference == null here
+    	** as it is already allocated.
+    	** So use the server member instead
+    	*/
+        if (scm->references[i].server[0] == '\0')
+        {
+        	return;
+        }
+        
+        reference = scm->references[i];
+        
+        rowcount = 0;
+        
+        exec sql select count(server)
+        		into :rowcount
+        		from references
+        			where database = :db_name
+        				and query_key = :reference.query_key
+        				and object_type = :reference.object_type
+        				and object_id = :reference.object_id
+        				and table_id = :reference.table_id;        				
+        				
+        /* 
+        ** Let's see if we saw this before
+        */
+        if (rowcount == 0)
+        {
+        	exec sql insert into references
+        		values (:reference);
+        }
+        	
+		if (sqlca.sqlcode != 0)
+        {
+            SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
+            PCexit(FAIL);
+        }
+        
+    }
+
+	return;
+}
+
 /*{
 **
 **  Name: main() -   main entry point to the tool.
@@ -547,7 +932,7 @@
     MEadvise(ME_INGRES_ALLOC); 
 
 	/* Process the command line to get all the necessary parameters */	
-/*    if (argc != 2)
+    if (argc != 2)
     {
     	SIprintf("Invalid number of parameters given\n");
     	SIprintf("Usage:\n");
@@ -555,8 +940,7 @@
     	PCexit(FAIL);
     }
   			
-	STncpy(db_name, argv[1], DB_MAXNAME);*/
-	STprintf(db_name, "test");
+	STncpy(db_name, argv[1], DB_MAXNAME);
     db_name[DB_MAXNAME-1] = '\0';
     
     /* Let's see if the database is valid */
@@ -569,49 +953,95 @@
 
 	exec sql disconnect;
 
+
+#ifndef	DEBUG
+
 	/* Let's fork as a daemon */
-/*	i4 pid;
+	i4 pid;
 	
 	switch (pid = PCfork(&status))
 	{
 		case -1:
-			status = errno;
 			SIprintf("Fork failed\n");
 			PCexit(FAIL);
 		case 0:
 			break;
 		default:
+			SIprintf("Forking to background - PID: %d\n", pid);
 			PCexit(OK);
 	}
-	*/
 	
+#endif
+	
 	/* Create the data container */
 	scm = (ESQL_SCM*)MEreqmem(0, sizeof(ESQL_SCM),TRUE,&status);
-
-	//PCsleep(1000);
 	
 	exec sql whenever sqlerror stop;		
+
 	exec sql connect imadb session 1;	/* Session 1 is for IMADB */
-	exec sql set_sql(session = 1);
 	exec sql set autocommit on;
-	
-	/* 
-	** Get the data from IMA.
-	** Should have been one function but 
-	** the esql preprocessor is a bit tricky
-	*/
-	get_statements();
-	get_tables();
-	get_attributes();
-	get_indexes();
-	get_references();
-	
+
 	exec sql connect workloaddb session 2;	/* Session 2 for the workload db */
 	exec sql set autocommit on;
+
 	
-	put_statements();
+	exec sql set_sql(session = 1);
 	
+	i4	round = 0;
 	
+	/* Main loop */
+	while(1)
+	{
+
+#ifdef DEBUG 
+		SIprintf("Round %d\n", round);
+#endif		
+				
+		/* 
+		** Get the data from IMA.
+		** Should have been one function but 
+		** the esql preprocessor is a bit tricky
+		*/
+		get_statements();
+		get_tables();
+		get_attributes();
+		get_indexes();
+		get_references();
+	
+	
+		if (++round > ROUNDS)
+		{
+#ifdef DEBUG 
+			SIprintf("Store in WLDB\n");
+#endif
+			
+			round = 0;
+			
+			/* Store the data in the workload db
+			
+			/* Switch to the other session */
+			exec sql set_sql(session = 2);
+			
+			put_statements();
+			put_tables();
+			put_attributes();
+			put_indexes();
+			put_references();
+			
+			/* Switch back to IMADB session */
+			exec sql set_sql(session = 1);
+			
+		}
+		
+		PCsleep(SLEEP);
+		
+		/* 
+		** FIXME
+		** We never exit.
+		** Add signal handler to react on SIGTERM
+		*/
+	}	
+	
     PCexit(OK);
 }
 




More information about the svn-commits mailing list