make the interaction of the stats event stuff with the
authorNathan Binkert <binkertn@umich.edu>
Sun, 23 May 2004 16:53:34 +0000 (12:53 -0400)
committerNathan Binkert <binkertn@umich.edu>
Sun, 23 May 2004 16:53:34 +0000 (12:53 -0400)
database work better.

base/stats/events.cc:
    properly connect to the database
base/stats/mysql.cc:
    cleanup the event stuff too

--HG--
extra : convert_revision : f05fd6456decc9c4f95beff5c12497439e45f886

base/stats/events.cc
base/stats/mysql.cc

index 3a858611f4fdca7982e1293ed8732e2b7f748d61..b579981e911b774fc18cd8b9a283d1a659569915 100644 (file)
@@ -66,11 +66,12 @@ __event(const string &stat)
                      stat));
 
         MySQL::Result result = mysql.store_result();
-        if (result) {
-            assert(result.num_fields() == 1);
-            MySQL::Row row = result.fetch_row();
-            if (!row)
-                panic("could not get a run\n%s\n", mysql.error);
+        if (!result)
+            panic("could not get a run\n%s\n", mysql.error);
+
+        assert(result.num_fields() == 1);
+        MySQL::Row row = result.fetch_row();
+        if (row) {
             if (!to_number(row[0], event))
                 panic("invalid event id: %s\n", row[0]);
         } else {
@@ -85,7 +86,6 @@ __event(const string &stat)
 
             event = mysql.insert_id();
         }
-
     } else {
         event = (*i).second;
     }
index 05808c211a1b5d262fecf18f8247fc096203539d..77366beb08579aa72104d7052ad43144525eb7e7 100644 (file)
@@ -134,6 +134,16 @@ MySqlRun::cleanup()
                 "FROM bins "
                 "LEFT JOIN data ON bn_id=dt_bin "
                 "WHERE dt_bin IS NULL");
+
+    mysql.query("DELETE events"
+                "FROM events"
+                "LEFT JOIN runs ON ev_run=rn_id"
+                "WHERE rn_id IS NULL");
+
+    mysql.query("DELETE event_names"
+                "FROM event_names"
+                "LEFT JOIN events ON en_id=ev_event"
+                "WHERE ev_event IS NULL");
 }
 
 void